| author | |
| committer | |
| log | bd680139d084b673d1f56d0e63e01936c4680a91 |
| tree | f066c89b83db70814a23e5be9731686610fea92c |
| parent | c89dd15e1be4959800dc7092d7dd4375253db7bc |
585 files changed, 40096 insertions(+), 19622 deletions(-)
lib/libcxx/include/__algorithm/adjacent_find.h+1-6| ... | ... | @@ -10,17 +10,14 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _ForwardIterator, class _BinaryPredicate> |
| ... | ... | @@ -46,6 +43,4 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { |
| 46 | 43 | |
| 47 | 44 | _LIBCPP_END_NAMESPACE_STD |
| 48 | 45 | |
| 49 | _LIBCPP_POP_MACROS | |
| 50 | ||
| 51 | 46 | #endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H |
lib/libcxx/include/__algorithm/all_of.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -32,6 +29,4 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_ALL_OF_H |
lib/libcxx/include/__algorithm/any_of.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -32,6 +29,4 @@ any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_ANY_OF_H |
lib/libcxx/include/__algorithm/binary_search.h+2-8| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_BINARY_SEARCH_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_BINARY_SEARCH_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/lower_bound.h> | |
| 15 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/lower_bound.h> | |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _ForwardIterator, class _Tp> |
| ... | ... | @@ -53,9 +50,6 @@ binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va |
| 53 | 50 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); |
| 54 | 51 | } |
| 55 | 52 | |
| 56 | ||
| 57 | 53 | _LIBCPP_END_NAMESPACE_STD |
| 58 | 54 | |
| 59 | _LIBCPP_POP_MACROS | |
| 60 | ||
| 61 | 55 | #endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H |
lib/libcxx/include/__algorithm/clamp.h+1-7| ... | ... | @@ -9,21 +9,17 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_CLAMP_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_CLAMP_H |
| 11 | 11 | |
| 12 | #include <__algorithm/comp.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__debug> |
| 14 | #include <__algorithm/comp.h> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | #if _LIBCPP_STD_VER > 14 |
| 26 | // clamp | |
| 27 | 23 | template<class _Tp, class _Compare> |
| 28 | 24 | _LIBCPP_NODISCARD_EXT inline |
| 29 | 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| ... | ... | @@ -47,6 +43,4 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) |
| 47 | 43 | |
| 48 | 44 | _LIBCPP_END_NAMESPACE_STD |
| 49 | 45 | |
| 50 | _LIBCPP_POP_MACROS | |
| 51 | ||
| 52 | 46 | #endif // _LIBCPP___ALGORITHM_CLAMP_H |
lib/libcxx/include/__algorithm/comp.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | // I'd like to replace these with _VSTD::equal_to<void>, but can't because: |
| ... | ... | @@ -92,6 +89,4 @@ struct __less<_T1, const _T1> |
| 92 | 89 | |
| 93 | 90 | _LIBCPP_END_NAMESPACE_STD |
| 94 | 91 | |
| 95 | _LIBCPP_POP_MACROS | |
| 96 | ||
| 97 | 92 | #endif // _LIBCPP___ALGORITHM_COMP_H |
lib/libcxx/include/__algorithm/comp_ref_type.h+11-13| ... | ... | @@ -10,15 +10,16 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <type_traits> | |
| 13 | ||
| 14 | #ifdef _LIBCPP_DEBUG | |
| 15 | # include <__debug> | |
| 16 | # include <__utility/declval.h> | |
| 17 | #endif | |
| 14 | 18 | |
| 15 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | 20 | #pragma GCC system_header |
| 17 | 21 | #endif |
| 18 | 22 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | |
| 24 | 25 | #ifdef _LIBCPP_DEBUG |
| ... | ... | @@ -27,11 +28,11 @@ template <class _Compare> |
| 27 | 28 | struct __debug_less |
| 28 | 29 | { |
| 29 | 30 | _Compare &__comp_; |
| 30 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 31 | _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 31 | 32 | __debug_less(_Compare& __c) : __comp_(__c) {} |
| 32 | 33 | |
| 33 | 34 | template <class _Tp, class _Up> |
| 34 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 35 | _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 35 | 36 | bool operator()(const _Tp& __x, const _Up& __y) |
| 36 | 37 | { |
| 37 | 38 | bool __r = __comp_(__x, __y); |
| ... | ... | @@ -41,7 +42,7 @@ struct __debug_less |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | template <class _Tp, class _Up> |
| 44 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 45 | _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 45 | 46 | bool operator()(_Tp& __x, _Up& __y) |
| 46 | 47 | { |
| 47 | 48 | bool __r = __comp_(__x, __y); |
| ... | ... | @@ -51,7 +52,7 @@ struct __debug_less |
| 51 | 52 | } |
| 52 | 53 | |
| 53 | 54 | template <class _LHS, class _RHS> |
| 54 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 55 | _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 55 | 56 | inline _LIBCPP_INLINE_VISIBILITY |
| 56 | 57 | decltype((void)declval<_Compare&>()( |
| 57 | 58 | declval<_LHS &>(), declval<_RHS &>())) |
| ... | ... | @@ -61,7 +62,7 @@ struct __debug_less |
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | template <class _LHS, class _RHS> |
| 64 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 65 | _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 65 | 66 | inline _LIBCPP_INLINE_VISIBILITY |
| 66 | 67 | void __do_compare_assert(long, _LHS &, _RHS &) {} |
| 67 | 68 | }; |
| ... | ... | @@ -73,15 +74,12 @@ struct __comp_ref_type { |
| 73 | 74 | // Pass the comparator by lvalue reference. Or in debug mode, using a |
| 74 | 75 | // debugging wrapper that stores a reference. |
| 75 | 76 | #ifndef _LIBCPP_DEBUG |
| 76 | typedef typename add_lvalue_reference<_Comp>::type type; | |
| 77 | typedef _Comp& type; | |
| 77 | 78 | #else |
| 78 | 79 | typedef __debug_less<_Comp> type; |
| 79 | 80 | #endif |
| 80 | 81 | }; |
| 81 | 82 | |
| 82 | ||
| 83 | 83 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 84 | |
| 85 | _LIBCPP_POP_MACROS | |
| 86 | ||
| 87 | 85 | #endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H |
lib/libcxx/include/__algorithm/copy.h+1-6| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_COPY_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <cstring> |
| 16 | 16 | #include <type_traits> |
| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | // copy |
| ... | ... | @@ -77,6 +74,4 @@ copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) |
| 77 | 74 | |
| 78 | 75 | _LIBCPP_END_NAMESPACE_STD |
| 79 | 76 | |
| 80 | _LIBCPP_POP_MACROS | |
| 81 | ||
| 82 | 77 | #endif // _LIBCPP___ALGORITHM_COPY_H |
lib/libcxx/include/__algorithm/copy_backward.h+1-6| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <cstring> |
| 16 | 16 | #include <type_traits> |
| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _BidirectionalIterator, class _OutputIterator> |
| ... | ... | @@ -79,6 +76,4 @@ copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, |
| 79 | 76 | |
| 80 | 77 | _LIBCPP_END_NAMESPACE_STD |
| 81 | 78 | |
| 82 | _LIBCPP_POP_MACROS | |
| 83 | ||
| 84 | 79 | #endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
lib/libcxx/include/__algorithm/copy_if.h-9| ... | ... | @@ -10,18 +10,11 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_IF_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__algorithm/unwrap_iter.h> | |
| 14 | #include <__iterator/iterator_traits.h> | |
| 15 | #include <cstring> | |
| 16 | #include <type_traits> | |
| 17 | 13 | |
| 18 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 15 | #pragma GCC system_header |
| 20 | 16 | #endif |
| 21 | 17 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 19 | |
| 27 | 20 | template<class _InputIterator, class _OutputIterator, class _Predicate> |
| ... | ... | @@ -43,6 +36,4 @@ copy_if(_InputIterator __first, _InputIterator __last, |
| 43 | 36 | |
| 44 | 37 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 38 | |
| 46 | _LIBCPP_POP_MACROS | |
| 47 | ||
| 48 | 39 | #endif // _LIBCPP___ALGORITHM_COPY_IF_H |
lib/libcxx/include/__algorithm/copy_n.h+3-9| ... | ... | @@ -9,20 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_COPY_N_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_N_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/copy.h> |
| 14 | #include <__algorithm/unwrap_iter.h> | |
| 13 | #include <__config> | |
| 15 | 14 | #include <__iterator/iterator_traits.h> |
| 16 | #include <cstring> | |
| 17 | 15 | #include <type_traits> |
| 18 | 16 | |
| 19 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 18 | #pragma GCC system_header |
| 21 | 19 | #endif |
| 22 | 20 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 22 | |
| 28 | 23 | template<class _InputIterator, class _Size, class _OutputIterator> |
| ... | ... | @@ -60,13 +55,12 @@ typename enable_if |
| 60 | 55 | >::type |
| 61 | 56 | copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) |
| 62 | 57 | { |
| 58 | typedef typename iterator_traits<_InputIterator>::difference_type difference_type; | |
| 63 | 59 | typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; |
| 64 | 60 | _IntegralSize __n = __orig_n; |
| 65 | return _VSTD::copy(__first, __first + __n, __result); | |
| 61 | return _VSTD::copy(__first, __first + difference_type(__n), __result); | |
| 66 | 62 | } |
| 67 | 63 | |
| 68 | 64 | _LIBCPP_END_NAMESPACE_STD |
| 69 | 65 | |
| 70 | _LIBCPP_POP_MACROS | |
| 71 | ||
| 72 | 66 | #endif // _LIBCPP___ALGORITHM_COPY_N_H |
lib/libcxx/include/__algorithm/count.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _InputIterator, class _Tp> |
| ... | ... | @@ -35,6 +32,4 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_C |
| 35 | 32 | |
| 36 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 34 | |
| 38 | _LIBCPP_POP_MACROS | |
| 39 | ||
| 40 | 35 | #endif // _LIBCPP___ALGORITHM_COUNT_H |
lib/libcxx/include/__algorithm/count_if.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -35,6 +32,4 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_C |
| 35 | 32 | |
| 36 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 34 | |
| 38 | _LIBCPP_POP_MACROS | |
| 39 | ||
| 40 | 35 | #endif // _LIBCPP___ALGORITHM_COUNT_IF_H |
lib/libcxx/include/__algorithm/equal.h+4-9| ... | ... | @@ -10,18 +10,15 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_EQUAL_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_EQUAL_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__config> | |
| 15 | #include <__iterator/distance.h> | |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | #include <iterator> // FIXME: replace with <__iterator/distance.h> when it lands | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| ... | ... | @@ -60,14 +57,14 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Random |
| 60 | 57 | if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) |
| 61 | 58 | return false; |
| 62 | 59 | return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2, |
| 63 | typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, __pred); | |
| 60 | _BinaryPredicate&>(__first1, __last1, __first2, __pred); | |
| 64 | 61 | } |
| 65 | 62 | |
| 66 | 63 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| 67 | 64 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 68 | 65 | equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, |
| 69 | 66 | _BinaryPredicate __pred) { |
| 70 | return _VSTD::__equal<typename add_lvalue_reference<_BinaryPredicate>::type>( | |
| 67 | return _VSTD::__equal<_BinaryPredicate&>( | |
| 71 | 68 | __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(), |
| 72 | 69 | typename iterator_traits<_InputIterator2>::iterator_category()); |
| 73 | 70 | } |
| ... | ... | @@ -85,6 +82,4 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first |
| 85 | 82 | |
| 86 | 83 | _LIBCPP_END_NAMESPACE_STD |
| 87 | 84 | |
| 88 | _LIBCPP_POP_MACROS | |
| 89 | ||
| 90 | 85 | #endif // _LIBCPP___ALGORITHM_EQUAL_H |
lib/libcxx/include/__algorithm/equal_range.h+1-6| ... | ... | @@ -9,21 +9,18 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_EQUAL_RANGE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_EQUAL_RANGE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/half_positive.h> |
| 16 | 15 | #include <__algorithm/lower_bound.h> |
| 17 | 16 | #include <__algorithm/upper_bound.h> |
| 17 | #include <__config> | |
| 18 | 18 | #include <iterator> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | 21 | #pragma GCC system_header |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 25 | |
| 29 | 26 | template <class _Compare, class _ForwardIterator, class _Tp> |
| ... | ... | @@ -82,6 +79,4 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 82 | 79 | |
| 83 | 80 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 81 | |
| 85 | _LIBCPP_POP_MACROS | |
| 86 | ||
| 87 | 82 | #endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H |
lib/libcxx/include/__algorithm/fill.h+1-6| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_FILL_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_FILL_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/fill_n.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _ForwardIterator, class _Tp> |
| ... | ... | @@ -50,6 +47,4 @@ fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) |
| 50 | 47 | |
| 51 | 48 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 49 | |
| 53 | _LIBCPP_POP_MACROS | |
| 54 | ||
| 55 | 50 | #endif // _LIBCPP___ALGORITHM_FILL_H |
lib/libcxx/include/__algorithm/fill_n.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _OutputIterator, class _Size, class _Tp> |
| ... | ... | @@ -42,6 +39,4 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) |
| 42 | 39 | |
| 43 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 44 | 41 | |
| 45 | _LIBCPP_POP_MACROS | |
| 46 | ||
| 47 | 42 | #endif // _LIBCPP___ALGORITHM_FILL_N_H |
lib/libcxx/include/__algorithm/find.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Tp> |
| ... | ... | @@ -32,6 +29,4 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_FIND_H |
lib/libcxx/include/__algorithm/find_end.h+7-11| ... | ... | @@ -10,18 +10,14 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_FIND_END_OF_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_FIND_END_OF_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <type_traits> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | #pragma GCC system_header |
| 20 | 19 | #endif |
| 21 | 20 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 22 | |
| 27 | 23 | template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2> |
| ... | ... | @@ -99,14 +95,16 @@ template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAcc |
| 99 | 95 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end( |
| 100 | 96 | _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, |
| 101 | 97 | _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) { |
| 98 | typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1; | |
| 99 | typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2; | |
| 102 | 100 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern |
| 103 | typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2; | |
| 101 | _D2 __len2 = __last2 - __first2; | |
| 104 | 102 | if (__len2 == 0) |
| 105 | 103 | return __last1; |
| 106 | typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1; | |
| 104 | _D1 __len1 = __last1 - __first1; | |
| 107 | 105 | if (__len1 < __len2) |
| 108 | 106 | return __last1; |
| 109 | const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here | |
| 107 | const _RandomAccessIterator1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here | |
| 110 | 108 | _RandomAccessIterator1 __l1 = __last1; |
| 111 | 109 | _RandomAccessIterator2 __l2 = __last2; |
| 112 | 110 | --__l2; |
| ... | ... | @@ -134,7 +132,7 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica |
| 134 | 132 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 |
| 135 | 133 | find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, |
| 136 | 134 | _BinaryPredicate __pred) { |
| 137 | return _VSTD::__find_end<typename add_lvalue_reference<_BinaryPredicate>::type>( | |
| 135 | return _VSTD::__find_end<_BinaryPredicate&>( | |
| 138 | 136 | __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), |
| 139 | 137 | typename iterator_traits<_ForwardIterator2>::iterator_category()); |
| 140 | 138 | } |
| ... | ... | @@ -149,6 +147,4 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator |
| 149 | 147 | |
| 150 | 148 | _LIBCPP_END_NAMESPACE_STD |
| 151 | 149 | |
| 152 | _LIBCPP_POP_MACROS | |
| 153 | ||
| 154 | 150 | #endif // _LIBCPP___ALGORITHM_FIND_END_OF_H |
lib/libcxx/include/__algorithm/find_first_of.h+1-6| ... | ... | @@ -10,17 +10,14 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_FIND_FIRST_OF_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| ... | ... | @@ -52,6 +49,4 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_C |
| 52 | 49 | |
| 53 | 50 | _LIBCPP_END_NAMESPACE_STD |
| 54 | 51 | |
| 55 | _LIBCPP_POP_MACROS | |
| 56 | ||
| 57 | 52 | #endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H |
lib/libcxx/include/__algorithm/find_if.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -32,6 +29,4 @@ find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_FIND_IF_H |
lib/libcxx/include/__algorithm/find_if_not.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -32,6 +29,4 @@ find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H |
lib/libcxx/include/__algorithm/for_each.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Function> |
| ... | ... | @@ -32,6 +29,4 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_eac |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_H |
lib/libcxx/include/__algorithm/for_each_n.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -42,6 +39,4 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator fo |
| 42 | 39 | |
| 43 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 44 | 41 | |
| 45 | _LIBCPP_POP_MACROS | |
| 46 | ||
| 47 | 42 | #endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H |
lib/libcxx/include/__algorithm/generate.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _ForwardIterator, class _Generator> |
| ... | ... | @@ -31,6 +28,4 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) |
| 31 | 28 | |
| 32 | 29 | _LIBCPP_END_NAMESPACE_STD |
| 33 | 30 | |
| 34 | _LIBCPP_POP_MACROS | |
| 35 | ||
| 36 | 31 | #endif // _LIBCPP___ALGORITHM_GENERATE_H |
lib/libcxx/include/__algorithm/generate_n.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _OutputIterator, class _Size, class _Generator> |
| ... | ... | @@ -35,6 +32,4 @@ generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) |
| 35 | 32 | |
| 36 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 34 | |
| 38 | _LIBCPP_POP_MACROS | |
| 39 | ||
| 40 | 35 | #endif // _LIBCPP___ALGORITHM_GENERATE_N_H |
lib/libcxx/include/__algorithm/half_positive.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | // Perform division by two quickly for positive integers (llvm.org/PR39129) |
| ... | ... | @@ -49,6 +46,4 @@ __half_positive(_Tp __value) |
| 49 | 46 | |
| 50 | 47 | _LIBCPP_END_NAMESPACE_STD |
| 51 | 48 | |
| 52 | _LIBCPP_POP_MACROS | |
| 53 | ||
| 54 | 49 | #endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H |
lib/libcxx/include/__algorithm/in_in_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_IN_OUT_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_IN_IN_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 !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | ||
| 27 | template <class _I1, class _I2, class _O1> | |
| 28 | struct in_in_out_result { | |
| 29 | [[no_unique_address]] _I1 in1; | |
| 30 | [[no_unique_address]] _I2 in2; | |
| 31 | [[no_unique_address]] _O1 out; | |
| 32 | ||
| 33 | template <class _II1, class _II2, class _OO1> | |
| 34 | requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> && convertible_to<const _O1&, _OO1> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 36 | operator in_in_out_result<_II1, _II2, _OO1>() const& { | |
| 37 | return {in1, in2, out}; | |
| 38 | } | |
| 39 | ||
| 40 | template <class _II1, class _II2, class _OO1> | |
| 41 | requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1> | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 43 | operator in_in_out_result<_II1, _II2, _OO1>() && { | |
| 44 | return {_VSTD::move(in1), _VSTD::move(in2), _VSTD::move(out)}; | |
| 45 | } | |
| 46 | }; | |
| 47 | ||
| 48 | } // namespace ranges | |
| 49 | ||
| 50 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | #endif // _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H |
lib/libcxx/include/__algorithm/in_in_result.h created+51| ... | ... | @@ -0,0 +1,51 @@ |
| 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_IN_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_IN_IN_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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | ||
| 27 | template <class _I1, class _I2> | |
| 28 | struct in_in_result { | |
| 29 | [[no_unique_address]] _I1 in1; | |
| 30 | [[no_unique_address]] _I2 in2; | |
| 31 | ||
| 32 | template <class _II1, class _II2> | |
| 33 | requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 35 | operator in_in_result<_II1, _II2>() const & { | |
| 36 | return {in1, in2}; | |
| 37 | } | |
| 38 | ||
| 39 | template <class _II1, class _II2> | |
| 40 | requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 42 | operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; } | |
| 43 | }; | |
| 44 | ||
| 45 | } // namespace ranges | |
| 46 | ||
| 47 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 48 | ||
| 49 | _LIBCPP_END_NAMESPACE_STD | |
| 50 | ||
| 51 | #endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H |
lib/libcxx/include/__algorithm/in_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_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_IN_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 !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | ||
| 27 | template<class _InputIterator, class _OutputIterator> | |
| 28 | struct in_out_result { | |
| 29 | [[no_unique_address]] _InputIterator in; | |
| 30 | [[no_unique_address]] _OutputIterator out; | |
| 31 | ||
| 32 | template <class _InputIterator2, class _OutputIterator2> | |
| 33 | requires convertible_to<const _InputIterator&, _InputIterator2> && convertible_to<const _OutputIterator&, | |
| 34 | _OutputIterator2> | |
| 35 | _LIBCPP_HIDE_FROM_ABI | |
| 36 | constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & { | |
| 37 | return {in, out}; | |
| 38 | } | |
| 39 | ||
| 40 | template <class _InputIterator2, class _OutputIterator2> | |
| 41 | requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2> | |
| 42 | _LIBCPP_HIDE_FROM_ABI | |
| 43 | constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && { | |
| 44 | return {_VSTD::move(in), _VSTD::move(out)}; | |
| 45 | } | |
| 46 | }; | |
| 47 | ||
| 48 | } // namespace ranges | |
| 49 | ||
| 50 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | #endif // _LIBCPP___ALGORITHM_IN_OUT_RESULT_H |
lib/libcxx/include/__algorithm/includes.h+1-6| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_INCLUDES_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_INCLUDES_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _Compare, class _InputIterator1, class _InputIterator2> |
| ... | ... | @@ -62,6 +59,4 @@ includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi |
| 62 | 59 | |
| 63 | 60 | _LIBCPP_END_NAMESPACE_STD |
| 64 | 61 | |
| 65 | _LIBCPP_POP_MACROS | |
| 66 | ||
| 67 | 62 | #endif // _LIBCPP___ALGORITHM_INCLUDES_H |
lib/libcxx/include/__algorithm/inplace_merge.h+2-2| ... | ... | @@ -9,14 +9,14 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 15 | 14 | #include <__algorithm/lower_bound.h> |
| 16 | 15 | #include <__algorithm/min.h> |
| 17 | 16 | #include <__algorithm/move.h> |
| 18 | 17 | #include <__algorithm/rotate.h> |
| 19 | 18 | #include <__algorithm/upper_bound.h> |
| 19 | #include <__config> | |
| 20 | 20 | #include <__iterator/iterator_traits.h> |
| 21 | 21 | #include <__utility/swap.h> |
| 22 | 22 | #include <memory> |
lib/libcxx/include/__algorithm/is_heap.h+4-7| ... | ... | @@ -9,18 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_IS_HEAP_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_IS_HEAP_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | 14 | #include <__algorithm/is_heap_until.h> |
| 15 | #include <__config> | |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 19 | #pragma GCC system_header |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 23 | |
| 26 | 24 | template <class _RandomAccessIterator, class _Compare> |
| ... | ... | @@ -29,7 +27,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 29 | 27 | bool |
| 30 | 28 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) |
| 31 | 29 | { |
| 32 | return _VSTD::is_heap_until(__first, __last, __comp) == __last; | |
| 30 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 31 | return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last; | |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | 34 | template<class _RandomAccessIterator> |
| ... | ... | @@ -43,6 +42,4 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 43 | 42 | |
| 44 | 43 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 44 | |
| 46 | _LIBCPP_POP_MACROS | |
| 47 | ||
| 48 | 45 | #endif // _LIBCPP___ALGORITHM_IS_HEAP_H |
lib/libcxx/include/__algorithm/is_heap_until.h+15-13| ... | ... | @@ -9,22 +9,20 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | #include <__config> | |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | template <class _RandomAccessIterator, class _Compare> | |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator | |
| 27 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 23 | template <class _Compare, class _RandomAccessIterator> | |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator | |
| 25 | __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 28 | 26 | { |
| 29 | 27 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 30 | 28 | difference_type __len = __last - __first; |
| ... | ... | @@ -49,17 +47,21 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp |
| 49 | 47 | return __last; |
| 50 | 48 | } |
| 51 | 49 | |
| 50 | template <class _RandomAccessIterator, class _Compare> | |
| 51 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator | |
| 52 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 53 | { | |
| 54 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 55 | return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp); | |
| 56 | } | |
| 57 | ||
| 52 | 58 | template<class _RandomAccessIterator> |
| 53 | _LIBCPP_NODISCARD_EXT inline | |
| 54 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 55 | _RandomAccessIterator | |
| 59 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator | |
| 56 | 60 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 57 | 61 | { |
| 58 | return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 62 | return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 59 | 63 | } |
| 60 | 64 | |
| 61 | 65 | _LIBCPP_END_NAMESPACE_STD |
| 62 | 66 | |
| 63 | _LIBCPP_POP_MACROS | |
| 64 | ||
| 65 | 67 | #endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H |
lib/libcxx/include/__algorithm/is_partitioned.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -38,6 +35,4 @@ is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) |
| 38 | 35 | |
| 39 | 36 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 37 | |
| 41 | _LIBCPP_POP_MACROS | |
| 42 | ||
| 43 | 38 | #endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H |
lib/libcxx/include/__algorithm/is_permutation.h+3-9| ... | ... | @@ -12,17 +12,14 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__iterator/distance.h> | |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__iterator/next.h> |
| 17 | #include <iterator> // FIXME: replace with <__iterator/distance.h> when it lands | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| ... | ... | @@ -136,15 +133,14 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __fir |
| 136 | 133 | if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) |
| 137 | 134 | return false; |
| 138 | 135 | return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2, |
| 139 | typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, | |
| 140 | __pred); | |
| 136 | _BinaryPredicate&>(__first1, __last1, __first2, __pred); | |
| 141 | 137 | } |
| 142 | 138 | |
| 143 | 139 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 144 | 140 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool |
| 145 | 141 | is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, |
| 146 | 142 | _ForwardIterator2 __last2, _BinaryPredicate __pred) { |
| 147 | return _VSTD::__is_permutation<typename add_lvalue_reference<_BinaryPredicate>::type>( | |
| 143 | return _VSTD::__is_permutation<_BinaryPredicate&>( | |
| 148 | 144 | __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), |
| 149 | 145 | typename iterator_traits<_ForwardIterator2>::iterator_category()); |
| 150 | 146 | } |
| ... | ... | @@ -163,6 +159,4 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt |
| 163 | 159 | |
| 164 | 160 | _LIBCPP_END_NAMESPACE_STD |
| 165 | 161 | |
| 166 | _LIBCPP_POP_MACROS | |
| 167 | ||
| 168 | 162 | #endif // _LIBCPP___ALGORITHM_IS_PERMUTATION_H |
lib/libcxx/include/__algorithm/is_sorted.h+3-6| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_IS_SORTED_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 13 | 14 | #include <__algorithm/is_sorted_until.h> |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| ... | ... | @@ -18,9 +19,6 @@ |
| 18 | 19 | #pragma GCC system_header |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 23 | |
| 26 | 24 | template <class _ForwardIterator, class _Compare> |
| ... | ... | @@ -29,7 +27,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 29 | 27 | bool |
| 30 | 28 | is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) |
| 31 | 29 | { |
| 32 | return _VSTD::is_sorted_until(__first, __last, __comp) == __last; | |
| 30 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 31 | return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp) == __last; | |
| 33 | 32 | } |
| 34 | 33 | |
| 35 | 34 | template<class _ForwardIterator> |
| ... | ... | @@ -43,6 +42,4 @@ is_sorted(_ForwardIterator __first, _ForwardIterator __last) |
| 43 | 42 | |
| 44 | 43 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 44 | |
| 46 | _LIBCPP_POP_MACROS | |
| 47 | ||
| 48 | 45 | #endif // _LIBCPP___ALGORITHM_IS_SORTED_H |
lib/libcxx/include/__algorithm/is_sorted_until.h+14-12| ... | ... | @@ -9,22 +9,20 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | #include <__config> | |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | template <class _ForwardIterator, class _Compare> | |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 27 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 23 | template <class _Compare, class _ForwardIterator> | |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 25 | __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 28 | 26 | { |
| 29 | 27 | if (__first != __last) |
| 30 | 28 | { |
| ... | ... | @@ -39,10 +37,16 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __co |
| 39 | 37 | return __last; |
| 40 | 38 | } |
| 41 | 39 | |
| 40 | template <class _ForwardIterator, class _Compare> | |
| 41 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 42 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 43 | { | |
| 44 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 45 | return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp); | |
| 46 | } | |
| 47 | ||
| 42 | 48 | template<class _ForwardIterator> |
| 43 | _LIBCPP_NODISCARD_EXT inline | |
| 44 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 45 | _ForwardIterator | |
| 49 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 46 | 50 | is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) |
| 47 | 51 | { |
| 48 | 52 | return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>()); |
| ... | ... | @@ -50,6 +54,4 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) |
| 50 | 54 | |
| 51 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 56 | |
| 53 | _LIBCPP_POP_MACROS | |
| 54 | ||
| 55 | 57 | #endif // _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H |
lib/libcxx/include/__algorithm/iter_swap.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _ForwardIterator1, class _ForwardIterator2> |
| ... | ... | @@ -32,6 +29,4 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_F |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_ITER_SWAP_H |
lib/libcxx/include/__algorithm/lexicographical_compare.h+1-6| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _Compare, class _InputIterator1, class _InputIterator2> |
| ... | ... | @@ -63,6 +60,4 @@ lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, |
| 63 | 60 | |
| 64 | 61 | _LIBCPP_END_NAMESPACE_STD |
| 65 | 62 | |
| 66 | _LIBCPP_POP_MACROS | |
| 67 | ||
| 68 | 63 | #endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H |
lib/libcxx/include/__algorithm/lower_bound.h+2-8| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_LOWER_BOUND_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_LOWER_BOUND_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/half_positive.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <iterator> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _Compare, class _ForwardIterator, class _Tp> |
| ... | ... | @@ -51,8 +48,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 51 | 48 | _ForwardIterator |
| 52 | 49 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) |
| 53 | 50 | { |
| 54 | typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; | |
| 55 | return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp); | |
| 51 | return _VSTD::__lower_bound<_Compare&>(__first, __last, __value_, __comp); | |
| 56 | 52 | } |
| 57 | 53 | |
| 58 | 54 | template <class _ForwardIterator, class _Tp> |
| ... | ... | @@ -67,6 +63,4 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 67 | 63 | |
| 68 | 64 | _LIBCPP_END_NAMESPACE_STD |
| 69 | 65 | |
| 70 | _LIBCPP_POP_MACROS | |
| 71 | ||
| 72 | 66 | #endif // _LIBCPP___ALGORITHM_LOWER_BOUND_H |
lib/libcxx/include/__algorithm/make_heap.h+2-7| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MAKE_HEAP_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MAKE_HEAP_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/sift_down.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _RandomAccessIterator> |
| ... | ... | @@ -35,7 +32,7 @@ __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar |
| 35 | 32 | // start from the first parent, there is no need to consider children |
| 36 | 33 | for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) |
| 37 | 34 | { |
| 38 | _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start); | |
| 35 | _VSTD::__sift_down<_Compare>(__first, __comp, __n, __first + __start); | |
| 39 | 36 | } |
| 40 | 37 | } |
| 41 | 38 | } |
| ... | ... | @@ -59,6 +56,4 @@ make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 59 | 56 | |
| 60 | 57 | _LIBCPP_END_NAMESPACE_STD |
| 61 | 58 | |
| 62 | _LIBCPP_POP_MACROS | |
| 63 | ||
| 64 | 59 | #endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H |
lib/libcxx/include/__algorithm/max.h+4-2| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MAX_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MAX_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | 14 | #include <__algorithm/max_element.h> |
| 15 | #include <__config> | |
| 15 | 16 | #include <initializer_list> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -49,7 +50,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 49 | 50 | _Tp |
| 50 | 51 | max(initializer_list<_Tp> __t, _Compare __comp) |
| 51 | 52 | { |
| 52 | return *_VSTD::max_element(__t.begin(), __t.end(), __comp); | |
| 53 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 54 | return *_VSTD::__max_element<_Comp_ref>(__t.begin(), __t.end(), __comp); | |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | 57 | template<class _Tp> |
lib/libcxx/include/__algorithm/max_element.h+14-14| ... | ... | @@ -9,24 +9,20 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MAX_ELEMENT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MAX_ELEMENT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | #include <__config> | |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | template <class _ForwardIterator, class _Compare> | |
| 26 | _LIBCPP_NODISCARD_EXT inline | |
| 27 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 28 | _ForwardIterator | |
| 29 | max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 23 | template <class _Compare, class _ForwardIterator> | |
| 24 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | |
| 25 | __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 30 | 26 | { |
| 31 | 27 | static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 32 | 28 | "std::max_element requires a ForwardIterator"); |
| ... | ... | @@ -40,11 +36,17 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) |
| 40 | 36 | return __first; |
| 41 | 37 | } |
| 42 | 38 | |
| 39 | template <class _ForwardIterator, class _Compare> | |
| 40 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | |
| 41 | max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 42 | { | |
| 43 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 44 | return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp); | |
| 45 | } | |
| 46 | ||
| 43 | 47 | |
| 44 | 48 | template <class _ForwardIterator> |
| 45 | _LIBCPP_NODISCARD_EXT inline | |
| 46 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 47 | _ForwardIterator | |
| 49 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | |
| 48 | 50 | max_element(_ForwardIterator __first, _ForwardIterator __last) |
| 49 | 51 | { |
| 50 | 52 | return _VSTD::max_element(__first, __last, |
| ... | ... | @@ -53,6 +55,4 @@ max_element(_ForwardIterator __first, _ForwardIterator __last) |
| 53 | 55 | |
| 54 | 56 | _LIBCPP_END_NAMESPACE_STD |
| 55 | 57 | |
| 56 | _LIBCPP_POP_MACROS | |
| 57 | ||
| 58 | 58 | #endif // _LIBCPP___ALGORITHM_MAX_ELEMENT_H |
lib/libcxx/include/__algorithm/merge.h+1-6| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MERGE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MERGE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| ... | ... | @@ -71,6 +68,4 @@ merge(_InputIterator1 __first1, _InputIterator1 __last1, |
| 71 | 68 | |
| 72 | 69 | _LIBCPP_END_NAMESPACE_STD |
| 73 | 70 | |
| 74 | _LIBCPP_POP_MACROS | |
| 75 | ||
| 76 | 71 | #endif // _LIBCPP___ALGORITHM_MERGE_H |
lib/libcxx/include/__algorithm/min.h+4-2| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MIN_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MIN_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | 14 | #include <__algorithm/min_element.h> |
| 15 | #include <__config> | |
| 15 | 16 | #include <initializer_list> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -49,7 +50,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 49 | 50 | _Tp |
| 50 | 51 | min(initializer_list<_Tp> __t, _Compare __comp) |
| 51 | 52 | { |
| 52 | return *_VSTD::min_element(__t.begin(), __t.end(), __comp); | |
| 53 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 54 | return *_VSTD::__min_element<_Comp_ref>(__t.begin(), __t.end(), __comp); | |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | 57 | template<class _Tp> |
lib/libcxx/include/__algorithm/min_element.h+14-14| ... | ... | @@ -9,24 +9,20 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MIN_ELEMENT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MIN_ELEMENT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/comp_ref_type.h> | |
| 14 | #include <__config> | |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | template <class _ForwardIterator, class _Compare> | |
| 26 | _LIBCPP_NODISCARD_EXT inline | |
| 27 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 28 | _ForwardIterator | |
| 29 | min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 23 | template <class _Compare, class _ForwardIterator> | |
| 24 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | |
| 25 | __min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 30 | 26 | { |
| 31 | 27 | static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 32 | 28 | "std::min_element requires a ForwardIterator"); |
| ... | ... | @@ -40,10 +36,16 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) |
| 40 | 36 | return __first; |
| 41 | 37 | } |
| 42 | 38 | |
| 39 | template <class _ForwardIterator, class _Compare> | |
| 40 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | |
| 41 | min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 42 | { | |
| 43 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 44 | return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp); | |
| 45 | } | |
| 46 | ||
| 43 | 47 | template <class _ForwardIterator> |
| 44 | _LIBCPP_NODISCARD_EXT inline | |
| 45 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 46 | _ForwardIterator | |
| 48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator | |
| 47 | 49 | min_element(_ForwardIterator __first, _ForwardIterator __last) |
| 48 | 50 | { |
| 49 | 51 | return _VSTD::min_element(__first, __last, |
| ... | ... | @@ -52,6 +54,4 @@ min_element(_ForwardIterator __first, _ForwardIterator __last) |
| 52 | 54 | |
| 53 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 54 | 56 | |
| 55 | _LIBCPP_POP_MACROS | |
| 56 | ||
| 57 | 57 | #endif // _LIBCPP___ALGORITHM_MIN_ELEMENT_H |
lib/libcxx/include/__algorithm/minmax.h+1-7| ... | ... | @@ -9,19 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MINMAX_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MINMAX_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <initializer_list> |
| 15 | 15 | #include <utility> |
| 16 | 16 | |
| 17 | ||
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | #pragma GCC system_header |
| 20 | 19 | #endif |
| 21 | 20 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 22 | |
| 27 | 23 | template<class _Tp, class _Compare> |
| ... | ... | @@ -96,6 +92,4 @@ minmax(initializer_list<_Tp> __t) |
| 96 | 92 | |
| 97 | 93 | _LIBCPP_END_NAMESPACE_STD |
| 98 | 94 | |
| 99 | _LIBCPP_POP_MACROS | |
| 100 | ||
| 101 | 95 | #endif // _LIBCPP___ALGORITHM_MINMAX_H |
lib/libcxx/include/__algorithm/minmax_element.h+1-6| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <utility> |
| 16 | 16 | |
| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _ForwardIterator, class _Compare> |
| ... | ... | @@ -85,6 +82,4 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last) |
| 85 | 82 | |
| 86 | 83 | _LIBCPP_END_NAMESPACE_STD |
| 87 | 84 | |
| 88 | _LIBCPP_POP_MACROS | |
| 89 | ||
| 90 | 85 | #endif // _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H |
lib/libcxx/include/__algorithm/mismatch.h+1-6| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_MISMATCH_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_MISMATCH_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | #include <utility> |
| 17 | 17 | |
| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> |
| ... | ... | @@ -67,6 +64,4 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY |
| 67 | 64 | |
| 68 | 65 | _LIBCPP_END_NAMESPACE_STD |
| 69 | 66 | |
| 70 | _LIBCPP_POP_MACROS | |
| 71 | ||
| 72 | 67 | #endif // _LIBCPP___ALGORITHM_MISMATCH_H |
lib/libcxx/include/__algorithm/move.h+2-7| ... | ... | @@ -9,20 +9,17 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MOVE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__utility/move.h> |
| 15 | 15 | #include <cstring> |
| 16 | #include <utility> | |
| 17 | 16 | #include <type_traits> |
| 17 | #include <utility> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | // move |
| ... | ... | @@ -78,6 +75,4 @@ move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) |
| 78 | 75 | |
| 79 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 80 | 77 | |
| 81 | _LIBCPP_POP_MACROS | |
| 82 | ||
| 83 | 78 | #endif // _LIBCPP___ALGORITHM_MOVE_H |
lib/libcxx/include/__algorithm/move_backward.h+2-7| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <cstring> |
| 15 | #include <utility> | |
| 16 | 15 | #include <type_traits> |
| 16 | #include <utility> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _InputIterator, class _OutputIterator> |
| ... | ... | @@ -79,6 +76,4 @@ move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, |
| 79 | 76 | |
| 80 | 77 | _LIBCPP_END_NAMESPACE_STD |
| 81 | 78 | |
| 82 | _LIBCPP_POP_MACROS | |
| 83 | ||
| 84 | 79 | #endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H |
lib/libcxx/include/__algorithm/next_permutation.h+1-6| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/reverse.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | #include <__utility/swap.h> |
| 18 | 18 | |
| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | template <class _Compare, class _BidirectionalIterator> |
| ... | ... | @@ -72,6 +69,4 @@ next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) |
| 72 | 69 | |
| 73 | 70 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 71 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 72 | #endif // _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H |
lib/libcxx/include/__algorithm/none_of.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _InputIterator, class _Predicate> |
| ... | ... | @@ -32,6 +29,4 @@ none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_NONE_OF_H |
lib/libcxx/include/__algorithm/nth_element.h+12-8| ... | ... | @@ -9,20 +9,21 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_NTH_ELEMENT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_NTH_ELEMENT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/sort.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | #include <__utility/swap.h> |
| 18 | 18 | |
| 19 | #if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 20 | # include <__algorithm/shuffle.h> | |
| 21 | #endif | |
| 22 | ||
| 19 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 24 | #pragma GCC system_header |
| 21 | 25 | #endif |
| 22 | 26 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 28 | |
| 28 | 29 | template<class _Compare, class _RandomAccessIterator> |
| ... | ... | @@ -225,8 +226,13 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 225 | 226 | void |
| 226 | 227 | nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) |
| 227 | 228 | { |
| 228 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 229 | _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp); | |
| 229 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); | |
| 230 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 231 | _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp); | |
| 232 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __nth); | |
| 233 | if (__nth != __last) { | |
| 234 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(++__nth, __last); | |
| 235 | } | |
| 230 | 236 | } |
| 231 | 237 | |
| 232 | 238 | template <class _RandomAccessIterator> |
| ... | ... | @@ -239,6 +245,4 @@ nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomA |
| 239 | 245 | |
| 240 | 246 | _LIBCPP_END_NAMESPACE_STD |
| 241 | 247 | |
| 242 | _LIBCPP_POP_MACROS | |
| 243 | ||
| 244 | 248 | #endif // _LIBCPP___ALGORITHM_NTH_ELEMENT_H |
lib/libcxx/include/__algorithm/partial_sort.h+14-11| ... | ... | @@ -9,29 +9,32 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_PARTIAL_SORT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/make_heap.h> |
| 16 | 15 | #include <__algorithm/sift_down.h> |
| 17 | 16 | #include <__algorithm/sort_heap.h> |
| 17 | #include <__config> | |
| 18 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | 19 | #include <__utility/swap.h> |
| 20 | 20 | |
| 21 | #if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 22 | # include <__algorithm/shuffle.h> | |
| 23 | #endif | |
| 24 | ||
| 21 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 26 | #pragma GCC system_header |
| 23 | 27 | #endif |
| 24 | 28 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 30 | |
| 30 | 31 | template <class _Compare, class _RandomAccessIterator> |
| 31 | 32 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void |
| 32 | 33 | __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, |
| 33 | _Compare __comp) | |
| 34 | _Compare __comp) | |
| 34 | 35 | { |
| 36 | if (__first == __middle) | |
| 37 | return; | |
| 35 | 38 | _VSTD::__make_heap<_Compare>(__first, __middle, __comp); |
| 36 | 39 | typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; |
| 37 | 40 | for (_RandomAccessIterator __i = __middle; __i != __last; ++__i) |
| ... | ... | @@ -39,7 +42,7 @@ __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _R |
| 39 | 42 | if (__comp(*__i, *__first)) |
| 40 | 43 | { |
| 41 | 44 | swap(*__i, *__first); |
| 42 | _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first); | |
| 45 | _VSTD::__sift_down<_Compare>(__first, __comp, __len, __first); | |
| 43 | 46 | } |
| 44 | 47 | } |
| 45 | 48 | _VSTD::__sort_heap<_Compare>(__first, __middle, __comp); |
| ... | ... | @@ -51,8 +54,10 @@ void |
| 51 | 54 | partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, |
| 52 | 55 | _Compare __comp) |
| 53 | 56 | { |
| 54 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 55 | _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp); | |
| 57 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); | |
| 58 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 59 | _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp); | |
| 60 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(__middle, __last); | |
| 56 | 61 | } |
| 57 | 62 | |
| 58 | 63 | template <class _RandomAccessIterator> |
| ... | ... | @@ -61,11 +66,9 @@ void |
| 61 | 66 | partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) |
| 62 | 67 | { |
| 63 | 68 | _VSTD::partial_sort(__first, __middle, __last, |
| 64 | __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 69 | __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 65 | 70 | } |
| 66 | 71 | |
| 67 | 72 | _LIBCPP_END_NAMESPACE_STD |
| 68 | 73 | |
| 69 | _LIBCPP_POP_MACROS | |
| 70 | ||
| 71 | 74 | #endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_H |
lib/libcxx/include/__algorithm/partial_sort_copy.h+2-8| ... | ... | @@ -9,22 +9,18 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/make_heap.h> |
| 16 | 15 | #include <__algorithm/sift_down.h> |
| 17 | 16 | #include <__algorithm/sort_heap.h> |
| 17 | #include <__config> | |
| 18 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <type_traits> // swap | |
| 20 | 19 | |
| 21 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 21 | #pragma GCC system_header |
| 23 | 22 | #endif |
| 24 | 23 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 25 | |
| 30 | 26 | template <class _Compare, class _InputIterator, class _RandomAccessIterator> |
| ... | ... | @@ -43,7 +39,7 @@ __partial_sort_copy(_InputIterator __first, _InputIterator __last, |
| 43 | 39 | if (__comp(*__first, *__result_first)) |
| 44 | 40 | { |
| 45 | 41 | *__result_first = *__first; |
| 46 | _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first); | |
| 42 | _VSTD::__sift_down<_Compare>(__result_first, __comp, __len, __result_first); | |
| 47 | 43 | } |
| 48 | 44 | _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp); |
| 49 | 45 | } |
| ... | ... | @@ -72,6 +68,4 @@ partial_sort_copy(_InputIterator __first, _InputIterator __last, |
| 72 | 68 | |
| 73 | 69 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 70 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 71 | #endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H |
lib/libcxx/include/__algorithm/partition.h+2-9| ... | ... | @@ -12,16 +12,11 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__iterator/iterator_traits.h> |
| 14 | 14 | #include <__utility/swap.h> |
| 15 | #include <utility> // pair | |
| 16 | #include <type_traits> | |
| 17 | 15 | |
| 18 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 17 | #pragma GCC system_header |
| 20 | 18 | #endif |
| 21 | 19 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 21 | |
| 27 | 22 | template <class _Predicate, class _ForwardIterator> |
| ... | ... | @@ -77,12 +72,10 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 77 | 72 | _ForwardIterator |
| 78 | 73 | partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) |
| 79 | 74 | { |
| 80 | return _VSTD::__partition<typename add_lvalue_reference<_Predicate>::type> | |
| 81 | (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 75 | return _VSTD::__partition<_Predicate&>( | |
| 76 | __first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 82 | 77 | } |
| 83 | 78 | |
| 84 | 79 | _LIBCPP_END_NAMESPACE_STD |
| 85 | 80 | |
| 86 | _LIBCPP_POP_MACROS | |
| 87 | ||
| 88 | 81 | #endif // _LIBCPP___ALGORITHM_PARTITION_H |
lib/libcxx/include/__algorithm/partition_copy.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _InputIterator, class _OutputIterator1, |
| ... | ... | @@ -47,6 +44,4 @@ partition_copy(_InputIterator __first, _InputIterator __last, |
| 47 | 44 | |
| 48 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 49 | 46 | |
| 50 | _LIBCPP_POP_MACROS | |
| 51 | ||
| 52 | 47 | #endif // _LIBCPP___ALGORITHM_PARTITION_COPY_H |
lib/libcxx/include/__algorithm/partition_point.h+1-6| ... | ... | @@ -9,17 +9,14 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_PARTITION_POINT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_PARTITION_POINT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/half_positive.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <iterator> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template<class _ForwardIterator, class _Predicate> |
| ... | ... | @@ -46,6 +43,4 @@ partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __ |
| 46 | 43 | |
| 47 | 44 | _LIBCPP_END_NAMESPACE_STD |
| 48 | 45 | |
| 49 | _LIBCPP_POP_MACROS | |
| 50 | ||
| 51 | 46 | #endif // _LIBCPP___ALGORITHM_PARTITION_POINT_H |
lib/libcxx/include/__algorithm/pop_heap.h+2-7| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_POP_HEAP_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_POP_HEAP_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/sift_down.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | #include <__utility/swap.h> |
| 18 | 18 | |
| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | template <class _Compare, class _RandomAccessIterator> |
| ... | ... | @@ -34,7 +31,7 @@ __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare |
| 34 | 31 | if (__len > 1) |
| 35 | 32 | { |
| 36 | 33 | swap(*__first, *--__last); |
| 37 | _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first); | |
| 34 | _VSTD::__sift_down<_Compare>(__first, __comp, __len - 1, __first); | |
| 38 | 35 | } |
| 39 | 36 | } |
| 40 | 37 | |
| ... | ... | @@ -57,6 +54,4 @@ pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 57 | 54 | |
| 58 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 59 | 56 | |
| 60 | _LIBCPP_POP_MACROS | |
| 61 | ||
| 62 | 57 | #endif // _LIBCPP___ALGORITHM_POP_HEAP_H |
lib/libcxx/include/__algorithm/prev_permutation.h+1-6| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_PREV_PERMUTATION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/reverse.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | #include <__utility/swap.h> |
| 18 | 18 | |
| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | template <class _Compare, class _BidirectionalIterator> |
| ... | ... | @@ -72,6 +69,4 @@ prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) |
| 72 | 69 | |
| 73 | 70 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 71 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 72 | #endif // _LIBCPP___ALGORITHM_PREV_PERMUTATION_H |
lib/libcxx/include/__algorithm/push_heap.h+1-6| ... | ... | @@ -9,9 +9,9 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_PUSH_HEAP_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_PUSH_HEAP_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | #include <__utility/move.h> |
| 17 | 17 | |
| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _RandomAccessIterator> |
| ... | ... | @@ -70,6 +67,4 @@ push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 70 | 67 | |
| 71 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 69 | |
| 73 | _LIBCPP_POP_MACROS | |
| 74 | ||
| 75 | 70 | #endif // _LIBCPP___ALGORITHM_PUSH_HEAP_H |
lib/libcxx/include/__algorithm/remove.h+1-6| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_REMOVE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_REMOVE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/find.h> |
| 14 | 13 | #include <__algorithm/find_if.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__utility/move.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _ForwardIterator, class _Tp> |
| ... | ... | @@ -45,6 +42,4 @@ remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) |
| 45 | 42 | |
| 46 | 43 | _LIBCPP_END_NAMESPACE_STD |
| 47 | 44 | |
| 48 | _LIBCPP_POP_MACROS | |
| 49 | ||
| 50 | 45 | #endif // _LIBCPP___ALGORITHM_REMOVE_H |
lib/libcxx/include/__algorithm/remove_copy.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _InputIterator, class _OutputIterator, class _Tp> |
| ... | ... | @@ -38,6 +35,4 @@ remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res |
| 38 | 35 | |
| 39 | 36 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 37 | |
| 41 | _LIBCPP_POP_MACROS | |
| 42 | ||
| 43 | 38 | #endif // _LIBCPP___ALGORITHM_REMOVE_COPY_H |
lib/libcxx/include/__algorithm/remove_copy_if.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _InputIterator, class _OutputIterator, class _Predicate> |
| ... | ... | @@ -38,6 +35,4 @@ remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __ |
| 38 | 35 | |
| 39 | 36 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 37 | |
| 41 | _LIBCPP_POP_MACROS | |
| 42 | ||
| 43 | 38 | #endif // _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H |
lib/libcxx/include/__algorithm/remove_if.h+2-9| ... | ... | @@ -9,26 +9,21 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_REMOVE_IF_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_REMOVE_IF_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/find_if.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <utility> |
| 15 | #include <type_traits> | |
| 16 | 15 | |
| 17 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 17 | #pragma GCC system_header |
| 19 | 18 | #endif |
| 20 | 19 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 21 | |
| 26 | 22 | template <class _ForwardIterator, class _Predicate> |
| 27 | 23 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator |
| 28 | 24 | remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) |
| 29 | 25 | { |
| 30 | __first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type> | |
| 31 | (__first, __last, __pred); | |
| 26 | __first = _VSTD::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred); | |
| 32 | 27 | if (__first != __last) |
| 33 | 28 | { |
| 34 | 29 | _ForwardIterator __i = __first; |
| ... | ... | @@ -46,6 +41,4 @@ remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) |
| 46 | 41 | |
| 47 | 42 | _LIBCPP_END_NAMESPACE_STD |
| 48 | 43 | |
| 49 | _LIBCPP_POP_MACROS | |
| 50 | ||
| 51 | 44 | #endif // _LIBCPP___ALGORITHM_REMOVE_IF_H |
lib/libcxx/include/__algorithm/replace.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _ForwardIterator, class _Tp> |
| ... | ... | @@ -32,6 +29,4 @@ replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_valu |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_REPLACE_H |
lib/libcxx/include/__algorithm/replace_copy.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _InputIterator, class _OutputIterator, class _Tp> |
| ... | ... | @@ -36,6 +33,4 @@ replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __re |
| 36 | 33 | |
| 37 | 34 | _LIBCPP_END_NAMESPACE_STD |
| 38 | 35 | |
| 39 | _LIBCPP_POP_MACROS | |
| 40 | ||
| 41 | 36 | #endif // _LIBCPP___ALGORITHM_REPLACE_COPY_H |
lib/libcxx/include/__algorithm/replace_copy_if.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _InputIterator, class _OutputIterator, class _Predicate, class _Tp> |
| ... | ... | @@ -36,6 +33,4 @@ replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator _ |
| 36 | 33 | |
| 37 | 34 | _LIBCPP_END_NAMESPACE_STD |
| 38 | 35 | |
| 39 | _LIBCPP_POP_MACROS | |
| 40 | ||
| 41 | 36 | #endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H |
lib/libcxx/include/__algorithm/replace_if.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _ForwardIterator, class _Predicate, class _Tp> |
| ... | ... | @@ -32,6 +29,4 @@ replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_REPLACE_IF_H |
lib/libcxx/include/__algorithm/reverse.h+1-6| ... | ... | @@ -9,17 +9,14 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_REVERSE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_REVERSE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/iter_swap.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _BidirectionalIterator> |
| ... | ... | @@ -56,6 +53,4 @@ reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) |
| 56 | 53 | |
| 57 | 54 | _LIBCPP_END_NAMESPACE_STD |
| 58 | 55 | |
| 59 | _LIBCPP_POP_MACROS | |
| 60 | ||
| 61 | 56 | #endif // _LIBCPP___ALGORITHM_REVERSE_H |
lib/libcxx/include/__algorithm/reverse_copy.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _BidirectionalIterator, class _OutputIterator> |
| ... | ... | @@ -32,6 +29,4 @@ reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _Out |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_REVERSE_COPY_H |
lib/libcxx/include/__algorithm/rotate.h-5| ... | ... | @@ -23,9 +23,6 @@ |
| 23 | 23 | #pragma GCC system_header |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 27 | |
| 31 | 28 | template <class _ForwardIterator> |
| ... | ... | @@ -200,6 +197,4 @@ rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __l |
| 200 | 197 | |
| 201 | 198 | _LIBCPP_END_NAMESPACE_STD |
| 202 | 199 | |
| 203 | _LIBCPP_POP_MACROS | |
| 204 | ||
| 205 | 200 | #endif // _LIBCPP___ALGORITHM_ROTATE_H |
lib/libcxx/include/__algorithm/rotate_copy.h+1-8| ... | ... | @@ -9,18 +9,13 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_ROTATE_COPY_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_ROTATE_COPY_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/copy.h> |
| 14 | #include <iterator> | |
| 15 | #include <type_traits> | |
| 13 | #include <__config> | |
| 16 | 14 | |
| 17 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 16 | #pragma GCC system_header |
| 19 | 17 | #endif |
| 20 | 18 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 20 | |
| 26 | 21 | template <class _ForwardIterator, class _OutputIterator> |
| ... | ... | @@ -33,6 +28,4 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato |
| 33 | 28 | |
| 34 | 29 | _LIBCPP_END_NAMESPACE_STD |
| 35 | 30 | |
| 36 | _LIBCPP_POP_MACROS | |
| 37 | ||
| 38 | 31 | #endif // _LIBCPP___ALGORITHM_ROTATE_COPY_H |
lib/libcxx/include/__algorithm/sample.h+2-1| ... | ... | @@ -9,8 +9,9 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SAMPLE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SAMPLE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/min.h> |
| 13 | #include <__config> | |
| 14 | #include <__debug> | |
| 14 | 15 | #include <__random/uniform_int_distribution.h> |
| 15 | 16 | #include <iterator> |
| 16 | 17 |
lib/libcxx/include/__algorithm/search.h+3-9| ... | ... | @@ -13,16 +13,12 @@ |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <type_traits> | |
| 17 | 16 | #include <utility> |
| 18 | 17 | |
| 19 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 19 | #pragma GCC system_header |
| 21 | 20 | #endif |
| 22 | 21 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 23 | |
| 28 | 24 | template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2> |
| ... | ... | @@ -72,7 +68,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando |
| 72 | 68 | const _D1 __len1 = __last1 - __first1; |
| 73 | 69 | if (__len1 < __len2) |
| 74 | 70 | return _VSTD::make_pair(__last1, __last1); |
| 75 | const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here | |
| 71 | const _RandomAccessIterator1 __s = __last1 - _D1(__len2 - 1); // Start of pattern match can't go beyond here | |
| 76 | 72 | |
| 77 | 73 | while (true) { |
| 78 | 74 | while (true) { |
| ... | ... | @@ -87,7 +83,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando |
| 87 | 83 | _RandomAccessIterator2 __m2 = __first2; |
| 88 | 84 | while (true) { |
| 89 | 85 | if (++__m2 == __last2) |
| 90 | return _VSTD::make_pair(__first1, __first1 + __len2); | |
| 86 | return _VSTD::make_pair(__first1, __first1 + _D1(__len2)); | |
| 91 | 87 | ++__m1; // no need to check range on __m1 because __s guarantees we have enough source |
| 92 | 88 | if (!__pred(*__m1, *__m2)) { |
| 93 | 89 | ++__first1; |
| ... | ... | @@ -101,7 +97,7 @@ template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredica |
| 101 | 97 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 |
| 102 | 98 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, |
| 103 | 99 | _BinaryPredicate __pred) { |
| 104 | return _VSTD::__search<typename add_lvalue_reference<_BinaryPredicate>::type>( | |
| 100 | return _VSTD::__search<_BinaryPredicate&>( | |
| 105 | 101 | __first1, __last1, __first2, __last2, __pred, |
| 106 | 102 | typename iterator_traits<_ForwardIterator1>::iterator_category(), |
| 107 | 103 | typename iterator_traits<_ForwardIterator2>::iterator_category()).first; |
| ... | ... | @@ -126,6 +122,4 @@ search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) { |
| 126 | 122 | |
| 127 | 123 | _LIBCPP_END_NAMESPACE_STD |
| 128 | 124 | |
| 129 | _LIBCPP_POP_MACROS | |
| 130 | ||
| 131 | 125 | #endif // _LIBCPP___ALGORITHM_SEARCH_H |
lib/libcxx/include/__algorithm/search_n.h+5-9| ... | ... | @@ -10,18 +10,15 @@ |
| 10 | 10 | #ifndef _LIBCPP___ALGORITHM_SEARCH_N_H |
| 11 | 11 | #define _LIBCPP___ALGORITHM_SEARCH_N_H |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <type_traits> | |
| 16 | #include <type_traits> // __convert_to_integral | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp> |
| ... | ... | @@ -62,12 +59,13 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter |
| 62 | 59 | _RandomAccessIterator __last, _Size __count, |
| 63 | 60 | const _Tp& __value_, _BinaryPredicate __pred, |
| 64 | 61 | random_access_iterator_tag) { |
| 62 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 65 | 63 | if (__count <= 0) |
| 66 | 64 | return __first; |
| 67 | 65 | _Size __len = static_cast<_Size>(__last - __first); |
| 68 | 66 | if (__len < __count) |
| 69 | 67 | return __last; |
| 70 | const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here | |
| 68 | const _RandomAccessIterator __s = __last - difference_type(__count - 1); // Start of pattern match can't go beyond here | |
| 71 | 69 | while (true) { |
| 72 | 70 | // Find first element in sequence that matchs __value_, with a mininum of loop checks |
| 73 | 71 | while (true) { |
| ... | ... | @@ -97,7 +95,7 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter |
| 97 | 95 | template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> |
| 98 | 96 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n( |
| 99 | 97 | _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) { |
| 100 | return _VSTD::__search_n<typename add_lvalue_reference<_BinaryPredicate>::type>( | |
| 98 | return _VSTD::__search_n<_BinaryPredicate&>( | |
| 101 | 99 | __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred, |
| 102 | 100 | typename iterator_traits<_ForwardIterator>::iterator_category()); |
| 103 | 101 | } |
| ... | ... | @@ -111,6 +109,4 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const |
| 111 | 109 | |
| 112 | 110 | _LIBCPP_END_NAMESPACE_STD |
| 113 | 111 | |
| 114 | _LIBCPP_POP_MACROS | |
| 115 | ||
| 116 | 112 | #endif // _LIBCPP___ALGORITHM_SEARCH_N_H |
lib/libcxx/include/__algorithm/set_difference.h+1-6| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SET_DIFFERENCE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| ... | ... | @@ -72,6 +69,4 @@ set_difference(_InputIterator1 __first1, _InputIterator1 __last1, |
| 72 | 69 | |
| 73 | 70 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 71 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 72 | #endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H |
lib/libcxx/include/__algorithm/set_intersection.h+1-6| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SET_INTERSECTION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SET_INTERSECTION_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| ... | ... | @@ -69,6 +66,4 @@ set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, |
| 69 | 66 | |
| 70 | 67 | _LIBCPP_END_NAMESPACE_STD |
| 71 | 68 | |
| 72 | _LIBCPP_POP_MACROS | |
| 73 | ||
| 74 | 69 | #endif // _LIBCPP___ALGORITHM_SET_INTERSECTION_H |
lib/libcxx/include/__algorithm/set_symmetric_difference.h+1-6| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| ... | ... | @@ -77,6 +74,4 @@ set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, |
| 77 | 74 | |
| 78 | 75 | _LIBCPP_END_NAMESPACE_STD |
| 79 | 76 | |
| 80 | _LIBCPP_POP_MACROS | |
| 81 | ||
| 82 | 77 | #endif // _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H |
lib/libcxx/include/__algorithm/set_union.h+1-6| ... | ... | @@ -9,19 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SET_UNION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SET_UNION_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/copy.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| ... | ... | @@ -72,6 +69,4 @@ set_union(_InputIterator1 __first1, _InputIterator1 __last1, |
| 72 | 69 | |
| 73 | 70 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 71 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 72 | #endif // _LIBCPP___ALGORITHM_SET_UNION_H |
lib/libcxx/include/__algorithm/shift_left.h+2-7| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SHIFT_LEFT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SHIFT_LEFT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/move.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | #include <type_traits> // swap | |
| 15 | #include <type_traits> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 17 |
| ... | ... | @@ -56,6 +53,4 @@ shift_left(_ForwardIterator __first, _ForwardIterator __last, |
| 56 | 53 | |
| 57 | 54 | _LIBCPP_END_NAMESPACE_STD |
| 58 | 55 | |
| 59 | _LIBCPP_POP_MACROS | |
| 60 | ||
| 61 | 56 | #endif // _LIBCPP___ALGORITHM_SHIFT_LEFT_H |
lib/libcxx/include/__algorithm/shift_right.h+3-7| ... | ... | @@ -9,20 +9,18 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SHIFT_RIGHT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/move.h> |
| 14 | 13 | #include <__algorithm/move_backward.h> |
| 15 | 14 | #include <__algorithm/swap_ranges.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <type_traits> // swap | |
| 17 | #include <__utility/swap.h> | |
| 18 | #include <type_traits> | |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 21 | #pragma GCC system_header |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 25 | |
| 28 | 26 | #if _LIBCPP_STD_VER > 17 |
| ... | ... | @@ -101,6 +99,4 @@ shift_right(_ForwardIterator __first, _ForwardIterator __last, |
| 101 | 99 | |
| 102 | 100 | _LIBCPP_END_NAMESPACE_STD |
| 103 | 101 | |
| 104 | _LIBCPP_POP_MACROS | |
| 105 | ||
| 106 | 102 | #endif // _LIBCPP___ALGORITHM_SHIFT_RIGHT_H |
lib/libcxx/include/__algorithm/shuffle.h+33| ... | ... | @@ -25,6 +25,39 @@ _LIBCPP_PUSH_MACROS |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | class _LIBCPP_TYPE_VIS __libcpp_debug_randomizer { | |
| 29 | public: | |
| 30 | __libcpp_debug_randomizer() { | |
| 31 | __state = __seed(); | |
| 32 | __inc = __state + 0xda3e39cb94b95bdbULL; | |
| 33 | __inc = (__inc << 1) | 1; | |
| 34 | } | |
| 35 | typedef uint_fast32_t result_type; | |
| 36 | ||
| 37 | static const result_type _Min = 0; | |
| 38 | static const result_type _Max = 0xFFFFFFFF; | |
| 39 | ||
| 40 | _LIBCPP_HIDE_FROM_ABI result_type operator()() { | |
| 41 | uint_fast64_t __oldstate = __state; | |
| 42 | __state = __oldstate * 6364136223846793005ULL + __inc; | |
| 43 | return __oldstate >> 32; | |
| 44 | } | |
| 45 | ||
| 46 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 47 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 48 | ||
| 49 | private: | |
| 50 | uint_fast64_t __state; | |
| 51 | uint_fast64_t __inc; | |
| 52 | _LIBCPP_HIDE_FROM_ABI static uint_fast64_t __seed() { | |
| 53 | #ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED | |
| 54 | return _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY_SEED; | |
| 55 | #else | |
| 56 | static char __x; | |
| 57 | return reinterpret_cast<uintptr_t>(&__x); | |
| 58 | #endif | |
| 59 | } | |
| 60 | }; | |
| 28 | 61 | |
| 29 | 62 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \ |
| 30 | 63 | || defined(_LIBCPP_BUILDING_LIBRARY) |
lib/libcxx/include/__algorithm/sift_down.h+4-10| ... | ... | @@ -17,15 +17,11 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _Compare, class _RandomAccessIterator> |
| 26 | 23 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void |
| 27 | __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, | |
| 28 | _Compare __comp, | |
| 24 | __sift_down(_RandomAccessIterator __first, _Compare __comp, | |
| 29 | 25 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, |
| 30 | 26 | _RandomAccessIterator __start) |
| 31 | 27 | { |
| ... | ... | @@ -41,7 +37,7 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, |
| 41 | 37 | __child = 2 * __child + 1; |
| 42 | 38 | _RandomAccessIterator __child_i = __first + __child; |
| 43 | 39 | |
| 44 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { | |
| 40 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { | |
| 45 | 41 | // right-child exists and is greater than left-child |
| 46 | 42 | ++__child_i; |
| 47 | 43 | ++__child; |
| ... | ... | @@ -49,7 +45,7 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, |
| 49 | 45 | |
| 50 | 46 | // check if we are in heap-order |
| 51 | 47 | if (__comp(*__child_i, *__start)) |
| 52 | // we are, __start is larger than it's largest child | |
| 48 | // we are, __start is larger than its largest child | |
| 53 | 49 | return; |
| 54 | 50 | |
| 55 | 51 | value_type __top(_VSTD::move(*__start)); |
| ... | ... | @@ -66,7 +62,7 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, |
| 66 | 62 | __child = 2 * __child + 1; |
| 67 | 63 | __child_i = __first + __child; |
| 68 | 64 | |
| 69 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { | |
| 65 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { | |
| 70 | 66 | // right-child exists and is greater than left-child |
| 71 | 67 | ++__child_i; |
| 72 | 68 | ++__child; |
| ... | ... | @@ -79,6 +75,4 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, |
| 79 | 75 | |
| 80 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 81 | 77 | |
| 82 | _LIBCPP_POP_MACROS | |
| 83 | ||
| 84 | 78 | #endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H |
lib/libcxx/include/__algorithm/sort.h+62-36| ... | ... | @@ -9,23 +9,23 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SORT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SORT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/min_element.h> |
| 16 | 15 | #include <__algorithm/partial_sort.h> |
| 17 | 16 | #include <__algorithm/unwrap_iter.h> |
| 17 | #include <__config> | |
| 18 | 18 | #include <__utility/swap.h> |
| 19 | 19 | #include <memory> |
| 20 | #include <type_traits> // swap | |
| 20 | ||
| 21 | #if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 22 | # include <__algorithm/shuffle.h> | |
| 23 | #endif | |
| 21 | 24 | |
| 22 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | 26 | #pragma GCC system_header |
| 24 | 27 | #endif |
| 25 | 28 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | |
| 31 | 31 | // stable, 2-3 compares, 0-2 swaps |
| ... | ... | @@ -131,9 +131,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, |
| 131 | 131 | _BidirectionalIterator __lm1 = __last; |
| 132 | 132 | for (--__lm1; __first != __lm1; ++__first) |
| 133 | 133 | { |
| 134 | _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator, | |
| 135 | typename add_lvalue_reference<_Compare>::type> | |
| 136 | (__first, __last, __comp); | |
| 134 | _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp); | |
| 137 | 135 | if (__i != __first) |
| 138 | 136 | swap(*__first, *__i); |
| 139 | 137 | } |
| ... | ... | @@ -162,10 +160,11 @@ template <class _Compare, class _RandomAccessIterator> |
| 162 | 160 | void |
| 163 | 161 | __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) |
| 164 | 162 | { |
| 163 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 165 | 164 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 166 | _RandomAccessIterator __j = __first+2; | |
| 167 | _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); | |
| 168 | for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) | |
| 165 | _RandomAccessIterator __j = __first+difference_type(2); | |
| 166 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp); | |
| 167 | for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i) | |
| 169 | 168 | { |
| 170 | 169 | if (__comp(*__i, *__j)) |
| 171 | 170 | { |
| ... | ... | @@ -187,6 +186,7 @@ template <class _Compare, class _RandomAccessIterator> |
| 187 | 186 | bool |
| 188 | 187 | __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) |
| 189 | 188 | { |
| 189 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 190 | 190 | switch (__last - __first) |
| 191 | 191 | { |
| 192 | 192 | case 0: |
| ... | ... | @@ -197,21 +197,21 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator |
| 197 | 197 | swap(*__first, *__last); |
| 198 | 198 | return true; |
| 199 | 199 | case 3: |
| 200 | _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); | |
| 200 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp); | |
| 201 | 201 | return true; |
| 202 | 202 | case 4: |
| 203 | _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); | |
| 203 | _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp); | |
| 204 | 204 | return true; |
| 205 | 205 | case 5: |
| 206 | _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); | |
| 206 | _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp); | |
| 207 | 207 | return true; |
| 208 | 208 | } |
| 209 | 209 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 210 | _RandomAccessIterator __j = __first+2; | |
| 211 | _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); | |
| 210 | _RandomAccessIterator __j = __first+difference_type(2); | |
| 211 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp); | |
| 212 | 212 | const unsigned __limit = 8; |
| 213 | 213 | unsigned __count = 0; |
| 214 | for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) | |
| 214 | for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i) | |
| 215 | 215 | { |
| 216 | 216 | if (__comp(*__i, *__j)) |
| 217 | 217 | { |
| ... | ... | @@ -269,7 +269,8 @@ __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __ |
| 269 | 269 | |
| 270 | 270 | template <class _Compare, class _RandomAccessIterator> |
| 271 | 271 | void |
| 272 | __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 272 | __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, | |
| 273 | typename iterator_traits<_RandomAccessIterator>::difference_type __depth) | |
| 273 | 274 | { |
| 274 | 275 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 275 | 276 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| ... | ... | @@ -289,13 +290,13 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c |
| 289 | 290 | swap(*__first, *__last); |
| 290 | 291 | return; |
| 291 | 292 | case 3: |
| 292 | _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); | |
| 293 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp); | |
| 293 | 294 | return; |
| 294 | 295 | case 4: |
| 295 | _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); | |
| 296 | _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp); | |
| 296 | 297 | return; |
| 297 | 298 | case 5: |
| 298 | _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); | |
| 299 | _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp); | |
| 299 | 300 | return; |
| 300 | 301 | } |
| 301 | 302 | if (__len <= __limit) |
| ... | ... | @@ -304,6 +305,13 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c |
| 304 | 305 | return; |
| 305 | 306 | } |
| 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; | |
| 307 | 315 | _RandomAccessIterator __m = __first; |
| 308 | 316 | _RandomAccessIterator __lm1 = __last; |
| 309 | 317 | --__lm1; |
| ... | ... | @@ -427,7 +435,7 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c |
| 427 | 435 | if (__n_swaps == 0) |
| 428 | 436 | { |
| 429 | 437 | bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp); |
| 430 | if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp)) | |
| 438 | if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+difference_type(1), __last, __comp)) | |
| 431 | 439 | { |
| 432 | 440 | if (__fs) |
| 433 | 441 | return; |
| ... | ... | @@ -446,19 +454,34 @@ __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __c |
| 446 | 454 | // sort smaller range with recursive call and larger with tail recursion elimination |
| 447 | 455 | if (__i - __first < __last - __i) |
| 448 | 456 | { |
| 449 | _VSTD::__sort<_Compare>(__first, __i, __comp); | |
| 450 | // _VSTD::__sort<_Compare>(__i+1, __last, __comp); | |
| 451 | __first = ++__i; | |
| 457 | _VSTD::__introsort<_Compare>(__first, __i, __comp, __depth); | |
| 458 | __first = ++__i; | |
| 452 | 459 | } |
| 453 | 460 | else |
| 454 | 461 | { |
| 455 | _VSTD::__sort<_Compare>(__i+1, __last, __comp); | |
| 456 | // _VSTD::__sort<_Compare>(__first, __i, __comp); | |
| 457 | __last = __i; | |
| 462 | _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth); | |
| 463 | __last = __i; | |
| 458 | 464 | } |
| 459 | 465 | } |
| 460 | 466 | } |
| 461 | 467 | |
| 468 | template <typename _Number> | |
| 469 | inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) { | |
| 470 | _Number __log2 = 0; | |
| 471 | while (__n > 1) { | |
| 472 | __log2++; | |
| 473 | __n >>= 1; | |
| 474 | } | |
| 475 | return __log2; | |
| 476 | } | |
| 477 | ||
| 478 | template <class _Compare, class _RandomAccessIterator> | |
| 479 | void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 480 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 481 | difference_type __depth_limit = 2 * __log2i(__last - __first); | |
| 482 | _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit); | |
| 483 | } | |
| 484 | ||
| 462 | 485 | template <class _Compare, class _Tp> |
| 463 | 486 | inline _LIBCPP_INLINE_VISIBILITY |
| 464 | 487 | void |
| ... | ... | @@ -469,7 +492,9 @@ __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) |
| 469 | 492 | } |
| 470 | 493 | |
| 471 | 494 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&)) |
| 495 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 472 | 496 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) |
| 497 | #endif | |
| 473 | 498 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) |
| 474 | 499 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) |
| 475 | 500 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&)) |
| ... | ... | @@ -485,7 +510,9 @@ _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(d |
| 485 | 510 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) |
| 486 | 511 | |
| 487 | 512 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&)) |
| 513 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 488 | 514 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) |
| 515 | #endif | |
| 489 | 516 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) |
| 490 | 517 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) |
| 491 | 518 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&)) |
| ... | ... | @@ -507,12 +534,13 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 507 | 534 | void |
| 508 | 535 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) |
| 509 | 536 | { |
| 510 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 511 | if (__libcpp_is_constant_evaluated()) { | |
| 512 | _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp)); | |
| 513 | } else { | |
| 514 | _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp)); | |
| 515 | } | |
| 537 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); | |
| 538 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 539 | if (__libcpp_is_constant_evaluated()) { | |
| 540 | _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp)); | |
| 541 | } else { | |
| 542 | _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp)); | |
| 543 | } | |
| 516 | 544 | } |
| 517 | 545 | |
| 518 | 546 | template <class _RandomAccessIterator> |
| ... | ... | @@ -525,6 +553,4 @@ sort(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 525 | 553 | |
| 526 | 554 | _LIBCPP_END_NAMESPACE_STD |
| 527 | 555 | |
| 528 | _LIBCPP_POP_MACROS | |
| 529 | ||
| 530 | 556 | #endif // _LIBCPP___ALGORITHM_SORT_H |
lib/libcxx/include/__algorithm/sort_heap.h+1-6| ... | ... | @@ -9,10 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SORT_HEAP_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SORT_HEAP_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/pop_heap.h> |
| 15 | #include <__config> | |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | #include <type_traits> // swap |
| 18 | 18 | |
| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | template <class _Compare, class _RandomAccessIterator> |
| ... | ... | @@ -53,6 +50,4 @@ sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 53 | 50 | |
| 54 | 51 | _LIBCPP_END_NAMESPACE_STD |
| 55 | 52 | |
| 56 | _LIBCPP_POP_MACROS | |
| 57 | ||
| 58 | 53 | #endif // _LIBCPP___ALGORITHM_SORT_HEAP_H |
lib/libcxx/include/__algorithm/stable_partition.h+8-18| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_STABLE_PARTITION_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/rotate.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <__utility/swap.h> |
| 16 | 16 | #include <memory> |
| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair> |
| ... | ... | @@ -85,8 +82,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 85 | 82 | // recurse on [__first, __m), *__first know to be false |
| 86 | 83 | // F????????????????? |
| 87 | 84 | // f m l |
| 88 | typedef typename add_lvalue_reference<_Predicate>::type _PredRef; | |
| 89 | _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit); | |
| 85 | _ForwardIterator __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m, __pred, __len2, __p, __fit); | |
| 90 | 86 | // TTTFFFFF?????????? |
| 91 | 87 | // f ff m l |
| 92 | 88 | // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true |
| ... | ... | @@ -101,7 +97,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 101 | 97 | } |
| 102 | 98 | // TTTFFFFFTTTF?????? |
| 103 | 99 | // f ff m m1 l |
| 104 | __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit); | |
| 100 | __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __fit); | |
| 105 | 101 | __second_half_done: |
| 106 | 102 | // TTTFFFFFTTTTTFFFFF |
| 107 | 103 | // f ff m sf l |
| ... | ... | @@ -137,8 +133,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 137 | 133 | __p = _VSTD::get_temporary_buffer<value_type>(__len); |
| 138 | 134 | __h.reset(__p.first); |
| 139 | 135 | } |
| 140 | return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type> | |
| 141 | (__first, __last, __pred, __len, __p, forward_iterator_tag()); | |
| 136 | return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag()); | |
| 142 | 137 | } |
| 143 | 138 | |
| 144 | 139 | template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair> |
| ... | ... | @@ -222,8 +217,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 222 | 217 | } |
| 223 | 218 | // F???TFFF?????????T |
| 224 | 219 | // f m1 m l |
| 225 | typedef typename add_lvalue_reference<_Predicate>::type _PredRef; | |
| 226 | __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit); | |
| 220 | __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m1, __pred, __len_half, __p, __bit); | |
| 227 | 221 | __first_half_done: |
| 228 | 222 | // TTTFFFFF?????????T |
| 229 | 223 | // f ff m l |
| ... | ... | @@ -240,7 +234,7 @@ __first_half_done: |
| 240 | 234 | } |
| 241 | 235 | // TTTFFFFFTTTF?????T |
| 242 | 236 | // f ff m m1 l |
| 243 | __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit); | |
| 237 | __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __bit); | |
| 244 | 238 | __second_half_done: |
| 245 | 239 | // TTTFFFFFTTTTTFFFFF |
| 246 | 240 | // f ff m sf l |
| ... | ... | @@ -285,8 +279,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 285 | 279 | __p = _VSTD::get_temporary_buffer<value_type>(__len); |
| 286 | 280 | __h.reset(__p.first); |
| 287 | 281 | } |
| 288 | return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type> | |
| 289 | (__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); | |
| 282 | return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); | |
| 290 | 283 | } |
| 291 | 284 | |
| 292 | 285 | template <class _ForwardIterator, class _Predicate> |
| ... | ... | @@ -294,12 +287,9 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 294 | 287 | _ForwardIterator |
| 295 | 288 | stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) |
| 296 | 289 | { |
| 297 | return _VSTD::__stable_partition<typename add_lvalue_reference<_Predicate>::type> | |
| 298 | (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 290 | return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 299 | 291 | } |
| 300 | 292 | |
| 301 | 293 | _LIBCPP_END_NAMESPACE_STD |
| 302 | 294 | |
| 303 | _LIBCPP_POP_MACROS | |
| 304 | ||
| 305 | 295 | #endif // _LIBCPP___ALGORITHM_STABLE_PARTITION_H |
lib/libcxx/include/__algorithm/stable_sort.h+4-9| ... | ... | @@ -9,23 +9,20 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_STABLE_SORT_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_STABLE_SORT_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/comp_ref_type.h> |
| 15 | 14 | #include <__algorithm/inplace_merge.h> |
| 16 | 15 | #include <__algorithm/sort.h> |
| 16 | #include <__config> | |
| 17 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | 18 | #include <__utility/swap.h> |
| 19 | 19 | #include <memory> |
| 20 | #include <type_traits> // swap | |
| 20 | #include <type_traits> | |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | 23 | #pragma GCC system_header |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 27 | |
| 31 | 28 | template <class _Compare, class _InputIterator1, class _InputIterator2> |
| ... | ... | @@ -41,14 +38,14 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1, |
| 41 | 38 | { |
| 42 | 39 | if (__first1 == __last1) |
| 43 | 40 | { |
| 44 | for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr<value_type>()) | |
| 41 | for (; __first2 != __last2; ++__first2, (void) ++__result, __d.template __incr<value_type>()) | |
| 45 | 42 | ::new ((void*)__result) value_type(_VSTD::move(*__first2)); |
| 46 | 43 | __h.release(); |
| 47 | 44 | return; |
| 48 | 45 | } |
| 49 | 46 | if (__first2 == __last2) |
| 50 | 47 | { |
| 51 | for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr<value_type>()) | |
| 48 | for (; __first1 != __last1; ++__first1, (void) ++__result, __d.template __incr<value_type>()) | |
| 52 | 49 | ::new ((void*)__result) value_type(_VSTD::move(*__first1)); |
| 53 | 50 | __h.release(); |
| 54 | 51 | return; |
| ... | ... | @@ -230,6 +227,4 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 230 | 227 | |
| 231 | 228 | _LIBCPP_END_NAMESPACE_STD |
| 232 | 229 | |
| 233 | _LIBCPP_POP_MACROS | |
| 234 | ||
| 235 | 230 | #endif // _LIBCPP___ALGORITHM_STABLE_SORT_H |
lib/libcxx/include/__algorithm/swap_ranges.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _ForwardIterator1, class _ForwardIterator2> |
| ... | ... | @@ -32,6 +29,4 @@ swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardItera |
| 32 | 29 | |
| 33 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 31 | |
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | 32 | #endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H |
lib/libcxx/include/__algorithm/transform.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _InputIterator, class _OutputIterator, class _UnaryOperation> |
| ... | ... | @@ -43,6 +40,4 @@ transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __f |
| 43 | 40 | |
| 44 | 41 | _LIBCPP_END_NAMESPACE_STD |
| 45 | 42 | |
| 46 | _LIBCPP_POP_MACROS | |
| 47 | ||
| 48 | 43 | #endif // _LIBCPP___ALGORITHM_TRANSFORM_H |
lib/libcxx/include/__algorithm/unique.h+3-10| ... | ... | @@ -9,20 +9,16 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_UNIQUE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_UNIQUE_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | #include <__algorithm/comp.h> | |
| 14 | 12 | #include <__algorithm/adjacent_find.h> |
| 13 | #include <__algorithm/comp.h> | |
| 14 | #include <__config> | |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | #include <__utility/move.h> |
| 17 | #include <type_traits> | |
| 18 | 17 | |
| 19 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 19 | #pragma GCC system_header |
| 21 | 20 | #endif |
| 22 | 21 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 23 | |
| 28 | 24 | // unique |
| ... | ... | @@ -31,8 +27,7 @@ template <class _ForwardIterator, class _BinaryPredicate> |
| 31 | 27 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator |
| 32 | 28 | unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) |
| 33 | 29 | { |
| 34 | __first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type> | |
| 35 | (__first, __last, __pred); | |
| 30 | __first = _VSTD::adjacent_find<_ForwardIterator, _BinaryPredicate&>(__first, __last, __pred); | |
| 36 | 31 | if (__first != __last) |
| 37 | 32 | { |
| 38 | 33 | // ... a a ? ... |
| ... | ... | @@ -58,6 +53,4 @@ unique(_ForwardIterator __first, _ForwardIterator __last) |
| 58 | 53 | |
| 59 | 54 | _LIBCPP_END_NAMESPACE_STD |
| 60 | 55 | |
| 61 | _LIBCPP_POP_MACROS | |
| 62 | ||
| 63 | 56 | #endif // _LIBCPP___ALGORITHM_UNIQUE_H |
lib/libcxx/include/__algorithm/unique_copy.h+2-9| ... | ... | @@ -9,19 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_UNIQUE_COPY_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_UNIQUE_COPY_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__config> | |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <utility> |
| 16 | #include <type_traits> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 18 | #pragma GCC system_header |
| 20 | 19 | #endif |
| 21 | 20 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 22 | |
| 27 | 23 | template <class _BinaryPredicate, class _InputIterator, class _OutputIterator> |
| ... | ... | @@ -91,8 +87,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 91 | 87 | _OutputIterator |
| 92 | 88 | unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) |
| 93 | 89 | { |
| 94 | return _VSTD::__unique_copy<typename add_lvalue_reference<_BinaryPredicate>::type> | |
| 95 | (__first, __last, __result, __pred, | |
| 90 | return _VSTD::__unique_copy<_BinaryPredicate&>(__first, __last, __result, __pred, | |
| 96 | 91 | typename iterator_traits<_InputIterator>::iterator_category(), |
| 97 | 92 | typename iterator_traits<_OutputIterator>::iterator_category()); |
| 98 | 93 | } |
| ... | ... | @@ -109,6 +104,4 @@ unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res |
| 109 | 104 | |
| 110 | 105 | _LIBCPP_END_NAMESPACE_STD |
| 111 | 106 | |
| 112 | _LIBCPP_POP_MACROS | |
| 113 | ||
| 114 | 107 | #endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H |
lib/libcxx/include/__algorithm/unwrap_iter.h+3-6| ... | ... | @@ -10,17 +10,14 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_UNWRAP_ITER_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <iterator> | |
| 14 | 13 | #include <__memory/pointer_traits.h> |
| 14 | #include <iterator> | |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | // The job of __unwrap_iter is to lower contiguous iterators (such as |
| ... | ... | @@ -67,12 +64,14 @@ __unwrap_iter(_Iter __i) _NOEXCEPT |
| 67 | 64 | } |
| 68 | 65 | |
| 69 | 66 | template<class _OrigIter> |
| 67 | _LIBCPP_HIDE_FROM_ABI | |
| 70 | 68 | _OrigIter __rewrap_iter(_OrigIter, _OrigIter __result) |
| 71 | 69 | { |
| 72 | 70 | return __result; |
| 73 | 71 | } |
| 74 | 72 | |
| 75 | 73 | template<class _OrigIter, class _UnwrappedIter> |
| 74 | _LIBCPP_HIDE_FROM_ABI | |
| 76 | 75 | _OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result) |
| 77 | 76 | { |
| 78 | 77 | // Precondition: __result is reachable from __first |
| ... | ... | @@ -82,6 +81,4 @@ _OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result) |
| 82 | 81 | |
| 83 | 82 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 83 | |
| 85 | _LIBCPP_POP_MACROS | |
| 86 | ||
| 87 | 84 | #endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H |
lib/libcxx/include/__algorithm/upper_bound.h+2-8| ... | ... | @@ -9,18 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_UPPER_BOUND_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_UPPER_BOUND_H |
| 11 | 11 | |
| 12 | #include <__config> | |
| 13 | 12 | #include <__algorithm/comp.h> |
| 14 | 13 | #include <__algorithm/half_positive.h> |
| 14 | #include <__config> | |
| 15 | 15 | #include <iterator> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _Compare, class _ForwardIterator, class _Tp> |
| ... | ... | @@ -51,8 +48,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 51 | 48 | _ForwardIterator |
| 52 | 49 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) |
| 53 | 50 | { |
| 54 | typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; | |
| 55 | return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp); | |
| 51 | return _VSTD::__upper_bound<_Compare&>(__first, __last, __value_, __comp); | |
| 56 | 52 | } |
| 57 | 53 | |
| 58 | 54 | template <class _ForwardIterator, class _Tp> |
| ... | ... | @@ -67,6 +63,4 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu |
| 67 | 63 | |
| 68 | 64 | _LIBCPP_END_NAMESPACE_STD |
| 69 | 65 | |
| 70 | _LIBCPP_POP_MACROS | |
| 71 | ||
| 72 | 66 | #endif // _LIBCPP___ALGORITHM_UPPER_BOUND_H |
lib/libcxx/include/__availability+13-6| ... | ... | @@ -129,6 +129,10 @@ |
| 129 | 129 | // This controls the availability of std::to_chars. |
| 130 | 130 | # define _LIBCPP_AVAILABILITY_TO_CHARS |
| 131 | 131 | |
| 132 | // This controls the availability of floating-point std::to_chars functions. | |
| 133 | // These overloads were added later than the integer overloads. | |
| 134 | # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT | |
| 135 | ||
| 132 | 136 | // This controls the availability of the C++20 synchronization library, |
| 133 | 137 | // which requires shared library support for various operations |
| 134 | 138 | // (see libcxx/src/atomic.cpp). |
| ... | ... | @@ -139,9 +143,9 @@ |
| 139 | 143 | // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore |
| 140 | 144 | |
| 141 | 145 | // This controls the availability of the C++20 format library. |
| 142 | // The library is in development and not ABI stable yet. Currently | |
| 143 | // P2216 is aiming to be retroactively accepted in C++20. This paper | |
| 144 | // contains ABI breaking changes. | |
| 146 | // The library is in development and not ABI stable yet. P2216 is | |
| 147 | // retroactively accepted in C++20. This paper contains ABI breaking | |
| 148 | // changes. | |
| 145 | 149 | # define _LIBCPP_AVAILABILITY_FORMAT |
| 146 | 150 | // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format |
| 147 | 151 | |
| ... | ... | @@ -222,6 +226,9 @@ |
| 222 | 226 | # define _LIBCPP_AVAILABILITY_TO_CHARS \ |
| 223 | 227 | _LIBCPP_AVAILABILITY_FILESYSTEM |
| 224 | 228 | |
| 229 | # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \ | |
| 230 | __attribute__((unavailable)) | |
| 231 | ||
| 225 | 232 | # define _LIBCPP_AVAILABILITY_SYNC \ |
| 226 | 233 | __attribute__((availability(macosx,strict,introduced=11.0))) \ |
| 227 | 234 | __attribute__((availability(ios,strict,introduced=14.0))) \ |
| ... | ... | @@ -238,9 +245,9 @@ |
| 238 | 245 | # endif |
| 239 | 246 | |
| 240 | 247 | // This controls the availability of the C++20 format library. |
| 241 | // The library is in development and not ABI stable yet. Currently | |
| 242 | // P2216 is aiming to be retroactively accepted in C++20. This paper | |
| 243 | // contains ABI breaking changes. | |
| 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. | |
| 244 | 251 | # define _LIBCPP_AVAILABILITY_FORMAT \ |
| 245 | 252 | __attribute__((unavailable)) |
| 246 | 253 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format |
lib/libcxx/include/__bit/bit_cast.h created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 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___BIT_BIT_CAST_H | |
| 11 | #define _LIBCPP___BIT_BIT_CAST_H | |
| 12 | ||
| 13 | #include <__config> | |
| 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 | #if _LIBCPP_STD_VER > 17 | |
| 23 | ||
| 24 | template<class _ToType, class _FromType, class = enable_if_t< | |
| 25 | sizeof(_ToType) == sizeof(_FromType) && | |
| 26 | is_trivially_copyable_v<_ToType> && | |
| 27 | is_trivially_copyable_v<_FromType> | |
| 28 | >> | |
| 29 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI | |
| 30 | constexpr _ToType bit_cast(_FromType const& __from) noexcept { | |
| 31 | return __builtin_bit_cast(_ToType, __from); | |
| 32 | } | |
| 33 | ||
| 34 | #endif // _LIBCPP_STD_VER > 17 | |
| 35 | ||
| 36 | _LIBCPP_END_NAMESPACE_STD | |
| 37 | ||
| 38 | #endif // _LIBCPP___BIT_BIT_CAST_H |
lib/libcxx/include/__bit/byteswap.h created+55| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___BIT_BYTESWAP_H | |
| 11 | #define _LIBCPP___BIT_BYTESWAP_H | |
| 12 | ||
| 13 | #include <__concepts/arithmetic.h> | |
| 14 | #include <__config> | |
| 15 | #include <cstdint> | |
| 16 | #include <cstdlib> | |
| 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 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | ||
| 26 | template <integral _Tp> | |
| 27 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept { | |
| 28 | ||
| 29 | if constexpr (sizeof(_Tp) == 1) { | |
| 30 | return __val; | |
| 31 | } else if constexpr (sizeof(_Tp) == 2) { | |
| 32 | return __builtin_bswap16(__val); | |
| 33 | } else if constexpr (sizeof(_Tp) == 4) { | |
| 34 | return __builtin_bswap32(__val); | |
| 35 | } else if constexpr (sizeof(_Tp) == 8) { | |
| 36 | return __builtin_bswap64(__val); | |
| 37 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 38 | } else if constexpr (sizeof(_Tp) == 16) { | |
| 39 | #if __has_builtin(__builtin_bswap128) | |
| 40 | return __builtin_bswap128(__val); | |
| 41 | #else | |
| 42 | return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 | | |
| 43 | static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64))); | |
| 44 | #endif // __has_builtin(__builtin_bswap128) | |
| 45 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 46 | } else { | |
| 47 | static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size"); | |
| 48 | } | |
| 49 | } | |
| 50 | ||
| 51 | #endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 52 | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | |
| 54 | ||
| 55 | #endif // _LIBCPP___BIT_BYTESWAP_H |
lib/libcxx/include/__bit_reference+1-1| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___BIT_REFERENCE |
| 11 | 11 | #define _LIBCPP___BIT_REFERENCE |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__bits> |
| 14 | #include <__config> | |
| 15 | 15 | #include <algorithm> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__bsd_locale_defaults.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------- __bsd_locale_defaults.h -----------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/__bsd_locale_fallbacks.h+8-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------- __bsd_locale_fallbacks.h ----------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -30,6 +30,7 @@ decltype(MB_CUR_MAX) __libcpp_mb_cur_max_l(locale_t __l) |
| 30 | 30 | return MB_CUR_MAX; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 33 | 34 | inline _LIBCPP_INLINE_VISIBILITY |
| 34 | 35 | wint_t __libcpp_btowc_l(int __c, locale_t __l) |
| 35 | 36 | { |
| ... | ... | @@ -88,6 +89,7 @@ size_t __libcpp_mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t |
| 88 | 89 | __libcpp_locale_guard __current(__l); |
| 89 | 90 | return mbrlen(__s, __n, __ps); |
| 90 | 91 | } |
| 92 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 91 | 93 | |
| 92 | 94 | inline _LIBCPP_INLINE_VISIBILITY |
| 93 | 95 | lconv *__libcpp_localeconv_l(locale_t __l) |
| ... | ... | @@ -96,6 +98,7 @@ lconv *__libcpp_localeconv_l(locale_t __l) |
| 96 | 98 | return localeconv(); |
| 97 | 99 | } |
| 98 | 100 | |
| 101 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 99 | 102 | inline _LIBCPP_INLINE_VISIBILITY |
| 100 | 103 | size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, |
| 101 | 104 | mbstate_t *__ps, locale_t __l) |
| ... | ... | @@ -103,8 +106,9 @@ size_t __libcpp_mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, |
| 103 | 106 | __libcpp_locale_guard __current(__l); |
| 104 | 107 | return mbsrtowcs(__dest, __src, __len, __ps); |
| 105 | 108 | } |
| 109 | #endif | |
| 106 | 110 | |
| 107 | inline | |
| 111 | inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) | |
| 108 | 112 | int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__format, ...) { |
| 109 | 113 | va_list __va; |
| 110 | 114 | va_start(__va, __format); |
| ... | ... | @@ -114,7 +118,7 @@ int __libcpp_snprintf_l(char *__s, size_t __n, locale_t __l, const char *__forma |
| 114 | 118 | return __res; |
| 115 | 119 | } |
| 116 | 120 | |
| 117 | inline | |
| 121 | inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) | |
| 118 | 122 | int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) { |
| 119 | 123 | va_list __va; |
| 120 | 124 | va_start(__va, __format); |
| ... | ... | @@ -124,7 +128,7 @@ int __libcpp_asprintf_l(char **__s, locale_t __l, const char *__format, ...) { |
| 124 | 128 | return __res; |
| 125 | 129 | } |
| 126 | 130 | |
| 127 | inline | |
| 131 | inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) | |
| 128 | 132 | int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) { |
| 129 | 133 | va_list __va; |
| 130 | 134 | va_start(__va, __format); |
lib/libcxx/include/__charconv/chars_format.h created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 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_CHARS_FORMAT_H | |
| 11 | #define _LIBCPP___CHARCONV_CHARS_FORMAT_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__utility/to_underlying.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | #pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | |
| 23 | ||
| 24 | enum class _LIBCPP_ENUM_VIS chars_format | |
| 25 | { | |
| 26 | scientific = 0x1, | |
| 27 | fixed = 0x2, | |
| 28 | hex = 0x4, | |
| 29 | general = fixed | scientific | |
| 30 | }; | |
| 31 | ||
| 32 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 33 | operator~(chars_format __x) { | |
| 34 | return chars_format(~_VSTD::__to_underlying(__x)); | |
| 35 | } | |
| 36 | ||
| 37 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 38 | operator&(chars_format __x, chars_format __y) { | |
| 39 | return chars_format(_VSTD::__to_underlying(__x) & | |
| 40 | _VSTD::__to_underlying(__y)); | |
| 41 | } | |
| 42 | ||
| 43 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 44 | operator|(chars_format __x, chars_format __y) { | |
| 45 | return chars_format(_VSTD::__to_underlying(__x) | | |
| 46 | _VSTD::__to_underlying(__y)); | |
| 47 | } | |
| 48 | ||
| 49 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 50 | operator^(chars_format __x, chars_format __y) { | |
| 51 | return chars_format(_VSTD::__to_underlying(__x) ^ | |
| 52 | _VSTD::__to_underlying(__y)); | |
| 53 | } | |
| 54 | ||
| 55 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& | |
| 56 | operator&=(chars_format& __x, chars_format __y) { | |
| 57 | __x = __x & __y; | |
| 58 | return __x; | |
| 59 | } | |
| 60 | ||
| 61 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& | |
| 62 | operator|=(chars_format& __x, chars_format __y) { | |
| 63 | __x = __x | __y; | |
| 64 | return __x; | |
| 65 | } | |
| 66 | ||
| 67 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& | |
| 68 | operator^=(chars_format& __x, chars_format __y) { | |
| 69 | __x = __x ^ __y; | |
| 70 | return __x; | |
| 71 | } | |
| 72 | ||
| 73 | #endif // _LIBCPP_CXX03_LANG | |
| 74 | ||
| 75 | _LIBCPP_END_NAMESPACE_STD | |
| 76 | ||
| 77 | #endif // _LIBCPP___CHARCONV_CHARS_FORMAT_H |
lib/libcxx/include/__charconv/from_chars_result.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___CHARCONV_FROM_CHARS_RESULT_H | |
| 11 | #define _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__errc> | |
| 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 | ||
| 24 | struct _LIBCPP_TYPE_VIS from_chars_result | |
| 25 | { | |
| 26 | const char* ptr; | |
| 27 | errc ec; | |
| 28 | # if _LIBCPP_STD_VER > 17 | |
| 29 | _LIBCPP_HIDE_FROM_ABI friend bool operator==(const from_chars_result&, const from_chars_result&) = default; | |
| 30 | # endif | |
| 31 | }; | |
| 32 | ||
| 33 | #endif // _LIBCPP_CXX03_LANG | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___CHARCONV_FROM_CHARS_RESULT_H |
lib/libcxx/include/__charconv/to_chars_result.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___CHARCONV_TO_CHARS_RESULT_H | |
| 11 | #define _LIBCPP___CHARCONV_TO_CHARS_RESULT_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__errc> | |
| 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 | ||
| 24 | struct _LIBCPP_TYPE_VIS to_chars_result | |
| 25 | { | |
| 26 | char* ptr; | |
| 27 | errc ec; | |
| 28 | # if _LIBCPP_STD_VER > 17 | |
| 29 | _LIBCPP_HIDE_FROM_ABI friend bool operator==(const to_chars_result&, const to_chars_result&) = default; | |
| 30 | # endif | |
| 31 | }; | |
| 32 | ||
| 33 | #endif // _LIBCPP_CXX03_LANG | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H |
lib/libcxx/include/__chrono/calendar.h created+1276| ... | ... | @@ -0,0 +1,1276 @@ |
| 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_CALENDAR_H | |
| 11 | #define _LIBCPP___CHRONO_CALENDAR_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/system_clock.h> | |
| 15 | #include <__chrono/time_point.h> | |
| 16 | #include <__config> | |
| 17 | #include <limits> | |
| 18 | #include <ratio> | |
| 19 | #include <type_traits> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | #pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace chrono | |
| 33 | { | |
| 34 | ||
| 35 | struct local_t {}; | |
| 36 | template<class Duration> | |
| 37 | using local_time = time_point<local_t, Duration>; | |
| 38 | using local_seconds = local_time<seconds>; | |
| 39 | using local_days = local_time<days>; | |
| 40 | ||
| 41 | struct last_spec { explicit last_spec() = default; }; | |
| 42 | ||
| 43 | class day { | |
| 44 | private: | |
| 45 | unsigned char __d; | |
| 46 | public: | |
| 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 | ||
| 60 | inline constexpr | |
| 61 | bool operator==(const day& __lhs, const day& __rhs) noexcept | |
| 62 | { return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); } | |
| 63 | ||
| 64 | inline constexpr | |
| 65 | bool operator!=(const day& __lhs, const day& __rhs) noexcept | |
| 66 | { return !(__lhs == __rhs); } | |
| 67 | ||
| 68 | inline constexpr | |
| 69 | bool operator< (const day& __lhs, const day& __rhs) noexcept | |
| 70 | { return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); } | |
| 71 | ||
| 72 | inline constexpr | |
| 73 | bool operator> (const day& __lhs, const day& __rhs) noexcept | |
| 74 | { return __rhs < __lhs; } | |
| 75 | ||
| 76 | inline constexpr | |
| 77 | bool operator<=(const day& __lhs, const day& __rhs) noexcept | |
| 78 | { return !(__rhs < __lhs);} | |
| 79 | ||
| 80 | inline constexpr | |
| 81 | bool operator>=(const day& __lhs, const day& __rhs) noexcept | |
| 82 | { return !(__lhs < __rhs); } | |
| 83 | ||
| 84 | inline constexpr | |
| 85 | day operator+ (const day& __lhs, const days& __rhs) noexcept | |
| 86 | { return day(static_cast<unsigned>(__lhs) + __rhs.count()); } | |
| 87 | ||
| 88 | inline constexpr | |
| 89 | day operator+ (const days& __lhs, const day& __rhs) noexcept | |
| 90 | { return __rhs + __lhs; } | |
| 91 | ||
| 92 | inline constexpr | |
| 93 | day operator- (const day& __lhs, const days& __rhs) noexcept | |
| 94 | { return __lhs + -__rhs; } | |
| 95 | ||
| 96 | inline constexpr | |
| 97 | days 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 | ||
| 101 | inline constexpr day& day::operator+=(const days& __dd) noexcept | |
| 102 | { *this = *this + __dd; return *this; } | |
| 103 | ||
| 104 | inline constexpr day& day::operator-=(const days& __dd) noexcept | |
| 105 | { *this = *this - __dd; return *this; } | |
| 106 | ||
| 107 | ||
| 108 | class month { | |
| 109 | private: | |
| 110 | unsigned char __m; | |
| 111 | public: | |
| 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 | ||
| 125 | inline constexpr | |
| 126 | bool operator==(const month& __lhs, const month& __rhs) noexcept | |
| 127 | { return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); } | |
| 128 | ||
| 129 | inline constexpr | |
| 130 | bool operator!=(const month& __lhs, const month& __rhs) noexcept | |
| 131 | { return !(__lhs == __rhs); } | |
| 132 | ||
| 133 | inline constexpr | |
| 134 | bool operator< (const month& __lhs, const month& __rhs) noexcept | |
| 135 | { return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); } | |
| 136 | ||
| 137 | inline constexpr | |
| 138 | bool operator> (const month& __lhs, const month& __rhs) noexcept | |
| 139 | { return __rhs < __lhs; } | |
| 140 | ||
| 141 | inline constexpr | |
| 142 | bool operator<=(const month& __lhs, const month& __rhs) noexcept | |
| 143 | { return !(__rhs < __lhs); } | |
| 144 | ||
| 145 | inline constexpr | |
| 146 | bool operator>=(const month& __lhs, const month& __rhs) noexcept | |
| 147 | { return !(__lhs < __rhs); } | |
| 148 | ||
| 149 | inline constexpr | |
| 150 | month 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 | ||
| 157 | inline constexpr | |
| 158 | month operator+ (const months& __lhs, const month& __rhs) noexcept | |
| 159 | { return __rhs + __lhs; } | |
| 160 | ||
| 161 | inline constexpr | |
| 162 | month operator- (const month& __lhs, const months& __rhs) noexcept | |
| 163 | { return __lhs + -__rhs; } | |
| 164 | ||
| 165 | inline constexpr | |
| 166 | months 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 | ||
| 172 | inline constexpr month& month::operator+=(const months& __dm) noexcept | |
| 173 | { *this = *this + __dm; return *this; } | |
| 174 | ||
| 175 | inline constexpr month& month::operator-=(const months& __dm) noexcept | |
| 176 | { *this = *this - __dm; return *this; } | |
| 177 | ||
| 178 | ||
| 179 | class year { | |
| 180 | private: | |
| 181 | short __y; | |
| 182 | public: | |
| 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 | ||
| 203 | inline constexpr | |
| 204 | bool operator==(const year& __lhs, const year& __rhs) noexcept | |
| 205 | { return static_cast<int>(__lhs) == static_cast<int>(__rhs); } | |
| 206 | ||
| 207 | inline constexpr | |
| 208 | bool operator!=(const year& __lhs, const year& __rhs) noexcept | |
| 209 | { return !(__lhs == __rhs); } | |
| 210 | ||
| 211 | inline constexpr | |
| 212 | bool operator< (const year& __lhs, const year& __rhs) noexcept | |
| 213 | { return static_cast<int>(__lhs) < static_cast<int>(__rhs); } | |
| 214 | ||
| 215 | inline constexpr | |
| 216 | bool operator> (const year& __lhs, const year& __rhs) noexcept | |
| 217 | { return __rhs < __lhs; } | |
| 218 | ||
| 219 | inline constexpr | |
| 220 | bool operator<=(const year& __lhs, const year& __rhs) noexcept | |
| 221 | { return !(__rhs < __lhs); } | |
| 222 | ||
| 223 | inline constexpr | |
| 224 | bool operator>=(const year& __lhs, const year& __rhs) noexcept | |
| 225 | { return !(__lhs < __rhs); } | |
| 226 | ||
| 227 | inline constexpr | |
| 228 | year operator+ (const year& __lhs, const years& __rhs) noexcept | |
| 229 | { return year(static_cast<int>(__lhs) + __rhs.count()); } | |
| 230 | ||
| 231 | inline constexpr | |
| 232 | year operator+ (const years& __lhs, const year& __rhs) noexcept | |
| 233 | { return __rhs + __lhs; } | |
| 234 | ||
| 235 | inline constexpr | |
| 236 | year operator- (const year& __lhs, const years& __rhs) noexcept | |
| 237 | { return __lhs + -__rhs; } | |
| 238 | ||
| 239 | inline constexpr | |
| 240 | years operator-(const year& __lhs, const year& __rhs) noexcept | |
| 241 | { return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; } | |
| 242 | ||
| 243 | ||
| 244 | inline constexpr year& year::operator+=(const years& __dy) noexcept | |
| 245 | { *this = *this + __dy; return *this; } | |
| 246 | ||
| 247 | inline constexpr year& year::operator-=(const years& __dy) noexcept | |
| 248 | { *this = *this - __dy; return *this; } | |
| 249 | ||
| 250 | inline constexpr bool year::ok() const noexcept | |
| 251 | { return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); } | |
| 252 | ||
| 253 | class weekday_indexed; | |
| 254 | class weekday_last; | |
| 255 | ||
| 256 | class weekday { | |
| 257 | private: | |
| 258 | unsigned char __wd; | |
| 259 | static constexpr unsigned char __weekday_from_days(int __days) noexcept; | |
| 260 | public: | |
| 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 | |
| 283 | inline constexpr | |
| 284 | unsigned 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 | ||
| 291 | inline constexpr | |
| 292 | bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 293 | { return __lhs.c_encoding() == __rhs.c_encoding(); } | |
| 294 | ||
| 295 | inline constexpr | |
| 296 | bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 297 | { return !(__lhs == __rhs); } | |
| 298 | ||
| 299 | inline constexpr | |
| 300 | bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept | |
| 301 | { return __lhs.c_encoding() < __rhs.c_encoding(); } | |
| 302 | ||
| 303 | inline constexpr | |
| 304 | bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept | |
| 305 | { return __rhs < __lhs; } | |
| 306 | ||
| 307 | inline constexpr | |
| 308 | bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 309 | { return !(__rhs < __lhs);} | |
| 310 | ||
| 311 | inline constexpr | |
| 312 | bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 313 | { return !(__lhs < __rhs); } | |
| 314 | ||
| 315 | constexpr 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 | ||
| 322 | constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept | |
| 323 | { return __rhs + __lhs; } | |
| 324 | ||
| 325 | constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept | |
| 326 | { return __lhs + -__rhs; } | |
| 327 | ||
| 328 | constexpr 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 | ||
| 335 | inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept | |
| 336 | { *this = *this + __dd; return *this; } | |
| 337 | ||
| 338 | inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept | |
| 339 | { *this = *this - __dd; return *this; } | |
| 340 | ||
| 341 | ||
| 342 | class weekday_indexed { | |
| 343 | private: | |
| 344 | chrono::weekday __wd; | |
| 345 | unsigned char __idx; | |
| 346 | public: | |
| 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 | ||
| 355 | inline constexpr | |
| 356 | bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept | |
| 357 | { return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); } | |
| 358 | ||
| 359 | inline constexpr | |
| 360 | bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept | |
| 361 | { return !(__lhs == __rhs); } | |
| 362 | ||
| 363 | ||
| 364 | class weekday_last { | |
| 365 | private: | |
| 366 | chrono::weekday __wd; | |
| 367 | public: | |
| 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 | ||
| 374 | inline constexpr | |
| 375 | bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept | |
| 376 | { return __lhs.weekday() == __rhs.weekday(); } | |
| 377 | ||
| 378 | inline constexpr | |
| 379 | bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept | |
| 380 | { return !(__lhs == __rhs); } | |
| 381 | ||
| 382 | inline constexpr | |
| 383 | weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; } | |
| 384 | ||
| 385 | inline constexpr | |
| 386 | weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; } | |
| 387 | ||
| 388 | ||
| 389 | inline constexpr last_spec last{}; | |
| 390 | inline constexpr weekday Sunday{0}; | |
| 391 | inline constexpr weekday Monday{1}; | |
| 392 | inline constexpr weekday Tuesday{2}; | |
| 393 | inline constexpr weekday Wednesday{3}; | |
| 394 | inline constexpr weekday Thursday{4}; | |
| 395 | inline constexpr weekday Friday{5}; | |
| 396 | inline constexpr weekday Saturday{6}; | |
| 397 | ||
| 398 | inline constexpr month January{1}; | |
| 399 | inline constexpr month February{2}; | |
| 400 | inline constexpr month March{3}; | |
| 401 | inline constexpr month April{4}; | |
| 402 | inline constexpr month May{5}; | |
| 403 | inline constexpr month June{6}; | |
| 404 | inline constexpr month July{7}; | |
| 405 | inline constexpr month August{8}; | |
| 406 | inline constexpr month September{9}; | |
| 407 | inline constexpr month October{10}; | |
| 408 | inline constexpr month November{11}; | |
| 409 | inline constexpr month December{12}; | |
| 410 | ||
| 411 | ||
| 412 | class month_day { | |
| 413 | private: | |
| 414 | chrono::month __m; | |
| 415 | chrono::day __d; | |
| 416 | public: | |
| 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 | ||
| 425 | inline constexpr | |
| 426 | bool 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 | ||
| 440 | inline constexpr | |
| 441 | bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 442 | { return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } | |
| 443 | ||
| 444 | inline constexpr | |
| 445 | bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 446 | { return !(__lhs == __rhs); } | |
| 447 | ||
| 448 | inline constexpr | |
| 449 | month_day operator/(const month& __lhs, const day& __rhs) noexcept | |
| 450 | { return month_day{__lhs, __rhs}; } | |
| 451 | ||
| 452 | constexpr | |
| 453 | month_day operator/(const day& __lhs, const month& __rhs) noexcept | |
| 454 | { return __rhs / __lhs; } | |
| 455 | ||
| 456 | inline constexpr | |
| 457 | month_day operator/(const month& __lhs, int __rhs) noexcept | |
| 458 | { return __lhs / day(__rhs); } | |
| 459 | ||
| 460 | constexpr | |
| 461 | month_day operator/(int __lhs, const day& __rhs) noexcept | |
| 462 | { return month(__lhs) / __rhs; } | |
| 463 | ||
| 464 | constexpr | |
| 465 | month_day operator/(const day& __lhs, int __rhs) noexcept | |
| 466 | { return month(__rhs) / __lhs; } | |
| 467 | ||
| 468 | ||
| 469 | inline constexpr | |
| 470 | bool 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 | ||
| 473 | inline constexpr | |
| 474 | bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept | |
| 475 | { return __rhs < __lhs; } | |
| 476 | ||
| 477 | inline constexpr | |
| 478 | bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 479 | { return !(__rhs < __lhs);} | |
| 480 | ||
| 481 | inline constexpr | |
| 482 | bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 483 | { return !(__lhs < __rhs); } | |
| 484 | ||
| 485 | ||
| 486 | ||
| 487 | class month_day_last { | |
| 488 | private: | |
| 489 | chrono::month __m; | |
| 490 | public: | |
| 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 | ||
| 497 | inline constexpr | |
| 498 | bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 499 | { return __lhs.month() == __rhs.month(); } | |
| 500 | ||
| 501 | inline constexpr | |
| 502 | bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 503 | { return !(__lhs == __rhs); } | |
| 504 | ||
| 505 | inline constexpr | |
| 506 | bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 507 | { return __lhs.month() < __rhs.month(); } | |
| 508 | ||
| 509 | inline constexpr | |
| 510 | bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 511 | { return __rhs < __lhs; } | |
| 512 | ||
| 513 | inline constexpr | |
| 514 | bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 515 | { return !(__rhs < __lhs);} | |
| 516 | ||
| 517 | inline constexpr | |
| 518 | bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 519 | { return !(__lhs < __rhs); } | |
| 520 | ||
| 521 | inline constexpr | |
| 522 | month_day_last operator/(const month& __lhs, last_spec) noexcept | |
| 523 | { return month_day_last{__lhs}; } | |
| 524 | ||
| 525 | inline constexpr | |
| 526 | month_day_last operator/(last_spec, const month& __rhs) noexcept | |
| 527 | { return month_day_last{__rhs}; } | |
| 528 | ||
| 529 | inline constexpr | |
| 530 | month_day_last operator/(int __lhs, last_spec) noexcept | |
| 531 | { return month_day_last{month(__lhs)}; } | |
| 532 | ||
| 533 | inline constexpr | |
| 534 | month_day_last operator/(last_spec, int __rhs) noexcept | |
| 535 | { return month_day_last{month(__rhs)}; } | |
| 536 | ||
| 537 | ||
| 538 | class month_weekday { | |
| 539 | private: | |
| 540 | chrono::month __m; | |
| 541 | chrono::weekday_indexed __wdi; | |
| 542 | public: | |
| 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 | ||
| 550 | inline constexpr | |
| 551 | bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept | |
| 552 | { return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } | |
| 553 | ||
| 554 | inline constexpr | |
| 555 | bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept | |
| 556 | { return !(__lhs == __rhs); } | |
| 557 | ||
| 558 | inline constexpr | |
| 559 | month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept | |
| 560 | { return month_weekday{__lhs, __rhs}; } | |
| 561 | ||
| 562 | inline constexpr | |
| 563 | month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept | |
| 564 | { return month_weekday{month(__lhs), __rhs}; } | |
| 565 | ||
| 566 | inline constexpr | |
| 567 | month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept | |
| 568 | { return month_weekday{__rhs, __lhs}; } | |
| 569 | ||
| 570 | inline constexpr | |
| 571 | month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept | |
| 572 | { return month_weekday{month(__rhs), __lhs}; } | |
| 573 | ||
| 574 | ||
| 575 | class 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 | ||
| 586 | inline constexpr | |
| 587 | bool 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 | ||
| 590 | inline constexpr | |
| 591 | bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept | |
| 592 | { return !(__lhs == __rhs); } | |
| 593 | ||
| 594 | ||
| 595 | inline constexpr | |
| 596 | month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept | |
| 597 | { return month_weekday_last{__lhs, __rhs}; } | |
| 598 | ||
| 599 | inline constexpr | |
| 600 | month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept | |
| 601 | { return month_weekday_last{month(__lhs), __rhs}; } | |
| 602 | ||
| 603 | inline constexpr | |
| 604 | month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept | |
| 605 | { return month_weekday_last{__rhs, __lhs}; } | |
| 606 | ||
| 607 | inline constexpr | |
| 608 | month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept | |
| 609 | { return month_weekday_last{month(__rhs), __lhs}; } | |
| 610 | ||
| 611 | ||
| 612 | class year_month { | |
| 613 | chrono::year __y; | |
| 614 | chrono::month __m; | |
| 615 | public: | |
| 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 | ||
| 628 | inline constexpr | |
| 629 | year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; } | |
| 630 | ||
| 631 | inline constexpr | |
| 632 | year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; } | |
| 633 | ||
| 634 | inline constexpr | |
| 635 | bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 636 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); } | |
| 637 | ||
| 638 | inline constexpr | |
| 639 | bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 640 | { return !(__lhs == __rhs); } | |
| 641 | ||
| 642 | inline constexpr | |
| 643 | bool 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 | ||
| 646 | inline constexpr | |
| 647 | bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept | |
| 648 | { return __rhs < __lhs; } | |
| 649 | ||
| 650 | inline constexpr | |
| 651 | bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 652 | { return !(__rhs < __lhs);} | |
| 653 | ||
| 654 | inline constexpr | |
| 655 | bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 656 | { return !(__lhs < __rhs); } | |
| 657 | ||
| 658 | constexpr 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 | ||
| 666 | constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept | |
| 667 | { return __rhs + __lhs; } | |
| 668 | ||
| 669 | constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept | |
| 670 | { return (__lhs.year() + __rhs) / __lhs.month(); } | |
| 671 | ||
| 672 | constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept | |
| 673 | { return __rhs + __lhs; } | |
| 674 | ||
| 675 | constexpr 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 | ||
| 678 | constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept | |
| 679 | { return __lhs + -__rhs; } | |
| 680 | ||
| 681 | constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept | |
| 682 | { return __lhs + -__rhs; } | |
| 683 | ||
| 684 | class year_month_day_last; | |
| 685 | ||
| 686 | class year_month_day { | |
| 687 | private: | |
| 688 | chrono::year __y; | |
| 689 | chrono::month __m; | |
| 690 | chrono::day __d; | |
| 691 | public: | |
| 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 | |
| 721 | inline constexpr | |
| 722 | year_month_day | |
| 723 | year_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 | |
| 740 | inline 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 | ||
| 756 | inline constexpr | |
| 757 | bool 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 | ||
| 760 | inline constexpr | |
| 761 | bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 762 | { return !(__lhs == __rhs); } | |
| 763 | ||
| 764 | inline constexpr | |
| 765 | bool 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 | ||
| 774 | inline constexpr | |
| 775 | bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 776 | { return __rhs < __lhs; } | |
| 777 | ||
| 778 | inline constexpr | |
| 779 | bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 780 | { return !(__rhs < __lhs);} | |
| 781 | ||
| 782 | inline constexpr | |
| 783 | bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 784 | { return !(__lhs < __rhs); } | |
| 785 | ||
| 786 | inline constexpr | |
| 787 | year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept | |
| 788 | { return year_month_day{__lhs.year(), __lhs.month(), __rhs}; } | |
| 789 | ||
| 790 | inline constexpr | |
| 791 | year_month_day operator/(const year_month& __lhs, int __rhs) noexcept | |
| 792 | { return __lhs / day(__rhs); } | |
| 793 | ||
| 794 | inline constexpr | |
| 795 | year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept | |
| 796 | { return __lhs / __rhs.month() / __rhs.day(); } | |
| 797 | ||
| 798 | inline constexpr | |
| 799 | year_month_day operator/(int __lhs, const month_day& __rhs) noexcept | |
| 800 | { return year(__lhs) / __rhs; } | |
| 801 | ||
| 802 | inline constexpr | |
| 803 | year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept | |
| 804 | { return __rhs / __lhs; } | |
| 805 | ||
| 806 | inline constexpr | |
| 807 | year_month_day operator/(const month_day& __lhs, int __rhs) noexcept | |
| 808 | { return year(__rhs) / __lhs; } | |
| 809 | ||
| 810 | ||
| 811 | inline constexpr | |
| 812 | year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept | |
| 813 | { return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); } | |
| 814 | ||
| 815 | inline constexpr | |
| 816 | year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept | |
| 817 | { return __rhs + __lhs; } | |
| 818 | ||
| 819 | inline constexpr | |
| 820 | year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept | |
| 821 | { return __lhs + -__rhs; } | |
| 822 | ||
| 823 | inline constexpr | |
| 824 | year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept | |
| 825 | { return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); } | |
| 826 | ||
| 827 | inline constexpr | |
| 828 | year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept | |
| 829 | { return __rhs + __lhs; } | |
| 830 | ||
| 831 | inline constexpr | |
| 832 | year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept | |
| 833 | { return __lhs + -__rhs; } | |
| 834 | ||
| 835 | inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 836 | inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 837 | inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 838 | inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 839 | ||
| 840 | class year_month_day_last { | |
| 841 | private: | |
| 842 | chrono::year __y; | |
| 843 | chrono::month_day_last __mdl; | |
| 844 | public: | |
| 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 | ||
| 862 | inline constexpr | |
| 863 | chrono::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 | ||
| 876 | inline constexpr | |
| 877 | bool 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 | ||
| 880 | inline constexpr | |
| 881 | bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 882 | { return !(__lhs == __rhs); } | |
| 883 | ||
| 884 | inline constexpr | |
| 885 | bool 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 | ||
| 892 | inline constexpr | |
| 893 | bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 894 | { return __rhs < __lhs; } | |
| 895 | ||
| 896 | inline constexpr | |
| 897 | bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 898 | { return !(__rhs < __lhs);} | |
| 899 | ||
| 900 | inline constexpr | |
| 901 | bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 902 | { return !(__lhs < __rhs); } | |
| 903 | ||
| 904 | inline 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 | ||
| 907 | inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept | |
| 908 | { return year_month_day_last{__lhs, __rhs}; } | |
| 909 | ||
| 910 | inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept | |
| 911 | { return year_month_day_last{year{__lhs}, __rhs}; } | |
| 912 | ||
| 913 | inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept | |
| 914 | { return __rhs / __lhs; } | |
| 915 | ||
| 916 | inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept | |
| 917 | { return year{__rhs} / __lhs; } | |
| 918 | ||
| 919 | ||
| 920 | inline constexpr | |
| 921 | year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept | |
| 922 | { return (__lhs.year() / __lhs.month() + __rhs) / last; } | |
| 923 | ||
| 924 | inline constexpr | |
| 925 | year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept | |
| 926 | { return __rhs + __lhs; } | |
| 927 | ||
| 928 | inline constexpr | |
| 929 | year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept | |
| 930 | { return __lhs + (-__rhs); } | |
| 931 | ||
| 932 | inline constexpr | |
| 933 | year_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 | ||
| 936 | inline constexpr | |
| 937 | year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept | |
| 938 | { return __rhs + __lhs; } | |
| 939 | ||
| 940 | inline constexpr | |
| 941 | year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept | |
| 942 | { return __lhs + (-__rhs); } | |
| 943 | ||
| 944 | inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 945 | inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 946 | inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 947 | inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 948 | ||
| 949 | inline 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 | ||
| 952 | inline 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 | ||
| 958 | class year_month_weekday { | |
| 959 | chrono::year __y; | |
| 960 | chrono::month __m; | |
| 961 | chrono::weekday_indexed __wdi; | |
| 962 | public: | |
| 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 | ||
| 1000 | inline constexpr | |
| 1001 | year_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 | ||
| 1010 | inline constexpr | |
| 1011 | days 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 | ||
| 1018 | inline constexpr | |
| 1019 | bool 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 | ||
| 1022 | inline constexpr | |
| 1023 | bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept | |
| 1024 | { return !(__lhs == __rhs); } | |
| 1025 | ||
| 1026 | inline constexpr | |
| 1027 | year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept | |
| 1028 | { return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; } | |
| 1029 | ||
| 1030 | inline constexpr | |
| 1031 | year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept | |
| 1032 | { return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; } | |
| 1033 | ||
| 1034 | inline constexpr | |
| 1035 | year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept | |
| 1036 | { return year(__lhs) / __rhs; } | |
| 1037 | ||
| 1038 | inline constexpr | |
| 1039 | year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept | |
| 1040 | { return __rhs / __lhs; } | |
| 1041 | ||
| 1042 | inline constexpr | |
| 1043 | year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept | |
| 1044 | { return year(__rhs) / __lhs; } | |
| 1045 | ||
| 1046 | ||
| 1047 | inline constexpr | |
| 1048 | year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept | |
| 1049 | { return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); } | |
| 1050 | ||
| 1051 | inline constexpr | |
| 1052 | year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept | |
| 1053 | { return __rhs + __lhs; } | |
| 1054 | ||
| 1055 | inline constexpr | |
| 1056 | year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept | |
| 1057 | { return __lhs + (-__rhs); } | |
| 1058 | ||
| 1059 | inline constexpr | |
| 1060 | year_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 | ||
| 1063 | inline constexpr | |
| 1064 | year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept | |
| 1065 | { return __rhs + __lhs; } | |
| 1066 | ||
| 1067 | inline constexpr | |
| 1068 | year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept | |
| 1069 | { return __lhs + (-__rhs); } | |
| 1070 | ||
| 1071 | ||
| 1072 | inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 1073 | inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 1074 | inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 1075 | inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 1076 | ||
| 1077 | class year_month_weekday_last { | |
| 1078 | private: | |
| 1079 | chrono::year __y; | |
| 1080 | chrono::month __m; | |
| 1081 | chrono::weekday_last __wdl; | |
| 1082 | public: | |
| 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 | ||
| 1103 | inline constexpr | |
| 1104 | days 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 | ||
| 1111 | inline constexpr | |
| 1112 | bool 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 | ||
| 1115 | inline constexpr | |
| 1116 | bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 1117 | { return !(__lhs == __rhs); } | |
| 1118 | ||
| 1119 | ||
| 1120 | inline constexpr | |
| 1121 | year_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 | ||
| 1124 | inline constexpr | |
| 1125 | year_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 | ||
| 1128 | inline constexpr | |
| 1129 | year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept | |
| 1130 | { return year(__lhs) / __rhs; } | |
| 1131 | ||
| 1132 | inline constexpr | |
| 1133 | year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept | |
| 1134 | { return __rhs / __lhs; } | |
| 1135 | ||
| 1136 | inline constexpr | |
| 1137 | year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept | |
| 1138 | { return year(__rhs) / __lhs; } | |
| 1139 | ||
| 1140 | ||
| 1141 | inline constexpr | |
| 1142 | year_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 | ||
| 1145 | inline constexpr | |
| 1146 | year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 1147 | { return __rhs + __lhs; } | |
| 1148 | ||
| 1149 | inline constexpr | |
| 1150 | year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept | |
| 1151 | { return __lhs + (-__rhs); } | |
| 1152 | ||
| 1153 | inline constexpr | |
| 1154 | year_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 | ||
| 1157 | inline constexpr | |
| 1158 | year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 1159 | { return __rhs + __lhs; } | |
| 1160 | ||
| 1161 | inline constexpr | |
| 1162 | year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept | |
| 1163 | { return __lhs + (-__rhs); } | |
| 1164 | ||
| 1165 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 1166 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 1167 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 1168 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 1169 | ||
| 1170 | ||
| 1171 | template <class _Duration> | |
| 1172 | class hh_mm_ss | |
| 1173 | { | |
| 1174 | private: | |
| 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 | ||
| 1193 | public: | |
| 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 | ||
| 1222 | private: | |
| 1223 | bool __is_neg; | |
| 1224 | chrono::hours __h; | |
| 1225 | chrono::minutes __m; | |
| 1226 | chrono::seconds __s; | |
| 1227 | precision __f; | |
| 1228 | }; | |
| 1229 | ||
| 1230 | constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); } | |
| 1231 | constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); } | |
| 1232 | ||
| 1233 | constexpr 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 | ||
| 1240 | constexpr 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 | ||
| 1250 | inline 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 | ||
| 1266 | namespace chrono { // hoist the literals into namespace std::chrono | |
| 1267 | using namespace literals::chrono_literals; | |
| 1268 | } // namespace chrono | |
| 1269 | ||
| 1270 | _LIBCPP_END_NAMESPACE_STD | |
| 1271 | ||
| 1272 | #endif // _LIBCPP_STD_VER > 17 | |
| 1273 | ||
| 1274 | _LIBCPP_POP_MACROS | |
| 1275 | ||
| 1276 | #endif // _LIBCPP___CHRONO_CALENDAR_H |
lib/libcxx/include/__chrono/convert_to_timespec.h created+55| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H | |
| 10 | #define _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H | |
| 11 | ||
| 12 | #include <__chrono/duration.h> | |
| 13 | #include <__config> | |
| 14 | #include <limits> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | #pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | // Convert a nanoseconds duration to the given TimeSpec type, which must have | |
| 26 | // the same properties as std::timespec. | |
| 27 | template <class _TimeSpec> | |
| 28 | _LIBCPP_HIDE_FROM_ABI inline | |
| 29 | _TimeSpec __convert_to_timespec(const chrono::nanoseconds& __ns) | |
| 30 | { | |
| 31 | using namespace chrono; | |
| 32 | seconds __s = duration_cast<seconds>(__ns); | |
| 33 | _TimeSpec __ts; | |
| 34 | typedef decltype(__ts.tv_sec) __ts_sec; | |
| 35 | const __ts_sec __ts_sec_max = numeric_limits<__ts_sec>::max(); | |
| 36 | ||
| 37 | if (__s.count() < __ts_sec_max) | |
| 38 | { | |
| 39 | __ts.tv_sec = static_cast<__ts_sec>(__s.count()); | |
| 40 | __ts.tv_nsec = static_cast<decltype(__ts.tv_nsec)>((__ns - __s).count()); | |
| 41 | } | |
| 42 | else | |
| 43 | { | |
| 44 | __ts.tv_sec = __ts_sec_max; | |
| 45 | __ts.tv_nsec = 999999999; // (10^9 - 1) | |
| 46 | } | |
| 47 | ||
| 48 | return __ts; | |
| 49 | } | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | _LIBCPP_POP_MACROS | |
| 54 | ||
| 55 | #endif // _LIBCPP___CHRONO_CONVERT_TO_TIMESPEC_H |
lib/libcxx/include/__chrono/duration.h created+615| ... | ... | @@ -0,0 +1,615 @@ |
| 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_DURATION_H | |
| 11 | #define _LIBCPP___CHRONO_DURATION_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <limits> | |
| 15 | #include <ratio> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | namespace chrono | |
| 28 | { | |
| 29 | ||
| 30 | template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration; | |
| 31 | ||
| 32 | template <class _Tp> | |
| 33 | struct __is_duration : false_type {}; | |
| 34 | ||
| 35 | template <class _Rep, class _Period> | |
| 36 | struct __is_duration<duration<_Rep, _Period> > : true_type {}; | |
| 37 | ||
| 38 | template <class _Rep, class _Period> | |
| 39 | struct __is_duration<const duration<_Rep, _Period> > : true_type {}; | |
| 40 | ||
| 41 | template <class _Rep, class _Period> | |
| 42 | struct __is_duration<volatile duration<_Rep, _Period> > : true_type {}; | |
| 43 | ||
| 44 | template <class _Rep, class _Period> | |
| 45 | struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; | |
| 46 | ||
| 47 | } // namespace chrono | |
| 48 | ||
| 49 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 50 | struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, | |
| 51 | chrono::duration<_Rep2, _Period2> > | |
| 52 | { | |
| 53 | typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, | |
| 54 | typename __ratio_gcd<_Period1, _Period2>::type> type; | |
| 55 | }; | |
| 56 | ||
| 57 | namespace chrono { | |
| 58 | ||
| 59 | // duration_cast | |
| 60 | ||
| 61 | template <class _FromDuration, class _ToDuration, | |
| 62 | class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type, | |
| 63 | bool = _Period::num == 1, | |
| 64 | bool = _Period::den == 1> | |
| 65 | struct __duration_cast; | |
| 66 | ||
| 67 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 68 | struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> | |
| 69 | { | |
| 70 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 71 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 72 | { | |
| 73 | return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count())); | |
| 74 | } | |
| 75 | }; | |
| 76 | ||
| 77 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 78 | struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> | |
| 79 | { | |
| 80 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 81 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 82 | { | |
| 83 | typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; | |
| 84 | return _ToDuration(static_cast<typename _ToDuration::rep>( | |
| 85 | static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); | |
| 86 | } | |
| 87 | }; | |
| 88 | ||
| 89 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 90 | struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> | |
| 91 | { | |
| 92 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 93 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 94 | { | |
| 95 | typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; | |
| 96 | return _ToDuration(static_cast<typename _ToDuration::rep>( | |
| 97 | static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); | |
| 98 | } | |
| 99 | }; | |
| 100 | ||
| 101 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 102 | struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> | |
| 103 | { | |
| 104 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 105 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 106 | { | |
| 107 | typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; | |
| 108 | return _ToDuration(static_cast<typename _ToDuration::rep>( | |
| 109 | static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) | |
| 110 | / static_cast<_Ct>(_Period::den))); | |
| 111 | } | |
| 112 | }; | |
| 113 | ||
| 114 | template <class _ToDuration, class _Rep, class _Period> | |
| 115 | inline _LIBCPP_INLINE_VISIBILITY | |
| 116 | _LIBCPP_CONSTEXPR | |
| 117 | typename enable_if | |
| 118 | < | |
| 119 | __is_duration<_ToDuration>::value, | |
| 120 | _ToDuration | |
| 121 | >::type | |
| 122 | duration_cast(const duration<_Rep, _Period>& __fd) | |
| 123 | { | |
| 124 | return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); | |
| 125 | } | |
| 126 | ||
| 127 | template <class _Rep> | |
| 128 | struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; | |
| 129 | ||
| 130 | #if _LIBCPP_STD_VER > 14 | |
| 131 | template <class _Rep> | |
| 132 | inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>::value; | |
| 133 | #endif | |
| 134 | ||
| 135 | template <class _Rep> | |
| 136 | struct _LIBCPP_TEMPLATE_VIS duration_values | |
| 137 | { | |
| 138 | public: | |
| 139 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);} | |
| 140 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();} | |
| 141 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();} | |
| 142 | }; | |
| 143 | ||
| 144 | #if _LIBCPP_STD_VER > 14 | |
| 145 | template <class _ToDuration, class _Rep, class _Period> | |
| 146 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 147 | typename enable_if | |
| 148 | < | |
| 149 | __is_duration<_ToDuration>::value, | |
| 150 | _ToDuration | |
| 151 | >::type | |
| 152 | floor(const duration<_Rep, _Period>& __d) | |
| 153 | { | |
| 154 | _ToDuration __t = duration_cast<_ToDuration>(__d); | |
| 155 | if (__t > __d) | |
| 156 | __t = __t - _ToDuration{1}; | |
| 157 | return __t; | |
| 158 | } | |
| 159 | ||
| 160 | template <class _ToDuration, class _Rep, class _Period> | |
| 161 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 162 | typename enable_if | |
| 163 | < | |
| 164 | __is_duration<_ToDuration>::value, | |
| 165 | _ToDuration | |
| 166 | >::type | |
| 167 | ceil(const duration<_Rep, _Period>& __d) | |
| 168 | { | |
| 169 | _ToDuration __t = duration_cast<_ToDuration>(__d); | |
| 170 | if (__t < __d) | |
| 171 | __t = __t + _ToDuration{1}; | |
| 172 | return __t; | |
| 173 | } | |
| 174 | ||
| 175 | template <class _ToDuration, class _Rep, class _Period> | |
| 176 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 177 | typename enable_if | |
| 178 | < | |
| 179 | __is_duration<_ToDuration>::value, | |
| 180 | _ToDuration | |
| 181 | >::type | |
| 182 | round(const duration<_Rep, _Period>& __d) | |
| 183 | { | |
| 184 | _ToDuration __lower = floor<_ToDuration>(__d); | |
| 185 | _ToDuration __upper = __lower + _ToDuration{1}; | |
| 186 | auto __lowerDiff = __d - __lower; | |
| 187 | auto __upperDiff = __upper - __d; | |
| 188 | if (__lowerDiff < __upperDiff) | |
| 189 | return __lower; | |
| 190 | if (__lowerDiff > __upperDiff) | |
| 191 | return __upper; | |
| 192 | return __lower.count() & 1 ? __upper : __lower; | |
| 193 | } | |
| 194 | #endif | |
| 195 | ||
| 196 | // duration | |
| 197 | ||
| 198 | template <class _Rep, class _Period> | |
| 199 | class _LIBCPP_TEMPLATE_VIS duration | |
| 200 | { | |
| 201 | static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); | |
| 202 | static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); | |
| 203 | static_assert(_Period::num > 0, "duration period must be positive"); | |
| 204 | ||
| 205 | template <class _R1, class _R2> | |
| 206 | struct __no_overflow | |
| 207 | { | |
| 208 | private: | |
| 209 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | |
| 210 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | |
| 211 | static const intmax_t __n1 = _R1::num / __gcd_n1_n2; | |
| 212 | static const intmax_t __d1 = _R1::den / __gcd_d1_d2; | |
| 213 | static const intmax_t __n2 = _R2::num / __gcd_n1_n2; | |
| 214 | static const intmax_t __d2 = _R2::den / __gcd_d1_d2; | |
| 215 | static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); | |
| 216 | ||
| 217 | template <intmax_t _Xp, intmax_t _Yp, bool __overflow> | |
| 218 | struct __mul // __overflow == false | |
| 219 | { | |
| 220 | static const intmax_t value = _Xp * _Yp; | |
| 221 | }; | |
| 222 | ||
| 223 | template <intmax_t _Xp, intmax_t _Yp> | |
| 224 | struct __mul<_Xp, _Yp, true> | |
| 225 | { | |
| 226 | static const intmax_t value = 1; | |
| 227 | }; | |
| 228 | ||
| 229 | public: | |
| 230 | static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); | |
| 231 | typedef ratio<__mul<__n1, __d2, !value>::value, | |
| 232 | __mul<__n2, __d1, !value>::value> type; | |
| 233 | }; | |
| 234 | ||
| 235 | public: | |
| 236 | typedef _Rep rep; | |
| 237 | typedef typename _Period::type period; | |
| 238 | private: | |
| 239 | rep __rep_; | |
| 240 | public: | |
| 241 | ||
| 242 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 243 | #ifndef _LIBCPP_CXX03_LANG | |
| 244 | duration() = default; | |
| 245 | #else | |
| 246 | duration() {} | |
| 247 | #endif | |
| 248 | ||
| 249 | template <class _Rep2> | |
| 250 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 251 | explicit duration(const _Rep2& __r, | |
| 252 | typename enable_if | |
| 253 | < | |
| 254 | is_convertible<const _Rep2&, rep>::value && | |
| 255 | (treat_as_floating_point<rep>::value || | |
| 256 | !treat_as_floating_point<_Rep2>::value) | |
| 257 | >::type* = nullptr) | |
| 258 | : __rep_(__r) {} | |
| 259 | ||
| 260 | // conversions | |
| 261 | template <class _Rep2, class _Period2> | |
| 262 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 263 | duration(const duration<_Rep2, _Period2>& __d, | |
| 264 | typename enable_if | |
| 265 | < | |
| 266 | __no_overflow<_Period2, period>::value && ( | |
| 267 | treat_as_floating_point<rep>::value || | |
| 268 | (__no_overflow<_Period2, period>::type::den == 1 && | |
| 269 | !treat_as_floating_point<_Rep2>::value)) | |
| 270 | >::type* = nullptr) | |
| 271 | : __rep_(chrono::duration_cast<duration>(__d).count()) {} | |
| 272 | ||
| 273 | // observer | |
| 274 | ||
| 275 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} | |
| 276 | ||
| 277 | // arithmetic | |
| 278 | ||
| 279 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} | |
| 280 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);} | |
| 281 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;} | |
| 282 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);} | |
| 283 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;} | |
| 284 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);} | |
| 285 | ||
| 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;} | |
| 288 | ||
| 289 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} | |
| 290 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} | |
| 291 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} | |
| 292 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} | |
| 293 | ||
| 294 | // special values | |
| 295 | ||
| 296 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());} | |
| 297 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values<rep>::min());} | |
| 298 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values<rep>::max());} | |
| 299 | }; | |
| 300 | ||
| 301 | typedef duration<long long, nano> nanoseconds; | |
| 302 | typedef duration<long long, micro> microseconds; | |
| 303 | typedef duration<long long, milli> milliseconds; | |
| 304 | typedef duration<long long > seconds; | |
| 305 | typedef duration< long, ratio< 60> > minutes; | |
| 306 | typedef duration< long, ratio<3600> > hours; | |
| 307 | #if _LIBCPP_STD_VER > 17 | |
| 308 | typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days; | |
| 309 | typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks; | |
| 310 | typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years; | |
| 311 | typedef duration< int, ratio_divide<years::period, ratio<12>>> months; | |
| 312 | #endif | |
| 313 | // Duration == | |
| 314 | ||
| 315 | template <class _LhsDuration, class _RhsDuration> | |
| 316 | struct __duration_eq | |
| 317 | { | |
| 318 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 319 | bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const | |
| 320 | { | |
| 321 | typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; | |
| 322 | return _Ct(__lhs).count() == _Ct(__rhs).count(); | |
| 323 | } | |
| 324 | }; | |
| 325 | ||
| 326 | template <class _LhsDuration> | |
| 327 | struct __duration_eq<_LhsDuration, _LhsDuration> | |
| 328 | { | |
| 329 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 330 | bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const | |
| 331 | {return __lhs.count() == __rhs.count();} | |
| 332 | }; | |
| 333 | ||
| 334 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 335 | inline _LIBCPP_INLINE_VISIBILITY | |
| 336 | _LIBCPP_CONSTEXPR | |
| 337 | bool | |
| 338 | operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 339 | { | |
| 340 | return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); | |
| 341 | } | |
| 342 | ||
| 343 | // Duration != | |
| 344 | ||
| 345 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 346 | inline _LIBCPP_INLINE_VISIBILITY | |
| 347 | _LIBCPP_CONSTEXPR | |
| 348 | bool | |
| 349 | operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 350 | { | |
| 351 | return !(__lhs == __rhs); | |
| 352 | } | |
| 353 | ||
| 354 | // Duration < | |
| 355 | ||
| 356 | template <class _LhsDuration, class _RhsDuration> | |
| 357 | struct __duration_lt | |
| 358 | { | |
| 359 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 360 | bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const | |
| 361 | { | |
| 362 | typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; | |
| 363 | return _Ct(__lhs).count() < _Ct(__rhs).count(); | |
| 364 | } | |
| 365 | }; | |
| 366 | ||
| 367 | template <class _LhsDuration> | |
| 368 | struct __duration_lt<_LhsDuration, _LhsDuration> | |
| 369 | { | |
| 370 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 371 | bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const | |
| 372 | {return __lhs.count() < __rhs.count();} | |
| 373 | }; | |
| 374 | ||
| 375 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 376 | inline _LIBCPP_INLINE_VISIBILITY | |
| 377 | _LIBCPP_CONSTEXPR | |
| 378 | bool | |
| 379 | operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 380 | { | |
| 381 | return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); | |
| 382 | } | |
| 383 | ||
| 384 | // Duration > | |
| 385 | ||
| 386 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 387 | inline _LIBCPP_INLINE_VISIBILITY | |
| 388 | _LIBCPP_CONSTEXPR | |
| 389 | bool | |
| 390 | operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 391 | { | |
| 392 | return __rhs < __lhs; | |
| 393 | } | |
| 394 | ||
| 395 | // Duration <= | |
| 396 | ||
| 397 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 398 | inline _LIBCPP_INLINE_VISIBILITY | |
| 399 | _LIBCPP_CONSTEXPR | |
| 400 | bool | |
| 401 | operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 402 | { | |
| 403 | return !(__rhs < __lhs); | |
| 404 | } | |
| 405 | ||
| 406 | // Duration >= | |
| 407 | ||
| 408 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 409 | inline _LIBCPP_INLINE_VISIBILITY | |
| 410 | _LIBCPP_CONSTEXPR | |
| 411 | bool | |
| 412 | operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 413 | { | |
| 414 | return !(__lhs < __rhs); | |
| 415 | } | |
| 416 | ||
| 417 | // Duration + | |
| 418 | ||
| 419 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 420 | inline _LIBCPP_INLINE_VISIBILITY | |
| 421 | _LIBCPP_CONSTEXPR | |
| 422 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | |
| 423 | operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 424 | { | |
| 425 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | |
| 426 | return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); | |
| 427 | } | |
| 428 | ||
| 429 | // Duration - | |
| 430 | ||
| 431 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 432 | inline _LIBCPP_INLINE_VISIBILITY | |
| 433 | _LIBCPP_CONSTEXPR | |
| 434 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | |
| 435 | operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 436 | { | |
| 437 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | |
| 438 | return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); | |
| 439 | } | |
| 440 | ||
| 441 | // Duration * | |
| 442 | ||
| 443 | template <class _Rep1, class _Period, class _Rep2> | |
| 444 | inline _LIBCPP_INLINE_VISIBILITY | |
| 445 | _LIBCPP_CONSTEXPR | |
| 446 | typename enable_if | |
| 447 | < | |
| 448 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 449 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 450 | >::type | |
| 451 | operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) | |
| 452 | { | |
| 453 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 454 | typedef duration<_Cr, _Period> _Cd; | |
| 455 | return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); | |
| 456 | } | |
| 457 | ||
| 458 | template <class _Rep1, class _Period, class _Rep2> | |
| 459 | inline _LIBCPP_INLINE_VISIBILITY | |
| 460 | _LIBCPP_CONSTEXPR | |
| 461 | typename enable_if | |
| 462 | < | |
| 463 | is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 464 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 465 | >::type | |
| 466 | operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) | |
| 467 | { | |
| 468 | return __d * __s; | |
| 469 | } | |
| 470 | ||
| 471 | // Duration / | |
| 472 | ||
| 473 | template <class _Rep1, class _Period, class _Rep2> | |
| 474 | inline _LIBCPP_INLINE_VISIBILITY | |
| 475 | _LIBCPP_CONSTEXPR | |
| 476 | typename enable_if | |
| 477 | < | |
| 478 | !__is_duration<_Rep2>::value && | |
| 479 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 480 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 481 | >::type | |
| 482 | operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) | |
| 483 | { | |
| 484 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 485 | typedef duration<_Cr, _Period> _Cd; | |
| 486 | return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); | |
| 487 | } | |
| 488 | ||
| 489 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 490 | inline _LIBCPP_INLINE_VISIBILITY | |
| 491 | _LIBCPP_CONSTEXPR | |
| 492 | typename common_type<_Rep1, _Rep2>::type | |
| 493 | operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 494 | { | |
| 495 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; | |
| 496 | return _Ct(__lhs).count() / _Ct(__rhs).count(); | |
| 497 | } | |
| 498 | ||
| 499 | // Duration % | |
| 500 | ||
| 501 | template <class _Rep1, class _Period, class _Rep2> | |
| 502 | inline _LIBCPP_INLINE_VISIBILITY | |
| 503 | _LIBCPP_CONSTEXPR | |
| 504 | typename enable_if | |
| 505 | < | |
| 506 | !__is_duration<_Rep2>::value && | |
| 507 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 508 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 509 | >::type | |
| 510 | operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) | |
| 511 | { | |
| 512 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 513 | typedef duration<_Cr, _Period> _Cd; | |
| 514 | return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); | |
| 515 | } | |
| 516 | ||
| 517 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 518 | inline _LIBCPP_INLINE_VISIBILITY | |
| 519 | _LIBCPP_CONSTEXPR | |
| 520 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | |
| 521 | operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 522 | { | |
| 523 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 524 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | |
| 525 | return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); | |
| 526 | } | |
| 527 | ||
| 528 | } // namespace chrono | |
| 529 | ||
| 530 | #if _LIBCPP_STD_VER > 11 | |
| 531 | // Suffixes for duration literals [time.duration.literals] | |
| 532 | inline namespace literals | |
| 533 | { | |
| 534 | inline namespace chrono_literals | |
| 535 | { | |
| 536 | ||
| 537 | constexpr chrono::hours operator""h(unsigned long long __h) | |
| 538 | { | |
| 539 | return chrono::hours(static_cast<chrono::hours::rep>(__h)); | |
| 540 | } | |
| 541 | ||
| 542 | constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h) | |
| 543 | { | |
| 544 | return chrono::duration<long double, ratio<3600,1>>(__h); | |
| 545 | } | |
| 546 | ||
| 547 | ||
| 548 | constexpr chrono::minutes operator""min(unsigned long long __m) | |
| 549 | { | |
| 550 | return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); | |
| 551 | } | |
| 552 | ||
| 553 | constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m) | |
| 554 | { | |
| 555 | return chrono::duration<long double, ratio<60,1>> (__m); | |
| 556 | } | |
| 557 | ||
| 558 | ||
| 559 | constexpr chrono::seconds operator""s(unsigned long long __s) | |
| 560 | { | |
| 561 | return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); | |
| 562 | } | |
| 563 | ||
| 564 | constexpr chrono::duration<long double> operator""s(long double __s) | |
| 565 | { | |
| 566 | return chrono::duration<long double> (__s); | |
| 567 | } | |
| 568 | ||
| 569 | ||
| 570 | constexpr chrono::milliseconds operator""ms(unsigned long long __ms) | |
| 571 | { | |
| 572 | return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); | |
| 573 | } | |
| 574 | ||
| 575 | constexpr chrono::duration<long double, milli> operator""ms(long double __ms) | |
| 576 | { | |
| 577 | return chrono::duration<long double, milli>(__ms); | |
| 578 | } | |
| 579 | ||
| 580 | ||
| 581 | constexpr chrono::microseconds operator""us(unsigned long long __us) | |
| 582 | { | |
| 583 | return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); | |
| 584 | } | |
| 585 | ||
| 586 | constexpr chrono::duration<long double, micro> operator""us(long double __us) | |
| 587 | { | |
| 588 | return chrono::duration<long double, micro> (__us); | |
| 589 | } | |
| 590 | ||
| 591 | ||
| 592 | constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) | |
| 593 | { | |
| 594 | return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); | |
| 595 | } | |
| 596 | ||
| 597 | constexpr chrono::duration<long double, nano> operator""ns(long double __ns) | |
| 598 | { | |
| 599 | return chrono::duration<long double, nano> (__ns); | |
| 600 | } | |
| 601 | ||
| 602 | } // namespace chrono_literals | |
| 603 | } // namespace literals | |
| 604 | ||
| 605 | namespace chrono { // hoist the literals into namespace std::chrono | |
| 606 | using namespace literals::chrono_literals; | |
| 607 | } // namespace chrono | |
| 608 | ||
| 609 | #endif // _LIBCPP_STD_VER > 11 | |
| 610 | ||
| 611 | _LIBCPP_END_NAMESPACE_STD | |
| 612 | ||
| 613 | _LIBCPP_POP_MACROS | |
| 614 | ||
| 615 | #endif // _LIBCPP___CHRONO_DURATION_H |
lib/libcxx/include/__chrono/file_clock.h created+85| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_FILE_CLOCK_H | |
| 11 | #define _LIBCPP___CHRONO_FILE_CLOCK_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__chrono/duration.h> | |
| 15 | #include <__chrono/system_clock.h> | |
| 16 | #include <__chrono/time_point.h> | |
| 17 | #include <__config> | |
| 18 | #include <ratio> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | #ifndef _LIBCPP_CXX03_LANG | |
| 25 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 26 | struct _FilesystemClock; | |
| 27 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 28 | #endif // !_LIBCPP_CXX03_LANG | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace chrono | |
| 35 | { | |
| 36 | ||
| 37 | // [time.clock.file], type file_clock | |
| 38 | using file_clock = _VSTD_FS::_FilesystemClock; | |
| 39 | ||
| 40 | template<class _Duration> | |
| 41 | using file_time = time_point<file_clock, _Duration>; | |
| 42 | ||
| 43 | } // namespace chrono | |
| 44 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | |
| 46 | ||
| 47 | #endif // _LIBCPP_STD_VER > 17 | |
| 48 | ||
| 49 | #ifndef _LIBCPP_CXX03_LANG | |
| 50 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 51 | struct _FilesystemClock { | |
| 52 | #if !defined(_LIBCPP_HAS_NO_INT128) | |
| 53 | typedef __int128_t rep; | |
| 54 | typedef nano period; | |
| 55 | #else | |
| 56 | typedef long long rep; | |
| 57 | typedef nano period; | |
| 58 | #endif | |
| 59 | ||
| 60 | typedef chrono::duration<rep, period> duration; | |
| 61 | typedef chrono::time_point<_FilesystemClock> time_point; | |
| 62 | ||
| 63 | _LIBCPP_EXPORTED_FROM_ABI | |
| 64 | static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; | |
| 65 | ||
| 66 | _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept; | |
| 67 | ||
| 68 | #if _LIBCPP_STD_VER > 17 | |
| 69 | template <class _Duration> | |
| 70 | _LIBCPP_HIDE_FROM_ABI | |
| 71 | static chrono::sys_time<_Duration> to_sys(const chrono::file_time<_Duration>& __t) { | |
| 72 | return chrono::sys_time<_Duration>(__t.time_since_epoch()); | |
| 73 | } | |
| 74 | ||
| 75 | template <class _Duration> | |
| 76 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | static chrono::file_time<_Duration> from_sys(const chrono::sys_time<_Duration>& __t) { | |
| 78 | return chrono::file_time<_Duration>(__t.time_since_epoch()); | |
| 79 | } | |
| 80 | #endif // _LIBCPP_STD_VER > 17 | |
| 81 | }; | |
| 82 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 83 | #endif // !_LIBCPP_CXX03_LANG | |
| 84 | ||
| 85 | #endif // _LIBCPP___CHRONO_FILE_CLOCK_H |
lib/libcxx/include/__chrono/high_resolution_clock.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 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_HIGH_RESOLUTION_CLOCK_H | |
| 11 | #define _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H | |
| 12 | ||
| 13 | #include <__chrono/steady_clock.h> | |
| 14 | #include <__chrono/system_clock.h> | |
| 15 | #include <__config> | |
| 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 | namespace chrono | |
| 24 | { | |
| 25 | ||
| 26 | #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 27 | typedef steady_clock high_resolution_clock; | |
| 28 | #else | |
| 29 | typedef system_clock high_resolution_clock; | |
| 30 | #endif | |
| 31 | ||
| 32 | } // namespace chrono | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___CHRONO_HIGH_RESOLUTION_CLOCK_H |
lib/libcxx/include/__chrono/steady_clock.h created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 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_STEADY_CLOCK_H | |
| 11 | #define _LIBCPP___CHRONO_STEADY_CLOCK_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/time_point.h> | |
| 15 | #include <__config> | |
| 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 | namespace chrono | |
| 24 | { | |
| 25 | ||
| 26 | #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 27 | class _LIBCPP_TYPE_VIS steady_clock | |
| 28 | { | |
| 29 | public: | |
| 30 | typedef nanoseconds duration; | |
| 31 | typedef duration::rep rep; | |
| 32 | typedef duration::period period; | |
| 33 | typedef chrono::time_point<steady_clock, duration> time_point; | |
| 34 | static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; | |
| 35 | ||
| 36 | static time_point now() _NOEXCEPT; | |
| 37 | }; | |
| 38 | #endif | |
| 39 | ||
| 40 | } // namespace chrono | |
| 41 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | |
| 43 | ||
| 44 | #endif // _LIBCPP___CHRONO_STEADY_CLOCK_H |
lib/libcxx/include/__chrono/system_clock.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___CHRONO_SYSTEM_CLOCK_H | |
| 11 | #define _LIBCPP___CHRONO_SYSTEM_CLOCK_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/time_point.h> | |
| 15 | #include <__config> | |
| 16 | #include <ctime> | |
| 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 | namespace chrono | |
| 25 | { | |
| 26 | ||
| 27 | class _LIBCPP_TYPE_VIS system_clock | |
| 28 | { | |
| 29 | public: | |
| 30 | typedef microseconds duration; | |
| 31 | typedef duration::rep rep; | |
| 32 | typedef duration::period period; | |
| 33 | typedef chrono::time_point<system_clock> time_point; | |
| 34 | static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; | |
| 35 | ||
| 36 | static time_point now() _NOEXCEPT; | |
| 37 | static time_t to_time_t (const time_point& __t) _NOEXCEPT; | |
| 38 | static time_point from_time_t(time_t __t) _NOEXCEPT; | |
| 39 | }; | |
| 40 | ||
| 41 | #if _LIBCPP_STD_VER > 17 | |
| 42 | ||
| 43 | template <class _Duration> | |
| 44 | using sys_time = time_point<system_clock, _Duration>; | |
| 45 | using sys_seconds = sys_time<seconds>; | |
| 46 | using sys_days = sys_time<days>; | |
| 47 | ||
| 48 | #endif | |
| 49 | ||
| 50 | } // namespace chrono | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | #endif // _LIBCPP___CHRONO_SYSTEM_CLOCK_H |
lib/libcxx/include/__chrono/time_point.h created+249| ... | ... | @@ -0,0 +1,249 @@ |
| 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_TIME_POINT_H | |
| 11 | #define _LIBCPP___CHRONO_TIME_POINT_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__config> | |
| 15 | #include <limits> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | namespace chrono | |
| 28 | { | |
| 29 | ||
| 30 | template <class _Clock, class _Duration = typename _Clock::duration> | |
| 31 | class _LIBCPP_TEMPLATE_VIS time_point | |
| 32 | { | |
| 33 | static_assert(__is_duration<_Duration>::value, | |
| 34 | "Second template parameter of time_point must be a std::chrono::duration"); | |
| 35 | public: | |
| 36 | typedef _Clock clock; | |
| 37 | typedef _Duration duration; | |
| 38 | typedef typename duration::rep rep; | |
| 39 | typedef typename duration::period period; | |
| 40 | private: | |
| 41 | duration __d_; | |
| 42 | ||
| 43 | public: | |
| 44 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} | |
| 45 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} | |
| 46 | ||
| 47 | // conversions | |
| 48 | template <class _Duration2> | |
| 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 50 | time_point(const time_point<clock, _Duration2>& t, | |
| 51 | typename enable_if | |
| 52 | < | |
| 53 | is_convertible<_Duration2, duration>::value | |
| 54 | >::type* = nullptr) | |
| 55 | : __d_(t.time_since_epoch()) {} | |
| 56 | ||
| 57 | // observer | |
| 58 | ||
| 59 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} | |
| 60 | ||
| 61 | // arithmetic | |
| 62 | ||
| 63 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} | |
| 64 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} | |
| 65 | ||
| 66 | // special values | |
| 67 | ||
| 68 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());} | |
| 69 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());} | |
| 70 | }; | |
| 71 | ||
| 72 | } // namespace chrono | |
| 73 | ||
| 74 | template <class _Clock, class _Duration1, class _Duration2> | |
| 75 | struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>, | |
| 76 | chrono::time_point<_Clock, _Duration2> > | |
| 77 | { | |
| 78 | typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; | |
| 79 | }; | |
| 80 | ||
| 81 | namespace chrono { | |
| 82 | ||
| 83 | template <class _ToDuration, class _Clock, class _Duration> | |
| 84 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 85 | time_point<_Clock, _ToDuration> | |
| 86 | time_point_cast(const time_point<_Clock, _Duration>& __t) | |
| 87 | { | |
| 88 | return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); | |
| 89 | } | |
| 90 | ||
| 91 | #if _LIBCPP_STD_VER > 14 | |
| 92 | template <class _ToDuration, class _Clock, class _Duration> | |
| 93 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 94 | typename enable_if | |
| 95 | < | |
| 96 | __is_duration<_ToDuration>::value, | |
| 97 | time_point<_Clock, _ToDuration> | |
| 98 | >::type | |
| 99 | floor(const time_point<_Clock, _Duration>& __t) | |
| 100 | { | |
| 101 | return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; | |
| 102 | } | |
| 103 | ||
| 104 | template <class _ToDuration, class _Clock, class _Duration> | |
| 105 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 106 | typename enable_if | |
| 107 | < | |
| 108 | __is_duration<_ToDuration>::value, | |
| 109 | time_point<_Clock, _ToDuration> | |
| 110 | >::type | |
| 111 | ceil(const time_point<_Clock, _Duration>& __t) | |
| 112 | { | |
| 113 | return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; | |
| 114 | } | |
| 115 | ||
| 116 | template <class _ToDuration, class _Clock, class _Duration> | |
| 117 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 118 | typename enable_if | |
| 119 | < | |
| 120 | __is_duration<_ToDuration>::value, | |
| 121 | time_point<_Clock, _ToDuration> | |
| 122 | >::type | |
| 123 | round(const time_point<_Clock, _Duration>& __t) | |
| 124 | { | |
| 125 | return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; | |
| 126 | } | |
| 127 | ||
| 128 | template <class _Rep, class _Period> | |
| 129 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 130 | typename enable_if | |
| 131 | < | |
| 132 | numeric_limits<_Rep>::is_signed, | |
| 133 | duration<_Rep, _Period> | |
| 134 | >::type | |
| 135 | abs(duration<_Rep, _Period> __d) | |
| 136 | { | |
| 137 | return __d >= __d.zero() ? +__d : -__d; | |
| 138 | } | |
| 139 | #endif // _LIBCPP_STD_VER > 14 | |
| 140 | ||
| 141 | // time_point == | |
| 142 | ||
| 143 | template <class _Clock, class _Duration1, class _Duration2> | |
| 144 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 145 | bool | |
| 146 | operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 147 | { | |
| 148 | return __lhs.time_since_epoch() == __rhs.time_since_epoch(); | |
| 149 | } | |
| 150 | ||
| 151 | // time_point != | |
| 152 | ||
| 153 | template <class _Clock, class _Duration1, class _Duration2> | |
| 154 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 155 | bool | |
| 156 | operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 157 | { | |
| 158 | return !(__lhs == __rhs); | |
| 159 | } | |
| 160 | ||
| 161 | // time_point < | |
| 162 | ||
| 163 | template <class _Clock, class _Duration1, class _Duration2> | |
| 164 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 165 | bool | |
| 166 | operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 167 | { | |
| 168 | return __lhs.time_since_epoch() < __rhs.time_since_epoch(); | |
| 169 | } | |
| 170 | ||
| 171 | // time_point > | |
| 172 | ||
| 173 | template <class _Clock, class _Duration1, class _Duration2> | |
| 174 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 175 | bool | |
| 176 | operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 177 | { | |
| 178 | return __rhs < __lhs; | |
| 179 | } | |
| 180 | ||
| 181 | // time_point <= | |
| 182 | ||
| 183 | template <class _Clock, class _Duration1, class _Duration2> | |
| 184 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 185 | bool | |
| 186 | operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 187 | { | |
| 188 | return !(__rhs < __lhs); | |
| 189 | } | |
| 190 | ||
| 191 | // time_point >= | |
| 192 | ||
| 193 | template <class _Clock, class _Duration1, class _Duration2> | |
| 194 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 195 | bool | |
| 196 | operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 197 | { | |
| 198 | return !(__lhs < __rhs); | |
| 199 | } | |
| 200 | ||
| 201 | // time_point operator+(time_point x, duration y); | |
| 202 | ||
| 203 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | |
| 204 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 205 | time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | |
| 206 | operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 207 | { | |
| 208 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; | |
| 209 | return _Tr (__lhs.time_since_epoch() + __rhs); | |
| 210 | } | |
| 211 | ||
| 212 | // time_point operator+(duration x, time_point y); | |
| 213 | ||
| 214 | template <class _Rep1, class _Period1, class _Clock, class _Duration2> | |
| 215 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 216 | time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> | |
| 217 | operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 218 | { | |
| 219 | return __rhs + __lhs; | |
| 220 | } | |
| 221 | ||
| 222 | // time_point operator-(time_point x, duration y); | |
| 223 | ||
| 224 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | |
| 225 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 226 | time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | |
| 227 | operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 228 | { | |
| 229 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; | |
| 230 | return _Ret(__lhs.time_since_epoch() -__rhs); | |
| 231 | } | |
| 232 | ||
| 233 | // duration operator-(time_point x, time_point y); | |
| 234 | ||
| 235 | template <class _Clock, class _Duration1, class _Duration2> | |
| 236 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 237 | typename common_type<_Duration1, _Duration2>::type | |
| 238 | operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 239 | { | |
| 240 | return __lhs.time_since_epoch() - __rhs.time_since_epoch(); | |
| 241 | } | |
| 242 | ||
| 243 | } // namespace chrono | |
| 244 | ||
| 245 | _LIBCPP_END_NAMESPACE_STD | |
| 246 | ||
| 247 | _LIBCPP_POP_MACROS | |
| 248 | ||
| 249 | #endif // _LIBCPP___CHRONO_TIME_POINT_H |
lib/libcxx/include/__compare/common_comparison_category.h created+94| ... | ... | @@ -0,0 +1,94 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H | |
| 10 | #define _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H | |
| 11 | ||
| 12 | #include <__compare/ordering.h> | |
| 13 | #include <__config> | |
| 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 | #if _LIBCPP_STD_VER > 17 | |
| 23 | ||
| 24 | namespace __comp_detail { | |
| 25 | ||
| 26 | enum _ClassifyCompCategory : unsigned { | |
| 27 | _None, | |
| 28 | _PartialOrd, | |
| 29 | _WeakOrd, | |
| 30 | _StrongOrd, | |
| 31 | _CCC_Size | |
| 32 | }; | |
| 33 | ||
| 34 | template <class _Tp> | |
| 35 | _LIBCPP_HIDE_FROM_ABI | |
| 36 | constexpr _ClassifyCompCategory __type_to_enum() noexcept { | |
| 37 | if (is_same_v<_Tp, partial_ordering>) | |
| 38 | return _PartialOrd; | |
| 39 | if (is_same_v<_Tp, weak_ordering>) | |
| 40 | return _WeakOrd; | |
| 41 | if (is_same_v<_Tp, strong_ordering>) | |
| 42 | return _StrongOrd; | |
| 43 | return _None; | |
| 44 | } | |
| 45 | ||
| 46 | template <size_t _Size> | |
| 47 | _LIBCPP_HIDE_FROM_ABI | |
| 48 | constexpr _ClassifyCompCategory | |
| 49 | __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) { | |
| 50 | int __seen[_CCC_Size] = {}; | |
| 51 | for (auto __type : __types) | |
| 52 | ++__seen[__type]; | |
| 53 | if (__seen[_None]) | |
| 54 | return _None; | |
| 55 | if (__seen[_PartialOrd]) | |
| 56 | return _PartialOrd; | |
| 57 | if (__seen[_WeakOrd]) | |
| 58 | return _WeakOrd; | |
| 59 | return _StrongOrd; | |
| 60 | } | |
| 61 | ||
| 62 | template <class ..._Ts, bool _False = false> | |
| 63 | _LIBCPP_HIDE_FROM_ABI | |
| 64 | constexpr auto __get_comp_type() { | |
| 65 | using _CCC = _ClassifyCompCategory; | |
| 66 | constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...}; | |
| 67 | constexpr _CCC _Cat = __compute_comp_type(__type_kinds); | |
| 68 | if constexpr (_Cat == _None) | |
| 69 | return void(); | |
| 70 | else if constexpr (_Cat == _PartialOrd) | |
| 71 | return partial_ordering::equivalent; | |
| 72 | else if constexpr (_Cat == _WeakOrd) | |
| 73 | return weak_ordering::equivalent; | |
| 74 | else if constexpr (_Cat == _StrongOrd) | |
| 75 | return strong_ordering::equivalent; | |
| 76 | else | |
| 77 | static_assert(_False, "unhandled case"); | |
| 78 | } | |
| 79 | } // namespace __comp_detail | |
| 80 | ||
| 81 | // [cmp.common], common comparison category type | |
| 82 | template<class... _Ts> | |
| 83 | struct _LIBCPP_TEMPLATE_VIS common_comparison_category { | |
| 84 | using type = decltype(__comp_detail::__get_comp_type<_Ts...>()); | |
| 85 | }; | |
| 86 | ||
| 87 | template<class... _Ts> | |
| 88 | using common_comparison_category_t = typename common_comparison_category<_Ts...>::type; | |
| 89 | ||
| 90 | #endif // _LIBCPP_STD_VER > 17 | |
| 91 | ||
| 92 | _LIBCPP_END_NAMESPACE_STD | |
| 93 | ||
| 94 | #endif // _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H |
lib/libcxx/include/__compare/compare_partial_order_fallback.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___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK | |
| 10 | #define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK | |
| 11 | ||
| 12 | #include <__compare/ordering.h> | |
| 13 | #include <__compare/partial_order.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <__utility/priority_tag.h> | |
| 17 | #include <type_traits> | |
| 18 | ||
| 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 20 | #pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | ||
| 27 | // [cmp.alg] | |
| 28 | namespace __compare_partial_order_fallback { | |
| 29 | struct __fn { | |
| 30 | template<class _Tp, class _Up> | |
| 31 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 32 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 33 | __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) | |
| 34 | noexcept(noexcept(_VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 35 | -> decltype( _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) | |
| 36 | { return _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } | |
| 37 | ||
| 38 | template<class _Tp, class _Up> | |
| 39 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 40 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 41 | __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) | |
| 42 | noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : | |
| 43 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : | |
| 44 | _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : | |
| 45 | partial_ordering::unordered)) | |
| 46 | -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : | |
| 47 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : | |
| 48 | _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : | |
| 49 | partial_ordering::unordered) | |
| 50 | { | |
| 51 | return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent : | |
| 52 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less : | |
| 53 | _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater : | |
| 54 | partial_ordering::unordered; | |
| 55 | } | |
| 56 | ||
| 57 | template<class _Tp, class _Up> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const | |
| 59 | noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) | |
| 60 | -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) | |
| 61 | { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } | |
| 62 | }; | |
| 63 | } // namespace __compare_partial_order_fallback | |
| 64 | ||
| 65 | inline namespace __cpo { | |
| 66 | inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{}; | |
| 67 | } // namespace __cpo | |
| 68 | ||
| 69 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 70 | ||
| 71 | _LIBCPP_END_NAMESPACE_STD | |
| 72 | ||
| 73 | #endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK |
lib/libcxx/include/__compare/compare_strong_order_fallback.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___COMPARE_COMPARE_STRONG_ORDER_FALLBACK | |
| 10 | #define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK | |
| 11 | ||
| 12 | #include <__compare/ordering.h> | |
| 13 | #include <__compare/strong_order.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <__utility/priority_tag.h> | |
| 17 | #include <type_traits> | |
| 18 | ||
| 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 20 | #pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | ||
| 27 | // [cmp.alg] | |
| 28 | namespace __compare_strong_order_fallback { | |
| 29 | struct __fn { | |
| 30 | template<class _Tp, class _Up> | |
| 31 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 32 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 33 | __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) | |
| 34 | noexcept(noexcept(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 35 | -> decltype( _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) | |
| 36 | { return _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } | |
| 37 | ||
| 38 | template<class _Tp, class _Up> | |
| 39 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 40 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 41 | __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) | |
| 42 | noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : | |
| 43 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : | |
| 44 | strong_ordering::greater)) | |
| 45 | -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : | |
| 46 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : | |
| 47 | strong_ordering::greater) | |
| 48 | { | |
| 49 | return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal : | |
| 50 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less : | |
| 51 | strong_ordering::greater; | |
| 52 | } | |
| 53 | ||
| 54 | template<class _Tp, class _Up> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const | |
| 56 | noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) | |
| 57 | -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) | |
| 58 | { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } | |
| 59 | }; | |
| 60 | } // namespace __compare_strong_order_fallback | |
| 61 | ||
| 62 | inline namespace __cpo { | |
| 63 | inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{}; | |
| 64 | } // namespace __cpo | |
| 65 | ||
| 66 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 67 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | |
| 69 | ||
| 70 | #endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK |
lib/libcxx/include/__compare/compare_three_way.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___COMPARE_COMPARE_THREE_WAY_H | |
| 11 | #define _LIBCPP___COMPARE_COMPARE_THREE_WAY_H | |
| 12 | ||
| 13 | #include <__compare/three_way_comparable.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/forward.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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | struct _LIBCPP_TEMPLATE_VIS compare_three_way | |
| 26 | { | |
| 27 | template<class _T1, class _T2> | |
| 28 | requires three_way_comparable_with<_T1, _T2> | |
| 29 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 30 | auto operator()(_T1&& __t, _T2&& __u) const | |
| 31 | noexcept(noexcept(_VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u))) | |
| 32 | { return _VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u); } | |
| 33 | ||
| 34 | using is_transparent = void; | |
| 35 | }; | |
| 36 | ||
| 37 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_H |
lib/libcxx/include/__compare/compare_three_way_result.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___COMPARE_COMPARE_THREE_WAY_RESULT_H | |
| 10 | #define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | ||
| 23 | template<class, class, class> | |
| 24 | struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { }; | |
| 25 | ||
| 26 | template<class _Tp, class _Up> | |
| 27 | struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype( | |
| 28 | declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>(), void() | |
| 29 | )> { | |
| 30 | using type = decltype(declval<__make_const_lvalue_ref<_Tp>>() <=> declval<__make_const_lvalue_ref<_Up>>()); | |
| 31 | }; | |
| 32 | ||
| 33 | template<class _Tp, class _Up = _Tp> | |
| 34 | struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> { }; | |
| 35 | ||
| 36 | template<class _Tp, class _Up = _Tp> | |
| 37 | using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type; | |
| 38 | ||
| 39 | #endif // _LIBCPP_STD_VER > 17 | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | #endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H |
lib/libcxx/include/__compare/compare_weak_order_fallback.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___COMPARE_COMPARE_WEAK_ORDER_FALLBACK | |
| 10 | #define _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK | |
| 11 | ||
| 12 | #include <__compare/ordering.h> | |
| 13 | #include <__compare/weak_order.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <__utility/priority_tag.h> | |
| 17 | #include <type_traits> | |
| 18 | ||
| 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 20 | #pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | ||
| 27 | // [cmp.alg] | |
| 28 | namespace __compare_weak_order_fallback { | |
| 29 | struct __fn { | |
| 30 | template<class _Tp, class _Up> | |
| 31 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 32 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 33 | __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) | |
| 34 | noexcept(noexcept(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 35 | -> decltype( _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))) | |
| 36 | { return _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); } | |
| 37 | ||
| 38 | template<class _Tp, class _Up> | |
| 39 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 40 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 41 | __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) | |
| 42 | noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : | |
| 43 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : | |
| 44 | weak_ordering::greater)) | |
| 45 | -> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : | |
| 46 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : | |
| 47 | weak_ordering::greater) | |
| 48 | { | |
| 49 | return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent : | |
| 50 | _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less : | |
| 51 | weak_ordering::greater; | |
| 52 | } | |
| 53 | ||
| 54 | template<class _Tp, class _Up> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const | |
| 56 | noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))) | |
| 57 | -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())) | |
| 58 | { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); } | |
| 59 | }; | |
| 60 | } // namespace __compare_weak_order_fallback | |
| 61 | ||
| 62 | inline namespace __cpo { | |
| 63 | inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{}; | |
| 64 | } // namespace __cpo | |
| 65 | ||
| 66 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 67 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | |
| 69 | ||
| 70 | #endif // _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK |
lib/libcxx/include/__compare/is_eq.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___COMPARE_IS_EQ_H | |
| 10 | #define _LIBCPP___COMPARE_IS_EQ_H | |
| 11 | ||
| 12 | #include <__compare/ordering.h> | |
| 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 | ||
| 23 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_eq(partial_ordering __c) noexcept { return __c == 0; } | |
| 24 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_neq(partial_ordering __c) noexcept { return __c != 0; } | |
| 25 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lt(partial_ordering __c) noexcept { return __c < 0; } | |
| 26 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lteq(partial_ordering __c) noexcept { return __c <= 0; } | |
| 27 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gt(partial_ordering __c) noexcept { return __c > 0; } | |
| 28 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gteq(partial_ordering __c) noexcept { return __c >= 0; } | |
| 29 | ||
| 30 | #endif // _LIBCPP_STD_VER > 17 | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___COMPARE_IS_EQ_H |
lib/libcxx/include/__compare/ordering.h created+319| ... | ... | @@ -0,0 +1,319 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___COMPARE_ORDERING_H | |
| 10 | #define _LIBCPP___COMPARE_ORDERING_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | ||
| 23 | // exposition only | |
| 24 | enum class _LIBCPP_ENUM_VIS _OrdResult : signed char { | |
| 25 | __less = -1, | |
| 26 | __equiv = 0, | |
| 27 | __greater = 1 | |
| 28 | }; | |
| 29 | ||
| 30 | enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char { | |
| 31 | __unordered = -127 | |
| 32 | }; | |
| 33 | ||
| 34 | class partial_ordering; | |
| 35 | class weak_ordering; | |
| 36 | class strong_ordering; | |
| 37 | ||
| 38 | template<class _Tp, class... _Args> | |
| 39 | inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...); | |
| 40 | ||
| 41 | struct _CmpUnspecifiedParam { | |
| 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEVAL | |
| 43 | _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} | |
| 44 | ||
| 45 | template<class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>> | |
| 46 | _CmpUnspecifiedParam(_Tp) = delete; | |
| 47 | }; | |
| 48 | ||
| 49 | class partial_ordering { | |
| 50 | using _ValueT = signed char; | |
| 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI | |
| 53 | explicit constexpr partial_ordering(_OrdResult __v) noexcept | |
| 54 | : __value_(_ValueT(__v)) {} | |
| 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI | |
| 57 | explicit constexpr partial_ordering(_NCmpResult __v) noexcept | |
| 58 | : __value_(_ValueT(__v)) {} | |
| 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI | |
| 61 | constexpr bool __is_ordered() const noexcept { | |
| 62 | return __value_ != _ValueT(_NCmpResult::__unordered); | |
| 63 | } | |
| 64 | public: | |
| 65 | // valid values | |
| 66 | static const partial_ordering less; | |
| 67 | static const partial_ordering equivalent; | |
| 68 | static const partial_ordering greater; | |
| 69 | static const partial_ordering unordered; | |
| 70 | ||
| 71 | // comparisons | |
| 72 | _LIBCPP_HIDE_FROM_ABI | |
| 73 | friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; | |
| 74 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI | |
| 76 | friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 77 | return __v.__is_ordered() && __v.__value_ == 0; | |
| 78 | } | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI | |
| 81 | friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 82 | return __v.__is_ordered() && __v.__value_ < 0; | |
| 83 | } | |
| 84 | ||
| 85 | _LIBCPP_HIDE_FROM_ABI | |
| 86 | friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 87 | return __v.__is_ordered() && __v.__value_ <= 0; | |
| 88 | } | |
| 89 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI | |
| 91 | friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 92 | return __v.__is_ordered() && __v.__value_ > 0; | |
| 93 | } | |
| 94 | ||
| 95 | _LIBCPP_HIDE_FROM_ABI | |
| 96 | friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 97 | return __v.__is_ordered() && __v.__value_ >= 0; | |
| 98 | } | |
| 99 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI | |
| 101 | friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 102 | return __v.__is_ordered() && 0 < __v.__value_; | |
| 103 | } | |
| 104 | ||
| 105 | _LIBCPP_HIDE_FROM_ABI | |
| 106 | friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 107 | return __v.__is_ordered() && 0 <= __v.__value_; | |
| 108 | } | |
| 109 | ||
| 110 | _LIBCPP_HIDE_FROM_ABI | |
| 111 | friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 112 | return __v.__is_ordered() && 0 > __v.__value_; | |
| 113 | } | |
| 114 | ||
| 115 | _LIBCPP_HIDE_FROM_ABI | |
| 116 | friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 117 | return __v.__is_ordered() && 0 >= __v.__value_; | |
| 118 | } | |
| 119 | ||
| 120 | _LIBCPP_HIDE_FROM_ABI | |
| 121 | friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 122 | return __v; | |
| 123 | } | |
| 124 | ||
| 125 | _LIBCPP_HIDE_FROM_ABI | |
| 126 | friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 127 | return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v); | |
| 128 | } | |
| 129 | private: | |
| 130 | _ValueT __value_; | |
| 131 | }; | |
| 132 | ||
| 133 | inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less); | |
| 134 | inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv); | |
| 135 | inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); | |
| 136 | inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); | |
| 137 | ||
| 138 | class weak_ordering { | |
| 139 | using _ValueT = signed char; | |
| 140 | ||
| 141 | _LIBCPP_HIDE_FROM_ABI | |
| 142 | explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 143 | ||
| 144 | public: | |
| 145 | static const weak_ordering less; | |
| 146 | static const weak_ordering equivalent; | |
| 147 | static const weak_ordering greater; | |
| 148 | ||
| 149 | _LIBCPP_HIDE_FROM_ABI | |
| 150 | constexpr operator partial_ordering() const noexcept { | |
| 151 | return __value_ == 0 ? partial_ordering::equivalent | |
| 152 | : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); | |
| 153 | } | |
| 154 | ||
| 155 | // comparisons | |
| 156 | _LIBCPP_HIDE_FROM_ABI | |
| 157 | friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default; | |
| 158 | ||
| 159 | _LIBCPP_HIDE_FROM_ABI | |
| 160 | friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 161 | return __v.__value_ == 0; | |
| 162 | } | |
| 163 | ||
| 164 | _LIBCPP_HIDE_FROM_ABI | |
| 165 | friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 166 | return __v.__value_ < 0; | |
| 167 | } | |
| 168 | ||
| 169 | _LIBCPP_HIDE_FROM_ABI | |
| 170 | friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 171 | return __v.__value_ <= 0; | |
| 172 | } | |
| 173 | ||
| 174 | _LIBCPP_HIDE_FROM_ABI | |
| 175 | friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 176 | return __v.__value_ > 0; | |
| 177 | } | |
| 178 | ||
| 179 | _LIBCPP_HIDE_FROM_ABI | |
| 180 | friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 181 | return __v.__value_ >= 0; | |
| 182 | } | |
| 183 | ||
| 184 | _LIBCPP_HIDE_FROM_ABI | |
| 185 | friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 186 | return 0 < __v.__value_; | |
| 187 | } | |
| 188 | ||
| 189 | _LIBCPP_HIDE_FROM_ABI | |
| 190 | friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 191 | return 0 <= __v.__value_; | |
| 192 | } | |
| 193 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI | |
| 195 | friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 196 | return 0 > __v.__value_; | |
| 197 | } | |
| 198 | ||
| 199 | _LIBCPP_HIDE_FROM_ABI | |
| 200 | friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 201 | return 0 >= __v.__value_; | |
| 202 | } | |
| 203 | ||
| 204 | _LIBCPP_HIDE_FROM_ABI | |
| 205 | friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 206 | return __v; | |
| 207 | } | |
| 208 | ||
| 209 | _LIBCPP_HIDE_FROM_ABI | |
| 210 | friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 211 | return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v); | |
| 212 | } | |
| 213 | ||
| 214 | private: | |
| 215 | _ValueT __value_; | |
| 216 | }; | |
| 217 | ||
| 218 | inline constexpr weak_ordering weak_ordering::less(_OrdResult::__less); | |
| 219 | inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv); | |
| 220 | inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater); | |
| 221 | ||
| 222 | class strong_ordering { | |
| 223 | using _ValueT = signed char; | |
| 224 | ||
| 225 | _LIBCPP_HIDE_FROM_ABI | |
| 226 | explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 227 | ||
| 228 | public: | |
| 229 | static const strong_ordering less; | |
| 230 | static const strong_ordering equal; | |
| 231 | static const strong_ordering equivalent; | |
| 232 | static const strong_ordering greater; | |
| 233 | ||
| 234 | // conversions | |
| 235 | _LIBCPP_HIDE_FROM_ABI | |
| 236 | constexpr operator partial_ordering() const noexcept { | |
| 237 | return __value_ == 0 ? partial_ordering::equivalent | |
| 238 | : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); | |
| 239 | } | |
| 240 | ||
| 241 | _LIBCPP_HIDE_FROM_ABI | |
| 242 | constexpr operator weak_ordering() const noexcept { | |
| 243 | return __value_ == 0 ? weak_ordering::equivalent | |
| 244 | : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater); | |
| 245 | } | |
| 246 | ||
| 247 | // comparisons | |
| 248 | _LIBCPP_HIDE_FROM_ABI | |
| 249 | friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default; | |
| 250 | ||
| 251 | _LIBCPP_HIDE_FROM_ABI | |
| 252 | friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 253 | return __v.__value_ == 0; | |
| 254 | } | |
| 255 | ||
| 256 | _LIBCPP_HIDE_FROM_ABI | |
| 257 | friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 258 | return __v.__value_ < 0; | |
| 259 | } | |
| 260 | ||
| 261 | _LIBCPP_HIDE_FROM_ABI | |
| 262 | friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 263 | return __v.__value_ <= 0; | |
| 264 | } | |
| 265 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI | |
| 267 | friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 268 | return __v.__value_ > 0; | |
| 269 | } | |
| 270 | ||
| 271 | _LIBCPP_HIDE_FROM_ABI | |
| 272 | friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 273 | return __v.__value_ >= 0; | |
| 274 | } | |
| 275 | ||
| 276 | _LIBCPP_HIDE_FROM_ABI | |
| 277 | friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 278 | return 0 < __v.__value_; | |
| 279 | } | |
| 280 | ||
| 281 | _LIBCPP_HIDE_FROM_ABI | |
| 282 | friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 283 | return 0 <= __v.__value_; | |
| 284 | } | |
| 285 | ||
| 286 | _LIBCPP_HIDE_FROM_ABI | |
| 287 | friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 288 | return 0 > __v.__value_; | |
| 289 | } | |
| 290 | ||
| 291 | _LIBCPP_HIDE_FROM_ABI | |
| 292 | friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 293 | return 0 >= __v.__value_; | |
| 294 | } | |
| 295 | ||
| 296 | _LIBCPP_HIDE_FROM_ABI | |
| 297 | friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 298 | return __v; | |
| 299 | } | |
| 300 | ||
| 301 | _LIBCPP_HIDE_FROM_ABI | |
| 302 | friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 303 | return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v); | |
| 304 | } | |
| 305 | ||
| 306 | private: | |
| 307 | _ValueT __value_; | |
| 308 | }; | |
| 309 | ||
| 310 | inline constexpr strong_ordering strong_ordering::less(_OrdResult::__less); | |
| 311 | inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv); | |
| 312 | inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv); | |
| 313 | inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater); | |
| 314 | ||
| 315 | #endif // _LIBCPP_STD_VER > 17 | |
| 316 | ||
| 317 | _LIBCPP_END_NAMESPACE_STD | |
| 318 | ||
| 319 | #endif // _LIBCPP___COMPARE_ORDERING_H |
lib/libcxx/include/__compare/partial_order.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___COMPARE_PARTIAL_ORDER | |
| 10 | #define _LIBCPP___COMPARE_PARTIAL_ORDER | |
| 11 | ||
| 12 | #include <__compare/compare_three_way.h> | |
| 13 | #include <__compare/ordering.h> | |
| 14 | #include <__compare/weak_order.h> | |
| 15 | #include <__config> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <__utility/priority_tag.h> | |
| 18 | #include <type_traits> | |
| 19 | ||
| 20 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | ||
| 28 | // [cmp.alg] | |
| 29 | namespace __partial_order { | |
| 30 | struct __fn { | |
| 31 | template<class _Tp, class _Up> | |
| 32 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 33 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 34 | __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) | |
| 35 | noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 36 | -> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 37 | { return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 38 | ||
| 39 | template<class _Tp, class _Up> | |
| 40 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 41 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 42 | __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) | |
| 43 | noexcept(noexcept(partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 44 | -> decltype( partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 45 | { return partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 46 | ||
| 47 | template<class _Tp, class _Up> | |
| 48 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 49 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 50 | __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) | |
| 51 | noexcept(noexcept(partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 52 | -> decltype( partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 53 | { return partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 54 | ||
| 55 | template<class _Tp, class _Up> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const | |
| 57 | noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))) | |
| 58 | -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())) | |
| 59 | { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); } | |
| 60 | }; | |
| 61 | } // namespace __partial_order | |
| 62 | ||
| 63 | inline namespace __cpo { | |
| 64 | inline constexpr auto partial_order = __partial_order::__fn{}; | |
| 65 | } // namespace __cpo | |
| 66 | ||
| 67 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 68 | ||
| 69 | _LIBCPP_END_NAMESPACE_STD | |
| 70 | ||
| 71 | #endif // _LIBCPP___COMPARE_PARTIAL_ORDER |
lib/libcxx/include/__compare/strong_order.h created+136| ... | ... | @@ -0,0 +1,136 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___COMPARE_STRONG_ORDER | |
| 10 | #define _LIBCPP___COMPARE_STRONG_ORDER | |
| 11 | ||
| 12 | #include <__bit/bit_cast.h> | |
| 13 | #include <__compare/compare_three_way.h> | |
| 14 | #include <__compare/ordering.h> | |
| 15 | #include <__config> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <__utility/priority_tag.h> | |
| 18 | #include <cmath> | |
| 19 | #include <cstdint> | |
| 20 | #include <limits> | |
| 21 | #include <type_traits> | |
| 22 | ||
| 23 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 24 | #pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_PUSH_MACROS | |
| 28 | #include <__undef_macros> | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | ||
| 34 | // [cmp.alg] | |
| 35 | namespace __strong_order { | |
| 36 | struct __fn { | |
| 37 | template<class _Tp, class _Up> | |
| 38 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 39 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 40 | __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) | |
| 41 | noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 42 | -> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 43 | { return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 44 | ||
| 45 | template<class _Tp, class _Up, class _Dp = decay_t<_Tp>> | |
| 46 | requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> | |
| 47 | _LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering | |
| 48 | __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept | |
| 49 | { | |
| 50 | if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int32_t)) { | |
| 51 | int32_t __rx = _VSTD::bit_cast<int32_t>(__t); | |
| 52 | int32_t __ry = _VSTD::bit_cast<int32_t>(__u); | |
| 53 | __rx = (__rx < 0) ? (numeric_limits<int32_t>::min() - __rx - 1) : __rx; | |
| 54 | __ry = (__ry < 0) ? (numeric_limits<int32_t>::min() - __ry - 1) : __ry; | |
| 55 | return (__rx <=> __ry); | |
| 56 | } else if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int64_t)) { | |
| 57 | int64_t __rx = _VSTD::bit_cast<int64_t>(__t); | |
| 58 | int64_t __ry = _VSTD::bit_cast<int64_t>(__u); | |
| 59 | __rx = (__rx < 0) ? (numeric_limits<int64_t>::min() - __rx - 1) : __rx; | |
| 60 | __ry = (__ry < 0) ? (numeric_limits<int64_t>::min() - __ry - 1) : __ry; | |
| 61 | return (__rx <=> __ry); | |
| 62 | } else if (__t < __u) { | |
| 63 | return strong_ordering::less; | |
| 64 | } else if (__t > __u) { | |
| 65 | return strong_ordering::greater; | |
| 66 | } else if (__t == __u) { | |
| 67 | if constexpr (numeric_limits<_Dp>::radix == 2) { | |
| 68 | return _VSTD::signbit(__u) <=> _VSTD::signbit(__t); | |
| 69 | } else { | |
| 70 | // This is bullet 3 of the IEEE754 algorithm, relevant | |
| 71 | // only for decimal floating-point; | |
| 72 | // see https://stackoverflow.com/questions/69068075/ | |
| 73 | if (__t == 0 || _VSTD::isinf(__t)) { | |
| 74 | return _VSTD::signbit(__u) <=> _VSTD::signbit(__t); | |
| 75 | } else { | |
| 76 | int __texp, __uexp; | |
| 77 | (void)_VSTD::frexp(__t, &__texp); | |
| 78 | (void)_VSTD::frexp(__u, &__uexp); | |
| 79 | return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp); | |
| 80 | } | |
| 81 | } | |
| 82 | } else { | |
| 83 | // They're unordered, so one of them must be a NAN. | |
| 84 | // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN. | |
| 85 | bool __t_is_nan = _VSTD::isnan(__t); | |
| 86 | bool __u_is_nan = _VSTD::isnan(__u); | |
| 87 | bool __t_is_negative = _VSTD::signbit(__t); | |
| 88 | bool __u_is_negative = _VSTD::signbit(__u); | |
| 89 | using _IntType = conditional_t< | |
| 90 | sizeof(__t) == sizeof(int32_t), int32_t, conditional_t< | |
| 91 | sizeof(__t) == sizeof(int64_t), int64_t, void> | |
| 92 | >; | |
| 93 | if constexpr (is_same_v<_IntType, void>) { | |
| 94 | static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type"); | |
| 95 | } else if (__t_is_nan && __u_is_nan) { | |
| 96 | // Order by sign bit, then by "payload bits" (we'll just use bit_cast). | |
| 97 | if (__t_is_negative != __u_is_negative) { | |
| 98 | return (__u_is_negative <=> __t_is_negative); | |
| 99 | } else { | |
| 100 | return _VSTD::bit_cast<_IntType>(__t) <=> _VSTD::bit_cast<_IntType>(__u); | |
| 101 | } | |
| 102 | } else if (__t_is_nan) { | |
| 103 | return __t_is_negative ? strong_ordering::less : strong_ordering::greater; | |
| 104 | } else { | |
| 105 | return __u_is_negative ? strong_ordering::greater : strong_ordering::less; | |
| 106 | } | |
| 107 | } | |
| 108 | } | |
| 109 | ||
| 110 | template<class _Tp, class _Up> | |
| 111 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 112 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 113 | __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) | |
| 114 | noexcept(noexcept(strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 115 | -> decltype( strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 116 | { return strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 117 | ||
| 118 | template<class _Tp, class _Up> | |
| 119 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const | |
| 120 | noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))) | |
| 121 | -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())) | |
| 122 | { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); } | |
| 123 | }; | |
| 124 | } // namespace __strong_order | |
| 125 | ||
| 126 | inline namespace __cpo { | |
| 127 | inline constexpr auto strong_order = __strong_order::__fn{}; | |
| 128 | } // namespace __cpo | |
| 129 | ||
| 130 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 131 | ||
| 132 | _LIBCPP_END_NAMESPACE_STD | |
| 133 | ||
| 134 | _LIBCPP_POP_MACROS | |
| 135 | ||
| 136 | #endif // _LIBCPP___COMPARE_STRONG_ORDER |
lib/libcxx/include/__compare/synth_three_way.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___COMPARE_SYNTH_THREE_WAY_H | |
| 10 | #define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H | |
| 11 | ||
| 12 | #include <__compare/ordering.h> | |
| 13 | #include <__compare/three_way_comparable.h> | |
| 14 | #include <__concepts/boolean_testable.h> | |
| 15 | #include <__config> | |
| 16 | #include <__utility/declval.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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | ||
| 26 | // [expos.only.func] | |
| 27 | ||
| 28 | _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = | |
| 29 | []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u) | |
| 30 | requires requires { | |
| 31 | { __t < __u } -> __boolean_testable; | |
| 32 | { __u < __t } -> __boolean_testable; | |
| 33 | } | |
| 34 | { | |
| 35 | if constexpr (three_way_comparable_with<_Tp, _Up>) { | |
| 36 | return __t <=> __u; | |
| 37 | } else { | |
| 38 | if (__t < __u) return weak_ordering::less; | |
| 39 | if (__u < __t) return weak_ordering::greater; | |
| 40 | return weak_ordering::equivalent; | |
| 41 | } | |
| 42 | }; | |
| 43 | ||
| 44 | template <class _Tp, class _Up = _Tp> | |
| 45 | using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>())); | |
| 46 | ||
| 47 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 48 | ||
| 49 | _LIBCPP_END_NAMESPACE_STD | |
| 50 | ||
| 51 | #endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H |
lib/libcxx/include/__compare/three_way_comparable.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___COMPARE_THREE_WAY_COMPARABLE_H | |
| 10 | #define _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H | |
| 11 | ||
| 12 | #include <__compare/common_comparison_category.h> | |
| 13 | #include <__compare/ordering.h> | |
| 14 | #include <__concepts/common_reference_with.h> | |
| 15 | #include <__concepts/equality_comparable.h> | |
| 16 | #include <__concepts/same_as.h> | |
| 17 | #include <__concepts/totally_ordered.h> | |
| 18 | #include <__config> | |
| 19 | #include <type_traits> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | #pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | ||
| 29 | template<class _Tp, class _Cat> | |
| 30 | concept __compares_as = | |
| 31 | same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>; | |
| 32 | ||
| 33 | template<class _Tp, class _Cat = partial_ordering> | |
| 34 | concept three_way_comparable = | |
| 35 | __weakly_equality_comparable_with<_Tp, _Tp> && | |
| 36 | __partially_ordered_with<_Tp, _Tp> && | |
| 37 | requires(__make_const_lvalue_ref<_Tp> __a, __make_const_lvalue_ref<_Tp> __b) { | |
| 38 | { __a <=> __b } -> __compares_as<_Cat>; | |
| 39 | }; | |
| 40 | ||
| 41 | template<class _Tp, class _Up, class _Cat = partial_ordering> | |
| 42 | concept three_way_comparable_with = | |
| 43 | three_way_comparable<_Tp, _Cat> && | |
| 44 | three_way_comparable<_Up, _Cat> && | |
| 45 | common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && | |
| 46 | three_way_comparable<common_reference_t<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>, _Cat> && | |
| 47 | __weakly_equality_comparable_with<_Tp, _Up> && | |
| 48 | __partially_ordered_with<_Tp, _Up> && | |
| 49 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { | |
| 50 | { __t <=> __u } -> __compares_as<_Cat>; | |
| 51 | { __u <=> __t } -> __compares_as<_Cat>; | |
| 52 | }; | |
| 53 | ||
| 54 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 55 | ||
| 56 | _LIBCPP_END_NAMESPACE_STD | |
| 57 | ||
| 58 | #endif // _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H |
lib/libcxx/include/__compare/weak_order.h created+100| ... | ... | @@ -0,0 +1,100 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___COMPARE_WEAK_ORDER | |
| 10 | #define _LIBCPP___COMPARE_WEAK_ORDER | |
| 11 | ||
| 12 | #include <__compare/compare_three_way.h> | |
| 13 | #include <__compare/ordering.h> | |
| 14 | #include <__compare/strong_order.h> | |
| 15 | #include <__config> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <__utility/priority_tag.h> | |
| 18 | #include <cmath> | |
| 19 | #include <type_traits> | |
| 20 | ||
| 21 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 22 | #pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | ||
| 29 | // [cmp.alg] | |
| 30 | namespace __weak_order { | |
| 31 | struct __fn { | |
| 32 | template<class _Tp, class _Up> | |
| 33 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 34 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 35 | __go(_Tp&& __t, _Up&& __u, __priority_tag<3>) | |
| 36 | noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 37 | -> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 38 | { return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 39 | ||
| 40 | template<class _Tp, class _Up, class _Dp = decay_t<_Tp>> | |
| 41 | requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp> | |
| 42 | _LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering | |
| 43 | __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept | |
| 44 | { | |
| 45 | partial_ordering __po = (__t <=> __u); | |
| 46 | if (__po == partial_ordering::less) { | |
| 47 | return weak_ordering::less; | |
| 48 | } else if (__po == partial_ordering::equivalent) { | |
| 49 | return weak_ordering::equivalent; | |
| 50 | } else if (__po == partial_ordering::greater) { | |
| 51 | return weak_ordering::greater; | |
| 52 | } else { | |
| 53 | // Otherwise, at least one of them is a NaN. | |
| 54 | bool __t_is_nan = _VSTD::isnan(__t); | |
| 55 | bool __u_is_nan = _VSTD::isnan(__u); | |
| 56 | bool __t_is_negative = _VSTD::signbit(__t); | |
| 57 | bool __u_is_negative = _VSTD::signbit(__u); | |
| 58 | if (__t_is_nan && __u_is_nan) { | |
| 59 | return (__u_is_negative <=> __t_is_negative); | |
| 60 | } else if (__t_is_nan) { | |
| 61 | return __t_is_negative ? weak_ordering::less : weak_ordering::greater; | |
| 62 | } else { | |
| 63 | return __u_is_negative ? weak_ordering::greater : weak_ordering::less; | |
| 64 | } | |
| 65 | } | |
| 66 | } | |
| 67 | ||
| 68 | template<class _Tp, class _Up> | |
| 69 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 70 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 71 | __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) | |
| 72 | noexcept(noexcept(weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 73 | -> decltype( weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 74 | { return weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 75 | ||
| 76 | template<class _Tp, class _Up> | |
| 77 | requires is_same_v<decay_t<_Tp>, decay_t<_Up>> | |
| 78 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 79 | __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) | |
| 80 | noexcept(noexcept(weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))) | |
| 81 | -> decltype( weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 82 | { return weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); } | |
| 83 | ||
| 84 | template<class _Tp, class _Up> | |
| 85 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const | |
| 86 | noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()))) | |
| 87 | -> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>())) | |
| 88 | { return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()); } | |
| 89 | }; | |
| 90 | } // namespace __weak_order | |
| 91 | ||
| 92 | inline namespace __cpo { | |
| 93 | inline constexpr auto weak_order = __weak_order::__fn{}; | |
| 94 | } // namespace __cpo | |
| 95 | ||
| 96 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 97 | ||
| 98 | _LIBCPP_END_NAMESPACE_STD | |
| 99 | ||
| 100 | #endif // _LIBCPP___COMPARE_WEAK_ORDER |
lib/libcxx/include/__concepts/arithmetic.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___CONCEPTS_ARITHMETIC_H | |
| 10 | #define _LIBCPP___CONCEPTS_ARITHMETIC_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | ||
| 23 | // [concepts.arithmetic], arithmetic concepts | |
| 24 | ||
| 25 | template<class _Tp> | |
| 26 | concept integral = is_integral_v<_Tp>; | |
| 27 | ||
| 28 | template<class _Tp> | |
| 29 | concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; | |
| 30 | ||
| 31 | template<class _Tp> | |
| 32 | concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; | |
| 33 | ||
| 34 | template<class _Tp> | |
| 35 | concept floating_point = is_floating_point_v<_Tp>; | |
| 36 | ||
| 37 | // Concept helpers for the internal type traits for the fundamental types. | |
| 38 | ||
| 39 | template <class _Tp> | |
| 40 | concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value; | |
| 41 | template <class _Tp> | |
| 42 | concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value; | |
| 43 | ||
| 44 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 45 | ||
| 46 | _LIBCPP_END_NAMESPACE_STD | |
| 47 | ||
| 48 | #endif // _LIBCPP___CONCEPTS_ARITHMETIC_H |
lib/libcxx/include/__concepts/assignable.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___CONCEPTS_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__concepts/common_reference_with.h> | |
| 13 | #include <__concepts/same_as.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <type_traits> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | ||
| 26 | // [concept.assignable] | |
| 27 | ||
| 28 | template<class _Lhs, class _Rhs> | |
| 29 | concept assignable_from = | |
| 30 | is_lvalue_reference_v<_Lhs> && | |
| 31 | common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> && | |
| 32 | requires (_Lhs __lhs, _Rhs&& __rhs) { | |
| 33 | { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>; | |
| 34 | }; | |
| 35 | ||
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 37 | ||
| 38 | _LIBCPP_END_NAMESPACE_STD | |
| 39 | ||
| 40 | #endif // _LIBCPP___CONCEPTS_ASSIGNABLE_H |
lib/libcxx/include/__concepts/boolean_testable.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___CONCEPTS_BOOLEAN_TESTABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H | |
| 11 | ||
| 12 | #include <__concepts/convertible_to.h> | |
| 13 | #include <__config> | |
| 14 | #include <__utility/forward.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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | ||
| 24 | // [concepts.booleantestable] | |
| 25 | ||
| 26 | template<class _Tp> | |
| 27 | concept __boolean_testable_impl = convertible_to<_Tp, bool>; | |
| 28 | ||
| 29 | template<class _Tp> | |
| 30 | concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) { | |
| 31 | { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl; | |
| 32 | }; | |
| 33 | ||
| 34 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | ||
| 36 | _LIBCPP_END_NAMESPACE_STD | |
| 37 | ||
| 38 | #endif // _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H |
lib/libcxx/include/__concepts/class_or_enum.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___CONCEPTS_CLASS_OR_ENUM_H | |
| 10 | #define _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | ||
| 23 | // Whether a type is a class type or enumeration type according to the Core wording. | |
| 24 | ||
| 25 | template<class _Tp> | |
| 26 | concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; | |
| 27 | ||
| 28 | // Work around Clang bug https://llvm.org/PR52970 | |
| 29 | template<class _Tp> | |
| 30 | concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>; | |
| 31 | ||
| 32 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H |
lib/libcxx/include/__concepts/common_reference_with.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___CONCEPTS_COMMON_REFERENCE_WITH_H | |
| 10 | #define _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H | |
| 11 | ||
| 12 | #include <__concepts/convertible_to.h> | |
| 13 | #include <__concepts/same_as.h> | |
| 14 | #include <__config> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.commonref] | |
| 26 | ||
| 27 | template<class _Tp, class _Up> | |
| 28 | concept common_reference_with = | |
| 29 | same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> && | |
| 30 | convertible_to<_Tp, common_reference_t<_Tp, _Up>> && | |
| 31 | convertible_to<_Up, common_reference_t<_Tp, _Up>>; | |
| 32 | ||
| 33 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H |
lib/libcxx/include/__concepts/common_with.h created+47| ... | ... | @@ -0,0 +1,47 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CONCEPTS_COMMON_WITH_H | |
| 10 | #define _LIBCPP___CONCEPTS_COMMON_WITH_H | |
| 11 | ||
| 12 | #include <__concepts/common_reference_with.h> | |
| 13 | #include <__concepts/same_as.h> | |
| 14 | #include <__config> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.common] | |
| 26 | ||
| 27 | template<class _Tp, class _Up> | |
| 28 | concept common_with = | |
| 29 | same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> && | |
| 30 | requires { | |
| 31 | static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>()); | |
| 32 | static_cast<common_type_t<_Tp, _Up>>(declval<_Up>()); | |
| 33 | } && | |
| 34 | common_reference_with< | |
| 35 | add_lvalue_reference_t<const _Tp>, | |
| 36 | add_lvalue_reference_t<const _Up>> && | |
| 37 | common_reference_with< | |
| 38 | add_lvalue_reference_t<common_type_t<_Tp, _Up>>, | |
| 39 | common_reference_t< | |
| 40 | add_lvalue_reference_t<const _Tp>, | |
| 41 | add_lvalue_reference_t<const _Up>>>; | |
| 42 | ||
| 43 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 44 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | |
| 46 | ||
| 47 | #endif // _LIBCPP___CONCEPTS_COMMON_WITH_H |
lib/libcxx/include/__concepts/constructible.h created+56| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__concepts/convertible_to.h> | |
| 13 | #include <__concepts/destructible.h> | |
| 14 | #include <__config> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.constructible] | |
| 26 | template<class _Tp, class... _Args> | |
| 27 | concept constructible_from = | |
| 28 | destructible<_Tp> && is_constructible_v<_Tp, _Args...>; | |
| 29 | ||
| 30 | // [concept.default.init] | |
| 31 | ||
| 32 | template<class _Tp> | |
| 33 | concept __default_initializable = requires { ::new _Tp; }; | |
| 34 | ||
| 35 | template<class _Tp> | |
| 36 | concept default_initializable = constructible_from<_Tp> && | |
| 37 | requires { _Tp{}; } && __default_initializable<_Tp>; | |
| 38 | ||
| 39 | // [concept.moveconstructible] | |
| 40 | template<class _Tp> | |
| 41 | concept move_constructible = | |
| 42 | constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; | |
| 43 | ||
| 44 | // [concept.copyconstructible] | |
| 45 | template<class _Tp> | |
| 46 | concept copy_constructible = | |
| 47 | move_constructible<_Tp> && | |
| 48 | constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> && | |
| 49 | constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> && | |
| 50 | constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>; | |
| 51 | ||
| 52 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 53 | ||
| 54 | _LIBCPP_END_NAMESPACE_STD | |
| 55 | ||
| 56 | #endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H |
lib/libcxx/include/__concepts/convertible_to.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___CONCEPTS_CONVERTIBLE_TO_H | |
| 10 | #define _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__utility/declval.h> | |
| 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 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | ||
| 24 | // [concept.convertible] | |
| 25 | ||
| 26 | template<class _From, class _To> | |
| 27 | concept convertible_to = | |
| 28 | is_convertible_v<_From, _To> && | |
| 29 | requires { | |
| 30 | static_cast<_To>(declval<_From>()); | |
| 31 | }; | |
| 32 | ||
| 33 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H |
lib/libcxx/include/__concepts/copyable.h created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CONCEPTS_COPYABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_COPYABLE_H | |
| 11 | ||
| 12 | #include <__concepts/assignable.h> | |
| 13 | #include <__concepts/constructible.h> | |
| 14 | #include <__concepts/movable.h> | |
| 15 | #include <__config> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concepts.object] | |
| 26 | ||
| 27 | template<class _Tp> | |
| 28 | concept copyable = | |
| 29 | copy_constructible<_Tp> && | |
| 30 | movable<_Tp> && | |
| 31 | assignable_from<_Tp&, _Tp&> && | |
| 32 | assignable_from<_Tp&, const _Tp&> && | |
| 33 | assignable_from<_Tp&, const _Tp>; | |
| 34 | ||
| 35 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 36 | ||
| 37 | _LIBCPP_END_NAMESPACE_STD | |
| 38 | ||
| 39 | #endif // _LIBCPP___CONCEPTS_COPYABLE_H |
lib/libcxx/include/__concepts/derived_from.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___CONCEPTS_DERIVED_FROM_H | |
| 10 | #define _LIBCPP___CONCEPTS_DERIVED_FROM_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | ||
| 23 | // [concept.derived] | |
| 24 | ||
| 25 | template<class _Dp, class _Bp> | |
| 26 | concept derived_from = | |
| 27 | is_base_of_v<_Bp, _Dp> && | |
| 28 | is_convertible_v<const volatile _Dp*, const volatile _Bp*>; | |
| 29 | ||
| 30 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___CONCEPTS_DERIVED_FROM_H |
lib/libcxx/include/__concepts/destructible.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___CONCEPTS_DESTRUCTIBLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_DESTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | ||
| 23 | // [concept.destructible] | |
| 24 | ||
| 25 | template<class _Tp> | |
| 26 | concept destructible = is_nothrow_destructible_v<_Tp>; | |
| 27 | ||
| 28 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___CONCEPTS_DESTRUCTIBLE_H |
lib/libcxx/include/__concepts/different_from.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___CONCEPTS_DIFFERENT_FROM_H | |
| 10 | #define _LIBCPP___CONCEPTS_DIFFERENT_FROM_H | |
| 11 | ||
| 12 | #include <__concepts/same_as.h> | |
| 13 | #include <__config> | |
| 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 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | ||
| 24 | template<class _Tp, class _Up> | |
| 25 | concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>; | |
| 26 | ||
| 27 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___CONCEPTS_DIFFERENT_FROM_H |
lib/libcxx/include/__concepts/equality_comparable.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___CONCEPTS_EQUALITY_COMPARABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H | |
| 11 | ||
| 12 | #include <__concepts/boolean_testable.h> | |
| 13 | #include <__concepts/common_reference_with.h> | |
| 14 | #include <__config> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.equalitycomparable] | |
| 26 | ||
| 27 | template<class _Tp, class _Up> | |
| 28 | concept __weakly_equality_comparable_with = | |
| 29 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { | |
| 30 | { __t == __u } -> __boolean_testable; | |
| 31 | { __t != __u } -> __boolean_testable; | |
| 32 | { __u == __t } -> __boolean_testable; | |
| 33 | { __u != __t } -> __boolean_testable; | |
| 34 | }; | |
| 35 | ||
| 36 | template<class _Tp> | |
| 37 | concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>; | |
| 38 | ||
| 39 | template<class _Tp, class _Up> | |
| 40 | concept equality_comparable_with = | |
| 41 | equality_comparable<_Tp> && equality_comparable<_Up> && | |
| 42 | common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && | |
| 43 | equality_comparable< | |
| 44 | common_reference_t< | |
| 45 | __make_const_lvalue_ref<_Tp>, | |
| 46 | __make_const_lvalue_ref<_Up>>> && | |
| 47 | __weakly_equality_comparable_with<_Tp, _Up>; | |
| 48 | ||
| 49 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H |
lib/libcxx/include/__concepts/invocable.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___CONCEPTS_INVOCABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_INVOCABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/invoke.h> | |
| 14 | #include <__utility/forward.h> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.invocable] | |
| 26 | ||
| 27 | template<class _Fn, class... _Args> | |
| 28 | concept invocable = requires(_Fn&& __fn, _Args&&... __args) { | |
| 29 | _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving | |
| 30 | }; | |
| 31 | ||
| 32 | // [concept.regular.invocable] | |
| 33 | ||
| 34 | template<class _Fn, class... _Args> | |
| 35 | concept regular_invocable = invocable<_Fn, _Args...>; | |
| 36 | ||
| 37 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___CONCEPTS_INVOCABLE_H |
lib/libcxx/include/__concepts/movable.h created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___CONCEPTS_MOVABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_MOVABLE_H | |
| 11 | ||
| 12 | #include <__concepts/assignable.h> | |
| 13 | #include <__concepts/constructible.h> | |
| 14 | #include <__concepts/swappable.h> | |
| 15 | #include <__config> | |
| 16 | #include <type_traits> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | ||
| 26 | // [concepts.object] | |
| 27 | ||
| 28 | template<class _Tp> | |
| 29 | concept movable = | |
| 30 | is_object_v<_Tp> && | |
| 31 | move_constructible<_Tp> && | |
| 32 | assignable_from<_Tp&, _Tp> && | |
| 33 | swappable<_Tp>; | |
| 34 | ||
| 35 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 36 | ||
| 37 | _LIBCPP_END_NAMESPACE_STD | |
| 38 | ||
| 39 | #endif // _LIBCPP___CONCEPTS_MOVABLE_H |
lib/libcxx/include/__concepts/predicate.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___CONCEPTS_PREDICATE_H | |
| 10 | #define _LIBCPP___CONCEPTS_PREDICATE_H | |
| 11 | ||
| 12 | #include <__concepts/boolean_testable.h> | |
| 13 | #include <__concepts/invocable.h> | |
| 14 | #include <__config> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.predicate] | |
| 26 | ||
| 27 | template<class _Fn, class... _Args> | |
| 28 | concept predicate = | |
| 29 | regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>; | |
| 30 | ||
| 31 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___CONCEPTS_PREDICATE_H |
lib/libcxx/include/__concepts/regular.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___CONCEPTS_REGULAR_H | |
| 10 | #define _LIBCPP___CONCEPTS_REGULAR_H | |
| 11 | ||
| 12 | #include <__concepts/equality_comparable.h> | |
| 13 | #include <__concepts/semiregular.h> | |
| 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 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | ||
| 24 | // [concept.object] | |
| 25 | ||
| 26 | template<class _Tp> | |
| 27 | concept regular = semiregular<_Tp> && equality_comparable<_Tp>; | |
| 28 | ||
| 29 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___CONCEPTS_REGULAR_H |
lib/libcxx/include/__concepts/relation.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___CONCEPTS_RELATION_H | |
| 10 | #define _LIBCPP___CONCEPTS_RELATION_H | |
| 11 | ||
| 12 | #include <__concepts/predicate.h> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | ||
| 23 | // [concept.relation] | |
| 24 | ||
| 25 | template<class _Rp, class _Tp, class _Up> | |
| 26 | concept relation = | |
| 27 | predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> && | |
| 28 | predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>; | |
| 29 | ||
| 30 | // [concept.equiv] | |
| 31 | ||
| 32 | template<class _Rp, class _Tp, class _Up> | |
| 33 | concept equivalence_relation = relation<_Rp, _Tp, _Up>; | |
| 34 | ||
| 35 | // [concept.strictweakorder] | |
| 36 | ||
| 37 | template<class _Rp, class _Tp, class _Up> | |
| 38 | concept strict_weak_order = relation<_Rp, _Tp, _Up>; | |
| 39 | ||
| 40 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 41 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | |
| 43 | ||
| 44 | #endif // _LIBCPP___CONCEPTS_RELATION_H |
lib/libcxx/include/__concepts/same_as.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___CONCEPTS_SAME_AS_H | |
| 10 | #define _LIBCPP___CONCEPTS_SAME_AS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | ||
| 23 | // [concept.same] | |
| 24 | ||
| 25 | template<class _Tp, class _Up> | |
| 26 | concept __same_as_impl = _IsSame<_Tp, _Up>::value; | |
| 27 | ||
| 28 | template<class _Tp, class _Up> | |
| 29 | concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>; | |
| 30 | ||
| 31 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___CONCEPTS_SAME_AS_H |
lib/libcxx/include/__concepts/semiregular.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___CONCEPTS_SEMIREGULAR_H | |
| 10 | #define _LIBCPP___CONCEPTS_SEMIREGULAR_H | |
| 11 | ||
| 12 | #include <__concepts/constructible.h> | |
| 13 | #include <__concepts/copyable.h> | |
| 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 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | ||
| 24 | // [concept.object] | |
| 25 | ||
| 26 | template<class _Tp> | |
| 27 | concept semiregular = copyable<_Tp> && default_initializable<_Tp>; | |
| 28 | ||
| 29 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___CONCEPTS_SEMIREGULAR_H |
lib/libcxx/include/__concepts/swappable.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___CONCEPTS_SWAPPABLE_H | |
| 10 | #define _LIBCPP___CONCEPTS_SWAPPABLE_H | |
| 11 | ||
| 12 | #include <__concepts/assignable.h> | |
| 13 | #include <__concepts/class_or_enum.h> | |
| 14 | #include <__concepts/common_reference_with.h> | |
| 15 | #include <__concepts/constructible.h> | |
| 16 | #include <__config> | |
| 17 | #include <__utility/exchange.h> | |
| 18 | #include <__utility/forward.h> | |
| 19 | #include <__utility/move.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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | ||
| 30 | // [concept.swappable] | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | namespace __swap { | |
| 34 | ||
| 35 | template<class _Tp> | |
| 36 | void swap(_Tp&, _Tp&) = delete; | |
| 37 | ||
| 38 | template<class _Tp, class _Up> | |
| 39 | concept __unqualified_swappable_with = | |
| 40 | (__class_or_enum<remove_cvref_t<_Tp>> || __class_or_enum<remove_cvref_t<_Up>>) && | |
| 41 | requires(_Tp&& __t, _Up&& __u) { | |
| 42 | swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); | |
| 43 | }; | |
| 44 | ||
| 45 | struct __fn; | |
| 46 | ||
| 47 | template<class _Tp, class _Up, size_t _Size> | |
| 48 | concept __swappable_arrays = | |
| 49 | !__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> && | |
| 50 | extent_v<_Tp> == extent_v<_Up> && | |
| 51 | requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) { | |
| 52 | __swap(__t[0], __u[0]); | |
| 53 | }; | |
| 54 | ||
| 55 | template<class _Tp> | |
| 56 | concept __exchangeable = | |
| 57 | !__unqualified_swappable_with<_Tp&, _Tp&> && | |
| 58 | move_constructible<_Tp> && | |
| 59 | assignable_from<_Tp&, _Tp>; | |
| 60 | ||
| 61 | struct __fn { | |
| 62 | // 2.1 `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and... | |
| 63 | // *The name `swap` is used here unqualified. | |
| 64 | template<class _Tp, class _Up> | |
| 65 | requires __unqualified_swappable_with<_Tp, _Up> | |
| 66 | constexpr void operator()(_Tp&& __t, _Up&& __u) const | |
| 67 | noexcept(noexcept(swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 68 | { | |
| 69 | swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); | |
| 70 | } | |
| 71 | ||
| 72 | // 2.2 Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and... | |
| 73 | template<class _Tp, class _Up, size_t _Size> | |
| 74 | requires __swappable_arrays<_Tp, _Up, _Size> | |
| 75 | constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const | |
| 76 | noexcept(noexcept((*this)(*__t, *__u))) | |
| 77 | { | |
| 78 | // TODO(cjdb): replace with `ranges::swap_ranges`. | |
| 79 | for (size_t __i = 0; __i < _Size; ++__i) { | |
| 80 | (*this)(__t[__i], __u[__i]); | |
| 81 | } | |
| 82 | } | |
| 83 | ||
| 84 | // 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models... | |
| 85 | template<__exchangeable _Tp> | |
| 86 | constexpr void operator()(_Tp& __x, _Tp& __y) const | |
| 87 | noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>) | |
| 88 | { | |
| 89 | __y = _VSTD::exchange(__x, _VSTD::move(__y)); | |
| 90 | } | |
| 91 | }; | |
| 92 | } // namespace __swap | |
| 93 | ||
| 94 | inline namespace __cpo { | |
| 95 | inline constexpr auto swap = __swap::__fn{}; | |
| 96 | } // namespace __cpo | |
| 97 | } // namespace ranges | |
| 98 | ||
| 99 | template<class _Tp> | |
| 100 | concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; | |
| 101 | ||
| 102 | template<class _Tp, class _Up> | |
| 103 | concept swappable_with = | |
| 104 | common_reference_with<_Tp, _Up> && | |
| 105 | requires(_Tp&& __t, _Up&& __u) { | |
| 106 | ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Tp>(__t)); | |
| 107 | ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Up>(__u)); | |
| 108 | ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); | |
| 109 | ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t)); | |
| 110 | }; | |
| 111 | ||
| 112 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 113 | ||
| 114 | _LIBCPP_END_NAMESPACE_STD | |
| 115 | ||
| 116 | #endif // _LIBCPP___CONCEPTS_SWAPPABLE_H |
lib/libcxx/include/__concepts/totally_ordered.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___CONCEPTS_TOTALLY_ORDERED_H | |
| 10 | #define _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H | |
| 11 | ||
| 12 | #include <__concepts/boolean_testable.h> | |
| 13 | #include <__concepts/equality_comparable.h> | |
| 14 | #include <__config> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | ||
| 25 | // [concept.totallyordered] | |
| 26 | ||
| 27 | template<class _Tp, class _Up> | |
| 28 | concept __partially_ordered_with = | |
| 29 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { | |
| 30 | { __t < __u } -> __boolean_testable; | |
| 31 | { __t > __u } -> __boolean_testable; | |
| 32 | { __t <= __u } -> __boolean_testable; | |
| 33 | { __t >= __u } -> __boolean_testable; | |
| 34 | { __u < __t } -> __boolean_testable; | |
| 35 | { __u > __t } -> __boolean_testable; | |
| 36 | { __u <= __t } -> __boolean_testable; | |
| 37 | { __u >= __t } -> __boolean_testable; | |
| 38 | }; | |
| 39 | ||
| 40 | template<class _Tp> | |
| 41 | concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>; | |
| 42 | ||
| 43 | template<class _Tp, class _Up> | |
| 44 | concept totally_ordered_with = | |
| 45 | totally_ordered<_Tp> && totally_ordered<_Up> && | |
| 46 | equality_comparable_with<_Tp, _Up> && | |
| 47 | totally_ordered< | |
| 48 | common_reference_t< | |
| 49 | __make_const_lvalue_ref<_Tp>, | |
| 50 | __make_const_lvalue_ref<_Up>>> && | |
| 51 | __partially_ordered_with<_Tp, _Up>; | |
| 52 | ||
| 53 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 54 | ||
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 56 | ||
| 57 | #endif // _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H |
lib/libcxx/include/__config+175-211| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- __config ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -10,6 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP_CONFIG |
| 11 | 11 | #define _LIBCPP_CONFIG |
| 12 | 12 | |
| 13 | #include <__config_site> | |
| 14 | ||
| 13 | 15 | #if defined(_MSC_VER) && !defined(__clang__) |
| 14 | 16 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | 17 | # define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| ... | ... | @@ -22,17 +24,7 @@ |
| 22 | 24 | |
| 23 | 25 | #ifdef __cplusplus |
| 24 | 26 | |
| 25 | #ifdef __GNUC__ | |
| 26 | # define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) | |
| 27 | // The _GNUC_VER_NEW macro better represents the new GCC versioning scheme | |
| 28 | // introduced in GCC 5.0. | |
| 29 | # define _GNUC_VER_NEW (_GNUC_VER * 10 + __GNUC_PATCHLEVEL__) | |
| 30 | #else | |
| 31 | # define _GNUC_VER 0 | |
| 32 | # define _GNUC_VER_NEW 0 | |
| 33 | #endif | |
| 34 | ||
| 35 | #define _LIBCPP_VERSION 13000 | |
| 27 | #define _LIBCPP_VERSION 14000 | |
| 36 | 28 | |
| 37 | 29 | #ifndef _LIBCPP_ABI_VERSION |
| 38 | 30 | # define _LIBCPP_ABI_VERSION 1 |
| ... | ... | @@ -82,14 +74,15 @@ |
| 82 | 74 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB |
| 83 | 75 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB |
| 84 | 76 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE |
| 85 | // Don't use a nullptr_t simulation type in C++03 instead using C++11 nullptr | |
| 86 | // provided under the alternate keyword __nullptr, which changes the mangling | |
| 87 | // of nullptr_t. This option is ABI incompatible with GCC in C++03 mode. | |
| 88 | # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR | |
| 89 | 77 | // Define a key function for `bad_function_call` in the library, to centralize |
| 90 | 78 | // its vtable and typeinfo to libc++ rather than having all other libraries |
| 91 | 79 | // using that class define their own copies. |
| 92 | 80 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION |
| 81 | // Override the default return value of exception::what() for | |
| 82 | // bad_function_call::what() with a string that is specific to | |
| 83 | // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break | |
| 84 | // because it changes the vtable layout of bad_function_call. | |
| 85 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | |
| 93 | 86 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. |
| 94 | 87 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET |
| 95 | 88 | // In C++20 and later, don't derive std::plus from std::binary_function, |
| ... | ... | @@ -114,6 +107,17 @@ |
| 114 | 107 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI |
| 115 | 108 | // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr |
| 116 | 109 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI |
| 110 | // std::random_device holds some state when it uses an implementation that gets | |
| 111 | // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this | |
| 112 | // implementation to another one on a platform that has already shipped | |
| 113 | // std::random_device, one needs to retain the same object layout to remain ABI | |
| 114 | // compatible. This switch removes these workarounds for platforms that don't care | |
| 115 | // about ABI compatibility. | |
| 116 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | |
| 117 | // Remove basic_string common base | |
| 118 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | |
| 119 | // Remove vector base class | |
| 120 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | |
| 117 | 121 | #elif _LIBCPP_ABI_VERSION == 1 |
| 118 | 122 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) |
| 119 | 123 | // Enable compiling copies of now inline methods into the dylib to support |
| ... | ... | @@ -125,16 +129,38 @@ |
| 125 | 129 | # endif |
| 126 | 130 | // Feature macros for disabling pre ABI v1 features. All of these options |
| 127 | 131 | // are deprecated. |
| 128 | # if defined(__FreeBSD__) || defined(__DragonFly__) | |
| 132 | # if defined(__FreeBSD__) | |
| 129 | 133 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR |
| 130 | 134 | # endif |
| 131 | 135 | #endif |
| 132 | 136 | |
| 137 | // By default, don't use a nullptr_t emulation type in C++03. | |
| 138 | // | |
| 139 | // This is technically an ABI break from previous releases, however it is | |
| 140 | // very unlikely to impact anyone. If a user is impacted by this break, | |
| 141 | // they can return to using the C++03 nullptr emulation by defining | |
| 142 | // _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION. | |
| 143 | // | |
| 144 | // This switch will be removed entirely in favour of never providing a | |
| 145 | // C++03 emulation after one release. | |
| 146 | // | |
| 147 | // IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE | |
| 148 | // A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN | |
| 149 | // IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION. | |
| 150 | #ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION | |
| 151 | # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR | |
| 152 | #endif | |
| 153 | ||
| 133 | 154 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 |
| 134 | 155 | // Enable additional explicit instantiations of iostreams components. This |
| 135 | 156 | // reduces the number of weak definitions generated in programs that use |
| 136 | 157 | // iostreams by providing a single strong definition in the shared library. |
| 137 | 158 | # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 |
| 159 | ||
| 160 | // Define a key function for `bad_function_call` in the library, to centralize | |
| 161 | // its vtable and typeinfo to libc++ rather than having all other libraries | |
| 162 | // using that class define their own copies. | |
| 163 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 138 | 164 | #endif |
| 139 | 165 | |
| 140 | 166 | #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y |
| ... | ... | @@ -235,6 +261,10 @@ |
| 235 | 261 | # endif // defined(__GLIBC_PREREQ) |
| 236 | 262 | #endif // defined(__linux__) |
| 237 | 263 | |
| 264 | #if defined(__MVS__) | |
| 265 | # include <features.h> // for __NATIVE_ASCII_F | |
| 266 | #endif | |
| 267 | ||
| 238 | 268 | #ifdef __LITTLE_ENDIAN__ |
| 239 | 269 | # if __LITTLE_ENDIAN__ |
| 240 | 270 | # define _LIBCPP_LITTLE_ENDIAN |
| ... | ... | @@ -263,9 +293,6 @@ |
| 263 | 293 | # else // _BYTE_ORDER == _LITTLE_ENDIAN |
| 264 | 294 | # define _LIBCPP_BIG_ENDIAN |
| 265 | 295 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN |
| 266 | # ifndef __LONG_LONG_SUPPORTED | |
| 267 | # define _LIBCPP_HAS_NO_LONG_LONG | |
| 268 | # endif // __LONG_LONG_SUPPORTED | |
| 269 | 296 | #endif // __FreeBSD__ |
| 270 | 297 | |
| 271 | 298 | #if defined(__NetBSD__) || defined(__OpenBSD__) |
| ... | ... | @@ -316,18 +343,56 @@ |
| 316 | 343 | # endif |
| 317 | 344 | #endif // __sun__ |
| 318 | 345 | |
| 319 | #if defined(__OpenBSD__) || defined(__CloudABI__) | |
| 320 | // Certain architectures provide arc4random(). Prefer using | |
| 321 | // arc4random() over /dev/{u,}random to make it possible to obtain | |
| 322 | // random data even when using sandboxing mechanisms such as chroots, | |
| 323 | // Capsicum, etc. | |
| 346 | #if defined(_AIX) && !defined(__64BIT__) | |
| 347 | // The size of wchar is 2 byte on 32-bit mode on AIX. | |
| 348 | # define _LIBCPP_SHORT_WCHAR 1 | |
| 349 | #endif | |
| 350 | ||
| 351 | // Libc++ supports various implementations of std::random_device. | |
| 352 | // | |
| 353 | // _LIBCPP_USING_DEV_RANDOM | |
| 354 | // Read entropy from the given file, by default `/dev/urandom`. | |
| 355 | // If a token is provided, it is assumed to be the path to a file | |
| 356 | // to read entropy from. This is the default behavior if nothing | |
| 357 | // else is specified. This implementation requires storing state | |
| 358 | // inside `std::random_device`. | |
| 359 | // | |
| 360 | // _LIBCPP_USING_ARC4_RANDOM | |
| 361 | // Use arc4random(). This allows obtaining random data even when | |
| 362 | // using sandboxing mechanisms. On some platforms like Apple, this | |
| 363 | // is the recommended source of entropy for user-space programs. | |
| 364 | // When this option is used, the token passed to `std::random_device`'s | |
| 365 | // constructor *must* be "/dev/urandom" -- anything else is an error. | |
| 366 | // | |
| 367 | // _LIBCPP_USING_GETENTROPY | |
| 368 | // Use getentropy(). | |
| 369 | // When this option is used, the token passed to `std::random_device`'s | |
| 370 | // constructor *must* be "/dev/urandom" -- anything else is an error. | |
| 371 | // | |
| 372 | // _LIBCPP_USING_FUCHSIA_CPRNG | |
| 373 | // Use Fuchsia's zx_cprng_draw() system call, which is specified to | |
| 374 | // deliver high-quality entropy and cannot fail. | |
| 375 | // When this option is used, the token passed to `std::random_device`'s | |
| 376 | // constructor *must* be "/dev/urandom" -- anything else is an error. | |
| 377 | // | |
| 378 | // _LIBCPP_USING_NACL_RANDOM | |
| 379 | // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, | |
| 380 | // including accesses to the special files under `/dev`. This implementation | |
| 381 | // uses the NaCL syscall `nacl_secure_random_init()` to get entropy. | |
| 382 | // When this option is used, the token passed to `std::random_device`'s | |
| 383 | // constructor *must* be "/dev/urandom" -- anything else is an error. | |
| 384 | // | |
| 385 | // _LIBCPP_USING_WIN32_RANDOM | |
| 386 | // Use rand_s(), for use on Windows. | |
| 387 | // When this option is used, the token passed to `std::random_device`'s | |
| 388 | // constructor *must* be "/dev/urandom" -- anything else is an error. | |
| 389 | #if defined(__OpenBSD__) || defined(__APPLE__) | |
| 324 | 390 | # define _LIBCPP_USING_ARC4_RANDOM |
| 325 | #elif defined(__Fuchsia__) || defined(__wasi__) | |
| 391 | #elif defined(__wasi__) | |
| 326 | 392 | # define _LIBCPP_USING_GETENTROPY |
| 393 | #elif defined(__Fuchsia__) | |
| 394 | # define _LIBCPP_USING_FUCHSIA_CPRNG | |
| 327 | 395 | #elif defined(__native_client__) |
| 328 | // NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access, | |
| 329 | // including accesses to the special files under /dev. C++11's | |
| 330 | // std::random_device is instead exposed through a NaCl syscall. | |
| 331 | 396 | # define _LIBCPP_USING_NACL_RANDOM |
| 332 | 397 | #elif defined(_LIBCPP_WIN32API) |
| 333 | 398 | # define _LIBCPP_USING_WIN32_RANDOM |
| ... | ... | @@ -380,7 +445,7 @@ |
| 380 | 445 | # if __ANDROID_API__ >= 29 |
| 381 | 446 | # define _LIBCPP_HAS_TIMESPEC_GET |
| 382 | 447 | # endif |
| 383 | # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) || defined(__DragonFly__) | |
| 448 | # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) | |
| 384 | 449 | # define _LIBCPP_HAS_ALIGNED_ALLOC |
| 385 | 450 | # define _LIBCPP_HAS_QUICK_EXIT |
| 386 | 451 | # define _LIBCPP_HAS_TIMESPEC_GET |
| ... | ... | @@ -490,14 +555,6 @@ typedef __char32_t char32_t; |
| 490 | 555 | # define _LIBCPP_HAS_BLOCKS_RUNTIME |
| 491 | 556 | #endif |
| 492 | 557 | |
| 493 | #if !(__has_feature(cxx_relaxed_constexpr)) | |
| 494 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR | |
| 495 | #endif | |
| 496 | ||
| 497 | #if !(__has_feature(cxx_variable_templates)) | |
| 498 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES | |
| 499 | #endif | |
| 500 | ||
| 501 | 558 | #if !(__has_feature(cxx_noexcept)) |
| 502 | 559 | #define _LIBCPP_HAS_NO_NOEXCEPT |
| 503 | 560 | #endif |
| ... | ... | @@ -511,26 +568,8 @@ typedef __char32_t char32_t; |
| 511 | 568 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) |
| 512 | 569 | #endif |
| 513 | 570 | |
| 514 | #if __has_builtin(__builtin_launder) | |
| 515 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER | |
| 516 | #endif | |
| 517 | ||
| 518 | #if __has_builtin(__builtin_constant_p) | |
| 519 | #define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P | |
| 520 | #endif | |
| 521 | ||
| 522 | #if !__is_identifier(__has_unique_object_representations) | |
| 523 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS | |
| 524 | #endif | |
| 525 | ||
| 526 | 571 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 527 | 572 | |
| 528 | // Literal operators ""d and ""y are supported starting with LLVM Clang 8 and AppleClang 10.0.1 | |
| 529 | #if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 800) || \ | |
| 530 | (defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1001) | |
| 531 | #define _LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS | |
| 532 | #endif | |
| 533 | ||
| 534 | 573 | #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ |
| 535 | 574 | |
| 536 | 575 | #elif defined(_LIBCPP_COMPILER_GCC) |
| ... | ... | @@ -544,26 +583,10 @@ typedef __char32_t char32_t; |
| 544 | 583 | # define _LIBCPP_NO_EXCEPTIONS |
| 545 | 584 | #endif |
| 546 | 585 | |
| 547 | // Determine if GCC supports relaxed constexpr | |
| 548 | #if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L | |
| 549 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR | |
| 550 | #endif | |
| 551 | ||
| 552 | // GCC 5 supports variable templates | |
| 553 | #if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L | |
| 554 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES | |
| 555 | #endif | |
| 556 | ||
| 557 | 586 | #if !defined(__SANITIZE_ADDRESS__) |
| 558 | 587 | #define _LIBCPP_HAS_NO_ASAN |
| 559 | 588 | #endif |
| 560 | 589 | |
| 561 | #if _GNUC_VER >= 700 | |
| 562 | #define _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER | |
| 563 | #define _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P | |
| 564 | #define _LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS | |
| 565 | #endif | |
| 566 | ||
| 567 | 590 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) |
| 568 | 591 | |
| 569 | 592 | #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ |
| ... | ... | @@ -578,8 +601,6 @@ typedef __char32_t char32_t; |
| 578 | 601 | #error "MSVC versions prior to Visual Studio 2015 are not supported" |
| 579 | 602 | #endif |
| 580 | 603 | |
| 581 | #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR | |
| 582 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES | |
| 583 | 604 | #define __alignof__ __alignof |
| 584 | 605 | #define _LIBCPP_NORETURN __declspec(noreturn) |
| 585 | 606 | #define _ALIGNAS(x) __declspec(align(x)) |
| ... | ... | @@ -603,7 +624,6 @@ typedef __char32_t char32_t; |
| 603 | 624 | #define _LIBCPP_NORETURN __attribute__((noreturn)) |
| 604 | 625 | |
| 605 | 626 | #define _LIBCPP_HAS_NO_UNICODE_CHARS |
| 606 | #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES | |
| 607 | 627 | |
| 608 | 628 | #if defined(_AIX) |
| 609 | 629 | #define __MULTILOCALE_API |
| ... | ... | @@ -803,10 +823,10 @@ typedef __char32_t char32_t; |
| 803 | 823 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. |
| 804 | 824 | #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { |
| 805 | 825 | #define _LIBCPP_END_NAMESPACE_STD } } |
| 806 | #define _VSTD std::_LIBCPP_ABI_NAMESPACE | |
| 826 | #define _VSTD std | |
| 807 | 827 | _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD |
| 808 | 828 | |
| 809 | #if _LIBCPP_STD_VER >= 17 | |
| 829 | #if _LIBCPP_STD_VER > 14 | |
| 810 | 830 | #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ |
| 811 | 831 | _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { |
| 812 | 832 | #else |
| ... | ... | @@ -834,7 +854,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD |
| 834 | 854 | #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 835 | 855 | typedef unsigned short char16_t; |
| 836 | 856 | typedef unsigned int char32_t; |
| 837 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 857 | #endif | |
| 838 | 858 | |
| 839 | 859 | #ifndef __SIZEOF_INT128__ |
| 840 | 860 | #define _LIBCPP_HAS_NO_INT128 |
| ... | ... | @@ -857,26 +877,10 @@ typedef unsigned int char32_t; |
| 857 | 877 | # define _LIBCPP_CONSTEVAL consteval |
| 858 | 878 | #endif |
| 859 | 879 | |
| 860 | #if !defined(__cpp_concepts) || __cpp_concepts < 201907L | |
| 880 | #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L | |
| 861 | 881 | #define _LIBCPP_HAS_NO_CONCEPTS |
| 862 | 882 | #endif |
| 863 | 883 | |
| 864 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 865 | #define _LIBCPP_HAS_NO_RANGES | |
| 866 | #endif | |
| 867 | ||
| 868 | #ifdef _LIBCPP_CXX03_LANG | |
| 869 | # define _LIBCPP_DEFAULT {} | |
| 870 | #else | |
| 871 | # define _LIBCPP_DEFAULT = default; | |
| 872 | #endif | |
| 873 | ||
| 874 | #ifdef _LIBCPP_CXX03_LANG | |
| 875 | # define _LIBCPP_EQUAL_DELETE | |
| 876 | #else | |
| 877 | # define _LIBCPP_EQUAL_DELETE = delete | |
| 878 | #endif | |
| 879 | ||
| 880 | 884 | #ifdef __GNUC__ |
| 881 | 885 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) |
| 882 | 886 | #else |
| ... | ... | @@ -905,16 +909,35 @@ typedef unsigned int char32_t; |
| 905 | 909 | // _LIBCPP_DEBUG potential values: |
| 906 | 910 | // - undefined: No assertions. This is the default. |
| 907 | 911 | // - 0: Basic assertions |
| 908 | // - 1: Basic assertions + iterator validity checks. | |
| 909 | #if !defined(_LIBCPP_DEBUG) | |
| 910 | # define _LIBCPP_DEBUG_LEVEL 0 | |
| 911 | #elif _LIBCPP_DEBUG == 0 | |
| 912 | # define _LIBCPP_DEBUG_LEVEL 1 | |
| 913 | #elif _LIBCPP_DEBUG == 1 | |
| 914 | # define _LIBCPP_DEBUG_LEVEL 2 | |
| 915 | #else | |
| 916 | # error Supported values for _LIBCPP_DEBUG are 0 and 1 | |
| 917 | #endif | |
| 912 | // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization. | |
| 913 | # if !defined(_LIBCPP_DEBUG) | |
| 914 | # define _LIBCPP_DEBUG_LEVEL 0 | |
| 915 | # elif _LIBCPP_DEBUG == 0 | |
| 916 | # define _LIBCPP_DEBUG_LEVEL 1 | |
| 917 | # elif _LIBCPP_DEBUG == 1 | |
| 918 | # define _LIBCPP_DEBUG_LEVEL 2 | |
| 919 | # else | |
| 920 | # error Supported values for _LIBCPP_DEBUG are 0 and 1 | |
| 921 | # endif | |
| 922 | ||
| 923 | # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG) | |
| 924 | # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY | |
| 925 | # endif | |
| 926 | ||
| 927 | # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 928 | # if defined(_LIBCPP_CXX03_LANG) | |
| 929 | # error Support for unspecified stability is only for C++11 and higher | |
| 930 | # endif | |
| 931 | # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ | |
| 932 | do { \ | |
| 933 | if (!__builtin_is_constant_evaluated()) \ | |
| 934 | _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \ | |
| 935 | } while (false) | |
| 936 | # else | |
| 937 | # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ | |
| 938 | do { \ | |
| 939 | } while (false) | |
| 940 | # endif | |
| 918 | 941 | |
| 919 | 942 | // Libc++ allows disabling extern template instantiation declarations by |
| 920 | 943 | // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE. |
| ... | ... | @@ -938,11 +961,11 @@ typedef unsigned int char32_t; |
| 938 | 961 | #endif |
| 939 | 962 | |
| 940 | 963 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ |
| 941 | defined(__sun__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__CloudABI__) | |
| 964 | defined(__sun__) || defined(__NetBSD__) | |
| 942 | 965 | #define _LIBCPP_LOCALE__L_EXTENSIONS 1 |
| 943 | 966 | #endif |
| 944 | 967 | |
| 945 | #if defined(__FreeBSD__) || defined(__DragonFly__) | |
| 968 | #ifdef __FreeBSD__ | |
| 946 | 969 | #define _DECLARE_C99_LDBL_MATH 1 |
| 947 | 970 | #endif |
| 948 | 971 | |
| ... | ... | @@ -958,23 +981,16 @@ typedef unsigned int char32_t; |
| 958 | 981 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION |
| 959 | 982 | #endif |
| 960 | 983 | |
| 961 | #if defined(__APPLE__) | |
| 962 | # if !defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \ | |
| 963 | defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) | |
| 964 | # define __MAC_OS_X_VERSION_MIN_REQUIRED __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ | |
| 965 | # endif | |
| 966 | #endif // defined(__APPLE__) | |
| 967 | ||
| 968 | 984 | #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ |
| 969 | 985 | (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) |
| 970 | 986 | # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION |
| 971 | 987 | #endif |
| 972 | 988 | |
| 973 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) | |
| 989 | #if defined(__APPLE__) || defined(__FreeBSD__) | |
| 974 | 990 | #define _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 975 | 991 | #endif |
| 976 | 992 | |
| 977 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__sun__) | |
| 993 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) | |
| 978 | 994 | #define _LIBCPP_WCTYPE_IS_MASK |
| 979 | 995 | #endif |
| 980 | 996 | |
| ... | ... | @@ -1047,64 +1063,50 @@ typedef unsigned int char32_t; |
| 1047 | 1063 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit |
| 1048 | 1064 | #endif |
| 1049 | 1065 | |
| 1050 | #if _LIBCPP_STD_VER > 11 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) | |
| 1066 | #if _LIBCPP_STD_VER > 11 | |
| 1051 | 1067 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr |
| 1052 | 1068 | #else |
| 1053 | 1069 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1054 | 1070 | #endif |
| 1055 | 1071 | |
| 1056 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) | |
| 1072 | #if _LIBCPP_STD_VER > 14 | |
| 1057 | 1073 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr |
| 1058 | 1074 | #else |
| 1059 | 1075 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 1060 | 1076 | #endif |
| 1061 | 1077 | |
| 1062 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) | |
| 1078 | #if _LIBCPP_STD_VER > 17 | |
| 1063 | 1079 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr |
| 1064 | 1080 | #else |
| 1065 | 1081 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1066 | 1082 | #endif |
| 1067 | 1083 | |
| 1068 | // The _LIBCPP_NODISCARD_ATTRIBUTE should only be used to define other | |
| 1069 | // NODISCARD macros to the correct attribute. | |
| 1070 | 1084 | #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) |
| 1071 | # define _LIBCPP_NODISCARD_ATTRIBUTE [[nodiscard]] | |
| 1085 | # define _LIBCPP_NODISCARD [[nodiscard]] | |
| 1072 | 1086 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) |
| 1073 | # define _LIBCPP_NODISCARD_ATTRIBUTE [[clang::warn_unused_result]] | |
| 1087 | # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] | |
| 1074 | 1088 | #else |
| 1075 | 1089 | // We can't use GCC's [[gnu::warn_unused_result]] and |
| 1076 | 1090 | // __attribute__((warn_unused_result)), because GCC does not silence them via |
| 1077 | 1091 | // (void) cast. |
| 1078 | # define _LIBCPP_NODISCARD_ATTRIBUTE | |
| 1092 | # define _LIBCPP_NODISCARD | |
| 1079 | 1093 | #endif |
| 1080 | 1094 | |
| 1081 | 1095 | // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not |
| 1082 | 1096 | // specified as such as an extension. |
| 1083 | 1097 | #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) |
| 1084 | # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD_ATTRIBUTE | |
| 1098 | # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD | |
| 1085 | 1099 | #else |
| 1086 | 1100 | # define _LIBCPP_NODISCARD_EXT |
| 1087 | 1101 | #endif |
| 1088 | 1102 | |
| 1089 | 1103 | #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ |
| 1090 | 1104 | (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) |
| 1091 | # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD_ATTRIBUTE | |
| 1105 | # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD | |
| 1092 | 1106 | #else |
| 1093 | 1107 | # define _LIBCPP_NODISCARD_AFTER_CXX17 |
| 1094 | 1108 | #endif |
| 1095 | 1109 | |
| 1096 | #if _LIBCPP_STD_VER > 14 && defined(__cpp_inline_variables) && (__cpp_inline_variables >= 201606L) | |
| 1097 | # define _LIBCPP_INLINE_VAR inline | |
| 1098 | #else | |
| 1099 | # define _LIBCPP_INLINE_VAR | |
| 1100 | #endif | |
| 1101 | ||
| 1102 | #if defined(_LIBCPP_DEBUG) || defined(_LIBCPP_HAS_NO_CXX14_CONSTEXPR) | |
| 1103 | # define _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 1104 | #else | |
| 1105 | # define _LIBCPP_CONSTEXPR_IF_NODEBUG constexpr | |
| 1106 | #endif | |
| 1107 | ||
| 1108 | 1110 | #if __has_attribute(no_destroy) |
| 1109 | 1111 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) |
| 1110 | 1112 | #else |
| ... | ... | @@ -1138,16 +1140,13 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1138 | 1140 | defined(__wasi__) || \ |
| 1139 | 1141 | defined(__NetBSD__) || \ |
| 1140 | 1142 | defined(__OpenBSD__) || \ |
| 1141 | defined(__DragonFly__) || \ | |
| 1142 | 1143 | defined(__NuttX__) || \ |
| 1143 | 1144 | defined(__linux__) || \ |
| 1144 | 1145 | defined(__GNU__) || \ |
| 1145 | 1146 | defined(__APPLE__) || \ |
| 1146 | defined(__CloudABI__) || \ | |
| 1147 | 1147 | defined(__sun__) || \ |
| 1148 | 1148 | defined(__MVS__) || \ |
| 1149 | defined(_AIX) || \ | |
| 1150 | (defined(__MINGW32__) && __has_include(<pthread.h>)) | |
| 1149 | defined(_AIX) | |
| 1151 | 1150 | # define _LIBCPP_HAS_THREAD_API_PTHREAD |
| 1152 | 1151 | # elif defined(__Fuchsia__) |
| 1153 | 1152 | // TODO(44575): Switch to C11 thread API when possible. |
| ... | ... | @@ -1217,21 +1216,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1217 | 1216 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION |
| 1218 | 1217 | #endif |
| 1219 | 1218 | |
| 1220 | // Systems that use capability-based security (FreeBSD with Capsicum, | |
| 1221 | // Nuxi CloudABI) may only provide local filesystem access (using *at()). | |
| 1222 | // Functions like open(), rename(), unlink() and stat() should not be | |
| 1223 | // used, as they attempt to access the global filesystem namespace. | |
| 1224 | #ifdef __CloudABI__ | |
| 1225 | #define _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1226 | #endif | |
| 1227 | ||
| 1228 | // CloudABI is intended for running networked services. Processes do not | |
| 1229 | // have standard input and output channels. | |
| 1230 | #ifdef __CloudABI__ | |
| 1231 | #define _LIBCPP_HAS_NO_STDIN | |
| 1232 | #define _LIBCPP_HAS_NO_STDOUT | |
| 1233 | #endif | |
| 1234 | ||
| 1235 | 1219 | // Some systems do not provide gets() in their C library, for security reasons. |
| 1236 | 1220 | #if defined(_LIBCPP_MSVCRT) || \ |
| 1237 | 1221 | (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ |
| ... | ... | @@ -1239,28 +1223,21 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1239 | 1223 | # define _LIBCPP_C_HAS_NO_GETS |
| 1240 | 1224 | #endif |
| 1241 | 1225 | |
| 1242 | #if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \ | |
| 1243 | defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \ | |
| 1244 | defined(__MVS__) || defined(__OpenBSD__) | |
| 1226 | #if defined(__BIONIC__) || defined(__NuttX__) || \ | |
| 1227 | defined(__Fuchsia__) || defined(__wasi__) || \ | |
| 1228 | defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) | |
| 1245 | 1229 | #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE |
| 1246 | 1230 | #endif |
| 1247 | 1231 | |
| 1248 | // Thread-unsafe functions such as strtok() and localtime() | |
| 1249 | // are not available. | |
| 1250 | #ifdef __CloudABI__ | |
| 1251 | #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS | |
| 1252 | #endif | |
| 1253 | ||
| 1254 | 1232 | #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) |
| 1255 | 1233 | # define _LIBCPP_HAS_C_ATOMIC_IMP |
| 1256 | 1234 | #elif defined(_LIBCPP_COMPILER_GCC) |
| 1257 | 1235 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP |
| 1258 | 1236 | #endif |
| 1259 | 1237 | |
| 1260 | #if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ | |
| 1261 | !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ | |
| 1262 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \ | |
| 1263 | || defined(_LIBCPP_HAS_NO_THREADS) | |
| 1238 | #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ | |
| 1239 | !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ | |
| 1240 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) | |
| 1264 | 1241 | # define _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 1265 | 1242 | #else |
| 1266 | 1243 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE |
| ... | ... | @@ -1279,8 +1256,9 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1279 | 1256 | # if defined(__clang__) && __has_attribute(acquire_capability) |
| 1280 | 1257 | // Work around the attribute handling in clang. When both __declspec and |
| 1281 | 1258 | // __attribute__ are present, the processing goes awry preventing the definition |
| 1282 | // of the types. | |
| 1283 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 1259 | // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus | |
| 1260 | // combining the two does work. | |
| 1261 | # if !defined(_MSC_VER) | |
| 1284 | 1262 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS |
| 1285 | 1263 | # endif |
| 1286 | 1264 | # endif |
| ... | ... | @@ -1298,14 +1276,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1298 | 1276 | # define _LIBCPP_SAFE_STATIC |
| 1299 | 1277 | #endif |
| 1300 | 1278 | |
| 1301 | #if !__has_builtin(__builtin_addressof) && _GNUC_VER < 700 | |
| 1302 | #define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF | |
| 1303 | #endif | |
| 1304 | ||
| 1305 | #if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900 | |
| 1306 | #define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED | |
| 1307 | #endif | |
| 1308 | ||
| 1309 | 1279 | #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) |
| 1310 | 1280 | # define _LIBCPP_DIAGNOSE_WARNING(...) \ |
| 1311 | 1281 | __attribute__((diagnose_if(__VA_ARGS__, "warning"))) |
| ... | ... | @@ -1321,7 +1291,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1321 | 1291 | # define _LIBCPP_FALLTHROUGH() [[fallthrough]] |
| 1322 | 1292 | #elif __has_cpp_attribute(clang::fallthrough) |
| 1323 | 1293 | # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] |
| 1324 | #elif __has_attribute(fallthrough) || _GNUC_VER >= 700 | |
| 1294 | #elif __has_attribute(__fallthrough__) | |
| 1325 | 1295 | # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) |
| 1326 | 1296 | #else |
| 1327 | 1297 | # define _LIBCPP_FALLTHROUGH() ((void)0) |
| ... | ... | @@ -1333,12 +1303,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1333 | 1303 | #define _LIBCPP_NODEBUG |
| 1334 | 1304 | #endif |
| 1335 | 1305 | |
| 1336 | #if __has_attribute(__nodebug__) && (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 900) | |
| 1337 | # define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug)) | |
| 1338 | #else | |
| 1339 | # define _LIBCPP_NODEBUG_TYPE | |
| 1340 | #endif | |
| 1341 | ||
| 1342 | 1306 | #if __has_attribute(__standalone_debug__) |
| 1343 | 1307 | #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) |
| 1344 | 1308 | #else |
| ... | ... | @@ -1351,6 +1315,16 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1351 | 1315 | #define _LIBCPP_PREFERRED_NAME(x) |
| 1352 | 1316 | #endif |
| 1353 | 1317 | |
| 1318 | // We often repeat things just for handling wide characters in the library. | |
| 1319 | // When wide characters are disabled, it can be useful to have a quick way of | |
| 1320 | // disabling it without having to resort to #if-#endif, which has a larger | |
| 1321 | // impact on readability. | |
| 1322 | #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 1323 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) | |
| 1324 | #else | |
| 1325 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ | |
| 1326 | #endif | |
| 1327 | ||
| 1354 | 1328 | #if defined(_LIBCPP_ABI_MICROSOFT) && \ |
| 1355 | 1329 | (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) |
| 1356 | 1330 | # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) |
| ... | ... | @@ -1373,20 +1347,8 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1373 | 1347 | #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS |
| 1374 | 1348 | #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES |
| 1375 | 1349 | |
| 1376 | #if !defined(__cpp_deduction_guides) || __cpp_deduction_guides < 201611 | |
| 1377 | #define _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1378 | #endif | |
| 1379 | ||
| 1380 | #if !__has_keyword(__is_aggregate) && (_GNUC_VER_NEW < 7001) | |
| 1381 | #define _LIBCPP_HAS_NO_IS_AGGREGATE | |
| 1382 | #endif | |
| 1383 | ||
| 1384 | #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L | |
| 1385 | #define _LIBCPP_HAS_NO_COROUTINES | |
| 1386 | #endif | |
| 1387 | ||
| 1388 | #if !defined(__cpp_impl_three_way_comparison) || __cpp_impl_three_way_comparison < 201907L | |
| 1389 | #define _LIBCPP_HAS_NO_SPACESHIP_OPERATOR | |
| 1350 | #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L | |
| 1351 | #define _LIBCPP_HAS_NO_CXX20_COROUTINES | |
| 1390 | 1352 | #endif |
| 1391 | 1353 | |
| 1392 | 1354 | #if defined(_LIBCPP_COMPILER_IBM) |
| ... | ... | @@ -1440,12 +1402,6 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1440 | 1402 | # define _LIBCPP_FOPEN_CLOEXEC_MODE |
| 1441 | 1403 | #endif |
| 1442 | 1404 | |
| 1443 | #ifdef _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P | |
| 1444 | #define _LIBCPP_BUILTIN_CONSTANT_P(x) __builtin_constant_p(x) | |
| 1445 | #else | |
| 1446 | #define _LIBCPP_BUILTIN_CONSTANT_P(x) false | |
| 1447 | #endif | |
| 1448 | ||
| 1449 | 1405 | // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set |
| 1450 | 1406 | // of functions used in cstdio may not be available for low API levels when |
| 1451 | 1407 | // using 64-bit file offsets on LP32. |
| ... | ... | @@ -1454,16 +1410,24 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1454 | 1410 | #endif |
| 1455 | 1411 | |
| 1456 | 1412 | #if __has_attribute(init_priority) |
| 1457 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) | |
| 1413 | // TODO: Remove this once we drop support for building libc++ with old Clangs | |
| 1414 | # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ | |
| 1415 | (defined(__apple_build_version__) && __apple_build_version__ < 13000000) | |
| 1416 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) | |
| 1417 | # else | |
| 1418 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) | |
| 1419 | # endif | |
| 1458 | 1420 | #else |
| 1459 | 1421 | # define _LIBCPP_INIT_PRIORITY_MAX |
| 1460 | 1422 | #endif |
| 1461 | 1423 | |
| 1462 | 1424 | #if defined(__GNUC__) || defined(__clang__) |
| 1463 | #define _LIBCPP_FORMAT_PRINTF(a, b) \ | |
| 1464 | __attribute__((__format__(__printf__, a, b))) | |
| 1425 | // The attribute uses 1-based indices for ordinary and static member functions. | |
| 1426 | // The attribute uses 2-based indices for non-static member functions. | |
| 1427 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ | |
| 1428 | __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) | |
| 1465 | 1429 | #else |
| 1466 | #define _LIBCPP_FORMAT_PRINTF(a, b) | |
| 1430 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ | |
| 1467 | 1431 | #endif |
| 1468 | 1432 | |
| 1469 | 1433 | #endif // __cplusplus |
lib/libcxx/include/__coroutine/coroutine_handle.h created+202| ... | ... | @@ -0,0 +1,202 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H | |
| 10 | #define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__debug> | |
| 14 | #include <__functional/hash.h> | |
| 15 | #include <__memory/addressof.h> | |
| 16 | #include <compare> | |
| 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 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | // [coroutine.handle] | |
| 28 | template <class _Promise = void> | |
| 29 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle; | |
| 30 | ||
| 31 | template <> | |
| 32 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle<void> { | |
| 33 | public: | |
| 34 | // [coroutine.handle.con], construct/reset | |
| 35 | _LIBCPP_HIDE_FROM_ABI | |
| 36 | constexpr coroutine_handle() noexcept = default; | |
| 37 | ||
| 38 | _LIBCPP_HIDE_FROM_ABI | |
| 39 | constexpr coroutine_handle(nullptr_t) noexcept {} | |
| 40 | ||
| 41 | _LIBCPP_HIDE_FROM_ABI | |
| 42 | coroutine_handle& operator=(nullptr_t) noexcept { | |
| 43 | __handle_ = nullptr; | |
| 44 | return *this; | |
| 45 | } | |
| 46 | ||
| 47 | // [coroutine.handle.export.import], export/import | |
| 48 | _LIBCPP_HIDE_FROM_ABI | |
| 49 | constexpr void* address() const noexcept { return __handle_; } | |
| 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI | |
| 52 | static constexpr coroutine_handle from_address(void* __addr) noexcept { | |
| 53 | coroutine_handle __tmp; | |
| 54 | __tmp.__handle_ = __addr; | |
| 55 | return __tmp; | |
| 56 | } | |
| 57 | ||
| 58 | // [coroutine.handle.observers], observers | |
| 59 | _LIBCPP_HIDE_FROM_ABI | |
| 60 | constexpr explicit operator bool() const noexcept { | |
| 61 | return __handle_ != nullptr; | |
| 62 | } | |
| 63 | ||
| 64 | _LIBCPP_HIDE_FROM_ABI | |
| 65 | bool done() const { | |
| 66 | _LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines"); | |
| 67 | return __builtin_coro_done(__handle_); | |
| 68 | } | |
| 69 | ||
| 70 | // [coroutine.handle.resumption], resumption | |
| 71 | _LIBCPP_HIDE_FROM_ABI | |
| 72 | void operator()() const { resume(); } | |
| 73 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI | |
| 75 | void resume() const { | |
| 76 | _LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines"); | |
| 77 | _LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done"); | |
| 78 | __builtin_coro_resume(__handle_); | |
| 79 | } | |
| 80 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI | |
| 82 | void destroy() const { | |
| 83 | _LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines"); | |
| 84 | __builtin_coro_destroy(__handle_); | |
| 85 | } | |
| 86 | ||
| 87 | private: | |
| 88 | bool __is_suspended() const { | |
| 89 | // FIXME actually implement a check for if the coro is suspended. | |
| 90 | return __handle_ != nullptr; | |
| 91 | } | |
| 92 | ||
| 93 | void* __handle_ = nullptr; | |
| 94 | }; | |
| 95 | ||
| 96 | // [coroutine.handle.compare] | |
| 97 | inline _LIBCPP_HIDE_FROM_ABI | |
| 98 | constexpr bool operator==(coroutine_handle<> __x, coroutine_handle<> __y) noexcept { | |
| 99 | return __x.address() == __y.address(); | |
| 100 | } | |
| 101 | inline _LIBCPP_HIDE_FROM_ABI | |
| 102 | constexpr strong_ordering operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept { | |
| 103 | return compare_three_way()(__x.address(), __y.address()); | |
| 104 | } | |
| 105 | ||
| 106 | template <class _Promise> | |
| 107 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle { | |
| 108 | public: | |
| 109 | // [coroutine.handle.con], construct/reset | |
| 110 | _LIBCPP_HIDE_FROM_ABI | |
| 111 | constexpr coroutine_handle() noexcept = default; | |
| 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI | |
| 114 | constexpr coroutine_handle(nullptr_t) noexcept {} | |
| 115 | ||
| 116 | _LIBCPP_HIDE_FROM_ABI | |
| 117 | static coroutine_handle from_promise(_Promise& __promise) { | |
| 118 | using _RawPromise = typename remove_cv<_Promise>::type; | |
| 119 | coroutine_handle __tmp; | |
| 120 | __tmp.__handle_ = | |
| 121 | __builtin_coro_promise(_VSTD::addressof(const_cast<_RawPromise&>(__promise)), alignof(_Promise), true); | |
| 122 | return __tmp; | |
| 123 | } | |
| 124 | ||
| 125 | _LIBCPP_HIDE_FROM_ABI | |
| 126 | coroutine_handle& operator=(nullptr_t) noexcept { | |
| 127 | __handle_ = nullptr; | |
| 128 | return *this; | |
| 129 | } | |
| 130 | ||
| 131 | // [coroutine.handle.export.import], export/import | |
| 132 | _LIBCPP_HIDE_FROM_ABI | |
| 133 | constexpr void* address() const noexcept { return __handle_; } | |
| 134 | ||
| 135 | _LIBCPP_HIDE_FROM_ABI | |
| 136 | static constexpr coroutine_handle from_address(void* __addr) noexcept { | |
| 137 | coroutine_handle __tmp; | |
| 138 | __tmp.__handle_ = __addr; | |
| 139 | return __tmp; | |
| 140 | } | |
| 141 | ||
| 142 | // [coroutine.handle.conv], conversion | |
| 143 | _LIBCPP_HIDE_FROM_ABI | |
| 144 | constexpr operator coroutine_handle<>() const noexcept { | |
| 145 | return coroutine_handle<>::from_address(address()); | |
| 146 | } | |
| 147 | ||
| 148 | // [coroutine.handle.observers], observers | |
| 149 | _LIBCPP_HIDE_FROM_ABI | |
| 150 | constexpr explicit operator bool() const noexcept { | |
| 151 | return __handle_ != nullptr; | |
| 152 | } | |
| 153 | ||
| 154 | _LIBCPP_HIDE_FROM_ABI | |
| 155 | bool done() const { | |
| 156 | _LIBCPP_ASSERT(__is_suspended(), "done() can be called only on suspended coroutines"); | |
| 157 | return __builtin_coro_done(__handle_); | |
| 158 | } | |
| 159 | ||
| 160 | // [coroutine.handle.resumption], resumption | |
| 161 | _LIBCPP_HIDE_FROM_ABI | |
| 162 | void operator()() const { resume(); } | |
| 163 | ||
| 164 | _LIBCPP_HIDE_FROM_ABI | |
| 165 | void resume() const { | |
| 166 | _LIBCPP_ASSERT(__is_suspended(), "resume() can be called only on suspended coroutines"); | |
| 167 | _LIBCPP_ASSERT(!done(), "resume() has undefined behavior when the coroutine is done"); | |
| 168 | __builtin_coro_resume(__handle_); | |
| 169 | } | |
| 170 | ||
| 171 | _LIBCPP_HIDE_FROM_ABI | |
| 172 | void destroy() const { | |
| 173 | _LIBCPP_ASSERT(__is_suspended(), "destroy() can be called only on suspended coroutines"); | |
| 174 | __builtin_coro_destroy(__handle_); | |
| 175 | } | |
| 176 | ||
| 177 | // [coroutine.handle.promise], promise access | |
| 178 | _LIBCPP_HIDE_FROM_ABI | |
| 179 | _Promise& promise() const { | |
| 180 | return *static_cast<_Promise*>(__builtin_coro_promise(this->__handle_, alignof(_Promise), false)); | |
| 181 | } | |
| 182 | ||
| 183 | private: | |
| 184 | bool __is_suspended() const { | |
| 185 | // FIXME actually implement a check for if the coro is suspended. | |
| 186 | return __handle_ != nullptr; | |
| 187 | } | |
| 188 | void* __handle_ = nullptr; | |
| 189 | }; | |
| 190 | ||
| 191 | // [coroutine.handle.hash] | |
| 192 | template <class _Tp> | |
| 193 | struct hash<coroutine_handle<_Tp>> { | |
| 194 | _LIBCPP_HIDE_FROM_ABI | |
| 195 | size_t operator()(const coroutine_handle<_Tp>& __v) const noexcept { return hash<void*>()(__v.address()); } | |
| 196 | }; | |
| 197 | ||
| 198 | _LIBCPP_END_NAMESPACE_STD | |
| 199 | ||
| 200 | #endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 201 | ||
| 202 | #endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H |
lib/libcxx/include/__coroutine/coroutine_traits.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___COROUTINE_COROUTINE_TRAITS_H | |
| 10 | #define _LIBCPP___COROUTINE_COROUTINE_TRAITS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | // [coroutine.traits] | |
| 24 | // [coroutine.traits.primary] | |
| 25 | // The header <coroutine> defined the primary template coroutine_traits such that | |
| 26 | // if ArgTypes is a parameter pack of types and if the qualified-id R::promise_type | |
| 27 | // is valid and denotes a type ([temp.deduct]), then coroutine_traits<R, ArgTypes...> | |
| 28 | // has the following publicly accessible memebr: | |
| 29 | // | |
| 30 | // using promise_type = typename R::promise_type; | |
| 31 | // | |
| 32 | // Otherwise, coroutine_traits<R, ArgTypes...> has no members. | |
| 33 | template <class _Tp, class = void> | |
| 34 | struct __coroutine_traits_sfinae {}; | |
| 35 | ||
| 36 | template <class _Tp> | |
| 37 | struct __coroutine_traits_sfinae< | |
| 38 | _Tp, typename __void_t<typename _Tp::promise_type>::type> | |
| 39 | { | |
| 40 | using promise_type = typename _Tp::promise_type; | |
| 41 | }; | |
| 42 | ||
| 43 | template <class _Ret, class... _Args> | |
| 44 | struct coroutine_traits | |
| 45 | : public __coroutine_traits_sfinae<_Ret> | |
| 46 | { | |
| 47 | }; | |
| 48 | ||
| 49 | _LIBCPP_END_NAMESPACE_STD | |
| 50 | ||
| 51 | #endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 52 | ||
| 53 | #endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H |
lib/libcxx/include/__coroutine/noop_coroutine_handle.h created+112| ... | ... | @@ -0,0 +1,112 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H | |
| 10 | #define _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__coroutine/coroutine_handle.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC) | |
| 24 | ||
| 25 | // [coroutine.noop] | |
| 26 | // [coroutine.promise.noop] | |
| 27 | struct noop_coroutine_promise {}; | |
| 28 | ||
| 29 | // [coroutine.handle.noop] | |
| 30 | template <> | |
| 31 | struct _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> { | |
| 32 | public: | |
| 33 | // [coroutine.handle.noop.conv], conversion | |
| 34 | _LIBCPP_HIDE_FROM_ABI | |
| 35 | constexpr operator coroutine_handle<>() const noexcept { | |
| 36 | return coroutine_handle<>::from_address(address()); | |
| 37 | } | |
| 38 | ||
| 39 | // [coroutine.handle.noop.observers], observers | |
| 40 | _LIBCPP_HIDE_FROM_ABI | |
| 41 | constexpr explicit operator bool() const noexcept { return true; } | |
| 42 | _LIBCPP_HIDE_FROM_ABI | |
| 43 | constexpr bool done() const noexcept { return false; } | |
| 44 | ||
| 45 | // [coroutine.handle.noop.resumption], resumption | |
| 46 | _LIBCPP_HIDE_FROM_ABI | |
| 47 | constexpr void operator()() const noexcept {} | |
| 48 | _LIBCPP_HIDE_FROM_ABI | |
| 49 | constexpr void resume() const noexcept {} | |
| 50 | _LIBCPP_HIDE_FROM_ABI | |
| 51 | constexpr void destroy() const noexcept {} | |
| 52 | ||
| 53 | // [coroutine.handle.noop.promise], promise access | |
| 54 | _LIBCPP_HIDE_FROM_ABI | |
| 55 | noop_coroutine_promise& promise() const noexcept { | |
| 56 | return *static_cast<noop_coroutine_promise*>( | |
| 57 | __builtin_coro_promise(this->__handle_, alignof(noop_coroutine_promise), false)); | |
| 58 | } | |
| 59 | ||
| 60 | // [coroutine.handle.noop.address], address | |
| 61 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | constexpr void* address() const noexcept { return __handle_; } | |
| 63 | ||
| 64 | private: | |
| 65 | _LIBCPP_HIDE_FROM_ABI | |
| 66 | friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept; | |
| 67 | ||
| 68 | #if __has_builtin(__builtin_coro_noop) | |
| 69 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { | |
| 70 | this->__handle_ = __builtin_coro_noop(); | |
| 71 | } | |
| 72 | ||
| 73 | void* __handle_ = nullptr; | |
| 74 | ||
| 75 | #elif defined(_LIBCPP_COMPILER_GCC) | |
| 76 | // GCC doesn't implement __builtin_coro_noop(). | |
| 77 | // Construct the coroutine frame manually instead. | |
| 78 | struct __noop_coroutine_frame_ty_ { | |
| 79 | static void __dummy_resume_destroy_func() { } | |
| 80 | ||
| 81 | void (*__resume_)() = __dummy_resume_destroy_func; | |
| 82 | void (*__destroy_)() = __dummy_resume_destroy_func; | |
| 83 | struct noop_coroutine_promise __promise_; | |
| 84 | }; | |
| 85 | ||
| 86 | static __noop_coroutine_frame_ty_ __noop_coroutine_frame_; | |
| 87 | ||
| 88 | void* __handle_ = &__noop_coroutine_frame_; | |
| 89 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept = default; | |
| 91 | ||
| 92 | #endif // __has_builtin(__builtin_coro_noop) | |
| 93 | }; | |
| 94 | ||
| 95 | using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; | |
| 96 | ||
| 97 | #if defined(_LIBCPP_COMPILER_GCC) | |
| 98 | inline noop_coroutine_handle::__noop_coroutine_frame_ty_ | |
| 99 | noop_coroutine_handle::__noop_coroutine_frame_{}; | |
| 100 | #endif | |
| 101 | ||
| 102 | // [coroutine.noop.coroutine] | |
| 103 | inline _LIBCPP_HIDE_FROM_ABI | |
| 104 | noop_coroutine_handle noop_coroutine() noexcept { return noop_coroutine_handle(); } | |
| 105 | ||
| 106 | #endif // __has_builtin(__builtin_coro_noop) || defined(_LIBCPP_COMPILER_GCC) | |
| 107 | ||
| 108 | _LIBCPP_END_NAMESPACE_STD | |
| 109 | ||
| 110 | #endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 111 | ||
| 112 | #endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H |
lib/libcxx/include/__coroutine/trivial_awaitables.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___COROUTINE_TRIVIAL_AWAITABLES_H | |
| 10 | #define __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__coroutine/coroutine_handle.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | // [coroutine.trivial.awaitables] | |
| 24 | struct suspend_never { | |
| 25 | _LIBCPP_HIDE_FROM_ABI | |
| 26 | constexpr bool await_ready() const noexcept { return true; } | |
| 27 | _LIBCPP_HIDE_FROM_ABI | |
| 28 | constexpr void await_suspend(coroutine_handle<>) const noexcept {} | |
| 29 | _LIBCPP_HIDE_FROM_ABI | |
| 30 | constexpr void await_resume() const noexcept {} | |
| 31 | }; | |
| 32 | ||
| 33 | struct suspend_always { | |
| 34 | _LIBCPP_HIDE_FROM_ABI | |
| 35 | constexpr bool await_ready() const noexcept { return false; } | |
| 36 | _LIBCPP_HIDE_FROM_ABI | |
| 37 | constexpr void await_suspend(coroutine_handle<>) const noexcept {} | |
| 38 | _LIBCPP_HIDE_FROM_ABI | |
| 39 | constexpr void await_resume() const noexcept {} | |
| 40 | }; | |
| 41 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | |
| 43 | ||
| 44 | #endif // __LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) | |
| 45 | ||
| 46 | #endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H |
lib/libcxx/include/__debug+25-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- __debug ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <iosfwd> |
| 15 | #include <type_traits> | |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| ... | ... | @@ -22,9 +23,9 @@ |
| 22 | 23 | #endif |
| 23 | 24 | |
| 24 | 25 | #if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 25 | # include <cstdlib> | |
| 26 | # include <cstdio> | |
| 27 | 26 | # include <cstddef> |
| 27 | # include <cstdio> | |
| 28 | # include <cstdlib> | |
| 28 | 29 | #endif |
| 29 | 30 | |
| 30 | 31 | #if _LIBCPP_DEBUG_LEVEL == 0 |
| ... | ... | @@ -34,7 +35,7 @@ |
| 34 | 35 | # define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) |
| 35 | 36 | # define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) |
| 36 | 37 | #elif _LIBCPP_DEBUG_LEVEL == 2 |
| 37 | # define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) | |
| 38 | # define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(__libcpp_is_constant_evaluated() || (x), m) | |
| 38 | 39 | # define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) |
| 39 | 40 | #else |
| 40 | 41 | # error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2 |
| ... | ... | @@ -268,6 +269,26 @@ _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); |
| 268 | 269 | |
| 269 | 270 | #endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 270 | 271 | |
| 272 | template <class _Tp> | |
| 273 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) { | |
| 274 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 275 | if (!__libcpp_is_constant_evaluated()) | |
| 276 | __get_db()->__insert_c(__c); | |
| 277 | #else | |
| 278 | (void)(__c); | |
| 279 | #endif | |
| 280 | } | |
| 281 | ||
| 282 | template <class _Tp> | |
| 283 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) { | |
| 284 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 285 | if (!__libcpp_is_constant_evaluated()) | |
| 286 | __get_db()->__insert_i(__i); | |
| 287 | #else | |
| 288 | (void)(__i); | |
| 289 | #endif | |
| 290 | } | |
| 291 | ||
| 271 | 292 | _LIBCPP_END_NAMESPACE_STD |
| 272 | 293 | |
| 273 | 294 | #endif // _LIBCPP_DEBUG_H |
lib/libcxx/include/__errc+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- __errc ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/__filesystem/copy_options.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 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___FILESYSTEM_COPY_OPTIONS_H | |
| 11 | #define _LIBCPP___FILESYSTEM_COPY_OPTIONS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #ifndef _LIBCPP_CXX03_LANG | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 19 | ||
| 20 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 21 | ||
| 22 | enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { | |
| 23 | none = 0, | |
| 24 | skip_existing = 1, | |
| 25 | overwrite_existing = 2, | |
| 26 | update_existing = 4, | |
| 27 | recursive = 8, | |
| 28 | copy_symlinks = 16, | |
| 29 | skip_symlinks = 32, | |
| 30 | directories_only = 64, | |
| 31 | create_symlinks = 128, | |
| 32 | create_hard_links = 256, | |
| 33 | __in_recursive_copy = 512, | |
| 34 | }; | |
| 35 | ||
| 36 | _LIBCPP_INLINE_VISIBILITY | |
| 37 | inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) { | |
| 38 | return static_cast<copy_options>(static_cast<unsigned short>(_LHS) & | |
| 39 | static_cast<unsigned short>(_RHS)); | |
| 40 | } | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) { | |
| 44 | return static_cast<copy_options>(static_cast<unsigned short>(_LHS) | | |
| 45 | static_cast<unsigned short>(_RHS)); | |
| 46 | } | |
| 47 | ||
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) { | |
| 50 | return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^ | |
| 51 | static_cast<unsigned short>(_RHS)); | |
| 52 | } | |
| 53 | ||
| 54 | _LIBCPP_INLINE_VISIBILITY | |
| 55 | inline constexpr copy_options operator~(copy_options _LHS) { | |
| 56 | return static_cast<copy_options>(~static_cast<unsigned short>(_LHS)); | |
| 57 | } | |
| 58 | ||
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) { | |
| 61 | return _LHS = _LHS & _RHS; | |
| 62 | } | |
| 63 | ||
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) { | |
| 66 | return _LHS = _LHS | _RHS; | |
| 67 | } | |
| 68 | ||
| 69 | _LIBCPP_INLINE_VISIBILITY | |
| 70 | inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) { | |
| 71 | return _LHS = _LHS ^ _RHS; | |
| 72 | } | |
| 73 | ||
| 74 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 77 | ||
| 78 | #endif // _LIBCPP_CXX03_LANG | |
| 79 | ||
| 80 | #endif // _LIBCPP___FILESYSTEM_COPY_OPTIONS_H |
lib/libcxx/include/__filesystem/directory_entry.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 | ||
| 10 | #ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H | |
| 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__errc> | |
| 16 | #include <__filesystem/file_status.h> | |
| 17 | #include <__filesystem/file_time_type.h> | |
| 18 | #include <__filesystem/file_type.h> | |
| 19 | #include <__filesystem/filesystem_error.h> | |
| 20 | #include <__filesystem/operations.h> | |
| 21 | #include <__filesystem/path.h> | |
| 22 | #include <__filesystem/perms.h> | |
| 23 | #include <chrono> | |
| 24 | #include <cstdint> | |
| 25 | #include <cstdlib> | |
| 26 | #include <iosfwd> | |
| 27 | #include <system_error> | |
| 28 | ||
| 29 | _LIBCPP_PUSH_MACROS | |
| 30 | #include <__undef_macros> | |
| 31 | ||
| 32 | #ifndef _LIBCPP_CXX03_LANG | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 35 | ||
| 36 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 37 | ||
| 38 | ||
| 39 | class directory_entry { | |
| 40 | typedef _VSTD_FS::path _Path; | |
| 41 | ||
| 42 | public: | |
| 43 | // constructors and destructors | |
| 44 | directory_entry() noexcept = default; | |
| 45 | directory_entry(directory_entry const&) = default; | |
| 46 | directory_entry(directory_entry&&) noexcept = default; | |
| 47 | ||
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | explicit directory_entry(_Path const& __p) : __p_(__p) { | |
| 50 | error_code __ec; | |
| 51 | __refresh(&__ec); | |
| 52 | } | |
| 53 | ||
| 54 | _LIBCPP_INLINE_VISIBILITY | |
| 55 | directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) { | |
| 56 | __refresh(&__ec); | |
| 57 | } | |
| 58 | ||
| 59 | ~directory_entry() {} | |
| 60 | ||
| 61 | directory_entry& operator=(directory_entry const&) = default; | |
| 62 | directory_entry& operator=(directory_entry&&) noexcept = default; | |
| 63 | ||
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | void assign(_Path const& __p) { | |
| 66 | __p_ = __p; | |
| 67 | error_code __ec; | |
| 68 | __refresh(&__ec); | |
| 69 | } | |
| 70 | ||
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | void assign(_Path const& __p, error_code& __ec) { | |
| 73 | __p_ = __p; | |
| 74 | __refresh(&__ec); | |
| 75 | } | |
| 76 | ||
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | void replace_filename(_Path const& __p) { | |
| 79 | __p_.replace_filename(__p); | |
| 80 | error_code __ec; | |
| 81 | __refresh(&__ec); | |
| 82 | } | |
| 83 | ||
| 84 | _LIBCPP_INLINE_VISIBILITY | |
| 85 | void replace_filename(_Path const& __p, error_code& __ec) { | |
| 86 | __p_ = __p_.parent_path() / __p; | |
| 87 | __refresh(&__ec); | |
| 88 | } | |
| 89 | ||
| 90 | _LIBCPP_INLINE_VISIBILITY | |
| 91 | void refresh() { __refresh(); } | |
| 92 | ||
| 93 | _LIBCPP_INLINE_VISIBILITY | |
| 94 | void refresh(error_code& __ec) noexcept { __refresh(&__ec); } | |
| 95 | ||
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | _Path const& path() const noexcept { return __p_; } | |
| 98 | ||
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | operator const _Path&() const noexcept { return __p_; } | |
| 101 | ||
| 102 | _LIBCPP_INLINE_VISIBILITY | |
| 103 | bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); } | |
| 104 | ||
| 105 | _LIBCPP_INLINE_VISIBILITY | |
| 106 | bool exists(error_code& __ec) const noexcept { | |
| 107 | return _VSTD_FS::exists(file_status{__get_ft(&__ec)}); | |
| 108 | } | |
| 109 | ||
| 110 | _LIBCPP_INLINE_VISIBILITY | |
| 111 | bool is_block_file() const { return __get_ft() == file_type::block; } | |
| 112 | ||
| 113 | _LIBCPP_INLINE_VISIBILITY | |
| 114 | bool is_block_file(error_code& __ec) const noexcept { | |
| 115 | return __get_ft(&__ec) == file_type::block; | |
| 116 | } | |
| 117 | ||
| 118 | _LIBCPP_INLINE_VISIBILITY | |
| 119 | bool is_character_file() const { return __get_ft() == file_type::character; } | |
| 120 | ||
| 121 | _LIBCPP_INLINE_VISIBILITY | |
| 122 | bool is_character_file(error_code& __ec) const noexcept { | |
| 123 | return __get_ft(&__ec) == file_type::character; | |
| 124 | } | |
| 125 | ||
| 126 | _LIBCPP_INLINE_VISIBILITY | |
| 127 | bool is_directory() const { return __get_ft() == file_type::directory; } | |
| 128 | ||
| 129 | _LIBCPP_INLINE_VISIBILITY | |
| 130 | bool is_directory(error_code& __ec) const noexcept { | |
| 131 | return __get_ft(&__ec) == file_type::directory; | |
| 132 | } | |
| 133 | ||
| 134 | _LIBCPP_INLINE_VISIBILITY | |
| 135 | bool is_fifo() const { return __get_ft() == file_type::fifo; } | |
| 136 | ||
| 137 | _LIBCPP_INLINE_VISIBILITY | |
| 138 | bool is_fifo(error_code& __ec) const noexcept { | |
| 139 | return __get_ft(&__ec) == file_type::fifo; | |
| 140 | } | |
| 141 | ||
| 142 | _LIBCPP_INLINE_VISIBILITY | |
| 143 | bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); } | |
| 144 | ||
| 145 | _LIBCPP_INLINE_VISIBILITY | |
| 146 | bool is_other(error_code& __ec) const noexcept { | |
| 147 | return _VSTD_FS::is_other(file_status{__get_ft(&__ec)}); | |
| 148 | } | |
| 149 | ||
| 150 | _LIBCPP_INLINE_VISIBILITY | |
| 151 | bool is_regular_file() const { return __get_ft() == file_type::regular; } | |
| 152 | ||
| 153 | _LIBCPP_INLINE_VISIBILITY | |
| 154 | bool is_regular_file(error_code& __ec) const noexcept { | |
| 155 | return __get_ft(&__ec) == file_type::regular; | |
| 156 | } | |
| 157 | ||
| 158 | _LIBCPP_INLINE_VISIBILITY | |
| 159 | bool is_socket() const { return __get_ft() == file_type::socket; } | |
| 160 | ||
| 161 | _LIBCPP_INLINE_VISIBILITY | |
| 162 | bool is_socket(error_code& __ec) const noexcept { | |
| 163 | return __get_ft(&__ec) == file_type::socket; | |
| 164 | } | |
| 165 | ||
| 166 | _LIBCPP_INLINE_VISIBILITY | |
| 167 | bool is_symlink() const { return __get_sym_ft() == file_type::symlink; } | |
| 168 | ||
| 169 | _LIBCPP_INLINE_VISIBILITY | |
| 170 | bool is_symlink(error_code& __ec) const noexcept { | |
| 171 | return __get_sym_ft(&__ec) == file_type::symlink; | |
| 172 | } | |
| 173 | _LIBCPP_INLINE_VISIBILITY | |
| 174 | uintmax_t file_size() const { return __get_size(); } | |
| 175 | ||
| 176 | _LIBCPP_INLINE_VISIBILITY | |
| 177 | uintmax_t file_size(error_code& __ec) const noexcept { | |
| 178 | return __get_size(&__ec); | |
| 179 | } | |
| 180 | ||
| 181 | _LIBCPP_INLINE_VISIBILITY | |
| 182 | uintmax_t hard_link_count() const { return __get_nlink(); } | |
| 183 | ||
| 184 | _LIBCPP_INLINE_VISIBILITY | |
| 185 | uintmax_t hard_link_count(error_code& __ec) const noexcept { | |
| 186 | return __get_nlink(&__ec); | |
| 187 | } | |
| 188 | ||
| 189 | _LIBCPP_INLINE_VISIBILITY | |
| 190 | file_time_type last_write_time() const { return __get_write_time(); } | |
| 191 | ||
| 192 | _LIBCPP_INLINE_VISIBILITY | |
| 193 | file_time_type last_write_time(error_code& __ec) const noexcept { | |
| 194 | return __get_write_time(&__ec); | |
| 195 | } | |
| 196 | ||
| 197 | _LIBCPP_INLINE_VISIBILITY | |
| 198 | file_status status() const { return __get_status(); } | |
| 199 | ||
| 200 | _LIBCPP_INLINE_VISIBILITY | |
| 201 | file_status status(error_code& __ec) const noexcept { | |
| 202 | return __get_status(&__ec); | |
| 203 | } | |
| 204 | ||
| 205 | _LIBCPP_INLINE_VISIBILITY | |
| 206 | file_status symlink_status() const { return __get_symlink_status(); } | |
| 207 | ||
| 208 | _LIBCPP_INLINE_VISIBILITY | |
| 209 | file_status symlink_status(error_code& __ec) const noexcept { | |
| 210 | return __get_symlink_status(&__ec); | |
| 211 | } | |
| 212 | ||
| 213 | _LIBCPP_INLINE_VISIBILITY | |
| 214 | bool operator<(directory_entry const& __rhs) const noexcept { | |
| 215 | return __p_ < __rhs.__p_; | |
| 216 | } | |
| 217 | ||
| 218 | _LIBCPP_INLINE_VISIBILITY | |
| 219 | bool operator==(directory_entry const& __rhs) const noexcept { | |
| 220 | return __p_ == __rhs.__p_; | |
| 221 | } | |
| 222 | ||
| 223 | _LIBCPP_INLINE_VISIBILITY | |
| 224 | bool operator!=(directory_entry const& __rhs) const noexcept { | |
| 225 | return __p_ != __rhs.__p_; | |
| 226 | } | |
| 227 | ||
| 228 | _LIBCPP_INLINE_VISIBILITY | |
| 229 | bool operator<=(directory_entry const& __rhs) const noexcept { | |
| 230 | return __p_ <= __rhs.__p_; | |
| 231 | } | |
| 232 | ||
| 233 | _LIBCPP_INLINE_VISIBILITY | |
| 234 | bool operator>(directory_entry const& __rhs) const noexcept { | |
| 235 | return __p_ > __rhs.__p_; | |
| 236 | } | |
| 237 | ||
| 238 | _LIBCPP_INLINE_VISIBILITY | |
| 239 | bool operator>=(directory_entry const& __rhs) const noexcept { | |
| 240 | return __p_ >= __rhs.__p_; | |
| 241 | } | |
| 242 | ||
| 243 | template <class _CharT, class _Traits> | |
| 244 | _LIBCPP_INLINE_VISIBILITY | |
| 245 | friend basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const directory_entry& __d) { | |
| 246 | return __os << __d.path(); | |
| 247 | } | |
| 248 | ||
| 249 | private: | |
| 250 | friend class directory_iterator; | |
| 251 | friend class recursive_directory_iterator; | |
| 252 | friend class _LIBCPP_HIDDEN __dir_stream; | |
| 253 | ||
| 254 | enum _CacheType : unsigned char { | |
| 255 | _Empty, | |
| 256 | _IterSymlink, | |
| 257 | _IterNonSymlink, | |
| 258 | _RefreshSymlink, | |
| 259 | _RefreshSymlinkUnresolved, | |
| 260 | _RefreshNonSymlink | |
| 261 | }; | |
| 262 | ||
| 263 | struct __cached_data { | |
| 264 | uintmax_t __size_; | |
| 265 | uintmax_t __nlink_; | |
| 266 | file_time_type __write_time_; | |
| 267 | perms __sym_perms_; | |
| 268 | perms __non_sym_perms_; | |
| 269 | file_type __type_; | |
| 270 | _CacheType __cache_type_; | |
| 271 | ||
| 272 | _LIBCPP_INLINE_VISIBILITY | |
| 273 | __cached_data() noexcept { __reset(); } | |
| 274 | ||
| 275 | _LIBCPP_INLINE_VISIBILITY | |
| 276 | void __reset() { | |
| 277 | __cache_type_ = _Empty; | |
| 278 | __type_ = file_type::none; | |
| 279 | __sym_perms_ = __non_sym_perms_ = perms::unknown; | |
| 280 | __size_ = __nlink_ = uintmax_t(-1); | |
| 281 | __write_time_ = file_time_type::min(); | |
| 282 | } | |
| 283 | }; | |
| 284 | ||
| 285 | _LIBCPP_INLINE_VISIBILITY | |
| 286 | static __cached_data __create_iter_result(file_type __ft) { | |
| 287 | __cached_data __data; | |
| 288 | __data.__type_ = __ft; | |
| 289 | __data.__cache_type_ = [&]() { | |
| 290 | switch (__ft) { | |
| 291 | case file_type::none: | |
| 292 | return _Empty; | |
| 293 | case file_type::symlink: | |
| 294 | return _IterSymlink; | |
| 295 | default: | |
| 296 | return _IterNonSymlink; | |
| 297 | } | |
| 298 | }(); | |
| 299 | return __data; | |
| 300 | } | |
| 301 | ||
| 302 | _LIBCPP_INLINE_VISIBILITY | |
| 303 | void __assign_iter_entry(_Path&& __p, __cached_data __dt) { | |
| 304 | __p_ = _VSTD::move(__p); | |
| 305 | __data_ = __dt; | |
| 306 | } | |
| 307 | ||
| 308 | _LIBCPP_FUNC_VIS | |
| 309 | error_code __do_refresh() noexcept; | |
| 310 | ||
| 311 | _LIBCPP_INLINE_VISIBILITY | |
| 312 | static bool __is_dne_error(error_code const& __ec) { | |
| 313 | if (!__ec) | |
| 314 | return true; | |
| 315 | switch (static_cast<errc>(__ec.value())) { | |
| 316 | case errc::no_such_file_or_directory: | |
| 317 | case errc::not_a_directory: | |
| 318 | return true; | |
| 319 | default: | |
| 320 | return false; | |
| 321 | } | |
| 322 | } | |
| 323 | ||
| 324 | _LIBCPP_INLINE_VISIBILITY | |
| 325 | void __handle_error(const char* __msg, error_code* __dest_ec, | |
| 326 | error_code const& __ec, bool __allow_dne = false) const { | |
| 327 | if (__dest_ec) { | |
| 328 | *__dest_ec = __ec; | |
| 329 | return; | |
| 330 | } | |
| 331 | if (__ec && (!__allow_dne || !__is_dne_error(__ec))) | |
| 332 | __throw_filesystem_error(__msg, __p_, __ec); | |
| 333 | } | |
| 334 | ||
| 335 | _LIBCPP_INLINE_VISIBILITY | |
| 336 | void __refresh(error_code* __ec = nullptr) { | |
| 337 | __handle_error("in directory_entry::refresh", __ec, __do_refresh(), | |
| 338 | /*allow_dne*/ true); | |
| 339 | } | |
| 340 | ||
| 341 | _LIBCPP_INLINE_VISIBILITY | |
| 342 | file_type __get_sym_ft(error_code* __ec = nullptr) const { | |
| 343 | switch (__data_.__cache_type_) { | |
| 344 | case _Empty: | |
| 345 | return __symlink_status(__p_, __ec).type(); | |
| 346 | case _IterSymlink: | |
| 347 | case _RefreshSymlink: | |
| 348 | case _RefreshSymlinkUnresolved: | |
| 349 | if (__ec) | |
| 350 | __ec->clear(); | |
| 351 | return file_type::symlink; | |
| 352 | case _IterNonSymlink: | |
| 353 | case _RefreshNonSymlink: | |
| 354 | file_status __st(__data_.__type_); | |
| 355 | if (__ec && !_VSTD_FS::exists(__st)) | |
| 356 | *__ec = make_error_code(errc::no_such_file_or_directory); | |
| 357 | else if (__ec) | |
| 358 | __ec->clear(); | |
| 359 | return __data_.__type_; | |
| 360 | } | |
| 361 | _LIBCPP_UNREACHABLE(); | |
| 362 | } | |
| 363 | ||
| 364 | _LIBCPP_INLINE_VISIBILITY | |
| 365 | file_type __get_ft(error_code* __ec = nullptr) const { | |
| 366 | switch (__data_.__cache_type_) { | |
| 367 | case _Empty: | |
| 368 | case _IterSymlink: | |
| 369 | case _RefreshSymlinkUnresolved: | |
| 370 | return __status(__p_, __ec).type(); | |
| 371 | case _IterNonSymlink: | |
| 372 | case _RefreshNonSymlink: | |
| 373 | case _RefreshSymlink: { | |
| 374 | file_status __st(__data_.__type_); | |
| 375 | if (__ec && !_VSTD_FS::exists(__st)) | |
| 376 | *__ec = make_error_code(errc::no_such_file_or_directory); | |
| 377 | else if (__ec) | |
| 378 | __ec->clear(); | |
| 379 | return __data_.__type_; | |
| 380 | } | |
| 381 | } | |
| 382 | _LIBCPP_UNREACHABLE(); | |
| 383 | } | |
| 384 | ||
| 385 | _LIBCPP_INLINE_VISIBILITY | |
| 386 | file_status __get_status(error_code* __ec = nullptr) const { | |
| 387 | switch (__data_.__cache_type_) { | |
| 388 | case _Empty: | |
| 389 | case _IterNonSymlink: | |
| 390 | case _IterSymlink: | |
| 391 | case _RefreshSymlinkUnresolved: | |
| 392 | return __status(__p_, __ec); | |
| 393 | case _RefreshNonSymlink: | |
| 394 | case _RefreshSymlink: | |
| 395 | return file_status(__get_ft(__ec), __data_.__non_sym_perms_); | |
| 396 | } | |
| 397 | _LIBCPP_UNREACHABLE(); | |
| 398 | } | |
| 399 | ||
| 400 | _LIBCPP_INLINE_VISIBILITY | |
| 401 | file_status __get_symlink_status(error_code* __ec = nullptr) const { | |
| 402 | switch (__data_.__cache_type_) { | |
| 403 | case _Empty: | |
| 404 | case _IterNonSymlink: | |
| 405 | case _IterSymlink: | |
| 406 | return __symlink_status(__p_, __ec); | |
| 407 | case _RefreshNonSymlink: | |
| 408 | return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_); | |
| 409 | case _RefreshSymlink: | |
| 410 | case _RefreshSymlinkUnresolved: | |
| 411 | return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); | |
| 412 | } | |
| 413 | _LIBCPP_UNREACHABLE(); | |
| 414 | } | |
| 415 | ||
| 416 | _LIBCPP_INLINE_VISIBILITY | |
| 417 | uintmax_t __get_size(error_code* __ec = nullptr) const { | |
| 418 | switch (__data_.__cache_type_) { | |
| 419 | case _Empty: | |
| 420 | case _IterNonSymlink: | |
| 421 | case _IterSymlink: | |
| 422 | case _RefreshSymlinkUnresolved: | |
| 423 | return _VSTD_FS::__file_size(__p_, __ec); | |
| 424 | case _RefreshSymlink: | |
| 425 | case _RefreshNonSymlink: { | |
| 426 | error_code __m_ec; | |
| 427 | file_status __st(__get_ft(&__m_ec)); | |
| 428 | __handle_error("in directory_entry::file_size", __ec, __m_ec); | |
| 429 | if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) { | |
| 430 | errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory | |
| 431 | : errc::not_supported; | |
| 432 | __handle_error("in directory_entry::file_size", __ec, | |
| 433 | make_error_code(__err_kind)); | |
| 434 | } | |
| 435 | return __data_.__size_; | |
| 436 | } | |
| 437 | } | |
| 438 | _LIBCPP_UNREACHABLE(); | |
| 439 | } | |
| 440 | ||
| 441 | _LIBCPP_INLINE_VISIBILITY | |
| 442 | uintmax_t __get_nlink(error_code* __ec = nullptr) const { | |
| 443 | switch (__data_.__cache_type_) { | |
| 444 | case _Empty: | |
| 445 | case _IterNonSymlink: | |
| 446 | case _IterSymlink: | |
| 447 | case _RefreshSymlinkUnresolved: | |
| 448 | return _VSTD_FS::__hard_link_count(__p_, __ec); | |
| 449 | case _RefreshSymlink: | |
| 450 | case _RefreshNonSymlink: { | |
| 451 | error_code __m_ec; | |
| 452 | (void)__get_ft(&__m_ec); | |
| 453 | __handle_error("in directory_entry::hard_link_count", __ec, __m_ec); | |
| 454 | return __data_.__nlink_; | |
| 455 | } | |
| 456 | } | |
| 457 | _LIBCPP_UNREACHABLE(); | |
| 458 | } | |
| 459 | ||
| 460 | _LIBCPP_INLINE_VISIBILITY | |
| 461 | file_time_type __get_write_time(error_code* __ec = nullptr) const { | |
| 462 | switch (__data_.__cache_type_) { | |
| 463 | case _Empty: | |
| 464 | case _IterNonSymlink: | |
| 465 | case _IterSymlink: | |
| 466 | case _RefreshSymlinkUnresolved: | |
| 467 | return _VSTD_FS::__last_write_time(__p_, __ec); | |
| 468 | case _RefreshSymlink: | |
| 469 | case _RefreshNonSymlink: { | |
| 470 | error_code __m_ec; | |
| 471 | file_status __st(__get_ft(&__m_ec)); | |
| 472 | __handle_error("in directory_entry::last_write_time", __ec, __m_ec); | |
| 473 | if (_VSTD_FS::exists(__st) && | |
| 474 | __data_.__write_time_ == file_time_type::min()) | |
| 475 | __handle_error("in directory_entry::last_write_time", __ec, | |
| 476 | make_error_code(errc::value_too_large)); | |
| 477 | return __data_.__write_time_; | |
| 478 | } | |
| 479 | } | |
| 480 | _LIBCPP_UNREACHABLE(); | |
| 481 | } | |
| 482 | ||
| 483 | private: | |
| 484 | _Path __p_; | |
| 485 | __cached_data __data_; | |
| 486 | }; | |
| 487 | ||
| 488 | class __dir_element_proxy { | |
| 489 | public: | |
| 490 | inline _LIBCPP_INLINE_VISIBILITY directory_entry operator*() { | |
| 491 | return _VSTD::move(__elem_); | |
| 492 | } | |
| 493 | ||
| 494 | private: | |
| 495 | friend class directory_iterator; | |
| 496 | friend class recursive_directory_iterator; | |
| 497 | explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {} | |
| 498 | __dir_element_proxy(__dir_element_proxy&& __o) | |
| 499 | : __elem_(_VSTD::move(__o.__elem_)) {} | |
| 500 | directory_entry __elem_; | |
| 501 | }; | |
| 502 | ||
| 503 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 504 | ||
| 505 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 506 | ||
| 507 | #endif // _LIBCPP_CXX03_LANG | |
| 508 | ||
| 509 | _LIBCPP_POP_MACROS | |
| 510 | ||
| 511 | #endif // _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H |
lib/libcxx/include/__filesystem/directory_iterator.h created+150| ... | ... | @@ -0,0 +1,150 @@ |
| 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___FILESYSTEM_DIRECTORY_ITERATOR_H | |
| 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__debug> | |
| 16 | #include <__filesystem/directory_entry.h> | |
| 17 | #include <__filesystem/directory_options.h> | |
| 18 | #include <__filesystem/path.h> | |
| 19 | #include <__iterator/iterator_traits.h> | |
| 20 | #include <__memory/shared_ptr.h> | |
| 21 | #include <__ranges/enable_borrowed_range.h> | |
| 22 | #include <__ranges/enable_view.h> | |
| 23 | #include <cstddef> | |
| 24 | #include <system_error> | |
| 25 | ||
| 26 | #ifndef _LIBCPP_CXX03_LANG | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 29 | ||
| 30 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 31 | ||
| 32 | class _LIBCPP_HIDDEN __dir_stream; | |
| 33 | class directory_iterator { | |
| 34 | public: | |
| 35 | typedef directory_entry value_type; | |
| 36 | typedef ptrdiff_t difference_type; | |
| 37 | typedef value_type const* pointer; | |
| 38 | typedef value_type const& reference; | |
| 39 | typedef input_iterator_tag iterator_category; | |
| 40 | ||
| 41 | public: | |
| 42 | //ctor & dtor | |
| 43 | directory_iterator() noexcept {} | |
| 44 | ||
| 45 | explicit directory_iterator(const path& __p) | |
| 46 | : directory_iterator(__p, nullptr) {} | |
| 47 | ||
| 48 | directory_iterator(const path& __p, directory_options __opts) | |
| 49 | : directory_iterator(__p, nullptr, __opts) {} | |
| 50 | ||
| 51 | directory_iterator(const path& __p, error_code& __ec) | |
| 52 | : directory_iterator(__p, &__ec) {} | |
| 53 | ||
| 54 | directory_iterator(const path& __p, directory_options __opts, | |
| 55 | error_code& __ec) | |
| 56 | : directory_iterator(__p, &__ec, __opts) {} | |
| 57 | ||
| 58 | directory_iterator(const directory_iterator&) = default; | |
| 59 | directory_iterator(directory_iterator&&) = default; | |
| 60 | directory_iterator& operator=(const directory_iterator&) = default; | |
| 61 | ||
| 62 | directory_iterator& operator=(directory_iterator&& __o) noexcept { | |
| 63 | // non-default implementation provided to support self-move assign. | |
| 64 | if (this != &__o) { | |
| 65 | __imp_ = _VSTD::move(__o.__imp_); | |
| 66 | } | |
| 67 | return *this; | |
| 68 | } | |
| 69 | ||
| 70 | ~directory_iterator() = default; | |
| 71 | ||
| 72 | const directory_entry& operator*() const { | |
| 73 | _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); | |
| 74 | return __dereference(); | |
| 75 | } | |
| 76 | ||
| 77 | const directory_entry* operator->() const { return &**this; } | |
| 78 | ||
| 79 | directory_iterator& operator++() { return __increment(); } | |
| 80 | ||
| 81 | __dir_element_proxy operator++(int) { | |
| 82 | __dir_element_proxy __p(**this); | |
| 83 | __increment(); | |
| 84 | return __p; | |
| 85 | } | |
| 86 | ||
| 87 | directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } | |
| 88 | ||
| 89 | private: | |
| 90 | inline _LIBCPP_INLINE_VISIBILITY friend bool | |
| 91 | operator==(const directory_iterator& __lhs, | |
| 92 | const directory_iterator& __rhs) noexcept; | |
| 93 | ||
| 94 | // construct the dir_stream | |
| 95 | _LIBCPP_FUNC_VIS | |
| 96 | directory_iterator(const path&, error_code*, | |
| 97 | directory_options = directory_options::none); | |
| 98 | ||
| 99 | _LIBCPP_FUNC_VIS | |
| 100 | directory_iterator& __increment(error_code* __ec = nullptr); | |
| 101 | ||
| 102 | _LIBCPP_FUNC_VIS | |
| 103 | const directory_entry& __dereference() const; | |
| 104 | ||
| 105 | private: | |
| 106 | shared_ptr<__dir_stream> __imp_; | |
| 107 | }; | |
| 108 | ||
| 109 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 110 | operator==(const directory_iterator& __lhs, | |
| 111 | const directory_iterator& __rhs) noexcept { | |
| 112 | return __lhs.__imp_ == __rhs.__imp_; | |
| 113 | } | |
| 114 | ||
| 115 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 116 | operator!=(const directory_iterator& __lhs, | |
| 117 | const directory_iterator& __rhs) noexcept { | |
| 118 | return !(__lhs == __rhs); | |
| 119 | } | |
| 120 | ||
| 121 | // enable directory_iterator range-based for statements | |
| 122 | inline _LIBCPP_INLINE_VISIBILITY directory_iterator | |
| 123 | begin(directory_iterator __iter) noexcept { | |
| 124 | return __iter; | |
| 125 | } | |
| 126 | ||
| 127 | inline _LIBCPP_INLINE_VISIBILITY directory_iterator | |
| 128 | end(directory_iterator) noexcept { | |
| 129 | return directory_iterator(); | |
| 130 | } | |
| 131 | ||
| 132 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 133 | ||
| 134 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 135 | ||
| 136 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 137 | ||
| 138 | template <> | |
| 139 | _LIBCPP_AVAILABILITY_FILESYSTEM | |
| 140 | inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::directory_iterator> = true; | |
| 141 | ||
| 142 | template <> | |
| 143 | _LIBCPP_AVAILABILITY_FILESYSTEM | |
| 144 | inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true; | |
| 145 | ||
| 146 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 147 | ||
| 148 | #endif // _LIBCPP_CXX03_LANG | |
| 149 | ||
| 150 | #endif // _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H |
lib/libcxx/include/__filesystem/directory_options.h created+78| ... | ... | @@ -0,0 +1,78 @@ |
| 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___FILESYSTEM_DIRECTORY_OPTIONS_H | |
| 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #ifndef _LIBCPP_CXX03_LANG | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 19 | ||
| 20 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 21 | ||
| 22 | enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { | |
| 23 | none = 0, | |
| 24 | follow_directory_symlink = 1, | |
| 25 | skip_permission_denied = 2 | |
| 26 | }; | |
| 27 | ||
| 28 | _LIBCPP_INLINE_VISIBILITY | |
| 29 | inline constexpr directory_options operator&(directory_options _LHS, | |
| 30 | directory_options _RHS) { | |
| 31 | return static_cast<directory_options>(static_cast<unsigned char>(_LHS) & | |
| 32 | static_cast<unsigned char>(_RHS)); | |
| 33 | } | |
| 34 | ||
| 35 | _LIBCPP_INLINE_VISIBILITY | |
| 36 | inline constexpr directory_options operator|(directory_options _LHS, | |
| 37 | directory_options _RHS) { | |
| 38 | return static_cast<directory_options>(static_cast<unsigned char>(_LHS) | | |
| 39 | static_cast<unsigned char>(_RHS)); | |
| 40 | } | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | inline constexpr directory_options operator^(directory_options _LHS, | |
| 44 | directory_options _RHS) { | |
| 45 | return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^ | |
| 46 | static_cast<unsigned char>(_RHS)); | |
| 47 | } | |
| 48 | ||
| 49 | _LIBCPP_INLINE_VISIBILITY | |
| 50 | inline constexpr directory_options operator~(directory_options _LHS) { | |
| 51 | return static_cast<directory_options>(~static_cast<unsigned char>(_LHS)); | |
| 52 | } | |
| 53 | ||
| 54 | _LIBCPP_INLINE_VISIBILITY | |
| 55 | inline directory_options& operator&=(directory_options& _LHS, | |
| 56 | directory_options _RHS) { | |
| 57 | return _LHS = _LHS & _RHS; | |
| 58 | } | |
| 59 | ||
| 60 | _LIBCPP_INLINE_VISIBILITY | |
| 61 | inline directory_options& operator|=(directory_options& _LHS, | |
| 62 | directory_options _RHS) { | |
| 63 | return _LHS = _LHS | _RHS; | |
| 64 | } | |
| 65 | ||
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | inline directory_options& operator^=(directory_options& _LHS, | |
| 68 | directory_options _RHS) { | |
| 69 | return _LHS = _LHS ^ _RHS; | |
| 70 | } | |
| 71 | ||
| 72 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 75 | ||
| 76 | #endif // _LIBCPP_CXX03_LANG | |
| 77 | ||
| 78 | #endif // _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H |
lib/libcxx/include/__filesystem/file_status.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 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___FILESYSTEM_FILE_STATUS_H | |
| 11 | #define _LIBCPP___FILESYSTEM_FILE_STATUS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__filesystem/file_type.h> | |
| 16 | #include <__filesystem/perms.h> | |
| 17 | ||
| 18 | #ifndef _LIBCPP_CXX03_LANG | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 21 | ||
| 22 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 23 | ||
| 24 | class _LIBCPP_TYPE_VIS file_status { | |
| 25 | public: | |
| 26 | // constructors | |
| 27 | _LIBCPP_INLINE_VISIBILITY | |
| 28 | file_status() noexcept : file_status(file_type::none) {} | |
| 29 | _LIBCPP_INLINE_VISIBILITY | |
| 30 | explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept | |
| 31 | : __ft_(__ft), | |
| 32 | __prms_(__prms) {} | |
| 33 | ||
| 34 | file_status(const file_status&) noexcept = default; | |
| 35 | file_status(file_status&&) noexcept = default; | |
| 36 | ||
| 37 | _LIBCPP_INLINE_VISIBILITY | |
| 38 | ~file_status() {} | |
| 39 | ||
| 40 | file_status& operator=(const file_status&) noexcept = default; | |
| 41 | file_status& operator=(file_status&&) noexcept = default; | |
| 42 | ||
| 43 | // observers | |
| 44 | _LIBCPP_INLINE_VISIBILITY | |
| 45 | file_type type() const noexcept { return __ft_; } | |
| 46 | ||
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | perms permissions() const noexcept { return __prms_; } | |
| 49 | ||
| 50 | // modifiers | |
| 51 | _LIBCPP_INLINE_VISIBILITY | |
| 52 | void type(file_type __ft) noexcept { __ft_ = __ft; } | |
| 53 | ||
| 54 | _LIBCPP_INLINE_VISIBILITY | |
| 55 | void permissions(perms __p) noexcept { __prms_ = __p; } | |
| 56 | ||
| 57 | private: | |
| 58 | file_type __ft_; | |
| 59 | perms __prms_; | |
| 60 | }; | |
| 61 | ||
| 62 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 65 | ||
| 66 | #endif // _LIBCPP_CXX03_LANG | |
| 67 | ||
| 68 | #endif // _LIBCPP___FILESYSTEM_FILE_STATUS_H |
lib/libcxx/include/__filesystem/file_time_type.h 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___FILESYSTEM_FILE_TIME_TYPE_H | |
| 11 | #define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <chrono> | |
| 16 | ||
| 17 | #ifndef _LIBCPP_CXX03_LANG | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 20 | ||
| 21 | typedef chrono::time_point<_FilesystemClock> file_time_type; | |
| 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 24 | ||
| 25 | #endif // _LIBCPP_CXX03_LANG | |
| 26 | ||
| 27 | #endif // _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H |
lib/libcxx/include/__filesystem/file_type.h created+39| ... | ... | @@ -0,0 +1,39 @@ |
| 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___FILESYSTEM_FILE_TYPE_H | |
| 11 | #define _LIBCPP___FILESYSTEM_FILE_TYPE_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #ifndef _LIBCPP_CXX03_LANG | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 19 | ||
| 20 | // On Windows, the library never identifies files as block, character, fifo | |
| 21 | // or socket. | |
| 22 | enum class _LIBCPP_ENUM_VIS file_type : signed char { | |
| 23 | none = 0, | |
| 24 | not_found = -1, | |
| 25 | regular = 1, | |
| 26 | directory = 2, | |
| 27 | symlink = 3, | |
| 28 | block = 4, | |
| 29 | character = 5, | |
| 30 | fifo = 6, | |
| 31 | socket = 7, | |
| 32 | unknown = 8 | |
| 33 | }; | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 36 | ||
| 37 | #endif // _LIBCPP_CXX03_LANG | |
| 38 | ||
| 39 | #endif // _LIBCPP___FILESYSTEM_FILE_TYPE_H |
lib/libcxx/include/__filesystem/filesystem_error.h created+99| ... | ... | @@ -0,0 +1,99 @@ |
| 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___FILESYSTEM_FILESYSTEM_ERROR_H | |
| 11 | #define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__filesystem/path.h> | |
| 16 | #include <__memory/shared_ptr.h> | |
| 17 | #include <iosfwd> | |
| 18 | #include <new> | |
| 19 | #include <system_error> | |
| 20 | #include <type_traits> | |
| 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 25 | ||
| 26 | class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error { | |
| 27 | public: | |
| 28 | _LIBCPP_INLINE_VISIBILITY | |
| 29 | filesystem_error(const string& __what, error_code __ec) | |
| 30 | : system_error(__ec, __what), | |
| 31 | __storage_(make_shared<_Storage>(path(), path())) { | |
| 32 | __create_what(0); | |
| 33 | } | |
| 34 | ||
| 35 | _LIBCPP_INLINE_VISIBILITY | |
| 36 | filesystem_error(const string& __what, const path& __p1, error_code __ec) | |
| 37 | : system_error(__ec, __what), | |
| 38 | __storage_(make_shared<_Storage>(__p1, path())) { | |
| 39 | __create_what(1); | |
| 40 | } | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | filesystem_error(const string& __what, const path& __p1, const path& __p2, | |
| 44 | error_code __ec) | |
| 45 | : system_error(__ec, __what), | |
| 46 | __storage_(make_shared<_Storage>(__p1, __p2)) { | |
| 47 | __create_what(2); | |
| 48 | } | |
| 49 | ||
| 50 | _LIBCPP_INLINE_VISIBILITY | |
| 51 | const path& path1() const noexcept { return __storage_->__p1_; } | |
| 52 | ||
| 53 | _LIBCPP_INLINE_VISIBILITY | |
| 54 | const path& path2() const noexcept { return __storage_->__p2_; } | |
| 55 | ||
| 56 | filesystem_error(const filesystem_error&) = default; | |
| 57 | ~filesystem_error() override; // key function | |
| 58 | ||
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | const char* what() const noexcept override { | |
| 61 | return __storage_->__what_.c_str(); | |
| 62 | } | |
| 63 | ||
| 64 | void __create_what(int __num_paths); | |
| 65 | ||
| 66 | private: | |
| 67 | struct _LIBCPP_HIDDEN _Storage { | |
| 68 | _LIBCPP_INLINE_VISIBILITY | |
| 69 | _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {} | |
| 70 | ||
| 71 | path __p1_; | |
| 72 | path __p2_; | |
| 73 | string __what_; | |
| 74 | }; | |
| 75 | shared_ptr<_Storage> __storage_; | |
| 76 | }; | |
| 77 | ||
| 78 | // TODO(ldionne): We need to pop the pragma and push it again after | |
| 79 | // filesystem_error to work around PR41078. | |
| 80 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 81 | ||
| 82 | template <class... _Args> | |
| 83 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY | |
| 84 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 85 | void __throw_filesystem_error(_Args&&... __args) { | |
| 86 | throw filesystem_error(_VSTD::forward<_Args>(__args)...); | |
| 87 | } | |
| 88 | #else | |
| 89 | void __throw_filesystem_error(_Args&&...) { | |
| 90 | _VSTD::abort(); | |
| 91 | } | |
| 92 | #endif | |
| 93 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 94 | ||
| 95 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 96 | ||
| 97 | #endif // _LIBCPP_CXX03_LANG | |
| 98 | ||
| 99 | #endif // _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H |
lib/libcxx/include/__filesystem/operations.h created+197| ... | ... | @@ -0,0 +1,197 @@ |
| 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___FILESYSTEM_OPERATIONS_H | |
| 11 | #define _LIBCPP___FILESYSTEM_OPERATIONS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__filesystem/copy_options.h> | |
| 16 | #include <__filesystem/file_status.h> | |
| 17 | #include <__filesystem/file_time_type.h> | |
| 18 | #include <__filesystem/file_type.h> | |
| 19 | #include <__filesystem/path.h> | |
| 20 | #include <__filesystem/perm_options.h> | |
| 21 | #include <__filesystem/perms.h> | |
| 22 | #include <__filesystem/space_info.h> | |
| 23 | #include <chrono> | |
| 24 | #include <cstdint> | |
| 25 | #include <system_error> | |
| 26 | ||
| 27 | #ifndef _LIBCPP_CXX03_LANG | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 30 | ||
| 31 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 32 | ||
| 33 | _LIBCPP_FUNC_VIS path __absolute(const path&, error_code* __ec = nullptr); | |
| 34 | _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); | |
| 36 | _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); | |
| 38 | _LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr); | |
| 39 | _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); | |
| 41 | _LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr); | |
| 42 | _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); | |
| 44 | _LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr); | |
| 45 | _LIBCPP_FUNC_VIS void __current_path(const path&, error_code* __ec = nullptr); | |
| 46 | _LIBCPP_FUNC_VIS bool __equivalent(const path&, const path&, error_code* __ec = nullptr); | |
| 47 | _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); | |
| 49 | _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); | |
| 51 | _LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr); | |
| 52 | _LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr); | |
| 53 | _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); | |
| 55 | _LIBCPP_FUNC_VIS uintmax_t __remove_all(const path& p, error_code* ec = nullptr); | |
| 56 | _LIBCPP_FUNC_VIS bool __remove(const path& p, error_code* ec = nullptr); | |
| 57 | _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); | |
| 59 | _LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr); | |
| 60 | ||
| 61 | inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { return __absolute(__p); } | |
| 62 | inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } | |
| 63 | inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { return __canonical(__p); } | |
| 64 | inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); } | |
| 65 | inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); } | |
| 66 | inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); } | |
| 67 | inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); } | |
| 68 | inline _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); } | |
| 69 | inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); } | |
| 70 | inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); } | |
| 71 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); } | |
| 72 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); } | |
| 73 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); } | |
| 74 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); } | |
| 75 | inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { return __create_directories(__p); } | |
| 76 | inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); } | |
| 77 | inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); } | |
| 78 | inline _LIBCPP_INLINE_VISIBILITY void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); } | |
| 79 | inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { return __create_directory(__p); } | |
| 80 | inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); } | |
| 81 | inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); } | |
| 82 | inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); } | |
| 83 | inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); } | |
| 84 | inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); } | |
| 85 | inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); } | |
| 86 | inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); } | |
| 87 | inline _LIBCPP_INLINE_VISIBILITY path current_path() { return __current_path(); } | |
| 88 | inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { return __current_path(&__ec); } | |
| 89 | inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { __current_path(__p); } | |
| 90 | inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); } | |
| 91 | inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); } | |
| 92 | inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); } | |
| 93 | inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; } | |
| 94 | inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; } | |
| 95 | inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { return exists(__status(__p)); } | |
| 96 | ||
| 97 | inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept { | |
| 98 | auto __s = __status(__p, &__ec); | |
| 99 | if (status_known(__s)) | |
| 100 | __ec.clear(); | |
| 101 | return exists(__s); | |
| 102 | } | |
| 103 | ||
| 104 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { return __file_size(__p); } | |
| 105 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); } | |
| 106 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); } | |
| 107 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); } | |
| 108 | inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; } | |
| 109 | inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { return is_block_file(__status(__p)); } | |
| 110 | inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); } | |
| 111 | inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; } | |
| 112 | inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { return is_character_file(__status(__p)); } | |
| 113 | inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); } | |
| 114 | inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; } | |
| 115 | inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { return is_directory(__status(__p)); } | |
| 116 | inline _LIBCPP_INLINE_VISIBILITY 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); | |
| 118 | inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { return __fs_is_empty(__p); } | |
| 119 | inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } | |
| 120 | inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } | |
| 121 | inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { return is_fifo(__status(__p)); } | |
| 122 | inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); } | |
| 123 | inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; } | |
| 124 | inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); } | |
| 125 | inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); } | |
| 126 | inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; } | |
| 127 | inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); } | |
| 128 | inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); } | |
| 129 | inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); } | |
| 130 | inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { return is_other(__status(__p)); } | |
| 131 | inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); } | |
| 132 | inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; } | |
| 133 | inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { return is_socket(__status(__p)); } | |
| 134 | inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); } | |
| 135 | inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p) { return __last_write_time(__p); } | |
| 136 | inline _LIBCPP_INLINE_VISIBILITY file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); } | |
| 137 | inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); } | |
| 138 | inline _LIBCPP_INLINE_VISIBILITY 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); | |
| 140 | inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); } | |
| 141 | inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); } | |
| 142 | inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); } | |
| 143 | ||
| 144 | inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) { | |
| 145 | path __tmp = __weakly_canonical(__p, &__ec); | |
| 146 | if (__ec) | |
| 147 | return {}; | |
| 148 | path __tmp_base = __weakly_canonical(__base, &__ec); | |
| 149 | if (__ec) | |
| 150 | return {}; | |
| 151 | return __tmp.lexically_proximate(__tmp_base); | |
| 152 | } | |
| 153 | ||
| 154 | inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); } | |
| 155 | inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); } | |
| 156 | inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { return __read_symlink(__p); } | |
| 157 | inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); } | |
| 158 | ||
| 159 | inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) { | |
| 160 | path __tmp = __weakly_canonical(__p, &__ec); | |
| 161 | if (__ec) | |
| 162 | return path(); | |
| 163 | path __tmpbase = __weakly_canonical(__base, &__ec); | |
| 164 | if (__ec) | |
| 165 | return path(); | |
| 166 | return __tmp.lexically_relative(__tmpbase); | |
| 167 | } | |
| 168 | ||
| 169 | inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); } | |
| 170 | inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); } | |
| 171 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { return __remove_all(__p); } | |
| 172 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); } | |
| 173 | inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { return __remove(__p); } | |
| 174 | inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); } | |
| 175 | inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to) { return __rename(__from, __to); } | |
| 176 | inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); } | |
| 177 | inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); } | |
| 178 | inline _LIBCPP_INLINE_VISIBILITY 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); | |
| 180 | inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { return __space(__p); } | |
| 181 | inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); } | |
| 182 | inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { return __status(__p); } | |
| 183 | inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); } | |
| 184 | inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { return __symlink_status(__p); } | |
| 185 | inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); } | |
| 186 | inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { return __temp_directory_path(); } | |
| 187 | inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); } | |
| 188 | inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { return __weakly_canonical(__p); } | |
| 189 | inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); } | |
| 190 | ||
| 191 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 192 | ||
| 193 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 194 | ||
| 195 | #endif // _LIBCPP_CXX03_LANG | |
| 196 | ||
| 197 | #endif // _LIBCPP___FILESYSTEM_OPERATIONS_H |
lib/libcxx/include/__filesystem/path.h created+1018| ... | ... | @@ -0,0 +1,1018 @@ |
| 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___FILESYSTEM_PATH_H | |
| 11 | #define _LIBCPP___FILESYSTEM_PATH_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/back_insert_iterator.h> | |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | #include <cstddef> | |
| 18 | #include <string> | |
| 19 | #include <string_view> | |
| 20 | #include <type_traits> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 23 | # include <iomanip> // for quoted | |
| 24 | # include <locale> | |
| 25 | #endif | |
| 26 | ||
| 27 | #ifndef _LIBCPP_CXX03_LANG | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 30 | ||
| 31 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 32 | ||
| 33 | template <class _Tp> | |
| 34 | struct __can_convert_char { | |
| 35 | static const bool value = false; | |
| 36 | }; | |
| 37 | template <class _Tp> | |
| 38 | struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {}; | |
| 39 | template <> | |
| 40 | struct __can_convert_char<char> { | |
| 41 | static const bool value = true; | |
| 42 | using __char_type = char; | |
| 43 | }; | |
| 44 | template <> | |
| 45 | struct __can_convert_char<wchar_t> { | |
| 46 | static const bool value = true; | |
| 47 | using __char_type = wchar_t; | |
| 48 | }; | |
| 49 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 50 | template <> | |
| 51 | struct __can_convert_char<char8_t> { | |
| 52 | static const bool value = true; | |
| 53 | using __char_type = char8_t; | |
| 54 | }; | |
| 55 | #endif | |
| 56 | template <> | |
| 57 | struct __can_convert_char<char16_t> { | |
| 58 | static const bool value = true; | |
| 59 | using __char_type = char16_t; | |
| 60 | }; | |
| 61 | template <> | |
| 62 | struct __can_convert_char<char32_t> { | |
| 63 | static const bool value = true; | |
| 64 | using __char_type = char32_t; | |
| 65 | }; | |
| 66 | ||
| 67 | template <class _ECharT> | |
| 68 | typename enable_if<__can_convert_char<_ECharT>::value, bool>::type | |
| 69 | __is_separator(_ECharT __e) { | |
| 70 | #if defined(_LIBCPP_WIN32API) | |
| 71 | return __e == _ECharT('/') || __e == _ECharT('\\'); | |
| 72 | #else | |
| 73 | return __e == _ECharT('/'); | |
| 74 | #endif | |
| 75 | } | |
| 76 | ||
| 77 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 78 | typedef u8string __u8_string; | |
| 79 | #else | |
| 80 | typedef string __u8_string; | |
| 81 | #endif | |
| 82 | ||
| 83 | struct _NullSentinel {}; | |
| 84 | ||
| 85 | template <class _Tp> | |
| 86 | using _Void = void; | |
| 87 | ||
| 88 | template <class _Tp, class = void> | |
| 89 | struct __is_pathable_string : public false_type {}; | |
| 90 | ||
| 91 | template <class _ECharT, class _Traits, class _Alloc> | |
| 92 | struct __is_pathable_string< | |
| 93 | basic_string<_ECharT, _Traits, _Alloc>, | |
| 94 | _Void<typename __can_convert_char<_ECharT>::__char_type> > | |
| 95 | : public __can_convert_char<_ECharT> { | |
| 96 | using _Str = basic_string<_ECharT, _Traits, _Alloc>; | |
| 97 | using _Base = __can_convert_char<_ECharT>; | |
| 98 | static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } | |
| 99 | static _ECharT const* __range_end(_Str const& __s) { | |
| 100 | return __s.data() + __s.length(); | |
| 101 | } | |
| 102 | static _ECharT __first_or_null(_Str const& __s) { | |
| 103 | return __s.empty() ? _ECharT{} : __s[0]; | |
| 104 | } | |
| 105 | }; | |
| 106 | ||
| 107 | template <class _ECharT, class _Traits> | |
| 108 | struct __is_pathable_string< | |
| 109 | basic_string_view<_ECharT, _Traits>, | |
| 110 | _Void<typename __can_convert_char<_ECharT>::__char_type> > | |
| 111 | : public __can_convert_char<_ECharT> { | |
| 112 | using _Str = basic_string_view<_ECharT, _Traits>; | |
| 113 | using _Base = __can_convert_char<_ECharT>; | |
| 114 | static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } | |
| 115 | static _ECharT const* __range_end(_Str const& __s) { | |
| 116 | return __s.data() + __s.length(); | |
| 117 | } | |
| 118 | static _ECharT __first_or_null(_Str const& __s) { | |
| 119 | return __s.empty() ? _ECharT{} : __s[0]; | |
| 120 | } | |
| 121 | }; | |
| 122 | ||
| 123 | template <class _Source, class _DS = typename decay<_Source>::type, | |
| 124 | class _UnqualPtrType = | |
| 125 | typename remove_const<typename remove_pointer<_DS>::type>::type, | |
| 126 | bool _IsCharPtr = is_pointer<_DS>::value&& | |
| 127 | __can_convert_char<_UnqualPtrType>::value> | |
| 128 | struct __is_pathable_char_array : false_type {}; | |
| 129 | ||
| 130 | template <class _Source, class _ECharT, class _UPtr> | |
| 131 | struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> | |
| 132 | : __can_convert_char<typename remove_const<_ECharT>::type> { | |
| 133 | using _Base = __can_convert_char<typename remove_const<_ECharT>::type>; | |
| 134 | ||
| 135 | static _ECharT const* __range_begin(const _ECharT* __b) { return __b; } | |
| 136 | static _ECharT const* __range_end(const _ECharT* __b) { | |
| 137 | using _Iter = const _ECharT*; | |
| 138 | const _ECharT __sentinel = _ECharT{}; | |
| 139 | _Iter __e = __b; | |
| 140 | for (; *__e != __sentinel; ++__e) | |
| 141 | ; | |
| 142 | return __e; | |
| 143 | } | |
| 144 | ||
| 145 | static _ECharT __first_or_null(const _ECharT* __b) { return *__b; } | |
| 146 | }; | |
| 147 | ||
| 148 | template <class _Iter, bool _IsIt = __is_cpp17_input_iterator<_Iter>::value, | |
| 149 | class = void> | |
| 150 | struct __is_pathable_iter : false_type {}; | |
| 151 | ||
| 152 | template <class _Iter> | |
| 153 | struct __is_pathable_iter< | |
| 154 | _Iter, true, | |
| 155 | _Void<typename __can_convert_char< | |
| 156 | typename iterator_traits<_Iter>::value_type>::__char_type> > | |
| 157 | : __can_convert_char<typename iterator_traits<_Iter>::value_type> { | |
| 158 | using _ECharT = typename iterator_traits<_Iter>::value_type; | |
| 159 | using _Base = __can_convert_char<_ECharT>; | |
| 160 | ||
| 161 | static _Iter __range_begin(_Iter __b) { return __b; } | |
| 162 | static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; } | |
| 163 | ||
| 164 | static _ECharT __first_or_null(_Iter __b) { return *__b; } | |
| 165 | }; | |
| 166 | ||
| 167 | template <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::value, | |
| 168 | bool _IsCharIterT = __is_pathable_char_array<_Tp>::value, | |
| 169 | bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value> | |
| 170 | struct __is_pathable : false_type { | |
| 171 | static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false"); | |
| 172 | }; | |
| 173 | ||
| 174 | template <class _Tp> | |
| 175 | struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {}; | |
| 176 | ||
| 177 | template <class _Tp> | |
| 178 | struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> { | |
| 179 | }; | |
| 180 | ||
| 181 | template <class _Tp> | |
| 182 | struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; | |
| 183 | ||
| 184 | #if defined(_LIBCPP_WIN32API) | |
| 185 | typedef wstring __path_string; | |
| 186 | typedef wchar_t __path_value; | |
| 187 | #else | |
| 188 | typedef string __path_string; | |
| 189 | typedef char __path_value; | |
| 190 | #endif | |
| 191 | ||
| 192 | #if defined(_LIBCPP_WIN32API) | |
| 193 | _LIBCPP_FUNC_VIS | |
| 194 | size_t __wide_to_char(const wstring&, char*, size_t); | |
| 195 | _LIBCPP_FUNC_VIS | |
| 196 | size_t __char_to_wide(const string&, wchar_t*, size_t); | |
| 197 | #endif | |
| 198 | ||
| 199 | template <class _ECharT> | |
| 200 | struct _PathCVT; | |
| 201 | ||
| 202 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 203 | template <class _ECharT> | |
| 204 | struct _PathCVT { | |
| 205 | static_assert(__can_convert_char<_ECharT>::value, | |
| 206 | "Char type not convertible"); | |
| 207 | ||
| 208 | typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower; | |
| 209 | #if defined(_LIBCPP_WIN32API) | |
| 210 | typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener; | |
| 211 | #endif | |
| 212 | ||
| 213 | static void __append_range(__path_string& __dest, _ECharT const* __b, | |
| 214 | _ECharT const* __e) { | |
| 215 | #if defined(_LIBCPP_WIN32API) | |
| 216 | string __utf8; | |
| 217 | _Narrower()(back_inserter(__utf8), __b, __e); | |
| 218 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 219 | #else | |
| 220 | _Narrower()(back_inserter(__dest), __b, __e); | |
| 221 | #endif | |
| 222 | } | |
| 223 | ||
| 224 | template <class _Iter> | |
| 225 | static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 226 | static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); | |
| 227 | if (__b == __e) | |
| 228 | return; | |
| 229 | basic_string<_ECharT> __tmp(__b, __e); | |
| 230 | #if defined(_LIBCPP_WIN32API) | |
| 231 | string __utf8; | |
| 232 | _Narrower()(back_inserter(__utf8), __tmp.data(), | |
| 233 | __tmp.data() + __tmp.length()); | |
| 234 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 235 | #else | |
| 236 | _Narrower()(back_inserter(__dest), __tmp.data(), | |
| 237 | __tmp.data() + __tmp.length()); | |
| 238 | #endif | |
| 239 | } | |
| 240 | ||
| 241 | template <class _Iter> | |
| 242 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { | |
| 243 | static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); | |
| 244 | const _ECharT __sentinel = _ECharT{}; | |
| 245 | if (*__b == __sentinel) | |
| 246 | return; | |
| 247 | basic_string<_ECharT> __tmp; | |
| 248 | for (; *__b != __sentinel; ++__b) | |
| 249 | __tmp.push_back(*__b); | |
| 250 | #if defined(_LIBCPP_WIN32API) | |
| 251 | string __utf8; | |
| 252 | _Narrower()(back_inserter(__utf8), __tmp.data(), | |
| 253 | __tmp.data() + __tmp.length()); | |
| 254 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 255 | #else | |
| 256 | _Narrower()(back_inserter(__dest), __tmp.data(), | |
| 257 | __tmp.data() + __tmp.length()); | |
| 258 | #endif | |
| 259 | } | |
| 260 | ||
| 261 | template <class _Source> | |
| 262 | static void __append_source(__path_string& __dest, _Source const& __s) { | |
| 263 | using _Traits = __is_pathable<_Source>; | |
| 264 | __append_range(__dest, _Traits::__range_begin(__s), | |
| 265 | _Traits::__range_end(__s)); | |
| 266 | } | |
| 267 | }; | |
| 268 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 269 | ||
| 270 | template <> | |
| 271 | struct _PathCVT<__path_value> { | |
| 272 | ||
| 273 | template <class _Iter> | |
| 274 | static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type | |
| 275 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 276 | for (; __b != __e; ++__b) | |
| 277 | __dest.push_back(*__b); | |
| 278 | } | |
| 279 | ||
| 280 | template <class _Iter> | |
| 281 | static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type | |
| 282 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 283 | __dest.append(__b, __e); | |
| 284 | } | |
| 285 | ||
| 286 | template <class _Iter> | |
| 287 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { | |
| 288 | const char __sentinel = char{}; | |
| 289 | for (; *__b != __sentinel; ++__b) | |
| 290 | __dest.push_back(*__b); | |
| 291 | } | |
| 292 | ||
| 293 | template <class _Source> | |
| 294 | static void __append_source(__path_string& __dest, _Source const& __s) { | |
| 295 | using _Traits = __is_pathable<_Source>; | |
| 296 | __append_range(__dest, _Traits::__range_begin(__s), | |
| 297 | _Traits::__range_end(__s)); | |
| 298 | } | |
| 299 | }; | |
| 300 | ||
| 301 | #if defined(_LIBCPP_WIN32API) | |
| 302 | template <> | |
| 303 | struct _PathCVT<char> { | |
| 304 | ||
| 305 | static void | |
| 306 | __append_string(__path_string& __dest, const basic_string<char> &__str) { | |
| 307 | size_t __size = __char_to_wide(__str, nullptr, 0); | |
| 308 | size_t __pos = __dest.size(); | |
| 309 | __dest.resize(__pos + __size); | |
| 310 | __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size); | |
| 311 | } | |
| 312 | ||
| 313 | template <class _Iter> | |
| 314 | static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type | |
| 315 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 316 | basic_string<char> __tmp(__b, __e); | |
| 317 | __append_string(__dest, __tmp); | |
| 318 | } | |
| 319 | ||
| 320 | template <class _Iter> | |
| 321 | static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type | |
| 322 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 323 | basic_string<char> __tmp(__b, __e); | |
| 324 | __append_string(__dest, __tmp); | |
| 325 | } | |
| 326 | ||
| 327 | template <class _Iter> | |
| 328 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { | |
| 329 | const char __sentinel = char{}; | |
| 330 | basic_string<char> __tmp; | |
| 331 | for (; *__b != __sentinel; ++__b) | |
| 332 | __tmp.push_back(*__b); | |
| 333 | __append_string(__dest, __tmp); | |
| 334 | } | |
| 335 | ||
| 336 | template <class _Source> | |
| 337 | static void __append_source(__path_string& __dest, _Source const& __s) { | |
| 338 | using _Traits = __is_pathable<_Source>; | |
| 339 | __append_range(__dest, _Traits::__range_begin(__s), | |
| 340 | _Traits::__range_end(__s)); | |
| 341 | } | |
| 342 | }; | |
| 343 | ||
| 344 | template <class _ECharT> | |
| 345 | struct _PathExport { | |
| 346 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; | |
| 347 | typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener; | |
| 348 | ||
| 349 | template <class _Str> | |
| 350 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 351 | string __utf8; | |
| 352 | _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size()); | |
| 353 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 354 | } | |
| 355 | }; | |
| 356 | ||
| 357 | template <> | |
| 358 | struct _PathExport<char> { | |
| 359 | template <class _Str> | |
| 360 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 361 | size_t __size = __wide_to_char(__src, nullptr, 0); | |
| 362 | size_t __pos = __dest.size(); | |
| 363 | __dest.resize(__size); | |
| 364 | __wide_to_char(__src, const_cast<char*>(__dest.data()) + __pos, __size); | |
| 365 | } | |
| 366 | }; | |
| 367 | ||
| 368 | template <> | |
| 369 | struct _PathExport<wchar_t> { | |
| 370 | template <class _Str> | |
| 371 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 372 | __dest.append(__src.begin(), __src.end()); | |
| 373 | } | |
| 374 | }; | |
| 375 | ||
| 376 | template <> | |
| 377 | struct _PathExport<char16_t> { | |
| 378 | template <class _Str> | |
| 379 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 380 | __dest.append(__src.begin(), __src.end()); | |
| 381 | } | |
| 382 | }; | |
| 383 | ||
| 384 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 385 | template <> | |
| 386 | struct _PathExport<char8_t> { | |
| 387 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; | |
| 388 | ||
| 389 | template <class _Str> | |
| 390 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 391 | _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); | |
| 392 | } | |
| 393 | }; | |
| 394 | #endif /* !_LIBCPP_HAS_NO_CHAR8_T */ | |
| 395 | #endif /* _LIBCPP_WIN32API */ | |
| 396 | ||
| 397 | class _LIBCPP_TYPE_VIS path { | |
| 398 | template <class _SourceOrIter, class _Tp = path&> | |
| 399 | using _EnableIfPathable = | |
| 400 | typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; | |
| 401 | ||
| 402 | template <class _Tp> | |
| 403 | using _SourceChar = typename __is_pathable<_Tp>::__char_type; | |
| 404 | ||
| 405 | template <class _Tp> | |
| 406 | using _SourceCVT = _PathCVT<_SourceChar<_Tp> >; | |
| 407 | ||
| 408 | public: | |
| 409 | #if defined(_LIBCPP_WIN32API) | |
| 410 | typedef wchar_t value_type; | |
| 411 | static constexpr value_type preferred_separator = L'\\'; | |
| 412 | #else | |
| 413 | typedef char value_type; | |
| 414 | static constexpr value_type preferred_separator = '/'; | |
| 415 | #endif | |
| 416 | typedef basic_string<value_type> string_type; | |
| 417 | typedef basic_string_view<value_type> __string_view; | |
| 418 | ||
| 419 | enum _LIBCPP_ENUM_VIS format : unsigned char { | |
| 420 | auto_format, | |
| 421 | native_format, | |
| 422 | generic_format | |
| 423 | }; | |
| 424 | ||
| 425 | // constructors and destructor | |
| 426 | _LIBCPP_INLINE_VISIBILITY path() noexcept {} | |
| 427 | _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {} | |
| 428 | _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept | |
| 429 | : __pn_(_VSTD::move(__p.__pn_)) {} | |
| 430 | ||
| 431 | _LIBCPP_INLINE_VISIBILITY | |
| 432 | path(string_type&& __s, format = format::auto_format) noexcept | |
| 433 | : __pn_(_VSTD::move(__s)) {} | |
| 434 | ||
| 435 | template <class _Source, class = _EnableIfPathable<_Source, void> > | |
| 436 | path(const _Source& __src, format = format::auto_format) { | |
| 437 | _SourceCVT<_Source>::__append_source(__pn_, __src); | |
| 438 | } | |
| 439 | ||
| 440 | template <class _InputIt> | |
| 441 | path(_InputIt __first, _InputIt __last, format = format::auto_format) { | |
| 442 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 443 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); | |
| 444 | } | |
| 445 | ||
| 446 | /* | |
| 447 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 448 | // TODO Implement locale conversions. | |
| 449 | template <class _Source, class = _EnableIfPathable<_Source, void> > | |
| 450 | path(const _Source& __src, const locale& __loc, format = format::auto_format); | |
| 451 | template <class _InputIt> | |
| 452 | path(_InputIt __first, _InputIt _last, const locale& __loc, | |
| 453 | format = format::auto_format); | |
| 454 | #endif | |
| 455 | */ | |
| 456 | ||
| 457 | _LIBCPP_INLINE_VISIBILITY | |
| 458 | ~path() = default; | |
| 459 | ||
| 460 | // assignments | |
| 461 | _LIBCPP_INLINE_VISIBILITY | |
| 462 | path& operator=(const path& __p) { | |
| 463 | __pn_ = __p.__pn_; | |
| 464 | return *this; | |
| 465 | } | |
| 466 | ||
| 467 | _LIBCPP_INLINE_VISIBILITY | |
| 468 | path& operator=(path&& __p) noexcept { | |
| 469 | __pn_ = _VSTD::move(__p.__pn_); | |
| 470 | return *this; | |
| 471 | } | |
| 472 | ||
| 473 | _LIBCPP_INLINE_VISIBILITY | |
| 474 | path& operator=(string_type&& __s) noexcept { | |
| 475 | __pn_ = _VSTD::move(__s); | |
| 476 | return *this; | |
| 477 | } | |
| 478 | ||
| 479 | _LIBCPP_INLINE_VISIBILITY | |
| 480 | path& assign(string_type&& __s) noexcept { | |
| 481 | __pn_ = _VSTD::move(__s); | |
| 482 | return *this; | |
| 483 | } | |
| 484 | ||
| 485 | template <class _Source> | |
| 486 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 487 | operator=(const _Source& __src) { | |
| 488 | return this->assign(__src); | |
| 489 | } | |
| 490 | ||
| 491 | template <class _Source> | |
| 492 | _EnableIfPathable<_Source> assign(const _Source& __src) { | |
| 493 | __pn_.clear(); | |
| 494 | _SourceCVT<_Source>::__append_source(__pn_, __src); | |
| 495 | return *this; | |
| 496 | } | |
| 497 | ||
| 498 | template <class _InputIt> | |
| 499 | path& assign(_InputIt __first, _InputIt __last) { | |
| 500 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 501 | __pn_.clear(); | |
| 502 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); | |
| 503 | return *this; | |
| 504 | } | |
| 505 | ||
| 506 | public: | |
| 507 | // appends | |
| 508 | #if defined(_LIBCPP_WIN32API) | |
| 509 | path& operator/=(const path& __p) { | |
| 510 | auto __p_root_name = __p.__root_name(); | |
| 511 | auto __p_root_name_size = __p_root_name.size(); | |
| 512 | if (__p.is_absolute() || | |
| 513 | (!__p_root_name.empty() && __p_root_name != __string_view(root_name().__pn_))) { | |
| 514 | __pn_ = __p.__pn_; | |
| 515 | return *this; | |
| 516 | } | |
| 517 | if (__p.has_root_directory()) { | |
| 518 | path __root_name_str = root_name(); | |
| 519 | __pn_ = __root_name_str.native(); | |
| 520 | __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size); | |
| 521 | return *this; | |
| 522 | } | |
| 523 | if (has_filename() || (!has_root_directory() && is_absolute())) | |
| 524 | __pn_ += preferred_separator; | |
| 525 | __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size); | |
| 526 | return *this; | |
| 527 | } | |
| 528 | template <class _Source> | |
| 529 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 530 | operator/=(const _Source& __src) { | |
| 531 | return operator/=(path(__src)); | |
| 532 | } | |
| 533 | ||
| 534 | template <class _Source> | |
| 535 | _EnableIfPathable<_Source> append(const _Source& __src) { | |
| 536 | return operator/=(path(__src)); | |
| 537 | } | |
| 538 | ||
| 539 | template <class _InputIt> | |
| 540 | path& append(_InputIt __first, _InputIt __last) { | |
| 541 | return operator/=(path(__first, __last)); | |
| 542 | } | |
| 543 | #else | |
| 544 | path& operator/=(const path& __p) { | |
| 545 | if (__p.is_absolute()) { | |
| 546 | __pn_ = __p.__pn_; | |
| 547 | return *this; | |
| 548 | } | |
| 549 | if (has_filename()) | |
| 550 | __pn_ += preferred_separator; | |
| 551 | __pn_ += __p.native(); | |
| 552 | return *this; | |
| 553 | } | |
| 554 | ||
| 555 | // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src | |
| 556 | // is known at compile time to be "/' since the user almost certainly intended | |
| 557 | // to append a separator instead of overwriting the path with "/" | |
| 558 | template <class _Source> | |
| 559 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 560 | operator/=(const _Source& __src) { | |
| 561 | return this->append(__src); | |
| 562 | } | |
| 563 | ||
| 564 | template <class _Source> | |
| 565 | _EnableIfPathable<_Source> append(const _Source& __src) { | |
| 566 | using _Traits = __is_pathable<_Source>; | |
| 567 | using _CVT = _PathCVT<_SourceChar<_Source> >; | |
| 568 | bool __source_is_absolute = __is_separator(_Traits::__first_or_null(__src)); | |
| 569 | if (__source_is_absolute) | |
| 570 | __pn_.clear(); | |
| 571 | else if (has_filename()) | |
| 572 | __pn_ += preferred_separator; | |
| 573 | _CVT::__append_source(__pn_, __src); | |
| 574 | return *this; | |
| 575 | } | |
| 576 | ||
| 577 | template <class _InputIt> | |
| 578 | path& append(_InputIt __first, _InputIt __last) { | |
| 579 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 580 | static_assert(__can_convert_char<_ItVal>::value, "Must convertible"); | |
| 581 | using _CVT = _PathCVT<_ItVal>; | |
| 582 | if (__first != __last && __is_separator(*__first)) | |
| 583 | __pn_.clear(); | |
| 584 | else if (has_filename()) | |
| 585 | __pn_ += preferred_separator; | |
| 586 | _CVT::__append_range(__pn_, __first, __last); | |
| 587 | return *this; | |
| 588 | } | |
| 589 | #endif | |
| 590 | ||
| 591 | // concatenation | |
| 592 | _LIBCPP_INLINE_VISIBILITY | |
| 593 | path& operator+=(const path& __x) { | |
| 594 | __pn_ += __x.__pn_; | |
| 595 | return *this; | |
| 596 | } | |
| 597 | ||
| 598 | _LIBCPP_INLINE_VISIBILITY | |
| 599 | path& operator+=(const string_type& __x) { | |
| 600 | __pn_ += __x; | |
| 601 | return *this; | |
| 602 | } | |
| 603 | ||
| 604 | _LIBCPP_INLINE_VISIBILITY | |
| 605 | path& operator+=(__string_view __x) { | |
| 606 | __pn_ += __x; | |
| 607 | return *this; | |
| 608 | } | |
| 609 | ||
| 610 | _LIBCPP_INLINE_VISIBILITY | |
| 611 | path& operator+=(const value_type* __x) { | |
| 612 | __pn_ += __x; | |
| 613 | return *this; | |
| 614 | } | |
| 615 | ||
| 616 | _LIBCPP_INLINE_VISIBILITY | |
| 617 | path& operator+=(value_type __x) { | |
| 618 | __pn_ += __x; | |
| 619 | return *this; | |
| 620 | } | |
| 621 | ||
| 622 | template <class _ECharT> | |
| 623 | typename enable_if<__can_convert_char<_ECharT>::value, path&>::type | |
| 624 | operator+=(_ECharT __x) { | |
| 625 | _PathCVT<_ECharT>::__append_source(__pn_, | |
| 626 | basic_string_view<_ECharT>(&__x, 1)); | |
| 627 | return *this; | |
| 628 | } | |
| 629 | ||
| 630 | template <class _Source> | |
| 631 | _EnableIfPathable<_Source> operator+=(const _Source& __x) { | |
| 632 | return this->concat(__x); | |
| 633 | } | |
| 634 | ||
| 635 | template <class _Source> | |
| 636 | _EnableIfPathable<_Source> concat(const _Source& __x) { | |
| 637 | _SourceCVT<_Source>::__append_source(__pn_, __x); | |
| 638 | return *this; | |
| 639 | } | |
| 640 | ||
| 641 | template <class _InputIt> | |
| 642 | path& concat(_InputIt __first, _InputIt __last) { | |
| 643 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 644 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); | |
| 645 | return *this; | |
| 646 | } | |
| 647 | ||
| 648 | // modifiers | |
| 649 | _LIBCPP_INLINE_VISIBILITY | |
| 650 | void clear() noexcept { __pn_.clear(); } | |
| 651 | ||
| 652 | path& make_preferred() { | |
| 653 | #if defined(_LIBCPP_WIN32API) | |
| 654 | _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\'); | |
| 655 | #endif | |
| 656 | return *this; | |
| 657 | } | |
| 658 | ||
| 659 | _LIBCPP_INLINE_VISIBILITY | |
| 660 | path& remove_filename() { | |
| 661 | auto __fname = __filename(); | |
| 662 | if (!__fname.empty()) | |
| 663 | __pn_.erase(__fname.data() - __pn_.data()); | |
| 664 | return *this; | |
| 665 | } | |
| 666 | ||
| 667 | path& replace_filename(const path& __replacement) { | |
| 668 | remove_filename(); | |
| 669 | return (*this /= __replacement); | |
| 670 | } | |
| 671 | ||
| 672 | path& replace_extension(const path& __replacement = path()); | |
| 673 | ||
| 674 | _LIBCPP_INLINE_VISIBILITY | |
| 675 | void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); } | |
| 676 | ||
| 677 | // private helper to allow reserving memory in the path | |
| 678 | _LIBCPP_INLINE_VISIBILITY | |
| 679 | void __reserve(size_t __s) { __pn_.reserve(__s); } | |
| 680 | ||
| 681 | // native format observers | |
| 682 | _LIBCPP_INLINE_VISIBILITY | |
| 683 | const string_type& native() const noexcept { return __pn_; } | |
| 684 | ||
| 685 | _LIBCPP_INLINE_VISIBILITY | |
| 686 | const value_type* c_str() const noexcept { return __pn_.c_str(); } | |
| 687 | ||
| 688 | _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; } | |
| 689 | ||
| 690 | #if defined(_LIBCPP_WIN32API) | |
| 691 | _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; } | |
| 692 | ||
| 693 | _VSTD::wstring generic_wstring() const { | |
| 694 | _VSTD::wstring __s; | |
| 695 | __s.resize(__pn_.size()); | |
| 696 | _VSTD::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/'); | |
| 697 | return __s; | |
| 698 | } | |
| 699 | ||
| 700 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 701 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 702 | class _Allocator = allocator<_ECharT> > | |
| 703 | basic_string<_ECharT, _Traits, _Allocator> | |
| 704 | string(const _Allocator& __a = _Allocator()) const { | |
| 705 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | |
| 706 | _Str __s(__a); | |
| 707 | __s.reserve(__pn_.size()); | |
| 708 | _PathExport<_ECharT>::__append(__s, __pn_); | |
| 709 | return __s; | |
| 710 | } | |
| 711 | ||
| 712 | _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { | |
| 713 | return string<char>(); | |
| 714 | } | |
| 715 | _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const { | |
| 716 | using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | |
| 717 | __u8_string __s; | |
| 718 | __s.reserve(__pn_.size()); | |
| 719 | _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); | |
| 720 | return __s; | |
| 721 | } | |
| 722 | ||
| 723 | _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { | |
| 724 | return string<char16_t>(); | |
| 725 | } | |
| 726 | _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { | |
| 727 | return string<char32_t>(); | |
| 728 | } | |
| 729 | ||
| 730 | // generic format observers | |
| 731 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 732 | class _Allocator = allocator<_ECharT> > | |
| 733 | basic_string<_ECharT, _Traits, _Allocator> | |
| 734 | generic_string(const _Allocator& __a = _Allocator()) const { | |
| 735 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | |
| 736 | _Str __s = string<_ECharT, _Traits, _Allocator>(__a); | |
| 737 | // Note: This (and generic_u8string below) is slightly suboptimal as | |
| 738 | // it iterates twice over the string; once to convert it to the right | |
| 739 | // character type, and once to replace path delimiters. | |
| 740 | _VSTD::replace(__s.begin(), __s.end(), | |
| 741 | static_cast<_ECharT>('\\'), static_cast<_ECharT>('/')); | |
| 742 | return __s; | |
| 743 | } | |
| 744 | ||
| 745 | _VSTD::string generic_string() const { return generic_string<char>(); } | |
| 746 | _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); } | |
| 747 | _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); } | |
| 748 | __u8_string generic_u8string() const { | |
| 749 | __u8_string __s = u8string(); | |
| 750 | _VSTD::replace(__s.begin(), __s.end(), '\\', '/'); | |
| 751 | return __s; | |
| 752 | } | |
| 753 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 754 | #else /* _LIBCPP_WIN32API */ | |
| 755 | ||
| 756 | _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; } | |
| 757 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 758 | _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 759 | #else | |
| 760 | _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; } | |
| 761 | #endif | |
| 762 | ||
| 763 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 764 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 765 | class _Allocator = allocator<_ECharT> > | |
| 766 | basic_string<_ECharT, _Traits, _Allocator> | |
| 767 | string(const _Allocator& __a = _Allocator()) const { | |
| 768 | using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>; | |
| 769 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | |
| 770 | _Str __s(__a); | |
| 771 | __s.reserve(__pn_.size()); | |
| 772 | _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); | |
| 773 | return __s; | |
| 774 | } | |
| 775 | ||
| 776 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 777 | _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { | |
| 778 | return string<wchar_t>(); | |
| 779 | } | |
| 780 | #endif | |
| 781 | _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { | |
| 782 | return string<char16_t>(); | |
| 783 | } | |
| 784 | _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { | |
| 785 | return string<char32_t>(); | |
| 786 | } | |
| 787 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 788 | ||
| 789 | // generic format observers | |
| 790 | _VSTD::string generic_string() const { return __pn_; } | |
| 791 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 792 | _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 793 | #else | |
| 794 | _VSTD::string generic_u8string() const { return __pn_; } | |
| 795 | #endif | |
| 796 | ||
| 797 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 798 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 799 | class _Allocator = allocator<_ECharT> > | |
| 800 | basic_string<_ECharT, _Traits, _Allocator> | |
| 801 | generic_string(const _Allocator& __a = _Allocator()) const { | |
| 802 | return string<_ECharT, _Traits, _Allocator>(__a); | |
| 803 | } | |
| 804 | ||
| 805 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 806 | _VSTD::wstring generic_wstring() const { return string<wchar_t>(); } | |
| 807 | #endif | |
| 808 | _VSTD::u16string generic_u16string() const { return string<char16_t>(); } | |
| 809 | _VSTD::u32string generic_u32string() const { return string<char32_t>(); } | |
| 810 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 811 | #endif /* !_LIBCPP_WIN32API */ | |
| 812 | ||
| 813 | private: | |
| 814 | int __compare(__string_view) const; | |
| 815 | __string_view __root_name() const; | |
| 816 | __string_view __root_directory() const; | |
| 817 | __string_view __root_path_raw() const; | |
| 818 | __string_view __relative_path() const; | |
| 819 | __string_view __parent_path() const; | |
| 820 | __string_view __filename() const; | |
| 821 | __string_view __stem() const; | |
| 822 | __string_view __extension() const; | |
| 823 | ||
| 824 | public: | |
| 825 | // compare | |
| 826 | _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept { | |
| 827 | return __compare(__p.__pn_); | |
| 828 | } | |
| 829 | _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { | |
| 830 | return __compare(__s); | |
| 831 | } | |
| 832 | _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { | |
| 833 | return __compare(__s); | |
| 834 | } | |
| 835 | _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { | |
| 836 | return __compare(__s); | |
| 837 | } | |
| 838 | ||
| 839 | // decomposition | |
| 840 | _LIBCPP_INLINE_VISIBILITY path root_name() const { | |
| 841 | return string_type(__root_name()); | |
| 842 | } | |
| 843 | _LIBCPP_INLINE_VISIBILITY path root_directory() const { | |
| 844 | return string_type(__root_directory()); | |
| 845 | } | |
| 846 | _LIBCPP_INLINE_VISIBILITY path root_path() const { | |
| 847 | #if defined(_LIBCPP_WIN32API) | |
| 848 | return string_type(__root_path_raw()); | |
| 849 | #else | |
| 850 | return root_name().append(string_type(__root_directory())); | |
| 851 | #endif | |
| 852 | } | |
| 853 | _LIBCPP_INLINE_VISIBILITY path relative_path() const { | |
| 854 | return string_type(__relative_path()); | |
| 855 | } | |
| 856 | _LIBCPP_INLINE_VISIBILITY path parent_path() const { | |
| 857 | return string_type(__parent_path()); | |
| 858 | } | |
| 859 | _LIBCPP_INLINE_VISIBILITY path filename() const { | |
| 860 | return string_type(__filename()); | |
| 861 | } | |
| 862 | _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); } | |
| 863 | _LIBCPP_INLINE_VISIBILITY path extension() const { | |
| 864 | return string_type(__extension()); | |
| 865 | } | |
| 866 | ||
| 867 | // query | |
| 868 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool | |
| 869 | empty() const noexcept { | |
| 870 | return __pn_.empty(); | |
| 871 | } | |
| 872 | ||
| 873 | _LIBCPP_INLINE_VISIBILITY bool has_root_name() const { | |
| 874 | return !__root_name().empty(); | |
| 875 | } | |
| 876 | _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { | |
| 877 | return !__root_directory().empty(); | |
| 878 | } | |
| 879 | _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { | |
| 880 | return !__root_path_raw().empty(); | |
| 881 | } | |
| 882 | _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { | |
| 883 | return !__relative_path().empty(); | |
| 884 | } | |
| 885 | _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { | |
| 886 | return !__parent_path().empty(); | |
| 887 | } | |
| 888 | _LIBCPP_INLINE_VISIBILITY bool has_filename() const { | |
| 889 | return !__filename().empty(); | |
| 890 | } | |
| 891 | _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); } | |
| 892 | _LIBCPP_INLINE_VISIBILITY bool has_extension() const { | |
| 893 | return !__extension().empty(); | |
| 894 | } | |
| 895 | ||
| 896 | _LIBCPP_INLINE_VISIBILITY bool is_absolute() const { | |
| 897 | #if defined(_LIBCPP_WIN32API) | |
| 898 | __string_view __root_name_str = __root_name(); | |
| 899 | __string_view __root_dir = __root_directory(); | |
| 900 | if (__root_name_str.size() == 2 && __root_name_str[1] == ':') { | |
| 901 | // A drive letter with no root directory is relative, e.g. x:example. | |
| 902 | return !__root_dir.empty(); | |
| 903 | } | |
| 904 | // If no root name, it's relative, e.g. \example is relative to the current drive | |
| 905 | if (__root_name_str.empty()) | |
| 906 | return false; | |
| 907 | if (__root_name_str.size() < 3) | |
| 908 | return false; | |
| 909 | // A server root name, like \\server, is always absolute | |
| 910 | if (__root_name_str[0] != '/' && __root_name_str[0] != '\\') | |
| 911 | return false; | |
| 912 | if (__root_name_str[1] != '/' && __root_name_str[1] != '\\') | |
| 913 | return false; | |
| 914 | // Seems to be a server root name | |
| 915 | return true; | |
| 916 | #else | |
| 917 | return has_root_directory(); | |
| 918 | #endif | |
| 919 | } | |
| 920 | _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); } | |
| 921 | ||
| 922 | // relative paths | |
| 923 | path lexically_normal() const; | |
| 924 | path lexically_relative(const path& __base) const; | |
| 925 | ||
| 926 | _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const { | |
| 927 | path __result = this->lexically_relative(__base); | |
| 928 | if (__result.native().empty()) | |
| 929 | return *this; | |
| 930 | return __result; | |
| 931 | } | |
| 932 | ||
| 933 | // iterators | |
| 934 | class _LIBCPP_TYPE_VIS iterator; | |
| 935 | typedef iterator const_iterator; | |
| 936 | ||
| 937 | iterator begin() const; | |
| 938 | iterator end() const; | |
| 939 | ||
| 940 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 941 | template <class _CharT, class _Traits> | |
| 942 | _LIBCPP_INLINE_VISIBILITY friend | |
| 943 | typename enable_if<is_same<_CharT, value_type>::value && | |
| 944 | is_same<_Traits, char_traits<value_type> >::value, | |
| 945 | basic_ostream<_CharT, _Traits>&>::type | |
| 946 | operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { | |
| 947 | __os << _VSTD::__quoted(__p.native()); | |
| 948 | return __os; | |
| 949 | } | |
| 950 | ||
| 951 | template <class _CharT, class _Traits> | |
| 952 | _LIBCPP_INLINE_VISIBILITY friend | |
| 953 | typename enable_if<!is_same<_CharT, value_type>::value || | |
| 954 | !is_same<_Traits, char_traits<value_type> >::value, | |
| 955 | basic_ostream<_CharT, _Traits>&>::type | |
| 956 | operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { | |
| 957 | __os << _VSTD::__quoted(__p.string<_CharT, _Traits>()); | |
| 958 | return __os; | |
| 959 | } | |
| 960 | ||
| 961 | template <class _CharT, class _Traits> | |
| 962 | _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>& | |
| 963 | operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) { | |
| 964 | basic_string<_CharT, _Traits> __tmp; | |
| 965 | __is >> __quoted(__tmp); | |
| 966 | __p = __tmp; | |
| 967 | return __is; | |
| 968 | } | |
| 969 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 970 | ||
| 971 | friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept { | |
| 972 | return __lhs.__compare(__rhs.__pn_) == 0; | |
| 973 | } | |
| 974 | friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept { | |
| 975 | return __lhs.__compare(__rhs.__pn_) != 0; | |
| 976 | } | |
| 977 | friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept { | |
| 978 | return __lhs.__compare(__rhs.__pn_) < 0; | |
| 979 | } | |
| 980 | friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept { | |
| 981 | return __lhs.__compare(__rhs.__pn_) <= 0; | |
| 982 | } | |
| 983 | friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept { | |
| 984 | return __lhs.__compare(__rhs.__pn_) > 0; | |
| 985 | } | |
| 986 | friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept { | |
| 987 | return __lhs.__compare(__rhs.__pn_) >= 0; | |
| 988 | } | |
| 989 | ||
| 990 | friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, | |
| 991 | const path& __rhs) { | |
| 992 | path __result(__lhs); | |
| 993 | __result /= __rhs; | |
| 994 | return __result; | |
| 995 | } | |
| 996 | private: | |
| 997 | inline _LIBCPP_INLINE_VISIBILITY path& | |
| 998 | __assign_view(__string_view const& __s) noexcept { | |
| 999 | __pn_ = string_type(__s); | |
| 1000 | return *this; | |
| 1001 | } | |
| 1002 | string_type __pn_; | |
| 1003 | }; | |
| 1004 | ||
| 1005 | inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept { | |
| 1006 | __lhs.swap(__rhs); | |
| 1007 | } | |
| 1008 | ||
| 1009 | _LIBCPP_FUNC_VIS | |
| 1010 | size_t hash_value(const path& __p) noexcept; | |
| 1011 | ||
| 1012 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 1013 | ||
| 1014 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 1015 | ||
| 1016 | #endif // _LIBCPP_CXX03_LANG | |
| 1017 | ||
| 1018 | #endif // _LIBCPP___FILESYSTEM_PATH_H |
lib/libcxx/include/__filesystem/path_iterator.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 | ||
| 10 | #ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H | |
| 11 | #define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__debug> | |
| 16 | #include <__filesystem/path.h> | |
| 17 | #include <__iterator/iterator_traits.h> | |
| 18 | #include <cstddef> | |
| 19 | #include <string> | |
| 20 | #include <string_view> | |
| 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 25 | ||
| 26 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 27 | ||
| 28 | class _LIBCPP_TYPE_VIS path::iterator { | |
| 29 | public: | |
| 30 | enum _ParserState : unsigned char { | |
| 31 | _Singular, | |
| 32 | _BeforeBegin, | |
| 33 | _InRootName, | |
| 34 | _InRootDir, | |
| 35 | _InFilenames, | |
| 36 | _InTrailingSep, | |
| 37 | _AtEnd | |
| 38 | }; | |
| 39 | ||
| 40 | public: | |
| 41 | typedef input_iterator_tag iterator_category; | |
| 42 | typedef bidirectional_iterator_tag iterator_concept; | |
| 43 | ||
| 44 | typedef path value_type; | |
| 45 | typedef ptrdiff_t difference_type; | |
| 46 | typedef const path* pointer; | |
| 47 | typedef path reference; | |
| 48 | ||
| 49 | public: | |
| 50 | _LIBCPP_INLINE_VISIBILITY | |
| 51 | iterator() | |
| 52 | : __stashed_elem_(), __path_ptr_(nullptr), __entry_(), | |
| 53 | __state_(_Singular) {} | |
| 54 | ||
| 55 | iterator(const iterator&) = default; | |
| 56 | ~iterator() = default; | |
| 57 | ||
| 58 | iterator& operator=(const iterator&) = default; | |
| 59 | ||
| 60 | _LIBCPP_INLINE_VISIBILITY | |
| 61 | reference operator*() const { return __stashed_elem_; } | |
| 62 | ||
| 63 | _LIBCPP_INLINE_VISIBILITY | |
| 64 | pointer operator->() const { return &__stashed_elem_; } | |
| 65 | ||
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | iterator& operator++() { | |
| 68 | _LIBCPP_ASSERT(__state_ != _Singular, | |
| 69 | "attempting to increment a singular iterator"); | |
| 70 | _LIBCPP_ASSERT(__state_ != _AtEnd, | |
| 71 | "attempting to increment the end iterator"); | |
| 72 | return __increment(); | |
| 73 | } | |
| 74 | ||
| 75 | _LIBCPP_INLINE_VISIBILITY | |
| 76 | iterator operator++(int) { | |
| 77 | iterator __it(*this); | |
| 78 | this->operator++(); | |
| 79 | return __it; | |
| 80 | } | |
| 81 | ||
| 82 | _LIBCPP_INLINE_VISIBILITY | |
| 83 | iterator& operator--() { | |
| 84 | _LIBCPP_ASSERT(__state_ != _Singular, | |
| 85 | "attempting to decrement a singular iterator"); | |
| 86 | _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(), | |
| 87 | "attempting to decrement the begin iterator"); | |
| 88 | return __decrement(); | |
| 89 | } | |
| 90 | ||
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | iterator operator--(int) { | |
| 93 | iterator __it(*this); | |
| 94 | this->operator--(); | |
| 95 | return __it; | |
| 96 | } | |
| 97 | ||
| 98 | private: | |
| 99 | friend class path; | |
| 100 | ||
| 101 | inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&, | |
| 102 | const iterator&); | |
| 103 | ||
| 104 | iterator& __increment(); | |
| 105 | iterator& __decrement(); | |
| 106 | ||
| 107 | path __stashed_elem_; | |
| 108 | const path* __path_ptr_; | |
| 109 | path::__string_view __entry_; | |
| 110 | _ParserState __state_; | |
| 111 | }; | |
| 112 | ||
| 113 | inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs, | |
| 114 | const path::iterator& __rhs) { | |
| 115 | return __lhs.__path_ptr_ == __rhs.__path_ptr_ && | |
| 116 | __lhs.__entry_.data() == __rhs.__entry_.data(); | |
| 117 | } | |
| 118 | ||
| 119 | inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs, | |
| 120 | const path::iterator& __rhs) { | |
| 121 | return !(__lhs == __rhs); | |
| 122 | } | |
| 123 | ||
| 124 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 125 | ||
| 126 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 127 | ||
| 128 | #endif // _LIBCPP_CXX03_LANG | |
| 129 | ||
| 130 | #endif // _LIBCPP___FILESYSTEM_PATH_ITERATOR_H |
lib/libcxx/include/__filesystem/perm_options.h created+73| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FILESYSTEM_PERM_OPTIONS_H | |
| 11 | #define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #ifndef _LIBCPP_CXX03_LANG | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 19 | ||
| 20 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 21 | ||
| 22 | enum class _LIBCPP_ENUM_VIS perm_options : unsigned char { | |
| 23 | replace = 1, | |
| 24 | add = 2, | |
| 25 | remove = 4, | |
| 26 | nofollow = 8 | |
| 27 | }; | |
| 28 | ||
| 29 | _LIBCPP_INLINE_VISIBILITY | |
| 30 | inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) { | |
| 31 | return static_cast<perm_options>(static_cast<unsigned>(_LHS) & | |
| 32 | static_cast<unsigned>(_RHS)); | |
| 33 | } | |
| 34 | ||
| 35 | _LIBCPP_INLINE_VISIBILITY | |
| 36 | inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) { | |
| 37 | return static_cast<perm_options>(static_cast<unsigned>(_LHS) | | |
| 38 | static_cast<unsigned>(_RHS)); | |
| 39 | } | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) { | |
| 43 | return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^ | |
| 44 | static_cast<unsigned>(_RHS)); | |
| 45 | } | |
| 46 | ||
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | inline constexpr perm_options operator~(perm_options _LHS) { | |
| 49 | return static_cast<perm_options>(~static_cast<unsigned>(_LHS)); | |
| 50 | } | |
| 51 | ||
| 52 | _LIBCPP_INLINE_VISIBILITY | |
| 53 | inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) { | |
| 54 | return _LHS = _LHS & _RHS; | |
| 55 | } | |
| 56 | ||
| 57 | _LIBCPP_INLINE_VISIBILITY | |
| 58 | inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) { | |
| 59 | return _LHS = _LHS | _RHS; | |
| 60 | } | |
| 61 | ||
| 62 | _LIBCPP_INLINE_VISIBILITY | |
| 63 | inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) { | |
| 64 | return _LHS = _LHS ^ _RHS; | |
| 65 | } | |
| 66 | ||
| 67 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 68 | ||
| 69 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 70 | ||
| 71 | #endif // _LIBCPP_CXX03_LANG | |
| 72 | ||
| 73 | #endif // _LIBCPP___FILESYSTEM_PERM_OPTIONS_H |
lib/libcxx/include/__filesystem/perms.h created+91| ... | ... | @@ -0,0 +1,91 @@ |
| 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___FILESYSTEM_PERMS_H | |
| 11 | #define _LIBCPP___FILESYSTEM_PERMS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #ifndef _LIBCPP_CXX03_LANG | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 19 | ||
| 20 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 21 | ||
| 22 | // On Windows, these permission bits map to one single readonly flag per | |
| 23 | // file, and the executable bit is always returned as set. When setting | |
| 24 | // permissions, as long as the write bit is set for either owner, group or | |
| 25 | // others, the readonly flag is cleared. | |
| 26 | enum class _LIBCPP_ENUM_VIS perms : unsigned { | |
| 27 | none = 0, | |
| 28 | ||
| 29 | owner_read = 0400, | |
| 30 | owner_write = 0200, | |
| 31 | owner_exec = 0100, | |
| 32 | owner_all = 0700, | |
| 33 | ||
| 34 | group_read = 040, | |
| 35 | group_write = 020, | |
| 36 | group_exec = 010, | |
| 37 | group_all = 070, | |
| 38 | ||
| 39 | others_read = 04, | |
| 40 | others_write = 02, | |
| 41 | others_exec = 01, | |
| 42 | others_all = 07, | |
| 43 | ||
| 44 | all = 0777, | |
| 45 | ||
| 46 | set_uid = 04000, | |
| 47 | set_gid = 02000, | |
| 48 | sticky_bit = 01000, | |
| 49 | mask = 07777, | |
| 50 | unknown = 0xFFFF, | |
| 51 | }; | |
| 52 | ||
| 53 | _LIBCPP_INLINE_VISIBILITY | |
| 54 | inline constexpr perms operator&(perms _LHS, perms _RHS) { | |
| 55 | return static_cast<perms>(static_cast<unsigned>(_LHS) & | |
| 56 | static_cast<unsigned>(_RHS)); | |
| 57 | } | |
| 58 | ||
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | inline constexpr perms operator|(perms _LHS, perms _RHS) { | |
| 61 | return static_cast<perms>(static_cast<unsigned>(_LHS) | | |
| 62 | static_cast<unsigned>(_RHS)); | |
| 63 | } | |
| 64 | ||
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | inline constexpr perms operator^(perms _LHS, perms _RHS) { | |
| 67 | return static_cast<perms>(static_cast<unsigned>(_LHS) ^ | |
| 68 | static_cast<unsigned>(_RHS)); | |
| 69 | } | |
| 70 | ||
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | inline constexpr perms operator~(perms _LHS) { | |
| 73 | return static_cast<perms>(~static_cast<unsigned>(_LHS)); | |
| 74 | } | |
| 75 | ||
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; } | |
| 78 | ||
| 79 | _LIBCPP_INLINE_VISIBILITY | |
| 80 | inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; } | |
| 81 | ||
| 82 | _LIBCPP_INLINE_VISIBILITY | |
| 83 | inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } | |
| 84 | ||
| 85 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 86 | ||
| 87 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 88 | ||
| 89 | #endif // _LIBCPP_CXX03_LANG | |
| 90 | ||
| 91 | #endif // _LIBCPP___FILESYSTEM_PERMS_H |
lib/libcxx/include/__filesystem/recursive_directory_iterator.h created+181| ... | ... | @@ -0,0 +1,181 @@ |
| 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___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H | |
| 11 | #define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__filesystem/directory_entry.h> | |
| 16 | #include <__filesystem/directory_options.h> | |
| 17 | #include <__filesystem/path.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__memory/shared_ptr.h> | |
| 20 | #include <__ranges/enable_borrowed_range.h> | |
| 21 | #include <__ranges/enable_view.h> | |
| 22 | #include <cstddef> | |
| 23 | #include <system_error> | |
| 24 | ||
| 25 | #ifndef _LIBCPP_CXX03_LANG | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 28 | ||
| 29 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 30 | ||
| 31 | class recursive_directory_iterator { | |
| 32 | public: | |
| 33 | using value_type = directory_entry; | |
| 34 | using difference_type = ptrdiff_t; | |
| 35 | using pointer = directory_entry const*; | |
| 36 | using reference = directory_entry const&; | |
| 37 | using iterator_category = input_iterator_tag; | |
| 38 | ||
| 39 | public: | |
| 40 | // constructors and destructor | |
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | recursive_directory_iterator() noexcept : __rec_(false) {} | |
| 43 | ||
| 44 | _LIBCPP_INLINE_VISIBILITY | |
| 45 | explicit recursive_directory_iterator( | |
| 46 | const path& __p, directory_options __xoptions = directory_options::none) | |
| 47 | : recursive_directory_iterator(__p, __xoptions, nullptr) {} | |
| 48 | ||
| 49 | _LIBCPP_INLINE_VISIBILITY | |
| 50 | recursive_directory_iterator(const path& __p, directory_options __xoptions, | |
| 51 | error_code& __ec) | |
| 52 | : recursive_directory_iterator(__p, __xoptions, &__ec) {} | |
| 53 | ||
| 54 | _LIBCPP_INLINE_VISIBILITY | |
| 55 | recursive_directory_iterator(const path& __p, error_code& __ec) | |
| 56 | : recursive_directory_iterator(__p, directory_options::none, &__ec) {} | |
| 57 | ||
| 58 | recursive_directory_iterator(const recursive_directory_iterator&) = default; | |
| 59 | recursive_directory_iterator(recursive_directory_iterator&&) = default; | |
| 60 | ||
| 61 | recursive_directory_iterator& | |
| 62 | operator=(const recursive_directory_iterator&) = default; | |
| 63 | ||
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | recursive_directory_iterator& | |
| 66 | operator=(recursive_directory_iterator&& __o) noexcept { | |
| 67 | // non-default implementation provided to support self-move assign. | |
| 68 | if (this != &__o) { | |
| 69 | __imp_ = _VSTD::move(__o.__imp_); | |
| 70 | __rec_ = __o.__rec_; | |
| 71 | } | |
| 72 | return *this; | |
| 73 | } | |
| 74 | ||
| 75 | ~recursive_directory_iterator() = default; | |
| 76 | ||
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | const directory_entry& operator*() const { return __dereference(); } | |
| 79 | ||
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | const directory_entry* operator->() const { return &__dereference(); } | |
| 82 | ||
| 83 | recursive_directory_iterator& operator++() { return __increment(); } | |
| 84 | ||
| 85 | _LIBCPP_INLINE_VISIBILITY | |
| 86 | __dir_element_proxy operator++(int) { | |
| 87 | __dir_element_proxy __p(**this); | |
| 88 | __increment(); | |
| 89 | return __p; | |
| 90 | } | |
| 91 | ||
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | recursive_directory_iterator& increment(error_code& __ec) { | |
| 94 | return __increment(&__ec); | |
| 95 | } | |
| 96 | ||
| 97 | _LIBCPP_FUNC_VIS directory_options options() const; | |
| 98 | _LIBCPP_FUNC_VIS int depth() const; | |
| 99 | ||
| 100 | _LIBCPP_INLINE_VISIBILITY | |
| 101 | void pop() { __pop(); } | |
| 102 | ||
| 103 | _LIBCPP_INLINE_VISIBILITY | |
| 104 | void pop(error_code& __ec) { __pop(&__ec); } | |
| 105 | ||
| 106 | _LIBCPP_INLINE_VISIBILITY | |
| 107 | bool recursion_pending() const { return __rec_; } | |
| 108 | ||
| 109 | _LIBCPP_INLINE_VISIBILITY | |
| 110 | void disable_recursion_pending() { __rec_ = false; } | |
| 111 | ||
| 112 | private: | |
| 113 | _LIBCPP_FUNC_VIS | |
| 114 | recursive_directory_iterator(const path& __p, directory_options __opt, | |
| 115 | error_code* __ec); | |
| 116 | ||
| 117 | _LIBCPP_FUNC_VIS | |
| 118 | const directory_entry& __dereference() const; | |
| 119 | ||
| 120 | _LIBCPP_FUNC_VIS | |
| 121 | bool __try_recursion(error_code* __ec); | |
| 122 | ||
| 123 | _LIBCPP_FUNC_VIS | |
| 124 | void __advance(error_code* __ec = nullptr); | |
| 125 | ||
| 126 | _LIBCPP_FUNC_VIS | |
| 127 | recursive_directory_iterator& __increment(error_code* __ec = nullptr); | |
| 128 | ||
| 129 | _LIBCPP_FUNC_VIS | |
| 130 | void __pop(error_code* __ec = nullptr); | |
| 131 | ||
| 132 | inline _LIBCPP_INLINE_VISIBILITY friend bool | |
| 133 | operator==(const recursive_directory_iterator&, | |
| 134 | const recursive_directory_iterator&) noexcept; | |
| 135 | ||
| 136 | struct _LIBCPP_HIDDEN __shared_imp; | |
| 137 | shared_ptr<__shared_imp> __imp_; | |
| 138 | bool __rec_; | |
| 139 | }; // class recursive_directory_iterator | |
| 140 | ||
| 141 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 142 | operator==(const recursive_directory_iterator& __lhs, | |
| 143 | const recursive_directory_iterator& __rhs) noexcept { | |
| 144 | return __lhs.__imp_ == __rhs.__imp_; | |
| 145 | } | |
| 146 | ||
| 147 | _LIBCPP_INLINE_VISIBILITY | |
| 148 | inline bool operator!=(const recursive_directory_iterator& __lhs, | |
| 149 | const recursive_directory_iterator& __rhs) noexcept { | |
| 150 | return !(__lhs == __rhs); | |
| 151 | } | |
| 152 | // enable recursive_directory_iterator range-based for statements | |
| 153 | inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator | |
| 154 | begin(recursive_directory_iterator __iter) noexcept { | |
| 155 | return __iter; | |
| 156 | } | |
| 157 | ||
| 158 | inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator | |
| 159 | end(recursive_directory_iterator) noexcept { | |
| 160 | return recursive_directory_iterator(); | |
| 161 | } | |
| 162 | ||
| 163 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 164 | ||
| 165 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 166 | ||
| 167 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 168 | ||
| 169 | template <> | |
| 170 | _LIBCPP_AVAILABILITY_FILESYSTEM | |
| 171 | inline constexpr bool _VSTD::ranges::enable_borrowed_range<_VSTD_FS::recursive_directory_iterator> = true; | |
| 172 | ||
| 173 | template <> | |
| 174 | _LIBCPP_AVAILABILITY_FILESYSTEM | |
| 175 | inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true; | |
| 176 | ||
| 177 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 178 | ||
| 179 | #endif // _LIBCPP_CXX03_LANG | |
| 180 | ||
| 181 | #endif // _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H |
lib/libcxx/include/__filesystem/space_info.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___FILESYSTEM_SPACE_INFO_H | |
| 11 | #define _LIBCPP___FILESYSTEM_SPACE_INFO_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <cstdint> | |
| 16 | ||
| 17 | #ifndef _LIBCPP_CXX03_LANG | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 20 | ||
| 21 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 22 | ||
| 23 | struct _LIBCPP_TYPE_VIS space_info { | |
| 24 | uintmax_t capacity; | |
| 25 | uintmax_t free; | |
| 26 | uintmax_t available; | |
| 27 | }; | |
| 28 | ||
| 29 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 32 | ||
| 33 | #endif // _LIBCPP_CXX03_LANG | |
| 34 | ||
| 35 | #endif // _LIBCPP___FILESYSTEM_SPACE_INFO_H |
lib/libcxx/include/__filesystem/u8path.h created+96| ... | ... | @@ -0,0 +1,96 @@ |
| 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___FILESYSTEM_U8PATH_H | |
| 11 | #define _LIBCPP___FILESYSTEM_U8PATH_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__filesystem/path.h> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #ifndef _LIBCPP_CXX03_LANG | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 21 | ||
| 22 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 23 | ||
| 24 | template <class _InputIt> | |
| 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 26 | typename enable_if<__is_pathable<_InputIt>::value, path>::type | |
| 27 | u8path(_InputIt __f, _InputIt __l) { | |
| 28 | static_assert( | |
| 29 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 30 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || | |
| 31 | #endif | |
| 32 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, | |
| 33 | "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" | |
| 34 | " or 'char8_t'"); | |
| 35 | #if defined(_LIBCPP_WIN32API) | |
| 36 | string __tmp(__f, __l); | |
| 37 | using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | |
| 38 | _VSTD::wstring __w; | |
| 39 | __w.reserve(__tmp.size()); | |
| 40 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); | |
| 41 | return path(__w); | |
| 42 | #else | |
| 43 | return path(__f, __l); | |
| 44 | #endif /* !_LIBCPP_WIN32API */ | |
| 45 | } | |
| 46 | ||
| 47 | #if defined(_LIBCPP_WIN32API) | |
| 48 | template <class _InputIt> | |
| 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 50 | typename enable_if<__is_pathable<_InputIt>::value, path>::type | |
| 51 | u8path(_InputIt __f, _NullSentinel) { | |
| 52 | static_assert( | |
| 53 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 54 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || | |
| 55 | #endif | |
| 56 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, | |
| 57 | "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" | |
| 58 | " or 'char8_t'"); | |
| 59 | string __tmp; | |
| 60 | const char __sentinel = char{}; | |
| 61 | for (; *__f != __sentinel; ++__f) | |
| 62 | __tmp.push_back(*__f); | |
| 63 | using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | |
| 64 | _VSTD::wstring __w; | |
| 65 | __w.reserve(__tmp.size()); | |
| 66 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); | |
| 67 | return path(__w); | |
| 68 | } | |
| 69 | #endif /* _LIBCPP_WIN32API */ | |
| 70 | ||
| 71 | template <class _Source> | |
| 72 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 73 | typename enable_if<__is_pathable<_Source>::value, path>::type | |
| 74 | u8path(const _Source& __s) { | |
| 75 | static_assert( | |
| 76 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 77 | is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value || | |
| 78 | #endif | |
| 79 | is_same<typename __is_pathable<_Source>::__char_type, char>::value, | |
| 80 | "u8path(Source const&) requires Source have a character type of type " | |
| 81 | "'char' or 'char8_t'"); | |
| 82 | #if defined(_LIBCPP_WIN32API) | |
| 83 | using _Traits = __is_pathable<_Source>; | |
| 84 | return u8path(_VSTD::__unwrap_iter(_Traits::__range_begin(__s)), _VSTD::__unwrap_iter(_Traits::__range_end(__s))); | |
| 85 | #else | |
| 86 | return path(__s); | |
| 87 | #endif | |
| 88 | } | |
| 89 | ||
| 90 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 91 | ||
| 92 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 93 | ||
| 94 | #endif // _LIBCPP_CXX03_LANG | |
| 95 | ||
| 96 | #endif // _LIBCPP___FILESYSTEM_U8PATH_H |
lib/libcxx/include/__format/format_arg.h created+292| ... | ... | @@ -0,0 +1,292 @@ |
| 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_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_ARG_H | |
| 12 | ||
| 13 | #include <__concepts/arithmetic.h> | |
| 14 | #include <__config> | |
| 15 | #include <__format/format_error.h> | |
| 16 | #include <__format/format_fwd.h> | |
| 17 | #include <__format/format_parse_context.h> | |
| 18 | #include <__functional_base> | |
| 19 | #include <__memory/addressof.h> | |
| 20 | #include <__variant/monostate.h> | |
| 21 | #include <string> | |
| 22 | #include <string_view> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | #pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 17 | |
| 34 | ||
| 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 | namespace __format { | |
| 42 | /// The type stored in @ref basic_format_arg. | |
| 43 | /// | |
| 44 | /// @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. | |
| 46 | enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { | |
| 47 | __none, | |
| 48 | __boolean, | |
| 49 | __char_type, | |
| 50 | __int, | |
| 51 | __long_long, | |
| 52 | __i128, | |
| 53 | __unsigned, | |
| 54 | __unsigned_long_long, | |
| 55 | __u128, | |
| 56 | __float, | |
| 57 | __double, | |
| 58 | __long_double, | |
| 59 | __const_char_type_ptr, | |
| 60 | __string_view, | |
| 61 | __ptr, | |
| 62 | __handle | |
| 63 | }; | |
| 64 | } // namespace __format | |
| 65 | ||
| 66 | template <class _Visitor, class _Context> | |
| 67 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) | |
| 68 | visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { | |
| 69 | switch (__arg.__type_) { | |
| 70 | case __format::__arg_t::__none: | |
| 71 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{}); | |
| 72 | case __format::__arg_t::__boolean: | |
| 73 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean); | |
| 74 | case __format::__arg_t::__char_type: | |
| 75 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type); | |
| 76 | case __format::__arg_t::__int: | |
| 77 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int); | |
| 78 | case __format::__arg_t::__long_long: | |
| 79 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long); | |
| 80 | case __format::__arg_t::__i128: | |
| 81 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 82 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128); | |
| 83 | #else | |
| 84 | _LIBCPP_UNREACHABLE(); | |
| 85 | #endif | |
| 86 | case __format::__arg_t::__unsigned: | |
| 87 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned); | |
| 88 | case __format::__arg_t::__unsigned_long_long: | |
| 89 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), | |
| 90 | __arg.__unsigned_long_long); | |
| 91 | case __format::__arg_t::__u128: | |
| 92 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 93 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128); | |
| 94 | #else | |
| 95 | _LIBCPP_UNREACHABLE(); | |
| 96 | #endif | |
| 97 | case __format::__arg_t::__float: | |
| 98 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float); | |
| 99 | case __format::__arg_t::__double: | |
| 100 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double); | |
| 101 | case __format::__arg_t::__long_double: | |
| 102 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double); | |
| 103 | case __format::__arg_t::__const_char_type_ptr: | |
| 104 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), | |
| 105 | __arg.__const_char_type_ptr); | |
| 106 | case __format::__arg_t::__string_view: | |
| 107 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view); | |
| 108 | case __format::__arg_t::__ptr: | |
| 109 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr); | |
| 110 | case __format::__arg_t::__handle: | |
| 111 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle); | |
| 112 | } | |
| 113 | _LIBCPP_UNREACHABLE(); | |
| 114 | } | |
| 115 | ||
| 116 | template <class _Context> | |
| 117 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg { | |
| 118 | public: | |
| 119 | class _LIBCPP_TEMPLATE_VIS handle; | |
| 120 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept | |
| 122 | : __type_{__format::__arg_t::__none} {} | |
| 123 | ||
| 124 | _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { | |
| 125 | return __type_ != __format::__arg_t::__none; | |
| 126 | } | |
| 127 | ||
| 128 | private: | |
| 129 | using char_type = typename _Context::char_type; | |
| 130 | ||
| 131 | // TODO FMT Implement constrain [format.arg]/4 | |
| 132 | // Constraints: The template specialization | |
| 133 | // typename Context::template formatter_type<T> | |
| 134 | // meets the Formatter requirements ([formatter.requirements]). The extent | |
| 135 | // to which an implementation determines that the specialization meets the | |
| 136 | // Formatter requirements is unspecified, except that as a minimum the | |
| 137 | // expression | |
| 138 | // typename Context::template formatter_type<T>() | |
| 139 | // .format(declval<const T&>(), declval<Context&>()) | |
| 140 | // shall be well-formed when treated as an unevaluated operand. | |
| 141 | ||
| 142 | template <class _Ctx, class... _Args> | |
| 143 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...> | |
| 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_; | |
| 170 | ||
| 171 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(bool __v) noexcept | |
| 172 | : __boolean(__v), __type_(__format::__arg_t::__boolean) {} | |
| 173 | ||
| 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 | }; | |
| 259 | ||
| 260 | template <class _Context> | |
| 261 | class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle { | |
| 262 | friend class basic_format_arg<_Context>; | |
| 263 | ||
| 264 | public: | |
| 265 | _LIBCPP_HIDE_FROM_ABI | |
| 266 | void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const { | |
| 267 | __format_(__parse_ctx, __ctx, __ptr_); | |
| 268 | } | |
| 269 | ||
| 270 | private: | |
| 271 | const void* __ptr_; | |
| 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 | }; | |
| 283 | ||
| 284 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 285 | ||
| 286 | #endif //_LIBCPP_STD_VER > 17 | |
| 287 | ||
| 288 | _LIBCPP_END_NAMESPACE_STD | |
| 289 | ||
| 290 | _LIBCPP_POP_MACROS | |
| 291 | ||
| 292 | #endif // _LIBCPP___FORMAT_FORMAT_ARG_H |
lib/libcxx/include/__format/format_args.h created+71| ... | ... | @@ -0,0 +1,71 @@ |
| 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_ARGS_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_ARGS_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__format/format_fwd.h> | |
| 16 | #include <cstddef> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | ||
| 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 | ||
| 35 | template <class _Context> | |
| 36 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args { | |
| 37 | public: | |
| 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; | |
| 45 | ||
| 46 | template <class... _Args> | |
| 47 | _LIBCPP_HIDE_FROM_ABI basic_format_args( | |
| 48 | const __format_arg_store<_Context, _Args...>& __store) noexcept | |
| 49 | : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {} | |
| 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI | |
| 52 | basic_format_arg<_Context> get(size_t __id) const noexcept { | |
| 53 | return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{}; | |
| 54 | } | |
| 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; } | |
| 57 | ||
| 58 | private: | |
| 59 | size_t __size_{0}; | |
| 60 | const basic_format_arg<_Context>* __data_{nullptr}; | |
| 61 | }; | |
| 62 | ||
| 63 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 64 | ||
| 65 | #endif //_LIBCPP_STD_VER > 17 | |
| 66 | ||
| 67 | _LIBCPP_END_NAMESPACE_STD | |
| 68 | ||
| 69 | _LIBCPP_POP_MACROS | |
| 70 | ||
| 71 | #endif // _LIBCPP___FORMAT_FORMAT_ARGS_H |
lib/libcxx/include/__format/format_context.h created+165| ... | ... | @@ -0,0 +1,165 @@ |
| 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_CONTEXT_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_CONTEXT_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__format/format_args.h> | |
| 16 | #include <__format/format_fwd.h> | |
| 17 | #include <__iterator/back_insert_iterator.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <concepts> | |
| 20 | ||
| 21 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 22 | #include <locale> | |
| 23 | #include <optional> | |
| 24 | #endif | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | #pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 | |
| 36 | ||
| 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 | ||
| 43 | template <class _OutIt, class _CharT> | |
| 44 | requires output_iterator<_OutIt, const _CharT&> | |
| 45 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context; | |
| 46 | ||
| 47 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 48 | /** | |
| 49 | * Helper to create a basic_format_context. | |
| 50 | * | |
| 51 | * This is needed since the constructor is private. | |
| 52 | */ | |
| 53 | template <class _OutIt, class _CharT> | |
| 54 | _LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT> | |
| 55 | __format_context_create( | |
| 56 | _OutIt __out_it, | |
| 57 | basic_format_args<basic_format_context<_OutIt, _CharT>> __args, | |
| 58 | optional<_VSTD::locale>&& __loc = nullopt) { | |
| 59 | return _VSTD::basic_format_context(_VSTD::move(__out_it), __args, | |
| 60 | _VSTD::move(__loc)); | |
| 61 | } | |
| 62 | #else | |
| 63 | template <class _OutIt, class _CharT> | |
| 64 | _LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT> | |
| 65 | __format_context_create( | |
| 66 | _OutIt __out_it, | |
| 67 | basic_format_args<basic_format_context<_OutIt, _CharT>> __args) { | |
| 68 | return _VSTD::basic_format_context(_VSTD::move(__out_it), __args); | |
| 69 | } | |
| 70 | #endif | |
| 71 | ||
| 72 | // TODO FMT Implement [format.context]/4 | |
| 73 | // [Note 1: For a given type charT, implementations are encouraged to provide a | |
| 74 | // single instantiation of basic_format_context for appending to | |
| 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 | ||
| 79 | using format_context = basic_format_context<back_insert_iterator<string>, char>; | |
| 80 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 81 | using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>; | |
| 82 | #endif | |
| 83 | ||
| 84 | template <class _OutIt, class _CharT> | |
| 85 | requires output_iterator<_OutIt, const _CharT&> | |
| 86 | class | |
| 87 | // clang-format off | |
| 88 | _LIBCPP_TEMPLATE_VIS | |
| 89 | _LIBCPP_AVAILABILITY_FORMAT | |
| 90 | _LIBCPP_PREFERRED_NAME(format_context) | |
| 91 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) | |
| 92 | // clang-format on | |
| 93 | basic_format_context { | |
| 94 | public: | |
| 95 | using iterator = _OutIt; | |
| 96 | using char_type = _CharT; | |
| 97 | template <class _Tp> | |
| 98 | using formatter_type = formatter<_Tp, _CharT>; | |
| 99 | ||
| 100 | basic_format_context(const basic_format_context&) = delete; | |
| 101 | basic_format_context& operator=(const basic_format_context&) = delete; | |
| 102 | ||
| 103 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> | |
| 104 | arg(size_t __id) const { | |
| 105 | return __args_.get(__id); | |
| 106 | } | |
| 107 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 108 | _LIBCPP_HIDE_FROM_ABI _VSTD::locale locale() { | |
| 109 | if (!__loc_) | |
| 110 | __loc_ = _VSTD::locale{}; | |
| 111 | return *__loc_; | |
| 112 | } | |
| 113 | #endif | |
| 114 | _LIBCPP_HIDE_FROM_ABI iterator out() { return __out_it_; } | |
| 115 | _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = __it; } | |
| 116 | ||
| 117 | private: | |
| 118 | iterator __out_it_; | |
| 119 | basic_format_args<basic_format_context> __args_; | |
| 120 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 121 | ||
| 122 | // The Standard doesn't specify how the locale is stored. | |
| 123 | // [format.context]/6 | |
| 124 | // std::locale locale(); | |
| 125 | // Returns: The locale passed to the formatting function if the latter | |
| 126 | // takes one, and std::locale() otherwise. | |
| 127 | // This is done by storing the locale of the constructor in this optional. If | |
| 128 | // locale() is called and the optional has no value the value will be created. | |
| 129 | // This allows the implementation to lazily create the locale. | |
| 130 | // TODO FMT Validate whether lazy creation is the best solution. | |
| 131 | optional<_VSTD::locale> __loc_; | |
| 132 | ||
| 133 | template <class __OutIt, class __CharT> | |
| 134 | friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> | |
| 135 | __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>, | |
| 136 | optional<_VSTD::locale>&&); | |
| 137 | ||
| 138 | // Note: the Standard doesn't specify the required constructors. | |
| 139 | _LIBCPP_HIDE_FROM_ABI | |
| 140 | explicit basic_format_context(_OutIt __out_it, | |
| 141 | basic_format_args<basic_format_context> __args, | |
| 142 | optional<_VSTD::locale>&& __loc) | |
| 143 | : __out_it_(_VSTD::move(__out_it)), __args_(__args), | |
| 144 | __loc_(_VSTD::move(__loc)) {} | |
| 145 | #else | |
| 146 | template <class __OutIt, class __CharT> | |
| 147 | friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT> | |
| 148 | __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>); | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI | |
| 151 | explicit basic_format_context(_OutIt __out_it, | |
| 152 | basic_format_args<basic_format_context> __args) | |
| 153 | : __out_it_(_VSTD::move(__out_it)), __args_(__args) {} | |
| 154 | #endif | |
| 155 | }; | |
| 156 | ||
| 157 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 158 | ||
| 159 | #endif //_LIBCPP_STD_VER > 17 | |
| 160 | ||
| 161 | _LIBCPP_END_NAMESPACE_STD | |
| 162 | ||
| 163 | _LIBCPP_POP_MACROS | |
| 164 | ||
| 165 | #endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H |
lib/libcxx/include/__format/format_error.h-5| ... | ... | @@ -21,9 +21,6 @@ |
| 21 | 21 | #pragma GCC system_header |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 25 | |
| 29 | 26 | #if _LIBCPP_STD_VER > 17 |
| ... | ... | @@ -51,6 +48,4 @@ __throw_format_error(const char* __s) { |
| 51 | 48 | |
| 52 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 50 | |
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | 51 | #endif // _LIBCPP___FORMAT_FORMAT_ERROR_H |
lib/libcxx/include/__format/format_fwd.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___FORMAT_FORMAT_FWD_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_FWD_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__utility/forward.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | ||
| 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 | ||
| 35 | template <class _Context> | |
| 36 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg; | |
| 37 | ||
| 38 | template <class _Context, class... _Args> | |
| 39 | struct _LIBCPP_TEMPLATE_VIS __format_arg_store; | |
| 40 | ||
| 41 | template <class _Ctx, class... _Args> | |
| 42 | _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Ctx, _Args...> | |
| 43 | make_format_args(const _Args&...); | |
| 44 | ||
| 45 | template <class _Tp, class _CharT = char> | |
| 46 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter; | |
| 47 | ||
| 48 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 49 | ||
| 50 | #endif //_LIBCPP_STD_VER > 17 | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | #endif // _LIBCPP___FORMAT_FORMAT_FWD_H |
lib/libcxx/include/__format/format_parse_context.h+4-8| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 17 |
| ... | ... | @@ -29,8 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 26 | // If the compiler has no concepts support, the format header will be disabled. |
| 30 | 27 | // Without concepts support enable_if needs to be used and that too much effort |
| 31 | 28 | // to support compilers with partial C++20 support. |
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && \ | |
| 33 | !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) | |
| 29 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 34 | 30 | |
| 35 | 31 | template <class _CharT> |
| 36 | 32 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context { |
| ... | ... | @@ -100,14 +96,14 @@ private: |
| 100 | 96 | }; |
| 101 | 97 | |
| 102 | 98 | using format_parse_context = basic_format_parse_context<char>; |
| 99 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 103 | 100 | using wformat_parse_context = basic_format_parse_context<wchar_t>; |
| 101 | #endif | |
| 104 | 102 | |
| 105 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) | |
| 103 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 106 | 104 | |
| 107 | 105 | #endif //_LIBCPP_STD_VER > 17 |
| 108 | 106 | |
| 109 | 107 | _LIBCPP_END_NAMESPACE_STD |
| 110 | 108 | |
| 111 | _LIBCPP_POP_MACROS | |
| 112 | ||
| 113 | 109 | #endif // _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H |
lib/libcxx/include/__format/format_string.h created+169| ... | ... | @@ -0,0 +1,169 @@ |
| 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_STRING_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_STRING_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__debug> | |
| 15 | #include <__format/format_error.h> | |
| 16 | #include <cstddef> | |
| 17 | #include <cstdint> | |
| 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 | // 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 | ||
| 33 | namespace __format { | |
| 34 | ||
| 35 | template <class _CharT> | |
| 36 | struct _LIBCPP_TEMPLATE_VIS __parse_number_result { | |
| 37 | const _CharT* __ptr; | |
| 38 | uint32_t __value; | |
| 39 | }; | |
| 40 | ||
| 41 | template <class _CharT> | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> | |
| 43 | __parse_number(const _CharT* __begin, const _CharT* __end); | |
| 44 | ||
| 45 | /** | |
| 46 | * The maximum value of a numeric argument. | |
| 47 | * | |
| 48 | * This is used for: | |
| 49 | * * arg-id | |
| 50 | * * width as value or arg-id. | |
| 51 | * * precision as value or arg-id. | |
| 52 | * | |
| 53 | * The value is compatible with the maximum formatting width and precision | |
| 54 | * using the `%*` syntax on a 32-bit system. | |
| 55 | */ | |
| 56 | inline constexpr uint32_t __number_max = INT32_MAX; | |
| 57 | ||
| 58 | namespace __detail { | |
| 59 | template <class _CharT> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> | |
| 61 | __parse_zero(const _CharT* __begin, const _CharT*, auto& __parse_ctx) { | |
| 62 | __parse_ctx.check_arg_id(0); | |
| 63 | return {++__begin, 0}; // can never be larger than the maximum. | |
| 64 | } | |
| 65 | ||
| 66 | template <class _CharT> | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> | |
| 68 | __parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) { | |
| 69 | size_t __value = __parse_ctx.next_arg_id(); | |
| 70 | _LIBCPP_ASSERT(__value <= __number_max, | |
| 71 | "Compilers don't support this number of arguments"); | |
| 72 | ||
| 73 | return {__begin, uint32_t(__value)}; | |
| 74 | } | |
| 75 | ||
| 76 | template <class _CharT> | |
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> | |
| 78 | __parse_manual(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { | |
| 79 | __parse_number_result<_CharT> __r = __parse_number(__begin, __end); | |
| 80 | __parse_ctx.check_arg_id(__r.__value); | |
| 81 | return __r; | |
| 82 | } | |
| 83 | ||
| 84 | } // namespace __detail | |
| 85 | ||
| 86 | /** | |
| 87 | * Parses a number. | |
| 88 | * | |
| 89 | * The number is used for the 31-bit values @em width and @em precision. This | |
| 90 | * allows a maximum value of 2147483647. | |
| 91 | */ | |
| 92 | template <class _CharT> | |
| 93 | _LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> | |
| 94 | __parse_number(const _CharT* __begin, const _CharT* __end_input) { | |
| 95 | static_assert(__format::__number_max == INT32_MAX, | |
| 96 | "The algorithm is implemented based on this value."); | |
| 97 | /* | |
| 98 | * Limit the input to 9 digits, otherwise we need two checks during every | |
| 99 | * iteration: | |
| 100 | * - Are we at the end of the input? | |
| 101 | * - Does the value exceed width of an uint32_t? (Switching to uint64_t would | |
| 102 | * have the same issue, but with a higher maximum.) | |
| 103 | */ | |
| 104 | const _CharT* __end = __end_input - __begin > 9 ? __begin + 9 : __end_input; | |
| 105 | uint32_t __value = *__begin - _CharT('0'); | |
| 106 | while (++__begin != __end) { | |
| 107 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 108 | return {__begin, __value}; | |
| 109 | ||
| 110 | __value = __value * 10 + *__begin - _CharT('0'); | |
| 111 | } | |
| 112 | ||
| 113 | if (__begin != __end_input && *__begin >= _CharT('0') && | |
| 114 | *__begin <= _CharT('9')) { | |
| 115 | ||
| 116 | /* | |
| 117 | * There are more than 9 digits, do additional validations: | |
| 118 | * - Does the 10th digit exceed the maximum allowed value? | |
| 119 | * - Are there more than 10 digits? | |
| 120 | * (More than 10 digits always overflows the maximum.) | |
| 121 | */ | |
| 122 | uint64_t __v = uint64_t(__value) * 10 + *__begin++ - _CharT('0'); | |
| 123 | if (__v > __number_max || | |
| 124 | (__begin != __end_input && *__begin >= _CharT('0') && | |
| 125 | *__begin <= _CharT('9'))) | |
| 126 | __throw_format_error("The numeric value of the format-spec is too large"); | |
| 127 | ||
| 128 | __value = __v; | |
| 129 | } | |
| 130 | ||
| 131 | return {__begin, __value}; | |
| 132 | } | |
| 133 | ||
| 134 | /** | |
| 135 | * Multiplexer for all parse functions. | |
| 136 | * | |
| 137 | * The parser will return a pointer beyond the last consumed character. This | |
| 138 | * should be the closing '}' of the arg-id. | |
| 139 | */ | |
| 140 | template <class _CharT> | |
| 141 | _LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT> | |
| 142 | __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { | |
| 143 | switch (*__begin) { | |
| 144 | case _CharT('0'): | |
| 145 | return __detail::__parse_zero(__begin, __end, __parse_ctx); | |
| 146 | ||
| 147 | case _CharT(':'): | |
| 148 | // This case is conditionally valid. It's allowed in an arg-id in the | |
| 149 | // replacement-field, but not in the std-format-spec. The caller can | |
| 150 | // provide a better diagnostic, so accept it here unconditionally. | |
| 151 | case _CharT('}'): | |
| 152 | return __detail::__parse_automatic(__begin, __end, __parse_ctx); | |
| 153 | } | |
| 154 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 155 | __throw_format_error( | |
| 156 | "The arg-id of the format-spec starts with an invalid character"); | |
| 157 | ||
| 158 | return __detail::__parse_manual(__begin, __end, __parse_ctx); | |
| 159 | } | |
| 160 | ||
| 161 | } // namespace __format | |
| 162 | ||
| 163 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 164 | ||
| 165 | #endif //_LIBCPP_STD_VER > 17 | |
| 166 | ||
| 167 | _LIBCPP_END_NAMESPACE_STD | |
| 168 | ||
| 169 | #endif // _LIBCPP___FORMAT_FORMAT_STRING_H |
lib/libcxx/include/__format/format_to_n_result.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___FORMAT_FORMAT_TO_N_RESULT_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H | |
| 12 | ||
| 13 | #include <__config> | |
| 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 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | ||
| 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 | ||
| 30 | template <class _OutIt> | |
| 31 | struct _LIBCPP_TEMPLATE_VIS format_to_n_result { | |
| 32 | _OutIt out; | |
| 33 | iter_difference_t<_OutIt> size; | |
| 34 | }; | |
| 35 | ||
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 37 | #endif //_LIBCPP_STD_VER > 17 | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H |
lib/libcxx/include/__format/formatter.h created+290| ... | ... | @@ -0,0 +1,290 @@ |
| 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_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_H | |
| 12 | ||
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/fill_n.h> | |
| 15 | #include <__availability> | |
| 16 | #include <__config> | |
| 17 | #include <__format/format_error.h> | |
| 18 | #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> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | #pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 17 | |
| 34 | ||
| 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. | |
| 42 | /// | |
| 43 | /// [format.formatter.spec]/5 | |
| 44 | /// If F is a disabled specialization of formatter, these values are false: | |
| 45 | /// - is_default_constructible_v<F>, | |
| 46 | /// - is_copy_constructible_v<F>, | |
| 47 | /// - is_move_constructible_v<F>, | |
| 48 | /// - is_copy_assignable<F>, and | |
| 49 | /// - is_move_assignable<F>. | |
| 50 | template <class _Tp, class _CharT> | |
| 51 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter { | |
| 52 | formatter() = delete; | |
| 53 | formatter(const formatter&) = delete; | |
| 54 | formatter& operator=(const formatter&) = delete; | |
| 55 | }; | |
| 56 | ||
| 57 | namespace __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 | ||
| 100 | namespace __formatter { | |
| 101 | ||
| 102 | /** The character types that formatters are specialized for. */ | |
| 103 | template <class _CharT> | |
| 104 | concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>; | |
| 105 | ||
| 106 | struct _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 | */ | |
| 171 | template <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 | */ | |
| 199 | template <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 | */ | |
| 222 | template <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 | */ | |
| 249 | template <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 __formatter | |
| 281 | ||
| 282 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 283 | ||
| 284 | #endif //_LIBCPP_STD_VER > 17 | |
| 285 | ||
| 286 | _LIBCPP_END_NAMESPACE_STD | |
| 287 | ||
| 288 | _LIBCPP_POP_MACROS | |
| 289 | ||
| 290 | #endif // _LIBCPP___FORMAT_FORMATTER_H |
lib/libcxx/include/__format/formatter_bool.h created+147| ... | ... | @@ -0,0 +1,147 @@ |
| 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_BOOL_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_BOOL_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__format/format_error.h> | |
| 16 | #include <__format/format_fwd.h> | |
| 17 | #include <__format/formatter.h> | |
| 18 | #include <__format/formatter_integral.h> | |
| 19 | #include <__format/parser_std_format_spec.h> | |
| 20 | #include <string_view> | |
| 21 | ||
| 22 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 23 | #include <locale> | |
| 24 | #endif | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | #pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 | |
| 33 | ||
| 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 | ||
| 40 | namespace __format_spec { | |
| 41 | ||
| 42 | template <class _CharT> | |
| 43 | class _LIBCPP_TEMPLATE_VIS __parser_bool : public __parser_integral<_CharT> { | |
| 44 | public: | |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) | |
| 46 | -> decltype(__parse_ctx.begin()) { | |
| 47 | auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); | |
| 48 | ||
| 49 | switch (this->__type) { | |
| 50 | case _Flags::_Type::__default: | |
| 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; | |
| 60 | ||
| 61 | case _Flags::_Type::__binary_lower_case: | |
| 62 | case _Flags::_Type::__binary_upper_case: | |
| 63 | case _Flags::_Type::__octal: | |
| 64 | case _Flags::_Type::__decimal: | |
| 65 | case _Flags::_Type::__hexadecimal_lower_case: | |
| 66 | case _Flags::_Type::__hexadecimal_upper_case: | |
| 67 | this->__handle_integer(); | |
| 68 | break; | |
| 69 | ||
| 70 | default: | |
| 71 | __throw_format_error( | |
| 72 | "The format-spec type has a type not supported for a bool argument"); | |
| 73 | } | |
| 74 | ||
| 75 | return __it; | |
| 76 | } | |
| 77 | }; | |
| 78 | ||
| 79 | template <class _CharT> | |
| 80 | struct _LIBCPP_TEMPLATE_VIS __bool_strings; | |
| 81 | ||
| 82 | template <> | |
| 83 | struct _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 | |
| 89 | template <> | |
| 90 | struct _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 | |
| 95 | ||
| 96 | template <class _CharT> | |
| 97 | using __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 | ||
| 105 | template <__formatter::__char_type _CharT> | |
| 106 | struct _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 | }; | |
| 140 | ||
| 141 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 142 | ||
| 143 | #endif //_LIBCPP_STD_VER > 17 | |
| 144 | ||
| 145 | _LIBCPP_END_NAMESPACE_STD | |
| 146 | ||
| 147 | #endif // _LIBCPP___FORMAT_FORMATTER_BOOL_H |
lib/libcxx/include/__format/formatter_char.h created+104| ... | ... | @@ -0,0 +1,104 @@ |
| 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_CHAR_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_CHAR_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__format/format_error.h> | |
| 16 | #include <__format/format_fwd.h> | |
| 17 | #include <__format/formatter.h> | |
| 18 | #include <__format/formatter_integral.h> | |
| 19 | #include <__format/parser_std_format_spec.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 | ||
| 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 | ||
| 35 | namespace __format_spec { | |
| 36 | ||
| 37 | template <class _CharT> | |
| 38 | class _LIBCPP_TEMPLATE_VIS __parser_char : public __parser_integral<_CharT> { | |
| 39 | public: | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) | |
| 41 | -> decltype(__parse_ctx.begin()) { | |
| 42 | auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); | |
| 43 | ||
| 44 | switch (this->__type) { | |
| 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 | } | |
| 68 | }; | |
| 69 | ||
| 70 | template <class _CharT> | |
| 71 | using __formatter_char = __formatter_integral<__parser_char<_CharT>>; | |
| 72 | ||
| 73 | } // namespace __format_spec | |
| 74 | ||
| 75 | // [format.formatter.spec]/2.1 The specializations | |
| 76 | ||
| 77 | template <> | |
| 78 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> | |
| 79 | : public __format_spec::__formatter_char<char> {}; | |
| 80 | ||
| 81 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 82 | template <> | |
| 83 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> | |
| 84 | : public __format_spec::__formatter_char<wchar_t> { | |
| 85 | using _Base = __format_spec::__formatter_char<wchar_t>; | |
| 86 | ||
| 87 | _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) | |
| 88 | -> decltype(__ctx.out()) { | |
| 89 | return _Base::format(static_cast<wchar_t>(__value), __ctx); | |
| 90 | } | |
| 91 | }; | |
| 92 | ||
| 93 | template <> | |
| 94 | struct _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) | |
| 99 | ||
| 100 | #endif //_LIBCPP_STD_VER > 17 | |
| 101 | ||
| 102 | _LIBCPP_END_NAMESPACE_STD | |
| 103 | ||
| 104 | #endif // _LIBCPP___FORMAT_FORMATTER_CHAR_H |
lib/libcxx/include/__format/formatter_floating_point.h created+717| ... | ... | @@ -0,0 +1,717 @@ |
| 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_FLOATING_POINT_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H | |
| 12 | ||
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/copy_n.h> | |
| 15 | #include <__algorithm/fill_n.h> | |
| 16 | #include <__algorithm/find.h> | |
| 17 | #include <__algorithm/min.h> | |
| 18 | #include <__algorithm/rotate.h> | |
| 19 | #include <__algorithm/transform.h> | |
| 20 | #include <__concepts/arithmetic.h> | |
| 21 | #include <__config> | |
| 22 | #include <__debug> | |
| 23 | #include <__format/format_error.h> | |
| 24 | #include <__format/format_fwd.h> | |
| 25 | #include <__format/format_string.h> | |
| 26 | #include <__format/formatter.h> | |
| 27 | #include <__format/formatter_integral.h> | |
| 28 | #include <__format/parser_std_format_spec.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | #include <charconv> | |
| 31 | #include <cmath> | |
| 32 | ||
| 33 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 34 | # include <locale> | |
| 35 | #endif | |
| 36 | ||
| 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 38 | # pragma GCC system_header | |
| 39 | #endif | |
| 40 | ||
| 41 | _LIBCPP_PUSH_MACROS | |
| 42 | #include <__undef_macros> | |
| 43 | ||
| 44 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 45 | ||
| 46 | #if _LIBCPP_STD_VER > 17 | |
| 47 | ||
| 48 | // TODO FMT Remove this once we require compilers with proper C++20 support. | |
| 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 | ||
| 54 | namespace __format_spec { | |
| 55 | ||
| 56 | template <floating_point _Tp> | |
| 57 | _LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) { | |
| 58 | to_chars_result __r = _VSTD::to_chars(__first, __last, __value); | |
| 59 | _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); | |
| 60 | return __r.ptr; | |
| 61 | } | |
| 62 | ||
| 63 | template <floating_point _Tp> | |
| 64 | _LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt) { | |
| 65 | to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt); | |
| 66 | _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); | |
| 67 | return __r.ptr; | |
| 68 | } | |
| 69 | ||
| 70 | template <floating_point _Tp> | |
| 71 | _LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt, int __precision) { | |
| 72 | to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt, __precision); | |
| 73 | _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); | |
| 74 | return __r.ptr; | |
| 75 | } | |
| 76 | ||
| 77 | // https://en.cppreference.com/w/cpp/language/types#cite_note-1 | |
| 78 | // float min subnormal: +/-0x1p-149 max: +/- 3.402,823,4 10^38 | |
| 79 | // double min subnormal: +/-0x1p-1074 max +/- 1.797,693,134,862,315,7 10^308 | |
| 80 | // long double (x86) min subnormal: +/-0x1p-16446 max: +/- 1.189,731,495,357,231,765,021 10^4932 | |
| 81 | // | |
| 82 | // The maximum number of digits required for the integral part is based on the | |
| 83 | // maximum's value power of 10. Every power of 10 requires one additional | |
| 84 | // decimal digit. | |
| 85 | // The maximum number of digits required for the fractional part is based on | |
| 86 | // the minimal subnormal hexadecimal output's power of 10. Every division of a | |
| 87 | // fraction's binary 1 by 2, requires one additional decimal digit. | |
| 88 | // | |
| 89 | // The maximum size of a formatted value depends on the selected output format. | |
| 90 | // Ignoring the fact the format string can request a precision larger than the | |
| 91 | // values maximum required, these values are: | |
| 92 | // | |
| 93 | // sign 1 code unit | |
| 94 | // __max_integral | |
| 95 | // radix point 1 code unit | |
| 96 | // __max_fractional | |
| 97 | // exponent character 1 code unit | |
| 98 | // sign 1 code unit | |
| 99 | // __max_fractional_value | |
| 100 | // ----------------------------------- | |
| 101 | // total 4 code units extra required. | |
| 102 | // | |
| 103 | // TODO FMT Optimize the storage to avoid storing digits that are known to be zero. | |
| 104 | // https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/ | |
| 105 | ||
| 106 | // TODO FMT Add long double specialization when to_chars has proper long double support. | |
| 107 | template <class _Tp> | |
| 108 | struct __traits; | |
| 109 | ||
| 110 | template <floating_point _Fp> | |
| 111 | static constexpr size_t __float_buffer_size(int __precision) { | |
| 112 | using _Traits = __traits<_Fp>; | |
| 113 | return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value; | |
| 114 | } | |
| 115 | ||
| 116 | template <> | |
| 117 | struct __traits<float> { | |
| 118 | static constexpr int __max_integral = 38; | |
| 119 | static constexpr int __max_fractional = 149; | |
| 120 | static constexpr int __max_fractional_value = 3; | |
| 121 | static constexpr size_t __stack_buffer_size = 256; | |
| 122 | ||
| 123 | static constexpr int __hex_precision_digits = 3; | |
| 124 | }; | |
| 125 | ||
| 126 | template <> | |
| 127 | struct __traits<double> { | |
| 128 | static constexpr int __max_integral = 308; | |
| 129 | static constexpr int __max_fractional = 1074; | |
| 130 | static constexpr int __max_fractional_value = 4; | |
| 131 | static constexpr size_t __stack_buffer_size = 1024; | |
| 132 | ||
| 133 | static constexpr int __hex_precision_digits = 4; | |
| 134 | }; | |
| 135 | ||
| 136 | /// Helper class to store the conversion buffer. | |
| 137 | /// | |
| 138 | /// Depending on the maxium size required for a value, the buffer is allocated | |
| 139 | /// on the stack or the heap. | |
| 140 | template <floating_point _Fp> | |
| 141 | class _LIBCPP_TEMPLATE_VIS __float_buffer { | |
| 142 | using _Traits = __traits<_Fp>; | |
| 143 | ||
| 144 | public: | |
| 145 | // TODO FMT Improve this constructor to do a better estimate. | |
| 146 | // When using a scientific formatting with a precision of 6 a stack buffer | |
| 147 | // will always suffice. At the moment that isn't important since floats and | |
| 148 | // doubles use a stack buffer, unless the precision used in the format string | |
| 149 | // is large. | |
| 150 | // When supporting long doubles the __max_integral part becomes 4932 which | |
| 151 | // may be too much for some platforms. For these cases a better estimate is | |
| 152 | // required. | |
| 153 | explicit _LIBCPP_HIDE_FROM_ABI __float_buffer(int __precision) | |
| 154 | : __precision_(__precision != -1 ? __precision : _Traits::__max_fractional) { | |
| 155 | ||
| 156 | // When the precision is larger than _Traits::__max_fractional the digits in | |
| 157 | // the range (_Traits::__max_fractional, precision] will contain the value | |
| 158 | // zero. There's no need to request to_chars to write these zeros: | |
| 159 | // - When the value is large a temporary heap buffer needs to be allocated. | |
| 160 | // - When to_chars writes the values they need to be "copied" to the output: | |
| 161 | // - char: std::fill on the output iterator is faster than std::copy. | |
| 162 | // - wchar_t: same argument as char, but additional std::copy won't work. | |
| 163 | // The input is always a char buffer, so every char in the buffer needs | |
| 164 | // to be converted from a char to a wchar_t. | |
| 165 | if (__precision_ > _Traits::__max_fractional) { | |
| 166 | __num_trailing_zeros_ = __precision_ - _Traits::__max_fractional; | |
| 167 | __precision_ = _Traits::__max_fractional; | |
| 168 | } | |
| 169 | ||
| 170 | __size_ = __format_spec::__float_buffer_size<_Fp>(__precision_); | |
| 171 | if (__size_ > _Traits::__stack_buffer_size) | |
| 172 | // The allocated buffer's contents don't need initialization. | |
| 173 | __begin_ = allocator<char>{}.allocate(__size_); | |
| 174 | else | |
| 175 | __begin_ = __buffer_; | |
| 176 | } | |
| 177 | ||
| 178 | _LIBCPP_HIDE_FROM_ABI ~__float_buffer() { | |
| 179 | if (__size_ > _Traits::__stack_buffer_size) | |
| 180 | allocator<char>{}.deallocate(__begin_, __size_); | |
| 181 | } | |
| 182 | _LIBCPP_HIDE_FROM_ABI __float_buffer(const __float_buffer&) = delete; | |
| 183 | _LIBCPP_HIDE_FROM_ABI __float_buffer& operator=(const __float_buffer&) = delete; | |
| 184 | ||
| 185 | _LIBCPP_HIDE_FROM_ABI char* begin() const { return __begin_; } | |
| 186 | _LIBCPP_HIDE_FROM_ABI char* end() const { return __begin_ + __size_; } | |
| 187 | ||
| 188 | _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; } | |
| 189 | _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; } | |
| 190 | _LIBCPP_HIDE_FROM_ABI void __remove_trailing_zeros() { __num_trailing_zeros_ = 0; } | |
| 191 | ||
| 192 | private: | |
| 193 | int __precision_; | |
| 194 | int __num_trailing_zeros_{0}; | |
| 195 | size_t __size_; | |
| 196 | char* __begin_; | |
| 197 | char __buffer_[_Traits::__stack_buffer_size]; | |
| 198 | }; | |
| 199 | ||
| 200 | struct __float_result { | |
| 201 | /// Points at the beginning of the integral part in the buffer. | |
| 202 | /// | |
| 203 | /// When there's no sign character this points at the start of the buffer. | |
| 204 | char* __integral; | |
| 205 | ||
| 206 | /// Points at the radix point, when not present it's the same as \ref __last. | |
| 207 | char* __radix_point; | |
| 208 | ||
| 209 | /// Points at the exponent character, when not present it's the same as \ref __last. | |
| 210 | char* __exponent; | |
| 211 | ||
| 212 | /// Points beyond the last written element in the buffer. | |
| 213 | char* __last; | |
| 214 | }; | |
| 215 | ||
| 216 | /// Finds the position of the exponent character 'e' at the end of the buffer. | |
| 217 | /// | |
| 218 | /// Assuming there is an exponent the input will terminate with | |
| 219 | /// eSdd and eSdddd (S = sign, d = digit) | |
| 220 | /// | |
| 221 | /// \returns a pointer to the exponent or __last when not found. | |
| 222 | constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) { | |
| 223 | ptrdiff_t __size = __last - __first; | |
| 224 | if (__size > 4) { | |
| 225 | __first = __last - _VSTD::min(__size, ptrdiff_t(6)); | |
| 226 | for (; __first != __last - 3; ++__first) { | |
| 227 | if (*__first == 'e') | |
| 228 | return __first; | |
| 229 | } | |
| 230 | } | |
| 231 | return __last; | |
| 232 | } | |
| 233 | ||
| 234 | template <class _Fp, class _Tp> | |
| 235 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffer<_Fp>& __buffer, _Tp __value, | |
| 236 | char* __integral) { | |
| 237 | __float_result __result; | |
| 238 | __result.__integral = __integral; | |
| 239 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value); | |
| 240 | ||
| 241 | __result.__exponent = __format_spec::__find_exponent(__result.__integral, __result.__last); | |
| 242 | ||
| 243 | // Constrains: | |
| 244 | // - There's at least one decimal digit before the radix point. | |
| 245 | // - The radix point, when present, is placed before the exponent. | |
| 246 | __result.__radix_point = _VSTD::find(__result.__integral + 1, __result.__exponent, '.'); | |
| 247 | ||
| 248 | // When the radix point isn't found its position is the exponent instead of | |
| 249 | // __result.__last. | |
| 250 | if (__result.__radix_point == __result.__exponent) | |
| 251 | __result.__radix_point = __result.__last; | |
| 252 | ||
| 253 | // clang-format off | |
| 254 | _LIBCPP_ASSERT((__result.__integral != __result.__last) && | |
| 255 | (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && | |
| 256 | (__result.__exponent == __result.__last || *__result.__exponent == 'e'), | |
| 257 | "Post-condition failure."); | |
| 258 | // clang-format on | |
| 259 | ||
| 260 | return __result; | |
| 261 | } | |
| 262 | ||
| 263 | template <class _Fp, class _Tp> | |
| 264 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(const __float_buffer<_Fp>& __buffer, | |
| 265 | _Tp __value, int __precision, | |
| 266 | char* __integral) { | |
| 267 | __float_result __result; | |
| 268 | __result.__integral = __integral; | |
| 269 | if (__precision == -1) | |
| 270 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex); | |
| 271 | else | |
| 272 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision); | |
| 273 | ||
| 274 | // H = one or more hex-digits | |
| 275 | // S = sign | |
| 276 | // D = one or more decimal-digits | |
| 277 | // When the fractional part is zero and no precision the output is 0p+0 | |
| 278 | // else the output is 0.HpSD | |
| 279 | // So testing the second position can differentiate between these two cases. | |
| 280 | char* __first = __integral + 1; | |
| 281 | if (*__first == '.') { | |
| 282 | __result.__radix_point = __first; | |
| 283 | // One digit is the minimum | |
| 284 | // 0.hpSd | |
| 285 | // ^-- last | |
| 286 | // ^---- integral = end of search | |
| 287 | // ^-------- start of search | |
| 288 | // 0123456 | |
| 289 | // | |
| 290 | // Four digits is the maximum | |
| 291 | // 0.hpSdddd | |
| 292 | // ^-- last | |
| 293 | // ^---- integral = end of search | |
| 294 | // ^-------- start of search | |
| 295 | // 0123456789 | |
| 296 | static_assert(__traits<_Fp>::__hex_precision_digits <= 4, "Guard against possible underflow."); | |
| 297 | ||
| 298 | char* __last = __result.__last - 2; | |
| 299 | __first = __last - __traits<_Fp>::__hex_precision_digits; | |
| 300 | __result.__exponent = _VSTD::find(__first, __last, 'p'); | |
| 301 | } else { | |
| 302 | __result.__radix_point = __result.__last; | |
| 303 | __result.__exponent = __first; | |
| 304 | } | |
| 305 | ||
| 306 | // clang-format off | |
| 307 | _LIBCPP_ASSERT((__result.__integral != __result.__last) && | |
| 308 | (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && | |
| 309 | (__result.__exponent != __result.__last && *__result.__exponent == 'p'), | |
| 310 | "Post-condition failure."); | |
| 311 | // clang-format on | |
| 312 | ||
| 313 | return __result; | |
| 314 | } | |
| 315 | ||
| 316 | template <class _Fp, class _Tp> | |
| 317 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(const __float_buffer<_Fp>& __buffer, | |
| 318 | _Tp __value, int __precision, | |
| 319 | char* __integral) { | |
| 320 | __float_result __result = | |
| 321 | __format_spec::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral); | |
| 322 | _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper); | |
| 323 | *__result.__exponent = 'P'; | |
| 324 | return __result; | |
| 325 | } | |
| 326 | ||
| 327 | template <class _Fp, class _Tp> | |
| 328 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const __float_buffer<_Fp>& __buffer, | |
| 329 | _Tp __value, int __precision, | |
| 330 | char* __integral) { | |
| 331 | __float_result __result; | |
| 332 | __result.__integral = __integral; | |
| 333 | __result.__last = | |
| 334 | __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision); | |
| 335 | ||
| 336 | char* __first = __integral + 1; | |
| 337 | _LIBCPP_ASSERT(__first != __result.__last, "No exponent present"); | |
| 338 | if (*__first == '.') { | |
| 339 | __result.__radix_point = __first; | |
| 340 | __result.__exponent = __format_spec::__find_exponent(__first + 1, __result.__last); | |
| 341 | } else { | |
| 342 | __result.__radix_point = __result.__last; | |
| 343 | __result.__exponent = __first; | |
| 344 | } | |
| 345 | ||
| 346 | // clang-format off | |
| 347 | _LIBCPP_ASSERT((__result.__integral != __result.__last) && | |
| 348 | (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && | |
| 349 | (__result.__exponent != __result.__last && *__result.__exponent == 'e'), | |
| 350 | "Post-condition failure."); | |
| 351 | // clang-format on | |
| 352 | return __result; | |
| 353 | } | |
| 354 | ||
| 355 | template <class _Fp, class _Tp> | |
| 356 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const __float_buffer<_Fp>& __buffer, | |
| 357 | _Tp __value, int __precision, | |
| 358 | char* __integral) { | |
| 359 | __float_result __result = | |
| 360 | __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral); | |
| 361 | *__result.__exponent = 'E'; | |
| 362 | return __result; | |
| 363 | } | |
| 364 | ||
| 365 | template <class _Fp, class _Tp> | |
| 366 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<_Fp>& __buffer, _Tp __value, | |
| 367 | int __precision, char* __integral) { | |
| 368 | __float_result __result; | |
| 369 | __result.__integral = __integral; | |
| 370 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision); | |
| 371 | ||
| 372 | // When there's no precision there's no radix point. | |
| 373 | // Else the radix point is placed at __precision + 1 from the end. | |
| 374 | // By converting __precision to a bool the subtraction can be done | |
| 375 | // unconditionally. | |
| 376 | __result.__radix_point = __result.__last - (__precision + bool(__precision)); | |
| 377 | __result.__exponent = __result.__last; | |
| 378 | ||
| 379 | // clang-format off | |
| 380 | _LIBCPP_ASSERT((__result.__integral != __result.__last) && | |
| 381 | (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && | |
| 382 | (__result.__exponent == __result.__last), | |
| 383 | "Post-condition failure."); | |
| 384 | // clang-format on | |
| 385 | return __result; | |
| 386 | } | |
| 387 | ||
| 388 | template <class _Fp, class _Tp> | |
| 389 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_buffer<_Fp>& __buffer, _Tp __value, | |
| 390 | int __precision, char* __integral) { | |
| 391 | ||
| 392 | __buffer.__remove_trailing_zeros(); | |
| 393 | ||
| 394 | __float_result __result; | |
| 395 | __result.__integral = __integral; | |
| 396 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision); | |
| 397 | ||
| 398 | char* __first = __integral + 1; | |
| 399 | if (__first == __result.__last) { | |
| 400 | __result.__radix_point = __result.__last; | |
| 401 | __result.__exponent = __result.__last; | |
| 402 | } else { | |
| 403 | __result.__exponent = __format_spec::__find_exponent(__first, __result.__last); | |
| 404 | if (__result.__exponent != __result.__last) | |
| 405 | // 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). | |
| 407 | __result.__radix_point = *__first == '.' ? __first : __result.__last; | |
| 408 | else { | |
| 409 | // In fixed mode the algorithm truncates trailing spaces and possibly the | |
| 410 | // radix point. There's no good guess for the position of the radix point | |
| 411 | // therefore scan the output after the first digit. | |
| 412 | __result.__radix_point = _VSTD::find(__first, __result.__last, '.'); | |
| 413 | } | |
| 414 | } | |
| 415 | ||
| 416 | // clang-format off | |
| 417 | _LIBCPP_ASSERT((__result.__integral != __result.__last) && | |
| 418 | (__result.__radix_point == __result.__last || *__result.__radix_point == '.') && | |
| 419 | (__result.__exponent == __result.__last || *__result.__exponent == 'e'), | |
| 420 | "Post-condition failure."); | |
| 421 | // clang-format on | |
| 422 | ||
| 423 | return __result; | |
| 424 | } | |
| 425 | ||
| 426 | template <class _Fp, class _Tp> | |
| 427 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value, | |
| 428 | int __precision, char* __integral) { | |
| 429 | __float_result __result = | |
| 430 | __format_spec::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral); | |
| 431 | if (__result.__exponent != __result.__last) | |
| 432 | *__result.__exponent = 'E'; | |
| 433 | return __result; | |
| 434 | } | |
| 435 | ||
| 436 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 437 | template <class _OutIt, class _Fp, class _CharT> | |
| 438 | _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, const __float_buffer<_Fp>& __buffer, | |
| 439 | const __float_result& __result, _VSTD::locale __loc, | |
| 440 | size_t __width, _Flags::_Alignment __alignment, | |
| 441 | _CharT __fill) { | |
| 442 | const auto& __np = use_facet<numpunct<_CharT>>(__loc); | |
| 443 | string __grouping = __np.grouping(); | |
| 444 | char* __first = __result.__integral; | |
| 445 | // When no radix point or exponent are present __last will be __result.__last. | |
| 446 | char* __last = _VSTD::min(__result.__radix_point, __result.__exponent); | |
| 447 | ||
| 448 | ptrdiff_t __digits = __last - __first; | |
| 449 | if (!__grouping.empty()) { | |
| 450 | if (__digits <= __grouping[0]) | |
| 451 | __grouping.clear(); | |
| 452 | else | |
| 453 | __grouping = __determine_grouping(__digits, __grouping); | |
| 454 | } | |
| 455 | ||
| 456 | size_t __size = __result.__last - __buffer.begin() + // Formatted string | |
| 457 | __buffer.__num_trailing_zeros() + // Not yet rendered zeros | |
| 458 | __grouping.size() - // Grouping contains one | |
| 459 | !__grouping.empty(); // additional character | |
| 460 | ||
| 461 | __formatter::__padding_size_result __padding = {0, 0}; | |
| 462 | bool __zero_padding = __alignment == _Flags::_Alignment::__default; | |
| 463 | if (__size < __width) { | |
| 464 | if (__zero_padding) { | |
| 465 | __alignment = _Flags::_Alignment::__right; | |
| 466 | __fill = _CharT('0'); | |
| 467 | } | |
| 468 | ||
| 469 | __padding = __formatter::__padding_size(__size, __width, __alignment); | |
| 470 | } | |
| 471 | ||
| 472 | // sign and (zero padding or alignment) | |
| 473 | if (__zero_padding && __first != __buffer.begin()) | |
| 474 | *__out_it++ = *__buffer.begin(); | |
| 475 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); | |
| 476 | if (!__zero_padding && __first != __buffer.begin()) | |
| 477 | *__out_it++ = *__buffer.begin(); | |
| 478 | ||
| 479 | // integral part | |
| 480 | if (__grouping.empty()) { | |
| 481 | __out_it = _VSTD::copy_n(__first, __digits, _VSTD::move(__out_it)); | |
| 482 | } else { | |
| 483 | auto __r = __grouping.rbegin(); | |
| 484 | auto __e = __grouping.rend() - 1; | |
| 485 | _CharT __sep = __np.thousands_sep(); | |
| 486 | // The output is divided in small groups of numbers to write: | |
| 487 | // - A group before the first separator. | |
| 488 | // - A separator and a group, repeated for the number of separators. | |
| 489 | // - A group after the last separator. | |
| 490 | // This loop achieves that process by testing the termination condition | |
| 491 | // midway in the loop. | |
| 492 | while (true) { | |
| 493 | __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it)); | |
| 494 | __first += *__r; | |
| 495 | ||
| 496 | if (__r == __e) | |
| 497 | break; | |
| 498 | ||
| 499 | ++__r; | |
| 500 | *__out_it++ = __sep; | |
| 501 | } | |
| 502 | } | |
| 503 | ||
| 504 | // fractional part | |
| 505 | if (__result.__radix_point != __result.__last) { | |
| 506 | *__out_it++ = __np.decimal_point(); | |
| 507 | __out_it = _VSTD::copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it)); | |
| 508 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0')); | |
| 509 | } | |
| 510 | ||
| 511 | // exponent | |
| 512 | if (__result.__exponent != __result.__last) | |
| 513 | __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it)); | |
| 514 | ||
| 515 | // alignment | |
| 516 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); | |
| 517 | } | |
| 518 | ||
| 519 | # endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 520 | ||
| 521 | template <__formatter::__char_type _CharT> | |
| 522 | class _LIBCPP_TEMPLATE_VIS __formatter_floating_point : public __parser_floating_point<_CharT> { | |
| 523 | public: | |
| 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 | } | |
| 569 | ||
| 570 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 571 | if (this->__locale_specific_form) | |
| 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 | } | |
| 588 | ||
| 589 | auto __out_it = __ctx.out(); | |
| 590 | char* __first = __buffer.begin(); | |
| 591 | if (this->__alignment == _Flags::_Alignment::__default) { | |
| 592 | // When there is a sign output it before the padding. Note the __size | |
| 593 | // doesn't need any adjustment, regardless whether the sign is written | |
| 594 | // here or in __formatter::__write. | |
| 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 | } | |
| 602 | ||
| 603 | if (__num_trailing_zeros) | |
| 604 | return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill, | |
| 605 | this->__alignment, __result.__exponent, __num_trailing_zeros); | |
| 606 | ||
| 607 | return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill, | |
| 608 | this->__alignment); | |
| 609 | } | |
| 610 | ||
| 611 | private: | |
| 612 | template <class _OutIt> | |
| 613 | _LIBCPP_HIDE_FROM_ABI _OutIt __format_non_finite(_OutIt __out_it, bool __negative, bool __isnan) { | |
| 614 | char __buffer[4]; | |
| 615 | char* __last = __insert_sign(__buffer, __negative, this->__sign); | |
| 616 | ||
| 617 | // to_char can return inf, infinity, nan, and nan(n-char-sequence). | |
| 618 | // The format library requires inf and nan. | |
| 619 | // All in one expression to avoid dangling references. | |
| 620 | __last = _VSTD::copy_n(&("infnanINFNAN"[6 * (this->__type == _Flags::_Type::__float_hexadecimal_upper_case || | |
| 621 | this->__type == _Flags::_Type::__scientific_upper_case || | |
| 622 | this->__type == _Flags::_Type::__fixed_upper_case || | |
| 623 | this->__type == _Flags::_Type::__general_upper_case) + | |
| 624 | 3 * __isnan]), | |
| 625 | 3, __last); | |
| 626 | ||
| 627 | // [format.string.std]/13 | |
| 628 | // A zero (0) character preceding the width field pads the field with | |
| 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 | } | |
| 641 | ||
| 642 | /// Fills the buffer with the data based on the requested formatting. | |
| 643 | /// | |
| 644 | /// This function, when needed, turns the characters to upper case and | |
| 645 | /// determines the "interesting" locations which are returned to the caller. | |
| 646 | /// | |
| 647 | /// This means the caller never has to convert the contents of the buffer to | |
| 648 | /// upper case or search for radix points and the location of the exponent. | |
| 649 | /// This gives a bit of overhead. The original code didn't do that, but due | |
| 650 | /// to the number of possible additional work needed to turn this number to | |
| 651 | /// the proper output the code was littered with tests for upper cases and | |
| 652 | /// searches for radix points and exponents. | |
| 653 | /// - When a precision larger than the type's precision is selected | |
| 654 | /// additional zero characters need to be written before the exponent. | |
| 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); | |
| 676 | ||
| 677 | case _Flags::_Type::__scientific_upper_case: | |
| 678 | return __format_spec::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first); | |
| 679 | ||
| 680 | case _Flags::_Type::__fixed_lower_case: | |
| 681 | case _Flags::_Type::__fixed_upper_case: | |
| 682 | return __format_spec::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first); | |
| 683 | ||
| 684 | case _Flags::_Type::__general_lower_case: | |
| 685 | return __format_spec::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first); | |
| 686 | ||
| 687 | case _Flags::_Type::__general_upper_case: | |
| 688 | return __format_spec::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first); | |
| 689 | ||
| 690 | default: | |
| 691 | _LIBCPP_ASSERT(false, "The parser should have validated the type"); | |
| 692 | _LIBCPP_UNREACHABLE(); | |
| 693 | } | |
| 694 | } | |
| 695 | }; | |
| 696 | ||
| 697 | } //namespace __format_spec | |
| 698 | ||
| 699 | template <__formatter::__char_type _CharT> | |
| 700 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT> | |
| 701 | : public __format_spec::__formatter_floating_point<_CharT> {}; | |
| 702 | template <__formatter::__char_type _CharT> | |
| 703 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT> | |
| 704 | : public __format_spec::__formatter_floating_point<_CharT> {}; | |
| 705 | template <__formatter::__char_type _CharT> | |
| 706 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT> | |
| 707 | : public __format_spec::__formatter_floating_point<_CharT> {}; | |
| 708 | ||
| 709 | # endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 710 | ||
| 711 | #endif //_LIBCPP_STD_VER > 17 | |
| 712 | ||
| 713 | _LIBCPP_END_NAMESPACE_STD | |
| 714 | ||
| 715 | _LIBCPP_POP_MACROS | |
| 716 | ||
| 717 | #endif // _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H |
lib/libcxx/include/__format/formatter_integer.h created+170| ... | ... | @@ -0,0 +1,170 @@ |
| 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_INTEGER_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_INTEGER_H | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | #include <__format/format_error.h> | |
| 16 | #include <__format/format_fwd.h> | |
| 17 | #include <__format/formatter.h> | |
| 18 | #include <__format/formatter_integral.h> | |
| 19 | #include <__format/parser_std_format_spec.h> | |
| 20 | #include <limits> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | #pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | #if _LIBCPP_STD_VER > 17 | |
| 32 | ||
| 33 | // TODO FMT Remove this once we require compilers with proper C++20 support. | |
| 34 | // If the compiler has no concepts support, the format header will be disabled. | |
| 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 | ||
| 39 | namespace __format_spec { | |
| 40 | ||
| 41 | template <class _CharT> | |
| 42 | class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> { | |
| 43 | public: | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) | |
| 45 | -> decltype(__parse_ctx.begin()) { | |
| 46 | auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); | |
| 47 | ||
| 48 | switch (this->__type) { | |
| 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 | } | |
| 72 | }; | |
| 73 | ||
| 74 | template <class _CharT> | |
| 75 | using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>; | |
| 76 | ||
| 77 | } // namespace __format_spec | |
| 78 | ||
| 79 | // [format.formatter.spec]/2.3 | |
| 80 | // For each charT, for each cv-unqualified arithmetic type ArithmeticT other | |
| 81 | // than char, wchar_t, char8_t, char16_t, or char32_t, a specialization | |
| 82 | ||
| 83 | // Signed integral types. | |
| 84 | template <__formatter::__char_type _CharT> | |
| 85 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 86 | formatter<signed char, _CharT> | |
| 87 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 88 | template <__formatter::__char_type _CharT> | |
| 89 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> | |
| 90 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 91 | template <__formatter::__char_type _CharT> | |
| 92 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> | |
| 93 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 94 | template <__formatter::__char_type _CharT> | |
| 95 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> | |
| 96 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 97 | template <__formatter::__char_type _CharT> | |
| 98 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 99 | formatter<long long, _CharT> | |
| 100 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 101 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 102 | template <__formatter::__char_type _CharT> | |
| 103 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 104 | formatter<__int128_t, _CharT> | |
| 105 | : public __format_spec::__formatter_integer<_CharT> { | |
| 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 | |
| 120 | ||
| 121 | // Unsigned integral types. | |
| 122 | template <__formatter::__char_type _CharT> | |
| 123 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 124 | formatter<unsigned char, _CharT> | |
| 125 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 126 | template <__formatter::__char_type _CharT> | |
| 127 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 128 | formatter<unsigned short, _CharT> | |
| 129 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 130 | template <__formatter::__char_type _CharT> | |
| 131 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 132 | formatter<unsigned, _CharT> | |
| 133 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 134 | template <__formatter::__char_type _CharT> | |
| 135 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 136 | formatter<unsigned long, _CharT> | |
| 137 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 138 | template <__formatter::__char_type _CharT> | |
| 139 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 140 | formatter<unsigned long long, _CharT> | |
| 141 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 142 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 143 | template <__formatter::__char_type _CharT> | |
| 144 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 145 | formatter<__uint128_t, _CharT> | |
| 146 | : public __format_spec::__formatter_integer<_CharT> { | |
| 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) | |
| 163 | ||
| 164 | #endif //_LIBCPP_STD_VER > 17 | |
| 165 | ||
| 166 | _LIBCPP_END_NAMESPACE_STD | |
| 167 | ||
| 168 | _LIBCPP_POP_MACROS | |
| 169 | ||
| 170 | #endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H |
lib/libcxx/include/__format/formatter_integral.h created+463| ... | ... | @@ -0,0 +1,463 @@ |
| 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_INTEGRAL_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_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/format_error.h> | |
| 19 | #include <__format/format_fwd.h> | |
| 20 | #include <__format/formatter.h> | |
| 21 | #include <__format/parser_std_format_spec.h> | |
| 22 | #include <array> | |
| 23 | #include <charconv> | |
| 24 | #include <concepts> | |
| 25 | #include <limits> | |
| 26 | #include <string> | |
| 27 | ||
| 28 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 29 | #include <locale> | |
| 30 | #endif | |
| 31 | ||
| 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 33 | #pragma GCC system_header | |
| 34 | #endif | |
| 35 | ||
| 36 | _LIBCPP_PUSH_MACROS | |
| 37 | #include <__undef_macros> | |
| 38 | ||
| 39 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 40 | ||
| 41 | #if _LIBCPP_STD_VER > 17 | |
| 42 | ||
| 43 | // TODO FMT Remove this once we require compilers with proper C++20 support. | |
| 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) | |
| 48 | ||
| 49 | /** | |
| 50 | * Integral formatting classes. | |
| 51 | * | |
| 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 | */ | |
| 82 | namespace __format_spec { | |
| 83 | ||
| 84 | /** Wrapper around @ref to_chars, returning the output pointer. */ | |
| 85 | template <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 | */ | |
| 101 | template <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 | ||
| 109 | template <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 | } | |
| 118 | ||
| 119 | template <unsigned_integral _Tp, size_t _Base> | |
| 120 | _LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept | |
| 121 | requires(_Base == 10) { | |
| 122 | return numeric_limits<_Tp>::digits10 // The floored value. | |
| 123 | + 1 // Turn floor to ceil. | |
| 124 | + 1; // Reserve space for the sign. | |
| 125 | } | |
| 126 | ||
| 127 | template <unsigned_integral _Tp, size_t _Base> | |
| 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 | } | |
| 135 | ||
| 136 | /** | |
| 137 | * Determines the required grouping based on the size of the input. | |
| 138 | * | |
| 139 | * The grouping's last element will be repeated. For simplicity this repeating | |
| 140 | * is unwrapped based on the length of the input. (When the input is short some | |
| 141 | * groups are not processed.) | |
| 142 | * | |
| 143 | * @returns The size of the groups to write. This means the number of | |
| 144 | * separator characters written is size() - 1. | |
| 145 | * | |
| 146 | * @note Since zero-sized groups cause issues they are silently ignored. | |
| 147 | * | |
| 148 | * @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. | |
| 150 | */ | |
| 151 | _LIBCPP_HIDE_FROM_ABI inline string | |
| 152 | __determine_grouping(ptrdiff_t __size, const string& __grouping) { | |
| 153 | _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0], | |
| 154 | "The slow grouping formatting is used while there will be no " | |
| 155 | "separators written"); | |
| 156 | string __r; | |
| 157 | auto __end = __grouping.end() - 1; | |
| 158 | auto __ptr = __grouping.begin(); | |
| 159 | ||
| 160 | while (true) { | |
| 161 | __size -= *__ptr; | |
| 162 | if (__size > 0) | |
| 163 | __r.push_back(*__ptr); | |
| 164 | else { | |
| 165 | // __size <= 0 so the value pushed will be <= *__ptr. | |
| 166 | __r.push_back(*__ptr + __size); | |
| 167 | return __r; | |
| 168 | } | |
| 169 | ||
| 170 | // Proceed to the next group. | |
| 171 | if (__ptr != __end) { | |
| 172 | do { | |
| 173 | ++__ptr; | |
| 174 | // Skip grouping with a width of 0. | |
| 175 | } while (*__ptr == 0 && __ptr != __end); | |
| 176 | } | |
| 177 | } | |
| 178 | ||
| 179 | _LIBCPP_UNREACHABLE(); | |
| 180 | } | |
| 181 | ||
| 182 | template <class _Parser> | |
| 183 | requires __formatter::__char_type<typename _Parser::char_type> | |
| 184 | class _LIBCPP_TEMPLATE_VIS __formatter_integral : public _Parser { | |
| 185 | public: | |
| 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); | |
| 196 | ||
| 197 | if constexpr (unsigned_integral<_Tp>) | |
| 198 | return __format_unsigned_integral(__value, false, __ctx); | |
| 199 | else { | |
| 200 | // Depending on the std-format-spec string the sign and the value | |
| 201 | // might not be outputted together: | |
| 202 | // - alternate form may insert a prefix string. | |
| 203 | // - zero-padding may insert additional '0' characters. | |
| 204 | // Therefore the value is processed as a positive unsigned value. | |
| 205 | // The function @ref __insert_sign will a '-' when the value was negative. | |
| 206 | auto __r = __to_unsigned_like(__value); | |
| 207 | bool __negative = __value < 0; | |
| 208 | if (__negative) | |
| 209 | __r = __complement(__r); | |
| 210 | ||
| 211 | return __format_unsigned_integral(__r, __negative, __ctx); | |
| 212 | } | |
| 213 | } | |
| 214 | ||
| 215 | private: | |
| 216 | /** Generic formatting for format-type c. */ | |
| 217 | _LIBCPP_HIDE_FROM_ABI auto __format_as_char(integral auto __value, | |
| 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 | } | |
| 245 | ||
| 246 | const auto __c = static_cast<_CharT>(__value); | |
| 247 | return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, | |
| 248 | __ctx.out()); | |
| 249 | } | |
| 250 | ||
| 251 | /** | |
| 252 | * Generic formatting for format-type bBdoxX. | |
| 253 | * | |
| 254 | * This small wrapper allocates a buffer with the required size. Then calls | |
| 255 | * the real formatter with the buffer and the prefix for the base. | |
| 256 | */ | |
| 257 | _LIBCPP_HIDE_FROM_ABI auto | |
| 258 | __format_unsigned_integral(unsigned_integral auto __value, bool __negative, | |
| 259 | auto& __ctx) -> decltype(__ctx.out()) { | |
| 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 | } | |
| 298 | ||
| 299 | template <class _Tp> | |
| 300 | requires(same_as<char, _Tp> || same_as<wchar_t, _Tp>) _LIBCPP_HIDE_FROM_ABI | |
| 301 | auto __write(const _Tp* __first, const _Tp* __last, auto __out_it) | |
| 302 | -> decltype(__out_it) { | |
| 303 | ||
| 304 | unsigned __size = __last - __first; | |
| 305 | if (this->__type != _Flags::_Type::__hexadecimal_upper_case) [[likely]] { | |
| 306 | if (__size >= this->__width) | |
| 307 | return _VSTD::copy(__first, __last, _VSTD::move(__out_it)); | |
| 308 | ||
| 309 | return __formatter::__write(_VSTD::move(__out_it), __first, __last, | |
| 310 | __size, this->__width, this->__fill, | |
| 311 | this->__alignment); | |
| 312 | } | |
| 313 | ||
| 314 | // this->__type == _Flags::_Type::__hexadecimal_upper_case | |
| 315 | // This means all characters in the range [a-f] need to be changed to their | |
| 316 | // uppercase representation. The transformation is done as transformation | |
| 317 | // in the output routine instead of before. This avoids another pass over | |
| 318 | // the data. | |
| 319 | // TODO FMT See whether it's possible to do this transformation during the | |
| 320 | // conversion. (This probably requires changing std::to_chars' alphabet.) | |
| 321 | if (__size >= this->__width) | |
| 322 | return _VSTD::transform(__first, __last, _VSTD::move(__out_it), | |
| 323 | __hex_to_upper); | |
| 324 | ||
| 325 | return __formatter::__write(_VSTD::move(__out_it), __first, __last, __size, | |
| 326 | __hex_to_upper, this->__width, this->__fill, | |
| 327 | this->__alignment); | |
| 328 | } | |
| 329 | ||
| 330 | _LIBCPP_HIDE_FROM_ABI auto | |
| 331 | __format_unsigned_integral(char* __begin, char* __end, | |
| 332 | unsigned_integral auto __value, bool __negative, | |
| 333 | int __base, auto& __ctx, const char* __prefix) | |
| 334 | -> decltype(__ctx.out()) { | |
| 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 | } | |
| 371 | ||
| 372 | return __write(__first, __last, _VSTD::move(__out_it)); | |
| 373 | } | |
| 374 | ||
| 375 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 376 | /** Format's the locale-specific form's groupings. */ | |
| 377 | template <class _OutIt, class _CharT> | |
| 378 | _LIBCPP_HIDE_FROM_ABI _OutIt | |
| 379 | __format_grouping(_OutIt __out_it, const char* __begin, const char* __first, | |
| 380 | const char* __last, string&& __grouping, _CharT __sep) { | |
| 381 | ||
| 382 | // TODO FMT This function duplicates some functionality of the normal | |
| 383 | // output routines. Evaluate whether these parts can be efficiently | |
| 384 | // combined with the existing routines. | |
| 385 | ||
| 386 | unsigned __size = (__first - __begin) + // [sign][prefix] | |
| 387 | (__last - __first) + // data | |
| 388 | (__grouping.size() - 1); // number of separator characters | |
| 389 | ||
| 390 | __formatter::__padding_size_result __padding = {0, 0}; | |
| 391 | if (this->__alignment == _Flags::_Alignment::__default) { | |
| 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 | } | |
| 413 | ||
| 414 | auto __r = __grouping.rbegin(); | |
| 415 | auto __e = __grouping.rend() - 1; | |
| 416 | _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while " | |
| 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 | } | |
| 446 | ||
| 447 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, | |
| 448 | this->__fill); | |
| 449 | } | |
| 450 | #endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 451 | }; | |
| 452 | ||
| 453 | } // namespace __format_spec | |
| 454 | ||
| 455 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 456 | ||
| 457 | #endif //_LIBCPP_STD_VER > 17 | |
| 458 | ||
| 459 | _LIBCPP_END_NAMESPACE_STD | |
| 460 | ||
| 461 | _LIBCPP_POP_MACROS | |
| 462 | ||
| 463 | #endif // _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H |
lib/libcxx/include/__format/formatter_pointer.h created+91| ... | ... | @@ -0,0 +1,91 @@ |
| 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_POINTER_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_POINTER_H | |
| 12 | ||
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__availability> | |
| 15 | #include <__config> | |
| 16 | #include <__debug> | |
| 17 | #include <__format/format_error.h> | |
| 18 | #include <__format/format_fwd.h> | |
| 19 | #include <__format/formatter.h> | |
| 20 | #include <__format/formatter_integral.h> | |
| 21 | #include <__format/parser_std_format_spec.h> | |
| 22 | #include <__iterator/access.h> | |
| 23 | #include <__nullptr> | |
| 24 | #include <cstdint> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 | |
| 33 | ||
| 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 | ||
| 40 | namespace __format_spec { | |
| 41 | ||
| 42 | template <__formatter::__char_type _CharT> | |
| 43 | class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> { | |
| 44 | public: | |
| 45 | _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) -> decltype(__ctx.out()) { | |
| 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)); | |
| 50 | ||
| 51 | // This code looks a lot like the code to format a hexadecimal integral, | |
| 52 | // but that code isn't public. Making that code public requires some | |
| 53 | // refactoring. | |
| 54 | // TODO FMT Remove code duplication. | |
| 55 | char __buffer[2 + 2 * sizeof(uintptr_t)]; | |
| 56 | __buffer[0] = '0'; | |
| 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()); | |
| 63 | ||
| 64 | return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment); | |
| 65 | } | |
| 66 | }; | |
| 67 | ||
| 68 | } // namespace __format_spec | |
| 69 | ||
| 70 | // [format.formatter.spec]/2.4 | |
| 71 | // For each charT, the pointer type specializations template<> | |
| 72 | // - struct formatter<nullptr_t, charT>; | |
| 73 | // - template<> struct formatter<void*, charT>; | |
| 74 | // - template<> struct formatter<const void*, charT>; | |
| 75 | template <__formatter::__char_type _CharT> | |
| 76 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT> | |
| 77 | : public __format_spec::__formatter_pointer<_CharT> {}; | |
| 78 | template <__formatter::__char_type _CharT> | |
| 79 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> | |
| 80 | : public __format_spec::__formatter_pointer<_CharT> {}; | |
| 81 | template <__formatter::__char_type _CharT> | |
| 82 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT> | |
| 83 | : public __format_spec::__formatter_pointer<_CharT> {}; | |
| 84 | ||
| 85 | # endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 86 | ||
| 87 | #endif //_LIBCPP_STD_VER > 17 | |
| 88 | ||
| 89 | _LIBCPP_END_NAMESPACE_STD | |
| 90 | ||
| 91 | #endif // _LIBCPP___FORMAT_FORMATTER_POINTER_H |
lib/libcxx/include/__format/formatter_string.h created+162| ... | ... | @@ -0,0 +1,162 @@ |
| 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_STRING_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_STRING_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__format/format_error.h> | |
| 15 | #include <__format/format_fwd.h> | |
| 16 | #include <__format/format_string.h> | |
| 17 | #include <__format/formatter.h> | |
| 18 | #include <__format/parser_std_format_spec.h> | |
| 19 | #include <string_view> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | #pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 | |
| 31 | ||
| 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 | ||
| 38 | namespace __format_spec { | |
| 39 | ||
| 40 | template <__formatter::__char_type _CharT> | |
| 41 | class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> { | |
| 42 | public: | |
| 43 | _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, | |
| 44 | auto& __ctx) -> decltype(__ctx.out()) { | |
| 45 | ||
| 46 | _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default, | |
| 47 | "The parser should not use these defaults"); | |
| 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 | } | |
| 60 | }; | |
| 61 | ||
| 62 | } //namespace __format_spec | |
| 63 | ||
| 64 | // [format.formatter.spec]/2.2 For each charT, the string type specializations | |
| 65 | ||
| 66 | // Formatter const char*. | |
| 67 | template <__formatter::__char_type _CharT> | |
| 68 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 69 | formatter<const _CharT*, _CharT> | |
| 70 | : public __format_spec::__formatter_string<_CharT> { | |
| 71 | using _Base = __format_spec::__formatter_string<_CharT>; | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) | |
| 74 | -> decltype(__ctx.out()) { | |
| 75 | _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have " | |
| 76 | "prevented an invalid pointer."); | |
| 77 | ||
| 78 | // When using a center or right alignment and the width option the length | |
| 79 | // of __str must be known to add the padding upfront. This case is handled | |
| 80 | // by the base class by converting the argument to a basic_string_view. | |
| 81 | // | |
| 82 | // When using left alignment and the width option the padding is added | |
| 83 | // after outputting __str so the length can be determined while outputting | |
| 84 | // __str. The same holds true for the precision, during outputting __str it | |
| 85 | // can be validated whether the precision threshold has been reached. For | |
| 86 | // now these optimizations aren't implemented. Instead the base class | |
| 87 | // handles these options. | |
| 88 | // TODO FMT Implement these improvements. | |
| 89 | if (this->__has_width_field() || this->__has_precision_field()) | |
| 90 | return _Base::format(__str, __ctx); | |
| 91 | ||
| 92 | // No formatting required, copy the string to the output. | |
| 93 | auto __out_it = __ctx.out(); | |
| 94 | while (*__str) | |
| 95 | *__out_it++ = *__str++; | |
| 96 | return __out_it; | |
| 97 | } | |
| 98 | }; | |
| 99 | ||
| 100 | // Formatter char*. | |
| 101 | template <__formatter::__char_type _CharT> | |
| 102 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 103 | formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> { | |
| 104 | using _Base = formatter<const _CharT*, _CharT>; | |
| 105 | ||
| 106 | _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) | |
| 107 | -> decltype(__ctx.out()) { | |
| 108 | return _Base::format(__str, __ctx); | |
| 109 | } | |
| 110 | }; | |
| 111 | ||
| 112 | // Formatter const char[]. | |
| 113 | template <__formatter::__char_type _CharT, size_t _Size> | |
| 114 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 115 | formatter<const _CharT[_Size], _CharT> | |
| 116 | : public __format_spec::__formatter_string<_CharT> { | |
| 117 | using _Base = __format_spec::__formatter_string<_CharT>; | |
| 118 | ||
| 119 | _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) | |
| 120 | -> decltype(__ctx.out()) { | |
| 121 | return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); | |
| 122 | } | |
| 123 | }; | |
| 124 | ||
| 125 | // Formatter std::string. | |
| 126 | template <__formatter::__char_type _CharT, class _Traits, class _Allocator> | |
| 127 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 128 | formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> | |
| 129 | : public __format_spec::__formatter_string<_CharT> { | |
| 130 | using _Base = __format_spec::__formatter_string<_CharT>; | |
| 131 | ||
| 132 | _LIBCPP_HIDE_FROM_ABI auto | |
| 133 | format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) | |
| 134 | -> decltype(__ctx.out()) { | |
| 135 | // drop _Traits and _Allocator | |
| 136 | return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); | |
| 137 | } | |
| 138 | }; | |
| 139 | ||
| 140 | // Formatter std::string_view. | |
| 141 | template <__formatter::__char_type _CharT, class _Traits> | |
| 142 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT> | |
| 143 | : public __format_spec::__formatter_string<_CharT> { | |
| 144 | using _Base = __format_spec::__formatter_string<_CharT>; | |
| 145 | ||
| 146 | _LIBCPP_HIDE_FROM_ABI auto | |
| 147 | format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) | |
| 148 | -> decltype(__ctx.out()) { | |
| 149 | // drop _Traits | |
| 150 | return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); | |
| 151 | } | |
| 152 | }; | |
| 153 | ||
| 154 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 155 | ||
| 156 | #endif //_LIBCPP_STD_VER > 17 | |
| 157 | ||
| 158 | _LIBCPP_END_NAMESPACE_STD | |
| 159 | ||
| 160 | _LIBCPP_POP_MACROS | |
| 161 | ||
| 162 | #endif // _LIBCPP___FORMAT_FORMATTER_STRING_H |
lib/libcxx/include/__format/parser_std_format_spec.h created+1398| ... | ... | @@ -0,0 +1,1398 @@ |
| 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_PARSER_STD_FORMAT_SPEC_H | |
| 11 | #define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H | |
| 12 | ||
| 13 | #include <__algorithm/find_if.h> | |
| 14 | #include <__algorithm/min.h> | |
| 15 | #include <__config> | |
| 16 | #include <__debug> | |
| 17 | #include <__format/format_arg.h> | |
| 18 | #include <__format/format_error.h> | |
| 19 | #include <__format/format_string.h> | |
| 20 | #include <__variant/monostate.h> | |
| 21 | #include <bit> | |
| 22 | #include <concepts> | |
| 23 | #include <cstdint> | |
| 24 | #include <type_traits> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 | |
| 36 | ||
| 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 | ||
| 43 | namespace __format_spec { | |
| 44 | ||
| 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 | */ | |
| 55 | class _LIBCPP_TYPE_VIS _Flags { | |
| 56 | public: | |
| 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 | ||
| 113 | namespace __detail { | |
| 114 | template <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 | ||
| 134 | template <class _CharT> | |
| 135 | class _LIBCPP_TEMPLATE_VIS __parser_fill_align { | |
| 136 | public: | |
| 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 | ||
| 141 | protected: | |
| 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 | ||
| 164 | template <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 | ||
| 183 | template <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 | ||
| 194 | template <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 | ||
| 205 | template <class _CharT> | |
| 206 | _LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT> | |
| 207 | __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { | |
| 208 | // This function is a wrapper to call the real parser. But it does the | |
| 209 | // validation for the pre-conditions and post-conditions. | |
| 210 | if (__begin == __end) | |
| 211 | __throw_format_error("End of input while parsing format-spec arg-id"); | |
| 212 | ||
| 213 | __format::__parse_number_result __r = | |
| 214 | __format::__parse_arg_id(__begin, __end, __parse_ctx); | |
| 215 | ||
| 216 | if (__r.__ptr == __end || *__r.__ptr != _CharT('}')) | |
| 217 | __throw_format_error("Invalid arg-id"); | |
| 218 | ||
| 219 | ++__r.__ptr; | |
| 220 | return __r; | |
| 221 | } | |
| 222 | ||
| 223 | template <class _Context> | |
| 224 | _LIBCPP_HIDE_FROM_ABI constexpr uint32_t | |
| 225 | __substitute_arg_id(basic_format_arg<_Context> __arg) { | |
| 226 | return visit_format_arg( | |
| 227 | [](auto __arg) -> uint32_t { | |
| 228 | using _Type = decltype(__arg); | |
| 229 | if constexpr (integral<_Type>) { | |
| 230 | if constexpr (signed_integral<_Type>) { | |
| 231 | if (__arg < 0) | |
| 232 | __throw_format_error("A format-spec arg-id replacement shouldn't " | |
| 233 | "have a negative value"); | |
| 234 | } | |
| 235 | ||
| 236 | using _CT = common_type_t<_Type, decltype(__format::__number_max)>; | |
| 237 | if (static_cast<_CT>(__arg) > | |
| 238 | static_cast<_CT>(__format::__number_max)) | |
| 239 | __throw_format_error("A format-spec arg-id replacement exceeds " | |
| 240 | "the maximum supported value"); | |
| 241 | ||
| 242 | return __arg; | |
| 243 | } else if constexpr (same_as<_Type, monostate>) | |
| 244 | __throw_format_error("Argument index out of bounds"); | |
| 245 | else | |
| 246 | __throw_format_error("A format-spec arg-id replacement argument " | |
| 247 | "isn't an integral type"); | |
| 248 | }, | |
| 249 | __arg); | |
| 250 | } | |
| 251 | ||
| 252 | class _LIBCPP_TYPE_VIS __parser_width { | |
| 253 | public: | |
| 254 | /** Contains a width or an arg-id. */ | |
| 255 | uint32_t __width : 31 {0}; | |
| 256 | /** Determines whether the value stored is a width or an arg-id. */ | |
| 257 | uint32_t __width_as_arg : 1 {0}; | |
| 258 | ||
| 259 | protected: | |
| 260 | /** | |
| 261 | * Does the supplied std-format-spec contain a width field? | |
| 262 | * | |
| 263 | * When the field isn't present there's no padding required. This can be used | |
| 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 | } | |
| 293 | ||
| 294 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 295 | return __begin; | |
| 296 | ||
| 297 | __format::__parse_number_result __r = | |
| 298 | __format::__parse_number(__begin, __end); | |
| 299 | __width = __r.__value; | |
| 300 | _LIBCPP_ASSERT(__width != 0, | |
| 301 | "A zero value isn't allowed and should be impossible, " | |
| 302 | "due to validations in this function"); | |
| 303 | return __r.__ptr; | |
| 304 | } | |
| 305 | ||
| 306 | _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_width_arg_id(auto __arg) { | |
| 307 | _LIBCPP_ASSERT(__width_as_arg == 1, | |
| 308 | "Substitute width called when no substitution is required"); | |
| 309 | ||
| 310 | // The clearing of the flag isn't required but looks better when debugging | |
| 311 | // the code. | |
| 312 | __width_as_arg = 0; | |
| 313 | __width = __substitute_arg_id(__arg); | |
| 314 | if (__width == 0) | |
| 315 | __throw_format_error( | |
| 316 | "A format-spec width field replacement should have a positive value"); | |
| 317 | } | |
| 318 | }; | |
| 319 | ||
| 320 | class _LIBCPP_TYPE_VIS __parser_precision { | |
| 321 | public: | |
| 322 | /** Contains a precision or an arg-id. */ | |
| 323 | uint32_t __precision : 31 {__format::__number_max}; | |
| 324 | /** | |
| 325 | * Determines whether the value stored is a precision or an arg-id. | |
| 326 | * | |
| 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 | ||
| 334 | protected: | |
| 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 | } | |
| 346 | ||
| 347 | /** | |
| 348 | * Does the supplied precision field contain an arg-id? | |
| 349 | * | |
| 350 | * If @c true the formatter needs to call @ref __substitute_precision_arg_id. | |
| 351 | */ | |
| 352 | constexpr bool __precision_needs_substitution() const noexcept { | |
| 353 | return __precision_as_arg && __precision != __format::__number_max; | |
| 354 | } | |
| 355 | ||
| 356 | template <class _CharT> | |
| 357 | _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* | |
| 358 | __parse(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { | |
| 359 | if (*__begin != _CharT('.')) | |
| 360 | return __begin; | |
| 361 | ||
| 362 | ++__begin; | |
| 363 | if (__begin == __end) | |
| 364 | __throw_format_error("End of input while parsing format-spec precision"); | |
| 365 | ||
| 366 | if (*__begin == _CharT('{')) { | |
| 367 | __format::__parse_number_result __arg_id = | |
| 368 | __parse_arg_id(++__begin, __end, __parse_ctx); | |
| 369 | _LIBCPP_ASSERT(__arg_id.__value != __format::__number_max, | |
| 370 | "Unsupported number of arguments, since this number of " | |
| 371 | "arguments is used a special value"); | |
| 372 | __precision = __arg_id.__value; | |
| 373 | return __arg_id.__ptr; | |
| 374 | } | |
| 375 | ||
| 376 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 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 | } | |
| 386 | ||
| 387 | _LIBCPP_HIDE_FROM_ABI constexpr void __substitute_precision_arg_id( | |
| 388 | auto __arg) { | |
| 389 | _LIBCPP_ASSERT( | |
| 390 | __precision_as_arg == 1 && __precision != __format::__number_max, | |
| 391 | "Substitute precision called when no substitution is required"); | |
| 392 | ||
| 393 | // The clearing of the flag isn't required but looks better when debugging | |
| 394 | // the code. | |
| 395 | __precision_as_arg = 0; | |
| 396 | __precision = __substitute_arg_id(__arg); | |
| 397 | } | |
| 398 | }; | |
| 399 | ||
| 400 | template <class _CharT> | |
| 401 | _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* | |
| 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 | ||
| 411 | template <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 | */ | |
| 512 | template <class _CharT> | |
| 513 | class _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 | { | |
| 519 | public: | |
| 520 | using char_type = _CharT; | |
| 521 | ||
| 522 | _LIBCPP_HIDE_FROM_ABI constexpr __parser_string() { | |
| 523 | this->__alignment = _Flags::_Alignment::__left; | |
| 524 | } | |
| 525 | ||
| 526 | /** | |
| 527 | * The low-level std-format-spec parse function. | |
| 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 | } | |
| 542 | ||
| 543 | private: | |
| 544 | /** | |
| 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()) { | |
| 554 | ||
| 555 | auto __begin = __parse_ctx.begin(); | |
| 556 | auto __end = __parse_ctx.end(); | |
| 557 | if (__begin == __end) | |
| 558 | return __begin; | |
| 559 | ||
| 560 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, | |
| 561 | static_cast<_Flags&>(*this)); | |
| 562 | if (__begin == __end) | |
| 563 | return __begin; | |
| 564 | ||
| 565 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 566 | if (__begin == __end) | |
| 567 | return __begin; | |
| 568 | ||
| 569 | __begin = __parser_precision::__parse(__begin, __end, __parse_ctx); | |
| 570 | if (__begin == __end) | |
| 571 | return __begin; | |
| 572 | ||
| 573 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 574 | ||
| 575 | if (__begin != __end && *__begin != _CharT('}')) | |
| 576 | __throw_format_error( | |
| 577 | "The format-spec should consume the input or end with a '}'"); | |
| 578 | ||
| 579 | return __begin; | |
| 580 | } | |
| 581 | ||
| 582 | /** Processes the parsed std-format-spec based on the parsed display type. */ | |
| 583 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { | |
| 584 | switch (this->__type) { | |
| 585 | case _Flags::_Type::__default: | |
| 586 | case _Flags::_Type::__string: | |
| 587 | break; | |
| 588 | ||
| 589 | default: | |
| 590 | __throw_format_error("The format-spec type has a type not supported for " | |
| 591 | "a string argument"); | |
| 592 | } | |
| 593 | } | |
| 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 | */ | |
| 604 | template <class _CharT> | |
| 605 | class _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 | { | |
| 610 | public: | |
| 611 | using char_type = _CharT; | |
| 612 | ||
| 613 | protected: | |
| 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; | |
| 630 | ||
| 631 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, | |
| 632 | static_cast<_Flags&>(*this)); | |
| 633 | if (__begin == __end) | |
| 634 | return __begin; | |
| 635 | ||
| 636 | __begin = __parse_sign(__begin, static_cast<_Flags&>(*this)); | |
| 637 | if (__begin == __end) | |
| 638 | return __begin; | |
| 639 | ||
| 640 | __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this)); | |
| 641 | if (__begin == __end) | |
| 642 | return __begin; | |
| 643 | ||
| 644 | __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this)); | |
| 645 | if (__begin == __end) | |
| 646 | return __begin; | |
| 647 | ||
| 648 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 649 | if (__begin == __end) | |
| 650 | return __begin; | |
| 651 | ||
| 652 | __begin = | |
| 653 | __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this)); | |
| 654 | if (__begin == __end) | |
| 655 | return __begin; | |
| 656 | ||
| 657 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 658 | ||
| 659 | if (__begin != __end && *__begin != _CharT('}')) | |
| 660 | __throw_format_error( | |
| 661 | "The format-spec should consume the input or end with a '}'"); | |
| 662 | ||
| 663 | return __begin; | |
| 664 | } | |
| 665 | ||
| 666 | /** Handles the post-parsing updates for the integer types. */ | |
| 667 | _LIBCPP_HIDE_FROM_ABI constexpr void __handle_integer() noexcept { | |
| 668 | __process_arithmetic_alignment(static_cast<_Flags&>(*this)); | |
| 669 | } | |
| 670 | ||
| 671 | /** | |
| 672 | * Handles the post-parsing updates for the character types. | |
| 673 | * | |
| 674 | * Sets the alignment and validates the format flags set for a character type. | |
| 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 | } | |
| 703 | }; | |
| 704 | ||
| 705 | /** | |
| 706 | * The parser for the std-format-spec. | |
| 707 | * | |
| 708 | * This implements the parser for the floating-point types. | |
| 709 | * | |
| 710 | * See @ref __parser_string. | |
| 711 | */ | |
| 712 | template <class _CharT> | |
| 713 | class _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 | { | |
| 719 | public: | |
| 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 | } | |
| 739 | protected: | |
| 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; | |
| 756 | ||
| 757 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, | |
| 758 | static_cast<_Flags&>(*this)); | |
| 759 | if (__begin == __end) | |
| 760 | return __begin; | |
| 761 | ||
| 762 | __begin = __parse_sign(__begin, static_cast<_Flags&>(*this)); | |
| 763 | if (__begin == __end) | |
| 764 | return __begin; | |
| 765 | ||
| 766 | __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this)); | |
| 767 | if (__begin == __end) | |
| 768 | return __begin; | |
| 769 | ||
| 770 | __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this)); | |
| 771 | if (__begin == __end) | |
| 772 | return __begin; | |
| 773 | ||
| 774 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 775 | if (__begin == __end) | |
| 776 | return __begin; | |
| 777 | ||
| 778 | __begin = __parser_precision::__parse(__begin, __end, __parse_ctx); | |
| 779 | if (__begin == __end) | |
| 780 | return __begin; | |
| 781 | ||
| 782 | __begin = | |
| 783 | __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this)); | |
| 784 | if (__begin == __end) | |
| 785 | return __begin; | |
| 786 | ||
| 787 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 788 | ||
| 789 | if (__begin != __end && *__begin != _CharT('}')) | |
| 790 | __throw_format_error( | |
| 791 | "The format-spec should consume the input or end with a '}'"); | |
| 792 | ||
| 793 | return __begin; | |
| 794 | } | |
| 795 | ||
| 796 | /** Processes the parsed std-format-spec based on the parsed display type. */ | |
| 797 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { | |
| 798 | switch (this->__type) { | |
| 799 | case _Flags::_Type::__default: | |
| 800 | // When no precision specified then it keeps default since that | |
| 801 | // formatting differs from the other types. | |
| 802 | if (this->__has_precision_field()) | |
| 803 | this->__type = _Flags::_Type::__general_lower_case; | |
| 804 | break; | |
| 805 | case _Flags::_Type::__float_hexadecimal_lower_case: | |
| 806 | case _Flags::_Type::__float_hexadecimal_upper_case: | |
| 807 | // Precision specific behavior will be handled later. | |
| 808 | break; | |
| 809 | case _Flags::_Type::__scientific_lower_case: | |
| 810 | case _Flags::_Type::__scientific_upper_case: | |
| 811 | case _Flags::_Type::__fixed_lower_case: | |
| 812 | case _Flags::_Type::__fixed_upper_case: | |
| 813 | case _Flags::_Type::__general_lower_case: | |
| 814 | case _Flags::_Type::__general_upper_case: | |
| 815 | if (!this->__has_precision_field()) { | |
| 816 | // Set the default precision for the call to to_chars. | |
| 817 | this->__precision = 6; | |
| 818 | this->__precision_as_arg = false; | |
| 819 | } | |
| 820 | break; | |
| 821 | ||
| 822 | default: | |
| 823 | __throw_format_error("The format-spec type has a type not supported for " | |
| 824 | "a floating-point argument"); | |
| 825 | } | |
| 826 | } | |
| 827 | }; | |
| 828 | ||
| 829 | /** | |
| 830 | * The parser for the std-format-spec. | |
| 831 | * | |
| 832 | * This implements the parser for the pointer types. | |
| 833 | * | |
| 834 | * See @ref __parser_string. | |
| 835 | */ | |
| 836 | template <class _CharT> | |
| 837 | class _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 | { | |
| 841 | public: | |
| 842 | using char_type = _CharT; | |
| 843 | ||
| 844 | _LIBCPP_HIDE_FROM_ABI constexpr __parser_pointer() { | |
| 845 | // Implements LWG3612 Inconsistent pointer alignment in std::format. | |
| 846 | // The issue's current status is "Tentatively Ready" and libc++ status is | |
| 847 | // still experimental. | |
| 848 | // | |
| 849 | // TODO FMT Validate this with the final resolution of LWG3612. | |
| 850 | this->__alignment = _Flags::_Alignment::__right; | |
| 851 | } | |
| 852 | ||
| 853 | /** | |
| 854 | * The low-level std-format-spec parse function. | |
| 855 | * | |
| 856 | * @pre __begin points at the beginning of the std-format-spec. This means | |
| 857 | * directly after the ':'. | |
| 858 | * @pre The std-format-spec parses the entire input, or the first unmatched | |
| 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 | } | |
| 868 | ||
| 869 | protected: | |
| 870 | /** | |
| 871 | * The low-level std-format-spec parse function. | |
| 872 | * | |
| 873 | * @pre __begin points at the beginning of the std-format-spec. This means | |
| 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; | |
| 885 | ||
| 886 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, static_cast<_Flags&>(*this)); | |
| 887 | if (__begin == __end) | |
| 888 | return __begin; | |
| 889 | ||
| 890 | // An integer presentation type isn't defined in the Standard. | |
| 891 | // Since a pointer is formatted as an integer it can be argued it's an | |
| 892 | // integer presentation type. However there are two LWG-issues asserting it | |
| 893 | // isn't an integer presentation type: | |
| 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. | |
| 905 | ||
| 906 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 907 | if (__begin == __end) | |
| 908 | return __begin; | |
| 909 | ||
| 910 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 911 | ||
| 912 | if (__begin != __end && *__begin != _CharT('}')) | |
| 913 | __throw_format_error("The format-spec should consume the input or end with a '}'"); | |
| 914 | ||
| 915 | return __begin; | |
| 916 | } | |
| 917 | ||
| 918 | /** Processes the parsed std-format-spec based on the parsed display type. */ | |
| 919 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type() { | |
| 920 | switch (this->__type) { | |
| 921 | case _Flags::_Type::__default: | |
| 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 | }; | |
| 931 | ||
| 932 | /** Helper struct returned from @ref __get_string_alignment. */ | |
| 933 | template <class _CharT> | |
| 934 | struct _LIBCPP_TEMPLATE_VIS __string_alignment { | |
| 935 | /** Points beyond the last character to write to the output. */ | |
| 936 | const _CharT* __last; | |
| 937 | /** | |
| 938 | * The estimated number of columns in the output or 0. | |
| 939 | * | |
| 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 | }; | |
| 966 | ||
| 967 | #ifndef _LIBCPP_HAS_NO_UNICODE | |
| 968 | namespace __detail { | |
| 969 | ||
| 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 | */ | |
| 1017 | inline constexpr uint32_t __two_column_code_point = 0x1100; | |
| 1018 | ||
| 1019 | /** Helper concept for an UTF-8 character type. */ | |
| 1020 | template <class _CharT> | |
| 1021 | concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>; | |
| 1022 | ||
| 1023 | /** Helper concept for an UTF-16 character type. */ | |
| 1024 | template <class _CharT> | |
| 1025 | concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>; | |
| 1026 | ||
| 1027 | /** Helper concept for an UTF-32 character type. */ | |
| 1028 | template <class _CharT> | |
| 1029 | concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>; | |
| 1030 | ||
| 1031 | /** Helper concept for an UTF-16 or UTF-32 character type. */ | |
| 1032 | template <class _CharT> | |
| 1033 | concept __utf16_or_32_character = __utf16_character<_CharT> || __utf32_character<_CharT>; | |
| 1034 | ||
| 1035 | /** | |
| 1036 | * Converts a code point to the column width. | |
| 1037 | * | |
| 1038 | * The estimations are conforming to [format.string.general]/11 | |
| 1039 | * | |
| 1040 | * This version expects a value less than 0x1'0000, which is a 3-byte UTF-8 | |
| 1041 | * character. | |
| 1042 | */ | |
| 1043 | _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexcept { | |
| 1044 | _LIBCPP_ASSERT(__c < 0x1'0000, | |
| 1045 | "Use __column_width_4 or __column_width for larger values"); | |
| 1046 | ||
| 1047 | // clang-format off | |
| 1048 | return 1 + (__c >= 0x1100 && (__c <= 0x115f || | |
| 1049 | (__c >= 0x2329 && (__c <= 0x232a || | |
| 1050 | (__c >= 0x2e80 && (__c <= 0x303e || | |
| 1051 | (__c >= 0x3040 && (__c <= 0xa4cf || | |
| 1052 | (__c >= 0xac00 && (__c <= 0xd7a3 || | |
| 1053 | (__c >= 0xf900 && (__c <= 0xfaff || | |
| 1054 | (__c >= 0xfe10 && (__c <= 0xfe19 || | |
| 1055 | (__c >= 0xfe30 && (__c <= 0xfe6f || | |
| 1056 | (__c >= 0xff00 && (__c <= 0xff60 || | |
| 1057 | (__c >= 0xffe0 && (__c <= 0xffe6 | |
| 1058 | )))))))))))))))))))); | |
| 1059 | // clang-format on | |
| 1060 | } | |
| 1061 | ||
| 1062 | /** | |
| 1063 | * @overload | |
| 1064 | * | |
| 1065 | * This version expects a value greater than or equal to 0x1'0000, which is a | |
| 1066 | * 4-byte UTF-8 character. | |
| 1067 | */ | |
| 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"); | |
| 1071 | ||
| 1072 | // clang-format off | |
| 1073 | return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f || | |
| 1074 | (__c >= 0x1'f900 && (__c <= 0x1'f9ff || | |
| 1075 | (__c >= 0x2'0000 && (__c <= 0x2'fffd || | |
| 1076 | (__c >= 0x3'0000 && (__c <= 0x3'fffd | |
| 1077 | )))))))); | |
| 1078 | // clang-format on | |
| 1079 | } | |
| 1080 | ||
| 1081 | /** | |
| 1082 | * @overload | |
| 1083 | * | |
| 1084 | * The general case, accepting all values. | |
| 1085 | */ | |
| 1086 | _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width(uint32_t __c) noexcept { | |
| 1087 | if (__c < 0x1'0000) | |
| 1088 | return __column_width_3(__c); | |
| 1089 | ||
| 1090 | return __column_width_4(__c); | |
| 1091 | } | |
| 1092 | ||
| 1093 | /** | |
| 1094 | * Estimate the column width for the UTF-8 sequence using the fast algorithm. | |
| 1095 | */ | |
| 1096 | template <__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 | */ | |
| 1109 | template <__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 | } | |
| 1116 | ||
| 1117 | template <class _CharT> | |
| 1118 | struct _LIBCPP_TEMPLATE_VIS __column_width_result { | |
| 1119 | /** The number of output columns. */ | |
| 1120 | size_t __width; | |
| 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 | */ | |
| 1136 | template <__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 | } | |
| 1144 | ||
| 1145 | /** | |
| 1146 | * Determines the number of output columns needed to render the input. | |
| 1147 | * | |
| 1148 | * @note When the scanner encounters malformed Unicode it acts as-if every code | |
| 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 | */ | |
| 1158 | template <__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; | |
| 1173 | ||
| 1174 | case 2: // 2-code unit encoding: all 1 column | |
| 1175 | // Malformed Unicode. | |
| 1176 | if (__last - __first < 2) [[unlikely]] | |
| 1177 | return __estimate_column_width_malformed(__first, __last, __maximum, | |
| 1178 | __result); | |
| 1179 | __first += 2; | |
| 1180 | ++__result; | |
| 1181 | break; | |
| 1182 | ||
| 1183 | case 3: // 3-code unit encoding: either 1 or 2 columns | |
| 1184 | // Malformed Unicode. | |
| 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 | } | |
| 1226 | return {__result, __first}; | |
| 1227 | } | |
| 1228 | ||
| 1229 | template <__utf16_character _CharT> | |
| 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 | ||
| 1267 | template <__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 | } | |
| 1287 | ||
| 1288 | } // namespace __detail | |
| 1289 | ||
| 1290 | template <class _CharT> | |
| 1291 | _LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT> | |
| 1292 | __get_string_alignment(const _CharT* __first, const _CharT* __last, | |
| 1293 | ptrdiff_t __width, ptrdiff_t __precision) noexcept { | |
| 1294 | _LIBCPP_ASSERT(__width != 0 || __precision != -1, | |
| 1295 | "The function has no effect and shouldn't be used"); | |
| 1296 | ||
| 1297 | // TODO FMT There might be more optimizations possible: | |
| 1298 | // If __precision == __format::__number_max and the encoding is: | |
| 1299 | // * UTF-8 : 4 * (__last - __first) >= __width | |
| 1300 | // * UTF-16 : 2 * (__last - __first) >= __width | |
| 1301 | // * UTF-32 : (__last - __first) >= __width | |
| 1302 | // In these cases it's certain the output is at least the requested width. | |
| 1303 | // It's unknown how often this happens in practice. For now the improvement | |
| 1304 | // isn't implemented. | |
| 1305 | ||
| 1306 | /* | |
| 1307 | * First assume there are no special Unicode code units in the input. | |
| 1308 | * - Apply the precision (this may reduce the size of the input). When | |
| 1309 | * __precison == -1 this step is omitted. | |
| 1310 | * - Scan for special code units in the input. | |
| 1311 | * If our assumption was correct the __pos will be at the end of the input. | |
| 1312 | */ | |
| 1313 | const ptrdiff_t __length = __last - __first; | |
| 1314 | const _CharT* __limit = | |
| 1315 | __first + | |
| 1316 | (__precision == -1 ? __length : _VSTD::min(__length, __precision)); | |
| 1317 | ptrdiff_t __size = __limit - __first; | |
| 1318 | const _CharT* __pos = | |
| 1319 | __detail::__estimate_column_width_fast(__first, __limit); | |
| 1320 | ||
| 1321 | if (__pos == __limit) | |
| 1322 | return {__limit, __size, __size < __width}; | |
| 1323 | ||
| 1324 | /* | |
| 1325 | * Our assumption was wrong, there are special Unicode code units. | |
| 1326 | * The range [__first, __pos) contains a set of code units with the | |
| 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 | } | |
| 1345 | ||
| 1346 | /* Else use __width to determine the number of required padding characters. */ | |
| 1347 | _LIBCPP_ASSERT(__width > __prefix, "Logic error."); | |
| 1348 | /* | |
| 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 | } | |
| 1370 | ||
| 1371 | __size = __lengh_info.__width + __prefix; | |
| 1372 | return {__last, __size, __size < __width}; | |
| 1373 | } | |
| 1374 | #else // _LIBCPP_HAS_NO_UNICODE | |
| 1375 | template <class _CharT> | |
| 1376 | _LIBCPP_HIDE_FROM_ABI constexpr __string_alignment<_CharT> | |
| 1377 | __get_string_alignment(const _CharT* __first, const _CharT* __last, | |
| 1378 | ptrdiff_t __width, ptrdiff_t __precision) noexcept { | |
| 1379 | const ptrdiff_t __length = __last - __first; | |
| 1380 | const _CharT* __limit = | |
| 1381 | __first + | |
| 1382 | (__precision == -1 ? __length : _VSTD::min(__length, __precision)); | |
| 1383 | ptrdiff_t __size = __limit - __first; | |
| 1384 | return {__limit, __size, __size < __width}; | |
| 1385 | } | |
| 1386 | #endif // _LIBCPP_HAS_NO_UNICODE | |
| 1387 | ||
| 1388 | } // namespace __format_spec | |
| 1389 | ||
| 1390 | # endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1391 | ||
| 1392 | #endif //_LIBCPP_STD_VER > 17 | |
| 1393 | ||
| 1394 | _LIBCPP_END_NAMESPACE_STD | |
| 1395 | ||
| 1396 | _LIBCPP_POP_MACROS | |
| 1397 | ||
| 1398 | #endif // _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H |
lib/libcxx/include/__function_like.h deleted-56| ... | ... | @@ -1,56 +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___ITERATOR_FUNCTION_LIKE_H | |
| 11 | #define _LIBCPP___ITERATOR_FUNCTION_LIKE_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_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 25 | ||
| 26 | namespace ranges { | |
| 27 | // Per [range.iter.ops.general] and [algorithms.requirements], functions in namespace std::ranges | |
| 28 | // can't be found by ADL and inhibit ADL when found by unqualified lookup. The easiest way to | |
| 29 | // facilitate this is to use function objects. | |
| 30 | // | |
| 31 | // Since these are still standard library functions, we use `__function_like` to eliminate most of | |
| 32 | // the properties that function objects get by default (e.g. semiregularity, addressability), to | |
| 33 | // limit the surface area of the unintended public interface, so as to curb the effect of Hyrum's | |
| 34 | // law. | |
| 35 | struct __function_like { | |
| 36 | __function_like() = delete; | |
| 37 | __function_like(__function_like const&) = delete; | |
| 38 | __function_like& operator=(__function_like const&) = delete; | |
| 39 | ||
| 40 | void operator&() const = delete; | |
| 41 | ||
| 42 | struct __tag { }; | |
| 43 | ||
| 44 | protected: | |
| 45 | constexpr explicit __function_like(__tag) noexcept {} | |
| 46 | ~__function_like() = default; | |
| 47 | }; | |
| 48 | } // namespace ranges | |
| 49 | ||
| 50 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | #endif // _LIBCPP___ITERATOR_FUNCTION_LIKE_H |
lib/libcxx/include/__functional/bind.h+30-24| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_BIND_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/weak_result_type.h> | |
| 15 | 14 | #include <__functional/invoke.h> |
| 15 | #include <__functional/weak_result_type.h> | |
| 16 | 16 | #include <cstddef> |
| 17 | 17 | #include <tuple> |
| 18 | 18 | #include <type_traits> |
| ... | ... | @@ -23,22 +23,28 @@ |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | template<class _Tp> struct __is_bind_expression : public false_type {}; | |
| 27 | template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_bind_expression | |
| 28 | : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; | |
| 26 | template<class _Tp> | |
| 27 | struct is_bind_expression : _If< | |
| 28 | _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, | |
| 29 | false_type, | |
| 30 | is_bind_expression<typename __uncvref<_Tp>::type> | |
| 31 | > {}; | |
| 29 | 32 | |
| 30 | 33 | #if _LIBCPP_STD_VER > 14 |
| 31 | 34 | template <class _Tp> |
| 32 | _LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; | |
| 35 | inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; | |
| 33 | 36 | #endif |
| 34 | 37 | |
| 35 | template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; | |
| 36 | template<class _Tp> struct _LIBCPP_TEMPLATE_VIS is_placeholder | |
| 37 | : public __is_placeholder<typename remove_cv<_Tp>::type> {}; | |
| 38 | template<class _Tp> | |
| 39 | struct is_placeholder : _If< | |
| 40 | _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, | |
| 41 | integral_constant<int, 0>, | |
| 42 | is_placeholder<typename __uncvref<_Tp>::type> | |
| 43 | > {}; | |
| 38 | 44 | |
| 39 | 45 | #if _LIBCPP_STD_VER > 14 |
| 40 | 46 | template <class _Tp> |
| 41 | _LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; | |
| 47 | inline constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; | |
| 42 | 48 | #endif |
| 43 | 49 | |
| 44 | 50 | namespace placeholders |
| ... | ... | @@ -58,22 +64,22 @@ _LIBCPP_FUNC_VIS extern const __ph<8> _8; |
| 58 | 64 | _LIBCPP_FUNC_VIS extern const __ph<9> _9; |
| 59 | 65 | _LIBCPP_FUNC_VIS extern const __ph<10> _10; |
| 60 | 66 | #else |
| 61 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{}; | |
| 62 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{}; | |
| 63 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{}; | |
| 64 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{}; | |
| 65 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{}; | |
| 66 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{}; | |
| 67 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{}; | |
| 68 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{}; | |
| 69 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{}; | |
| 70 | /* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{}; | |
| 67 | /* inline */ constexpr __ph<1> _1{}; | |
| 68 | /* inline */ constexpr __ph<2> _2{}; | |
| 69 | /* inline */ constexpr __ph<3> _3{}; | |
| 70 | /* inline */ constexpr __ph<4> _4{}; | |
| 71 | /* inline */ constexpr __ph<5> _5{}; | |
| 72 | /* inline */ constexpr __ph<6> _6{}; | |
| 73 | /* inline */ constexpr __ph<7> _7{}; | |
| 74 | /* inline */ constexpr __ph<8> _8{}; | |
| 75 | /* inline */ constexpr __ph<9> _9{}; | |
| 76 | /* inline */ constexpr __ph<10> _10{}; | |
| 71 | 77 | #endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) |
| 72 | 78 | |
| 73 | } // placeholders | |
| 79 | } // namespace placeholders | |
| 74 | 80 | |
| 75 | 81 | template<int _Np> |
| 76 | struct __is_placeholder<placeholders::__ph<_Np> > | |
| 82 | struct is_placeholder<placeholders::__ph<_Np> > | |
| 77 | 83 | : public integral_constant<int, _Np> {}; |
| 78 | 84 | |
| 79 | 85 | |
| ... | ... | @@ -97,7 +103,7 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) |
| 97 | 103 | |
| 98 | 104 | template <class _Ti, class ..._Uj> |
| 99 | 105 | inline _LIBCPP_INLINE_VISIBILITY |
| 100 | typename _EnableIf | |
| 106 | typename __enable_if_t | |
| 101 | 107 | < |
| 102 | 108 | is_bind_expression<_Ti>::value, |
| 103 | 109 | __invoke_of<_Ti&, _Uj...> |
| ... | ... | @@ -304,7 +310,7 @@ public: |
| 304 | 310 | }; |
| 305 | 311 | |
| 306 | 312 | template<class _Fp, class ..._BoundArgs> |
| 307 | struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; | |
| 313 | struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; | |
| 308 | 314 | |
| 309 | 315 | template<class _Rp, class _Fp, class ..._BoundArgs> |
| 310 | 316 | class __bind_r |
| ... | ... | @@ -359,7 +365,7 @@ public: |
| 359 | 365 | }; |
| 360 | 366 | |
| 361 | 367 | template<class _Rp, class _Fp, class ..._BoundArgs> |
| 362 | struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; | |
| 368 | struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; | |
| 363 | 369 | |
| 364 | 370 | template<class _Fp, class ..._BoundArgs> |
| 365 | 371 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
lib/libcxx/include/__functional/bind_back.h created+65| ... | ... | @@ -0,0 +1,65 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FUNCTIONAL_BIND_BACK_H | |
| 11 | #define _LIBCPP___FUNCTIONAL_BIND_BACK_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/perfect_forward.h> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <__utility/integer_sequence.h> | |
| 18 | #include <tuple> | |
| 19 | #include <type_traits> | |
| 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 | ||
| 29 | template <size_t _NBound, class = make_index_sequence<_NBound>> | |
| 30 | struct __bind_back_op; | |
| 31 | ||
| 32 | template <size_t _NBound, size_t ..._Ip> | |
| 33 | struct __bind_back_op<_NBound, index_sequence<_Ip...>> { | |
| 34 | template <class _Fn, class _Bound, class ..._Args> | |
| 35 | _LIBCPP_HIDE_FROM_ABI | |
| 36 | constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const | |
| 37 | noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))) | |
| 38 | -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)) | |
| 39 | { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); } | |
| 40 | }; | |
| 41 | ||
| 42 | template <class _Fn, class _BoundArgs> | |
| 43 | struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs> { | |
| 44 | using __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs>::__perfect_forward; | |
| 45 | }; | |
| 46 | ||
| 47 | template <class _Fn, class ..._Args, class = enable_if_t< | |
| 48 | _And< | |
| 49 | is_constructible<decay_t<_Fn>, _Fn>, | |
| 50 | is_move_constructible<decay_t<_Fn>>, | |
| 51 | is_constructible<decay_t<_Args>, _Args>..., | |
| 52 | is_move_constructible<decay_t<_Args>>... | |
| 53 | >::value | |
| 54 | >> | |
| 55 | _LIBCPP_HIDE_FROM_ABI | |
| 56 | constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) | |
| 57 | noexcept(noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)))) | |
| 58 | -> decltype( __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))) | |
| 59 | { return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); } | |
| 60 | ||
| 61 | #endif // _LIBCPP_STD_VER > 17 | |
| 62 | ||
| 63 | _LIBCPP_END_NAMESPACE_STD | |
| 64 | ||
| 65 | #endif // _LIBCPP___FUNCTIONAL_BIND_BACK_H |
lib/libcxx/include/__functional/bind_front.h+24-18| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_BIND_FRONT_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/perfect_forward.h> | |
| 15 | 14 | #include <__functional/invoke.h> |
| 15 | #include <__functional/perfect_forward.h> | |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | #include <utility> |
| 18 | 18 | |
| ... | ... | @@ -24,25 +24,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | #if _LIBCPP_STD_VER > 17 |
| 26 | 26 | |
| 27 | struct __bind_front_op | |
| 28 | { | |
| 29 | template<class... _Args> | |
| 30 | constexpr static auto __call(_Args&&... __args) | |
| 31 | noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) | |
| 32 | -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) | |
| 33 | { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } | |
| 27 | struct __bind_front_op { | |
| 28 | template <class ..._Args> | |
| 29 | _LIBCPP_HIDE_FROM_ABI | |
| 30 | constexpr auto operator()(_Args&& ...__args) const | |
| 31 | noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) | |
| 32 | -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) | |
| 33 | { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } | |
| 34 | }; | |
| 35 | ||
| 36 | template <class _Fn, class ..._BoundArgs> | |
| 37 | struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> { | |
| 38 | using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward; | |
| 34 | 39 | }; |
| 35 | 40 | |
| 36 | template<class _Fn, class... _Args, | |
| 37 | class = _EnableIf<conjunction<is_constructible<decay_t<_Fn>, _Fn>, | |
| 38 | is_move_constructible<decay_t<_Fn>>, | |
| 39 | is_constructible<decay_t<_Args>, _Args>..., | |
| 40 | is_move_constructible<decay_t<_Args>>... | |
| 41 | >::value>> | |
| 42 | constexpr auto bind_front(_Fn&& __f, _Args&&... __args) | |
| 43 | { | |
| 44 | return __perfect_forward<__bind_front_op, _Fn, _Args...>(_VSTD::forward<_Fn>(__f), | |
| 45 | _VSTD::forward<_Args>(__args)...); | |
| 41 | template <class _Fn, class... _Args, class = enable_if_t< | |
| 42 | _And< | |
| 43 | is_constructible<decay_t<_Fn>, _Fn>, | |
| 44 | is_move_constructible<decay_t<_Fn>>, | |
| 45 | is_constructible<decay_t<_Args>, _Args>..., | |
| 46 | is_move_constructible<decay_t<_Args>>... | |
| 47 | >::value | |
| 48 | >> | |
| 49 | _LIBCPP_HIDE_FROM_ABI | |
| 50 | constexpr auto bind_front(_Fn&& __f, _Args&&... __args) { | |
| 51 | return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); | |
| 46 | 52 | } |
| 47 | 53 | |
| 48 | 54 | #endif // _LIBCPP_STD_VER > 17 |
lib/libcxx/include/__functional/compose.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___FUNCTIONAL_COMPOSE_H | |
| 11 | #define _LIBCPP___FUNCTIONAL_COMPOSE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/perfect_forward.h> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <type_traits> | |
| 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 | struct __compose_op { | |
| 28 | template<class _Fn1, class _Fn2, class ..._Args> | |
| 29 | _LIBCPP_HIDE_FROM_ABI | |
| 30 | constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const | |
| 31 | noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)))) | |
| 32 | -> decltype( _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...))) | |
| 33 | { return _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)); } | |
| 34 | }; | |
| 35 | ||
| 36 | template <class _Fn1, class _Fn2> | |
| 37 | struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> { | |
| 38 | using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward; | |
| 39 | }; | |
| 40 | ||
| 41 | template <class _Fn1, class _Fn2> | |
| 42 | _LIBCPP_HIDE_FROM_ABI | |
| 43 | constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) | |
| 44 | noexcept(noexcept(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)))) | |
| 45 | -> decltype( __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2))) | |
| 46 | { return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)); } | |
| 47 | ||
| 48 | #endif // _LIBCPP_STD_VER > 17 | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___FUNCTIONAL_COMPOSE_H |
lib/libcxx/include/__functional/function.h+31-30| ... | ... | @@ -11,10 +11,12 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_FUNCTION_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__debug> | |
| 14 | 15 | #include <__functional/binary_function.h> |
| 15 | 16 | #include <__functional/invoke.h> |
| 16 | 17 | #include <__functional/unary_function.h> |
| 17 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__memory/addressof.h> | |
| 18 | 20 | #include <__memory/allocator_traits.h> |
| 19 | 21 | #include <__memory/compressed_pair.h> |
| 20 | 22 | #include <__memory/shared_ptr.h> |
| ... | ... | @@ -34,10 +36,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 36 | class _LIBCPP_EXCEPTION_ABI bad_function_call |
| 35 | 37 | : public exception |
| 36 | 38 | { |
| 37 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 38 | 39 | public: |
| 40 | // Note that when a key function is not used, every translation unit that uses | |
| 41 | // bad_function_call will end up containing a weak definition of the vtable and | |
| 42 | // typeinfo. | |
| 43 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 39 | 44 | virtual ~bad_function_call() _NOEXCEPT; |
| 45 | #else | |
| 46 | virtual ~bad_function_call() _NOEXCEPT {} | |
| 47 | #endif | |
| 40 | 48 | |
| 49 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | |
| 41 | 50 | virtual const char* what() const _NOEXCEPT; |
| 42 | 51 | #endif |
| 43 | 52 | }; |
| ... | ... | @@ -126,8 +135,8 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> |
| 126 | 135 | __compressed_pair<_Fp, _Ap> __f_; |
| 127 | 136 | |
| 128 | 137 | public: |
| 129 | typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; | |
| 130 | typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc; | |
| 138 | typedef _LIBCPP_NODEBUG _Fp _Target; | |
| 139 | typedef _LIBCPP_NODEBUG _Ap _Alloc; | |
| 131 | 140 | |
| 132 | 141 | _LIBCPP_INLINE_VISIBILITY |
| 133 | 142 | const _Target& __target() const { return __f_.first(); } |
| ... | ... | @@ -204,7 +213,7 @@ class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> { |
| 204 | 213 | _Fp __f_; |
| 205 | 214 | |
| 206 | 215 | public: |
| 207 | typedef _LIBCPP_NODEBUG_TYPE _Fp _Target; | |
| 216 | typedef _LIBCPP_NODEBUG _Fp _Target; | |
| 208 | 217 | |
| 209 | 218 | _LIBCPP_INLINE_VISIBILITY |
| 210 | 219 | const _Target& __target() const { return __f_; } |
| ... | ... | @@ -352,7 +361,7 @@ const void* |
| 352 | 361 | __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT |
| 353 | 362 | { |
| 354 | 363 | if (__ti == typeid(_Fp)) |
| 355 | return &__f_.__target(); | |
| 364 | return _VSTD::addressof(__f_.__target()); | |
| 356 | 365 | return nullptr; |
| 357 | 366 | } |
| 358 | 367 | |
| ... | ... | @@ -938,7 +947,7 @@ public: |
| 938 | 947 | |
| 939 | 948 | #endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC |
| 940 | 949 | |
| 941 | } // __function | |
| 950 | } // namespace __function | |
| 942 | 951 | |
| 943 | 952 | template<class _Rp, class ..._ArgTypes> |
| 944 | 953 | class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
| ... | ... | @@ -1044,7 +1053,7 @@ public: |
| 1044 | 1053 | #endif // _LIBCPP_NO_RTTI |
| 1045 | 1054 | }; |
| 1046 | 1055 | |
| 1047 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1056 | #if _LIBCPP_STD_VER >= 17 | |
| 1048 | 1057 | template<class _Rp, class ..._Ap> |
| 1049 | 1058 | function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>; |
| 1050 | 1059 | |
| ... | ... | @@ -1089,7 +1098,7 @@ struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { usin |
| 1089 | 1098 | |
| 1090 | 1099 | template<class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type> |
| 1091 | 1100 | function(_Fp) -> function<_Stripped>; |
| 1092 | #endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1101 | #endif // _LIBCPP_STD_VER >= 17 | |
| 1093 | 1102 | |
| 1094 | 1103 | template<class _Rp, class ..._ArgTypes> |
| 1095 | 1104 | function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {} |
| ... | ... | @@ -1384,7 +1393,7 @@ const void* |
| 1384 | 1393 | __func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const |
| 1385 | 1394 | { |
| 1386 | 1395 | if (__ti == typeid(_Fp)) |
| 1387 | return &__f_.first(); | |
| 1396 | return _VSTD::addressof(__f_.first()); | |
| 1388 | 1397 | return (const void*)0; |
| 1389 | 1398 | } |
| 1390 | 1399 | |
| ... | ... | @@ -1655,7 +1664,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const |
| 1655 | 1664 | |
| 1656 | 1665 | #endif // _LIBCPP_NO_RTTI |
| 1657 | 1666 | |
| 1658 | } // __function | |
| 1667 | } // namespace __function | |
| 1659 | 1668 | |
| 1660 | 1669 | template<class _Rp> |
| 1661 | 1670 | class _LIBCPP_TEMPLATE_VIS function<_Rp()> |
| ... | ... | @@ -1709,13 +1718,11 @@ public: |
| 1709 | 1718 | // 20.7.16.2.3, function capacity: |
| 1710 | 1719 | _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} |
| 1711 | 1720 | |
| 1712 | private: | |
| 1713 | // deleted overloads close possible hole in the type system | |
| 1714 | 1721 | template<class _R2> |
| 1715 | bool operator==(const function<_R2()>&) const;// = delete; | |
| 1722 | bool operator==(const function<_R2()>&) const = delete; | |
| 1716 | 1723 | template<class _R2> |
| 1717 | bool operator!=(const function<_R2()>&) const;// = delete; | |
| 1718 | public: | |
| 1724 | bool operator!=(const function<_R2()>&) const = delete; | |
| 1725 | ||
| 1719 | 1726 | // 20.7.16.2.4, function invocation: |
| 1720 | 1727 | _Rp operator()() const; |
| 1721 | 1728 | |
| ... | ... | @@ -1989,13 +1996,11 @@ public: |
| 1989 | 1996 | // 20.7.16.2.3, function capacity: |
| 1990 | 1997 | _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} |
| 1991 | 1998 | |
| 1992 | private: | |
| 1993 | // deleted overloads close possible hole in the type system | |
| 1994 | 1999 | template<class _R2, class _B0> |
| 1995 | bool operator==(const function<_R2(_B0)>&) const;// = delete; | |
| 2000 | bool operator==(const function<_R2(_B0)>&) const = delete; | |
| 1996 | 2001 | template<class _R2, class _B0> |
| 1997 | bool operator!=(const function<_R2(_B0)>&) const;// = delete; | |
| 1998 | public: | |
| 2002 | bool operator!=(const function<_R2(_B0)>&) const = delete; | |
| 2003 | ||
| 1999 | 2004 | // 20.7.16.2.4, function invocation: |
| 2000 | 2005 | _Rp operator()(_A0) const; |
| 2001 | 2006 | |
| ... | ... | @@ -2269,13 +2274,11 @@ public: |
| 2269 | 2274 | // 20.7.16.2.3, function capacity: |
| 2270 | 2275 | _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} |
| 2271 | 2276 | |
| 2272 | private: | |
| 2273 | // deleted overloads close possible hole in the type system | |
| 2274 | 2277 | template<class _R2, class _B0, class _B1> |
| 2275 | bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete; | |
| 2278 | bool operator==(const function<_R2(_B0, _B1)>&) const = delete; | |
| 2276 | 2279 | template<class _R2, class _B0, class _B1> |
| 2277 | bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete; | |
| 2278 | public: | |
| 2280 | bool operator!=(const function<_R2(_B0, _B1)>&) const = delete; | |
| 2281 | ||
| 2279 | 2282 | // 20.7.16.2.4, function invocation: |
| 2280 | 2283 | _Rp operator()(_A0, _A1) const; |
| 2281 | 2284 | |
| ... | ... | @@ -2548,13 +2551,11 @@ public: |
| 2548 | 2551 | // 20.7.16.2.3, function capacity: |
| 2549 | 2552 | _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} |
| 2550 | 2553 | |
| 2551 | private: | |
| 2552 | // deleted overloads close possible hole in the type system | |
| 2553 | 2554 | template<class _R2, class _B0, class _B1, class _B2> |
| 2554 | bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; | |
| 2555 | bool operator==(const function<_R2(_B0, _B1, _B2)>&) const = delete; | |
| 2555 | 2556 | template<class _R2, class _B0, class _B1, class _B2> |
| 2556 | bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; | |
| 2557 | public: | |
| 2557 | bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const = delete; | |
| 2558 | ||
| 2558 | 2559 | // 20.7.16.2.4, function invocation: |
| 2559 | 2560 | _Rp operator()(_A0, _A1, _A2) const; |
| 2560 | 2561 |
lib/libcxx/include/__functional/hash.h+8-11| ... | ... | @@ -16,9 +16,9 @@ |
| 16 | 16 | #include <__utility/move.h> |
| 17 | 17 | #include <__utility/pair.h> |
| 18 | 18 | #include <__utility/swap.h> |
| 19 | #include <cstddef> | |
| 19 | 20 | #include <cstdint> |
| 20 | 21 | #include <cstring> |
| 21 | #include <cstddef> | |
| 22 | 22 | #include <limits> |
| 23 | 23 | #include <type_traits> |
| 24 | 24 | |
| ... | ... | @@ -26,9 +26,6 @@ |
| 26 | 26 | #pragma GCC system_header |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | _LIBCPP_PUSH_MACROS | |
| 30 | #include <__undef_macros> | |
| 31 | ||
| 32 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 30 | |
| 34 | 31 | template <class _Size> |
| ... | ... | @@ -564,6 +561,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 564 | 561 | |
| 565 | 562 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS |
| 566 | 563 | |
| 564 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 567 | 565 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 568 | 566 | template <> |
| 569 | 567 | struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> |
| ... | ... | @@ -579,6 +577,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 579 | 577 | _LIBCPP_INLINE_VISIBILITY |
| 580 | 578 | size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 581 | 579 | }; |
| 580 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 582 | 581 | |
| 583 | 582 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 584 | 583 | template <> |
| ... | ... | @@ -839,35 +838,33 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 839 | 838 | |
| 840 | 839 | #ifndef _LIBCPP_CXX03_LANG |
| 841 | 840 | template <class _Key, class _Hash> |
| 842 | using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant<bool, | |
| 841 | using __check_hash_requirements _LIBCPP_NODEBUG = integral_constant<bool, | |
| 843 | 842 | is_copy_constructible<_Hash>::value && |
| 844 | 843 | is_move_constructible<_Hash>::value && |
| 845 | 844 | __invokable_r<size_t, _Hash, _Key const&>::value |
| 846 | 845 | >; |
| 847 | 846 | |
| 848 | 847 | template <class _Key, class _Hash = hash<_Key> > |
| 849 | using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant<bool, | |
| 848 | using __has_enabled_hash _LIBCPP_NODEBUG = integral_constant<bool, | |
| 850 | 849 | __check_hash_requirements<_Key, _Hash>::value && |
| 851 | 850 | is_default_constructible<_Hash>::value |
| 852 | 851 | >; |
| 853 | 852 | |
| 854 | 853 | #if _LIBCPP_STD_VER > 14 |
| 855 | 854 | template <class _Type, class> |
| 856 | using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type; | |
| 855 | using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; | |
| 857 | 856 | |
| 858 | 857 | template <class _Type, class ..._Keys> |
| 859 | using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type, | |
| 858 | using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type, | |
| 860 | 859 | typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type |
| 861 | 860 | >; |
| 862 | 861 | #else |
| 863 | 862 | template <class _Type, class ...> |
| 864 | using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type; | |
| 863 | using __enable_hash_helper _LIBCPP_NODEBUG = _Type; | |
| 865 | 864 | #endif |
| 866 | 865 | |
| 867 | 866 | #endif // !_LIBCPP_CXX03_LANG |
| 868 | 867 | |
| 869 | 868 | _LIBCPP_END_NAMESPACE_STD |
| 870 | 869 | |
| 871 | _LIBCPP_POP_MACROS | |
| 872 | ||
| 873 | 870 | #endif // _LIBCPP___FUNCTIONAL_HASH_H |
lib/libcxx/include/__functional/mem_fn.h+1-1| ... | ... | @@ -11,9 +11,9 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_MEM_FN_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/weak_result_type.h> | |
| 15 | 14 | #include <__functional/binary_function.h> |
| 16 | 15 | #include <__functional/invoke.h> |
| 16 | #include <__functional/weak_result_type.h> | |
| 17 | 17 | #include <utility> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/__functional/mem_fun_ref.h+1-1| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/unary_function.h> | |
| 15 | 14 | #include <__functional/binary_function.h> |
| 15 | #include <__functional/unary_function.h> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 18 | #pragma GCC system_header |
lib/libcxx/include/__functional/not_fn.h+20-14| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_NOT_FN_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/perfect_forward.h> | |
| 15 | 14 | #include <__functional/invoke.h> |
| 15 | #include <__functional/perfect_forward.h> | |
| 16 | 16 | #include <utility> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -23,21 +23,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | #if _LIBCPP_STD_VER > 14 |
| 25 | 25 | |
| 26 | struct __not_fn_op | |
| 27 | { | |
| 28 | template<class... _Args> | |
| 29 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 auto __call(_Args&&... __args) | |
| 30 | noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) | |
| 31 | -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) | |
| 32 | { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } | |
| 26 | struct __not_fn_op { | |
| 27 | template <class... _Args> | |
| 28 | _LIBCPP_HIDE_FROM_ABI | |
| 29 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto operator()(_Args&&... __args) const | |
| 30 | noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) | |
| 31 | -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) | |
| 32 | { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } | |
| 33 | }; | |
| 34 | ||
| 35 | template <class _Fn> | |
| 36 | struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> { | |
| 37 | using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward; | |
| 33 | 38 | }; |
| 34 | 39 | |
| 35 | template<class _Fn, | |
| 36 | class = _EnableIf<is_constructible_v<decay_t<_Fn>, _Fn> && | |
| 37 | is_move_constructible_v<_Fn>>> | |
| 38 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) | |
| 39 | { | |
| 40 | return __perfect_forward<__not_fn_op, _Fn>(_VSTD::forward<_Fn>(__f)); | |
| 40 | template <class _Fn, class = enable_if_t< | |
| 41 | is_constructible_v<decay_t<_Fn>, _Fn> && | |
| 42 | is_move_constructible_v<decay_t<_Fn>> | |
| 43 | >> | |
| 44 | _LIBCPP_HIDE_FROM_ABI | |
| 45 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) { | |
| 46 | return __not_fn_t<decay_t<_Fn>>(_VSTD::forward<_Fn>(__f)); | |
| 41 | 47 | } |
| 42 | 48 | |
| 43 | 49 | #endif // _LIBCPP_STD_VER > 14 |
lib/libcxx/include/__functional/operations.h+57-57| ... | ... | @@ -53,9 +53,9 @@ struct _LIBCPP_TEMPLATE_VIS plus<void> |
| 53 | 53 | template <class _T1, class _T2> |
| 54 | 54 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 55 | 55 | auto operator()(_T1&& __t, _T2&& __u) const |
| 56 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) | |
| 57 | -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) | |
| 58 | { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } | |
| 56 | noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) | |
| 57 | -> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) | |
| 58 | { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } | |
| 59 | 59 | typedef void is_transparent; |
| 60 | 60 | }; |
| 61 | 61 | #endif |
| ... | ... | @@ -90,9 +90,9 @@ struct _LIBCPP_TEMPLATE_VIS minus<void> |
| 90 | 90 | template <class _T1, class _T2> |
| 91 | 91 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 92 | 92 | auto operator()(_T1&& __t, _T2&& __u) const |
| 93 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) | |
| 94 | -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) | |
| 95 | { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } | |
| 93 | noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) | |
| 94 | -> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) | |
| 95 | { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } | |
| 96 | 96 | typedef void is_transparent; |
| 97 | 97 | }; |
| 98 | 98 | #endif |
| ... | ... | @@ -127,9 +127,9 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void> |
| 127 | 127 | template <class _T1, class _T2> |
| 128 | 128 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 129 | 129 | auto operator()(_T1&& __t, _T2&& __u) const |
| 130 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) | |
| 131 | -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) | |
| 132 | { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } | |
| 130 | noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) | |
| 131 | -> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) | |
| 132 | { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } | |
| 133 | 133 | typedef void is_transparent; |
| 134 | 134 | }; |
| 135 | 135 | #endif |
| ... | ... | @@ -164,9 +164,9 @@ struct _LIBCPP_TEMPLATE_VIS divides<void> |
| 164 | 164 | template <class _T1, class _T2> |
| 165 | 165 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 166 | 166 | auto operator()(_T1&& __t, _T2&& __u) const |
| 167 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) | |
| 168 | -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) | |
| 169 | { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } | |
| 167 | noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) | |
| 168 | -> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) | |
| 169 | { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } | |
| 170 | 170 | typedef void is_transparent; |
| 171 | 171 | }; |
| 172 | 172 | #endif |
| ... | ... | @@ -201,9 +201,9 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void> |
| 201 | 201 | template <class _T1, class _T2> |
| 202 | 202 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 203 | 203 | auto operator()(_T1&& __t, _T2&& __u) const |
| 204 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) | |
| 205 | -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) | |
| 206 | { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } | |
| 204 | noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) | |
| 205 | -> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) | |
| 206 | { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } | |
| 207 | 207 | typedef void is_transparent; |
| 208 | 208 | }; |
| 209 | 209 | #endif |
| ... | ... | @@ -237,9 +237,9 @@ struct _LIBCPP_TEMPLATE_VIS negate<void> |
| 237 | 237 | template <class _Tp> |
| 238 | 238 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 239 | 239 | auto operator()(_Tp&& __x) const |
| 240 | _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) | |
| 241 | -> decltype (- _VSTD::forward<_Tp>(__x)) | |
| 242 | { return - _VSTD::forward<_Tp>(__x); } | |
| 240 | noexcept(noexcept(- _VSTD::forward<_Tp>(__x))) | |
| 241 | -> decltype( - _VSTD::forward<_Tp>(__x)) | |
| 242 | { return - _VSTD::forward<_Tp>(__x); } | |
| 243 | 243 | typedef void is_transparent; |
| 244 | 244 | }; |
| 245 | 245 | #endif |
| ... | ... | @@ -276,9 +276,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> |
| 276 | 276 | template <class _T1, class _T2> |
| 277 | 277 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 278 | 278 | auto operator()(_T1&& __t, _T2&& __u) const |
| 279 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) | |
| 280 | -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) | |
| 281 | { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } | |
| 279 | noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) | |
| 280 | -> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) | |
| 281 | { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } | |
| 282 | 282 | typedef void is_transparent; |
| 283 | 283 | }; |
| 284 | 284 | #endif |
| ... | ... | @@ -307,9 +307,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void> |
| 307 | 307 | template <class _Tp> |
| 308 | 308 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 309 | 309 | auto operator()(_Tp&& __x) const |
| 310 | _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) | |
| 311 | -> decltype (~_VSTD::forward<_Tp>(__x)) | |
| 312 | { return ~_VSTD::forward<_Tp>(__x); } | |
| 310 | noexcept(noexcept(~_VSTD::forward<_Tp>(__x))) | |
| 311 | -> decltype( ~_VSTD::forward<_Tp>(__x)) | |
| 312 | { return ~_VSTD::forward<_Tp>(__x); } | |
| 313 | 313 | typedef void is_transparent; |
| 314 | 314 | }; |
| 315 | 315 | #endif |
| ... | ... | @@ -344,9 +344,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void> |
| 344 | 344 | template <class _T1, class _T2> |
| 345 | 345 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 346 | 346 | auto operator()(_T1&& __t, _T2&& __u) const |
| 347 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) | |
| 348 | -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) | |
| 349 | { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } | |
| 347 | noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) | |
| 348 | -> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) | |
| 349 | { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } | |
| 350 | 350 | typedef void is_transparent; |
| 351 | 351 | }; |
| 352 | 352 | #endif |
| ... | ... | @@ -381,9 +381,9 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void> |
| 381 | 381 | template <class _T1, class _T2> |
| 382 | 382 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 383 | 383 | auto operator()(_T1&& __t, _T2&& __u) const |
| 384 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) | |
| 385 | -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) | |
| 386 | { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } | |
| 384 | noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) | |
| 385 | -> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) | |
| 386 | { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } | |
| 387 | 387 | typedef void is_transparent; |
| 388 | 388 | }; |
| 389 | 389 | #endif |
| ... | ... | @@ -420,9 +420,9 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void> |
| 420 | 420 | template <class _T1, class _T2> |
| 421 | 421 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 422 | 422 | auto operator()(_T1&& __t, _T2&& __u) const |
| 423 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) | |
| 424 | -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) | |
| 425 | { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } | |
| 423 | noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) | |
| 424 | -> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) | |
| 425 | { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } | |
| 426 | 426 | typedef void is_transparent; |
| 427 | 427 | }; |
| 428 | 428 | #endif |
| ... | ... | @@ -457,9 +457,9 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> |
| 457 | 457 | template <class _T1, class _T2> |
| 458 | 458 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 459 | 459 | auto operator()(_T1&& __t, _T2&& __u) const |
| 460 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) | |
| 461 | -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) | |
| 462 | { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } | |
| 460 | noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) | |
| 461 | -> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) | |
| 462 | { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } | |
| 463 | 463 | typedef void is_transparent; |
| 464 | 464 | }; |
| 465 | 465 | #endif |
| ... | ... | @@ -494,9 +494,9 @@ struct _LIBCPP_TEMPLATE_VIS less<void> |
| 494 | 494 | template <class _T1, class _T2> |
| 495 | 495 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 496 | 496 | auto operator()(_T1&& __t, _T2&& __u) const |
| 497 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) | |
| 498 | -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) | |
| 499 | { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } | |
| 497 | noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) | |
| 498 | -> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) | |
| 499 | { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } | |
| 500 | 500 | typedef void is_transparent; |
| 501 | 501 | }; |
| 502 | 502 | #endif |
| ... | ... | @@ -531,9 +531,9 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void> |
| 531 | 531 | template <class _T1, class _T2> |
| 532 | 532 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 533 | 533 | auto operator()(_T1&& __t, _T2&& __u) const |
| 534 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) | |
| 535 | -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) | |
| 536 | { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } | |
| 534 | noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) | |
| 535 | -> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) | |
| 536 | { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } | |
| 537 | 537 | typedef void is_transparent; |
| 538 | 538 | }; |
| 539 | 539 | #endif |
| ... | ... | @@ -568,9 +568,9 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void> |
| 568 | 568 | template <class _T1, class _T2> |
| 569 | 569 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 570 | 570 | auto operator()(_T1&& __t, _T2&& __u) const |
| 571 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) | |
| 572 | -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) | |
| 573 | { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } | |
| 571 | noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) | |
| 572 | -> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) | |
| 573 | { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } | |
| 574 | 574 | typedef void is_transparent; |
| 575 | 575 | }; |
| 576 | 576 | #endif |
| ... | ... | @@ -605,9 +605,9 @@ struct _LIBCPP_TEMPLATE_VIS greater<void> |
| 605 | 605 | template <class _T1, class _T2> |
| 606 | 606 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 607 | 607 | auto operator()(_T1&& __t, _T2&& __u) const |
| 608 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) | |
| 609 | -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) | |
| 610 | { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } | |
| 608 | noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) | |
| 609 | -> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) | |
| 610 | { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } | |
| 611 | 611 | typedef void is_transparent; |
| 612 | 612 | }; |
| 613 | 613 | #endif |
| ... | ... | @@ -644,9 +644,9 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void> |
| 644 | 644 | template <class _T1, class _T2> |
| 645 | 645 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 646 | 646 | auto operator()(_T1&& __t, _T2&& __u) const |
| 647 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) | |
| 648 | -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) | |
| 649 | { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } | |
| 647 | noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) | |
| 648 | -> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) | |
| 649 | { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } | |
| 650 | 650 | typedef void is_transparent; |
| 651 | 651 | }; |
| 652 | 652 | #endif |
| ... | ... | @@ -680,9 +680,9 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void> |
| 680 | 680 | template <class _Tp> |
| 681 | 681 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 682 | 682 | auto operator()(_Tp&& __x) const |
| 683 | _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) | |
| 684 | -> decltype (!_VSTD::forward<_Tp>(__x)) | |
| 685 | { return !_VSTD::forward<_Tp>(__x); } | |
| 683 | noexcept(noexcept(!_VSTD::forward<_Tp>(__x))) | |
| 684 | -> decltype( !_VSTD::forward<_Tp>(__x)) | |
| 685 | { return !_VSTD::forward<_Tp>(__x); } | |
| 686 | 686 | typedef void is_transparent; |
| 687 | 687 | }; |
| 688 | 688 | #endif |
| ... | ... | @@ -717,9 +717,9 @@ struct _LIBCPP_TEMPLATE_VIS logical_or<void> |
| 717 | 717 | template <class _T1, class _T2> |
| 718 | 718 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 719 | 719 | auto operator()(_T1&& __t, _T2&& __u) const |
| 720 | _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) | |
| 721 | -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) | |
| 722 | { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } | |
| 720 | noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) | |
| 721 | -> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) | |
| 722 | { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } | |
| 723 | 723 | typedef void is_transparent; |
| 724 | 724 | }; |
| 725 | 725 | #endif |
lib/libcxx/include/__functional/perfect_forward.h+59-52| ... | ... | @@ -11,9 +11,11 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__utility/declval.h> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <__utility/move.h> | |
| 14 | 17 | #include <tuple> |
| 15 | 18 | #include <type_traits> |
| 16 | #include <utility> | |
| 17 | 19 | |
| 18 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 21 | #pragma GCC system_header |
| ... | ... | @@ -23,63 +25,68 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 25 | |
| 24 | 26 | #if _LIBCPP_STD_VER > 14 |
| 25 | 27 | |
| 26 | template<class _Op, class _Tuple, | |
| 27 | class _Idxs = typename __make_tuple_indices<tuple_size<_Tuple>::value>::type> | |
| 28 | template <class _Op, class _Indices, class ..._Bound> | |
| 28 | 29 | struct __perfect_forward_impl; |
| 29 | 30 | |
| 30 | template<class _Op, class... _Bound, size_t... _Idxs> | |
| 31 | struct __perfect_forward_impl<_Op, __tuple_types<_Bound...>, __tuple_indices<_Idxs...>> | |
| 32 | { | |
| 31 | template <class _Op, size_t ..._Idx, class ..._Bound> | |
| 32 | struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> { | |
| 33 | private: | |
| 33 | 34 | tuple<_Bound...> __bound_; |
| 34 | 35 | |
| 35 | template<class... _Args> | |
| 36 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) & | |
| 37 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) | |
| 38 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) | |
| 39 | {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} | |
| 40 | ||
| 41 | template<class... _Args> | |
| 42 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const& | |
| 43 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) | |
| 44 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) | |
| 45 | {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} | |
| 46 | ||
| 47 | template<class... _Args> | |
| 48 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) && | |
| 49 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., | |
| 50 | _VSTD::forward<_Args>(__args)...))) | |
| 51 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., | |
| 52 | _VSTD::forward<_Args>(__args)...)) | |
| 53 | {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., | |
| 54 | _VSTD::forward<_Args>(__args)...);} | |
| 55 | ||
| 56 | template<class... _Args> | |
| 57 | _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&& | |
| 58 | noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., | |
| 59 | _VSTD::forward<_Args>(__args)...))) | |
| 60 | -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., | |
| 61 | _VSTD::forward<_Args>(__args)...)) | |
| 62 | {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., | |
| 63 | _VSTD::forward<_Args>(__args)...);} | |
| 64 | ||
| 65 | template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type, | |
| 66 | class = _EnableIf<is_copy_constructible_v<_Fn>>> | |
| 67 | constexpr __perfect_forward_impl(__perfect_forward_impl const& __other) | |
| 68 | : __bound_(__other.__bound_) {} | |
| 69 | ||
| 70 | template<class _Fn = typename tuple_element<0, tuple<_Bound...>>::type, | |
| 71 | class = _EnableIf<is_move_constructible_v<_Fn>>> | |
| 72 | constexpr __perfect_forward_impl(__perfect_forward_impl && __other) | |
| 73 | : __bound_(_VSTD::move(__other.__bound_)) {} | |
| 74 | ||
| 75 | template<class... _BoundArgs> | |
| 76 | explicit constexpr __perfect_forward_impl(_BoundArgs&&... __bound) : | |
| 77 | __bound_(_VSTD::forward<_BoundArgs>(__bound)...) { } | |
| 36 | public: | |
| 37 | template <class ..._BoundArgs, class = enable_if_t< | |
| 38 | is_constructible_v<tuple<_Bound...>, _BoundArgs&&...> | |
| 39 | >> | |
| 40 | explicit constexpr __perfect_forward_impl(_BoundArgs&& ...__bound) | |
| 41 | : __bound_(_VSTD::forward<_BoundArgs>(__bound)...) | |
| 42 | { } | |
| 43 | ||
| 44 | __perfect_forward_impl(__perfect_forward_impl const&) = default; | |
| 45 | __perfect_forward_impl(__perfect_forward_impl&&) = default; | |
| 46 | ||
| 47 | __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default; | |
| 48 | __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default; | |
| 49 | ||
| 50 | template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound&..., _Args...>>> | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) & | |
| 52 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))) | |
| 53 | -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)) | |
| 54 | { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); } | |
| 55 | ||
| 56 | template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound&..., _Args...>>> | |
| 57 | auto operator()(_Args&&...) & = delete; | |
| 58 | ||
| 59 | template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const&..., _Args...>>> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const& | |
| 61 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...))) | |
| 62 | -> decltype( _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...)) | |
| 63 | { return _Op()(_VSTD::get<_Idx>(__bound_)..., _VSTD::forward<_Args>(__args)...); } | |
| 64 | ||
| 65 | template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const&..., _Args...>>> | |
| 66 | auto operator()(_Args&&...) const& = delete; | |
| 67 | ||
| 68 | template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound..., _Args...>>> | |
| 69 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) && | |
| 70 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))) | |
| 71 | -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)) | |
| 72 | { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); } | |
| 73 | ||
| 74 | template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound..., _Args...>>> | |
| 75 | auto operator()(_Args&&...) && = delete; | |
| 76 | ||
| 77 | template <class ..._Args, class = enable_if_t<is_invocable_v<_Op, _Bound const..., _Args...>>> | |
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&& | |
| 79 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...))) | |
| 80 | -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...)) | |
| 81 | { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_))..., _VSTD::forward<_Args>(__args)...); } | |
| 82 | ||
| 83 | template <class ..._Args, class = enable_if_t<!is_invocable_v<_Op, _Bound const..., _Args...>>> | |
| 84 | auto operator()(_Args&&...) const&& = delete; | |
| 78 | 85 | }; |
| 79 | 86 | |
| 80 | template<class _Op, class... _Args> | |
| 81 | using __perfect_forward = | |
| 82 | __perfect_forward_impl<_Op, __tuple_types<decay_t<_Args>...>>; | |
| 87 | // __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require]. | |
| 88 | template <class _Op, class ..._Args> | |
| 89 | using __perfect_forward = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>; | |
| 83 | 90 | |
| 84 | 91 | #endif // _LIBCPP_STD_VER > 14 |
| 85 | 92 |
lib/libcxx/include/__functional/ranges_operations.h+3-2| ... | ... | @@ -20,7 +20,8 @@ |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | ||
| 24 | 25 | namespace ranges { |
| 25 | 26 | |
| 26 | 27 | struct equal_to { |
| ... | ... | @@ -90,7 +91,7 @@ struct greater_equal { |
| 90 | 91 | }; |
| 91 | 92 | |
| 92 | 93 | } // namespace ranges |
| 93 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 94 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 94 | 95 | |
| 95 | 96 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 97 |
lib/libcxx/include/__functional/reference_wrapper.h+4-15| ... | ... | @@ -34,25 +34,16 @@ public: |
| 34 | 34 | private: |
| 35 | 35 | type* __f_; |
| 36 | 36 | |
| 37 | #ifndef _LIBCPP_CXX03_LANG | |
| 38 | 37 | static void __fun(_Tp&) _NOEXCEPT; |
| 39 | 38 | static void __fun(_Tp&&) = delete; |
| 40 | #endif | |
| 41 | 39 | |
| 42 | 40 | public: |
| 43 | // construct/copy/destroy | |
| 44 | #ifdef _LIBCPP_CXX03_LANG | |
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | reference_wrapper(type& __f) _NOEXCEPT | |
| 47 | : __f_(_VSTD::addressof(__f)) {} | |
| 48 | #else | |
| 49 | template <class _Up, class = _EnableIf<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) >> | |
| 41 | template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(declval<_Up>())) > > | |
| 50 | 42 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 51 | 43 | reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) { |
| 52 | 44 | type& __f = static_cast<_Up&&>(__u); |
| 53 | 45 | __f_ = _VSTD::addressof(__f); |
| 54 | 46 | } |
| 55 | #endif | |
| 56 | 47 | |
| 57 | 48 | // access |
| 58 | 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -176,7 +167,7 @@ public: |
| 176 | 167 | #endif // _LIBCPP_CXX03_LANG |
| 177 | 168 | }; |
| 178 | 169 | |
| 179 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 170 | #if _LIBCPP_STD_VER > 14 | |
| 180 | 171 | template <class _Tp> |
| 181 | 172 | reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; |
| 182 | 173 | #endif |
| ... | ... | @@ -194,7 +185,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 194 | 185 | reference_wrapper<_Tp> |
| 195 | 186 | ref(reference_wrapper<_Tp> __t) _NOEXCEPT |
| 196 | 187 | { |
| 197 | return _VSTD::ref(__t.get()); | |
| 188 | return __t; | |
| 198 | 189 | } |
| 199 | 190 | |
| 200 | 191 | template <class _Tp> |
| ... | ... | @@ -210,13 +201,11 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 210 | 201 | reference_wrapper<const _Tp> |
| 211 | 202 | cref(reference_wrapper<_Tp> __t) _NOEXCEPT |
| 212 | 203 | { |
| 213 | return _VSTD::cref(__t.get()); | |
| 204 | return __t; | |
| 214 | 205 | } |
| 215 | 206 | |
| 216 | #ifndef _LIBCPP_CXX03_LANG | |
| 217 | 207 | template <class _Tp> void ref(const _Tp&&) = delete; |
| 218 | 208 | template <class _Tp> void cref(const _Tp&&) = delete; |
| 219 | #endif | |
| 220 | 209 | |
| 221 | 210 | _LIBCPP_END_NAMESPACE_STD |
| 222 | 211 |
lib/libcxx/include/__functional/unary_function.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _Arg, class _Result> |
| ... | ... | @@ -29,6 +26,4 @@ struct _LIBCPP_TEMPLATE_VIS unary_function |
| 29 | 26 | |
| 30 | 27 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 28 | |
| 32 | _LIBCPP_POP_MACROS | |
| 33 | ||
| 34 | 29 | #endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H |
lib/libcxx/include/__functional/unwrap_ref.h+2-7| ... | ... | @@ -15,19 +15,16 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | template <class _Tp> |
| 24 | struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; | |
| 21 | struct __unwrap_reference { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 25 | 22 | |
| 26 | 23 | template <class _Tp> |
| 27 | 24 | class reference_wrapper; |
| 28 | 25 | |
| 29 | 26 | template <class _Tp> |
| 30 | struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; | |
| 27 | struct __unwrap_reference<reference_wrapper<_Tp> > { typedef _LIBCPP_NODEBUG _Tp& type; }; | |
| 31 | 28 | |
| 32 | 29 | template <class _Tp> |
| 33 | 30 | struct decay; |
| ... | ... | @@ -57,6 +54,4 @@ struct __unwrap_ref_decay |
| 57 | 54 | |
| 58 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 59 | 56 | |
| 60 | _LIBCPP_POP_MACROS | |
| 61 | ||
| 62 | 57 | #endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H |
lib/libcxx/include/__functional/weak_result_type.h+4-4| ... | ... | @@ -89,7 +89,7 @@ struct __weak_result_type_imp // bool is true |
| 89 | 89 | : public __maybe_derive_from_unary_function<_Tp>, |
| 90 | 90 | public __maybe_derive_from_binary_function<_Tp> |
| 91 | 91 | { |
| 92 | typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type; | |
| 92 | typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type; | |
| 93 | 93 | }; |
| 94 | 94 | |
| 95 | 95 | template <class _Tp> |
| ... | ... | @@ -110,19 +110,19 @@ struct __weak_result_type |
| 110 | 110 | template <class _Rp> |
| 111 | 111 | struct __weak_result_type<_Rp ()> |
| 112 | 112 | { |
| 113 | typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; | |
| 113 | typedef _LIBCPP_NODEBUG _Rp result_type; | |
| 114 | 114 | }; |
| 115 | 115 | |
| 116 | 116 | template <class _Rp> |
| 117 | 117 | struct __weak_result_type<_Rp (&)()> |
| 118 | 118 | { |
| 119 | typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; | |
| 119 | typedef _LIBCPP_NODEBUG _Rp result_type; | |
| 120 | 120 | }; |
| 121 | 121 | |
| 122 | 122 | template <class _Rp> |
| 123 | 123 | struct __weak_result_type<_Rp (*)()> |
| 124 | 124 | { |
| 125 | typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; | |
| 125 | typedef _LIBCPP_NODEBUG _Rp result_type; | |
| 126 | 126 | }; |
| 127 | 127 | |
| 128 | 128 | // 1 argument case |
lib/libcxx/include/__hash_table+40-54| ... | ... | @@ -288,9 +288,7 @@ public: |
| 288 | 288 | typedef typename _NodeTypes::__node_value_type_pointer pointer; |
| 289 | 289 | |
| 290 | 290 | _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) { |
| 291 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 292 | __get_db()->__insert_i(this); | |
| 293 | #endif | |
| 291 | _VSTD::__debug_db_insert_i(this); | |
| 294 | 292 | } |
| 295 | 293 | |
| 296 | 294 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| ... | ... | @@ -298,7 +296,7 @@ public: |
| 298 | 296 | __hash_iterator(const __hash_iterator& __i) |
| 299 | 297 | : __node_(__i.__node_) |
| 300 | 298 | { |
| 301 | __get_db()->__iterator_copy(this, &__i); | |
| 299 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 302 | 300 | } |
| 303 | 301 | |
| 304 | 302 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -310,9 +308,9 @@ public: |
| 310 | 308 | _LIBCPP_INLINE_VISIBILITY |
| 311 | 309 | __hash_iterator& operator=(const __hash_iterator& __i) |
| 312 | 310 | { |
| 313 | if (this != &__i) | |
| 311 | if (this != _VSTD::addressof(__i)) | |
| 314 | 312 | { |
| 315 | __get_db()->__iterator_copy(this, &__i); | |
| 313 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 316 | 314 | __node_ = __i.__node_; |
| 317 | 315 | } |
| 318 | 316 | return *this; |
| ... | ... | @@ -400,9 +398,7 @@ public: |
| 400 | 398 | |
| 401 | 399 | |
| 402 | 400 | _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) { |
| 403 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 404 | __get_db()->__insert_i(this); | |
| 405 | #endif | |
| 401 | _VSTD::__debug_db_insert_i(this); | |
| 406 | 402 | } |
| 407 | 403 | |
| 408 | 404 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -410,7 +406,7 @@ public: |
| 410 | 406 | : __node_(__x.__node_) |
| 411 | 407 | { |
| 412 | 408 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 413 | __get_db()->__iterator_copy(this, &__x); | |
| 409 | __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); | |
| 414 | 410 | #endif |
| 415 | 411 | } |
| 416 | 412 | |
| ... | ... | @@ -419,7 +415,7 @@ public: |
| 419 | 415 | __hash_const_iterator(const __hash_const_iterator& __i) |
| 420 | 416 | : __node_(__i.__node_) |
| 421 | 417 | { |
| 422 | __get_db()->__iterator_copy(this, &__i); | |
| 418 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 423 | 419 | } |
| 424 | 420 | |
| 425 | 421 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -431,9 +427,9 @@ public: |
| 431 | 427 | _LIBCPP_INLINE_VISIBILITY |
| 432 | 428 | __hash_const_iterator& operator=(const __hash_const_iterator& __i) |
| 433 | 429 | { |
| 434 | if (this != &__i) | |
| 430 | if (this != _VSTD::addressof(__i)) | |
| 435 | 431 | { |
| 436 | __get_db()->__iterator_copy(this, &__i); | |
| 432 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 437 | 433 | __node_ = __i.__node_; |
| 438 | 434 | } |
| 439 | 435 | return *this; |
| ... | ... | @@ -517,9 +513,7 @@ public: |
| 517 | 513 | typedef typename _NodeTypes::__node_value_type_pointer pointer; |
| 518 | 514 | |
| 519 | 515 | _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) { |
| 520 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 521 | __get_db()->__insert_i(this); | |
| 522 | #endif | |
| 516 | _VSTD::__debug_db_insert_i(this); | |
| 523 | 517 | } |
| 524 | 518 | |
| 525 | 519 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| ... | ... | @@ -529,7 +523,7 @@ public: |
| 529 | 523 | __bucket_(__i.__bucket_), |
| 530 | 524 | __bucket_count_(__i.__bucket_count_) |
| 531 | 525 | { |
| 532 | __get_db()->__iterator_copy(this, &__i); | |
| 526 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 533 | 527 | } |
| 534 | 528 | |
| 535 | 529 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -541,9 +535,9 @@ public: |
| 541 | 535 | _LIBCPP_INLINE_VISIBILITY |
| 542 | 536 | __hash_local_iterator& operator=(const __hash_local_iterator& __i) |
| 543 | 537 | { |
| 544 | if (this != &__i) | |
| 538 | if (this != _VSTD::addressof(__i)) | |
| 545 | 539 | { |
| 546 | __get_db()->__iterator_copy(this, &__i); | |
| 540 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 547 | 541 | __node_ = __i.__node_; |
| 548 | 542 | __bucket_ = __i.__bucket_; |
| 549 | 543 | __bucket_count_ = __i.__bucket_count_; |
| ... | ... | @@ -651,9 +645,7 @@ public: |
| 651 | 645 | |
| 652 | 646 | |
| 653 | 647 | _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) { |
| 654 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 655 | __get_db()->__insert_i(this); | |
| 656 | #endif | |
| 648 | _VSTD::__debug_db_insert_i(this); | |
| 657 | 649 | } |
| 658 | 650 | |
| 659 | 651 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -663,7 +655,7 @@ public: |
| 663 | 655 | __bucket_count_(__x.__bucket_count_) |
| 664 | 656 | { |
| 665 | 657 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 666 | __get_db()->__iterator_copy(this, &__x); | |
| 658 | __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); | |
| 667 | 659 | #endif |
| 668 | 660 | } |
| 669 | 661 | |
| ... | ... | @@ -674,7 +666,7 @@ public: |
| 674 | 666 | __bucket_(__i.__bucket_), |
| 675 | 667 | __bucket_count_(__i.__bucket_count_) |
| 676 | 668 | { |
| 677 | __get_db()->__iterator_copy(this, &__i); | |
| 669 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 678 | 670 | } |
| 679 | 671 | |
| 680 | 672 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -686,9 +678,9 @@ public: |
| 686 | 678 | _LIBCPP_INLINE_VISIBILITY |
| 687 | 679 | __hash_const_local_iterator& operator=(const __hash_const_local_iterator& __i) |
| 688 | 680 | { |
| 689 | if (this != &__i) | |
| 681 | if (this != _VSTD::addressof(__i)) | |
| 690 | 682 | { |
| 691 | __get_db()->__iterator_copy(this, &__i); | |
| 683 | __get_db()->__iterator_copy(this, _VSTD::addressof(__i)); | |
| 692 | 684 | __node_ = __i.__node_; |
| 693 | 685 | __bucket_ = __i.__bucket_; |
| 694 | 686 | __bucket_count_ = __i.__bucket_count_; |
| ... | ... | @@ -1541,7 +1533,7 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 1541 | 1533 | __hash_table<_Tp, _Hash, _Equal, _Alloc>& |
| 1542 | 1534 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(const __hash_table& __u) |
| 1543 | 1535 | { |
| 1544 | if (this != &__u) | |
| 1536 | if (this != _VSTD::addressof(__u)) | |
| 1545 | 1537 | { |
| 1546 | 1538 | __copy_assign_alloc(__u); |
| 1547 | 1539 | hash_function() = __u.hash_function(); |
| ... | ... | @@ -1623,7 +1615,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( |
| 1623 | 1615 | __u.size() = 0; |
| 1624 | 1616 | } |
| 1625 | 1617 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1626 | __get_db()->swap(this, &__u); | |
| 1618 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1627 | 1619 | #endif |
| 1628 | 1620 | } |
| 1629 | 1621 | |
| ... | ... | @@ -2029,11 +2021,9 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 2029 | 2021 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( |
| 2030 | 2022 | const_iterator __p, __node_pointer __cp) |
| 2031 | 2023 | { |
| 2032 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2033 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 2034 | "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 2035 | " referring to this unordered container"); | |
| 2036 | #endif | |
| 2024 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 2025 | "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 2026 | " referring to this unordered container"); | |
| 2037 | 2027 | if (__p != end() && key_eq()(*__p, __cp->__value_)) |
| 2038 | 2028 | { |
| 2039 | 2029 | __next_pointer __np = __p.__node_; |
| ... | ... | @@ -2158,11 +2148,9 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 2158 | 2148 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( |
| 2159 | 2149 | const_iterator __p, _Args&&... __args) |
| 2160 | 2150 | { |
| 2161 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2162 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 2163 | "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 2164 | " referring to this unordered container"); | |
| 2165 | #endif | |
| 2151 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 2152 | "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 2153 | " referring to this unordered container"); | |
| 2166 | 2154 | __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); |
| 2167 | 2155 | iterator __r = __node_insert_multi(__p, __h.get()); |
| 2168 | 2156 | __h.release(); |
| ... | ... | @@ -2348,7 +2336,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) |
| 2348 | 2336 | size_type __chash = __constrain_hash(__cp->__hash(), __nbc); |
| 2349 | 2337 | __bucket_list_[__chash] = __pp; |
| 2350 | 2338 | size_type __phash = __chash; |
| 2351 | for (__pp = __cp, __cp = __cp->__next_; __cp != nullptr; | |
| 2339 | for (__pp = __cp, void(), __cp = __cp->__next_; __cp != nullptr; | |
| 2352 | 2340 | __cp = __pp->__next_) |
| 2353 | 2341 | { |
| 2354 | 2342 | __chash = __constrain_hash(__cp->__hash(), __nbc); |
| ... | ... | @@ -2484,12 +2472,12 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 2484 | 2472 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) |
| 2485 | 2473 | { |
| 2486 | 2474 | __next_pointer __np = __p.__node_; |
| 2475 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 2476 | "unordered container erase(iterator) called with an iterator not" | |
| 2477 | " referring to this container"); | |
| 2478 | _LIBCPP_DEBUG_ASSERT(__p != end(), | |
| 2479 | "unordered container erase(iterator) called with a non-dereferenceable iterator"); | |
| 2487 | 2480 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2488 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 2489 | "unordered container erase(iterator) called with an iterator not" | |
| 2490 | " referring to this container"); | |
| 2491 | _LIBCPP_ASSERT(__p != end(), | |
| 2492 | "unordered container erase(iterator) called with a non-dereferenceable iterator"); | |
| 2493 | 2481 | iterator __r(__np, this); |
| 2494 | 2482 | #else |
| 2495 | 2483 | iterator __r(__np); |
| ... | ... | @@ -2504,14 +2492,12 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 2504 | 2492 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, |
| 2505 | 2493 | const_iterator __last) |
| 2506 | 2494 | { |
| 2507 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2508 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | |
| 2509 | "unordered container::erase(iterator, iterator) called with an iterator not" | |
| 2510 | " referring to this container"); | |
| 2511 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, | |
| 2512 | "unordered container::erase(iterator, iterator) called with an iterator not" | |
| 2513 | " referring to this container"); | |
| 2514 | #endif | |
| 2495 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this, | |
| 2496 | "unordered container::erase(iterator, iterator) called with an iterator not" | |
| 2497 | " referring to this container"); | |
| 2498 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this, | |
| 2499 | "unordered container::erase(iterator, iterator) called with an iterator not" | |
| 2500 | " referring to this container"); | |
| 2515 | 2501 | for (const_iterator __p = __first; __first != __last; __p = __first) |
| 2516 | 2502 | { |
| 2517 | 2503 | ++__first; |
| ... | ... | @@ -2741,7 +2727,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) |
| 2741 | 2727 | __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = |
| 2742 | 2728 | __u.__p1_.first().__ptr(); |
| 2743 | 2729 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2744 | __get_db()->swap(this, &__u); | |
| 2730 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 2745 | 2731 | #endif |
| 2746 | 2732 | } |
| 2747 | 2733 | |
| ... | ... | @@ -2758,7 +2744,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::bucket_size(size_type __n) const |
| 2758 | 2744 | { |
| 2759 | 2745 | for (__np = __np->__next_; __np != nullptr && |
| 2760 | 2746 | __constrain_hash(__np->__hash(), __bc) == __n; |
| 2761 | __np = __np->__next_, ++__r) | |
| 2747 | __np = __np->__next_, (void) ++__r) | |
| 2762 | 2748 | ; |
| 2763 | 2749 | } |
| 2764 | 2750 | return __r; |
lib/libcxx/include/__iterator/access.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _Tp, size_t _Np> |
| ... | ... | @@ -129,6 +126,4 @@ end(const _Cp& __c) |
| 129 | 126 | |
| 130 | 127 | _LIBCPP_END_NAMESPACE_STD |
| 131 | 128 | |
| 132 | _LIBCPP_POP_MACROS | |
| 133 | ||
| 134 | 129 | #endif // _LIBCPP___ITERATOR_ACCESS_H |
lib/libcxx/include/__iterator/advance.h+20-21| ... | ... | @@ -12,13 +12,12 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__debug> |
| 15 | #include <__function_like.h> | |
| 16 | 15 | #include <__iterator/concepts.h> |
| 17 | 16 | #include <__iterator/incrementable_traits.h> |
| 18 | 17 | #include <__iterator/iterator_traits.h> |
| 19 | 18 | #include <__utility/move.h> |
| 20 | #include <cstdlib> | |
| 21 | 19 | #include <concepts> |
| 20 | #include <cstdlib> | |
| 22 | 21 | #include <limits> |
| 23 | 22 | #include <type_traits> |
| 24 | 23 | |
| ... | ... | @@ -26,9 +25,6 @@ |
| 26 | 25 | #pragma GCC system_header |
| 27 | 26 | #endif |
| 28 | 27 | |
| 29 | _LIBCPP_PUSH_MACROS | |
| 30 | #include <__undef_macros> | |
| 31 | ||
| 32 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 29 | |
| 34 | 30 | template <class _InputIter> |
| ... | ... | @@ -58,7 +54,7 @@ void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_t |
| 58 | 54 | template < |
| 59 | 55 | class _InputIter, class _Distance, |
| 60 | 56 | class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())), |
| 61 | class = _EnableIf<is_integral<_IntegralDistance>::value> > | |
| 57 | class = __enable_if_t<is_integral<_IntegralDistance>::value> > | |
| 62 | 58 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 63 | 59 | void advance(_InputIter& __i, _Distance __orig_n) { |
| 64 | 60 | typedef typename iterator_traits<_InputIter>::difference_type _Difference; |
| ... | ... | @@ -68,18 +64,15 @@ void advance(_InputIter& __i, _Distance __orig_n) { |
| 68 | 64 | _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); |
| 69 | 65 | } |
| 70 | 66 | |
| 71 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 67 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 72 | 68 | |
| 73 | namespace ranges { | |
| 74 | 69 | // [range.iter.op.advance] |
| 75 | struct __advance_fn final : private __function_like { | |
| 76 | private: | |
| 77 | template <class _Tp> | |
| 78 | _LIBCPP_HIDE_FROM_ABI | |
| 79 | static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept { | |
| 80 | return __a < 0 ? (__a <= __b) : (__a >= __b); | |
| 81 | } | |
| 82 | 70 | |
| 71 | namespace ranges { | |
| 72 | namespace __advance { | |
| 73 | ||
| 74 | struct __fn { | |
| 75 | private: | |
| 83 | 76 | template <class _Ip> |
| 84 | 77 | _LIBCPP_HIDE_FROM_ABI |
| 85 | 78 | static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { |
| ... | ... | @@ -99,8 +92,6 @@ private: |
| 99 | 92 | } |
| 100 | 93 | |
| 101 | 94 | public: |
| 102 | constexpr explicit __advance_fn(__tag __x) noexcept : __function_like(__x) {} | |
| 103 | ||
| 104 | 95 | // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. |
| 105 | 96 | template <input_or_output_iterator _Ip> |
| 106 | 97 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -158,6 +149,12 @@ public: |
| 158 | 149 | // If `S` and `I` model `sized_sentinel_for<S, I>`: |
| 159 | 150 | if constexpr (sized_sentinel_for<_Sp, _Ip>) { |
| 160 | 151 | // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. |
| 152 | // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign. | |
| 153 | auto __magnitude_geq = [](auto __a, auto __b) { | |
| 154 | return __a == 0 ? __b == 0 : | |
| 155 | __a > 0 ? __a >= __b : | |
| 156 | __a <= __b; | |
| 157 | }; | |
| 161 | 158 | if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) { |
| 162 | 159 | (*this)(__i, __bound); |
| 163 | 160 | return __n - __M; |
| ... | ... | @@ -188,13 +185,15 @@ public: |
| 188 | 185 | } |
| 189 | 186 | }; |
| 190 | 187 | |
| 191 | inline constexpr auto advance = __advance_fn(__function_like::__tag()); | |
| 188 | } // namespace __advance | |
| 189 | ||
| 190 | inline namespace __cpo { | |
| 191 | inline constexpr auto advance = __advance::__fn{}; | |
| 192 | } // namespace __cpo | |
| 192 | 193 | } // namespace ranges |
| 193 | 194 | |
| 194 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 195 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 195 | 196 | |
| 196 | 197 | _LIBCPP_END_NAMESPACE_STD |
| 197 | 198 | |
| 198 | _LIBCPP_POP_MACROS | |
| 199 | ||
| 200 | 199 | #endif // _LIBCPP___ITERATOR_ADVANCE_H |
lib/libcxx/include/__iterator/back_insert_iterator.h+7-12| ... | ... | @@ -21,9 +21,6 @@ |
| 21 | 21 | #pragma GCC system_header |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 25 | |
| 29 | 26 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -48,20 +45,20 @@ public: |
| 48 | 45 | typedef void reference; |
| 49 | 46 | typedef _Container container_type; |
| 50 | 47 | |
| 51 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} | |
| 52 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) | |
| 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_) | |
| 53 | 50 | {container->push_back(__value_); return *this;} |
| 54 | 51 | #ifndef _LIBCPP_CXX03_LANG |
| 55 | _LIBCPP_INLINE_VISIBILITY _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_) | |
| 56 | 53 | {container->push_back(_VSTD::move(__value_)); return *this;} |
| 57 | 54 | #endif // _LIBCPP_CXX03_LANG |
| 58 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} | |
| 59 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} | |
| 60 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {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;} | |
| 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} | |
| 61 | 58 | }; |
| 62 | 59 | |
| 63 | 60 | template <class _Container> |
| 64 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 61 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 65 | 62 | back_insert_iterator<_Container> |
| 66 | 63 | back_inserter(_Container& __x) |
| 67 | 64 | { |
| ... | ... | @@ -70,6 +67,4 @@ back_inserter(_Container& __x) |
| 70 | 67 | |
| 71 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 69 | |
| 73 | _LIBCPP_POP_MACROS | |
| 74 | ||
| 75 | 70 | #endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H |
lib/libcxx/include/__iterator/common_iterator.h+36-54| ... | ... | @@ -25,12 +25,14 @@ |
| 25 | 25 | #pragma GCC system_header |
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 29 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 30 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 31 | ||
| 32 | template<class _Iter> | |
| 33 | concept __can_use_postfix_proxy = | |
| 34 | constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>> && | |
| 35 | move_constructible<iter_value_t<_Iter>>; | |
| 34 | 36 | |
| 35 | 37 | template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent> |
| 36 | 38 | requires (!same_as<_Iter, _Sent> && copyable<_Iter>) |
| ... | ... | @@ -44,7 +46,7 @@ class common_iterator { |
| 44 | 46 | : __value(_VSTD::move(__x)) {} |
| 45 | 47 | |
| 46 | 48 | public: |
| 47 | const iter_value_t<_Iter>* operator->() const { | |
| 49 | constexpr const iter_value_t<_Iter>* operator->() const noexcept { | |
| 48 | 50 | return _VSTD::addressof(__value); |
| 49 | 51 | } |
| 50 | 52 | }; |
| ... | ... | @@ -57,11 +59,7 @@ class common_iterator { |
| 57 | 59 | : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {} |
| 58 | 60 | |
| 59 | 61 | public: |
| 60 | constexpr static bool __valid_for_iter = | |
| 61 | constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>> && | |
| 62 | move_constructible<iter_value_t<_Iter>>; | |
| 63 | ||
| 64 | const iter_value_t<_Iter>& operator*() const { | |
| 62 | constexpr const iter_value_t<_Iter>& operator*() const noexcept { | |
| 65 | 63 | return __value; |
| 66 | 64 | } |
| 67 | 65 | }; |
| ... | ... | @@ -78,7 +76,7 @@ public: |
| 78 | 76 | requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> |
| 79 | 77 | constexpr common_iterator(const common_iterator<_I2, _S2>& __other) |
| 80 | 78 | : __hold_([&]() -> variant<_Iter, _Sent> { |
| 81 | _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Constructed from valueless iterator."); | |
| 79 | _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Attempted to construct from a valueless common_iterator"); | |
| 82 | 80 | if (__other.__hold_.index() == 0) |
| 83 | 81 | return variant<_Iter, _Sent>{in_place_index<0>, _VSTD::__unchecked_get<0>(__other.__hold_)}; |
| 84 | 82 | return variant<_Iter, _Sent>{in_place_index<1>, _VSTD::__unchecked_get<1>(__other.__hold_)}; |
| ... | ... | @@ -88,7 +86,7 @@ public: |
| 88 | 86 | requires convertible_to<const _I2&, _Iter> && convertible_to<const _S2&, _Sent> && |
| 89 | 87 | assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&> |
| 90 | 88 | common_iterator& operator=(const common_iterator<_I2, _S2>& __other) { |
| 91 | _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Assigned from valueless iterator."); | |
| 89 | _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Attempted to assign from a valueless common_iterator"); | |
| 92 | 90 | |
| 93 | 91 | auto __idx = __hold_.index(); |
| 94 | 92 | auto __other_idx = __other.__hold_.index(); |
| ... | ... | @@ -108,18 +106,16 @@ public: |
| 108 | 106 | return *this; |
| 109 | 107 | } |
| 110 | 108 | |
| 111 | decltype(auto) operator*() | |
| 109 | constexpr decltype(auto) operator*() | |
| 112 | 110 | { |
| 113 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), | |
| 114 | "Cannot dereference sentinel. Common iterator not holding an iterator."); | |
| 111 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator"); | |
| 115 | 112 | return *_VSTD::__unchecked_get<_Iter>(__hold_); |
| 116 | 113 | } |
| 117 | 114 | |
| 118 | decltype(auto) operator*() const | |
| 115 | constexpr decltype(auto) operator*() const | |
| 119 | 116 | requires __dereferenceable<const _Iter> |
| 120 | 117 | { |
| 121 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), | |
| 122 | "Cannot dereference sentinel. Common iterator not holding an iterator."); | |
| 118 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator"); | |
| 123 | 119 | return *_VSTD::__unchecked_get<_Iter>(__hold_); |
| 124 | 120 | } |
| 125 | 121 | |
| ... | ... | @@ -130,9 +126,7 @@ public: |
| 130 | 126 | is_reference_v<iter_reference_t<_I2>> || |
| 131 | 127 | constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>) |
| 132 | 128 | { |
| 133 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), | |
| 134 | "Cannot dereference sentinel. Common iterator not holding an iterator."); | |
| 135 | ||
| 129 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator"); | |
| 136 | 130 | if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) { |
| 137 | 131 | return _VSTD::__unchecked_get<_Iter>(__hold_); |
| 138 | 132 | } else if constexpr (is_reference_v<iter_reference_t<_Iter>>) { |
| ... | ... | @@ -144,21 +138,18 @@ public: |
| 144 | 138 | } |
| 145 | 139 | |
| 146 | 140 | common_iterator& operator++() { |
| 147 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), | |
| 148 | "Cannot increment sentinel. Common iterator not holding an iterator."); | |
| 141 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator"); | |
| 149 | 142 | ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this; |
| 150 | 143 | } |
| 151 | 144 | |
| 152 | 145 | decltype(auto) operator++(int) { |
| 153 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), | |
| 154 | "Cannot increment sentinel. Common iterator not holding an iterator."); | |
| 155 | ||
| 146 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), "Attempted to increment a non-dereferenceable common_iterator"); | |
| 156 | 147 | if constexpr (forward_iterator<_Iter>) { |
| 157 | 148 | auto __tmp = *this; |
| 158 | 149 | ++*this; |
| 159 | 150 | return __tmp; |
| 160 | 151 | } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } || |
| 161 | !__postfix_proxy::__valid_for_iter) { | |
| 152 | !__can_use_postfix_proxy<_Iter>) { | |
| 162 | 153 | return _VSTD::__unchecked_get<_Iter>(__hold_)++; |
| 163 | 154 | } else { |
| 164 | 155 | __postfix_proxy __p(**this); |
| ... | ... | @@ -169,10 +160,9 @@ public: |
| 169 | 160 | |
| 170 | 161 | template<class _I2, sentinel_for<_Iter> _S2> |
| 171 | 162 | requires sentinel_for<_Sent, _I2> |
| 172 | friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { | |
| 173 | _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && | |
| 174 | !__y.__hold_.valueless_by_exception(), | |
| 175 | "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); | |
| 163 | friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { | |
| 164 | _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); | |
| 165 | _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); | |
| 176 | 166 | |
| 177 | 167 | auto __x_index = __x.__hold_.index(); |
| 178 | 168 | auto __y_index = __y.__hold_.index(); |
| ... | ... | @@ -188,10 +178,9 @@ public: |
| 188 | 178 | |
| 189 | 179 | template<class _I2, sentinel_for<_Iter> _S2> |
| 190 | 180 | requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2> |
| 191 | friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { | |
| 192 | _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && | |
| 193 | !__y.__hold_.valueless_by_exception(), | |
| 194 | "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); | |
| 181 | friend constexpr bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { | |
| 182 | _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); | |
| 183 | _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to compare a valueless common_iterator"); | |
| 195 | 184 | |
| 196 | 185 | auto __x_index = __x.__hold_.index(); |
| 197 | 186 | auto __y_index = __y.__hold_.index(); |
| ... | ... | @@ -210,10 +199,9 @@ public: |
| 210 | 199 | |
| 211 | 200 | template<sized_sentinel_for<_Iter> _I2, sized_sentinel_for<_Iter> _S2> |
| 212 | 201 | requires sized_sentinel_for<_Sent, _I2> |
| 213 | friend iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { | |
| 214 | _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && | |
| 215 | !__y.__hold_.valueless_by_exception(), | |
| 216 | "One or both common_iterators are valueless. (Cannot subtract valueless iterators.)"); | |
| 202 | friend constexpr iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { | |
| 203 | _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception(), "Attempted to subtract from a valueless common_iterator"); | |
| 204 | _LIBCPP_ASSERT(!__y.__hold_.valueless_by_exception(), "Attempted to subtract a valueless common_iterator"); | |
| 217 | 205 | |
| 218 | 206 | auto __x_index = __x.__hold_.index(); |
| 219 | 207 | auto __y_index = __y.__hold_.index(); |
| ... | ... | @@ -230,24 +218,21 @@ public: |
| 230 | 218 | return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); |
| 231 | 219 | } |
| 232 | 220 | |
| 233 | friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) | |
| 221 | friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) | |
| 234 | 222 | noexcept(noexcept(ranges::iter_move(declval<const _Iter&>()))) |
| 235 | 223 | requires input_iterator<_Iter> |
| 236 | 224 | { |
| 237 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), | |
| 238 | "Cannot iter_move a sentinel. Common iterator not holding an iterator."); | |
| 225 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), "Attempted to iter_move a non-dereferenceable common_iterator"); | |
| 239 | 226 | return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_)); |
| 240 | 227 | } |
| 241 | 228 | |
| 242 | 229 | template<indirectly_swappable<_Iter> _I2, class _S2> |
| 243 | friend void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) | |
| 230 | friend constexpr void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) | |
| 244 | 231 | noexcept(noexcept(ranges::iter_swap(declval<const _Iter&>(), declval<const _I2&>()))) |
| 245 | 232 | { |
| 246 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), | |
| 247 | "Cannot swap __y with a sentinel. Common iterator (__x) not holding an iterator."); | |
| 248 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__y.__hold_), | |
| 249 | "Cannot swap __x with a sentinel. Common iterator (__y) not holding an iterator."); | |
| 250 | return ranges::iter_swap( _VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_Iter>(__y.__hold_)); | |
| 233 | _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator"); | |
| 234 | _LIBCPP_ASSERT(holds_alternative<_I2>(__y.__hold_), "Attempted to iter_swap a non-dereferenceable common_iterator"); | |
| 235 | return ranges::iter_swap(_VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_I2>(__y.__hold_)); | |
| 251 | 236 | } |
| 252 | 237 | }; |
| 253 | 238 | |
| ... | ... | @@ -274,10 +259,10 @@ struct __arrow_type_or_void { |
| 274 | 259 | template<class _Iter, class _Sent> |
| 275 | 260 | requires __common_iter_has_ptr_op<_Iter, _Sent> |
| 276 | 261 | struct __arrow_type_or_void<_Iter, _Sent> { |
| 277 | using type = decltype(declval<const common_iterator<_Iter, _Sent>>().operator->()); | |
| 262 | using type = decltype(declval<const common_iterator<_Iter, _Sent>&>().operator->()); | |
| 278 | 263 | }; |
| 279 | 264 | |
| 280 | template<class _Iter, class _Sent> | |
| 265 | template<input_iterator _Iter, class _Sent> | |
| 281 | 266 | struct iterator_traits<common_iterator<_Iter, _Sent>> { |
| 282 | 267 | using iterator_concept = _If<forward_iterator<_Iter>, |
| 283 | 268 | forward_iterator_tag, |
| ... | ... | @@ -291,11 +276,8 @@ struct iterator_traits<common_iterator<_Iter, _Sent>> { |
| 291 | 276 | using reference = iter_reference_t<_Iter>; |
| 292 | 277 | }; |
| 293 | 278 | |
| 294 | ||
| 295 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 279 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 296 | 280 | |
| 297 | 281 | _LIBCPP_END_NAMESPACE_STD |
| 298 | 282 | |
| 299 | _LIBCPP_POP_MACROS | |
| 300 | ||
| 301 | 283 | #endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H |
lib/libcxx/include/__iterator/concepts.h+4-12| ... | ... | @@ -24,14 +24,9 @@ |
| 24 | 24 | #pragma GCC system_header |
| 25 | 25 | #endif |
| 26 | 26 | |
| 27 | _LIBCPP_PUSH_MACROS | |
| 28 | #include <__undef_macros> | |
| 29 | ||
| 30 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 28 | |
| 32 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 33 | ||
| 34 | // clang-format off | |
| 29 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | 30 | |
| 36 | 31 | // [iterator.concept.readable] |
| 37 | 32 | template<class _In> |
| ... | ... | @@ -72,6 +67,8 @@ concept __signed_integer_like = signed_integral<_Tp>; |
| 72 | 67 | |
| 73 | 68 | template<class _Ip> |
| 74 | 69 | concept weakly_incrementable = |
| 70 | // TODO: remove this once the clang bug is fixed (bugs.llvm.org/PR48173). | |
| 71 | !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. | |
| 75 | 72 | movable<_Ip> && |
| 76 | 73 | requires(_Ip __i) { |
| 77 | 74 | typename iter_difference_t<_Ip>; |
| ... | ... | @@ -172,7 +169,6 @@ concept contiguous_iterator = |
| 172 | 169 | derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> && |
| 173 | 170 | is_lvalue_reference_v<iter_reference_t<_Ip>> && |
| 174 | 171 | same_as<iter_value_t<_Ip>, remove_cvref_t<iter_reference_t<_Ip>>> && |
| 175 | (is_pointer_v<_Ip> || requires { sizeof(__pointer_traits_element_type<_Ip>); }) && | |
| 176 | 172 | requires(const _Ip& __i) { |
| 177 | 173 | { _VSTD::to_address(__i) } -> same_as<add_pointer_t<iter_reference_t<_Ip>>>; |
| 178 | 174 | }; |
| ... | ... | @@ -261,12 +257,8 @@ concept indirectly_movable_storable = |
| 261 | 257 | // Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle |
| 262 | 258 | // (both iter_swap and indirectly_swappable require indirectly_readable). |
| 263 | 259 | |
| 264 | // clang-format on | |
| 265 | ||
| 266 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 260 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 267 | 261 | |
| 268 | 262 | _LIBCPP_END_NAMESPACE_STD |
| 269 | 263 | |
| 270 | _LIBCPP_POP_MACROS | |
| 271 | ||
| 272 | 264 | #endif // _LIBCPP___ITERATOR_CONCEPTS_H |
lib/libcxx/include/__iterator/counted_iterator.h+6-9| ... | ... | @@ -13,12 +13,14 @@ |
| 13 | 13 | #include <__debug> |
| 14 | 14 | #include <__iterator/concepts.h> |
| 15 | 15 | #include <__iterator/default_sentinel.h> |
| 16 | #include <__iterator/incrementable_traits.h> | |
| 16 | 17 | #include <__iterator/iter_move.h> |
| 17 | 18 | #include <__iterator/iter_swap.h> |
| 18 | #include <__iterator/incrementable_traits.h> | |
| 19 | 19 | #include <__iterator/iterator_traits.h> |
| 20 | 20 | #include <__iterator/readable_traits.h> |
| 21 | 21 | #include <__memory/pointer_traits.h> |
| 22 | #include <__utility/move.h> | |
| 23 | #include <compare> | |
| 22 | 24 | #include <concepts> |
| 23 | 25 | #include <type_traits> |
| 24 | 26 | |
| ... | ... | @@ -26,12 +28,9 @@ |
| 26 | 28 | #pragma GCC system_header |
| 27 | 29 | #endif |
| 28 | 30 | |
| 29 | _LIBCPP_PUSH_MACROS | |
| 30 | #include <__undef_macros> | |
| 31 | ||
| 32 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 32 | |
| 34 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 33 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | 34 | |
| 36 | 35 | template<class> |
| 37 | 36 | struct __counted_iterator_concept {}; |
| ... | ... | @@ -97,7 +96,7 @@ public: |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | 98 | _LIBCPP_HIDE_FROM_ABI |
| 100 | constexpr const _Iter& base() const& { return __current_; } | |
| 99 | constexpr const _Iter& base() const& noexcept { return __current_; } | |
| 101 | 100 | |
| 102 | 101 | _LIBCPP_HIDE_FROM_ABI |
| 103 | 102 | constexpr _Iter base() && { return _VSTD::move(__current_); } |
| ... | ... | @@ -297,10 +296,8 @@ struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> { |
| 297 | 296 | add_pointer_t<iter_reference_t<_Iter>>, void>; |
| 298 | 297 | }; |
| 299 | 298 | |
| 300 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 299 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 301 | 300 | |
| 302 | 301 | _LIBCPP_END_NAMESPACE_STD |
| 303 | 302 | |
| 304 | _LIBCPP_POP_MACROS | |
| 305 | ||
| 306 | 303 | #endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H |
lib/libcxx/include/__iterator/data.h-5| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -51,6 +48,4 @@ constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.beg |
| 51 | 48 | |
| 52 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 50 | |
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | 51 | #endif // _LIBCPP___ITERATOR_DATA_H |
lib/libcxx/include/__iterator/default_sentinel.h+2-7| ... | ... | @@ -16,20 +16,15 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | 22 | |
| 26 | 23 | struct default_sentinel_t { }; |
| 27 | 24 | inline constexpr default_sentinel_t default_sentinel{}; |
| 28 | 25 | |
| 29 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 26 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | 27 | |
| 31 | 28 | _LIBCPP_END_NAMESPACE_STD |
| 32 | 29 | |
| 33 | _LIBCPP_POP_MACROS | |
| 34 | ||
| 35 | 30 | #endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H |
lib/libcxx/include/__iterator/distance.h+56-5| ... | ... | @@ -11,15 +11,18 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_DISTANCE_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/incrementable_traits.h> | |
| 14 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__ranges/size.h> | |
| 20 | #include <type_traits> | |
| 15 | 21 | |
| 16 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 23 | #pragma GCC system_header |
| 18 | 24 | #endif |
| 19 | 25 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 27 | |
| 25 | 28 | template <class _InputIter> |
| ... | ... | @@ -49,8 +52,56 @@ distance(_InputIter __first, _InputIter __last) |
| 49 | 52 | return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); |
| 50 | 53 | } |
| 51 | 54 | |
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 55 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 56 | ||
| 57 | // [range.iter.op.distance] | |
| 58 | ||
| 59 | namespace ranges { | |
| 60 | namespace __distance { | |
| 61 | ||
| 62 | struct __fn { | |
| 63 | template<class _Ip, sentinel_for<_Ip> _Sp> | |
| 64 | requires (!sized_sentinel_for<_Sp, _Ip>) | |
| 65 | _LIBCPP_HIDE_FROM_ABI | |
| 66 | constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const { | |
| 67 | iter_difference_t<_Ip> __n = 0; | |
| 68 | while (__first != __last) { | |
| 69 | ++__first; | |
| 70 | ++__n; | |
| 71 | } | |
| 72 | return __n; | |
| 73 | } | |
| 74 | ||
| 75 | template<class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp> | |
| 76 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const { | |
| 78 | if constexpr (sized_sentinel_for<_Sp, __uncvref_t<_Ip>>) { | |
| 79 | return __last - __first; | |
| 80 | } else { | |
| 81 | return __last - decay_t<_Ip>(__first); | |
| 82 | } | |
| 83 | } | |
| 53 | 84 | |
| 54 | _LIBCPP_POP_MACROS | |
| 85 | template<range _Rp> | |
| 86 | _LIBCPP_HIDE_FROM_ABI | |
| 87 | constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const { | |
| 88 | if constexpr (sized_range<_Rp>) { | |
| 89 | return static_cast<range_difference_t<_Rp>>(ranges::size(__r)); | |
| 90 | } else { | |
| 91 | return operator()(ranges::begin(__r), ranges::end(__r)); | |
| 92 | } | |
| 93 | } | |
| 94 | }; | |
| 95 | ||
| 96 | } // namespace __distance | |
| 97 | ||
| 98 | inline namespace __cpo { | |
| 99 | inline constexpr auto distance = __distance::__fn{}; | |
| 100 | } // namespace __cpo | |
| 101 | } // namespace ranges | |
| 102 | ||
| 103 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 104 | ||
| 105 | _LIBCPP_END_NAMESPACE_STD | |
| 55 | 106 | |
| 56 | 107 | #endif // _LIBCPP___ITERATOR_DISTANCE_H |
lib/libcxx/include/__iterator/empty.h-5| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -44,6 +41,4 @@ constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() = |
| 44 | 41 | |
| 45 | 42 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 43 | |
| 47 | _LIBCPP_POP_MACROS | |
| 48 | ||
| 49 | 44 | #endif // _LIBCPP___ITERATOR_EMPTY_H |
lib/libcxx/include/__iterator/erase_if_container.h-5| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | template <class _Container, class _Predicate> |
| ... | ... | @@ -40,6 +37,4 @@ __libcpp_erase_if_container(_Container& __c, _Predicate& __pred) { |
| 40 | 37 | |
| 41 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 39 | |
| 43 | _LIBCPP_POP_MACROS | |
| 44 | ||
| 45 | 40 | #endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H |
lib/libcxx/include/__iterator/front_insert_iterator.h-5| ... | ... | @@ -21,9 +21,6 @@ |
| 21 | 21 | #pragma GCC system_header |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 25 | |
| 29 | 26 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -70,6 +67,4 @@ front_inserter(_Container& __x) |
| 70 | 67 | |
| 71 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 69 | |
| 73 | _LIBCPP_POP_MACROS | |
| 74 | ||
| 75 | 70 | #endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H |
lib/libcxx/include/__iterator/incrementable_traits.h+2-7| ... | ... | @@ -18,12 +18,9 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | 24 | |
| 28 | 25 | // [incrementable.traits] |
| 29 | 26 | template<class> struct incrementable_traits {}; |
| ... | ... | @@ -68,10 +65,8 @@ using iter_difference_t = typename conditional_t<__is_primary_template<iterator_ |
| 68 | 65 | incrementable_traits<remove_cvref_t<_Ip> >, |
| 69 | 66 | iterator_traits<remove_cvref_t<_Ip> > >::difference_type; |
| 70 | 67 | |
| 71 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 68 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 72 | 69 | |
| 73 | 70 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 71 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 72 | #endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H |
lib/libcxx/include/__iterator/indirectly_comparable.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 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_INDIRECTLY_COMPARABLE_H | |
| 11 | #define _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/projected.h> | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | ||
| 22 | template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity> | |
| 23 | concept indirectly_comparable = | |
| 24 | indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>; | |
| 25 | ||
| 26 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___ITERATOR_INDIRECTLY_COMPARABLE_H |
lib/libcxx/include/__iterator/insert_iterator.h+12-8| ... | ... | @@ -14,6 +14,7 @@ |
| 14 | 14 | #include <__iterator/iterator.h> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | #include <__memory/addressof.h> |
| 17 | #include <__ranges/access.h> | |
| 17 | 18 | #include <__utility/move.h> |
| 18 | 19 | #include <cstddef> |
| 19 | 20 | |
| ... | ... | @@ -21,11 +22,16 @@ |
| 21 | 22 | #pragma GCC system_header |
| 22 | 23 | #endif |
| 23 | 24 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | template <class _Container> | |
| 29 | using __insert_iterator_iter_t = ranges::iterator_t<_Container>; | |
| 30 | #else | |
| 31 | template <class _Container> | |
| 32 | using __insert_iterator_iter_t = typename _Container::iterator; | |
| 33 | #endif | |
| 34 | ||
| 29 | 35 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 30 | 36 | template <class _Container> |
| 31 | 37 | class _LIBCPP_TEMPLATE_VIS insert_iterator |
| ... | ... | @@ -36,7 +42,7 @@ class _LIBCPP_TEMPLATE_VIS insert_iterator |
| 36 | 42 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 37 | 43 | protected: |
| 38 | 44 | _Container* container; |
| 39 | typename _Container::iterator iter; // FIXME: `ranges::iterator_t<Container>` in C++20 mode | |
| 45 | __insert_iterator_iter_t<_Container> iter; | |
| 40 | 46 | public: |
| 41 | 47 | typedef output_iterator_tag iterator_category; |
| 42 | 48 | typedef void value_type; |
| ... | ... | @@ -49,7 +55,7 @@ public: |
| 49 | 55 | typedef void reference; |
| 50 | 56 | typedef _Container container_type; |
| 51 | 57 | |
| 52 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i) | |
| 58 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) | |
| 53 | 59 | : container(_VSTD::addressof(__x)), iter(__i) {} |
| 54 | 60 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) |
| 55 | 61 | {iter = container->insert(iter, __value_); ++iter; return *this;} |
| ... | ... | @@ -65,13 +71,11 @@ public: |
| 65 | 71 | template <class _Container> |
| 66 | 72 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 67 | 73 | insert_iterator<_Container> |
| 68 | inserter(_Container& __x, typename _Container::iterator __i) | |
| 74 | inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) | |
| 69 | 75 | { |
| 70 | 76 | return insert_iterator<_Container>(__x, __i); |
| 71 | 77 | } |
| 72 | 78 | |
| 73 | 79 | _LIBCPP_END_NAMESPACE_STD |
| 74 | 80 | |
| 75 | _LIBCPP_POP_MACROS | |
| 76 | ||
| 77 | 81 | #endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H |
lib/libcxx/include/__iterator/istream_iterator.h-11| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -70,12 +67,6 @@ public: |
| 70 | 67 | bool |
| 71 | 68 | operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, |
| 72 | 69 | const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); |
| 73 | ||
| 74 | template <class _Up, class _CharU, class _TraitsU, class _DistanceU> | |
| 75 | friend _LIBCPP_INLINE_VISIBILITY | |
| 76 | bool | |
| 77 | operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, | |
| 78 | const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); | |
| 79 | 70 | }; |
| 80 | 71 | |
| 81 | 72 | template <class _Tp, class _CharT, class _Traits, class _Distance> |
| ... | ... | @@ -98,6 +89,4 @@ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, |
| 98 | 89 | |
| 99 | 90 | _LIBCPP_END_NAMESPACE_STD |
| 100 | 91 | |
| 101 | _LIBCPP_POP_MACROS | |
| 102 | ||
| 103 | 92 | #endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H |
lib/libcxx/include/__iterator/istreambuf_iterator.h-5| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -105,6 +102,4 @@ bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, |
| 105 | 102 | |
| 106 | 103 | _LIBCPP_END_NAMESPACE_STD |
| 107 | 104 | |
| 108 | _LIBCPP_POP_MACROS | |
| 109 | ||
| 110 | 105 | #endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H |
lib/libcxx/include/__iterator/iter_move.h+18-16| ... | ... | @@ -21,20 +21,23 @@ |
| 21 | 21 | #pragma GCC system_header |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 25 | |
| 29 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 26 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | ||
| 28 | // [iterator.cust.move] | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | namespace __iter_move { | |
| 30 | 32 | |
| 31 | namespace ranges::__iter_move { | |
| 32 | 33 | void iter_move(); |
| 33 | 34 | |
| 34 | template<class _Ip> | |
| 35 | concept __unqualified_iter_move = requires(_Ip&& __i) { | |
| 36 | iter_move(_VSTD::forward<_Ip>(__i)); | |
| 37 | }; | |
| 35 | template <class _Tp> | |
| 36 | concept __unqualified_iter_move = | |
| 37 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 38 | requires (_Tp&& __t) { | |
| 39 | iter_move(_VSTD::forward<_Tp>(__t)); | |
| 40 | }; | |
| 38 | 41 | |
| 39 | 42 | // [iterator.cust.move]/1 |
| 40 | 43 | // The name ranges::iter_move denotes a customization point object. |
| ... | ... | @@ -72,20 +75,19 @@ struct __fn { |
| 72 | 75 | // [iterator.cust.move]/1.3 |
| 73 | 76 | // Otherwise, ranges::iter_move(E) is ill-formed. |
| 74 | 77 | }; |
| 75 | } // namespace ranges::__iter_move | |
| 78 | } // namespace __iter_move | |
| 76 | 79 | |
| 77 | namespace ranges::inline __cpo { | |
| 80 | inline namespace __cpo { | |
| 78 | 81 | inline constexpr auto iter_move = __iter_move::__fn{}; |
| 79 | } | |
| 82 | } // namespace __cpo | |
| 83 | } // namespace ranges | |
| 80 | 84 | |
| 81 | 85 | template<__dereferenceable _Tp> |
| 82 | requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } | |
| 86 | requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } | |
| 83 | 87 | using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); |
| 84 | 88 | |
| 85 | #endif // !_LIBCPP_HAS_NO_RANGES | |
| 89 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 86 | 90 | |
| 87 | 91 | _LIBCPP_END_NAMESPACE_STD |
| 88 | 92 | |
| 89 | _LIBCPP_POP_MACROS | |
| 90 | ||
| 91 | 93 | #endif // _LIBCPP___ITERATOR_ITER_MOVE_H |
lib/libcxx/include/__iterator/iter_swap.h+12-13| ... | ... | @@ -14,7 +14,8 @@ |
| 14 | 14 | #include <__iterator/iter_move.h> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | #include <__iterator/readable_traits.h> |
| 17 | #include <__ranges/access.h> | |
| 17 | #include <__utility/forward.h> | |
| 18 | #include <__utility/move.h> | |
| 18 | 19 | #include <concepts> |
| 19 | 20 | #include <type_traits> |
| 20 | 21 | |
| ... | ... | @@ -22,12 +23,11 @@ |
| 22 | 23 | #pragma GCC system_header |
| 23 | 24 | #endif |
| 24 | 25 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 27 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | ||
| 30 | // [iter.cust.swap] | |
| 31 | 31 | |
| 32 | 32 | namespace ranges { |
| 33 | 33 | namespace __iter_swap { |
| ... | ... | @@ -35,9 +35,11 @@ namespace __iter_swap { |
| 35 | 35 | void iter_swap(_I1, _I2) = delete; |
| 36 | 36 | |
| 37 | 37 | template<class _T1, class _T2> |
| 38 | concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) { | |
| 39 | iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); | |
| 40 | }; | |
| 38 | concept __unqualified_iter_swap = | |
| 39 | (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) && | |
| 40 | requires (_T1&& __x, _T2&& __y) { | |
| 41 | iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); | |
| 42 | }; | |
| 41 | 43 | |
| 42 | 44 | template<class _T1, class _T2> |
| 43 | 45 | concept __readable_swappable = |
| ... | ... | @@ -80,12 +82,11 @@ namespace __iter_swap { |
| 80 | 82 | *_VSTD::forward<_T1>(__x) = _VSTD::move(__old); |
| 81 | 83 | } |
| 82 | 84 | }; |
| 83 | } // end namespace __iter_swap | |
| 85 | } // namespace __iter_swap | |
| 84 | 86 | |
| 85 | 87 | inline namespace __cpo { |
| 86 | 88 | inline constexpr auto iter_swap = __iter_swap::__fn{}; |
| 87 | 89 | } // namespace __cpo |
| 88 | ||
| 89 | 90 | } // namespace ranges |
| 90 | 91 | |
| 91 | 92 | template<class _I1, class _I2 = _I1> |
| ... | ... | @@ -98,10 +99,8 @@ concept indirectly_swappable = |
| 98 | 99 | ranges::iter_swap(__i2, __i1); |
| 99 | 100 | }; |
| 100 | 101 | |
| 101 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 102 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 102 | 103 | |
| 103 | 104 | _LIBCPP_END_NAMESPACE_STD |
| 104 | 105 | |
| 105 | _LIBCPP_POP_MACROS | |
| 106 | ||
| 107 | 106 | #endif // _LIBCPP___ITERATOR_ITER_SWAP_H |
lib/libcxx/include/__iterator/iterator.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template<class _Category, class _Tp, class _Distance = ptrdiff_t, |
| ... | ... | @@ -35,6 +32,4 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator |
| 35 | 32 | |
| 36 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 34 | |
| 38 | _LIBCPP_POP_MACROS | |
| 39 | ||
| 40 | 35 | #endif // _LIBCPP___ITERATOR_ITERATOR_H |
lib/libcxx/include/__iterator/iterator_traits.h+9-14| ... | ... | @@ -20,12 +20,9 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | 26 | |
| 30 | 27 | template <class _Tp> |
| 31 | 28 | using __with_reference = _Tp&; |
| ... | ... | @@ -44,7 +41,7 @@ concept __dereferenceable = requires(_Tp& __t) { |
| 44 | 41 | template<__dereferenceable _Tp> |
| 45 | 42 | using iter_reference_t = decltype(*declval<_Tp&>()); |
| 46 | 43 | |
| 47 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 44 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 48 | 45 | |
| 49 | 46 | template <class _Iter> |
| 50 | 47 | struct _LIBCPP_TEMPLATE_VIS iterator_traits; |
| ... | ... | @@ -79,7 +76,7 @@ struct __iter_concept_category_test { |
| 79 | 76 | }; |
| 80 | 77 | struct __iter_concept_random_fallback { |
| 81 | 78 | template <class _Iter> |
| 82 | using _Apply = _EnableIf< | |
| 79 | using _Apply = __enable_if_t< | |
| 83 | 80 | __is_primary_template<iterator_traits<_Iter> >::value, |
| 84 | 81 | random_access_iterator_tag |
| 85 | 82 | >; |
| ... | ... | @@ -142,7 +139,7 @@ public: |
| 142 | 139 | static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; |
| 143 | 140 | }; |
| 144 | 141 | |
| 145 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 142 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 146 | 143 | |
| 147 | 144 | // The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, |
| 148 | 145 | // so they've been banished to a namespace that makes it obvious they have a niche use-case. |
| ... | ... | @@ -365,7 +362,7 @@ struct iterator_traits : __iterator_traits<_Ip> { |
| 365 | 362 | using __primary_template = iterator_traits; |
| 366 | 363 | }; |
| 367 | 364 | |
| 368 | #else // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 365 | #else // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 369 | 366 | |
| 370 | 367 | template <class _Iter, bool> struct __iterator_traits {}; |
| 371 | 368 | |
| ... | ... | @@ -402,10 +399,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits |
| 402 | 399 | |
| 403 | 400 | using __primary_template = iterator_traits; |
| 404 | 401 | }; |
| 405 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 402 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 406 | 403 | |
| 407 | 404 | template<class _Tp> |
| 408 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 405 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 409 | 406 | requires is_object_v<_Tp> |
| 410 | 407 | #endif |
| 411 | 408 | struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> |
| ... | ... | @@ -477,7 +474,7 @@ struct __is_exactly_cpp17_input_iterator |
| 477 | 474 | __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && |
| 478 | 475 | !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; |
| 479 | 476 | |
| 480 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 477 | #if _LIBCPP_STD_VER >= 17 | |
| 481 | 478 | template<class _InputIterator> |
| 482 | 479 | using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; |
| 483 | 480 | |
| ... | ... | @@ -491,10 +488,8 @@ template<class _InputIterator> |
| 491 | 488 | using __iter_to_alloc_type = pair< |
| 492 | 489 | add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>, |
| 493 | 490 | typename iterator_traits<_InputIterator>::value_type::second_type>; |
| 494 | #endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 491 | #endif // _LIBCPP_STD_VER >= 17 | |
| 495 | 492 | |
| 496 | 493 | _LIBCPP_END_NAMESPACE_STD |
| 497 | 494 | |
| 498 | _LIBCPP_POP_MACROS | |
| 499 | ||
| 500 | 495 | #endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H |
lib/libcxx/include/__iterator/move_iterator.h+76-80| ... | ... | @@ -12,33 +12,32 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__utility/move.h> | |
| 15 | 16 | #include <type_traits> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | 19 | #pragma GCC system_header |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 23 | |
| 26 | 24 | template <class _Iter> |
| 27 | 25 | class _LIBCPP_TEMPLATE_VIS move_iterator |
| 28 | 26 | { |
| 29 | private: | |
| 30 | _Iter __i; | |
| 31 | 27 | public: |
| 32 | typedef _Iter iterator_type; | |
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | typedef input_iterator_tag iterator_concept; | |
| 30 | #endif | |
| 31 | ||
| 32 | typedef _Iter iterator_type; | |
| 33 | typedef _If< | |
| 34 | __is_cpp17_random_access_iterator<_Iter>::value, | |
| 35 | random_access_iterator_tag, | |
| 36 | typename iterator_traits<_Iter>::iterator_category | |
| 37 | > iterator_category; | |
| 33 | 38 | typedef typename iterator_traits<iterator_type>::value_type value_type; |
| 34 | 39 | typedef typename iterator_traits<iterator_type>::difference_type difference_type; |
| 35 | 40 | typedef iterator_type pointer; |
| 36 | typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, | |
| 37 | random_access_iterator_tag, | |
| 38 | typename iterator_traits<_Iter>::iterator_category> iterator_category; | |
| 39 | #if _LIBCPP_STD_VER > 17 | |
| 40 | typedef input_iterator_tag iterator_concept; | |
| 41 | #endif | |
| 42 | 41 | |
| 43 | 42 | #ifndef _LIBCPP_CXX03_LANG |
| 44 | 43 | typedef typename iterator_traits<iterator_type>::reference __reference; |
| ... | ... | @@ -51,114 +50,113 @@ public: |
| 51 | 50 | typedef typename iterator_traits<iterator_type>::reference reference; |
| 52 | 51 | #endif |
| 53 | 52 | |
| 54 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 55 | move_iterator() : __i() {} | |
| 53 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 54 | move_iterator() : __current_() {} | |
| 56 | 55 | |
| 57 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 58 | explicit move_iterator(_Iter __x) : __i(__x) {} | |
| 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 57 | explicit move_iterator(_Iter __i) : __current_(_VSTD::move(__i)) {} | |
| 59 | 58 | |
| 60 | template <class _Up, class = _EnableIf< | |
| 61 | !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value | |
| 59 | template <class _Up, class = __enable_if_t< | |
| 60 | !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value | |
| 62 | 61 | > > |
| 63 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 64 | move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} | |
| 62 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 63 | move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {} | |
| 65 | 64 | |
| 66 | template <class _Up, class = _EnableIf< | |
| 65 | template <class _Up, class = __enable_if_t< | |
| 67 | 66 | !is_same<_Up, _Iter>::value && |
| 68 | is_convertible<_Up const&, _Iter>::value && | |
| 69 | is_assignable<_Iter&, _Up const&>::value | |
| 67 | is_convertible<const _Up&, _Iter>::value && | |
| 68 | is_assignable<_Iter&, const _Up&>::value | |
| 70 | 69 | > > |
| 71 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 70 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 72 | 71 | move_iterator& operator=(const move_iterator<_Up>& __u) { |
| 73 | __i = __u.base(); | |
| 72 | __current_ = __u.base(); | |
| 74 | 73 | return *this; |
| 75 | 74 | } |
| 76 | 75 | |
| 77 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} | |
| 78 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 79 | reference operator*() const { return static_cast<reference>(*__i); } | |
| 80 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 81 | pointer operator->() const { return __i;} | |
| 82 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 83 | move_iterator& operator++() {++__i; return *this;} | |
| 84 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 85 | move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} | |
| 86 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 87 | move_iterator& operator--() {--__i; return *this;} | |
| 88 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 89 | move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} | |
| 90 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 91 | move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} | |
| 92 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 93 | move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} | |
| 94 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 95 | move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} | |
| 96 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 97 | move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} | |
| 98 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 99 | reference operator[](difference_type __n) const { return static_cast<reference>(__i[__n]); } | |
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 77 | _Iter base() const { return __current_; } | |
| 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 80 | reference operator*() const { return static_cast<reference>(*__current_); } | |
| 81 | _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]); } | |
| 85 | ||
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 87 | move_iterator& operator++() { ++__current_; return *this; } | |
| 88 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 89 | move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; } | |
| 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 91 | move_iterator& operator--() { --__current_; return *this; } | |
| 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 93 | move_iterator operator--(int) { move_iterator __tmp(*this); --__current_; return __tmp; } | |
| 94 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 95 | move_iterator operator+(difference_type __n) const { return move_iterator(__current_ + __n); } | |
| 96 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 97 | move_iterator& operator+=(difference_type __n) { __current_ += __n; return *this; } | |
| 98 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 99 | move_iterator operator-(difference_type __n) const { return move_iterator(__current_ - __n); } | |
| 100 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 101 | move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; } | |
| 102 | ||
| 103 | private: | |
| 104 | _Iter __current_; | |
| 100 | 105 | }; |
| 101 | 106 | |
| 102 | 107 | template <class _Iter1, class _Iter2> |
| 103 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 104 | bool | |
| 105 | operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 108 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 109 | bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 106 | 110 | { |
| 107 | 111 | return __x.base() == __y.base(); |
| 108 | 112 | } |
| 109 | 113 | |
| 110 | 114 | template <class _Iter1, class _Iter2> |
| 111 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 112 | bool | |
| 113 | operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 115 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 116 | bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 114 | 117 | { |
| 115 | return __x.base() < __y.base(); | |
| 118 | return __x.base() != __y.base(); | |
| 116 | 119 | } |
| 117 | 120 | |
| 118 | 121 | template <class _Iter1, class _Iter2> |
| 119 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 120 | bool | |
| 121 | operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 122 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 123 | bool operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 122 | 124 | { |
| 123 | return __x.base() != __y.base(); | |
| 125 | return __x.base() < __y.base(); | |
| 124 | 126 | } |
| 125 | 127 | |
| 126 | 128 | template <class _Iter1, class _Iter2> |
| 127 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 128 | bool | |
| 129 | operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 129 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 130 | bool operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 130 | 131 | { |
| 131 | 132 | return __x.base() > __y.base(); |
| 132 | 133 | } |
| 133 | 134 | |
| 134 | 135 | template <class _Iter1, class _Iter2> |
| 135 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 136 | bool | |
| 137 | operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 136 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 137 | bool operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 138 | 138 | { |
| 139 | return __x.base() >= __y.base(); | |
| 139 | return __x.base() <= __y.base(); | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | template <class _Iter1, class _Iter2> |
| 143 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 144 | bool | |
| 145 | operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 143 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 144 | bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 146 | 145 | { |
| 147 | return __x.base() <= __y.base(); | |
| 146 | return __x.base() >= __y.base(); | |
| 148 | 147 | } |
| 149 | 148 | |
| 150 | 149 | #ifndef _LIBCPP_CXX03_LANG |
| 151 | 150 | template <class _Iter1, class _Iter2> |
| 152 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 153 | auto | |
| 154 | operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 155 | -> decltype(__x.base() - __y.base()) | |
| 151 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 152 | auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 153 | -> decltype(__x.base() - __y.base()) | |
| 156 | 154 | { |
| 157 | 155 | return __x.base() - __y.base(); |
| 158 | 156 | } |
| 159 | 157 | #else |
| 160 | 158 | template <class _Iter1, class _Iter2> |
| 161 | inline _LIBCPP_INLINE_VISIBILITY | |
| 159 | inline _LIBCPP_HIDE_FROM_ABI | |
| 162 | 160 | typename move_iterator<_Iter1>::difference_type |
| 163 | 161 | operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) |
| 164 | 162 | { |
| ... | ... | @@ -167,7 +165,7 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) |
| 167 | 165 | #endif |
| 168 | 166 | |
| 169 | 167 | template <class _Iter> |
| 170 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 168 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 171 | 169 | move_iterator<_Iter> |
| 172 | 170 | operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) |
| 173 | 171 | { |
| ... | ... | @@ -175,15 +173,13 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato |
| 175 | 173 | } |
| 176 | 174 | |
| 177 | 175 | template <class _Iter> |
| 178 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 176 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 179 | 177 | move_iterator<_Iter> |
| 180 | 178 | make_move_iterator(_Iter __i) |
| 181 | 179 | { |
| 182 | return move_iterator<_Iter>(__i); | |
| 180 | return move_iterator<_Iter>(_VSTD::move(__i)); | |
| 183 | 181 | } |
| 184 | 182 | |
| 185 | 183 | _LIBCPP_END_NAMESPACE_STD |
| 186 | 184 | |
| 187 | _LIBCPP_POP_MACROS | |
| 188 | ||
| 189 | 185 | #endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H |
lib/libcxx/include/__iterator/next.h+12-13| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__debug> |
| 15 | #include <__function_like.h> | |
| 16 | 15 | #include <__iterator/advance.h> |
| 17 | 16 | #include <__iterator/concepts.h> |
| 18 | 17 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -23,9 +22,6 @@ |
| 23 | 22 | #pragma GCC system_header |
| 24 | 23 | #endif |
| 25 | 24 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 26 | |
| 31 | 27 | template <class _InputIter> |
| ... | ... | @@ -39,13 +35,14 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 39 | 35 | return __x; |
| 40 | 36 | } |
| 41 | 37 | |
| 42 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 38 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 39 | ||
| 40 | // [range.iter.op.next] | |
| 43 | 41 | |
| 44 | 42 | namespace ranges { |
| 45 | struct __next_fn final : private __function_like { | |
| 46 | _LIBCPP_HIDE_FROM_ABI | |
| 47 | constexpr explicit __next_fn(__tag __x) noexcept : __function_like(__x) {} | |
| 43 | namespace __next { | |
| 48 | 44 | |
| 45 | struct __fn { | |
| 49 | 46 | template <input_or_output_iterator _Ip> |
| 50 | 47 | _LIBCPP_HIDE_FROM_ABI |
| 51 | 48 | constexpr _Ip operator()(_Ip __x) const { |
| ... | ... | @@ -75,13 +72,15 @@ struct __next_fn final : private __function_like { |
| 75 | 72 | } |
| 76 | 73 | }; |
| 77 | 74 | |
| 78 | inline constexpr auto next = __next_fn(__function_like::__tag()); | |
| 75 | } // namespace __next | |
| 76 | ||
| 77 | inline namespace __cpo { | |
| 78 | inline constexpr auto next = __next::__fn{}; | |
| 79 | } // namespace __cpo | |
| 79 | 80 | } // namespace ranges |
| 80 | 81 | |
| 81 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 82 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 82 | 83 | |
| 83 | 84 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 85 | |
| 85 | _LIBCPP_POP_MACROS | |
| 86 | ||
| 87 | #endif // _LIBCPP___ITERATOR_PRIMITIVES_H | |
| 86 | #endif // _LIBCPP___ITERATOR_NEXT_H |
lib/libcxx/include/__iterator/ostream_iterator.h-5| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -70,6 +67,4 @@ public: |
| 70 | 67 | |
| 71 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 69 | |
| 73 | _LIBCPP_POP_MACROS | |
| 74 | ||
| 75 | 70 | #endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H |
lib/libcxx/include/__iterator/ostreambuf_iterator.h-5| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -76,6 +73,4 @@ public: |
| 76 | 73 | |
| 77 | 74 | _LIBCPP_END_NAMESPACE_STD |
| 78 | 75 | |
| 79 | _LIBCPP_POP_MACROS | |
| 80 | ||
| 81 | 76 | #endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H |
lib/libcxx/include/__iterator/prev.h+11-12| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__debug> |
| 15 | #include <__function_like.h> | |
| 16 | 15 | #include <__iterator/advance.h> |
| 17 | 16 | #include <__iterator/concepts.h> |
| 18 | 17 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -23,9 +22,6 @@ |
| 23 | 22 | #pragma GCC system_header |
| 24 | 23 | #endif |
| 25 | 24 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 26 | |
| 31 | 27 | template <class _InputIter> |
| ... | ... | @@ -38,13 +34,14 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 38 | 34 | return __x; |
| 39 | 35 | } |
| 40 | 36 | |
| 41 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 37 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | ||
| 39 | // [range.iter.op.prev] | |
| 42 | 40 | |
| 43 | 41 | namespace ranges { |
| 44 | struct __prev_fn final : private __function_like { | |
| 45 | _LIBCPP_HIDE_FROM_ABI | |
| 46 | constexpr explicit __prev_fn(__tag __x) noexcept : __function_like(__x) {} | |
| 42 | namespace __prev { | |
| 47 | 43 | |
| 44 | struct __fn { | |
| 48 | 45 | template <bidirectional_iterator _Ip> |
| 49 | 46 | _LIBCPP_HIDE_FROM_ABI |
| 50 | 47 | constexpr _Ip operator()(_Ip __x) const { |
| ... | ... | @@ -67,13 +64,15 @@ struct __prev_fn final : private __function_like { |
| 67 | 64 | } |
| 68 | 65 | }; |
| 69 | 66 | |
| 70 | inline constexpr auto prev = __prev_fn(__function_like::__tag()); | |
| 67 | } // namespace __prev | |
| 68 | ||
| 69 | inline namespace __cpo { | |
| 70 | inline constexpr auto prev = __prev::__fn{}; | |
| 71 | } // namespace __cpo | |
| 71 | 72 | } // namespace ranges |
| 72 | 73 | |
| 73 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 74 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 74 | 75 | |
| 75 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 76 | 77 | |
| 77 | _LIBCPP_POP_MACROS | |
| 78 | ||
| 79 | 78 | #endif // _LIBCPP___ITERATOR_PREV_H |
lib/libcxx/include/__iterator/projected.h+2-7| ... | ... | @@ -18,12 +18,9 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | 24 | |
| 28 | 25 | template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> |
| 29 | 26 | struct projected { |
| ... | ... | @@ -36,10 +33,8 @@ struct incrementable_traits<projected<_It, _Proj>> { |
| 36 | 33 | using difference_type = iter_difference_t<_It>; |
| 37 | 34 | }; |
| 38 | 35 | |
| 39 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 40 | 37 | |
| 41 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 39 | |
| 43 | _LIBCPP_POP_MACROS | |
| 44 | ||
| 45 | 40 | #endif // _LIBCPP___ITERATOR_PROJECTED_H |
lib/libcxx/include/__iterator/readable_traits.h+7-12| ... | ... | @@ -18,12 +18,9 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | 24 | |
| 28 | 25 | // [readable.traits] |
| 29 | 26 | template<class> struct __cond_value_type {}; |
| ... | ... | @@ -60,14 +57,14 @@ template<__has_member_element_type _Tp> |
| 60 | 57 | struct indirectly_readable_traits<_Tp> |
| 61 | 58 | : __cond_value_type<typename _Tp::element_type> {}; |
| 62 | 59 | |
| 63 | // Pre-emptively applies LWG3541 | |
| 64 | 60 | template<__has_member_value_type _Tp> |
| 65 | requires __has_member_element_type<_Tp> | |
| 61 | requires __has_member_element_type<_Tp> | |
| 66 | 62 | struct indirectly_readable_traits<_Tp> {}; |
| 63 | ||
| 67 | 64 | template<__has_member_value_type _Tp> |
| 68 | requires __has_member_element_type<_Tp> && | |
| 69 | same_as<remove_cv_t<typename _Tp::element_type>, | |
| 70 | remove_cv_t<typename _Tp::value_type>> | |
| 65 | requires __has_member_element_type<_Tp> && | |
| 66 | same_as<remove_cv_t<typename _Tp::element_type>, | |
| 67 | remove_cv_t<typename _Tp::value_type>> | |
| 71 | 68 | struct indirectly_readable_traits<_Tp> |
| 72 | 69 | : __cond_value_type<typename _Tp::value_type> {}; |
| 73 | 70 | |
| ... | ... | @@ -82,10 +79,8 @@ using iter_value_t = typename conditional_t<__is_primary_template<iterator_trait |
| 82 | 79 | indirectly_readable_traits<remove_cvref_t<_Ip> >, |
| 83 | 80 | iterator_traits<remove_cvref_t<_Ip> > >::value_type; |
| 84 | 81 | |
| 85 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 82 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 86 | 83 | |
| 87 | 84 | _LIBCPP_END_NAMESPACE_STD |
| 88 | 85 | |
| 89 | _LIBCPP_POP_MACROS | |
| 90 | ||
| 91 | 86 | #endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H |
lib/libcxx/include/__iterator/reverse_access.h-5| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | #if !defined(_LIBCPP_CXX03_LANG) |
| ... | ... | @@ -104,6 +101,4 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) |
| 104 | 101 | |
| 105 | 102 | _LIBCPP_END_NAMESPACE_STD |
| 106 | 103 | |
| 107 | _LIBCPP_POP_MACROS | |
| 108 | ||
| 109 | 104 | #endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H |
lib/libcxx/include/__iterator/reverse_iterator.h+18-22| ... | ... | @@ -10,6 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H |
| 12 | 12 | |
| 13 | #include <__compare/compare_three_way_result.h> | |
| 14 | #include <__compare/three_way_comparable.h> | |
| 13 | 15 | #include <__config> |
| 14 | 16 | #include <__iterator/iterator.h> |
| 15 | 17 | #include <__iterator/iterator_traits.h> |
| ... | ... | @@ -20,18 +22,8 @@ |
| 20 | 22 | #pragma GCC system_header |
| 21 | 23 | #endif |
| 22 | 24 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 26 | |
| 28 | template <class _Tp, class = void> | |
| 29 | struct __is_stashing_iterator : false_type {}; | |
| 30 | ||
| 31 | template <class _Tp> | |
| 32 | struct __is_stashing_iterator<_Tp, typename __void_t<typename _Tp::__stashing_iterator_tag>::type> | |
| 33 | : true_type {}; | |
| 34 | ||
| 35 | 27 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 36 | 28 | template <class _Iter> |
| 37 | 29 | class _LIBCPP_TEMPLATE_VIS reverse_iterator |
| ... | ... | @@ -49,10 +41,6 @@ private: |
| 49 | 41 | _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break |
| 50 | 42 | #endif |
| 51 | 43 | |
| 52 | static_assert(!__is_stashing_iterator<_Iter>::value, | |
| 53 | "The specified iterator type cannot be used with reverse_iterator; " | |
| 54 | "Using stashing iterators with reverse_iterator causes undefined behavior"); | |
| 55 | ||
| 56 | 44 | protected: |
| 57 | 45 | _Iter current; |
| 58 | 46 | public: |
| ... | ... | @@ -78,7 +66,7 @@ public: |
| 78 | 66 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 79 | 67 | explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} |
| 80 | 68 | |
| 81 | template <class _Up, class = _EnableIf< | |
| 69 | template <class _Up, class = __enable_if_t< | |
| 82 | 70 | !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value |
| 83 | 71 | > > |
| 84 | 72 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -86,10 +74,10 @@ public: |
| 86 | 74 | : __t(__u.base()), current(__u.base()) |
| 87 | 75 | { } |
| 88 | 76 | |
| 89 | template <class _Up, class = _EnableIf< | |
| 77 | template <class _Up, class = __enable_if_t< | |
| 90 | 78 | !is_same<_Up, _Iter>::value && |
| 91 | 79 | is_convertible<_Up const&, _Iter>::value && |
| 92 | is_assignable<_Up const&, _Iter>::value | |
| 80 | is_assignable<_Iter&, _Up const&>::value | |
| 93 | 81 | > > |
| 94 | 82 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 95 | 83 | reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { |
| ... | ... | @@ -103,7 +91,7 @@ public: |
| 103 | 91 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 104 | 92 | explicit reverse_iterator(_Iter __x) : current(__x) {} |
| 105 | 93 | |
| 106 | template <class _Up, class = _EnableIf< | |
| 94 | template <class _Up, class = __enable_if_t< | |
| 107 | 95 | !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value |
| 108 | 96 | > > |
| 109 | 97 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -111,10 +99,10 @@ public: |
| 111 | 99 | : current(__u.base()) |
| 112 | 100 | { } |
| 113 | 101 | |
| 114 | template <class _Up, class = _EnableIf< | |
| 102 | template <class _Up, class = __enable_if_t< | |
| 115 | 103 | !is_same<_Up, _Iter>::value && |
| 116 | 104 | is_convertible<_Up const&, _Iter>::value && |
| 117 | is_assignable<_Up const&, _Iter>::value | |
| 105 | is_assignable<_Iter&, _Up const&>::value | |
| 118 | 106 | > > |
| 119 | 107 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 120 | 108 | reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { |
| ... | ... | @@ -196,6 +184,16 @@ operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& |
| 196 | 184 | return __x.base() >= __y.base(); |
| 197 | 185 | } |
| 198 | 186 | |
| 187 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 188 | template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2> | |
| 189 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 190 | compare_three_way_result_t<_Iter1, _Iter2> | |
| 191 | operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) | |
| 192 | { | |
| 193 | return __y.base() <=> __x.base(); | |
| 194 | } | |
| 195 | #endif | |
| 196 | ||
| 199 | 197 | #ifndef _LIBCPP_CXX03_LANG |
| 200 | 198 | template <class _Iter1, class _Iter2> |
| 201 | 199 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -234,6 +232,4 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) |
| 234 | 232 | |
| 235 | 233 | _LIBCPP_END_NAMESPACE_STD |
| 236 | 234 | |
| 237 | _LIBCPP_POP_MACROS | |
| 238 | ||
| 239 | 235 | #endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H |
lib/libcxx/include/__iterator/size.h-5| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -53,6 +50,4 @@ constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } |
| 53 | 50 | |
| 54 | 51 | _LIBCPP_END_NAMESPACE_STD |
| 55 | 52 | |
| 56 | _LIBCPP_POP_MACROS | |
| 57 | ||
| 58 | 53 | #endif // _LIBCPP___ITERATOR_SIZE_H |
lib/libcxx/include/__iterator/unreachable_sentinel.h created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 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_UNREACHABLE_SENTINEL_H | |
| 11 | #define _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.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 !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | ||
| 24 | struct unreachable_sentinel_t { | |
| 25 | template<weakly_incrementable _Iter> | |
| 26 | _LIBCPP_HIDE_FROM_ABI | |
| 27 | friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&) noexcept { | |
| 28 | return false; | |
| 29 | } | |
| 30 | }; | |
| 31 | ||
| 32 | inline constexpr unreachable_sentinel_t unreachable_sentinel{}; | |
| 33 | ||
| 34 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | ||
| 36 | _LIBCPP_END_NAMESPACE_STD | |
| 37 | ||
| 38 | #endif // _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H |
lib/libcxx/include/__iterator/wrap_iter.h+76-91| ... | ... | @@ -13,16 +13,14 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__debug> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__memory/pointer_traits.h> // __to_address | |
| 16 | #include <__memory/addressof.h> | |
| 17 | #include <__memory/pointer_traits.h> | |
| 17 | 18 | #include <type_traits> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 21 | #pragma GCC system_header |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 25 | |
| 28 | 26 | template <class _Iter> |
| ... | ... | @@ -42,120 +40,109 @@ public: |
| 42 | 40 | private: |
| 43 | 41 | iterator_type __i; |
| 44 | 42 | public: |
| 45 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT | |
| 46 | #if _LIBCPP_STD_VER > 11 | |
| 47 | : __i{} | |
| 48 | #endif | |
| 43 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter() _NOEXCEPT | |
| 44 | : __i() | |
| 49 | 45 | { |
| 50 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 51 | __get_db()->__insert_i(this); | |
| 52 | #endif | |
| 46 | _VSTD::__debug_db_insert_i(this); | |
| 53 | 47 | } |
| 54 | template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 48 | template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 55 | 49 | __wrap_iter(const __wrap_iter<_Up>& __u, |
| 56 | 50 | typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT |
| 57 | 51 | : __i(__u.base()) |
| 58 | 52 | { |
| 59 | 53 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 60 | __get_db()->__iterator_copy(this, &__u); | |
| 54 | if (!__libcpp_is_constant_evaluated()) | |
| 55 | __get_db()->__iterator_copy(this, _VSTD::addressof(__u)); | |
| 61 | 56 | #endif |
| 62 | 57 | } |
| 63 | 58 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 64 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 59 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 65 | 60 | __wrap_iter(const __wrap_iter& __x) |
| 66 | 61 | : __i(__x.base()) |
| 67 | 62 | { |
| 68 | __get_db()->__iterator_copy(this, &__x); | |
| 63 | if (!__libcpp_is_constant_evaluated()) | |
| 64 | __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); | |
| 69 | 65 | } |
| 70 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 66 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 71 | 67 | __wrap_iter& operator=(const __wrap_iter& __x) |
| 72 | 68 | { |
| 73 | if (this != &__x) | |
| 69 | if (this != _VSTD::addressof(__x)) | |
| 74 | 70 | { |
| 75 | __get_db()->__iterator_copy(this, &__x); | |
| 71 | if (!__libcpp_is_constant_evaluated()) | |
| 72 | __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); | |
| 76 | 73 | __i = __x.__i; |
| 77 | 74 | } |
| 78 | 75 | return *this; |
| 79 | 76 | } |
| 80 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 77 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 81 | 78 | ~__wrap_iter() |
| 82 | 79 | { |
| 80 | if (!__libcpp_is_constant_evaluated()) | |
| 83 | 81 | __get_db()->__erase_i(this); |
| 84 | 82 | } |
| 85 | 83 | #endif |
| 86 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT | |
| 84 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT | |
| 87 | 85 | { |
| 88 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 89 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 90 | "Attempted to dereference a non-dereferenceable iterator"); | |
| 91 | #endif | |
| 86 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 87 | "Attempted to dereference a non-dereferenceable iterator"); | |
| 92 | 88 | return *__i; |
| 93 | 89 | } |
| 94 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT | |
| 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT | |
| 95 | 91 | { |
| 96 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 97 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 98 | "Attempted to dereference a non-dereferenceable iterator"); | |
| 99 | #endif | |
| 92 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 93 | "Attempted to dereference a non-dereferenceable iterator"); | |
| 100 | 94 | return _VSTD::__to_address(__i); |
| 101 | 95 | } |
| 102 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT | |
| 96 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator++() _NOEXCEPT | |
| 103 | 97 | { |
| 104 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 105 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 106 | "Attempted to increment a non-incrementable iterator"); | |
| 107 | #endif | |
| 98 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 99 | "Attempted to increment a non-incrementable iterator"); | |
| 108 | 100 | ++__i; |
| 109 | 101 | return *this; |
| 110 | 102 | } |
| 111 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT | |
| 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator++(int) _NOEXCEPT | |
| 112 | 104 | {__wrap_iter __tmp(*this); ++(*this); return __tmp;} |
| 113 | 105 | |
| 114 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT | |
| 106 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator--() _NOEXCEPT | |
| 115 | 107 | { |
| 116 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 117 | _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), | |
| 118 | "Attempted to decrement a non-decrementable iterator"); | |
| 119 | #endif | |
| 108 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this), | |
| 109 | "Attempted to decrement a non-decrementable iterator"); | |
| 120 | 110 | --__i; |
| 121 | 111 | return *this; |
| 122 | 112 | } |
| 123 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT | |
| 113 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator--(int) _NOEXCEPT | |
| 124 | 114 | {__wrap_iter __tmp(*this); --(*this); return __tmp;} |
| 125 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT | |
| 115 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator+ (difference_type __n) const _NOEXCEPT | |
| 126 | 116 | {__wrap_iter __w(*this); __w += __n; return __w;} |
| 127 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT | |
| 117 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator+=(difference_type __n) _NOEXCEPT | |
| 128 | 118 | { |
| 129 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 130 | _LIBCPP_ASSERT(__get_const_db()->__addable(this, __n), | |
| 131 | "Attempted to add/subtract an iterator outside its valid range"); | |
| 132 | #endif | |
| 119 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__addable(this, __n), | |
| 120 | "Attempted to add/subtract an iterator outside its valid range"); | |
| 133 | 121 | __i += __n; |
| 134 | 122 | return *this; |
| 135 | 123 | } |
| 136 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT | |
| 124 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter operator- (difference_type __n) const _NOEXCEPT | |
| 137 | 125 | {return *this + (-__n);} |
| 138 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT | |
| 126 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT | |
| 139 | 127 | {*this += -__n; return *this;} |
| 140 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT | |
| 128 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT | |
| 141 | 129 | { |
| 142 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 143 | _LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n), | |
| 144 | "Attempted to subscript an iterator outside its valid range"); | |
| 145 | #endif | |
| 130 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__subscriptable(this, __n), | |
| 131 | "Attempted to subscript an iterator outside its valid range"); | |
| 146 | 132 | return __i[__n]; |
| 147 | 133 | } |
| 148 | 134 | |
| 149 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;} | |
| 135 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;} | |
| 150 | 136 | |
| 151 | 137 | private: |
| 152 | 138 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 153 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) | |
| 139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(const void* __p, iterator_type __x) : __i(__x) | |
| 154 | 140 | { |
| 141 | if (!__libcpp_is_constant_evaluated()) | |
| 155 | 142 | __get_db()->__insert_ic(this, __p); |
| 156 | 143 | } |
| 157 | 144 | #else |
| 158 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} | |
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} | |
| 159 | 146 | #endif |
| 160 | 147 | |
| 161 | 148 | template <class _Up> friend class __wrap_iter; |
| ... | ... | @@ -165,99 +152,95 @@ private: |
| 165 | 152 | }; |
| 166 | 153 | |
| 167 | 154 | template <class _Iter1> |
| 168 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 155 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 169 | 156 | bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT |
| 170 | 157 | { |
| 171 | 158 | return __x.base() == __y.base(); |
| 172 | 159 | } |
| 173 | 160 | |
| 174 | 161 | template <class _Iter1, class _Iter2> |
| 175 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 162 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 176 | 163 | bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 177 | 164 | { |
| 178 | 165 | return __x.base() == __y.base(); |
| 179 | 166 | } |
| 180 | 167 | |
| 181 | 168 | template <class _Iter1> |
| 182 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 169 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 183 | 170 | bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT |
| 184 | 171 | { |
| 185 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 186 | _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), | |
| 187 | "Attempted to compare incomparable iterators"); | |
| 188 | #endif | |
| 172 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)), | |
| 173 | "Attempted to compare incomparable iterators"); | |
| 189 | 174 | return __x.base() < __y.base(); |
| 190 | 175 | } |
| 191 | 176 | |
| 192 | 177 | template <class _Iter1, class _Iter2> |
| 193 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 194 | 179 | bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 195 | 180 | { |
| 196 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 197 | _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), | |
| 198 | "Attempted to compare incomparable iterators"); | |
| 199 | #endif | |
| 181 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), | |
| 182 | "Attempted to compare incomparable iterators"); | |
| 200 | 183 | return __x.base() < __y.base(); |
| 201 | 184 | } |
| 202 | 185 | |
| 203 | 186 | template <class _Iter1> |
| 204 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 187 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 205 | 188 | bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT |
| 206 | 189 | { |
| 207 | 190 | return !(__x == __y); |
| 208 | 191 | } |
| 209 | 192 | |
| 210 | 193 | template <class _Iter1, class _Iter2> |
| 211 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 194 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 212 | 195 | bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 213 | 196 | { |
| 214 | 197 | return !(__x == __y); |
| 215 | 198 | } |
| 216 | 199 | |
| 217 | 200 | template <class _Iter1> |
| 218 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 201 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 219 | 202 | bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT |
| 220 | 203 | { |
| 221 | 204 | return __y < __x; |
| 222 | 205 | } |
| 223 | 206 | |
| 224 | 207 | template <class _Iter1, class _Iter2> |
| 225 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 208 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 226 | 209 | bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 227 | 210 | { |
| 228 | 211 | return __y < __x; |
| 229 | 212 | } |
| 230 | 213 | |
| 231 | 214 | template <class _Iter1> |
| 232 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 233 | 216 | bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT |
| 234 | 217 | { |
| 235 | 218 | return !(__x < __y); |
| 236 | 219 | } |
| 237 | 220 | |
| 238 | 221 | template <class _Iter1, class _Iter2> |
| 239 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 222 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 240 | 223 | bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 241 | 224 | { |
| 242 | 225 | return !(__x < __y); |
| 243 | 226 | } |
| 244 | 227 | |
| 245 | 228 | template <class _Iter1> |
| 246 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 229 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 247 | 230 | bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT |
| 248 | 231 | { |
| 249 | 232 | return !(__y < __x); |
| 250 | 233 | } |
| 251 | 234 | |
| 252 | 235 | template <class _Iter1, class _Iter2> |
| 253 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 236 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 254 | 237 | bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 255 | 238 | { |
| 256 | 239 | return !(__y < __x); |
| 257 | 240 | } |
| 258 | 241 | |
| 259 | 242 | template <class _Iter1, class _Iter2> |
| 260 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 261 | 244 | #ifndef _LIBCPP_CXX03_LANG |
| 262 | 245 | auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 263 | 246 | -> decltype(__x.base() - __y.base()) |
| ... | ... | @@ -266,15 +249,13 @@ typename __wrap_iter<_Iter1>::difference_type |
| 266 | 249 | operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT |
| 267 | 250 | #endif // C++03 |
| 268 | 251 | { |
| 269 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 270 | _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), | |
| 271 | "Attempted to subtract incompatible iterators"); | |
| 272 | #endif | |
| 252 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__less_than_comparable(_VSTD::addressof(__x), _VSTD::addressof(__y)), | |
| 253 | "Attempted to subtract incompatible iterators"); | |
| 273 | 254 | return __x.base() - __y.base(); |
| 274 | 255 | } |
| 275 | 256 | |
| 276 | 257 | template <class _Iter1> |
| 277 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG | |
| 258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 278 | 259 | __wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT |
| 279 | 260 | { |
| 280 | 261 | __x += __n; |
| ... | ... | @@ -286,15 +267,19 @@ template <class _It> |
| 286 | 267 | struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; |
| 287 | 268 | #endif |
| 288 | 269 | |
| 289 | template <class _Iter> | |
| 290 | _LIBCPP_CONSTEXPR | |
| 291 | decltype(_VSTD::__to_address(declval<_Iter>())) | |
| 292 | __to_address(__wrap_iter<_Iter> __w) _NOEXCEPT { | |
| 293 | return _VSTD::__to_address(__w.base()); | |
| 294 | } | |
| 270 | template <class _It> | |
| 271 | struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > | |
| 272 | { | |
| 273 | typedef __wrap_iter<_It> pointer; | |
| 274 | typedef typename pointer_traits<_It>::element_type element_type; | |
| 275 | typedef typename pointer_traits<_It>::difference_type difference_type; | |
| 295 | 276 | |
| 296 | _LIBCPP_END_NAMESPACE_STD | |
| 277 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 278 | static element_type *to_address(pointer __w) _NOEXCEPT { | |
| 279 | return _VSTD::__to_address(__w.base()); | |
| 280 | } | |
| 281 | }; | |
| 297 | 282 | |
| 298 | _LIBCPP_POP_MACROS | |
| 283 | _LIBCPP_END_NAMESPACE_STD | |
| 299 | 284 | |
| 300 | 285 | #endif // _LIBCPP___ITERATOR_WRAP_ITER_H |
lib/libcxx/include/__libcpp_version+1-1| ... | ... | @@ -1 +1 @@ |
| 1 | 13000 | |
| 1 | 14000 |
lib/libcxx/include/__locale+66-13| ... | ... | @@ -12,18 +12,17 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | #include <string> | |
| 16 | #include <memory> | |
| 17 | #include <utility> | |
| 18 | #include <mutex> | |
| 19 | #include <cstdint> | |
| 20 | 15 | #include <cctype> |
| 16 | #include <cstdint> | |
| 21 | 17 | #include <locale.h> |
| 18 | #include <memory> | |
| 19 | #include <mutex> | |
| 20 | #include <string> | |
| 21 | #include <utility> | |
| 22 | ||
| 22 | 23 | #if defined(_LIBCPP_MSVCRT_LIKE) |
| 23 | 24 | # include <cstring> |
| 24 | 25 | # include <__support/win32/locale_win32.h> |
| 25 | #elif defined(__NuttX__) | |
| 26 | # include <__support/nuttx/xlocale.h> | |
| 27 | 26 | #elif defined(_AIX) || defined(__MVS__) |
| 28 | 27 | # include <__support/ibm/xlocale.h> |
| 29 | 28 | #elif defined(__ANDROID__) |
| ... | ... | @@ -35,7 +34,7 @@ |
| 35 | 34 | # include <__support/newlib/xlocale.h> |
| 36 | 35 | #elif defined(__OpenBSD__) |
| 37 | 36 | # include <__support/openbsd/xlocale.h> |
| 38 | #elif (defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) \ | |
| 37 | #elif (defined(__APPLE__) || defined(__FreeBSD__) \ | |
| 39 | 38 | || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) |
| 40 | 39 | # include <xlocale.h> |
| 41 | 40 | #elif defined(__Fuchsia__) |
| ... | ... | @@ -210,10 +209,11 @@ class _LIBCPP_TYPE_VIS locale::id |
| 210 | 209 | static int32_t __next_id; |
| 211 | 210 | public: |
| 212 | 211 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR id() :__id_(0) {} |
| 212 | void operator=(const id&) = delete; | |
| 213 | id(const id&) = delete; | |
| 214 | ||
| 213 | 215 | private: |
| 214 | 216 | void __init(); |
| 215 | void operator=(const id&); // = delete; | |
| 216 | id(const id&); // = delete; | |
| 217 | 217 | public: // only needed for tests |
| 218 | 218 | long __get(); |
| 219 | 219 | |
| ... | ... | @@ -340,7 +340,9 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>) |
| 343 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 343 | 344 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>) |
| 345 | #endif | |
| 344 | 346 | |
| 345 | 347 | // template <class CharT> class collate_byname; |
| 346 | 348 | |
| ... | ... | @@ -365,6 +367,7 @@ protected: |
| 365 | 367 | virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; |
| 366 | 368 | }; |
| 367 | 369 | |
| 370 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 368 | 371 | template <> |
| 369 | 372 | class _LIBCPP_TYPE_VIS collate_byname<wchar_t> |
| 370 | 373 | : public collate<wchar_t> |
| ... | ... | @@ -384,6 +387,7 @@ protected: |
| 384 | 387 | const char_type* __lo2, const char_type* __hi2) const; |
| 385 | 388 | virtual string_type do_transform(const char_type* __lo, const char_type* __hi) const; |
| 386 | 389 | }; |
| 390 | #endif | |
| 387 | 391 | |
| 388 | 392 | template <class _CharT, class _Traits, class _Allocator> |
| 389 | 393 | bool |
| ... | ... | @@ -448,12 +452,12 @@ public: |
| 448 | 452 | static const mask punct = _PUNCT; |
| 449 | 453 | static const mask xdigit = _HEX; |
| 450 | 454 | static const mask blank = _BLANK; |
| 451 | static const mask __regex_word = 0x80; | |
| 455 | static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used | |
| 452 | 456 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 453 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__DragonFly__) | |
| 457 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) | |
| 454 | 458 | # ifdef __APPLE__ |
| 455 | 459 | typedef __uint32_t mask; |
| 456 | # elif defined(__FreeBSD__) || defined(__DragonFly__) | |
| 460 | # elif defined(__FreeBSD__) | |
| 457 | 461 | typedef unsigned long mask; |
| 458 | 462 | # elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) |
| 459 | 463 | typedef unsigned short mask; |
| ... | ... | @@ -507,6 +511,33 @@ public: |
| 507 | 511 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 508 | 512 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA |
| 509 | 513 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT |
| 514 | #elif defined(__MVS__) | |
| 515 | # if defined(__NATIVE_ASCII_F) | |
| 516 | typedef unsigned int mask; | |
| 517 | static const mask space = _ISSPACE_A; | |
| 518 | static const mask print = _ISPRINT_A; | |
| 519 | static const mask cntrl = _ISCNTRL_A; | |
| 520 | static const mask upper = _ISUPPER_A; | |
| 521 | static const mask lower = _ISLOWER_A; | |
| 522 | static const mask alpha = _ISALPHA_A; | |
| 523 | static const mask digit = _ISDIGIT_A; | |
| 524 | static const mask punct = _ISPUNCT_A; | |
| 525 | static const mask xdigit = _ISXDIGIT_A; | |
| 526 | static const mask blank = _ISBLANK_A; | |
| 527 | # else | |
| 528 | typedef unsigned short mask; | |
| 529 | static const mask space = __ISSPACE; | |
| 530 | static const mask print = __ISPRINT; | |
| 531 | static const mask cntrl = __ISCNTRL; | |
| 532 | static const mask upper = __ISUPPER; | |
| 533 | static const mask lower = __ISLOWER; | |
| 534 | static const mask alpha = __ISALPHA; | |
| 535 | static const mask digit = __ISDIGIT; | |
| 536 | static const mask punct = __ISPUNCT; | |
| 537 | static const mask xdigit = __ISXDIGIT; | |
| 538 | static const mask blank = __ISBLANK; | |
| 539 | # endif | |
| 540 | static const mask __regex_word = 0x8000; | |
| 510 | 541 | #else |
| 511 | 542 | # error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE? |
| 512 | 543 | #endif |
| ... | ... | @@ -514,10 +545,17 @@ public: |
| 514 | 545 | static const mask graph = alnum | punct; |
| 515 | 546 | |
| 516 | 547 | _LIBCPP_INLINE_VISIBILITY ctype_base() {} |
| 548 | ||
| 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 | "__regex_word can't overlap other bits"); | |
| 553 | #endif | |
| 517 | 554 | }; |
| 518 | 555 | |
| 519 | 556 | template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype; |
| 520 | 557 | |
| 558 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 521 | 559 | template <> |
| 522 | 560 | class _LIBCPP_TYPE_VIS ctype<wchar_t> |
| 523 | 561 | : public locale::facet, |
| ... | ... | @@ -619,6 +657,7 @@ protected: |
| 619 | 657 | virtual char do_narrow(char_type, char __dfault) const; |
| 620 | 658 | virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; |
| 621 | 659 | }; |
| 660 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 622 | 661 | |
| 623 | 662 | template <> |
| 624 | 663 | class _LIBCPP_TYPE_VIS ctype<char> |
| ... | ... | @@ -728,6 +767,10 @@ public: |
| 728 | 767 | static const short* __classic_upper_table() _NOEXCEPT; |
| 729 | 768 | static const short* __classic_lower_table() _NOEXCEPT; |
| 730 | 769 | #endif |
| 770 | #if defined(__MVS__) | |
| 771 | static const unsigned short* __classic_upper_table() _NOEXCEPT; | |
| 772 | static const unsigned short* __classic_lower_table() _NOEXCEPT; | |
| 773 | #endif | |
| 731 | 774 | |
| 732 | 775 | protected: |
| 733 | 776 | ~ctype(); |
| ... | ... | @@ -763,6 +806,7 @@ protected: |
| 763 | 806 | virtual const char_type* do_tolower(char_type* __low, const char_type* __high) const; |
| 764 | 807 | }; |
| 765 | 808 | |
| 809 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 766 | 810 | template <> |
| 767 | 811 | class _LIBCPP_TYPE_VIS ctype_byname<wchar_t> |
| 768 | 812 | : public ctype<wchar_t> |
| ... | ... | @@ -788,6 +832,7 @@ protected: |
| 788 | 832 | virtual char do_narrow(char_type, char __dfault) const; |
| 789 | 833 | virtual const char_type* do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const; |
| 790 | 834 | }; |
| 835 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 791 | 836 | |
| 792 | 837 | template <class _CharT> |
| 793 | 838 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -994,6 +1039,7 @@ protected: |
| 994 | 1039 | |
| 995 | 1040 | // template <> class codecvt<wchar_t, char, mbstate_t> |
| 996 | 1041 | |
| 1042 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 997 | 1043 | template <> |
| 998 | 1044 | class _LIBCPP_TYPE_VIS codecvt<wchar_t, char, mbstate_t> |
| 999 | 1045 | : public locale::facet, |
| ... | ... | @@ -1074,6 +1120,7 @@ protected: |
| 1074 | 1120 | virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const; |
| 1075 | 1121 | virtual int do_max_length() const _NOEXCEPT; |
| 1076 | 1122 | }; |
| 1123 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1077 | 1124 | |
| 1078 | 1125 | // template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20 |
| 1079 | 1126 | |
| ... | ... | @@ -1452,7 +1499,9 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() |
| 1452 | 1499 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 1453 | 1500 | |
| 1454 | 1501 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>) |
| 1502 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1455 | 1503 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) |
| 1504 | #endif | |
| 1456 | 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++20 |
| 1457 | 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++20 |
| 1458 | 1507 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| ... | ... | @@ -1683,6 +1732,7 @@ protected: |
| 1683 | 1732 | string __grouping_; |
| 1684 | 1733 | }; |
| 1685 | 1734 | |
| 1735 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1686 | 1736 | template <> |
| 1687 | 1737 | class _LIBCPP_TYPE_VIS numpunct<wchar_t> |
| 1688 | 1738 | : public locale::facet |
| ... | ... | @@ -1713,6 +1763,7 @@ protected: |
| 1713 | 1763 | char_type __thousands_sep_; |
| 1714 | 1764 | string __grouping_; |
| 1715 | 1765 | }; |
| 1766 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1716 | 1767 | |
| 1717 | 1768 | // template <class charT> class numpunct_byname |
| 1718 | 1769 | |
| ... | ... | @@ -1736,6 +1787,7 @@ private: |
| 1736 | 1787 | void __init(const char*); |
| 1737 | 1788 | }; |
| 1738 | 1789 | |
| 1790 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1739 | 1791 | template <> |
| 1740 | 1792 | class _LIBCPP_TYPE_VIS numpunct_byname<wchar_t> |
| 1741 | 1793 | : public numpunct<wchar_t> |
| ... | ... | @@ -1753,6 +1805,7 @@ protected: |
| 1753 | 1805 | private: |
| 1754 | 1806 | void __init(const char*); |
| 1755 | 1807 | }; |
| 1808 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1756 | 1809 | |
| 1757 | 1810 | _LIBCPP_END_NAMESPACE_STD |
| 1758 | 1811 |
lib/libcxx/include/__mbstate_t.h created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 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___MBSTATE_T_H | |
| 11 | #define _LIBCPP___MBSTATE_T_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | // TODO(ldionne): | |
| 20 | // The goal of this header is to provide mbstate_t without having to pull in | |
| 21 | // <wchar.h> or <uchar.h>. This is necessary because we need that type even | |
| 22 | // when we don't have (or try to provide) support for wchar_t, because several | |
| 23 | // types like std::fpos are defined in terms of mbstate_t. | |
| 24 | // | |
| 25 | // This is a gruesome hack, but I don't know how to make it cleaner for | |
| 26 | // the time being. | |
| 27 | ||
| 28 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 29 | # include <wchar.h> // for mbstate_t | |
| 30 | #elif __has_include(<bits/types/mbstate_t.h>) | |
| 31 | # include <bits/types/mbstate_t.h> // works on most Unixes | |
| 32 | #elif __has_include(<sys/_types/_mbstate_t.h>) | |
| 33 | # include <sys/_types/_mbstate_t.h> // works on Darwin | |
| 34 | #else | |
| 35 | # error "The library was configured without support for wide-characters, but we don't know how to get the definition of mbstate_t without <wchar.h> on your platform." | |
| 36 | #endif | |
| 37 | ||
| 38 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 39 | ||
| 40 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS; | |
| 41 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | |
| 43 | ||
| 44 | #endif // _LIBCPP___MBSTATE_T_H |
lib/libcxx/include/__memory/addressof.h-20| ... | ... | @@ -16,13 +16,8 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF | |
| 25 | ||
| 26 | 21 | template <class _Tp> |
| 27 | 22 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 28 | 23 | _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -32,19 +27,6 @@ addressof(_Tp& __x) _NOEXCEPT |
| 32 | 27 | return __builtin_addressof(__x); |
| 33 | 28 | } |
| 34 | 29 | |
| 35 | #else | |
| 36 | ||
| 37 | template <class _Tp> | |
| 38 | inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY | |
| 39 | _Tp* | |
| 40 | addressof(_Tp& __x) _NOEXCEPT | |
| 41 | { | |
| 42 | return reinterpret_cast<_Tp *>( | |
| 43 | const_cast<char *>(&reinterpret_cast<const volatile char &>(__x))); | |
| 44 | } | |
| 45 | ||
| 46 | #endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF | |
| 47 | ||
| 48 | 30 | #if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) |
| 49 | 31 | // Objective-C++ Automatic Reference Counting uses qualified pointers |
| 50 | 32 | // that require special addressof() signatures. When |
| ... | ... | @@ -91,6 +73,4 @@ template <class _Tp> _Tp* addressof(const _Tp&&) noexcept = delete; |
| 91 | 73 | |
| 92 | 74 | _LIBCPP_END_NAMESPACE_STD |
| 93 | 75 | |
| 94 | _LIBCPP_POP_MACROS | |
| 95 | ||
| 96 | 76 | #endif // _LIBCPP___MEMORY_ADDRESSOF_H |
lib/libcxx/include/__memory/allocation_guard.h-6| ... | ... | @@ -19,10 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | ||
| 26 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 23 | |
| 28 | 24 | // Helper class to allocate memory using an Allocator in an exception safe |
| ... | ... | @@ -84,6 +80,4 @@ private: |
| 84 | 80 | |
| 85 | 81 | _LIBCPP_END_NAMESPACE_STD |
| 86 | 82 | |
| 87 | _LIBCPP_POP_MACROS | |
| 88 | ||
| 89 | 83 | #endif // _LIBCPP___MEMORY_ALLOCATION_GUARD_H |
lib/libcxx/include/__memory/allocator.h+6-11| ... | ... | @@ -22,9 +22,6 @@ |
| 22 | 22 | #pragma GCC system_header |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 26 | |
| 30 | 27 | template <class _Tp> class allocator; |
| ... | ... | @@ -83,6 +80,7 @@ template <class _Tp> |
| 83 | 80 | class _LIBCPP_TEMPLATE_VIS allocator |
| 84 | 81 | : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > |
| 85 | 82 | { |
| 83 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); | |
| 86 | 84 | public: |
| 87 | 85 | typedef size_t size_type; |
| 88 | 86 | typedef ptrdiff_t difference_type; |
| ... | ... | @@ -91,7 +89,7 @@ public: |
| 91 | 89 | typedef true_type is_always_equal; |
| 92 | 90 | |
| 93 | 91 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 94 | allocator() _NOEXCEPT _LIBCPP_DEFAULT | |
| 92 | allocator() _NOEXCEPT = default; | |
| 95 | 93 | |
| 96 | 94 | template <class _Up> |
| 97 | 95 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -100,8 +98,7 @@ public: |
| 100 | 98 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 101 | 99 | _Tp* allocate(size_t __n) { |
| 102 | 100 | if (__n > allocator_traits<allocator>::max_size(*this)) |
| 103 | __throw_length_error("allocator<T>::allocate(size_t n)" | |
| 104 | " 'n' exceeds maximum supported size"); | |
| 101 | __throw_bad_array_new_length(); | |
| 105 | 102 | if (__libcpp_is_constant_evaluated()) { |
| 106 | 103 | return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); |
| 107 | 104 | } else { |
| ... | ... | @@ -165,6 +162,7 @@ template <class _Tp> |
| 165 | 162 | class _LIBCPP_TEMPLATE_VIS allocator<const _Tp> |
| 166 | 163 | : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > |
| 167 | 164 | { |
| 165 | static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types"); | |
| 168 | 166 | public: |
| 169 | 167 | typedef size_t size_type; |
| 170 | 168 | typedef ptrdiff_t difference_type; |
| ... | ... | @@ -173,7 +171,7 @@ public: |
| 173 | 171 | typedef true_type is_always_equal; |
| 174 | 172 | |
| 175 | 173 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 176 | allocator() _NOEXCEPT _LIBCPP_DEFAULT | |
| 174 | allocator() _NOEXCEPT = default; | |
| 177 | 175 | |
| 178 | 176 | template <class _Up> |
| 179 | 177 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -182,8 +180,7 @@ public: |
| 182 | 180 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 183 | 181 | const _Tp* allocate(size_t __n) { |
| 184 | 182 | if (__n > allocator_traits<allocator>::max_size(*this)) |
| 185 | __throw_length_error("allocator<const T>::allocate(size_t n)" | |
| 186 | " 'n' exceeds maximum supported size"); | |
| 183 | __throw_bad_array_new_length(); | |
| 187 | 184 | if (__libcpp_is_constant_evaluated()) { |
| 188 | 185 | return static_cast<const _Tp*>(::operator new(__n * sizeof(_Tp))); |
| 189 | 186 | } else { |
| ... | ... | @@ -249,6 +246,4 @@ bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return |
| 249 | 246 | |
| 250 | 247 | _LIBCPP_END_NAMESPACE_STD |
| 251 | 248 | |
| 252 | _LIBCPP_POP_MACROS | |
| 253 | ||
| 254 | 249 | #endif // _LIBCPP___MEMORY_ALLOCATOR_H |
lib/libcxx/include/__memory/allocator_arg_t.h+5-5| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H | |
| 11 | #define _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H | |
| 10 | #ifndef _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H | |
| 11 | #define _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H | |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__memory/uses_allocator.h> |
| ... | ... | @@ -26,7 +26,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = defau |
| 26 | 26 | #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) |
| 27 | 27 | extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; |
| 28 | 28 | #else |
| 29 | /* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); | |
| 29 | /* inline */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); | |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -36,7 +36,7 @@ extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; |
| 36 | 36 | template <class _Tp, class _Alloc, class ..._Args> |
| 37 | 37 | struct __uses_alloc_ctor_imp |
| 38 | 38 | { |
| 39 | typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc; | |
| 39 | typedef _LIBCPP_NODEBUG typename __uncvref<_Alloc>::type _RawAlloc; | |
| 40 | 40 | static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value; |
| 41 | 41 | static const bool __ic = |
| 42 | 42 | is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; |
| ... | ... | @@ -75,4 +75,4 @@ void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, con |
| 75 | 75 | |
| 76 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 77 | 77 | |
| 78 | #endif // _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H | |
| 78 | #endif // _LIBCPP___FUNCTIONAL_ALLOCATOR_ARG_T_H |
lib/libcxx/include/__memory/allocator_traits.h+33-33| ... | ... | @@ -36,11 +36,11 @@ template <class _Tp, class _Alloc, |
| 36 | 36 | class _RawAlloc = typename remove_reference<_Alloc>::type, |
| 37 | 37 | bool = __has_pointer<_RawAlloc>::value> |
| 38 | 38 | struct __pointer { |
| 39 | using type _LIBCPP_NODEBUG_TYPE = typename _RawAlloc::pointer; | |
| 39 | using type _LIBCPP_NODEBUG = typename _RawAlloc::pointer; | |
| 40 | 40 | }; |
| 41 | 41 | template <class _Tp, class _Alloc, class _RawAlloc> |
| 42 | 42 | struct __pointer<_Tp, _Alloc, _RawAlloc, false> { |
| 43 | using type _LIBCPP_NODEBUG_TYPE = _Tp*; | |
| 43 | using type _LIBCPP_NODEBUG = _Tp*; | |
| 44 | 44 | }; |
| 45 | 45 | |
| 46 | 46 | // __const_pointer |
| ... | ... | @@ -48,14 +48,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); |
| 48 | 48 | template <class _Tp, class _Ptr, class _Alloc, |
| 49 | 49 | bool = __has_const_pointer<_Alloc>::value> |
| 50 | 50 | struct __const_pointer { |
| 51 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_pointer; | |
| 51 | using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer; | |
| 52 | 52 | }; |
| 53 | 53 | template <class _Tp, class _Ptr, class _Alloc> |
| 54 | 54 | struct __const_pointer<_Tp, _Ptr, _Alloc, false> { |
| 55 | 55 | #ifdef _LIBCPP_CXX03_LANG |
| 56 | 56 | using type = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other; |
| 57 | 57 | #else |
| 58 | using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const _Tp>; | |
| 58 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>; | |
| 59 | 59 | #endif |
| 60 | 60 | }; |
| 61 | 61 | |
| ... | ... | @@ -64,14 +64,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer); |
| 64 | 64 | template <class _Ptr, class _Alloc, |
| 65 | 65 | bool = __has_void_pointer<_Alloc>::value> |
| 66 | 66 | struct __void_pointer { |
| 67 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::void_pointer; | |
| 67 | using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer; | |
| 68 | 68 | }; |
| 69 | 69 | template <class _Ptr, class _Alloc> |
| 70 | 70 | struct __void_pointer<_Ptr, _Alloc, false> { |
| 71 | 71 | #ifdef _LIBCPP_CXX03_LANG |
| 72 | using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<void>::other; | |
| 72 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>::other; | |
| 73 | 73 | #else |
| 74 | using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<void>; | |
| 74 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>; | |
| 75 | 75 | #endif |
| 76 | 76 | }; |
| 77 | 77 | |
| ... | ... | @@ -80,14 +80,14 @@ _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer); |
| 80 | 80 | template <class _Ptr, class _Alloc, |
| 81 | 81 | bool = __has_const_void_pointer<_Alloc>::value> |
| 82 | 82 | struct __const_void_pointer { |
| 83 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_void_pointer; | |
| 83 | using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer; | |
| 84 | 84 | }; |
| 85 | 85 | template <class _Ptr, class _Alloc> |
| 86 | 86 | struct __const_void_pointer<_Ptr, _Alloc, false> { |
| 87 | 87 | #ifdef _LIBCPP_CXX03_LANG |
| 88 | using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const void>::other; | |
| 88 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>::other; | |
| 89 | 89 | #else |
| 90 | using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind<const void>; | |
| 90 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>; | |
| 91 | 91 | #endif |
| 92 | 92 | }; |
| 93 | 93 | |
| ... | ... | @@ -97,18 +97,18 @@ template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value> |
| 97 | 97 | struct __size_type : make_unsigned<_DiffType> { }; |
| 98 | 98 | template <class _Alloc, class _DiffType> |
| 99 | 99 | struct __size_type<_Alloc, _DiffType, true> { |
| 100 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::size_type; | |
| 100 | using type _LIBCPP_NODEBUG = typename _Alloc::size_type; | |
| 101 | 101 | }; |
| 102 | 102 | |
| 103 | 103 | // __alloc_traits_difference_type |
| 104 | 104 | _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); |
| 105 | 105 | template <class _Alloc, class _Ptr, bool = __has_alloc_traits_difference_type<_Alloc>::value> |
| 106 | 106 | struct __alloc_traits_difference_type { |
| 107 | using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::difference_type; | |
| 107 | using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type; | |
| 108 | 108 | }; |
| 109 | 109 | template <class _Alloc, class _Ptr> |
| 110 | 110 | struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { |
| 111 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::difference_type; | |
| 111 | using type _LIBCPP_NODEBUG = typename _Alloc::difference_type; | |
| 112 | 112 | }; |
| 113 | 113 | |
| 114 | 114 | // __propagate_on_container_copy_assignment |
| ... | ... | @@ -117,7 +117,7 @@ template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_All |
| 117 | 117 | struct __propagate_on_container_copy_assignment : false_type { }; |
| 118 | 118 | template <class _Alloc> |
| 119 | 119 | struct __propagate_on_container_copy_assignment<_Alloc, true> { |
| 120 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_copy_assignment; | |
| 120 | using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_copy_assignment; | |
| 121 | 121 | }; |
| 122 | 122 | |
| 123 | 123 | // __propagate_on_container_move_assignment |
| ... | ... | @@ -126,7 +126,7 @@ template <class _Alloc, bool = __has_propagate_on_container_move_assignment<_All |
| 126 | 126 | struct __propagate_on_container_move_assignment : false_type { }; |
| 127 | 127 | template <class _Alloc> |
| 128 | 128 | struct __propagate_on_container_move_assignment<_Alloc, true> { |
| 129 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_move_assignment; | |
| 129 | using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_move_assignment; | |
| 130 | 130 | }; |
| 131 | 131 | |
| 132 | 132 | // __propagate_on_container_swap |
| ... | ... | @@ -135,7 +135,7 @@ template <class _Alloc, bool = __has_propagate_on_container_swap<_Alloc>::value> |
| 135 | 135 | struct __propagate_on_container_swap : false_type { }; |
| 136 | 136 | template <class _Alloc> |
| 137 | 137 | struct __propagate_on_container_swap<_Alloc, true> { |
| 138 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_swap; | |
| 138 | using type _LIBCPP_NODEBUG = typename _Alloc::propagate_on_container_swap; | |
| 139 | 139 | }; |
| 140 | 140 | |
| 141 | 141 | // __is_always_equal |
| ... | ... | @@ -144,7 +144,7 @@ template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value> |
| 144 | 144 | struct __is_always_equal : is_empty<_Alloc> { }; |
| 145 | 145 | template <class _Alloc> |
| 146 | 146 | struct __is_always_equal<_Alloc, true> { |
| 147 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::is_always_equal; | |
| 147 | using type _LIBCPP_NODEBUG = typename _Alloc::is_always_equal; | |
| 148 | 148 | }; |
| 149 | 149 | |
| 150 | 150 | // __allocator_traits_rebind |
| ... | ... | @@ -158,15 +158,15 @@ struct __has_rebind_other<_Tp, _Up, typename __void_t< |
| 158 | 158 | |
| 159 | 159 | template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value> |
| 160 | 160 | struct __allocator_traits_rebind { |
| 161 | using type _LIBCPP_NODEBUG_TYPE = typename _Tp::template rebind<_Up>::other; | |
| 161 | using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other; | |
| 162 | 162 | }; |
| 163 | 163 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> |
| 164 | 164 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true> { |
| 165 | using type _LIBCPP_NODEBUG_TYPE = typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other; | |
| 165 | using type _LIBCPP_NODEBUG = typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other; | |
| 166 | 166 | }; |
| 167 | 167 | template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up> |
| 168 | 168 | struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false> { |
| 169 | using type _LIBCPP_NODEBUG_TYPE = _Alloc<_Up, _Args...>; | |
| 169 | using type _LIBCPP_NODEBUG = _Alloc<_Up, _Args...>; | |
| 170 | 170 | }; |
| 171 | 171 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 172 | 172 | |
| ... | ... | @@ -263,7 +263,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | template <class _Ap = _Alloc, class = |
| 266 | _EnableIf<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> > | |
| 266 | __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> > | |
| 267 | 267 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 268 | 268 | static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) { |
| 269 | 269 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -271,7 +271,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 271 | 271 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 272 | 272 | } |
| 273 | 273 | template <class _Ap = _Alloc, class = void, class = |
| 274 | _EnableIf<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> > | |
| 274 | __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> > | |
| 275 | 275 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 276 | 276 | static pointer allocate(allocator_type& __a, size_type __n, const_void_pointer) { |
| 277 | 277 | return __a.allocate(__n); |
| ... | ... | @@ -283,7 +283,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | template <class _Tp, class... _Args, class = |
| 286 | _EnableIf<__has_construct<allocator_type, _Tp*, _Args...>::value> > | |
| 286 | __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> > | |
| 287 | 287 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 288 | 288 | static void construct(allocator_type& __a, _Tp* __p, _Args&&... __args) { |
| 289 | 289 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -291,7 +291,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 291 | 291 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 292 | 292 | } |
| 293 | 293 | template <class _Tp, class... _Args, class = void, class = |
| 294 | _EnableIf<!__has_construct<allocator_type, _Tp*, _Args...>::value> > | |
| 294 | __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> > | |
| 295 | 295 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 296 | 296 | static void construct(allocator_type&, _Tp* __p, _Args&&... __args) { |
| 297 | 297 | #if _LIBCPP_STD_VER > 17 |
| ... | ... | @@ -302,7 +302,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | template <class _Tp, class = |
| 305 | _EnableIf<__has_destroy<allocator_type, _Tp*>::value> > | |
| 305 | __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> > | |
| 306 | 306 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 307 | 307 | static void destroy(allocator_type& __a, _Tp* __p) { |
| 308 | 308 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -310,7 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 310 | 310 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 311 | 311 | } |
| 312 | 312 | template <class _Tp, class = void, class = |
| 313 | _EnableIf<!__has_destroy<allocator_type, _Tp*>::value> > | |
| 313 | __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> > | |
| 314 | 314 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 315 | 315 | static void destroy(allocator_type&, _Tp* __p) { |
| 316 | 316 | #if _LIBCPP_STD_VER > 17 |
| ... | ... | @@ -321,7 +321,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | template <class _Ap = _Alloc, class = |
| 324 | _EnableIf<__has_max_size<const _Ap>::value> > | |
| 324 | __enable_if_t<__has_max_size<const _Ap>::value> > | |
| 325 | 325 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 326 | 326 | static size_type max_size(const allocator_type& __a) _NOEXCEPT { |
| 327 | 327 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| ... | ... | @@ -329,20 +329,20 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 329 | 329 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 330 | 330 | } |
| 331 | 331 | template <class _Ap = _Alloc, class = void, class = |
| 332 | _EnableIf<!__has_max_size<const _Ap>::value> > | |
| 332 | __enable_if_t<!__has_max_size<const _Ap>::value> > | |
| 333 | 333 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 334 | 334 | static size_type max_size(const allocator_type&) _NOEXCEPT { |
| 335 | 335 | return numeric_limits<size_type>::max() / sizeof(value_type); |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | template <class _Ap = _Alloc, class = |
| 339 | _EnableIf<__has_select_on_container_copy_construction<const _Ap>::value> > | |
| 339 | __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> > | |
| 340 | 340 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 341 | 341 | static allocator_type select_on_container_copy_construction(const allocator_type& __a) { |
| 342 | 342 | return __a.select_on_container_copy_construction(); |
| 343 | 343 | } |
| 344 | 344 | template <class _Ap = _Alloc, class = void, class = |
| 345 | _EnableIf<!__has_select_on_container_copy_construction<const _Ap>::value> > | |
| 345 | __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> > | |
| 346 | 346 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 347 | 347 | static allocator_type select_on_container_copy_construction(const allocator_type& __a) { |
| 348 | 348 | return __a; |
| ... | ... | @@ -352,7 +352,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits |
| 352 | 352 | template <class _Traits, class _Tp> |
| 353 | 353 | struct __rebind_alloc_helper { |
| 354 | 354 | #ifndef _LIBCPP_CXX03_LANG |
| 355 | using type _LIBCPP_NODEBUG_TYPE = typename _Traits::template rebind_alloc<_Tp>; | |
| 355 | using type _LIBCPP_NODEBUG = typename _Traits::template rebind_alloc<_Tp>; | |
| 356 | 356 | #else |
| 357 | 357 | using type = typename _Traits::template rebind_alloc<_Tp>::other; |
| 358 | 358 | #endif |
| ... | ... | @@ -374,7 +374,7 @@ struct __is_cpp17_move_insertable |
| 374 | 374 | { }; |
| 375 | 375 | |
| 376 | 376 | template <class _Alloc> |
| 377 | struct __is_cpp17_move_insertable<_Alloc, _EnableIf< | |
| 377 | struct __is_cpp17_move_insertable<_Alloc, __enable_if_t< | |
| 378 | 378 | !__is_default_allocator<_Alloc>::value && |
| 379 | 379 | __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value |
| 380 | 380 | > > : true_type { }; |
| ... | ... | @@ -389,7 +389,7 @@ struct __is_cpp17_copy_insertable |
| 389 | 389 | { }; |
| 390 | 390 | |
| 391 | 391 | template <class _Alloc> |
| 392 | struct __is_cpp17_copy_insertable<_Alloc, _EnableIf< | |
| 392 | struct __is_cpp17_copy_insertable<_Alloc, __enable_if_t< | |
| 393 | 393 | !__is_default_allocator<_Alloc>::value && |
| 394 | 394 | __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value |
| 395 | 395 | > > |
lib/libcxx/include/__memory/auto_ptr.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _Tp> |
| ... | ... | @@ -81,6 +78,4 @@ public: |
| 81 | 78 | |
| 82 | 79 | _LIBCPP_END_NAMESPACE_STD |
| 83 | 80 | |
| 84 | _LIBCPP_POP_MACROS | |
| 85 | ||
| 86 | 81 | #endif // _LIBCPP___MEMORY_AUTO_PTR_H |
lib/libcxx/include/__memory/compressed_pair.h+14-30| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | // Tag used to default initialize one or both of the pair's elements. |
| ... | ... | @@ -61,10 +58,8 @@ struct __compressed_pair_elem { |
| 61 | 58 | : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} |
| 62 | 59 | #endif |
| 63 | 60 | |
| 64 | ||
| 65 | _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; } | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | const_reference __get() const _NOEXCEPT { return __value_; } | |
| 61 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; } | |
| 62 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; } | |
| 68 | 63 | |
| 69 | 64 | private: |
| 70 | 65 | _Tp __value_; |
| ... | ... | @@ -100,9 +95,8 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { |
| 100 | 95 | : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} |
| 101 | 96 | #endif |
| 102 | 97 | |
| 103 | _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; } | |
| 104 | _LIBCPP_INLINE_VISIBILITY | |
| 105 | const_reference __get() const _NOEXCEPT { return *this; } | |
| 98 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; } | |
| 99 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; } | |
| 106 | 100 | }; |
| 107 | 101 | |
| 108 | 102 | template <class _T1, class _T2> |
| ... | ... | @@ -118,8 +112,8 @@ public: |
| 118 | 112 | "The current implementation is NOT ABI-compatible with the previous " |
| 119 | 113 | "implementation for this configuration"); |
| 120 | 114 | |
| 121 | typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1; | |
| 122 | typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2; | |
| 115 | typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T1, 0> _Base1; | |
| 116 | typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T2, 1> _Base2; | |
| 123 | 117 | |
| 124 | 118 | template <bool _Dummy = true, |
| 125 | 119 | class = typename enable_if< |
| ... | ... | @@ -146,23 +140,19 @@ public: |
| 146 | 140 | typename __make_tuple_indices<sizeof...(_Args2)>::type()) {} |
| 147 | 141 | #endif |
| 148 | 142 | |
| 149 | _LIBCPP_INLINE_VISIBILITY | |
| 150 | typename _Base1::reference first() _NOEXCEPT { | |
| 143 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::reference first() _NOEXCEPT { | |
| 151 | 144 | return static_cast<_Base1&>(*this).__get(); |
| 152 | 145 | } |
| 153 | 146 | |
| 154 | _LIBCPP_INLINE_VISIBILITY | |
| 155 | typename _Base1::const_reference first() const _NOEXCEPT { | |
| 147 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT { | |
| 156 | 148 | return static_cast<_Base1 const&>(*this).__get(); |
| 157 | 149 | } |
| 158 | 150 | |
| 159 | _LIBCPP_INLINE_VISIBILITY | |
| 160 | typename _Base2::reference second() _NOEXCEPT { | |
| 151 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::reference second() _NOEXCEPT { | |
| 161 | 152 | return static_cast<_Base2&>(*this).__get(); |
| 162 | 153 | } |
| 163 | 154 | |
| 164 | _LIBCPP_INLINE_VISIBILITY | |
| 165 | typename _Base2::const_reference second() const _NOEXCEPT { | |
| 155 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT { | |
| 166 | 156 | return static_cast<_Base2 const&>(*this).__get(); |
| 167 | 157 | } |
| 168 | 158 | |
| ... | ... | @@ -175,11 +165,8 @@ public: |
| 175 | 165 | return static_cast<_Base2*>(__pair); |
| 176 | 166 | } |
| 177 | 167 | |
| 178 | _LIBCPP_INLINE_VISIBILITY | |
| 179 | void swap(__compressed_pair& __x) | |
| 180 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | |
| 181 | __is_nothrow_swappable<_T2>::value) | |
| 182 | { | |
| 168 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair& __x) | |
| 169 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) { | |
| 183 | 170 | using _VSTD::swap; |
| 184 | 171 | swap(first(), __x.first()); |
| 185 | 172 | swap(second(), __x.second()); |
| ... | ... | @@ -187,15 +174,12 @@ public: |
| 187 | 174 | }; |
| 188 | 175 | |
| 189 | 176 | template <class _T1, class _T2> |
| 190 | inline _LIBCPP_INLINE_VISIBILITY | |
| 177 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 191 | 178 | void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) |
| 192 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && | |
| 193 | __is_nothrow_swappable<_T2>::value) { | |
| 179 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) { | |
| 194 | 180 | __x.swap(__y); |
| 195 | 181 | } |
| 196 | 182 | |
| 197 | 183 | _LIBCPP_END_NAMESPACE_STD |
| 198 | 184 | |
| 199 | _LIBCPP_POP_MACROS | |
| 200 | ||
| 201 | 185 | #endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H |
lib/libcxx/include/__memory/concepts.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 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_CONCEPTS_H | |
| 11 | #define _LIBCPP___MEMORY_CONCEPTS_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/iterator_traits.h> | |
| 16 | #include <__iterator/readable_traits.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <concepts> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | ||
| 32 | // [special.mem.concepts] | |
| 33 | ||
| 34 | // This concept ensures that uninitialized algorithms can construct an object | |
| 35 | // at the address pointed-to by the iterator, which requires an lvalue. | |
| 36 | template <class _Ip> | |
| 37 | concept __nothrow_input_iterator = | |
| 38 | input_iterator<_Ip> && | |
| 39 | is_lvalue_reference_v<iter_reference_t<_Ip>> && | |
| 40 | same_as<remove_cvref_t<iter_reference_t<_Ip>>, iter_value_t<_Ip>>; | |
| 41 | ||
| 42 | template <class _Sp, class _Ip> | |
| 43 | concept __nothrow_sentinel_for = sentinel_for<_Sp, _Ip>; | |
| 44 | ||
| 45 | template <class _Rp> | |
| 46 | concept __nothrow_input_range = | |
| 47 | range<_Rp> && | |
| 48 | __nothrow_input_iterator<iterator_t<_Rp>> && | |
| 49 | __nothrow_sentinel_for<sentinel_t<_Rp>, iterator_t<_Rp>>; | |
| 50 | ||
| 51 | template <class _Ip> | |
| 52 | concept __nothrow_forward_iterator = | |
| 53 | __nothrow_input_iterator<_Ip> && | |
| 54 | forward_iterator<_Ip> && | |
| 55 | __nothrow_sentinel_for<_Ip, _Ip>; | |
| 56 | ||
| 57 | template <class _Rp> | |
| 58 | concept __nothrow_forward_range = | |
| 59 | __nothrow_input_range<_Rp> && | |
| 60 | __nothrow_forward_iterator<iterator_t<_Rp>>; | |
| 61 | ||
| 62 | } // namespace ranges | |
| 63 | ||
| 64 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 65 | ||
| 66 | _LIBCPP_END_NAMESPACE_STD | |
| 67 | ||
| 68 | #endif // _LIBCPP___MEMORY_CONCEPTS_H |
lib/libcxx/include/__memory/construct_at.h+62-11| ... | ... | @@ -12,16 +12,17 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__debug> |
| 15 | #include <__iterator/access.h> | |
| 16 | #include <__memory/addressof.h> | |
| 17 | #include <__memory/voidify.h> | |
| 15 | 18 | #include <__utility/forward.h> |
| 19 | #include <type_traits> | |
| 16 | 20 | #include <utility> |
| 17 | 21 | |
| 18 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 23 | #pragma GCC system_header |
| 20 | 24 | #endif |
| 21 | 25 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | |
| 27 | 28 | // construct_at |
| ... | ... | @@ -31,29 +32,79 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 32 | template<class _Tp, class ..._Args, class = decltype( |
| 32 | 33 | ::new (declval<void*>()) _Tp(declval<_Args>()...) |
| 33 | 34 | )> |
| 34 | _LIBCPP_INLINE_VISIBILITY | |
| 35 | _LIBCPP_HIDE_FROM_ABI | |
| 35 | 36 | constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) { |
| 36 | 37 | _LIBCPP_ASSERT(__location, "null pointer given to construct_at"); |
| 37 | return ::new ((void*)__location) _Tp(_VSTD::forward<_Args>(__args)...); | |
| 38 | return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...); | |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | 41 | #endif |
| 41 | 42 | |
| 42 | 43 | // destroy_at |
| 43 | 44 | |
| 44 | #if _LIBCPP_STD_VER > 14 | |
| 45 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` | |
| 46 | // taking an array). | |
| 45 | 47 | |
| 46 | template <class _Tp> | |
| 47 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 48 | void destroy_at(_Tp* __loc) { | |
| 48 | template <class _ForwardIterator> | |
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 50 | _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); | |
| 51 | ||
| 52 | template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0> | |
| 53 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 54 | void __destroy_at(_Tp* __loc) { | |
| 49 | 55 | _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at"); |
| 50 | 56 | __loc->~_Tp(); |
| 51 | 57 | } |
| 52 | 58 | |
| 59 | #if _LIBCPP_STD_VER > 17 | |
| 60 | template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0> | |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 62 | void __destroy_at(_Tp* __loc) { | |
| 63 | _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at"); | |
| 64 | _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc)); | |
| 65 | } | |
| 53 | 66 | #endif |
| 54 | 67 | |
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 68 | template <class _ForwardIterator> | |
| 69 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 70 | _ForwardIterator __destroy(_ForwardIterator __first, _ForwardIterator __last) { | |
| 71 | for (; __first != __last; ++__first) | |
| 72 | _VSTD::__destroy_at(_VSTD::addressof(*__first)); | |
| 73 | return __first; | |
| 74 | } | |
| 75 | ||
| 76 | #if _LIBCPP_STD_VER > 14 | |
| 56 | 77 | |
| 57 | _LIBCPP_POP_MACROS | |
| 78 | template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0> | |
| 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 80 | void destroy_at(_Tp* __loc) { | |
| 81 | _VSTD::__destroy_at(__loc); | |
| 82 | } | |
| 83 | ||
| 84 | #if _LIBCPP_STD_VER > 17 | |
| 85 | template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0> | |
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 87 | void destroy_at(_Tp* __loc) { | |
| 88 | _VSTD::__destroy_at(__loc); | |
| 89 | } | |
| 90 | #endif | |
| 91 | ||
| 92 | template <class _ForwardIterator> | |
| 93 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 94 | void destroy(_ForwardIterator __first, _ForwardIterator __last) { | |
| 95 | (void)_VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last)); | |
| 96 | } | |
| 97 | ||
| 98 | template <class _ForwardIterator, class _Size> | |
| 99 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 100 | _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { | |
| 101 | for (; __n > 0; (void)++__first, --__n) | |
| 102 | _VSTD::__destroy_at(_VSTD::addressof(*__first)); | |
| 103 | return __first; | |
| 104 | } | |
| 105 | ||
| 106 | #endif // _LIBCPP_STD_VER > 14 | |
| 107 | ||
| 108 | _LIBCPP_END_NAMESPACE_STD | |
| 58 | 109 | |
| 59 | 110 | #endif // _LIBCPP___MEMORY_CONSTRUCT_AT_H |
lib/libcxx/include/__memory/pointer_safety.h deleted-57| ... | ... | @@ -1,57 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___MEMORY_POINTER_SAFETY_H | |
| 11 | #define _LIBCPP___MEMORY_POINTER_SAFETY_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | #pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 26 | ||
| 27 | enum class pointer_safety : unsigned char { | |
| 28 | relaxed, | |
| 29 | preferred, | |
| 30 | strict | |
| 31 | }; | |
| 32 | ||
| 33 | inline _LIBCPP_INLINE_VISIBILITY | |
| 34 | pointer_safety get_pointer_safety() _NOEXCEPT { | |
| 35 | return pointer_safety::relaxed; | |
| 36 | } | |
| 37 | ||
| 38 | _LIBCPP_FUNC_VIS void declare_reachable(void* __p); | |
| 39 | _LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); | |
| 40 | _LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); | |
| 41 | _LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); | |
| 42 | ||
| 43 | template <class _Tp> | |
| 44 | inline _LIBCPP_INLINE_VISIBILITY | |
| 45 | _Tp* | |
| 46 | undeclare_reachable(_Tp* __p) | |
| 47 | { | |
| 48 | return static_cast<_Tp*>(__undeclare_reachable(__p)); | |
| 49 | } | |
| 50 | ||
| 51 | #endif // !C++03 | |
| 52 | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | |
| 54 | ||
| 55 | _LIBCPP_POP_MACROS | |
| 56 | ||
| 57 | #endif // _LIBCPP___MEMORY_POINTER_SAFETY_H |
lib/libcxx/include/__memory/pointer_traits.h+20-17| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | template <class _Tp, class = void> |
| ... | ... | @@ -36,19 +33,19 @@ struct __pointer_traits_element_type; |
| 36 | 33 | template <class _Ptr> |
| 37 | 34 | struct __pointer_traits_element_type<_Ptr, true> |
| 38 | 35 | { |
| 39 | typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type; | |
| 36 | typedef _LIBCPP_NODEBUG typename _Ptr::element_type type; | |
| 40 | 37 | }; |
| 41 | 38 | |
| 42 | 39 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> |
| 43 | 40 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> |
| 44 | 41 | { |
| 45 | typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type; | |
| 42 | typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::element_type type; | |
| 46 | 43 | }; |
| 47 | 44 | |
| 48 | 45 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> |
| 49 | 46 | struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> |
| 50 | 47 | { |
| 51 | typedef _LIBCPP_NODEBUG_TYPE _Tp type; | |
| 48 | typedef _LIBCPP_NODEBUG _Tp type; | |
| 52 | 49 | }; |
| 53 | 50 | |
| 54 | 51 | template <class _Tp, class = void> |
| ... | ... | @@ -61,13 +58,13 @@ struct __has_difference_type<_Tp, |
| 61 | 58 | template <class _Ptr, bool = __has_difference_type<_Ptr>::value> |
| 62 | 59 | struct __pointer_traits_difference_type |
| 63 | 60 | { |
| 64 | typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type; | |
| 61 | typedef _LIBCPP_NODEBUG ptrdiff_t type; | |
| 65 | 62 | }; |
| 66 | 63 | |
| 67 | 64 | template <class _Ptr> |
| 68 | 65 | struct __pointer_traits_difference_type<_Ptr, true> |
| 69 | 66 | { |
| 70 | typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type; | |
| 67 | typedef _LIBCPP_NODEBUG typename _Ptr::difference_type type; | |
| 71 | 68 | }; |
| 72 | 69 | |
| 73 | 70 | template <class _Tp, class _Up> |
| ... | ... | @@ -87,9 +84,9 @@ template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> |
| 87 | 84 | struct __pointer_traits_rebind |
| 88 | 85 | { |
| 89 | 86 | #ifndef _LIBCPP_CXX03_LANG |
| 90 | typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type; | |
| 87 | typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up> type; | |
| 91 | 88 | #else |
| 92 | typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type; | |
| 89 | typedef _LIBCPP_NODEBUG typename _Tp::template rebind<_Up>::other type; | |
| 93 | 90 | #endif |
| 94 | 91 | }; |
| 95 | 92 | |
| ... | ... | @@ -97,9 +94,9 @@ template <template <class, class...> class _Sp, class _Tp, class ..._Args, class |
| 97 | 94 | struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> |
| 98 | 95 | { |
| 99 | 96 | #ifndef _LIBCPP_CXX03_LANG |
| 100 | typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type; | |
| 97 | typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up> type; | |
| 101 | 98 | #else |
| 102 | typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; | |
| 99 | typedef _LIBCPP_NODEBUG typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type; | |
| 103 | 100 | #endif |
| 104 | 101 | }; |
| 105 | 102 | |
| ... | ... | @@ -176,7 +173,9 @@ _Tp* __to_address(_Tp* __p) _NOEXCEPT { |
| 176 | 173 | } |
| 177 | 174 | |
| 178 | 175 | // enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers |
| 179 | template <class _Pointer, class = _EnableIf<!is_pointer<_Pointer>::value> > | |
| 176 | template <class _Pointer, class = __enable_if_t< | |
| 177 | !is_pointer<_Pointer>::value && !is_array<_Pointer>::value && !is_function<_Pointer>::value | |
| 178 | > > | |
| 180 | 179 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 181 | 180 | typename decay<decltype(__to_address_helper<_Pointer>::__call(declval<const _Pointer&>()))>::type |
| 182 | 181 | __to_address(const _Pointer& __p) _NOEXCEPT { |
| ... | ... | @@ -187,7 +186,7 @@ template <class _Pointer, class> |
| 187 | 186 | struct __to_address_helper { |
| 188 | 187 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 189 | 188 | static decltype(_VSTD::__to_address(declval<const _Pointer&>().operator->())) |
| 190 | __call(const _Pointer&__p) _NOEXCEPT { | |
| 189 | __call(const _Pointer& __p) _NOEXCEPT { | |
| 191 | 190 | return _VSTD::__to_address(__p.operator->()); |
| 192 | 191 | } |
| 193 | 192 | }; |
| ... | ... | @@ -196,12 +195,18 @@ template <class _Pointer> |
| 196 | 195 | struct __to_address_helper<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(declval<const _Pointer&>()))> { |
| 197 | 196 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 198 | 197 | static decltype(pointer_traits<_Pointer>::to_address(declval<const _Pointer&>())) |
| 199 | __call(const _Pointer&__p) _NOEXCEPT { | |
| 198 | __call(const _Pointer& __p) _NOEXCEPT { | |
| 200 | 199 | return pointer_traits<_Pointer>::to_address(__p); |
| 201 | 200 | } |
| 202 | 201 | }; |
| 203 | 202 | |
| 204 | 203 | #if _LIBCPP_STD_VER > 17 |
| 204 | template <class _Tp> | |
| 205 | inline _LIBCPP_INLINE_VISIBILITY constexpr | |
| 206 | auto to_address(_Tp *__p) noexcept { | |
| 207 | return _VSTD::__to_address(__p); | |
| 208 | } | |
| 209 | ||
| 205 | 210 | template <class _Pointer> |
| 206 | 211 | inline _LIBCPP_INLINE_VISIBILITY constexpr |
| 207 | 212 | auto to_address(const _Pointer& __p) noexcept { |
| ... | ... | @@ -211,6 +216,4 @@ auto to_address(const _Pointer& __p) noexcept { |
| 211 | 216 | |
| 212 | 217 | _LIBCPP_END_NAMESPACE_STD |
| 213 | 218 | |
| 214 | _LIBCPP_POP_MACROS | |
| 215 | ||
| 216 | 219 | #endif // _LIBCPP___MEMORY_POINTER_TRAITS_H |
lib/libcxx/include/__memory/ranges_construct_at.h created+124| ... | ... | @@ -0,0 +1,124 @@ |
| 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_RANGES_CONSTRUCT_AT_H | |
| 11 | #define _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H | |
| 12 | ||
| 13 | #include <__concepts/destructible.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/incrementable_traits.h> | |
| 16 | #include <__iterator/readable_traits.h> | |
| 17 | #include <__memory/concepts.h> | |
| 18 | #include <__memory/construct_at.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | #include <__utility/declval.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 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | namespace ranges { | |
| 34 | ||
| 35 | // construct_at | |
| 36 | ||
| 37 | namespace __construct_at { | |
| 38 | ||
| 39 | struct __fn { | |
| 40 | template<class _Tp, class... _Args, class = decltype( | |
| 41 | ::new (declval<void*>()) _Tp(declval<_Args>()...) | |
| 42 | )> | |
| 43 | _LIBCPP_HIDE_FROM_ABI | |
| 44 | constexpr _Tp* operator()(_Tp* __location, _Args&& ...__args) const { | |
| 45 | return _VSTD::construct_at(__location, _VSTD::forward<_Args>(__args)...); | |
| 46 | } | |
| 47 | }; | |
| 48 | ||
| 49 | } // namespace __construct_at | |
| 50 | ||
| 51 | inline namespace __cpo { | |
| 52 | inline constexpr auto construct_at = __construct_at::__fn{}; | |
| 53 | } // namespace __cpo | |
| 54 | ||
| 55 | // destroy_at | |
| 56 | ||
| 57 | namespace __destroy_at { | |
| 58 | ||
| 59 | struct __fn { | |
| 60 | template <destructible _Tp> | |
| 61 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | constexpr void operator()(_Tp* __location) const noexcept { | |
| 63 | _VSTD::destroy_at(__location); | |
| 64 | } | |
| 65 | }; | |
| 66 | ||
| 67 | } // namespace __destroy_at | |
| 68 | ||
| 69 | inline namespace __cpo { | |
| 70 | inline constexpr auto destroy_at = __destroy_at::__fn{}; | |
| 71 | } // namespace __cpo | |
| 72 | ||
| 73 | // destroy | |
| 74 | ||
| 75 | namespace __destroy { | |
| 76 | ||
| 77 | struct __fn { | |
| 78 | template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel> | |
| 79 | requires destructible<iter_value_t<_InputIterator>> | |
| 80 | _LIBCPP_HIDE_FROM_ABI | |
| 81 | constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept { | |
| 82 | return _VSTD::__destroy(_VSTD::move(__first), _VSTD::move(__last)); | |
| 83 | } | |
| 84 | ||
| 85 | template <__nothrow_input_range _InputRange> | |
| 86 | requires destructible<range_value_t<_InputRange>> | |
| 87 | _LIBCPP_HIDE_FROM_ABI | |
| 88 | constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept { | |
| 89 | return (*this)(ranges::begin(__range), ranges::end(__range)); | |
| 90 | } | |
| 91 | }; | |
| 92 | ||
| 93 | } // namespace __destroy | |
| 94 | ||
| 95 | inline namespace __cpo { | |
| 96 | inline constexpr auto destroy = __destroy::__fn{}; | |
| 97 | } // namespace __cpo | |
| 98 | ||
| 99 | // destroy_n | |
| 100 | ||
| 101 | namespace __destroy_n { | |
| 102 | ||
| 103 | struct __fn { | |
| 104 | template <__nothrow_input_iterator _InputIterator> | |
| 105 | requires destructible<iter_value_t<_InputIterator>> | |
| 106 | _LIBCPP_HIDE_FROM_ABI | |
| 107 | constexpr _InputIterator operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept { | |
| 108 | return _VSTD::destroy_n(_VSTD::move(__first), __n); | |
| 109 | } | |
| 110 | }; | |
| 111 | ||
| 112 | } // namespace __destroy_n | |
| 113 | ||
| 114 | inline namespace __cpo { | |
| 115 | inline constexpr auto destroy_n = __destroy_n::__fn{}; | |
| 116 | } // namespace __cpo | |
| 117 | ||
| 118 | } // namespace ranges | |
| 119 | ||
| 120 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 121 | ||
| 122 | _LIBCPP_END_NAMESPACE_STD | |
| 123 | ||
| 124 | #endif // _LIBCPP___MEMORY_RANGES_CONSTRUCT_AT_H |
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h created+318| ... | ... | @@ -0,0 +1,318 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___MEMORY_RANGES_UNINITIALIZED_ALGORITHMS_H | |
| 11 | #define _LIBCPP___MEMORY_RANGES_UNINITIALIZED_ALGORITHMS_H | |
| 12 | ||
| 13 | #include <__algorithm/in_out_result.h> | |
| 14 | #include <__concepts/constructible.h> | |
| 15 | #include <__config> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/incrementable_traits.h> | |
| 18 | #include <__iterator/iter_move.h> | |
| 19 | #include <__iterator/iterator_traits.h> | |
| 20 | #include <__iterator/readable_traits.h> | |
| 21 | #include <__memory/concepts.h> | |
| 22 | #include <__memory/uninitialized_algorithms.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/concepts.h> | |
| 25 | #include <__ranges/dangling.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 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | ||
| 35 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | namespace ranges { | |
| 38 | ||
| 39 | // uninitialized_default_construct | |
| 40 | ||
| 41 | namespace __uninitialized_default_construct { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | template <__nothrow_forward_iterator _ForwardIterator, | |
| 45 | __nothrow_sentinel_for<_ForwardIterator> _Sentinel> | |
| 46 | requires default_initializable<iter_value_t<_ForwardIterator>> | |
| 47 | _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { | |
| 48 | using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; | |
| 49 | return _VSTD::__uninitialized_default_construct<_ValueType>( | |
| 50 | _VSTD::move(__first), _VSTD::move(__last)); | |
| 51 | } | |
| 52 | ||
| 53 | template <__nothrow_forward_range _ForwardRange> | |
| 54 | requires default_initializable<range_value_t<_ForwardRange>> | |
| 55 | borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const { | |
| 56 | return (*this)(ranges::begin(__range), ranges::end(__range)); | |
| 57 | } | |
| 58 | }; | |
| 59 | ||
| 60 | } // namespace __uninitialized_default_construct | |
| 61 | ||
| 62 | inline namespace __cpo { | |
| 63 | inline constexpr auto uninitialized_default_construct = __uninitialized_default_construct::__fn{}; | |
| 64 | } // namespace __cpo | |
| 65 | ||
| 66 | // uninitialized_default_construct_n | |
| 67 | ||
| 68 | namespace __uninitialized_default_construct_n { | |
| 69 | ||
| 70 | struct __fn { | |
| 71 | template <__nothrow_forward_iterator _ForwardIterator> | |
| 72 | requires default_initializable<iter_value_t<_ForwardIterator>> | |
| 73 | _ForwardIterator operator()(_ForwardIterator __first, | |
| 74 | iter_difference_t<_ForwardIterator> __n) const { | |
| 75 | using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; | |
| 76 | return _VSTD::__uninitialized_default_construct_n<_ValueType>(_VSTD::move(__first), __n); | |
| 77 | } | |
| 78 | }; | |
| 79 | ||
| 80 | } // namespace __uninitialized_default_construct_n | |
| 81 | ||
| 82 | inline namespace __cpo { | |
| 83 | inline constexpr auto uninitialized_default_construct_n = __uninitialized_default_construct_n::__fn{}; | |
| 84 | } // namespace __cpo | |
| 85 | ||
| 86 | // uninitialized_value_construct | |
| 87 | ||
| 88 | namespace __uninitialized_value_construct { | |
| 89 | ||
| 90 | struct __fn { | |
| 91 | template <__nothrow_forward_iterator _ForwardIterator, | |
| 92 | __nothrow_sentinel_for<_ForwardIterator> _Sentinel> | |
| 93 | requires default_initializable<iter_value_t<_ForwardIterator>> | |
| 94 | _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const { | |
| 95 | using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; | |
| 96 | return _VSTD::__uninitialized_value_construct<_ValueType>( | |
| 97 | _VSTD::move(__first), _VSTD::move(__last)); | |
| 98 | } | |
| 99 | ||
| 100 | template <__nothrow_forward_range _ForwardRange> | |
| 101 | requires default_initializable<range_value_t<_ForwardRange>> | |
| 102 | borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const { | |
| 103 | return (*this)(ranges::begin(__range), ranges::end(__range)); | |
| 104 | } | |
| 105 | }; | |
| 106 | ||
| 107 | } // namespace __uninitialized_value_construct | |
| 108 | ||
| 109 | inline namespace __cpo { | |
| 110 | inline constexpr auto uninitialized_value_construct = __uninitialized_value_construct::__fn{}; | |
| 111 | } // namespace __cpo | |
| 112 | ||
| 113 | // uninitialized_value_construct_n | |
| 114 | ||
| 115 | namespace __uninitialized_value_construct_n { | |
| 116 | ||
| 117 | struct __fn { | |
| 118 | template <__nothrow_forward_iterator _ForwardIterator> | |
| 119 | requires default_initializable<iter_value_t<_ForwardIterator>> | |
| 120 | _ForwardIterator operator()(_ForwardIterator __first, | |
| 121 | iter_difference_t<_ForwardIterator> __n) const { | |
| 122 | using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; | |
| 123 | return _VSTD::__uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n); | |
| 124 | } | |
| 125 | }; | |
| 126 | ||
| 127 | } // namespace __uninitialized_value_construct_n | |
| 128 | ||
| 129 | inline namespace __cpo { | |
| 130 | inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_construct_n::__fn{}; | |
| 131 | } // namespace __cpo | |
| 132 | ||
| 133 | // uninitialized_fill | |
| 134 | ||
| 135 | namespace __uninitialized_fill { | |
| 136 | ||
| 137 | struct __fn { | |
| 138 | template <__nothrow_forward_iterator _ForwardIterator, | |
| 139 | __nothrow_sentinel_for<_ForwardIterator> _Sentinel, | |
| 140 | class _Tp> | |
| 141 | requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> | |
| 142 | _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const { | |
| 143 | using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; | |
| 144 | return _VSTD::__uninitialized_fill<_ValueType>(_VSTD::move(__first), _VSTD::move(__last), __x); | |
| 145 | } | |
| 146 | ||
| 147 | template <__nothrow_forward_range _ForwardRange, class _Tp> | |
| 148 | requires constructible_from<range_value_t<_ForwardRange>, const _Tp&> | |
| 149 | borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range, const _Tp& __x) const { | |
| 150 | return (*this)(ranges::begin(__range), ranges::end(__range), __x); | |
| 151 | } | |
| 152 | }; | |
| 153 | ||
| 154 | } // namespace __uninitialized_fill | |
| 155 | ||
| 156 | inline namespace __cpo { | |
| 157 | inline constexpr auto uninitialized_fill = __uninitialized_fill::__fn{}; | |
| 158 | } // namespace __cpo | |
| 159 | ||
| 160 | // uninitialized_fill_n | |
| 161 | ||
| 162 | namespace __uninitialized_fill_n { | |
| 163 | ||
| 164 | struct __fn { | |
| 165 | template <__nothrow_forward_iterator _ForwardIterator, class _Tp> | |
| 166 | requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&> | |
| 167 | _ForwardIterator operator()(_ForwardIterator __first, | |
| 168 | iter_difference_t<_ForwardIterator> __n, | |
| 169 | const _Tp& __x) const { | |
| 170 | using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>; | |
| 171 | return _VSTD::__uninitialized_fill_n<_ValueType>(_VSTD::move(__first), __n, __x); | |
| 172 | } | |
| 173 | }; | |
| 174 | ||
| 175 | } // namespace __uninitialized_fill_n | |
| 176 | ||
| 177 | inline namespace __cpo { | |
| 178 | inline constexpr auto uninitialized_fill_n = __uninitialized_fill_n::__fn{}; | |
| 179 | } // namespace __cpo | |
| 180 | ||
| 181 | // uninitialized_copy | |
| 182 | ||
| 183 | template <class _InputIterator, class _OutputIterator> | |
| 184 | using uninitialized_copy_result = in_out_result<_InputIterator, _OutputIterator>; | |
| 185 | ||
| 186 | namespace __uninitialized_copy { | |
| 187 | ||
| 188 | struct __fn { | |
| 189 | template <input_iterator _InputIterator, | |
| 190 | sentinel_for<_InputIterator> _Sentinel1, | |
| 191 | __nothrow_forward_iterator _OutputIterator, | |
| 192 | __nothrow_sentinel_for<_OutputIterator> _Sentinel2> | |
| 193 | requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>> | |
| 194 | uninitialized_copy_result<_InputIterator, _OutputIterator> | |
| 195 | operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const { | |
| 196 | using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; | |
| 197 | ||
| 198 | auto __result = _VSTD::__uninitialized_copy<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast), | |
| 199 | _VSTD::move(__ofirst), _VSTD::move(__olast)); | |
| 200 | return {_VSTD::move(__result.first), _VSTD::move(__result.second)}; | |
| 201 | } | |
| 202 | ||
| 203 | template <input_range _InputRange, __nothrow_forward_range _OutputRange> | |
| 204 | requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>> | |
| 205 | uninitialized_copy_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>> | |
| 206 | operator()( _InputRange&& __in_range, _OutputRange&& __out_range) const { | |
| 207 | return (*this)(ranges::begin(__in_range), ranges::end(__in_range), | |
| 208 | ranges::begin(__out_range), ranges::end(__out_range)); | |
| 209 | } | |
| 210 | }; | |
| 211 | ||
| 212 | } // namespace __uninitialized_copy | |
| 213 | ||
| 214 | inline namespace __cpo { | |
| 215 | inline constexpr auto uninitialized_copy = __uninitialized_copy::__fn{}; | |
| 216 | } // namespace __cpo | |
| 217 | ||
| 218 | // uninitialized_copy_n | |
| 219 | ||
| 220 | template <class _InputIterator, class _OutputIterator> | |
| 221 | using uninitialized_copy_n_result = in_out_result<_InputIterator, _OutputIterator>; | |
| 222 | ||
| 223 | namespace __uninitialized_copy_n { | |
| 224 | ||
| 225 | struct __fn { | |
| 226 | template <input_iterator _InputIterator, | |
| 227 | __nothrow_forward_iterator _OutputIterator, | |
| 228 | __nothrow_sentinel_for<_OutputIterator> _Sentinel> | |
| 229 | requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>> | |
| 230 | uninitialized_copy_n_result<_InputIterator, _OutputIterator> | |
| 231 | operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n, | |
| 232 | _OutputIterator __ofirst, _Sentinel __olast) const { | |
| 233 | using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; | |
| 234 | auto __result = _VSTD::__uninitialized_copy_n<_ValueType>(_VSTD::move(__ifirst), __n, | |
| 235 | _VSTD::move(__ofirst), _VSTD::move(__olast)); | |
| 236 | return {_VSTD::move(__result.first), _VSTD::move(__result.second)}; | |
| 237 | } | |
| 238 | }; | |
| 239 | ||
| 240 | } // namespace __uninitialized_copy_n | |
| 241 | ||
| 242 | inline namespace __cpo { | |
| 243 | inline constexpr auto uninitialized_copy_n = __uninitialized_copy_n::__fn{}; | |
| 244 | } // namespace __cpo | |
| 245 | ||
| 246 | // uninitialized_move | |
| 247 | ||
| 248 | template <class _InputIterator, class _OutputIterator> | |
| 249 | using uninitialized_move_result = in_out_result<_InputIterator, _OutputIterator>; | |
| 250 | ||
| 251 | namespace __uninitialized_move { | |
| 252 | ||
| 253 | struct __fn { | |
| 254 | template <input_iterator _InputIterator, | |
| 255 | sentinel_for<_InputIterator> _Sentinel1, | |
| 256 | __nothrow_forward_iterator _OutputIterator, | |
| 257 | __nothrow_sentinel_for<_OutputIterator> _Sentinel2> | |
| 258 | requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>> | |
| 259 | uninitialized_move_result<_InputIterator, _OutputIterator> | |
| 260 | operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const { | |
| 261 | using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; | |
| 262 | auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); }; | |
| 263 | auto __result = _VSTD::__uninitialized_move<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast), | |
| 264 | _VSTD::move(__ofirst), _VSTD::move(__olast), __iter_move); | |
| 265 | return {_VSTD::move(__result.first), _VSTD::move(__result.second)}; | |
| 266 | } | |
| 267 | ||
| 268 | template <input_range _InputRange, __nothrow_forward_range _OutputRange> | |
| 269 | requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>> | |
| 270 | uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>> | |
| 271 | operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const { | |
| 272 | return (*this)(ranges::begin(__in_range), ranges::end(__in_range), | |
| 273 | ranges::begin(__out_range), ranges::end(__out_range)); | |
| 274 | } | |
| 275 | }; | |
| 276 | ||
| 277 | } // namespace __uninitialized_move | |
| 278 | ||
| 279 | inline namespace __cpo { | |
| 280 | inline constexpr auto uninitialized_move = __uninitialized_move::__fn{}; | |
| 281 | } // namespace __cpo | |
| 282 | ||
| 283 | // uninitialized_move_n | |
| 284 | ||
| 285 | template <class _InputIterator, class _OutputIterator> | |
| 286 | using uninitialized_move_n_result = in_out_result<_InputIterator, _OutputIterator>; | |
| 287 | ||
| 288 | namespace __uninitialized_move_n { | |
| 289 | ||
| 290 | struct __fn { | |
| 291 | template <input_iterator _InputIterator, | |
| 292 | __nothrow_forward_iterator _OutputIterator, | |
| 293 | __nothrow_sentinel_for<_OutputIterator> _Sentinel> | |
| 294 | requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>> | |
| 295 | uninitialized_move_n_result<_InputIterator, _OutputIterator> | |
| 296 | operator()(_InputIterator __ifirst, iter_difference_t<_InputIterator> __n, | |
| 297 | _OutputIterator __ofirst, _Sentinel __olast) const { | |
| 298 | using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>; | |
| 299 | auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); }; | |
| 300 | auto __result = _VSTD::__uninitialized_move_n<_ValueType>(_VSTD::move(__ifirst), __n, | |
| 301 | _VSTD::move(__ofirst), _VSTD::move(__olast), __iter_move); | |
| 302 | return {_VSTD::move(__result.first), _VSTD::move(__result.second)}; | |
| 303 | } | |
| 304 | }; | |
| 305 | ||
| 306 | } // namespace __uninitialized_move_n | |
| 307 | ||
| 308 | inline namespace __cpo { | |
| 309 | inline constexpr auto uninitialized_move_n = __uninitialized_move_n::__fn{}; | |
| 310 | } // namespace __cpo | |
| 311 | ||
| 312 | } // namespace ranges | |
| 313 | ||
| 314 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 315 | ||
| 316 | _LIBCPP_END_NAMESPACE_STD | |
| 317 | ||
| 318 | #endif // _LIBCPP___MEMORY_RANGES_UNINITIALIZED_ALGORITHMS_H |
lib/libcxx/include/__memory/raw_storage_iterator.h-5| ... | ... | @@ -20,9 +20,6 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | 25 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR) |
| ... | ... | @@ -68,6 +65,4 @@ public: |
| 68 | 65 | |
| 69 | 66 | _LIBCPP_END_NAMESPACE_STD |
| 70 | 67 | |
| 71 | _LIBCPP_POP_MACROS | |
| 72 | ||
| 73 | 68 | #endif // _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H |
lib/libcxx/include/__memory/shared_ptr.h+446-606| ... | ... | @@ -12,14 +12,14 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | #include <__functional_base> | |
| 16 | 15 | #include <__functional/binary_function.h> |
| 17 | 16 | #include <__functional/operations.h> |
| 18 | 17 | #include <__functional/reference_wrapper.h> |
| 18 | #include <__functional_base> | |
| 19 | 19 | #include <__memory/addressof.h> |
| 20 | 20 | #include <__memory/allocation_guard.h> |
| 21 | #include <__memory/allocator_traits.h> | |
| 22 | 21 | #include <__memory/allocator.h> |
| 22 | #include <__memory/allocator_traits.h> | |
| 23 | 23 | #include <__memory/compressed_pair.h> |
| 24 | 24 | #include <__memory/pointer_traits.h> |
| 25 | 25 | #include <__memory/unique_ptr.h> |
| ... | ... | @@ -28,8 +28,8 @@ |
| 28 | 28 | #include <cstdlib> // abort |
| 29 | 29 | #include <iosfwd> |
| 30 | 30 | #include <stdexcept> |
| 31 | #include <typeinfo> | |
| 32 | 31 | #include <type_traits> |
| 32 | #include <typeinfo> | |
| 33 | 33 | #include <utility> |
| 34 | 34 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
| 35 | 35 | # include <atomic> |
| ... | ... | @@ -43,18 +43,15 @@ |
| 43 | 43 | #pragma GCC system_header |
| 44 | 44 | #endif |
| 45 | 45 | |
| 46 | _LIBCPP_PUSH_MACROS | |
| 47 | #include <__undef_macros> | |
| 48 | ||
| 49 | 46 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 50 | 47 | |
| 51 | 48 | template <class _Alloc> |
| 52 | 49 | class __allocator_destructor |
| 53 | 50 | { |
| 54 | typedef _LIBCPP_NODEBUG_TYPE allocator_traits<_Alloc> __alloc_traits; | |
| 51 | typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits; | |
| 55 | 52 | public: |
| 56 | typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::pointer pointer; | |
| 57 | typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::size_type size_type; | |
| 53 | typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer; | |
| 54 | typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type; | |
| 58 | 55 | private: |
| 59 | 56 | _Alloc& __alloc_; |
| 60 | 57 | size_type __s_; |
| ... | ... | @@ -433,14 +430,20 @@ private: |
| 433 | 430 | element_type* __ptr_; |
| 434 | 431 | __shared_weak_count* __cntrl_; |
| 435 | 432 | |
| 436 | struct __nat {int __for_bool_;}; | |
| 437 | 433 | public: |
| 438 | _LIBCPP_INLINE_VISIBILITY | |
| 439 | _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; | |
| 440 | _LIBCPP_INLINE_VISIBILITY | |
| 441 | _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; | |
| 434 | _LIBCPP_HIDE_FROM_ABI | |
| 435 | _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT | |
| 436 | : __ptr_(nullptr), | |
| 437 | __cntrl_(nullptr) | |
| 438 | { } | |
| 439 | ||
| 440 | _LIBCPP_HIDE_FROM_ABI | |
| 441 | _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT | |
| 442 | : __ptr_(nullptr), | |
| 443 | __cntrl_(nullptr) | |
| 444 | { } | |
| 442 | 445 | |
| 443 | template<class _Yp, class = _EnableIf< | |
| 446 | template<class _Yp, class = __enable_if_t< | |
| 444 | 447 | _And< |
| 445 | 448 | __compatible_with<_Yp, _Tp> |
| 446 | 449 | // In C++03 we get errors when trying to do SFINAE with the |
| ... | ... | @@ -460,643 +463,488 @@ public: |
| 460 | 463 | __enable_weak_this(__p, __p); |
| 461 | 464 | } |
| 462 | 465 | |
| 463 | template<class _Yp, class _Dp> | |
| 464 | shared_ptr(_Yp* __p, _Dp __d, | |
| 465 | typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type = __nat()); | |
| 466 | template<class _Yp, class _Dp, class _Alloc> | |
| 467 | shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, | |
| 468 | typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type = __nat()); | |
| 469 | template <class _Dp> shared_ptr(nullptr_t __p, _Dp __d); | |
| 470 | template <class _Dp, class _Alloc> shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); | |
| 471 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; | |
| 472 | _LIBCPP_INLINE_VISIBILITY | |
| 473 | shared_ptr(const shared_ptr& __r) _NOEXCEPT; | |
| 474 | template<class _Yp> | |
| 475 | _LIBCPP_INLINE_VISIBILITY | |
| 476 | shared_ptr(const shared_ptr<_Yp>& __r, | |
| 477 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()) | |
| 478 | _NOEXCEPT; | |
| 479 | _LIBCPP_INLINE_VISIBILITY | |
| 480 | shared_ptr(shared_ptr&& __r) _NOEXCEPT; | |
| 481 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, | |
| 482 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type = __nat()) | |
| 483 | _NOEXCEPT; | |
| 484 | template<class _Yp> explicit shared_ptr(const weak_ptr<_Yp>& __r, | |
| 485 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type= __nat()); | |
| 486 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 487 | template<class _Yp> | |
| 488 | shared_ptr(auto_ptr<_Yp>&& __r, | |
| 489 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type = __nat()); | |
| 490 | #endif | |
| 491 | template <class _Yp, class _Dp> | |
| 492 | shared_ptr(unique_ptr<_Yp, _Dp>&&, | |
| 493 | typename enable_if | |
| 494 | < | |
| 495 | !is_lvalue_reference<_Dp>::value && | |
| 496 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | |
| 497 | __nat | |
| 498 | >::type = __nat()); | |
| 499 | template <class _Yp, class _Dp> | |
| 500 | shared_ptr(unique_ptr<_Yp, _Dp>&&, | |
| 501 | typename enable_if | |
| 502 | < | |
| 503 | is_lvalue_reference<_Dp>::value && | |
| 504 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | |
| 505 | __nat | |
| 506 | >::type = __nat()); | |
| 507 | ||
| 508 | ~shared_ptr(); | |
| 466 | template<class _Yp, class _Dp, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value> > | |
| 467 | _LIBCPP_HIDE_FROM_ABI | |
| 468 | shared_ptr(_Yp* __p, _Dp __d) | |
| 469 | : __ptr_(__p) | |
| 470 | { | |
| 471 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 472 | try | |
| 473 | { | |
| 474 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 475 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | |
| 476 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; | |
| 477 | #ifndef _LIBCPP_CXX03_LANG | |
| 478 | __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); | |
| 479 | #else | |
| 480 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); | |
| 481 | #endif // not _LIBCPP_CXX03_LANG | |
| 482 | __enable_weak_this(__p, __p); | |
| 483 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 484 | } | |
| 485 | catch (...) | |
| 486 | { | |
| 487 | __d(__p); | |
| 488 | throw; | |
| 489 | } | |
| 490 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 491 | } | |
| 509 | 492 | |
| 510 | _LIBCPP_INLINE_VISIBILITY | |
| 511 | shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; | |
| 512 | template<class _Yp> | |
| 513 | typename enable_if | |
| 514 | < | |
| 515 | __compatible_with<_Yp, element_type>::value, | |
| 516 | shared_ptr& | |
| 517 | >::type | |
| 518 | _LIBCPP_INLINE_VISIBILITY | |
| 519 | operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; | |
| 520 | _LIBCPP_INLINE_VISIBILITY | |
| 521 | shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; | |
| 522 | template<class _Yp> | |
| 523 | typename enable_if | |
| 524 | < | |
| 525 | __compatible_with<_Yp, element_type>::value, | |
| 526 | shared_ptr& | |
| 527 | >::type | |
| 528 | _LIBCPP_INLINE_VISIBILITY | |
| 529 | operator=(shared_ptr<_Yp>&& __r); | |
| 530 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 531 | template<class _Yp> | |
| 532 | _LIBCPP_INLINE_VISIBILITY | |
| 533 | typename enable_if | |
| 534 | < | |
| 535 | !is_array<_Yp>::value && | |
| 536 | is_convertible<_Yp*, element_type*>::value, | |
| 537 | shared_ptr | |
| 538 | >::type& | |
| 539 | operator=(auto_ptr<_Yp>&& __r); | |
| 540 | #endif | |
| 541 | template <class _Yp, class _Dp> | |
| 542 | typename enable_if | |
| 543 | < | |
| 544 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | |
| 545 | shared_ptr& | |
| 546 | >::type | |
| 547 | _LIBCPP_INLINE_VISIBILITY | |
| 548 | operator=(unique_ptr<_Yp, _Dp>&& __r); | |
| 493 | template<class _Yp, class _Dp, class _Alloc, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value> > | |
| 494 | _LIBCPP_HIDE_FROM_ABI | |
| 495 | shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) | |
| 496 | : __ptr_(__p) | |
| 497 | { | |
| 498 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 499 | try | |
| 500 | { | |
| 501 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 502 | typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | |
| 503 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | |
| 504 | typedef __allocator_destructor<_A2> _D2; | |
| 505 | _A2 __a2(__a); | |
| 506 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | |
| 507 | ::new ((void*)_VSTD::addressof(*__hold2.get())) | |
| 508 | #ifndef _LIBCPP_CXX03_LANG | |
| 509 | _CntrlBlk(__p, _VSTD::move(__d), __a); | |
| 510 | #else | |
| 511 | _CntrlBlk(__p, __d, __a); | |
| 512 | #endif // not _LIBCPP_CXX03_LANG | |
| 513 | __cntrl_ = _VSTD::addressof(*__hold2.release()); | |
| 514 | __enable_weak_this(__p, __p); | |
| 515 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 516 | } | |
| 517 | catch (...) | |
| 518 | { | |
| 519 | __d(__p); | |
| 520 | throw; | |
| 521 | } | |
| 522 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 523 | } | |
| 524 | ||
| 525 | template<class _Dp> | |
| 526 | _LIBCPP_HIDE_FROM_ABI | |
| 527 | shared_ptr(nullptr_t __p, _Dp __d) | |
| 528 | : __ptr_(nullptr) | |
| 529 | { | |
| 530 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 531 | try | |
| 532 | { | |
| 533 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 534 | typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; | |
| 535 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk; | |
| 536 | #ifndef _LIBCPP_CXX03_LANG | |
| 537 | __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); | |
| 538 | #else | |
| 539 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); | |
| 540 | #endif // not _LIBCPP_CXX03_LANG | |
| 541 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 542 | } | |
| 543 | catch (...) | |
| 544 | { | |
| 545 | __d(__p); | |
| 546 | throw; | |
| 547 | } | |
| 548 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 549 | } | |
| 550 | ||
| 551 | template<class _Dp, class _Alloc> | |
| 552 | _LIBCPP_HIDE_FROM_ABI | |
| 553 | shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) | |
| 554 | : __ptr_(nullptr) | |
| 555 | { | |
| 556 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 557 | try | |
| 558 | { | |
| 559 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 560 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | |
| 561 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | |
| 562 | typedef __allocator_destructor<_A2> _D2; | |
| 563 | _A2 __a2(__a); | |
| 564 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | |
| 565 | ::new ((void*)_VSTD::addressof(*__hold2.get())) | |
| 566 | #ifndef _LIBCPP_CXX03_LANG | |
| 567 | _CntrlBlk(__p, _VSTD::move(__d), __a); | |
| 568 | #else | |
| 569 | _CntrlBlk(__p, __d, __a); | |
| 570 | #endif // not _LIBCPP_CXX03_LANG | |
| 571 | __cntrl_ = _VSTD::addressof(*__hold2.release()); | |
| 572 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 573 | } | |
| 574 | catch (...) | |
| 575 | { | |
| 576 | __d(__p); | |
| 577 | throw; | |
| 578 | } | |
| 579 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 580 | } | |
| 549 | 581 | |
| 550 | _LIBCPP_INLINE_VISIBILITY | |
| 551 | void swap(shared_ptr& __r) _NOEXCEPT; | |
| 552 | _LIBCPP_INLINE_VISIBILITY | |
| 553 | void reset() _NOEXCEPT; | |
| 554 | 582 | template<class _Yp> |
| 555 | typename enable_if | |
| 556 | < | |
| 557 | __compatible_with<_Yp, element_type>::value, | |
| 558 | void | |
| 559 | >::type | |
| 560 | _LIBCPP_INLINE_VISIBILITY | |
| 561 | reset(_Yp* __p); | |
| 562 | template<class _Yp, class _Dp> | |
| 563 | typename enable_if | |
| 564 | < | |
| 565 | __compatible_with<_Yp, element_type>::value, | |
| 566 | void | |
| 567 | >::type | |
| 568 | _LIBCPP_INLINE_VISIBILITY | |
| 569 | reset(_Yp* __p, _Dp __d); | |
| 570 | template<class _Yp, class _Dp, class _Alloc> | |
| 571 | typename enable_if | |
| 572 | < | |
| 573 | __compatible_with<_Yp, element_type>::value, | |
| 574 | void | |
| 575 | >::type | |
| 576 | _LIBCPP_INLINE_VISIBILITY | |
| 577 | reset(_Yp* __p, _Dp __d, _Alloc __a); | |
| 583 | _LIBCPP_HIDE_FROM_ABI | |
| 584 | shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT | |
| 585 | : __ptr_(__p), | |
| 586 | __cntrl_(__r.__cntrl_) | |
| 587 | { | |
| 588 | if (__cntrl_) | |
| 589 | __cntrl_->__add_shared(); | |
| 590 | } | |
| 578 | 591 | |
| 579 | _LIBCPP_INLINE_VISIBILITY | |
| 580 | element_type* get() const _NOEXCEPT {return __ptr_;} | |
| 581 | _LIBCPP_INLINE_VISIBILITY | |
| 582 | typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT | |
| 583 | {return *__ptr_;} | |
| 584 | _LIBCPP_INLINE_VISIBILITY | |
| 585 | element_type* operator->() const _NOEXCEPT | |
| 592 | _LIBCPP_HIDE_FROM_ABI | |
| 593 | shared_ptr(const shared_ptr& __r) _NOEXCEPT | |
| 594 | : __ptr_(__r.__ptr_), | |
| 595 | __cntrl_(__r.__cntrl_) | |
| 586 | 596 | { |
| 587 | static_assert(!is_array<_Tp>::value, | |
| 588 | "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); | |
| 589 | return __ptr_; | |
| 597 | if (__cntrl_) | |
| 598 | __cntrl_->__add_shared(); | |
| 590 | 599 | } |
| 591 | _LIBCPP_INLINE_VISIBILITY | |
| 592 | long use_count() const _NOEXCEPT {return __cntrl_ ? __cntrl_->use_count() : 0;} | |
| 593 | _LIBCPP_INLINE_VISIBILITY | |
| 594 | bool unique() const _NOEXCEPT {return use_count() == 1;} | |
| 595 | _LIBCPP_INLINE_VISIBILITY | |
| 596 | explicit operator bool() const _NOEXCEPT {return get() != nullptr;} | |
| 597 | template <class _Up> | |
| 598 | _LIBCPP_INLINE_VISIBILITY | |
| 599 | bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT | |
| 600 | {return __cntrl_ < __p.__cntrl_;} | |
| 601 | template <class _Up> | |
| 602 | _LIBCPP_INLINE_VISIBILITY | |
| 603 | bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT | |
| 604 | {return __cntrl_ < __p.__cntrl_;} | |
| 605 | _LIBCPP_INLINE_VISIBILITY | |
| 606 | bool | |
| 607 | __owner_equivalent(const shared_ptr& __p) const | |
| 608 | {return __cntrl_ == __p.__cntrl_;} | |
| 609 | 600 | |
| 610 | #if _LIBCPP_STD_VER > 14 | |
| 611 | typename add_lvalue_reference<element_type>::type | |
| 612 | _LIBCPP_INLINE_VISIBILITY | |
| 613 | operator[](ptrdiff_t __i) const | |
| 601 | template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | |
| 602 | _LIBCPP_HIDE_FROM_ABI | |
| 603 | shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT | |
| 604 | : __ptr_(__r.__ptr_), | |
| 605 | __cntrl_(__r.__cntrl_) | |
| 614 | 606 | { |
| 615 | static_assert(is_array<_Tp>::value, | |
| 616 | "std::shared_ptr<T>::operator[] is only valid when T is an array type."); | |
| 617 | return __ptr_[__i]; | |
| 607 | if (__cntrl_) | |
| 608 | __cntrl_->__add_shared(); | |
| 618 | 609 | } |
| 619 | #endif | |
| 620 | 610 | |
| 621 | #ifndef _LIBCPP_NO_RTTI | |
| 622 | template <class _Dp> | |
| 623 | _LIBCPP_INLINE_VISIBILITY | |
| 624 | _Dp* __get_deleter() const _NOEXCEPT | |
| 625 | {return static_cast<_Dp*>(__cntrl_ | |
| 626 | ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp))) | |
| 627 | : nullptr);} | |
| 628 | #endif // _LIBCPP_NO_RTTI | |
| 611 | _LIBCPP_HIDE_FROM_ABI | |
| 612 | shared_ptr(shared_ptr&& __r) _NOEXCEPT | |
| 613 | : __ptr_(__r.__ptr_), | |
| 614 | __cntrl_(__r.__cntrl_) | |
| 615 | { | |
| 616 | __r.__ptr_ = nullptr; | |
| 617 | __r.__cntrl_ = nullptr; | |
| 618 | } | |
| 629 | 619 | |
| 630 | template<class _Yp, class _CntrlBlk> | |
| 631 | static shared_ptr<_Tp> | |
| 632 | __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT | |
| 620 | template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | |
| 621 | _LIBCPP_HIDE_FROM_ABI | |
| 622 | shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT | |
| 623 | : __ptr_(__r.__ptr_), | |
| 624 | __cntrl_(__r.__cntrl_) | |
| 633 | 625 | { |
| 634 | shared_ptr<_Tp> __r; | |
| 635 | __r.__ptr_ = __p; | |
| 636 | __r.__cntrl_ = __cntrl; | |
| 637 | __r.__enable_weak_this(__r.__ptr_, __r.__ptr_); | |
| 638 | return __r; | |
| 626 | __r.__ptr_ = nullptr; | |
| 627 | __r.__cntrl_ = nullptr; | |
| 639 | 628 | } |
| 640 | 629 | |
| 641 | private: | |
| 642 | template <class _Yp, bool = is_function<_Yp>::value> | |
| 643 | struct __shared_ptr_default_allocator | |
| 644 | { | |
| 645 | typedef allocator<_Yp> type; | |
| 646 | }; | |
| 630 | template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | |
| 631 | _LIBCPP_HIDE_FROM_ABI | |
| 632 | explicit shared_ptr(const weak_ptr<_Yp>& __r) | |
| 633 | : __ptr_(__r.__ptr_), | |
| 634 | __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) | |
| 635 | { | |
| 636 | if (__cntrl_ == nullptr) | |
| 637 | __throw_bad_weak_ptr(); | |
| 638 | } | |
| 647 | 639 | |
| 648 | template <class _Yp> | |
| 649 | struct __shared_ptr_default_allocator<_Yp, true> | |
| 640 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 641 | template<class _Yp, class = __enable_if_t<is_convertible<_Yp*, element_type*>::value> > | |
| 642 | _LIBCPP_HIDE_FROM_ABI | |
| 643 | shared_ptr(auto_ptr<_Yp>&& __r) | |
| 644 | : __ptr_(__r.get()) | |
| 645 | { | |
| 646 | typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | |
| 647 | __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); | |
| 648 | __enable_weak_this(__r.get(), __r.get()); | |
| 649 | __r.release(); | |
| 650 | } | |
| 651 | #endif | |
| 652 | ||
| 653 | template <class _Yp, class _Dp, class = __enable_if_t< | |
| 654 | !is_lvalue_reference<_Dp>::value && | |
| 655 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | |
| 656 | > > | |
| 657 | _LIBCPP_HIDE_FROM_ABI | |
| 658 | shared_ptr(unique_ptr<_Yp, _Dp>&& __r) | |
| 659 | : __ptr_(__r.get()) | |
| 660 | { | |
| 661 | #if _LIBCPP_STD_VER > 11 | |
| 662 | if (__ptr_ == nullptr) | |
| 663 | __cntrl_ = nullptr; | |
| 664 | else | |
| 665 | #endif | |
| 650 | 666 | { |
| 651 | typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type; | |
| 652 | }; | |
| 667 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | |
| 668 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk; | |
| 669 | __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT()); | |
| 670 | __enable_weak_this(__r.get(), __r.get()); | |
| 671 | } | |
| 672 | __r.release(); | |
| 673 | } | |
| 653 | 674 | |
| 654 | template <class _Yp, class _OrigPtr> | |
| 655 | _LIBCPP_INLINE_VISIBILITY | |
| 656 | typename enable_if<is_convertible<_OrigPtr*, | |
| 657 | const enable_shared_from_this<_Yp>* | |
| 658 | >::value, | |
| 659 | void>::type | |
| 660 | __enable_weak_this(const enable_shared_from_this<_Yp>* __e, | |
| 661 | _OrigPtr* __ptr) _NOEXCEPT | |
| 675 | template <class _Yp, class _Dp, class = void, class = __enable_if_t< | |
| 676 | is_lvalue_reference<_Dp>::value && | |
| 677 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | |
| 678 | > > | |
| 679 | _LIBCPP_HIDE_FROM_ABI | |
| 680 | shared_ptr(unique_ptr<_Yp, _Dp>&& __r) | |
| 681 | : __ptr_(__r.get()) | |
| 682 | { | |
| 683 | #if _LIBCPP_STD_VER > 11 | |
| 684 | if (__ptr_ == nullptr) | |
| 685 | __cntrl_ = nullptr; | |
| 686 | else | |
| 687 | #endif | |
| 662 | 688 | { |
| 663 | typedef typename remove_cv<_Yp>::type _RawYp; | |
| 664 | if (__e && __e->__weak_this_.expired()) | |
| 665 | { | |
| 666 | __e->__weak_this_ = shared_ptr<_RawYp>(*this, | |
| 667 | const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr))); | |
| 668 | } | |
| 689 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | |
| 690 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, | |
| 691 | reference_wrapper<typename remove_reference<_Dp>::type>, | |
| 692 | _AllocT > _CntrlBlk; | |
| 693 | __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT()); | |
| 694 | __enable_weak_this(__r.get(), __r.get()); | |
| 669 | 695 | } |
| 696 | __r.release(); | |
| 697 | } | |
| 670 | 698 | |
| 671 | _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {} | |
| 699 | _LIBCPP_HIDE_FROM_ABI | |
| 700 | ~shared_ptr() | |
| 701 | { | |
| 702 | if (__cntrl_) | |
| 703 | __cntrl_->__release_shared(); | |
| 704 | } | |
| 672 | 705 | |
| 673 | template <class, class _Yp> | |
| 674 | struct __shared_ptr_default_delete | |
| 675 | : default_delete<_Yp> {}; | |
| 706 | _LIBCPP_HIDE_FROM_ABI | |
| 707 | shared_ptr<_Tp>& operator=(const shared_ptr& __r) _NOEXCEPT | |
| 708 | { | |
| 709 | shared_ptr(__r).swap(*this); | |
| 710 | return *this; | |
| 711 | } | |
| 676 | 712 | |
| 677 | template <class _Yp, class _Un, size_t _Sz> | |
| 678 | struct __shared_ptr_default_delete<_Yp[_Sz], _Un> | |
| 679 | : default_delete<_Yp[]> {}; | |
| 713 | template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | |
| 714 | _LIBCPP_HIDE_FROM_ABI | |
| 715 | shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT | |
| 716 | { | |
| 717 | shared_ptr(__r).swap(*this); | |
| 718 | return *this; | |
| 719 | } | |
| 680 | 720 | |
| 681 | template <class _Yp, class _Un> | |
| 682 | struct __shared_ptr_default_delete<_Yp[], _Un> | |
| 683 | : default_delete<_Yp[]> {}; | |
| 721 | _LIBCPP_HIDE_FROM_ABI | |
| 722 | shared_ptr<_Tp>& operator=(shared_ptr&& __r) _NOEXCEPT | |
| 723 | { | |
| 724 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 725 | return *this; | |
| 726 | } | |
| 684 | 727 | |
| 685 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; | |
| 686 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; | |
| 687 | }; | |
| 728 | template<class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> > | |
| 729 | _LIBCPP_HIDE_FROM_ABI | |
| 730 | shared_ptr<_Tp>& operator=(shared_ptr<_Yp>&& __r) | |
| 731 | { | |
| 732 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 733 | return *this; | |
| 734 | } | |
| 688 | 735 | |
| 689 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 690 | template<class _Tp> | |
| 691 | shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; | |
| 692 | template<class _Tp, class _Dp> | |
| 693 | shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; | |
| 736 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 737 | template<class _Yp, class = __enable_if_t< | |
| 738 | !is_array<_Yp>::value && | |
| 739 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value | |
| 740 | > > | |
| 741 | _LIBCPP_HIDE_FROM_ABI | |
| 742 | shared_ptr<_Tp>& operator=(auto_ptr<_Yp>&& __r) | |
| 743 | { | |
| 744 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 745 | return *this; | |
| 746 | } | |
| 694 | 747 | #endif |
| 695 | 748 | |
| 696 | template<class _Tp> | |
| 697 | inline | |
| 698 | _LIBCPP_CONSTEXPR | |
| 699 | shared_ptr<_Tp>::shared_ptr() _NOEXCEPT | |
| 700 | : __ptr_(nullptr), | |
| 701 | __cntrl_(nullptr) | |
| 702 | { | |
| 703 | } | |
| 749 | template <class _Yp, class _Dp, class = __enable_if_t< | |
| 750 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value | |
| 751 | > > | |
| 752 | _LIBCPP_HIDE_FROM_ABI | |
| 753 | shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r) | |
| 754 | { | |
| 755 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 756 | return *this; | |
| 757 | } | |
| 704 | 758 | |
| 705 | template<class _Tp> | |
| 706 | inline | |
| 707 | _LIBCPP_CONSTEXPR | |
| 708 | shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT | |
| 709 | : __ptr_(nullptr), | |
| 710 | __cntrl_(nullptr) | |
| 711 | { | |
| 712 | } | |
| 759 | _LIBCPP_HIDE_FROM_ABI | |
| 760 | void swap(shared_ptr& __r) _NOEXCEPT | |
| 761 | { | |
| 762 | _VSTD::swap(__ptr_, __r.__ptr_); | |
| 763 | _VSTD::swap(__cntrl_, __r.__cntrl_); | |
| 764 | } | |
| 713 | 765 | |
| 714 | template<class _Tp> | |
| 715 | template<class _Yp, class _Dp> | |
| 716 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, | |
| 717 | typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type) | |
| 718 | : __ptr_(__p) | |
| 719 | { | |
| 720 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 721 | try | |
| 766 | _LIBCPP_HIDE_FROM_ABI | |
| 767 | void reset() _NOEXCEPT | |
| 722 | 768 | { |
| 723 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 724 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | |
| 725 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; | |
| 726 | #ifndef _LIBCPP_CXX03_LANG | |
| 727 | __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); | |
| 728 | #else | |
| 729 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); | |
| 730 | #endif // not _LIBCPP_CXX03_LANG | |
| 731 | __enable_weak_this(__p, __p); | |
| 732 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 769 | shared_ptr().swap(*this); | |
| 733 | 770 | } |
| 734 | catch (...) | |
| 771 | ||
| 772 | template<class _Yp, class = __enable_if_t< | |
| 773 | __compatible_with<_Yp, _Tp>::value | |
| 774 | > > | |
| 775 | _LIBCPP_HIDE_FROM_ABI | |
| 776 | void reset(_Yp* __p) | |
| 735 | 777 | { |
| 736 | __d(__p); | |
| 737 | throw; | |
| 778 | shared_ptr(__p).swap(*this); | |
| 738 | 779 | } |
| 739 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 740 | } | |
| 741 | 780 | |
| 742 | template<class _Tp> | |
| 743 | template<class _Dp> | |
| 744 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d) | |
| 745 | : __ptr_(nullptr) | |
| 746 | { | |
| 747 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 748 | try | |
| 781 | template<class _Yp, class _Dp, class = __enable_if_t< | |
| 782 | __compatible_with<_Yp, _Tp>::value | |
| 783 | > > | |
| 784 | _LIBCPP_HIDE_FROM_ABI | |
| 785 | void reset(_Yp* __p, _Dp __d) | |
| 749 | 786 | { |
| 750 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 751 | typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; | |
| 752 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk; | |
| 753 | #ifndef _LIBCPP_CXX03_LANG | |
| 754 | __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); | |
| 755 | #else | |
| 756 | __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); | |
| 757 | #endif // not _LIBCPP_CXX03_LANG | |
| 758 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 787 | shared_ptr(__p, __d).swap(*this); | |
| 759 | 788 | } |
| 760 | catch (...) | |
| 789 | ||
| 790 | template<class _Yp, class _Dp, class _Alloc, class = __enable_if_t< | |
| 791 | __compatible_with<_Yp, _Tp>::value | |
| 792 | > > | |
| 793 | _LIBCPP_HIDE_FROM_ABI | |
| 794 | void reset(_Yp* __p, _Dp __d, _Alloc __a) | |
| 761 | 795 | { |
| 762 | __d(__p); | |
| 763 | throw; | |
| 796 | shared_ptr(__p, __d, __a).swap(*this); | |
| 764 | 797 | } |
| 765 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 766 | } | |
| 767 | 798 | |
| 768 | template<class _Tp> | |
| 769 | template<class _Yp, class _Dp, class _Alloc> | |
| 770 | shared_ptr<_Tp>::shared_ptr(_Yp* __p, _Dp __d, _Alloc __a, | |
| 771 | typename enable_if<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, element_type>::value, __nat>::type) | |
| 772 | : __ptr_(__p) | |
| 773 | { | |
| 774 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 775 | try | |
| 799 | _LIBCPP_HIDE_FROM_ABI | |
| 800 | element_type* get() const _NOEXCEPT | |
| 776 | 801 | { |
| 777 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 778 | typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; | |
| 779 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | |
| 780 | typedef __allocator_destructor<_A2> _D2; | |
| 781 | _A2 __a2(__a); | |
| 782 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | |
| 783 | ::new ((void*)_VSTD::addressof(*__hold2.get())) | |
| 784 | #ifndef _LIBCPP_CXX03_LANG | |
| 785 | _CntrlBlk(__p, _VSTD::move(__d), __a); | |
| 786 | #else | |
| 787 | _CntrlBlk(__p, __d, __a); | |
| 788 | #endif // not _LIBCPP_CXX03_LANG | |
| 789 | __cntrl_ = _VSTD::addressof(*__hold2.release()); | |
| 790 | __enable_weak_this(__p, __p); | |
| 791 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 802 | return __ptr_; | |
| 792 | 803 | } |
| 793 | catch (...) | |
| 804 | ||
| 805 | _LIBCPP_HIDE_FROM_ABI | |
| 806 | typename add_lvalue_reference<element_type>::type operator*() const _NOEXCEPT | |
| 794 | 807 | { |
| 795 | __d(__p); | |
| 796 | throw; | |
| 808 | return *__ptr_; | |
| 797 | 809 | } |
| 798 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 799 | } | |
| 800 | 810 | |
| 801 | template<class _Tp> | |
| 802 | template<class _Dp, class _Alloc> | |
| 803 | shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) | |
| 804 | : __ptr_(nullptr) | |
| 805 | { | |
| 806 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 807 | try | |
| 811 | _LIBCPP_HIDE_FROM_ABI | |
| 812 | element_type* operator->() const _NOEXCEPT | |
| 808 | 813 | { |
| 809 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 810 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk; | |
| 811 | typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; | |
| 812 | typedef __allocator_destructor<_A2> _D2; | |
| 813 | _A2 __a2(__a); | |
| 814 | unique_ptr<_CntrlBlk, _D2> __hold2(__a2.allocate(1), _D2(__a2, 1)); | |
| 815 | ::new ((void*)_VSTD::addressof(*__hold2.get())) | |
| 816 | #ifndef _LIBCPP_CXX03_LANG | |
| 817 | _CntrlBlk(__p, _VSTD::move(__d), __a); | |
| 818 | #else | |
| 819 | _CntrlBlk(__p, __d, __a); | |
| 820 | #endif // not _LIBCPP_CXX03_LANG | |
| 821 | __cntrl_ = _VSTD::addressof(*__hold2.release()); | |
| 822 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 814 | static_assert(!is_array<_Tp>::value, | |
| 815 | "std::shared_ptr<T>::operator-> is only valid when T is not an array type."); | |
| 816 | return __ptr_; | |
| 823 | 817 | } |
| 824 | catch (...) | |
| 818 | ||
| 819 | _LIBCPP_HIDE_FROM_ABI | |
| 820 | long use_count() const _NOEXCEPT | |
| 825 | 821 | { |
| 826 | __d(__p); | |
| 827 | throw; | |
| 822 | return __cntrl_ ? __cntrl_->use_count() : 0; | |
| 828 | 823 | } |
| 829 | #endif // _LIBCPP_NO_EXCEPTIONS | |
| 830 | } | |
| 831 | 824 | |
| 832 | template<class _Tp> | |
| 833 | template<class _Yp> | |
| 834 | inline | |
| 835 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT | |
| 836 | : __ptr_(__p), | |
| 837 | __cntrl_(__r.__cntrl_) | |
| 838 | { | |
| 839 | if (__cntrl_) | |
| 840 | __cntrl_->__add_shared(); | |
| 841 | } | |
| 825 | _LIBCPP_HIDE_FROM_ABI | |
| 826 | bool unique() const _NOEXCEPT | |
| 827 | { | |
| 828 | return use_count() == 1; | |
| 829 | } | |
| 842 | 830 | |
| 843 | template<class _Tp> | |
| 844 | inline | |
| 845 | shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT | |
| 846 | : __ptr_(__r.__ptr_), | |
| 847 | __cntrl_(__r.__cntrl_) | |
| 848 | { | |
| 849 | if (__cntrl_) | |
| 850 | __cntrl_->__add_shared(); | |
| 851 | } | |
| 831 | _LIBCPP_HIDE_FROM_ABI | |
| 832 | explicit operator bool() const _NOEXCEPT | |
| 833 | { | |
| 834 | return get() != nullptr; | |
| 835 | } | |
| 852 | 836 | |
| 853 | template<class _Tp> | |
| 854 | template<class _Yp> | |
| 855 | inline | |
| 856 | shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, | |
| 857 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) | |
| 858 | _NOEXCEPT | |
| 859 | : __ptr_(__r.__ptr_), | |
| 860 | __cntrl_(__r.__cntrl_) | |
| 861 | { | |
| 862 | if (__cntrl_) | |
| 863 | __cntrl_->__add_shared(); | |
| 864 | } | |
| 837 | template <class _Up> | |
| 838 | _LIBCPP_HIDE_FROM_ABI | |
| 839 | bool owner_before(shared_ptr<_Up> const& __p) const _NOEXCEPT | |
| 840 | { | |
| 841 | return __cntrl_ < __p.__cntrl_; | |
| 842 | } | |
| 865 | 843 | |
| 866 | template<class _Tp> | |
| 867 | inline | |
| 868 | shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT | |
| 869 | : __ptr_(__r.__ptr_), | |
| 870 | __cntrl_(__r.__cntrl_) | |
| 871 | { | |
| 872 | __r.__ptr_ = nullptr; | |
| 873 | __r.__cntrl_ = nullptr; | |
| 874 | } | |
| 844 | template <class _Up> | |
| 845 | _LIBCPP_HIDE_FROM_ABI | |
| 846 | bool owner_before(weak_ptr<_Up> const& __p) const _NOEXCEPT | |
| 847 | { | |
| 848 | return __cntrl_ < __p.__cntrl_; | |
| 849 | } | |
| 875 | 850 | |
| 876 | template<class _Tp> | |
| 877 | template<class _Yp> | |
| 878 | inline | |
| 879 | shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, | |
| 880 | typename enable_if<__compatible_with<_Yp, element_type>::value, __nat>::type) | |
| 881 | _NOEXCEPT | |
| 882 | : __ptr_(__r.__ptr_), | |
| 883 | __cntrl_(__r.__cntrl_) | |
| 884 | { | |
| 885 | __r.__ptr_ = nullptr; | |
| 886 | __r.__cntrl_ = nullptr; | |
| 887 | } | |
| 851 | _LIBCPP_HIDE_FROM_ABI | |
| 852 | bool __owner_equivalent(const shared_ptr& __p) const | |
| 853 | { | |
| 854 | return __cntrl_ == __p.__cntrl_; | |
| 855 | } | |
| 888 | 856 | |
| 889 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 890 | template<class _Tp> | |
| 891 | template<class _Yp> | |
| 892 | shared_ptr<_Tp>::shared_ptr(auto_ptr<_Yp>&& __r, | |
| 893 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | |
| 894 | : __ptr_(__r.get()) | |
| 895 | { | |
| 896 | typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk; | |
| 897 | __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>()); | |
| 898 | __enable_weak_this(__r.get(), __r.get()); | |
| 899 | __r.release(); | |
| 900 | } | |
| 857 | #if _LIBCPP_STD_VER > 14 | |
| 858 | _LIBCPP_HIDE_FROM_ABI | |
| 859 | typename add_lvalue_reference<element_type>::type operator[](ptrdiff_t __i) const | |
| 860 | { | |
| 861 | static_assert(is_array<_Tp>::value, | |
| 862 | "std::shared_ptr<T>::operator[] is only valid when T is an array type."); | |
| 863 | return __ptr_[__i]; | |
| 864 | } | |
| 901 | 865 | #endif |
| 902 | 866 | |
| 903 | template<class _Tp> | |
| 904 | template <class _Yp, class _Dp> | |
| 905 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | |
| 906 | typename enable_if | |
| 907 | < | |
| 908 | !is_lvalue_reference<_Dp>::value && | |
| 909 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | |
| 910 | __nat | |
| 911 | >::type) | |
| 912 | : __ptr_(__r.get()) | |
| 913 | { | |
| 914 | #if _LIBCPP_STD_VER > 11 | |
| 915 | if (__ptr_ == nullptr) | |
| 916 | __cntrl_ = nullptr; | |
| 917 | else | |
| 918 | #endif | |
| 867 | #ifndef _LIBCPP_NO_RTTI | |
| 868 | template <class _Dp> | |
| 869 | _LIBCPP_HIDE_FROM_ABI | |
| 870 | _Dp* __get_deleter() const _NOEXCEPT | |
| 919 | 871 | { |
| 920 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | |
| 921 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT > _CntrlBlk; | |
| 922 | __cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT()); | |
| 923 | __enable_weak_this(__r.get(), __r.get()); | |
| 872 | return static_cast<_Dp*>(__cntrl_ | |
| 873 | ? const_cast<void *>(__cntrl_->__get_deleter(typeid(_Dp))) | |
| 874 | : nullptr); | |
| 924 | 875 | } |
| 925 | __r.release(); | |
| 926 | } | |
| 876 | #endif // _LIBCPP_NO_RTTI | |
| 927 | 877 | |
| 928 | template<class _Tp> | |
| 929 | template <class _Yp, class _Dp> | |
| 930 | shared_ptr<_Tp>::shared_ptr(unique_ptr<_Yp, _Dp>&& __r, | |
| 931 | typename enable_if | |
| 932 | < | |
| 933 | is_lvalue_reference<_Dp>::value && | |
| 934 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value, | |
| 935 | __nat | |
| 936 | >::type) | |
| 937 | : __ptr_(__r.get()) | |
| 938 | { | |
| 939 | #if _LIBCPP_STD_VER > 11 | |
| 940 | if (__ptr_ == nullptr) | |
| 941 | __cntrl_ = nullptr; | |
| 942 | else | |
| 943 | #endif | |
| 878 | template<class _Yp, class _CntrlBlk> | |
| 879 | _LIBCPP_HIDE_FROM_ABI | |
| 880 | static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT | |
| 944 | 881 | { |
| 945 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; | |
| 946 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, | |
| 947 | reference_wrapper<typename remove_reference<_Dp>::type>, | |
| 948 | _AllocT > _CntrlBlk; | |
| 949 | __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT()); | |
| 950 | __enable_weak_this(__r.get(), __r.get()); | |
| 882 | shared_ptr<_Tp> __r; | |
| 883 | __r.__ptr_ = __p; | |
| 884 | __r.__cntrl_ = __cntrl; | |
| 885 | __r.__enable_weak_this(__r.__ptr_, __r.__ptr_); | |
| 886 | return __r; | |
| 951 | 887 | } |
| 952 | __r.release(); | |
| 953 | } | |
| 954 | ||
| 955 | template<class _Tp> | |
| 956 | shared_ptr<_Tp>::~shared_ptr() | |
| 957 | { | |
| 958 | if (__cntrl_) | |
| 959 | __cntrl_->__release_shared(); | |
| 960 | } | |
| 961 | ||
| 962 | template<class _Tp> | |
| 963 | inline | |
| 964 | shared_ptr<_Tp>& | |
| 965 | shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT | |
| 966 | { | |
| 967 | shared_ptr(__r).swap(*this); | |
| 968 | return *this; | |
| 969 | } | |
| 970 | ||
| 971 | template<class _Tp> | |
| 972 | template<class _Yp> | |
| 973 | inline | |
| 974 | typename enable_if | |
| 975 | < | |
| 976 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, | |
| 977 | shared_ptr<_Tp>& | |
| 978 | >::type | |
| 979 | shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT | |
| 980 | { | |
| 981 | shared_ptr(__r).swap(*this); | |
| 982 | return *this; | |
| 983 | } | |
| 984 | 888 | |
| 985 | template<class _Tp> | |
| 986 | inline | |
| 987 | shared_ptr<_Tp>& | |
| 988 | shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT | |
| 989 | { | |
| 990 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 991 | return *this; | |
| 992 | } | |
| 889 | private: | |
| 890 | template <class _Yp, bool = is_function<_Yp>::value> | |
| 891 | struct __shared_ptr_default_allocator | |
| 892 | { | |
| 893 | typedef allocator<_Yp> type; | |
| 894 | }; | |
| 993 | 895 | |
| 994 | template<class _Tp> | |
| 995 | template<class _Yp> | |
| 996 | inline | |
| 997 | typename enable_if | |
| 998 | < | |
| 999 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, | |
| 1000 | shared_ptr<_Tp>& | |
| 1001 | >::type | |
| 1002 | shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) | |
| 1003 | { | |
| 1004 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 1005 | return *this; | |
| 1006 | } | |
| 896 | template <class _Yp> | |
| 897 | struct __shared_ptr_default_allocator<_Yp, true> | |
| 898 | { | |
| 899 | typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type; | |
| 900 | }; | |
| 1007 | 901 | |
| 1008 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 1009 | template<class _Tp> | |
| 1010 | template<class _Yp> | |
| 1011 | inline | |
| 1012 | typename enable_if | |
| 1013 | < | |
| 1014 | !is_array<_Yp>::value && | |
| 1015 | is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value, | |
| 1016 | shared_ptr<_Tp> | |
| 1017 | >::type& | |
| 1018 | shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) | |
| 1019 | { | |
| 1020 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 1021 | return *this; | |
| 1022 | } | |
| 1023 | #endif | |
| 902 | template <class _Yp, class _OrigPtr, class = __enable_if_t< | |
| 903 | is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value | |
| 904 | > > | |
| 905 | _LIBCPP_HIDE_FROM_ABI | |
| 906 | void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT | |
| 907 | { | |
| 908 | typedef typename remove_cv<_Yp>::type _RawYp; | |
| 909 | if (__e && __e->__weak_this_.expired()) | |
| 910 | { | |
| 911 | __e->__weak_this_ = shared_ptr<_RawYp>(*this, | |
| 912 | const_cast<_RawYp*>(static_cast<const _Yp*>(__ptr))); | |
| 913 | } | |
| 914 | } | |
| 1024 | 915 | |
| 1025 | template<class _Tp> | |
| 1026 | template <class _Yp, class _Dp> | |
| 1027 | inline | |
| 1028 | typename enable_if | |
| 1029 | < | |
| 1030 | is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, | |
| 1031 | typename shared_ptr<_Tp>::element_type*>::value, | |
| 1032 | shared_ptr<_Tp>& | |
| 1033 | >::type | |
| 1034 | shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp>&& __r) | |
| 1035 | { | |
| 1036 | shared_ptr(_VSTD::move(__r)).swap(*this); | |
| 1037 | return *this; | |
| 1038 | } | |
| 916 | _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(...) _NOEXCEPT { } | |
| 1039 | 917 | |
| 1040 | template<class _Tp> | |
| 1041 | inline | |
| 1042 | void | |
| 1043 | shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT | |
| 1044 | { | |
| 1045 | _VSTD::swap(__ptr_, __r.__ptr_); | |
| 1046 | _VSTD::swap(__cntrl_, __r.__cntrl_); | |
| 1047 | } | |
| 918 | template <class, class _Yp> | |
| 919 | struct __shared_ptr_default_delete | |
| 920 | : default_delete<_Yp> | |
| 921 | { }; | |
| 1048 | 922 | |
| 1049 | template<class _Tp> | |
| 1050 | inline | |
| 1051 | void | |
| 1052 | shared_ptr<_Tp>::reset() _NOEXCEPT | |
| 1053 | { | |
| 1054 | shared_ptr().swap(*this); | |
| 1055 | } | |
| 923 | template <class _Yp, class _Un, size_t _Sz> | |
| 924 | struct __shared_ptr_default_delete<_Yp[_Sz], _Un> | |
| 925 | : default_delete<_Yp[]> | |
| 926 | { }; | |
| 1056 | 927 | |
| 1057 | template<class _Tp> | |
| 1058 | template<class _Yp> | |
| 1059 | inline | |
| 1060 | typename enable_if | |
| 1061 | < | |
| 1062 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, | |
| 1063 | void | |
| 1064 | >::type | |
| 1065 | shared_ptr<_Tp>::reset(_Yp* __p) | |
| 1066 | { | |
| 1067 | shared_ptr(__p).swap(*this); | |
| 1068 | } | |
| 928 | template <class _Yp, class _Un> | |
| 929 | struct __shared_ptr_default_delete<_Yp[], _Un> | |
| 930 | : default_delete<_Yp[]> | |
| 931 | { }; | |
| 1069 | 932 | |
| 1070 | template<class _Tp> | |
| 1071 | template<class _Yp, class _Dp> | |
| 1072 | inline | |
| 1073 | typename enable_if | |
| 1074 | < | |
| 1075 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, | |
| 1076 | void | |
| 1077 | >::type | |
| 1078 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) | |
| 1079 | { | |
| 1080 | shared_ptr(__p, __d).swap(*this); | |
| 1081 | } | |
| 933 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; | |
| 934 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS weak_ptr; | |
| 935 | }; | |
| 1082 | 936 | |
| 937 | #if _LIBCPP_STD_VER > 14 | |
| 1083 | 938 | template<class _Tp> |
| 1084 | template<class _Yp, class _Dp, class _Alloc> | |
| 1085 | inline | |
| 1086 | typename enable_if | |
| 1087 | < | |
| 1088 | __compatible_with<_Yp, typename shared_ptr<_Tp>::element_type>::value, | |
| 1089 | void | |
| 1090 | >::type | |
| 1091 | shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d, _Alloc __a) | |
| 1092 | { | |
| 1093 | shared_ptr(__p, __d, __a).swap(*this); | |
| 1094 | } | |
| 939 | shared_ptr(weak_ptr<_Tp>) -> shared_ptr<_Tp>; | |
| 940 | template<class _Tp, class _Dp> | |
| 941 | shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>; | |
| 942 | #endif | |
| 1095 | 943 | |
| 1096 | 944 | // |
| 1097 | 945 | // std::allocate_shared and std::make_shared |
| 1098 | 946 | // |
| 1099 | template<class _Tp, class _Alloc, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> > | |
| 947 | template<class _Tp, class _Alloc, class ..._Args, class = __enable_if_t<!is_array<_Tp>::value> > | |
| 1100 | 948 | _LIBCPP_HIDE_FROM_ABI |
| 1101 | 949 | shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& ...__args) |
| 1102 | 950 | { |
| ... | ... | @@ -1108,7 +956,7 @@ shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&& ...__args) |
| 1108 | 956 | return shared_ptr<_Tp>::__create_with_control_block((*__control_block).__get_elem(), _VSTD::addressof(*__control_block)); |
| 1109 | 957 | } |
| 1110 | 958 | |
| 1111 | template<class _Tp, class ..._Args, class = _EnableIf<!is_array<_Tp>::value> > | |
| 959 | template<class _Tp, class ..._Args, class = __enable_if_t<!is_array<_Tp>::value> > | |
| 1112 | 960 | _LIBCPP_HIDE_FROM_ABI |
| 1113 | 961 | shared_ptr<_Tp> make_shared(_Args&& ...__args) |
| 1114 | 962 | { |
| ... | ... | @@ -1326,7 +1174,12 @@ template<class _Tp> |
| 1326 | 1174 | class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr |
| 1327 | 1175 | { |
| 1328 | 1176 | public: |
| 1177 | #if _LIBCPP_STD_VER > 14 | |
| 1178 | typedef remove_extent_t<_Tp> element_type; | |
| 1179 | #else | |
| 1329 | 1180 | typedef _Tp element_type; |
| 1181 | #endif | |
| 1182 | ||
| 1330 | 1183 | private: |
| 1331 | 1184 | element_type* __ptr_; |
| 1332 | 1185 | __shared_weak_count* __cntrl_; |
| ... | ... | @@ -1335,18 +1188,18 @@ public: |
| 1335 | 1188 | _LIBCPP_INLINE_VISIBILITY |
| 1336 | 1189 | _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; |
| 1337 | 1190 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r, |
| 1338 | typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | |
| 1191 | typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) | |
| 1339 | 1192 | _NOEXCEPT; |
| 1340 | 1193 | _LIBCPP_INLINE_VISIBILITY |
| 1341 | 1194 | weak_ptr(weak_ptr const& __r) _NOEXCEPT; |
| 1342 | 1195 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r, |
| 1343 | typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | |
| 1196 | typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) | |
| 1344 | 1197 | _NOEXCEPT; |
| 1345 | 1198 | |
| 1346 | 1199 | _LIBCPP_INLINE_VISIBILITY |
| 1347 | 1200 | weak_ptr(weak_ptr&& __r) _NOEXCEPT; |
| 1348 | 1201 | template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r, |
| 1349 | typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type = 0) | |
| 1202 | typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) | |
| 1350 | 1203 | _NOEXCEPT; |
| 1351 | 1204 | ~weak_ptr(); |
| 1352 | 1205 | |
| ... | ... | @@ -1355,7 +1208,7 @@ public: |
| 1355 | 1208 | template<class _Yp> |
| 1356 | 1209 | typename enable_if |
| 1357 | 1210 | < |
| 1358 | is_convertible<_Yp*, element_type*>::value, | |
| 1211 | __compatible_with<_Yp, _Tp>::value, | |
| 1359 | 1212 | weak_ptr& |
| 1360 | 1213 | >::type |
| 1361 | 1214 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1366,7 +1219,7 @@ public: |
| 1366 | 1219 | template<class _Yp> |
| 1367 | 1220 | typename enable_if |
| 1368 | 1221 | < |
| 1369 | is_convertible<_Yp*, element_type*>::value, | |
| 1222 | __compatible_with<_Yp, _Tp>::value, | |
| 1370 | 1223 | weak_ptr& |
| 1371 | 1224 | >::type |
| 1372 | 1225 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1375,7 +1228,7 @@ public: |
| 1375 | 1228 | template<class _Yp> |
| 1376 | 1229 | typename enable_if |
| 1377 | 1230 | < |
| 1378 | is_convertible<_Yp*, element_type*>::value, | |
| 1231 | __compatible_with<_Yp, _Tp>::value, | |
| 1379 | 1232 | weak_ptr& |
| 1380 | 1233 | >::type |
| 1381 | 1234 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1406,7 +1259,7 @@ public: |
| 1406 | 1259 | template <class _Up> friend class _LIBCPP_TEMPLATE_VIS shared_ptr; |
| 1407 | 1260 | }; |
| 1408 | 1261 | |
| 1409 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1262 | #if _LIBCPP_STD_VER > 14 | |
| 1410 | 1263 | template<class _Tp> |
| 1411 | 1264 | weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>; |
| 1412 | 1265 | #endif |
| ... | ... | @@ -1434,7 +1287,7 @@ template<class _Tp> |
| 1434 | 1287 | template<class _Yp> |
| 1435 | 1288 | inline |
| 1436 | 1289 | weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, |
| 1437 | typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | |
| 1290 | typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) | |
| 1438 | 1291 | _NOEXCEPT |
| 1439 | 1292 | : __ptr_(__r.__ptr_), |
| 1440 | 1293 | __cntrl_(__r.__cntrl_) |
| ... | ... | @@ -1447,7 +1300,7 @@ template<class _Tp> |
| 1447 | 1300 | template<class _Yp> |
| 1448 | 1301 | inline |
| 1449 | 1302 | weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, |
| 1450 | typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | |
| 1303 | typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) | |
| 1451 | 1304 | _NOEXCEPT |
| 1452 | 1305 | : __ptr_(__r.__ptr_), |
| 1453 | 1306 | __cntrl_(__r.__cntrl_) |
| ... | ... | @@ -1470,7 +1323,7 @@ template<class _Tp> |
| 1470 | 1323 | template<class _Yp> |
| 1471 | 1324 | inline |
| 1472 | 1325 | weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, |
| 1473 | typename enable_if<is_convertible<_Yp*, _Tp*>::value, __nat*>::type) | |
| 1326 | typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) | |
| 1474 | 1327 | _NOEXCEPT |
| 1475 | 1328 | : __ptr_(__r.__ptr_), |
| 1476 | 1329 | __cntrl_(__r.__cntrl_) |
| ... | ... | @@ -1500,7 +1353,7 @@ template<class _Yp> |
| 1500 | 1353 | inline |
| 1501 | 1354 | typename enable_if |
| 1502 | 1355 | < |
| 1503 | is_convertible<_Yp*, _Tp*>::value, | |
| 1356 | __compatible_with<_Yp, _Tp>::value, | |
| 1504 | 1357 | weak_ptr<_Tp>& |
| 1505 | 1358 | >::type |
| 1506 | 1359 | weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT |
| ... | ... | @@ -1523,7 +1376,7 @@ template<class _Yp> |
| 1523 | 1376 | inline |
| 1524 | 1377 | typename enable_if |
| 1525 | 1378 | < |
| 1526 | is_convertible<_Yp*, _Tp*>::value, | |
| 1379 | __compatible_with<_Yp, _Tp>::value, | |
| 1527 | 1380 | weak_ptr<_Tp>& |
| 1528 | 1381 | >::type |
| 1529 | 1382 | weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT |
| ... | ... | @@ -1537,7 +1390,7 @@ template<class _Yp> |
| 1537 | 1390 | inline |
| 1538 | 1391 | typename enable_if |
| 1539 | 1392 | < |
| 1540 | is_convertible<_Yp*, _Tp*>::value, | |
| 1393 | __compatible_with<_Yp, _Tp>::value, | |
| 1541 | 1394 | weak_ptr<_Tp>& |
| 1542 | 1395 | >::type |
| 1543 | 1396 | weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT |
| ... | ... | @@ -1571,17 +1424,6 @@ weak_ptr<_Tp>::reset() _NOEXCEPT |
| 1571 | 1424 | weak_ptr().swap(*this); |
| 1572 | 1425 | } |
| 1573 | 1426 | |
| 1574 | template<class _Tp> | |
| 1575 | template<class _Yp> | |
| 1576 | shared_ptr<_Tp>::shared_ptr(const weak_ptr<_Yp>& __r, | |
| 1577 | typename enable_if<is_convertible<_Yp*, element_type*>::value, __nat>::type) | |
| 1578 | : __ptr_(__r.__ptr_), | |
| 1579 | __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) | |
| 1580 | { | |
| 1581 | if (__cntrl_ == nullptr) | |
| 1582 | __throw_bad_weak_ptr(); | |
| 1583 | } | |
| 1584 | ||
| 1585 | 1427 | template<class _Tp> |
| 1586 | 1428 | shared_ptr<_Tp> |
| 1587 | 1429 | weak_ptr<_Tp>::lock() const _NOEXCEPT |
| ... | ... | @@ -1730,7 +1572,7 @@ basic_ostream<_CharT, _Traits>& |
| 1730 | 1572 | operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); |
| 1731 | 1573 | |
| 1732 | 1574 | |
| 1733 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | |
| 1575 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 1734 | 1576 | |
| 1735 | 1577 | class _LIBCPP_TYPE_VIS __sp_mut |
| 1736 | 1578 | { |
| ... | ... | @@ -1870,10 +1712,8 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v |
| 1870 | 1712 | return atomic_compare_exchange_weak(__p, __v, __w); |
| 1871 | 1713 | } |
| 1872 | 1714 | |
| 1873 | #endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | |
| 1715 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 1874 | 1716 | |
| 1875 | 1717 | _LIBCPP_END_NAMESPACE_STD |
| 1876 | 1718 | |
| 1877 | _LIBCPP_POP_MACROS | |
| 1878 | ||
| 1879 | 1719 | #endif // _LIBCPP___MEMORY_SHARED_PTR_H |
lib/libcxx/include/__memory/temporary_buffer.h-5| ... | ... | @@ -19,9 +19,6 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | template <class _Tp> |
| ... | ... | @@ -84,6 +81,4 @@ struct __return_temporary_buffer |
| 84 | 81 | |
| 85 | 82 | _LIBCPP_END_NAMESPACE_STD |
| 86 | 83 | |
| 87 | _LIBCPP_POP_MACROS | |
| 88 | ||
| 89 | 84 | #endif // _LIBCPP___MEMORY_TEMPORARY_BUFFER_H |
lib/libcxx/include/__memory/uninitialized_algorithms.h+216-127| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__memory/addressof.h> |
| 15 | 15 | #include <__memory/construct_at.h> |
| 16 | #include <__memory/voidify.h> | |
| 16 | 17 | #include <iterator> |
| 17 | 18 | #include <utility> |
| 18 | 19 | |
| ... | ... | @@ -20,242 +21,330 @@ |
| 20 | 21 | #pragma GCC system_header |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 25 | |
| 26 | // This is a simplified version of C++20 `unreachable_sentinel` that doesn't use concepts and thus can be used in any | |
| 27 | // language mode. | |
| 28 | struct __unreachable_sentinel { | |
| 29 | template <class _Iter> | |
| 30 | _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool operator!=(const _Iter&, __unreachable_sentinel) _NOEXCEPT { | |
| 31 | return true; | |
| 32 | } | |
| 33 | }; | |
| 34 | ||
| 35 | // uninitialized_copy | |
| 36 | ||
| 37 | template <class _ValueType, class _InputIterator, class _Sentinel1, class _ForwardIterator, class _Sentinel2> | |
| 38 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> | |
| 39 | __uninitialized_copy(_InputIterator __ifirst, _Sentinel1 __ilast, | |
| 40 | _ForwardIterator __ofirst, _Sentinel2 __olast) { | |
| 41 | _ForwardIterator __idx = __ofirst; | |
| 42 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 43 | try { | |
| 44 | #endif | |
| 45 | for (; __ifirst != __ilast && __idx != __olast; ++__ifirst, (void)++__idx) | |
| 46 | ::new (_VSTD::__voidify(*__idx)) _ValueType(*__ifirst); | |
| 47 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 48 | } catch (...) { | |
| 49 | _VSTD::__destroy(__ofirst, __idx); | |
| 50 | throw; | |
| 51 | } | |
| 52 | #endif | |
| 53 | ||
| 54 | return pair<_InputIterator, _ForwardIterator>(_VSTD::move(__ifirst), _VSTD::move(__idx)); | |
| 55 | } | |
| 56 | ||
| 28 | 57 | template <class _InputIterator, class _ForwardIterator> |
| 29 | _ForwardIterator | |
| 30 | uninitialized_copy(_InputIterator __f, _InputIterator __l, _ForwardIterator __r) | |
| 31 | { | |
| 32 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | |
| 58 | _ForwardIterator uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast, | |
| 59 | _ForwardIterator __ofirst) { | |
| 60 | typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; | |
| 61 | auto __result = _VSTD::__uninitialized_copy<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast), | |
| 62 | _VSTD::move(__ofirst), __unreachable_sentinel()); | |
| 63 | return _VSTD::move(__result.second); | |
| 64 | } | |
| 65 | ||
| 66 | // uninitialized_copy_n | |
| 67 | ||
| 68 | template <class _ValueType, class _InputIterator, class _Size, class _ForwardIterator, class _Sentinel> | |
| 69 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> | |
| 70 | __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, | |
| 71 | _ForwardIterator __ofirst, _Sentinel __olast) { | |
| 72 | _ForwardIterator __idx = __ofirst; | |
| 33 | 73 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 34 | _ForwardIterator __s = __r; | |
| 35 | try | |
| 36 | { | |
| 74 | try { | |
| 37 | 75 | #endif |
| 38 | for (; __f != __l; ++__f, (void) ++__r) | |
| 39 | ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f); | |
| 76 | for (; __n > 0 && __idx != __olast; ++__ifirst, (void)++__idx, (void)--__n) | |
| 77 | ::new (_VSTD::__voidify(*__idx)) _ValueType(*__ifirst); | |
| 40 | 78 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 41 | } | |
| 42 | catch (...) | |
| 43 | { | |
| 44 | for (; __s != __r; ++__s) | |
| 45 | __s->~value_type(); | |
| 46 | throw; | |
| 47 | } | |
| 79 | } catch (...) { | |
| 80 | _VSTD::__destroy(__ofirst, __idx); | |
| 81 | throw; | |
| 82 | } | |
| 48 | 83 | #endif |
| 49 | return __r; | |
| 84 | ||
| 85 | return pair<_InputIterator, _ForwardIterator>(_VSTD::move(__ifirst), _VSTD::move(__idx)); | |
| 50 | 86 | } |
| 51 | 87 | |
| 52 | 88 | template <class _InputIterator, class _Size, class _ForwardIterator> |
| 53 | _ForwardIterator | |
| 54 | uninitialized_copy_n(_InputIterator __f, _Size __n, _ForwardIterator __r) | |
| 89 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_copy_n(_InputIterator __ifirst, _Size __n, | |
| 90 | _ForwardIterator __ofirst) { | |
| 91 | typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; | |
| 92 | auto __result = _VSTD::__uninitialized_copy_n<_ValueType>(_VSTD::move(__ifirst), __n, _VSTD::move(__ofirst), | |
| 93 | __unreachable_sentinel()); | |
| 94 | return _VSTD::move(__result.second); | |
| 95 | } | |
| 96 | ||
| 97 | // uninitialized_fill | |
| 98 | ||
| 99 | template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp> | |
| 100 | inline _LIBCPP_HIDE_FROM_ABI | |
| 101 | _ForwardIterator __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) | |
| 55 | 102 | { |
| 56 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | |
| 103 | _ForwardIterator __idx = __first; | |
| 57 | 104 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 58 | _ForwardIterator __s = __r; | |
| 59 | 105 | try |
| 60 | 106 | { |
| 61 | 107 | #endif |
| 62 | for (; __n > 0; ++__f, (void) ++__r, (void) --__n) | |
| 63 | ::new ((void*)_VSTD::addressof(*__r)) value_type(*__f); | |
| 108 | for (; __idx != __last; ++__idx) | |
| 109 | ::new (_VSTD::__voidify(*__idx)) _ValueType(__x); | |
| 64 | 110 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 65 | 111 | } |
| 66 | 112 | catch (...) |
| 67 | 113 | { |
| 68 | for (; __s != __r; ++__s) | |
| 69 | __s->~value_type(); | |
| 114 | _VSTD::__destroy(__first, __idx); | |
| 70 | 115 | throw; |
| 71 | 116 | } |
| 72 | 117 | #endif |
| 73 | return __r; | |
| 118 | ||
| 119 | return __idx; | |
| 74 | 120 | } |
| 75 | 121 | |
| 76 | 122 | template <class _ForwardIterator, class _Tp> |
| 77 | void | |
| 78 | uninitialized_fill(_ForwardIterator __f, _ForwardIterator __l, const _Tp& __x) | |
| 123 | inline _LIBCPP_HIDE_FROM_ABI | |
| 124 | void uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) | |
| 79 | 125 | { |
| 80 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | |
| 126 | typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; | |
| 127 | (void)_VSTD::__uninitialized_fill<_ValueType>(__first, __last, __x); | |
| 128 | } | |
| 129 | ||
| 130 | // uninitialized_fill_n | |
| 131 | ||
| 132 | template <class _ValueType, class _ForwardIterator, class _Size, class _Tp> | |
| 133 | inline _LIBCPP_HIDE_FROM_ABI | |
| 134 | _ForwardIterator __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) | |
| 135 | { | |
| 136 | _ForwardIterator __idx = __first; | |
| 81 | 137 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 82 | _ForwardIterator __s = __f; | |
| 83 | 138 | try |
| 84 | 139 | { |
| 85 | 140 | #endif |
| 86 | for (; __f != __l; ++__f) | |
| 87 | ::new ((void*)_VSTD::addressof(*__f)) value_type(__x); | |
| 141 | for (; __n > 0; ++__idx, (void) --__n) | |
| 142 | ::new (_VSTD::__voidify(*__idx)) _ValueType(__x); | |
| 88 | 143 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 89 | 144 | } |
| 90 | 145 | catch (...) |
| 91 | 146 | { |
| 92 | for (; __s != __f; ++__s) | |
| 93 | __s->~value_type(); | |
| 147 | _VSTD::__destroy(__first, __idx); | |
| 94 | 148 | throw; |
| 95 | 149 | } |
| 96 | 150 | #endif |
| 151 | ||
| 152 | return __idx; | |
| 97 | 153 | } |
| 98 | 154 | |
| 99 | 155 | template <class _ForwardIterator, class _Size, class _Tp> |
| 100 | _ForwardIterator | |
| 101 | uninitialized_fill_n(_ForwardIterator __f, _Size __n, const _Tp& __x) | |
| 156 | inline _LIBCPP_HIDE_FROM_ABI | |
| 157 | _ForwardIterator uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) | |
| 102 | 158 | { |
| 103 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; | |
| 159 | typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType; | |
| 160 | return _VSTD::__uninitialized_fill_n<_ValueType>(__first, __n, __x); | |
| 161 | } | |
| 162 | ||
| 163 | #if _LIBCPP_STD_VER > 14 | |
| 164 | ||
| 165 | // uninitialized_default_construct | |
| 166 | ||
| 167 | template <class _ValueType, class _ForwardIterator, class _Sentinel> | |
| 168 | inline _LIBCPP_HIDE_FROM_ABI | |
| 169 | _ForwardIterator __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) { | |
| 170 | auto __idx = __first; | |
| 104 | 171 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 105 | _ForwardIterator __s = __f; | |
| 106 | try | |
| 107 | { | |
| 172 | try { | |
| 108 | 173 | #endif |
| 109 | for (; __n > 0; ++__f, (void) --__n) | |
| 110 | ::new ((void*)_VSTD::addressof(*__f)) value_type(__x); | |
| 174 | for (; __idx != __last; ++__idx) | |
| 175 | ::new (_VSTD::__voidify(*__idx)) _ValueType; | |
| 111 | 176 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 112 | } | |
| 113 | catch (...) | |
| 114 | { | |
| 115 | for (; __s != __f; ++__s) | |
| 116 | __s->~value_type(); | |
| 177 | } catch (...) { | |
| 178 | _VSTD::__destroy(__first, __idx); | |
| 117 | 179 | throw; |
| 118 | 180 | } |
| 119 | 181 | #endif |
| 120 | return __f; | |
| 121 | } | |
| 122 | 182 | |
| 123 | #if _LIBCPP_STD_VER > 14 | |
| 183 | return __idx; | |
| 184 | } | |
| 124 | 185 | |
| 125 | 186 | template <class _ForwardIterator> |
| 126 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 127 | void destroy(_ForwardIterator __first, _ForwardIterator __last) { | |
| 128 | for (; __first != __last; ++__first) | |
| 129 | _VSTD::destroy_at(_VSTD::addressof(*__first)); | |
| 187 | inline _LIBCPP_HIDE_FROM_ABI | |
| 188 | void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) { | |
| 189 | using _ValueType = typename iterator_traits<_ForwardIterator>::value_type; | |
| 190 | (void)_VSTD::__uninitialized_default_construct<_ValueType>( | |
| 191 | _VSTD::move(__first), _VSTD::move(__last)); | |
| 130 | 192 | } |
| 131 | 193 | |
| 132 | template <class _ForwardIterator, class _Size> | |
| 133 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 134 | _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) { | |
| 135 | for (; __n > 0; (void)++__first, --__n) | |
| 136 | _VSTD::destroy_at(_VSTD::addressof(*__first)); | |
| 137 | return __first; | |
| 138 | } | |
| 194 | // uninitialized_default_construct_n | |
| 139 | 195 | |
| 140 | template <class _ForwardIterator> | |
| 141 | inline _LIBCPP_INLINE_VISIBILITY | |
| 142 | void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) { | |
| 143 | using _Vt = typename iterator_traits<_ForwardIterator>::value_type; | |
| 196 | template <class _ValueType, class _ForwardIterator, class _Size> | |
| 197 | inline _LIBCPP_HIDE_FROM_ABI | |
| 198 | _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { | |
| 144 | 199 | auto __idx = __first; |
| 145 | 200 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 146 | 201 | try { |
| 147 | 202 | #endif |
| 148 | for (; __idx != __last; ++__idx) | |
| 149 | ::new ((void*)_VSTD::addressof(*__idx)) _Vt; | |
| 203 | for (; __n > 0; ++__idx, (void) --__n) | |
| 204 | ::new (_VSTD::__voidify(*__idx)) _ValueType; | |
| 150 | 205 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 151 | 206 | } catch (...) { |
| 152 | _VSTD::destroy(__first, __idx); | |
| 207 | _VSTD::__destroy(__first, __idx); | |
| 153 | 208 | throw; |
| 154 | 209 | } |
| 155 | 210 | #endif |
| 211 | ||
| 212 | return __idx; | |
| 156 | 213 | } |
| 157 | 214 | |
| 158 | 215 | template <class _ForwardIterator, class _Size> |
| 159 | inline _LIBCPP_INLINE_VISIBILITY | |
| 216 | inline _LIBCPP_HIDE_FROM_ABI | |
| 160 | 217 | _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { |
| 161 | using _Vt = typename iterator_traits<_ForwardIterator>::value_type; | |
| 218 | using _ValueType = typename iterator_traits<_ForwardIterator>::value_type; | |
| 219 | return _VSTD::__uninitialized_default_construct_n<_ValueType>(_VSTD::move(__first), __n); | |
| 220 | } | |
| 221 | ||
| 222 | // uninitialized_value_construct | |
| 223 | ||
| 224 | template <class _ValueType, class _ForwardIterator, class _Sentinel> | |
| 225 | inline _LIBCPP_HIDE_FROM_ABI | |
| 226 | _ForwardIterator __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) { | |
| 162 | 227 | auto __idx = __first; |
| 163 | 228 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 164 | 229 | try { |
| 165 | 230 | #endif |
| 166 | for (; __n > 0; (void)++__idx, --__n) | |
| 167 | ::new ((void*)_VSTD::addressof(*__idx)) _Vt; | |
| 168 | return __idx; | |
| 231 | for (; __idx != __last; ++__idx) | |
| 232 | ::new (_VSTD::__voidify(*__idx)) _ValueType(); | |
| 169 | 233 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 170 | 234 | } catch (...) { |
| 171 | _VSTD::destroy(__first, __idx); | |
| 235 | _VSTD::__destroy(__first, __idx); | |
| 172 | 236 | throw; |
| 173 | 237 | } |
| 174 | 238 | #endif |
| 175 | } | |
| 176 | 239 | |
| 240 | return __idx; | |
| 241 | } | |
| 177 | 242 | |
| 178 | 243 | template <class _ForwardIterator> |
| 179 | inline _LIBCPP_INLINE_VISIBILITY | |
| 244 | inline _LIBCPP_HIDE_FROM_ABI | |
| 180 | 245 | void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) { |
| 181 | using _Vt = typename iterator_traits<_ForwardIterator>::value_type; | |
| 246 | using _ValueType = typename iterator_traits<_ForwardIterator>::value_type; | |
| 247 | (void)_VSTD::__uninitialized_value_construct<_ValueType>( | |
| 248 | _VSTD::move(__first), _VSTD::move(__last)); | |
| 249 | } | |
| 250 | ||
| 251 | // uninitialized_value_construct_n | |
| 252 | ||
| 253 | template <class _ValueType, class _ForwardIterator, class _Size> | |
| 254 | inline _LIBCPP_HIDE_FROM_ABI | |
| 255 | _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { | |
| 182 | 256 | auto __idx = __first; |
| 183 | 257 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 184 | 258 | try { |
| 185 | 259 | #endif |
| 186 | for (; __idx != __last; ++__idx) | |
| 187 | ::new ((void*)_VSTD::addressof(*__idx)) _Vt(); | |
| 260 | for (; __n > 0; ++__idx, (void) --__n) | |
| 261 | ::new (_VSTD::__voidify(*__idx)) _ValueType(); | |
| 188 | 262 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 189 | 263 | } catch (...) { |
| 190 | _VSTD::destroy(__first, __idx); | |
| 264 | _VSTD::__destroy(__first, __idx); | |
| 191 | 265 | throw; |
| 192 | 266 | } |
| 193 | 267 | #endif |
| 268 | ||
| 269 | return __idx; | |
| 194 | 270 | } |
| 195 | 271 | |
| 196 | 272 | template <class _ForwardIterator, class _Size> |
| 197 | inline _LIBCPP_INLINE_VISIBILITY | |
| 273 | inline _LIBCPP_HIDE_FROM_ABI | |
| 198 | 274 | _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { |
| 199 | using _Vt = typename iterator_traits<_ForwardIterator>::value_type; | |
| 200 | auto __idx = __first; | |
| 201 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 202 | try { | |
| 203 | #endif | |
| 204 | for (; __n > 0; (void)++__idx, --__n) | |
| 205 | ::new ((void*)_VSTD::addressof(*__idx)) _Vt(); | |
| 206 | return __idx; | |
| 207 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 208 | } catch (...) { | |
| 209 | _VSTD::destroy(__first, __idx); | |
| 210 | throw; | |
| 211 | } | |
| 212 | #endif | |
| 275 | using _ValueType = typename iterator_traits<_ForwardIterator>::value_type; | |
| 276 | return __uninitialized_value_construct_n<_ValueType>(_VSTD::move(__first), __n); | |
| 213 | 277 | } |
| 214 | 278 | |
| 279 | // uninitialized_move | |
| 215 | 280 | |
| 216 | template <class _InputIt, class _ForwardIt> | |
| 217 | inline _LIBCPP_INLINE_VISIBILITY | |
| 218 | _ForwardIt uninitialized_move(_InputIt __first, _InputIt __last, _ForwardIt __first_res) { | |
| 219 | using _Vt = typename iterator_traits<_ForwardIt>::value_type; | |
| 220 | auto __idx = __first_res; | |
| 281 | template <class _ValueType, class _InputIterator, class _Sentinel1, class _ForwardIterator, class _Sentinel2, | |
| 282 | class _IterMove> | |
| 283 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> | |
| 284 | __uninitialized_move(_InputIterator __ifirst, _Sentinel1 __ilast, | |
| 285 | _ForwardIterator __ofirst, _Sentinel2 __olast, _IterMove __iter_move) { | |
| 286 | auto __idx = __ofirst; | |
| 221 | 287 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 222 | try { | |
| 288 | try { | |
| 223 | 289 | #endif |
| 224 | for (; __first != __last; (void)++__idx, ++__first) | |
| 225 | ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first)); | |
| 226 | return __idx; | |
| 227 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 228 | } catch (...) { | |
| 229 | _VSTD::destroy(__first_res, __idx); | |
| 230 | throw; | |
| 290 | for (; __ifirst != __ilast && __idx != __olast; ++__idx, (void)++__ifirst) { | |
| 291 | ::new (_VSTD::__voidify(*__idx)) _ValueType(__iter_move(__ifirst)); | |
| 231 | 292 | } |
| 293 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 294 | } catch (...) { | |
| 295 | _VSTD::__destroy(__ofirst, __idx); | |
| 296 | throw; | |
| 297 | } | |
| 232 | 298 | #endif |
| 299 | ||
| 300 | return {_VSTD::move(__ifirst), _VSTD::move(__idx)}; | |
| 301 | } | |
| 302 | ||
| 303 | template <class _InputIterator, class _ForwardIterator> | |
| 304 | inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_move(_InputIterator __ifirst, _InputIterator __ilast, | |
| 305 | _ForwardIterator __ofirst) { | |
| 306 | using _ValueType = typename iterator_traits<_ForwardIterator>::value_type; | |
| 307 | auto __iter_move = [](auto&& __iter) -> decltype(auto) { return _VSTD::move(*__iter); }; | |
| 308 | ||
| 309 | auto __result = _VSTD::__uninitialized_move<_ValueType>(_VSTD::move(__ifirst), _VSTD::move(__ilast), | |
| 310 | _VSTD::move(__ofirst), __unreachable_sentinel(), __iter_move); | |
| 311 | return _VSTD::move(__result.second); | |
| 233 | 312 | } |
| 234 | 313 | |
| 235 | template <class _InputIt, class _Size, class _ForwardIt> | |
| 236 | inline _LIBCPP_INLINE_VISIBILITY | |
| 237 | pair<_InputIt, _ForwardIt> | |
| 238 | uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) { | |
| 239 | using _Vt = typename iterator_traits<_ForwardIt>::value_type; | |
| 240 | auto __idx = __first_res; | |
| 314 | // uninitialized_move_n | |
| 315 | ||
| 316 | template <class _ValueType, class _InputIterator, class _Size, class _ForwardIterator, class _Sentinel, class _IterMove> | |
| 317 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> | |
| 318 | __uninitialized_move_n(_InputIterator __ifirst, _Size __n, | |
| 319 | _ForwardIterator __ofirst, _Sentinel __olast, _IterMove __iter_move) { | |
| 320 | auto __idx = __ofirst; | |
| 241 | 321 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 242 | try { | |
| 322 | try { | |
| 243 | 323 | #endif |
| 244 | for (; __n > 0; ++__idx, (void)++__first, --__n) | |
| 245 | ::new ((void*)_VSTD::addressof(*__idx)) _Vt(_VSTD::move(*__first)); | |
| 246 | return {__first, __idx}; | |
| 324 | for (; __n > 0 && __idx != __olast; ++__idx, (void)++__ifirst, --__n) | |
| 325 | ::new (_VSTD::__voidify(*__idx)) _ValueType(__iter_move(__ifirst)); | |
| 247 | 326 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 248 | } catch (...) { | |
| 249 | _VSTD::destroy(__first_res, __idx); | |
| 250 | throw; | |
| 251 | } | |
| 327 | } catch (...) { | |
| 328 | _VSTD::__destroy(__ofirst, __idx); | |
| 329 | throw; | |
| 330 | } | |
| 252 | 331 | #endif |
| 332 | ||
| 333 | return {_VSTD::move(__ifirst), _VSTD::move(__idx)}; | |
| 334 | } | |
| 335 | ||
| 336 | template <class _InputIterator, class _Size, class _ForwardIterator> | |
| 337 | inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> | |
| 338 | uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) { | |
| 339 | using _ValueType = typename iterator_traits<_ForwardIterator>::value_type; | |
| 340 | auto __iter_move = [](auto&& __iter) -> decltype(auto) { return _VSTD::move(*__iter); }; | |
| 341 | ||
| 342 | return _VSTD::__uninitialized_move_n<_ValueType>(_VSTD::move(__ifirst), __n, _VSTD::move(__ofirst), | |
| 343 | __unreachable_sentinel(), __iter_move); | |
| 253 | 344 | } |
| 254 | 345 | |
| 255 | 346 | #endif // _LIBCPP_STD_VER > 14 |
| 256 | 347 | |
| 257 | 348 | _LIBCPP_END_NAMESPACE_STD |
| 258 | 349 | |
| 259 | _LIBCPP_POP_MACROS | |
| 260 | ||
| 261 | 350 | #endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H |
lib/libcxx/include/__memory/unique_ptr.h+26-31| ... | ... | @@ -11,9 +11,9 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_UNIQUE_PTR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional_base> | |
| 15 | 14 | #include <__functional/hash.h> |
| 16 | 15 | #include <__functional/operations.h> |
| 16 | #include <__functional_base> | |
| 17 | 17 | #include <__memory/allocator_traits.h> // __pointer |
| 18 | 18 | #include <__memory/compressed_pair.h> |
| 19 | 19 | #include <__utility/forward.h> |
| ... | ... | @@ -29,9 +29,6 @@ |
| 29 | 29 | #pragma GCC system_header |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | _LIBCPP_PUSH_MACROS | |
| 33 | #include <__undef_macros> | |
| 34 | ||
| 35 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 33 | |
| 37 | 34 | template <class _Tp> |
| ... | ... | @@ -122,7 +119,7 @@ class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr { |
| 122 | 119 | public: |
| 123 | 120 | typedef _Tp element_type; |
| 124 | 121 | typedef _Dp deleter_type; |
| 125 | typedef _LIBCPP_NODEBUG_TYPE typename __pointer<_Tp, deleter_type>::type pointer; | |
| 122 | typedef _LIBCPP_NODEBUG typename __pointer<_Tp, deleter_type>::type pointer; | |
| 126 | 123 | |
| 127 | 124 | static_assert(!is_rvalue_reference<deleter_type>::value, |
| 128 | 125 | "the specified deleter type cannot be an rvalue reference"); |
| ... | ... | @@ -132,38 +129,38 @@ private: |
| 132 | 129 | |
| 133 | 130 | struct __nat { int __for_bool_; }; |
| 134 | 131 | |
| 135 | typedef _LIBCPP_NODEBUG_TYPE __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE; | |
| 132 | typedef _LIBCPP_NODEBUG __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE; | |
| 136 | 133 | |
| 137 | 134 | template <bool _Dummy> |
| 138 | using _LValRefType _LIBCPP_NODEBUG_TYPE = | |
| 135 | using _LValRefType _LIBCPP_NODEBUG = | |
| 139 | 136 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type; |
| 140 | 137 | |
| 141 | 138 | template <bool _Dummy> |
| 142 | using _GoodRValRefType _LIBCPP_NODEBUG_TYPE = | |
| 139 | using _GoodRValRefType _LIBCPP_NODEBUG = | |
| 143 | 140 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type; |
| 144 | 141 | |
| 145 | 142 | template <bool _Dummy> |
| 146 | using _BadRValRefType _LIBCPP_NODEBUG_TYPE = | |
| 143 | using _BadRValRefType _LIBCPP_NODEBUG = | |
| 147 | 144 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type; |
| 148 | 145 | |
| 149 | 146 | template <bool _Dummy, class _Deleter = typename __dependent_type< |
| 150 | 147 | __identity<deleter_type>, _Dummy>::type> |
| 151 | using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE = | |
| 148 | using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG = | |
| 152 | 149 | typename enable_if<is_default_constructible<_Deleter>::value && |
| 153 | 150 | !is_pointer<_Deleter>::value>::type; |
| 154 | 151 | |
| 155 | 152 | template <class _ArgType> |
| 156 | using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE = | |
| 153 | using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = | |
| 157 | 154 | typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type; |
| 158 | 155 | |
| 159 | 156 | template <class _UPtr, class _Up> |
| 160 | using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if< | |
| 157 | using _EnableIfMoveConvertible _LIBCPP_NODEBUG = typename enable_if< | |
| 161 | 158 | is_convertible<typename _UPtr::pointer, pointer>::value && |
| 162 | 159 | !is_array<_Up>::value |
| 163 | 160 | >::type; |
| 164 | 161 | |
| 165 | 162 | template <class _UDel> |
| 166 | using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if< | |
| 163 | using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = typename enable_if< | |
| 167 | 164 | (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) || |
| 168 | 165 | (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) |
| 169 | 166 | >::type; |
| ... | ... | @@ -177,17 +174,17 @@ public: |
| 177 | 174 | template <bool _Dummy = true, |
| 178 | 175 | class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 179 | 176 | _LIBCPP_INLINE_VISIBILITY |
| 180 | _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} | |
| 177 | _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 181 | 178 | |
| 182 | 179 | template <bool _Dummy = true, |
| 183 | 180 | class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 184 | 181 | _LIBCPP_INLINE_VISIBILITY |
| 185 | _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} | |
| 182 | _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 186 | 183 | |
| 187 | 184 | template <bool _Dummy = true, |
| 188 | 185 | class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 189 | 186 | _LIBCPP_INLINE_VISIBILITY |
| 190 | explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __default_init_tag()) {} | |
| 187 | explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {} | |
| 191 | 188 | |
| 192 | 189 | template <bool _Dummy = true, |
| 193 | 190 | class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > > |
| ... | ... | @@ -229,7 +226,7 @@ public: |
| 229 | 226 | typename enable_if<is_convertible<_Up*, _Tp*>::value && |
| 230 | 227 | is_same<_Dp, default_delete<_Tp> >::value, |
| 231 | 228 | __nat>::type = __nat()) _NOEXCEPT |
| 232 | : __ptr_(__p.release(), __default_init_tag()) {} | |
| 229 | : __ptr_(__p.release(), __value_init_tag()) {} | |
| 233 | 230 | #endif |
| 234 | 231 | |
| 235 | 232 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -350,35 +347,35 @@ private: |
| 350 | 347 | typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE; |
| 351 | 348 | |
| 352 | 349 | template <bool _Dummy> |
| 353 | using _LValRefType _LIBCPP_NODEBUG_TYPE = | |
| 350 | using _LValRefType _LIBCPP_NODEBUG = | |
| 354 | 351 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type; |
| 355 | 352 | |
| 356 | 353 | template <bool _Dummy> |
| 357 | using _GoodRValRefType _LIBCPP_NODEBUG_TYPE = | |
| 354 | using _GoodRValRefType _LIBCPP_NODEBUG = | |
| 358 | 355 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type; |
| 359 | 356 | |
| 360 | 357 | template <bool _Dummy> |
| 361 | using _BadRValRefType _LIBCPP_NODEBUG_TYPE = | |
| 358 | using _BadRValRefType _LIBCPP_NODEBUG = | |
| 362 | 359 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type; |
| 363 | 360 | |
| 364 | 361 | template <bool _Dummy, class _Deleter = typename __dependent_type< |
| 365 | 362 | __identity<deleter_type>, _Dummy>::type> |
| 366 | using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE = | |
| 363 | using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG = | |
| 367 | 364 | typename enable_if<is_default_constructible<_Deleter>::value && |
| 368 | 365 | !is_pointer<_Deleter>::value>::type; |
| 369 | 366 | |
| 370 | 367 | template <class _ArgType> |
| 371 | using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE = | |
| 368 | using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = | |
| 372 | 369 | typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type; |
| 373 | 370 | |
| 374 | 371 | template <class _Pp> |
| 375 | using _EnableIfPointerConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if< | |
| 372 | using _EnableIfPointerConvertible _LIBCPP_NODEBUG = typename enable_if< | |
| 376 | 373 | _CheckArrayPointerConversion<_Pp>::value |
| 377 | 374 | >::type; |
| 378 | 375 | |
| 379 | 376 | template <class _UPtr, class _Up, |
| 380 | 377 | class _ElemT = typename _UPtr::element_type> |
| 381 | using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if< | |
| 378 | using _EnableIfMoveConvertible _LIBCPP_NODEBUG = typename enable_if< | |
| 382 | 379 | is_array<_Up>::value && |
| 383 | 380 | is_same<pointer, element_type*>::value && |
| 384 | 381 | is_same<typename _UPtr::pointer, _ElemT*>::value && |
| ... | ... | @@ -386,13 +383,13 @@ private: |
| 386 | 383 | >::type; |
| 387 | 384 | |
| 388 | 385 | template <class _UDel> |
| 389 | using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if< | |
| 386 | using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = typename enable_if< | |
| 390 | 387 | (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) || |
| 391 | 388 | (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) |
| 392 | 389 | >::type; |
| 393 | 390 | |
| 394 | 391 | template <class _UDel> |
| 395 | using _EnableIfDeleterAssignable _LIBCPP_NODEBUG_TYPE = typename enable_if< | |
| 392 | using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = typename enable_if< | |
| 396 | 393 | is_assignable<_Dp&, _UDel&&>::value |
| 397 | 394 | >::type; |
| 398 | 395 | |
| ... | ... | @@ -400,19 +397,19 @@ public: |
| 400 | 397 | template <bool _Dummy = true, |
| 401 | 398 | class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 402 | 399 | _LIBCPP_INLINE_VISIBILITY |
| 403 | _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} | |
| 400 | _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 404 | 401 | |
| 405 | 402 | template <bool _Dummy = true, |
| 406 | 403 | class = _EnableIfDeleterDefaultConstructible<_Dummy> > |
| 407 | 404 | _LIBCPP_INLINE_VISIBILITY |
| 408 | _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} | |
| 405 | _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(__value_init_tag(), __value_init_tag()) {} | |
| 409 | 406 | |
| 410 | 407 | template <class _Pp, bool _Dummy = true, |
| 411 | 408 | class = _EnableIfDeleterDefaultConstructible<_Dummy>, |
| 412 | 409 | class = _EnableIfPointerConvertible<_Pp> > |
| 413 | 410 | _LIBCPP_INLINE_VISIBILITY |
| 414 | 411 | explicit unique_ptr(_Pp __p) _NOEXCEPT |
| 415 | : __ptr_(__p, __default_init_tag()) {} | |
| 412 | : __ptr_(__p, __value_init_tag()) {} | |
| 416 | 413 | |
| 417 | 414 | template <class _Pp, bool _Dummy = true, |
| 418 | 415 | class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >, |
| ... | ... | @@ -768,6 +765,4 @@ struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< |
| 768 | 765 | |
| 769 | 766 | _LIBCPP_END_NAMESPACE_STD |
| 770 | 767 | |
| 771 | _LIBCPP_POP_MACROS | |
| 772 | ||
| 773 | 768 | #endif // _LIBCPP___MEMORY_UNIQUE_PTR_H |
lib/libcxx/include/__memory/uses_allocator.h+1-1| ... | ... | @@ -52,7 +52,7 @@ struct _LIBCPP_TEMPLATE_VIS uses_allocator |
| 52 | 52 | |
| 53 | 53 | #if _LIBCPP_STD_VER > 14 |
| 54 | 54 | template <class _Tp, class _Alloc> |
| 55 | _LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; | |
| 55 | inline constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; | |
| 56 | 56 | #endif |
| 57 | 57 | |
| 58 | 58 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__memory/voidify.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___MEMORY_VOIDIFY_H | |
| 11 | #define _LIBCPP___MEMORY_VOIDIFY_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__memory/addressof.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <typename _Tp> | |
| 23 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void* __voidify(_Tp& __from) { | |
| 24 | // Cast away cv-qualifiers to allow modifying elements of a range through const iterators. | |
| 25 | return const_cast<void*>(static_cast<const volatile void*>(_VSTD::addressof(__from))); | |
| 26 | } | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___MEMORY_VOIDIFY_H |
lib/libcxx/include/__mutex_base+8-9| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__threading_support> |
| 15 | 15 | #include <chrono> |
| 16 | #include <ratio> | |
| 16 | 17 | #include <system_error> |
| 17 | 18 | #include <time.h> |
| 18 | 19 | |
| ... | ... | @@ -68,9 +69,9 @@ extern _LIBCPP_EXPORTED_FROM_ABI const adopt_lock_t adopt_lock; |
| 68 | 69 | |
| 69 | 70 | #else |
| 70 | 71 | |
| 71 | /* _LIBCPP_INLINE_VAR */ constexpr defer_lock_t defer_lock = defer_lock_t(); | |
| 72 | /* _LIBCPP_INLINE_VAR */ constexpr try_to_lock_t try_to_lock = try_to_lock_t(); | |
| 73 | /* _LIBCPP_INLINE_VAR */ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); | |
| 72 | /* inline */ constexpr defer_lock_t defer_lock = defer_lock_t(); | |
| 73 | /* inline */ constexpr try_to_lock_t try_to_lock = try_to_lock_t(); | |
| 74 | /* inline */ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); | |
| 74 | 75 | |
| 75 | 76 | #endif |
| 76 | 77 | |
| ... | ... | @@ -96,8 +97,8 @@ public: |
| 96 | 97 | ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) {__m_.unlock();} |
| 97 | 98 | |
| 98 | 99 | private: |
| 99 | lock_guard(lock_guard const&) _LIBCPP_EQUAL_DELETE; | |
| 100 | lock_guard& operator=(lock_guard const&) _LIBCPP_EQUAL_DELETE; | |
| 100 | lock_guard(lock_guard const&) = delete; | |
| 101 | lock_guard& operator=(lock_guard const&) = delete; | |
| 101 | 102 | }; |
| 102 | 103 | |
| 103 | 104 | template <class _Mutex> |
| ... | ... | @@ -140,11 +141,9 @@ public: |
| 140 | 141 | __m_->unlock(); |
| 141 | 142 | } |
| 142 | 143 | |
| 143 | private: | |
| 144 | unique_lock(unique_lock const&); // = delete; | |
| 145 | unique_lock& operator=(unique_lock const&); // = delete; | |
| 144 | unique_lock(unique_lock const&) = delete; | |
| 145 | unique_lock& operator=(unique_lock const&) = delete; | |
| 146 | 146 | |
| 147 | public: | |
| 148 | 147 | _LIBCPP_INLINE_VISIBILITY |
| 149 | 148 | unique_lock(unique_lock&& __u) _NOEXCEPT |
| 150 | 149 | : __m_(__u.__m_), __owns_(__u.__owns_) |
lib/libcxx/include/__node_handle+48-4| ... | ... | @@ -10,6 +10,54 @@ |
| 10 | 10 | #ifndef _LIBCPP___NODE_HANDLE |
| 11 | 11 | #define _LIBCPP___NODE_HANDLE |
| 12 | 12 | |
| 13 | /* | |
| 14 | ||
| 15 | template<unspecified> | |
| 16 | class node-handle { | |
| 17 | public: | |
| 18 | using value_type = see below; // not present for map containers | |
| 19 | using key_type = see below; // not present for set containers | |
| 20 | using mapped_type = see below; // not present for set containers | |
| 21 | using allocator_type = see below; | |
| 22 | ||
| 23 | private: | |
| 24 | using container_node_type = unspecified; // exposition only | |
| 25 | using ator_traits = allocator_traits<allocator_type>; // exposition only | |
| 26 | ||
| 27 | typename ator_traits::template | |
| 28 | rebind_traits<container_node_type>::pointer ptr_; // exposition only | |
| 29 | optional<allocator_type> alloc_; // exposition only | |
| 30 | ||
| 31 | public: | |
| 32 | // [container.node.cons], constructors, copy, and assignment | |
| 33 | constexpr node-handle() noexcept : ptr_(), alloc_() {} | |
| 34 | node-handle(node-handle&&) noexcept; | |
| 35 | node-handle& operator=(node-handle&&); | |
| 36 | ||
| 37 | // [container.node.dtor], destructor | |
| 38 | ~node-handle(); | |
| 39 | ||
| 40 | // [container.node.observers], observers | |
| 41 | value_type& value() const; // not present for map containers | |
| 42 | key_type& key() const; // not present for set containers | |
| 43 | mapped_type& mapped() const; // not present for set containers | |
| 44 | ||
| 45 | allocator_type get_allocator() const; | |
| 46 | explicit operator bool() const noexcept; | |
| 47 | [[nodiscard]] bool empty() const noexcept; // nodiscard since C++20 | |
| 48 | ||
| 49 | // [container.node.modifiers], modifiers | |
| 50 | void swap(node-handle&) | |
| 51 | noexcept(ator_traits::propagate_on_container_swap::value || | |
| 52 | ator_traits::is_always_equal::value); | |
| 53 | ||
| 54 | friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) { | |
| 55 | x.swap(y); | |
| 56 | } | |
| 57 | }; | |
| 58 | ||
| 59 | */ | |
| 60 | ||
| 13 | 61 | #include <__config> |
| 14 | 62 | #include <__debug> |
| 15 | 63 | #include <memory> |
| ... | ... | @@ -19,9 +67,6 @@ |
| 19 | 67 | #pragma GCC system_header |
| 20 | 68 | #endif |
| 21 | 69 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 70 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 71 | |
| 27 | 72 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -204,6 +249,5 @@ struct _LIBCPP_TEMPLATE_VIS __insert_return_type |
| 204 | 249 | #endif // _LIBCPP_STD_VER > 14 |
| 205 | 250 | |
| 206 | 251 | _LIBCPP_END_NAMESPACE_STD |
| 207 | _LIBCPP_POP_MACROS | |
| 208 | 252 | |
| 209 | 253 | #endif // _LIBCPP___NODE_HANDLE |
lib/libcxx/include/__nullptr+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- __nullptr --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -54,7 +54,7 @@ _LIBCPP_END_NAMESPACE_STD |
| 54 | 54 | namespace std |
| 55 | 55 | { |
| 56 | 56 | typedef decltype(nullptr) nullptr_t; |
| 57 | } | |
| 57 | } // namespace std | |
| 58 | 58 | |
| 59 | 59 | #endif // _LIBCPP_HAS_NO_NULLPTR |
| 60 | 60 |
lib/libcxx/include/__numeric/accumulate.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___NUMERIC_ACCUMULATE_H | |
| 11 | #define _LIBCPP___NUMERIC_ACCUMULATE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__utility/move.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 | template <class _InputIterator, class _Tp> | |
| 23 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 24 | _Tp | |
| 25 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) | |
| 26 | { | |
| 27 | for (; __first != __last; ++__first) | |
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | __init = _VSTD::move(__init) + *__first; | |
| 30 | #else | |
| 31 | __init = __init + *__first; | |
| 32 | #endif | |
| 33 | return __init; | |
| 34 | } | |
| 35 | ||
| 36 | template <class _InputIterator, class _Tp, class _BinaryOperation> | |
| 37 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 38 | _Tp | |
| 39 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) | |
| 40 | { | |
| 41 | for (; __first != __last; ++__first) | |
| 42 | #if _LIBCPP_STD_VER > 17 | |
| 43 | __init = __binary_op(_VSTD::move(__init), *__first); | |
| 44 | #else | |
| 45 | __init = __binary_op(__init, *__first); | |
| 46 | #endif | |
| 47 | return __init; | |
| 48 | } | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___NUMERIC_ACCUMULATE_H |
lib/libcxx/include/__numeric/adjacent_difference.h created+72| ... | ... | @@ -0,0 +1,72 @@ |
| 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___NUMERIC_ADJACENT_DIFFERENCE_H | |
| 11 | #define _LIBCPP___NUMERIC_ADJACENT_DIFFERENCE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__iterator/iterator_traits.h> | |
| 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 | template <class _InputIterator, class _OutputIterator> | |
| 24 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 25 | _OutputIterator | |
| 26 | adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 27 | { | |
| 28 | if (__first != __last) | |
| 29 | { | |
| 30 | typename iterator_traits<_InputIterator>::value_type __acc(*__first); | |
| 31 | *__result = __acc; | |
| 32 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 33 | { | |
| 34 | typename iterator_traits<_InputIterator>::value_type __val(*__first); | |
| 35 | #if _LIBCPP_STD_VER > 17 | |
| 36 | *__result = __val - _VSTD::move(__acc); | |
| 37 | #else | |
| 38 | *__result = __val - __acc; | |
| 39 | #endif | |
| 40 | __acc = _VSTD::move(__val); | |
| 41 | } | |
| 42 | } | |
| 43 | return __result; | |
| 44 | } | |
| 45 | ||
| 46 | template <class _InputIterator, class _OutputIterator, class _BinaryOperation> | |
| 47 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 48 | _OutputIterator | |
| 49 | adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result, | |
| 50 | _BinaryOperation __binary_op) | |
| 51 | { | |
| 52 | if (__first != __last) | |
| 53 | { | |
| 54 | typename iterator_traits<_InputIterator>::value_type __acc(*__first); | |
| 55 | *__result = __acc; | |
| 56 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 57 | { | |
| 58 | typename iterator_traits<_InputIterator>::value_type __val(*__first); | |
| 59 | #if _LIBCPP_STD_VER > 17 | |
| 60 | *__result = __binary_op(__val, _VSTD::move(__acc)); | |
| 61 | #else | |
| 62 | *__result = __binary_op(__val, __acc); | |
| 63 | #endif | |
| 64 | __acc = _VSTD::move(__val); | |
| 65 | } | |
| 66 | } | |
| 67 | return __result; | |
| 68 | } | |
| 69 | ||
| 70 | _LIBCPP_END_NAMESPACE_STD | |
| 71 | ||
| 72 | #endif // _LIBCPP___NUMERIC_ADJACENT_DIFFERENCE_H |
lib/libcxx/include/__numeric/exclusive_scan.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___NUMERIC_EXCLUSIVE_SCAN_H | |
| 11 | #define _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/operations.h> | |
| 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 > 14 | |
| 24 | ||
| 25 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp> | |
| 26 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 27 | exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init, _BinaryOp __b) { | |
| 28 | if (__first != __last) { | |
| 29 | _Tp __tmp(__b(__init, *__first)); | |
| 30 | while (true) { | |
| 31 | *__result = _VSTD::move(__init); | |
| 32 | ++__result; | |
| 33 | ++__first; | |
| 34 | if (__first == __last) | |
| 35 | break; | |
| 36 | __init = _VSTD::move(__tmp); | |
| 37 | __tmp = __b(__init, *__first); | |
| 38 | } | |
| 39 | } | |
| 40 | return __result; | |
| 41 | } | |
| 42 | ||
| 43 | template <class _InputIterator, class _OutputIterator, class _Tp> | |
| 44 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 45 | exclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Tp __init) { | |
| 46 | return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>()); | |
| 47 | } | |
| 48 | ||
| 49 | #endif // _LIBCPP_STD_VER > 14 | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___NUMERIC_EXCLUSIVE_SCAN_H |
lib/libcxx/include/__numeric/gcd_lcm.h created+96| ... | ... | @@ -0,0 +1,96 @@ |
| 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___NUMERIC_GCD_LCM_H | |
| 11 | #define _LIBCPP___NUMERIC_GCD_LCM_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__debug> | |
| 15 | #include <limits> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | ||
| 29 | template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __ct_abs; | |
| 30 | ||
| 31 | template <typename _Result, typename _Source> | |
| 32 | struct __ct_abs<_Result, _Source, true> { | |
| 33 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 34 | _Result operator()(_Source __t) const noexcept | |
| 35 | { | |
| 36 | if (__t >= 0) return __t; | |
| 37 | if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t); | |
| 38 | return -__t; | |
| 39 | } | |
| 40 | }; | |
| 41 | ||
| 42 | template <typename _Result, typename _Source> | |
| 43 | struct __ct_abs<_Result, _Source, false> { | |
| 44 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 45 | _Result operator()(_Source __t) const noexcept { return __t; } | |
| 46 | }; | |
| 47 | ||
| 48 | ||
| 49 | template<class _Tp> | |
| 50 | _LIBCPP_CONSTEXPR _LIBCPP_HIDDEN | |
| 51 | _Tp __gcd(_Tp __m, _Tp __n) | |
| 52 | { | |
| 53 | static_assert((!is_signed<_Tp>::value), ""); | |
| 54 | return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n); | |
| 55 | } | |
| 56 | ||
| 57 | template<class _Tp, class _Up> | |
| 58 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 59 | common_type_t<_Tp,_Up> | |
| 60 | gcd(_Tp __m, _Up __n) | |
| 61 | { | |
| 62 | static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); | |
| 63 | static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" ); | |
| 64 | static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" ); | |
| 65 | using _Rp = common_type_t<_Tp,_Up>; | |
| 66 | using _Wp = make_unsigned_t<_Rp>; | |
| 67 | return static_cast<_Rp>(_VSTD::__gcd( | |
| 68 | static_cast<_Wp>(__ct_abs<_Rp, _Tp>()(__m)), | |
| 69 | static_cast<_Wp>(__ct_abs<_Rp, _Up>()(__n)))); | |
| 70 | } | |
| 71 | ||
| 72 | template<class _Tp, class _Up> | |
| 73 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 74 | common_type_t<_Tp,_Up> | |
| 75 | lcm(_Tp __m, _Up __n) | |
| 76 | { | |
| 77 | static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); | |
| 78 | static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" ); | |
| 79 | static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" ); | |
| 80 | if (__m == 0 || __n == 0) | |
| 81 | return 0; | |
| 82 | ||
| 83 | using _Rp = common_type_t<_Tp,_Up>; | |
| 84 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n); | |
| 85 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); | |
| 86 | _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); | |
| 87 | return __val1 * __val2; | |
| 88 | } | |
| 89 | ||
| 90 | #endif // _LIBCPP_STD_VER | |
| 91 | ||
| 92 | _LIBCPP_END_NAMESPACE_STD | |
| 93 | ||
| 94 | _LIBCPP_POP_MACROS | |
| 95 | ||
| 96 | #endif // _LIBCPP___NUMERIC_GCD_LCM_H |
lib/libcxx/include/__numeric/inclusive_scan.h created+60| ... | ... | @@ -0,0 +1,60 @@ |
| 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___NUMERIC_INCLUSIVE_SCAN_H | |
| 11 | #define _LIBCPP___NUMERIC_INCLUSIVE_SCAN_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/operations.h> | |
| 15 | #include <__iterator/iterator_traits.h> | |
| 16 | #include <__utility/move.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 14 | |
| 25 | ||
| 26 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp> | |
| 27 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 28 | inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b, _Tp __init) { | |
| 29 | for (; __first != __last; ++__first, (void)++__result) { | |
| 30 | __init = __b(__init, *__first); | |
| 31 | *__result = __init; | |
| 32 | } | |
| 33 | return __result; | |
| 34 | } | |
| 35 | ||
| 36 | template <class _InputIterator, class _OutputIterator, class _BinaryOp> | |
| 37 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 38 | inclusive_scan(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryOp __b) { | |
| 39 | if (__first != __last) { | |
| 40 | typename iterator_traits<_InputIterator>::value_type __init = *__first; | |
| 41 | *__result++ = __init; | |
| 42 | if (++__first != __last) | |
| 43 | return _VSTD::inclusive_scan(__first, __last, __result, __b, __init); | |
| 44 | } | |
| 45 | ||
| 46 | return __result; | |
| 47 | } | |
| 48 | ||
| 49 | template <class _InputIterator, class _OutputIterator> | |
| 50 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator inclusive_scan(_InputIterator __first, | |
| 51 | _InputIterator __last, | |
| 52 | _OutputIterator __result) { | |
| 53 | return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>()); | |
| 54 | } | |
| 55 | ||
| 56 | #endif // _LIBCPP_STD_VER > 14 | |
| 57 | ||
| 58 | _LIBCPP_END_NAMESPACE_STD | |
| 59 | ||
| 60 | #endif // _LIBCPP___NUMERIC_INCLUSIVE_SCAN_H |
lib/libcxx/include/__numeric/inner_product.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___NUMERIC_INNER_PRODUCT_H | |
| 11 | #define _LIBCPP___NUMERIC_INNER_PRODUCT_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__utility/move.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 | template <class _InputIterator1, class _InputIterator2, class _Tp> | |
| 23 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 24 | _Tp | |
| 25 | inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) | |
| 26 | { | |
| 27 | for (; __first1 != __last1; ++__first1, (void) ++__first2) | |
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | __init = _VSTD::move(__init) + *__first1 * *__first2; | |
| 30 | #else | |
| 31 | __init = __init + *__first1 * *__first2; | |
| 32 | #endif | |
| 33 | return __init; | |
| 34 | } | |
| 35 | ||
| 36 | template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2> | |
| 37 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 38 | _Tp | |
| 39 | inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, | |
| 40 | _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2) | |
| 41 | { | |
| 42 | for (; __first1 != __last1; ++__first1, (void) ++__first2) | |
| 43 | #if _LIBCPP_STD_VER > 17 | |
| 44 | __init = __binary_op1(_VSTD::move(__init), __binary_op2(*__first1, *__first2)); | |
| 45 | #else | |
| 46 | __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); | |
| 47 | #endif | |
| 48 | return __init; | |
| 49 | } | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___NUMERIC_INNER_PRODUCT_H |
lib/libcxx/include/__numeric/iota.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___NUMERIC_IOTA_H | |
| 11 | #define _LIBCPP___NUMERIC_IOTA_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 | template <class _ForwardIterator, class _Tp> | |
| 22 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 23 | void | |
| 24 | iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_) | |
| 25 | { | |
| 26 | for (; __first != __last; ++__first, (void) ++__value_) | |
| 27 | *__first = __value_; | |
| 28 | } | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___NUMERIC_IOTA_H |
lib/libcxx/include/__numeric/midpoint.h created+85| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___NUMERIC_MIDPOINT_H | |
| 11 | #define _LIBCPP___NUMERIC_MIDPOINT_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <limits> | |
| 15 | #include <type_traits> | |
| 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 | template <class _Tp> | |
| 28 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 29 | enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp> | |
| 30 | midpoint(_Tp __a, _Tp __b) noexcept | |
| 31 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 32 | { | |
| 33 | using _Up = make_unsigned_t<_Tp>; | |
| 34 | constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1; | |
| 35 | ||
| 36 | _Up __diff = _Up(__b) - _Up(__a); | |
| 37 | _Up __sign_bit = __b < __a; | |
| 38 | ||
| 39 | _Up __half_diff = (__diff / 2) + (__sign_bit << __bitshift) + (__sign_bit & __diff); | |
| 40 | ||
| 41 | return __a + __half_diff; | |
| 42 | } | |
| 43 | ||
| 44 | ||
| 45 | template <class _TPtr> | |
| 46 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 47 | enable_if_t<is_pointer_v<_TPtr> | |
| 48 | && is_object_v<remove_pointer_t<_TPtr>> | |
| 49 | && ! is_void_v<remove_pointer_t<_TPtr>> | |
| 50 | && (sizeof(remove_pointer_t<_TPtr>) > 0), _TPtr> | |
| 51 | midpoint(_TPtr __a, _TPtr __b) noexcept | |
| 52 | { | |
| 53 | return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a); | |
| 54 | } | |
| 55 | ||
| 56 | ||
| 57 | template <typename _Tp> | |
| 58 | constexpr int __sign(_Tp __val) { | |
| 59 | return (_Tp(0) < __val) - (__val < _Tp(0)); | |
| 60 | } | |
| 61 | ||
| 62 | template <typename _Fp> | |
| 63 | constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; } | |
| 64 | ||
| 65 | template <class _Fp> | |
| 66 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 67 | enable_if_t<is_floating_point_v<_Fp>, _Fp> | |
| 68 | midpoint(_Fp __a, _Fp __b) noexcept | |
| 69 | { | |
| 70 | constexpr _Fp __lo = numeric_limits<_Fp>::min()*2; | |
| 71 | constexpr _Fp __hi = numeric_limits<_Fp>::max()/2; | |
| 72 | return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible | |
| 73 | (__a + __b)/2 : // always correctly rounded | |
| 74 | __fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a | |
| 75 | __fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b | |
| 76 | __a/2 + __b/2; // otherwise correctly rounded | |
| 77 | } | |
| 78 | ||
| 79 | #endif // _LIBCPP_STD_VER > 17 | |
| 80 | ||
| 81 | _LIBCPP_END_NAMESPACE_STD | |
| 82 | ||
| 83 | _LIBCPP_POP_MACROS | |
| 84 | ||
| 85 | #endif // _LIBCPP___NUMERIC_MIDPOINT_H |
lib/libcxx/include/__numeric/partial_sum.h created+70| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___NUMERIC_PARTIAL_SUM_H | |
| 11 | #define _LIBCPP___NUMERIC_PARTIAL_SUM_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__iterator/iterator_traits.h> | |
| 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 | template <class _InputIterator, class _OutputIterator> | |
| 24 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 25 | _OutputIterator | |
| 26 | partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 27 | { | |
| 28 | if (__first != __last) | |
| 29 | { | |
| 30 | typename iterator_traits<_InputIterator>::value_type __t(*__first); | |
| 31 | *__result = __t; | |
| 32 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 33 | { | |
| 34 | #if _LIBCPP_STD_VER > 17 | |
| 35 | __t = _VSTD::move(__t) + *__first; | |
| 36 | #else | |
| 37 | __t = __t + *__first; | |
| 38 | #endif | |
| 39 | *__result = __t; | |
| 40 | } | |
| 41 | } | |
| 42 | return __result; | |
| 43 | } | |
| 44 | ||
| 45 | template <class _InputIterator, class _OutputIterator, class _BinaryOperation> | |
| 46 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 47 | _OutputIterator | |
| 48 | partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result, | |
| 49 | _BinaryOperation __binary_op) | |
| 50 | { | |
| 51 | if (__first != __last) | |
| 52 | { | |
| 53 | typename iterator_traits<_InputIterator>::value_type __t(*__first); | |
| 54 | *__result = __t; | |
| 55 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 56 | { | |
| 57 | #if _LIBCPP_STD_VER > 17 | |
| 58 | __t = __binary_op(_VSTD::move(__t), *__first); | |
| 59 | #else | |
| 60 | __t = __binary_op(__t, *__first); | |
| 61 | #endif | |
| 62 | *__result = __t; | |
| 63 | } | |
| 64 | } | |
| 65 | return __result; | |
| 66 | } | |
| 67 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | |
| 69 | ||
| 70 | #endif // _LIBCPP___NUMERIC_PARTIAL_SUM_H |
lib/libcxx/include/__numeric/reduce.h created+47| ... | ... | @@ -0,0 +1,47 @@ |
| 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___NUMERIC_REDUCE_H | |
| 11 | #define _LIBCPP___NUMERIC_REDUCE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/operations.h> | |
| 15 | #include <__iterator/iterator_traits.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 | template <class _InputIterator, class _Tp, class _BinaryOp> | |
| 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last, | |
| 26 | _Tp __init, _BinaryOp __b) { | |
| 27 | for (; __first != __last; ++__first) | |
| 28 | __init = __b(__init, *__first); | |
| 29 | return __init; | |
| 30 | } | |
| 31 | ||
| 32 | template <class _InputIterator, class _Tp> | |
| 33 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp reduce(_InputIterator __first, _InputIterator __last, | |
| 34 | _Tp __init) { | |
| 35 | return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>()); | |
| 36 | } | |
| 37 | ||
| 38 | template <class _InputIterator> | |
| 39 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 typename iterator_traits<_InputIterator>::value_type | |
| 40 | reduce(_InputIterator __first, _InputIterator __last) { | |
| 41 | return _VSTD::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{}); | |
| 42 | } | |
| 43 | #endif | |
| 44 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | |
| 46 | ||
| 47 | #endif // _LIBCPP___NUMERIC_REDUCE_H |
lib/libcxx/include/__numeric/transform_exclusive_scan.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___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H | |
| 11 | #define _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_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 > 14 | |
| 22 | ||
| 23 | template <class _InputIterator, class _OutputIterator, class _Tp, | |
| 24 | class _BinaryOp, class _UnaryOp> | |
| 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 26 | _OutputIterator | |
| 27 | transform_exclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 28 | _OutputIterator __result, _Tp __init, | |
| 29 | _BinaryOp __b, _UnaryOp __u) | |
| 30 | { | |
| 31 | if (__first != __last) | |
| 32 | { | |
| 33 | _Tp __saved = __init; | |
| 34 | do | |
| 35 | { | |
| 36 | __init = __b(__init, __u(*__first)); | |
| 37 | *__result = __saved; | |
| 38 | __saved = __init; | |
| 39 | ++__result; | |
| 40 | } while (++__first != __last); | |
| 41 | } | |
| 42 | return __result; | |
| 43 | } | |
| 44 | ||
| 45 | #endif // _LIBCPP_STD_VER > 14 | |
| 46 | ||
| 47 | _LIBCPP_END_NAMESPACE_STD | |
| 48 | ||
| 49 | #endif // _LIBCPP___NUMERIC_TRANSFORM_EXCLUSIVE_SCAN_H |
lib/libcxx/include/__numeric/transform_inclusive_scan.h created+58| ... | ... | @@ -0,0 +1,58 @@ |
| 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___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H | |
| 11 | #define _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__iterator/iterator_traits.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 _LIBCPP_STD_VER > 14 | |
| 23 | ||
| 24 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp> | |
| 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 26 | _OutputIterator | |
| 27 | transform_inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 28 | _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init) | |
| 29 | { | |
| 30 | for (; __first != __last; ++__first, (void) ++__result) { | |
| 31 | __init = __b(__init, __u(*__first)); | |
| 32 | *__result = __init; | |
| 33 | } | |
| 34 | ||
| 35 | return __result; | |
| 36 | } | |
| 37 | ||
| 38 | template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp> | |
| 39 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 40 | _OutputIterator | |
| 41 | transform_inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 42 | _OutputIterator __result, _BinaryOp __b, _UnaryOp __u) | |
| 43 | { | |
| 44 | if (__first != __last) { | |
| 45 | typename iterator_traits<_InputIterator>::value_type __init = __u(*__first); | |
| 46 | *__result++ = __init; | |
| 47 | if (++__first != __last) | |
| 48 | return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init); | |
| 49 | } | |
| 50 | ||
| 51 | return __result; | |
| 52 | } | |
| 53 | ||
| 54 | #endif // _LIBCPP_STD_VER > 14 | |
| 55 | ||
| 56 | _LIBCPP_END_NAMESPACE_STD | |
| 57 | ||
| 58 | #endif // _LIBCPP___NUMERIC_TRANSFORM_INCLUSIVE_SCAN_H |
lib/libcxx/include/__numeric/transform_reduce.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___NUMERIC_TRANSFORM_REDUCE_H | |
| 11 | #define _LIBCPP___NUMERIC_TRANSFORM_REDUCE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/operations.h> | |
| 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 > 14 | |
| 24 | template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp> | |
| 25 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator __first, | |
| 26 | _InputIterator __last, _Tp __init, | |
| 27 | _BinaryOp __b, _UnaryOp __u) { | |
| 28 | for (; __first != __last; ++__first) | |
| 29 | __init = __b(__init, __u(*__first)); | |
| 30 | return __init; | |
| 31 | } | |
| 32 | ||
| 33 | template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2> | |
| 34 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1, | |
| 35 | _InputIterator1 __last1, | |
| 36 | _InputIterator2 __first2, _Tp __init, | |
| 37 | _BinaryOp1 __b1, _BinaryOp2 __b2) { | |
| 38 | for (; __first1 != __last1; ++__first1, (void)++__first2) | |
| 39 | __init = __b1(__init, __b2(*__first1, *__first2)); | |
| 40 | return __init; | |
| 41 | } | |
| 42 | ||
| 43 | template <class _InputIterator1, class _InputIterator2, class _Tp> | |
| 44 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp transform_reduce(_InputIterator1 __first1, | |
| 45 | _InputIterator1 __last1, | |
| 46 | _InputIterator2 __first2, _Tp __init) { | |
| 47 | return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), _VSTD::plus<>(), | |
| 48 | _VSTD::multiplies<>()); | |
| 49 | } | |
| 50 | #endif | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | #endif // _LIBCPP___NUMERIC_TRANSFORM_REDUCE_H |
lib/libcxx/include/__random/bernoulli_distribution.h created+143| ... | ... | @@ -0,0 +1,143 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_BERNOULLI_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/uniform_real_distribution.h> | |
| 14 | #include <iosfwd> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | #pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | class _LIBCPP_TEMPLATE_VIS bernoulli_distribution | |
| 26 | { | |
| 27 | public: | |
| 28 | // types | |
| 29 | typedef bool result_type; | |
| 30 | ||
| 31 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 32 | { | |
| 33 | double __p_; | |
| 34 | public: | |
| 35 | typedef bernoulli_distribution distribution_type; | |
| 36 | ||
| 37 | _LIBCPP_INLINE_VISIBILITY | |
| 38 | explicit param_type(double __p = 0.5) : __p_(__p) {} | |
| 39 | ||
| 40 | _LIBCPP_INLINE_VISIBILITY | |
| 41 | double p() const {return __p_;} | |
| 42 | ||
| 43 | friend _LIBCPP_INLINE_VISIBILITY | |
| 44 | bool operator==(const param_type& __x, const param_type& __y) | |
| 45 | {return __x.__p_ == __y.__p_;} | |
| 46 | friend _LIBCPP_INLINE_VISIBILITY | |
| 47 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 48 | {return !(__x == __y);} | |
| 49 | }; | |
| 50 | ||
| 51 | private: | |
| 52 | param_type __p_; | |
| 53 | ||
| 54 | public: | |
| 55 | // constructors and reset functions | |
| 56 | #ifndef _LIBCPP_CXX03_LANG | |
| 57 | _LIBCPP_INLINE_VISIBILITY | |
| 58 | bernoulli_distribution() : bernoulli_distribution(0.5) {} | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | explicit bernoulli_distribution(double __p) : __p_(param_type(__p)) {} | |
| 61 | #else | |
| 62 | _LIBCPP_INLINE_VISIBILITY | |
| 63 | explicit bernoulli_distribution(double __p = 0.5) : __p_(param_type(__p)) {} | |
| 64 | #endif | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {} | |
| 67 | _LIBCPP_INLINE_VISIBILITY | |
| 68 | void reset() {} | |
| 69 | ||
| 70 | // generating functions | |
| 71 | template<class _URNG> | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | result_type operator()(_URNG& __g) | |
| 74 | {return (*this)(__g, __p_);} | |
| 75 | template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); | |
| 76 | ||
| 77 | // property functions | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | double p() const {return __p_.p();} | |
| 80 | ||
| 81 | _LIBCPP_INLINE_VISIBILITY | |
| 82 | param_type param() const {return __p_;} | |
| 83 | _LIBCPP_INLINE_VISIBILITY | |
| 84 | void param(const param_type& __p) {__p_ = __p;} | |
| 85 | ||
| 86 | _LIBCPP_INLINE_VISIBILITY | |
| 87 | result_type min() const {return false;} | |
| 88 | _LIBCPP_INLINE_VISIBILITY | |
| 89 | result_type max() const {return true;} | |
| 90 | ||
| 91 | friend _LIBCPP_INLINE_VISIBILITY | |
| 92 | bool operator==(const bernoulli_distribution& __x, | |
| 93 | const bernoulli_distribution& __y) | |
| 94 | {return __x.__p_ == __y.__p_;} | |
| 95 | friend _LIBCPP_INLINE_VISIBILITY | |
| 96 | bool operator!=(const bernoulli_distribution& __x, | |
| 97 | const bernoulli_distribution& __y) | |
| 98 | {return !(__x == __y);} | |
| 99 | }; | |
| 100 | ||
| 101 | template<class _URNG> | |
| 102 | inline | |
| 103 | bernoulli_distribution::result_type | |
| 104 | bernoulli_distribution::operator()(_URNG& __g, const param_type& __p) | |
| 105 | { | |
| 106 | uniform_real_distribution<double> __gen; | |
| 107 | return __gen(__g) < __p.p(); | |
| 108 | } | |
| 109 | ||
| 110 | template <class _CharT, class _Traits> | |
| 111 | basic_ostream<_CharT, _Traits>& | |
| 112 | operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x) | |
| 113 | { | |
| 114 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 115 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 116 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 117 | _OStream::scientific); | |
| 118 | _CharT __sp = __os.widen(' '); | |
| 119 | __os.fill(__sp); | |
| 120 | return __os << __x.p(); | |
| 121 | } | |
| 122 | ||
| 123 | template <class _CharT, class _Traits> | |
| 124 | basic_istream<_CharT, _Traits>& | |
| 125 | operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x) | |
| 126 | { | |
| 127 | typedef bernoulli_distribution _Eng; | |
| 128 | typedef typename _Eng::param_type param_type; | |
| 129 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 130 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 131 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 132 | double __p; | |
| 133 | __is >> __p; | |
| 134 | if (!__is.fail()) | |
| 135 | __x.param(param_type(__p)); | |
| 136 | return __is; | |
| 137 | } | |
| 138 | ||
| 139 | _LIBCPP_END_NAMESPACE_STD | |
| 140 | ||
| 141 | _LIBCPP_POP_MACROS | |
| 142 | ||
| 143 | #endif // _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H |
lib/libcxx/include/__random/binomial_distribution.h created+225| ... | ... | @@ -0,0 +1,225 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_BINOMIAL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/uniform_real_distribution.h> | |
| 14 | #include <cmath> | |
| 15 | #include <iosfwd> | |
| 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 | template<class _IntType = int> | |
| 27 | class _LIBCPP_TEMPLATE_VIS binomial_distribution | |
| 28 | { | |
| 29 | public: | |
| 30 | // types | |
| 31 | typedef _IntType result_type; | |
| 32 | ||
| 33 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 34 | { | |
| 35 | result_type __t_; | |
| 36 | double __p_; | |
| 37 | double __pr_; | |
| 38 | double __odds_ratio_; | |
| 39 | result_type __r0_; | |
| 40 | public: | |
| 41 | typedef binomial_distribution distribution_type; | |
| 42 | ||
| 43 | explicit param_type(result_type __t = 1, double __p = 0.5); | |
| 44 | ||
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | result_type t() const {return __t_;} | |
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | double p() const {return __p_;} | |
| 49 | ||
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator==(const param_type& __x, const param_type& __y) | |
| 52 | {return __x.__t_ == __y.__t_ && __x.__p_ == __y.__p_;} | |
| 53 | friend _LIBCPP_INLINE_VISIBILITY | |
| 54 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 55 | {return !(__x == __y);} | |
| 56 | ||
| 57 | friend class binomial_distribution; | |
| 58 | }; | |
| 59 | ||
| 60 | private: | |
| 61 | param_type __p_; | |
| 62 | ||
| 63 | public: | |
| 64 | // constructors and reset functions | |
| 65 | #ifndef _LIBCPP_CXX03_LANG | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | binomial_distribution() : binomial_distribution(1) {} | |
| 68 | _LIBCPP_INLINE_VISIBILITY | |
| 69 | explicit binomial_distribution(result_type __t, double __p = 0.5) | |
| 70 | : __p_(param_type(__t, __p)) {} | |
| 71 | #else | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | explicit binomial_distribution(result_type __t = 1, double __p = 0.5) | |
| 74 | : __p_(param_type(__t, __p)) {} | |
| 75 | #endif | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | explicit binomial_distribution(const param_type& __p) : __p_(__p) {} | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | void reset() {} | |
| 80 | ||
| 81 | // generating functions | |
| 82 | template<class _URNG> | |
| 83 | _LIBCPP_INLINE_VISIBILITY | |
| 84 | result_type operator()(_URNG& __g) | |
| 85 | {return (*this)(__g, __p_);} | |
| 86 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 87 | ||
| 88 | // property functions | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | result_type t() const {return __p_.t();} | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | double p() const {return __p_.p();} | |
| 93 | ||
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | param_type param() const {return __p_;} | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | void param(const param_type& __p) {__p_ = __p;} | |
| 98 | ||
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | result_type min() const {return 0;} | |
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | result_type max() const {return t();} | |
| 103 | ||
| 104 | friend _LIBCPP_INLINE_VISIBILITY | |
| 105 | bool operator==(const binomial_distribution& __x, | |
| 106 | const binomial_distribution& __y) | |
| 107 | {return __x.__p_ == __y.__p_;} | |
| 108 | friend _LIBCPP_INLINE_VISIBILITY | |
| 109 | bool operator!=(const binomial_distribution& __x, | |
| 110 | const binomial_distribution& __y) | |
| 111 | {return !(__x == __y);} | |
| 112 | }; | |
| 113 | ||
| 114 | #ifndef _LIBCPP_MSVCRT_LIKE | |
| 115 | extern "C" double lgamma_r(double, int *); | |
| 116 | #endif | |
| 117 | ||
| 118 | inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) { | |
| 119 | #if defined(_LIBCPP_MSVCRT_LIKE) | |
| 120 | return lgamma(__d); | |
| 121 | #else | |
| 122 | int __sign; | |
| 123 | return lgamma_r(__d, &__sign); | |
| 124 | #endif | |
| 125 | } | |
| 126 | ||
| 127 | template<class _IntType> | |
| 128 | binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p) | |
| 129 | : __t_(__t), __p_(__p) | |
| 130 | { | |
| 131 | if (0 < __p_ && __p_ < 1) | |
| 132 | { | |
| 133 | __r0_ = static_cast<result_type>((__t_ + 1) * __p_); | |
| 134 | __pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) - | |
| 135 | __libcpp_lgamma(__r0_ + 1.) - | |
| 136 | __libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) + | |
| 137 | (__t_ - __r0_) * _VSTD::log(1 - __p_)); | |
| 138 | __odds_ratio_ = __p_ / (1 - __p_); | |
| 139 | } | |
| 140 | } | |
| 141 | ||
| 142 | // Reference: Kemp, C.D. (1986). `A modal method for generating binomial | |
| 143 | // variables', Commun. Statist. - Theor. Meth. 15(3), 805-813. | |
| 144 | template<class _IntType> | |
| 145 | template<class _URNG> | |
| 146 | _IntType | |
| 147 | binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) | |
| 148 | { | |
| 149 | if (__pr.__t_ == 0 || __pr.__p_ == 0) | |
| 150 | return 0; | |
| 151 | if (__pr.__p_ == 1) | |
| 152 | return __pr.__t_; | |
| 153 | uniform_real_distribution<double> __gen; | |
| 154 | double __u = __gen(__g) - __pr.__pr_; | |
| 155 | if (__u < 0) | |
| 156 | return __pr.__r0_; | |
| 157 | double __pu = __pr.__pr_; | |
| 158 | double __pd = __pu; | |
| 159 | result_type __ru = __pr.__r0_; | |
| 160 | result_type __rd = __ru; | |
| 161 | while (true) | |
| 162 | { | |
| 163 | bool __break = true; | |
| 164 | if (__rd >= 1) | |
| 165 | { | |
| 166 | __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1)); | |
| 167 | __u -= __pd; | |
| 168 | __break = false; | |
| 169 | if (__u < 0) | |
| 170 | return __rd - 1; | |
| 171 | } | |
| 172 | if ( __rd != 0 ) | |
| 173 | --__rd; | |
| 174 | ++__ru; | |
| 175 | if (__ru <= __pr.__t_) | |
| 176 | { | |
| 177 | __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru; | |
| 178 | __u -= __pu; | |
| 179 | __break = false; | |
| 180 | if (__u < 0) | |
| 181 | return __ru; | |
| 182 | } | |
| 183 | if (__break) | |
| 184 | return 0; | |
| 185 | } | |
| 186 | } | |
| 187 | ||
| 188 | template <class _CharT, class _Traits, class _IntType> | |
| 189 | basic_ostream<_CharT, _Traits>& | |
| 190 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 191 | const binomial_distribution<_IntType>& __x) | |
| 192 | { | |
| 193 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 194 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 195 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 196 | _OStream::scientific); | |
| 197 | _CharT __sp = __os.widen(' '); | |
| 198 | __os.fill(__sp); | |
| 199 | return __os << __x.t() << __sp << __x.p(); | |
| 200 | } | |
| 201 | ||
| 202 | template <class _CharT, class _Traits, class _IntType> | |
| 203 | basic_istream<_CharT, _Traits>& | |
| 204 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 205 | binomial_distribution<_IntType>& __x) | |
| 206 | { | |
| 207 | typedef binomial_distribution<_IntType> _Eng; | |
| 208 | typedef typename _Eng::result_type result_type; | |
| 209 | typedef typename _Eng::param_type param_type; | |
| 210 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 211 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 212 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 213 | result_type __t; | |
| 214 | double __p; | |
| 215 | __is >> __t >> __p; | |
| 216 | if (!__is.fail()) | |
| 217 | __x.param(param_type(__t, __p)); | |
| 218 | return __is; | |
| 219 | } | |
| 220 | ||
| 221 | _LIBCPP_END_NAMESPACE_STD | |
| 222 | ||
| 223 | _LIBCPP_POP_MACROS | |
| 224 | ||
| 225 | #endif // _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H |
lib/libcxx/include/__random/cauchy_distribution.h created+162| ... | ... | @@ -0,0 +1,162 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_CAUCHY_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/uniform_real_distribution.h> | |
| 14 | #include <cmath> | |
| 15 | #include <iosfwd> | |
| 16 | #include <limits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | template<class _RealType = double> | |
| 28 | class _LIBCPP_TEMPLATE_VIS cauchy_distribution | |
| 29 | { | |
| 30 | public: | |
| 31 | // types | |
| 32 | typedef _RealType result_type; | |
| 33 | ||
| 34 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 35 | { | |
| 36 | result_type __a_; | |
| 37 | result_type __b_; | |
| 38 | public: | |
| 39 | typedef cauchy_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __a = 0, result_type __b = 1) | |
| 43 | : __a_(__a), __b_(__b) {} | |
| 44 | ||
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | result_type a() const {return __a_;} | |
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | result_type b() const {return __b_;} | |
| 49 | ||
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator==(const param_type& __x, const param_type& __y) | |
| 52 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 53 | friend _LIBCPP_INLINE_VISIBILITY | |
| 54 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 55 | {return !(__x == __y);} | |
| 56 | }; | |
| 57 | ||
| 58 | private: | |
| 59 | param_type __p_; | |
| 60 | ||
| 61 | public: | |
| 62 | // constructor and reset functions | |
| 63 | #ifndef _LIBCPP_CXX03_LANG | |
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | cauchy_distribution() : cauchy_distribution(0) {} | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | explicit cauchy_distribution(result_type __a, result_type __b = 1) | |
| 68 | : __p_(param_type(__a, __b)) {} | |
| 69 | #else | |
| 70 | _LIBCPP_INLINE_VISIBILITY | |
| 71 | explicit cauchy_distribution(result_type __a = 0, result_type __b = 1) | |
| 72 | : __p_(param_type(__a, __b)) {} | |
| 73 | #endif | |
| 74 | _LIBCPP_INLINE_VISIBILITY | |
| 75 | explicit cauchy_distribution(const param_type& __p) | |
| 76 | : __p_(__p) {} | |
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | void reset() {} | |
| 79 | ||
| 80 | // generating functions | |
| 81 | template<class _URNG> | |
| 82 | _LIBCPP_INLINE_VISIBILITY | |
| 83 | result_type operator()(_URNG& __g) | |
| 84 | {return (*this)(__g, __p_);} | |
| 85 | template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); | |
| 86 | ||
| 87 | // property functions | |
| 88 | _LIBCPP_INLINE_VISIBILITY | |
| 89 | result_type a() const {return __p_.a();} | |
| 90 | _LIBCPP_INLINE_VISIBILITY | |
| 91 | result_type b() const {return __p_.b();} | |
| 92 | ||
| 93 | _LIBCPP_INLINE_VISIBILITY | |
| 94 | param_type param() const {return __p_;} | |
| 95 | _LIBCPP_INLINE_VISIBILITY | |
| 96 | void param(const param_type& __p) {__p_ = __p;} | |
| 97 | ||
| 98 | _LIBCPP_INLINE_VISIBILITY | |
| 99 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 100 | _LIBCPP_INLINE_VISIBILITY | |
| 101 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 102 | ||
| 103 | friend _LIBCPP_INLINE_VISIBILITY | |
| 104 | bool operator==(const cauchy_distribution& __x, | |
| 105 | const cauchy_distribution& __y) | |
| 106 | {return __x.__p_ == __y.__p_;} | |
| 107 | friend _LIBCPP_INLINE_VISIBILITY | |
| 108 | bool operator!=(const cauchy_distribution& __x, | |
| 109 | const cauchy_distribution& __y) | |
| 110 | {return !(__x == __y);} | |
| 111 | }; | |
| 112 | ||
| 113 | template <class _RealType> | |
| 114 | template<class _URNG> | |
| 115 | inline | |
| 116 | _RealType | |
| 117 | cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 118 | { | |
| 119 | uniform_real_distribution<result_type> __gen; | |
| 120 | // 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)); | |
| 122 | } | |
| 123 | ||
| 124 | template <class _CharT, class _Traits, class _RT> | |
| 125 | basic_ostream<_CharT, _Traits>& | |
| 126 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 127 | const cauchy_distribution<_RT>& __x) | |
| 128 | { | |
| 129 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 130 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 131 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 132 | _OStream::scientific); | |
| 133 | _CharT __sp = __os.widen(' '); | |
| 134 | __os.fill(__sp); | |
| 135 | __os << __x.a() << __sp << __x.b(); | |
| 136 | return __os; | |
| 137 | } | |
| 138 | ||
| 139 | template <class _CharT, class _Traits, class _RT> | |
| 140 | basic_istream<_CharT, _Traits>& | |
| 141 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 142 | cauchy_distribution<_RT>& __x) | |
| 143 | { | |
| 144 | typedef cauchy_distribution<_RT> _Eng; | |
| 145 | typedef typename _Eng::result_type result_type; | |
| 146 | typedef typename _Eng::param_type param_type; | |
| 147 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 148 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 149 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 150 | result_type __a; | |
| 151 | result_type __b; | |
| 152 | __is >> __a >> __b; | |
| 153 | if (!__is.fail()) | |
| 154 | __x.param(param_type(__a, __b)); | |
| 155 | return __is; | |
| 156 | } | |
| 157 | ||
| 158 | _LIBCPP_END_NAMESPACE_STD | |
| 159 | ||
| 160 | _LIBCPP_POP_MACROS | |
| 161 | ||
| 162 | #endif // _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H |
lib/libcxx/include/__random/chi_squared_distribution.h created+144| ... | ... | @@ -0,0 +1,144 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_CHI_SQUARED_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_CHI_SQUARED_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/gamma_distribution.h> | |
| 14 | #include <iosfwd> | |
| 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 | template<class _RealType = double> | |
| 27 | class _LIBCPP_TEMPLATE_VIS chi_squared_distribution | |
| 28 | { | |
| 29 | public: | |
| 30 | // types | |
| 31 | typedef _RealType result_type; | |
| 32 | ||
| 33 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 34 | { | |
| 35 | result_type __n_; | |
| 36 | public: | |
| 37 | typedef chi_squared_distribution distribution_type; | |
| 38 | ||
| 39 | _LIBCPP_INLINE_VISIBILITY | |
| 40 | explicit param_type(result_type __n = 1) : __n_(__n) {} | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | result_type n() const {return __n_;} | |
| 44 | ||
| 45 | friend _LIBCPP_INLINE_VISIBILITY | |
| 46 | bool operator==(const param_type& __x, const param_type& __y) | |
| 47 | {return __x.__n_ == __y.__n_;} | |
| 48 | friend _LIBCPP_INLINE_VISIBILITY | |
| 49 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 50 | {return !(__x == __y);} | |
| 51 | }; | |
| 52 | ||
| 53 | private: | |
| 54 | param_type __p_; | |
| 55 | ||
| 56 | public: | |
| 57 | // constructor and reset functions | |
| 58 | #ifndef _LIBCPP_CXX03_LANG | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | chi_squared_distribution() : chi_squared_distribution(1) {} | |
| 61 | _LIBCPP_INLINE_VISIBILITY | |
| 62 | explicit chi_squared_distribution(result_type __n) | |
| 63 | : __p_(param_type(__n)) {} | |
| 64 | #else | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | explicit chi_squared_distribution(result_type __n = 1) | |
| 67 | : __p_(param_type(__n)) {} | |
| 68 | #endif | |
| 69 | _LIBCPP_INLINE_VISIBILITY | |
| 70 | explicit chi_squared_distribution(const param_type& __p) | |
| 71 | : __p_(__p) {} | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | void reset() {} | |
| 74 | ||
| 75 | // generating functions | |
| 76 | template<class _URNG> | |
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | result_type operator()(_URNG& __g) | |
| 79 | {return (*this)(__g, __p_);} | |
| 80 | template<class _URNG> | |
| 81 | _LIBCPP_INLINE_VISIBILITY | |
| 82 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 83 | {return gamma_distribution<result_type>(__p.n() / 2, 2)(__g);} | |
| 84 | ||
| 85 | // property functions | |
| 86 | _LIBCPP_INLINE_VISIBILITY | |
| 87 | result_type n() const {return __p_.n();} | |
| 88 | ||
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | param_type param() const {return __p_;} | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | void param(const param_type& __p) {__p_ = __p;} | |
| 93 | ||
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | result_type min() const {return 0;} | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 98 | ||
| 99 | friend _LIBCPP_INLINE_VISIBILITY | |
| 100 | bool operator==(const chi_squared_distribution& __x, | |
| 101 | const chi_squared_distribution& __y) | |
| 102 | {return __x.__p_ == __y.__p_;} | |
| 103 | friend _LIBCPP_INLINE_VISIBILITY | |
| 104 | bool operator!=(const chi_squared_distribution& __x, | |
| 105 | const chi_squared_distribution& __y) | |
| 106 | {return !(__x == __y);} | |
| 107 | }; | |
| 108 | ||
| 109 | template <class _CharT, class _Traits, class _RT> | |
| 110 | basic_ostream<_CharT, _Traits>& | |
| 111 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 112 | const chi_squared_distribution<_RT>& __x) | |
| 113 | { | |
| 114 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 115 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 116 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 117 | _OStream::scientific); | |
| 118 | __os << __x.n(); | |
| 119 | return __os; | |
| 120 | } | |
| 121 | ||
| 122 | template <class _CharT, class _Traits, class _RT> | |
| 123 | basic_istream<_CharT, _Traits>& | |
| 124 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 125 | chi_squared_distribution<_RT>& __x) | |
| 126 | { | |
| 127 | typedef chi_squared_distribution<_RT> _Eng; | |
| 128 | typedef typename _Eng::result_type result_type; | |
| 129 | typedef typename _Eng::param_type param_type; | |
| 130 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 131 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 132 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 133 | result_type __n; | |
| 134 | __is >> __n; | |
| 135 | if (!__is.fail()) | |
| 136 | __x.param(param_type(__n)); | |
| 137 | return __is; | |
| 138 | } | |
| 139 | ||
| 140 | _LIBCPP_END_NAMESPACE_STD | |
| 141 | ||
| 142 | _LIBCPP_POP_MACROS | |
| 143 | ||
| 144 | #endif // _LIBCPP___RANDOM_CHI_SQUARED_DISTRIBUTION_H |
lib/libcxx/include/__random/clamp_to_integral.h created+60| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_CLAMP_TO_INTEGRAL_H | |
| 10 | #define _LIBCPP___RANDOM_CLAMP_TO_INTEGRAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cmath> | |
| 14 | #include <limits> | |
| 15 | #include <type_traits> | |
| 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 | template <class _IntT, class _FloatT, | |
| 27 | bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits), | |
| 28 | int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)> | |
| 29 | _LIBCPP_INLINE_VISIBILITY | |
| 30 | _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT { | |
| 31 | static_assert(is_floating_point<_FloatT>::value, "must be a floating point type"); | |
| 32 | static_assert(is_integral<_IntT>::value, "must be an integral type"); | |
| 33 | static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix"); | |
| 34 | static_assert((_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value | |
| 35 | || _IsSame<_FloatT,long double>::value), "unsupported floating point type"); | |
| 36 | return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits); | |
| 37 | } | |
| 38 | ||
| 39 | // Convert a floating point number to the specified integral type after | |
| 40 | // clamping to the integral type's representable range. | |
| 41 | // | |
| 42 | // The behavior is undefined if `__r` is NaN. | |
| 43 | template <class _IntT, class _RealT> | |
| 44 | _LIBCPP_INLINE_VISIBILITY | |
| 45 | _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT { | |
| 46 | using _Lim = numeric_limits<_IntT>; | |
| 47 | const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>(); | |
| 48 | if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) { | |
| 49 | return _Lim::max(); | |
| 50 | } else if (__r <= _Lim::lowest()) { | |
| 51 | return _Lim::min(); | |
| 52 | } | |
| 53 | return static_cast<_IntT>(__r); | |
| 54 | } | |
| 55 | ||
| 56 | _LIBCPP_END_NAMESPACE_STD | |
| 57 | ||
| 58 | _LIBCPP_POP_MACROS | |
| 59 | ||
| 60 | #endif // _LIBCPP___RANDOM_CLAMP_TO_INTEGRAL_H |
lib/libcxx/include/__random/default_random_engine.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___RANDOM_DEFAULT_RANDOM_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_DEFAULT_RANDOM_ENGINE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/linear_congruential_engine.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 | typedef minstd_rand default_random_engine; | |
| 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD | |
| 24 | ||
| 25 | #endif // _LIBCPP___RANDOM_DEFAULT_RANDOM_ENGINE_H |
lib/libcxx/include/__random/discard_block_engine.h created+203| ... | ... | @@ -0,0 +1,203 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_DISCARD_BLOCK_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/is_seed_sequence.h> | |
| 14 | #include <__utility/move.h> | |
| 15 | #include <climits> | |
| 16 | #include <iosfwd> | |
| 17 | #include <type_traits> | |
| 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 | template<class _Engine, size_t __p, size_t __r> | |
| 29 | class _LIBCPP_TEMPLATE_VIS discard_block_engine | |
| 30 | { | |
| 31 | _Engine __e_; | |
| 32 | int __n_; | |
| 33 | ||
| 34 | static_assert( 0 < __r, "discard_block_engine invalid parameters"); | |
| 35 | static_assert(__r <= __p, "discard_block_engine invalid parameters"); | |
| 36 | static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters"); | |
| 37 | public: | |
| 38 | // types | |
| 39 | typedef typename _Engine::result_type result_type; | |
| 40 | ||
| 41 | // engine characteristics | |
| 42 | static _LIBCPP_CONSTEXPR const size_t block_size = __p; | |
| 43 | static _LIBCPP_CONSTEXPR const size_t used_block = __r; | |
| 44 | ||
| 45 | #ifdef _LIBCPP_CXX03_LANG | |
| 46 | static const result_type _Min = _Engine::_Min; | |
| 47 | static const result_type _Max = _Engine::_Max; | |
| 48 | #else | |
| 49 | static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); | |
| 50 | static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); | |
| 51 | #endif | |
| 52 | ||
| 53 | _LIBCPP_INLINE_VISIBILITY | |
| 54 | static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); } | |
| 55 | _LIBCPP_INLINE_VISIBILITY | |
| 56 | static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); } | |
| 57 | ||
| 58 | // constructors and seeding functions | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | discard_block_engine() : __n_(0) {} | |
| 61 | _LIBCPP_INLINE_VISIBILITY | |
| 62 | explicit discard_block_engine(const _Engine& __e) | |
| 63 | : __e_(__e), __n_(0) {} | |
| 64 | #ifndef _LIBCPP_CXX03_LANG | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | explicit discard_block_engine(_Engine&& __e) | |
| 67 | : __e_(_VSTD::move(__e)), __n_(0) {} | |
| 68 | #endif // _LIBCPP_CXX03_LANG | |
| 69 | _LIBCPP_INLINE_VISIBILITY | |
| 70 | explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {} | |
| 71 | template<class _Sseq> | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | explicit discard_block_engine(_Sseq& __q, | |
| 74 | typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value && | |
| 75 | !is_convertible<_Sseq, _Engine>::value>::type* = 0) | |
| 76 | : __e_(__q), __n_(0) {} | |
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | void seed() {__e_.seed(); __n_ = 0;} | |
| 79 | _LIBCPP_INLINE_VISIBILITY | |
| 80 | void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;} | |
| 81 | template<class _Sseq> | |
| 82 | _LIBCPP_INLINE_VISIBILITY | |
| 83 | typename enable_if | |
| 84 | < | |
| 85 | __is_seed_sequence<_Sseq, discard_block_engine>::value, | |
| 86 | void | |
| 87 | >::type | |
| 88 | seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;} | |
| 89 | ||
| 90 | // generating functions | |
| 91 | result_type operator()(); | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 94 | ||
| 95 | // property functions | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | const _Engine& base() const _NOEXCEPT {return __e_;} | |
| 98 | ||
| 99 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 100 | friend | |
| 101 | bool | |
| 102 | operator==( | |
| 103 | const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 104 | const discard_block_engine<_Eng, _Pp, _Rp>& __y); | |
| 105 | ||
| 106 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 107 | friend | |
| 108 | bool | |
| 109 | operator!=( | |
| 110 | const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 111 | const discard_block_engine<_Eng, _Pp, _Rp>& __y); | |
| 112 | ||
| 113 | template <class _CharT, class _Traits, | |
| 114 | class _Eng, size_t _Pp, size_t _Rp> | |
| 115 | friend | |
| 116 | basic_ostream<_CharT, _Traits>& | |
| 117 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 118 | const discard_block_engine<_Eng, _Pp, _Rp>& __x); | |
| 119 | ||
| 120 | template <class _CharT, class _Traits, | |
| 121 | class _Eng, size_t _Pp, size_t _Rp> | |
| 122 | friend | |
| 123 | basic_istream<_CharT, _Traits>& | |
| 124 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 125 | discard_block_engine<_Eng, _Pp, _Rp>& __x); | |
| 126 | }; | |
| 127 | ||
| 128 | template<class _Engine, size_t __p, size_t __r> | |
| 129 | _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size; | |
| 130 | ||
| 131 | template<class _Engine, size_t __p, size_t __r> | |
| 132 | _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block; | |
| 133 | ||
| 134 | template<class _Engine, size_t __p, size_t __r> | |
| 135 | typename discard_block_engine<_Engine, __p, __r>::result_type | |
| 136 | discard_block_engine<_Engine, __p, __r>::operator()() | |
| 137 | { | |
| 138 | if (__n_ >= static_cast<int>(__r)) | |
| 139 | { | |
| 140 | __e_.discard(__p - __r); | |
| 141 | __n_ = 0; | |
| 142 | } | |
| 143 | ++__n_; | |
| 144 | return __e_(); | |
| 145 | } | |
| 146 | ||
| 147 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 148 | inline _LIBCPP_INLINE_VISIBILITY | |
| 149 | bool | |
| 150 | operator==(const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 151 | const discard_block_engine<_Eng, _Pp, _Rp>& __y) | |
| 152 | { | |
| 153 | return __x.__n_ == __y.__n_ && __x.__e_ == __y.__e_; | |
| 154 | } | |
| 155 | ||
| 156 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 157 | inline _LIBCPP_INLINE_VISIBILITY | |
| 158 | bool | |
| 159 | operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 160 | const discard_block_engine<_Eng, _Pp, _Rp>& __y) | |
| 161 | { | |
| 162 | return !(__x == __y); | |
| 163 | } | |
| 164 | ||
| 165 | template <class _CharT, class _Traits, | |
| 166 | class _Eng, size_t _Pp, size_t _Rp> | |
| 167 | basic_ostream<_CharT, _Traits>& | |
| 168 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 169 | const discard_block_engine<_Eng, _Pp, _Rp>& __x) | |
| 170 | { | |
| 171 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 172 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 173 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 174 | _CharT __sp = __os.widen(' '); | |
| 175 | __os.fill(__sp); | |
| 176 | return __os << __x.__e_ << __sp << __x.__n_; | |
| 177 | } | |
| 178 | ||
| 179 | template <class _CharT, class _Traits, | |
| 180 | class _Eng, size_t _Pp, size_t _Rp> | |
| 181 | basic_istream<_CharT, _Traits>& | |
| 182 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 183 | discard_block_engine<_Eng, _Pp, _Rp>& __x) | |
| 184 | { | |
| 185 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 186 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 187 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 188 | _Eng __e; | |
| 189 | int __n; | |
| 190 | __is >> __e >> __n; | |
| 191 | if (!__is.fail()) | |
| 192 | { | |
| 193 | __x.__e_ = __e; | |
| 194 | __x.__n_ = __n; | |
| 195 | } | |
| 196 | return __is; | |
| 197 | } | |
| 198 | ||
| 199 | _LIBCPP_END_NAMESPACE_STD | |
| 200 | ||
| 201 | _LIBCPP_POP_MACROS | |
| 202 | ||
| 203 | #endif // _LIBCPP___RANDOM_DISCARD_BLOCK_ENGINE_H |
lib/libcxx/include/__random/discrete_distribution.h created+260| ... | ... | @@ -0,0 +1,260 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_DISCRETE_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_DISCRETE_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__algorithm/upper_bound.h> | |
| 13 | #include <__config> | |
| 14 | #include <__random/uniform_real_distribution.h> | |
| 15 | #include <cstddef> | |
| 16 | #include <iosfwd> | |
| 17 | #include <numeric> | |
| 18 | #include <vector> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | template<class _IntType = int> | |
| 30 | class _LIBCPP_TEMPLATE_VIS discrete_distribution | |
| 31 | { | |
| 32 | public: | |
| 33 | // types | |
| 34 | typedef _IntType result_type; | |
| 35 | ||
| 36 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 37 | { | |
| 38 | vector<double> __p_; | |
| 39 | public: | |
| 40 | typedef discrete_distribution distribution_type; | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | param_type() {} | |
| 44 | template<class _InputIterator> | |
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | param_type(_InputIterator __f, _InputIterator __l) | |
| 47 | : __p_(__f, __l) {__init();} | |
| 48 | #ifndef _LIBCPP_CXX03_LANG | |
| 49 | _LIBCPP_INLINE_VISIBILITY | |
| 50 | param_type(initializer_list<double> __wl) | |
| 51 | : __p_(__wl.begin(), __wl.end()) {__init();} | |
| 52 | #endif // _LIBCPP_CXX03_LANG | |
| 53 | template<class _UnaryOperation> | |
| 54 | param_type(size_t __nw, double __xmin, double __xmax, | |
| 55 | _UnaryOperation __fw); | |
| 56 | ||
| 57 | vector<double> probabilities() const; | |
| 58 | ||
| 59 | friend _LIBCPP_INLINE_VISIBILITY | |
| 60 | bool operator==(const param_type& __x, const param_type& __y) | |
| 61 | {return __x.__p_ == __y.__p_;} | |
| 62 | friend _LIBCPP_INLINE_VISIBILITY | |
| 63 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 64 | {return !(__x == __y);} | |
| 65 | ||
| 66 | private: | |
| 67 | void __init(); | |
| 68 | ||
| 69 | friend class discrete_distribution; | |
| 70 | ||
| 71 | template <class _CharT, class _Traits, class _IT> | |
| 72 | friend | |
| 73 | basic_ostream<_CharT, _Traits>& | |
| 74 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 75 | const discrete_distribution<_IT>& __x); | |
| 76 | ||
| 77 | template <class _CharT, class _Traits, class _IT> | |
| 78 | friend | |
| 79 | basic_istream<_CharT, _Traits>& | |
| 80 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 81 | discrete_distribution<_IT>& __x); | |
| 82 | }; | |
| 83 | ||
| 84 | private: | |
| 85 | param_type __p_; | |
| 86 | ||
| 87 | public: | |
| 88 | // constructor and reset functions | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | discrete_distribution() {} | |
| 91 | template<class _InputIterator> | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | discrete_distribution(_InputIterator __f, _InputIterator __l) | |
| 94 | : __p_(__f, __l) {} | |
| 95 | #ifndef _LIBCPP_CXX03_LANG | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | discrete_distribution(initializer_list<double> __wl) | |
| 98 | : __p_(__wl) {} | |
| 99 | #endif // _LIBCPP_CXX03_LANG | |
| 100 | template<class _UnaryOperation> | |
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | discrete_distribution(size_t __nw, double __xmin, double __xmax, | |
| 103 | _UnaryOperation __fw) | |
| 104 | : __p_(__nw, __xmin, __xmax, __fw) {} | |
| 105 | _LIBCPP_INLINE_VISIBILITY | |
| 106 | explicit discrete_distribution(const param_type& __p) | |
| 107 | : __p_(__p) {} | |
| 108 | _LIBCPP_INLINE_VISIBILITY | |
| 109 | void reset() {} | |
| 110 | ||
| 111 | // generating functions | |
| 112 | template<class _URNG> | |
| 113 | _LIBCPP_INLINE_VISIBILITY | |
| 114 | result_type operator()(_URNG& __g) | |
| 115 | {return (*this)(__g, __p_);} | |
| 116 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 117 | ||
| 118 | // property functions | |
| 119 | _LIBCPP_INLINE_VISIBILITY | |
| 120 | vector<double> probabilities() const {return __p_.probabilities();} | |
| 121 | ||
| 122 | _LIBCPP_INLINE_VISIBILITY | |
| 123 | param_type param() const {return __p_;} | |
| 124 | _LIBCPP_INLINE_VISIBILITY | |
| 125 | void param(const param_type& __p) {__p_ = __p;} | |
| 126 | ||
| 127 | _LIBCPP_INLINE_VISIBILITY | |
| 128 | result_type min() const {return 0;} | |
| 129 | _LIBCPP_INLINE_VISIBILITY | |
| 130 | result_type max() const {return __p_.__p_.size();} | |
| 131 | ||
| 132 | friend _LIBCPP_INLINE_VISIBILITY | |
| 133 | bool operator==(const discrete_distribution& __x, | |
| 134 | const discrete_distribution& __y) | |
| 135 | {return __x.__p_ == __y.__p_;} | |
| 136 | friend _LIBCPP_INLINE_VISIBILITY | |
| 137 | bool operator!=(const discrete_distribution& __x, | |
| 138 | const discrete_distribution& __y) | |
| 139 | {return !(__x == __y);} | |
| 140 | ||
| 141 | template <class _CharT, class _Traits, class _IT> | |
| 142 | friend | |
| 143 | basic_ostream<_CharT, _Traits>& | |
| 144 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 145 | const discrete_distribution<_IT>& __x); | |
| 146 | ||
| 147 | template <class _CharT, class _Traits, class _IT> | |
| 148 | friend | |
| 149 | basic_istream<_CharT, _Traits>& | |
| 150 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 151 | discrete_distribution<_IT>& __x); | |
| 152 | }; | |
| 153 | ||
| 154 | template<class _IntType> | |
| 155 | template<class _UnaryOperation> | |
| 156 | discrete_distribution<_IntType>::param_type::param_type(size_t __nw, | |
| 157 | double __xmin, | |
| 158 | double __xmax, | |
| 159 | _UnaryOperation __fw) | |
| 160 | { | |
| 161 | if (__nw > 1) | |
| 162 | { | |
| 163 | __p_.reserve(__nw - 1); | |
| 164 | double __d = (__xmax - __xmin) / __nw; | |
| 165 | double __d2 = __d / 2; | |
| 166 | for (size_t __k = 0; __k < __nw; ++__k) | |
| 167 | __p_.push_back(__fw(__xmin + __k * __d + __d2)); | |
| 168 | __init(); | |
| 169 | } | |
| 170 | } | |
| 171 | ||
| 172 | template<class _IntType> | |
| 173 | void | |
| 174 | discrete_distribution<_IntType>::param_type::__init() | |
| 175 | { | |
| 176 | if (!__p_.empty()) | |
| 177 | { | |
| 178 | if (__p_.size() > 1) | |
| 179 | { | |
| 180 | double __s = _VSTD::accumulate(__p_.begin(), __p_.end(), 0.0); | |
| 181 | for (vector<double>::iterator __i = __p_.begin(), __e = __p_.end(); __i < __e; ++__i) | |
| 182 | *__i /= __s; | |
| 183 | vector<double> __t(__p_.size() - 1); | |
| 184 | _VSTD::partial_sum(__p_.begin(), __p_.end() - 1, __t.begin()); | |
| 185 | swap(__p_, __t); | |
| 186 | } | |
| 187 | else | |
| 188 | { | |
| 189 | __p_.clear(); | |
| 190 | __p_.shrink_to_fit(); | |
| 191 | } | |
| 192 | } | |
| 193 | } | |
| 194 | ||
| 195 | template<class _IntType> | |
| 196 | vector<double> | |
| 197 | discrete_distribution<_IntType>::param_type::probabilities() const | |
| 198 | { | |
| 199 | size_t __n = __p_.size(); | |
| 200 | vector<double> __p(__n+1); | |
| 201 | _VSTD::adjacent_difference(__p_.begin(), __p_.end(), __p.begin()); | |
| 202 | if (__n > 0) | |
| 203 | __p[__n] = 1 - __p_[__n-1]; | |
| 204 | else | |
| 205 | __p[0] = 1; | |
| 206 | return __p; | |
| 207 | } | |
| 208 | ||
| 209 | template<class _IntType> | |
| 210 | template<class _URNG> | |
| 211 | _IntType | |
| 212 | discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) | |
| 213 | { | |
| 214 | uniform_real_distribution<double> __gen; | |
| 215 | return static_cast<_IntType>( | |
| 216 | _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) - | |
| 217 | __p.__p_.begin()); | |
| 218 | } | |
| 219 | ||
| 220 | template <class _CharT, class _Traits, class _IT> | |
| 221 | basic_ostream<_CharT, _Traits>& | |
| 222 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 223 | const discrete_distribution<_IT>& __x) | |
| 224 | { | |
| 225 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 226 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 227 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 228 | _OStream::scientific); | |
| 229 | _CharT __sp = __os.widen(' '); | |
| 230 | __os.fill(__sp); | |
| 231 | size_t __n = __x.__p_.__p_.size(); | |
| 232 | __os << __n; | |
| 233 | for (size_t __i = 0; __i < __n; ++__i) | |
| 234 | __os << __sp << __x.__p_.__p_[__i]; | |
| 235 | return __os; | |
| 236 | } | |
| 237 | ||
| 238 | template <class _CharT, class _Traits, class _IT> | |
| 239 | basic_istream<_CharT, _Traits>& | |
| 240 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 241 | discrete_distribution<_IT>& __x) | |
| 242 | { | |
| 243 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 244 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 245 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 246 | size_t __n; | |
| 247 | __is >> __n; | |
| 248 | vector<double> __p(__n); | |
| 249 | for (size_t __i = 0; __i < __n; ++__i) | |
| 250 | __is >> __p[__i]; | |
| 251 | if (!__is.fail()) | |
| 252 | swap(__x.__p_.__p_, __p); | |
| 253 | return __is; | |
| 254 | } | |
| 255 | ||
| 256 | _LIBCPP_END_NAMESPACE_STD | |
| 257 | ||
| 258 | _LIBCPP_POP_MACROS | |
| 259 | ||
| 260 | #endif // _LIBCPP___RANDOM_DISCRETE_DISTRIBUTION_H |
lib/libcxx/include/__random/exponential_distribution.h created+155| ... | ... | @@ -0,0 +1,155 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_EXPONENTIAL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_EXPONENTIAL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/generate_canonical.h> | |
| 14 | #include <__random/uniform_real_distribution.h> | |
| 15 | #include <cmath> | |
| 16 | #include <iosfwd> | |
| 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 | template<class _RealType = double> | |
| 29 | class _LIBCPP_TEMPLATE_VIS exponential_distribution | |
| 30 | { | |
| 31 | public: | |
| 32 | // types | |
| 33 | typedef _RealType result_type; | |
| 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 36 | { | |
| 37 | result_type __lambda_; | |
| 38 | public: | |
| 39 | typedef exponential_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __lambda = 1) : __lambda_(__lambda) {} | |
| 43 | ||
| 44 | _LIBCPP_INLINE_VISIBILITY | |
| 45 | result_type lambda() const {return __lambda_;} | |
| 46 | ||
| 47 | friend _LIBCPP_INLINE_VISIBILITY | |
| 48 | bool operator==(const param_type& __x, const param_type& __y) | |
| 49 | {return __x.__lambda_ == __y.__lambda_;} | |
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 52 | {return !(__x == __y);} | |
| 53 | }; | |
| 54 | ||
| 55 | private: | |
| 56 | param_type __p_; | |
| 57 | ||
| 58 | public: | |
| 59 | // constructors and reset functions | |
| 60 | #ifndef _LIBCPP_CXX03_LANG | |
| 61 | _LIBCPP_INLINE_VISIBILITY | |
| 62 | exponential_distribution() : exponential_distribution(1) {} | |
| 63 | _LIBCPP_INLINE_VISIBILITY | |
| 64 | explicit exponential_distribution(result_type __lambda) | |
| 65 | : __p_(param_type(__lambda)) {} | |
| 66 | #else | |
| 67 | _LIBCPP_INLINE_VISIBILITY | |
| 68 | explicit exponential_distribution(result_type __lambda = 1) | |
| 69 | : __p_(param_type(__lambda)) {} | |
| 70 | #endif | |
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | explicit exponential_distribution(const param_type& __p) : __p_(__p) {} | |
| 73 | _LIBCPP_INLINE_VISIBILITY | |
| 74 | void reset() {} | |
| 75 | ||
| 76 | // generating functions | |
| 77 | template<class _URNG> | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | result_type operator()(_URNG& __g) | |
| 80 | {return (*this)(__g, __p_);} | |
| 81 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 82 | ||
| 83 | // property functions | |
| 84 | _LIBCPP_INLINE_VISIBILITY | |
| 85 | result_type lambda() const {return __p_.lambda();} | |
| 86 | ||
| 87 | _LIBCPP_INLINE_VISIBILITY | |
| 88 | param_type param() const {return __p_;} | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | void param(const param_type& __p) {__p_ = __p;} | |
| 91 | ||
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | result_type min() const {return 0;} | |
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 96 | ||
| 97 | friend _LIBCPP_INLINE_VISIBILITY | |
| 98 | bool operator==(const exponential_distribution& __x, | |
| 99 | const exponential_distribution& __y) | |
| 100 | {return __x.__p_ == __y.__p_;} | |
| 101 | friend _LIBCPP_INLINE_VISIBILITY | |
| 102 | bool operator!=(const exponential_distribution& __x, | |
| 103 | const exponential_distribution& __y) | |
| 104 | {return !(__x == __y);} | |
| 105 | }; | |
| 106 | ||
| 107 | template <class _RealType> | |
| 108 | template<class _URNG> | |
| 109 | _RealType | |
| 110 | exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 111 | { | |
| 112 | return -_VSTD::log | |
| 113 | ( | |
| 114 | result_type(1) - | |
| 115 | _VSTD::generate_canonical<result_type, | |
| 116 | numeric_limits<result_type>::digits>(__g) | |
| 117 | ) | |
| 118 | / __p.lambda(); | |
| 119 | } | |
| 120 | ||
| 121 | template <class _CharT, class _Traits, class _RealType> | |
| 122 | basic_ostream<_CharT, _Traits>& | |
| 123 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 124 | const exponential_distribution<_RealType>& __x) | |
| 125 | { | |
| 126 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 127 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 128 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 129 | _OStream::scientific); | |
| 130 | return __os << __x.lambda(); | |
| 131 | } | |
| 132 | ||
| 133 | template <class _CharT, class _Traits, class _RealType> | |
| 134 | basic_istream<_CharT, _Traits>& | |
| 135 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 136 | exponential_distribution<_RealType>& __x) | |
| 137 | { | |
| 138 | typedef exponential_distribution<_RealType> _Eng; | |
| 139 | typedef typename _Eng::result_type result_type; | |
| 140 | typedef typename _Eng::param_type param_type; | |
| 141 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 142 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 143 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 144 | result_type __lambda; | |
| 145 | __is >> __lambda; | |
| 146 | if (!__is.fail()) | |
| 147 | __x.param(param_type(__lambda)); | |
| 148 | return __is; | |
| 149 | } | |
| 150 | ||
| 151 | _LIBCPP_END_NAMESPACE_STD | |
| 152 | ||
| 153 | _LIBCPP_POP_MACROS | |
| 154 | ||
| 155 | #endif // _LIBCPP___RANDOM_EXPONENTIAL_DISTRIBUTION_H |
lib/libcxx/include/__random/extreme_value_distribution.h created+161| ... | ... | @@ -0,0 +1,161 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_EXTREME_VALUE_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/uniform_real_distribution.h> | |
| 14 | #include <cmath> | |
| 15 | #include <iosfwd> | |
| 16 | #include <limits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | template<class _RealType = double> | |
| 28 | class _LIBCPP_TEMPLATE_VIS extreme_value_distribution | |
| 29 | { | |
| 30 | public: | |
| 31 | // types | |
| 32 | typedef _RealType result_type; | |
| 33 | ||
| 34 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 35 | { | |
| 36 | result_type __a_; | |
| 37 | result_type __b_; | |
| 38 | public: | |
| 39 | typedef extreme_value_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __a = 0, result_type __b = 1) | |
| 43 | : __a_(__a), __b_(__b) {} | |
| 44 | ||
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | result_type a() const {return __a_;} | |
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | result_type b() const {return __b_;} | |
| 49 | ||
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator==(const param_type& __x, const param_type& __y) | |
| 52 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 53 | friend _LIBCPP_INLINE_VISIBILITY | |
| 54 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 55 | {return !(__x == __y);} | |
| 56 | }; | |
| 57 | ||
| 58 | private: | |
| 59 | param_type __p_; | |
| 60 | ||
| 61 | public: | |
| 62 | // constructor and reset functions | |
| 63 | #ifndef _LIBCPP_CXX03_LANG | |
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | extreme_value_distribution() : extreme_value_distribution(0) {} | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | explicit extreme_value_distribution(result_type __a, result_type __b = 1) | |
| 68 | : __p_(param_type(__a, __b)) {} | |
| 69 | #else | |
| 70 | _LIBCPP_INLINE_VISIBILITY | |
| 71 | explicit extreme_value_distribution(result_type __a = 0, | |
| 72 | result_type __b = 1) | |
| 73 | : __p_(param_type(__a, __b)) {} | |
| 74 | #endif | |
| 75 | _LIBCPP_INLINE_VISIBILITY | |
| 76 | explicit extreme_value_distribution(const param_type& __p) | |
| 77 | : __p_(__p) {} | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | void reset() {} | |
| 80 | ||
| 81 | // generating functions | |
| 82 | template<class _URNG> | |
| 83 | _LIBCPP_INLINE_VISIBILITY | |
| 84 | result_type operator()(_URNG& __g) | |
| 85 | {return (*this)(__g, __p_);} | |
| 86 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 87 | ||
| 88 | // property functions | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | result_type a() const {return __p_.a();} | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | result_type b() const {return __p_.b();} | |
| 93 | ||
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | param_type param() const {return __p_;} | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | void param(const param_type& __p) {__p_ = __p;} | |
| 98 | ||
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 103 | ||
| 104 | friend _LIBCPP_INLINE_VISIBILITY | |
| 105 | bool operator==(const extreme_value_distribution& __x, | |
| 106 | const extreme_value_distribution& __y) | |
| 107 | {return __x.__p_ == __y.__p_;} | |
| 108 | friend _LIBCPP_INLINE_VISIBILITY | |
| 109 | bool operator!=(const extreme_value_distribution& __x, | |
| 110 | const extreme_value_distribution& __y) | |
| 111 | {return !(__x == __y);} | |
| 112 | }; | |
| 113 | ||
| 114 | template<class _RealType> | |
| 115 | template<class _URNG> | |
| 116 | _RealType | |
| 117 | extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 118 | { | |
| 119 | return __p.a() - __p.b() * | |
| 120 | _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g))); | |
| 121 | } | |
| 122 | ||
| 123 | template <class _CharT, class _Traits, class _RT> | |
| 124 | basic_ostream<_CharT, _Traits>& | |
| 125 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 126 | const extreme_value_distribution<_RT>& __x) | |
| 127 | { | |
| 128 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 129 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 130 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 131 | _OStream::scientific); | |
| 132 | _CharT __sp = __os.widen(' '); | |
| 133 | __os.fill(__sp); | |
| 134 | __os << __x.a() << __sp << __x.b(); | |
| 135 | return __os; | |
| 136 | } | |
| 137 | ||
| 138 | template <class _CharT, class _Traits, class _RT> | |
| 139 | basic_istream<_CharT, _Traits>& | |
| 140 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 141 | extreme_value_distribution<_RT>& __x) | |
| 142 | { | |
| 143 | typedef extreme_value_distribution<_RT> _Eng; | |
| 144 | typedef typename _Eng::result_type result_type; | |
| 145 | typedef typename _Eng::param_type param_type; | |
| 146 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 147 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 148 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 149 | result_type __a; | |
| 150 | result_type __b; | |
| 151 | __is >> __a >> __b; | |
| 152 | if (!__is.fail()) | |
| 153 | __x.param(param_type(__a, __b)); | |
| 154 | return __is; | |
| 155 | } | |
| 156 | ||
| 157 | _LIBCPP_END_NAMESPACE_STD | |
| 158 | ||
| 159 | _LIBCPP_POP_MACROS | |
| 160 | ||
| 161 | #endif // _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H |
lib/libcxx/include/__random/fisher_f_distribution.h created+160| ... | ... | @@ -0,0 +1,160 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___RANDOM_FISHER_F_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_FISHER_F_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/gamma_distribution.h> | |
| 14 | #include <iosfwd> | |
| 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 | template<class _RealType = double> | |
| 27 | class _LIBCPP_TEMPLATE_VIS fisher_f_distribution | |
| 28 | { | |
| 29 | public: | |
| 30 | // types | |
| 31 | typedef _RealType result_type; | |
| 32 | ||
| 33 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 34 | { | |
| 35 | result_type __m_; | |
| 36 | result_type __n_; | |
| 37 | public: | |
| 38 | typedef fisher_f_distribution distribution_type; | |
| 39 | ||
| 40 | _LIBCPP_INLINE_VISIBILITY | |
| 41 | explicit param_type(result_type __m = 1, result_type __n = 1) | |
| 42 | : __m_(__m), __n_(__n) {} | |
| 43 | ||
| 44 | _LIBCPP_INLINE_VISIBILITY | |
| 45 | result_type m() const {return __m_;} | |
| 46 | _LIBCPP_INLINE_VISIBILITY | |
| 47 | result_type n() const {return __n_;} | |
| 48 | ||
| 49 | friend _LIBCPP_INLINE_VISIBILITY | |
| 50 | bool operator==(const param_type& __x, const param_type& __y) | |
| 51 | {return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;} | |
| 52 | friend _LIBCPP_INLINE_VISIBILITY | |
| 53 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 54 | {return !(__x == __y);} | |
| 55 | }; | |
| 56 | ||
| 57 | private: | |
| 58 | param_type __p_; | |
| 59 | ||
| 60 | public: | |
| 61 | // constructor and reset functions | |
| 62 | #ifndef _LIBCPP_CXX03_LANG | |
| 63 | _LIBCPP_INLINE_VISIBILITY | |
| 64 | fisher_f_distribution() : fisher_f_distribution(1) {} | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | explicit fisher_f_distribution(result_type __m, result_type __n = 1) | |
| 67 | : __p_(param_type(__m, __n)) {} | |
| 68 | #else | |
| 69 | _LIBCPP_INLINE_VISIBILITY | |
| 70 | explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1) | |
| 71 | : __p_(param_type(__m, __n)) {} | |
| 72 | #endif | |
| 73 | _LIBCPP_INLINE_VISIBILITY | |
| 74 | explicit fisher_f_distribution(const param_type& __p) | |
| 75 | : __p_(__p) {} | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | void reset() {} | |
| 78 | ||
| 79 | // generating functions | |
| 80 | template<class _URNG> | |
| 81 | _LIBCPP_INLINE_VISIBILITY | |
| 82 | result_type operator()(_URNG& __g) | |
| 83 | {return (*this)(__g, __p_);} | |
| 84 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 85 | ||
| 86 | // property functions | |
| 87 | _LIBCPP_INLINE_VISIBILITY | |
| 88 | result_type m() const {return __p_.m();} | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | result_type n() const {return __p_.n();} | |
| 91 | ||
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | param_type param() const {return __p_;} | |
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | void param(const param_type& __p) {__p_ = __p;} | |
| 96 | ||
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | result_type min() const {return 0;} | |
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 101 | ||
| 102 | friend _LIBCPP_INLINE_VISIBILITY | |
| 103 | bool operator==(const fisher_f_distribution& __x, | |
| 104 | const fisher_f_distribution& __y) | |
| 105 | {return __x.__p_ == __y.__p_;} | |
| 106 | friend _LIBCPP_INLINE_VISIBILITY | |
| 107 | bool operator!=(const fisher_f_distribution& __x, | |
| 108 | const fisher_f_distribution& __y) | |
| 109 | {return !(__x == __y);} | |
| 110 | }; | |
| 111 | ||
| 112 | template <class _RealType> | |
| 113 | template<class _URNG> | |
| 114 | _RealType | |
| 115 | fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 116 | { | |
| 117 | gamma_distribution<result_type> __gdm(__p.m() * result_type(.5)); | |
| 118 | gamma_distribution<result_type> __gdn(__p.n() * result_type(.5)); | |
| 119 | return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g)); | |
| 120 | } | |
| 121 | ||
| 122 | template <class _CharT, class _Traits, class _RT> | |
| 123 | basic_ostream<_CharT, _Traits>& | |
| 124 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 125 | const fisher_f_distribution<_RT>& __x) | |
| 126 | { | |
| 127 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 128 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 129 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 130 | _OStream::scientific); | |
| 131 | _CharT __sp = __os.widen(' '); | |
| 132 | __os.fill(__sp); | |
| 133 | __os << __x.m() << __sp << __x.n(); | |
| 134 | return __os; | |
| 135 | } | |
| 136 | ||
| 137 | template <class _CharT, class _Traits, class _RT> | |
| 138 | basic_istream<_CharT, _Traits>& | |
| 139 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 140 | fisher_f_distribution<_RT>& __x) | |
| 141 | { | |
| 142 | typedef fisher_f_distribution<_RT> _Eng; | |
| 143 | typedef typename _Eng::result_type result_type; | |
| 144 | typedef typename _Eng::param_type param_type; | |
| 145 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 146 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 147 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 148 | result_type __m; | |
| 149 | result_type __n; | |
| 150 | __is >> __m >> __n; | |
| 151 | if (!__is.fail()) | |
| 152 | __x.param(param_type(__m, __n)); | |
| 153 | return __is; | |
| 154 | } | |
| 155 | ||
| 156 | _LIBCPP_END_NAMESPACE_STD | |
| 157 | ||
| 158 | _LIBCPP_POP_MACROS | |
| 159 | ||
| 160 | #endif // _LIBCPP___RANDOM_FISHER_F_DISTRIBUTION_H |
lib/libcxx/include/__random/gamma_distribution.h created+213| ... | ... | @@ -0,0 +1,213 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_GAMMA_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_GAMMA_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/exponential_distribution.h> | |
| 14 | #include <__random/uniform_real_distribution.h> | |
| 15 | #include <cmath> | |
| 16 | #include <iosfwd> | |
| 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 | template<class _RealType = double> | |
| 29 | class _LIBCPP_TEMPLATE_VIS gamma_distribution | |
| 30 | { | |
| 31 | public: | |
| 32 | // types | |
| 33 | typedef _RealType result_type; | |
| 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 36 | { | |
| 37 | result_type __alpha_; | |
| 38 | result_type __beta_; | |
| 39 | public: | |
| 40 | typedef gamma_distribution distribution_type; | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | explicit param_type(result_type __alpha = 1, result_type __beta = 1) | |
| 44 | : __alpha_(__alpha), __beta_(__beta) {} | |
| 45 | ||
| 46 | _LIBCPP_INLINE_VISIBILITY | |
| 47 | result_type alpha() const {return __alpha_;} | |
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | result_type beta() const {return __beta_;} | |
| 50 | ||
| 51 | friend _LIBCPP_INLINE_VISIBILITY | |
| 52 | bool operator==(const param_type& __x, const param_type& __y) | |
| 53 | {return __x.__alpha_ == __y.__alpha_ && __x.__beta_ == __y.__beta_;} | |
| 54 | friend _LIBCPP_INLINE_VISIBILITY | |
| 55 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 56 | {return !(__x == __y);} | |
| 57 | }; | |
| 58 | ||
| 59 | private: | |
| 60 | param_type __p_; | |
| 61 | ||
| 62 | public: | |
| 63 | // constructors and reset functions | |
| 64 | #ifndef _LIBCPP_CXX03_LANG | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | gamma_distribution() : gamma_distribution(1) {} | |
| 67 | _LIBCPP_INLINE_VISIBILITY | |
| 68 | explicit gamma_distribution(result_type __alpha, result_type __beta = 1) | |
| 69 | : __p_(param_type(__alpha, __beta)) {} | |
| 70 | #else | |
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | explicit gamma_distribution(result_type __alpha = 1, | |
| 73 | result_type __beta = 1) | |
| 74 | : __p_(param_type(__alpha, __beta)) {} | |
| 75 | #endif | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | explicit gamma_distribution(const param_type& __p) | |
| 78 | : __p_(__p) {} | |
| 79 | _LIBCPP_INLINE_VISIBILITY | |
| 80 | void reset() {} | |
| 81 | ||
| 82 | // generating functions | |
| 83 | template<class _URNG> | |
| 84 | _LIBCPP_INLINE_VISIBILITY | |
| 85 | result_type operator()(_URNG& __g) | |
| 86 | {return (*this)(__g, __p_);} | |
| 87 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 88 | ||
| 89 | // property functions | |
| 90 | _LIBCPP_INLINE_VISIBILITY | |
| 91 | result_type alpha() const {return __p_.alpha();} | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | result_type beta() const {return __p_.beta();} | |
| 94 | ||
| 95 | _LIBCPP_INLINE_VISIBILITY | |
| 96 | param_type param() const {return __p_;} | |
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | void param(const param_type& __p) {__p_ = __p;} | |
| 99 | ||
| 100 | _LIBCPP_INLINE_VISIBILITY | |
| 101 | result_type min() const {return 0;} | |
| 102 | _LIBCPP_INLINE_VISIBILITY | |
| 103 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 104 | ||
| 105 | friend _LIBCPP_INLINE_VISIBILITY | |
| 106 | bool operator==(const gamma_distribution& __x, | |
| 107 | const gamma_distribution& __y) | |
| 108 | {return __x.__p_ == __y.__p_;} | |
| 109 | friend _LIBCPP_INLINE_VISIBILITY | |
| 110 | bool operator!=(const gamma_distribution& __x, | |
| 111 | const gamma_distribution& __y) | |
| 112 | {return !(__x == __y);} | |
| 113 | }; | |
| 114 | ||
| 115 | template <class _RealType> | |
| 116 | template<class _URNG> | |
| 117 | _RealType | |
| 118 | gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 119 | { | |
| 120 | result_type __a = __p.alpha(); | |
| 121 | uniform_real_distribution<result_type> __gen(0, 1); | |
| 122 | exponential_distribution<result_type> __egen; | |
| 123 | result_type __x; | |
| 124 | if (__a == 1) | |
| 125 | __x = __egen(__g); | |
| 126 | else if (__a > 1) | |
| 127 | { | |
| 128 | const result_type __b = __a - 1; | |
| 129 | const result_type __c = 3 * __a - result_type(0.75); | |
| 130 | while (true) | |
| 131 | { | |
| 132 | const result_type __u = __gen(__g); | |
| 133 | const result_type __v = __gen(__g); | |
| 134 | const result_type __w = __u * (1 - __u); | |
| 135 | if (__w != 0) | |
| 136 | { | |
| 137 | const result_type __y = _VSTD::sqrt(__c / __w) * | |
| 138 | (__u - result_type(0.5)); | |
| 139 | __x = __b + __y; | |
| 140 | if (__x >= 0) | |
| 141 | { | |
| 142 | const result_type __z = 64 * __w * __w * __w * __v * __v; | |
| 143 | if (__z <= 1 - 2 * __y * __y / __x) | |
| 144 | break; | |
| 145 | if (_VSTD::log(__z) <= 2 * (__b * _VSTD::log(__x / __b) - __y)) | |
| 146 | break; | |
| 147 | } | |
| 148 | } | |
| 149 | } | |
| 150 | } | |
| 151 | else // __a < 1 | |
| 152 | { | |
| 153 | while (true) | |
| 154 | { | |
| 155 | const result_type __u = __gen(__g); | |
| 156 | const result_type __es = __egen(__g); | |
| 157 | if (__u <= 1 - __a) | |
| 158 | { | |
| 159 | __x = _VSTD::pow(__u, 1 / __a); | |
| 160 | if (__x <= __es) | |
| 161 | break; | |
| 162 | } | |
| 163 | else | |
| 164 | { | |
| 165 | const result_type __e = -_VSTD::log((1-__u)/__a); | |
| 166 | __x = _VSTD::pow(1 - __a + __a * __e, 1 / __a); | |
| 167 | if (__x <= __e + __es) | |
| 168 | break; | |
| 169 | } | |
| 170 | } | |
| 171 | } | |
| 172 | return __x * __p.beta(); | |
| 173 | } | |
| 174 | ||
| 175 | template <class _CharT, class _Traits, class _RT> | |
| 176 | basic_ostream<_CharT, _Traits>& | |
| 177 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 178 | const gamma_distribution<_RT>& __x) | |
| 179 | { | |
| 180 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 181 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 182 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 183 | _OStream::scientific); | |
| 184 | _CharT __sp = __os.widen(' '); | |
| 185 | __os.fill(__sp); | |
| 186 | __os << __x.alpha() << __sp << __x.beta(); | |
| 187 | return __os; | |
| 188 | } | |
| 189 | ||
| 190 | template <class _CharT, class _Traits, class _RT> | |
| 191 | basic_istream<_CharT, _Traits>& | |
| 192 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 193 | gamma_distribution<_RT>& __x) | |
| 194 | { | |
| 195 | typedef gamma_distribution<_RT> _Eng; | |
| 196 | typedef typename _Eng::result_type result_type; | |
| 197 | typedef typename _Eng::param_type param_type; | |
| 198 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 199 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 200 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 201 | result_type __alpha; | |
| 202 | result_type __beta; | |
| 203 | __is >> __alpha >> __beta; | |
| 204 | if (!__is.fail()) | |
| 205 | __x.param(param_type(__alpha, __beta)); | |
| 206 | return __is; | |
| 207 | } | |
| 208 | ||
| 209 | _LIBCPP_END_NAMESPACE_STD | |
| 210 | ||
| 211 | _LIBCPP_POP_MACROS | |
| 212 | ||
| 213 | #endif // _LIBCPP___RANDOM_GAMMA_DISTRIBUTION_H |
lib/libcxx/include/__random/generate_canonical.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___RANDOM_GENERATE_CANONICAL_H | |
| 10 | #define _LIBCPP___RANDOM_GENERATE_CANONICAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/log2.h> | |
| 14 | #include <cstdint> | |
| 15 | #include <initializer_list> | |
| 16 | #include <limits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | // generate_canonical | |
| 28 | ||
| 29 | template<class _RealType, size_t __bits, class _URNG> | |
| 30 | _RealType | |
| 31 | generate_canonical(_URNG& __g) | |
| 32 | { | |
| 33 | const size_t _Dt = numeric_limits<_RealType>::digits; | |
| 34 | const size_t __b = _Dt < __bits ? _Dt : __bits; | |
| 35 | #ifdef _LIBCPP_CXX03_LANG | |
| 36 | const size_t __logR = __log2<uint64_t, _URNG::_Max - _URNG::_Min + uint64_t(1)>::value; | |
| 37 | #else | |
| 38 | const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value; | |
| 39 | #endif | |
| 40 | const size_t __k = __b / __logR + (__b % __logR != 0) + (__b == 0); | |
| 41 | const _RealType _Rp = static_cast<_RealType>(_URNG::max() - _URNG::min()) + _RealType(1); | |
| 42 | _RealType __base = _Rp; | |
| 43 | _RealType _Sp = __g() - _URNG::min(); | |
| 44 | for (size_t __i = 1; __i < __k; ++__i, __base *= _Rp) | |
| 45 | _Sp += (__g() - _URNG::min()) * __base; | |
| 46 | return _Sp / __base; | |
| 47 | } | |
| 48 | ||
| 49 | _LIBCPP_END_NAMESPACE_STD | |
| 50 | ||
| 51 | _LIBCPP_POP_MACROS | |
| 52 | ||
| 53 | #endif // _LIBCPP___RANDOM_GENERATE_CANONICAL_H |
lib/libcxx/include/__random/geometric_distribution.h created+141| ... | ... | @@ -0,0 +1,141 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_GEOMETRIC_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/negative_binomial_distribution.h> | |
| 14 | #include <iosfwd> | |
| 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 | template<class _IntType = int> | |
| 27 | class _LIBCPP_TEMPLATE_VIS geometric_distribution | |
| 28 | { | |
| 29 | public: | |
| 30 | // types | |
| 31 | typedef _IntType result_type; | |
| 32 | ||
| 33 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 34 | { | |
| 35 | double __p_; | |
| 36 | public: | |
| 37 | typedef geometric_distribution distribution_type; | |
| 38 | ||
| 39 | _LIBCPP_INLINE_VISIBILITY | |
| 40 | explicit param_type(double __p = 0.5) : __p_(__p) {} | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | double p() const {return __p_;} | |
| 44 | ||
| 45 | friend _LIBCPP_INLINE_VISIBILITY | |
| 46 | bool operator==(const param_type& __x, const param_type& __y) | |
| 47 | {return __x.__p_ == __y.__p_;} | |
| 48 | friend _LIBCPP_INLINE_VISIBILITY | |
| 49 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 50 | {return !(__x == __y);} | |
| 51 | }; | |
| 52 | ||
| 53 | private: | |
| 54 | param_type __p_; | |
| 55 | ||
| 56 | public: | |
| 57 | // constructors and reset functions | |
| 58 | #ifndef _LIBCPP_CXX03_LANG | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | geometric_distribution() : geometric_distribution(0.5) {} | |
| 61 | _LIBCPP_INLINE_VISIBILITY | |
| 62 | explicit geometric_distribution(double __p) | |
| 63 | : __p_(__p) {} | |
| 64 | #else | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | explicit geometric_distribution(double __p = 0.5) | |
| 67 | : __p_(__p) {} | |
| 68 | #endif | |
| 69 | _LIBCPP_INLINE_VISIBILITY | |
| 70 | explicit geometric_distribution(const param_type& __p) : __p_(__p) {} | |
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | void reset() {} | |
| 73 | ||
| 74 | // generating functions | |
| 75 | template<class _URNG> | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | result_type operator()(_URNG& __g) | |
| 78 | {return (*this)(__g, __p_);} | |
| 79 | template<class _URNG> | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 82 | {return negative_binomial_distribution<result_type>(1, __p.p())(__g);} | |
| 83 | ||
| 84 | // property functions | |
| 85 | _LIBCPP_INLINE_VISIBILITY | |
| 86 | double p() const {return __p_.p();} | |
| 87 | ||
| 88 | _LIBCPP_INLINE_VISIBILITY | |
| 89 | param_type param() const {return __p_;} | |
| 90 | _LIBCPP_INLINE_VISIBILITY | |
| 91 | void param(const param_type& __p) {__p_ = __p;} | |
| 92 | ||
| 93 | _LIBCPP_INLINE_VISIBILITY | |
| 94 | result_type min() const {return 0;} | |
| 95 | _LIBCPP_INLINE_VISIBILITY | |
| 96 | result_type max() const {return numeric_limits<result_type>::max();} | |
| 97 | ||
| 98 | friend _LIBCPP_INLINE_VISIBILITY | |
| 99 | bool operator==(const geometric_distribution& __x, | |
| 100 | const geometric_distribution& __y) | |
| 101 | {return __x.__p_ == __y.__p_;} | |
| 102 | friend _LIBCPP_INLINE_VISIBILITY | |
| 103 | bool operator!=(const geometric_distribution& __x, | |
| 104 | const geometric_distribution& __y) | |
| 105 | {return !(__x == __y);} | |
| 106 | }; | |
| 107 | ||
| 108 | template <class _CharT, class _Traits, class _IntType> | |
| 109 | basic_ostream<_CharT, _Traits>& | |
| 110 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 111 | const geometric_distribution<_IntType>& __x) | |
| 112 | { | |
| 113 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 114 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 115 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 116 | _OStream::scientific); | |
| 117 | return __os << __x.p(); | |
| 118 | } | |
| 119 | ||
| 120 | template <class _CharT, class _Traits, class _IntType> | |
| 121 | basic_istream<_CharT, _Traits>& | |
| 122 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 123 | geometric_distribution<_IntType>& __x) | |
| 124 | { | |
| 125 | typedef geometric_distribution<_IntType> _Eng; | |
| 126 | typedef typename _Eng::param_type param_type; | |
| 127 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 128 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 129 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 130 | double __p; | |
| 131 | __is >> __p; | |
| 132 | if (!__is.fail()) | |
| 133 | __x.param(param_type(__p)); | |
| 134 | return __is; | |
| 135 | } | |
| 136 | ||
| 137 | _LIBCPP_END_NAMESPACE_STD | |
| 138 | ||
| 139 | _LIBCPP_POP_MACROS | |
| 140 | ||
| 141 | #endif // _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H |
lib/libcxx/include/__random/independent_bits_engine.h created+271| ... | ... | @@ -0,0 +1,271 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_INDEPENDENT_BITS_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/is_seed_sequence.h> | |
| 14 | #include <__random/log2.h> | |
| 15 | #include <__utility/move.h> | |
| 16 | #include <iosfwd> | |
| 17 | #include <limits> | |
| 18 | #include <type_traits> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | template<class _Engine, size_t __w, class _UIntType> | |
| 30 | class _LIBCPP_TEMPLATE_VIS independent_bits_engine | |
| 31 | { | |
| 32 | template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp> | |
| 33 | class __get_n | |
| 34 | { | |
| 35 | static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits; | |
| 36 | static _LIBCPP_CONSTEXPR const size_t _Np = _Wp / _Mp + (_Wp % _Mp != 0); | |
| 37 | static _LIBCPP_CONSTEXPR const size_t _W0 = _Wp / _Np; | |
| 38 | static _LIBCPP_CONSTEXPR const _UInt _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0; | |
| 39 | public: | |
| 40 | static _LIBCPP_CONSTEXPR const size_t value = _R0 - _Y0 > _Y0 / _Np ? _Np + 1 : _Np; | |
| 41 | }; | |
| 42 | public: | |
| 43 | // types | |
| 44 | typedef _UIntType result_type; | |
| 45 | ||
| 46 | private: | |
| 47 | _Engine __e_; | |
| 48 | ||
| 49 | static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; | |
| 50 | static_assert( 0 < __w, "independent_bits_engine invalid parameters"); | |
| 51 | static_assert(__w <= _Dt, "independent_bits_engine invalid parameters"); | |
| 52 | ||
| 53 | typedef typename _Engine::result_type _Engine_result_type; | |
| 54 | typedef typename conditional | |
| 55 | < | |
| 56 | sizeof(_Engine_result_type) <= sizeof(result_type), | |
| 57 | result_type, | |
| 58 | _Engine_result_type | |
| 59 | >::type _Working_result_type; | |
| 60 | #ifdef _LIBCPP_CXX03_LANG | |
| 61 | static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min | |
| 62 | + _Working_result_type(1); | |
| 63 | #else | |
| 64 | static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() | |
| 65 | + _Working_result_type(1); | |
| 66 | #endif | |
| 67 | static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; | |
| 68 | static _LIBCPP_CONSTEXPR const size_t __n = __get_n<_Working_result_type, _Rp, __w, __m>::value; | |
| 69 | static _LIBCPP_CONSTEXPR const size_t __w0 = __w / __n; | |
| 70 | static _LIBCPP_CONSTEXPR const size_t __n0 = __n - __w % __n; | |
| 71 | static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; | |
| 72 | static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; | |
| 73 | static _LIBCPP_CONSTEXPR const _Working_result_type __y0 = __w0 >= _WDt ? 0 : | |
| 74 | (_Rp >> __w0) << __w0; | |
| 75 | static _LIBCPP_CONSTEXPR const _Working_result_type __y1 = __w0 >= _WDt - 1 ? 0 : | |
| 76 | (_Rp >> (__w0+1)) << (__w0+1); | |
| 77 | static _LIBCPP_CONSTEXPR const _Engine_result_type __mask0 = __w0 > 0 ? | |
| 78 | _Engine_result_type(~0) >> (_EDt - __w0) : | |
| 79 | _Engine_result_type(0); | |
| 80 | static _LIBCPP_CONSTEXPR const _Engine_result_type __mask1 = __w0 < _EDt - 1 ? | |
| 81 | _Engine_result_type(~0) >> (_EDt - (__w0 + 1)) : | |
| 82 | _Engine_result_type(~0); | |
| 83 | public: | |
| 84 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 85 | static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : | |
| 86 | (result_type(1) << __w) - result_type(1); | |
| 87 | static_assert(_Min < _Max, "independent_bits_engine invalid parameters"); | |
| 88 | ||
| 89 | // engine characteristics | |
| 90 | _LIBCPP_INLINE_VISIBILITY | |
| 91 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 94 | ||
| 95 | // constructors and seeding functions | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | independent_bits_engine() {} | |
| 98 | _LIBCPP_INLINE_VISIBILITY | |
| 99 | explicit independent_bits_engine(const _Engine& __e) | |
| 100 | : __e_(__e) {} | |
| 101 | #ifndef _LIBCPP_CXX03_LANG | |
| 102 | _LIBCPP_INLINE_VISIBILITY | |
| 103 | explicit independent_bits_engine(_Engine&& __e) | |
| 104 | : __e_(_VSTD::move(__e)) {} | |
| 105 | #endif // _LIBCPP_CXX03_LANG | |
| 106 | _LIBCPP_INLINE_VISIBILITY | |
| 107 | explicit independent_bits_engine(result_type __sd) : __e_(__sd) {} | |
| 108 | template<class _Sseq> | |
| 109 | _LIBCPP_INLINE_VISIBILITY | |
| 110 | explicit independent_bits_engine(_Sseq& __q, | |
| 111 | typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value && | |
| 112 | !is_convertible<_Sseq, _Engine>::value>::type* = 0) | |
| 113 | : __e_(__q) {} | |
| 114 | _LIBCPP_INLINE_VISIBILITY | |
| 115 | void seed() {__e_.seed();} | |
| 116 | _LIBCPP_INLINE_VISIBILITY | |
| 117 | void seed(result_type __sd) {__e_.seed(__sd);} | |
| 118 | template<class _Sseq> | |
| 119 | _LIBCPP_INLINE_VISIBILITY | |
| 120 | typename enable_if | |
| 121 | < | |
| 122 | __is_seed_sequence<_Sseq, independent_bits_engine>::value, | |
| 123 | void | |
| 124 | >::type | |
| 125 | seed(_Sseq& __q) {__e_.seed(__q);} | |
| 126 | ||
| 127 | // generating functions | |
| 128 | _LIBCPP_INLINE_VISIBILITY | |
| 129 | result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());} | |
| 130 | _LIBCPP_INLINE_VISIBILITY | |
| 131 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 132 | ||
| 133 | // property functions | |
| 134 | _LIBCPP_INLINE_VISIBILITY | |
| 135 | const _Engine& base() const _NOEXCEPT {return __e_;} | |
| 136 | ||
| 137 | template<class _Eng, size_t _Wp, class _UInt> | |
| 138 | friend | |
| 139 | bool | |
| 140 | operator==( | |
| 141 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 142 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y); | |
| 143 | ||
| 144 | template<class _Eng, size_t _Wp, class _UInt> | |
| 145 | friend | |
| 146 | bool | |
| 147 | operator!=( | |
| 148 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 149 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y); | |
| 150 | ||
| 151 | template <class _CharT, class _Traits, | |
| 152 | class _Eng, size_t _Wp, class _UInt> | |
| 153 | friend | |
| 154 | basic_ostream<_CharT, _Traits>& | |
| 155 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 156 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x); | |
| 157 | ||
| 158 | template <class _CharT, class _Traits, | |
| 159 | class _Eng, size_t _Wp, class _UInt> | |
| 160 | friend | |
| 161 | basic_istream<_CharT, _Traits>& | |
| 162 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 163 | independent_bits_engine<_Eng, _Wp, _UInt>& __x); | |
| 164 | ||
| 165 | private: | |
| 166 | _LIBCPP_INLINE_VISIBILITY | |
| 167 | result_type __eval(false_type); | |
| 168 | result_type __eval(true_type); | |
| 169 | ||
| 170 | template <size_t __count> | |
| 171 | _LIBCPP_INLINE_VISIBILITY | |
| 172 | static | |
| 173 | typename enable_if | |
| 174 | < | |
| 175 | __count < _Dt, | |
| 176 | result_type | |
| 177 | >::type | |
| 178 | __lshift(result_type __x) {return __x << __count;} | |
| 179 | ||
| 180 | template <size_t __count> | |
| 181 | _LIBCPP_INLINE_VISIBILITY | |
| 182 | static | |
| 183 | typename enable_if | |
| 184 | < | |
| 185 | (__count >= _Dt), | |
| 186 | result_type | |
| 187 | >::type | |
| 188 | __lshift(result_type) {return result_type(0);} | |
| 189 | }; | |
| 190 | ||
| 191 | template<class _Engine, size_t __w, class _UIntType> | |
| 192 | inline | |
| 193 | _UIntType | |
| 194 | independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) | |
| 195 | { | |
| 196 | return static_cast<result_type>(__e_() & __mask0); | |
| 197 | } | |
| 198 | ||
| 199 | template<class _Engine, size_t __w, class _UIntType> | |
| 200 | _UIntType | |
| 201 | independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) | |
| 202 | { | |
| 203 | result_type _Sp = 0; | |
| 204 | for (size_t __k = 0; __k < __n0; ++__k) | |
| 205 | { | |
| 206 | _Engine_result_type __u; | |
| 207 | do | |
| 208 | { | |
| 209 | __u = __e_() - _Engine::min(); | |
| 210 | } while (__u >= __y0); | |
| 211 | _Sp = static_cast<result_type>(__lshift<__w0>(_Sp) + (__u & __mask0)); | |
| 212 | } | |
| 213 | for (size_t __k = __n0; __k < __n; ++__k) | |
| 214 | { | |
| 215 | _Engine_result_type __u; | |
| 216 | do | |
| 217 | { | |
| 218 | __u = __e_() - _Engine::min(); | |
| 219 | } while (__u >= __y1); | |
| 220 | _Sp = static_cast<result_type>(__lshift<__w0+1>(_Sp) + (__u & __mask1)); | |
| 221 | } | |
| 222 | return _Sp; | |
| 223 | } | |
| 224 | ||
| 225 | template<class _Eng, size_t _Wp, class _UInt> | |
| 226 | inline _LIBCPP_INLINE_VISIBILITY | |
| 227 | bool | |
| 228 | operator==( | |
| 229 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 230 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y) | |
| 231 | { | |
| 232 | return __x.base() == __y.base(); | |
| 233 | } | |
| 234 | ||
| 235 | template<class _Eng, size_t _Wp, class _UInt> | |
| 236 | inline _LIBCPP_INLINE_VISIBILITY | |
| 237 | bool | |
| 238 | operator!=( | |
| 239 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 240 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y) | |
| 241 | { | |
| 242 | return !(__x == __y); | |
| 243 | } | |
| 244 | ||
| 245 | template <class _CharT, class _Traits, | |
| 246 | class _Eng, size_t _Wp, class _UInt> | |
| 247 | basic_ostream<_CharT, _Traits>& | |
| 248 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 249 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x) | |
| 250 | { | |
| 251 | return __os << __x.base(); | |
| 252 | } | |
| 253 | ||
| 254 | template <class _CharT, class _Traits, | |
| 255 | class _Eng, size_t _Wp, class _UInt> | |
| 256 | basic_istream<_CharT, _Traits>& | |
| 257 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 258 | independent_bits_engine<_Eng, _Wp, _UInt>& __x) | |
| 259 | { | |
| 260 | _Eng __e; | |
| 261 | __is >> __e; | |
| 262 | if (!__is.fail()) | |
| 263 | __x.__e_ = __e; | |
| 264 | return __is; | |
| 265 | } | |
| 266 | ||
| 267 | _LIBCPP_END_NAMESPACE_STD | |
| 268 | ||
| 269 | _LIBCPP_POP_MACROS | |
| 270 | ||
| 271 | #endif // _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H |
lib/libcxx/include/__random/is_seed_sequence.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___RANDOM_IS_SEED_SEQUENCE_H | |
| 10 | #define _LIBCPP___RANDOM_IS_SEED_SEQUENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <type_traits> | |
| 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 | template <class _Sseq, class _Engine> | |
| 22 | struct __is_seed_sequence | |
| 23 | { | |
| 24 | static _LIBCPP_CONSTEXPR const bool value = | |
| 25 | !is_convertible<_Sseq, typename _Engine::result_type>::value && | |
| 26 | !is_same<typename remove_cv<_Sseq>::type, _Engine>::value; | |
| 27 | }; | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___RANDOM_IS_SEED_SEQUENCE_H |
lib/libcxx/include/__random/knuth_b.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___RANDOM_KNUTH_B_H | |
| 10 | #define _LIBCPP___RANDOM_KNUTH_B_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/linear_congruential_engine.h> | |
| 14 | #include <__random/shuffle_order_engine.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 | typedef shuffle_order_engine<minstd_rand0, 256> knuth_b; | |
| 23 | ||
| 24 | _LIBCPP_END_NAMESPACE_STD | |
| 25 | ||
| 26 | #endif // _LIBCPP___RANDOM_KNUTH_B_H |
lib/libcxx/include/__random/linear_congruential_engine.h created+398| ... | ... | @@ -0,0 +1,398 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_LINEAR_CONGRUENTIAL_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_LINEAR_CONGRUENTIAL_ENGINE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/is_seed_sequence.h> | |
| 14 | #include <cstdint> | |
| 15 | #include <iosfwd> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | template <unsigned long long __a, unsigned long long __c, | |
| 28 | unsigned long long __m, unsigned long long _Mp, | |
| 29 | bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a), | |
| 30 | bool _OverflowOK = ((__m | (__m-1)) > __m), // m = 2^n | |
| 31 | bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q | |
| 32 | struct __lce_alg_picker | |
| 33 | { | |
| 34 | static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK, | |
| 35 | "The current values of a, c, and m cannot generate a number " | |
| 36 | "within bounds of linear_congruential_engine."); | |
| 37 | ||
| 38 | static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow && | |
| 39 | !_OverflowOK && | |
| 40 | _SchrageOK; | |
| 41 | }; | |
| 42 | ||
| 43 | template <unsigned long long __a, unsigned long long __c, | |
| 44 | unsigned long long __m, unsigned long long _Mp, | |
| 45 | bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage> | |
| 46 | struct __lce_ta; | |
| 47 | ||
| 48 | // 64 | |
| 49 | ||
| 50 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | |
| 51 | struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> | |
| 52 | { | |
| 53 | typedef unsigned long long result_type; | |
| 54 | _LIBCPP_INLINE_VISIBILITY | |
| 55 | static result_type next(result_type __x) | |
| 56 | { | |
| 57 | // Schrage's algorithm | |
| 58 | const result_type __q = __m / __a; | |
| 59 | const result_type __r = __m % __a; | |
| 60 | const result_type __t0 = __a * (__x % __q); | |
| 61 | const result_type __t1 = __r * (__x / __q); | |
| 62 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 63 | __x += __c - (__x >= __m - __c) * __m; | |
| 64 | return __x; | |
| 65 | } | |
| 66 | }; | |
| 67 | ||
| 68 | template <unsigned long long __a, unsigned long long __m> | |
| 69 | struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> | |
| 70 | { | |
| 71 | typedef unsigned long long result_type; | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | static result_type next(result_type __x) | |
| 74 | { | |
| 75 | // Schrage's algorithm | |
| 76 | const result_type __q = __m / __a; | |
| 77 | const result_type __r = __m % __a; | |
| 78 | const result_type __t0 = __a * (__x % __q); | |
| 79 | const result_type __t1 = __r * (__x / __q); | |
| 80 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 81 | return __x; | |
| 82 | } | |
| 83 | }; | |
| 84 | ||
| 85 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | |
| 86 | struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false> | |
| 87 | { | |
| 88 | typedef unsigned long long result_type; | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | static result_type next(result_type __x) | |
| 91 | { | |
| 92 | return (__a * __x + __c) % __m; | |
| 93 | } | |
| 94 | }; | |
| 95 | ||
| 96 | template <unsigned long long __a, unsigned long long __c> | |
| 97 | struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false> | |
| 98 | { | |
| 99 | typedef unsigned long long result_type; | |
| 100 | _LIBCPP_INLINE_VISIBILITY | |
| 101 | static result_type next(result_type __x) | |
| 102 | { | |
| 103 | return __a * __x + __c; | |
| 104 | } | |
| 105 | }; | |
| 106 | ||
| 107 | // 32 | |
| 108 | ||
| 109 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | |
| 110 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> | |
| 111 | { | |
| 112 | typedef unsigned result_type; | |
| 113 | _LIBCPP_INLINE_VISIBILITY | |
| 114 | static result_type next(result_type __x) | |
| 115 | { | |
| 116 | const result_type __a = static_cast<result_type>(_Ap); | |
| 117 | const result_type __c = static_cast<result_type>(_Cp); | |
| 118 | const result_type __m = static_cast<result_type>(_Mp); | |
| 119 | // Schrage's algorithm | |
| 120 | const result_type __q = __m / __a; | |
| 121 | const result_type __r = __m % __a; | |
| 122 | const result_type __t0 = __a * (__x % __q); | |
| 123 | const result_type __t1 = __r * (__x / __q); | |
| 124 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 125 | __x += __c - (__x >= __m - __c) * __m; | |
| 126 | return __x; | |
| 127 | } | |
| 128 | }; | |
| 129 | ||
| 130 | template <unsigned long long _Ap, unsigned long long _Mp> | |
| 131 | struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> | |
| 132 | { | |
| 133 | typedef unsigned result_type; | |
| 134 | _LIBCPP_INLINE_VISIBILITY | |
| 135 | static result_type next(result_type __x) | |
| 136 | { | |
| 137 | const result_type __a = static_cast<result_type>(_Ap); | |
| 138 | const result_type __m = static_cast<result_type>(_Mp); | |
| 139 | // Schrage's algorithm | |
| 140 | const result_type __q = __m / __a; | |
| 141 | const result_type __r = __m % __a; | |
| 142 | const result_type __t0 = __a * (__x % __q); | |
| 143 | const result_type __t1 = __r * (__x / __q); | |
| 144 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 145 | return __x; | |
| 146 | } | |
| 147 | }; | |
| 148 | ||
| 149 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | |
| 150 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> | |
| 151 | { | |
| 152 | typedef unsigned result_type; | |
| 153 | _LIBCPP_INLINE_VISIBILITY | |
| 154 | static result_type next(result_type __x) | |
| 155 | { | |
| 156 | const result_type __a = static_cast<result_type>(_Ap); | |
| 157 | const result_type __c = static_cast<result_type>(_Cp); | |
| 158 | const result_type __m = static_cast<result_type>(_Mp); | |
| 159 | return (__a * __x + __c) % __m; | |
| 160 | } | |
| 161 | }; | |
| 162 | ||
| 163 | template <unsigned long long _Ap, unsigned long long _Cp> | |
| 164 | struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> | |
| 165 | { | |
| 166 | typedef unsigned result_type; | |
| 167 | _LIBCPP_INLINE_VISIBILITY | |
| 168 | static result_type next(result_type __x) | |
| 169 | { | |
| 170 | const result_type __a = static_cast<result_type>(_Ap); | |
| 171 | const result_type __c = static_cast<result_type>(_Cp); | |
| 172 | return __a * __x + __c; | |
| 173 | } | |
| 174 | }; | |
| 175 | ||
| 176 | // 16 | |
| 177 | ||
| 178 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m, bool __b> | |
| 179 | struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> | |
| 180 | { | |
| 181 | typedef unsigned short result_type; | |
| 182 | _LIBCPP_INLINE_VISIBILITY | |
| 183 | static result_type next(result_type __x) | |
| 184 | { | |
| 185 | return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x)); | |
| 186 | } | |
| 187 | }; | |
| 188 | ||
| 189 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 190 | class _LIBCPP_TEMPLATE_VIS linear_congruential_engine; | |
| 191 | ||
| 192 | template <class _CharT, class _Traits, | |
| 193 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 194 | _LIBCPP_INLINE_VISIBILITY | |
| 195 | basic_ostream<_CharT, _Traits>& | |
| 196 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 197 | const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); | |
| 198 | ||
| 199 | template <class _CharT, class _Traits, | |
| 200 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 201 | basic_istream<_CharT, _Traits>& | |
| 202 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 203 | linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); | |
| 204 | ||
| 205 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 206 | class _LIBCPP_TEMPLATE_VIS linear_congruential_engine | |
| 207 | { | |
| 208 | public: | |
| 209 | // types | |
| 210 | typedef _UIntType result_type; | |
| 211 | ||
| 212 | private: | |
| 213 | result_type __x_; | |
| 214 | ||
| 215 | static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0); | |
| 216 | ||
| 217 | static_assert(__m == 0 || __a < __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"); | |
| 220 | public: | |
| 221 | static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u; | |
| 222 | static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u; | |
| 223 | static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); | |
| 224 | ||
| 225 | // engine characteristics | |
| 226 | static _LIBCPP_CONSTEXPR const result_type multiplier = __a; | |
| 227 | static _LIBCPP_CONSTEXPR const result_type increment = __c; | |
| 228 | static _LIBCPP_CONSTEXPR const result_type modulus = __m; | |
| 229 | _LIBCPP_INLINE_VISIBILITY | |
| 230 | static _LIBCPP_CONSTEXPR result_type min() {return _Min;} | |
| 231 | _LIBCPP_INLINE_VISIBILITY | |
| 232 | static _LIBCPP_CONSTEXPR result_type max() {return _Max;} | |
| 233 | static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; | |
| 234 | ||
| 235 | // constructors and seeding functions | |
| 236 | #ifndef _LIBCPP_CXX03_LANG | |
| 237 | _LIBCPP_INLINE_VISIBILITY | |
| 238 | linear_congruential_engine() : linear_congruential_engine(default_seed) {} | |
| 239 | _LIBCPP_INLINE_VISIBILITY | |
| 240 | explicit linear_congruential_engine(result_type __s) { seed(__s); } | |
| 241 | #else | |
| 242 | _LIBCPP_INLINE_VISIBILITY | |
| 243 | explicit linear_congruential_engine(result_type __s = default_seed) { | |
| 244 | seed(__s); | |
| 245 | } | |
| 246 | #endif | |
| 247 | template<class _Sseq> | |
| 248 | _LIBCPP_INLINE_VISIBILITY | |
| 249 | explicit linear_congruential_engine(_Sseq& __q, | |
| 250 | typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0) | |
| 251 | {seed(__q);} | |
| 252 | _LIBCPP_INLINE_VISIBILITY | |
| 253 | void seed(result_type __s = default_seed) | |
| 254 | {seed(integral_constant<bool, __m == 0>(), | |
| 255 | integral_constant<bool, __c == 0>(), __s);} | |
| 256 | template<class _Sseq> | |
| 257 | _LIBCPP_INLINE_VISIBILITY | |
| 258 | typename enable_if | |
| 259 | < | |
| 260 | __is_seed_sequence<_Sseq, linear_congruential_engine>::value, | |
| 261 | void | |
| 262 | >::type | |
| 263 | seed(_Sseq& __q) | |
| 264 | {__seed(__q, integral_constant<unsigned, | |
| 265 | 1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1)/32 | |
| 266 | : (__m > 0x100000000ull))>());} | |
| 267 | ||
| 268 | // generating functions | |
| 269 | _LIBCPP_INLINE_VISIBILITY | |
| 270 | result_type operator()() | |
| 271 | {return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _Mp>::next(__x_));} | |
| 272 | _LIBCPP_INLINE_VISIBILITY | |
| 273 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 274 | ||
| 275 | friend _LIBCPP_INLINE_VISIBILITY | |
| 276 | bool operator==(const linear_congruential_engine& __x, | |
| 277 | const linear_congruential_engine& __y) | |
| 278 | {return __x.__x_ == __y.__x_;} | |
| 279 | friend _LIBCPP_INLINE_VISIBILITY | |
| 280 | bool operator!=(const linear_congruential_engine& __x, | |
| 281 | const linear_congruential_engine& __y) | |
| 282 | {return !(__x == __y);} | |
| 283 | ||
| 284 | private: | |
| 285 | ||
| 286 | _LIBCPP_INLINE_VISIBILITY | |
| 287 | void seed(true_type, true_type, result_type __s) {__x_ = __s == 0 ? 1 : __s;} | |
| 288 | _LIBCPP_INLINE_VISIBILITY | |
| 289 | void seed(true_type, false_type, result_type __s) {__x_ = __s;} | |
| 290 | _LIBCPP_INLINE_VISIBILITY | |
| 291 | void seed(false_type, true_type, result_type __s) {__x_ = __s % __m == 0 ? | |
| 292 | 1 : __s % __m;} | |
| 293 | _LIBCPP_INLINE_VISIBILITY | |
| 294 | void seed(false_type, false_type, result_type __s) {__x_ = __s % __m;} | |
| 295 | ||
| 296 | template<class _Sseq> | |
| 297 | void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | |
| 298 | template<class _Sseq> | |
| 299 | void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | |
| 300 | ||
| 301 | template <class _CharT, class _Traits, | |
| 302 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 303 | friend | |
| 304 | basic_ostream<_CharT, _Traits>& | |
| 305 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 306 | const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); | |
| 307 | ||
| 308 | template <class _CharT, class _Traits, | |
| 309 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 310 | friend | |
| 311 | basic_istream<_CharT, _Traits>& | |
| 312 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 313 | linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); | |
| 314 | }; | |
| 315 | ||
| 316 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 317 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 318 | linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; | |
| 319 | ||
| 320 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 321 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 322 | linear_congruential_engine<_UIntType, __a, __c, __m>::increment; | |
| 323 | ||
| 324 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 325 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 326 | linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; | |
| 327 | ||
| 328 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 329 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 330 | linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; | |
| 331 | ||
| 332 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 333 | template<class _Sseq> | |
| 334 | void | |
| 335 | linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, | |
| 336 | integral_constant<unsigned, 1>) | |
| 337 | { | |
| 338 | const unsigned __k = 1; | |
| 339 | uint32_t __ar[__k+3]; | |
| 340 | __q.generate(__ar, __ar + __k + 3); | |
| 341 | result_type __s = static_cast<result_type>(__ar[3] % __m); | |
| 342 | __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; | |
| 343 | } | |
| 344 | ||
| 345 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 346 | template<class _Sseq> | |
| 347 | void | |
| 348 | linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, | |
| 349 | integral_constant<unsigned, 2>) | |
| 350 | { | |
| 351 | const unsigned __k = 2; | |
| 352 | uint32_t __ar[__k+3]; | |
| 353 | __q.generate(__ar, __ar + __k + 3); | |
| 354 | result_type __s = static_cast<result_type>((__ar[3] + | |
| 355 | ((uint64_t)__ar[4] << 32)) % __m); | |
| 356 | __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; | |
| 357 | } | |
| 358 | ||
| 359 | template <class _CharT, class _Traits, | |
| 360 | class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 361 | inline _LIBCPP_INLINE_VISIBILITY | |
| 362 | basic_ostream<_CharT, _Traits>& | |
| 363 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 364 | const linear_congruential_engine<_UIntType, __a, __c, __m>& __x) | |
| 365 | { | |
| 366 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 367 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 368 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 369 | __os.fill(__os.widen(' ')); | |
| 370 | return __os << __x.__x_; | |
| 371 | } | |
| 372 | ||
| 373 | template <class _CharT, class _Traits, | |
| 374 | class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 375 | basic_istream<_CharT, _Traits>& | |
| 376 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 377 | linear_congruential_engine<_UIntType, __a, __c, __m>& __x) | |
| 378 | { | |
| 379 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 380 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 381 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 382 | _UIntType __t; | |
| 383 | __is >> __t; | |
| 384 | if (!__is.fail()) | |
| 385 | __x.__x_ = __t; | |
| 386 | return __is; | |
| 387 | } | |
| 388 | ||
| 389 | typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647> | |
| 390 | minstd_rand0; | |
| 391 | typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647> | |
| 392 | minstd_rand; | |
| 393 | ||
| 394 | _LIBCPP_END_NAMESPACE_STD | |
| 395 | ||
| 396 | _LIBCPP_POP_MACROS | |
| 397 | ||
| 398 | #endif // _LIBCPP___RANDOM_LINEAR_CONGRUENTIAL_ENGINE_H |
lib/libcxx/include/__random/log2.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___RANDOM_LOG2_H | |
| 10 | #define _LIBCPP___RANDOM_LOG2_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstddef> | |
| 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 | template <class _UIntType, _UIntType _Xp, size_t _Rp> | |
| 23 | struct __log2_imp; | |
| 24 | ||
| 25 | template <unsigned long long _Xp, size_t _Rp> | |
| 26 | struct __log2_imp<unsigned long long, _Xp, _Rp> | |
| 27 | { | |
| 28 | static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp | |
| 29 | : __log2_imp<unsigned long long, _Xp, _Rp - 1>::value; | |
| 30 | }; | |
| 31 | ||
| 32 | template <unsigned long long _Xp> | |
| 33 | struct __log2_imp<unsigned long long, _Xp, 0> | |
| 34 | { | |
| 35 | static const size_t value = 0; | |
| 36 | }; | |
| 37 | ||
| 38 | template <size_t _Rp> | |
| 39 | struct __log2_imp<unsigned long long, 0, _Rp> | |
| 40 | { | |
| 41 | static const size_t value = _Rp + 1; | |
| 42 | }; | |
| 43 | ||
| 44 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 45 | ||
| 46 | template <__uint128_t _Xp, size_t _Rp> | |
| 47 | struct __log2_imp<__uint128_t, _Xp, _Rp> | |
| 48 | { | |
| 49 | static const size_t value = (_Xp >> 64) | |
| 50 | ? (64 + __log2_imp<unsigned long long, (_Xp >> 64), 63>::value) | |
| 51 | : __log2_imp<unsigned long long, _Xp, 63>::value; | |
| 52 | }; | |
| 53 | ||
| 54 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 55 | ||
| 56 | template <class _UIntType, _UIntType _Xp> | |
| 57 | struct __log2 | |
| 58 | { | |
| 59 | static const size_t value = __log2_imp< | |
| 60 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 61 | typename conditional< | |
| 62 | sizeof(_UIntType) <= sizeof(unsigned long long), | |
| 63 | unsigned long long, | |
| 64 | __uint128_t | |
| 65 | >::type, | |
| 66 | #else | |
| 67 | unsigned long long, | |
| 68 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 69 | _Xp, sizeof(_UIntType) * __CHAR_BIT__ - 1>::value; | |
| 70 | }; | |
| 71 | ||
| 72 | _LIBCPP_END_NAMESPACE_STD | |
| 73 | ||
| 74 | #endif // _LIBCPP___RANDOM_LOG2_H |
lib/libcxx/include/__random/lognormal_distribution.h created+299| ... | ... | @@ -0,0 +1,299 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_LOGNORMAL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_LOGNORMAL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/normal_distribution.h> | |
| 14 | #include <cmath> | |
| 15 | #include <iosfwd> | |
| 16 | #include <limits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #ifdef _LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION | |
| 28 | ||
| 29 | template<class _RealType = double> | |
| 30 | class _LIBCPP_TEMPLATE_VIS lognormal_distribution | |
| 31 | { | |
| 32 | public: | |
| 33 | // types | |
| 34 | typedef _RealType result_type; | |
| 35 | ||
| 36 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 37 | { | |
| 38 | normal_distribution<result_type> __nd_; | |
| 39 | public: | |
| 40 | typedef lognormal_distribution distribution_type; | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | explicit param_type(result_type __m = 0, result_type __s = 1) | |
| 44 | : __nd_(__m, __s) {} | |
| 45 | ||
| 46 | _LIBCPP_INLINE_VISIBILITY | |
| 47 | result_type m() const {return __nd_.mean();} | |
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | result_type s() const {return __nd_.stddev();} | |
| 50 | ||
| 51 | friend _LIBCPP_INLINE_VISIBILITY | |
| 52 | bool operator==(const param_type& __x, const param_type& __y) | |
| 53 | {return __x.__nd_ == __y.__nd_;} | |
| 54 | friend _LIBCPP_INLINE_VISIBILITY | |
| 55 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 56 | {return !(__x == __y);} | |
| 57 | friend class lognormal_distribution; | |
| 58 | ||
| 59 | template <class _CharT, class _Traits, class _RT> | |
| 60 | friend | |
| 61 | basic_ostream<_CharT, _Traits>& | |
| 62 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 63 | const lognormal_distribution<_RT>& __x); | |
| 64 | ||
| 65 | template <class _CharT, class _Traits, class _RT> | |
| 66 | friend | |
| 67 | basic_istream<_CharT, _Traits>& | |
| 68 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 69 | lognormal_distribution<_RT>& __x); | |
| 70 | }; | |
| 71 | ||
| 72 | private: | |
| 73 | param_type __p_; | |
| 74 | ||
| 75 | public: | |
| 76 | // constructor and reset functions | |
| 77 | #ifndef _LIBCPP_CXX03_LANG | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | lognormal_distribution() : lognormal_distribution(0) {} | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | explicit lognormal_distribution(result_type __m, result_type __s = 1) | |
| 82 | : __p_(param_type(__m, __s)) {} | |
| 83 | #else | |
| 84 | _LIBCPP_INLINE_VISIBILITY | |
| 85 | explicit lognormal_distribution(result_type __m = 0, | |
| 86 | result_type __s = 1) | |
| 87 | : __p_(param_type(__m, __s)) {} | |
| 88 | #endif | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | explicit lognormal_distribution(const param_type& __p) | |
| 91 | : __p_(__p) {} | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | void reset() {__p_.__nd_.reset();} | |
| 94 | ||
| 95 | // generating functions | |
| 96 | template<class _URNG> | |
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | result_type operator()(_URNG& __g) | |
| 99 | {return (*this)(__g, __p_);} | |
| 100 | template<class _URNG> | |
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 103 | {return _VSTD::exp(const_cast<normal_distribution<result_type>&>(__p.__nd_)(__g));} | |
| 104 | ||
| 105 | // property functions | |
| 106 | _LIBCPP_INLINE_VISIBILITY | |
| 107 | result_type m() const {return __p_.m();} | |
| 108 | _LIBCPP_INLINE_VISIBILITY | |
| 109 | result_type s() const {return __p_.s();} | |
| 110 | ||
| 111 | _LIBCPP_INLINE_VISIBILITY | |
| 112 | param_type param() const {return __p_;} | |
| 113 | _LIBCPP_INLINE_VISIBILITY | |
| 114 | void param(const param_type& __p) {__p_ = __p;} | |
| 115 | ||
| 116 | _LIBCPP_INLINE_VISIBILITY | |
| 117 | result_type min() const {return 0;} | |
| 118 | _LIBCPP_INLINE_VISIBILITY | |
| 119 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 120 | ||
| 121 | friend _LIBCPP_INLINE_VISIBILITY | |
| 122 | bool operator==(const lognormal_distribution& __x, | |
| 123 | const lognormal_distribution& __y) | |
| 124 | {return __x.__p_ == __y.__p_;} | |
| 125 | friend _LIBCPP_INLINE_VISIBILITY | |
| 126 | bool operator!=(const lognormal_distribution& __x, | |
| 127 | const lognormal_distribution& __y) | |
| 128 | {return !(__x == __y);} | |
| 129 | ||
| 130 | template <class _CharT, class _Traits, class _RT> | |
| 131 | friend | |
| 132 | basic_ostream<_CharT, _Traits>& | |
| 133 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 134 | const lognormal_distribution<_RT>& __x); | |
| 135 | ||
| 136 | template <class _CharT, class _Traits, class _RT> | |
| 137 | friend | |
| 138 | basic_istream<_CharT, _Traits>& | |
| 139 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 140 | lognormal_distribution<_RT>& __x); | |
| 141 | }; | |
| 142 | ||
| 143 | template <class _CharT, class _Traits, class _RT> | |
| 144 | inline _LIBCPP_INLINE_VISIBILITY | |
| 145 | basic_ostream<_CharT, _Traits>& | |
| 146 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 147 | const lognormal_distribution<_RT>& __x) | |
| 148 | { | |
| 149 | return __os << __x.__p_.__nd_; | |
| 150 | } | |
| 151 | ||
| 152 | template <class _CharT, class _Traits, class _RT> | |
| 153 | inline _LIBCPP_INLINE_VISIBILITY | |
| 154 | basic_istream<_CharT, _Traits>& | |
| 155 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 156 | lognormal_distribution<_RT>& __x) | |
| 157 | { | |
| 158 | return __is >> __x.__p_.__nd_; | |
| 159 | } | |
| 160 | ||
| 161 | #else // _LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION | |
| 162 | ||
| 163 | template<class _RealType = double> | |
| 164 | class _LIBCPP_TEMPLATE_VIS lognormal_distribution | |
| 165 | { | |
| 166 | public: | |
| 167 | // types | |
| 168 | typedef _RealType result_type; | |
| 169 | ||
| 170 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 171 | { | |
| 172 | result_type __m_; | |
| 173 | result_type __s_; | |
| 174 | public: | |
| 175 | typedef lognormal_distribution distribution_type; | |
| 176 | ||
| 177 | _LIBCPP_INLINE_VISIBILITY | |
| 178 | explicit param_type(result_type __m = 0, result_type __s = 1) | |
| 179 | : __m_(__m), __s_(__s) {} | |
| 180 | ||
| 181 | _LIBCPP_INLINE_VISIBILITY | |
| 182 | result_type m() const {return __m_;} | |
| 183 | _LIBCPP_INLINE_VISIBILITY | |
| 184 | result_type s() const {return __s_;} | |
| 185 | ||
| 186 | friend _LIBCPP_INLINE_VISIBILITY | |
| 187 | bool operator==(const param_type& __x, const param_type& __y) | |
| 188 | {return __x.__m_ == __y.__m_ && __x.__s_ == __y.__s_;} | |
| 189 | friend _LIBCPP_INLINE_VISIBILITY | |
| 190 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 191 | {return !(__x == __y);} | |
| 192 | }; | |
| 193 | ||
| 194 | private: | |
| 195 | normal_distribution<result_type> __nd_; | |
| 196 | ||
| 197 | public: | |
| 198 | // constructor and reset functions | |
| 199 | #ifndef _LIBCPP_CXX03_LANG | |
| 200 | _LIBCPP_INLINE_VISIBILITY | |
| 201 | lognormal_distribution() : lognormal_distribution(0) {} | |
| 202 | _LIBCPP_INLINE_VISIBILITY | |
| 203 | explicit lognormal_distribution(result_type __m, result_type __s = 1) | |
| 204 | : __nd_(__m, __s) {} | |
| 205 | #else | |
| 206 | _LIBCPP_INLINE_VISIBILITY | |
| 207 | explicit lognormal_distribution(result_type __m = 0, | |
| 208 | result_type __s = 1) | |
| 209 | : __nd_(__m, __s) {} | |
| 210 | #endif | |
| 211 | _LIBCPP_INLINE_VISIBILITY | |
| 212 | explicit lognormal_distribution(const param_type& __p) | |
| 213 | : __nd_(__p.m(), __p.s()) {} | |
| 214 | _LIBCPP_INLINE_VISIBILITY | |
| 215 | void reset() {__nd_.reset();} | |
| 216 | ||
| 217 | // generating functions | |
| 218 | template<class _URNG> | |
| 219 | _LIBCPP_INLINE_VISIBILITY | |
| 220 | result_type operator()(_URNG& __g) | |
| 221 | { | |
| 222 | return _VSTD::exp(__nd_(__g)); | |
| 223 | } | |
| 224 | ||
| 225 | template<class _URNG> | |
| 226 | _LIBCPP_INLINE_VISIBILITY | |
| 227 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 228 | { | |
| 229 | typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s()); | |
| 230 | return _VSTD::exp(__nd_(__g, __pn)); | |
| 231 | } | |
| 232 | ||
| 233 | // property functions | |
| 234 | _LIBCPP_INLINE_VISIBILITY | |
| 235 | result_type m() const {return __nd_.mean();} | |
| 236 | _LIBCPP_INLINE_VISIBILITY | |
| 237 | result_type s() const {return __nd_.stddev();} | |
| 238 | ||
| 239 | _LIBCPP_INLINE_VISIBILITY | |
| 240 | param_type param() const {return param_type(__nd_.mean(), __nd_.stddev());} | |
| 241 | _LIBCPP_INLINE_VISIBILITY | |
| 242 | void param(const param_type& __p) | |
| 243 | { | |
| 244 | typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s()); | |
| 245 | __nd_.param(__pn); | |
| 246 | } | |
| 247 | ||
| 248 | _LIBCPP_INLINE_VISIBILITY | |
| 249 | result_type min() const {return 0;} | |
| 250 | _LIBCPP_INLINE_VISIBILITY | |
| 251 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 252 | ||
| 253 | friend _LIBCPP_INLINE_VISIBILITY | |
| 254 | bool operator==(const lognormal_distribution& __x, | |
| 255 | const lognormal_distribution& __y) | |
| 256 | {return __x.__nd_ == __y.__nd_;} | |
| 257 | friend _LIBCPP_INLINE_VISIBILITY | |
| 258 | bool operator!=(const lognormal_distribution& __x, | |
| 259 | const lognormal_distribution& __y) | |
| 260 | {return !(__x == __y);} | |
| 261 | ||
| 262 | template <class _CharT, class _Traits, class _RT> | |
| 263 | friend | |
| 264 | basic_ostream<_CharT, _Traits>& | |
| 265 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 266 | const lognormal_distribution<_RT>& __x); | |
| 267 | ||
| 268 | template <class _CharT, class _Traits, class _RT> | |
| 269 | friend | |
| 270 | basic_istream<_CharT, _Traits>& | |
| 271 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 272 | lognormal_distribution<_RT>& __x); | |
| 273 | }; | |
| 274 | ||
| 275 | template <class _CharT, class _Traits, class _RT> | |
| 276 | inline _LIBCPP_INLINE_VISIBILITY | |
| 277 | basic_ostream<_CharT, _Traits>& | |
| 278 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 279 | const lognormal_distribution<_RT>& __x) | |
| 280 | { | |
| 281 | return __os << __x.__nd_; | |
| 282 | } | |
| 283 | ||
| 284 | template <class _CharT, class _Traits, class _RT> | |
| 285 | inline _LIBCPP_INLINE_VISIBILITY | |
| 286 | basic_istream<_CharT, _Traits>& | |
| 287 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 288 | lognormal_distribution<_RT>& __x) | |
| 289 | { | |
| 290 | return __is >> __x.__nd_; | |
| 291 | } | |
| 292 | ||
| 293 | #endif // _LIBCPP_ABI_OLD_LOGNORMAL_DISTRIBUTION | |
| 294 | ||
| 295 | _LIBCPP_END_NAMESPACE_STD | |
| 296 | ||
| 297 | _LIBCPP_POP_MACROS | |
| 298 | ||
| 299 | #endif // _LIBCPP___RANDOM_LOGNORMAL_DISTRIBUTION_H |
lib/libcxx/include/__random/mersenne_twister_engine.h created+534| ... | ... | @@ -0,0 +1,534 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_MERSENNE_TWISTER_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H | |
| 11 | ||
| 12 | #include <__algorithm/equal.h> | |
| 13 | #include <__algorithm/min.h> | |
| 14 | #include <__config> | |
| 15 | #include <__random/is_seed_sequence.h> | |
| 16 | #include <cstddef> | |
| 17 | #include <cstdint> | |
| 18 | #include <iosfwd> | |
| 19 | #include <limits> | |
| 20 | #include <type_traits> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | #pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 32 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 33 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 34 | class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine; | |
| 35 | ||
| 36 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 37 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 38 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 39 | bool | |
| 40 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 41 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 42 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 43 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 44 | ||
| 45 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 46 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 47 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | bool | |
| 50 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 51 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 52 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 53 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 54 | ||
| 55 | template <class _CharT, class _Traits, | |
| 56 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 57 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 58 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 59 | basic_ostream<_CharT, _Traits>& | |
| 60 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 61 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 62 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 63 | ||
| 64 | template <class _CharT, class _Traits, | |
| 65 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 66 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 67 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 68 | basic_istream<_CharT, _Traits>& | |
| 69 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 70 | mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 71 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 72 | ||
| 73 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 74 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 75 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 76 | class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine | |
| 77 | { | |
| 78 | public: | |
| 79 | // types | |
| 80 | typedef _UIntType result_type; | |
| 81 | ||
| 82 | private: | |
| 83 | result_type __x_[__n]; | |
| 84 | size_t __i_; | |
| 85 | ||
| 86 | static_assert( 0 < __m, "mersenne_twister_engine invalid parameters"); | |
| 87 | static_assert(__m <= __n, "mersenne_twister_engine invalid parameters"); | |
| 88 | static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; | |
| 89 | static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters"); | |
| 90 | static_assert( 2 <= __w, "mersenne_twister_engine invalid parameters"); | |
| 91 | static_assert(__r <= __w, "mersenne_twister_engine invalid parameters"); | |
| 92 | static_assert(__u <= __w, "mersenne_twister_engine invalid parameters"); | |
| 93 | static_assert(__s <= __w, "mersenne_twister_engine invalid parameters"); | |
| 94 | static_assert(__t <= __w, "mersenne_twister_engine invalid parameters"); | |
| 95 | static_assert(__l <= __w, "mersenne_twister_engine invalid parameters"); | |
| 96 | public: | |
| 97 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 98 | static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : | |
| 99 | (result_type(1) << __w) - result_type(1); | |
| 100 | static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters"); | |
| 101 | static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 102 | static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 103 | static_assert(__c <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 104 | static_assert(__d <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 105 | static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 106 | ||
| 107 | // engine characteristics | |
| 108 | static _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 109 | static _LIBCPP_CONSTEXPR const size_t state_size = __n; | |
| 110 | static _LIBCPP_CONSTEXPR const size_t shift_size = __m; | |
| 111 | static _LIBCPP_CONSTEXPR const size_t mask_bits = __r; | |
| 112 | static _LIBCPP_CONSTEXPR const result_type xor_mask = __a; | |
| 113 | static _LIBCPP_CONSTEXPR const size_t tempering_u = __u; | |
| 114 | static _LIBCPP_CONSTEXPR const result_type tempering_d = __d; | |
| 115 | static _LIBCPP_CONSTEXPR const size_t tempering_s = __s; | |
| 116 | static _LIBCPP_CONSTEXPR const result_type tempering_b = __b; | |
| 117 | static _LIBCPP_CONSTEXPR const size_t tempering_t = __t; | |
| 118 | static _LIBCPP_CONSTEXPR const result_type tempering_c = __c; | |
| 119 | static _LIBCPP_CONSTEXPR const size_t tempering_l = __l; | |
| 120 | static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; | |
| 121 | _LIBCPP_INLINE_VISIBILITY | |
| 122 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 123 | _LIBCPP_INLINE_VISIBILITY | |
| 124 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 125 | static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; | |
| 126 | ||
| 127 | // constructors and seeding functions | |
| 128 | #ifndef _LIBCPP_CXX03_LANG | |
| 129 | _LIBCPP_INLINE_VISIBILITY | |
| 130 | mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} | |
| 131 | _LIBCPP_INLINE_VISIBILITY | |
| 132 | explicit mersenne_twister_engine(result_type __sd) { seed(__sd); } | |
| 133 | #else | |
| 134 | _LIBCPP_INLINE_VISIBILITY | |
| 135 | explicit mersenne_twister_engine(result_type __sd = default_seed) { | |
| 136 | seed(__sd); | |
| 137 | } | |
| 138 | #endif | |
| 139 | template<class _Sseq> | |
| 140 | _LIBCPP_INLINE_VISIBILITY | |
| 141 | explicit mersenne_twister_engine(_Sseq& __q, | |
| 142 | typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0) | |
| 143 | {seed(__q);} | |
| 144 | void seed(result_type __sd = default_seed); | |
| 145 | template<class _Sseq> | |
| 146 | _LIBCPP_INLINE_VISIBILITY | |
| 147 | typename enable_if | |
| 148 | < | |
| 149 | __is_seed_sequence<_Sseq, mersenne_twister_engine>::value, | |
| 150 | void | |
| 151 | >::type | |
| 152 | seed(_Sseq& __q) | |
| 153 | {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());} | |
| 154 | ||
| 155 | // generating functions | |
| 156 | result_type operator()(); | |
| 157 | _LIBCPP_INLINE_VISIBILITY | |
| 158 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 159 | ||
| 160 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 161 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 162 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 163 | friend | |
| 164 | bool | |
| 165 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 166 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 167 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 168 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 169 | ||
| 170 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 171 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 172 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 173 | friend | |
| 174 | bool | |
| 175 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 176 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 177 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 178 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 179 | ||
| 180 | template <class _CharT, class _Traits, | |
| 181 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 182 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 183 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 184 | friend | |
| 185 | basic_ostream<_CharT, _Traits>& | |
| 186 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 187 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 188 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 189 | ||
| 190 | template <class _CharT, class _Traits, | |
| 191 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 192 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 193 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 194 | friend | |
| 195 | basic_istream<_CharT, _Traits>& | |
| 196 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 197 | mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 198 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 199 | private: | |
| 200 | ||
| 201 | template<class _Sseq> | |
| 202 | void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | |
| 203 | template<class _Sseq> | |
| 204 | void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | |
| 205 | ||
| 206 | template <size_t __count> | |
| 207 | _LIBCPP_INLINE_VISIBILITY | |
| 208 | static | |
| 209 | typename enable_if | |
| 210 | < | |
| 211 | __count < __w, | |
| 212 | result_type | |
| 213 | >::type | |
| 214 | __lshift(result_type __x) {return (__x << __count) & _Max;} | |
| 215 | ||
| 216 | template <size_t __count> | |
| 217 | _LIBCPP_INLINE_VISIBILITY | |
| 218 | static | |
| 219 | typename enable_if | |
| 220 | < | |
| 221 | (__count >= __w), | |
| 222 | result_type | |
| 223 | >::type | |
| 224 | __lshift(result_type) {return result_type(0);} | |
| 225 | ||
| 226 | template <size_t __count> | |
| 227 | _LIBCPP_INLINE_VISIBILITY | |
| 228 | static | |
| 229 | typename enable_if | |
| 230 | < | |
| 231 | __count < _Dt, | |
| 232 | result_type | |
| 233 | >::type | |
| 234 | __rshift(result_type __x) {return __x >> __count;} | |
| 235 | ||
| 236 | template <size_t __count> | |
| 237 | _LIBCPP_INLINE_VISIBILITY | |
| 238 | static | |
| 239 | typename enable_if | |
| 240 | < | |
| 241 | (__count >= _Dt), | |
| 242 | result_type | |
| 243 | >::type | |
| 244 | __rshift(result_type) {return result_type(0);} | |
| 245 | }; | |
| 246 | ||
| 247 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 248 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 249 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 250 | _LIBCPP_CONSTEXPR const size_t | |
| 251 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size; | |
| 252 | ||
| 253 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 254 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 255 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 256 | _LIBCPP_CONSTEXPR const size_t | |
| 257 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size; | |
| 258 | ||
| 259 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 260 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 261 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 262 | _LIBCPP_CONSTEXPR const size_t | |
| 263 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size; | |
| 264 | ||
| 265 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 266 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 267 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 268 | _LIBCPP_CONSTEXPR const size_t | |
| 269 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits; | |
| 270 | ||
| 271 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 272 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 273 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 274 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 275 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask; | |
| 276 | ||
| 277 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 278 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 279 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 280 | _LIBCPP_CONSTEXPR const size_t | |
| 281 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u; | |
| 282 | ||
| 283 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 284 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 285 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 286 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 287 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d; | |
| 288 | ||
| 289 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 290 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 291 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 292 | _LIBCPP_CONSTEXPR const size_t | |
| 293 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s; | |
| 294 | ||
| 295 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 296 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 297 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 298 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 299 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b; | |
| 300 | ||
| 301 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 302 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 303 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 304 | _LIBCPP_CONSTEXPR const size_t | |
| 305 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t; | |
| 306 | ||
| 307 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 308 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 309 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 310 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 311 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c; | |
| 312 | ||
| 313 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 314 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 315 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 316 | _LIBCPP_CONSTEXPR const size_t | |
| 317 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l; | |
| 318 | ||
| 319 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 320 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 321 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 322 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 323 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::initialization_multiplier; | |
| 324 | ||
| 325 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 326 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 327 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 328 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 329 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed; | |
| 330 | ||
| 331 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 332 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 333 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 334 | void | |
| 335 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 336 | __t, __c, __l, __f>::seed(result_type __sd) | |
| 337 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 338 | { // __w >= 2 | |
| 339 | __x_[0] = __sd & _Max; | |
| 340 | for (size_t __i = 1; __i < __n; ++__i) | |
| 341 | __x_[__i] = (__f * (__x_[__i-1] ^ __rshift<__w - 2>(__x_[__i-1])) + __i) & _Max; | |
| 342 | __i_ = 0; | |
| 343 | } | |
| 344 | ||
| 345 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 346 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 347 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 348 | template<class _Sseq> | |
| 349 | void | |
| 350 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 351 | __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) | |
| 352 | { | |
| 353 | const unsigned __k = 1; | |
| 354 | uint32_t __ar[__n * __k]; | |
| 355 | __q.generate(__ar, __ar + __n * __k); | |
| 356 | for (size_t __i = 0; __i < __n; ++__i) | |
| 357 | __x_[__i] = static_cast<result_type>(__ar[__i] & _Max); | |
| 358 | const result_type __mask = __r == _Dt ? result_type(~0) : | |
| 359 | (result_type(1) << __r) - result_type(1); | |
| 360 | __i_ = 0; | |
| 361 | if ((__x_[0] & ~__mask) == 0) | |
| 362 | { | |
| 363 | for (size_t __i = 1; __i < __n; ++__i) | |
| 364 | if (__x_[__i] != 0) | |
| 365 | return; | |
| 366 | __x_[0] = result_type(1) << (__w - 1); | |
| 367 | } | |
| 368 | } | |
| 369 | ||
| 370 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 371 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 372 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 373 | template<class _Sseq> | |
| 374 | void | |
| 375 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 376 | __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 2>) | |
| 377 | { | |
| 378 | const unsigned __k = 2; | |
| 379 | uint32_t __ar[__n * __k]; | |
| 380 | __q.generate(__ar, __ar + __n * __k); | |
| 381 | for (size_t __i = 0; __i < __n; ++__i) | |
| 382 | __x_[__i] = static_cast<result_type>( | |
| 383 | (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); | |
| 384 | const result_type __mask = __r == _Dt ? result_type(~0) : | |
| 385 | (result_type(1) << __r) - result_type(1); | |
| 386 | __i_ = 0; | |
| 387 | if ((__x_[0] & ~__mask) == 0) | |
| 388 | { | |
| 389 | for (size_t __i = 1; __i < __n; ++__i) | |
| 390 | if (__x_[__i] != 0) | |
| 391 | return; | |
| 392 | __x_[0] = result_type(1) << (__w - 1); | |
| 393 | } | |
| 394 | } | |
| 395 | ||
| 396 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 397 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 398 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 399 | _UIntType | |
| 400 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 401 | __t, __c, __l, __f>::operator()() | |
| 402 | { | |
| 403 | const size_t __j = (__i_ + 1) % __n; | |
| 404 | const result_type __mask = __r == _Dt ? result_type(~0) : | |
| 405 | (result_type(1) << __r) - result_type(1); | |
| 406 | const result_type _Yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); | |
| 407 | const size_t __k = (__i_ + __m) % __n; | |
| 408 | __x_[__i_] = __x_[__k] ^ __rshift<1>(_Yp) ^ (__a * (_Yp & 1)); | |
| 409 | result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d); | |
| 410 | __i_ = __j; | |
| 411 | __z ^= __lshift<__s>(__z) & __b; | |
| 412 | __z ^= __lshift<__t>(__z) & __c; | |
| 413 | return __z ^ __rshift<__l>(__z); | |
| 414 | } | |
| 415 | ||
| 416 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 417 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 418 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 419 | bool | |
| 420 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 421 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 422 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 423 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y) | |
| 424 | { | |
| 425 | if (__x.__i_ == __y.__i_) | |
| 426 | return _VSTD::equal(__x.__x_, __x.__x_ + _Np, __y.__x_); | |
| 427 | if (__x.__i_ == 0 || __y.__i_ == 0) | |
| 428 | { | |
| 429 | size_t __j = _VSTD::min(_Np - __x.__i_, _Np - __y.__i_); | |
| 430 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, | |
| 431 | __y.__x_ + __y.__i_)) | |
| 432 | return false; | |
| 433 | if (__x.__i_ == 0) | |
| 434 | return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_); | |
| 435 | return _VSTD::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j); | |
| 436 | } | |
| 437 | if (__x.__i_ < __y.__i_) | |
| 438 | { | |
| 439 | size_t __j = _Np - __y.__i_; | |
| 440 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), | |
| 441 | __y.__x_ + __y.__i_)) | |
| 442 | return false; | |
| 443 | if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np, | |
| 444 | __y.__x_)) | |
| 445 | return false; | |
| 446 | return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, | |
| 447 | __y.__x_ + (_Np - (__x.__i_ + __j))); | |
| 448 | } | |
| 449 | size_t __j = _Np - __x.__i_; | |
| 450 | if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), | |
| 451 | __x.__x_ + __x.__i_)) | |
| 452 | return false; | |
| 453 | if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np, | |
| 454 | __x.__x_)) | |
| 455 | return false; | |
| 456 | return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, | |
| 457 | __x.__x_ + (_Np - (__y.__i_ + __j))); | |
| 458 | } | |
| 459 | ||
| 460 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 461 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 462 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 463 | inline _LIBCPP_INLINE_VISIBILITY | |
| 464 | bool | |
| 465 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 466 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 467 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 468 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y) | |
| 469 | { | |
| 470 | return !(__x == __y); | |
| 471 | } | |
| 472 | ||
| 473 | template <class _CharT, class _Traits, | |
| 474 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 475 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 476 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 477 | basic_ostream<_CharT, _Traits>& | |
| 478 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 479 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 480 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x) | |
| 481 | { | |
| 482 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 483 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 484 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 485 | _CharT __sp = __os.widen(' '); | |
| 486 | __os.fill(__sp); | |
| 487 | __os << __x.__x_[__x.__i_]; | |
| 488 | for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j) | |
| 489 | __os << __sp << __x.__x_[__j]; | |
| 490 | for (size_t __j = 0; __j < __x.__i_; ++__j) | |
| 491 | __os << __sp << __x.__x_[__j]; | |
| 492 | return __os; | |
| 493 | } | |
| 494 | ||
| 495 | template <class _CharT, class _Traits, | |
| 496 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 497 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 498 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 499 | basic_istream<_CharT, _Traits>& | |
| 500 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 501 | mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 502 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x) | |
| 503 | { | |
| 504 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 505 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 506 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 507 | _UInt __t[_Np]; | |
| 508 | for (size_t __i = 0; __i < _Np; ++__i) | |
| 509 | __is >> __t[__i]; | |
| 510 | if (!__is.fail()) | |
| 511 | { | |
| 512 | for (size_t __i = 0; __i < _Np; ++__i) | |
| 513 | __x.__x_[__i] = __t[__i]; | |
| 514 | __x.__i_ = 0; | |
| 515 | } | |
| 516 | return __is; | |
| 517 | } | |
| 518 | ||
| 519 | typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31, | |
| 520 | 0x9908b0df, 11, 0xffffffff, | |
| 521 | 7, 0x9d2c5680, | |
| 522 | 15, 0xefc60000, | |
| 523 | 18, 1812433253> mt19937; | |
| 524 | typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31, | |
| 525 | 0xb5026f5aa96619e9ULL, 29, 0x5555555555555555ULL, | |
| 526 | 17, 0x71d67fffeda60000ULL, | |
| 527 | 37, 0xfff7eee000000000ULL, | |
| 528 | 43, 6364136223846793005ULL> mt19937_64; | |
| 529 | ||
| 530 | _LIBCPP_END_NAMESPACE_STD | |
| 531 | ||
| 532 | _LIBCPP_POP_MACROS | |
| 533 | ||
| 534 | #endif // _LIBCPP___RANDOM_MERSENNE_TWISTER_ENGINE_H |
lib/libcxx/include/__random/negative_binomial_distribution.h created+176| ... | ... | @@ -0,0 +1,176 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_NEGATIVE_BINOMIAL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/bernoulli_distribution.h> | |
| 14 | #include <__random/gamma_distribution.h> | |
| 15 | #include <__random/poisson_distribution.h> | |
| 16 | #include <iosfwd> | |
| 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 | template<class _IntType = int> | |
| 29 | class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution | |
| 30 | { | |
| 31 | public: | |
| 32 | // types | |
| 33 | typedef _IntType result_type; | |
| 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 36 | { | |
| 37 | result_type __k_; | |
| 38 | double __p_; | |
| 39 | public: | |
| 40 | typedef negative_binomial_distribution distribution_type; | |
| 41 | ||
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | explicit param_type(result_type __k = 1, double __p = 0.5) | |
| 44 | : __k_(__k), __p_(__p) {} | |
| 45 | ||
| 46 | _LIBCPP_INLINE_VISIBILITY | |
| 47 | result_type k() const {return __k_;} | |
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | double p() const {return __p_;} | |
| 50 | ||
| 51 | friend _LIBCPP_INLINE_VISIBILITY | |
| 52 | bool operator==(const param_type& __x, const param_type& __y) | |
| 53 | {return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;} | |
| 54 | friend _LIBCPP_INLINE_VISIBILITY | |
| 55 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 56 | {return !(__x == __y);} | |
| 57 | }; | |
| 58 | ||
| 59 | private: | |
| 60 | param_type __p_; | |
| 61 | ||
| 62 | public: | |
| 63 | // constructor and reset functions | |
| 64 | #ifndef _LIBCPP_CXX03_LANG | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | negative_binomial_distribution() : negative_binomial_distribution(1) {} | |
| 67 | _LIBCPP_INLINE_VISIBILITY | |
| 68 | explicit negative_binomial_distribution(result_type __k, double __p = 0.5) | |
| 69 | : __p_(__k, __p) {} | |
| 70 | #else | |
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | explicit negative_binomial_distribution(result_type __k = 1, | |
| 73 | double __p = 0.5) | |
| 74 | : __p_(__k, __p) {} | |
| 75 | #endif | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {} | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | void reset() {} | |
| 80 | ||
| 81 | // generating functions | |
| 82 | template<class _URNG> | |
| 83 | _LIBCPP_INLINE_VISIBILITY | |
| 84 | result_type operator()(_URNG& __g) | |
| 85 | {return (*this)(__g, __p_);} | |
| 86 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 87 | ||
| 88 | // property functions | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | result_type k() const {return __p_.k();} | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | double p() const {return __p_.p();} | |
| 93 | ||
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | param_type param() const {return __p_;} | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | void param(const param_type& __p) {__p_ = __p;} | |
| 98 | ||
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | result_type min() const {return 0;} | |
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | result_type max() const {return numeric_limits<result_type>::max();} | |
| 103 | ||
| 104 | friend _LIBCPP_INLINE_VISIBILITY | |
| 105 | bool operator==(const negative_binomial_distribution& __x, | |
| 106 | const negative_binomial_distribution& __y) | |
| 107 | {return __x.__p_ == __y.__p_;} | |
| 108 | friend _LIBCPP_INLINE_VISIBILITY | |
| 109 | bool operator!=(const negative_binomial_distribution& __x, | |
| 110 | const negative_binomial_distribution& __y) | |
| 111 | {return !(__x == __y);} | |
| 112 | }; | |
| 113 | ||
| 114 | template <class _IntType> | |
| 115 | template<class _URNG> | |
| 116 | _IntType | |
| 117 | negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) | |
| 118 | { | |
| 119 | result_type __k = __pr.k(); | |
| 120 | double __p = __pr.p(); | |
| 121 | if (__k <= 21 * __p) | |
| 122 | { | |
| 123 | bernoulli_distribution __gen(__p); | |
| 124 | result_type __f = 0; | |
| 125 | result_type __s = 0; | |
| 126 | while (__s < __k) | |
| 127 | { | |
| 128 | if (__gen(__urng)) | |
| 129 | ++__s; | |
| 130 | else | |
| 131 | ++__f; | |
| 132 | } | |
| 133 | return __f; | |
| 134 | } | |
| 135 | return poisson_distribution<result_type>(gamma_distribution<double> | |
| 136 | (__k, (1-__p)/__p)(__urng))(__urng); | |
| 137 | } | |
| 138 | ||
| 139 | template <class _CharT, class _Traits, class _IntType> | |
| 140 | basic_ostream<_CharT, _Traits>& | |
| 141 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 142 | const negative_binomial_distribution<_IntType>& __x) | |
| 143 | { | |
| 144 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 145 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 146 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 147 | _OStream::scientific); | |
| 148 | _CharT __sp = __os.widen(' '); | |
| 149 | __os.fill(__sp); | |
| 150 | return __os << __x.k() << __sp << __x.p(); | |
| 151 | } | |
| 152 | ||
| 153 | template <class _CharT, class _Traits, class _IntType> | |
| 154 | basic_istream<_CharT, _Traits>& | |
| 155 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 156 | negative_binomial_distribution<_IntType>& __x) | |
| 157 | { | |
| 158 | typedef negative_binomial_distribution<_IntType> _Eng; | |
| 159 | typedef typename _Eng::result_type result_type; | |
| 160 | typedef typename _Eng::param_type param_type; | |
| 161 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 162 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 163 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 164 | result_type __k; | |
| 165 | double __p; | |
| 166 | __is >> __k >> __p; | |
| 167 | if (!__is.fail()) | |
| 168 | __x.param(param_type(__k, __p)); | |
| 169 | return __is; | |
| 170 | } | |
| 171 | ||
| 172 | _LIBCPP_END_NAMESPACE_STD | |
| 173 | ||
| 174 | _LIBCPP_POP_MACROS | |
| 175 | ||
| 176 | #endif // _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H |
lib/libcxx/include/__random/normal_distribution.h created+208| ... | ... | @@ -0,0 +1,208 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_NORMAL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/uniform_real_distribution.h> | |
| 14 | #include <cmath> | |
| 15 | #include <iosfwd> | |
| 16 | #include <limits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | template<class _RealType = double> | |
| 28 | class _LIBCPP_TEMPLATE_VIS normal_distribution | |
| 29 | { | |
| 30 | public: | |
| 31 | // types | |
| 32 | typedef _RealType result_type; | |
| 33 | ||
| 34 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 35 | { | |
| 36 | result_type __mean_; | |
| 37 | result_type __stddev_; | |
| 38 | public: | |
| 39 | typedef normal_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __mean = 0, result_type __stddev = 1) | |
| 43 | : __mean_(__mean), __stddev_(__stddev) {} | |
| 44 | ||
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | result_type mean() const {return __mean_;} | |
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | result_type stddev() const {return __stddev_;} | |
| 49 | ||
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator==(const param_type& __x, const param_type& __y) | |
| 52 | {return __x.__mean_ == __y.__mean_ && __x.__stddev_ == __y.__stddev_;} | |
| 53 | friend _LIBCPP_INLINE_VISIBILITY | |
| 54 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 55 | {return !(__x == __y);} | |
| 56 | }; | |
| 57 | ||
| 58 | private: | |
| 59 | param_type __p_; | |
| 60 | result_type _V_; | |
| 61 | bool _V_hot_; | |
| 62 | ||
| 63 | public: | |
| 64 | // constructors and reset functions | |
| 65 | #ifndef _LIBCPP_CXX03_LANG | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | normal_distribution() : normal_distribution(0) {} | |
| 68 | _LIBCPP_INLINE_VISIBILITY | |
| 69 | explicit normal_distribution(result_type __mean, result_type __stddev = 1) | |
| 70 | : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} | |
| 71 | #else | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | explicit normal_distribution(result_type __mean = 0, | |
| 74 | result_type __stddev = 1) | |
| 75 | : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} | |
| 76 | #endif | |
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | explicit normal_distribution(const param_type& __p) | |
| 79 | : __p_(__p), _V_hot_(false) {} | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | void reset() {_V_hot_ = false;} | |
| 82 | ||
| 83 | // generating functions | |
| 84 | template<class _URNG> | |
| 85 | _LIBCPP_INLINE_VISIBILITY | |
| 86 | result_type operator()(_URNG& __g) | |
| 87 | {return (*this)(__g, __p_);} | |
| 88 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 89 | ||
| 90 | // property functions | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | result_type mean() const {return __p_.mean();} | |
| 93 | _LIBCPP_INLINE_VISIBILITY | |
| 94 | result_type stddev() const {return __p_.stddev();} | |
| 95 | ||
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | param_type param() const {return __p_;} | |
| 98 | _LIBCPP_INLINE_VISIBILITY | |
| 99 | void param(const param_type& __p) {__p_ = __p;} | |
| 100 | ||
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 103 | _LIBCPP_INLINE_VISIBILITY | |
| 104 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 105 | ||
| 106 | friend _LIBCPP_INLINE_VISIBILITY | |
| 107 | bool operator==(const normal_distribution& __x, | |
| 108 | const normal_distribution& __y) | |
| 109 | {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ && | |
| 110 | (!__x._V_hot_ || __x._V_ == __y._V_);} | |
| 111 | friend _LIBCPP_INLINE_VISIBILITY | |
| 112 | bool operator!=(const normal_distribution& __x, | |
| 113 | const normal_distribution& __y) | |
| 114 | {return !(__x == __y);} | |
| 115 | ||
| 116 | template <class _CharT, class _Traits, class _RT> | |
| 117 | friend | |
| 118 | basic_ostream<_CharT, _Traits>& | |
| 119 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 120 | const normal_distribution<_RT>& __x); | |
| 121 | ||
| 122 | template <class _CharT, class _Traits, class _RT> | |
| 123 | friend | |
| 124 | basic_istream<_CharT, _Traits>& | |
| 125 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 126 | normal_distribution<_RT>& __x); | |
| 127 | }; | |
| 128 | ||
| 129 | template <class _RealType> | |
| 130 | template<class _URNG> | |
| 131 | _RealType | |
| 132 | normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 133 | { | |
| 134 | result_type _Up; | |
| 135 | if (_V_hot_) | |
| 136 | { | |
| 137 | _V_hot_ = false; | |
| 138 | _Up = _V_; | |
| 139 | } | |
| 140 | else | |
| 141 | { | |
| 142 | uniform_real_distribution<result_type> _Uni(-1, 1); | |
| 143 | result_type __u; | |
| 144 | result_type __v; | |
| 145 | result_type __s; | |
| 146 | do | |
| 147 | { | |
| 148 | __u = _Uni(__g); | |
| 149 | __v = _Uni(__g); | |
| 150 | __s = __u * __u + __v * __v; | |
| 151 | } while (__s > 1 || __s == 0); | |
| 152 | result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s); | |
| 153 | _V_ = __v * _Fp; | |
| 154 | _V_hot_ = true; | |
| 155 | _Up = __u * _Fp; | |
| 156 | } | |
| 157 | return _Up * __p.stddev() + __p.mean(); | |
| 158 | } | |
| 159 | ||
| 160 | template <class _CharT, class _Traits, class _RT> | |
| 161 | basic_ostream<_CharT, _Traits>& | |
| 162 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 163 | const normal_distribution<_RT>& __x) | |
| 164 | { | |
| 165 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 166 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 167 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 168 | _OStream::scientific); | |
| 169 | _CharT __sp = __os.widen(' '); | |
| 170 | __os.fill(__sp); | |
| 171 | __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_; | |
| 172 | if (__x._V_hot_) | |
| 173 | __os << __sp << __x._V_; | |
| 174 | return __os; | |
| 175 | } | |
| 176 | ||
| 177 | template <class _CharT, class _Traits, class _RT> | |
| 178 | basic_istream<_CharT, _Traits>& | |
| 179 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 180 | normal_distribution<_RT>& __x) | |
| 181 | { | |
| 182 | typedef normal_distribution<_RT> _Eng; | |
| 183 | typedef typename _Eng::result_type result_type; | |
| 184 | typedef typename _Eng::param_type param_type; | |
| 185 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 186 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 187 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 188 | result_type __mean; | |
| 189 | result_type __stddev; | |
| 190 | result_type _Vp = 0; | |
| 191 | bool _V_hot = false; | |
| 192 | __is >> __mean >> __stddev >> _V_hot; | |
| 193 | if (_V_hot) | |
| 194 | __is >> _Vp; | |
| 195 | if (!__is.fail()) | |
| 196 | { | |
| 197 | __x.param(param_type(__mean, __stddev)); | |
| 198 | __x._V_hot_ = _V_hot; | |
| 199 | __x._V_ = _Vp; | |
| 200 | } | |
| 201 | return __is; | |
| 202 | } | |
| 203 | ||
| 204 | _LIBCPP_END_NAMESPACE_STD | |
| 205 | ||
| 206 | _LIBCPP_POP_MACROS | |
| 207 | ||
| 208 | #endif // _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H |
lib/libcxx/include/__random/piecewise_constant_distribution.h created+356| ... | ... | @@ -0,0 +1,356 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_PIECEWISE_CONSTANT_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__algorithm/upper_bound.h> | |
| 13 | #include <__config> | |
| 14 | #include <__random/uniform_real_distribution.h> | |
| 15 | #include <iosfwd> | |
| 16 | #include <numeric> | |
| 17 | #include <vector> | |
| 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 | template<class _RealType = double> | |
| 29 | class _LIBCPP_TEMPLATE_VIS piecewise_constant_distribution | |
| 30 | { | |
| 31 | public: | |
| 32 | // types | |
| 33 | typedef _RealType result_type; | |
| 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 36 | { | |
| 37 | vector<result_type> __b_; | |
| 38 | vector<result_type> __densities_; | |
| 39 | vector<result_type> __areas_; | |
| 40 | public: | |
| 41 | typedef piecewise_constant_distribution distribution_type; | |
| 42 | ||
| 43 | param_type(); | |
| 44 | template<class _InputIteratorB, class _InputIteratorW> | |
| 45 | param_type(_InputIteratorB __fB, _InputIteratorB __lB, | |
| 46 | _InputIteratorW __fW); | |
| 47 | #ifndef _LIBCPP_CXX03_LANG | |
| 48 | template<class _UnaryOperation> | |
| 49 | param_type(initializer_list<result_type> __bl, _UnaryOperation __fw); | |
| 50 | #endif // _LIBCPP_CXX03_LANG | |
| 51 | template<class _UnaryOperation> | |
| 52 | param_type(size_t __nw, result_type __xmin, result_type __xmax, | |
| 53 | _UnaryOperation __fw); | |
| 54 | param_type(param_type const&) = default; | |
| 55 | param_type & operator=(const param_type& __rhs); | |
| 56 | ||
| 57 | _LIBCPP_INLINE_VISIBILITY | |
| 58 | vector<result_type> intervals() const {return __b_;} | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | vector<result_type> densities() const {return __densities_;} | |
| 61 | ||
| 62 | friend _LIBCPP_INLINE_VISIBILITY | |
| 63 | bool operator==(const param_type& __x, const param_type& __y) | |
| 64 | {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;} | |
| 65 | friend _LIBCPP_INLINE_VISIBILITY | |
| 66 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 67 | {return !(__x == __y);} | |
| 68 | ||
| 69 | private: | |
| 70 | void __init(); | |
| 71 | ||
| 72 | friend class piecewise_constant_distribution; | |
| 73 | ||
| 74 | template <class _CharT, class _Traits, class _RT> | |
| 75 | friend | |
| 76 | basic_ostream<_CharT, _Traits>& | |
| 77 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 78 | const piecewise_constant_distribution<_RT>& __x); | |
| 79 | ||
| 80 | template <class _CharT, class _Traits, class _RT> | |
| 81 | friend | |
| 82 | basic_istream<_CharT, _Traits>& | |
| 83 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 84 | piecewise_constant_distribution<_RT>& __x); | |
| 85 | }; | |
| 86 | ||
| 87 | private: | |
| 88 | param_type __p_; | |
| 89 | ||
| 90 | public: | |
| 91 | // constructor and reset functions | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | piecewise_constant_distribution() {} | |
| 94 | template<class _InputIteratorB, class _InputIteratorW> | |
| 95 | _LIBCPP_INLINE_VISIBILITY | |
| 96 | piecewise_constant_distribution(_InputIteratorB __fB, | |
| 97 | _InputIteratorB __lB, | |
| 98 | _InputIteratorW __fW) | |
| 99 | : __p_(__fB, __lB, __fW) {} | |
| 100 | ||
| 101 | #ifndef _LIBCPP_CXX03_LANG | |
| 102 | template<class _UnaryOperation> | |
| 103 | _LIBCPP_INLINE_VISIBILITY | |
| 104 | piecewise_constant_distribution(initializer_list<result_type> __bl, | |
| 105 | _UnaryOperation __fw) | |
| 106 | : __p_(__bl, __fw) {} | |
| 107 | #endif // _LIBCPP_CXX03_LANG | |
| 108 | ||
| 109 | template<class _UnaryOperation> | |
| 110 | _LIBCPP_INLINE_VISIBILITY | |
| 111 | piecewise_constant_distribution(size_t __nw, result_type __xmin, | |
| 112 | result_type __xmax, _UnaryOperation __fw) | |
| 113 | : __p_(__nw, __xmin, __xmax, __fw) {} | |
| 114 | ||
| 115 | _LIBCPP_INLINE_VISIBILITY | |
| 116 | explicit piecewise_constant_distribution(const param_type& __p) | |
| 117 | : __p_(__p) {} | |
| 118 | ||
| 119 | _LIBCPP_INLINE_VISIBILITY | |
| 120 | void reset() {} | |
| 121 | ||
| 122 | // generating functions | |
| 123 | template<class _URNG> | |
| 124 | _LIBCPP_INLINE_VISIBILITY | |
| 125 | result_type operator()(_URNG& __g) | |
| 126 | {return (*this)(__g, __p_);} | |
| 127 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 128 | ||
| 129 | // property functions | |
| 130 | _LIBCPP_INLINE_VISIBILITY | |
| 131 | vector<result_type> intervals() const {return __p_.intervals();} | |
| 132 | _LIBCPP_INLINE_VISIBILITY | |
| 133 | vector<result_type> densities() const {return __p_.densities();} | |
| 134 | ||
| 135 | _LIBCPP_INLINE_VISIBILITY | |
| 136 | param_type param() const {return __p_;} | |
| 137 | _LIBCPP_INLINE_VISIBILITY | |
| 138 | void param(const param_type& __p) {__p_ = __p;} | |
| 139 | ||
| 140 | _LIBCPP_INLINE_VISIBILITY | |
| 141 | result_type min() const {return __p_.__b_.front();} | |
| 142 | _LIBCPP_INLINE_VISIBILITY | |
| 143 | result_type max() const {return __p_.__b_.back();} | |
| 144 | ||
| 145 | friend _LIBCPP_INLINE_VISIBILITY | |
| 146 | bool operator==(const piecewise_constant_distribution& __x, | |
| 147 | const piecewise_constant_distribution& __y) | |
| 148 | {return __x.__p_ == __y.__p_;} | |
| 149 | friend _LIBCPP_INLINE_VISIBILITY | |
| 150 | bool operator!=(const piecewise_constant_distribution& __x, | |
| 151 | const piecewise_constant_distribution& __y) | |
| 152 | {return !(__x == __y);} | |
| 153 | ||
| 154 | template <class _CharT, class _Traits, class _RT> | |
| 155 | friend | |
| 156 | basic_ostream<_CharT, _Traits>& | |
| 157 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 158 | const piecewise_constant_distribution<_RT>& __x); | |
| 159 | ||
| 160 | template <class _CharT, class _Traits, class _RT> | |
| 161 | friend | |
| 162 | basic_istream<_CharT, _Traits>& | |
| 163 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 164 | piecewise_constant_distribution<_RT>& __x); | |
| 165 | }; | |
| 166 | ||
| 167 | template<class _RealType> | |
| 168 | typename piecewise_constant_distribution<_RealType>::param_type & | |
| 169 | piecewise_constant_distribution<_RealType>::param_type::operator= | |
| 170 | (const param_type& __rhs) | |
| 171 | { | |
| 172 | // These can throw | |
| 173 | __b_.reserve (__rhs.__b_.size ()); | |
| 174 | __densities_.reserve(__rhs.__densities_.size()); | |
| 175 | __areas_.reserve (__rhs.__areas_.size()); | |
| 176 | ||
| 177 | // These can not throw | |
| 178 | __b_ = __rhs.__b_; | |
| 179 | __densities_ = __rhs.__densities_; | |
| 180 | __areas_ = __rhs.__areas_; | |
| 181 | return *this; | |
| 182 | } | |
| 183 | ||
| 184 | template<class _RealType> | |
| 185 | void | |
| 186 | piecewise_constant_distribution<_RealType>::param_type::__init() | |
| 187 | { | |
| 188 | // __densities_ contains non-normalized areas | |
| 189 | result_type __total_area = _VSTD::accumulate(__densities_.begin(), | |
| 190 | __densities_.end(), | |
| 191 | result_type()); | |
| 192 | for (size_t __i = 0; __i < __densities_.size(); ++__i) | |
| 193 | __densities_[__i] /= __total_area; | |
| 194 | // __densities_ contains normalized areas | |
| 195 | __areas_.assign(__densities_.size(), result_type()); | |
| 196 | _VSTD::partial_sum(__densities_.begin(), __densities_.end() - 1, | |
| 197 | __areas_.begin() + 1); | |
| 198 | // __areas_ contains partial sums of normalized areas: [0, __densities_ - 1] | |
| 199 | __densities_.back() = 1 - __areas_.back(); // correct round off error | |
| 200 | for (size_t __i = 0; __i < __densities_.size(); ++__i) | |
| 201 | __densities_[__i] /= (__b_[__i+1] - __b_[__i]); | |
| 202 | // __densities_ now contains __densities_ | |
| 203 | } | |
| 204 | ||
| 205 | template<class _RealType> | |
| 206 | piecewise_constant_distribution<_RealType>::param_type::param_type() | |
| 207 | : __b_(2), | |
| 208 | __densities_(1, 1.0), | |
| 209 | __areas_(1, 0.0) | |
| 210 | { | |
| 211 | __b_[1] = 1; | |
| 212 | } | |
| 213 | ||
| 214 | template<class _RealType> | |
| 215 | template<class _InputIteratorB, class _InputIteratorW> | |
| 216 | piecewise_constant_distribution<_RealType>::param_type::param_type( | |
| 217 | _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) | |
| 218 | : __b_(__fB, __lB) | |
| 219 | { | |
| 220 | if (__b_.size() < 2) | |
| 221 | { | |
| 222 | __b_.resize(2); | |
| 223 | __b_[0] = 0; | |
| 224 | __b_[1] = 1; | |
| 225 | __densities_.assign(1, 1.0); | |
| 226 | __areas_.assign(1, 0.0); | |
| 227 | } | |
| 228 | else | |
| 229 | { | |
| 230 | __densities_.reserve(__b_.size() - 1); | |
| 231 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW) | |
| 232 | __densities_.push_back(*__fW); | |
| 233 | __init(); | |
| 234 | } | |
| 235 | } | |
| 236 | ||
| 237 | #ifndef _LIBCPP_CXX03_LANG | |
| 238 | ||
| 239 | template<class _RealType> | |
| 240 | template<class _UnaryOperation> | |
| 241 | piecewise_constant_distribution<_RealType>::param_type::param_type( | |
| 242 | initializer_list<result_type> __bl, _UnaryOperation __fw) | |
| 243 | : __b_(__bl.begin(), __bl.end()) | |
| 244 | { | |
| 245 | if (__b_.size() < 2) | |
| 246 | { | |
| 247 | __b_.resize(2); | |
| 248 | __b_[0] = 0; | |
| 249 | __b_[1] = 1; | |
| 250 | __densities_.assign(1, 1.0); | |
| 251 | __areas_.assign(1, 0.0); | |
| 252 | } | |
| 253 | else | |
| 254 | { | |
| 255 | __densities_.reserve(__b_.size() - 1); | |
| 256 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i) | |
| 257 | __densities_.push_back(__fw((__b_[__i+1] + __b_[__i])*.5)); | |
| 258 | __init(); | |
| 259 | } | |
| 260 | } | |
| 261 | ||
| 262 | #endif // _LIBCPP_CXX03_LANG | |
| 263 | ||
| 264 | template<class _RealType> | |
| 265 | template<class _UnaryOperation> | |
| 266 | piecewise_constant_distribution<_RealType>::param_type::param_type( | |
| 267 | size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) | |
| 268 | : __b_(__nw == 0 ? 2 : __nw + 1) | |
| 269 | { | |
| 270 | size_t __n = __b_.size() - 1; | |
| 271 | result_type __d = (__xmax - __xmin) / __n; | |
| 272 | __densities_.reserve(__n); | |
| 273 | for (size_t __i = 0; __i < __n; ++__i) | |
| 274 | { | |
| 275 | __b_[__i] = __xmin + __i * __d; | |
| 276 | __densities_.push_back(__fw(__b_[__i] + __d*.5)); | |
| 277 | } | |
| 278 | __b_[__n] = __xmax; | |
| 279 | __init(); | |
| 280 | } | |
| 281 | ||
| 282 | template<class _RealType> | |
| 283 | template<class _URNG> | |
| 284 | _RealType | |
| 285 | piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 286 | { | |
| 287 | typedef uniform_real_distribution<result_type> _Gen; | |
| 288 | result_type __u = _Gen()(__g); | |
| 289 | ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), | |
| 290 | __u) - __p.__areas_.begin() - 1; | |
| 291 | return (__u - __p.__areas_[__k]) / __p.__densities_[__k] + __p.__b_[__k]; | |
| 292 | } | |
| 293 | ||
| 294 | template <class _CharT, class _Traits, class _RT> | |
| 295 | basic_ostream<_CharT, _Traits>& | |
| 296 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 297 | const piecewise_constant_distribution<_RT>& __x) | |
| 298 | { | |
| 299 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 300 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 301 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 302 | _OStream::scientific); | |
| 303 | _CharT __sp = __os.widen(' '); | |
| 304 | __os.fill(__sp); | |
| 305 | size_t __n = __x.__p_.__b_.size(); | |
| 306 | __os << __n; | |
| 307 | for (size_t __i = 0; __i < __n; ++__i) | |
| 308 | __os << __sp << __x.__p_.__b_[__i]; | |
| 309 | __n = __x.__p_.__densities_.size(); | |
| 310 | __os << __sp << __n; | |
| 311 | for (size_t __i = 0; __i < __n; ++__i) | |
| 312 | __os << __sp << __x.__p_.__densities_[__i]; | |
| 313 | __n = __x.__p_.__areas_.size(); | |
| 314 | __os << __sp << __n; | |
| 315 | for (size_t __i = 0; __i < __n; ++__i) | |
| 316 | __os << __sp << __x.__p_.__areas_[__i]; | |
| 317 | return __os; | |
| 318 | } | |
| 319 | ||
| 320 | template <class _CharT, class _Traits, class _RT> | |
| 321 | basic_istream<_CharT, _Traits>& | |
| 322 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 323 | piecewise_constant_distribution<_RT>& __x) | |
| 324 | { | |
| 325 | typedef piecewise_constant_distribution<_RT> _Eng; | |
| 326 | typedef typename _Eng::result_type result_type; | |
| 327 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 328 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 329 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 330 | size_t __n; | |
| 331 | __is >> __n; | |
| 332 | vector<result_type> __b(__n); | |
| 333 | for (size_t __i = 0; __i < __n; ++__i) | |
| 334 | __is >> __b[__i]; | |
| 335 | __is >> __n; | |
| 336 | vector<result_type> __densities(__n); | |
| 337 | for (size_t __i = 0; __i < __n; ++__i) | |
| 338 | __is >> __densities[__i]; | |
| 339 | __is >> __n; | |
| 340 | vector<result_type> __areas(__n); | |
| 341 | for (size_t __i = 0; __i < __n; ++__i) | |
| 342 | __is >> __areas[__i]; | |
| 343 | if (!__is.fail()) | |
| 344 | { | |
| 345 | swap(__x.__p_.__b_, __b); | |
| 346 | swap(__x.__p_.__densities_, __densities); | |
| 347 | swap(__x.__p_.__areas_, __areas); | |
| 348 | } | |
| 349 | return __is; | |
| 350 | } | |
| 351 | ||
| 352 | _LIBCPP_END_NAMESPACE_STD | |
| 353 | ||
| 354 | _LIBCPP_POP_MACROS | |
| 355 | ||
| 356 | #endif // _LIBCPP___RANDOM_PIECEWISE_CONSTANT_DISTRIBUTION_H |
lib/libcxx/include/__random/piecewise_linear_distribution.h created+372| ... | ... | @@ -0,0 +1,372 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_PIECEWISE_LINEAR_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__algorithm/upper_bound.h> | |
| 13 | #include <__config> | |
| 14 | #include <__random/uniform_real_distribution.h> | |
| 15 | #include <iosfwd> | |
| 16 | #include <numeric> | |
| 17 | #include <vector> | |
| 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 | template<class _RealType = double> | |
| 29 | class _LIBCPP_TEMPLATE_VIS piecewise_linear_distribution | |
| 30 | { | |
| 31 | public: | |
| 32 | // types | |
| 33 | typedef _RealType result_type; | |
| 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 36 | { | |
| 37 | vector<result_type> __b_; | |
| 38 | vector<result_type> __densities_; | |
| 39 | vector<result_type> __areas_; | |
| 40 | public: | |
| 41 | typedef piecewise_linear_distribution distribution_type; | |
| 42 | ||
| 43 | param_type(); | |
| 44 | template<class _InputIteratorB, class _InputIteratorW> | |
| 45 | param_type(_InputIteratorB __fB, _InputIteratorB __lB, | |
| 46 | _InputIteratorW __fW); | |
| 47 | #ifndef _LIBCPP_CXX03_LANG | |
| 48 | template<class _UnaryOperation> | |
| 49 | param_type(initializer_list<result_type> __bl, _UnaryOperation __fw); | |
| 50 | #endif // _LIBCPP_CXX03_LANG | |
| 51 | template<class _UnaryOperation> | |
| 52 | param_type(size_t __nw, result_type __xmin, result_type __xmax, | |
| 53 | _UnaryOperation __fw); | |
| 54 | param_type(param_type const&) = default; | |
| 55 | param_type & operator=(const param_type& __rhs); | |
| 56 | ||
| 57 | _LIBCPP_INLINE_VISIBILITY | |
| 58 | vector<result_type> intervals() const {return __b_;} | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | vector<result_type> densities() const {return __densities_;} | |
| 61 | ||
| 62 | friend _LIBCPP_INLINE_VISIBILITY | |
| 63 | bool operator==(const param_type& __x, const param_type& __y) | |
| 64 | {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;} | |
| 65 | friend _LIBCPP_INLINE_VISIBILITY | |
| 66 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 67 | {return !(__x == __y);} | |
| 68 | ||
| 69 | private: | |
| 70 | void __init(); | |
| 71 | ||
| 72 | friend class piecewise_linear_distribution; | |
| 73 | ||
| 74 | template <class _CharT, class _Traits, class _RT> | |
| 75 | friend | |
| 76 | basic_ostream<_CharT, _Traits>& | |
| 77 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 78 | const piecewise_linear_distribution<_RT>& __x); | |
| 79 | ||
| 80 | template <class _CharT, class _Traits, class _RT> | |
| 81 | friend | |
| 82 | basic_istream<_CharT, _Traits>& | |
| 83 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 84 | piecewise_linear_distribution<_RT>& __x); | |
| 85 | }; | |
| 86 | ||
| 87 | private: | |
| 88 | param_type __p_; | |
| 89 | ||
| 90 | public: | |
| 91 | // constructor and reset functions | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | piecewise_linear_distribution() {} | |
| 94 | template<class _InputIteratorB, class _InputIteratorW> | |
| 95 | _LIBCPP_INLINE_VISIBILITY | |
| 96 | piecewise_linear_distribution(_InputIteratorB __fB, | |
| 97 | _InputIteratorB __lB, | |
| 98 | _InputIteratorW __fW) | |
| 99 | : __p_(__fB, __lB, __fW) {} | |
| 100 | ||
| 101 | #ifndef _LIBCPP_CXX03_LANG | |
| 102 | template<class _UnaryOperation> | |
| 103 | _LIBCPP_INLINE_VISIBILITY | |
| 104 | piecewise_linear_distribution(initializer_list<result_type> __bl, | |
| 105 | _UnaryOperation __fw) | |
| 106 | : __p_(__bl, __fw) {} | |
| 107 | #endif // _LIBCPP_CXX03_LANG | |
| 108 | ||
| 109 | template<class _UnaryOperation> | |
| 110 | _LIBCPP_INLINE_VISIBILITY | |
| 111 | piecewise_linear_distribution(size_t __nw, result_type __xmin, | |
| 112 | result_type __xmax, _UnaryOperation __fw) | |
| 113 | : __p_(__nw, __xmin, __xmax, __fw) {} | |
| 114 | ||
| 115 | _LIBCPP_INLINE_VISIBILITY | |
| 116 | explicit piecewise_linear_distribution(const param_type& __p) | |
| 117 | : __p_(__p) {} | |
| 118 | ||
| 119 | _LIBCPP_INLINE_VISIBILITY | |
| 120 | void reset() {} | |
| 121 | ||
| 122 | // generating functions | |
| 123 | template<class _URNG> | |
| 124 | _LIBCPP_INLINE_VISIBILITY | |
| 125 | result_type operator()(_URNG& __g) | |
| 126 | {return (*this)(__g, __p_);} | |
| 127 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 128 | ||
| 129 | // property functions | |
| 130 | _LIBCPP_INLINE_VISIBILITY | |
| 131 | vector<result_type> intervals() const {return __p_.intervals();} | |
| 132 | _LIBCPP_INLINE_VISIBILITY | |
| 133 | vector<result_type> densities() const {return __p_.densities();} | |
| 134 | ||
| 135 | _LIBCPP_INLINE_VISIBILITY | |
| 136 | param_type param() const {return __p_;} | |
| 137 | _LIBCPP_INLINE_VISIBILITY | |
| 138 | void param(const param_type& __p) {__p_ = __p;} | |
| 139 | ||
| 140 | _LIBCPP_INLINE_VISIBILITY | |
| 141 | result_type min() const {return __p_.__b_.front();} | |
| 142 | _LIBCPP_INLINE_VISIBILITY | |
| 143 | result_type max() const {return __p_.__b_.back();} | |
| 144 | ||
| 145 | friend _LIBCPP_INLINE_VISIBILITY | |
| 146 | bool operator==(const piecewise_linear_distribution& __x, | |
| 147 | const piecewise_linear_distribution& __y) | |
| 148 | {return __x.__p_ == __y.__p_;} | |
| 149 | friend _LIBCPP_INLINE_VISIBILITY | |
| 150 | bool operator!=(const piecewise_linear_distribution& __x, | |
| 151 | const piecewise_linear_distribution& __y) | |
| 152 | {return !(__x == __y);} | |
| 153 | ||
| 154 | template <class _CharT, class _Traits, class _RT> | |
| 155 | friend | |
| 156 | basic_ostream<_CharT, _Traits>& | |
| 157 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 158 | const piecewise_linear_distribution<_RT>& __x); | |
| 159 | ||
| 160 | template <class _CharT, class _Traits, class _RT> | |
| 161 | friend | |
| 162 | basic_istream<_CharT, _Traits>& | |
| 163 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 164 | piecewise_linear_distribution<_RT>& __x); | |
| 165 | }; | |
| 166 | ||
| 167 | template<class _RealType> | |
| 168 | typename piecewise_linear_distribution<_RealType>::param_type & | |
| 169 | piecewise_linear_distribution<_RealType>::param_type::operator= | |
| 170 | (const param_type& __rhs) | |
| 171 | { | |
| 172 | // These can throw | |
| 173 | __b_.reserve (__rhs.__b_.size ()); | |
| 174 | __densities_.reserve(__rhs.__densities_.size()); | |
| 175 | __areas_.reserve (__rhs.__areas_.size()); | |
| 176 | ||
| 177 | // These can not throw | |
| 178 | __b_ = __rhs.__b_; | |
| 179 | __densities_ = __rhs.__densities_; | |
| 180 | __areas_ = __rhs.__areas_; | |
| 181 | return *this; | |
| 182 | } | |
| 183 | ||
| 184 | ||
| 185 | template<class _RealType> | |
| 186 | void | |
| 187 | piecewise_linear_distribution<_RealType>::param_type::__init() | |
| 188 | { | |
| 189 | __areas_.assign(__densities_.size() - 1, result_type()); | |
| 190 | result_type _Sp = 0; | |
| 191 | for (size_t __i = 0; __i < __areas_.size(); ++__i) | |
| 192 | { | |
| 193 | __areas_[__i] = (__densities_[__i+1] + __densities_[__i]) * | |
| 194 | (__b_[__i+1] - __b_[__i]) * .5; | |
| 195 | _Sp += __areas_[__i]; | |
| 196 | } | |
| 197 | for (size_t __i = __areas_.size(); __i > 1;) | |
| 198 | { | |
| 199 | --__i; | |
| 200 | __areas_[__i] = __areas_[__i-1] / _Sp; | |
| 201 | } | |
| 202 | __areas_[0] = 0; | |
| 203 | for (size_t __i = 1; __i < __areas_.size(); ++__i) | |
| 204 | __areas_[__i] += __areas_[__i-1]; | |
| 205 | for (size_t __i = 0; __i < __densities_.size(); ++__i) | |
| 206 | __densities_[__i] /= _Sp; | |
| 207 | } | |
| 208 | ||
| 209 | template<class _RealType> | |
| 210 | piecewise_linear_distribution<_RealType>::param_type::param_type() | |
| 211 | : __b_(2), | |
| 212 | __densities_(2, 1.0), | |
| 213 | __areas_(1, 0.0) | |
| 214 | { | |
| 215 | __b_[1] = 1; | |
| 216 | } | |
| 217 | ||
| 218 | template<class _RealType> | |
| 219 | template<class _InputIteratorB, class _InputIteratorW> | |
| 220 | piecewise_linear_distribution<_RealType>::param_type::param_type( | |
| 221 | _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) | |
| 222 | : __b_(__fB, __lB) | |
| 223 | { | |
| 224 | if (__b_.size() < 2) | |
| 225 | { | |
| 226 | __b_.resize(2); | |
| 227 | __b_[0] = 0; | |
| 228 | __b_[1] = 1; | |
| 229 | __densities_.assign(2, 1.0); | |
| 230 | __areas_.assign(1, 0.0); | |
| 231 | } | |
| 232 | else | |
| 233 | { | |
| 234 | __densities_.reserve(__b_.size()); | |
| 235 | for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW) | |
| 236 | __densities_.push_back(*__fW); | |
| 237 | __init(); | |
| 238 | } | |
| 239 | } | |
| 240 | ||
| 241 | #ifndef _LIBCPP_CXX03_LANG | |
| 242 | ||
| 243 | template<class _RealType> | |
| 244 | template<class _UnaryOperation> | |
| 245 | piecewise_linear_distribution<_RealType>::param_type::param_type( | |
| 246 | initializer_list<result_type> __bl, _UnaryOperation __fw) | |
| 247 | : __b_(__bl.begin(), __bl.end()) | |
| 248 | { | |
| 249 | if (__b_.size() < 2) | |
| 250 | { | |
| 251 | __b_.resize(2); | |
| 252 | __b_[0] = 0; | |
| 253 | __b_[1] = 1; | |
| 254 | __densities_.assign(2, 1.0); | |
| 255 | __areas_.assign(1, 0.0); | |
| 256 | } | |
| 257 | else | |
| 258 | { | |
| 259 | __densities_.reserve(__b_.size()); | |
| 260 | for (size_t __i = 0; __i < __b_.size(); ++__i) | |
| 261 | __densities_.push_back(__fw(__b_[__i])); | |
| 262 | __init(); | |
| 263 | } | |
| 264 | } | |
| 265 | ||
| 266 | #endif // _LIBCPP_CXX03_LANG | |
| 267 | ||
| 268 | template<class _RealType> | |
| 269 | template<class _UnaryOperation> | |
| 270 | piecewise_linear_distribution<_RealType>::param_type::param_type( | |
| 271 | size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) | |
| 272 | : __b_(__nw == 0 ? 2 : __nw + 1) | |
| 273 | { | |
| 274 | size_t __n = __b_.size() - 1; | |
| 275 | result_type __d = (__xmax - __xmin) / __n; | |
| 276 | __densities_.reserve(__b_.size()); | |
| 277 | for (size_t __i = 0; __i < __n; ++__i) | |
| 278 | { | |
| 279 | __b_[__i] = __xmin + __i * __d; | |
| 280 | __densities_.push_back(__fw(__b_[__i])); | |
| 281 | } | |
| 282 | __b_[__n] = __xmax; | |
| 283 | __densities_.push_back(__fw(__b_[__n])); | |
| 284 | __init(); | |
| 285 | } | |
| 286 | ||
| 287 | template<class _RealType> | |
| 288 | template<class _URNG> | |
| 289 | _RealType | |
| 290 | piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 291 | { | |
| 292 | typedef uniform_real_distribution<result_type> _Gen; | |
| 293 | result_type __u = _Gen()(__g); | |
| 294 | ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), | |
| 295 | __u) - __p.__areas_.begin() - 1; | |
| 296 | __u -= __p.__areas_[__k]; | |
| 297 | const result_type __dk = __p.__densities_[__k]; | |
| 298 | const result_type __dk1 = __p.__densities_[__k+1]; | |
| 299 | const result_type __deltad = __dk1 - __dk; | |
| 300 | const result_type __bk = __p.__b_[__k]; | |
| 301 | if (__deltad == 0) | |
| 302 | return __u / __dk + __bk; | |
| 303 | const result_type __bk1 = __p.__b_[__k+1]; | |
| 304 | const result_type __deltab = __bk1 - __bk; | |
| 305 | return (__bk * __dk1 - __bk1 * __dk + | |
| 306 | _VSTD::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) / | |
| 307 | __deltad; | |
| 308 | } | |
| 309 | ||
| 310 | template <class _CharT, class _Traits, class _RT> | |
| 311 | basic_ostream<_CharT, _Traits>& | |
| 312 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 313 | const piecewise_linear_distribution<_RT>& __x) | |
| 314 | { | |
| 315 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 316 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 317 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 318 | _OStream::scientific); | |
| 319 | _CharT __sp = __os.widen(' '); | |
| 320 | __os.fill(__sp); | |
| 321 | size_t __n = __x.__p_.__b_.size(); | |
| 322 | __os << __n; | |
| 323 | for (size_t __i = 0; __i < __n; ++__i) | |
| 324 | __os << __sp << __x.__p_.__b_[__i]; | |
| 325 | __n = __x.__p_.__densities_.size(); | |
| 326 | __os << __sp << __n; | |
| 327 | for (size_t __i = 0; __i < __n; ++__i) | |
| 328 | __os << __sp << __x.__p_.__densities_[__i]; | |
| 329 | __n = __x.__p_.__areas_.size(); | |
| 330 | __os << __sp << __n; | |
| 331 | for (size_t __i = 0; __i < __n; ++__i) | |
| 332 | __os << __sp << __x.__p_.__areas_[__i]; | |
| 333 | return __os; | |
| 334 | } | |
| 335 | ||
| 336 | template <class _CharT, class _Traits, class _RT> | |
| 337 | basic_istream<_CharT, _Traits>& | |
| 338 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 339 | piecewise_linear_distribution<_RT>& __x) | |
| 340 | { | |
| 341 | typedef piecewise_linear_distribution<_RT> _Eng; | |
| 342 | typedef typename _Eng::result_type result_type; | |
| 343 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 344 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 345 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 346 | size_t __n; | |
| 347 | __is >> __n; | |
| 348 | vector<result_type> __b(__n); | |
| 349 | for (size_t __i = 0; __i < __n; ++__i) | |
| 350 | __is >> __b[__i]; | |
| 351 | __is >> __n; | |
| 352 | vector<result_type> __densities(__n); | |
| 353 | for (size_t __i = 0; __i < __n; ++__i) | |
| 354 | __is >> __densities[__i]; | |
| 355 | __is >> __n; | |
| 356 | vector<result_type> __areas(__n); | |
| 357 | for (size_t __i = 0; __i < __n; ++__i) | |
| 358 | __is >> __areas[__i]; | |
| 359 | if (!__is.fail()) | |
| 360 | { | |
| 361 | swap(__x.__p_.__b_, __b); | |
| 362 | swap(__x.__p_.__densities_, __densities); | |
| 363 | swap(__x.__p_.__areas_, __areas); | |
| 364 | } | |
| 365 | return __is; | |
| 366 | } | |
| 367 | ||
| 368 | _LIBCPP_END_NAMESPACE_STD | |
| 369 | ||
| 370 | _LIBCPP_POP_MACROS | |
| 371 | ||
| 372 | #endif // _LIBCPP___RANDOM_PIECEWISE_LINEAR_DISTRIBUTION_H |
lib/libcxx/include/__random/poisson_distribution.h created+277| ... | ... | @@ -0,0 +1,277 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_POISSON_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_POISSON_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/clamp_to_integral.h> | |
| 14 | #include <__random/exponential_distribution.h> | |
| 15 | #include <__random/normal_distribution.h> | |
| 16 | #include <__random/uniform_real_distribution.h> | |
| 17 | #include <cmath> | |
| 18 | #include <iosfwd> | |
| 19 | #include <limits> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | #pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | template<class _IntType = int> | |
| 31 | class _LIBCPP_TEMPLATE_VIS poisson_distribution | |
| 32 | { | |
| 33 | public: | |
| 34 | // types | |
| 35 | typedef _IntType result_type; | |
| 36 | ||
| 37 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 38 | { | |
| 39 | double __mean_; | |
| 40 | double __s_; | |
| 41 | double __d_; | |
| 42 | double __l_; | |
| 43 | double __omega_; | |
| 44 | double __c0_; | |
| 45 | double __c1_; | |
| 46 | double __c2_; | |
| 47 | double __c3_; | |
| 48 | double __c_; | |
| 49 | ||
| 50 | public: | |
| 51 | typedef poisson_distribution distribution_type; | |
| 52 | ||
| 53 | explicit param_type(double __mean = 1.0); | |
| 54 | ||
| 55 | _LIBCPP_INLINE_VISIBILITY | |
| 56 | double mean() const {return __mean_;} | |
| 57 | ||
| 58 | friend _LIBCPP_INLINE_VISIBILITY | |
| 59 | bool operator==(const param_type& __x, const param_type& __y) | |
| 60 | {return __x.__mean_ == __y.__mean_;} | |
| 61 | friend _LIBCPP_INLINE_VISIBILITY | |
| 62 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 63 | {return !(__x == __y);} | |
| 64 | ||
| 65 | friend class poisson_distribution; | |
| 66 | }; | |
| 67 | ||
| 68 | private: | |
| 69 | param_type __p_; | |
| 70 | ||
| 71 | public: | |
| 72 | // constructors and reset functions | |
| 73 | #ifndef _LIBCPP_CXX03_LANG | |
| 74 | _LIBCPP_INLINE_VISIBILITY | |
| 75 | poisson_distribution() : poisson_distribution(1.0) {} | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | explicit poisson_distribution(double __mean) | |
| 78 | : __p_(__mean) {} | |
| 79 | #else | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | explicit poisson_distribution(double __mean = 1.0) | |
| 82 | : __p_(__mean) {} | |
| 83 | #endif | |
| 84 | _LIBCPP_INLINE_VISIBILITY | |
| 85 | explicit poisson_distribution(const param_type& __p) : __p_(__p) {} | |
| 86 | _LIBCPP_INLINE_VISIBILITY | |
| 87 | void reset() {} | |
| 88 | ||
| 89 | // generating functions | |
| 90 | template<class _URNG> | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | result_type operator()(_URNG& __g) | |
| 93 | {return (*this)(__g, __p_);} | |
| 94 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 95 | ||
| 96 | // property functions | |
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | double mean() const {return __p_.mean();} | |
| 99 | ||
| 100 | _LIBCPP_INLINE_VISIBILITY | |
| 101 | param_type param() const {return __p_;} | |
| 102 | _LIBCPP_INLINE_VISIBILITY | |
| 103 | void param(const param_type& __p) {__p_ = __p;} | |
| 104 | ||
| 105 | _LIBCPP_INLINE_VISIBILITY | |
| 106 | result_type min() const {return 0;} | |
| 107 | _LIBCPP_INLINE_VISIBILITY | |
| 108 | result_type max() const {return numeric_limits<result_type>::max();} | |
| 109 | ||
| 110 | friend _LIBCPP_INLINE_VISIBILITY | |
| 111 | bool operator==(const poisson_distribution& __x, | |
| 112 | const poisson_distribution& __y) | |
| 113 | {return __x.__p_ == __y.__p_;} | |
| 114 | friend _LIBCPP_INLINE_VISIBILITY | |
| 115 | bool operator!=(const poisson_distribution& __x, | |
| 116 | const poisson_distribution& __y) | |
| 117 | {return !(__x == __y);} | |
| 118 | }; | |
| 119 | ||
| 120 | template<class _IntType> | |
| 121 | poisson_distribution<_IntType>::param_type::param_type(double __mean) | |
| 122 | // According to the standard `inf` is a valid input, but it causes the | |
| 123 | // distribution to hang, so we replace it with the maximum representable | |
| 124 | // mean. | |
| 125 | : __mean_(isinf(__mean) ? numeric_limits<double>::max() : __mean) | |
| 126 | { | |
| 127 | if (__mean_ < 10) | |
| 128 | { | |
| 129 | __s_ = 0; | |
| 130 | __d_ = 0; | |
| 131 | __l_ = _VSTD::exp(-__mean_); | |
| 132 | __omega_ = 0; | |
| 133 | __c3_ = 0; | |
| 134 | __c2_ = 0; | |
| 135 | __c1_ = 0; | |
| 136 | __c0_ = 0; | |
| 137 | __c_ = 0; | |
| 138 | } | |
| 139 | else | |
| 140 | { | |
| 141 | __s_ = _VSTD::sqrt(__mean_); | |
| 142 | __d_ = 6 * __mean_ * __mean_; | |
| 143 | __l_ = _VSTD::trunc(__mean_ - 1.1484); | |
| 144 | __omega_ = .3989423 / __s_; | |
| 145 | double __b1_ = .4166667E-1 / __mean_; | |
| 146 | double __b2_ = .3 * __b1_ * __b1_; | |
| 147 | __c3_ = .1428571 * __b1_ * __b2_; | |
| 148 | __c2_ = __b2_ - 15. * __c3_; | |
| 149 | __c1_ = __b1_ - 6. * __b2_ + 45. * __c3_; | |
| 150 | __c0_ = 1. - __b1_ + 3. * __b2_ - 15. * __c3_; | |
| 151 | __c_ = .1069 / __mean_; | |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 155 | template <class _IntType> | |
| 156 | template<class _URNG> | |
| 157 | _IntType | |
| 158 | poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) | |
| 159 | { | |
| 160 | double __tx; | |
| 161 | uniform_real_distribution<double> __urd; | |
| 162 | if (__pr.__mean_ < 10) | |
| 163 | { | |
| 164 | __tx = 0; | |
| 165 | for (double __p = __urd(__urng); __p > __pr.__l_; ++__tx) | |
| 166 | __p *= __urd(__urng); | |
| 167 | } | |
| 168 | else | |
| 169 | { | |
| 170 | double __difmuk; | |
| 171 | double __g = __pr.__mean_ + __pr.__s_ * normal_distribution<double>()(__urng); | |
| 172 | double __u; | |
| 173 | if (__g > 0) | |
| 174 | { | |
| 175 | __tx = _VSTD::trunc(__g); | |
| 176 | if (__tx >= __pr.__l_) | |
| 177 | return _VSTD::__clamp_to_integral<result_type>(__tx); | |
| 178 | __difmuk = __pr.__mean_ - __tx; | |
| 179 | __u = __urd(__urng); | |
| 180 | if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk) | |
| 181 | return _VSTD::__clamp_to_integral<result_type>(__tx); | |
| 182 | } | |
| 183 | exponential_distribution<double> __edist; | |
| 184 | for (bool __using_exp_dist = false; true; __using_exp_dist = true) | |
| 185 | { | |
| 186 | double __e; | |
| 187 | if (__using_exp_dist || __g <= 0) | |
| 188 | { | |
| 189 | double __t; | |
| 190 | do | |
| 191 | { | |
| 192 | __e = __edist(__urng); | |
| 193 | __u = __urd(__urng); | |
| 194 | __u += __u - 1; | |
| 195 | __t = 1.8 + (__u < 0 ? -__e : __e); | |
| 196 | } while (__t <= -.6744); | |
| 197 | __tx = _VSTD::trunc(__pr.__mean_ + __pr.__s_ * __t); | |
| 198 | __difmuk = __pr.__mean_ - __tx; | |
| 199 | __using_exp_dist = true; | |
| 200 | } | |
| 201 | double __px; | |
| 202 | double __py; | |
| 203 | if (__tx < 10 && __tx >= 0) | |
| 204 | { | |
| 205 | const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, | |
| 206 | 40320, 362880}; | |
| 207 | __px = -__pr.__mean_; | |
| 208 | __py = _VSTD::pow(__pr.__mean_, (double)__tx) / __fac[static_cast<int>(__tx)]; | |
| 209 | } | |
| 210 | else | |
| 211 | { | |
| 212 | double __del = .8333333E-1 / __tx; | |
| 213 | __del -= 4.8 * __del * __del * __del; | |
| 214 | double __v = __difmuk / __tx; | |
| 215 | if (_VSTD::abs(__v) > 0.25) | |
| 216 | __px = __tx * _VSTD::log(1 + __v) - __difmuk - __del; | |
| 217 | else | |
| 218 | __px = __tx * __v * __v * (((((((.1250060 * __v + -.1384794) * | |
| 219 | __v + .1421878) * __v + -.1661269) * __v + .2000118) * | |
| 220 | __v + -.2500068) * __v + .3333333) * __v + -.5) - __del; | |
| 221 | __py = .3989423 / _VSTD::sqrt(__tx); | |
| 222 | } | |
| 223 | double __r = (0.5 - __difmuk) / __pr.__s_; | |
| 224 | double __r2 = __r * __r; | |
| 225 | double __fx = -0.5 * __r2; | |
| 226 | double __fy = __pr.__omega_ * (((__pr.__c3_ * __r2 + __pr.__c2_) * | |
| 227 | __r2 + __pr.__c1_) * __r2 + __pr.__c0_); | |
| 228 | if (__using_exp_dist) | |
| 229 | { | |
| 230 | if (__pr.__c_ * _VSTD::abs(__u) <= __py * _VSTD::exp(__px + __e) - | |
| 231 | __fy * _VSTD::exp(__fx + __e)) | |
| 232 | break; | |
| 233 | } | |
| 234 | else | |
| 235 | { | |
| 236 | if (__fy - __u * __fy <= __py * _VSTD::exp(__px - __fx)) | |
| 237 | break; | |
| 238 | } | |
| 239 | } | |
| 240 | } | |
| 241 | return _VSTD::__clamp_to_integral<result_type>(__tx); | |
| 242 | } | |
| 243 | ||
| 244 | template <class _CharT, class _Traits, class _IntType> | |
| 245 | basic_ostream<_CharT, _Traits>& | |
| 246 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 247 | const poisson_distribution<_IntType>& __x) | |
| 248 | { | |
| 249 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 250 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 251 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 252 | _OStream::scientific); | |
| 253 | return __os << __x.mean(); | |
| 254 | } | |
| 255 | ||
| 256 | template <class _CharT, class _Traits, class _IntType> | |
| 257 | basic_istream<_CharT, _Traits>& | |
| 258 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 259 | poisson_distribution<_IntType>& __x) | |
| 260 | { | |
| 261 | typedef poisson_distribution<_IntType> _Eng; | |
| 262 | typedef typename _Eng::param_type param_type; | |
| 263 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 264 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 265 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 266 | double __mean; | |
| 267 | __is >> __mean; | |
| 268 | if (!__is.fail()) | |
| 269 | __x.param(param_type(__mean)); | |
| 270 | return __is; | |
| 271 | } | |
| 272 | ||
| 273 | _LIBCPP_END_NAMESPACE_STD | |
| 274 | ||
| 275 | _LIBCPP_POP_MACROS | |
| 276 | ||
| 277 | #endif // _LIBCPP___RANDOM_POISSON_DISTRIBUTION_H |
lib/libcxx/include/__random/random_device.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___RANDOM_RANDOM_DEVICE_H | |
| 10 | #define _LIBCPP___RANDOM_RANDOM_DEVICE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <string> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE) | |
| 25 | ||
| 26 | class _LIBCPP_TYPE_VIS random_device | |
| 27 | { | |
| 28 | #ifdef _LIBCPP_USING_DEV_RANDOM | |
| 29 | int __f_; | |
| 30 | #elif !defined(_LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT) | |
| 31 | # if defined(__clang__) | |
| 32 | # pragma clang diagnostic push | |
| 33 | # pragma clang diagnostic ignored "-Wunused-private-field" | |
| 34 | # endif | |
| 35 | ||
| 36 | // 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, we | |
| 38 | // retain the same layout as before. | |
| 39 | # if defined(__APPLE__) | |
| 40 | int __padding_; // padding to fake the `__f_` field above | |
| 41 | # endif | |
| 42 | ||
| 43 | // ... vendors can add workarounds here if they switch to a different representation ... | |
| 44 | ||
| 45 | # if defined(__clang__) | |
| 46 | # pragma clang diagnostic pop | |
| 47 | # endif | |
| 48 | #endif | |
| 49 | ||
| 50 | public: | |
| 51 | // types | |
| 52 | typedef unsigned result_type; | |
| 53 | ||
| 54 | // generator characteristics | |
| 55 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 56 | static _LIBCPP_CONSTEXPR const result_type _Max = 0xFFFFFFFFu; | |
| 57 | ||
| 58 | _LIBCPP_INLINE_VISIBILITY | |
| 59 | static _LIBCPP_CONSTEXPR result_type min() { return _Min;} | |
| 60 | _LIBCPP_INLINE_VISIBILITY | |
| 61 | static _LIBCPP_CONSTEXPR result_type max() { return _Max;} | |
| 62 | ||
| 63 | // constructors | |
| 64 | #ifndef _LIBCPP_CXX03_LANG | |
| 65 | random_device() : random_device("/dev/urandom") {} | |
| 66 | explicit random_device(const string& __token); | |
| 67 | #else | |
| 68 | explicit random_device(const string& __token = "/dev/urandom"); | |
| 69 | #endif | |
| 70 | ~random_device(); | |
| 71 | ||
| 72 | // generating functions | |
| 73 | result_type operator()(); | |
| 74 | ||
| 75 | // property functions | |
| 76 | double entropy() const _NOEXCEPT; | |
| 77 | ||
| 78 | random_device(const random_device&) = delete; | |
| 79 | void operator=(const random_device&) = delete; | |
| 80 | }; | |
| 81 | ||
| 82 | #endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE | |
| 83 | ||
| 84 | _LIBCPP_END_NAMESPACE_STD | |
| 85 | ||
| 86 | _LIBCPP_POP_MACROS | |
| 87 | ||
| 88 | #endif // _LIBCPP___RANDOM_RANDOM_DEVICE_H |
lib/libcxx/include/__random/ranlux.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___RANDOM_RANLUX_H | |
| 10 | #define _LIBCPP___RANDOM_RANLUX_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/discard_block_engine.h> | |
| 14 | #include <__random/subtract_with_carry_engine.h> | |
| 15 | #include <cstdint> | |
| 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 | typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base; | |
| 24 | typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base; | |
| 25 | ||
| 26 | typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24; | |
| 27 | typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48; | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___RANDOM_RANLUX_H |
lib/libcxx/include/__random/seed_seq.h created+153| ... | ... | @@ -0,0 +1,153 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_SEED_SEQ_H | |
| 10 | #define _LIBCPP___RANDOM_SEED_SEQ_H | |
| 11 | ||
| 12 | #include <__algorithm/copy.h> | |
| 13 | #include <__algorithm/fill.h> | |
| 14 | #include <__algorithm/max.h> | |
| 15 | #include <__config> | |
| 16 | #include <initializer_list> | |
| 17 | #include <vector> | |
| 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 | class _LIBCPP_TEMPLATE_VIS seed_seq | |
| 29 | { | |
| 30 | public: | |
| 31 | // types | |
| 32 | typedef uint32_t result_type; | |
| 33 | ||
| 34 | // constructors | |
| 35 | _LIBCPP_INLINE_VISIBILITY | |
| 36 | seed_seq() _NOEXCEPT {} | |
| 37 | #ifndef _LIBCPP_CXX03_LANG | |
| 38 | template<class _Tp, __enable_if_t<is_integral<_Tp>::value>* = nullptr> | |
| 39 | _LIBCPP_INLINE_VISIBILITY | |
| 40 | seed_seq(initializer_list<_Tp> __il) { | |
| 41 | __init(__il.begin(), __il.end()); | |
| 42 | } | |
| 43 | #endif // _LIBCPP_CXX03_LANG | |
| 44 | ||
| 45 | template<class _InputIterator> | |
| 46 | _LIBCPP_INLINE_VISIBILITY | |
| 47 | seed_seq(_InputIterator __first, _InputIterator __last) { | |
| 48 | static_assert(is_integral<typename iterator_traits<_InputIterator>::value_type>::value, | |
| 49 | "Mandates: iterator_traits<InputIterator>::value_type is an integer type"); | |
| 50 | __init(__first, __last); | |
| 51 | } | |
| 52 | ||
| 53 | // generating functions | |
| 54 | template<class _RandomAccessIterator> | |
| 55 | void generate(_RandomAccessIterator __first, _RandomAccessIterator __last); | |
| 56 | ||
| 57 | // property functions | |
| 58 | _LIBCPP_INLINE_VISIBILITY | |
| 59 | size_t size() const _NOEXCEPT {return __v_.size();} | |
| 60 | template<class _OutputIterator> | |
| 61 | _LIBCPP_INLINE_VISIBILITY | |
| 62 | void param(_OutputIterator __dest) const | |
| 63 | {_VSTD::copy(__v_.begin(), __v_.end(), __dest);} | |
| 64 | ||
| 65 | seed_seq(const seed_seq&) = delete; | |
| 66 | void operator=(const seed_seq&) = delete; | |
| 67 | ||
| 68 | _LIBCPP_INLINE_VISIBILITY | |
| 69 | static result_type _Tp(result_type __x) {return __x ^ (__x >> 27);} | |
| 70 | ||
| 71 | private: | |
| 72 | template<class _InputIterator> | |
| 73 | void __init(_InputIterator __first, _InputIterator __last); | |
| 74 | ||
| 75 | vector<result_type> __v_; | |
| 76 | }; | |
| 77 | ||
| 78 | template<class _InputIterator> | |
| 79 | void | |
| 80 | seed_seq::__init(_InputIterator __first, _InputIterator __last) | |
| 81 | { | |
| 82 | for (_InputIterator __s = __first; __s != __last; ++__s) | |
| 83 | __v_.push_back(*__s & 0xFFFFFFFF); | |
| 84 | } | |
| 85 | ||
| 86 | template<class _RandomAccessIterator> | |
| 87 | void | |
| 88 | seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 89 | { | |
| 90 | if (__first != __last) | |
| 91 | { | |
| 92 | _VSTD::fill(__first, __last, 0x8b8b8b8b); | |
| 93 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 94 | const size_t __s = __v_.size(); | |
| 95 | const size_t __t = (__n >= 623) ? 11 | |
| 96 | : (__n >= 68) ? 7 | |
| 97 | : (__n >= 39) ? 5 | |
| 98 | : (__n >= 7) ? 3 | |
| 99 | : (__n - 1) / 2; | |
| 100 | const size_t __p = (__n - __t) / 2; | |
| 101 | const size_t __q = __p + __t; | |
| 102 | const size_t __m = _VSTD::max(__s + 1, __n); | |
| 103 | // __k = 0; | |
| 104 | { | |
| 105 | result_type __r = 1664525 * _Tp(__first[0] ^ __first[__p] | |
| 106 | ^ __first[__n - 1]); | |
| 107 | __first[__p] += __r; | |
| 108 | __r += __s; | |
| 109 | __first[__q] += __r; | |
| 110 | __first[0] = __r; | |
| 111 | } | |
| 112 | for (size_t __k = 1; __k <= __s; ++__k) | |
| 113 | { | |
| 114 | const size_t __kmodn = __k % __n; | |
| 115 | const size_t __kpmodn = (__k + __p) % __n; | |
| 116 | result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] | |
| 117 | ^ __first[(__k - 1) % __n]); | |
| 118 | __first[__kpmodn] += __r; | |
| 119 | __r += __kmodn + __v_[__k-1]; | |
| 120 | __first[(__k + __q) % __n] += __r; | |
| 121 | __first[__kmodn] = __r; | |
| 122 | } | |
| 123 | for (size_t __k = __s + 1; __k < __m; ++__k) | |
| 124 | { | |
| 125 | const size_t __kmodn = __k % __n; | |
| 126 | const size_t __kpmodn = (__k + __p) % __n; | |
| 127 | result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] | |
| 128 | ^ __first[(__k - 1) % __n]); | |
| 129 | __first[__kpmodn] += __r; | |
| 130 | __r += __kmodn; | |
| 131 | __first[(__k + __q) % __n] += __r; | |
| 132 | __first[__kmodn] = __r; | |
| 133 | } | |
| 134 | for (size_t __k = __m; __k < __m + __n; ++__k) | |
| 135 | { | |
| 136 | const size_t __kmodn = __k % __n; | |
| 137 | const size_t __kpmodn = (__k + __p) % __n; | |
| 138 | result_type __r = 1566083941 * _Tp(__first[__kmodn] + | |
| 139 | __first[__kpmodn] + | |
| 140 | __first[(__k - 1) % __n]); | |
| 141 | __first[__kpmodn] ^= __r; | |
| 142 | __r -= __kmodn; | |
| 143 | __first[(__k + __q) % __n] ^= __r; | |
| 144 | __first[__kmodn] = __r; | |
| 145 | } | |
| 146 | } | |
| 147 | } | |
| 148 | ||
| 149 | _LIBCPP_END_NAMESPACE_STD | |
| 150 | ||
| 151 | _LIBCPP_POP_MACROS | |
| 152 | ||
| 153 | #endif // _LIBCPP___RANDOM_SEED_SEQ_H |
lib/libcxx/include/__random/shuffle_order_engine.h created+283| ... | ... | @@ -0,0 +1,283 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_SHUFFLE_ORDER_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_SHUFFLE_ORDER_ENGINE_H | |
| 11 | ||
| 12 | #include <__algorithm/equal.h> | |
| 13 | #include <__config> | |
| 14 | #include <__random/is_seed_sequence.h> | |
| 15 | #include <__utility/move.h> | |
| 16 | #include <cstdint> | |
| 17 | #include <iosfwd> | |
| 18 | #include <type_traits> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | template <uint64_t _Xp, uint64_t _Yp> | |
| 30 | struct __ugcd | |
| 31 | { | |
| 32 | static _LIBCPP_CONSTEXPR const uint64_t value = __ugcd<_Yp, _Xp % _Yp>::value; | |
| 33 | }; | |
| 34 | ||
| 35 | template <uint64_t _Xp> | |
| 36 | struct __ugcd<_Xp, 0> | |
| 37 | { | |
| 38 | static _LIBCPP_CONSTEXPR const uint64_t value = _Xp; | |
| 39 | }; | |
| 40 | ||
| 41 | template <uint64_t _Np, uint64_t _Dp> | |
| 42 | class __uratio | |
| 43 | { | |
| 44 | static_assert(_Dp != 0, "__uratio divide by 0"); | |
| 45 | static _LIBCPP_CONSTEXPR const uint64_t __gcd = __ugcd<_Np, _Dp>::value; | |
| 46 | public: | |
| 47 | static _LIBCPP_CONSTEXPR const uint64_t num = _Np / __gcd; | |
| 48 | static _LIBCPP_CONSTEXPR const uint64_t den = _Dp / __gcd; | |
| 49 | ||
| 50 | typedef __uratio<num, den> type; | |
| 51 | }; | |
| 52 | ||
| 53 | template<class _Engine, size_t __k> | |
| 54 | class _LIBCPP_TEMPLATE_VIS shuffle_order_engine | |
| 55 | { | |
| 56 | static_assert(0 < __k, "shuffle_order_engine invalid parameters"); | |
| 57 | public: | |
| 58 | // types | |
| 59 | typedef typename _Engine::result_type result_type; | |
| 60 | ||
| 61 | private: | |
| 62 | _Engine __e_; | |
| 63 | result_type _V_[__k]; | |
| 64 | result_type _Y_; | |
| 65 | ||
| 66 | public: | |
| 67 | // engine characteristics | |
| 68 | static _LIBCPP_CONSTEXPR const size_t table_size = __k; | |
| 69 | ||
| 70 | #ifdef _LIBCPP_CXX03_LANG | |
| 71 | static const result_type _Min = _Engine::_Min; | |
| 72 | static const result_type _Max = _Engine::_Max; | |
| 73 | #else | |
| 74 | static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); | |
| 75 | static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); | |
| 76 | #endif | |
| 77 | static_assert(_Min < _Max, "shuffle_order_engine invalid parameters"); | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 82 | ||
| 83 | static _LIBCPP_CONSTEXPR const unsigned long long _Rp = _Max - _Min + 1ull; | |
| 84 | ||
| 85 | // constructors and seeding functions | |
| 86 | _LIBCPP_INLINE_VISIBILITY | |
| 87 | shuffle_order_engine() {__init();} | |
| 88 | _LIBCPP_INLINE_VISIBILITY | |
| 89 | explicit shuffle_order_engine(const _Engine& __e) | |
| 90 | : __e_(__e) {__init();} | |
| 91 | #ifndef _LIBCPP_CXX03_LANG | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | explicit shuffle_order_engine(_Engine&& __e) | |
| 94 | : __e_(_VSTD::move(__e)) {__init();} | |
| 95 | #endif // _LIBCPP_CXX03_LANG | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();} | |
| 98 | template<class _Sseq> | |
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | explicit shuffle_order_engine(_Sseq& __q, | |
| 101 | typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value && | |
| 102 | !is_convertible<_Sseq, _Engine>::value>::type* = 0) | |
| 103 | : __e_(__q) {__init();} | |
| 104 | _LIBCPP_INLINE_VISIBILITY | |
| 105 | void seed() {__e_.seed(); __init();} | |
| 106 | _LIBCPP_INLINE_VISIBILITY | |
| 107 | void seed(result_type __sd) {__e_.seed(__sd); __init();} | |
| 108 | template<class _Sseq> | |
| 109 | _LIBCPP_INLINE_VISIBILITY | |
| 110 | typename enable_if | |
| 111 | < | |
| 112 | __is_seed_sequence<_Sseq, shuffle_order_engine>::value, | |
| 113 | void | |
| 114 | >::type | |
| 115 | seed(_Sseq& __q) {__e_.seed(__q); __init();} | |
| 116 | ||
| 117 | // generating functions | |
| 118 | _LIBCPP_INLINE_VISIBILITY | |
| 119 | result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());} | |
| 120 | _LIBCPP_INLINE_VISIBILITY | |
| 121 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 122 | ||
| 123 | // property functions | |
| 124 | _LIBCPP_INLINE_VISIBILITY | |
| 125 | const _Engine& base() const _NOEXCEPT {return __e_;} | |
| 126 | ||
| 127 | private: | |
| 128 | template<class _Eng, size_t _Kp> | |
| 129 | friend | |
| 130 | bool | |
| 131 | operator==( | |
| 132 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 133 | const shuffle_order_engine<_Eng, _Kp>& __y); | |
| 134 | ||
| 135 | template<class _Eng, size_t _Kp> | |
| 136 | friend | |
| 137 | bool | |
| 138 | operator!=( | |
| 139 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 140 | const shuffle_order_engine<_Eng, _Kp>& __y); | |
| 141 | ||
| 142 | template <class _CharT, class _Traits, | |
| 143 | class _Eng, size_t _Kp> | |
| 144 | friend | |
| 145 | basic_ostream<_CharT, _Traits>& | |
| 146 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 147 | const shuffle_order_engine<_Eng, _Kp>& __x); | |
| 148 | ||
| 149 | template <class _CharT, class _Traits, | |
| 150 | class _Eng, size_t _Kp> | |
| 151 | friend | |
| 152 | basic_istream<_CharT, _Traits>& | |
| 153 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 154 | shuffle_order_engine<_Eng, _Kp>& __x); | |
| 155 | ||
| 156 | _LIBCPP_INLINE_VISIBILITY | |
| 157 | void __init() | |
| 158 | { | |
| 159 | for (size_t __i = 0; __i < __k; ++__i) | |
| 160 | _V_[__i] = __e_(); | |
| 161 | _Y_ = __e_(); | |
| 162 | } | |
| 163 | ||
| 164 | _LIBCPP_INLINE_VISIBILITY | |
| 165 | result_type __eval(false_type) {return __eval2(integral_constant<bool, __k & 1>());} | |
| 166 | _LIBCPP_INLINE_VISIBILITY | |
| 167 | result_type __eval(true_type) {return __eval(__uratio<__k, _Rp>());} | |
| 168 | ||
| 169 | _LIBCPP_INLINE_VISIBILITY | |
| 170 | result_type __eval2(false_type) {return __eval(__uratio<__k/2, 0x8000000000000000ull>());} | |
| 171 | _LIBCPP_INLINE_VISIBILITY | |
| 172 | result_type __eval2(true_type) {return __evalf<__k, 0>();} | |
| 173 | ||
| 174 | template <uint64_t _Np, uint64_t _Dp> | |
| 175 | _LIBCPP_INLINE_VISIBILITY | |
| 176 | typename enable_if | |
| 177 | < | |
| 178 | (__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)), | |
| 179 | result_type | |
| 180 | >::type | |
| 181 | __eval(__uratio<_Np, _Dp>) | |
| 182 | {return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();} | |
| 183 | ||
| 184 | template <uint64_t _Np, uint64_t _Dp> | |
| 185 | _LIBCPP_INLINE_VISIBILITY | |
| 186 | typename enable_if | |
| 187 | < | |
| 188 | __uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min), | |
| 189 | result_type | |
| 190 | >::type | |
| 191 | __eval(__uratio<_Np, _Dp>) | |
| 192 | { | |
| 193 | const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (_Y_ - _Min) | |
| 194 | / __uratio<_Np, _Dp>::den); | |
| 195 | _Y_ = _V_[__j]; | |
| 196 | _V_[__j] = __e_(); | |
| 197 | return _Y_; | |
| 198 | } | |
| 199 | ||
| 200 | template <uint64_t __n, uint64_t __d> | |
| 201 | _LIBCPP_INLINE_VISIBILITY | |
| 202 | result_type __evalf() | |
| 203 | { | |
| 204 | const double _Fp = __d == 0 ? | |
| 205 | __n / (2. * 0x8000000000000000ull) : | |
| 206 | __n / (double)__d; | |
| 207 | const size_t __j = static_cast<size_t>(_Fp * (_Y_ - _Min)); | |
| 208 | _Y_ = _V_[__j]; | |
| 209 | _V_[__j] = __e_(); | |
| 210 | return _Y_; | |
| 211 | } | |
| 212 | }; | |
| 213 | ||
| 214 | template<class _Engine, size_t __k> | |
| 215 | _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size; | |
| 216 | ||
| 217 | template<class _Eng, size_t _Kp> | |
| 218 | bool | |
| 219 | operator==( | |
| 220 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 221 | const shuffle_order_engine<_Eng, _Kp>& __y) | |
| 222 | { | |
| 223 | return __x._Y_ == __y._Y_ && _VSTD::equal(__x._V_, __x._V_ + _Kp, __y._V_) && | |
| 224 | __x.__e_ == __y.__e_; | |
| 225 | } | |
| 226 | ||
| 227 | template<class _Eng, size_t _Kp> | |
| 228 | inline _LIBCPP_INLINE_VISIBILITY | |
| 229 | bool | |
| 230 | operator!=( | |
| 231 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 232 | const shuffle_order_engine<_Eng, _Kp>& __y) | |
| 233 | { | |
| 234 | return !(__x == __y); | |
| 235 | } | |
| 236 | ||
| 237 | template <class _CharT, class _Traits, | |
| 238 | class _Eng, size_t _Kp> | |
| 239 | basic_ostream<_CharT, _Traits>& | |
| 240 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 241 | const shuffle_order_engine<_Eng, _Kp>& __x) | |
| 242 | { | |
| 243 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 244 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 245 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 246 | _CharT __sp = __os.widen(' '); | |
| 247 | __os.fill(__sp); | |
| 248 | __os << __x.__e_ << __sp << __x._V_[0]; | |
| 249 | for (size_t __i = 1; __i < _Kp; ++__i) | |
| 250 | __os << __sp << __x._V_[__i]; | |
| 251 | return __os << __sp << __x._Y_; | |
| 252 | } | |
| 253 | ||
| 254 | template <class _CharT, class _Traits, | |
| 255 | class _Eng, size_t _Kp> | |
| 256 | basic_istream<_CharT, _Traits>& | |
| 257 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 258 | shuffle_order_engine<_Eng, _Kp>& __x) | |
| 259 | { | |
| 260 | typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type; | |
| 261 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 262 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 263 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 264 | _Eng __e; | |
| 265 | result_type _Vp[_Kp+1]; | |
| 266 | __is >> __e; | |
| 267 | for (size_t __i = 0; __i < _Kp+1; ++__i) | |
| 268 | __is >> _Vp[__i]; | |
| 269 | if (!__is.fail()) | |
| 270 | { | |
| 271 | __x.__e_ = __e; | |
| 272 | for (size_t __i = 0; __i < _Kp; ++__i) | |
| 273 | __x._V_[__i] = _Vp[__i]; | |
| 274 | __x._Y_ = _Vp[_Kp]; | |
| 275 | } | |
| 276 | return __is; | |
| 277 | } | |
| 278 | ||
| 279 | _LIBCPP_END_NAMESPACE_STD | |
| 280 | ||
| 281 | _LIBCPP_POP_MACROS | |
| 282 | ||
| 283 | #endif // _LIBCPP___RANDOM_SHUFFLE_ORDER_ENGINE_H |
lib/libcxx/include/__random/student_t_distribution.h created+153| ... | ... | @@ -0,0 +1,153 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_STUDENT_T_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_STUDENT_T_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/gamma_distribution.h> | |
| 14 | #include <__random/normal_distribution.h> | |
| 15 | #include <cmath> | |
| 16 | #include <iosfwd> | |
| 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 | template<class _RealType = double> | |
| 29 | class _LIBCPP_TEMPLATE_VIS student_t_distribution | |
| 30 | { | |
| 31 | public: | |
| 32 | // types | |
| 33 | typedef _RealType result_type; | |
| 34 | ||
| 35 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 36 | { | |
| 37 | result_type __n_; | |
| 38 | public: | |
| 39 | typedef student_t_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __n = 1) : __n_(__n) {} | |
| 43 | ||
| 44 | _LIBCPP_INLINE_VISIBILITY | |
| 45 | result_type n() const {return __n_;} | |
| 46 | ||
| 47 | friend _LIBCPP_INLINE_VISIBILITY | |
| 48 | bool operator==(const param_type& __x, const param_type& __y) | |
| 49 | {return __x.__n_ == __y.__n_;} | |
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 52 | {return !(__x == __y);} | |
| 53 | }; | |
| 54 | ||
| 55 | private: | |
| 56 | param_type __p_; | |
| 57 | normal_distribution<result_type> __nd_; | |
| 58 | ||
| 59 | public: | |
| 60 | // constructor and reset functions | |
| 61 | #ifndef _LIBCPP_CXX03_LANG | |
| 62 | _LIBCPP_INLINE_VISIBILITY | |
| 63 | student_t_distribution() : student_t_distribution(1) {} | |
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | explicit student_t_distribution(result_type __n) | |
| 66 | : __p_(param_type(__n)) {} | |
| 67 | #else | |
| 68 | _LIBCPP_INLINE_VISIBILITY | |
| 69 | explicit student_t_distribution(result_type __n = 1) | |
| 70 | : __p_(param_type(__n)) {} | |
| 71 | #endif | |
| 72 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | explicit student_t_distribution(const param_type& __p) | |
| 74 | : __p_(__p) {} | |
| 75 | _LIBCPP_INLINE_VISIBILITY | |
| 76 | void reset() {__nd_.reset();} | |
| 77 | ||
| 78 | // generating functions | |
| 79 | template<class _URNG> | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | result_type operator()(_URNG& __g) | |
| 82 | {return (*this)(__g, __p_);} | |
| 83 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 84 | ||
| 85 | // property functions | |
| 86 | _LIBCPP_INLINE_VISIBILITY | |
| 87 | result_type n() const {return __p_.n();} | |
| 88 | ||
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | param_type param() const {return __p_;} | |
| 91 | _LIBCPP_INLINE_VISIBILITY | |
| 92 | void param(const param_type& __p) {__p_ = __p;} | |
| 93 | ||
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 96 | _LIBCPP_INLINE_VISIBILITY | |
| 97 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 98 | ||
| 99 | friend _LIBCPP_INLINE_VISIBILITY | |
| 100 | bool operator==(const student_t_distribution& __x, | |
| 101 | const student_t_distribution& __y) | |
| 102 | {return __x.__p_ == __y.__p_;} | |
| 103 | friend _LIBCPP_INLINE_VISIBILITY | |
| 104 | bool operator!=(const student_t_distribution& __x, | |
| 105 | const student_t_distribution& __y) | |
| 106 | {return !(__x == __y);} | |
| 107 | }; | |
| 108 | ||
| 109 | template <class _RealType> | |
| 110 | template<class _URNG> | |
| 111 | _RealType | |
| 112 | student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 113 | { | |
| 114 | gamma_distribution<result_type> __gd(__p.n() * .5, 2); | |
| 115 | return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g)); | |
| 116 | } | |
| 117 | ||
| 118 | template <class _CharT, class _Traits, class _RT> | |
| 119 | basic_ostream<_CharT, _Traits>& | |
| 120 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 121 | const student_t_distribution<_RT>& __x) | |
| 122 | { | |
| 123 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 124 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 125 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 126 | _OStream::scientific); | |
| 127 | __os << __x.n(); | |
| 128 | return __os; | |
| 129 | } | |
| 130 | ||
| 131 | template <class _CharT, class _Traits, class _RT> | |
| 132 | basic_istream<_CharT, _Traits>& | |
| 133 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 134 | student_t_distribution<_RT>& __x) | |
| 135 | { | |
| 136 | typedef student_t_distribution<_RT> _Eng; | |
| 137 | typedef typename _Eng::result_type result_type; | |
| 138 | typedef typename _Eng::param_type param_type; | |
| 139 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 140 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 141 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 142 | result_type __n; | |
| 143 | __is >> __n; | |
| 144 | if (!__is.fail()) | |
| 145 | __x.param(param_type(__n)); | |
| 146 | return __is; | |
| 147 | } | |
| 148 | ||
| 149 | _LIBCPP_END_NAMESPACE_STD | |
| 150 | ||
| 151 | _LIBCPP_POP_MACROS | |
| 152 | ||
| 153 | #endif // _LIBCPP___RANDOM_STUDENT_T_DISTRIBUTION_H |
lib/libcxx/include/__random/subtract_with_carry_engine.h created+352| ... | ... | @@ -0,0 +1,352 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_SUBTRACT_WITH_CARRY_ENGINE_H | |
| 10 | #define _LIBCPP___RANDOM_SUBTRACT_WITH_CARRY_ENGINE_H | |
| 11 | ||
| 12 | #include <__algorithm/equal.h> | |
| 13 | #include <__algorithm/min.h> | |
| 14 | #include <__config> | |
| 15 | #include <__random/is_seed_sequence.h> | |
| 16 | #include <__random/linear_congruential_engine.h> | |
| 17 | #include <cstddef> | |
| 18 | #include <cstdint> | |
| 19 | #include <iosfwd> | |
| 20 | #include <limits> | |
| 21 | #include <type_traits> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | #pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_PUSH_MACROS | |
| 28 | #include <__undef_macros> | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 33 | class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine; | |
| 34 | ||
| 35 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 36 | bool | |
| 37 | operator==( | |
| 38 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 39 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 40 | ||
| 41 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 42 | _LIBCPP_INLINE_VISIBILITY | |
| 43 | bool | |
| 44 | operator!=( | |
| 45 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 46 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 47 | ||
| 48 | template <class _CharT, class _Traits, | |
| 49 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 50 | basic_ostream<_CharT, _Traits>& | |
| 51 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 52 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 53 | ||
| 54 | template <class _CharT, class _Traits, | |
| 55 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 56 | basic_istream<_CharT, _Traits>& | |
| 57 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 58 | subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 59 | ||
| 60 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 61 | class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine | |
| 62 | { | |
| 63 | public: | |
| 64 | // types | |
| 65 | typedef _UIntType result_type; | |
| 66 | ||
| 67 | private: | |
| 68 | result_type __x_[__r]; | |
| 69 | result_type __c_; | |
| 70 | size_t __i_; | |
| 71 | ||
| 72 | static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; | |
| 73 | static_assert( 0 < __w, "subtract_with_carry_engine invalid parameters"); | |
| 74 | static_assert(__w <= _Dt, "subtract_with_carry_engine invalid parameters"); | |
| 75 | static_assert( 0 < __s, "subtract_with_carry_engine invalid parameters"); | |
| 76 | static_assert(__s < __r, "subtract_with_carry_engine invalid parameters"); | |
| 77 | public: | |
| 78 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 79 | static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : | |
| 80 | (result_type(1) << __w) - result_type(1); | |
| 81 | static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters"); | |
| 82 | ||
| 83 | // engine characteristics | |
| 84 | static _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 85 | static _LIBCPP_CONSTEXPR const size_t short_lag = __s; | |
| 86 | static _LIBCPP_CONSTEXPR const size_t long_lag = __r; | |
| 87 | _LIBCPP_INLINE_VISIBILITY | |
| 88 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 91 | static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; | |
| 92 | ||
| 93 | // constructors and seeding functions | |
| 94 | #ifndef _LIBCPP_CXX03_LANG | |
| 95 | _LIBCPP_INLINE_VISIBILITY | |
| 96 | subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} | |
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | explicit subtract_with_carry_engine(result_type __sd) { seed(__sd); } | |
| 99 | #else | |
| 100 | _LIBCPP_INLINE_VISIBILITY | |
| 101 | explicit subtract_with_carry_engine(result_type __sd = default_seed) { | |
| 102 | seed(__sd); | |
| 103 | } | |
| 104 | #endif | |
| 105 | template<class _Sseq> | |
| 106 | _LIBCPP_INLINE_VISIBILITY | |
| 107 | explicit subtract_with_carry_engine(_Sseq& __q, | |
| 108 | typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0) | |
| 109 | {seed(__q);} | |
| 110 | _LIBCPP_INLINE_VISIBILITY | |
| 111 | void seed(result_type __sd = default_seed) | |
| 112 | {seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());} | |
| 113 | template<class _Sseq> | |
| 114 | _LIBCPP_INLINE_VISIBILITY | |
| 115 | typename enable_if | |
| 116 | < | |
| 117 | __is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, | |
| 118 | void | |
| 119 | >::type | |
| 120 | seed(_Sseq& __q) | |
| 121 | {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());} | |
| 122 | ||
| 123 | // generating functions | |
| 124 | result_type operator()(); | |
| 125 | _LIBCPP_INLINE_VISIBILITY | |
| 126 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 127 | ||
| 128 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 129 | friend | |
| 130 | bool | |
| 131 | operator==( | |
| 132 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 133 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 134 | ||
| 135 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 136 | friend | |
| 137 | bool | |
| 138 | operator!=( | |
| 139 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 140 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 141 | ||
| 142 | template <class _CharT, class _Traits, | |
| 143 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 144 | friend | |
| 145 | basic_ostream<_CharT, _Traits>& | |
| 146 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 147 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 148 | ||
| 149 | template <class _CharT, class _Traits, | |
| 150 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 151 | friend | |
| 152 | basic_istream<_CharT, _Traits>& | |
| 153 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 154 | subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 155 | ||
| 156 | private: | |
| 157 | ||
| 158 | void seed(result_type __sd, integral_constant<unsigned, 1>); | |
| 159 | void seed(result_type __sd, integral_constant<unsigned, 2>); | |
| 160 | template<class _Sseq> | |
| 161 | void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | |
| 162 | template<class _Sseq> | |
| 163 | void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | |
| 164 | }; | |
| 165 | ||
| 166 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 167 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; | |
| 168 | ||
| 169 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 170 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; | |
| 171 | ||
| 172 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 173 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; | |
| 174 | ||
| 175 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 176 | _LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type | |
| 177 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; | |
| 178 | ||
| 179 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 180 | void | |
| 181 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, | |
| 182 | integral_constant<unsigned, 1>) | |
| 183 | { | |
| 184 | linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> | |
| 185 | __e(__sd == 0u ? default_seed : __sd); | |
| 186 | for (size_t __i = 0; __i < __r; ++__i) | |
| 187 | __x_[__i] = static_cast<result_type>(__e() & _Max); | |
| 188 | __c_ = __x_[__r-1] == 0; | |
| 189 | __i_ = 0; | |
| 190 | } | |
| 191 | ||
| 192 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 193 | void | |
| 194 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, | |
| 195 | integral_constant<unsigned, 2>) | |
| 196 | { | |
| 197 | linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> | |
| 198 | __e(__sd == 0u ? default_seed : __sd); | |
| 199 | for (size_t __i = 0; __i < __r; ++__i) | |
| 200 | { | |
| 201 | result_type __e0 = __e(); | |
| 202 | __x_[__i] = static_cast<result_type>( | |
| 203 | (__e0 + ((uint64_t)__e() << 32)) & _Max); | |
| 204 | } | |
| 205 | __c_ = __x_[__r-1] == 0; | |
| 206 | __i_ = 0; | |
| 207 | } | |
| 208 | ||
| 209 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 210 | template<class _Sseq> | |
| 211 | void | |
| 212 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, | |
| 213 | integral_constant<unsigned, 1>) | |
| 214 | { | |
| 215 | const unsigned __k = 1; | |
| 216 | uint32_t __ar[__r * __k]; | |
| 217 | __q.generate(__ar, __ar + __r * __k); | |
| 218 | for (size_t __i = 0; __i < __r; ++__i) | |
| 219 | __x_[__i] = static_cast<result_type>(__ar[__i] & _Max); | |
| 220 | __c_ = __x_[__r-1] == 0; | |
| 221 | __i_ = 0; | |
| 222 | } | |
| 223 | ||
| 224 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 225 | template<class _Sseq> | |
| 226 | void | |
| 227 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, | |
| 228 | integral_constant<unsigned, 2>) | |
| 229 | { | |
| 230 | const unsigned __k = 2; | |
| 231 | uint32_t __ar[__r * __k]; | |
| 232 | __q.generate(__ar, __ar + __r * __k); | |
| 233 | for (size_t __i = 0; __i < __r; ++__i) | |
| 234 | __x_[__i] = static_cast<result_type>( | |
| 235 | (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); | |
| 236 | __c_ = __x_[__r-1] == 0; | |
| 237 | __i_ = 0; | |
| 238 | } | |
| 239 | ||
| 240 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 241 | _UIntType | |
| 242 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()() | |
| 243 | { | |
| 244 | const result_type& __xs = __x_[(__i_ + (__r - __s)) % __r]; | |
| 245 | result_type& __xr = __x_[__i_]; | |
| 246 | result_type __new_c = __c_ == 0 ? __xs < __xr : __xs != 0 ? __xs <= __xr : 1; | |
| 247 | __xr = (__xs - __xr - __c_) & _Max; | |
| 248 | __c_ = __new_c; | |
| 249 | __i_ = (__i_ + 1) % __r; | |
| 250 | return __xr; | |
| 251 | } | |
| 252 | ||
| 253 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 254 | bool | |
| 255 | operator==( | |
| 256 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 257 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y) | |
| 258 | { | |
| 259 | if (__x.__c_ != __y.__c_) | |
| 260 | return false; | |
| 261 | if (__x.__i_ == __y.__i_) | |
| 262 | return _VSTD::equal(__x.__x_, __x.__x_ + _Rp, __y.__x_); | |
| 263 | if (__x.__i_ == 0 || __y.__i_ == 0) | |
| 264 | { | |
| 265 | size_t __j = _VSTD::min(_Rp - __x.__i_, _Rp - __y.__i_); | |
| 266 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, | |
| 267 | __y.__x_ + __y.__i_)) | |
| 268 | return false; | |
| 269 | if (__x.__i_ == 0) | |
| 270 | return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Rp, __y.__x_); | |
| 271 | return _VSTD::equal(__x.__x_, __x.__x_ + (_Rp - __j), __y.__x_ + __j); | |
| 272 | } | |
| 273 | if (__x.__i_ < __y.__i_) | |
| 274 | { | |
| 275 | size_t __j = _Rp - __y.__i_; | |
| 276 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), | |
| 277 | __y.__x_ + __y.__i_)) | |
| 278 | return false; | |
| 279 | if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Rp, | |
| 280 | __y.__x_)) | |
| 281 | return false; | |
| 282 | return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, | |
| 283 | __y.__x_ + (_Rp - (__x.__i_ + __j))); | |
| 284 | } | |
| 285 | size_t __j = _Rp - __x.__i_; | |
| 286 | if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), | |
| 287 | __x.__x_ + __x.__i_)) | |
| 288 | return false; | |
| 289 | if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Rp, | |
| 290 | __x.__x_)) | |
| 291 | return false; | |
| 292 | return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, | |
| 293 | __x.__x_ + (_Rp - (__y.__i_ + __j))); | |
| 294 | } | |
| 295 | ||
| 296 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 297 | inline _LIBCPP_INLINE_VISIBILITY | |
| 298 | bool | |
| 299 | operator!=( | |
| 300 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 301 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y) | |
| 302 | { | |
| 303 | return !(__x == __y); | |
| 304 | } | |
| 305 | ||
| 306 | template <class _CharT, class _Traits, | |
| 307 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 308 | basic_ostream<_CharT, _Traits>& | |
| 309 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 310 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x) | |
| 311 | { | |
| 312 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 313 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 314 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 315 | _CharT __sp = __os.widen(' '); | |
| 316 | __os.fill(__sp); | |
| 317 | __os << __x.__x_[__x.__i_]; | |
| 318 | for (size_t __j = __x.__i_ + 1; __j < _Rp; ++__j) | |
| 319 | __os << __sp << __x.__x_[__j]; | |
| 320 | for (size_t __j = 0; __j < __x.__i_; ++__j) | |
| 321 | __os << __sp << __x.__x_[__j]; | |
| 322 | __os << __sp << __x.__c_; | |
| 323 | return __os; | |
| 324 | } | |
| 325 | ||
| 326 | template <class _CharT, class _Traits, | |
| 327 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 328 | basic_istream<_CharT, _Traits>& | |
| 329 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 330 | subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x) | |
| 331 | { | |
| 332 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 333 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 334 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 335 | _UInt __t[_Rp+1]; | |
| 336 | for (size_t __i = 0; __i < _Rp+1; ++__i) | |
| 337 | __is >> __t[__i]; | |
| 338 | if (!__is.fail()) | |
| 339 | { | |
| 340 | for (size_t __i = 0; __i < _Rp; ++__i) | |
| 341 | __x.__x_[__i] = __t[__i]; | |
| 342 | __x.__c_ = __t[_Rp]; | |
| 343 | __x.__i_ = 0; | |
| 344 | } | |
| 345 | return __is; | |
| 346 | } | |
| 347 | ||
| 348 | _LIBCPP_END_NAMESPACE_STD | |
| 349 | ||
| 350 | _LIBCPP_POP_MACROS | |
| 351 | ||
| 352 | #endif // _LIBCPP___RANDOM_SUBTRACT_WITH_CARRY_ENGINE_H |
lib/libcxx/include/__random/uniform_int_distribution.h+6-32| ... | ... | @@ -11,6 +11,8 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__bits> |
| 13 | 13 | #include <__config> |
| 14 | #include <__random/log2.h> | |
| 15 | #include <bit> | |
| 14 | 16 | #include <cstddef> |
| 15 | 17 | #include <cstdint> |
| 16 | 18 | #include <iosfwd> |
| ... | ... | @@ -26,34 +28,6 @@ _LIBCPP_PUSH_MACROS |
| 26 | 28 | |
| 27 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 30 | |
| 29 | // __independent_bits_engine | |
| 30 | ||
| 31 | template <unsigned long long _Xp, size_t _Rp> | |
| 32 | struct __log2_imp | |
| 33 | { | |
| 34 | static const size_t value = _Xp & ((unsigned long long)(1) << _Rp) ? _Rp | |
| 35 | : __log2_imp<_Xp, _Rp - 1>::value; | |
| 36 | }; | |
| 37 | ||
| 38 | template <unsigned long long _Xp> | |
| 39 | struct __log2_imp<_Xp, 0> | |
| 40 | { | |
| 41 | static const size_t value = 0; | |
| 42 | }; | |
| 43 | ||
| 44 | template <size_t _Rp> | |
| 45 | struct __log2_imp<0, _Rp> | |
| 46 | { | |
| 47 | static const size_t value = _Rp + 1; | |
| 48 | }; | |
| 49 | ||
| 50 | template <class _UIntType, _UIntType _Xp> | |
| 51 | struct __log2 | |
| 52 | { | |
| 53 | static const size_t value = __log2_imp<_Xp, | |
| 54 | sizeof(_UIntType) * __CHAR_BIT__ - 1>::value; | |
| 55 | }; | |
| 56 | ||
| 57 | 31 | template<class _Engine, class _UIntType> |
| 58 | 32 | class __independent_bits_engine |
| 59 | 33 | { |
| ... | ... | @@ -181,7 +155,7 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) |
| 181 | 155 | return _Sp; |
| 182 | 156 | } |
| 183 | 157 | |
| 184 | template<class _IntType = int> | |
| 158 | template<class _IntType = int> // __int128_t is also supported as an extension here | |
| 185 | 159 | class uniform_int_distribution |
| 186 | 160 | { |
| 187 | 161 | public: |
| ... | ... | @@ -256,8 +230,8 @@ typename uniform_int_distribution<_IntType>::result_type |
| 256 | 230 | uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) |
| 257 | 231 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 258 | 232 | { |
| 259 | typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), | |
| 260 | uint32_t, uint64_t>::type _UIntType; | |
| 233 | typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t, | |
| 234 | typename make_unsigned<result_type>::type>::type _UIntType; | |
| 261 | 235 | const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1); |
| 262 | 236 | if (_Rp == 1) |
| 263 | 237 | return __p.a(); |
| ... | ... | @@ -265,7 +239,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 265 | 239 | typedef __independent_bits_engine<_URNG, _UIntType> _Eng; |
| 266 | 240 | if (_Rp == 0) |
| 267 | 241 | return static_cast<result_type>(_Eng(__g, _Dt)()); |
| 268 | size_t __w = _Dt - __libcpp_clz(_Rp) - 1; | |
| 242 | size_t __w = _Dt - __countl_zero(_Rp) - 1; | |
| 269 | 243 | if ((_Rp & (numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0) |
| 270 | 244 | ++__w; |
| 271 | 245 | _Eng __e(__g, __w); |
lib/libcxx/include/__random/uniform_random_bit_generator.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___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H | |
| 10 | #define _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H | |
| 11 | ||
| 12 | #include <__concepts/arithmetic.h> | |
| 13 | #include <__concepts/invocable.h> | |
| 14 | #include <__concepts/same_as.h> | |
| 15 | #include <__config> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | ||
| 29 | // [rand.req.urng] | |
| 30 | template<class _Gen> | |
| 31 | concept uniform_random_bit_generator = | |
| 32 | invocable<_Gen&> && unsigned_integral<invoke_result_t<_Gen&>> && | |
| 33 | requires { | |
| 34 | { _Gen::min() } -> same_as<invoke_result_t<_Gen&>>; | |
| 35 | { _Gen::max() } -> same_as<invoke_result_t<_Gen&>>; | |
| 36 | requires bool_constant<(_Gen::min() < _Gen::max())>::value; | |
| 37 | }; | |
| 38 | ||
| 39 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | _LIBCPP_POP_MACROS | |
| 44 | ||
| 45 | #endif // _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H |
lib/libcxx/include/__random/uniform_real_distribution.h created+160| ... | ... | @@ -0,0 +1,160 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___RANDOM_UNIFORM_REAL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_UNIFORM_REAL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/generate_canonical.h> | |
| 14 | #include <iosfwd> | |
| 15 | #include <limits> | |
| 16 | #include <type_traits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | template<class _RealType = double> | |
| 28 | class _LIBCPP_TEMPLATE_VIS uniform_real_distribution | |
| 29 | { | |
| 30 | public: | |
| 31 | // types | |
| 32 | typedef _RealType result_type; | |
| 33 | ||
| 34 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 35 | { | |
| 36 | result_type __a_; | |
| 37 | result_type __b_; | |
| 38 | public: | |
| 39 | typedef uniform_real_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __a = 0, | |
| 43 | result_type __b = 1) | |
| 44 | : __a_(__a), __b_(__b) {} | |
| 45 | ||
| 46 | _LIBCPP_INLINE_VISIBILITY | |
| 47 | result_type a() const {return __a_;} | |
| 48 | _LIBCPP_INLINE_VISIBILITY | |
| 49 | result_type b() const {return __b_;} | |
| 50 | ||
| 51 | friend _LIBCPP_INLINE_VISIBILITY | |
| 52 | bool operator==(const param_type& __x, const param_type& __y) | |
| 53 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 54 | friend _LIBCPP_INLINE_VISIBILITY | |
| 55 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 56 | {return !(__x == __y);} | |
| 57 | }; | |
| 58 | ||
| 59 | private: | |
| 60 | param_type __p_; | |
| 61 | ||
| 62 | public: | |
| 63 | // constructors and reset functions | |
| 64 | #ifndef _LIBCPP_CXX03_LANG | |
| 65 | _LIBCPP_INLINE_VISIBILITY | |
| 66 | uniform_real_distribution() : uniform_real_distribution(0) {} | |
| 67 | explicit uniform_real_distribution(result_type __a, result_type __b = 1) | |
| 68 | : __p_(param_type(__a, __b)) {} | |
| 69 | #else | |
| 70 | _LIBCPP_INLINE_VISIBILITY | |
| 71 | explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1) | |
| 72 | : __p_(param_type(__a, __b)) {} | |
| 73 | #endif | |
| 74 | _LIBCPP_INLINE_VISIBILITY | |
| 75 | explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {} | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | void reset() {} | |
| 78 | ||
| 79 | // generating functions | |
| 80 | template<class _URNG> | |
| 81 | _LIBCPP_INLINE_VISIBILITY | |
| 82 | result_type operator()(_URNG& __g) | |
| 83 | {return (*this)(__g, __p_);} | |
| 84 | template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); | |
| 85 | ||
| 86 | // property functions | |
| 87 | _LIBCPP_INLINE_VISIBILITY | |
| 88 | result_type a() const {return __p_.a();} | |
| 89 | _LIBCPP_INLINE_VISIBILITY | |
| 90 | result_type b() const {return __p_.b();} | |
| 91 | ||
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | param_type param() const {return __p_;} | |
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | void param(const param_type& __p) {__p_ = __p;} | |
| 96 | ||
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | result_type min() const {return a();} | |
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | result_type max() const {return b();} | |
| 101 | ||
| 102 | friend _LIBCPP_INLINE_VISIBILITY | |
| 103 | bool operator==(const uniform_real_distribution& __x, | |
| 104 | const uniform_real_distribution& __y) | |
| 105 | {return __x.__p_ == __y.__p_;} | |
| 106 | friend _LIBCPP_INLINE_VISIBILITY | |
| 107 | bool operator!=(const uniform_real_distribution& __x, | |
| 108 | const uniform_real_distribution& __y) | |
| 109 | {return !(__x == __y);} | |
| 110 | }; | |
| 111 | ||
| 112 | template<class _RealType> | |
| 113 | template<class _URNG> | |
| 114 | inline | |
| 115 | typename uniform_real_distribution<_RealType>::result_type | |
| 116 | uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 117 | { | |
| 118 | return (__p.b() - __p.a()) | |
| 119 | * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g) | |
| 120 | + __p.a(); | |
| 121 | } | |
| 122 | ||
| 123 | template <class _CharT, class _Traits, class _RT> | |
| 124 | basic_ostream<_CharT, _Traits>& | |
| 125 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 126 | const uniform_real_distribution<_RT>& __x) | |
| 127 | { | |
| 128 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 129 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 130 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 131 | _OStream::scientific); | |
| 132 | _CharT __sp = __os.widen(' '); | |
| 133 | __os.fill(__sp); | |
| 134 | return __os << __x.a() << __sp << __x.b(); | |
| 135 | } | |
| 136 | ||
| 137 | template <class _CharT, class _Traits, class _RT> | |
| 138 | basic_istream<_CharT, _Traits>& | |
| 139 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 140 | uniform_real_distribution<_RT>& __x) | |
| 141 | { | |
| 142 | typedef uniform_real_distribution<_RT> _Eng; | |
| 143 | typedef typename _Eng::result_type result_type; | |
| 144 | typedef typename _Eng::param_type param_type; | |
| 145 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 146 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 147 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 148 | result_type __a; | |
| 149 | result_type __b; | |
| 150 | __is >> __a >> __b; | |
| 151 | if (!__is.fail()) | |
| 152 | __x.param(param_type(__a, __b)); | |
| 153 | return __is; | |
| 154 | } | |
| 155 | ||
| 156 | _LIBCPP_END_NAMESPACE_STD | |
| 157 | ||
| 158 | _LIBCPP_POP_MACROS | |
| 159 | ||
| 160 | #endif // _LIBCPP___RANDOM_UNIFORM_REAL_DISTRIBUTION_H |
lib/libcxx/include/__random/weibull_distribution.h created+155| ... | ... | @@ -0,0 +1,155 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See 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_WEIBULL_DISTRIBUTION_H | |
| 10 | #define _LIBCPP___RANDOM_WEIBULL_DISTRIBUTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__random/exponential_distribution.h> | |
| 14 | #include <cmath> | |
| 15 | #include <iosfwd> | |
| 16 | #include <limits> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | #pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | template<class _RealType = double> | |
| 28 | class _LIBCPP_TEMPLATE_VIS weibull_distribution | |
| 29 | { | |
| 30 | public: | |
| 31 | // types | |
| 32 | typedef _RealType result_type; | |
| 33 | ||
| 34 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 35 | { | |
| 36 | result_type __a_; | |
| 37 | result_type __b_; | |
| 38 | public: | |
| 39 | typedef weibull_distribution distribution_type; | |
| 40 | ||
| 41 | _LIBCPP_INLINE_VISIBILITY | |
| 42 | explicit param_type(result_type __a = 1, result_type __b = 1) | |
| 43 | : __a_(__a), __b_(__b) {} | |
| 44 | ||
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | result_type a() const {return __a_;} | |
| 47 | _LIBCPP_INLINE_VISIBILITY | |
| 48 | result_type b() const {return __b_;} | |
| 49 | ||
| 50 | friend _LIBCPP_INLINE_VISIBILITY | |
| 51 | bool operator==(const param_type& __x, const param_type& __y) | |
| 52 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 53 | friend _LIBCPP_INLINE_VISIBILITY | |
| 54 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 55 | {return !(__x == __y);} | |
| 56 | }; | |
| 57 | ||
| 58 | private: | |
| 59 | param_type __p_; | |
| 60 | ||
| 61 | public: | |
| 62 | // constructor and reset functions | |
| 63 | #ifndef _LIBCPP_CXX03_LANG | |
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | weibull_distribution() : weibull_distribution(1) {} | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | explicit weibull_distribution(result_type __a, result_type __b = 1) | |
| 68 | : __p_(param_type(__a, __b)) {} | |
| 69 | #else | |
| 70 | _LIBCPP_INLINE_VISIBILITY | |
| 71 | explicit weibull_distribution(result_type __a = 1, result_type __b = 1) | |
| 72 | : __p_(param_type(__a, __b)) {} | |
| 73 | #endif | |
| 74 | _LIBCPP_INLINE_VISIBILITY | |
| 75 | explicit weibull_distribution(const param_type& __p) | |
| 76 | : __p_(__p) {} | |
| 77 | _LIBCPP_INLINE_VISIBILITY | |
| 78 | void reset() {} | |
| 79 | ||
| 80 | // generating functions | |
| 81 | template<class _URNG> | |
| 82 | _LIBCPP_INLINE_VISIBILITY | |
| 83 | result_type operator()(_URNG& __g) | |
| 84 | {return (*this)(__g, __p_);} | |
| 85 | template<class _URNG> | |
| 86 | _LIBCPP_INLINE_VISIBILITY | |
| 87 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 88 | {return __p.b() * | |
| 89 | _VSTD::pow(exponential_distribution<result_type>()(__g), 1/__p.a());} | |
| 90 | ||
| 91 | // property functions | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | result_type a() const {return __p_.a();} | |
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | result_type b() const {return __p_.b();} | |
| 96 | ||
| 97 | _LIBCPP_INLINE_VISIBILITY | |
| 98 | param_type param() const {return __p_;} | |
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | void param(const param_type& __p) {__p_ = __p;} | |
| 101 | ||
| 102 | _LIBCPP_INLINE_VISIBILITY | |
| 103 | result_type min() const {return 0;} | |
| 104 | _LIBCPP_INLINE_VISIBILITY | |
| 105 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 106 | ||
| 107 | friend _LIBCPP_INLINE_VISIBILITY | |
| 108 | bool operator==(const weibull_distribution& __x, | |
| 109 | const weibull_distribution& __y) | |
| 110 | {return __x.__p_ == __y.__p_;} | |
| 111 | friend _LIBCPP_INLINE_VISIBILITY | |
| 112 | bool operator!=(const weibull_distribution& __x, | |
| 113 | const weibull_distribution& __y) | |
| 114 | {return !(__x == __y);} | |
| 115 | }; | |
| 116 | ||
| 117 | template <class _CharT, class _Traits, class _RT> | |
| 118 | basic_ostream<_CharT, _Traits>& | |
| 119 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 120 | const weibull_distribution<_RT>& __x) | |
| 121 | { | |
| 122 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 123 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 124 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 125 | _OStream::scientific); | |
| 126 | _CharT __sp = __os.widen(' '); | |
| 127 | __os.fill(__sp); | |
| 128 | __os << __x.a() << __sp << __x.b(); | |
| 129 | return __os; | |
| 130 | } | |
| 131 | ||
| 132 | template <class _CharT, class _Traits, class _RT> | |
| 133 | basic_istream<_CharT, _Traits>& | |
| 134 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 135 | weibull_distribution<_RT>& __x) | |
| 136 | { | |
| 137 | typedef weibull_distribution<_RT> _Eng; | |
| 138 | typedef typename _Eng::result_type result_type; | |
| 139 | typedef typename _Eng::param_type param_type; | |
| 140 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 141 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 142 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 143 | result_type __a; | |
| 144 | result_type __b; | |
| 145 | __is >> __a >> __b; | |
| 146 | if (!__is.fail()) | |
| 147 | __x.param(param_type(__a, __b)); | |
| 148 | return __is; | |
| 149 | } | |
| 150 | ||
| 151 | _LIBCPP_END_NAMESPACE_STD | |
| 152 | ||
| 153 | _LIBCPP_POP_MACROS | |
| 154 | ||
| 155 | #endif // _LIBCPP___RANDOM_WEIBULL_DISTRIBUTION_H |
lib/libcxx/include/__ranges/access.h+100-95| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ __ranges/access.h ---------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,12 +9,13 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_ACCESS_H |
| 10 | 10 | #define _LIBCPP___RANGES_ACCESS_H |
| 11 | 11 | |
| 12 | #include <__concepts/class_or_enum.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__iterator/readable_traits.h> |
| 15 | 16 | #include <__ranges/enable_borrowed_range.h> |
| 16 | #include <__utility/__decay_copy.h> | |
| 17 | #include <__utility/forward.h> | |
| 17 | #include <__utility/as_const.h> | |
| 18 | #include <__utility/auto_cast.h> | |
| 18 | 19 | #include <concepts> |
| 19 | 20 | #include <type_traits> |
| 20 | 21 | |
| ... | ... | @@ -22,31 +23,26 @@ |
| 22 | 23 | #pragma GCC system_header |
| 23 | 24 | #endif |
| 24 | 25 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 27 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 31 | ||
| 32 | // clang-format off | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | 29 | |
| 34 | 30 | namespace ranges { |
| 35 | 31 | template <class _Tp> |
| 36 | 32 | concept __can_borrow = |
| 37 | is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp> >; | |
| 38 | ||
| 39 | template<class _Tp> | |
| 40 | concept __is_complete = requires { sizeof(_Tp); }; | |
| 33 | is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>; | |
| 41 | 34 | } // namespace ranges |
| 42 | 35 | |
| 43 | 36 | // [range.access.begin] |
| 44 | namespace ranges::__begin { | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | namespace __begin { | |
| 45 | 40 | template <class _Tp> |
| 46 | 41 | concept __member_begin = |
| 47 | 42 | __can_borrow<_Tp> && |
| 43 | __workaround_52970<_Tp> && | |
| 48 | 44 | requires(_Tp&& __t) { |
| 49 | { _VSTD::__decay_copy(__t.begin()) } -> input_or_output_iterator; | |
| 45 | { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator; | |
| 50 | 46 | }; |
| 51 | 47 | |
| 52 | 48 | void begin(auto&) = delete; |
| ... | ... | @@ -56,61 +52,69 @@ namespace ranges::__begin { |
| 56 | 52 | concept __unqualified_begin = |
| 57 | 53 | !__member_begin<_Tp> && |
| 58 | 54 | __can_borrow<_Tp> && |
| 59 | __class_or_enum<remove_cvref_t<_Tp> > && | |
| 55 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 60 | 56 | requires(_Tp && __t) { |
| 61 | { _VSTD::__decay_copy(begin(__t)) } -> input_or_output_iterator; | |
| 57 | { _LIBCPP_AUTO_CAST(begin(__t)) } -> input_or_output_iterator; | |
| 62 | 58 | }; |
| 63 | 59 | |
| 64 | 60 | struct __fn { |
| 65 | 61 | template <class _Tp> |
| 66 | requires is_array_v<remove_cv_t<_Tp>> | |
| 67 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const noexcept { | |
| 68 | constexpr bool __complete = __is_complete<iter_value_t<_Tp> >; | |
| 69 | if constexpr (__complete) { // used to disable cryptic diagnostic | |
| 70 | return __t + 0; | |
| 71 | } | |
| 72 | else { | |
| 73 | static_assert(__complete, "`std::ranges::begin` is SFINAE-unfriendly on arrays of an incomplete type."); | |
| 74 | } | |
| 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept | |
| 63 | requires (sizeof(_Tp) != 0) // Disallow incomplete element types. | |
| 64 | { | |
| 65 | return __t + 0; | |
| 66 | } | |
| 67 | ||
| 68 | template <class _Tp, size_t _Np> | |
| 69 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept | |
| 70 | requires (sizeof(_Tp) != 0) // Disallow incomplete element types. | |
| 71 | { | |
| 72 | return __t + 0; | |
| 75 | 73 | } |
| 76 | 74 | |
| 77 | 75 | template <class _Tp> |
| 78 | requires __member_begin<_Tp> | |
| 76 | requires __member_begin<_Tp> | |
| 79 | 77 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const |
| 80 | noexcept(noexcept(_VSTD::__decay_copy(__t.begin()))) | |
| 78 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.begin()))) | |
| 81 | 79 | { |
| 82 | return __t.begin(); | |
| 80 | return _LIBCPP_AUTO_CAST(__t.begin()); | |
| 83 | 81 | } |
| 84 | 82 | |
| 85 | 83 | template <class _Tp> |
| 86 | requires __unqualified_begin<_Tp> | |
| 84 | requires __unqualified_begin<_Tp> | |
| 87 | 85 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const |
| 88 | noexcept(noexcept(_VSTD::__decay_copy(begin(__t)))) | |
| 86 | noexcept(noexcept(_LIBCPP_AUTO_CAST(begin(__t)))) | |
| 89 | 87 | { |
| 90 | return begin(__t); | |
| 88 | return _LIBCPP_AUTO_CAST(begin(__t)); | |
| 91 | 89 | } |
| 92 | 90 | |
| 93 | 91 | void operator()(auto&&) const = delete; |
| 94 | 92 | }; |
| 95 | } // namespace ranges::__begin | |
| 93 | } // namespace __begin | |
| 96 | 94 | |
| 97 | namespace ranges { | |
| 98 | inline namespace __cpo { | |
| 99 | inline constexpr auto begin = __begin::__fn{}; | |
| 100 | } // namespace __cpo | |
| 95 | inline namespace __cpo { | |
| 96 | inline constexpr auto begin = __begin::__fn{}; | |
| 97 | } // namespace __cpo | |
| 98 | } // namespace ranges | |
| 101 | 99 | |
| 100 | // [range.range] | |
| 101 | ||
| 102 | namespace ranges { | |
| 102 | 103 | template <class _Tp> |
| 103 | 104 | using iterator_t = decltype(ranges::begin(declval<_Tp&>())); |
| 104 | 105 | } // namespace ranges |
| 105 | 106 | |
| 106 | 107 | // [range.access.end] |
| 107 | namespace ranges::__end { | |
| 108 | ||
| 109 | namespace ranges { | |
| 110 | namespace __end { | |
| 108 | 111 | template <class _Tp> |
| 109 | 112 | concept __member_end = |
| 110 | 113 | __can_borrow<_Tp> && |
| 114 | __workaround_52970<_Tp> && | |
| 111 | 115 | requires(_Tp&& __t) { |
| 112 | 116 | typename iterator_t<_Tp>; |
| 113 | { _VSTD::__decay_copy(_VSTD::forward<_Tp>(__t).end()) } -> sentinel_for<iterator_t<_Tp> >; | |
| 117 | { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>; | |
| 114 | 118 | }; |
| 115 | 119 | |
| 116 | 120 | void end(auto&) = delete; |
| ... | ... | @@ -120,103 +124,104 @@ namespace ranges::__end { |
| 120 | 124 | concept __unqualified_end = |
| 121 | 125 | !__member_end<_Tp> && |
| 122 | 126 | __can_borrow<_Tp> && |
| 123 | __class_or_enum<remove_cvref_t<_Tp> > && | |
| 127 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 124 | 128 | requires(_Tp && __t) { |
| 125 | 129 | typename iterator_t<_Tp>; |
| 126 | { _VSTD::__decay_copy(end(_VSTD::forward<_Tp>(__t))) } -> sentinel_for<iterator_t<_Tp> >; | |
| 130 | { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>; | |
| 127 | 131 | }; |
| 128 | 132 | |
| 129 | 133 | class __fn { |
| 130 | 134 | public: |
| 131 | 135 | template <class _Tp, size_t _Np> |
| 132 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept { | |
| 133 | constexpr bool __complete = __is_complete<remove_cv_t<_Tp> >; | |
| 134 | if constexpr (__complete) { // used to disable cryptic diagnostic | |
| 135 | return __t + _Np; | |
| 136 | } | |
| 137 | else { | |
| 138 | static_assert(__complete, "`std::ranges::end` is SFINAE-unfriendly on arrays of an incomplete type."); | |
| 139 | } | |
| 136 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept | |
| 137 | requires (sizeof(_Tp) != 0) // Disallow incomplete element types. | |
| 138 | { | |
| 139 | return __t + _Np; | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | template <class _Tp> |
| 143 | requires __member_end<_Tp> | |
| 143 | requires __member_end<_Tp> | |
| 144 | 144 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const |
| 145 | noexcept(noexcept(_VSTD::__decay_copy(__t.end()))) | |
| 145 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.end()))) | |
| 146 | 146 | { |
| 147 | return _VSTD::forward<_Tp>(__t).end(); | |
| 147 | return _LIBCPP_AUTO_CAST(__t.end()); | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | template <class _Tp> |
| 151 | requires __unqualified_end<_Tp> | |
| 151 | requires __unqualified_end<_Tp> | |
| 152 | 152 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const |
| 153 | noexcept(noexcept(_VSTD::__decay_copy(end(__t)))) | |
| 153 | noexcept(noexcept(_LIBCPP_AUTO_CAST(end(__t)))) | |
| 154 | 154 | { |
| 155 | return end(__t); | |
| 155 | return _LIBCPP_AUTO_CAST(end(__t)); | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | void operator()(auto&&) const = delete; |
| 159 | 159 | }; |
| 160 | } // namespace ranges::__end | |
| 160 | } // namespace __end | |
| 161 | 161 | |
| 162 | namespace ranges::inline __cpo { | |
| 162 | inline namespace __cpo { | |
| 163 | 163 | inline constexpr auto end = __end::__fn{}; |
| 164 | } // namespace ranges::__cpo | |
| 164 | } // namespace __cpo | |
| 165 | } // namespace ranges | |
| 165 | 166 | |
| 166 | namespace ranges::__cbegin { | |
| 167 | // [range.access.cbegin] | |
| 168 | ||
| 169 | namespace ranges { | |
| 170 | namespace __cbegin { | |
| 167 | 171 | struct __fn { |
| 168 | 172 | template <class _Tp> |
| 169 | requires invocable<decltype(ranges::begin), _Tp const&> | |
| 170 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const | |
| 171 | noexcept(noexcept(ranges::begin(_VSTD::as_const(__t)))) | |
| 172 | { | |
| 173 | return ranges::begin(_VSTD::as_const(__t)); | |
| 174 | } | |
| 173 | requires is_lvalue_reference_v<_Tp&&> | |
| 174 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 175 | constexpr auto operator()(_Tp&& __t) const | |
| 176 | noexcept(noexcept(ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)))) | |
| 177 | -> decltype( ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t))) | |
| 178 | { return ranges::begin(static_cast<const remove_reference_t<_Tp>&>(__t)); } | |
| 175 | 179 | |
| 176 | 180 | template <class _Tp> |
| 177 | requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::begin), _Tp const&&> | |
| 178 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 179 | noexcept(noexcept(ranges::begin(static_cast<_Tp const&&>(__t)))) | |
| 180 | { | |
| 181 | return ranges::begin(static_cast<_Tp const&&>(__t)); | |
| 182 | } | |
| 181 | requires is_rvalue_reference_v<_Tp&&> | |
| 182 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 183 | constexpr auto operator()(_Tp&& __t) const | |
| 184 | noexcept(noexcept(ranges::begin(static_cast<const _Tp&&>(__t)))) | |
| 185 | -> decltype( ranges::begin(static_cast<const _Tp&&>(__t))) | |
| 186 | { return ranges::begin(static_cast<const _Tp&&>(__t)); } | |
| 183 | 187 | }; |
| 184 | } // namespace ranges::__cbegin | |
| 188 | } // namespace __cbegin | |
| 185 | 189 | |
| 186 | namespace ranges::inline __cpo { | |
| 190 | inline namespace __cpo { | |
| 187 | 191 | inline constexpr auto cbegin = __cbegin::__fn{}; |
| 188 | } // namespace ranges::__cpo | |
| 192 | } // namespace __cpo | |
| 193 | } // namespace ranges | |
| 194 | ||
| 195 | // [range.access.cend] | |
| 189 | 196 | |
| 190 | namespace ranges::__cend { | |
| 197 | namespace ranges { | |
| 198 | namespace __cend { | |
| 191 | 199 | struct __fn { |
| 192 | 200 | template <class _Tp> |
| 193 | requires invocable<decltype(ranges::end), _Tp const&> | |
| 194 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp& __t) const | |
| 195 | noexcept(noexcept(ranges::end(_VSTD::as_const(__t)))) | |
| 196 | { | |
| 197 | return ranges::end(_VSTD::as_const(__t)); | |
| 198 | } | |
| 201 | requires is_lvalue_reference_v<_Tp&&> | |
| 202 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 203 | constexpr auto operator()(_Tp&& __t) const | |
| 204 | noexcept(noexcept(ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)))) | |
| 205 | -> decltype( ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t))) | |
| 206 | { return ranges::end(static_cast<const remove_reference_t<_Tp>&>(__t)); } | |
| 199 | 207 | |
| 200 | 208 | template <class _Tp> |
| 201 | requires is_rvalue_reference_v<_Tp> && invocable<decltype(ranges::end), _Tp const&&> | |
| 202 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 203 | noexcept(noexcept(ranges::end(static_cast<_Tp const&&>(__t)))) | |
| 204 | { | |
| 205 | return ranges::end(static_cast<_Tp const&&>(__t)); | |
| 206 | } | |
| 209 | requires is_rvalue_reference_v<_Tp&&> | |
| 210 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 211 | constexpr auto operator()(_Tp&& __t) const | |
| 212 | noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) | |
| 213 | -> decltype( ranges::end(static_cast<const _Tp&&>(__t))) | |
| 214 | { return ranges::end(static_cast<const _Tp&&>(__t)); } | |
| 207 | 215 | }; |
| 208 | } // namespace ranges::__cend | |
| 216 | } // namespace __cend | |
| 209 | 217 | |
| 210 | namespace ranges::inline __cpo { | |
| 218 | inline namespace __cpo { | |
| 211 | 219 | inline constexpr auto cend = __cend::__fn{}; |
| 212 | } // namespace ranges::__cpo | |
| 213 | ||
| 214 | // clang-format off | |
| 220 | } // namespace __cpo | |
| 221 | } // namespace ranges | |
| 215 | 222 | |
| 216 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 223 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 217 | 224 | |
| 218 | 225 | _LIBCPP_END_NAMESPACE_STD |
| 219 | 226 | |
| 220 | _LIBCPP_POP_MACROS | |
| 221 | ||
| 222 | 227 | #endif // _LIBCPP___RANGES_ACCESS_H |
lib/libcxx/include/__ranges/all.h+17-21| ... | ... | @@ -14,9 +14,10 @@ |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | #include <__ranges/access.h> |
| 16 | 16 | #include <__ranges/concepts.h> |
| 17 | #include <__ranges/owning_view.h> | |
| 18 | #include <__ranges/range_adaptor.h> | |
| 17 | 19 | #include <__ranges/ref_view.h> |
| 18 | #include <__ranges/subrange.h> | |
| 19 | #include <__utility/__decay_copy.h> | |
| 20 | #include <__utility/auto_cast.h> | |
| 20 | 21 | #include <__utility/declval.h> |
| 21 | 22 | #include <__utility/forward.h> |
| 22 | 23 | #include <type_traits> |
| ... | ... | @@ -25,30 +26,27 @@ |
| 25 | 26 | #pragma GCC system_header |
| 26 | 27 | #endif |
| 27 | 28 | |
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 30 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 31 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | 32 | |
| 35 | namespace views { | |
| 33 | namespace ranges::views { | |
| 36 | 34 | |
| 37 | 35 | namespace __all { |
| 38 | struct __fn { | |
| 36 | struct __fn : __range_adaptor_closure<__fn> { | |
| 39 | 37 | template<class _Tp> |
| 40 | 38 | requires ranges::view<decay_t<_Tp>> |
| 41 | _LIBCPP_HIDE_FROM_ABI | |
| 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 42 | 40 | constexpr auto operator()(_Tp&& __t) const |
| 43 | noexcept(noexcept(_VSTD::__decay_copy(_VSTD::forward<_Tp>(__t)))) | |
| 41 | noexcept(noexcept(_LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t)))) | |
| 44 | 42 | { |
| 45 | return _VSTD::forward<_Tp>(__t); | |
| 43 | return _LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t)); | |
| 46 | 44 | } |
| 47 | 45 | |
| 48 | 46 | template<class _Tp> |
| 49 | 47 | requires (!ranges::view<decay_t<_Tp>>) && |
| 50 | 48 | requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } |
| 51 | _LIBCPP_HIDE_FROM_ABI | |
| 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 52 | 50 | constexpr auto operator()(_Tp&& __t) const |
| 53 | 51 | noexcept(noexcept(ranges::ref_view{_VSTD::forward<_Tp>(__t)})) |
| 54 | 52 | { |
| ... | ... | @@ -58,15 +56,15 @@ namespace __all { |
| 58 | 56 | template<class _Tp> |
| 59 | 57 | requires (!ranges::view<decay_t<_Tp>> && |
| 60 | 58 | !requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } && |
| 61 | requires (_Tp&& __t) { ranges::subrange{_VSTD::forward<_Tp>(__t)}; }) | |
| 62 | _LIBCPP_HIDE_FROM_ABI | |
| 59 | requires (_Tp&& __t) { ranges::owning_view{_VSTD::forward<_Tp>(__t)}; }) | |
| 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 63 | 61 | constexpr auto operator()(_Tp&& __t) const |
| 64 | noexcept(noexcept(ranges::subrange{_VSTD::forward<_Tp>(__t)})) | |
| 62 | noexcept(noexcept(ranges::owning_view{_VSTD::forward<_Tp>(__t)})) | |
| 65 | 63 | { |
| 66 | return ranges::subrange{_VSTD::forward<_Tp>(__t)}; | |
| 64 | return ranges::owning_view{_VSTD::forward<_Tp>(__t)}; | |
| 67 | 65 | } |
| 68 | 66 | }; |
| 69 | } | |
| 67 | } // namespace __all | |
| 70 | 68 | |
| 71 | 69 | inline namespace __cpo { |
| 72 | 70 | inline constexpr auto all = __all::__fn{}; |
| ... | ... | @@ -75,12 +73,10 @@ inline namespace __cpo { |
| 75 | 73 | template<ranges::viewable_range _Range> |
| 76 | 74 | using all_t = decltype(views::all(declval<_Range>())); |
| 77 | 75 | |
| 78 | } // namespace views | |
| 76 | } // namespace ranges::views | |
| 79 | 77 | |
| 80 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 78 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 81 | 79 | |
| 82 | 80 | _LIBCPP_END_NAMESPACE_STD |
| 83 | 81 | |
| 84 | _LIBCPP_POP_MACROS | |
| 85 | ||
| 86 | 82 | #endif // _LIBCPP___RANGES_ALL_H |
lib/libcxx/include/__ranges/common_view.h+29-7| ... | ... | @@ -16,8 +16,11 @@ |
| 16 | 16 | #include <__ranges/all.h> |
| 17 | 17 | #include <__ranges/concepts.h> |
| 18 | 18 | #include <__ranges/enable_borrowed_range.h> |
| 19 | #include <__ranges/range_adaptor.h> | |
| 19 | 20 | #include <__ranges/size.h> |
| 20 | 21 | #include <__ranges/view_interface.h> |
| 22 | #include <__utility/forward.h> | |
| 23 | #include <__utility/move.h> | |
| 21 | 24 | #include <concepts> |
| 22 | 25 | #include <type_traits> |
| 23 | 26 | |
| ... | ... | @@ -25,12 +28,9 @@ |
| 25 | 28 | #pragma GCC system_header |
| 26 | 29 | #endif |
| 27 | 30 | |
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 33 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | 36 | |
| ... | ... | @@ -102,12 +102,34 @@ common_view(_Range&&) |
| 102 | 102 | template<class _View> |
| 103 | 103 | inline constexpr bool enable_borrowed_range<common_view<_View>> = enable_borrowed_range<_View>; |
| 104 | 104 | |
| 105 | namespace views { | |
| 106 | namespace __common { | |
| 107 | struct __fn : __range_adaptor_closure<__fn> { | |
| 108 | template<class _Range> | |
| 109 | requires common_range<_Range> | |
| 110 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 111 | constexpr auto operator()(_Range&& __range) const | |
| 112 | noexcept(noexcept(views::all(_VSTD::forward<_Range>(__range)))) | |
| 113 | -> decltype( views::all(_VSTD::forward<_Range>(__range))) | |
| 114 | { return views::all(_VSTD::forward<_Range>(__range)); } | |
| 115 | ||
| 116 | template<class _Range> | |
| 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 118 | constexpr auto operator()(_Range&& __range) const | |
| 119 | noexcept(noexcept(common_view{_VSTD::forward<_Range>(__range)})) | |
| 120 | -> decltype( common_view{_VSTD::forward<_Range>(__range)}) | |
| 121 | { return common_view{_VSTD::forward<_Range>(__range)}; } | |
| 122 | }; | |
| 123 | } // namespace __common | |
| 124 | ||
| 125 | inline namespace __cpo { | |
| 126 | inline constexpr auto common = __common::__fn{}; | |
| 127 | } // namespace __cpo | |
| 128 | } // namespace views | |
| 105 | 129 | } // namespace ranges |
| 106 | 130 | |
| 107 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 131 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 108 | 132 | |
| 109 | 133 | _LIBCPP_END_NAMESPACE_STD |
| 110 | 134 | |
| 111 | _LIBCPP_POP_MACROS | |
| 112 | ||
| 113 | 135 | #endif // _LIBCPP___RANGES_COMMON_VIEW_H |
lib/libcxx/include/__ranges/concepts.h+28-24| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------- __ranges/concepts.h ----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,6 +9,9 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_CONCEPTS_H |
| 10 | 10 | #define _LIBCPP___RANGES_CONCEPTS_H |
| 11 | 11 | |
| 12 | #include <__concepts/constructible.h> | |
| 13 | #include <__concepts/movable.h> | |
| 14 | #include <__concepts/same_as.h> | |
| 12 | 15 | #include <__config> |
| 13 | 16 | #include <__iterator/concepts.h> |
| 14 | 17 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -16,34 +19,34 @@ |
| 16 | 19 | #include <__iterator/iterator_traits.h> |
| 17 | 20 | #include <__iterator/readable_traits.h> |
| 18 | 21 | #include <__ranges/access.h> |
| 19 | #include <__ranges/enable_borrowed_range.h> | |
| 20 | 22 | #include <__ranges/data.h> |
| 23 | #include <__ranges/enable_borrowed_range.h> | |
| 21 | 24 | #include <__ranges/enable_view.h> |
| 22 | 25 | #include <__ranges/size.h> |
| 23 | #include <concepts> | |
| 26 | #include <initializer_list> | |
| 24 | 27 | #include <type_traits> |
| 25 | 28 | |
| 26 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 30 | #pragma GCC system_header |
| 28 | 31 | #endif |
| 29 | 32 | |
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | // clang-format off | |
| 36 | ||
| 37 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 35 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 38 | 36 | |
| 39 | 37 | namespace ranges { |
| 38 | ||
| 40 | 39 | // [range.range] |
| 40 | ||
| 41 | 41 | template <class _Tp> |
| 42 | 42 | concept range = requires(_Tp& __t) { |
| 43 | 43 | ranges::begin(__t); // sometimes equality-preserving |
| 44 | 44 | ranges::end(__t); |
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | template <class _Tp> | |
| 48 | concept input_range = range<_Tp> && input_iterator<iterator_t<_Tp>>; | |
| 49 | ||
| 47 | 50 | template<class _Range> |
| 48 | 51 | concept borrowed_range = range<_Range> && |
| 49 | 52 | (is_lvalue_reference_v<_Range> || enable_borrowed_range<remove_cvref_t<_Range>>); |
| ... | ... | @@ -85,19 +88,16 @@ namespace ranges { |
| 85 | 88 | movable<_Tp> && |
| 86 | 89 | enable_view<_Tp>; |
| 87 | 90 | |
| 88 | template<class _Range> | |
| 91 | template <class _Range> | |
| 89 | 92 | concept __simple_view = |
| 90 | 93 | view<_Range> && range<const _Range> && |
| 91 | 94 | same_as<iterator_t<_Range>, iterator_t<const _Range>> && |
| 92 | same_as<sentinel_t<_Range>, iterator_t<const _Range>>; | |
| 95 | same_as<sentinel_t<_Range>, sentinel_t<const _Range>>; | |
| 93 | 96 | |
| 94 | 97 | // [range.refinements], other range refinements |
| 95 | 98 | template <class _Rp, class _Tp> |
| 96 | 99 | concept output_range = range<_Rp> && output_iterator<iterator_t<_Rp>, _Tp>; |
| 97 | 100 | |
| 98 | template <class _Tp> | |
| 99 | concept input_range = range<_Tp> && input_iterator<iterator_t<_Tp>>; | |
| 100 | ||
| 101 | 101 | template <class _Tp> |
| 102 | 102 | concept forward_range = input_range<_Tp> && forward_iterator<iterator_t<_Tp>>; |
| 103 | 103 | |
| ... | ... | @@ -119,20 +119,24 @@ namespace ranges { |
| 119 | 119 | template <class _Tp> |
| 120 | 120 | concept common_range = range<_Tp> && same_as<iterator_t<_Tp>, sentinel_t<_Tp>>; |
| 121 | 121 | |
| 122 | template<class _Tp> | |
| 122 | template <class _Tp> | |
| 123 | inline constexpr bool __is_std_initializer_list = false; | |
| 124 | ||
| 125 | template <class _Ep> | |
| 126 | inline constexpr bool __is_std_initializer_list<initializer_list<_Ep>> = true; | |
| 127 | ||
| 128 | template <class _Tp> | |
| 123 | 129 | concept viewable_range = |
| 124 | range<_Tp> && ( | |
| 125 | (view<remove_cvref_t<_Tp>> && constructible_from<remove_cvref_t<_Tp>, _Tp>) || | |
| 126 | (!view<remove_cvref_t<_Tp>> && borrowed_range<_Tp>) | |
| 127 | ); | |
| 128 | } // namespace ranges | |
| 130 | range<_Tp> && | |
| 131 | ((view<remove_cvref_t<_Tp>> && constructible_from<remove_cvref_t<_Tp>, _Tp>) || | |
| 132 | (!view<remove_cvref_t<_Tp>> && | |
| 133 | (is_lvalue_reference_v<_Tp> || | |
| 134 | (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>)))); | |
| 129 | 135 | |
| 130 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 136 | } // namespace ranges | |
| 131 | 137 | |
| 132 | // clang-format on | |
| 138 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 133 | 139 | |
| 134 | 140 | _LIBCPP_END_NAMESPACE_STD |
| 135 | 141 | |
| 136 | _LIBCPP_POP_MACROS | |
| 137 | ||
| 138 | 142 | #endif // _LIBCPP___RANGES_CONCEPTS_H |
lib/libcxx/include/__ranges/copyable_box.h+10-7| ... | ... | @@ -22,12 +22,9 @@ |
| 22 | 22 | #pragma GCC system_header |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 26 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | 28 | |
| 32 | 29 | // __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into |
| 33 | 30 | // a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state |
| ... | ... | @@ -91,6 +88,10 @@ namespace ranges { |
| 91 | 88 | |
| 92 | 89 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return *__val_; } |
| 93 | 90 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return *__val_; } |
| 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return __val_.operator->(); } | |
| 93 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return __val_.operator->(); } | |
| 94 | ||
| 94 | 95 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return __val_.has_value(); } |
| 95 | 96 | }; |
| 96 | 97 | |
| ... | ... | @@ -162,14 +163,16 @@ namespace ranges { |
| 162 | 163 | |
| 163 | 164 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return __val_; } |
| 164 | 165 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return __val_; } |
| 166 | ||
| 167 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return _VSTD::addressof(__val_); } | |
| 168 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return _VSTD::addressof(__val_); } | |
| 169 | ||
| 165 | 170 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; } |
| 166 | 171 | }; |
| 167 | 172 | } // namespace ranges |
| 168 | 173 | |
| 169 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 174 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 170 | 175 | |
| 171 | 176 | _LIBCPP_END_NAMESPACE_STD |
| 172 | 177 | |
| 173 | _LIBCPP_POP_MACROS | |
| 174 | ||
| 175 | 178 | #endif // _LIBCPP___RANGES_COPYABLE_BOX_H |
lib/libcxx/include/__ranges/counted.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 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_COUNTED_H | |
| 10 | #define _LIBCPP___RANGES_COUNTED_H | |
| 11 | ||
| 12 | #include <__concepts/convertible_to.h> | |
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/counted_iterator.h> | |
| 16 | #include <__iterator/default_sentinel.h> | |
| 17 | #include <__iterator/incrementable_traits.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__memory/pointer_traits.h> | |
| 20 | #include <__ranges/subrange.h> | |
| 21 | #include <__utility/forward.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | #include <span> | |
| 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 | ||
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | namespace ranges::views { | |
| 35 | ||
| 36 | namespace __counted { | |
| 37 | ||
| 38 | struct __fn { | |
| 39 | template<contiguous_iterator _It> | |
| 40 | _LIBCPP_HIDE_FROM_ABI | |
| 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)))) | |
| 43 | // Deliberately omit return-type SFINAE, because to_address is not SFINAE-friendly | |
| 44 | { return span(_VSTD::to_address(__it), static_cast<size_t>(__count)); } | |
| 45 | ||
| 46 | template<random_access_iterator _It> | |
| 47 | _LIBCPP_HIDE_FROM_ABI | |
| 48 | static constexpr auto __go(_It __it, iter_difference_t<_It> __count) | |
| 49 | noexcept(noexcept(subrange(__it, __it + __count))) | |
| 50 | -> decltype( subrange(__it, __it + __count)) | |
| 51 | { return subrange(__it, __it + __count); } | |
| 52 | ||
| 53 | template<class _It> | |
| 54 | _LIBCPP_HIDE_FROM_ABI | |
| 55 | static constexpr auto __go(_It __it, iter_difference_t<_It> __count) | |
| 56 | noexcept(noexcept(subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel))) | |
| 57 | -> decltype( subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel)) | |
| 58 | { return subrange(counted_iterator(_VSTD::move(__it), __count), default_sentinel); } | |
| 59 | ||
| 60 | template<class _It, convertible_to<iter_difference_t<_It>> _Diff> | |
| 61 | requires input_or_output_iterator<decay_t<_It>> | |
| 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 63 | constexpr auto operator()(_It&& __it, _Diff&& __count) const | |
| 64 | noexcept(noexcept(__go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count)))) | |
| 65 | -> decltype( __go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count))) | |
| 66 | { return __go(_VSTD::forward<_It>(__it), _VSTD::forward<_Diff>(__count)); } | |
| 67 | }; | |
| 68 | ||
| 69 | } // namespace __counted | |
| 70 | ||
| 71 | inline namespace __cpo { | |
| 72 | inline constexpr auto counted = __counted::__fn{}; | |
| 73 | } // namespace __cpo | |
| 74 | ||
| 75 | } // namespace ranges::views | |
| 76 | ||
| 77 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | ||
| 79 | _LIBCPP_END_NAMESPACE_STD | |
| 80 | ||
| 81 | #endif // _LIBCPP___RANGES_COUNTED_H |
lib/libcxx/include/__ranges/dangling.h+2-7| ... | ... | @@ -19,12 +19,9 @@ |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 24 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | 25 | |
| 29 | 26 | namespace ranges { |
| 30 | 27 | struct dangling { |
| ... | ... | @@ -38,10 +35,8 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>; |
| 38 | 35 | // borrowed_subrange_t defined in <__ranges/subrange.h> |
| 39 | 36 | } // namespace ranges |
| 40 | 37 | |
| 41 | #endif // !_LIBCPP_HAS_NO_RANGES | |
| 38 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 42 | 39 | |
| 43 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 44 | 41 | |
| 45 | _LIBCPP_POP_MACROS | |
| 46 | ||
| 47 | 42 | #endif // _LIBCPP___RANGES_DANGLING_H |
lib/libcxx/include/__ranges/data.h+45-25| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ __ranges/data.h ------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,78 +9,98 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_DATA_H |
| 10 | 10 | #define _LIBCPP___RANGES_DATA_H |
| 11 | 11 | |
| 12 | #include <__concepts/class_or_enum.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | #include <__memory/pointer_traits.h> |
| 16 | 17 | #include <__ranges/access.h> |
| 17 | #include <__utility/forward.h> | |
| 18 | #include <concepts> | |
| 18 | #include <__utility/auto_cast.h> | |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | 22 | #pragma GCC system_header |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 26 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 31 | 28 | |
| 32 | // clang-format off | |
| 33 | namespace ranges { | |
| 34 | 29 | // [range.prim.data] |
| 30 | ||
| 31 | namespace ranges { | |
| 35 | 32 | namespace __data { |
| 36 | 33 | template <class _Tp> |
| 37 | 34 | concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>; |
| 38 | 35 | |
| 39 | 36 | template <class _Tp> |
| 40 | 37 | concept __member_data = |
| 38 | __can_borrow<_Tp> && | |
| 39 | __workaround_52970<_Tp> && | |
| 41 | 40 | requires(_Tp&& __t) { |
| 42 | { _VSTD::forward<_Tp>(__t) } -> __can_borrow; | |
| 43 | { __t.data() } -> __ptr_to_object; | |
| 41 | { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object; | |
| 44 | 42 | }; |
| 45 | 43 | |
| 46 | 44 | template <class _Tp> |
| 47 | 45 | concept __ranges_begin_invocable = |
| 48 | 46 | !__member_data<_Tp> && |
| 47 | __can_borrow<_Tp> && | |
| 49 | 48 | requires(_Tp&& __t) { |
| 50 | { _VSTD::forward<_Tp>(__t) } -> __can_borrow; | |
| 51 | { ranges::begin(_VSTD::forward<_Tp>(__t)) } -> contiguous_iterator; | |
| 49 | { ranges::begin(__t) } -> contiguous_iterator; | |
| 52 | 50 | }; |
| 53 | 51 | |
| 54 | 52 | struct __fn { |
| 55 | 53 | template <__member_data _Tp> |
| 56 | requires __can_borrow<_Tp> | |
| 57 | 54 | _LIBCPP_HIDE_FROM_ABI |
| 58 | constexpr __ptr_to_object auto operator()(_Tp&& __t) const | |
| 55 | constexpr auto operator()(_Tp&& __t) const | |
| 59 | 56 | noexcept(noexcept(__t.data())) { |
| 60 | 57 | return __t.data(); |
| 61 | 58 | } |
| 62 | 59 | |
| 63 | 60 | template<__ranges_begin_invocable _Tp> |
| 64 | requires __can_borrow<_Tp> | |
| 65 | 61 | _LIBCPP_HIDE_FROM_ABI |
| 66 | constexpr __ptr_to_object auto operator()(_Tp&& __t) const | |
| 67 | noexcept(noexcept(_VSTD::to_address(ranges::begin(_VSTD::forward<_Tp>(__t))))) { | |
| 68 | return _VSTD::to_address(ranges::begin(_VSTD::forward<_Tp>(__t))); | |
| 62 | constexpr auto operator()(_Tp&& __t) const | |
| 63 | noexcept(noexcept(_VSTD::to_address(ranges::begin(__t)))) { | |
| 64 | return _VSTD::to_address(ranges::begin(__t)); | |
| 69 | 65 | } |
| 70 | 66 | }; |
| 71 | } // end namespace __data | |
| 67 | } // namespace __data | |
| 72 | 68 | |
| 73 | 69 | inline namespace __cpo { |
| 74 | inline constexpr const auto data = __data::__fn{}; | |
| 70 | inline constexpr auto data = __data::__fn{}; | |
| 75 | 71 | } // namespace __cpo |
| 76 | 72 | } // namespace ranges |
| 77 | 73 | |
| 78 | // clang-format off | |
| 74 | // [range.prim.cdata] | |
| 75 | ||
| 76 | namespace ranges { | |
| 77 | namespace __cdata { | |
| 78 | struct __fn { | |
| 79 | template <class _Tp> | |
| 80 | requires is_lvalue_reference_v<_Tp&&> | |
| 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 82 | constexpr auto operator()(_Tp&& __t) const | |
| 83 | noexcept(noexcept(ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t)))) | |
| 84 | -> decltype( ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t))) | |
| 85 | { return ranges::data(static_cast<const remove_reference_t<_Tp>&>(__t)); } | |
| 86 | ||
| 87 | template <class _Tp> | |
| 88 | requires is_rvalue_reference_v<_Tp&&> | |
| 89 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 90 | constexpr auto operator()(_Tp&& __t) const | |
| 91 | noexcept(noexcept(ranges::data(static_cast<const _Tp&&>(__t)))) | |
| 92 | -> decltype( ranges::data(static_cast<const _Tp&&>(__t))) | |
| 93 | { return ranges::data(static_cast<const _Tp&&>(__t)); } | |
| 94 | }; | |
| 95 | } // namespace __cdata | |
| 96 | ||
| 97 | inline namespace __cpo { | |
| 98 | inline constexpr auto cdata = __cdata::__fn{}; | |
| 99 | } // namespace __cpo | |
| 100 | } // namespace ranges | |
| 79 | 101 | |
| 80 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 102 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 81 | 103 | |
| 82 | 104 | _LIBCPP_END_NAMESPACE_STD |
| 83 | 105 | |
| 84 | _LIBCPP_POP_MACROS | |
| 85 | ||
| 86 | 106 | #endif // _LIBCPP___RANGES_DATA_H |
lib/libcxx/include/__ranges/drop_view.h+4-8| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___RANGES_DROP_VIEW_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__debug> | |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | #include <__iterator/next.h> |
| ... | ... | @@ -28,12 +29,9 @@ |
| 28 | 29 | #pragma GCC system_header |
| 29 | 30 | #endif |
| 30 | 31 | |
| 31 | _LIBCPP_PUSH_MACROS | |
| 32 | #include <__undef_macros> | |
| 33 | ||
| 34 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 33 | |
| 36 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 34 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 37 | 35 | |
| 38 | 36 | namespace ranges { |
| 39 | 37 | template<view _View> |
| ... | ... | @@ -76,7 +74,7 @@ public: |
| 76 | 74 | |
| 77 | 75 | auto __tmp = ranges::next(ranges::begin(__base_), __count_, ranges::end(__base_)); |
| 78 | 76 | if constexpr (_UseCache) |
| 79 | __cached_begin_.__set(__tmp); | |
| 77 | __cached_begin_.__emplace(__tmp); | |
| 80 | 78 | return __tmp; |
| 81 | 79 | } |
| 82 | 80 | |
| ... | ... | @@ -122,10 +120,8 @@ public: |
| 122 | 120 | inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; |
| 123 | 121 | } // namespace ranges |
| 124 | 122 | |
| 125 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 123 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 126 | 124 | |
| 127 | 125 | _LIBCPP_END_NAMESPACE_STD |
| 128 | 126 | |
| 129 | _LIBCPP_POP_MACROS | |
| 130 | ||
| 131 | 127 | #endif // _LIBCPP___RANGES_DROP_VIEW_H |
lib/libcxx/include/__ranges/empty.h+15-19| ... | ... | @@ -9,37 +9,36 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_EMPTY_H |
| 10 | 10 | #define _LIBCPP___RANGES_EMPTY_H |
| 11 | 11 | |
| 12 | #include <__concepts/class_or_enum.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__ranges/access.h> |
| 15 | 16 | #include <__ranges/size.h> |
| 16 | #include <__utility/forward.h> | |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | 26 | |
| 30 | // clang-format off | |
| 31 | namespace ranges { | |
| 32 | 27 | // [range.prim.empty] |
| 28 | ||
| 29 | namespace ranges { | |
| 33 | 30 | namespace __empty { |
| 34 | 31 | template <class _Tp> |
| 35 | concept __member_empty = requires(_Tp&& __t) { | |
| 36 | bool(_VSTD::forward<_Tp>(__t).empty()); | |
| 37 | }; | |
| 32 | concept __member_empty = | |
| 33 | __workaround_52970<_Tp> && | |
| 34 | requires(_Tp&& __t) { | |
| 35 | bool(__t.empty()); | |
| 36 | }; | |
| 38 | 37 | |
| 39 | 38 | template<class _Tp> |
| 40 | 39 | concept __can_invoke_size = |
| 41 | 40 | !__member_empty<_Tp> && |
| 42 | requires(_Tp&& __t) { ranges::size(_VSTD::forward<_Tp>(__t)); }; | |
| 41 | requires(_Tp&& __t) { ranges::size(__t); }; | |
| 43 | 42 | |
| 44 | 43 | template <class _Tp> |
| 45 | 44 | concept __can_compare_begin_end = |
| ... | ... | @@ -54,13 +53,13 @@ namespace __empty { |
| 54 | 53 | template <__member_empty _Tp> |
| 55 | 54 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t) const |
| 56 | 55 | noexcept(noexcept(bool(__t.empty()))) { |
| 57 | return __t.empty(); | |
| 56 | return bool(__t.empty()); | |
| 58 | 57 | } |
| 59 | 58 | |
| 60 | 59 | template <__can_invoke_size _Tp> |
| 61 | 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t) const |
| 62 | noexcept(noexcept(ranges::size(_VSTD::forward<_Tp>(__t)))) { | |
| 63 | return ranges::size(_VSTD::forward<_Tp>(__t)) == 0; | |
| 61 | noexcept(noexcept(ranges::size(__t))) { | |
| 62 | return ranges::size(__t) == 0; | |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | 65 | template<__can_compare_begin_end _Tp> |
| ... | ... | @@ -69,18 +68,15 @@ namespace __empty { |
| 69 | 68 | return ranges::begin(__t) == ranges::end(__t); |
| 70 | 69 | } |
| 71 | 70 | }; |
| 72 | } | |
| 71 | } // namespace __empty | |
| 73 | 72 | |
| 74 | 73 | inline namespace __cpo { |
| 75 | 74 | inline constexpr auto empty = __empty::__fn{}; |
| 76 | 75 | } // namespace __cpo |
| 77 | 76 | } // namespace ranges |
| 78 | // clang-format off | |
| 79 | 77 | |
| 80 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 78 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 81 | 79 | |
| 82 | 80 | _LIBCPP_END_NAMESPACE_STD |
| 83 | 81 | |
| 84 | _LIBCPP_POP_MACROS | |
| 85 | ||
| 86 | 82 | #endif // _LIBCPP___RANGES_EMPTY_H |
lib/libcxx/include/__ranges/empty_view.h+6-7| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___RANGES_EMPTY_VIEW_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__ranges/enable_borrowed_range.h> | |
| 13 | 14 | #include <__ranges/view_interface.h> |
| 14 | 15 | #include <type_traits> |
| 15 | 16 | |
| ... | ... | @@ -17,12 +18,9 @@ |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | 24 | |
| 27 | 25 | namespace ranges { |
| 28 | 26 | template<class _Tp> |
| ... | ... | @@ -35,12 +33,13 @@ namespace ranges { |
| 35 | 33 | _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; } |
| 36 | 34 | _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; } |
| 37 | 35 | }; |
| 36 | ||
| 37 | template<class _Tp> | |
| 38 | inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true; | |
| 38 | 39 | } // namespace ranges |
| 39 | 40 | |
| 40 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 41 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 41 | 42 | |
| 42 | 43 | _LIBCPP_END_NAMESPACE_STD |
| 43 | 44 | |
| 44 | _LIBCPP_POP_MACROS | |
| 45 | ||
| 46 | 45 | #endif // _LIBCPP___RANGES_EMPTY_VIEW_H |
lib/libcxx/include/__ranges/enable_borrowed_range.h+4-10| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------ __ranges/enable_borrowed_range.h ------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -20,15 +20,11 @@ |
| 20 | 20 | #pragma GCC system_header |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 24 | |
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | 26 | |
| 30 | namespace ranges | |
| 31 | { | |
| 27 | namespace ranges { | |
| 32 | 28 | |
| 33 | 29 | // [range.range], ranges |
| 34 | 30 | |
| ... | ... | @@ -37,10 +33,8 @@ inline constexpr bool enable_borrowed_range = false; |
| 37 | 33 | |
| 38 | 34 | } // namespace ranges |
| 39 | 35 | |
| 40 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 41 | 37 | |
| 42 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 43 | 39 | |
| 44 | _LIBCPP_POP_MACROS | |
| 45 | ||
| 46 | 40 | #endif // _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H |
lib/libcxx/include/__ranges/enable_view.h+14-9| ... | ... | @@ -12,31 +12,36 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <concepts> |
| 15 | #include <type_traits> | |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | 24 | |
| 27 | 25 | namespace ranges { |
| 28 | 26 | |
| 29 | 27 | struct view_base { }; |
| 30 | 28 | |
| 29 | template<class _Derived> | |
| 30 | requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>> | |
| 31 | class view_interface; | |
| 32 | ||
| 33 | template<class _Op, class _Yp> | |
| 34 | requires is_convertible_v<_Op*, view_interface<_Yp>*> | |
| 35 | void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*); | |
| 36 | ||
| 31 | 37 | template <class _Tp> |
| 32 | inline constexpr bool enable_view = derived_from<_Tp, view_base>; | |
| 38 | inline constexpr bool enable_view = derived_from<_Tp, view_base> || | |
| 39 | requires { ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr); }; | |
| 33 | 40 | |
| 34 | } // end namespace ranges | |
| 41 | } // namespace ranges | |
| 35 | 42 | |
| 36 | #endif // !_LIBCPP_HAS_NO_RANGES | |
| 43 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 37 | 44 | |
| 38 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 39 | 46 | |
| 40 | _LIBCPP_POP_MACROS | |
| 41 | ||
| 42 | 47 | #endif // _LIBCPP___RANGES_ENABLE_VIEW_H |
lib/libcxx/include/__ranges/iota_view.h created+408| ... | ... | @@ -0,0 +1,408 @@ |
| 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_IOTA_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_IOTA_VIEW_H | |
| 11 | ||
| 12 | #include <__compare/three_way_comparable.h> | |
| 13 | #include <__concepts/arithmetic.h> | |
| 14 | #include <__concepts/constructible.h> | |
| 15 | #include <__concepts/convertible_to.h> | |
| 16 | #include <__concepts/copyable.h> | |
| 17 | #include <__concepts/equality_comparable.h> | |
| 18 | #include <__concepts/invocable.h> | |
| 19 | #include <__concepts/same_as.h> | |
| 20 | #include <__concepts/semiregular.h> | |
| 21 | #include <__concepts/totally_ordered.h> | |
| 22 | #include <__config> | |
| 23 | #include <__debug> | |
| 24 | #include <__functional/ranges_operations.h> | |
| 25 | #include <__iterator/concepts.h> | |
| 26 | #include <__iterator/incrementable_traits.h> | |
| 27 | #include <__iterator/iterator_traits.h> | |
| 28 | #include <__iterator/unreachable_sentinel.h> | |
| 29 | #include <__ranges/copyable_box.h> | |
| 30 | #include <__ranges/enable_borrowed_range.h> | |
| 31 | #include <__ranges/view_interface.h> | |
| 32 | #include <__utility/forward.h> | |
| 33 | #include <__utility/move.h> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 43 | ||
| 44 | namespace ranges { | |
| 45 | template<class _Int> | |
| 46 | struct __get_wider_signed { | |
| 47 | static auto __call() { | |
| 48 | if constexpr (sizeof(_Int) < sizeof(short)) return type_identity<short>{}; | |
| 49 | else if constexpr (sizeof(_Int) < sizeof(int)) return type_identity<int>{}; | |
| 50 | else if constexpr (sizeof(_Int) < sizeof(long)) return type_identity<long>{}; | |
| 51 | else return type_identity<long long>{}; | |
| 52 | ||
| 53 | static_assert(sizeof(_Int) <= sizeof(long long), | |
| 54 | "Found integer-like type that is bigger than largest integer like type."); | |
| 55 | } | |
| 56 | ||
| 57 | using type = typename decltype(__call())::type; | |
| 58 | }; | |
| 59 | ||
| 60 | template<class _Start> | |
| 61 | using _IotaDiffT = typename _If< | |
| 62 | (!integral<_Start> || sizeof(iter_difference_t<_Start>) > sizeof(_Start)), | |
| 63 | type_identity<iter_difference_t<_Start>>, | |
| 64 | __get_wider_signed<_Start> | |
| 65 | >::type; | |
| 66 | ||
| 67 | template<class _Iter> | |
| 68 | concept __decrementable = incrementable<_Iter> && requires(_Iter __i) { | |
| 69 | { --__i } -> same_as<_Iter&>; | |
| 70 | { __i-- } -> same_as<_Iter>; | |
| 71 | }; | |
| 72 | ||
| 73 | template<class _Iter> | |
| 74 | concept __advanceable = | |
| 75 | __decrementable<_Iter> && totally_ordered<_Iter> && | |
| 76 | requires(_Iter __i, const _Iter __j, const _IotaDiffT<_Iter> __n) { | |
| 77 | { __i += __n } -> same_as<_Iter&>; | |
| 78 | { __i -= __n } -> same_as<_Iter&>; | |
| 79 | _Iter(__j + __n); | |
| 80 | _Iter(__n + __j); | |
| 81 | _Iter(__j - __n); | |
| 82 | { __j - __j } -> convertible_to<_IotaDiffT<_Iter>>; | |
| 83 | }; | |
| 84 | ||
| 85 | template<class> | |
| 86 | struct __iota_iterator_category {}; | |
| 87 | ||
| 88 | template<incrementable _Tp> | |
| 89 | struct __iota_iterator_category<_Tp> { | |
| 90 | using iterator_category = input_iterator_tag; | |
| 91 | }; | |
| 92 | ||
| 93 | template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t> | |
| 94 | requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start> | |
| 95 | class iota_view : public view_interface<iota_view<_Start, _Bound>> { | |
| 96 | struct __iterator : public __iota_iterator_category<_Start> { | |
| 97 | friend class iota_view; | |
| 98 | ||
| 99 | using iterator_concept = | |
| 100 | _If<__advanceable<_Start>, random_access_iterator_tag, | |
| 101 | _If<__decrementable<_Start>, bidirectional_iterator_tag, | |
| 102 | _If<incrementable<_Start>, forward_iterator_tag, | |
| 103 | /*Else*/ input_iterator_tag>>>; | |
| 104 | ||
| 105 | using value_type = _Start; | |
| 106 | using difference_type = _IotaDiffT<_Start>; | |
| 107 | ||
| 108 | _Start __value_ = _Start(); | |
| 109 | ||
| 110 | _LIBCPP_HIDE_FROM_ABI | |
| 111 | __iterator() requires default_initializable<_Start> = default; | |
| 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI | |
| 114 | constexpr explicit __iterator(_Start __value) : __value_(_VSTD::move(__value)) {} | |
| 115 | ||
| 116 | _LIBCPP_HIDE_FROM_ABI | |
| 117 | constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) { | |
| 118 | return __value_; | |
| 119 | } | |
| 120 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI | |
| 122 | constexpr __iterator& operator++() { | |
| 123 | ++__value_; | |
| 124 | return *this; | |
| 125 | } | |
| 126 | ||
| 127 | _LIBCPP_HIDE_FROM_ABI | |
| 128 | constexpr void operator++(int) { ++*this; } | |
| 129 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI | |
| 131 | constexpr __iterator operator++(int) requires incrementable<_Start> { | |
| 132 | auto __tmp = *this; | |
| 133 | ++*this; | |
| 134 | return __tmp; | |
| 135 | } | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI | |
| 138 | constexpr __iterator& operator--() requires __decrementable<_Start> { | |
| 139 | --__value_; | |
| 140 | return *this; | |
| 141 | } | |
| 142 | ||
| 143 | _LIBCPP_HIDE_FROM_ABI | |
| 144 | constexpr __iterator operator--(int) requires __decrementable<_Start> { | |
| 145 | auto __tmp = *this; | |
| 146 | --*this; | |
| 147 | return __tmp; | |
| 148 | } | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI | |
| 151 | constexpr __iterator& operator+=(difference_type __n) | |
| 152 | requires __advanceable<_Start> | |
| 153 | { | |
| 154 | if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) { | |
| 155 | if (__n >= difference_type(0)) { | |
| 156 | __value_ += static_cast<_Start>(__n); | |
| 157 | } else { | |
| 158 | __value_ -= static_cast<_Start>(-__n); | |
| 159 | } | |
| 160 | } else { | |
| 161 | __value_ += __n; | |
| 162 | } | |
| 163 | return *this; | |
| 164 | } | |
| 165 | ||
| 166 | _LIBCPP_HIDE_FROM_ABI | |
| 167 | constexpr __iterator& operator-=(difference_type __n) | |
| 168 | requires __advanceable<_Start> | |
| 169 | { | |
| 170 | if constexpr (__integer_like<_Start> && !__signed_integer_like<_Start>) { | |
| 171 | if (__n >= difference_type(0)) { | |
| 172 | __value_ -= static_cast<_Start>(__n); | |
| 173 | } else { | |
| 174 | __value_ += static_cast<_Start>(-__n); | |
| 175 | } | |
| 176 | } else { | |
| 177 | __value_ -= __n; | |
| 178 | } | |
| 179 | return *this; | |
| 180 | } | |
| 181 | ||
| 182 | _LIBCPP_HIDE_FROM_ABI | |
| 183 | constexpr _Start operator[](difference_type __n) const | |
| 184 | requires __advanceable<_Start> | |
| 185 | { | |
| 186 | return _Start(__value_ + __n); | |
| 187 | } | |
| 188 | ||
| 189 | _LIBCPP_HIDE_FROM_ABI | |
| 190 | friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) | |
| 191 | requires equality_comparable<_Start> | |
| 192 | { | |
| 193 | return __x.__value_ == __y.__value_; | |
| 194 | } | |
| 195 | ||
| 196 | _LIBCPP_HIDE_FROM_ABI | |
| 197 | friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) | |
| 198 | requires totally_ordered<_Start> | |
| 199 | { | |
| 200 | return __x.__value_ < __y.__value_; | |
| 201 | } | |
| 202 | ||
| 203 | _LIBCPP_HIDE_FROM_ABI | |
| 204 | friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) | |
| 205 | requires totally_ordered<_Start> | |
| 206 | { | |
| 207 | return __y < __x; | |
| 208 | } | |
| 209 | ||
| 210 | _LIBCPP_HIDE_FROM_ABI | |
| 211 | friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) | |
| 212 | requires totally_ordered<_Start> | |
| 213 | { | |
| 214 | return !(__y < __x); | |
| 215 | } | |
| 216 | ||
| 217 | _LIBCPP_HIDE_FROM_ABI | |
| 218 | friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) | |
| 219 | requires totally_ordered<_Start> | |
| 220 | { | |
| 221 | return !(__x < __y); | |
| 222 | } | |
| 223 | ||
| 224 | friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | |
| 225 | requires totally_ordered<_Start> && three_way_comparable<_Start> | |
| 226 | { | |
| 227 | return __x.__value_ <=> __y.__value_; | |
| 228 | } | |
| 229 | ||
| 230 | _LIBCPP_HIDE_FROM_ABI | |
| 231 | friend constexpr __iterator operator+(__iterator __i, difference_type __n) | |
| 232 | requires __advanceable<_Start> | |
| 233 | { | |
| 234 | __i += __n; | |
| 235 | return __i; | |
| 236 | } | |
| 237 | ||
| 238 | _LIBCPP_HIDE_FROM_ABI | |
| 239 | friend constexpr __iterator operator+(difference_type __n, __iterator __i) | |
| 240 | requires __advanceable<_Start> | |
| 241 | { | |
| 242 | return __i + __n; | |
| 243 | } | |
| 244 | ||
| 245 | _LIBCPP_HIDE_FROM_ABI | |
| 246 | friend constexpr __iterator operator-(__iterator __i, difference_type __n) | |
| 247 | requires __advanceable<_Start> | |
| 248 | { | |
| 249 | __i -= __n; | |
| 250 | return __i; | |
| 251 | } | |
| 252 | ||
| 253 | _LIBCPP_HIDE_FROM_ABI | |
| 254 | friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) | |
| 255 | requires __advanceable<_Start> | |
| 256 | { | |
| 257 | if constexpr (__integer_like<_Start>) { | |
| 258 | if constexpr (__signed_integer_like<_Start>) { | |
| 259 | return difference_type(difference_type(__x.__value_) - difference_type(__y.__value_)); | |
| 260 | } | |
| 261 | if (__y.__value_ > __x.__value_) { | |
| 262 | return difference_type(-difference_type(__y.__value_ - __x.__value_)); | |
| 263 | } | |
| 264 | return difference_type(__x.__value_ - __y.__value_); | |
| 265 | } | |
| 266 | return __x.__value_ - __y.__value_; | |
| 267 | } | |
| 268 | }; | |
| 269 | ||
| 270 | struct __sentinel { | |
| 271 | friend class iota_view; | |
| 272 | ||
| 273 | private: | |
| 274 | _Bound __bound_ = _Bound(); | |
| 275 | ||
| 276 | public: | |
| 277 | _LIBCPP_HIDE_FROM_ABI | |
| 278 | __sentinel() = default; | |
| 279 | constexpr explicit __sentinel(_Bound __bound) : __bound_(_VSTD::move(__bound)) {} | |
| 280 | ||
| 281 | _LIBCPP_HIDE_FROM_ABI | |
| 282 | friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) { | |
| 283 | return __x.__value_ == __y.__bound_; | |
| 284 | } | |
| 285 | ||
| 286 | _LIBCPP_HIDE_FROM_ABI | |
| 287 | friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y) | |
| 288 | requires sized_sentinel_for<_Bound, _Start> | |
| 289 | { | |
| 290 | return __x.__value_ - __y.__bound_; | |
| 291 | } | |
| 292 | ||
| 293 | _LIBCPP_HIDE_FROM_ABI | |
| 294 | friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y) | |
| 295 | requires sized_sentinel_for<_Bound, _Start> | |
| 296 | { | |
| 297 | return -(__y - __x); | |
| 298 | } | |
| 299 | }; | |
| 300 | ||
| 301 | _Start __value_ = _Start(); | |
| 302 | _Bound __bound_ = _Bound(); | |
| 303 | ||
| 304 | public: | |
| 305 | _LIBCPP_HIDE_FROM_ABI | |
| 306 | iota_view() requires default_initializable<_Start> = default; | |
| 307 | ||
| 308 | _LIBCPP_HIDE_FROM_ABI | |
| 309 | constexpr explicit iota_view(_Start __value) : __value_(_VSTD::move(__value)) { } | |
| 310 | ||
| 311 | _LIBCPP_HIDE_FROM_ABI | |
| 312 | constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound) | |
| 313 | : __value_(_VSTD::move(__value)), __bound_(_VSTD::move(__bound)) { | |
| 314 | // Validate the precondition if possible. | |
| 315 | if constexpr (totally_ordered_with<_Start, _Bound>) { | |
| 316 | _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_), | |
| 317 | "Precondition violated: value is greater than bound."); | |
| 318 | } | |
| 319 | } | |
| 320 | ||
| 321 | _LIBCPP_HIDE_FROM_ABI | |
| 322 | constexpr iota_view(__iterator __first, __iterator __last) | |
| 323 | requires same_as<_Start, _Bound> | |
| 324 | : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last.__value_)) {} | |
| 325 | ||
| 326 | _LIBCPP_HIDE_FROM_ABI | |
| 327 | constexpr iota_view(__iterator __first, _Bound __last) | |
| 328 | requires same_as<_Bound, unreachable_sentinel_t> | |
| 329 | : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last)) {} | |
| 330 | ||
| 331 | _LIBCPP_HIDE_FROM_ABI | |
| 332 | constexpr iota_view(__iterator __first, __sentinel __last) | |
| 333 | requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>) | |
| 334 | : iota_view(_VSTD::move(__first.__value_), _VSTD::move(__last.__bound_)) {} | |
| 335 | ||
| 336 | _LIBCPP_HIDE_FROM_ABI | |
| 337 | constexpr __iterator begin() const { return __iterator{__value_}; } | |
| 338 | ||
| 339 | _LIBCPP_HIDE_FROM_ABI | |
| 340 | constexpr auto end() const { | |
| 341 | if constexpr (same_as<_Bound, unreachable_sentinel_t>) | |
| 342 | return unreachable_sentinel; | |
| 343 | else | |
| 344 | return __sentinel{__bound_}; | |
| 345 | } | |
| 346 | ||
| 347 | _LIBCPP_HIDE_FROM_ABI | |
| 348 | constexpr __iterator end() const requires same_as<_Start, _Bound> { | |
| 349 | return __iterator{__bound_}; | |
| 350 | } | |
| 351 | ||
| 352 | _LIBCPP_HIDE_FROM_ABI | |
| 353 | constexpr auto size() const | |
| 354 | requires (same_as<_Start, _Bound> && __advanceable<_Start>) || | |
| 355 | (integral<_Start> && integral<_Bound>) || | |
| 356 | sized_sentinel_for<_Bound, _Start> | |
| 357 | { | |
| 358 | if constexpr (__integer_like<_Start> && __integer_like<_Bound>) { | |
| 359 | if (__value_ < 0) { | |
| 360 | if (__bound_ < 0) { | |
| 361 | return _VSTD::__to_unsigned_like(-__value_) - _VSTD::__to_unsigned_like(-__bound_); | |
| 362 | } | |
| 363 | return _VSTD::__to_unsigned_like(__bound_) + _VSTD::__to_unsigned_like(-__value_); | |
| 364 | } | |
| 365 | return _VSTD::__to_unsigned_like(__bound_) - _VSTD::__to_unsigned_like(__value_); | |
| 366 | } | |
| 367 | return _VSTD::__to_unsigned_like(__bound_ - __value_); | |
| 368 | } | |
| 369 | }; | |
| 370 | ||
| 371 | template<class _Start, class _Bound> | |
| 372 | requires (!__integer_like<_Start> || !__integer_like<_Bound> || | |
| 373 | (__signed_integer_like<_Start> == __signed_integer_like<_Bound>)) | |
| 374 | iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>; | |
| 375 | ||
| 376 | template<class _Start, class _Bound> | |
| 377 | inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true; | |
| 378 | ||
| 379 | namespace views { | |
| 380 | namespace __iota { | |
| 381 | struct __fn { | |
| 382 | template<class _Start> | |
| 383 | _LIBCPP_HIDE_FROM_ABI | |
| 384 | constexpr auto operator()(_Start&& __start) const | |
| 385 | noexcept(noexcept(ranges::iota_view(_VSTD::forward<_Start>(__start)))) | |
| 386 | -> decltype( ranges::iota_view(_VSTD::forward<_Start>(__start))) | |
| 387 | { return ranges::iota_view(_VSTD::forward<_Start>(__start)); } | |
| 388 | ||
| 389 | template<class _Start, class _Bound> | |
| 390 | _LIBCPP_HIDE_FROM_ABI | |
| 391 | constexpr auto operator()(_Start&& __start, _Bound&& __bound) const | |
| 392 | noexcept(noexcept(ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound)))) | |
| 393 | -> decltype( ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound))) | |
| 394 | { return ranges::iota_view(_VSTD::forward<_Start>(__start), _VSTD::forward<_Bound>(__bound)); } | |
| 395 | }; | |
| 396 | } // namespace __iota | |
| 397 | ||
| 398 | inline namespace __cpo { | |
| 399 | inline constexpr auto iota = __iota::__fn{}; | |
| 400 | } // namespace __cpo | |
| 401 | } // namespace views | |
| 402 | } // namespace ranges | |
| 403 | ||
| 404 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 405 | ||
| 406 | _LIBCPP_END_NAMESPACE_STD | |
| 407 | ||
| 408 | #endif // _LIBCPP___RANGES_IOTA_VIEW_H |
lib/libcxx/include/__ranges/join_view.h created+350| ... | ... | @@ -0,0 +1,350 @@ |
| 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_JOIN_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_JOIN_VIEW_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__iterator/concepts.h> | |
| 14 | #include <__iterator/iterator_traits.h> | |
| 15 | #include <__ranges/access.h> | |
| 16 | #include <__ranges/all.h> | |
| 17 | #include <__ranges/concepts.h> | |
| 18 | #include <__ranges/non_propagating_cache.h> | |
| 19 | #include <__ranges/ref_view.h> | |
| 20 | #include <__ranges/subrange.h> | |
| 21 | #include <__ranges/view_interface.h> | |
| 22 | #include <__utility/declval.h> | |
| 23 | #include <__utility/forward.h> | |
| 24 | #include <optional> | |
| 25 | #include <type_traits> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | ||
| 35 | namespace ranges { | |
| 36 | template<class> | |
| 37 | struct __join_view_iterator_category {}; | |
| 38 | ||
| 39 | template<class _View> | |
| 40 | requires is_reference_v<range_reference_t<_View>> && | |
| 41 | forward_range<_View> && | |
| 42 | forward_range<range_reference_t<_View>> | |
| 43 | struct __join_view_iterator_category<_View> { | |
| 44 | using _OuterC = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 45 | using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category; | |
| 46 | ||
| 47 | using iterator_category = _If< | |
| 48 | derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag>, | |
| 49 | bidirectional_iterator_tag, | |
| 50 | _If< | |
| 51 | derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag>, | |
| 52 | forward_iterator_tag, | |
| 53 | input_iterator_tag | |
| 54 | > | |
| 55 | >; | |
| 56 | }; | |
| 57 | ||
| 58 | template<input_range _View> | |
| 59 | requires view<_View> && input_range<range_reference_t<_View>> | |
| 60 | class join_view | |
| 61 | : public view_interface<join_view<_View>> { | |
| 62 | private: | |
| 63 | using _InnerRange = range_reference_t<_View>; | |
| 64 | ||
| 65 | template<bool> struct __iterator; | |
| 66 | template<bool> struct __sentinel; | |
| 67 | ||
| 68 | static constexpr bool _UseCache = !is_reference_v<_InnerRange>; | |
| 69 | using _Cache = _If<_UseCache, __non_propagating_cache<remove_cvref_t<_InnerRange>>, __empty_cache>; | |
| 70 | [[no_unique_address]] _Cache __cache_; | |
| 71 | _View __base_ = _View(); // TODO: [[no_unique_address]] makes clang crash! File a bug :) | |
| 72 | ||
| 73 | public: | |
| 74 | _LIBCPP_HIDE_FROM_ABI | |
| 75 | join_view() requires default_initializable<_View> = default; | |
| 76 | ||
| 77 | _LIBCPP_HIDE_FROM_ABI | |
| 78 | constexpr explicit join_view(_View __base) | |
| 79 | : __base_(_VSTD::move(__base)) {} | |
| 80 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI | |
| 82 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } | |
| 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI | |
| 85 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 86 | ||
| 87 | _LIBCPP_HIDE_FROM_ABI | |
| 88 | constexpr auto begin() { | |
| 89 | constexpr bool __use_const = __simple_view<_View> && | |
| 90 | is_reference_v<range_reference_t<_View>>; | |
| 91 | return __iterator<__use_const>{*this, ranges::begin(__base_)}; | |
| 92 | } | |
| 93 | ||
| 94 | template<class _V2 = _View> | |
| 95 | _LIBCPP_HIDE_FROM_ABI | |
| 96 | constexpr auto begin() const | |
| 97 | requires input_range<const _V2> && | |
| 98 | is_reference_v<range_reference_t<const _V2>> | |
| 99 | { | |
| 100 | return __iterator<true>{*this, ranges::begin(__base_)}; | |
| 101 | } | |
| 102 | ||
| 103 | _LIBCPP_HIDE_FROM_ABI | |
| 104 | constexpr auto end() { | |
| 105 | if constexpr (forward_range<_View> && | |
| 106 | is_reference_v<_InnerRange> && | |
| 107 | forward_range<_InnerRange> && | |
| 108 | common_range<_View> && | |
| 109 | common_range<_InnerRange>) | |
| 110 | return __iterator<__simple_view<_View>>{*this, ranges::end(__base_)}; | |
| 111 | else | |
| 112 | return __sentinel<__simple_view<_View>>{*this}; | |
| 113 | } | |
| 114 | ||
| 115 | template<class _V2 = _View> | |
| 116 | _LIBCPP_HIDE_FROM_ABI | |
| 117 | constexpr auto end() const | |
| 118 | requires input_range<const _V2> && | |
| 119 | is_reference_v<range_reference_t<const _V2>> | |
| 120 | { | |
| 121 | using _ConstInnerRange = range_reference_t<const _View>; | |
| 122 | if constexpr (forward_range<const _View> && | |
| 123 | is_reference_v<_ConstInnerRange> && | |
| 124 | forward_range<_ConstInnerRange> && | |
| 125 | common_range<const _View> && | |
| 126 | common_range<_ConstInnerRange>) { | |
| 127 | return __iterator<true>{*this, ranges::end(__base_)}; | |
| 128 | } else { | |
| 129 | return __sentinel<true>{*this}; | |
| 130 | } | |
| 131 | } | |
| 132 | }; | |
| 133 | ||
| 134 | template<input_range _View> | |
| 135 | requires view<_View> && input_range<range_reference_t<_View>> | |
| 136 | template<bool _Const> struct join_view<_View>::__sentinel { | |
| 137 | template<bool> friend struct __sentinel; | |
| 138 | ||
| 139 | private: | |
| 140 | using _Parent = __maybe_const<_Const, join_view>; | |
| 141 | using _Base = __maybe_const<_Const, _View>; | |
| 142 | sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | |
| 143 | ||
| 144 | public: | |
| 145 | _LIBCPP_HIDE_FROM_ABI | |
| 146 | __sentinel() = default; | |
| 147 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI | |
| 149 | constexpr explicit __sentinel(_Parent& __parent) | |
| 150 | : __end_(ranges::end(__parent.__base_)) {} | |
| 151 | ||
| 152 | _LIBCPP_HIDE_FROM_ABI | |
| 153 | constexpr __sentinel(__sentinel<!_Const> __s) | |
| 154 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> | |
| 155 | : __end_(_VSTD::move(__s.__end_)) {} | |
| 156 | ||
| 157 | template<bool _OtherConst> | |
| 158 | requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | |
| 159 | _LIBCPP_HIDE_FROM_ABI | |
| 160 | friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | |
| 161 | return __x.__outer_ == __y.__end_; | |
| 162 | } | |
| 163 | }; | |
| 164 | ||
| 165 | template<input_range _View> | |
| 166 | requires view<_View> && input_range<range_reference_t<_View>> | |
| 167 | template<bool _Const> struct join_view<_View>::__iterator | |
| 168 | : public __join_view_iterator_category<__maybe_const<_Const, _View>> { | |
| 169 | ||
| 170 | template<bool> friend struct __iterator; | |
| 171 | ||
| 172 | private: | |
| 173 | using _Parent = __maybe_const<_Const, join_view>; | |
| 174 | using _Base = __maybe_const<_Const, _View>; | |
| 175 | using _Outer = iterator_t<_Base>; | |
| 176 | using _Inner = iterator_t<range_reference_t<_Base>>; | |
| 177 | ||
| 178 | static constexpr bool __ref_is_glvalue = is_reference_v<range_reference_t<_Base>>; | |
| 179 | ||
| 180 | public: | |
| 181 | _Outer __outer_ = _Outer(); | |
| 182 | ||
| 183 | private: | |
| 184 | optional<_Inner> __inner_; | |
| 185 | _Parent *__parent_ = nullptr; | |
| 186 | ||
| 187 | _LIBCPP_HIDE_FROM_ABI | |
| 188 | constexpr void __satisfy() { | |
| 189 | for (; __outer_ != ranges::end(__parent_->__base_); ++__outer_) { | |
| 190 | auto&& __inner = [&]() -> auto&& { | |
| 191 | if constexpr (__ref_is_glvalue) | |
| 192 | return *__outer_; | |
| 193 | else | |
| 194 | return __parent_->__cache_.__emplace_from([&]() -> decltype(auto) { return *__outer_; }); | |
| 195 | }(); | |
| 196 | __inner_ = ranges::begin(__inner); | |
| 197 | if (*__inner_ != ranges::end(__inner)) | |
| 198 | return; | |
| 199 | } | |
| 200 | ||
| 201 | if constexpr (__ref_is_glvalue) | |
| 202 | __inner_.reset(); | |
| 203 | } | |
| 204 | ||
| 205 | public: | |
| 206 | using iterator_concept = _If< | |
| 207 | __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>>, | |
| 208 | bidirectional_iterator_tag, | |
| 209 | _If< | |
| 210 | __ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>, | |
| 211 | forward_iterator_tag, | |
| 212 | input_iterator_tag | |
| 213 | > | |
| 214 | >; | |
| 215 | ||
| 216 | using value_type = range_value_t<range_reference_t<_Base>>; | |
| 217 | ||
| 218 | using difference_type = common_type_t< | |
| 219 | range_difference_t<_Base>, range_difference_t<range_reference_t<_Base>>>; | |
| 220 | ||
| 221 | _LIBCPP_HIDE_FROM_ABI | |
| 222 | __iterator() requires default_initializable<_Outer> = default; | |
| 223 | ||
| 224 | _LIBCPP_HIDE_FROM_ABI | |
| 225 | constexpr __iterator(_Parent& __parent, _Outer __outer) | |
| 226 | : __outer_(_VSTD::move(__outer)) | |
| 227 | , __parent_(_VSTD::addressof(__parent)) { | |
| 228 | __satisfy(); | |
| 229 | } | |
| 230 | ||
| 231 | _LIBCPP_HIDE_FROM_ABI | |
| 232 | constexpr __iterator(__iterator<!_Const> __i) | |
| 233 | requires _Const && | |
| 234 | convertible_to<iterator_t<_View>, _Outer> && | |
| 235 | convertible_to<iterator_t<_InnerRange>, _Inner> | |
| 236 | : __outer_(_VSTD::move(__i.__outer_)) | |
| 237 | , __inner_(_VSTD::move(__i.__inner_)) | |
| 238 | , __parent_(__i.__parent_) {} | |
| 239 | ||
| 240 | _LIBCPP_HIDE_FROM_ABI | |
| 241 | constexpr decltype(auto) operator*() const { | |
| 242 | return **__inner_; | |
| 243 | } | |
| 244 | ||
| 245 | _LIBCPP_HIDE_FROM_ABI | |
| 246 | constexpr _Inner operator->() const | |
| 247 | requires __has_arrow<_Inner> && copyable<_Inner> | |
| 248 | { | |
| 249 | return *__inner_; | |
| 250 | } | |
| 251 | ||
| 252 | _LIBCPP_HIDE_FROM_ABI | |
| 253 | constexpr __iterator& operator++() { | |
| 254 | auto&& __inner = [&]() -> auto&& { | |
| 255 | if constexpr (__ref_is_glvalue) | |
| 256 | return *__outer_; | |
| 257 | else | |
| 258 | return *__parent_->__cache_; | |
| 259 | }(); | |
| 260 | if (++*__inner_ == ranges::end(__inner)) { | |
| 261 | ++__outer_; | |
| 262 | __satisfy(); | |
| 263 | } | |
| 264 | return *this; | |
| 265 | } | |
| 266 | ||
| 267 | _LIBCPP_HIDE_FROM_ABI | |
| 268 | constexpr void operator++(int) { | |
| 269 | ++*this; | |
| 270 | } | |
| 271 | ||
| 272 | _LIBCPP_HIDE_FROM_ABI | |
| 273 | constexpr __iterator operator++(int) | |
| 274 | requires __ref_is_glvalue && | |
| 275 | forward_range<_Base> && | |
| 276 | forward_range<range_reference_t<_Base>> | |
| 277 | { | |
| 278 | auto __tmp = *this; | |
| 279 | ++*this; | |
| 280 | return __tmp; | |
| 281 | } | |
| 282 | ||
| 283 | _LIBCPP_HIDE_FROM_ABI | |
| 284 | constexpr __iterator& operator--() | |
| 285 | requires __ref_is_glvalue && | |
| 286 | bidirectional_range<_Base> && | |
| 287 | bidirectional_range<range_reference_t<_Base>> && | |
| 288 | common_range<range_reference_t<_Base>> | |
| 289 | { | |
| 290 | if (__outer_ == ranges::end(__parent_->__base_)) | |
| 291 | __inner_ = ranges::end(*--__outer_); | |
| 292 | ||
| 293 | // Skip empty inner ranges when going backwards. | |
| 294 | while (*__inner_ == ranges::begin(*__outer_)) { | |
| 295 | __inner_ = ranges::end(*--__outer_); | |
| 296 | } | |
| 297 | ||
| 298 | --*__inner_; | |
| 299 | return *this; | |
| 300 | } | |
| 301 | ||
| 302 | _LIBCPP_HIDE_FROM_ABI | |
| 303 | constexpr __iterator operator--(int) | |
| 304 | requires __ref_is_glvalue && | |
| 305 | bidirectional_range<_Base> && | |
| 306 | bidirectional_range<range_reference_t<_Base>> && | |
| 307 | common_range<range_reference_t<_Base>> | |
| 308 | { | |
| 309 | auto __tmp = *this; | |
| 310 | --*this; | |
| 311 | return __tmp; | |
| 312 | } | |
| 313 | ||
| 314 | _LIBCPP_HIDE_FROM_ABI | |
| 315 | friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) | |
| 316 | requires __ref_is_glvalue && | |
| 317 | equality_comparable<iterator_t<_Base>> && | |
| 318 | equality_comparable<iterator_t<range_reference_t<_Base>>> | |
| 319 | { | |
| 320 | return __x.__outer_ == __y.__outer_ && __x.__inner_ == __y.__inner_; | |
| 321 | } | |
| 322 | ||
| 323 | _LIBCPP_HIDE_FROM_ABI | |
| 324 | friend constexpr decltype(auto) iter_move(const __iterator& __i) | |
| 325 | noexcept(noexcept(ranges::iter_move(*__i.__inner_))) | |
| 326 | { | |
| 327 | return ranges::iter_move(*__i.__inner_); | |
| 328 | } | |
| 329 | ||
| 330 | _LIBCPP_HIDE_FROM_ABI | |
| 331 | friend constexpr void iter_swap(const __iterator& __x, const __iterator& __y) | |
| 332 | noexcept(noexcept(ranges::iter_swap(*__x.__inner_, *__y.__inner_))) | |
| 333 | requires indirectly_swappable<_Inner> | |
| 334 | { | |
| 335 | return ranges::iter_swap(*__x.__inner_, *__y.__inner_); | |
| 336 | } | |
| 337 | }; | |
| 338 | ||
| 339 | template<class _Range> | |
| 340 | explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>; | |
| 341 | ||
| 342 | } // namespace ranges | |
| 343 | ||
| 344 | #undef _CONSTEXPR_TERNARY | |
| 345 | ||
| 346 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 347 | ||
| 348 | _LIBCPP_END_NAMESPACE_STD | |
| 349 | ||
| 350 | #endif // _LIBCPP___RANGES_JOIN_VIEW_H |
lib/libcxx/include/__ranges/non_propagating_cache.h+29-14| ... | ... | @@ -13,6 +13,7 @@ |
| 13 | 13 | #include <__iterator/concepts.h> // indirectly_readable |
| 14 | 14 | #include <__iterator/iterator_traits.h> // iter_reference_t |
| 15 | 15 | #include <__memory/addressof.h> |
| 16 | #include <__utility/forward.h> | |
| 16 | 17 | #include <concepts> // constructible_from |
| 17 | 18 | #include <optional> |
| 18 | 19 | #include <type_traits> |
| ... | ... | @@ -21,14 +22,9 @@ |
| 21 | 22 | #pragma GCC system_header |
| 22 | 23 | #endif |
| 23 | 24 | |
| 24 | _LIBCPP_PUSH_MACROS | |
| 25 | #include <__undef_macros> | |
| 26 | ||
| 27 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 26 | |
| 29 | // clang-format off | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | 28 | |
| 33 | 29 | namespace ranges { |
| 34 | 30 | // __non_propagating_cache is a helper type that allows storing an optional value in it, |
| ... | ... | @@ -42,7 +38,20 @@ namespace ranges { |
| 42 | 38 | template<class _Tp> |
| 43 | 39 | requires is_object_v<_Tp> |
| 44 | 40 | class _LIBCPP_TEMPLATE_VIS __non_propagating_cache { |
| 45 | optional<_Tp> __value_ = nullopt; | |
| 41 | struct __from_tag { }; | |
| 42 | struct __forward_tag { }; | |
| 43 | ||
| 44 | // This helper class is needed to perform copy and move elision when | |
| 45 | // constructing the contained type from an iterator. | |
| 46 | struct __wrapper { | |
| 47 | template<class ..._Args> | |
| 48 | constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(_VSTD::forward<_Args>(__args)...) { } | |
| 49 | template<class _Fn> | |
| 50 | constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { } | |
| 51 | _Tp __t_; | |
| 52 | }; | |
| 53 | ||
| 54 | optional<__wrapper> __value_ = nullopt; | |
| 46 | 55 | |
| 47 | 56 | public: |
| 48 | 57 | _LIBCPP_HIDE_FROM_ABI __non_propagating_cache() = default; |
| ... | ... | @@ -75,25 +84,31 @@ namespace ranges { |
| 75 | 84 | } |
| 76 | 85 | |
| 77 | 86 | _LIBCPP_HIDE_FROM_ABI |
| 78 | constexpr _Tp& operator*() { return *__value_; } | |
| 87 | constexpr _Tp& operator*() { return __value_->__t_; } | |
| 79 | 88 | _LIBCPP_HIDE_FROM_ABI |
| 80 | constexpr _Tp const& operator*() const { return *__value_; } | |
| 89 | constexpr _Tp const& operator*() const { return __value_->__t_; } | |
| 81 | 90 | |
| 82 | 91 | _LIBCPP_HIDE_FROM_ABI |
| 83 | 92 | constexpr bool __has_value() const { return __value_.has_value(); } |
| 93 | ||
| 94 | template<class _Fn> | |
| 84 | 95 | _LIBCPP_HIDE_FROM_ABI |
| 85 | constexpr void __set(_Tp const& __value) { __value_.emplace(__value); } | |
| 96 | constexpr _Tp& __emplace_from(_Fn const& __f) { | |
| 97 | return __value_.emplace(__from_tag{}, __f).__t_; | |
| 98 | } | |
| 99 | ||
| 100 | template<class ..._Args> | |
| 86 | 101 | _LIBCPP_HIDE_FROM_ABI |
| 87 | constexpr void __set(_Tp&& __value) { __value_.emplace(_VSTD::move(__value)); } | |
| 102 | constexpr _Tp& __emplace(_Args&& ...__args) { | |
| 103 | return __value_.emplace(__forward_tag{}, _VSTD::forward<_Args>(__args)...).__t_; | |
| 104 | } | |
| 88 | 105 | }; |
| 89 | 106 | |
| 90 | 107 | struct __empty_cache { }; |
| 91 | 108 | } // namespace ranges |
| 92 | 109 | |
| 93 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 110 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 94 | 111 | |
| 95 | 112 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 113 | |
| 97 | _LIBCPP_POP_MACROS | |
| 98 | ||
| 99 | 114 | #endif // _LIBCPP___RANGES_NON_PROPAGATING_CACHE_H |
lib/libcxx/include/__ranges/owning_view.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 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_OWNING_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_OWNING_VIEW_H | |
| 11 | ||
| 12 | #include <__concepts/constructible.h> | |
| 13 | #include <__concepts/movable.h> | |
| 14 | #include <__config> | |
| 15 | #include <__ranges/access.h> | |
| 16 | #include <__ranges/concepts.h> | |
| 17 | #include <__ranges/data.h> | |
| 18 | #include <__ranges/empty.h> | |
| 19 | #include <__ranges/enable_borrowed_range.h> | |
| 20 | #include <__ranges/size.h> | |
| 21 | #include <__ranges/view_interface.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 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | template<range _Rp> | |
| 35 | requires movable<_Rp> && (!__is_std_initializer_list<remove_cvref_t<_Rp>>) | |
| 36 | class owning_view : public view_interface<owning_view<_Rp>> { | |
| 37 | _Rp __r_ = _Rp(); | |
| 38 | ||
| 39 | public: | |
| 40 | owning_view() requires default_initializable<_Rp> = default; | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(_VSTD::move(__r)) {} | |
| 42 | ||
| 43 | owning_view(owning_view&&) = default; | |
| 44 | owning_view& operator=(owning_view&&) = default; | |
| 45 | ||
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & 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_); } | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return _VSTD::move(__r_); } | |
| 50 | ||
| 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_); } | |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const requires range<const _Rp> { return ranges::begin(__r_); } | |
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr auto end() const requires range<const _Rp> { return ranges::end(__r_); } | |
| 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() requires requires { ranges::empty(__r_); } | |
| 57 | { return ranges::empty(__r_); } | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const requires requires { ranges::empty(__r_); } | |
| 59 | { return ranges::empty(__r_); } | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() requires sized_range<_Rp> | |
| 62 | { return ranges::size(__r_); } | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr auto size() const requires sized_range<const _Rp> | |
| 64 | { return ranges::size(__r_); } | |
| 65 | ||
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() requires contiguous_range<_Rp> | |
| 67 | { return ranges::data(__r_); } | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr auto data() const requires contiguous_range<const _Rp> | |
| 69 | { return ranges::data(__r_); } | |
| 70 | }; | |
| 71 | ||
| 72 | template<class _Tp> | |
| 73 | inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 74 | ||
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | ||
| 79 | _LIBCPP_END_NAMESPACE_STD | |
| 80 | ||
| 81 | #endif // _LIBCPP___RANGES_OWNING_VIEW_H |
lib/libcxx/include/__ranges/range_adaptor.h created+73| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___RANGES_RANGE_ADAPTOR_H | |
| 11 | #define _LIBCPP___RANGES_RANGE_ADAPTOR_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/compose.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__ranges/concepts.h> | |
| 17 | #include <__utility/forward.h> | |
| 18 | #include <__utility/move.h> | |
| 19 | #include <concepts> | |
| 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 !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | // 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 to | |
| 32 | // make the following hold: | |
| 33 | // - `x | f` is equivalent to `f(x)` | |
| 34 | // - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))` | |
| 35 | template <class _Tp> | |
| 36 | struct __range_adaptor_closure; | |
| 37 | ||
| 38 | // Type that wraps an arbitrary function object and makes it into a range adaptor closure, | |
| 39 | // i.e. something that can be called via the `x | f` notation. | |
| 40 | template <class _Fn> | |
| 41 | struct __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)) { } | |
| 43 | }; | |
| 44 | ||
| 45 | template <class _Tp> | |
| 46 | concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>; | |
| 47 | ||
| 48 | template <class _Tp> | |
| 49 | struct __range_adaptor_closure { | |
| 50 | template <ranges::viewable_range _View, _RangeAdaptorClosure _Closure> | |
| 51 | requires same_as<_Tp, remove_cvref_t<_Closure>> && | |
| 52 | invocable<_Closure, _View> | |
| 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 54 | friend constexpr decltype(auto) operator|(_View&& __view, _Closure&& __closure) | |
| 55 | noexcept(is_nothrow_invocable_v<_Closure, _View>) | |
| 56 | { return _VSTD::invoke(_VSTD::forward<_Closure>(__closure), _VSTD::forward<_View>(__view)); } | |
| 57 | ||
| 58 | template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure> | |
| 59 | requires same_as<_Tp, remove_cvref_t<_Closure>> && | |
| 60 | constructible_from<decay_t<_Closure>, _Closure> && | |
| 61 | constructible_from<decay_t<_OtherClosure>, _OtherClosure> | |
| 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 63 | friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) | |
| 64 | noexcept(is_nothrow_constructible_v<decay_t<_Closure>, _Closure> && | |
| 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))); } | |
| 67 | }; | |
| 68 | ||
| 69 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 70 | ||
| 71 | _LIBCPP_END_NAMESPACE_STD | |
| 72 | ||
| 73 | #endif // _LIBCPP___RANGES_RANGE_ADAPTOR_H |
lib/libcxx/include/__ranges/ref_view.h+6-7| ... | ... | @@ -18,8 +18,10 @@ |
| 18 | 18 | #include <__ranges/concepts.h> |
| 19 | 19 | #include <__ranges/data.h> |
| 20 | 20 | #include <__ranges/empty.h> |
| 21 | #include <__ranges/enable_borrowed_range.h> | |
| 21 | 22 | #include <__ranges/size.h> |
| 22 | 23 | #include <__ranges/view_interface.h> |
| 24 | #include <__utility/forward.h> | |
| 23 | 25 | #include <concepts> |
| 24 | 26 | #include <type_traits> |
| 25 | 27 | |
| ... | ... | @@ -27,12 +29,9 @@ |
| 27 | 29 | #pragma GCC system_header |
| 28 | 30 | #endif |
| 29 | 31 | |
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 33 | |
| 35 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 34 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | 35 | |
| 37 | 36 | namespace ranges { |
| 38 | 37 | template<range _Range> |
| ... | ... | @@ -76,12 +75,12 @@ public: |
| 76 | 75 | template<class _Range> |
| 77 | 76 | ref_view(_Range&) -> ref_view<_Range>; |
| 78 | 77 | |
| 78 | template<class _Tp> | |
| 79 | inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true; | |
| 79 | 80 | } // namespace ranges |
| 80 | 81 | |
| 81 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 82 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 82 | 83 | |
| 83 | 84 | _LIBCPP_END_NAMESPACE_STD |
| 84 | 85 | |
| 85 | _LIBCPP_POP_MACROS | |
| 86 | ||
| 87 | 86 | #endif // _LIBCPP___RANGES_REF_VIEW_H |
lib/libcxx/include/__ranges/reverse_view.h created+190| ... | ... | @@ -0,0 +1,190 @@ |
| 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_REVERSE_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_REVERSE_VIEW_H | |
| 11 | ||
| 12 | #include <__concepts/constructible.h> | |
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/next.h> | |
| 16 | #include <__iterator/reverse_iterator.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/all.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/enable_borrowed_range.h> | |
| 21 | #include <__ranges/non_propagating_cache.h> | |
| 22 | #include <__ranges/range_adaptor.h> | |
| 23 | #include <__ranges/size.h> | |
| 24 | #include <__ranges/subrange.h> | |
| 25 | #include <__ranges/view_interface.h> | |
| 26 | #include <__utility/forward.h> | |
| 27 | #include <__utility/move.h> | |
| 28 | #include <type_traits> | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | #pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | template<view _View> | |
| 40 | requires bidirectional_range<_View> | |
| 41 | class reverse_view : public view_interface<reverse_view<_View>> { | |
| 42 | // We cache begin() whenever ranges::next is not guaranteed O(1) to provide an | |
| 43 | // amortized O(1) begin() method. | |
| 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>; | |
| 46 | [[no_unique_address]] _Cache __cached_begin_ = _Cache(); | |
| 47 | [[no_unique_address]] _View __base_ = _View(); | |
| 48 | ||
| 49 | public: | |
| 50 | _LIBCPP_HIDE_FROM_ABI | |
| 51 | reverse_view() requires default_initializable<_View> = default; | |
| 52 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI | |
| 54 | constexpr explicit reverse_view(_View __view) : __base_(_VSTD::move(__view)) {} | |
| 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI | |
| 57 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } | |
| 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI | |
| 60 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 61 | ||
| 62 | _LIBCPP_HIDE_FROM_ABI | |
| 63 | constexpr reverse_iterator<iterator_t<_View>> begin() { | |
| 64 | if constexpr (_UseCache) | |
| 65 | if (__cached_begin_.__has_value()) | |
| 66 | return *__cached_begin_; | |
| 67 | ||
| 68 | auto __tmp = _VSTD::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_))); | |
| 69 | if constexpr (_UseCache) | |
| 70 | __cached_begin_.__emplace(__tmp); | |
| 71 | return __tmp; | |
| 72 | } | |
| 73 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI | |
| 75 | constexpr reverse_iterator<iterator_t<_View>> begin() requires common_range<_View> { | |
| 76 | return _VSTD::make_reverse_iterator(ranges::end(__base_)); | |
| 77 | } | |
| 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI | |
| 80 | constexpr auto begin() const requires common_range<const _View> { | |
| 81 | return _VSTD::make_reverse_iterator(ranges::end(__base_)); | |
| 82 | } | |
| 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI | |
| 85 | constexpr reverse_iterator<iterator_t<_View>> end() { | |
| 86 | return _VSTD::make_reverse_iterator(ranges::begin(__base_)); | |
| 87 | } | |
| 88 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI | |
| 90 | constexpr auto end() const requires common_range<const _View> { | |
| 91 | return _VSTD::make_reverse_iterator(ranges::begin(__base_)); | |
| 92 | } | |
| 93 | ||
| 94 | _LIBCPP_HIDE_FROM_ABI | |
| 95 | constexpr auto size() requires sized_range<_View> { | |
| 96 | return ranges::size(__base_); | |
| 97 | } | |
| 98 | ||
| 99 | _LIBCPP_HIDE_FROM_ABI | |
| 100 | constexpr auto size() const requires sized_range<const _View> { | |
| 101 | return ranges::size(__base_); | |
| 102 | } | |
| 103 | }; | |
| 104 | ||
| 105 | template<class _Range> | |
| 106 | reverse_view(_Range&&) -> reverse_view<views::all_t<_Range>>; | |
| 107 | ||
| 108 | template<class _Tp> | |
| 109 | inline constexpr bool enable_borrowed_range<reverse_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 110 | ||
| 111 | namespace views { | |
| 112 | namespace __reverse { | |
| 113 | template<class _Tp> | |
| 114 | constexpr bool __is_reverse_view = false; | |
| 115 | ||
| 116 | template<class _Tp> | |
| 117 | constexpr bool __is_reverse_view<reverse_view<_Tp>> = true; | |
| 118 | ||
| 119 | template<class _Tp> | |
| 120 | constexpr bool __is_sized_reverse_subrange = false; | |
| 121 | ||
| 122 | template<class _Iter> | |
| 123 | constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true; | |
| 124 | ||
| 125 | template<class _Tp> | |
| 126 | constexpr bool __is_unsized_reverse_subrange = false; | |
| 127 | ||
| 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; | |
| 130 | ||
| 131 | template<class _Tp> | |
| 132 | struct __unwrapped_reverse_subrange { | |
| 133 | using type = void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics | |
| 134 | }; | |
| 135 | ||
| 136 | template<class _Iter, subrange_kind _Kind> | |
| 137 | struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> { | |
| 138 | using type = subrange<_Iter, _Iter, _Kind>; | |
| 139 | }; | |
| 140 | ||
| 141 | struct __fn : __range_adaptor_closure<__fn> { | |
| 142 | template<class _Range> | |
| 143 | requires __is_reverse_view<remove_cvref_t<_Range>> | |
| 144 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 145 | constexpr auto operator()(_Range&& __range) const | |
| 146 | noexcept(noexcept(_VSTD::forward<_Range>(__range).base())) | |
| 147 | -> decltype( _VSTD::forward<_Range>(__range).base()) | |
| 148 | { return _VSTD::forward<_Range>(__range).base(); } | |
| 149 | ||
| 150 | template<class _Range, | |
| 151 | class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type> | |
| 152 | requires __is_sized_reverse_subrange<remove_cvref_t<_Range>> | |
| 153 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 154 | constexpr auto operator()(_Range&& __range) const | |
| 155 | noexcept(noexcept(_UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size()))) | |
| 156 | -> decltype( _UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size())) | |
| 157 | { return _UnwrappedSubrange(__range.end().base(), __range.begin().base(), __range.size()); } | |
| 158 | ||
| 159 | template<class _Range, | |
| 160 | class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type> | |
| 161 | requires __is_unsized_reverse_subrange<remove_cvref_t<_Range>> | |
| 162 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 163 | constexpr auto operator()(_Range&& __range) const | |
| 164 | noexcept(noexcept(_UnwrappedSubrange(__range.end().base(), __range.begin().base()))) | |
| 165 | -> decltype( _UnwrappedSubrange(__range.end().base(), __range.begin().base())) | |
| 166 | { return _UnwrappedSubrange(__range.end().base(), __range.begin().base()); } | |
| 167 | ||
| 168 | template<class _Range> | |
| 169 | requires (!__is_reverse_view<remove_cvref_t<_Range>> && | |
| 170 | !__is_sized_reverse_subrange<remove_cvref_t<_Range>> && | |
| 171 | !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>) | |
| 172 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 173 | constexpr auto operator()(_Range&& __range) const | |
| 174 | noexcept(noexcept(reverse_view{_VSTD::forward<_Range>(__range)})) | |
| 175 | -> decltype( reverse_view{_VSTD::forward<_Range>(__range)}) | |
| 176 | { return reverse_view{_VSTD::forward<_Range>(__range)}; } | |
| 177 | }; | |
| 178 | } // namespace __reverse | |
| 179 | ||
| 180 | inline namespace __cpo { | |
| 181 | inline constexpr auto reverse = __reverse::__fn{}; | |
| 182 | } // namespace __cpo | |
| 183 | } // namespace views | |
| 184 | } // namespace ranges | |
| 185 | ||
| 186 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 187 | ||
| 188 | _LIBCPP_END_NAMESPACE_STD | |
| 189 | ||
| 190 | #endif // _LIBCPP___RANGES_REVERSE_VIEW_H |
lib/libcxx/include/__ranges/single_view.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 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_SINGLE_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_SINGLE_VIEW_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__ranges/copyable_box.h> | |
| 14 | #include <__ranges/view_interface.h> | |
| 15 | #include <__utility/forward.h> | |
| 16 | #include <__utility/in_place.h> | |
| 17 | #include <__utility/move.h> | |
| 18 | #include <concepts> | |
| 19 | #include <type_traits> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | #pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | namespace ranges { | |
| 30 | template<copy_constructible _Tp> | |
| 31 | requires is_object_v<_Tp> | |
| 32 | class single_view : public view_interface<single_view<_Tp>> { | |
| 33 | __copyable_box<_Tp> __value_; | |
| 34 | ||
| 35 | public: | |
| 36 | _LIBCPP_HIDE_FROM_ABI | |
| 37 | single_view() requires default_initializable<_Tp> = default; | |
| 38 | ||
| 39 | _LIBCPP_HIDE_FROM_ABI | |
| 40 | constexpr explicit single_view(const _Tp& __t) : __value_(in_place, __t) {} | |
| 41 | ||
| 42 | _LIBCPP_HIDE_FROM_ABI | |
| 43 | constexpr explicit single_view(_Tp&& __t) : __value_(in_place, _VSTD::move(__t)) {} | |
| 44 | ||
| 45 | template<class... _Args> | |
| 46 | requires constructible_from<_Tp, _Args...> | |
| 47 | _LIBCPP_HIDE_FROM_ABI | |
| 48 | constexpr explicit single_view(in_place_t, _Args&&... __args) | |
| 49 | : __value_{in_place, _VSTD::forward<_Args>(__args)...} {} | |
| 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI | |
| 52 | constexpr _Tp* begin() noexcept { return data(); } | |
| 53 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI | |
| 55 | constexpr const _Tp* begin() const noexcept { return data(); } | |
| 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI | |
| 58 | constexpr _Tp* end() noexcept { return data() + 1; } | |
| 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI | |
| 61 | constexpr const _Tp* end() const noexcept { return data() + 1; } | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI | |
| 64 | static constexpr size_t size() noexcept { return 1; } | |
| 65 | ||
| 66 | _LIBCPP_HIDE_FROM_ABI | |
| 67 | constexpr _Tp* data() noexcept { return __value_.operator->(); } | |
| 68 | ||
| 69 | _LIBCPP_HIDE_FROM_ABI | |
| 70 | constexpr const _Tp* data() const noexcept { return __value_.operator->(); } | |
| 71 | }; | |
| 72 | ||
| 73 | template<class _Tp> | |
| 74 | single_view(_Tp) -> single_view<_Tp>; | |
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | ||
| 79 | _LIBCPP_END_NAMESPACE_STD | |
| 80 | ||
| 81 | #endif // _LIBCPP___RANGES_SINGLE_VIEW_H |
lib/libcxx/include/__ranges/size.h+29-26| ... | ... | @@ -9,12 +9,12 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_SIZE_H |
| 10 | 10 | #define _LIBCPP___RANGES_SIZE_H |
| 11 | 11 | |
| 12 | #include <__concepts/class_or_enum.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | #include <__ranges/access.h> |
| 16 | #include <__utility/__decay_copy.h> | |
| 17 | #include <__utility/forward.h> | |
| 17 | #include <__utility/auto_cast.h> | |
| 18 | 18 | #include <concepts> |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| ... | ... | @@ -22,19 +22,18 @@ |
| 22 | 22 | #pragma GCC system_header |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 26 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 31 | 28 | |
| 32 | // clang-format off | |
| 33 | 29 | namespace ranges { |
| 34 | template<class> | |
| 35 | inline constexpr bool disable_sized_range = false; | |
| 30 | template<class> | |
| 31 | inline constexpr bool disable_sized_range = false; | |
| 32 | } // namespace ranges | |
| 36 | 33 | |
| 37 | 34 | // [range.prim.size] |
| 35 | ||
| 36 | namespace ranges { | |
| 38 | 37 | namespace __size { |
| 39 | 38 | void size(auto&) = delete; |
| 40 | 39 | void size(const auto&) = delete; |
| ... | ... | @@ -43,9 +42,12 @@ namespace __size { |
| 43 | 42 | concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; |
| 44 | 43 | |
| 45 | 44 | template <class _Tp> |
| 46 | concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) { | |
| 47 | { _VSTD::__decay_copy(_VSTD::forward<_Tp>(__t).size()) } -> __integer_like; | |
| 48 | }; | |
| 45 | concept __member_size = | |
| 46 | __size_enabled<_Tp> && | |
| 47 | __workaround_52970<_Tp> && | |
| 48 | requires(_Tp&& __t) { | |
| 49 | { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like; | |
| 50 | }; | |
| 49 | 51 | |
| 50 | 52 | template <class _Tp> |
| 51 | 53 | concept __unqualified_size = |
| ... | ... | @@ -53,7 +55,7 @@ namespace __size { |
| 53 | 55 | !__member_size<_Tp> && |
| 54 | 56 | __class_or_enum<remove_cvref_t<_Tp>> && |
| 55 | 57 | requires(_Tp&& __t) { |
| 56 | { _VSTD::__decay_copy(size(_VSTD::forward<_Tp>(__t))) } -> __integer_like; | |
| 58 | { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like; | |
| 57 | 59 | }; |
| 58 | 60 | |
| 59 | 61 | template <class _Tp> |
| ... | ... | @@ -79,14 +81,14 @@ namespace __size { |
| 79 | 81 | |
| 80 | 82 | template <__member_size _Tp> |
| 81 | 83 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const |
| 82 | noexcept(noexcept(_VSTD::forward<_Tp>(__t).size())) { | |
| 83 | return _VSTD::forward<_Tp>(__t).size(); | |
| 84 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) { | |
| 85 | return _LIBCPP_AUTO_CAST(__t.size()); | |
| 84 | 86 | } |
| 85 | 87 | |
| 86 | 88 | template <__unqualified_size _Tp> |
| 87 | 89 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const |
| 88 | noexcept(noexcept(size(_VSTD::forward<_Tp>(__t)))) { | |
| 89 | return size(_VSTD::forward<_Tp>(__t)); | |
| 90 | noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) { | |
| 91 | return _LIBCPP_AUTO_CAST(size(__t)); | |
| 90 | 92 | } |
| 91 | 93 | |
| 92 | 94 | template<__difference _Tp> |
| ... | ... | @@ -95,18 +97,23 @@ namespace __size { |
| 95 | 97 | return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)); |
| 96 | 98 | } |
| 97 | 99 | }; |
| 98 | } // end namespace __size | |
| 100 | } // namespace __size | |
| 99 | 101 | |
| 100 | 102 | inline namespace __cpo { |
| 101 | 103 | inline constexpr auto size = __size::__fn{}; |
| 102 | 104 | } // namespace __cpo |
| 105 | } // namespace ranges | |
| 106 | ||
| 107 | // [range.prim.ssize] | |
| 103 | 108 | |
| 109 | namespace ranges { | |
| 104 | 110 | namespace __ssize { |
| 105 | 111 | struct __fn { |
| 106 | 112 | template<class _Tp> |
| 107 | 113 | requires requires (_Tp&& __t) { ranges::size(__t); } |
| 108 | 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const |
| 109 | noexcept(noexcept(ranges::size(__t))) { | |
| 115 | noexcept(noexcept(ranges::size(__t))) | |
| 116 | { | |
| 110 | 117 | using _Signed = make_signed_t<decltype(ranges::size(__t))>; |
| 111 | 118 | if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed)) |
| 112 | 119 | return static_cast<ptrdiff_t>(ranges::size(__t)); |
| ... | ... | @@ -114,19 +121,15 @@ namespace __ssize { |
| 114 | 121 | return static_cast<_Signed>(ranges::size(__t)); |
| 115 | 122 | } |
| 116 | 123 | }; |
| 117 | } | |
| 124 | } // namespace __ssize | |
| 118 | 125 | |
| 119 | 126 | inline namespace __cpo { |
| 120 | inline constexpr const auto ssize = __ssize::__fn{}; | |
| 127 | inline constexpr auto ssize = __ssize::__fn{}; | |
| 121 | 128 | } // namespace __cpo |
| 122 | 129 | } // namespace ranges |
| 123 | 130 | |
| 124 | // clang-format off | |
| 125 | ||
| 126 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 131 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 127 | 132 | |
| 128 | 133 | _LIBCPP_END_NAMESPACE_STD |
| 129 | 134 | |
| 130 | _LIBCPP_POP_MACROS | |
| 131 | ||
| 132 | 135 | #endif // _LIBCPP___RANGES_SIZE_H |
lib/libcxx/include/__ranges/subrange.h+99-77| ... | ... | @@ -9,40 +9,45 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_SUBRANGE_H |
| 10 | 10 | #define _LIBCPP___RANGES_SUBRANGE_H |
| 11 | 11 | |
| 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/different_from.h> | |
| 12 | 17 | #include <__config> |
| 18 | #include <__debug> | |
| 19 | #include <__iterator/advance.h> | |
| 13 | 20 | #include <__iterator/concepts.h> |
| 14 | 21 | #include <__iterator/incrementable_traits.h> |
| 15 | 22 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__iterator/advance.h> | |
| 17 | 23 | #include <__ranges/access.h> |
| 18 | 24 | #include <__ranges/concepts.h> |
| 19 | 25 | #include <__ranges/dangling.h> |
| 20 | 26 | #include <__ranges/enable_borrowed_range.h> |
| 21 | 27 | #include <__ranges/size.h> |
| 22 | 28 | #include <__ranges/view_interface.h> |
| 23 | #include <concepts> | |
| 29 | #include <__tuple> | |
| 30 | #include <__utility/move.h> | |
| 24 | 31 | #include <type_traits> |
| 25 | 32 | |
| 26 | 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 34 | #pragma GCC system_header |
| 28 | 35 | #endif |
| 29 | 36 | |
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 38 | |
| 35 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 39 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | 40 | |
| 37 | // clang-format off | |
| 38 | 41 | namespace ranges { |
| 42 | template<class _From, class _To> | |
| 43 | concept __uses_nonqualification_pointer_conversion = | |
| 44 | is_pointer_v<_From> && is_pointer_v<_To> && | |
| 45 | !convertible_to<remove_pointer_t<_From>(*)[], remove_pointer_t<_To>(*)[]>; | |
| 46 | ||
| 39 | 47 | template<class _From, class _To> |
| 40 | 48 | concept __convertible_to_non_slicing = |
| 41 | 49 | convertible_to<_From, _To> && |
| 42 | // If they're both pointers, they must have the same element type. | |
| 43 | !(is_pointer_v<decay_t<_From>> && | |
| 44 | is_pointer_v<decay_t<_To>> && | |
| 45 | __different_from<remove_pointer_t<decay_t<_From>>, remove_pointer_t<decay_t<_To>>>); | |
| 50 | !__uses_nonqualification_pointer_conversion<decay_t<_From>, decay_t<_To>>; | |
| 46 | 51 | |
| 47 | 52 | template<class _Tp> |
| 48 | 53 | concept __pair_like = |
| ... | ... | @@ -64,59 +69,43 @@ namespace ranges { |
| 64 | 69 | |
| 65 | 70 | enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized }; |
| 66 | 71 | |
| 67 | template<class _Iter, class _Sent, bool> | |
| 68 | struct __subrange_base { | |
| 69 | static constexpr bool __store_size = false; | |
| 70 | _Iter __begin_ = _Iter(); | |
| 71 | _Sent __end_ = _Sent(); | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI | |
| 74 | constexpr __subrange_base() = default; | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | constexpr __subrange_base(_Iter __iter, _Sent __sent, make_unsigned_t<iter_difference_t<_Iter>> = 0) | |
| 78 | : __begin_(_VSTD::move(__iter)), __end_(__sent) { } | |
| 79 | }; | |
| 80 | ||
| 81 | template<class _Iter, class _Sent> | |
| 82 | struct __subrange_base<_Iter, _Sent, true> { | |
| 83 | static constexpr bool __store_size = true; | |
| 84 | _Iter __begin_ = _Iter(); | |
| 85 | _Sent __end_ = _Sent(); | |
| 86 | make_unsigned_t<iter_difference_t<_Iter>> __size_ = 0; | |
| 87 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI | |
| 89 | constexpr __subrange_base() = default; | |
| 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI | |
| 92 | constexpr __subrange_base(_Iter __iter, _Sent __sent, decltype(__size_) __size) | |
| 93 | : __begin_(_VSTD::move(__iter)), __end_(__sent), __size_(__size) { } | |
| 94 | }; | |
| 95 | ||
| 96 | 72 | template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent = _Iter, |
| 97 | 73 | subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter> |
| 98 | 74 | ? subrange_kind::sized |
| 99 | 75 | : subrange_kind::unsized> |
| 100 | 76 | requires (_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) |
| 101 | struct _LIBCPP_TEMPLATE_VIS subrange | |
| 102 | : public view_interface<subrange<_Iter, _Sent, _Kind>>, | |
| 103 | private __subrange_base<_Iter, _Sent, _Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>> { | |
| 104 | ||
| 105 | using _Base = __subrange_base<_Iter, _Sent, _Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>>; | |
| 106 | ||
| 77 | class _LIBCPP_TEMPLATE_VIS subrange | |
| 78 | : public view_interface<subrange<_Iter, _Sent, _Kind>> | |
| 79 | { | |
| 80 | private: | |
| 81 | static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>); | |
| 82 | static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics | |
| 83 | struct _Empty { constexpr _Empty(auto) noexcept { } }; | |
| 84 | using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>; | |
| 85 | [[no_unique_address]] _Iter __begin_ = _Iter(); | |
| 86 | [[no_unique_address]] _Sent __end_ = _Sent(); | |
| 87 | [[no_unique_address]] _Size __size_ = 0; | |
| 88 | ||
| 89 | public: | |
| 107 | 90 | _LIBCPP_HIDE_FROM_ABI |
| 108 | 91 | subrange() requires default_initializable<_Iter> = default; |
| 109 | 92 | |
| 110 | 93 | _LIBCPP_HIDE_FROM_ABI |
| 111 | 94 | constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent) |
| 112 | requires (!_Base::__store_size) | |
| 113 | : _Base(_VSTD::move(__iter), __sent) {} | |
| 95 | requires _MustProvideSizeAtConstruction | |
| 96 | : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent)) | |
| 97 | { } | |
| 114 | 98 | |
| 115 | 99 | _LIBCPP_HIDE_FROM_ABI |
| 116 | 100 | constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent, |
| 117 | 101 | make_unsigned_t<iter_difference_t<_Iter>> __n) |
| 118 | 102 | requires (_Kind == subrange_kind::sized) |
| 119 | : _Base(_VSTD::move(__iter), __sent, __n) { } | |
| 103 | : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent)), __size_(__n) | |
| 104 | { | |
| 105 | if constexpr (sized_sentinel_for<_Sent, _Iter>) | |
| 106 | _LIBCPP_ASSERT((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n), | |
| 107 | "std::ranges::subrange was passed an invalid size hint"); | |
| 108 | } | |
| 120 | 109 | |
| 121 | 110 | template<__different_from<subrange> _Range> |
| 122 | 111 | requires borrowed_range<_Range> && |
| ... | ... | @@ -124,8 +113,9 @@ namespace ranges { |
| 124 | 113 | convertible_to<sentinel_t<_Range>, _Sent> |
| 125 | 114 | _LIBCPP_HIDE_FROM_ABI |
| 126 | 115 | constexpr subrange(_Range&& __range) |
| 127 | requires (!_Base::__store_size) | |
| 128 | : subrange(ranges::begin(__range), ranges::end(__range)) { } | |
| 116 | requires (!_StoreSize) | |
| 117 | : subrange(ranges::begin(__range), ranges::end(__range)) | |
| 118 | { } | |
| 129 | 119 | |
| 130 | 120 | template<__different_from<subrange> _Range> |
| 131 | 121 | requires borrowed_range<_Range> && |
| ... | ... | @@ -133,9 +123,9 @@ namespace ranges { |
| 133 | 123 | convertible_to<sentinel_t<_Range>, _Sent> |
| 134 | 124 | _LIBCPP_HIDE_FROM_ABI |
| 135 | 125 | constexpr subrange(_Range&& __range) |
| 136 | requires _Base::__store_size && sized_range<_Range> | |
| 137 | : subrange(__range, ranges::size(__range)) { } | |
| 138 | ||
| 126 | requires _StoreSize && sized_range<_Range> | |
| 127 | : subrange(__range, ranges::size(__range)) | |
| 128 | { } | |
| 139 | 129 | |
| 140 | 130 | template<borrowed_range _Range> |
| 141 | 131 | requires __convertible_to_non_slicing<iterator_t<_Range>, _Iter> && |
| ... | ... | @@ -143,39 +133,47 @@ namespace ranges { |
| 143 | 133 | _LIBCPP_HIDE_FROM_ABI |
| 144 | 134 | constexpr subrange(_Range&& __range, make_unsigned_t<iter_difference_t<_Iter>> __n) |
| 145 | 135 | requires (_Kind == subrange_kind::sized) |
| 146 | : subrange(ranges::begin(__range), ranges::end(__range), __n) { } | |
| 136 | : subrange(ranges::begin(__range), ranges::end(__range), __n) | |
| 137 | { } | |
| 147 | 138 | |
| 148 | 139 | template<__different_from<subrange> _Pair> |
| 149 | 140 | requires __pair_like_convertible_from<_Pair, const _Iter&, const _Sent&> |
| 150 | 141 | _LIBCPP_HIDE_FROM_ABI |
| 151 | constexpr operator _Pair() const { return _Pair(this->__begin_, this->__end_); } | |
| 142 | constexpr operator _Pair() const { | |
| 143 | return _Pair(__begin_, __end_); | |
| 144 | } | |
| 152 | 145 | |
| 153 | 146 | _LIBCPP_HIDE_FROM_ABI |
| 154 | 147 | constexpr _Iter begin() const requires copyable<_Iter> { |
| 155 | return this->__begin_; | |
| 148 | return __begin_; | |
| 156 | 149 | } |
| 157 | 150 | |
| 158 | 151 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) { |
| 159 | return _VSTD::move(this->__begin_); | |
| 152 | return _VSTD::move(__begin_); | |
| 160 | 153 | } |
| 161 | 154 | |
| 162 | 155 | _LIBCPP_HIDE_FROM_ABI |
| 163 | constexpr _Sent end() const { return this->__end_; } | |
| 156 | constexpr _Sent end() const { | |
| 157 | return __end_; | |
| 158 | } | |
| 164 | 159 | |
| 165 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return this->__begin_ == this->__end_; } | |
| 160 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { | |
| 161 | return __begin_ == __end_; | |
| 162 | } | |
| 166 | 163 | |
| 167 | 164 | _LIBCPP_HIDE_FROM_ABI |
| 168 | 165 | constexpr make_unsigned_t<iter_difference_t<_Iter>> size() const |
| 169 | 166 | requires (_Kind == subrange_kind::sized) |
| 170 | 167 | { |
| 171 | if constexpr (_Base::__store_size) | |
| 172 | return this->__size_; | |
| 168 | if constexpr (_StoreSize) | |
| 169 | return __size_; | |
| 173 | 170 | else |
| 174 | return __to_unsigned_like(this->__end_ - this->__begin_); | |
| 171 | return _VSTD::__to_unsigned_like(__end_ - __begin_); | |
| 175 | 172 | } |
| 176 | 173 | |
| 177 | 174 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) const& |
| 178 | requires forward_iterator<_Iter> { | |
| 175 | requires forward_iterator<_Iter> | |
| 176 | { | |
| 179 | 177 | auto __tmp = *this; |
| 180 | 178 | __tmp.advance(__n); |
| 181 | 179 | return __tmp; |
| ... | ... | @@ -187,7 +185,8 @@ namespace ranges { |
| 187 | 185 | } |
| 188 | 186 | |
| 189 | 187 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange prev(iter_difference_t<_Iter> __n = 1) const |
| 190 | requires bidirectional_iterator<_Iter> { | |
| 188 | requires bidirectional_iterator<_Iter> | |
| 189 | { | |
| 191 | 190 | auto __tmp = *this; |
| 192 | 191 | __tmp.advance(-__n); |
| 193 | 192 | return __tmp; |
| ... | ... | @@ -197,16 +196,16 @@ namespace ranges { |
| 197 | 196 | constexpr subrange& advance(iter_difference_t<_Iter> __n) { |
| 198 | 197 | if constexpr (bidirectional_iterator<_Iter>) { |
| 199 | 198 | if (__n < 0) { |
| 200 | ranges::advance(this->__begin_, __n); | |
| 201 | if constexpr (_Base::__store_size) | |
| 202 | this->__size_ += _VSTD::__to_unsigned_like(-__n); | |
| 199 | ranges::advance(__begin_, __n); | |
| 200 | if constexpr (_StoreSize) | |
| 201 | __size_ += _VSTD::__to_unsigned_like(-__n); | |
| 203 | 202 | return *this; |
| 204 | 203 | } |
| 205 | 204 | } |
| 206 | 205 | |
| 207 | auto __d = __n - ranges::advance(this->__begin_, __n, this->__end_); | |
| 208 | if constexpr (_Base::__store_size) | |
| 209 | this->__size_ -= _VSTD::__to_unsigned_like(__d); | |
| 206 | auto __d = __n - ranges::advance(__begin_, __n, __end_); | |
| 207 | if constexpr (_StoreSize) | |
| 208 | __size_ -= _VSTD::__to_unsigned_like(__d); | |
| 210 | 209 | return *this; |
| 211 | 210 | } |
| 212 | 211 | }; |
| ... | ... | @@ -228,7 +227,7 @@ namespace ranges { |
| 228 | 227 | -> subrange<iterator_t<_Range>, sentinel_t<_Range>, subrange_kind::sized>; |
| 229 | 228 | |
| 230 | 229 | template<size_t _Index, class _Iter, class _Sent, subrange_kind _Kind> |
| 231 | requires (_Index < 2) | |
| 230 | requires ((_Index == 0 && copyable<_Iter>) || _Index == 1) | |
| 232 | 231 | _LIBCPP_HIDE_FROM_ABI |
| 233 | 232 | constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange) { |
| 234 | 233 | if constexpr (_Index == 0) |
| ... | ... | @@ -251,17 +250,40 @@ namespace ranges { |
| 251 | 250 | inline constexpr bool enable_borrowed_range<subrange<_Ip, _Sp, _Kp>> = true; |
| 252 | 251 | |
| 253 | 252 | template<range _Rp> |
| 254 | using borrowed_subrange_t = _If<borrowed_range<_Rp>, subrange<iterator_t<_Rp> >, dangling>; | |
| 253 | using borrowed_subrange_t = _If<borrowed_range<_Rp>, subrange<iterator_t<_Rp>>, dangling>; | |
| 255 | 254 | } // namespace ranges |
| 256 | 255 | |
| 256 | // [range.subrange.general] | |
| 257 | ||
| 257 | 258 | using ranges::get; |
| 258 | 259 | |
| 259 | // clang-format off | |
| 260 | // [ranges.syn] | |
| 260 | 261 | |
| 261 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 262 | template<class _Ip, class _Sp, ranges::subrange_kind _Kp> | |
| 263 | struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2> {}; | |
| 262 | 264 | |
| 263 | _LIBCPP_END_NAMESPACE_STD | |
| 265 | template<class _Ip, class _Sp, ranges::subrange_kind _Kp> | |
| 266 | struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> { | |
| 267 | using type = _Ip; | |
| 268 | }; | |
| 269 | ||
| 270 | template<class _Ip, class _Sp, ranges::subrange_kind _Kp> | |
| 271 | struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> { | |
| 272 | using type = _Sp; | |
| 273 | }; | |
| 264 | 274 | |
| 265 | _LIBCPP_POP_MACROS | |
| 275 | template<class _Ip, class _Sp, ranges::subrange_kind _Kp> | |
| 276 | struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> { | |
| 277 | using type = _Ip; | |
| 278 | }; | |
| 279 | ||
| 280 | template<class _Ip, class _Sp, ranges::subrange_kind _Kp> | |
| 281 | struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> { | |
| 282 | using type = _Sp; | |
| 283 | }; | |
| 284 | ||
| 285 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 286 | ||
| 287 | _LIBCPP_END_NAMESPACE_STD | |
| 266 | 288 | |
| 267 | 289 | #endif // _LIBCPP___RANGES_SUBRANGE_H |
lib/libcxx/include/__ranges/take_view.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 | #ifndef _LIBCPP___RANGES_TAKE_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_TAKE_VIEW_H | |
| 11 | ||
| 12 | #include <__algorithm/min.h> | |
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/counted_iterator.h> | |
| 16 | #include <__iterator/default_sentinel.h> | |
| 17 | #include <__iterator/iterator_traits.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/all.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/enable_borrowed_range.h> | |
| 22 | #include <__ranges/size.h> | |
| 23 | #include <__ranges/view_interface.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | #include <concepts> | |
| 26 | #include <type_traits> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | #pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_PUSH_MACROS | |
| 33 | #include <__undef_macros> | |
| 34 | ||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 36 | ||
| 37 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | template<view _View> | |
| 41 | class take_view : public view_interface<take_view<_View>> { | |
| 42 | [[no_unique_address]] _View __base_ = _View(); | |
| 43 | range_difference_t<_View> __count_ = 0; | |
| 44 | ||
| 45 | template<bool> class __sentinel; | |
| 46 | ||
| 47 | public: | |
| 48 | _LIBCPP_HIDE_FROM_ABI | |
| 49 | take_view() requires default_initializable<_View> = default; | |
| 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI | |
| 52 | constexpr take_view(_View __base, range_difference_t<_View> __count) | |
| 53 | : __base_(_VSTD::move(__base)), __count_(__count) {} | |
| 54 | ||
| 55 | _LIBCPP_HIDE_FROM_ABI | |
| 56 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } | |
| 57 | ||
| 58 | _LIBCPP_HIDE_FROM_ABI | |
| 59 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | constexpr auto begin() requires (!__simple_view<_View>) { | |
| 63 | if constexpr (sized_range<_View>) { | |
| 64 | if constexpr (random_access_range<_View>) { | |
| 65 | return ranges::begin(__base_); | |
| 66 | } else { | |
| 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 { | |
| 72 | return counted_iterator(ranges::begin(__base_), __count_); | |
| 73 | } | |
| 74 | } | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | constexpr auto begin() const requires range<const _View> { | |
| 78 | if constexpr (sized_range<const _View>) { | |
| 79 | if constexpr (random_access_range<const _View>) { | |
| 80 | 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 { | |
| 87 | return counted_iterator(ranges::begin(__base_), __count_); | |
| 88 | } | |
| 89 | } | |
| 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI | |
| 92 | constexpr auto end() requires (!__simple_view<_View>) { | |
| 93 | if constexpr (sized_range<_View>) { | |
| 94 | if constexpr (random_access_range<_View>) { | |
| 95 | return ranges::begin(__base_) + size(); | |
| 96 | } else { | |
| 97 | return default_sentinel; | |
| 98 | } | |
| 99 | } else { | |
| 100 | return __sentinel<false>{ranges::end(__base_)}; | |
| 101 | } | |
| 102 | } | |
| 103 | ||
| 104 | _LIBCPP_HIDE_FROM_ABI | |
| 105 | constexpr auto end() const requires range<const _View> { | |
| 106 | if constexpr (sized_range<const _View>) { | |
| 107 | if constexpr (random_access_range<const _View>) { | |
| 108 | return ranges::begin(__base_) + size(); | |
| 109 | } else { | |
| 110 | return default_sentinel; | |
| 111 | } | |
| 112 | } else { | |
| 113 | return __sentinel<true>{ranges::end(__base_)}; | |
| 114 | } | |
| 115 | } | |
| 116 | ||
| 117 | ||
| 118 | _LIBCPP_HIDE_FROM_ABI | |
| 119 | constexpr auto size() requires sized_range<_View> { | |
| 120 | auto __n = ranges::size(__base_); | |
| 121 | // TODO: use ranges::min here. | |
| 122 | return _VSTD::min(__n, static_cast<decltype(__n)>(__count_)); | |
| 123 | } | |
| 124 | ||
| 125 | _LIBCPP_HIDE_FROM_ABI | |
| 126 | constexpr auto size() const requires sized_range<const _View> { | |
| 127 | auto __n = ranges::size(__base_); | |
| 128 | // TODO: use ranges::min here. | |
| 129 | return _VSTD::min(__n, static_cast<decltype(__n)>(__count_)); | |
| 130 | } | |
| 131 | }; | |
| 132 | ||
| 133 | template<view _View> | |
| 134 | template<bool _Const> | |
| 135 | class take_view<_View>::__sentinel { | |
| 136 | using _Base = __maybe_const<_Const, _View>; | |
| 137 | template<bool _OtherConst> | |
| 138 | using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>; | |
| 139 | [[no_unique_address]] sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | |
| 140 | ||
| 141 | template<bool> | |
| 142 | friend class take_view<_View>::__sentinel; | |
| 143 | ||
| 144 | public: | |
| 145 | _LIBCPP_HIDE_FROM_ABI | |
| 146 | __sentinel() = default; | |
| 147 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI | |
| 149 | constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(_VSTD::move(__end)) {} | |
| 150 | ||
| 151 | _LIBCPP_HIDE_FROM_ABI | |
| 152 | constexpr __sentinel(__sentinel<!_Const> __s) | |
| 153 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> | |
| 154 | : __end_(_VSTD::move(__s.__end_)) {} | |
| 155 | ||
| 156 | _LIBCPP_HIDE_FROM_ABI | |
| 157 | constexpr sentinel_t<_Base> base() const { return __end_; } | |
| 158 | ||
| 159 | _LIBCPP_HIDE_FROM_ABI | |
| 160 | friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) { | |
| 161 | return __lhs.count() == 0 || __lhs.base() == __rhs.__end_; | |
| 162 | } | |
| 163 | ||
| 164 | template<bool _OtherConst = !_Const> | |
| 165 | requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | |
| 166 | _LIBCPP_HIDE_FROM_ABI | |
| 167 | friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) { | |
| 168 | return __lhs.count() == 0 || __lhs.base() == __rhs.__end_; | |
| 169 | } | |
| 170 | }; | |
| 171 | ||
| 172 | template<class _Range> | |
| 173 | take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>; | |
| 174 | ||
| 175 | template<class _Tp> | |
| 176 | inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 177 | } // namespace ranges | |
| 178 | ||
| 179 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 180 | ||
| 181 | _LIBCPP_END_NAMESPACE_STD | |
| 182 | ||
| 183 | _LIBCPP_POP_MACROS | |
| 184 | ||
| 185 | #endif // _LIBCPP___RANGES_TAKE_VIEW_H |
lib/libcxx/include/__ranges/transform_view.h+57-25| ... | ... | @@ -9,38 +9,51 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_TRANSFORM_VIEW_H |
| 10 | 10 | #define _LIBCPP___RANGES_TRANSFORM_VIEW_H |
| 11 | 11 | |
| 12 | #include <__compare/three_way_comparable.h> | |
| 13 | #include <__concepts/constructible.h> | |
| 14 | #include <__concepts/convertible_to.h> | |
| 15 | #include <__concepts/copyable.h> | |
| 16 | #include <__concepts/derived_from.h> | |
| 17 | #include <__concepts/equality_comparable.h> | |
| 18 | #include <__concepts/invocable.h> | |
| 12 | 19 | #include <__config> |
| 20 | #include <__functional/bind_back.h> | |
| 21 | #include <__functional/invoke.h> | |
| 13 | 22 | #include <__iterator/concepts.h> |
| 14 | #include <__iterator/iter_swap.h> | |
| 15 | 23 | #include <__iterator/iterator_traits.h> |
| 24 | #include <__memory/addressof.h> | |
| 16 | 25 | #include <__ranges/access.h> |
| 17 | 26 | #include <__ranges/all.h> |
| 18 | 27 | #include <__ranges/concepts.h> |
| 19 | 28 | #include <__ranges/copyable_box.h> |
| 20 | 29 | #include <__ranges/empty.h> |
| 30 | #include <__ranges/range_adaptor.h> | |
| 21 | 31 | #include <__ranges/size.h> |
| 22 | 32 | #include <__ranges/view_interface.h> |
| 23 | #include <concepts> | |
| 33 | #include <__utility/forward.h> | |
| 34 | #include <__utility/in_place.h> | |
| 35 | #include <__utility/move.h> | |
| 24 | 36 | #include <type_traits> |
| 25 | 37 | |
| 26 | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | 39 | #pragma GCC system_header |
| 28 | 40 | #endif |
| 29 | 41 | |
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | 42 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 43 | |
| 35 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 44 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | 45 | |
| 37 | 46 | namespace ranges { |
| 38 | 47 | |
| 48 | template<class _Fn, class _View> | |
| 49 | concept __regular_invocable_with_range_ref = | |
| 50 | regular_invocable<_Fn, range_reference_t<_View>>; | |
| 51 | ||
| 39 | 52 | template<class _View, class _Fn> |
| 40 | 53 | concept __transform_view_constraints = |
| 41 | view<_View> && is_object_v<_Fn> && | |
| 42 | regular_invocable<_Fn&, range_reference_t<_View>> && | |
| 43 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>; | |
| 54 | view<_View> && is_object_v<_Fn> && | |
| 55 | regular_invocable<_Fn&, range_reference_t<_View>> && | |
| 56 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>; | |
| 44 | 57 | |
| 45 | 58 | template<input_range _View, copy_constructible _Fn> |
| 46 | 59 | requires __transform_view_constraints<_View, _Fn> |
| ... | ... | @@ -72,7 +85,7 @@ public: |
| 72 | 85 | _LIBCPP_HIDE_FROM_ABI |
| 73 | 86 | constexpr __iterator<true> begin() const |
| 74 | 87 | requires range<const _View> && |
| 75 | regular_invocable<const _Fn&, range_reference_t<const _View>> | |
| 88 | __regular_invocable_with_range_ref<const _Fn&, const _View> | |
| 76 | 89 | { |
| 77 | 90 | return __iterator<true>(*this, ranges::begin(__base_)); |
| 78 | 91 | } |
| ... | ... | @@ -90,14 +103,14 @@ public: |
| 90 | 103 | _LIBCPP_HIDE_FROM_ABI |
| 91 | 104 | constexpr __sentinel<true> end() const |
| 92 | 105 | requires range<const _View> && |
| 93 | regular_invocable<const _Fn&, range_reference_t<const _View>> | |
| 106 | __regular_invocable_with_range_ref<const _Fn&, const _View> | |
| 94 | 107 | { |
| 95 | 108 | return __sentinel<true>(ranges::end(__base_)); |
| 96 | 109 | } |
| 97 | 110 | _LIBCPP_HIDE_FROM_ABI |
| 98 | 111 | constexpr __iterator<true> end() const |
| 99 | 112 | requires common_range<const _View> && |
| 100 | regular_invocable<const _Fn&, range_reference_t<const _View>> | |
| 113 | __regular_invocable_with_range_ref<const _Fn&, const _View> | |
| 101 | 114 | { |
| 102 | 115 | return __iterator<true>(*this, ranges::end(__base_)); |
| 103 | 116 | } |
| ... | ... | @@ -181,9 +194,7 @@ public: |
| 181 | 194 | : __parent_(__i.__parent_), __current_(_VSTD::move(__i.__current_)) {} |
| 182 | 195 | |
| 183 | 196 | _LIBCPP_HIDE_FROM_ABI |
| 184 | constexpr iterator_t<_Base> base() const& | |
| 185 | requires copyable<iterator_t<_Base>> | |
| 186 | { | |
| 197 | constexpr const iterator_t<_Base>& base() const& noexcept { | |
| 187 | 198 | return __current_; |
| 188 | 199 | } |
| 189 | 200 | |
| ... | ... | @@ -293,13 +304,12 @@ public: |
| 293 | 304 | return __x.__current_ >= __y.__current_; |
| 294 | 305 | } |
| 295 | 306 | |
| 296 | // TODO: Fix this as soon as soon as three_way_comparable is implemented. | |
| 297 | // _LIBCPP_HIDE_FROM_ABI | |
| 298 | // friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | |
| 299 | // requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>> | |
| 300 | // { | |
| 301 | // return __x.__current_ <=> __y.__current_; | |
| 302 | // } | |
| 307 | _LIBCPP_HIDE_FROM_ABI | |
| 308 | friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | |
| 309 | requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>> | |
| 310 | { | |
| 311 | return __x.__current_ <=> __y.__current_; | |
| 312 | } | |
| 303 | 313 | |
| 304 | 314 | _LIBCPP_HIDE_FROM_ABI |
| 305 | 315 | friend constexpr __iterator operator+(__iterator __i, difference_type __n) |
| ... | ... | @@ -397,12 +407,34 @@ public: |
| 397 | 407 | } |
| 398 | 408 | }; |
| 399 | 409 | |
| 410 | namespace views { | |
| 411 | namespace __transform { | |
| 412 | struct __fn { | |
| 413 | template<class _Range, class _Fn> | |
| 414 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 415 | constexpr auto operator()(_Range&& __range, _Fn&& __f) const | |
| 416 | noexcept(noexcept(transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)))) | |
| 417 | -> decltype( transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f))) | |
| 418 | { return transform_view(_VSTD::forward<_Range>(__range), _VSTD::forward<_Fn>(__f)); } | |
| 419 | ||
| 420 | template<class _Fn> | |
| 421 | requires constructible_from<decay_t<_Fn>, _Fn> | |
| 422 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 423 | constexpr auto operator()(_Fn&& __f) const | |
| 424 | noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) | |
| 425 | { return __range_adaptor_closure_t(_VSTD::__bind_back(*this, _VSTD::forward<_Fn>(__f))); } | |
| 426 | }; | |
| 427 | } // namespace __transform | |
| 428 | ||
| 429 | inline namespace __cpo { | |
| 430 | inline constexpr auto transform = __transform::__fn{}; | |
| 431 | } // namespace __cpo | |
| 432 | } // namespace views | |
| 433 | ||
| 400 | 434 | } // namespace ranges |
| 401 | 435 | |
| 402 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 436 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 403 | 437 | |
| 404 | 438 | _LIBCPP_END_NAMESPACE_STD |
| 405 | 439 | |
| 406 | _LIBCPP_POP_MACROS | |
| 407 | ||
| 408 | 440 | #endif // _LIBCPP___RANGES_TRANSFORM_VIEW_H |
lib/libcxx/include/__ranges/view_interface.h+7-10| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #define _LIBCPP___RANGES_VIEW_INTERFACE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__debug> | |
| 13 | 14 | #include <__iterator/concepts.h> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | #include <__iterator/prev.h> |
| ... | ... | @@ -17,7 +18,6 @@ |
| 17 | 18 | #include <__ranges/access.h> |
| 18 | 19 | #include <__ranges/concepts.h> |
| 19 | 20 | #include <__ranges/empty.h> |
| 20 | #include <__ranges/enable_view.h> | |
| 21 | 21 | #include <concepts> |
| 22 | 22 | #include <type_traits> |
| 23 | 23 | |
| ... | ... | @@ -25,12 +25,9 @@ |
| 25 | 25 | #pragma GCC system_header |
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 29 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 30 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | 31 | |
| 35 | 32 | namespace ranges { |
| 36 | 33 | |
| ... | ... | @@ -42,14 +39,16 @@ void __implicitly_convert_to(type_identity_t<_Tp>) noexcept; |
| 42 | 39 | |
| 43 | 40 | template<class _Derived> |
| 44 | 41 | requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>> |
| 45 | class view_interface : public view_base { | |
| 42 | class view_interface { | |
| 46 | 43 | _LIBCPP_HIDE_FROM_ABI |
| 47 | 44 | constexpr _Derived& __derived() noexcept { |
| 45 | static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>); | |
| 48 | 46 | return static_cast<_Derived&>(*this); |
| 49 | 47 | } |
| 50 | 48 | |
| 51 | 49 | _LIBCPP_HIDE_FROM_ABI |
| 52 | 50 | constexpr _Derived const& __derived() const noexcept { |
| 51 | static_assert(sizeof(_Derived) && derived_from<_Derived, view_interface> && view<_Derived>); | |
| 53 | 52 | return static_cast<_Derived const&>(*this); |
| 54 | 53 | } |
| 55 | 54 | |
| ... | ... | @@ -187,12 +186,10 @@ public: |
| 187 | 186 | } |
| 188 | 187 | }; |
| 189 | 188 | |
| 190 | } | |
| 189 | } // namespace ranges | |
| 191 | 190 | |
| 192 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 191 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 193 | 192 | |
| 194 | 193 | _LIBCPP_END_NAMESPACE_STD |
| 195 | 194 | |
| 196 | _LIBCPP_POP_MACROS | |
| 197 | ||
| 198 | 195 | #endif // _LIBCPP___RANGES_VIEW_INTERFACE_H |
lib/libcxx/include/__ranges/views.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___RANGES_VIEWS | |
| 11 | #define _LIBCPP___RANGES_VIEWS | |
| 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 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 22 | ||
| 23 | namespace ranges { | |
| 24 | ||
| 25 | namespace views { } | |
| 26 | ||
| 27 | } // namespace ranges | |
| 28 | ||
| 29 | namespace views = ranges::views; | |
| 30 | ||
| 31 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___RANGES_VIEWS |
lib/libcxx/include/__split_buffer+2-11| ... | ... | @@ -17,17 +17,8 @@ _LIBCPP_PUSH_MACROS |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | template <bool> | |
| 21 | class __split_buffer_common | |
| 22 | { | |
| 23 | protected: | |
| 24 | _LIBCPP_NORETURN void __throw_length_error() const; | |
| 25 | _LIBCPP_NORETURN void __throw_out_of_range() const; | |
| 26 | }; | |
| 27 | ||
| 28 | 20 | template <class _Tp, class _Allocator = allocator<_Tp> > |
| 29 | 21 | struct __split_buffer |
| 30 | : private __split_buffer_common<true> | |
| 31 | 22 | { |
| 32 | 23 | private: |
| 33 | 24 | __split_buffer(const __split_buffer&); |
| ... | ... | @@ -248,7 +239,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt |
| 248 | 239 | size_type __old_cap = __end_cap() - __first_; |
| 249 | 240 | size_type __new_cap = _VSTD::max<size_type>(2 * __old_cap, 8); |
| 250 | 241 | __split_buffer __buf(__new_cap, 0, __a); |
| 251 | for (pointer __p = __begin_; __p != __end_; ++__p, ++__buf.__end_) | |
| 242 | for (pointer __p = __begin_; __p != __end_; ++__p, (void) ++__buf.__end_) | |
| 252 | 243 | __alloc_traits::construct(__buf.__alloc(), |
| 253 | 244 | _VSTD::__to_address(__buf.__end_), _VSTD::move(*__p)); |
| 254 | 245 | swap(__buf); |
| ... | ... | @@ -268,7 +259,7 @@ typename enable_if |
| 268 | 259 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) |
| 269 | 260 | { |
| 270 | 261 | _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last)); |
| 271 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, ++__first) { | |
| 262 | for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void) ++__first) { | |
| 272 | 263 | __alloc_traits::construct(this->__alloc(), |
| 273 | 264 | _VSTD::__to_address(__tx.__pos_), *__first); |
| 274 | 265 | } |
lib/libcxx/include/__string+71-42| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- __string ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -10,22 +10,26 @@ |
| 10 | 10 | #ifndef _LIBCPP___STRING |
| 11 | 11 | #define _LIBCPP___STRING |
| 12 | 12 | |
| 13 | #include <__config> | |
| 14 | 13 | #include <__algorithm/copy.h> |
| 15 | 14 | #include <__algorithm/copy_backward.h> |
| 16 | 15 | #include <__algorithm/copy_n.h> |
| 17 | 16 | #include <__algorithm/fill_n.h> |
| 18 | #include <__algorithm/find_first_of.h> | |
| 19 | 17 | #include <__algorithm/find_end.h> |
| 18 | #include <__algorithm/find_first_of.h> | |
| 20 | 19 | #include <__algorithm/min.h> |
| 20 | #include <__config> | |
| 21 | 21 | #include <__functional/hash.h> // for __murmur2_or_cityhash |
| 22 | 22 | #include <__iterator/iterator_traits.h> |
| 23 | #include <cstdio> // for EOF | |
| 24 | 23 | #include <cstdint> // for uint_least16_t |
| 24 | #include <cstdio> // for EOF | |
| 25 | 25 | #include <cstring> // for memcpy |
| 26 | #include <cwchar> // for wmemcpy | |
| 26 | #include <iosfwd> // for streampos & friends | |
| 27 | 27 | #include <type_traits> // for __libcpp_is_constant_evaluated |
| 28 | 28 | |
| 29 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 30 | # include <cwchar> // for wmemcpy | |
| 31 | #endif | |
| 32 | ||
| 29 | 33 | #include <__debug> |
| 30 | 34 | |
| 31 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -38,9 +42,6 @@ _LIBCPP_PUSH_MACROS |
| 38 | 42 | |
| 39 | 43 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 44 | |
| 41 | // The the extern template ABI lists are kept outside of <string> to improve the | |
| 42 | // readability of that header. | |
| 43 | ||
| 44 | 45 | // The extern template ABI lists are kept outside of <string> to improve the |
| 45 | 46 | // readability of that header. We maintain 2 ABI lists: |
| 46 | 47 | // - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST |
| ... | ... | @@ -265,7 +266,9 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 265 | 266 | _CharT* |
| 266 | 267 | char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) |
| 267 | 268 | { |
| 268 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 269 | if (!__libcpp_is_constant_evaluated()) { | |
| 270 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 271 | } | |
| 269 | 272 | char_type* __r = __s1; |
| 270 | 273 | for (; __n; --__n, ++__s1, ++__s2) |
| 271 | 274 | assign(*__s1, *__s2); |
| ... | ... | @@ -287,31 +290,34 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) |
| 287 | 290 | |
| 288 | 291 | template <class _CharT> |
| 289 | 292 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 290 | _CharT* __move_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT | |
| 293 | _CharT* __copy_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT | |
| 291 | 294 | { |
| 292 | if (__n == 0) return __s1; | |
| 293 | if (__s1 < __s2) { | |
| 294 | _VSTD::copy(__s2, __s2 + __n, __s1); | |
| 295 | } else if (__s2 < __s1) { | |
| 296 | _VSTD::copy_backward(__s2, __s2 + __n, __s1 + __n); | |
| 297 | } | |
| 298 | return __s1; | |
| 295 | _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__copy_constexpr() should always be constant evaluated"); | |
| 296 | _VSTD::copy_n(__source, __n, __dest); | |
| 297 | return __dest; | |
| 299 | 298 | } |
| 300 | 299 | |
| 301 | 300 | template <class _CharT> |
| 302 | 301 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 303 | _CharT* __copy_constexpr(_CharT* __s1, const _CharT* __s2, size_t __n) _NOEXCEPT | |
| 302 | _CharT* __move_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT | |
| 304 | 303 | { |
| 305 | _VSTD::copy_n(__s2, __n, __s1); | |
| 306 | return __s1; | |
| 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; | |
| 307 | 312 | } |
| 308 | 313 | |
| 309 | 314 | template <class _CharT> |
| 310 | 315 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 311 | 316 | _CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT |
| 312 | 317 | { |
| 313 | _VSTD::fill_n(__s, __n, __a); | |
| 314 | return __s; | |
| 318 | _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__assign_constexpr() should always be constant evaluated"); | |
| 319 | _VSTD::fill_n(__s, __n, __a); | |
| 320 | return __s; | |
| 315 | 321 | } |
| 316 | 322 | |
| 317 | 323 | // char_traits<char> |
| ... | ... | @@ -334,8 +340,21 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> |
| 334 | 340 | |
| 335 | 341 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 336 | 342 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; |
| 337 | static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 338 | length(const char_type* __s) _NOEXCEPT {return __builtin_strlen(__s);} | |
| 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 | ||
| 339 | 358 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 340 | 359 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; |
| 341 | 360 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -348,7 +367,9 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> |
| 348 | 367 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 349 | 368 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT |
| 350 | 369 | { |
| 351 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 370 | if (!__libcpp_is_constant_evaluated()) { | |
| 371 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 372 | } | |
| 352 | 373 | return __libcpp_is_constant_evaluated() |
| 353 | 374 | ? _VSTD::__copy_constexpr(__s1, __s2, __n) |
| 354 | 375 | : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); |
| ... | ... | @@ -419,6 +440,7 @@ char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) |
| 419 | 440 | |
| 420 | 441 | // char_traits<wchar_t> |
| 421 | 442 | |
| 443 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 422 | 444 | template <> |
| 423 | 445 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> |
| 424 | 446 | { |
| ... | ... | @@ -451,7 +473,9 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> |
| 451 | 473 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 452 | 474 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT |
| 453 | 475 | { |
| 454 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 476 | if (!__libcpp_is_constant_evaluated()) { | |
| 477 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 478 | } | |
| 455 | 479 | return __libcpp_is_constant_evaluated() |
| 456 | 480 | ? _VSTD::__copy_constexpr(__s1, __s2, __n) |
| 457 | 481 | : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n); |
| ... | ... | @@ -497,18 +521,6 @@ char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size |
| 497 | 521 | #endif |
| 498 | 522 | } |
| 499 | 523 | |
| 500 | ||
| 501 | template <class _Traits> | |
| 502 | _LIBCPP_INLINE_VISIBILITY | |
| 503 | _LIBCPP_CONSTEXPR | |
| 504 | inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT { | |
| 505 | #if _LIBCPP_DEBUG_LEVEL >= 1 | |
| 506 | 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); | |
| 507 | #else | |
| 508 | return _Traits::length(__s); | |
| 509 | #endif | |
| 510 | } | |
| 511 | ||
| 512 | 524 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 513 | 525 | size_t |
| 514 | 526 | char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT |
| ... | ... | @@ -545,7 +557,18 @@ char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __ |
| 545 | 557 | return nullptr; |
| 546 | 558 | #endif |
| 547 | 559 | } |
| 560 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 548 | 561 | |
| 562 | template <class _Traits> | |
| 563 | _LIBCPP_INLINE_VISIBILITY | |
| 564 | _LIBCPP_CONSTEXPR | |
| 565 | inline 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 | } | |
| 549 | 572 | |
| 550 | 573 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 551 | 574 | |
| ... | ... | @@ -584,8 +607,10 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> |
| 584 | 607 | |
| 585 | 608 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 586 | 609 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT |
| 587 | { | |
| 588 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 610 | { | |
| 611 | if (!__libcpp_is_constant_evaluated()) { | |
| 612 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 613 | } | |
| 589 | 614 | return __libcpp_is_constant_evaluated() |
| 590 | 615 | ? _VSTD::__copy_constexpr(__s1, __s2, __n) |
| 591 | 616 | : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); |
| ... | ... | @@ -761,7 +786,9 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 761 | 786 | char16_t* |
| 762 | 787 | char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT |
| 763 | 788 | { |
| 764 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 789 | if (!__libcpp_is_constant_evaluated()) { | |
| 790 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 791 | } | |
| 765 | 792 | char_type* __r = __s1; |
| 766 | 793 | for (; __n; --__n, ++__s1, ++__s2) |
| 767 | 794 | assign(*__s1, *__s2); |
| ... | ... | @@ -881,7 +908,9 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 881 | 908 | char32_t* |
| 882 | 909 | char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT |
| 883 | 910 | { |
| 884 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 911 | if (!__libcpp_is_constant_evaluated()) { | |
| 912 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 913 | } | |
| 885 | 914 | char_type* __r = __s1; |
| 886 | 915 | for (; __n; --__n, ++__s1, ++__s2) |
| 887 | 916 | assign(*__s1, *__s2); |
lib/libcxx/include/__support/ibm/locale_mgmt_aix.h deleted-84| ... | ... | @@ -1,84 +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_LOCALE_MGMT_AIX_H | |
| 11 | #define _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H | |
| 12 | ||
| 13 | #if defined(_AIX) | |
| 14 | #include "cstdlib" | |
| 15 | ||
| 16 | #ifdef __cplusplus | |
| 17 | extern "C" { | |
| 18 | #endif | |
| 19 | ||
| 20 | #if !defined(_AIX71) | |
| 21 | // AIX 7.1 and higher has these definitions. Definitions and stubs | |
| 22 | // are provied here as a temporary workaround on AIX 6.1. | |
| 23 | ||
| 24 | #define LC_COLLATE_MASK 1 | |
| 25 | #define LC_CTYPE_MASK 2 | |
| 26 | #define LC_MESSAGES_MASK 4 | |
| 27 | #define LC_MONETARY_MASK 8 | |
| 28 | #define LC_NUMERIC_MASK 16 | |
| 29 | #define LC_TIME_MASK 32 | |
| 30 | #define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ | |
| 31 | LC_MESSAGES_MASK | LC_MONETARY_MASK |\ | |
| 32 | LC_NUMERIC_MASK | LC_TIME_MASK) | |
| 33 | ||
| 34 | typedef void* locale_t; | |
| 35 | ||
| 36 | // The following are stubs. They are not supported on AIX 6.1. | |
| 37 | static inline | |
| 38 | locale_t newlocale(int category_mask, const char *locale, locale_t base) | |
| 39 | { | |
| 40 | _LC_locale_t *newloc, *loc; | |
| 41 | if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) | |
| 42 | { | |
| 43 | errno = EINVAL; | |
| 44 | return (locale_t)0; | |
| 45 | } | |
| 46 | if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) | |
| 47 | { | |
| 48 | errno = ENOMEM; | |
| 49 | return (locale_t)0; | |
| 50 | } | |
| 51 | if (!base) | |
| 52 | base = (_LC_locale_t *)__xopen_locale("C"); | |
| 53 | memcpy(newloc, base, sizeof (_LC_locale_t)); | |
| 54 | if (category_mask & LC_COLLATE_MASK) | |
| 55 | newloc->lc_collate = loc->lc_collate; | |
| 56 | if (category_mask & LC_CTYPE_MASK) | |
| 57 | newloc->lc_ctype = loc->lc_ctype; | |
| 58 | //if (category_mask & LC_MESSAGES_MASK) | |
| 59 | // newloc->lc_messages = loc->lc_messages; | |
| 60 | if (category_mask & LC_MONETARY_MASK) | |
| 61 | newloc->lc_monetary = loc->lc_monetary; | |
| 62 | if (category_mask & LC_TIME_MASK) | |
| 63 | newloc->lc_time = loc->lc_time; | |
| 64 | if (category_mask & LC_NUMERIC_MASK) | |
| 65 | newloc->lc_numeric = loc->lc_numeric; | |
| 66 | return (locale_t)newloc; | |
| 67 | } | |
| 68 | static inline | |
| 69 | void freelocale(locale_t locobj) | |
| 70 | { | |
| 71 | free(locobj); | |
| 72 | } | |
| 73 | static inline | |
| 74 | locale_t uselocale(locale_t newloc) | |
| 75 | { | |
| 76 | return (locale_t)0; | |
| 77 | } | |
| 78 | #endif // !defined(_AIX71) | |
| 79 | ||
| 80 | #ifdef __cplusplus | |
| 81 | } | |
| 82 | #endif | |
| 83 | #endif // defined(_AIX) | |
| 84 | #endif // _LIBCPP_SUPPORT_IBM_LOCALE_MGMT_AIX_H |
lib/libcxx/include/__support/ibm/nanosleep.h+3-4| ... | ... | @@ -21,14 +21,13 @@ inline int nanosleep(const struct timespec* __req, struct timespec* __rem) { |
| 21 | 21 | errno = EINVAL; |
| 22 | 22 | return -1; |
| 23 | 23 | } |
| 24 | useconds_t __micro_sec = | |
| 25 | static_cast<useconds_t>((__req->tv_nsec + 999) / 1000); | |
| 24 | long __micro_sec = (__req->tv_nsec + 999) / 1000; | |
| 26 | 25 | time_t __sec = __req->tv_sec; |
| 27 | 26 | if (__micro_sec > 999999) { |
| 28 | 27 | ++__sec; |
| 29 | 28 | __micro_sec -= 1000000; |
| 30 | 29 | } |
| 31 | __sec = sleep(static_cast<unsigned int>(__sec)); | |
| 30 | __sec = static_cast<time_t>(sleep(static_cast<unsigned int>(__sec))); | |
| 32 | 31 | if (__sec) { |
| 33 | 32 | if (__rem) { |
| 34 | 33 | // Updating the remaining time to sleep in case of unsuccessful call to sleep(). |
| ... | ... | @@ -39,7 +38,7 @@ inline int nanosleep(const struct timespec* __req, struct timespec* __rem) { |
| 39 | 38 | return -1; |
| 40 | 39 | } |
| 41 | 40 | if (__micro_sec) { |
| 42 | int __rt = usleep(__micro_sec); | |
| 41 | int __rt = usleep(static_cast<unsigned int>(__micro_sec)); | |
| 43 | 42 | if (__rt != 0 && __rem) { |
| 44 | 43 | // The usleep() does not provide the amount of remaining time upon its failure, |
| 45 | 44 | // so the time slept will be ignored. |
lib/libcxx/include/__support/ibm/xlocale.h+1-202| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H |
| 11 | 11 | #define _LIBCPP_SUPPORT_IBM_XLOCALE_H |
| 12 | 12 | |
| 13 | #include <__support/ibm/locale_mgmt_aix.h> | |
| 14 | 13 | #include <__support/ibm/locale_mgmt_zos.h> |
| 15 | 14 | #include <stdarg.h> |
| 16 | 15 | |
| ... | ... | @@ -20,207 +19,7 @@ |
| 20 | 19 | extern "C" { |
| 21 | 20 | #endif |
| 22 | 21 | |
| 23 | #if defined(_AIX) | |
| 24 | #if !defined(_AIX71) | |
| 25 | // AIX 7.1 and higher has these definitions. Definitions and stubs | |
| 26 | // are provied here as a temporary workaround on AIX 6.1. | |
| 27 | static inline | |
| 28 | int isalnum_l(int c, locale_t locale) | |
| 29 | { | |
| 30 | return __xisalnum(locale, c); | |
| 31 | } | |
| 32 | static inline | |
| 33 | int isalpha_l(int c, locale_t locale) | |
| 34 | { | |
| 35 | return __xisalpha(locale, c); | |
| 36 | } | |
| 37 | static inline | |
| 38 | int isblank_l(int c, locale_t locale) | |
| 39 | { | |
| 40 | return __xisblank(locale, c); | |
| 41 | } | |
| 42 | static inline | |
| 43 | int iscntrl_l(int c, locale_t locale) | |
| 44 | { | |
| 45 | return __xiscntrl(locale, c); | |
| 46 | } | |
| 47 | static inline | |
| 48 | int isdigit_l(int c, locale_t locale) | |
| 49 | { | |
| 50 | return __xisdigit(locale, c); | |
| 51 | } | |
| 52 | static inline | |
| 53 | int isgraph_l(int c, locale_t locale) | |
| 54 | { | |
| 55 | return __xisgraph(locale, c); | |
| 56 | } | |
| 57 | static inline | |
| 58 | int islower_l(int c, locale_t locale) | |
| 59 | { | |
| 60 | return __xislower(locale, c); | |
| 61 | } | |
| 62 | static inline | |
| 63 | int isprint_l(int c, locale_t locale) | |
| 64 | { | |
| 65 | return __xisprint(locale, c); | |
| 66 | } | |
| 67 | ||
| 68 | static inline | |
| 69 | int ispunct_l(int c, locale_t locale) | |
| 70 | { | |
| 71 | return __xispunct(locale, c); | |
| 72 | } | |
| 73 | static inline | |
| 74 | int isspace_l(int c, locale_t locale) | |
| 75 | { | |
| 76 | return __xisspace(locale, c); | |
| 77 | } | |
| 78 | static inline | |
| 79 | int isupper_l(int c, locale_t locale) | |
| 80 | { | |
| 81 | return __xisupper(locale, c); | |
| 82 | } | |
| 83 | ||
| 84 | static inline | |
| 85 | int isxdigit_l(int c, locale_t locale) | |
| 86 | { | |
| 87 | return __xisxdigit(locale, c); | |
| 88 | } | |
| 89 | ||
| 90 | static inline | |
| 91 | int iswalnum_l(wchar_t wc, locale_t locale) | |
| 92 | { | |
| 93 | return __xiswalnum(locale, wc); | |
| 94 | } | |
| 95 | ||
| 96 | static inline | |
| 97 | int iswalpha_l(wchar_t wc, locale_t locale) | |
| 98 | { | |
| 99 | return __xiswalpha(locale, wc); | |
| 100 | } | |
| 101 | ||
| 102 | static inline | |
| 103 | int iswblank_l(wchar_t wc, locale_t locale) | |
| 104 | { | |
| 105 | return __xiswblank(locale, wc); | |
| 106 | } | |
| 107 | ||
| 108 | static inline | |
| 109 | int iswcntrl_l(wchar_t wc, locale_t locale) | |
| 110 | { | |
| 111 | return __xiswcntrl(locale, wc); | |
| 112 | } | |
| 113 | ||
| 114 | static inline | |
| 115 | int iswdigit_l(wchar_t wc, locale_t locale) | |
| 116 | { | |
| 117 | return __xiswdigit(locale, wc); | |
| 118 | } | |
| 119 | ||
| 120 | static inline | |
| 121 | int iswgraph_l(wchar_t wc, locale_t locale) | |
| 122 | { | |
| 123 | return __xiswgraph(locale, wc); | |
| 124 | } | |
| 125 | ||
| 126 | static inline | |
| 127 | int iswlower_l(wchar_t wc, locale_t locale) | |
| 128 | { | |
| 129 | return __xiswlower(locale, wc); | |
| 130 | } | |
| 131 | ||
| 132 | static inline | |
| 133 | int iswprint_l(wchar_t wc, locale_t locale) | |
| 134 | { | |
| 135 | return __xiswprint(locale, wc); | |
| 136 | } | |
| 137 | ||
| 138 | static inline | |
| 139 | int iswpunct_l(wchar_t wc, locale_t locale) | |
| 140 | { | |
| 141 | return __xiswpunct(locale, wc); | |
| 142 | } | |
| 143 | ||
| 144 | static inline | |
| 145 | int iswspace_l(wchar_t wc, locale_t locale) | |
| 146 | { | |
| 147 | return __xiswspace(locale, wc); | |
| 148 | } | |
| 149 | ||
| 150 | static inline | |
| 151 | int iswupper_l(wchar_t wc, locale_t locale) | |
| 152 | { | |
| 153 | return __xiswupper(locale, wc); | |
| 154 | } | |
| 155 | ||
| 156 | static inline | |
| 157 | int iswxdigit_l(wchar_t wc, locale_t locale) | |
| 158 | { | |
| 159 | return __xiswxdigit(locale, wc); | |
| 160 | } | |
| 161 | ||
| 162 | static inline | |
| 163 | int iswctype_l(wint_t wc, wctype_t desc, locale_t locale) | |
| 164 | { | |
| 165 | return __xiswctype(locale, wc, desc); | |
| 166 | } | |
| 167 | ||
| 168 | static inline | |
| 169 | int toupper_l(int c, locale_t locale) | |
| 170 | { | |
| 171 | return __xtoupper(locale, c); | |
| 172 | } | |
| 173 | static inline | |
| 174 | int tolower_l(int c, locale_t locale) | |
| 175 | { | |
| 176 | return __xtolower(locale, c); | |
| 177 | } | |
| 178 | static inline | |
| 179 | wint_t towupper_l(wint_t wc, locale_t locale) | |
| 180 | { | |
| 181 | return __xtowupper(locale, wc); | |
| 182 | } | |
| 183 | static inline | |
| 184 | wint_t towlower_l(wint_t wc, locale_t locale) | |
| 185 | { | |
| 186 | return __xtowlower(locale, wc); | |
| 187 | } | |
| 188 | ||
| 189 | static inline | |
| 190 | int strcoll_l(const char *__s1, const char *__s2, locale_t locale) | |
| 191 | { | |
| 192 | return __xstrcoll(locale, __s1, __s2); | |
| 193 | } | |
| 194 | static inline | |
| 195 | int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t locale) | |
| 196 | { | |
| 197 | return __xwcscoll(locale, __s1, __s2); | |
| 198 | } | |
| 199 | static inline | |
| 200 | size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t locale) | |
| 201 | { | |
| 202 | return __xstrxfrm(locale, __s1, __s2, __n); | |
| 203 | } | |
| 204 | ||
| 205 | static inline | |
| 206 | size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n, | |
| 207 | locale_t locale) | |
| 208 | { | |
| 209 | return __xwcsxfrm(locale, __ws1, __ws2, __n); | |
| 210 | } | |
| 211 | #endif // !defined(_AIX71) | |
| 212 | ||
| 213 | // strftime_l() is defined by POSIX. However, AIX 7.1 and z/OS do not have it | |
| 214 | // implemented yet. z/OS retrieves it from the POSIX fallbacks. | |
| 215 | #if !defined(_AIX72) | |
| 216 | static inline | |
| 217 | size_t strftime_l(char *__s, size_t __size, const char *__fmt, | |
| 218 | const struct tm *__tm, locale_t locale) { | |
| 219 | return __xstrftime(locale, __s, __size, __fmt, __tm); | |
| 220 | } | |
| 221 | #endif | |
| 222 | ||
| 223 | #elif defined(__MVS__) | |
| 22 | #if defined(__MVS__) | |
| 224 | 23 | #include <wctype.h> |
| 225 | 24 | // POSIX routines |
| 226 | 25 | #include <__support/xlocale/__posix_l_fallback.h> |
lib/libcxx/include/__support/nuttx/xlocale.h deleted-18| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===-----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_SUPPORT_NUTTX_XLOCALE_H | |
| 11 | #define _LIBCPP_SUPPORT_NUTTX_XLOCALE_H | |
| 12 | ||
| 13 | #if defined(__NuttX__) | |
| 14 | #include <__support/xlocale/__posix_l_fallback.h> | |
| 15 | #include <__support/xlocale/__strtonum_fallback.h> | |
| 16 | #endif // __NuttX__ | |
| 17 | ||
| 18 | #endif |
lib/libcxx/include/__support/openbsd/xlocale.h+20| ... | ... | @@ -16,4 +16,24 @@ |
| 16 | 16 | #include <ctype.h> |
| 17 | 17 | #include <cwctype> |
| 18 | 18 | |
| 19 | #ifdef __cplusplus | |
| 20 | extern "C" { | |
| 21 | #endif | |
| 22 | ||
| 23 | ||
| 24 | inline _LIBCPP_HIDE_FROM_ABI long | |
| 25 | strtol_l(const char *nptr, char **endptr, int base, locale_t) { | |
| 26 | return ::strtol(nptr, endptr, base); | |
| 27 | } | |
| 28 | ||
| 29 | inline _LIBCPP_HIDE_FROM_ABI unsigned long | |
| 30 | strtoul_l(const char *nptr, char **endptr, int base, locale_t) { | |
| 31 | return ::strtoul(nptr, endptr, base); | |
| 32 | } | |
| 33 | ||
| 34 | ||
| 35 | #ifdef __cplusplus | |
| 36 | } | |
| 37 | #endif | |
| 38 | ||
| 19 | 39 | #endif |
lib/libcxx/include/__support/win32/limits_msvc_win32.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #error "This header complements the Microsoft C Runtime library, and should not be included otherwise." |
| 15 | 15 | #endif |
| 16 | 16 | #if defined(__clang__) |
| 17 | #error "This header should only be included when using Microsofts C1XX frontend" | |
| 17 | #error "This header should only be included when using Microsoft's C1XX frontend" | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | #include <float.h> // limit constants |
lib/libcxx/include/__thread/poll_with_backoff.h created+69| ... | ... | @@ -0,0 +1,69 @@ |
| 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___THREAD_POLL_WITH_BACKOFF_H | |
| 10 | #define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H | |
| 11 | ||
| 12 | #include <__availability> | |
| 13 | #include <__config> | |
| 14 | #include <chrono> | |
| 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 | static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; | |
| 23 | ||
| 24 | // Polls a thread for a condition given by a predicate, and backs off based on a backoff policy | |
| 25 | // before polling again. | |
| 26 | // | |
| 27 | // - __f is the "test function" that should return true if polling succeeded, and false if it failed. | |
| 28 | // | |
| 29 | // - __bf is the "backoff policy", which is called with the duration since we started polling. It should | |
| 30 | // return false in order to resume polling, and true if polling should stop entirely for some reason. | |
| 31 | // In general, backoff policies sleep for some time before returning control to the polling loop. | |
| 32 | // | |
| 33 | // - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded, | |
| 34 | // the polling loop will return false to report a timeout. | |
| 35 | template<class _Fn, class _BFn> | |
| 36 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI | |
| 37 | bool __libcpp_thread_poll_with_backoff(_Fn&& __f, _BFn&& __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) { | |
| 38 | auto const __start = chrono::high_resolution_clock::now(); | |
| 39 | for (int __count = 0;;) { | |
| 40 | if (__f()) | |
| 41 | return true; // _Fn completion means success | |
| 42 | if (__count < __libcpp_polling_count) { | |
| 43 | __count += 1; | |
| 44 | continue; | |
| 45 | } | |
| 46 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; | |
| 47 | if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) | |
| 48 | return false; // timeout failure | |
| 49 | if (__bf(__elapsed)) | |
| 50 | return false; // _BFn completion means failure | |
| 51 | } | |
| 52 | } | |
| 53 | ||
| 54 | // A trivial backoff policy that always immediately returns the control to | |
| 55 | // the polling loop. | |
| 56 | // | |
| 57 | // This is not very well-behaved since it will cause the polling loop to spin, | |
| 58 | // so this should most likely only be used on single-threaded systems where there | |
| 59 | // are no other threads to compete with. | |
| 60 | struct __spinning_backoff_policy { | |
| 61 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 62 | bool operator()(chrono::nanoseconds const&) const { | |
| 63 | return false; | |
| 64 | } | |
| 65 | }; | |
| 66 | ||
| 67 | _LIBCPP_END_NAMESPACE_STD | |
| 68 | ||
| 69 | #endif // _LIBCPP___THREAD_POLL_WITH_BACKOFF_H |
lib/libcxx/include/__thread/timed_backoff_policy.h created+45| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H | |
| 10 | #define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 15 | ||
| 16 | #include <__threading_support> | |
| 17 | #include <chrono> | |
| 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 | struct __libcpp_timed_backoff_policy { | |
| 26 | _LIBCPP_INLINE_VISIBILITY | |
| 27 | bool operator()(chrono::nanoseconds __elapsed) const | |
| 28 | { | |
| 29 | if(__elapsed > chrono::milliseconds(128)) | |
| 30 | __libcpp_thread_sleep_for(chrono::milliseconds(8)); | |
| 31 | else if(__elapsed > chrono::microseconds(64)) | |
| 32 | __libcpp_thread_sleep_for(__elapsed / 2); | |
| 33 | else if(__elapsed > chrono::microseconds(4)) | |
| 34 | __libcpp_thread_yield(); | |
| 35 | else | |
| 36 | {} // poll | |
| 37 | return false; | |
| 38 | } | |
| 39 | }; | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 44 | ||
| 45 | #endif // _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H |
lib/libcxx/include/__threading_support+5-146| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | #include <__thread/poll_with_backoff.h> | |
| 15 | 16 | #include <chrono> |
| 16 | 17 | #include <errno.h> |
| 17 | 18 | #include <iosfwd> |
| ... | ... | @@ -29,16 +30,9 @@ |
| 29 | 30 | # include <__external_threading> |
| 30 | 31 | #elif !defined(_LIBCPP_HAS_NO_THREADS) |
| 31 | 32 | |
| 32 | #if defined(__APPLE__) || defined(__MVS__) | |
| 33 | # define _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 34 | #endif | |
| 35 | ||
| 36 | 33 | #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) |
| 37 | 34 | # include <pthread.h> |
| 38 | 35 | # include <sched.h> |
| 39 | # ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 40 | # include <semaphore.h> | |
| 41 | # endif | |
| 42 | 36 | #elif defined(_LIBCPP_HAS_THREAD_API_C11) |
| 43 | 37 | # include <threads.h> |
| 44 | 38 | #endif |
| ... | ... | @@ -60,9 +54,6 @@ |
| 60 | 54 | typedef ::timespec __libcpp_timespec_t; |
| 61 | 55 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) |
| 62 | 56 | |
| 63 | _LIBCPP_PUSH_MACROS | |
| 64 | #include <__undef_macros> | |
| 65 | ||
| 66 | 57 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 67 | 58 | |
| 68 | 59 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| ... | ... | @@ -78,12 +69,6 @@ typedef pthread_mutex_t __libcpp_recursive_mutex_t; |
| 78 | 69 | typedef pthread_cond_t __libcpp_condvar_t; |
| 79 | 70 | #define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER |
| 80 | 71 | |
| 81 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 82 | // Semaphore | |
| 83 | typedef sem_t __libcpp_semaphore_t; | |
| 84 | # define _LIBCPP_SEMAPHORE_MAX SEM_VALUE_MAX | |
| 85 | #endif | |
| 86 | ||
| 87 | 72 | // Execute once |
| 88 | 73 | typedef pthread_once_t __libcpp_exec_once_flag; |
| 89 | 74 | #define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT |
| ... | ... | @@ -149,12 +134,6 @@ typedef void* __libcpp_recursive_mutex_t[5]; |
| 149 | 134 | typedef void* __libcpp_condvar_t; |
| 150 | 135 | #define _LIBCPP_CONDVAR_INITIALIZER 0 |
| 151 | 136 | |
| 152 | // Semaphore | |
| 153 | typedef void* __libcpp_semaphore_t; | |
| 154 | #if defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 155 | # define _LIBCPP_SEMAPHORE_MAX (::std::numeric_limits<long>::max()) | |
| 156 | #endif | |
| 157 | ||
| 158 | 137 | // Execute Once |
| 159 | 138 | typedef void* __libcpp_exec_once_flag; |
| 160 | 139 | #define _LIBCPP_EXEC_ONCE_INITIALIZER 0 |
| ... | ... | @@ -219,26 +198,6 @@ int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m, |
| 219 | 198 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 220 | 199 | int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); |
| 221 | 200 | |
| 222 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 223 | ||
| 224 | // Semaphore | |
| 225 | _LIBCPP_THREAD_ABI_VISIBILITY | |
| 226 | bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init); | |
| 227 | ||
| 228 | _LIBCPP_THREAD_ABI_VISIBILITY | |
| 229 | bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem); | |
| 230 | ||
| 231 | _LIBCPP_THREAD_ABI_VISIBILITY | |
| 232 | bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem); | |
| 233 | ||
| 234 | _LIBCPP_THREAD_ABI_VISIBILITY | |
| 235 | bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem); | |
| 236 | ||
| 237 | _LIBCPP_THREAD_ABI_VISIBILITY | |
| 238 | bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns); | |
| 239 | ||
| 240 | #endif // _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 241 | ||
| 242 | 201 | // Execute once |
| 243 | 202 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 244 | 203 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, |
| ... | ... | @@ -290,75 +249,9 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p); |
| 290 | 249 | |
| 291 | 250 | #endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
| 292 | 251 | |
| 293 | struct __libcpp_timed_backoff_policy { | |
| 294 | _LIBCPP_INLINE_VISIBILITY | |
| 295 | bool operator()(chrono::nanoseconds __elapsed) const | |
| 296 | { | |
| 297 | if(__elapsed > chrono::milliseconds(128)) | |
| 298 | __libcpp_thread_sleep_for(chrono::milliseconds(8)); | |
| 299 | else if(__elapsed > chrono::microseconds(64)) | |
| 300 | __libcpp_thread_sleep_for(__elapsed / 2); | |
| 301 | else if(__elapsed > chrono::microseconds(4)) | |
| 302 | __libcpp_thread_yield(); | |
| 303 | else | |
| 304 | {} // poll | |
| 305 | return false; | |
| 306 | } | |
| 307 | }; | |
| 308 | ||
| 309 | static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64; | |
| 310 | ||
| 311 | template<class _Fn, class _BFn> | |
| 312 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | |
| 313 | bool __libcpp_thread_poll_with_backoff( | |
| 314 | _Fn && __f, _BFn && __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) | |
| 315 | { | |
| 316 | auto const __start = chrono::high_resolution_clock::now(); | |
| 317 | for(int __count = 0;;) { | |
| 318 | if(__f()) | |
| 319 | return true; // _Fn completion means success | |
| 320 | if(__count < __libcpp_polling_count) { | |
| 321 | __count += 1; | |
| 322 | continue; | |
| 323 | } | |
| 324 | chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start; | |
| 325 | if(__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed) | |
| 326 | return false; // timeout failure | |
| 327 | if(__bf(__elapsed)) | |
| 328 | return false; // _BFn completion means failure | |
| 329 | } | |
| 330 | } | |
| 331 | ||
| 332 | 252 | #if (!defined(_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL) || \ |
| 333 | 253 | defined(_LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL)) |
| 334 | 254 | |
| 335 | ||
| 336 | namespace __thread_detail { | |
| 337 | ||
| 338 | inline __libcpp_timespec_t __convert_to_timespec(const chrono::nanoseconds& __ns) | |
| 339 | { | |
| 340 | using namespace chrono; | |
| 341 | seconds __s = duration_cast<seconds>(__ns); | |
| 342 | __libcpp_timespec_t __ts; | |
| 343 | typedef decltype(__ts.tv_sec) __ts_sec; | |
| 344 | const __ts_sec __ts_sec_max = numeric_limits<__ts_sec>::max(); | |
| 345 | ||
| 346 | if (__s.count() < __ts_sec_max) | |
| 347 | { | |
| 348 | __ts.tv_sec = static_cast<__ts_sec>(__s.count()); | |
| 349 | __ts.tv_nsec = static_cast<decltype(__ts.tv_nsec)>((__ns - __s).count()); | |
| 350 | } | |
| 351 | else | |
| 352 | { | |
| 353 | __ts.tv_sec = __ts_sec_max; | |
| 354 | __ts.tv_nsec = 999999999; // (10^9 - 1) | |
| 355 | } | |
| 356 | ||
| 357 | return __ts; | |
| 358 | } | |
| 359 | ||
| 360 | } | |
| 361 | ||
| 362 | 255 | #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) |
| 363 | 256 | |
| 364 | 257 | int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) |
| ... | ... | @@ -452,38 +345,6 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) |
| 452 | 345 | return pthread_cond_destroy(__cv); |
| 453 | 346 | } |
| 454 | 347 | |
| 455 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 456 | ||
| 457 | // Semaphore | |
| 458 | bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init) | |
| 459 | { | |
| 460 | return sem_init(__sem, 0, __init) == 0; | |
| 461 | } | |
| 462 | ||
| 463 | bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem) | |
| 464 | { | |
| 465 | return sem_destroy(__sem) == 0; | |
| 466 | } | |
| 467 | ||
| 468 | bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem) | |
| 469 | { | |
| 470 | return sem_post(__sem) == 0; | |
| 471 | } | |
| 472 | ||
| 473 | bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem) | |
| 474 | { | |
| 475 | return sem_wait(__sem) == 0; | |
| 476 | } | |
| 477 | ||
| 478 | bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, chrono::nanoseconds const& __ns) | |
| 479 | { | |
| 480 | auto const __abs_time = chrono::system_clock::now().time_since_epoch() + __ns; | |
| 481 | __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__abs_time); | |
| 482 | return sem_timedwait(__sem, &__ts) == 0; | |
| 483 | } | |
| 484 | ||
| 485 | #endif //_LIBCPP_NO_NATIVE_SEMAPHORES | |
| 486 | ||
| 487 | 348 | // Execute once |
| 488 | 349 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, |
| 489 | 350 | void (*init_routine)()) { |
| ... | ... | @@ -546,7 +407,7 @@ void __libcpp_thread_yield() |
| 546 | 407 | |
| 547 | 408 | void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) |
| 548 | 409 | { |
| 549 | __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__ns); | |
| 410 | __libcpp_timespec_t __ts = _VSTD::__convert_to_timespec<__libcpp_timespec_t>(__ns); | |
| 550 | 411 | while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR); |
| 551 | 412 | } |
| 552 | 413 | |
| ... | ... | @@ -703,7 +564,7 @@ void __libcpp_thread_yield() |
| 703 | 564 | |
| 704 | 565 | void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) |
| 705 | 566 | { |
| 706 | __libcpp_timespec_t __ts = __thread_detail::__convert_to_timespec(__ns); | |
| 567 | __libcpp_timespec_t __ts = _VSTD::__convert_to_timespec<__libcpp_timespec_t>(__ns); | |
| 707 | 568 | thrd_sleep(&__ts, nullptr); |
| 708 | 569 | } |
| 709 | 570 | |
| ... | ... | @@ -736,7 +597,7 @@ namespace this_thread |
| 736 | 597 | |
| 737 | 598 | _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT; |
| 738 | 599 | |
| 739 | } // this_thread | |
| 600 | } // namespace this_thread | |
| 740 | 601 | |
| 741 | 602 | template<> struct hash<__thread_id>; |
| 742 | 603 | |
| ... | ... | @@ -806,12 +667,10 @@ get_id() _NOEXCEPT |
| 806 | 667 | return __libcpp_thread_get_current_id(); |
| 807 | 668 | } |
| 808 | 669 | |
| 809 | } // this_thread | |
| 670 | } // namespace this_thread | |
| 810 | 671 | |
| 811 | 672 | #endif // !_LIBCPP_HAS_NO_THREADS |
| 812 | 673 | |
| 813 | 674 | _LIBCPP_END_NAMESPACE_STD |
| 814 | 675 | |
| 815 | _LIBCPP_POP_MACROS | |
| 816 | ||
| 817 | 676 | #endif // _LIBCPP_THREADING_SUPPORT |
lib/libcxx/include/__tree+7-7| ... | ... | @@ -738,9 +738,9 @@ public: |
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | private: |
| 741 | ~__tree_node_base() _LIBCPP_EQUAL_DELETE; | |
| 742 | __tree_node_base(__tree_node_base const&) _LIBCPP_EQUAL_DELETE; | |
| 743 | __tree_node_base& operator=(__tree_node_base const&) _LIBCPP_EQUAL_DELETE; | |
| 741 | ~__tree_node_base() = delete; | |
| 742 | __tree_node_base(__tree_node_base const&) = delete; | |
| 743 | __tree_node_base& operator=(__tree_node_base const&) = delete; | |
| 744 | 744 | }; |
| 745 | 745 | |
| 746 | 746 | template <class _Tp, class _VoidPtr> |
| ... | ... | @@ -753,9 +753,9 @@ public: |
| 753 | 753 | __node_value_type __value_; |
| 754 | 754 | |
| 755 | 755 | private: |
| 756 | ~__tree_node() _LIBCPP_EQUAL_DELETE; | |
| 757 | __tree_node(__tree_node const&) _LIBCPP_EQUAL_DELETE; | |
| 758 | __tree_node& operator=(__tree_node const&) _LIBCPP_EQUAL_DELETE; | |
| 756 | ~__tree_node() = delete; | |
| 757 | __tree_node(__tree_node const&) = delete; | |
| 758 | __tree_node& operator=(__tree_node const&) = delete; | |
| 759 | 759 | }; |
| 760 | 760 | |
| 761 | 761 | |
| ... | ... | @@ -1612,7 +1612,7 @@ template <class _Tp, class _Compare, class _Allocator> |
| 1612 | 1612 | __tree<_Tp, _Compare, _Allocator>& |
| 1613 | 1613 | __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) |
| 1614 | 1614 | { |
| 1615 | if (this != &__t) | |
| 1615 | if (this != _VSTD::addressof(__t)) | |
| 1616 | 1616 | { |
| 1617 | 1617 | value_comp() = __t.value_comp(); |
| 1618 | 1618 | __copy_assign_alloc(__t); |
lib/libcxx/include/__tuple+22-22| ... | ... | @@ -58,19 +58,19 @@ template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element; |
| 58 | 58 | template <size_t _Ip, class _Tp> |
| 59 | 59 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> |
| 60 | 60 | { |
| 61 | typedef _LIBCPP_NODEBUG_TYPE typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type; | |
| 61 | typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type; | |
| 62 | 62 | }; |
| 63 | 63 | |
| 64 | 64 | template <size_t _Ip, class _Tp> |
| 65 | 65 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> |
| 66 | 66 | { |
| 67 | typedef _LIBCPP_NODEBUG_TYPE typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type; | |
| 67 | typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type; | |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | 70 | template <size_t _Ip, class _Tp> |
| 71 | 71 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> |
| 72 | 72 | { |
| 73 | typedef _LIBCPP_NODEBUG_TYPE typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type; | |
| 73 | typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type; | |
| 74 | 74 | }; |
| 75 | 75 | |
| 76 | 76 | template <class _Tp> struct __tuple_like : false_type {}; |
| ... | ... | @@ -99,7 +99,7 @@ namespace __detail { |
| 99 | 99 | |
| 100 | 100 | template<typename _Tp, size_t ..._Extra> struct __repeat; |
| 101 | 101 | template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> { |
| 102 | typedef _LIBCPP_NODEBUG_TYPE __integer_sequence<_Tp, | |
| 102 | typedef _LIBCPP_NODEBUG __integer_sequence<_Tp, | |
| 103 | 103 | _Np..., |
| 104 | 104 | sizeof...(_Np) + _Np..., |
| 105 | 105 | 2 * sizeof...(_Np) + _Np..., |
| ... | ... | @@ -253,7 +253,7 @@ template <class ..._Tp> struct __tuple_types {}; |
| 253 | 253 | namespace __indexer_detail { |
| 254 | 254 | |
| 255 | 255 | template <size_t _Idx, class _Tp> |
| 256 | struct __indexed { using type _LIBCPP_NODEBUG_TYPE = _Tp; }; | |
| 256 | struct __indexed { using type _LIBCPP_NODEBUG = _Tp; }; | |
| 257 | 257 | |
| 258 | 258 | template <class _Types, class _Indexes> struct __indexer; |
| 259 | 259 | |
| ... | ... | @@ -268,7 +268,7 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&); |
| 268 | 268 | } // namespace __indexer_detail |
| 269 | 269 | |
| 270 | 270 | template <size_t _Idx, class ..._Types> |
| 271 | using __type_pack_element _LIBCPP_NODEBUG_TYPE = typename decltype( | |
| 271 | using __type_pack_element _LIBCPP_NODEBUG = typename decltype( | |
| 272 | 272 | __indexer_detail::__at_index<_Idx>( |
| 273 | 273 | __indexer_detail::__indexer< |
| 274 | 274 | __tuple_types<_Types...>, |
| ... | ... | @@ -281,7 +281,7 @@ template <size_t _Ip, class ..._Types> |
| 281 | 281 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>> |
| 282 | 282 | { |
| 283 | 283 | static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range"); |
| 284 | typedef _LIBCPP_NODEBUG_TYPE __type_pack_element<_Ip, _Types...> type; | |
| 284 | typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type; | |
| 285 | 285 | }; |
| 286 | 286 | |
| 287 | 287 | |
| ... | ... | @@ -301,34 +301,34 @@ struct __apply_cv_mf<false, false, false> { |
| 301 | 301 | }; |
| 302 | 302 | template <> |
| 303 | 303 | struct __apply_cv_mf<false, true, false> { |
| 304 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const _Tp; | |
| 304 | template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp; | |
| 305 | 305 | }; |
| 306 | 306 | template <> |
| 307 | 307 | struct __apply_cv_mf<false, false, true> { |
| 308 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp; | |
| 308 | template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp; | |
| 309 | 309 | }; |
| 310 | 310 | template <> |
| 311 | 311 | struct __apply_cv_mf<false, true, true> { |
| 312 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp; | |
| 312 | template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp; | |
| 313 | 313 | }; |
| 314 | 314 | template <> |
| 315 | 315 | struct __apply_cv_mf<true, false, false> { |
| 316 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = _Tp&; | |
| 316 | template <class _Tp> using __apply _LIBCPP_NODEBUG = _Tp&; | |
| 317 | 317 | }; |
| 318 | 318 | template <> |
| 319 | 319 | struct __apply_cv_mf<true, true, false> { |
| 320 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const _Tp&; | |
| 320 | template <class _Tp> using __apply _LIBCPP_NODEBUG = const _Tp&; | |
| 321 | 321 | }; |
| 322 | 322 | template <> |
| 323 | 323 | struct __apply_cv_mf<true, false, true> { |
| 324 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp&; | |
| 324 | template <class _Tp> using __apply _LIBCPP_NODEBUG = volatile _Tp&; | |
| 325 | 325 | }; |
| 326 | 326 | template <> |
| 327 | 327 | struct __apply_cv_mf<true, true, true> { |
| 328 | template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp&; | |
| 328 | template <class _Tp> using __apply _LIBCPP_NODEBUG = const volatile _Tp&; | |
| 329 | 329 | }; |
| 330 | 330 | template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type> |
| 331 | using __apply_cv_t _LIBCPP_NODEBUG_TYPE = __apply_cv_mf< | |
| 331 | using __apply_cv_t _LIBCPP_NODEBUG = __apply_cv_mf< | |
| 332 | 332 | is_lvalue_reference<_Tp>::value, |
| 333 | 333 | is_const<_RawTp>::value, |
| 334 | 334 | is_volatile<_RawTp>::value>; |
| ... | ... | @@ -347,7 +347,7 @@ template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx> |
| 347 | 347 | struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> { |
| 348 | 348 | // Specialization for pair, tuple, and __tuple_types |
| 349 | 349 | template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>> |
| 350 | using __apply_quals _LIBCPP_NODEBUG_TYPE = __tuple_types< | |
| 350 | using __apply_quals _LIBCPP_NODEBUG = __tuple_types< | |
| 351 | 351 | typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>... |
| 352 | 352 | >; |
| 353 | 353 | }; |
| ... | ... | @@ -375,19 +375,19 @@ struct __make_tuple_types |
| 375 | 375 | |
| 376 | 376 | template <class ..._Types, size_t _Ep> |
| 377 | 377 | struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> { |
| 378 | typedef _LIBCPP_NODEBUG_TYPE __tuple_types<_Types...> type; | |
| 378 | typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; | |
| 379 | 379 | }; |
| 380 | 380 | |
| 381 | 381 | template <class ..._Types, size_t _Ep> |
| 382 | 382 | struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> { |
| 383 | typedef _LIBCPP_NODEBUG_TYPE __tuple_types<_Types...> type; | |
| 383 | typedef _LIBCPP_NODEBUG __tuple_types<_Types...> type; | |
| 384 | 384 | }; |
| 385 | 385 | |
| 386 | 386 | template <bool ..._Preds> |
| 387 | 387 | struct __all_dummy; |
| 388 | 388 | |
| 389 | 389 | template <bool ..._Pred> |
| 390 | using __all = _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>; | |
| 390 | struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {}; | |
| 391 | 391 | |
| 392 | 392 | struct __tuple_sfinae_base { |
| 393 | 393 | template <template <class, class...> class _Trait, |
| ... | ... | @@ -454,12 +454,12 @@ struct __tuple_assignable<_Tp, _Up, true, true> |
| 454 | 454 | template <size_t _Ip, class ..._Tp> |
| 455 | 455 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > |
| 456 | 456 | { |
| 457 | typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; | |
| 457 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; | |
| 458 | 458 | }; |
| 459 | 459 | |
| 460 | 460 | #if _LIBCPP_STD_VER > 11 |
| 461 | 461 | template <size_t _Ip, class ..._Tp> |
| 462 | using tuple_element_t _LIBCPP_NODEBUG_TYPE = typename tuple_element <_Ip, _Tp...>::type; | |
| 462 | using tuple_element_t _LIBCPP_NODEBUG = typename tuple_element <_Ip, _Tp...>::type; | |
| 463 | 463 | #endif |
| 464 | 464 | |
| 465 | 465 | template <bool _IsTuple, class _SizeTrait, size_t _Expected> |
| ... | ... | @@ -471,7 +471,7 @@ struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected> |
| 471 | 471 | |
| 472 | 472 | template <class _Tuple, size_t _ExpectedSize, |
| 473 | 473 | class _RawTuple = typename __uncvref<_Tuple>::type> |
| 474 | using __tuple_like_with_size _LIBCPP_NODEBUG_TYPE = __tuple_like_with_size_imp< | |
| 474 | using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp< | |
| 475 | 475 | __tuple_like<_RawTuple>::value, |
| 476 | 476 | tuple_size<_RawTuple>, _ExpectedSize |
| 477 | 477 | >; |
lib/libcxx/include/__undef_macros+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ __undef_macros ------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/__utility/__decay_copy.h deleted-39| ... | ... | @@ -1,39 +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___TYPE_TRAITS_DECAY_COPY_H | |
| 11 | #define _LIBCPP___TYPE_TRAITS_DECAY_COPY_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__utility/forward.h> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | template <class _Tp> | |
| 27 | inline _LIBCPP_INLINE_VISIBILITY typename decay<_Tp>::type __decay_copy(_Tp&& __t) | |
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | noexcept(is_nothrow_convertible_v<_Tp, remove_reference_t<_Tp> >) | |
| 30 | #endif | |
| 31 | { | |
| 32 | return _VSTD::forward<_Tp>(__t); | |
| 33 | } | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | _LIBCPP_POP_MACROS | |
| 38 | ||
| 39 | #endif // _LIBCPP___TYPE_TRAITS_DECAY_COPY_H |
lib/libcxx/include/__utility/as_const.h-5| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -33,6 +30,4 @@ void as_const(const _Tp&&) = delete; |
| 33 | 30 | |
| 34 | 31 | _LIBCPP_END_NAMESPACE_STD |
| 35 | 32 | |
| 36 | _LIBCPP_POP_MACROS | |
| 37 | ||
| 38 | 33 | #endif // _LIBCPP___UTILITY_AS_CONST_H |
lib/libcxx/include/__utility/auto_cast.h created+22| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___UTILITY_AUTO_CAST_H | |
| 11 | #define _LIBCPP___UTILITY_AUTO_CAST_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <type_traits> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | #pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | #define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr) | |
| 21 | ||
| 22 | #endif // _LIBCPP___UTILITY_AUTO_CAST_H |
lib/libcxx/include/__utility/cmp.h+8-5| ... | ... | @@ -24,20 +24,23 @@ _LIBCPP_PUSH_MACROS |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | 28 | template<class _Tp, class... _Up> |
| 29 | 29 | struct _IsSameAsAny : _Or<_IsSame<_Tp, _Up>...> {}; |
| 30 | 30 | |
| 31 | 31 | template<class _Tp> |
| 32 | 32 | concept __is_safe_integral_cmp = is_integral_v<_Tp> && |
| 33 | !_IsSameAsAny<_Tp, bool, char, | |
| 33 | !_IsSameAsAny<_Tp, bool, char | |
| 34 | 34 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 35 | char8_t, | |
| 35 | , char8_t | |
| 36 | 36 | #endif |
| 37 | 37 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 38 | char16_t, char32_t, | |
| 38 | , char16_t, char32_t | |
| 39 | 39 | #endif |
| 40 | wchar_t>::value; | |
| 40 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 41 | , wchar_t | |
| 42 | #endif | |
| 43 | >::value; | |
| 41 | 44 | |
| 42 | 45 | template<__is_safe_integral_cmp _Tp, __is_safe_integral_cmp _Up> |
| 43 | 46 | _LIBCPP_INLINE_VISIBILITY constexpr |
lib/libcxx/include/__utility/declval.h-5| ... | ... | @@ -15,9 +15,6 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | // Suppress deprecation notice for volatile-qualified return type resulting |
| ... | ... | @@ -34,6 +31,4 @@ decltype(__declval<_Tp>(0)) declval() _NOEXCEPT; |
| 34 | 31 | |
| 35 | 32 | _LIBCPP_END_NAMESPACE_STD |
| 36 | 33 | |
| 37 | _LIBCPP_POP_MACROS | |
| 38 | ||
| 39 | 34 | #endif // _LIBCPP___UTILITY_DECLVAL_H |
lib/libcxx/include/__utility/exchange.h+3-6| ... | ... | @@ -12,20 +12,19 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__utility/forward.h> |
| 14 | 14 | #include <__utility/move.h> |
| 15 | #include <type_traits> | |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | 18 | #pragma GCC system_header |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 22 | |
| 25 | 23 | #if _LIBCPP_STD_VER > 11 |
| 26 | 24 | template<class _T1, class _T2 = _T1> |
| 27 | 25 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 28 | _T1 exchange(_T1& __obj, _T2 && __new_value) | |
| 26 | _T1 exchange(_T1& __obj, _T2&& __new_value) | |
| 27 | noexcept(is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value) | |
| 29 | 28 | { |
| 30 | 29 | _T1 __old_value = _VSTD::move(__obj); |
| 31 | 30 | __obj = _VSTD::forward<_T2>(__new_value); |
| ... | ... | @@ -35,6 +34,4 @@ _T1 exchange(_T1& __obj, _T2 && __new_value) |
| 35 | 34 | |
| 36 | 35 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 36 | |
| 38 | _LIBCPP_POP_MACROS | |
| 39 | ||
| 40 | 37 | #endif // _LIBCPP___UTILITY_EXCHANGE_H |
lib/libcxx/include/__utility/forward.h-5| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _Tp> |
| ... | ... | @@ -37,6 +34,4 @@ forward(typename remove_reference<_Tp>::type&& __t) _NOEXCEPT { |
| 37 | 34 | |
| 38 | 35 | _LIBCPP_END_NAMESPACE_STD |
| 39 | 36 | |
| 40 | _LIBCPP_POP_MACROS | |
| 41 | ||
| 42 | 37 | #endif // _LIBCPP___UTILITY_FORWARD_H |
lib/libcxx/include/__utility/in_place.h+3-8| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -26,21 +23,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | struct _LIBCPP_TYPE_VIS in_place_t { |
| 27 | 24 | explicit in_place_t() = default; |
| 28 | 25 | }; |
| 29 | _LIBCPP_INLINE_VAR constexpr in_place_t in_place{}; | |
| 26 | inline constexpr in_place_t in_place{}; | |
| 30 | 27 | |
| 31 | 28 | template <class _Tp> |
| 32 | 29 | struct _LIBCPP_TEMPLATE_VIS in_place_type_t { |
| 33 | 30 | explicit in_place_type_t() = default; |
| 34 | 31 | }; |
| 35 | 32 | template <class _Tp> |
| 36 | _LIBCPP_INLINE_VAR constexpr in_place_type_t<_Tp> in_place_type{}; | |
| 33 | inline constexpr in_place_type_t<_Tp> in_place_type{}; | |
| 37 | 34 | |
| 38 | 35 | template <size_t _Idx> |
| 39 | 36 | struct _LIBCPP_TEMPLATE_VIS in_place_index_t { |
| 40 | 37 | explicit in_place_index_t() = default; |
| 41 | 38 | }; |
| 42 | 39 | template <size_t _Idx> |
| 43 | _LIBCPP_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{}; | |
| 40 | inline constexpr in_place_index_t<_Idx> in_place_index{}; | |
| 44 | 41 | |
| 45 | 42 | template <class _Tp> struct __is_inplace_type_imp : false_type {}; |
| 46 | 43 | template <class _Tp> struct __is_inplace_type_imp<in_place_type_t<_Tp>> : true_type {}; |
| ... | ... | @@ -58,6 +55,4 @@ using __is_inplace_index = __is_inplace_index_imp<__uncvref_t<_Tp>>; |
| 58 | 55 | |
| 59 | 56 | _LIBCPP_END_NAMESPACE_STD |
| 60 | 57 | |
| 61 | _LIBCPP_POP_MACROS | |
| 62 | ||
| 63 | 58 | #endif // _LIBCPP___UTILITY_IN_PLACE_H |
lib/libcxx/include/__utility/integer_sequence.h+4-9| ... | ... | @@ -16,9 +16,6 @@ |
| 16 | 16 | #pragma GCC system_header |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | _LIBCPP_PUSH_MACROS | |
| 20 | #include <__undef_macros> | |
| 21 | ||
| 22 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 20 | |
| 24 | 21 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -42,11 +39,11 @@ template<size_t... _Ip> |
| 42 | 39 | #if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) |
| 43 | 40 | |
| 44 | 41 | template <class _Tp, _Tp _Ep> |
| 45 | using __make_integer_sequence _LIBCPP_NODEBUG_TYPE = __make_integer_seq<integer_sequence, _Tp, _Ep>; | |
| 42 | using __make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>; | |
| 46 | 43 | |
| 47 | 44 | #else |
| 48 | 45 | |
| 49 | template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked _LIBCPP_NODEBUG_TYPE = | |
| 46 | template<typename _Tp, _Tp _Np> using __make_integer_sequence_unchecked _LIBCPP_NODEBUG = | |
| 50 | 47 | typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>; |
| 51 | 48 | |
| 52 | 49 | template <class _Tp, _Tp _Ep> |
| ... | ... | @@ -57,11 +54,11 @@ struct __make_integer_sequence_checked |
| 57 | 54 | static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length"); |
| 58 | 55 | // Workaround GCC bug by preventing bad installations when 0 <= _Ep |
| 59 | 56 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929 |
| 60 | typedef _LIBCPP_NODEBUG_TYPE __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type; | |
| 57 | typedef _LIBCPP_NODEBUG __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type; | |
| 61 | 58 | }; |
| 62 | 59 | |
| 63 | 60 | template <class _Tp, _Tp _Ep> |
| 64 | using __make_integer_sequence _LIBCPP_NODEBUG_TYPE = typename __make_integer_sequence_checked<_Tp, _Ep>::type; | |
| 61 | using __make_integer_sequence _LIBCPP_NODEBUG = typename __make_integer_sequence_checked<_Tp, _Ep>::type; | |
| 65 | 62 | |
| 66 | 63 | #endif |
| 67 | 64 | |
| ... | ... | @@ -78,6 +75,4 @@ template<class... _Tp> |
| 78 | 75 | |
| 79 | 76 | _LIBCPP_END_NAMESPACE_STD |
| 80 | 77 | |
| 81 | _LIBCPP_POP_MACROS | |
| 82 | ||
| 83 | 78 | #endif // _LIBCPP___UTILITY_INTEGER_SEQUENCE_H |
lib/libcxx/include/__utility/move.h+1-6| ... | ... | @@ -17,15 +17,12 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | template <class _Tp> |
| 26 | 23 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename remove_reference<_Tp>::type&& |
| 27 | 24 | move(_Tp&& __t) _NOEXCEPT { |
| 28 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up; | |
| 25 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up; | |
| 29 | 26 | return static_cast<_Up&&>(__t); |
| 30 | 27 | } |
| 31 | 28 | |
| ... | ... | @@ -47,6 +44,4 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT { |
| 47 | 44 | |
| 48 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 49 | 46 | |
| 50 | _LIBCPP_POP_MACROS | |
| 51 | ||
| 52 | 47 | #endif // _LIBCPP___UTILITY_MOVE_H |
lib/libcxx/include/__utility/pair.h+67-43| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___UTILITY_PAIR_H |
| 10 | 10 | #define _LIBCPP___UTILITY_PAIR_H |
| 11 | 11 | |
| 12 | #include <__compare/common_comparison_category.h> | |
| 13 | #include <__compare/synth_three_way.h> | |
| 12 | 14 | #include <__config> |
| 13 | 15 | #include <__functional/unwrap_ref.h> |
| 14 | 16 | #include <__tuple> |
| ... | ... | @@ -22,12 +24,8 @@ |
| 22 | 24 | #pragma GCC system_header |
| 23 | 25 | #endif |
| 24 | 26 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 28 | |
| 30 | ||
| 31 | 29 | #if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR) |
| 32 | 30 | template <class, class> |
| 33 | 31 | struct __non_trivially_copyable_base { |
| ... | ... | @@ -75,9 +73,6 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 75 | 73 | return *this; |
| 76 | 74 | } |
| 77 | 75 | #else |
| 78 | template <bool _Val> | |
| 79 | using _EnableB _LIBCPP_NODEBUG_TYPE = typename enable_if<_Val, bool>::type; | |
| 80 | ||
| 81 | 76 | struct _CheckArgs { |
| 82 | 77 | template <int&...> |
| 83 | 78 | static constexpr bool __enable_explicit_default() { |
| ... | ... | @@ -110,7 +105,7 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 110 | 105 | }; |
| 111 | 106 | |
| 112 | 107 | template <bool _MaybeEnable> |
| 113 | using _CheckArgsDep _LIBCPP_NODEBUG_TYPE = typename conditional< | |
| 108 | using _CheckArgsDep _LIBCPP_NODEBUG = typename conditional< | |
| 114 | 109 | _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; |
| 115 | 110 | |
| 116 | 111 | struct _CheckTupleLikeConstructor { |
| ... | ... | @@ -132,112 +127,122 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 132 | 127 | }; |
| 133 | 128 | |
| 134 | 129 | template <class _Tuple> |
| 135 | using _CheckTLC _LIBCPP_NODEBUG_TYPE = typename conditional< | |
| 130 | using _CheckTLC _LIBCPP_NODEBUG = typename conditional< | |
| 136 | 131 | __tuple_like_with_size<_Tuple, 2>::value |
| 137 | 132 | && !is_same<typename decay<_Tuple>::type, pair>::value, |
| 138 | 133 | _CheckTupleLikeConstructor, |
| 139 | 134 | __check_tuple_constructor_fail |
| 140 | 135 | >::type; |
| 141 | 136 | |
| 142 | template<bool _Dummy = true, _EnableB< | |
| 137 | template<bool _Dummy = true, typename enable_if< | |
| 143 | 138 | _CheckArgsDep<_Dummy>::__enable_explicit_default() |
| 144 | > = false> | |
| 139 | >::type* = nullptr> | |
| 145 | 140 | explicit _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 146 | 141 | pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && |
| 147 | 142 | is_nothrow_default_constructible<second_type>::value) |
| 148 | 143 | : first(), second() {} |
| 149 | 144 | |
| 150 | template<bool _Dummy = true, _EnableB< | |
| 145 | template<bool _Dummy = true, typename enable_if< | |
| 151 | 146 | _CheckArgsDep<_Dummy>::__enable_implicit_default() |
| 152 | > = false> | |
| 147 | >::type* = nullptr> | |
| 153 | 148 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 154 | 149 | pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && |
| 155 | 150 | is_nothrow_default_constructible<second_type>::value) |
| 156 | 151 | : first(), second() {} |
| 157 | 152 | |
| 158 | template <bool _Dummy = true, _EnableB< | |
| 153 | template <bool _Dummy = true, typename enable_if< | |
| 159 | 154 | _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>() |
| 160 | > = false> | |
| 155 | >::type* = nullptr> | |
| 161 | 156 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 162 | 157 | explicit pair(_T1 const& __t1, _T2 const& __t2) |
| 163 | 158 | _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && |
| 164 | 159 | is_nothrow_copy_constructible<second_type>::value) |
| 165 | 160 | : first(__t1), second(__t2) {} |
| 166 | 161 | |
| 167 | template<bool _Dummy = true, _EnableB< | |
| 162 | template<bool _Dummy = true, typename enable_if< | |
| 168 | 163 | _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>() |
| 169 | > = false> | |
| 164 | >::type* = nullptr> | |
| 170 | 165 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 171 | 166 | pair(_T1 const& __t1, _T2 const& __t2) |
| 172 | 167 | _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && |
| 173 | 168 | is_nothrow_copy_constructible<second_type>::value) |
| 174 | 169 | : first(__t1), second(__t2) {} |
| 175 | 170 | |
| 176 | template<class _U1, class _U2, _EnableB< | |
| 177 | _CheckArgs::template __enable_explicit<_U1, _U2>() | |
| 178 | > = false> | |
| 171 | template < | |
| 172 | #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951 | |
| 173 | class _U1 = _T1, class _U2 = _T2, | |
| 174 | #else | |
| 175 | class _U1, class _U2, | |
| 176 | #endif | |
| 177 | typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr | |
| 178 | > | |
| 179 | 179 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 180 | 180 | explicit pair(_U1&& __u1, _U2&& __u2) |
| 181 | 181 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && |
| 182 | 182 | is_nothrow_constructible<second_type, _U2>::value)) |
| 183 | 183 | : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} |
| 184 | 184 | |
| 185 | template<class _U1, class _U2, _EnableB< | |
| 186 | _CheckArgs::template __enable_implicit<_U1, _U2>() | |
| 187 | > = false> | |
| 185 | template < | |
| 186 | #if _LIBCPP_STD_VER > 20 // http://wg21.link/P1951 | |
| 187 | class _U1 = _T1, class _U2 = _T2, | |
| 188 | #else | |
| 189 | class _U1, class _U2, | |
| 190 | #endif | |
| 191 | typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr | |
| 192 | > | |
| 188 | 193 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 189 | 194 | pair(_U1&& __u1, _U2&& __u2) |
| 190 | 195 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value && |
| 191 | 196 | is_nothrow_constructible<second_type, _U2>::value)) |
| 192 | 197 | : first(_VSTD::forward<_U1>(__u1)), second(_VSTD::forward<_U2>(__u2)) {} |
| 193 | 198 | |
| 194 | template<class _U1, class _U2, _EnableB< | |
| 199 | template<class _U1, class _U2, typename enable_if< | |
| 195 | 200 | _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>() |
| 196 | > = false> | |
| 201 | >::type* = nullptr> | |
| 197 | 202 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 198 | 203 | explicit pair(pair<_U1, _U2> const& __p) |
| 199 | 204 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && |
| 200 | 205 | is_nothrow_constructible<second_type, _U2 const&>::value)) |
| 201 | 206 | : first(__p.first), second(__p.second) {} |
| 202 | 207 | |
| 203 | template<class _U1, class _U2, _EnableB< | |
| 208 | template<class _U1, class _U2, typename enable_if< | |
| 204 | 209 | _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>() |
| 205 | > = false> | |
| 210 | >::type* = nullptr> | |
| 206 | 211 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 207 | 212 | pair(pair<_U1, _U2> const& __p) |
| 208 | 213 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && |
| 209 | 214 | is_nothrow_constructible<second_type, _U2 const&>::value)) |
| 210 | 215 | : first(__p.first), second(__p.second) {} |
| 211 | 216 | |
| 212 | template<class _U1, class _U2, _EnableB< | |
| 217 | template<class _U1, class _U2, typename enable_if< | |
| 213 | 218 | _CheckArgs::template __enable_explicit<_U1, _U2>() |
| 214 | > = false> | |
| 219 | >::type* = nullptr> | |
| 215 | 220 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 216 | 221 | explicit pair(pair<_U1, _U2>&&__p) |
| 217 | 222 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && |
| 218 | 223 | is_nothrow_constructible<second_type, _U2&&>::value)) |
| 219 | 224 | : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} |
| 220 | 225 | |
| 221 | template<class _U1, class _U2, _EnableB< | |
| 226 | template<class _U1, class _U2, typename enable_if< | |
| 222 | 227 | _CheckArgs::template __enable_implicit<_U1, _U2>() |
| 223 | > = false> | |
| 228 | >::type* = nullptr> | |
| 224 | 229 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 225 | 230 | pair(pair<_U1, _U2>&& __p) |
| 226 | 231 | _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && |
| 227 | 232 | is_nothrow_constructible<second_type, _U2&&>::value)) |
| 228 | 233 | : first(_VSTD::forward<_U1>(__p.first)), second(_VSTD::forward<_U2>(__p.second)) {} |
| 229 | 234 | |
| 230 | template<class _Tuple, _EnableB< | |
| 235 | template<class _Tuple, typename enable_if< | |
| 231 | 236 | _CheckTLC<_Tuple>::template __enable_explicit<_Tuple>() |
| 232 | > = false> | |
| 237 | >::type* = nullptr> | |
| 233 | 238 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 234 | 239 | explicit pair(_Tuple&& __p) |
| 235 | 240 | : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), |
| 236 | 241 | second(_VSTD::get<1>(_VSTD::forward<_Tuple>(__p))) {} |
| 237 | 242 | |
| 238 | template<class _Tuple, _EnableB< | |
| 243 | template<class _Tuple, typename enable_if< | |
| 239 | 244 | _CheckTLC<_Tuple>::template __enable_implicit<_Tuple>() |
| 240 | > = false> | |
| 245 | >::type* = nullptr> | |
| 241 | 246 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 242 | 247 | pair(_Tuple&& __p) |
| 243 | 248 | : first(_VSTD::get<0>(_VSTD::forward<_Tuple>(__p))), |
| ... | ... | @@ -279,9 +284,9 @@ struct _LIBCPP_TEMPLATE_VIS pair |
| 279 | 284 | return *this; |
| 280 | 285 | } |
| 281 | 286 | |
| 282 | template <class _Tuple, _EnableB< | |
| 287 | template <class _Tuple, typename enable_if< | |
| 283 | 288 | _CheckTLC<_Tuple>::template __enable_assign<_Tuple>() |
| 284 | > = false> | |
| 289 | >::type* = nullptr> | |
| 285 | 290 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 286 | 291 | pair& operator=(_Tuple&& __p) { |
| 287 | 292 | first = _VSTD::get<0>(_VSTD::forward<_Tuple>(__p)); |
| ... | ... | @@ -310,10 +315,12 @@ private: |
| 310 | 315 | #endif |
| 311 | 316 | }; |
| 312 | 317 | |
| 313 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 318 | #if _LIBCPP_STD_VER >= 17 | |
| 314 | 319 | template<class _T1, class _T2> |
| 315 | 320 | pair(_T1, _T2) -> pair<_T1, _T2>; |
| 316 | #endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 321 | #endif | |
| 322 | ||
| 323 | // [pairs.spec], specialized algorithms | |
| 317 | 324 | |
| 318 | 325 | template <class _T1, class _T2> |
| 319 | 326 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| ... | ... | @@ -323,6 +330,23 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) |
| 323 | 330 | return __x.first == __y.first && __x.second == __y.second; |
| 324 | 331 | } |
| 325 | 332 | |
| 333 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 334 | ||
| 335 | template <class _T1, class _T2> | |
| 336 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 337 | common_comparison_category_t< | |
| 338 | __synth_three_way_result<_T1>, | |
| 339 | __synth_three_way_result<_T2> > | |
| 340 | operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) | |
| 341 | { | |
| 342 | if (auto __c = _VSTD::__synth_three_way(__x.first, __y.first); __c != 0) { | |
| 343 | return __c; | |
| 344 | } | |
| 345 | return _VSTD::__synth_three_way(__x.second, __y.second); | |
| 346 | } | |
| 347 | ||
| 348 | #else // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 349 | ||
| 326 | 350 | template <class _T1, class _T2> |
| 327 | 351 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 328 | 352 | bool |
| ... | ... | @@ -363,6 +387,8 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) |
| 363 | 387 | return !(__y < __x); |
| 364 | 388 | } |
| 365 | 389 | |
| 390 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 391 | ||
| 366 | 392 | template <class _T1, class _T2> |
| 367 | 393 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 368 | 394 | typename enable_if |
| ... | ... | @@ -414,13 +440,13 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > |
| 414 | 440 | template <class _T1, class _T2> |
| 415 | 441 | struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > |
| 416 | 442 | { |
| 417 | typedef _LIBCPP_NODEBUG_TYPE _T1 type; | |
| 443 | typedef _LIBCPP_NODEBUG _T1 type; | |
| 418 | 444 | }; |
| 419 | 445 | |
| 420 | 446 | template <class _T1, class _T2> |
| 421 | 447 | struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > |
| 422 | 448 | { |
| 423 | typedef _LIBCPP_NODEBUG_TYPE _T2 type; | |
| 449 | typedef _LIBCPP_NODEBUG _T2 type; | |
| 424 | 450 | }; |
| 425 | 451 | |
| 426 | 452 | template <size_t _Ip> struct __get_pair; |
| ... | ... | @@ -580,6 +606,4 @@ constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT |
| 580 | 606 | |
| 581 | 607 | _LIBCPP_END_NAMESPACE_STD |
| 582 | 608 | |
| 583 | _LIBCPP_POP_MACROS | |
| 584 | ||
| 585 | 609 | #endif // _LIBCPP___UTILITY_PAIR_H |
lib/libcxx/include/__utility/piecewise_construct.h+1-6| ... | ... | @@ -15,20 +15,15 @@ |
| 15 | 15 | #pragma GCC system_header |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | _LIBCPP_PUSH_MACROS | |
| 19 | #include <__undef_macros> | |
| 20 | ||
| 21 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 19 | |
| 23 | 20 | struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t { explicit piecewise_construct_t() = default; }; |
| 24 | 21 | #if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) |
| 25 | 22 | extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); |
| 26 | 23 | #else |
| 27 | /* _LIBCPP_INLINE_VAR */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); | |
| 24 | /* inline */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); | |
| 28 | 25 | #endif |
| 29 | 26 | |
| 30 | 27 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 28 | |
| 32 | _LIBCPP_POP_MACROS | |
| 33 | ||
| 34 | 29 | #endif // _LIBCPP___UTILITY_PIECEWISE_CONSTRUCT_H |
lib/libcxx/include/__utility/priority_tag.h created+26| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___UTILITY_PRIORITY_TAG_H | |
| 10 | #define _LIBCPP___UTILITY_PRIORITY_TAG_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstddef> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template<size_t _Ip> struct __priority_tag : __priority_tag<_Ip - 1> {}; | |
| 22 | template<> struct __priority_tag<0> {}; | |
| 23 | ||
| 24 | _LIBCPP_END_NAMESPACE_STD | |
| 25 | ||
| 26 | #endif // _LIBCPP___UTILITY_PRIORITY_TAG_H |
lib/libcxx/include/__utility/rel_ops.h+1-6| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | namespace rel_ops |
| ... | ... | @@ -58,10 +55,8 @@ operator>=(const _Tp& __x, const _Tp& __y) |
| 58 | 55 | return !(__x < __y); |
| 59 | 56 | } |
| 60 | 57 | |
| 61 | } // rel_ops | |
| 58 | } // namespace rel_ops | |
| 62 | 59 | |
| 63 | 60 | _LIBCPP_END_NAMESPACE_STD |
| 64 | 61 | |
| 65 | _LIBCPP_POP_MACROS | |
| 66 | ||
| 67 | 62 | #endif // _LIBCPP___UTILITY_REL_OPS_H |
lib/libcxx/include/__utility/swap.h+1-6| ... | ... | @@ -12,16 +12,13 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__utility/declval.h> |
| 14 | 14 | #include <__utility/move.h> |
| 15 | #include <type_traits> | |
| 16 | 15 | #include <cstddef> |
| 16 | #include <type_traits> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | 19 | #pragma GCC system_header |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 23 | |
| 27 | 24 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -50,6 +47,4 @@ swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::v |
| 50 | 47 | |
| 51 | 48 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 49 | |
| 53 | _LIBCPP_POP_MACROS | |
| 54 | ||
| 55 | 50 | #endif // _LIBCPP___UTILITY_SWAP_H |
lib/libcxx/include/__utility/to_underlying.h+1-6| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------- __utility/to_underlying.h --------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -17,9 +17,6 @@ |
| 17 | 17 | #pragma GCC system_header |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | _LIBCPP_PUSH_MACROS | |
| 21 | #include <__undef_macros> | |
| 22 | ||
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | 22 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -40,6 +37,4 @@ to_underlying(_Tp __val) noexcept { |
| 40 | 37 | |
| 41 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 39 | |
| 43 | _LIBCPP_POP_MACROS | |
| 44 | ||
| 45 | 40 | #endif // _LIBCPP___UTILITY_TO_UNDERLYING_H |
lib/libcxx/include/__utility/transaction.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___UTILITY_TRANSACTION_H | |
| 10 | #define _LIBCPP___UTILITY_TRANSACTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__utility/exchange.h> | |
| 14 | #include <__utility/move.h> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | #pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | // __transaction is a helper class for writing code with the strong exception guarantee. | |
| 24 | // | |
| 25 | // When writing code that can throw an exception, one can store rollback instructions in a | |
| 26 | // transaction so that if an exception is thrown at any point during the lifetime of the | |
| 27 | // transaction, it will be rolled back automatically. When the transaction is done, one | |
| 28 | // must mark it as being complete so it isn't rolled back when the transaction is destroyed. | |
| 29 | // | |
| 30 | // Transactions are not default constructible, they can't be copied or assigned to, but | |
| 31 | // they can be moved around for convenience. | |
| 32 | // | |
| 33 | // __transaction can help greatly simplify code that would normally be cluttered by | |
| 34 | // `#if _LIBCPP_NO_EXCEPTIONS`. For example: | |
| 35 | // | |
| 36 | // template <class Iterator, class Size, class OutputIterator> | |
| 37 | // Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) { | |
| 38 | // typedef typename iterator_traits<Iterator>::value_type value_type; | |
| 39 | // __transaction transaction([start=out, &out] { | |
| 40 | // std::destroy(start, out); | |
| 41 | // }); | |
| 42 | // | |
| 43 | // for (; n > 0; ++iter, ++out, --n) { | |
| 44 | // ::new ((void*)std::addressof(*out)) value_type(*iter); | |
| 45 | // } | |
| 46 | // transaction.__complete(); | |
| 47 | // return out; | |
| 48 | // } | |
| 49 | // | |
| 50 | template <class _Rollback> | |
| 51 | struct __transaction { | |
| 52 | __transaction() = delete; | |
| 53 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI | |
| 55 | _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __transaction(_Rollback __rollback) | |
| 56 | : __rollback_(_VSTD::move(__rollback)) | |
| 57 | , __completed_(false) | |
| 58 | { } | |
| 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI | |
| 61 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __transaction(__transaction&& __other) | |
| 62 | _NOEXCEPT_(is_nothrow_move_constructible<_Rollback>::value) | |
| 63 | : __rollback_(_VSTD::move(__other.__rollback_)) | |
| 64 | , __completed_(__other.__completed_) | |
| 65 | { | |
| 66 | __other.__completed_ = true; | |
| 67 | } | |
| 68 | ||
| 69 | __transaction(__transaction const&) = delete; | |
| 70 | __transaction& operator=(__transaction const&) = delete; | |
| 71 | __transaction& operator=(__transaction&&) = delete; | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI | |
| 74 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __complete() _NOEXCEPT { | |
| 75 | __completed_ = true; | |
| 76 | } | |
| 77 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI | |
| 79 | _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__transaction() { | |
| 80 | if (!__completed_) | |
| 81 | __rollback_(); | |
| 82 | } | |
| 83 | ||
| 84 | private: | |
| 85 | _Rollback __rollback_; | |
| 86 | bool __completed_; | |
| 87 | }; | |
| 88 | ||
| 89 | _LIBCPP_END_NAMESPACE_STD | |
| 90 | ||
| 91 | #endif // _LIBCPP___UTILITY_TRANSACTION_H |
lib/libcxx/include/__variant/monostate.h-5| ... | ... | @@ -18,9 +18,6 @@ |
| 18 | 18 | #pragma GCC system_header |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 22 | |
| 26 | 23 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -60,6 +57,4 @@ struct _LIBCPP_TEMPLATE_VIS hash<monostate> { |
| 60 | 57 | |
| 61 | 58 | _LIBCPP_END_NAMESPACE_STD |
| 62 | 59 | |
| 63 | _LIBCPP_POP_MACROS | |
| 64 | ||
| 65 | 60 | #endif // _LIBCPP___VARIANT_MONOSTATE_H |
lib/libcxx/include/algorithm+22-12| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- algorithm ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -18,6 +18,14 @@ |
| 18 | 18 | namespace std |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | namespace ranges { | |
| 22 | template <class I1, class I2> | |
| 23 | struct in_in_result; // since C++20 | |
| 24 | ||
| 25 | template <class I1, class I2, class O> | |
| 26 | struct in_in_out_result; // since C++20 | |
| 27 | } | |
| 28 | ||
| 21 | 29 | template <class InputIterator, class Predicate> |
| 22 | 30 | constexpr bool // constexpr in C++20 |
| 23 | 31 | all_of(InputIterator first, InputIterator last, Predicate pred); |
| ... | ... | @@ -641,19 +649,23 @@ template <class BidirectionalIterator, class Compare> |
| 641 | 649 | constexpr bool // constexpr in C++20 |
| 642 | 650 | prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); |
| 643 | 651 | |
| 652 | namespace ranges { | |
| 653 | // [algorithms.results], algorithm result types | |
| 654 | template<class InputIterator, class OutputIterator> | |
| 655 | struct in_out_result; | |
| 656 | } | |
| 657 | ||
| 644 | 658 | } // std |
| 645 | 659 | |
| 646 | 660 | */ |
| 647 | 661 | |
| 662 | #include <__bits> // __libcpp_clz | |
| 648 | 663 | #include <__config> |
| 649 | 664 | #include <__debug> |
| 650 | #include <__bits> // __libcpp_clz | |
| 651 | 665 | #include <cstddef> |
| 652 | 666 | #include <cstring> |
| 653 | 667 | #include <functional> |
| 654 | 668 | #include <initializer_list> |
| 655 | #include <utility> // needed to provide swap_ranges. | |
| 656 | #include <memory> | |
| 657 | 669 | #include <iterator> |
| 658 | 670 | #include <memory> |
| 659 | 671 | #include <type_traits> |
| ... | ... | @@ -675,8 +687,8 @@ template <class BidirectionalIterator, class Compare> |
| 675 | 687 | #include <__algorithm/count_if.h> |
| 676 | 688 | #include <__algorithm/equal.h> |
| 677 | 689 | #include <__algorithm/equal_range.h> |
| 678 | #include <__algorithm/fill_n.h> | |
| 679 | 690 | #include <__algorithm/fill.h> |
| 691 | #include <__algorithm/fill_n.h> | |
| 680 | 692 | #include <__algorithm/find.h> |
| 681 | 693 | #include <__algorithm/find_end.h> |
| 682 | 694 | #include <__algorithm/find_first_of.h> |
| ... | ... | @@ -684,9 +696,12 @@ template <class BidirectionalIterator, class Compare> |
| 684 | 696 | #include <__algorithm/find_if_not.h> |
| 685 | 697 | #include <__algorithm/for_each.h> |
| 686 | 698 | #include <__algorithm/for_each_n.h> |
| 687 | #include <__algorithm/generate_n.h> | |
| 688 | 699 | #include <__algorithm/generate.h> |
| 700 | #include <__algorithm/generate_n.h> | |
| 689 | 701 | #include <__algorithm/half_positive.h> |
| 702 | #include <__algorithm/in_in_out_result.h> | |
| 703 | #include <__algorithm/in_in_result.h> | |
| 704 | #include <__algorithm/in_out_result.h> | |
| 690 | 705 | #include <__algorithm/includes.h> |
| 691 | 706 | #include <__algorithm/inplace_merge.h> |
| 692 | 707 | #include <__algorithm/is_heap.h> |
| ... | ... | @@ -749,8 +764,8 @@ template <class BidirectionalIterator, class Compare> |
| 749 | 764 | #include <__algorithm/stable_sort.h> |
| 750 | 765 | #include <__algorithm/swap_ranges.h> |
| 751 | 766 | #include <__algorithm/transform.h> |
| 752 | #include <__algorithm/unique_copy.h> | |
| 753 | 767 | #include <__algorithm/unique.h> |
| 768 | #include <__algorithm/unique_copy.h> | |
| 754 | 769 | #include <__algorithm/unwrap_iter.h> |
| 755 | 770 | #include <__algorithm/upper_bound.h> |
| 756 | 771 | |
| ... | ... | @@ -758,11 +773,6 @@ template <class BidirectionalIterator, class Compare> |
| 758 | 773 | #pragma GCC system_header |
| 759 | 774 | #endif |
| 760 | 775 | |
| 761 | _LIBCPP_PUSH_MACROS | |
| 762 | #include <__undef_macros> | |
| 763 | ||
| 764 | _LIBCPP_POP_MACROS | |
| 765 | ||
| 766 | 776 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
| 767 | 777 | # include <__pstl_algorithm> |
| 768 | 778 | #endif |
lib/libcxx/include/any+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------ any -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/array+3-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- array -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -356,9 +356,9 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> |
| 356 | 356 | }; |
| 357 | 357 | |
| 358 | 358 | |
| 359 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 359 | #if _LIBCPP_STD_VER >= 17 | |
| 360 | 360 | template<class _Tp, class... _Args, |
| 361 | class = _EnableIf<__all<_IsSame<_Tp, _Args>::value...>::value> | |
| 361 | class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> | |
| 362 | 362 | > |
| 363 | 363 | array(_Tp, _Args...) |
| 364 | 364 | -> array<_Tp, 1 + sizeof...(_Args)>; |
lib/libcxx/include/atomic+208-328| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- atomic -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -263,196 +263,137 @@ struct atomic<T*> |
| 263 | 263 | }; |
| 264 | 264 | |
| 265 | 265 | |
| 266 | template <class T> | |
| 267 | bool atomic_is_lock_free(const volatile atomic<T>* obj) noexcept; | |
| 268 | ||
| 269 | template <class T> | |
| 270 | bool atomic_is_lock_free(const atomic<T>* obj) noexcept; | |
| 271 | ||
| 272 | template <class T> | |
| 273 | void atomic_store(volatile atomic<T>* obj, T desr) noexcept; | |
| 274 | ||
| 275 | template <class T> | |
| 276 | void atomic_store(atomic<T>* obj, T desr) noexcept; | |
| 277 | ||
| 278 | template <class T> | |
| 279 | void atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; | |
| 280 | ||
| 281 | template <class T> | |
| 282 | void atomic_store_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; | |
| 283 | ||
| 284 | template <class T> | |
| 285 | T atomic_load(const volatile atomic<T>* obj) noexcept; | |
| 286 | ||
| 287 | template <class T> | |
| 288 | T atomic_load(const atomic<T>* obj) noexcept; | |
| 289 | ||
| 290 | template <class T> | |
| 291 | T atomic_load_explicit(const volatile atomic<T>* obj, memory_order m) noexcept; | |
| 292 | ||
| 293 | template <class T> | |
| 294 | T atomic_load_explicit(const atomic<T>* obj, memory_order m) noexcept; | |
| 295 | ||
| 296 | template <class T> | |
| 297 | T atomic_exchange(volatile atomic<T>* obj, T desr) noexcept; | |
| 298 | ||
| 299 | template <class T> | |
| 300 | T atomic_exchange(atomic<T>* obj, T desr) noexcept; | |
| 301 | ||
| 302 | template <class T> | |
| 303 | T atomic_exchange_explicit(volatile atomic<T>* obj, T desr, memory_order m) noexcept; | |
| 304 | ||
| 305 | template <class T> | |
| 306 | T atomic_exchange_explicit(atomic<T>* obj, T desr, memory_order m) noexcept; | |
| 307 | ||
| 308 | template <class T> | |
| 309 | bool atomic_compare_exchange_weak(volatile atomic<T>* obj, T* expc, T desr) noexcept; | |
| 310 | ||
| 311 | template <class T> | |
| 312 | bool atomic_compare_exchange_weak(atomic<T>* obj, T* expc, T desr) noexcept; | |
| 313 | ||
| 314 | template <class T> | |
| 315 | bool atomic_compare_exchange_strong(volatile atomic<T>* obj, T* expc, T desr) noexcept; | |
| 316 | ||
| 317 | template <class T> | |
| 318 | bool atomic_compare_exchange_strong(atomic<T>* obj, T* expc, T desr) noexcept; | |
| 319 | ||
| 320 | template <class T> | |
| 321 | bool atomic_compare_exchange_weak_explicit(volatile atomic<T>* obj, T* expc, | |
| 322 | T desr, | |
| 323 | memory_order s, memory_order f) noexcept; | |
| 324 | ||
| 325 | template <class T> | |
| 326 | bool atomic_compare_exchange_weak_explicit(atomic<T>* obj, T* expc, T desr, | |
| 327 | memory_order s, memory_order f) noexcept; | |
| 328 | ||
| 329 | template <class T> | |
| 330 | bool atomic_compare_exchange_strong_explicit(volatile atomic<T>* obj, | |
| 331 | T* expc, T desr, | |
| 332 | memory_order s, memory_order f) noexcept; | |
| 333 | ||
| 334 | template <class T> | |
| 335 | bool atomic_compare_exchange_strong_explicit(atomic<T>* obj, T* expc, | |
| 336 | T desr, | |
| 337 | memory_order s, memory_order f) noexcept; | |
| 338 | ||
| 339 | template <class T> | |
| 340 | void atomic_wait(const volatile atomic<T>* obj, T old) noexcept; | |
| 341 | ||
| 342 | template <class T> | |
| 343 | void atomic_wait(const atomic<T>* obj, T old) noexcept; | |
| 344 | ||
| 345 | template <class T> | |
| 346 | void atomic_wait_explicit(const volatile atomic<T>* obj, T old, memory_order m) noexcept; | |
| 347 | ||
| 348 | template <class T> | |
| 349 | void atomic_wait_explicit(const atomic<T>* obj, T old, memory_order m) noexcept; | |
| 350 | ||
| 351 | template <class T> | |
| 352 | void atomic_one(volatile atomic<T>* obj) noexcept; | |
| 353 | ||
| 354 | template <class T> | |
| 355 | void atomic_one(atomic<T>* obj) noexcept; | |
| 356 | ||
| 357 | template <class T> | |
| 358 | void atomic_all(volatile atomic<T>* obj) noexcept; | |
| 359 | ||
| 360 | template <class T> | |
| 361 | void atomic_all(atomic<T>* obj) noexcept; | |
| 362 | ||
| 363 | template <class Integral> | |
| 364 | Integral atomic_fetch_add(volatile atomic<Integral>* obj, Integral op) noexcept; | |
| 365 | ||
| 366 | template <class Integral> | |
| 367 | Integral atomic_fetch_add(atomic<Integral>* obj, Integral op) noexcept; | |
| 368 | ||
| 369 | template <class Integral> | |
| 370 | Integral atomic_fetch_add_explicit(volatile atomic<Integral>* obj, Integral op, | |
| 371 | memory_order m) noexcept; | |
| 372 | template <class Integral> | |
| 373 | Integral atomic_fetch_add_explicit(atomic<Integral>* obj, Integral op, | |
| 374 | memory_order m) noexcept; | |
| 375 | template <class Integral> | |
| 376 | Integral atomic_fetch_sub(volatile atomic<Integral>* obj, Integral op) noexcept; | |
| 377 | ||
| 378 | template <class Integral> | |
| 379 | Integral atomic_fetch_sub(atomic<Integral>* obj, Integral op) noexcept; | |
| 380 | ||
| 381 | template <class Integral> | |
| 382 | Integral atomic_fetch_sub_explicit(volatile atomic<Integral>* obj, Integral op, | |
| 383 | memory_order m) noexcept; | |
| 384 | ||
| 385 | template <class Integral> | |
| 386 | Integral atomic_fetch_sub_explicit(atomic<Integral>* obj, Integral op, | |
| 387 | memory_order m) noexcept; | |
| 388 | ||
| 389 | template <class Integral> | |
| 390 | Integral atomic_fetch_and(volatile atomic<Integral>* obj, Integral op) noexcept; | |
| 391 | ||
| 392 | template <class Integral> | |
| 393 | Integral atomic_fetch_and(atomic<Integral>* obj, Integral op) noexcept; | |
| 394 | ||
| 395 | template <class Integral> | |
| 396 | Integral atomic_fetch_and_explicit(volatile atomic<Integral>* obj, Integral op, | |
| 397 | memory_order m) noexcept; | |
| 398 | ||
| 399 | template <class Integral> | |
| 400 | Integral atomic_fetch_and_explicit(atomic<Integral>* obj, Integral op, | |
| 401 | memory_order m) noexcept; | |
| 402 | ||
| 403 | template <class Integral> | |
| 404 | Integral atomic_fetch_or(volatile atomic<Integral>* obj, Integral op) noexcept; | |
| 405 | ||
| 406 | template <class Integral> | |
| 407 | Integral atomic_fetch_or(atomic<Integral>* obj, Integral op) noexcept; | |
| 408 | ||
| 409 | template <class Integral> | |
| 410 | Integral atomic_fetch_or_explicit(volatile atomic<Integral>* obj, Integral op, | |
| 411 | memory_order m) noexcept; | |
| 412 | ||
| 413 | template <class Integral> | |
| 414 | Integral atomic_fetch_or_explicit(atomic<Integral>* obj, Integral op, | |
| 415 | memory_order m) noexcept; | |
| 416 | ||
| 417 | template <class Integral> | |
| 418 | Integral atomic_fetch_xor(volatile atomic<Integral>* obj, Integral op) noexcept; | |
| 419 | ||
| 420 | template <class Integral> | |
| 421 | Integral atomic_fetch_xor(atomic<Integral>* obj, Integral op) noexcept; | |
| 422 | ||
| 423 | template <class Integral> | |
| 424 | Integral atomic_fetch_xor_explicit(volatile atomic<Integral>* obj, Integral op, | |
| 425 | memory_order m) noexcept; | |
| 426 | ||
| 427 | template <class Integral> | |
| 428 | Integral atomic_fetch_xor_explicit(atomic<Integral>* obj, Integral op, | |
| 429 | memory_order m) noexcept; | |
| 430 | ||
| 431 | template <class T> | |
| 432 | T* atomic_fetch_add(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; | |
| 433 | ||
| 434 | template <class T> | |
| 435 | T* atomic_fetch_add(atomic<T*>* obj, ptrdiff_t op) noexcept; | |
| 436 | ||
| 437 | template <class T> | |
| 438 | T* atomic_fetch_add_explicit(volatile atomic<T*>* obj, ptrdiff_t op, | |
| 439 | memory_order m) noexcept; | |
| 440 | ||
| 441 | template <class T> | |
| 442 | T* atomic_fetch_add_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; | |
| 443 | ||
| 444 | template <class T> | |
| 445 | T* atomic_fetch_sub(volatile atomic<T*>* obj, ptrdiff_t op) noexcept; | |
| 446 | ||
| 447 | template <class T> | |
| 448 | T* atomic_fetch_sub(atomic<T*>* obj, ptrdiff_t op) noexcept; | |
| 449 | ||
| 450 | template <class T> | |
| 451 | T* atomic_fetch_sub_explicit(volatile atomic<T*>* obj, ptrdiff_t op, | |
| 452 | memory_order m) noexcept; | |
| 453 | ||
| 454 | template <class T> | |
| 455 | T* atomic_fetch_sub_explicit(atomic<T*>* obj, ptrdiff_t op, memory_order m) noexcept; | |
| 266 | // [atomics.nonmembers], non-member functions | |
| 267 | template<class T> | |
| 268 | bool atomic_is_lock_free(const volatile atomic<T>*) noexcept; | |
| 269 | template<class T> | |
| 270 | bool atomic_is_lock_free(const atomic<T>*) noexcept; | |
| 271 | template<class T> | |
| 272 | void atomic_store(volatile atomic<T>*, atomic<T>::value_type) noexcept; | |
| 273 | template<class T> | |
| 274 | void atomic_store(atomic<T>*, atomic<T>::value_type) noexcept; | |
| 275 | template<class T> | |
| 276 | void atomic_store_explicit(volatile atomic<T>*, atomic<T>::value_type, | |
| 277 | memory_order) noexcept; | |
| 278 | template<class T> | |
| 279 | void atomic_store_explicit(atomic<T>*, atomic<T>::value_type, | |
| 280 | memory_order) noexcept; | |
| 281 | template<class T> | |
| 282 | T atomic_load(const volatile atomic<T>*) noexcept; | |
| 283 | template<class T> | |
| 284 | T atomic_load(const atomic<T>*) noexcept; | |
| 285 | template<class T> | |
| 286 | T atomic_load_explicit(const volatile atomic<T>*, memory_order) noexcept; | |
| 287 | template<class T> | |
| 288 | T atomic_load_explicit(const atomic<T>*, memory_order) noexcept; | |
| 289 | template<class T> | |
| 290 | T atomic_exchange(volatile atomic<T>*, atomic<T>::value_type) noexcept; | |
| 291 | template<class T> | |
| 292 | T atomic_exchange(atomic<T>*, atomic<T>::value_type) noexcept; | |
| 293 | template<class T> | |
| 294 | T atomic_exchange_explicit(volatile atomic<T>*, atomic<T>::value_type, | |
| 295 | memory_order) noexcept; | |
| 296 | template<class T> | |
| 297 | T atomic_exchange_explicit(atomic<T>*, atomic<T>::value_type, | |
| 298 | memory_order) noexcept; | |
| 299 | template<class T> | |
| 300 | bool atomic_compare_exchange_weak(volatile atomic<T>*, atomic<T>::value_type*, | |
| 301 | atomic<T>::value_type) noexcept; | |
| 302 | template<class T> | |
| 303 | bool atomic_compare_exchange_weak(atomic<T>*, atomic<T>::value_type*, | |
| 304 | atomic<T>::value_type) noexcept; | |
| 305 | template<class T> | |
| 306 | bool atomic_compare_exchange_strong(volatile atomic<T>*, atomic<T>::value_type*, | |
| 307 | atomic<T>::value_type) noexcept; | |
| 308 | template<class T> | |
| 309 | bool atomic_compare_exchange_strong(atomic<T>*, atomic<T>::value_type*, | |
| 310 | atomic<T>::value_type) noexcept; | |
| 311 | template<class T> | |
| 312 | bool atomic_compare_exchange_weak_explicit(volatile atomic<T>*, atomic<T>::value_type*, | |
| 313 | atomic<T>::value_type, | |
| 314 | memory_order, memory_order) noexcept; | |
| 315 | template<class T> | |
| 316 | bool atomic_compare_exchange_weak_explicit(atomic<T>*, atomic<T>::value_type*, | |
| 317 | atomic<T>::value_type, | |
| 318 | memory_order, memory_order) noexcept; | |
| 319 | template<class T> | |
| 320 | bool atomic_compare_exchange_strong_explicit(volatile atomic<T>*, atomic<T>::value_type*, | |
| 321 | atomic<T>::value_type, | |
| 322 | memory_order, memory_order) noexcept; | |
| 323 | template<class T> | |
| 324 | bool atomic_compare_exchange_strong_explicit(atomic<T>*, atomic<T>::value_type*, | |
| 325 | atomic<T>::value_type, | |
| 326 | memory_order, memory_order) noexcept; | |
| 327 | ||
| 328 | template<class T> | |
| 329 | T atomic_fetch_add(volatile atomic<T>*, atomic<T>::difference_type) noexcept; | |
| 330 | template<class T> | |
| 331 | T atomic_fetch_add(atomic<T>*, atomic<T>::difference_type) noexcept; | |
| 332 | template<class T> | |
| 333 | T atomic_fetch_add_explicit(volatile atomic<T>*, atomic<T>::difference_type, | |
| 334 | memory_order) noexcept; | |
| 335 | template<class T> | |
| 336 | T atomic_fetch_add_explicit(atomic<T>*, atomic<T>::difference_type, | |
| 337 | memory_order) noexcept; | |
| 338 | template<class T> | |
| 339 | T atomic_fetch_sub(volatile atomic<T>*, atomic<T>::difference_type) noexcept; | |
| 340 | template<class T> | |
| 341 | T atomic_fetch_sub(atomic<T>*, atomic<T>::difference_type) noexcept; | |
| 342 | template<class T> | |
| 343 | T atomic_fetch_sub_explicit(volatile atomic<T>*, atomic<T>::difference_type, | |
| 344 | memory_order) noexcept; | |
| 345 | template<class T> | |
| 346 | T atomic_fetch_sub_explicit(atomic<T>*, atomic<T>::difference_type, | |
| 347 | memory_order) noexcept; | |
| 348 | template<class T> | |
| 349 | T atomic_fetch_and(volatile atomic<T>*, atomic<T>::value_type) noexcept; | |
| 350 | template<class T> | |
| 351 | T atomic_fetch_and(atomic<T>*, atomic<T>::value_type) noexcept; | |
| 352 | template<class T> | |
| 353 | T atomic_fetch_and_explicit(volatile atomic<T>*, atomic<T>::value_type, | |
| 354 | memory_order) noexcept; | |
| 355 | template<class T> | |
| 356 | T atomic_fetch_and_explicit(atomic<T>*, atomic<T>::value_type, | |
| 357 | memory_order) noexcept; | |
| 358 | template<class T> | |
| 359 | T atomic_fetch_or(volatile atomic<T>*, atomic<T>::value_type) noexcept; | |
| 360 | template<class T> | |
| 361 | T atomic_fetch_or(atomic<T>*, atomic<T>::value_type) noexcept; | |
| 362 | template<class T> | |
| 363 | T atomic_fetch_or_explicit(volatile atomic<T>*, atomic<T>::value_type, | |
| 364 | memory_order) noexcept; | |
| 365 | template<class T> | |
| 366 | T atomic_fetch_or_explicit(atomic<T>*, atomic<T>::value_type, | |
| 367 | memory_order) noexcept; | |
| 368 | template<class T> | |
| 369 | T atomic_fetch_xor(volatile atomic<T>*, atomic<T>::value_type) noexcept; | |
| 370 | template<class T> | |
| 371 | T atomic_fetch_xor(atomic<T>*, atomic<T>::value_type) noexcept; | |
| 372 | template<class T> | |
| 373 | T atomic_fetch_xor_explicit(volatile atomic<T>*, atomic<T>::value_type, | |
| 374 | memory_order) noexcept; | |
| 375 | template<class T> | |
| 376 | T atomic_fetch_xor_explicit(atomic<T>*, atomic<T>::value_type, | |
| 377 | memory_order) noexcept; | |
| 378 | ||
| 379 | template<class T> | |
| 380 | void atomic_wait(const volatile atomic<T>*, atomic<T>::value_type); | |
| 381 | template<class T> | |
| 382 | void atomic_wait(const atomic<T>*, atomic<T>::value_type); | |
| 383 | template<class T> | |
| 384 | void atomic_wait_explicit(const volatile atomic<T>*, atomic<T>::value_type, | |
| 385 | memory_order); | |
| 386 | template<class T> | |
| 387 | void atomic_wait_explicit(const atomic<T>*, atomic<T>::value_type, | |
| 388 | memory_order); | |
| 389 | template<class T> | |
| 390 | void atomic_notify_one(volatile atomic<T>*); | |
| 391 | template<class T> | |
| 392 | void atomic_notify_one(atomic<T>*); | |
| 393 | template<class T> | |
| 394 | void atomic_notify_all(volatile atomic<T>*); | |
| 395 | template<class T> | |
| 396 | void atomic_notify_all(atomic<T>*); | |
| 456 | 397 | |
| 457 | 398 | // Atomics for standard typedef types |
| 458 | 399 | |
| ... | ... | @@ -564,10 +505,10 @@ void atomic_signal_fence(memory_order m) noexcept; |
| 564 | 505 | // deprecated |
| 565 | 506 | |
| 566 | 507 | template <class T> |
| 567 | void atomic_init(volatile atomic<T>* obj, typename atomic<T>::value_type desr) noexcept; | |
| 508 | void atomic_init(volatile atomic<T>* obj, atomic<T>::value_type desr) noexcept; | |
| 568 | 509 | |
| 569 | 510 | template <class T> |
| 570 | void atomic_init(atomic<T>* obj, typename atomic<T>::value_type desr) noexcept; | |
| 511 | void atomic_init(atomic<T>* obj, atomic<T>::value_type desr) noexcept; | |
| 571 | 512 | |
| 572 | 513 | #define ATOMIC_VAR_INIT(value) see below |
| 573 | 514 | |
| ... | ... | @@ -579,20 +520,22 @@ template <class T> |
| 579 | 520 | |
| 580 | 521 | #include <__availability> |
| 581 | 522 | #include <__config> |
| 582 | #include <__threading_support> | |
| 523 | #include <__thread/poll_with_backoff.h> | |
| 524 | #include <__thread/timed_backoff_policy.h> | |
| 583 | 525 | #include <cstddef> |
| 584 | 526 | #include <cstdint> |
| 585 | 527 | #include <cstring> |
| 586 | 528 | #include <type_traits> |
| 587 | 529 | #include <version> |
| 588 | 530 | |
| 531 | #ifndef _LIBCPP_HAS_NO_THREADS | |
| 532 | # include <__threading_support> | |
| 533 | #endif | |
| 534 | ||
| 589 | 535 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 590 | 536 | #pragma GCC system_header |
| 591 | 537 | #endif |
| 592 | 538 | |
| 593 | #ifdef _LIBCPP_HAS_NO_THREADS | |
| 594 | # error <atomic> is not supported on this single threaded system | |
| 595 | #endif | |
| 596 | 539 | #ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 597 | 540 | # error <atomic> is not implemented |
| 598 | 541 | #endif |
| ... | ... | @@ -1473,7 +1416,9 @@ template<> struct __cxx_is_always_lock_free<char8_t> { enum { __value = 2 == ATO |
| 1473 | 1416 | #endif |
| 1474 | 1417 | template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; }; |
| 1475 | 1418 | template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; }; |
| 1419 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1476 | 1420 | template<> struct __cxx_is_always_lock_free<wchar_t> { enum { __value = 2 == ATOMIC_WCHAR_T_LOCK_FREE }; }; |
| 1421 | #endif | |
| 1477 | 1422 | template<> struct __cxx_is_always_lock_free<short> { enum { __value = 2 == ATOMIC_SHORT_LOCK_FREE }; }; |
| 1478 | 1423 | template<> struct __cxx_is_always_lock_free<unsigned short> { enum { __value = 2 == ATOMIC_SHORT_LOCK_FREE }; }; |
| 1479 | 1424 | template<> struct __cxx_is_always_lock_free<int> { enum { __value = 2 == ATOMIC_INT_LOCK_FREE }; }; |
| ... | ... | @@ -1496,13 +1441,10 @@ template <typename _Tp, |
| 1496 | 1441 | typename _Base = __cxx_atomic_base_impl<_Tp> > |
| 1497 | 1442 | #endif //_LIBCPP_ATOMIC_ONLY_USE_BUILTINS |
| 1498 | 1443 | struct __cxx_atomic_impl : public _Base { |
| 1499 | ||
| 1500 | #if _GNUC_VER >= 501 | |
| 1501 | 1444 | static_assert(is_trivially_copyable<_Tp>::value, |
| 1502 | "std::atomic<Tp> requires that 'Tp' be a trivially copyable type"); | |
| 1503 | #endif | |
| 1445 | "std::atomic<T> requires that 'T' be a trivially copyable type"); | |
| 1504 | 1446 | |
| 1505 | _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT _LIBCPP_DEFAULT | |
| 1447 | _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT = default; | |
| 1506 | 1448 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT |
| 1507 | 1449 | : _Base(value) {} |
| 1508 | 1450 | }; |
| ... | ... | @@ -1515,6 +1457,16 @@ struct __cxx_atomic_impl : public _Base { |
| 1515 | 1457 | |
| 1516 | 1458 | using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>; |
| 1517 | 1459 | |
| 1460 | #if defined(_LIBCPP_HAS_NO_THREADS) | |
| 1461 | # define _LIBCPP_HAS_NO_PLATFORM_WAIT | |
| 1462 | #endif | |
| 1463 | ||
| 1464 | // TODO: | |
| 1465 | // _LIBCPP_HAS_NO_PLATFORM_WAIT is currently a "dead" macro, in the sense that | |
| 1466 | // it is not tied anywhere into the build system or even documented. We should | |
| 1467 | // clean it up because it is technically never defined except when threads are | |
| 1468 | // disabled. We should clean it up in its own changeset in case we break "bad" | |
| 1469 | // users. | |
| 1518 | 1470 | #ifndef _LIBCPP_HAS_NO_PLATFORM_WAIT |
| 1519 | 1471 | |
| 1520 | 1472 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*); |
| ... | ... | @@ -1566,7 +1518,12 @@ _LIBCPP_INLINE_VISIBILITY void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> co |
| 1566 | 1518 | template <class _Atp, class _Fn> |
| 1567 | 1519 | _LIBCPP_INLINE_VISIBILITY bool __cxx_atomic_wait(_Atp*, _Fn && __test_fn) |
| 1568 | 1520 | { |
| 1569 | return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); | |
| 1521 | #if defined(_LIBCPP_HAS_NO_THREADS) | |
| 1522 | using _Policy = __spinning_backoff_policy; | |
| 1523 | #else | |
| 1524 | using _Policy = __libcpp_timed_backoff_policy; | |
| 1525 | #endif | |
| 1526 | return __libcpp_thread_poll_with_backoff(__test_fn, _Policy()); | |
| 1570 | 1527 | } |
| 1571 | 1528 | |
| 1572 | 1529 | #endif // _LIBCPP_HAS_NO_PLATFORM_WAIT |
| ... | ... | @@ -1688,7 +1645,7 @@ struct __atomic_base // false |
| 1688 | 1645 | __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {} |
| 1689 | 1646 | #else |
| 1690 | 1647 | _LIBCPP_INLINE_VISIBILITY |
| 1691 | __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT | |
| 1648 | __atomic_base() _NOEXCEPT = default; | |
| 1692 | 1649 | #endif |
| 1693 | 1650 | |
| 1694 | 1651 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| ... | ... | @@ -1717,7 +1674,7 @@ struct __atomic_base<_Tp, true> |
| 1717 | 1674 | typedef __atomic_base<_Tp, false> __base; |
| 1718 | 1675 | |
| 1719 | 1676 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1720 | __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT | |
| 1677 | __atomic_base() _NOEXCEPT = default; | |
| 1721 | 1678 | |
| 1722 | 1679 | _LIBCPP_INLINE_VISIBILITY |
| 1723 | 1680 | _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {} |
| ... | ... | @@ -1806,7 +1763,7 @@ struct atomic |
| 1806 | 1763 | atomic() = default; |
| 1807 | 1764 | #else |
| 1808 | 1765 | _LIBCPP_INLINE_VISIBILITY |
| 1809 | atomic() _NOEXCEPT _LIBCPP_DEFAULT | |
| 1766 | atomic() _NOEXCEPT = default; | |
| 1810 | 1767 | #endif |
| 1811 | 1768 | |
| 1812 | 1769 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1834,7 +1791,7 @@ struct atomic<_Tp*> |
| 1834 | 1791 | typedef ptrdiff_t difference_type; |
| 1835 | 1792 | |
| 1836 | 1793 | _LIBCPP_INLINE_VISIBILITY |
| 1837 | atomic() _NOEXCEPT _LIBCPP_DEFAULT | |
| 1794 | atomic() _NOEXCEPT = default; | |
| 1838 | 1795 | |
| 1839 | 1796 | _LIBCPP_INLINE_VISIBILITY |
| 1840 | 1797 | _LIBCPP_CONSTEXPR atomic(_Tp* __d) _NOEXCEPT : __base(__d) {} |
| ... | ... | @@ -1847,19 +1804,32 @@ struct atomic<_Tp*> |
| 1847 | 1804 | {__base::store(__d); return __d;} |
| 1848 | 1805 | |
| 1849 | 1806 | _LIBCPP_INLINE_VISIBILITY |
| 1850 | _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) | |
| 1851 | volatile _NOEXCEPT | |
| 1852 | {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);} | |
| 1807 | _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 1808 | // __atomic_fetch_add accepts function pointers, guard against them. | |
| 1809 | static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed"); | |
| 1810 | return __cxx_atomic_fetch_add(&this->__a_, __op, __m); | |
| 1811 | } | |
| 1812 | ||
| 1853 | 1813 | _LIBCPP_INLINE_VISIBILITY |
| 1854 | _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT | |
| 1855 | {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);} | |
| 1814 | _Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 1815 | // __atomic_fetch_add accepts function pointers, guard against them. | |
| 1816 | static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed"); | |
| 1817 | return __cxx_atomic_fetch_add(&this->__a_, __op, __m); | |
| 1818 | } | |
| 1819 | ||
| 1856 | 1820 | _LIBCPP_INLINE_VISIBILITY |
| 1857 | _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) | |
| 1858 | volatile _NOEXCEPT | |
| 1859 | {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);} | |
| 1821 | _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT { | |
| 1822 | // __atomic_fetch_add accepts function pointers, guard against them. | |
| 1823 | static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed"); | |
| 1824 | return __cxx_atomic_fetch_sub(&this->__a_, __op, __m); | |
| 1825 | } | |
| 1826 | ||
| 1860 | 1827 | _LIBCPP_INLINE_VISIBILITY |
| 1861 | _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT | |
| 1862 | {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);} | |
| 1828 | _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT { | |
| 1829 | // __atomic_fetch_add accepts function pointers, guard against them. | |
| 1830 | static_assert(!is_function<typename remove_pointer<_Tp>::type>::value, "Pointer to function isn't allowed"); | |
| 1831 | return __cxx_atomic_fetch_sub(&this->__a_, __op, __m); | |
| 1832 | } | |
| 1863 | 1833 | |
| 1864 | 1834 | _LIBCPP_INLINE_VISIBILITY |
| 1865 | 1835 | _Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);} |
| ... | ... | @@ -2195,11 +2165,7 @@ void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT |
| 2195 | 2165 | |
| 2196 | 2166 | template <class _Tp> |
| 2197 | 2167 | _LIBCPP_INLINE_VISIBILITY |
| 2198 | typename enable_if | |
| 2199 | < | |
| 2200 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2201 | _Tp | |
| 2202 | >::type | |
| 2168 | _Tp | |
| 2203 | 2169 | atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT |
| 2204 | 2170 | { |
| 2205 | 2171 | return __o->fetch_add(__op); |
| ... | ... | @@ -2207,70 +2173,24 @@ atomic_fetch_add(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_typ |
| 2207 | 2173 | |
| 2208 | 2174 | template <class _Tp> |
| 2209 | 2175 | _LIBCPP_INLINE_VISIBILITY |
| 2210 | typename enable_if | |
| 2211 | < | |
| 2212 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2213 | _Tp | |
| 2214 | >::type | |
| 2176 | _Tp | |
| 2215 | 2177 | atomic_fetch_add(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT |
| 2216 | 2178 | { |
| 2217 | 2179 | return __o->fetch_add(__op); |
| 2218 | 2180 | } |
| 2219 | 2181 | |
| 2220 | template <class _Tp> | |
| 2221 | _LIBCPP_INLINE_VISIBILITY | |
| 2222 | _Tp* | |
| 2223 | atomic_fetch_add(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT | |
| 2224 | { | |
| 2225 | return __o->fetch_add(__op); | |
| 2226 | } | |
| 2227 | ||
| 2228 | template <class _Tp> | |
| 2229 | _LIBCPP_INLINE_VISIBILITY | |
| 2230 | _Tp* | |
| 2231 | atomic_fetch_add(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT | |
| 2232 | { | |
| 2233 | return __o->fetch_add(__op); | |
| 2234 | } | |
| 2235 | ||
| 2236 | 2182 | // atomic_fetch_add_explicit |
| 2237 | 2183 | |
| 2238 | 2184 | template <class _Tp> |
| 2239 | 2185 | _LIBCPP_INLINE_VISIBILITY |
| 2240 | typename enable_if | |
| 2241 | < | |
| 2242 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2243 | _Tp | |
| 2244 | >::type | |
| 2245 | atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2186 | _Tp atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2246 | 2187 | { |
| 2247 | 2188 | return __o->fetch_add(__op, __m); |
| 2248 | 2189 | } |
| 2249 | 2190 | |
| 2250 | 2191 | template <class _Tp> |
| 2251 | 2192 | _LIBCPP_INLINE_VISIBILITY |
| 2252 | typename enable_if | |
| 2253 | < | |
| 2254 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2255 | _Tp | |
| 2256 | >::type | |
| 2257 | atomic_fetch_add_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2258 | { | |
| 2259 | return __o->fetch_add(__op, __m); | |
| 2260 | } | |
| 2261 | ||
| 2262 | template <class _Tp> | |
| 2263 | _LIBCPP_INLINE_VISIBILITY | |
| 2264 | _Tp* | |
| 2265 | atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2266 | { | |
| 2267 | return __o->fetch_add(__op, __m); | |
| 2268 | } | |
| 2269 | ||
| 2270 | template <class _Tp> | |
| 2271 | _LIBCPP_INLINE_VISIBILITY | |
| 2272 | _Tp* | |
| 2273 | atomic_fetch_add_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2193 | _Tp atomic_fetch_add_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2274 | 2194 | { |
| 2275 | 2195 | return __o->fetch_add(__op, __m); |
| 2276 | 2196 | } |
| ... | ... | @@ -2279,40 +2199,14 @@ atomic_fetch_add_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_t |
| 2279 | 2199 | |
| 2280 | 2200 | template <class _Tp> |
| 2281 | 2201 | _LIBCPP_INLINE_VISIBILITY |
| 2282 | typename enable_if | |
| 2283 | < | |
| 2284 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2285 | _Tp | |
| 2286 | >::type | |
| 2287 | atomic_fetch_sub(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT | |
| 2288 | { | |
| 2289 | return __o->fetch_sub(__op); | |
| 2290 | } | |
| 2291 | ||
| 2292 | template <class _Tp> | |
| 2293 | _LIBCPP_INLINE_VISIBILITY | |
| 2294 | typename enable_if | |
| 2295 | < | |
| 2296 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2297 | _Tp | |
| 2298 | >::type | |
| 2299 | atomic_fetch_sub(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT | |
| 2300 | { | |
| 2301 | return __o->fetch_sub(__op); | |
| 2302 | } | |
| 2303 | ||
| 2304 | template <class _Tp> | |
| 2305 | _LIBCPP_INLINE_VISIBILITY | |
| 2306 | _Tp* | |
| 2307 | atomic_fetch_sub(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT | |
| 2202 | _Tp atomic_fetch_sub(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT | |
| 2308 | 2203 | { |
| 2309 | 2204 | return __o->fetch_sub(__op); |
| 2310 | 2205 | } |
| 2311 | 2206 | |
| 2312 | 2207 | template <class _Tp> |
| 2313 | 2208 | _LIBCPP_INLINE_VISIBILITY |
| 2314 | _Tp* | |
| 2315 | atomic_fetch_sub(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) _NOEXCEPT | |
| 2209 | _Tp atomic_fetch_sub(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op) _NOEXCEPT | |
| 2316 | 2210 | { |
| 2317 | 2211 | return __o->fetch_sub(__op); |
| 2318 | 2212 | } |
| ... | ... | @@ -2321,40 +2215,14 @@ atomic_fetch_sub(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op) |
| 2321 | 2215 | |
| 2322 | 2216 | template <class _Tp> |
| 2323 | 2217 | _LIBCPP_INLINE_VISIBILITY |
| 2324 | typename enable_if | |
| 2325 | < | |
| 2326 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2327 | _Tp | |
| 2328 | >::type | |
| 2329 | atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2218 | _Tp atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2330 | 2219 | { |
| 2331 | 2220 | return __o->fetch_sub(__op, __m); |
| 2332 | 2221 | } |
| 2333 | 2222 | |
| 2334 | 2223 | template <class _Tp> |
| 2335 | 2224 | _LIBCPP_INLINE_VISIBILITY |
| 2336 | typename enable_if | |
| 2337 | < | |
| 2338 | is_integral<_Tp>::value && !is_same<_Tp, bool>::value && !is_const<_Tp>::value, | |
| 2339 | _Tp | |
| 2340 | >::type | |
| 2341 | atomic_fetch_sub_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2342 | { | |
| 2343 | return __o->fetch_sub(__op, __m); | |
| 2344 | } | |
| 2345 | ||
| 2346 | template <class _Tp> | |
| 2347 | _LIBCPP_INLINE_VISIBILITY | |
| 2348 | _Tp* | |
| 2349 | atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2350 | { | |
| 2351 | return __o->fetch_sub(__op, __m); | |
| 2352 | } | |
| 2353 | ||
| 2354 | template <class _Tp> | |
| 2355 | _LIBCPP_INLINE_VISIBILITY | |
| 2356 | _Tp* | |
| 2357 | atomic_fetch_sub_explicit(atomic<_Tp*>* __o, typename atomic<_Tp*>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2225 | _Tp atomic_fetch_sub_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference_type __op, memory_order __m) _NOEXCEPT | |
| 2358 | 2226 | { |
| 2359 | 2227 | return __o->fetch_sub(__op, __m); |
| 2360 | 2228 | } |
| ... | ... | @@ -2565,7 +2433,7 @@ typedef struct atomic_flag |
| 2565 | 2433 | atomic_flag() _NOEXCEPT : __a_(false) {} |
| 2566 | 2434 | #else |
| 2567 | 2435 | _LIBCPP_INLINE_VISIBILITY |
| 2568 | atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT | |
| 2436 | atomic_flag() _NOEXCEPT = default; | |
| 2569 | 2437 | #endif |
| 2570 | 2438 | |
| 2571 | 2439 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| ... | ... | @@ -2764,7 +2632,9 @@ typedef atomic<char8_t> atomic_char8_t; |
| 2764 | 2632 | #endif |
| 2765 | 2633 | typedef atomic<char16_t> atomic_char16_t; |
| 2766 | 2634 | typedef atomic<char32_t> atomic_char32_t; |
| 2635 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2767 | 2636 | typedef atomic<wchar_t> atomic_wchar_t; |
| 2637 | #endif | |
| 2768 | 2638 | |
| 2769 | 2639 | typedef atomic<int_least8_t> atomic_int_least8_t; |
| 2770 | 2640 | typedef atomic<uint_least8_t> atomic_uint_least8_t; |
| ... | ... | @@ -2822,14 +2692,24 @@ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::typ |
| 2822 | 2692 | typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free; |
| 2823 | 2693 | #else |
| 2824 | 2694 | // No signed/unsigned lock-free types |
| 2695 | #define _LIBCPP_NO_LOCK_FREE_TYPES | |
| 2825 | 2696 | #endif |
| 2826 | 2697 | |
| 2698 | #if !defined(_LIBCPP_NO_LOCK_FREE_TYPES) | |
| 2827 | 2699 | typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free; |
| 2828 | 2700 | typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; |
| 2701 | #endif | |
| 2829 | 2702 | |
| 2830 | 2703 | #define ATOMIC_FLAG_INIT {false} |
| 2831 | 2704 | #define ATOMIC_VAR_INIT(__v) {__v} |
| 2832 | 2705 | |
| 2706 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | |
| 2707 | # if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400 | |
| 2708 | # pragma clang deprecated(ATOMIC_FLAG_INIT) | |
| 2709 | # pragma clang deprecated(ATOMIC_VAR_INIT) | |
| 2710 | # endif | |
| 2711 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | |
| 2712 | ||
| 2833 | 2713 | _LIBCPP_END_NAMESPACE_STD |
| 2834 | 2714 | |
| 2835 | 2715 | #endif // _LIBCPP_ATOMIC |
lib/libcxx/include/barrier+2-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- barrier ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -47,6 +47,7 @@ namespace std |
| 47 | 47 | |
| 48 | 48 | #include <__availability> |
| 49 | 49 | #include <__config> |
| 50 | #include <__thread/timed_backoff_policy.h> | |
| 50 | 51 | #include <atomic> |
| 51 | 52 | #ifndef _LIBCPP_HAS_NO_TREE_BARRIER |
| 52 | 53 | # include <memory> |
lib/libcxx/include/bit+24-15| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------ bit ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -14,6 +14,13 @@ |
| 14 | 14 | bit synopsis |
| 15 | 15 | |
| 16 | 16 | namespace std { |
| 17 | // [bit.cast], bit_cast | |
| 18 | template<class To, class From> | |
| 19 | constexpr To bit_cast(const From& from) noexcept; // C++20 | |
| 20 | ||
| 21 | // [bit.byteswap], byteswap | |
| 22 | template<class T> | |
| 23 | constexpr T byteswap(T value) noexcept; // C++23 | |
| 17 | 24 | |
| 18 | 25 | // [bit.pow.two], integral powers of 2 |
| 19 | 26 | template <class T> |
| ... | ... | @@ -48,14 +55,16 @@ namespace std { |
| 48 | 55 | little = see below, // C++20 |
| 49 | 56 | big = see below, // C++20 |
| 50 | 57 | native = see below // C++20 |
| 51 | }; | |
| 58 | }; | |
| 52 | 59 | |
| 53 | 60 | } // namespace std |
| 54 | 61 | |
| 55 | 62 | */ |
| 56 | 63 | |
| 57 | #include <__config> | |
| 64 | #include <__bit/bit_cast.h> | |
| 65 | #include <__bit/byteswap.h> | |
| 58 | 66 | #include <__bits> // __libcpp_clz |
| 67 | #include <__config> | |
| 59 | 68 | #include <__debug> |
| 60 | 69 | #include <limits> |
| 61 | 70 | #include <type_traits> |
| ... | ... | @@ -222,7 +231,7 @@ bool __has_single_bit(_Tp __t) _NOEXCEPT |
| 222 | 231 | |
| 223 | 232 | template<class _Tp> |
| 224 | 233 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 225 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 234 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 226 | 235 | rotl(_Tp __t, unsigned int __cnt) noexcept |
| 227 | 236 | { |
| 228 | 237 | return __rotl(__t, __cnt); |
| ... | ... | @@ -230,7 +239,7 @@ rotl(_Tp __t, unsigned int __cnt) noexcept |
| 230 | 239 | |
| 231 | 240 | template<class _Tp> |
| 232 | 241 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 233 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 242 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 234 | 243 | rotr(_Tp __t, unsigned int __cnt) noexcept |
| 235 | 244 | { |
| 236 | 245 | return __rotr(__t, __cnt); |
| ... | ... | @@ -238,7 +247,7 @@ rotr(_Tp __t, unsigned int __cnt) noexcept |
| 238 | 247 | |
| 239 | 248 | template<class _Tp> |
| 240 | 249 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 241 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 250 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 242 | 251 | countl_zero(_Tp __t) noexcept |
| 243 | 252 | { |
| 244 | 253 | return __countl_zero(__t); |
| ... | ... | @@ -246,7 +255,7 @@ countl_zero(_Tp __t) noexcept |
| 246 | 255 | |
| 247 | 256 | template<class _Tp> |
| 248 | 257 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 249 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 258 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 250 | 259 | countl_one(_Tp __t) noexcept |
| 251 | 260 | { |
| 252 | 261 | return __countl_one(__t); |
| ... | ... | @@ -254,7 +263,7 @@ countl_one(_Tp __t) noexcept |
| 254 | 263 | |
| 255 | 264 | template<class _Tp> |
| 256 | 265 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 257 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 266 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 258 | 267 | countr_zero(_Tp __t) noexcept |
| 259 | 268 | { |
| 260 | 269 | return __countr_zero(__t); |
| ... | ... | @@ -262,7 +271,7 @@ countr_zero(_Tp __t) noexcept |
| 262 | 271 | |
| 263 | 272 | template<class _Tp> |
| 264 | 273 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 265 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 274 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 266 | 275 | countr_one(_Tp __t) noexcept |
| 267 | 276 | { |
| 268 | 277 | return __countr_one(__t); |
| ... | ... | @@ -270,7 +279,7 @@ countr_one(_Tp __t) noexcept |
| 270 | 279 | |
| 271 | 280 | template<class _Tp> |
| 272 | 281 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 273 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 282 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 274 | 283 | popcount(_Tp __t) noexcept |
| 275 | 284 | { |
| 276 | 285 | return __popcount(__t); |
| ... | ... | @@ -278,7 +287,7 @@ popcount(_Tp __t) noexcept |
| 278 | 287 | |
| 279 | 288 | template <class _Tp> |
| 280 | 289 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 281 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, bool> | |
| 290 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, bool> | |
| 282 | 291 | has_single_bit(_Tp __t) noexcept |
| 283 | 292 | { |
| 284 | 293 | return __has_single_bit(__t); |
| ... | ... | @@ -286,7 +295,7 @@ has_single_bit(_Tp __t) noexcept |
| 286 | 295 | |
| 287 | 296 | template <class _Tp> |
| 288 | 297 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 289 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 298 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 290 | 299 | bit_floor(_Tp __t) noexcept |
| 291 | 300 | { |
| 292 | 301 | return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t); |
| ... | ... | @@ -294,12 +303,12 @@ bit_floor(_Tp __t) noexcept |
| 294 | 303 | |
| 295 | 304 | template <class _Tp> |
| 296 | 305 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 297 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 306 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 298 | 307 | bit_ceil(_Tp __t) noexcept |
| 299 | 308 | { |
| 300 | 309 | if (__t < 2) return 1; |
| 301 | 310 | const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u)); |
| 302 | _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); | |
| 311 | _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); | |
| 303 | 312 | |
| 304 | 313 | if constexpr (sizeof(_Tp) >= sizeof(unsigned)) |
| 305 | 314 | return _Tp{1} << __n; |
| ... | ... | @@ -313,7 +322,7 @@ bit_ceil(_Tp __t) noexcept |
| 313 | 322 | |
| 314 | 323 | template <class _Tp> |
| 315 | 324 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 316 | _EnableIf<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 325 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 317 | 326 | bit_width(_Tp __t) noexcept |
| 318 | 327 | { |
| 319 | 328 | return __t == 0 ? 0 : __bit_log2(__t) + 1; |
lib/libcxx/include/bitset+4-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- bitset ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -112,14 +112,15 @@ template <size_t N> struct hash<std::bitset<N>>; |
| 112 | 112 | |
| 113 | 113 | */ |
| 114 | 114 | |
| 115 | #include <__config> | |
| 116 | 115 | #include <__bit_reference> |
| 116 | #include <__config> | |
| 117 | 117 | #include <__functional_base> |
| 118 | 118 | #include <climits> |
| 119 | 119 | #include <cstddef> |
| 120 | 120 | #include <iosfwd> |
| 121 | 121 | #include <stdexcept> |
| 122 | 122 | #include <string> |
| 123 | #include <version> | |
| 123 | 124 | |
| 124 | 125 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 125 | 126 | #pragma GCC system_header |
| ... | ... | @@ -679,7 +680,7 @@ public: |
| 679 | 680 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {} |
| 680 | 681 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 681 | 682 | bitset(unsigned long long __v) _NOEXCEPT : base(__v) {} |
| 682 | template<class _CharT, class = _EnableIf<_IsCharLikeType<_CharT>::value> > | |
| 683 | template<class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> > | |
| 683 | 684 | explicit bitset(const _CharT* __str, |
| 684 | 685 | typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, |
| 685 | 686 | _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); |
lib/libcxx/include/cassert+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- cassert -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/ccomplex+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- ccomplex ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cctype+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- cctype ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cerrno+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- cerrno ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cfenv+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- cfenv -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cfloat+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cfloat -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/charconv+46-90| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------ charconv ------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -27,10 +27,13 @@ namespace std { |
| 27 | 27 | struct to_chars_result { |
| 28 | 28 | char* ptr; |
| 29 | 29 | errc ec; |
| 30 | friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20 | |
| 30 | 31 | }; |
| 31 | 32 | |
| 32 | 33 | to_chars_result to_chars(char* first, char* last, see below value, |
| 33 | 34 | int base = 10); |
| 35 | to_chars_result to_chars(char* first, char* last, bool value, | |
| 36 | int base = 10) = delete; | |
| 34 | 37 | |
| 35 | 38 | to_chars_result to_chars(char* first, char* last, float value); |
| 36 | 39 | to_chars_result to_chars(char* first, char* last, double value); |
| ... | ... | @@ -54,6 +57,7 @@ namespace std { |
| 54 | 57 | struct from_chars_result { |
| 55 | 58 | const char* ptr; |
| 56 | 59 | errc ec; |
| 60 | friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20 | |
| 57 | 61 | }; |
| 58 | 62 | |
| 59 | 63 | from_chars_result from_chars(const char* first, const char* last, |
| ... | ... | @@ -74,9 +78,12 @@ namespace std { |
| 74 | 78 | */ |
| 75 | 79 | |
| 76 | 80 | #include <__availability> |
| 81 | #include <__bits> | |
| 82 | #include <__charconv/chars_format.h> | |
| 83 | #include <__charconv/from_chars_result.h> | |
| 84 | #include <__charconv/to_chars_result.h> | |
| 77 | 85 | #include <__config> |
| 78 | 86 | #include <__errc> |
| 79 | #include <__utility/to_underlying.h> | |
| 80 | 87 | #include <cmath> // for log2f |
| 81 | 88 | #include <cstdint> |
| 82 | 89 | #include <cstdlib> // for _LIBCPP_UNREACHABLE |
| ... | ... | @@ -98,73 +105,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 98 | 105 | namespace __itoa { |
| 99 | 106 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT; |
| 100 | 107 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT; |
| 101 | } | |
| 108 | } // namespace __itoa | |
| 102 | 109 | |
| 103 | 110 | #ifndef _LIBCPP_CXX03_LANG |
| 104 | 111 | |
| 105 | enum class _LIBCPP_ENUM_VIS chars_format | |
| 106 | { | |
| 107 | scientific = 0x1, | |
| 108 | fixed = 0x2, | |
| 109 | hex = 0x4, | |
| 110 | general = fixed | scientific | |
| 111 | }; | |
| 112 | ||
| 113 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 114 | operator~(chars_format __x) { | |
| 115 | return chars_format(~_VSTD::__to_underlying(__x)); | |
| 116 | } | |
| 117 | ||
| 118 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 119 | operator&(chars_format __x, chars_format __y) { | |
| 120 | return chars_format(_VSTD::__to_underlying(__x) & | |
| 121 | _VSTD::__to_underlying(__y)); | |
| 122 | } | |
| 123 | ||
| 124 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 125 | operator|(chars_format __x, chars_format __y) { | |
| 126 | return chars_format(_VSTD::__to_underlying(__x) | | |
| 127 | _VSTD::__to_underlying(__y)); | |
| 128 | } | |
| 129 | ||
| 130 | inline _LIBCPP_INLINE_VISIBILITY constexpr chars_format | |
| 131 | operator^(chars_format __x, chars_format __y) { | |
| 132 | return chars_format(_VSTD::__to_underlying(__x) ^ | |
| 133 | _VSTD::__to_underlying(__y)); | |
| 134 | } | |
| 135 | ||
| 136 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& | |
| 137 | operator&=(chars_format& __x, chars_format __y) { | |
| 138 | __x = __x & __y; | |
| 139 | return __x; | |
| 140 | } | |
| 141 | ||
| 142 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& | |
| 143 | operator|=(chars_format& __x, chars_format __y) { | |
| 144 | __x = __x | __y; | |
| 145 | return __x; | |
| 146 | } | |
| 147 | ||
| 148 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 chars_format& | |
| 149 | operator^=(chars_format& __x, chars_format __y) { | |
| 150 | __x = __x ^ __y; | |
| 151 | return __x; | |
| 152 | } | |
| 153 | ||
| 154 | struct _LIBCPP_TYPE_VIS to_chars_result | |
| 155 | { | |
| 156 | char* ptr; | |
| 157 | errc ec; | |
| 158 | }; | |
| 159 | ||
| 160 | struct _LIBCPP_TYPE_VIS from_chars_result | |
| 161 | { | |
| 162 | const char* ptr; | |
| 163 | errc ec; | |
| 164 | }; | |
| 165 | ||
| 166 | void to_chars(char*, char*, bool, int = 10) = delete; | |
| 167 | void from_chars(const char*, const char*, bool, int = 10) = delete; | |
| 112 | to_chars_result to_chars(char*, char*, bool, int = 10) = delete; | |
| 113 | from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete; | |
| 168 | 114 | |
| 169 | 115 | namespace __itoa |
| 170 | 116 | { |
| ... | ... | @@ -204,13 +150,11 @@ struct _LIBCPP_HIDDEN __traits_base |
| 204 | 150 | { |
| 205 | 151 | using type = uint64_t; |
| 206 | 152 | |
| 207 | #if !defined(_LIBCPP_COMPILER_MSVC) | |
| 208 | 153 | static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) |
| 209 | 154 | { |
| 210 | auto __t = (64 - __builtin_clzll(__v | 1)) * 1233 >> 12; | |
| 155 | auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | |
| 211 | 156 | return __t - (__v < __pow10_64[__t]) + 1; |
| 212 | 157 | } |
| 213 | #endif | |
| 214 | 158 | |
| 215 | 159 | _LIBCPP_AVAILABILITY_TO_CHARS |
| 216 | 160 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) |
| ... | ... | @@ -227,13 +171,11 @@ struct _LIBCPP_HIDDEN |
| 227 | 171 | { |
| 228 | 172 | using type = uint32_t; |
| 229 | 173 | |
| 230 | #if !defined(_LIBCPP_COMPILER_MSVC) | |
| 231 | 174 | static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) |
| 232 | 175 | { |
| 233 | auto __t = (32 - __builtin_clz(__v | 1)) * 1233 >> 12; | |
| 176 | auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | |
| 234 | 177 | return __t - (__v < __pow10_32[__t]) + 1; |
| 235 | 178 | } |
| 236 | #endif | |
| 237 | 179 | |
| 238 | 180 | _LIBCPP_AVAILABILITY_TO_CHARS |
| 239 | 181 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) |
| ... | ... | @@ -354,28 +296,10 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) |
| 354 | 296 | using __tx = __itoa::__traits<_Tp>; |
| 355 | 297 | auto __diff = __last - __first; |
| 356 | 298 | |
| 357 | #if !defined(_LIBCPP_COMPILER_MSVC) | |
| 358 | 299 | if (__tx::digits <= __diff || __tx::__width(__value) <= __diff) |
| 359 | 300 | return {__tx::__convert(__value, __first), errc(0)}; |
| 360 | 301 | else |
| 361 | 302 | return {__last, errc::value_too_large}; |
| 362 | #else | |
| 363 | if (__tx::digits <= __diff) | |
| 364 | return {__tx::__convert(__value, __first), {}}; | |
| 365 | else | |
| 366 | { | |
| 367 | char __buf[__tx::digits]; | |
| 368 | auto __p = __tx::__convert(__value, __buf); | |
| 369 | auto __len = __p - __buf; | |
| 370 | if (__len <= __diff) | |
| 371 | { | |
| 372 | _VSTD::memcpy(__first, __buf, __len); | |
| 373 | return {__first + __len, {}}; | |
| 374 | } | |
| 375 | else | |
| 376 | return {__last, errc::value_too_large}; | |
| 377 | } | |
| 378 | #endif | |
| 379 | 303 | } |
| 380 | 304 | |
| 381 | 305 | template <typename _Tp> |
| ... | ... | @@ -674,6 +598,38 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base) |
| 674 | 598 | return __from_chars_integral(__first, __last, __value, __base); |
| 675 | 599 | } |
| 676 | 600 | |
| 601 | // Floating-point implementation starts here. | |
| 602 | // Unlike the other parts of charconv this is only available in C++17 and newer. | |
| 603 | #if _LIBCPP_STD_VER > 14 | |
| 604 | ||
| 605 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 606 | to_chars_result to_chars(char* __first, char* __last, float __value); | |
| 607 | ||
| 608 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 609 | to_chars_result to_chars(char* __first, char* __last, double __value); | |
| 610 | ||
| 611 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 612 | to_chars_result to_chars(char* __first, char* __last, long double __value); | |
| 613 | ||
| 614 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 615 | to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt); | |
| 616 | ||
| 617 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 618 | to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt); | |
| 619 | ||
| 620 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 621 | to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt); | |
| 622 | ||
| 623 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 624 | to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision); | |
| 625 | ||
| 626 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 627 | to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision); | |
| 628 | ||
| 629 | _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_FUNC_VIS | |
| 630 | to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision); | |
| 631 | ||
| 632 | # endif // _LIBCPP_STD_VER > 14 | |
| 677 | 633 | #endif // _LIBCPP_CXX03_LANG |
| 678 | 634 | |
| 679 | 635 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/chrono+23-2278| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- chrono ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -148,11 +148,6 @@ template <class Clock, class Duration1, class Duration2> |
| 148 | 148 | |
| 149 | 149 | namespace chrono { |
| 150 | 150 | |
| 151 | ||
| 152 | template<class T> struct is_clock; // C++20 | |
| 153 | template<class T> inline constexpr bool is_clock_v = is_clock<T>::value; // C++20 | |
| 154 | ||
| 155 | ||
| 156 | 151 | // duration arithmetic |
| 157 | 152 | template <class Rep1, class Period1, class Rep2, class Period2> |
| 158 | 153 | constexpr |
| ... | ... | @@ -281,19 +276,23 @@ template <class Duration> |
| 281 | 276 | using sys_seconds = sys_time<seconds>; // C++20 |
| 282 | 277 | using sys_days = sys_time<days>; // C++20 |
| 283 | 278 | |
| 284 | class utc_clock; // C++20 | |
| 285 | ||
| 286 | template <class Duration> | |
| 287 | using utc_time = time_point<utc_clock, Duration>; // C++20 | |
| 288 | using utc_seconds = utc_time<seconds>; // C++20 | |
| 279 | class file_clock // C++20 | |
| 280 | { | |
| 281 | public: | |
| 282 | typedef see-below rep; | |
| 283 | typedef nano period; | |
| 284 | typedef chrono::duration<rep, period> duration; | |
| 285 | typedef chrono::time_point<file_clock> time_point; | |
| 286 | static constexpr bool is_steady = false; | |
| 289 | 287 | |
| 290 | class tai_clock; // C++20 | |
| 288 | static time_point now() noexcept; | |
| 291 | 289 | |
| 292 | template <class Duration> | |
| 293 | using tai_time = time_point<tai_clock, Duration>; // C++20 | |
| 294 | using tai_seconds = tai_time<seconds>; // C++20 | |
| 290 | template<class Duration> | |
| 291 | static sys_time<see-below> to_sys(const file_time<Duration>&); | |
| 295 | 292 | |
| 296 | class file_clock; // C++20 | |
| 293 | template<class Duration> | |
| 294 | static file_time<see-below> from_sys(const sys_time<Duration>&); | |
| 295 | }; | |
| 297 | 296 | |
| 298 | 297 | template<class Duration> |
| 299 | 298 | using file_time = time_point<file_clock, Duration>; // C++20 |
| ... | ... | @@ -319,12 +318,6 @@ template<class Duration> |
| 319 | 318 | using local_seconds = local_time<seconds>; |
| 320 | 319 | using local_days = local_time<days>; |
| 321 | 320 | |
| 322 | // 25.7.9, time_point conversions template<class DestClock, class SourceClock> // C++20 | |
| 323 | struct clock_time_conversion; | |
| 324 | ||
| 325 | template<class DestClock, class SourceClock, class Duration> | |
| 326 | auto clock_cast(const time_point<SourceClock, Duration>& t); | |
| 327 | ||
| 328 | 321 | // 25.8.2, class last_spec // C++20 |
| 329 | 322 | struct last_spec; |
| 330 | 323 | |
| ... | ... | @@ -639,39 +632,12 @@ public: |
| 639 | 632 | constexpr precision to_duration() const noexcept; |
| 640 | 633 | }; |
| 641 | 634 | |
| 642 | template <class charT, class traits, class Duration> | |
| 643 | basic_ostream<charT, traits>& | |
| 644 | operator<<(basic_ostream<charT, traits>& os, hh_mm_ss<Duration> const& hms); | |
| 645 | ||
| 646 | 635 | // 26.10, 12/24 hour functions |
| 647 | 636 | constexpr bool is_am(hours const& h) noexcept; |
| 648 | 637 | constexpr bool is_pm(hours const& h) noexcept; |
| 649 | 638 | constexpr hours make12(const hours& h) noexcept; |
| 650 | 639 | constexpr hours make24(const hours& h, bool is_pm) noexcept; |
| 651 | 640 | |
| 652 | ||
| 653 | // 25.10.2, time zone database // C++20 | |
| 654 | struct tzdb; | |
| 655 | class tzdb_list; | |
| 656 | ||
| 657 | // 25.10.2.3, time zone database access // C++20 | |
| 658 | const tzdb& get_tzdb(); | |
| 659 | tzdb_list& get_tzdb_list(); | |
| 660 | const time_zone* locate_zone(string_view tz_name); | |
| 661 | const time_zone* current_zone(); | |
| 662 | ||
| 663 | // 25.10.2.4, remote time zone database support // C++20 | |
| 664 | const tzdb& reload_tzdb(); | |
| 665 | string remote_version(); | |
| 666 | ||
| 667 | // 25.10.3, exception classes // C++20 | |
| 668 | class nonexistent_local_time; | |
| 669 | class ambiguous_local_time; | |
| 670 | ||
| 671 | // 25.10.4, information classes // C++20 | |
| 672 | struct sys_info; | |
| 673 | struct local_info; | |
| 674 | ||
| 675 | 641 | // 25.10.5, class time_zone // C++20 |
| 676 | 642 | enum class choose {earliest, latest}; |
| 677 | 643 | class time_zone; |
| ... | ... | @@ -682,101 +648,6 @@ bool operator>(const time_zone& x, const time_zone& y) noexcept; |
| 682 | 648 | bool operator<=(const time_zone& x, const time_zone& y) noexcept; |
| 683 | 649 | bool operator>=(const time_zone& x, const time_zone& y) noexcept; |
| 684 | 650 | |
| 685 | // 25.10.6, class template zoned_traits // C++20 | |
| 686 | template<class T> struct zoned_traits; | |
| 687 | ||
| 688 | // 25.10.7, class template zoned_time // C++20 | |
| 689 | template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time; | |
| 690 | using zoned_seconds = zoned_time<seconds>; | |
| 691 | ||
| 692 | template<class Duration1, class Duration2, class TimeZonePtr> | |
| 693 | bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, | |
| 694 | const zoned_time<Duration2, TimeZonePtr>& y); | |
| 695 | template<class Duration1, class Duration2, class TimeZonePtr> | |
| 696 | bool operator!=(const zoned_time<Duration1, TimeZonePtr>& x, | |
| 697 | const zoned_time<Duration2, TimeZonePtr>& y); | |
| 698 | ||
| 699 | // 25.10.8, leap second support // C++20 | |
| 700 | class leap; | |
| 701 | ||
| 702 | bool operator==(const leap& x, const leap& y); | |
| 703 | bool operator!=(const leap& x, const leap& y); | |
| 704 | bool operator< (const leap& x, const leap& y); | |
| 705 | bool operator> (const leap& x, const leap& y); | |
| 706 | bool operator<=(const leap& x, const leap& y); | |
| 707 | bool operator>=(const leap& x, const leap& y); | |
| 708 | template<class Duration> | |
| 709 | bool operator==(const leap& x, const sys_time<Duration>& y); | |
| 710 | template<class Duration> | |
| 711 | bool operator==(const sys_time<Duration>& x, const leap& y); | |
| 712 | template<class Duration> | |
| 713 | bool operator!=(const leap& x, const sys_time<Duration>& y); | |
| 714 | template<class Duration> | |
| 715 | bool operator!=(const sys_time<Duration>& x, const leap& y); | |
| 716 | template<class Duration> | |
| 717 | bool operator< (const leap& x, const sys_time<Duration>& y); | |
| 718 | template<class Duration> | |
| 719 | bool operator< (const sys_time<Duration>& x, const leap& y); | |
| 720 | template<class Duration> | |
| 721 | bool operator> (const leap& x, const sys_time<Duration>& y); | |
| 722 | template<class Duration> | |
| 723 | bool operator> (const sys_time<Duration>& x, const leap& y); | |
| 724 | template<class Duration> | |
| 725 | bool operator<=(const leap& x, const sys_time<Duration>& y); | |
| 726 | template<class Duration> | |
| 727 | bool operator<=(const sys_time<Duration>& x, const leap& y); | |
| 728 | template<class Duration> | |
| 729 | bool operator>=(const leap& x, const sys_time<Duration>& y); | |
| 730 | template<class Duration> | |
| 731 | bool operator>=(const sys_time<Duration>& x, const leap& y); | |
| 732 | ||
| 733 | // 25.10.9, class link // C++20 | |
| 734 | class link; | |
| 735 | bool operator==(const link& x, const link& y); | |
| 736 | bool operator!=(const link& x, const link& y); | |
| 737 | bool operator< (const link& x, const link& y); | |
| 738 | bool operator> (const link& x, const link& y); | |
| 739 | bool operator<=(const link& x, const link& y); | |
| 740 | bool operator>=(const link& x, const link& y); | |
| 741 | ||
| 742 | // 25.11, formatting // C++20 | |
| 743 | template<class charT, class Streamable> | |
| 744 | basic_string<charT> | |
| 745 | format(const charT* fmt, const Streamable& s); | |
| 746 | ||
| 747 | template<class charT, class Streamable> | |
| 748 | basic_string<charT> | |
| 749 | format(const locale& loc, const charT* fmt, const Streamable& s); | |
| 750 | ||
| 751 | template<class charT, class traits, class Alloc, class Streamable> | |
| 752 | basic_string<charT, traits, Alloc> | |
| 753 | format(const basic_string<charT, traits, Alloc>& fmt, const Streamable& s); | |
| 754 | ||
| 755 | template<class charT, class traits, class Alloc, class Streamable> | |
| 756 | basic_string<charT, traits, Alloc> | |
| 757 | format(const locale& loc, const basic_string<charT, traits, Alloc>& fmt, | |
| 758 | const Streamable& s); | |
| 759 | ||
| 760 | // 25.12, parsing // C++20 | |
| 761 | template<class charT, class traits, class Alloc, class Parsable> | |
| 762 | unspecified | |
| 763 | parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp); | |
| 764 | ||
| 765 | template<class charT, class traits, class Alloc, class Parsable> | |
| 766 | unspecified | |
| 767 | parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, | |
| 768 | basic_string<charT, traits, Alloc>& abbrev); | |
| 769 | ||
| 770 | template<class charT, class traits, class Alloc, class Parsable> | |
| 771 | unspecified | |
| 772 | parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, | |
| 773 | minutes& offset); | |
| 774 | ||
| 775 | template<class charT, class traits, class Alloc, class Parsable> | |
| 776 | unspecified | |
| 777 | parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp, | |
| 778 | basic_string<charT, traits, Alloc>& abbrev, minutes& offset); | |
| 779 | ||
| 780 | 651 | // calendrical constants |
| 781 | 652 | inline constexpr last_spec last{}; // C++20 |
| 782 | 653 | inline constexpr chrono::weekday Sunday{0}; // C++20 |
| ... | ... | @@ -823,2146 +694,20 @@ constexpr chrono::year operator ""y(unsigned lo |
| 823 | 694 | } // std |
| 824 | 695 | */ |
| 825 | 696 | |
| 826 | #include <__availability> | |
| 697 | #include <__chrono/calendar.h> | |
| 698 | #include <__chrono/convert_to_timespec.h> | |
| 699 | #include <__chrono/duration.h> | |
| 700 | #include <__chrono/file_clock.h> | |
| 701 | #include <__chrono/high_resolution_clock.h> | |
| 702 | #include <__chrono/steady_clock.h> | |
| 703 | #include <__chrono/system_clock.h> | |
| 704 | #include <__chrono/time_point.h> | |
| 827 | 705 | #include <__config> |
| 828 | 706 | #include <compare> |
| 829 | #include <ctime> | |
| 830 | #include <limits> | |
| 831 | #include <ratio> | |
| 832 | #include <type_traits> | |
| 833 | 707 | #include <version> |
| 834 | 708 | |
| 835 | 709 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 836 | 710 | #pragma GCC system_header |
| 837 | 711 | #endif |
| 838 | 712 | |
| 839 | _LIBCPP_PUSH_MACROS | |
| 840 | #include <__undef_macros> | |
| 841 | ||
| 842 | #ifndef _LIBCPP_CXX03_LANG | |
| 843 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 844 | struct _FilesystemClock; | |
| 845 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 846 | #endif // !_LIBCPP_CXX03_LANG | |
| 847 | ||
| 848 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 849 | ||
| 850 | namespace chrono | |
| 851 | { | |
| 852 | ||
| 853 | template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TEMPLATE_VIS duration; | |
| 854 | ||
| 855 | template <class _Tp> | |
| 856 | struct __is_duration : false_type {}; | |
| 857 | ||
| 858 | template <class _Rep, class _Period> | |
| 859 | struct __is_duration<duration<_Rep, _Period> > : true_type {}; | |
| 860 | ||
| 861 | template <class _Rep, class _Period> | |
| 862 | struct __is_duration<const duration<_Rep, _Period> > : true_type {}; | |
| 863 | ||
| 864 | template <class _Rep, class _Period> | |
| 865 | struct __is_duration<volatile duration<_Rep, _Period> > : true_type {}; | |
| 866 | ||
| 867 | template <class _Rep, class _Period> | |
| 868 | struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; | |
| 869 | ||
| 870 | } // chrono | |
| 871 | ||
| 872 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 873 | struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, | |
| 874 | chrono::duration<_Rep2, _Period2> > | |
| 875 | { | |
| 876 | typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, | |
| 877 | typename __ratio_gcd<_Period1, _Period2>::type> type; | |
| 878 | }; | |
| 879 | ||
| 880 | namespace chrono { | |
| 881 | ||
| 882 | // duration_cast | |
| 883 | ||
| 884 | template <class _FromDuration, class _ToDuration, | |
| 885 | class _Period = typename ratio_divide<typename _FromDuration::period, typename _ToDuration::period>::type, | |
| 886 | bool = _Period::num == 1, | |
| 887 | bool = _Period::den == 1> | |
| 888 | struct __duration_cast; | |
| 889 | ||
| 890 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 891 | struct __duration_cast<_FromDuration, _ToDuration, _Period, true, true> | |
| 892 | { | |
| 893 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 894 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 895 | { | |
| 896 | return _ToDuration(static_cast<typename _ToDuration::rep>(__fd.count())); | |
| 897 | } | |
| 898 | }; | |
| 899 | ||
| 900 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 901 | struct __duration_cast<_FromDuration, _ToDuration, _Period, true, false> | |
| 902 | { | |
| 903 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 904 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 905 | { | |
| 906 | typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; | |
| 907 | return _ToDuration(static_cast<typename _ToDuration::rep>( | |
| 908 | static_cast<_Ct>(__fd.count()) / static_cast<_Ct>(_Period::den))); | |
| 909 | } | |
| 910 | }; | |
| 911 | ||
| 912 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 913 | struct __duration_cast<_FromDuration, _ToDuration, _Period, false, true> | |
| 914 | { | |
| 915 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 916 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 917 | { | |
| 918 | typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; | |
| 919 | return _ToDuration(static_cast<typename _ToDuration::rep>( | |
| 920 | static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num))); | |
| 921 | } | |
| 922 | }; | |
| 923 | ||
| 924 | template <class _FromDuration, class _ToDuration, class _Period> | |
| 925 | struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> | |
| 926 | { | |
| 927 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 928 | _ToDuration operator()(const _FromDuration& __fd) const | |
| 929 | { | |
| 930 | typedef typename common_type<typename _ToDuration::rep, typename _FromDuration::rep, intmax_t>::type _Ct; | |
| 931 | return _ToDuration(static_cast<typename _ToDuration::rep>( | |
| 932 | static_cast<_Ct>(__fd.count()) * static_cast<_Ct>(_Period::num) | |
| 933 | / static_cast<_Ct>(_Period::den))); | |
| 934 | } | |
| 935 | }; | |
| 936 | ||
| 937 | template <class _ToDuration, class _Rep, class _Period> | |
| 938 | inline _LIBCPP_INLINE_VISIBILITY | |
| 939 | _LIBCPP_CONSTEXPR | |
| 940 | typename enable_if | |
| 941 | < | |
| 942 | __is_duration<_ToDuration>::value, | |
| 943 | _ToDuration | |
| 944 | >::type | |
| 945 | duration_cast(const duration<_Rep, _Period>& __fd) | |
| 946 | { | |
| 947 | return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); | |
| 948 | } | |
| 949 | ||
| 950 | template <class _Rep> | |
| 951 | struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; | |
| 952 | ||
| 953 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 954 | template <class _Rep> | |
| 955 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool treat_as_floating_point_v | |
| 956 | = treat_as_floating_point<_Rep>::value; | |
| 957 | #endif | |
| 958 | ||
| 959 | template <class _Rep> | |
| 960 | struct _LIBCPP_TEMPLATE_VIS duration_values | |
| 961 | { | |
| 962 | public: | |
| 963 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT {return _Rep(0);} | |
| 964 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT {return numeric_limits<_Rep>::max();} | |
| 965 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() _NOEXCEPT {return numeric_limits<_Rep>::lowest();} | |
| 966 | }; | |
| 967 | ||
| 968 | #if _LIBCPP_STD_VER > 14 | |
| 969 | template <class _ToDuration, class _Rep, class _Period> | |
| 970 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 971 | typename enable_if | |
| 972 | < | |
| 973 | __is_duration<_ToDuration>::value, | |
| 974 | _ToDuration | |
| 975 | >::type | |
| 976 | floor(const duration<_Rep, _Period>& __d) | |
| 977 | { | |
| 978 | _ToDuration __t = duration_cast<_ToDuration>(__d); | |
| 979 | if (__t > __d) | |
| 980 | __t = __t - _ToDuration{1}; | |
| 981 | return __t; | |
| 982 | } | |
| 983 | ||
| 984 | template <class _ToDuration, class _Rep, class _Period> | |
| 985 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 986 | typename enable_if | |
| 987 | < | |
| 988 | __is_duration<_ToDuration>::value, | |
| 989 | _ToDuration | |
| 990 | >::type | |
| 991 | ceil(const duration<_Rep, _Period>& __d) | |
| 992 | { | |
| 993 | _ToDuration __t = duration_cast<_ToDuration>(__d); | |
| 994 | if (__t < __d) | |
| 995 | __t = __t + _ToDuration{1}; | |
| 996 | return __t; | |
| 997 | } | |
| 998 | ||
| 999 | template <class _ToDuration, class _Rep, class _Period> | |
| 1000 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1001 | typename enable_if | |
| 1002 | < | |
| 1003 | __is_duration<_ToDuration>::value, | |
| 1004 | _ToDuration | |
| 1005 | >::type | |
| 1006 | round(const duration<_Rep, _Period>& __d) | |
| 1007 | { | |
| 1008 | _ToDuration __lower = floor<_ToDuration>(__d); | |
| 1009 | _ToDuration __upper = __lower + _ToDuration{1}; | |
| 1010 | auto __lowerDiff = __d - __lower; | |
| 1011 | auto __upperDiff = __upper - __d; | |
| 1012 | if (__lowerDiff < __upperDiff) | |
| 1013 | return __lower; | |
| 1014 | if (__lowerDiff > __upperDiff) | |
| 1015 | return __upper; | |
| 1016 | return __lower.count() & 1 ? __upper : __lower; | |
| 1017 | } | |
| 1018 | #endif | |
| 1019 | ||
| 1020 | // duration | |
| 1021 | ||
| 1022 | template <class _Rep, class _Period> | |
| 1023 | class _LIBCPP_TEMPLATE_VIS duration | |
| 1024 | { | |
| 1025 | static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); | |
| 1026 | static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); | |
| 1027 | static_assert(_Period::num > 0, "duration period must be positive"); | |
| 1028 | ||
| 1029 | template <class _R1, class _R2> | |
| 1030 | struct __no_overflow | |
| 1031 | { | |
| 1032 | private: | |
| 1033 | static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; | |
| 1034 | static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; | |
| 1035 | static const intmax_t __n1 = _R1::num / __gcd_n1_n2; | |
| 1036 | static const intmax_t __d1 = _R1::den / __gcd_d1_d2; | |
| 1037 | static const intmax_t __n2 = _R2::num / __gcd_n1_n2; | |
| 1038 | static const intmax_t __d2 = _R2::den / __gcd_d1_d2; | |
| 1039 | static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); | |
| 1040 | ||
| 1041 | template <intmax_t _Xp, intmax_t _Yp, bool __overflow> | |
| 1042 | struct __mul // __overflow == false | |
| 1043 | { | |
| 1044 | static const intmax_t value = _Xp * _Yp; | |
| 1045 | }; | |
| 1046 | ||
| 1047 | template <intmax_t _Xp, intmax_t _Yp> | |
| 1048 | struct __mul<_Xp, _Yp, true> | |
| 1049 | { | |
| 1050 | static const intmax_t value = 1; | |
| 1051 | }; | |
| 1052 | ||
| 1053 | public: | |
| 1054 | static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); | |
| 1055 | typedef ratio<__mul<__n1, __d2, !value>::value, | |
| 1056 | __mul<__n2, __d1, !value>::value> type; | |
| 1057 | }; | |
| 1058 | ||
| 1059 | public: | |
| 1060 | typedef _Rep rep; | |
| 1061 | typedef typename _Period::type period; | |
| 1062 | private: | |
| 1063 | rep __rep_; | |
| 1064 | public: | |
| 1065 | ||
| 1066 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1067 | #ifndef _LIBCPP_CXX03_LANG | |
| 1068 | duration() = default; | |
| 1069 | #else | |
| 1070 | duration() {} | |
| 1071 | #endif | |
| 1072 | ||
| 1073 | template <class _Rep2> | |
| 1074 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1075 | explicit duration(const _Rep2& __r, | |
| 1076 | typename enable_if | |
| 1077 | < | |
| 1078 | is_convertible<_Rep2, rep>::value && | |
| 1079 | (treat_as_floating_point<rep>::value || | |
| 1080 | !treat_as_floating_point<_Rep2>::value) | |
| 1081 | >::type* = nullptr) | |
| 1082 | : __rep_(__r) {} | |
| 1083 | ||
| 1084 | // conversions | |
| 1085 | template <class _Rep2, class _Period2> | |
| 1086 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1087 | duration(const duration<_Rep2, _Period2>& __d, | |
| 1088 | typename enable_if | |
| 1089 | < | |
| 1090 | __no_overflow<_Period2, period>::value && ( | |
| 1091 | treat_as_floating_point<rep>::value || | |
| 1092 | (__no_overflow<_Period2, period>::type::den == 1 && | |
| 1093 | !treat_as_floating_point<_Rep2>::value)) | |
| 1094 | >::type* = nullptr) | |
| 1095 | : __rep_(chrono::duration_cast<duration>(__d).count()) {} | |
| 1096 | ||
| 1097 | // observer | |
| 1098 | ||
| 1099 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR rep count() const {return __rep_;} | |
| 1100 | ||
| 1101 | // arithmetic | |
| 1102 | ||
| 1103 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator+() const {return typename common_type<duration>::type(*this);} | |
| 1104 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename common_type<duration>::type operator-() const {return typename common_type<duration>::type(-__rep_);} | |
| 1105 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator++() {++__rep_; return *this;} | |
| 1106 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator++(int) {return duration(__rep_++);} | |
| 1107 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator--() {--__rep_; return *this;} | |
| 1108 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration operator--(int) {return duration(__rep_--);} | |
| 1109 | ||
| 1110 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} | |
| 1111 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} | |
| 1112 | ||
| 1113 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator*=(const rep& rhs) {__rep_ *= rhs; return *this;} | |
| 1114 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator/=(const rep& rhs) {__rep_ /= rhs; return *this;} | |
| 1115 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const rep& rhs) {__rep_ %= rhs; return *this;} | |
| 1116 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator%=(const duration& rhs) {__rep_ %= rhs.count(); return *this;} | |
| 1117 | ||
| 1118 | // special values | |
| 1119 | ||
| 1120 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration zero() _NOEXCEPT {return duration(duration_values<rep>::zero());} | |
| 1121 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration min() _NOEXCEPT {return duration(duration_values<rep>::min());} | |
| 1122 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR duration max() _NOEXCEPT {return duration(duration_values<rep>::max());} | |
| 1123 | }; | |
| 1124 | ||
| 1125 | typedef duration<long long, nano> nanoseconds; | |
| 1126 | typedef duration<long long, micro> microseconds; | |
| 1127 | typedef duration<long long, milli> milliseconds; | |
| 1128 | typedef duration<long long > seconds; | |
| 1129 | typedef duration< long, ratio< 60> > minutes; | |
| 1130 | typedef duration< long, ratio<3600> > hours; | |
| 1131 | #if _LIBCPP_STD_VER > 17 | |
| 1132 | typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days; | |
| 1133 | typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks; | |
| 1134 | typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years; | |
| 1135 | typedef duration< int, ratio_divide<years::period, ratio<12>>> months; | |
| 1136 | #endif | |
| 1137 | // Duration == | |
| 1138 | ||
| 1139 | template <class _LhsDuration, class _RhsDuration> | |
| 1140 | struct __duration_eq | |
| 1141 | { | |
| 1142 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1143 | bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const | |
| 1144 | { | |
| 1145 | typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; | |
| 1146 | return _Ct(__lhs).count() == _Ct(__rhs).count(); | |
| 1147 | } | |
| 1148 | }; | |
| 1149 | ||
| 1150 | template <class _LhsDuration> | |
| 1151 | struct __duration_eq<_LhsDuration, _LhsDuration> | |
| 1152 | { | |
| 1153 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1154 | bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const | |
| 1155 | {return __lhs.count() == __rhs.count();} | |
| 1156 | }; | |
| 1157 | ||
| 1158 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1159 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1160 | _LIBCPP_CONSTEXPR | |
| 1161 | bool | |
| 1162 | operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1163 | { | |
| 1164 | return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); | |
| 1165 | } | |
| 1166 | ||
| 1167 | // Duration != | |
| 1168 | ||
| 1169 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1170 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1171 | _LIBCPP_CONSTEXPR | |
| 1172 | bool | |
| 1173 | operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1174 | { | |
| 1175 | return !(__lhs == __rhs); | |
| 1176 | } | |
| 1177 | ||
| 1178 | // Duration < | |
| 1179 | ||
| 1180 | template <class _LhsDuration, class _RhsDuration> | |
| 1181 | struct __duration_lt | |
| 1182 | { | |
| 1183 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1184 | bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const | |
| 1185 | { | |
| 1186 | typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct; | |
| 1187 | return _Ct(__lhs).count() < _Ct(__rhs).count(); | |
| 1188 | } | |
| 1189 | }; | |
| 1190 | ||
| 1191 | template <class _LhsDuration> | |
| 1192 | struct __duration_lt<_LhsDuration, _LhsDuration> | |
| 1193 | { | |
| 1194 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1195 | bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const | |
| 1196 | {return __lhs.count() < __rhs.count();} | |
| 1197 | }; | |
| 1198 | ||
| 1199 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1200 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1201 | _LIBCPP_CONSTEXPR | |
| 1202 | bool | |
| 1203 | operator< (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1204 | { | |
| 1205 | return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs); | |
| 1206 | } | |
| 1207 | ||
| 1208 | // Duration > | |
| 1209 | ||
| 1210 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1211 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1212 | _LIBCPP_CONSTEXPR | |
| 1213 | bool | |
| 1214 | operator> (const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1215 | { | |
| 1216 | return __rhs < __lhs; | |
| 1217 | } | |
| 1218 | ||
| 1219 | // Duration <= | |
| 1220 | ||
| 1221 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1222 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1223 | _LIBCPP_CONSTEXPR | |
| 1224 | bool | |
| 1225 | operator<=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1226 | { | |
| 1227 | return !(__rhs < __lhs); | |
| 1228 | } | |
| 1229 | ||
| 1230 | // Duration >= | |
| 1231 | ||
| 1232 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1233 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1234 | _LIBCPP_CONSTEXPR | |
| 1235 | bool | |
| 1236 | operator>=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1237 | { | |
| 1238 | return !(__lhs < __rhs); | |
| 1239 | } | |
| 1240 | ||
| 1241 | // Duration + | |
| 1242 | ||
| 1243 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1244 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1245 | _LIBCPP_CONSTEXPR | |
| 1246 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | |
| 1247 | operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1248 | { | |
| 1249 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | |
| 1250 | return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count()); | |
| 1251 | } | |
| 1252 | ||
| 1253 | // Duration - | |
| 1254 | ||
| 1255 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1256 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1257 | _LIBCPP_CONSTEXPR | |
| 1258 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | |
| 1259 | operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1260 | { | |
| 1261 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | |
| 1262 | return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count()); | |
| 1263 | } | |
| 1264 | ||
| 1265 | // Duration * | |
| 1266 | ||
| 1267 | template <class _Rep1, class _Period, class _Rep2> | |
| 1268 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1269 | _LIBCPP_CONSTEXPR | |
| 1270 | typename enable_if | |
| 1271 | < | |
| 1272 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 1273 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 1274 | >::type | |
| 1275 | operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) | |
| 1276 | { | |
| 1277 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 1278 | typedef duration<_Cr, _Period> _Cd; | |
| 1279 | return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); | |
| 1280 | } | |
| 1281 | ||
| 1282 | template <class _Rep1, class _Period, class _Rep2> | |
| 1283 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1284 | _LIBCPP_CONSTEXPR | |
| 1285 | typename enable_if | |
| 1286 | < | |
| 1287 | is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 1288 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 1289 | >::type | |
| 1290 | operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) | |
| 1291 | { | |
| 1292 | return __d * __s; | |
| 1293 | } | |
| 1294 | ||
| 1295 | // Duration / | |
| 1296 | ||
| 1297 | template <class _Rep1, class _Period, class _Rep2> | |
| 1298 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1299 | _LIBCPP_CONSTEXPR | |
| 1300 | typename enable_if | |
| 1301 | < | |
| 1302 | !__is_duration<_Rep2>::value && | |
| 1303 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 1304 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 1305 | >::type | |
| 1306 | operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) | |
| 1307 | { | |
| 1308 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 1309 | typedef duration<_Cr, _Period> _Cd; | |
| 1310 | return _Cd(_Cd(__d).count() / static_cast<_Cr>(__s)); | |
| 1311 | } | |
| 1312 | ||
| 1313 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1314 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1315 | _LIBCPP_CONSTEXPR | |
| 1316 | typename common_type<_Rep1, _Rep2>::type | |
| 1317 | operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1318 | { | |
| 1319 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Ct; | |
| 1320 | return _Ct(__lhs).count() / _Ct(__rhs).count(); | |
| 1321 | } | |
| 1322 | ||
| 1323 | // Duration % | |
| 1324 | ||
| 1325 | template <class _Rep1, class _Period, class _Rep2> | |
| 1326 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1327 | _LIBCPP_CONSTEXPR | |
| 1328 | typename enable_if | |
| 1329 | < | |
| 1330 | !__is_duration<_Rep2>::value && | |
| 1331 | is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, | |
| 1332 | duration<typename common_type<_Rep1, _Rep2>::type, _Period> | |
| 1333 | >::type | |
| 1334 | operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) | |
| 1335 | { | |
| 1336 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 1337 | typedef duration<_Cr, _Period> _Cd; | |
| 1338 | return _Cd(_Cd(__d).count() % static_cast<_Cr>(__s)); | |
| 1339 | } | |
| 1340 | ||
| 1341 | template <class _Rep1, class _Period1, class _Rep2, class _Period2> | |
| 1342 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1343 | _LIBCPP_CONSTEXPR | |
| 1344 | typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type | |
| 1345 | operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1346 | { | |
| 1347 | typedef typename common_type<_Rep1, _Rep2>::type _Cr; | |
| 1348 | typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd; | |
| 1349 | return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count())); | |
| 1350 | } | |
| 1351 | ||
| 1352 | ////////////////////////////////////////////////////////// | |
| 1353 | ///////////////////// time_point ///////////////////////// | |
| 1354 | ////////////////////////////////////////////////////////// | |
| 1355 | ||
| 1356 | template <class _Clock, class _Duration = typename _Clock::duration> | |
| 1357 | class _LIBCPP_TEMPLATE_VIS time_point | |
| 1358 | { | |
| 1359 | static_assert(__is_duration<_Duration>::value, | |
| 1360 | "Second template parameter of time_point must be a std::chrono::duration"); | |
| 1361 | public: | |
| 1362 | typedef _Clock clock; | |
| 1363 | typedef _Duration duration; | |
| 1364 | typedef typename duration::rep rep; | |
| 1365 | typedef typename duration::period period; | |
| 1366 | private: | |
| 1367 | duration __d_; | |
| 1368 | ||
| 1369 | public: | |
| 1370 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 time_point() : __d_(duration::zero()) {} | |
| 1371 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit time_point(const duration& __d) : __d_(__d) {} | |
| 1372 | ||
| 1373 | // conversions | |
| 1374 | template <class _Duration2> | |
| 1375 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1376 | time_point(const time_point<clock, _Duration2>& t, | |
| 1377 | typename enable_if | |
| 1378 | < | |
| 1379 | is_convertible<_Duration2, duration>::value | |
| 1380 | >::type* = nullptr) | |
| 1381 | : __d_(t.time_since_epoch()) {} | |
| 1382 | ||
| 1383 | // observer | |
| 1384 | ||
| 1385 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 duration time_since_epoch() const {return __d_;} | |
| 1386 | ||
| 1387 | // arithmetic | |
| 1388 | ||
| 1389 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator+=(const duration& __d) {__d_ += __d; return *this;} | |
| 1390 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 time_point& operator-=(const duration& __d) {__d_ -= __d; return *this;} | |
| 1391 | ||
| 1392 | // special values | |
| 1393 | ||
| 1394 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point min() _NOEXCEPT {return time_point(duration::min());} | |
| 1395 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR time_point max() _NOEXCEPT {return time_point(duration::max());} | |
| 1396 | }; | |
| 1397 | ||
| 1398 | } // chrono | |
| 1399 | ||
| 1400 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1401 | struct _LIBCPP_TEMPLATE_VIS common_type<chrono::time_point<_Clock, _Duration1>, | |
| 1402 | chrono::time_point<_Clock, _Duration2> > | |
| 1403 | { | |
| 1404 | typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; | |
| 1405 | }; | |
| 1406 | ||
| 1407 | namespace chrono { | |
| 1408 | ||
| 1409 | template <class _ToDuration, class _Clock, class _Duration> | |
| 1410 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1411 | time_point<_Clock, _ToDuration> | |
| 1412 | time_point_cast(const time_point<_Clock, _Duration>& __t) | |
| 1413 | { | |
| 1414 | return time_point<_Clock, _ToDuration>(chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); | |
| 1415 | } | |
| 1416 | ||
| 1417 | #if _LIBCPP_STD_VER > 14 | |
| 1418 | template <class _ToDuration, class _Clock, class _Duration> | |
| 1419 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1420 | typename enable_if | |
| 1421 | < | |
| 1422 | __is_duration<_ToDuration>::value, | |
| 1423 | time_point<_Clock, _ToDuration> | |
| 1424 | >::type | |
| 1425 | floor(const time_point<_Clock, _Duration>& __t) | |
| 1426 | { | |
| 1427 | return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; | |
| 1428 | } | |
| 1429 | ||
| 1430 | template <class _ToDuration, class _Clock, class _Duration> | |
| 1431 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1432 | typename enable_if | |
| 1433 | < | |
| 1434 | __is_duration<_ToDuration>::value, | |
| 1435 | time_point<_Clock, _ToDuration> | |
| 1436 | >::type | |
| 1437 | ceil(const time_point<_Clock, _Duration>& __t) | |
| 1438 | { | |
| 1439 | return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; | |
| 1440 | } | |
| 1441 | ||
| 1442 | template <class _ToDuration, class _Clock, class _Duration> | |
| 1443 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1444 | typename enable_if | |
| 1445 | < | |
| 1446 | __is_duration<_ToDuration>::value, | |
| 1447 | time_point<_Clock, _ToDuration> | |
| 1448 | >::type | |
| 1449 | round(const time_point<_Clock, _Duration>& __t) | |
| 1450 | { | |
| 1451 | return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; | |
| 1452 | } | |
| 1453 | ||
| 1454 | template <class _Rep, class _Period> | |
| 1455 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 1456 | typename enable_if | |
| 1457 | < | |
| 1458 | numeric_limits<_Rep>::is_signed, | |
| 1459 | duration<_Rep, _Period> | |
| 1460 | >::type | |
| 1461 | abs(duration<_Rep, _Period> __d) | |
| 1462 | { | |
| 1463 | return __d >= __d.zero() ? +__d : -__d; | |
| 1464 | } | |
| 1465 | #endif | |
| 1466 | ||
| 1467 | // time_point == | |
| 1468 | ||
| 1469 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1470 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1471 | bool | |
| 1472 | operator==(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1473 | { | |
| 1474 | return __lhs.time_since_epoch() == __rhs.time_since_epoch(); | |
| 1475 | } | |
| 1476 | ||
| 1477 | // time_point != | |
| 1478 | ||
| 1479 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1480 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1481 | bool | |
| 1482 | operator!=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1483 | { | |
| 1484 | return !(__lhs == __rhs); | |
| 1485 | } | |
| 1486 | ||
| 1487 | // time_point < | |
| 1488 | ||
| 1489 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1490 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1491 | bool | |
| 1492 | operator<(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1493 | { | |
| 1494 | return __lhs.time_since_epoch() < __rhs.time_since_epoch(); | |
| 1495 | } | |
| 1496 | ||
| 1497 | // time_point > | |
| 1498 | ||
| 1499 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1500 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1501 | bool | |
| 1502 | operator>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1503 | { | |
| 1504 | return __rhs < __lhs; | |
| 1505 | } | |
| 1506 | ||
| 1507 | // time_point <= | |
| 1508 | ||
| 1509 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1510 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1511 | bool | |
| 1512 | operator<=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1513 | { | |
| 1514 | return !(__rhs < __lhs); | |
| 1515 | } | |
| 1516 | ||
| 1517 | // time_point >= | |
| 1518 | ||
| 1519 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1520 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1521 | bool | |
| 1522 | operator>=(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1523 | { | |
| 1524 | return !(__lhs < __rhs); | |
| 1525 | } | |
| 1526 | ||
| 1527 | // time_point operator+(time_point x, duration y); | |
| 1528 | ||
| 1529 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | |
| 1530 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1531 | time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | |
| 1532 | operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1533 | { | |
| 1534 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr; | |
| 1535 | return _Tr (__lhs.time_since_epoch() + __rhs); | |
| 1536 | } | |
| 1537 | ||
| 1538 | // time_point operator+(duration x, time_point y); | |
| 1539 | ||
| 1540 | template <class _Rep1, class _Period1, class _Clock, class _Duration2> | |
| 1541 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1542 | time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type> | |
| 1543 | operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1544 | { | |
| 1545 | return __rhs + __lhs; | |
| 1546 | } | |
| 1547 | ||
| 1548 | // time_point operator-(time_point x, duration y); | |
| 1549 | ||
| 1550 | template <class _Clock, class _Duration1, class _Rep2, class _Period2> | |
| 1551 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1552 | time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> | |
| 1553 | operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) | |
| 1554 | { | |
| 1555 | typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret; | |
| 1556 | return _Ret(__lhs.time_since_epoch() -__rhs); | |
| 1557 | } | |
| 1558 | ||
| 1559 | // duration operator-(time_point x, time_point y); | |
| 1560 | ||
| 1561 | template <class _Clock, class _Duration1, class _Duration2> | |
| 1562 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1563 | typename common_type<_Duration1, _Duration2>::type | |
| 1564 | operator-(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) | |
| 1565 | { | |
| 1566 | return __lhs.time_since_epoch() - __rhs.time_since_epoch(); | |
| 1567 | } | |
| 1568 | ||
| 1569 | ////////////////////////////////////////////////////////// | |
| 1570 | /////////////////////// clocks /////////////////////////// | |
| 1571 | ////////////////////////////////////////////////////////// | |
| 1572 | ||
| 1573 | class _LIBCPP_TYPE_VIS system_clock | |
| 1574 | { | |
| 1575 | public: | |
| 1576 | typedef microseconds duration; | |
| 1577 | typedef duration::rep rep; | |
| 1578 | typedef duration::period period; | |
| 1579 | typedef chrono::time_point<system_clock> time_point; | |
| 1580 | static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; | |
| 1581 | ||
| 1582 | static time_point now() _NOEXCEPT; | |
| 1583 | static time_t to_time_t (const time_point& __t) _NOEXCEPT; | |
| 1584 | static time_point from_time_t(time_t __t) _NOEXCEPT; | |
| 1585 | }; | |
| 1586 | ||
| 1587 | #ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK | |
| 1588 | class _LIBCPP_TYPE_VIS steady_clock | |
| 1589 | { | |
| 1590 | public: | |
| 1591 | typedef nanoseconds duration; | |
| 1592 | typedef duration::rep rep; | |
| 1593 | typedef duration::period period; | |
| 1594 | typedef chrono::time_point<steady_clock, duration> time_point; | |
| 1595 | static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = true; | |
| 1596 | ||
| 1597 | static time_point now() _NOEXCEPT; | |
| 1598 | }; | |
| 1599 | ||
| 1600 | typedef steady_clock high_resolution_clock; | |
| 1601 | #else | |
| 1602 | typedef system_clock high_resolution_clock; | |
| 1603 | #endif | |
| 1604 | ||
| 1605 | #if _LIBCPP_STD_VER > 17 | |
| 1606 | // [time.clock.file], type file_clock | |
| 1607 | using file_clock = _VSTD_FS::_FilesystemClock; | |
| 1608 | ||
| 1609 | template<class _Duration> | |
| 1610 | using file_time = time_point<file_clock, _Duration>; | |
| 1611 | ||
| 1612 | ||
| 1613 | template <class _Duration> | |
| 1614 | using sys_time = time_point<system_clock, _Duration>; | |
| 1615 | using sys_seconds = sys_time<seconds>; | |
| 1616 | using sys_days = sys_time<days>; | |
| 1617 | ||
| 1618 | struct local_t {}; | |
| 1619 | template<class Duration> | |
| 1620 | using local_time = time_point<local_t, Duration>; | |
| 1621 | using local_seconds = local_time<seconds>; | |
| 1622 | using local_days = local_time<days>; | |
| 1623 | ||
| 1624 | ||
| 1625 | struct last_spec { explicit last_spec() = default; }; | |
| 1626 | ||
| 1627 | class day { | |
| 1628 | private: | |
| 1629 | unsigned char __d; | |
| 1630 | public: | |
| 1631 | day() = default; | |
| 1632 | explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {} | |
| 1633 | inline constexpr day& operator++() noexcept { ++__d; return *this; } | |
| 1634 | inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; } | |
| 1635 | inline constexpr day& operator--() noexcept { --__d; return *this; } | |
| 1636 | inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; } | |
| 1637 | constexpr day& operator+=(const days& __dd) noexcept; | |
| 1638 | constexpr day& operator-=(const days& __dd) noexcept; | |
| 1639 | explicit inline constexpr operator unsigned() const noexcept { return __d; } | |
| 1640 | inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; } | |
| 1641 | }; | |
| 1642 | ||
| 1643 | ||
| 1644 | inline constexpr | |
| 1645 | bool operator==(const day& __lhs, const day& __rhs) noexcept | |
| 1646 | { return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); } | |
| 1647 | ||
| 1648 | inline constexpr | |
| 1649 | bool operator!=(const day& __lhs, const day& __rhs) noexcept | |
| 1650 | { return !(__lhs == __rhs); } | |
| 1651 | ||
| 1652 | inline constexpr | |
| 1653 | bool operator< (const day& __lhs, const day& __rhs) noexcept | |
| 1654 | { return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); } | |
| 1655 | ||
| 1656 | inline constexpr | |
| 1657 | bool operator> (const day& __lhs, const day& __rhs) noexcept | |
| 1658 | { return __rhs < __lhs; } | |
| 1659 | ||
| 1660 | inline constexpr | |
| 1661 | bool operator<=(const day& __lhs, const day& __rhs) noexcept | |
| 1662 | { return !(__rhs < __lhs);} | |
| 1663 | ||
| 1664 | inline constexpr | |
| 1665 | bool operator>=(const day& __lhs, const day& __rhs) noexcept | |
| 1666 | { return !(__lhs < __rhs); } | |
| 1667 | ||
| 1668 | inline constexpr | |
| 1669 | day operator+ (const day& __lhs, const days& __rhs) noexcept | |
| 1670 | { return day(static_cast<unsigned>(__lhs) + __rhs.count()); } | |
| 1671 | ||
| 1672 | inline constexpr | |
| 1673 | day operator+ (const days& __lhs, const day& __rhs) noexcept | |
| 1674 | { return __rhs + __lhs; } | |
| 1675 | ||
| 1676 | inline constexpr | |
| 1677 | day operator- (const day& __lhs, const days& __rhs) noexcept | |
| 1678 | { return __lhs + -__rhs; } | |
| 1679 | ||
| 1680 | inline constexpr | |
| 1681 | days operator-(const day& __lhs, const day& __rhs) noexcept | |
| 1682 | { return days(static_cast<int>(static_cast<unsigned>(__lhs)) - | |
| 1683 | static_cast<int>(static_cast<unsigned>(__rhs))); } | |
| 1684 | ||
| 1685 | inline constexpr day& day::operator+=(const days& __dd) noexcept | |
| 1686 | { *this = *this + __dd; return *this; } | |
| 1687 | ||
| 1688 | inline constexpr day& day::operator-=(const days& __dd) noexcept | |
| 1689 | { *this = *this - __dd; return *this; } | |
| 1690 | ||
| 1691 | ||
| 1692 | class month { | |
| 1693 | private: | |
| 1694 | unsigned char __m; | |
| 1695 | public: | |
| 1696 | month() = default; | |
| 1697 | explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {} | |
| 1698 | inline constexpr month& operator++() noexcept { ++__m; return *this; } | |
| 1699 | inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; } | |
| 1700 | inline constexpr month& operator--() noexcept { --__m; return *this; } | |
| 1701 | inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; } | |
| 1702 | constexpr month& operator+=(const months& __m1) noexcept; | |
| 1703 | constexpr month& operator-=(const months& __m1) noexcept; | |
| 1704 | explicit inline constexpr operator unsigned() const noexcept { return __m; } | |
| 1705 | inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; } | |
| 1706 | }; | |
| 1707 | ||
| 1708 | ||
| 1709 | inline constexpr | |
| 1710 | bool operator==(const month& __lhs, const month& __rhs) noexcept | |
| 1711 | { return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); } | |
| 1712 | ||
| 1713 | inline constexpr | |
| 1714 | bool operator!=(const month& __lhs, const month& __rhs) noexcept | |
| 1715 | { return !(__lhs == __rhs); } | |
| 1716 | ||
| 1717 | inline constexpr | |
| 1718 | bool operator< (const month& __lhs, const month& __rhs) noexcept | |
| 1719 | { return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); } | |
| 1720 | ||
| 1721 | inline constexpr | |
| 1722 | bool operator> (const month& __lhs, const month& __rhs) noexcept | |
| 1723 | { return __rhs < __lhs; } | |
| 1724 | ||
| 1725 | inline constexpr | |
| 1726 | bool operator<=(const month& __lhs, const month& __rhs) noexcept | |
| 1727 | { return !(__rhs < __lhs); } | |
| 1728 | ||
| 1729 | inline constexpr | |
| 1730 | bool operator>=(const month& __lhs, const month& __rhs) noexcept | |
| 1731 | { return !(__lhs < __rhs); } | |
| 1732 | ||
| 1733 | inline constexpr | |
| 1734 | month operator+ (const month& __lhs, const months& __rhs) noexcept | |
| 1735 | { | |
| 1736 | auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1); | |
| 1737 | auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12; | |
| 1738 | return month{static_cast<unsigned>(__mu - __yr * 12 + 1)}; | |
| 1739 | } | |
| 1740 | ||
| 1741 | inline constexpr | |
| 1742 | month operator+ (const months& __lhs, const month& __rhs) noexcept | |
| 1743 | { return __rhs + __lhs; } | |
| 1744 | ||
| 1745 | inline constexpr | |
| 1746 | month operator- (const month& __lhs, const months& __rhs) noexcept | |
| 1747 | { return __lhs + -__rhs; } | |
| 1748 | ||
| 1749 | inline constexpr | |
| 1750 | months operator-(const month& __lhs, const month& __rhs) noexcept | |
| 1751 | { | |
| 1752 | auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs); | |
| 1753 | return months(__dm <= 11 ? __dm : __dm + 12); | |
| 1754 | } | |
| 1755 | ||
| 1756 | inline constexpr month& month::operator+=(const months& __dm) noexcept | |
| 1757 | { *this = *this + __dm; return *this; } | |
| 1758 | ||
| 1759 | inline constexpr month& month::operator-=(const months& __dm) noexcept | |
| 1760 | { *this = *this - __dm; return *this; } | |
| 1761 | ||
| 1762 | ||
| 1763 | class year { | |
| 1764 | private: | |
| 1765 | short __y; | |
| 1766 | public: | |
| 1767 | year() = default; | |
| 1768 | explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {} | |
| 1769 | ||
| 1770 | inline constexpr year& operator++() noexcept { ++__y; return *this; } | |
| 1771 | inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; } | |
| 1772 | inline constexpr year& operator--() noexcept { --__y; return *this; } | |
| 1773 | inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; } | |
| 1774 | constexpr year& operator+=(const years& __dy) noexcept; | |
| 1775 | constexpr year& operator-=(const years& __dy) noexcept; | |
| 1776 | inline constexpr year operator+() const noexcept { return *this; } | |
| 1777 | inline constexpr year operator-() const noexcept { return year{-__y}; } | |
| 1778 | ||
| 1779 | inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); } | |
| 1780 | explicit inline constexpr operator int() const noexcept { return __y; } | |
| 1781 | constexpr bool ok() const noexcept; | |
| 1782 | static inline constexpr year min() noexcept { return year{-32767}; } | |
| 1783 | static inline constexpr year max() noexcept { return year{ 32767}; } | |
| 1784 | }; | |
| 1785 | ||
| 1786 | ||
| 1787 | inline constexpr | |
| 1788 | bool operator==(const year& __lhs, const year& __rhs) noexcept | |
| 1789 | { return static_cast<int>(__lhs) == static_cast<int>(__rhs); } | |
| 1790 | ||
| 1791 | inline constexpr | |
| 1792 | bool operator!=(const year& __lhs, const year& __rhs) noexcept | |
| 1793 | { return !(__lhs == __rhs); } | |
| 1794 | ||
| 1795 | inline constexpr | |
| 1796 | bool operator< (const year& __lhs, const year& __rhs) noexcept | |
| 1797 | { return static_cast<int>(__lhs) < static_cast<int>(__rhs); } | |
| 1798 | ||
| 1799 | inline constexpr | |
| 1800 | bool operator> (const year& __lhs, const year& __rhs) noexcept | |
| 1801 | { return __rhs < __lhs; } | |
| 1802 | ||
| 1803 | inline constexpr | |
| 1804 | bool operator<=(const year& __lhs, const year& __rhs) noexcept | |
| 1805 | { return !(__rhs < __lhs); } | |
| 1806 | ||
| 1807 | inline constexpr | |
| 1808 | bool operator>=(const year& __lhs, const year& __rhs) noexcept | |
| 1809 | { return !(__lhs < __rhs); } | |
| 1810 | ||
| 1811 | inline constexpr | |
| 1812 | year operator+ (const year& __lhs, const years& __rhs) noexcept | |
| 1813 | { return year(static_cast<int>(__lhs) + __rhs.count()); } | |
| 1814 | ||
| 1815 | inline constexpr | |
| 1816 | year operator+ (const years& __lhs, const year& __rhs) noexcept | |
| 1817 | { return __rhs + __lhs; } | |
| 1818 | ||
| 1819 | inline constexpr | |
| 1820 | year operator- (const year& __lhs, const years& __rhs) noexcept | |
| 1821 | { return __lhs + -__rhs; } | |
| 1822 | ||
| 1823 | inline constexpr | |
| 1824 | years operator-(const year& __lhs, const year& __rhs) noexcept | |
| 1825 | { return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; } | |
| 1826 | ||
| 1827 | ||
| 1828 | inline constexpr year& year::operator+=(const years& __dy) noexcept | |
| 1829 | { *this = *this + __dy; return *this; } | |
| 1830 | ||
| 1831 | inline constexpr year& year::operator-=(const years& __dy) noexcept | |
| 1832 | { *this = *this - __dy; return *this; } | |
| 1833 | ||
| 1834 | inline constexpr bool year::ok() const noexcept | |
| 1835 | { return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); } | |
| 1836 | ||
| 1837 | class weekday_indexed; | |
| 1838 | class weekday_last; | |
| 1839 | ||
| 1840 | class weekday { | |
| 1841 | private: | |
| 1842 | unsigned char __wd; | |
| 1843 | public: | |
| 1844 | weekday() = default; | |
| 1845 | inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {} | |
| 1846 | inline constexpr weekday(const sys_days& __sysd) noexcept | |
| 1847 | : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {} | |
| 1848 | inline explicit constexpr weekday(const local_days& __locd) noexcept | |
| 1849 | : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {} | |
| 1850 | ||
| 1851 | inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; } | |
| 1852 | inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; } | |
| 1853 | inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; } | |
| 1854 | inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; } | |
| 1855 | constexpr weekday& operator+=(const days& __dd) noexcept; | |
| 1856 | constexpr weekday& operator-=(const days& __dd) noexcept; | |
| 1857 | inline constexpr unsigned c_encoding() const noexcept { return __wd; } | |
| 1858 | inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; } | |
| 1859 | inline constexpr bool ok() const noexcept { return __wd <= 6; } | |
| 1860 | constexpr weekday_indexed operator[](unsigned __index) const noexcept; | |
| 1861 | constexpr weekday_last operator[](last_spec) const noexcept; | |
| 1862 | ||
| 1863 | // TODO: Make private? | |
| 1864 | static constexpr unsigned char __weekday_from_days(int __days) noexcept; | |
| 1865 | }; | |
| 1866 | ||
| 1867 | ||
| 1868 | // https://howardhinnant.github.io/date_algorithms.html#weekday_from_days | |
| 1869 | inline constexpr | |
| 1870 | unsigned char weekday::__weekday_from_days(int __days) noexcept | |
| 1871 | { | |
| 1872 | return static_cast<unsigned char>( | |
| 1873 | static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6) | |
| 1874 | ); | |
| 1875 | } | |
| 1876 | ||
| 1877 | inline constexpr | |
| 1878 | bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1879 | { return __lhs.c_encoding() == __rhs.c_encoding(); } | |
| 1880 | ||
| 1881 | inline constexpr | |
| 1882 | bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1883 | { return !(__lhs == __rhs); } | |
| 1884 | ||
| 1885 | inline constexpr | |
| 1886 | bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1887 | { return __lhs.c_encoding() < __rhs.c_encoding(); } | |
| 1888 | ||
| 1889 | inline constexpr | |
| 1890 | bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1891 | { return __rhs < __lhs; } | |
| 1892 | ||
| 1893 | inline constexpr | |
| 1894 | bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1895 | { return !(__rhs < __lhs);} | |
| 1896 | ||
| 1897 | inline constexpr | |
| 1898 | bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1899 | { return !(__lhs < __rhs); } | |
| 1900 | ||
| 1901 | constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept | |
| 1902 | { | |
| 1903 | auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); | |
| 1904 | auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7; | |
| 1905 | return weekday{static_cast<unsigned>(__mu - __yr * 7)}; | |
| 1906 | } | |
| 1907 | ||
| 1908 | constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept | |
| 1909 | { return __rhs + __lhs; } | |
| 1910 | ||
| 1911 | constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept | |
| 1912 | { return __lhs + -__rhs; } | |
| 1913 | ||
| 1914 | constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 1915 | { | |
| 1916 | const int __wdu = __lhs.c_encoding() - __rhs.c_encoding(); | |
| 1917 | const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7; | |
| 1918 | return days{__wdu - __wk * 7}; | |
| 1919 | } | |
| 1920 | ||
| 1921 | inline constexpr weekday& weekday::operator+=(const days& __dd) noexcept | |
| 1922 | { *this = *this + __dd; return *this; } | |
| 1923 | ||
| 1924 | inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept | |
| 1925 | { *this = *this - __dd; return *this; } | |
| 1926 | ||
| 1927 | ||
| 1928 | class weekday_indexed { | |
| 1929 | private: | |
| 1930 | chrono::weekday __wd; | |
| 1931 | unsigned char __idx; | |
| 1932 | public: | |
| 1933 | weekday_indexed() = default; | |
| 1934 | inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept | |
| 1935 | : __wd{__wdval}, __idx(__idxval) {} | |
| 1936 | inline constexpr chrono::weekday weekday() const noexcept { return __wd; } | |
| 1937 | inline constexpr unsigned index() const noexcept { return __idx; } | |
| 1938 | inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; } | |
| 1939 | }; | |
| 1940 | ||
| 1941 | inline constexpr | |
| 1942 | bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept | |
| 1943 | { return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); } | |
| 1944 | ||
| 1945 | inline constexpr | |
| 1946 | bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept | |
| 1947 | { return !(__lhs == __rhs); } | |
| 1948 | ||
| 1949 | ||
| 1950 | class weekday_last { | |
| 1951 | private: | |
| 1952 | chrono::weekday __wd; | |
| 1953 | public: | |
| 1954 | explicit constexpr weekday_last(const chrono::weekday& __val) noexcept | |
| 1955 | : __wd{__val} {} | |
| 1956 | constexpr chrono::weekday weekday() const noexcept { return __wd; } | |
| 1957 | constexpr bool ok() const noexcept { return __wd.ok(); } | |
| 1958 | }; | |
| 1959 | ||
| 1960 | inline constexpr | |
| 1961 | bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept | |
| 1962 | { return __lhs.weekday() == __rhs.weekday(); } | |
| 1963 | ||
| 1964 | inline constexpr | |
| 1965 | bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept | |
| 1966 | { return !(__lhs == __rhs); } | |
| 1967 | ||
| 1968 | inline constexpr | |
| 1969 | weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; } | |
| 1970 | ||
| 1971 | inline constexpr | |
| 1972 | weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; } | |
| 1973 | ||
| 1974 | ||
| 1975 | inline constexpr last_spec last{}; | |
| 1976 | inline constexpr weekday Sunday{0}; | |
| 1977 | inline constexpr weekday Monday{1}; | |
| 1978 | inline constexpr weekday Tuesday{2}; | |
| 1979 | inline constexpr weekday Wednesday{3}; | |
| 1980 | inline constexpr weekday Thursday{4}; | |
| 1981 | inline constexpr weekday Friday{5}; | |
| 1982 | inline constexpr weekday Saturday{6}; | |
| 1983 | ||
| 1984 | inline constexpr month January{1}; | |
| 1985 | inline constexpr month February{2}; | |
| 1986 | inline constexpr month March{3}; | |
| 1987 | inline constexpr month April{4}; | |
| 1988 | inline constexpr month May{5}; | |
| 1989 | inline constexpr month June{6}; | |
| 1990 | inline constexpr month July{7}; | |
| 1991 | inline constexpr month August{8}; | |
| 1992 | inline constexpr month September{9}; | |
| 1993 | inline constexpr month October{10}; | |
| 1994 | inline constexpr month November{11}; | |
| 1995 | inline constexpr month December{12}; | |
| 1996 | ||
| 1997 | ||
| 1998 | class month_day { | |
| 1999 | private: | |
| 2000 | chrono::month __m; | |
| 2001 | chrono::day __d; | |
| 2002 | public: | |
| 2003 | month_day() = default; | |
| 2004 | constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept | |
| 2005 | : __m{__mval}, __d{__dval} {} | |
| 2006 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2007 | inline constexpr chrono::day day() const noexcept { return __d; } | |
| 2008 | constexpr bool ok() const noexcept; | |
| 2009 | }; | |
| 2010 | ||
| 2011 | inline constexpr | |
| 2012 | bool month_day::ok() const noexcept | |
| 2013 | { | |
| 2014 | if (!__m.ok()) return false; | |
| 2015 | const unsigned __dval = static_cast<unsigned>(__d); | |
| 2016 | if (__dval < 1 || __dval > 31) return false; | |
| 2017 | if (__dval <= 29) return true; | |
| 2018 | // Now we've got either 30 or 31 | |
| 2019 | const unsigned __mval = static_cast<unsigned>(__m); | |
| 2020 | if (__mval == 2) return false; | |
| 2021 | if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11) | |
| 2022 | return __dval == 30; | |
| 2023 | return true; | |
| 2024 | } | |
| 2025 | ||
| 2026 | inline constexpr | |
| 2027 | bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 2028 | { return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } | |
| 2029 | ||
| 2030 | inline constexpr | |
| 2031 | bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 2032 | { return !(__lhs == __rhs); } | |
| 2033 | ||
| 2034 | inline constexpr | |
| 2035 | month_day operator/(const month& __lhs, const day& __rhs) noexcept | |
| 2036 | { return month_day{__lhs, __rhs}; } | |
| 2037 | ||
| 2038 | constexpr | |
| 2039 | month_day operator/(const day& __lhs, const month& __rhs) noexcept | |
| 2040 | { return __rhs / __lhs; } | |
| 2041 | ||
| 2042 | inline constexpr | |
| 2043 | month_day operator/(const month& __lhs, int __rhs) noexcept | |
| 2044 | { return __lhs / day(__rhs); } | |
| 2045 | ||
| 2046 | constexpr | |
| 2047 | month_day operator/(int __lhs, const day& __rhs) noexcept | |
| 2048 | { return month(__lhs) / __rhs; } | |
| 2049 | ||
| 2050 | constexpr | |
| 2051 | month_day operator/(const day& __lhs, int __rhs) noexcept | |
| 2052 | { return month(__rhs) / __lhs; } | |
| 2053 | ||
| 2054 | ||
| 2055 | inline constexpr | |
| 2056 | bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept | |
| 2057 | { return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); } | |
| 2058 | ||
| 2059 | inline constexpr | |
| 2060 | bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept | |
| 2061 | { return __rhs < __lhs; } | |
| 2062 | ||
| 2063 | inline constexpr | |
| 2064 | bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 2065 | { return !(__rhs < __lhs);} | |
| 2066 | ||
| 2067 | inline constexpr | |
| 2068 | bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 2069 | { return !(__lhs < __rhs); } | |
| 2070 | ||
| 2071 | ||
| 2072 | ||
| 2073 | class month_day_last { | |
| 2074 | private: | |
| 2075 | chrono::month __m; | |
| 2076 | public: | |
| 2077 | explicit constexpr month_day_last(const chrono::month& __val) noexcept | |
| 2078 | : __m{__val} {} | |
| 2079 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2080 | inline constexpr bool ok() const noexcept { return __m.ok(); } | |
| 2081 | }; | |
| 2082 | ||
| 2083 | inline constexpr | |
| 2084 | bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 2085 | { return __lhs.month() == __rhs.month(); } | |
| 2086 | ||
| 2087 | inline constexpr | |
| 2088 | bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 2089 | { return !(__lhs == __rhs); } | |
| 2090 | ||
| 2091 | inline constexpr | |
| 2092 | bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 2093 | { return __lhs.month() < __rhs.month(); } | |
| 2094 | ||
| 2095 | inline constexpr | |
| 2096 | bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 2097 | { return __rhs < __lhs; } | |
| 2098 | ||
| 2099 | inline constexpr | |
| 2100 | bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 2101 | { return !(__rhs < __lhs);} | |
| 2102 | ||
| 2103 | inline constexpr | |
| 2104 | bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 2105 | { return !(__lhs < __rhs); } | |
| 2106 | ||
| 2107 | inline constexpr | |
| 2108 | month_day_last operator/(const month& __lhs, last_spec) noexcept | |
| 2109 | { return month_day_last{__lhs}; } | |
| 2110 | ||
| 2111 | inline constexpr | |
| 2112 | month_day_last operator/(last_spec, const month& __rhs) noexcept | |
| 2113 | { return month_day_last{__rhs}; } | |
| 2114 | ||
| 2115 | inline constexpr | |
| 2116 | month_day_last operator/(int __lhs, last_spec) noexcept | |
| 2117 | { return month_day_last{month(__lhs)}; } | |
| 2118 | ||
| 2119 | inline constexpr | |
| 2120 | month_day_last operator/(last_spec, int __rhs) noexcept | |
| 2121 | { return month_day_last{month(__rhs)}; } | |
| 2122 | ||
| 2123 | ||
| 2124 | class month_weekday { | |
| 2125 | private: | |
| 2126 | chrono::month __m; | |
| 2127 | chrono::weekday_indexed __wdi; | |
| 2128 | public: | |
| 2129 | month_weekday() = default; | |
| 2130 | constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept | |
| 2131 | : __m{__mval}, __wdi{__wdival} {} | |
| 2132 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2133 | inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; } | |
| 2134 | inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); } | |
| 2135 | }; | |
| 2136 | ||
| 2137 | inline constexpr | |
| 2138 | bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept | |
| 2139 | { return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } | |
| 2140 | ||
| 2141 | inline constexpr | |
| 2142 | bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept | |
| 2143 | { return !(__lhs == __rhs); } | |
| 2144 | ||
| 2145 | inline constexpr | |
| 2146 | month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept | |
| 2147 | { return month_weekday{__lhs, __rhs}; } | |
| 2148 | ||
| 2149 | inline constexpr | |
| 2150 | month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept | |
| 2151 | { return month_weekday{month(__lhs), __rhs}; } | |
| 2152 | ||
| 2153 | inline constexpr | |
| 2154 | month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept | |
| 2155 | { return month_weekday{__rhs, __lhs}; } | |
| 2156 | ||
| 2157 | inline constexpr | |
| 2158 | month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept | |
| 2159 | { return month_weekday{month(__rhs), __lhs}; } | |
| 2160 | ||
| 2161 | ||
| 2162 | class month_weekday_last { | |
| 2163 | chrono::month __m; | |
| 2164 | chrono::weekday_last __wdl; | |
| 2165 | public: | |
| 2166 | constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept | |
| 2167 | : __m{__mval}, __wdl{__wdlval} {} | |
| 2168 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2169 | inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; } | |
| 2170 | inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); } | |
| 2171 | }; | |
| 2172 | ||
| 2173 | inline constexpr | |
| 2174 | bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept | |
| 2175 | { return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } | |
| 2176 | ||
| 2177 | inline constexpr | |
| 2178 | bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept | |
| 2179 | { return !(__lhs == __rhs); } | |
| 2180 | ||
| 2181 | ||
| 2182 | inline constexpr | |
| 2183 | month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept | |
| 2184 | { return month_weekday_last{__lhs, __rhs}; } | |
| 2185 | ||
| 2186 | inline constexpr | |
| 2187 | month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept | |
| 2188 | { return month_weekday_last{month(__lhs), __rhs}; } | |
| 2189 | ||
| 2190 | inline constexpr | |
| 2191 | month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept | |
| 2192 | { return month_weekday_last{__rhs, __lhs}; } | |
| 2193 | ||
| 2194 | inline constexpr | |
| 2195 | month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept | |
| 2196 | { return month_weekday_last{month(__rhs), __lhs}; } | |
| 2197 | ||
| 2198 | ||
| 2199 | class year_month { | |
| 2200 | chrono::year __y; | |
| 2201 | chrono::month __m; | |
| 2202 | public: | |
| 2203 | year_month() = default; | |
| 2204 | constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept | |
| 2205 | : __y{__yval}, __m{__mval} {} | |
| 2206 | inline constexpr chrono::year year() const noexcept { return __y; } | |
| 2207 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2208 | inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; } | |
| 2209 | inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; } | |
| 2210 | inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; } | |
| 2211 | inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; } | |
| 2212 | inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); } | |
| 2213 | }; | |
| 2214 | ||
| 2215 | inline constexpr | |
| 2216 | year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; } | |
| 2217 | ||
| 2218 | inline constexpr | |
| 2219 | year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; } | |
| 2220 | ||
| 2221 | inline constexpr | |
| 2222 | bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2223 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); } | |
| 2224 | ||
| 2225 | inline constexpr | |
| 2226 | bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2227 | { return !(__lhs == __rhs); } | |
| 2228 | ||
| 2229 | inline constexpr | |
| 2230 | bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2231 | { return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); } | |
| 2232 | ||
| 2233 | inline constexpr | |
| 2234 | bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2235 | { return __rhs < __lhs; } | |
| 2236 | ||
| 2237 | inline constexpr | |
| 2238 | bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2239 | { return !(__rhs < __lhs);} | |
| 2240 | ||
| 2241 | inline constexpr | |
| 2242 | bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2243 | { return !(__lhs < __rhs); } | |
| 2244 | ||
| 2245 | constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept | |
| 2246 | { | |
| 2247 | int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count(); | |
| 2248 | const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12; | |
| 2249 | __dmi = __dmi - __dy * 12 + 1; | |
| 2250 | return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi)); | |
| 2251 | } | |
| 2252 | ||
| 2253 | constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept | |
| 2254 | { return __rhs + __lhs; } | |
| 2255 | ||
| 2256 | constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept | |
| 2257 | { return (__lhs.year() + __rhs) / __lhs.month(); } | |
| 2258 | ||
| 2259 | constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept | |
| 2260 | { return __rhs + __lhs; } | |
| 2261 | ||
| 2262 | constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 2263 | { return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); } | |
| 2264 | ||
| 2265 | constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept | |
| 2266 | { return __lhs + -__rhs; } | |
| 2267 | ||
| 2268 | constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept | |
| 2269 | { return __lhs + -__rhs; } | |
| 2270 | ||
| 2271 | class year_month_day_last; | |
| 2272 | ||
| 2273 | class year_month_day { | |
| 2274 | private: | |
| 2275 | chrono::year __y; | |
| 2276 | chrono::month __m; | |
| 2277 | chrono::day __d; | |
| 2278 | public: | |
| 2279 | year_month_day() = default; | |
| 2280 | inline constexpr year_month_day( | |
| 2281 | const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept | |
| 2282 | : __y{__yval}, __m{__mval}, __d{__dval} {} | |
| 2283 | constexpr year_month_day(const year_month_day_last& __ymdl) noexcept; | |
| 2284 | inline constexpr year_month_day(const sys_days& __sysd) noexcept | |
| 2285 | : year_month_day(__from_days(__sysd.time_since_epoch())) {} | |
| 2286 | inline explicit constexpr year_month_day(const local_days& __locd) noexcept | |
| 2287 | : year_month_day(__from_days(__locd.time_since_epoch())) {} | |
| 2288 | ||
| 2289 | constexpr year_month_day& operator+=(const months& __dm) noexcept; | |
| 2290 | constexpr year_month_day& operator-=(const months& __dm) noexcept; | |
| 2291 | constexpr year_month_day& operator+=(const years& __dy) noexcept; | |
| 2292 | constexpr year_month_day& operator-=(const years& __dy) noexcept; | |
| 2293 | ||
| 2294 | inline constexpr chrono::year year() const noexcept { return __y; } | |
| 2295 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2296 | inline constexpr chrono::day day() const noexcept { return __d; } | |
| 2297 | inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } | |
| 2298 | inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } | |
| 2299 | ||
| 2300 | constexpr bool ok() const noexcept; | |
| 2301 | ||
| 2302 | static constexpr year_month_day __from_days(days __d) noexcept; | |
| 2303 | constexpr days __to_days() const noexcept; | |
| 2304 | }; | |
| 2305 | ||
| 2306 | ||
| 2307 | // https://howardhinnant.github.io/date_algorithms.html#civil_from_days | |
| 2308 | inline constexpr | |
| 2309 | year_month_day | |
| 2310 | year_month_day::__from_days(days __d) noexcept | |
| 2311 | { | |
| 2312 | static_assert(numeric_limits<unsigned>::digits >= 18, ""); | |
| 2313 | static_assert(numeric_limits<int>::digits >= 20 , ""); | |
| 2314 | const int __z = __d.count() + 719468; | |
| 2315 | const int __era = (__z >= 0 ? __z : __z - 146096) / 146097; | |
| 2316 | const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096] | |
| 2317 | const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399] | |
| 2318 | const int __yr = static_cast<int>(__yoe) + __era * 400; | |
| 2319 | const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365] | |
| 2320 | const unsigned __mp = (5 * __doy + 2)/153; // [0, 11] | |
| 2321 | const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31] | |
| 2322 | const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12] | |
| 2323 | return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}}; | |
| 2324 | } | |
| 2325 | ||
| 2326 | // https://howardhinnant.github.io/date_algorithms.html#days_from_civil | |
| 2327 | inline constexpr days year_month_day::__to_days() const noexcept | |
| 2328 | { | |
| 2329 | static_assert(numeric_limits<unsigned>::digits >= 18, ""); | |
| 2330 | static_assert(numeric_limits<int>::digits >= 20 , ""); | |
| 2331 | ||
| 2332 | const int __yr = static_cast<int>(__y) - (__m <= February); | |
| 2333 | const unsigned __mth = static_cast<unsigned>(__m); | |
| 2334 | const unsigned __dy = static_cast<unsigned>(__d); | |
| 2335 | ||
| 2336 | const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400; | |
| 2337 | const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399] | |
| 2338 | const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365] | |
| 2339 | const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096] | |
| 2340 | return days{__era * 146097 + static_cast<int>(__doe) - 719468}; | |
| 2341 | } | |
| 2342 | ||
| 2343 | inline constexpr | |
| 2344 | bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 2345 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } | |
| 2346 | ||
| 2347 | inline constexpr | |
| 2348 | bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 2349 | { return !(__lhs == __rhs); } | |
| 2350 | ||
| 2351 | inline constexpr | |
| 2352 | bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 2353 | { | |
| 2354 | if (__lhs.year() < __rhs.year()) return true; | |
| 2355 | if (__lhs.year() > __rhs.year()) return false; | |
| 2356 | if (__lhs.month() < __rhs.month()) return true; | |
| 2357 | if (__lhs.month() > __rhs.month()) return false; | |
| 2358 | return __lhs.day() < __rhs.day(); | |
| 2359 | } | |
| 2360 | ||
| 2361 | inline constexpr | |
| 2362 | bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 2363 | { return __rhs < __lhs; } | |
| 2364 | ||
| 2365 | inline constexpr | |
| 2366 | bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 2367 | { return !(__rhs < __lhs);} | |
| 2368 | ||
| 2369 | inline constexpr | |
| 2370 | bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 2371 | { return !(__lhs < __rhs); } | |
| 2372 | ||
| 2373 | inline constexpr | |
| 2374 | year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept | |
| 2375 | { return year_month_day{__lhs.year(), __lhs.month(), __rhs}; } | |
| 2376 | ||
| 2377 | inline constexpr | |
| 2378 | year_month_day operator/(const year_month& __lhs, int __rhs) noexcept | |
| 2379 | { return __lhs / day(__rhs); } | |
| 2380 | ||
| 2381 | inline constexpr | |
| 2382 | year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept | |
| 2383 | { return __lhs / __rhs.month() / __rhs.day(); } | |
| 2384 | ||
| 2385 | inline constexpr | |
| 2386 | year_month_day operator/(int __lhs, const month_day& __rhs) noexcept | |
| 2387 | { return year(__lhs) / __rhs; } | |
| 2388 | ||
| 2389 | inline constexpr | |
| 2390 | year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept | |
| 2391 | { return __rhs / __lhs; } | |
| 2392 | ||
| 2393 | inline constexpr | |
| 2394 | year_month_day operator/(const month_day& __lhs, int __rhs) noexcept | |
| 2395 | { return year(__rhs) / __lhs; } | |
| 2396 | ||
| 2397 | ||
| 2398 | inline constexpr | |
| 2399 | year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept | |
| 2400 | { return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); } | |
| 2401 | ||
| 2402 | inline constexpr | |
| 2403 | year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept | |
| 2404 | { return __rhs + __lhs; } | |
| 2405 | ||
| 2406 | inline constexpr | |
| 2407 | year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept | |
| 2408 | { return __lhs + -__rhs; } | |
| 2409 | ||
| 2410 | inline constexpr | |
| 2411 | year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept | |
| 2412 | { return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); } | |
| 2413 | ||
| 2414 | inline constexpr | |
| 2415 | year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept | |
| 2416 | { return __rhs + __lhs; } | |
| 2417 | ||
| 2418 | inline constexpr | |
| 2419 | year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept | |
| 2420 | { return __lhs + -__rhs; } | |
| 2421 | ||
| 2422 | inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 2423 | inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 2424 | inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 2425 | inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 2426 | ||
| 2427 | class year_month_day_last { | |
| 2428 | private: | |
| 2429 | chrono::year __y; | |
| 2430 | chrono::month_day_last __mdl; | |
| 2431 | public: | |
| 2432 | constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept | |
| 2433 | : __y{__yval}, __mdl{__mdlval} {} | |
| 2434 | ||
| 2435 | constexpr year_month_day_last& operator+=(const months& __m) noexcept; | |
| 2436 | constexpr year_month_day_last& operator-=(const months& __m) noexcept; | |
| 2437 | constexpr year_month_day_last& operator+=(const years& __y) noexcept; | |
| 2438 | constexpr year_month_day_last& operator-=(const years& __y) noexcept; | |
| 2439 | ||
| 2440 | inline constexpr chrono::year year() const noexcept { return __y; } | |
| 2441 | inline constexpr chrono::month month() const noexcept { return __mdl.month(); } | |
| 2442 | inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; } | |
| 2443 | constexpr chrono::day day() const noexcept; | |
| 2444 | inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; } | |
| 2445 | inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; } | |
| 2446 | inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); } | |
| 2447 | }; | |
| 2448 | ||
| 2449 | inline constexpr | |
| 2450 | chrono::day year_month_day_last::day() const noexcept | |
| 2451 | { | |
| 2452 | constexpr chrono::day __d[] = | |
| 2453 | { | |
| 2454 | chrono::day(31), chrono::day(28), chrono::day(31), | |
| 2455 | chrono::day(30), chrono::day(31), chrono::day(30), | |
| 2456 | chrono::day(31), chrono::day(31), chrono::day(30), | |
| 2457 | chrono::day(31), chrono::day(30), chrono::day(31) | |
| 2458 | }; | |
| 2459 | return (month() != February || !__y.is_leap()) && month().ok() ? | |
| 2460 | __d[static_cast<unsigned>(month()) - 1] : chrono::day{29}; | |
| 2461 | } | |
| 2462 | ||
| 2463 | inline constexpr | |
| 2464 | bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2465 | { return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); } | |
| 2466 | ||
| 2467 | inline constexpr | |
| 2468 | bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2469 | { return !(__lhs == __rhs); } | |
| 2470 | ||
| 2471 | inline constexpr | |
| 2472 | bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2473 | { | |
| 2474 | if (__lhs.year() < __rhs.year()) return true; | |
| 2475 | if (__lhs.year() > __rhs.year()) return false; | |
| 2476 | return __lhs.month_day_last() < __rhs.month_day_last(); | |
| 2477 | } | |
| 2478 | ||
| 2479 | inline constexpr | |
| 2480 | bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2481 | { return __rhs < __lhs; } | |
| 2482 | ||
| 2483 | inline constexpr | |
| 2484 | bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2485 | { return !(__rhs < __lhs);} | |
| 2486 | ||
| 2487 | inline constexpr | |
| 2488 | bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2489 | { return !(__lhs < __rhs); } | |
| 2490 | ||
| 2491 | inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept | |
| 2492 | { return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; } | |
| 2493 | ||
| 2494 | inline constexpr year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept | |
| 2495 | { return year_month_day_last{__lhs, __rhs}; } | |
| 2496 | ||
| 2497 | inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept | |
| 2498 | { return year_month_day_last{year{__lhs}, __rhs}; } | |
| 2499 | ||
| 2500 | inline constexpr year_month_day_last operator/(const month_day_last& __lhs, const year& __rhs) noexcept | |
| 2501 | { return __rhs / __lhs; } | |
| 2502 | ||
| 2503 | inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept | |
| 2504 | { return year{__rhs} / __lhs; } | |
| 2505 | ||
| 2506 | ||
| 2507 | inline constexpr | |
| 2508 | year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept | |
| 2509 | { return (__lhs.year() / __lhs.month() + __rhs) / last; } | |
| 2510 | ||
| 2511 | inline constexpr | |
| 2512 | year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2513 | { return __rhs + __lhs; } | |
| 2514 | ||
| 2515 | inline constexpr | |
| 2516 | year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept | |
| 2517 | { return __lhs + (-__rhs); } | |
| 2518 | ||
| 2519 | inline constexpr | |
| 2520 | year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept | |
| 2521 | { return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; } | |
| 2522 | ||
| 2523 | inline constexpr | |
| 2524 | year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept | |
| 2525 | { return __rhs + __lhs; } | |
| 2526 | ||
| 2527 | inline constexpr | |
| 2528 | year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept | |
| 2529 | { return __lhs + (-__rhs); } | |
| 2530 | ||
| 2531 | inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 2532 | inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 2533 | inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 2534 | inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 2535 | ||
| 2536 | inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept | |
| 2537 | : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {} | |
| 2538 | ||
| 2539 | inline constexpr bool year_month_day::ok() const noexcept | |
| 2540 | { | |
| 2541 | if (!__y.ok() || !__m.ok()) return false; | |
| 2542 | return chrono::day{1} <= __d && __d <= (__y / __m / last).day(); | |
| 2543 | } | |
| 2544 | ||
| 2545 | class year_month_weekday { | |
| 2546 | chrono::year __y; | |
| 2547 | chrono::month __m; | |
| 2548 | chrono::weekday_indexed __wdi; | |
| 2549 | public: | |
| 2550 | year_month_weekday() = default; | |
| 2551 | constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval, | |
| 2552 | const chrono::weekday_indexed& __wdival) noexcept | |
| 2553 | : __y{__yval}, __m{__mval}, __wdi{__wdival} {} | |
| 2554 | constexpr year_month_weekday(const sys_days& __sysd) noexcept | |
| 2555 | : year_month_weekday(__from_days(__sysd.time_since_epoch())) {} | |
| 2556 | inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept | |
| 2557 | : year_month_weekday(__from_days(__locd.time_since_epoch())) {} | |
| 2558 | constexpr year_month_weekday& operator+=(const months& m) noexcept; | |
| 2559 | constexpr year_month_weekday& operator-=(const months& m) noexcept; | |
| 2560 | constexpr year_month_weekday& operator+=(const years& y) noexcept; | |
| 2561 | constexpr year_month_weekday& operator-=(const years& y) noexcept; | |
| 2562 | ||
| 2563 | inline constexpr chrono::year year() const noexcept { return __y; } | |
| 2564 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2565 | inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); } | |
| 2566 | inline constexpr unsigned index() const noexcept { return __wdi.index(); } | |
| 2567 | inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; } | |
| 2568 | ||
| 2569 | inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } | |
| 2570 | inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } | |
| 2571 | inline constexpr bool ok() const noexcept | |
| 2572 | { | |
| 2573 | if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false; | |
| 2574 | if (__wdi.index() <= 4) return true; | |
| 2575 | auto __nth_weekday_day = | |
| 2576 | __wdi.weekday() - | |
| 2577 | chrono::weekday{static_cast<sys_days>(__y / __m / 1)} + | |
| 2578 | days{(__wdi.index() - 1) * 7 + 1}; | |
| 2579 | return static_cast<unsigned>(__nth_weekday_day.count()) <= | |
| 2580 | static_cast<unsigned>((__y / __m / last).day()); | |
| 2581 | } | |
| 2582 | ||
| 2583 | static constexpr year_month_weekday __from_days(days __d) noexcept; | |
| 2584 | constexpr days __to_days() const noexcept; | |
| 2585 | }; | |
| 2586 | ||
| 2587 | inline constexpr | |
| 2588 | year_month_weekday year_month_weekday::__from_days(days __d) noexcept | |
| 2589 | { | |
| 2590 | const sys_days __sysd{__d}; | |
| 2591 | const chrono::weekday __wd = chrono::weekday(__sysd); | |
| 2592 | const year_month_day __ymd = year_month_day(__sysd); | |
| 2593 | return year_month_weekday{__ymd.year(), __ymd.month(), | |
| 2594 | __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]}; | |
| 2595 | } | |
| 2596 | ||
| 2597 | inline constexpr | |
| 2598 | days year_month_weekday::__to_days() const noexcept | |
| 2599 | { | |
| 2600 | const sys_days __sysd = sys_days(__y/__m/1); | |
| 2601 | return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7})) | |
| 2602 | .time_since_epoch(); | |
| 2603 | } | |
| 2604 | ||
| 2605 | inline constexpr | |
| 2606 | bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept | |
| 2607 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } | |
| 2608 | ||
| 2609 | inline constexpr | |
| 2610 | bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept | |
| 2611 | { return !(__lhs == __rhs); } | |
| 2612 | ||
| 2613 | inline constexpr | |
| 2614 | year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept | |
| 2615 | { return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; } | |
| 2616 | ||
| 2617 | inline constexpr | |
| 2618 | year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept | |
| 2619 | { return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; } | |
| 2620 | ||
| 2621 | inline constexpr | |
| 2622 | year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept | |
| 2623 | { return year(__lhs) / __rhs; } | |
| 2624 | ||
| 2625 | inline constexpr | |
| 2626 | year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept | |
| 2627 | { return __rhs / __lhs; } | |
| 2628 | ||
| 2629 | inline constexpr | |
| 2630 | year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept | |
| 2631 | { return year(__rhs) / __lhs; } | |
| 2632 | ||
| 2633 | ||
| 2634 | inline constexpr | |
| 2635 | year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept | |
| 2636 | { return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); } | |
| 2637 | ||
| 2638 | inline constexpr | |
| 2639 | year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept | |
| 2640 | { return __rhs + __lhs; } | |
| 2641 | ||
| 2642 | inline constexpr | |
| 2643 | year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept | |
| 2644 | { return __lhs + (-__rhs); } | |
| 2645 | ||
| 2646 | inline constexpr | |
| 2647 | year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept | |
| 2648 | { return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; } | |
| 2649 | ||
| 2650 | inline constexpr | |
| 2651 | year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept | |
| 2652 | { return __rhs + __lhs; } | |
| 2653 | ||
| 2654 | inline constexpr | |
| 2655 | year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept | |
| 2656 | { return __lhs + (-__rhs); } | |
| 2657 | ||
| 2658 | ||
| 2659 | inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 2660 | inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 2661 | inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 2662 | inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 2663 | ||
| 2664 | class year_month_weekday_last { | |
| 2665 | private: | |
| 2666 | chrono::year __y; | |
| 2667 | chrono::month __m; | |
| 2668 | chrono::weekday_last __wdl; | |
| 2669 | public: | |
| 2670 | constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval, | |
| 2671 | const chrono::weekday_last& __wdlval) noexcept | |
| 2672 | : __y{__yval}, __m{__mval}, __wdl{__wdlval} {} | |
| 2673 | constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept; | |
| 2674 | constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept; | |
| 2675 | constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept; | |
| 2676 | constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept; | |
| 2677 | ||
| 2678 | inline constexpr chrono::year year() const noexcept { return __y; } | |
| 2679 | inline constexpr chrono::month month() const noexcept { return __m; } | |
| 2680 | inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); } | |
| 2681 | inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; } | |
| 2682 | inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } | |
| 2683 | inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } | |
| 2684 | inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); } | |
| 2685 | ||
| 2686 | constexpr days __to_days() const noexcept; | |
| 2687 | ||
| 2688 | }; | |
| 2689 | ||
| 2690 | inline constexpr | |
| 2691 | days year_month_weekday_last::__to_days() const noexcept | |
| 2692 | { | |
| 2693 | const sys_days __last = sys_days{__y/__m/last}; | |
| 2694 | return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch(); | |
| 2695 | ||
| 2696 | } | |
| 2697 | ||
| 2698 | inline constexpr | |
| 2699 | bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 2700 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } | |
| 2701 | ||
| 2702 | inline constexpr | |
| 2703 | bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 2704 | { return !(__lhs == __rhs); } | |
| 2705 | ||
| 2706 | ||
| 2707 | inline constexpr | |
| 2708 | year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept | |
| 2709 | { return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; } | |
| 2710 | ||
| 2711 | inline constexpr | |
| 2712 | year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept | |
| 2713 | { return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; } | |
| 2714 | ||
| 2715 | inline constexpr | |
| 2716 | year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept | |
| 2717 | { return year(__lhs) / __rhs; } | |
| 2718 | ||
| 2719 | inline constexpr | |
| 2720 | year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept | |
| 2721 | { return __rhs / __lhs; } | |
| 2722 | ||
| 2723 | inline constexpr | |
| 2724 | year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept | |
| 2725 | { return year(__rhs) / __lhs; } | |
| 2726 | ||
| 2727 | ||
| 2728 | inline constexpr | |
| 2729 | year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept | |
| 2730 | { return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); } | |
| 2731 | ||
| 2732 | inline constexpr | |
| 2733 | year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 2734 | { return __rhs + __lhs; } | |
| 2735 | ||
| 2736 | inline constexpr | |
| 2737 | year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept | |
| 2738 | { return __lhs + (-__rhs); } | |
| 2739 | ||
| 2740 | inline constexpr | |
| 2741 | year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept | |
| 2742 | { return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; } | |
| 2743 | ||
| 2744 | inline constexpr | |
| 2745 | year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 2746 | { return __rhs + __lhs; } | |
| 2747 | ||
| 2748 | inline constexpr | |
| 2749 | year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept | |
| 2750 | { return __lhs + (-__rhs); } | |
| 2751 | ||
| 2752 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 2753 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 2754 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 2755 | inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 2756 | ||
| 2757 | ||
| 2758 | template <class _Duration> | |
| 2759 | class hh_mm_ss | |
| 2760 | { | |
| 2761 | private: | |
| 2762 | static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration"); | |
| 2763 | using __CommonType = common_type_t<_Duration, chrono::seconds>; | |
| 2764 | ||
| 2765 | static constexpr uint64_t __pow10(unsigned __exp) | |
| 2766 | { | |
| 2767 | uint64_t __ret = 1; | |
| 2768 | for (unsigned __i = 0; __i < __exp; ++__i) | |
| 2769 | __ret *= 10U; | |
| 2770 | return __ret; | |
| 2771 | } | |
| 2772 | ||
| 2773 | static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0) | |
| 2774 | { | |
| 2775 | if (__n >= 2 && __d != 0 && __w < 19) | |
| 2776 | return 1 + __width(__n, __d % __n * 10, __w+1); | |
| 2777 | return 0; | |
| 2778 | } | |
| 2779 | ||
| 2780 | public: | |
| 2781 | static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ? | |
| 2782 | __width(__CommonType::period::den) : 6u; | |
| 2783 | using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>; | |
| 2784 | ||
| 2785 | constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {} | |
| 2786 | ||
| 2787 | constexpr explicit hh_mm_ss(_Duration __d) noexcept : | |
| 2788 | __is_neg(__d < _Duration(0)), | |
| 2789 | __h(duration_cast<chrono::hours> (abs(__d))), | |
| 2790 | __m(duration_cast<chrono::minutes>(abs(__d) - hours())), | |
| 2791 | __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())), | |
| 2792 | __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds())) | |
| 2793 | {} | |
| 2794 | ||
| 2795 | constexpr bool is_negative() const noexcept { return __is_neg; } | |
| 2796 | constexpr chrono::hours hours() const noexcept { return __h; } | |
| 2797 | constexpr chrono::minutes minutes() const noexcept { return __m; } | |
| 2798 | constexpr chrono::seconds seconds() const noexcept { return __s; } | |
| 2799 | constexpr precision subseconds() const noexcept { return __f; } | |
| 2800 | ||
| 2801 | constexpr precision to_duration() const noexcept | |
| 2802 | { | |
| 2803 | auto __dur = __h + __m + __s + __f; | |
| 2804 | return __is_neg ? -__dur : __dur; | |
| 2805 | } | |
| 2806 | ||
| 2807 | constexpr explicit operator precision() const noexcept { return to_duration(); } | |
| 2808 | ||
| 2809 | private: | |
| 2810 | bool __is_neg; | |
| 2811 | chrono::hours __h; | |
| 2812 | chrono::minutes __m; | |
| 2813 | chrono::seconds __s; | |
| 2814 | precision __f; | |
| 2815 | }; | |
| 2816 | ||
| 2817 | constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); } | |
| 2818 | constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); } | |
| 2819 | ||
| 2820 | constexpr hours make12(const hours& __h) noexcept | |
| 2821 | { | |
| 2822 | if (__h == hours( 0)) return hours(12); | |
| 2823 | else if (__h <= hours(12)) return __h; | |
| 2824 | else return __h - hours(12); | |
| 2825 | } | |
| 2826 | ||
| 2827 | constexpr hours make24(const hours& __h, bool __is_pm) noexcept | |
| 2828 | { | |
| 2829 | if (__is_pm) | |
| 2830 | return __h == hours(12) ? __h : __h + hours(12); | |
| 2831 | else | |
| 2832 | return __h == hours(12) ? hours(0) : __h; | |
| 2833 | } | |
| 2834 | ||
| 2835 | #endif // _LIBCPP_STD_VER > 17 | |
| 2836 | } // chrono | |
| 2837 | ||
| 2838 | #if _LIBCPP_STD_VER > 11 | |
| 2839 | // Suffixes for duration literals [time.duration.literals] | |
| 2840 | inline namespace literals | |
| 2841 | { | |
| 2842 | inline namespace chrono_literals | |
| 2843 | { | |
| 2844 | ||
| 2845 | constexpr chrono::hours operator""h(unsigned long long __h) | |
| 2846 | { | |
| 2847 | return chrono::hours(static_cast<chrono::hours::rep>(__h)); | |
| 2848 | } | |
| 2849 | ||
| 2850 | constexpr chrono::duration<long double, ratio<3600,1>> operator""h(long double __h) | |
| 2851 | { | |
| 2852 | return chrono::duration<long double, ratio<3600,1>>(__h); | |
| 2853 | } | |
| 2854 | ||
| 2855 | ||
| 2856 | constexpr chrono::minutes operator""min(unsigned long long __m) | |
| 2857 | { | |
| 2858 | return chrono::minutes(static_cast<chrono::minutes::rep>(__m)); | |
| 2859 | } | |
| 2860 | ||
| 2861 | constexpr chrono::duration<long double, ratio<60,1>> operator""min(long double __m) | |
| 2862 | { | |
| 2863 | return chrono::duration<long double, ratio<60,1>> (__m); | |
| 2864 | } | |
| 2865 | ||
| 2866 | ||
| 2867 | constexpr chrono::seconds operator""s(unsigned long long __s) | |
| 2868 | { | |
| 2869 | return chrono::seconds(static_cast<chrono::seconds::rep>(__s)); | |
| 2870 | } | |
| 2871 | ||
| 2872 | constexpr chrono::duration<long double> operator""s(long double __s) | |
| 2873 | { | |
| 2874 | return chrono::duration<long double> (__s); | |
| 2875 | } | |
| 2876 | ||
| 2877 | ||
| 2878 | constexpr chrono::milliseconds operator""ms(unsigned long long __ms) | |
| 2879 | { | |
| 2880 | return chrono::milliseconds(static_cast<chrono::milliseconds::rep>(__ms)); | |
| 2881 | } | |
| 2882 | ||
| 2883 | constexpr chrono::duration<long double, milli> operator""ms(long double __ms) | |
| 2884 | { | |
| 2885 | return chrono::duration<long double, milli>(__ms); | |
| 2886 | } | |
| 2887 | ||
| 2888 | ||
| 2889 | constexpr chrono::microseconds operator""us(unsigned long long __us) | |
| 2890 | { | |
| 2891 | return chrono::microseconds(static_cast<chrono::microseconds::rep>(__us)); | |
| 2892 | } | |
| 2893 | ||
| 2894 | constexpr chrono::duration<long double, micro> operator""us(long double __us) | |
| 2895 | { | |
| 2896 | return chrono::duration<long double, micro> (__us); | |
| 2897 | } | |
| 2898 | ||
| 2899 | ||
| 2900 | constexpr chrono::nanoseconds operator""ns(unsigned long long __ns) | |
| 2901 | { | |
| 2902 | return chrono::nanoseconds(static_cast<chrono::nanoseconds::rep>(__ns)); | |
| 2903 | } | |
| 2904 | ||
| 2905 | constexpr chrono::duration<long double, nano> operator""ns(long double __ns) | |
| 2906 | { | |
| 2907 | return chrono::duration<long double, nano> (__ns); | |
| 2908 | } | |
| 2909 | ||
| 2910 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_CHRONO_LITERALS) | |
| 2911 | constexpr chrono::day operator ""d(unsigned long long __d) noexcept | |
| 2912 | { | |
| 2913 | return chrono::day(static_cast<unsigned>(__d)); | |
| 2914 | } | |
| 2915 | ||
| 2916 | constexpr chrono::year operator ""y(unsigned long long __y) noexcept | |
| 2917 | { | |
| 2918 | return chrono::year(static_cast<int>(__y)); | |
| 2919 | } | |
| 2920 | #endif | |
| 2921 | }} | |
| 2922 | ||
| 2923 | namespace chrono { // hoist the literals into namespace std::chrono | |
| 2924 | using namespace literals::chrono_literals; | |
| 2925 | } | |
| 2926 | ||
| 2927 | #endif | |
| 2928 | ||
| 2929 | _LIBCPP_END_NAMESPACE_STD | |
| 2930 | ||
| 2931 | #ifndef _LIBCPP_CXX03_LANG | |
| 2932 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 2933 | struct _FilesystemClock { | |
| 2934 | #if !defined(_LIBCPP_HAS_NO_INT128) | |
| 2935 | typedef __int128_t rep; | |
| 2936 | typedef nano period; | |
| 2937 | #else | |
| 2938 | typedef long long rep; | |
| 2939 | typedef nano period; | |
| 2940 | #endif | |
| 2941 | ||
| 2942 | typedef chrono::duration<rep, period> duration; | |
| 2943 | typedef chrono::time_point<_FilesystemClock> time_point; | |
| 2944 | ||
| 2945 | _LIBCPP_EXPORTED_FROM_ABI | |
| 2946 | static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false; | |
| 2947 | ||
| 2948 | _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept; | |
| 2949 | ||
| 2950 | _LIBCPP_INLINE_VISIBILITY | |
| 2951 | static time_t to_time_t(const time_point& __t) noexcept { | |
| 2952 | typedef chrono::duration<rep> __secs; | |
| 2953 | return time_t( | |
| 2954 | chrono::duration_cast<__secs>(__t.time_since_epoch()).count()); | |
| 2955 | } | |
| 2956 | ||
| 2957 | _LIBCPP_INLINE_VISIBILITY | |
| 2958 | static time_point from_time_t(time_t __t) noexcept { | |
| 2959 | typedef chrono::duration<rep> __secs; | |
| 2960 | return time_point(__secs(__t)); | |
| 2961 | } | |
| 2962 | }; | |
| 2963 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 2964 | #endif // !_LIBCPP_CXX03_LANG | |
| 2965 | ||
| 2966 | _LIBCPP_POP_MACROS | |
| 2967 | ||
| 2968 | 713 | #endif // _LIBCPP_CHRONO |
lib/libcxx/include/cinttypes+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cinttypes --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/ciso646+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- ciso646 ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/climits+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- climits ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/clocale+1-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- clocale ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -44,9 +44,7 @@ lconv* localeconv(); |
| 44 | 44 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 45 | 45 | |
| 46 | 46 | using ::lconv _LIBCPP_USING_IF_EXISTS; |
| 47 | #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS | |
| 48 | 47 | using ::setlocale _LIBCPP_USING_IF_EXISTS; |
| 49 | #endif | |
| 50 | 48 | using ::localeconv _LIBCPP_USING_IF_EXISTS; |
| 51 | 49 | |
| 52 | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/cmath+20-33| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- cmath -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -306,8 +306,8 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept |
| 306 | 306 | |
| 307 | 307 | #include <__config> |
| 308 | 308 | #include <math.h> |
| 309 | #include <version> | |
| 310 | 309 | #include <type_traits> |
| 310 | #include <version> | |
| 311 | 311 | |
| 312 | 312 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 313 | 313 | #pragma GCC system_header |
| ... | ... | @@ -535,7 +535,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y |
| 535 | 535 | |
| 536 | 536 | template <class _A1, class _A2, class _A3> |
| 537 | 537 | inline _LIBCPP_INLINE_VISIBILITY |
| 538 | typename _EnableIf | |
| 538 | typename enable_if_t | |
| 539 | 539 | < |
| 540 | 540 | is_arithmetic<_A1>::value && |
| 541 | 541 | is_arithmetic<_A2>::value && |
| ... | ... | @@ -636,37 +636,24 @@ lerp(double __a, double __b, double __t) _NOEXCEPT { return __ler |
| 636 | 636 | constexpr long double |
| 637 | 637 | lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); } |
| 638 | 638 | |
| 639 | #endif // _LIBCPP_STD_VER > 17 | |
| 640 | ||
| 641 | template <class _IntT, class _FloatT, | |
| 642 | bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits), | |
| 643 | int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)> | |
| 644 | _LIBCPP_INLINE_VISIBILITY | |
| 645 | _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT { | |
| 646 | static_assert(is_floating_point<_FloatT>::value, "must be a floating point type"); | |
| 647 | static_assert(is_integral<_IntT>::value, "must be an integral type"); | |
| 648 | static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix"); | |
| 649 | static_assert((_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value | |
| 650 | || _IsSame<_FloatT,long double>::value), "unsupported floating point type"); | |
| 651 | return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits); | |
| 652 | } | |
| 653 | ||
| 654 | // Convert a floating point number to the specified integral type after | |
| 655 | // clamping to the integral types representable range. | |
| 656 | // | |
| 657 | // The behavior is undefined if `__r` is NaN. | |
| 658 | template <class _IntT, class _RealT> | |
| 659 | _LIBCPP_INLINE_VISIBILITY | |
| 660 | _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT { | |
| 661 | using _Lim = numeric_limits<_IntT>; | |
| 662 | const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>(); | |
| 663 | if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) { | |
| 664 | return _Lim::max(); | |
| 665 | } else if (__r <= _Lim::lowest()) { | |
| 666 | return _Lim::min(); | |
| 667 | } | |
| 668 | return static_cast<_IntT>(__r); | |
| 639 | template <class _A1, class _A2, class _A3> | |
| 640 | inline _LIBCPP_HIDE_FROM_ABI | |
| 641 | constexpr typename enable_if_t | |
| 642 | < | |
| 643 | is_arithmetic<_A1>::value && | |
| 644 | is_arithmetic<_A2>::value && | |
| 645 | is_arithmetic<_A3>::value, | |
| 646 | __promote<_A1, _A2, _A3> | |
| 647 | >::type | |
| 648 | lerp(_A1 __a, _A2 __b, _A3 __t) noexcept | |
| 649 | { | |
| 650 | typedef typename __promote<_A1, _A2, _A3>::type __result_type; | |
| 651 | static_assert(!(_IsSame<_A1, __result_type>::value && | |
| 652 | _IsSame<_A2, __result_type>::value && | |
| 653 | _IsSame<_A3, __result_type>::value)); | |
| 654 | return __lerp((__result_type)__a, (__result_type)__b, (__result_type)__t); | |
| 669 | 655 | } |
| 656 | #endif // _LIBCPP_STD_VER > 17 | |
| 670 | 657 | |
| 671 | 658 | _LIBCPP_END_NAMESPACE_STD |
| 672 | 659 |
lib/libcxx/include/codecvt+8-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- codecvt -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -56,6 +56,7 @@ class codecvt_utf8_utf16 |
| 56 | 56 | |
| 57 | 57 | #include <__config> |
| 58 | 58 | #include <__locale> |
| 59 | #include <version> | |
| 59 | 60 | |
| 60 | 61 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 61 | 62 | #pragma GCC system_header |
| ... | ... | @@ -74,6 +75,7 @@ enum codecvt_mode |
| 74 | 75 | |
| 75 | 76 | template <class _Elem> class __codecvt_utf8; |
| 76 | 77 | |
| 78 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 77 | 79 | template <> |
| 78 | 80 | class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t> |
| 79 | 81 | : public codecvt<wchar_t, char, mbstate_t> |
| ... | ... | @@ -108,6 +110,7 @@ protected: |
| 108 | 110 | size_t __mx) const; |
| 109 | 111 | virtual int do_max_length() const _NOEXCEPT; |
| 110 | 112 | }; |
| 113 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 111 | 114 | |
| 112 | 115 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 113 | 116 | template <> |
| ... | ... | @@ -203,6 +206,7 @@ public: |
| 203 | 206 | |
| 204 | 207 | template <class _Elem, bool _LittleEndian> class __codecvt_utf16; |
| 205 | 208 | |
| 209 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 206 | 210 | template <> |
| 207 | 211 | class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false> |
| 208 | 212 | : public codecvt<wchar_t, char, mbstate_t> |
| ... | ... | @@ -272,6 +276,7 @@ protected: |
| 272 | 276 | size_t __mx) const; |
| 273 | 277 | virtual int do_max_length() const _NOEXCEPT; |
| 274 | 278 | }; |
| 279 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 275 | 280 | |
| 276 | 281 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 277 | 282 | template <> |
| ... | ... | @@ -443,6 +448,7 @@ public: |
| 443 | 448 | |
| 444 | 449 | template <class _Elem> class __codecvt_utf8_utf16; |
| 445 | 450 | |
| 451 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 446 | 452 | template <> |
| 447 | 453 | class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t> |
| 448 | 454 | : public codecvt<wchar_t, char, mbstate_t> |
| ... | ... | @@ -477,6 +483,7 @@ protected: |
| 477 | 483 | size_t __mx) const; |
| 478 | 484 | virtual int do_max_length() const _NOEXCEPT; |
| 479 | 485 | }; |
| 486 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 480 | 487 | |
| 481 | 488 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 482 | 489 | template <> |
lib/libcxx/include/compare+40-367| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- compare -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -20,8 +20,8 @@ namespace std { |
| 20 | 20 | class strong_ordering; |
| 21 | 21 | |
| 22 | 22 | // named comparison functions |
| 23 | constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; } | |
| 24 | constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; } | |
| 23 | constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; } | |
| 24 | constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; } | |
| 25 | 25 | constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; } |
| 26 | 26 | constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; } |
| 27 | 27 | constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; } |
| ... | ... | @@ -35,10 +35,30 @@ namespace std { |
| 35 | 35 | template<class... Ts> |
| 36 | 36 | using common_comparison_category_t = typename common_comparison_category<Ts...>::type; |
| 37 | 37 | |
| 38 | // [cmp.concept], concept three_way_comparable | |
| 39 | template<class T, class Cat = partial_ordering> | |
| 40 | concept three_way_comparable = see below; | |
| 41 | template<class T, class U, class Cat = partial_ordering> | |
| 42 | concept three_way_comparable_with = see below; | |
| 43 | ||
| 44 | // [cmp.result], result of three-way comparison | |
| 45 | template<class T, class U = T> struct compare_three_way_result; | |
| 46 | ||
| 47 | template<class T, class U = T> | |
| 48 | using compare_three_way_result_t = typename compare_three_way_result<T, U>::type; | |
| 49 | ||
| 50 | // [comparisons.three.way], class compare_three_way | |
| 51 | struct compare_three_way; // C++20 | |
| 52 | ||
| 38 | 53 | // [cmp.alg], comparison algorithms |
| 39 | template<class T> constexpr strong_ordering strong_order(const T& a, const T& b); | |
| 40 | template<class T> constexpr weak_ordering weak_order(const T& a, const T& b); | |
| 41 | template<class T> constexpr partial_ordering partial_order(const T& a, const T& b); | |
| 54 | inline namespace unspecified { | |
| 55 | inline constexpr unspecified strong_order = unspecified; | |
| 56 | inline constexpr unspecified weak_order = unspecified; | |
| 57 | inline constexpr unspecified partial_order = unspecified; | |
| 58 | inline constexpr unspecified compare_strong_order_fallback = unspecified; | |
| 59 | inline constexpr unspecified compare_weak_order_fallback = unspecified; | |
| 60 | inline constexpr unspecified compare_partial_order_fallback = unspecified; | |
| 61 | } | |
| 42 | 62 | |
| 43 | 63 | // [cmp.partialord], Class partial_ordering |
| 44 | 64 | class partial_ordering { |
| ... | ... | @@ -120,370 +140,23 @@ namespace std { |
| 120 | 140 | } |
| 121 | 141 | */ |
| 122 | 142 | |
| 143 | #include <__compare/common_comparison_category.h> | |
| 144 | #include <__compare/compare_partial_order_fallback.h> | |
| 145 | #include <__compare/compare_strong_order_fallback.h> | |
| 146 | #include <__compare/compare_three_way.h> | |
| 147 | #include <__compare/compare_three_way_result.h> | |
| 148 | #include <__compare/compare_weak_order_fallback.h> | |
| 149 | #include <__compare/is_eq.h> | |
| 150 | #include <__compare/ordering.h> | |
| 151 | #include <__compare/partial_order.h> | |
| 152 | #include <__compare/strong_order.h> | |
| 153 | #include <__compare/three_way_comparable.h> | |
| 154 | #include <__compare/weak_order.h> | |
| 123 | 155 | #include <__config> |
| 124 | #include <type_traits> | |
| 156 | #include <version> | |
| 125 | 157 | |
| 126 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 158 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 127 | 159 | #pragma GCC system_header |
| 128 | 160 | #endif |
| 129 | 161 | |
| 130 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 131 | ||
| 132 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR) | |
| 133 | // exposition only | |
| 134 | enum class _LIBCPP_ENUM_VIS _EqResult : unsigned char { | |
| 135 | __zero = 0, | |
| 136 | __equal = __zero, | |
| 137 | __equiv = __equal, | |
| 138 | __nonequal = 1, | |
| 139 | __nonequiv = __nonequal | |
| 140 | }; | |
| 141 | ||
| 142 | enum class _LIBCPP_ENUM_VIS _OrdResult : signed char { | |
| 143 | __less = -1, | |
| 144 | __greater = 1 | |
| 145 | }; | |
| 146 | ||
| 147 | enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char { | |
| 148 | __unordered = -127 | |
| 149 | }; | |
| 150 | ||
| 151 | class partial_ordering; | |
| 152 | class weak_ordering; | |
| 153 | class strong_ordering; | |
| 154 | ||
| 155 | template<class _Tp, class... _Args> | |
| 156 | inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...); | |
| 157 | ||
| 158 | struct _CmpUnspecifiedParam { | |
| 159 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEVAL | |
| 160 | _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} | |
| 161 | ||
| 162 | template<class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>> | |
| 163 | _CmpUnspecifiedParam(_Tp) = delete; | |
| 164 | }; | |
| 165 | ||
| 166 | class partial_ordering { | |
| 167 | using _ValueT = signed char; | |
| 168 | ||
| 169 | _LIBCPP_INLINE_VISIBILITY | |
| 170 | explicit constexpr partial_ordering(_EqResult __v) noexcept | |
| 171 | : __value_(_ValueT(__v)) {} | |
| 172 | ||
| 173 | _LIBCPP_INLINE_VISIBILITY | |
| 174 | explicit constexpr partial_ordering(_OrdResult __v) noexcept | |
| 175 | : __value_(_ValueT(__v)) {} | |
| 176 | ||
| 177 | _LIBCPP_INLINE_VISIBILITY | |
| 178 | explicit constexpr partial_ordering(_NCmpResult __v) noexcept | |
| 179 | : __value_(_ValueT(__v)) {} | |
| 180 | ||
| 181 | constexpr bool __is_ordered() const noexcept { | |
| 182 | return __value_ != _ValueT(_NCmpResult::__unordered); | |
| 183 | } | |
| 184 | public: | |
| 185 | // valid values | |
| 186 | static const partial_ordering less; | |
| 187 | static const partial_ordering equivalent; | |
| 188 | static const partial_ordering greater; | |
| 189 | static const partial_ordering unordered; | |
| 190 | ||
| 191 | // comparisons | |
| 192 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; | |
| 193 | ||
| 194 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 195 | return __v.__is_ordered() && __v.__value_ == 0; | |
| 196 | } | |
| 197 | ||
| 198 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 199 | return __v.__is_ordered() && __v.__value_ < 0; | |
| 200 | } | |
| 201 | ||
| 202 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 203 | return __v.__is_ordered() && __v.__value_ <= 0; | |
| 204 | } | |
| 205 | ||
| 206 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 207 | return __v.__is_ordered() && __v.__value_ > 0; | |
| 208 | } | |
| 209 | ||
| 210 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 211 | return __v.__is_ordered() && __v.__value_ >= 0; | |
| 212 | } | |
| 213 | ||
| 214 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 215 | return __v.__is_ordered() && 0 < __v.__value_; | |
| 216 | } | |
| 217 | ||
| 218 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 219 | return __v.__is_ordered() && 0 <= __v.__value_; | |
| 220 | } | |
| 221 | ||
| 222 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 223 | return __v.__is_ordered() && 0 > __v.__value_; | |
| 224 | } | |
| 225 | ||
| 226 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 227 | return __v.__is_ordered() && 0 >= __v.__value_; | |
| 228 | } | |
| 229 | ||
| 230 | _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 231 | return __v; | |
| 232 | } | |
| 233 | ||
| 234 | _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { | |
| 235 | return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v); | |
| 236 | } | |
| 237 | private: | |
| 238 | _ValueT __value_; | |
| 239 | }; | |
| 240 | ||
| 241 | _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::less(_OrdResult::__less); | |
| 242 | _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv); | |
| 243 | _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); | |
| 244 | _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); | |
| 245 | ||
| 246 | class weak_ordering { | |
| 247 | using _ValueT = signed char; | |
| 248 | ||
| 249 | _LIBCPP_INLINE_VISIBILITY | |
| 250 | explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 251 | _LIBCPP_INLINE_VISIBILITY | |
| 252 | explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 253 | ||
| 254 | public: | |
| 255 | static const weak_ordering less; | |
| 256 | static const weak_ordering equivalent; | |
| 257 | static const weak_ordering greater; | |
| 258 | ||
| 259 | _LIBCPP_INLINE_VISIBILITY | |
| 260 | constexpr operator partial_ordering() const noexcept { | |
| 261 | return __value_ == 0 ? partial_ordering::equivalent | |
| 262 | : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); | |
| 263 | } | |
| 264 | ||
| 265 | // comparisons | |
| 266 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default; | |
| 267 | ||
| 268 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 269 | return __v.__value_ == 0; | |
| 270 | } | |
| 271 | ||
| 272 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 273 | return __v.__value_ < 0; | |
| 274 | } | |
| 275 | ||
| 276 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 277 | return __v.__value_ <= 0; | |
| 278 | } | |
| 279 | ||
| 280 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 281 | return __v.__value_ > 0; | |
| 282 | } | |
| 283 | ||
| 284 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 285 | return __v.__value_ >= 0; | |
| 286 | } | |
| 287 | ||
| 288 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 289 | return 0 < __v.__value_; | |
| 290 | } | |
| 291 | ||
| 292 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 293 | return 0 <= __v.__value_; | |
| 294 | } | |
| 295 | ||
| 296 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 297 | return 0 > __v.__value_; | |
| 298 | } | |
| 299 | ||
| 300 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 301 | return 0 >= __v.__value_; | |
| 302 | } | |
| 303 | ||
| 304 | _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 305 | return __v; | |
| 306 | } | |
| 307 | ||
| 308 | _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { | |
| 309 | return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v); | |
| 310 | } | |
| 311 | ||
| 312 | private: | |
| 313 | _ValueT __value_; | |
| 314 | }; | |
| 315 | ||
| 316 | _LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less); | |
| 317 | _LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv); | |
| 318 | _LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater); | |
| 319 | class strong_ordering { | |
| 320 | using _ValueT = signed char; | |
| 321 | ||
| 322 | _LIBCPP_INLINE_VISIBILITY | |
| 323 | explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 324 | _LIBCPP_INLINE_VISIBILITY | |
| 325 | explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {} | |
| 326 | ||
| 327 | public: | |
| 328 | static const strong_ordering less; | |
| 329 | static const strong_ordering equal; | |
| 330 | static const strong_ordering equivalent; | |
| 331 | static const strong_ordering greater; | |
| 332 | ||
| 333 | // conversions | |
| 334 | _LIBCPP_INLINE_VISIBILITY | |
| 335 | constexpr operator partial_ordering() const noexcept { | |
| 336 | return __value_ == 0 ? partial_ordering::equivalent | |
| 337 | : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater); | |
| 338 | } | |
| 339 | ||
| 340 | _LIBCPP_INLINE_VISIBILITY | |
| 341 | constexpr operator weak_ordering() const noexcept { | |
| 342 | return __value_ == 0 ? weak_ordering::equivalent | |
| 343 | : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater); | |
| 344 | } | |
| 345 | ||
| 346 | // comparisons | |
| 347 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default; | |
| 348 | ||
| 349 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 350 | return __v.__value_ == 0; | |
| 351 | } | |
| 352 | ||
| 353 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 354 | return __v.__value_ < 0; | |
| 355 | } | |
| 356 | ||
| 357 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 358 | return __v.__value_ <= 0; | |
| 359 | } | |
| 360 | ||
| 361 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 362 | return __v.__value_ > 0; | |
| 363 | } | |
| 364 | ||
| 365 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 366 | return __v.__value_ >= 0; | |
| 367 | } | |
| 368 | ||
| 369 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 370 | return 0 < __v.__value_; | |
| 371 | } | |
| 372 | ||
| 373 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 374 | return 0 <= __v.__value_; | |
| 375 | } | |
| 376 | ||
| 377 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 378 | return 0 > __v.__value_; | |
| 379 | } | |
| 380 | ||
| 381 | _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 382 | return 0 >= __v.__value_; | |
| 383 | } | |
| 384 | ||
| 385 | _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { | |
| 386 | return __v; | |
| 387 | } | |
| 388 | ||
| 389 | _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { | |
| 390 | return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v); | |
| 391 | } | |
| 392 | ||
| 393 | private: | |
| 394 | _ValueT __value_; | |
| 395 | }; | |
| 396 | ||
| 397 | _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::less(_OrdResult::__less); | |
| 398 | _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equal(_EqResult::__equal); | |
| 399 | _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv); | |
| 400 | _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater); | |
| 401 | ||
| 402 | // named comparison functions | |
| 403 | _LIBCPP_INLINE_VISIBILITY | |
| 404 | constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; } | |
| 405 | ||
| 406 | _LIBCPP_INLINE_VISIBILITY | |
| 407 | constexpr bool is_lteq(partial_ordering __cmp) noexcept { return __cmp <= 0; } | |
| 408 | ||
| 409 | _LIBCPP_INLINE_VISIBILITY | |
| 410 | constexpr bool is_gt(partial_ordering __cmp) noexcept { return __cmp > 0; } | |
| 411 | ||
| 412 | _LIBCPP_INLINE_VISIBILITY | |
| 413 | constexpr bool is_gteq(partial_ordering __cmp) noexcept { return __cmp >= 0; } | |
| 414 | ||
| 415 | namespace __comp_detail { | |
| 416 | ||
| 417 | enum _ClassifyCompCategory : unsigned{ | |
| 418 | _None, | |
| 419 | _PartialOrd, | |
| 420 | _WeakOrd, | |
| 421 | _StrongOrd, | |
| 422 | _CCC_Size | |
| 423 | }; | |
| 424 | ||
| 425 | template <class _Tp> | |
| 426 | _LIBCPP_INLINE_VISIBILITY | |
| 427 | constexpr _ClassifyCompCategory __type_to_enum() noexcept { | |
| 428 | if (is_same_v<_Tp, partial_ordering>) | |
| 429 | return _PartialOrd; | |
| 430 | if (is_same_v<_Tp, weak_ordering>) | |
| 431 | return _WeakOrd; | |
| 432 | if (is_same_v<_Tp, strong_ordering>) | |
| 433 | return _StrongOrd; | |
| 434 | return _None; | |
| 435 | } | |
| 436 | ||
| 437 | template <size_t _Size> | |
| 438 | constexpr _ClassifyCompCategory | |
| 439 | __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) { | |
| 440 | int __seen[_CCC_Size] = {}; | |
| 441 | for (auto __type : __types) | |
| 442 | ++__seen[__type]; | |
| 443 | if (__seen[_None]) | |
| 444 | return _None; | |
| 445 | if (__seen[_PartialOrd]) | |
| 446 | return _PartialOrd; | |
| 447 | if (__seen[_WeakOrd]) | |
| 448 | return _WeakOrd; | |
| 449 | return _StrongOrd; | |
| 450 | } | |
| 451 | ||
| 452 | template <class ..._Ts, bool _False = false> | |
| 453 | constexpr auto __get_comp_type() { | |
| 454 | using _CCC = _ClassifyCompCategory; | |
| 455 | constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...}; | |
| 456 | constexpr _CCC _Cat = __compute_comp_type(__type_kinds); | |
| 457 | if constexpr (_Cat == _None) | |
| 458 | return void(); | |
| 459 | else if constexpr (_Cat == _PartialOrd) | |
| 460 | return partial_ordering::equivalent; | |
| 461 | else if constexpr (_Cat == _WeakOrd) | |
| 462 | return weak_ordering::equivalent; | |
| 463 | else if constexpr (_Cat == _StrongOrd) | |
| 464 | return strong_ordering::equivalent; | |
| 465 | else | |
| 466 | static_assert(_False, "unhandled case"); | |
| 467 | } | |
| 468 | } // namespace __comp_detail | |
| 469 | ||
| 470 | // [cmp.common], common comparison category type | |
| 471 | template<class... _Ts> | |
| 472 | struct _LIBCPP_TEMPLATE_VIS common_comparison_category { | |
| 473 | using type = decltype(__comp_detail::__get_comp_type<_Ts...>()); | |
| 474 | }; | |
| 475 | ||
| 476 | template<class... _Ts> | |
| 477 | using common_comparison_category_t = typename common_comparison_category<_Ts...>::type; | |
| 478 | ||
| 479 | // [cmp.alg], comparison algorithms | |
| 480 | // TODO: unimplemented | |
| 481 | template<class _Tp> constexpr strong_ordering strong_order(const _Tp& __lhs, const _Tp& __rhs); | |
| 482 | template<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs); | |
| 483 | template<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs); | |
| 484 | ||
| 485 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_SPACESHIP_OPERATOR) | |
| 486 | ||
| 487 | _LIBCPP_END_NAMESPACE_STD | |
| 488 | ||
| 489 | 162 | #endif // _LIBCPP_COMPARE |
lib/libcxx/include/complex+8-7| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- complex ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -1056,6 +1056,9 @@ complex<_Tp> |
| 1056 | 1056 | exp(const complex<_Tp>& __x) |
| 1057 | 1057 | { |
| 1058 | 1058 | _Tp __i = __x.imag(); |
| 1059 | if (__i == 0) { | |
| 1060 | return complex<_Tp>(exp(__x.real()), copysign(_Tp(0), __x.imag())); | |
| 1061 | } | |
| 1059 | 1062 | if (__libcpp_isinf_or_builtin(__x.real())) |
| 1060 | 1063 | { |
| 1061 | 1064 | if (__x.real() < _Tp(0)) |
| ... | ... | @@ -1070,8 +1073,6 @@ exp(const complex<_Tp>& __x) |
| 1070 | 1073 | return complex<_Tp>(__x.real(), __i); |
| 1071 | 1074 | } |
| 1072 | 1075 | } |
| 1073 | else if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0) | |
| 1074 | return __x; | |
| 1075 | 1076 | _Tp __e = exp(__x.real()); |
| 1076 | 1077 | return complex<_Tp>(__e * cos(__i), __e * sin(__i)); |
| 1077 | 1078 | } |
| ... | ... | @@ -1269,8 +1270,8 @@ tanh(const complex<_Tp>& __x) |
| 1269 | 1270 | if (__libcpp_isinf_or_builtin(__x.real())) |
| 1270 | 1271 | { |
| 1271 | 1272 | if (!__libcpp_isfinite_or_builtin(__x.imag())) |
| 1272 | return complex<_Tp>(_Tp(1), _Tp(0)); | |
| 1273 | return complex<_Tp>(_Tp(1), copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); | |
| 1273 | return complex<_Tp>(copysign(_Tp(1), __x.real()), _Tp(0)); | |
| 1274 | return complex<_Tp>(copysign(_Tp(1), __x.real()), copysign(_Tp(0), sin(_Tp(2) * __x.imag()))); | |
| 1274 | 1275 | } |
| 1275 | 1276 | if (__libcpp_isnan_or_builtin(__x.real()) && __x.imag() == 0) |
| 1276 | 1277 | return __x; |
| ... | ... | @@ -1484,8 +1485,8 @@ inline namespace literals |
| 1484 | 1485 | { |
| 1485 | 1486 | return { 0.0f, static_cast<float>(__im) }; |
| 1486 | 1487 | } |
| 1487 | } | |
| 1488 | } | |
| 1488 | } // namespace complex_literals | |
| 1489 | } // namespace literals | |
| 1489 | 1490 | #endif |
| 1490 | 1491 | |
| 1491 | 1492 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/complex.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- complex.h --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/concepts+23-317| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- concepts ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -129,327 +129,33 @@ namespace std { |
| 129 | 129 | |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | #include <__concepts/arithmetic.h> | |
| 133 | #include <__concepts/assignable.h> | |
| 134 | #include <__concepts/boolean_testable.h> | |
| 135 | #include <__concepts/class_or_enum.h> | |
| 136 | #include <__concepts/common_reference_with.h> | |
| 137 | #include <__concepts/common_with.h> | |
| 138 | #include <__concepts/constructible.h> | |
| 139 | #include <__concepts/convertible_to.h> | |
| 140 | #include <__concepts/copyable.h> | |
| 141 | #include <__concepts/derived_from.h> | |
| 142 | #include <__concepts/destructible.h> | |
| 143 | #include <__concepts/different_from.h> | |
| 144 | #include <__concepts/equality_comparable.h> | |
| 145 | #include <__concepts/invocable.h> | |
| 146 | #include <__concepts/movable.h> | |
| 147 | #include <__concepts/predicate.h> | |
| 148 | #include <__concepts/regular.h> | |
| 149 | #include <__concepts/relation.h> | |
| 150 | #include <__concepts/same_as.h> | |
| 151 | #include <__concepts/semiregular.h> | |
| 152 | #include <__concepts/swappable.h> | |
| 153 | #include <__concepts/totally_ordered.h> | |
| 132 | 154 | #include <__config> |
| 133 | #include <__functional/invoke.h> | |
| 134 | #include <__functional_base> | |
| 135 | #include <type_traits> | |
| 136 | #include <utility> | |
| 137 | 155 | #include <version> |
| 138 | 156 | |
| 139 | 157 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 140 | 158 | #pragma GCC system_header |
| 141 | 159 | #endif |
| 142 | 160 | |
| 143 | _LIBCPP_PUSH_MACROS | |
| 144 | #include <__undef_macros> | |
| 145 | ||
| 146 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 147 | ||
| 148 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 149 | ||
| 150 | // [concept.same] | |
| 151 | ||
| 152 | template<class _Tp, class _Up> | |
| 153 | concept __same_as_impl = _VSTD::_IsSame<_Tp, _Up>::value; | |
| 154 | ||
| 155 | template<class _Tp, class _Up> | |
| 156 | concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>; | |
| 157 | ||
| 158 | // [concept.derived] | |
| 159 | template<class _Dp, class _Bp> | |
| 160 | concept derived_from = | |
| 161 | is_base_of_v<_Bp, _Dp> && | |
| 162 | is_convertible_v<const volatile _Dp*, const volatile _Bp*>; | |
| 163 | ||
| 164 | // [concept.convertible] | |
| 165 | template<class _From, class _To> | |
| 166 | concept convertible_to = | |
| 167 | is_convertible_v<_From, _To> && | |
| 168 | requires(add_rvalue_reference_t<_From> (&__f)()) { | |
| 169 | static_cast<_To>(__f()); | |
| 170 | }; | |
| 171 | ||
| 172 | // [concept.commonref] | |
| 173 | template<class _Tp, class _Up> | |
| 174 | concept common_reference_with = | |
| 175 | same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> && | |
| 176 | convertible_to<_Tp, common_reference_t<_Tp, _Up>> && | |
| 177 | convertible_to<_Up, common_reference_t<_Tp, _Up>>; | |
| 178 | ||
| 179 | // [concept.common] | |
| 180 | template<class _Tp, class _Up> | |
| 181 | concept common_with = | |
| 182 | same_as<common_type_t<_Tp, _Up>, common_type_t<_Up, _Tp>> && | |
| 183 | requires { | |
| 184 | static_cast<common_type_t<_Tp, _Up>>(declval<_Tp>()); | |
| 185 | static_cast<common_type_t<_Tp, _Up>>(declval<_Up>()); | |
| 186 | } && | |
| 187 | common_reference_with< | |
| 188 | add_lvalue_reference_t<const _Tp>, | |
| 189 | add_lvalue_reference_t<const _Up>> && | |
| 190 | common_reference_with< | |
| 191 | add_lvalue_reference_t<common_type_t<_Tp, _Up>>, | |
| 192 | common_reference_t< | |
| 193 | add_lvalue_reference_t<const _Tp>, | |
| 194 | add_lvalue_reference_t<const _Up>>>; | |
| 195 | ||
| 196 | // [concepts.arithmetic], arithmetic concepts | |
| 197 | template<class _Tp> | |
| 198 | concept integral = is_integral_v<_Tp>; | |
| 199 | ||
| 200 | template<class _Tp> | |
| 201 | concept signed_integral = integral<_Tp> && is_signed_v<_Tp>; | |
| 202 | ||
| 203 | template<class _Tp> | |
| 204 | concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>; | |
| 205 | ||
| 206 | template<class _Tp> | |
| 207 | concept floating_point = is_floating_point_v<_Tp>; | |
| 208 | ||
| 209 | // [concept.assignable] | |
| 210 | template<class _Lhs, class _Rhs> | |
| 211 | concept assignable_from = | |
| 212 | is_lvalue_reference_v<_Lhs> && | |
| 213 | common_reference_with<__make_const_lvalue_ref<_Lhs>, __make_const_lvalue_ref<_Rhs>> && | |
| 214 | requires (_Lhs __lhs, _Rhs&& __rhs) { | |
| 215 | { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>; | |
| 216 | }; | |
| 217 | ||
| 218 | // [concept.destructible] | |
| 219 | ||
| 220 | template<class _Tp> | |
| 221 | concept destructible = is_nothrow_destructible_v<_Tp>; | |
| 222 | ||
| 223 | // [concept.constructible] | |
| 224 | template<class _Tp, class... _Args> | |
| 225 | concept constructible_from = | |
| 226 | destructible<_Tp> && is_constructible_v<_Tp, _Args...>; | |
| 227 | ||
| 228 | // [concept.default.init] | |
| 229 | ||
| 230 | template<class _Tp> | |
| 231 | concept __default_initializable = requires { ::new _Tp; }; | |
| 232 | ||
| 233 | template<class _Tp> | |
| 234 | concept default_initializable = constructible_from<_Tp> && | |
| 235 | requires { _Tp{}; } && __default_initializable<_Tp>; | |
| 236 | ||
| 237 | // [concept.moveconstructible] | |
| 238 | template<class _Tp> | |
| 239 | concept move_constructible = | |
| 240 | constructible_from<_Tp, _Tp> && convertible_to<_Tp, _Tp>; | |
| 241 | ||
| 242 | // [concept.copyconstructible] | |
| 243 | template<class _Tp> | |
| 244 | concept copy_constructible = | |
| 245 | move_constructible<_Tp> && | |
| 246 | constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> && | |
| 247 | constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> && | |
| 248 | constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>; | |
| 249 | ||
| 250 | // Whether a type is a class type or enumeration type according to the Core wording. | |
| 251 | template<class _Tp> | |
| 252 | concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; | |
| 253 | ||
| 254 | // [concept.swappable] | |
| 255 | namespace ranges::__swap { | |
| 256 | // Deleted to inhibit ADL | |
| 257 | template<class _Tp> | |
| 258 | void swap(_Tp&, _Tp&) = delete; | |
| 259 | ||
| 260 | ||
| 261 | // [1] | |
| 262 | template<class _Tp, class _Up> | |
| 263 | concept __unqualified_swappable_with = | |
| 264 | (__class_or_enum<remove_cvref_t<_Tp>> || __class_or_enum<remove_cvref_t<_Up>>) && | |
| 265 | requires(_Tp&& __t, _Up&& __u) { | |
| 266 | swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); | |
| 267 | }; | |
| 268 | ||
| 269 | struct __fn; | |
| 270 | ||
| 271 | template<class _Tp, class _Up, size_t _Size> | |
| 272 | concept __swappable_arrays = | |
| 273 | !__unqualified_swappable_with<_Tp(&)[_Size], _Up(&)[_Size]> && | |
| 274 | extent_v<_Tp> == extent_v<_Up> && | |
| 275 | requires(_Tp(& __t)[_Size], _Up(& __u)[_Size], const __fn& __swap) { | |
| 276 | __swap(__t[0], __u[0]); | |
| 277 | }; | |
| 278 | ||
| 279 | template<class _Tp> | |
| 280 | concept __exchangeable = | |
| 281 | !__unqualified_swappable_with<_Tp&, _Tp&> && | |
| 282 | move_constructible<_Tp> && | |
| 283 | assignable_from<_Tp&, _Tp>; | |
| 284 | ||
| 285 | struct __fn { | |
| 286 | // 2.1 `S` is `(void)swap(E1, E2)`* if `E1` or `E2` has class or enumeration type and... | |
| 287 | // *The name `swap` is used here unqualified. | |
| 288 | template<class _Tp, class _Up> | |
| 289 | requires __unqualified_swappable_with<_Tp, _Up> | |
| 290 | constexpr void operator()(_Tp&& __t, _Up&& __u) const | |
| 291 | noexcept(noexcept(swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))) | |
| 292 | { | |
| 293 | swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); | |
| 294 | } | |
| 295 | ||
| 296 | // 2.2 Otherwise, if `E1` and `E2` are lvalues of array types with equal extent and... | |
| 297 | template<class _Tp, class _Up, size_t _Size> | |
| 298 | requires __swappable_arrays<_Tp, _Up, _Size> | |
| 299 | constexpr void operator()(_Tp(& __t)[_Size], _Up(& __u)[_Size]) const | |
| 300 | noexcept(noexcept((*this)(*__t, *__u))) | |
| 301 | { | |
| 302 | // TODO(cjdb): replace with `ranges::swap_ranges`. | |
| 303 | for (size_t __i = 0; __i < _Size; ++__i) { | |
| 304 | (*this)(__t[__i], __u[__i]); | |
| 305 | } | |
| 306 | } | |
| 307 | ||
| 308 | // 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models... | |
| 309 | template<__exchangeable _Tp> | |
| 310 | constexpr void operator()(_Tp& __x, _Tp& __y) const | |
| 311 | noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>) | |
| 312 | { | |
| 313 | __y = _VSTD::exchange(__x, _VSTD::move(__y)); | |
| 314 | } | |
| 315 | }; | |
| 316 | } // namespace ranges::__swap | |
| 317 | ||
| 318 | namespace ranges::inline __cpo { | |
| 319 | inline constexpr auto swap = __swap::__fn{}; | |
| 320 | } // namespace ranges::__cpo | |
| 321 | ||
| 322 | template<class _Tp> | |
| 323 | concept swappable = requires(_Tp& __a, _Tp& __b) { ranges::swap(__a, __b); }; | |
| 324 | ||
| 325 | template<class _Tp, class _Up> | |
| 326 | concept swappable_with = | |
| 327 | common_reference_with<_Tp, _Up> && | |
| 328 | requires(_Tp&& __t, _Up&& __u) { | |
| 329 | ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Tp>(__t)); | |
| 330 | ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Up>(__u)); | |
| 331 | ranges::swap(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); | |
| 332 | ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t)); | |
| 333 | }; | |
| 334 | ||
| 335 | // [concept.booleantestable] | |
| 336 | template<class _Tp> | |
| 337 | concept __boolean_testable_impl = convertible_to<_Tp, bool>; | |
| 338 | ||
| 339 | template<class _Tp> | |
| 340 | concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) { | |
| 341 | { !std::forward<_Tp>(__t) } -> __boolean_testable_impl; | |
| 342 | }; | |
| 343 | ||
| 344 | // [concept.equalitycomparable] | |
| 345 | template<class _Tp, class _Up> | |
| 346 | concept __weakly_equality_comparable_with = | |
| 347 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { | |
| 348 | { __t == __u } -> __boolean_testable; | |
| 349 | { __t != __u } -> __boolean_testable; | |
| 350 | { __u == __t } -> __boolean_testable; | |
| 351 | { __u != __t } -> __boolean_testable; | |
| 352 | }; | |
| 353 | ||
| 354 | template<class _Tp> | |
| 355 | concept equality_comparable = __weakly_equality_comparable_with<_Tp, _Tp>; | |
| 356 | ||
| 357 | template<class _Tp, class _Up> | |
| 358 | concept equality_comparable_with = | |
| 359 | equality_comparable<_Tp> && equality_comparable<_Up> && | |
| 360 | common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> && | |
| 361 | equality_comparable< | |
| 362 | common_reference_t< | |
| 363 | __make_const_lvalue_ref<_Tp>, | |
| 364 | __make_const_lvalue_ref<_Up>>> && | |
| 365 | __weakly_equality_comparable_with<_Tp, _Up>; | |
| 366 | ||
| 367 | // [concept.totallyordered] | |
| 368 | ||
| 369 | template<class _Tp, class _Up> | |
| 370 | concept __partially_ordered_with = | |
| 371 | requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) { | |
| 372 | { __t < __u } -> __boolean_testable; | |
| 373 | { __t > __u } -> __boolean_testable; | |
| 374 | { __t <= __u } -> __boolean_testable; | |
| 375 | { __t >= __u } -> __boolean_testable; | |
| 376 | { __u < __t } -> __boolean_testable; | |
| 377 | { __u > __t } -> __boolean_testable; | |
| 378 | { __u <= __t } -> __boolean_testable; | |
| 379 | { __u >= __t } -> __boolean_testable; | |
| 380 | }; | |
| 381 | ||
| 382 | template<class _Tp> | |
| 383 | concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>; | |
| 384 | ||
| 385 | template<class _Tp, class _Up> | |
| 386 | concept totally_ordered_with = | |
| 387 | totally_ordered<_Tp> && totally_ordered<_Up> && | |
| 388 | equality_comparable_with<_Tp, _Up> && | |
| 389 | totally_ordered< | |
| 390 | common_reference_t< | |
| 391 | __make_const_lvalue_ref<_Tp>, | |
| 392 | __make_const_lvalue_ref<_Up>>> && | |
| 393 | __partially_ordered_with<_Tp, _Up>; | |
| 394 | ||
| 395 | // [concepts.object] | |
| 396 | template<class _Tp> | |
| 397 | concept movable = | |
| 398 | is_object_v<_Tp> && | |
| 399 | move_constructible<_Tp> && | |
| 400 | assignable_from<_Tp&, _Tp> && | |
| 401 | swappable<_Tp>; | |
| 402 | ||
| 403 | template<class _Tp> | |
| 404 | concept copyable = | |
| 405 | copy_constructible<_Tp> && | |
| 406 | movable<_Tp> && | |
| 407 | assignable_from<_Tp&, _Tp&> && | |
| 408 | assignable_from<_Tp&, const _Tp&> && | |
| 409 | assignable_from<_Tp&, const _Tp>; | |
| 410 | ||
| 411 | template<class _Tp> | |
| 412 | concept semiregular = copyable<_Tp> && default_initializable<_Tp>; | |
| 413 | ||
| 414 | template<class _Tp> | |
| 415 | concept regular = semiregular<_Tp> && equality_comparable<_Tp>; | |
| 416 | ||
| 417 | // [concept.invocable] | |
| 418 | template<class _Fn, class... _Args> | |
| 419 | concept invocable = requires(_Fn&& __fn, _Args&&... __args) { | |
| 420 | _VSTD::invoke(_VSTD::forward<_Fn>(__fn), _VSTD::forward<_Args>(__args)...); // not required to be equality preserving | |
| 421 | }; | |
| 422 | ||
| 423 | // [concept.regular.invocable] | |
| 424 | template<class _Fn, class... _Args> | |
| 425 | concept regular_invocable = invocable<_Fn, _Args...>; | |
| 426 | ||
| 427 | // [concept.predicate] | |
| 428 | template<class _Fn, class... _Args> | |
| 429 | concept predicate = | |
| 430 | regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>; | |
| 431 | ||
| 432 | // [concept.relation] | |
| 433 | template<class _Rp, class _Tp, class _Up> | |
| 434 | concept relation = | |
| 435 | predicate<_Rp, _Tp, _Tp> && predicate<_Rp, _Up, _Up> && | |
| 436 | predicate<_Rp, _Tp, _Up> && predicate<_Rp, _Up, _Tp>; | |
| 437 | ||
| 438 | // [concept.equiv] | |
| 439 | template<class _Rp, class _Tp, class _Up> | |
| 440 | concept equivalence_relation = relation<_Rp, _Tp, _Up>; | |
| 441 | ||
| 442 | // [concept.strictweakorder] | |
| 443 | template<class _Rp, class _Tp, class _Up> | |
| 444 | concept strict_weak_order = relation<_Rp, _Tp, _Up>; | |
| 445 | ||
| 446 | template<class _Tp, class _Up> | |
| 447 | concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>; | |
| 448 | ||
| 449 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 450 | ||
| 451 | _LIBCPP_END_NAMESPACE_STD | |
| 452 | ||
| 453 | _LIBCPP_POP_MACROS | |
| 454 | ||
| 455 | 161 | #endif // _LIBCPP_CONCEPTS |
lib/libcxx/include/condition_variable+2-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------- condition_variable ----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -109,6 +109,7 @@ public: |
| 109 | 109 | #include <__config> |
| 110 | 110 | #include <__mutex_base> |
| 111 | 111 | #include <memory> |
| 112 | #include <version> | |
| 112 | 113 | |
| 113 | 114 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 114 | 115 | #pragma GCC system_header |
lib/libcxx/include/coroutine 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_COROUTINE | |
| 11 | #define _LIBCPP_COROUTINE | |
| 12 | ||
| 13 | /** | |
| 14 | coroutine synopsis | |
| 15 | ||
| 16 | namespace std { | |
| 17 | // [coroutine.traits] | |
| 18 | template <class R, class... ArgTypes> | |
| 19 | struct coroutine_traits; | |
| 20 | // [coroutine.handle] | |
| 21 | template <class Promise = void> | |
| 22 | struct coroutine_handle; | |
| 23 | // [coroutine.handle.compare] | |
| 24 | constexpr bool operator==(coroutine_handle<> x, coroutine_handle<> y) noexcept; | |
| 25 | constexpr strong_ordering operator<=>(coroutine_handle<> x, coroutine_handle<> y) noexcept; | |
| 26 | // [coroutine.handle.hash] | |
| 27 | template <class T> struct hash; | |
| 28 | template <class P> struct hash<coroutine_handle<P>>; | |
| 29 | // [coroutine.noop] | |
| 30 | struct noop_coroutine_promise; | |
| 31 | template<> struct coroutine_handle<noop_coroutine_promise>; | |
| 32 | using noop_coroutine_handle = coroutine_handle<noop_coroutine_promise>; | |
| 33 | noop_coroutine_handle noop_coroutine() noexcept; | |
| 34 | // [coroutine.trivial.awaitables] | |
| 35 | struct suspend_never; | |
| 36 | struct suspend_always; | |
| 37 | } // namespace std | |
| 38 | ||
| 39 | */ | |
| 40 | ||
| 41 | #include <__config> | |
| 42 | #include <__coroutine/coroutine_handle.h> | |
| 43 | #include <__coroutine/coroutine_traits.h> | |
| 44 | #include <__coroutine/noop_coroutine_handle.h> | |
| 45 | #include <__coroutine/trivial_awaitables.h> | |
| 46 | #include <version> | |
| 47 | ||
| 48 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER | |
| 49 | #pragma GCC system_header | |
| 50 | #endif | |
| 51 | ||
| 52 | #endif // _LIBCPP_COROUTINE |
lib/libcxx/include/csetjmp+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- csetjmp ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/csignal+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- csignal ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cstdarg+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstdarg ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cstdbool+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstdbool ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cstddef+6-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstddef ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -58,14 +58,16 @@ template <> struct __libcpp_is_integral<bool> { enum { va |
| 58 | 58 | template <> struct __libcpp_is_integral<char> { enum { value = 1 }; }; |
| 59 | 59 | template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; }; |
| 60 | 60 | template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; }; |
| 61 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 61 | 62 | template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; }; |
| 63 | #endif | |
| 62 | 64 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 63 | 65 | template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; }; |
| 64 | 66 | #endif |
| 65 | 67 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 66 | 68 | template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; }; |
| 67 | 69 | template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; }; |
| 68 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 70 | #endif | |
| 69 | 71 | template <> struct __libcpp_is_integral<short> { enum { value = 1 }; }; |
| 70 | 72 | template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; }; |
| 71 | 73 | template <> struct __libcpp_is_integral<int> { enum { value = 1 }; }; |
| ... | ... | @@ -154,7 +156,8 @@ template <class _Integer> |
| 154 | 156 | template <class _Integer, class = _EnableByteOverload<_Integer> > |
| 155 | 157 | _LIBCPP_NODISCARD_EXT constexpr _Integer |
| 156 | 158 | to_integer(byte __b) noexcept { return static_cast<_Integer>(__b); } |
| 157 | } | |
| 159 | ||
| 160 | } // namespace std | |
| 158 | 161 | |
| 159 | 162 | #endif |
| 160 | 163 |
lib/libcxx/include/cstdint+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstdint ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cstdio+1-7| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- cstdio ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -145,30 +145,24 @@ using ::feof _LIBCPP_USING_IF_EXISTS; |
| 145 | 145 | using ::ferror _LIBCPP_USING_IF_EXISTS; |
| 146 | 146 | using ::perror _LIBCPP_USING_IF_EXISTS; |
| 147 | 147 | |
| 148 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 149 | 148 | using ::fopen _LIBCPP_USING_IF_EXISTS; |
| 150 | 149 | using ::freopen _LIBCPP_USING_IF_EXISTS; |
| 151 | 150 | using ::remove _LIBCPP_USING_IF_EXISTS; |
| 152 | 151 | using ::rename _LIBCPP_USING_IF_EXISTS; |
| 153 | 152 | using ::tmpfile _LIBCPP_USING_IF_EXISTS; |
| 154 | 153 | using ::tmpnam _LIBCPP_USING_IF_EXISTS; |
| 155 | #endif | |
| 156 | 154 | |
| 157 | #ifndef _LIBCPP_HAS_NO_STDIN | |
| 158 | 155 | using ::getchar _LIBCPP_USING_IF_EXISTS; |
| 159 | 156 | #if _LIBCPP_STD_VER <= 11 && !defined(_LIBCPP_C_HAS_NO_GETS) |
| 160 | 157 | using ::gets _LIBCPP_USING_IF_EXISTS; |
| 161 | 158 | #endif |
| 162 | 159 | using ::scanf _LIBCPP_USING_IF_EXISTS; |
| 163 | 160 | using ::vscanf _LIBCPP_USING_IF_EXISTS; |
| 164 | #endif | |
| 165 | 161 | |
| 166 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 167 | 162 | using ::printf _LIBCPP_USING_IF_EXISTS; |
| 168 | 163 | using ::putchar _LIBCPP_USING_IF_EXISTS; |
| 169 | 164 | using ::puts _LIBCPP_USING_IF_EXISTS; |
| 170 | 165 | using ::vprintf _LIBCPP_USING_IF_EXISTS; |
| 171 | #endif | |
| 172 | 166 | |
| 173 | 167 | _LIBCPP_END_NAMESPACE_STD |
| 174 | 168 |
lib/libcxx/include/cstdlib+1-13| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstdlib ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -99,26 +99,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 99 | 99 | using ::size_t _LIBCPP_USING_IF_EXISTS; |
| 100 | 100 | using ::div_t _LIBCPP_USING_IF_EXISTS; |
| 101 | 101 | using ::ldiv_t _LIBCPP_USING_IF_EXISTS; |
| 102 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 103 | 102 | using ::lldiv_t _LIBCPP_USING_IF_EXISTS; |
| 104 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 105 | 103 | using ::atof _LIBCPP_USING_IF_EXISTS; |
| 106 | 104 | using ::atoi _LIBCPP_USING_IF_EXISTS; |
| 107 | 105 | using ::atol _LIBCPP_USING_IF_EXISTS; |
| 108 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 109 | 106 | using ::atoll _LIBCPP_USING_IF_EXISTS; |
| 110 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 111 | 107 | using ::strtod _LIBCPP_USING_IF_EXISTS; |
| 112 | 108 | using ::strtof _LIBCPP_USING_IF_EXISTS; |
| 113 | 109 | using ::strtold _LIBCPP_USING_IF_EXISTS; |
| 114 | 110 | using ::strtol _LIBCPP_USING_IF_EXISTS; |
| 115 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 116 | 111 | using ::strtoll _LIBCPP_USING_IF_EXISTS; |
| 117 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 118 | 112 | using ::strtoul _LIBCPP_USING_IF_EXISTS; |
| 119 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 120 | 113 | using ::strtoull _LIBCPP_USING_IF_EXISTS; |
| 121 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 122 | 114 | using ::rand _LIBCPP_USING_IF_EXISTS; |
| 123 | 115 | using ::srand _LIBCPP_USING_IF_EXISTS; |
| 124 | 116 | using ::calloc _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -137,14 +129,10 @@ using ::bsearch _LIBCPP_USING_IF_EXISTS; |
| 137 | 129 | using ::qsort _LIBCPP_USING_IF_EXISTS; |
| 138 | 130 | using ::abs _LIBCPP_USING_IF_EXISTS; |
| 139 | 131 | using ::labs _LIBCPP_USING_IF_EXISTS; |
| 140 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 141 | 132 | using ::llabs _LIBCPP_USING_IF_EXISTS; |
| 142 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 143 | 133 | using ::div _LIBCPP_USING_IF_EXISTS; |
| 144 | 134 | using ::ldiv _LIBCPP_USING_IF_EXISTS; |
| 145 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 146 | 135 | using ::lldiv _LIBCPP_USING_IF_EXISTS; |
| 147 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 148 | 136 | using ::mblen _LIBCPP_USING_IF_EXISTS; |
| 149 | 137 | using ::mbtowc _LIBCPP_USING_IF_EXISTS; |
| 150 | 138 | using ::wctomb _LIBCPP_USING_IF_EXISTS; |
lib/libcxx/include/cstring+1-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cstring ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -84,9 +84,7 @@ using ::strpbrk _LIBCPP_USING_IF_EXISTS; |
| 84 | 84 | using ::strrchr _LIBCPP_USING_IF_EXISTS; |
| 85 | 85 | using ::strspn _LIBCPP_USING_IF_EXISTS; |
| 86 | 86 | using ::strstr _LIBCPP_USING_IF_EXISTS; |
| 87 | #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS | |
| 88 | 87 | using ::strtok _LIBCPP_USING_IF_EXISTS; |
| 89 | #endif | |
| 90 | 88 | using ::memset _LIBCPP_USING_IF_EXISTS; |
| 91 | 89 | using ::strerror _LIBCPP_USING_IF_EXISTS; |
| 92 | 90 | using ::strlen _LIBCPP_USING_IF_EXISTS; |
lib/libcxx/include/ctgmath+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- ctgmath -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/ctime+1-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- ctime -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -79,12 +79,10 @@ using ::clock _LIBCPP_USING_IF_EXISTS; |
| 79 | 79 | using ::difftime _LIBCPP_USING_IF_EXISTS; |
| 80 | 80 | using ::mktime _LIBCPP_USING_IF_EXISTS; |
| 81 | 81 | using ::time _LIBCPP_USING_IF_EXISTS; |
| 82 | #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS | |
| 83 | 82 | using ::asctime _LIBCPP_USING_IF_EXISTS; |
| 84 | 83 | using ::ctime _LIBCPP_USING_IF_EXISTS; |
| 85 | 84 | using ::gmtime _LIBCPP_USING_IF_EXISTS; |
| 86 | 85 | using ::localtime _LIBCPP_USING_IF_EXISTS; |
| 87 | #endif | |
| 88 | 86 | using ::strftime _LIBCPP_USING_IF_EXISTS; |
| 89 | 87 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED) |
| 90 | 88 | using ::timespec_get _LIBCPP_USING_IF_EXISTS; |
lib/libcxx/include/ctype.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- ctype.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/cwchar+1-9| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cwchar -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -137,13 +137,9 @@ using ::wcstod _LIBCPP_USING_IF_EXISTS; |
| 137 | 137 | using ::wcstof _LIBCPP_USING_IF_EXISTS; |
| 138 | 138 | using ::wcstold _LIBCPP_USING_IF_EXISTS; |
| 139 | 139 | using ::wcstol _LIBCPP_USING_IF_EXISTS; |
| 140 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 141 | 140 | using ::wcstoll _LIBCPP_USING_IF_EXISTS; |
| 142 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 143 | 141 | using ::wcstoul _LIBCPP_USING_IF_EXISTS; |
| 144 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 145 | 142 | using ::wcstoull _LIBCPP_USING_IF_EXISTS; |
| 146 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 147 | 143 | using ::wcscpy _LIBCPP_USING_IF_EXISTS; |
| 148 | 144 | using ::wcsncpy _LIBCPP_USING_IF_EXISTS; |
| 149 | 145 | using ::wcscat _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -175,17 +171,13 @@ using ::wcrtomb _LIBCPP_USING_IF_EXISTS; |
| 175 | 171 | using ::mbsrtowcs _LIBCPP_USING_IF_EXISTS; |
| 176 | 172 | using ::wcsrtombs _LIBCPP_USING_IF_EXISTS; |
| 177 | 173 | |
| 178 | #ifndef _LIBCPP_HAS_NO_STDIN | |
| 179 | 174 | using ::getwchar _LIBCPP_USING_IF_EXISTS; |
| 180 | 175 | using ::vwscanf _LIBCPP_USING_IF_EXISTS; |
| 181 | 176 | using ::wscanf _LIBCPP_USING_IF_EXISTS; |
| 182 | #endif | |
| 183 | 177 | |
| 184 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 185 | 178 | using ::putwchar _LIBCPP_USING_IF_EXISTS; |
| 186 | 179 | using ::vwprintf _LIBCPP_USING_IF_EXISTS; |
| 187 | 180 | using ::wprintf _LIBCPP_USING_IF_EXISTS; |
| 188 | #endif | |
| 189 | 181 | |
| 190 | 182 | _LIBCPP_END_NAMESPACE_STD |
| 191 | 183 |
lib/libcxx/include/cwctype+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- cwctype ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/deque+42-64| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- deque -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -129,7 +129,7 @@ public: |
| 129 | 129 | |
| 130 | 130 | template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> |
| 131 | 131 | deque(InputIterator, InputIterator, Allocator = Allocator()) |
| 132 | -> deque<typename iterator_traits<InputIterator>::value_type, Allocator>; | |
| 132 | -> deque<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17 | |
| 133 | 133 | |
| 134 | 134 | template <class T, class Allocator> |
| 135 | 135 | bool operator==(const deque<T,Allocator>& x, const deque<T,Allocator>& y); |
| ... | ... | @@ -162,6 +162,7 @@ template <class T, class Allocator, class Predicate> |
| 162 | 162 | |
| 163 | 163 | #include <__config> |
| 164 | 164 | #include <__debug> |
| 165 | #include <__iterator/iterator_traits.h> | |
| 165 | 166 | #include <__split_buffer> |
| 166 | 167 | #include <__utility/forward.h> |
| 167 | 168 | #include <algorithm> |
| ... | ... | @@ -908,45 +909,22 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, |
| 908 | 909 | return __r; |
| 909 | 910 | } |
| 910 | 911 | |
| 911 | template <bool> | |
| 912 | class __deque_base_common | |
| 913 | { | |
| 914 | protected: | |
| 915 | _LIBCPP_NORETURN void __throw_length_error() const; | |
| 916 | _LIBCPP_NORETURN void __throw_out_of_range() const; | |
| 917 | }; | |
| 918 | ||
| 919 | template <bool __b> | |
| 920 | void | |
| 921 | __deque_base_common<__b>::__throw_length_error() const | |
| 922 | { | |
| 923 | _VSTD::__throw_length_error("deque"); | |
| 924 | } | |
| 925 | ||
| 926 | template <bool __b> | |
| 927 | void | |
| 928 | __deque_base_common<__b>::__throw_out_of_range() const | |
| 929 | { | |
| 930 | _VSTD::__throw_out_of_range("deque"); | |
| 931 | } | |
| 932 | ||
| 933 | 912 | template <class _Tp, class _Allocator> |
| 934 | 913 | class __deque_base |
| 935 | : protected __deque_base_common<true> | |
| 936 | 914 | { |
| 937 | 915 | __deque_base(const __deque_base& __c); |
| 938 | 916 | __deque_base& operator=(const __deque_base& __c); |
| 939 | 917 | public: |
| 940 | typedef _Allocator allocator_type; | |
| 941 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 942 | typedef typename __alloc_traits::size_type size_type; | |
| 918 | typedef _Allocator allocator_type; | |
| 919 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 920 | typedef typename __alloc_traits::size_type size_type; | |
| 943 | 921 | |
| 944 | typedef _Tp value_type; | |
| 945 | typedef value_type& reference; | |
| 946 | typedef const value_type& const_reference; | |
| 947 | typedef typename __alloc_traits::difference_type difference_type; | |
| 948 | typedef typename __alloc_traits::pointer pointer; | |
| 949 | typedef typename __alloc_traits::const_pointer const_pointer; | |
| 922 | typedef _Tp value_type; | |
| 923 | typedef value_type& reference; | |
| 924 | typedef const value_type& const_reference; | |
| 925 | typedef typename __alloc_traits::difference_type difference_type; | |
| 926 | typedef typename __alloc_traits::pointer pointer; | |
| 927 | typedef typename __alloc_traits::const_pointer const_pointer; | |
| 950 | 928 | |
| 951 | 929 | static const difference_type __block_size; |
| 952 | 930 | |
| ... | ... | @@ -1281,20 +1259,20 @@ public: |
| 1281 | 1259 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1282 | 1260 | "Allocator::value_type must be same type as value_type"); |
| 1283 | 1261 | |
| 1284 | typedef __deque_base<value_type, allocator_type> __base; | |
| 1262 | typedef __deque_base<value_type, allocator_type> __base; | |
| 1285 | 1263 | |
| 1286 | typedef typename __base::__alloc_traits __alloc_traits; | |
| 1287 | typedef typename __base::reference reference; | |
| 1288 | typedef typename __base::const_reference const_reference; | |
| 1289 | typedef typename __base::iterator iterator; | |
| 1290 | typedef typename __base::const_iterator const_iterator; | |
| 1291 | typedef typename __base::size_type size_type; | |
| 1292 | typedef typename __base::difference_type difference_type; | |
| 1264 | typedef typename __base::__alloc_traits __alloc_traits; | |
| 1265 | typedef typename __base::reference reference; | |
| 1266 | typedef typename __base::const_reference const_reference; | |
| 1267 | typedef typename __base::iterator iterator; | |
| 1268 | typedef typename __base::const_iterator const_iterator; | |
| 1269 | typedef typename __base::size_type size_type; | |
| 1270 | typedef typename __base::difference_type difference_type; | |
| 1293 | 1271 | |
| 1294 | typedef typename __base::pointer pointer; | |
| 1295 | typedef typename __base::const_pointer const_pointer; | |
| 1296 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 1297 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 1272 | typedef typename __base::pointer pointer; | |
| 1273 | typedef typename __base::const_pointer const_pointer; | |
| 1274 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 1275 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 1298 | 1276 | |
| 1299 | 1277 | using typename __base::__deque_range; |
| 1300 | 1278 | using typename __base::__deque_block_range; |
| ... | ... | @@ -1311,7 +1289,14 @@ public: |
| 1311 | 1289 | explicit deque(size_type __n, const _Allocator& __a); |
| 1312 | 1290 | #endif |
| 1313 | 1291 | deque(size_type __n, const value_type& __v); |
| 1314 | deque(size_type __n, const value_type& __v, const allocator_type& __a); | |
| 1292 | ||
| 1293 | template <class = __enable_if_t<__is_allocator<_Allocator>::value> > | |
| 1294 | deque(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a) | |
| 1295 | { | |
| 1296 | if (__n > 0) | |
| 1297 | __append(__n, __v); | |
| 1298 | } | |
| 1299 | ||
| 1315 | 1300 | template <class _InputIter> |
| 1316 | 1301 | deque(_InputIter __f, _InputIter __l, |
| 1317 | 1302 | typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0); |
| ... | ... | @@ -1588,23 +1573,24 @@ public: |
| 1588 | 1573 | void __move_assign(deque& __c, false_type); |
| 1589 | 1574 | }; |
| 1590 | 1575 | |
| 1591 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1576 | #if _LIBCPP_STD_VER >= 17 | |
| 1592 | 1577 | template<class _InputIterator, |
| 1593 | 1578 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 1594 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 1579 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1580 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 1595 | 1581 | > |
| 1596 | 1582 | deque(_InputIterator, _InputIterator) |
| 1597 | 1583 | -> deque<__iter_value_type<_InputIterator>, _Alloc>; |
| 1598 | 1584 | |
| 1599 | 1585 | template<class _InputIterator, |
| 1600 | 1586 | class _Alloc, |
| 1601 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 1587 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1588 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 1602 | 1589 | > |
| 1603 | 1590 | deque(_InputIterator, _InputIterator, _Alloc) |
| 1604 | 1591 | -> deque<__iter_value_type<_InputIterator>, _Alloc>; |
| 1605 | 1592 | #endif |
| 1606 | 1593 | |
| 1607 | ||
| 1608 | 1594 | template <class _Tp, class _Allocator> |
| 1609 | 1595 | deque<_Tp, _Allocator>::deque(size_type __n) |
| 1610 | 1596 | { |
| ... | ... | @@ -1629,14 +1615,6 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) |
| 1629 | 1615 | __append(__n, __v); |
| 1630 | 1616 | } |
| 1631 | 1617 | |
| 1632 | template <class _Tp, class _Allocator> | |
| 1633 | deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v, const allocator_type& __a) | |
| 1634 | : __base(__a) | |
| 1635 | { | |
| 1636 | if (__n > 0) | |
| 1637 | __append(__n, __v); | |
| 1638 | } | |
| 1639 | ||
| 1640 | 1618 | template <class _Tp, class _Allocator> |
| 1641 | 1619 | template <class _InputIter> |
| 1642 | 1620 | deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, |
| ... | ... | @@ -1672,7 +1650,7 @@ template <class _Tp, class _Allocator> |
| 1672 | 1650 | deque<_Tp, _Allocator>& |
| 1673 | 1651 | deque<_Tp, _Allocator>::operator=(const deque& __c) |
| 1674 | 1652 | { |
| 1675 | if (this != &__c) | |
| 1653 | if (this != _VSTD::addressof(__c)) | |
| 1676 | 1654 | { |
| 1677 | 1655 | __copy_assign_alloc(__c); |
| 1678 | 1656 | assign(__c.begin(), __c.end()); |
| ... | ... | @@ -1873,7 +1851,7 @@ typename deque<_Tp, _Allocator>::reference |
| 1873 | 1851 | deque<_Tp, _Allocator>::at(size_type __i) |
| 1874 | 1852 | { |
| 1875 | 1853 | if (__i >= __base::size()) |
| 1876 | __base::__throw_out_of_range(); | |
| 1854 | _VSTD::__throw_out_of_range("deque"); | |
| 1877 | 1855 | size_type __p = __base::__start_ + __i; |
| 1878 | 1856 | return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); |
| 1879 | 1857 | } |
| ... | ... | @@ -1884,7 +1862,7 @@ typename deque<_Tp, _Allocator>::const_reference |
| 1884 | 1862 | deque<_Tp, _Allocator>::at(size_type __i) const |
| 1885 | 1863 | { |
| 1886 | 1864 | if (__i >= __base::size()) |
| 1887 | __base::__throw_out_of_range(); | |
| 1865 | _VSTD::__throw_out_of_range("deque"); | |
| 1888 | 1866 | size_type __p = __base::__start_ + __i; |
| 1889 | 1867 | return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size); |
| 1890 | 1868 | } |
| ... | ... | @@ -2237,7 +2215,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty |
| 2237 | 2215 | size_type __de = __base::size() - __pos; |
| 2238 | 2216 | if (__n > __de) |
| 2239 | 2217 | { |
| 2240 | for (size_type __m = __n - __de; __m; --__m, ++__i, ++__base::size()) | |
| 2218 | for (size_type __m = __n - __de; __m; --__m, (void) ++__i, ++__base::size()) | |
| 2241 | 2219 | __alloc_traits::construct(__a, _VSTD::addressof(*__i), __v); |
| 2242 | 2220 | __n = __de; |
| 2243 | 2221 | } |
| ... | ... | @@ -2340,7 +2318,7 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, |
| 2340 | 2318 | if (__n > 0) |
| 2341 | 2319 | { |
| 2342 | 2320 | iterator __oen = __old_end - __n; |
| 2343 | for (iterator __j = __oen; __j != __old_end; ++__i, ++__j, ++__base::size()) | |
| 2321 | for (iterator __j = __oen; __j != __old_end; ++__i, (void) ++__j, ++__base::size()) | |
| 2344 | 2322 | __alloc_traits::construct(__a, _VSTD::addressof(*__i), _VSTD::move(*__j)); |
| 2345 | 2323 | if (__n < __de) |
| 2346 | 2324 | __old_end = _VSTD::move_backward(__old_end - __de, __oen, __old_end); |
lib/libcxx/include/errno.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- errno.h -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/exception+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- exception ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -328,6 +328,6 @@ rethrow_if_nested(const _Ep&, |
| 328 | 328 | { |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | } // std | |
| 331 | } // namespace std | |
| 332 | 332 | |
| 333 | 333 | #endif // _LIBCPP_EXCEPTION |
lib/libcxx/include/execution+6-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- execution ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -11,9 +11,14 @@ |
| 11 | 11 | #define _LIBCPP_EXECUTION |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <version> | |
| 14 | 15 | |
| 15 | 16 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
| 16 | 17 | # include <__pstl_execution> |
| 17 | 18 | #endif |
| 18 | 19 | |
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 19 | 24 | #endif // _LIBCPP_EXECUTION |
lib/libcxx/include/experimental/__config+5-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- __config ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -45,6 +45,10 @@ |
| 45 | 45 | #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ |
| 46 | 46 | } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL |
| 47 | 47 | |
| 48 | #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L | |
| 49 | #define _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES | |
| 50 | #endif | |
| 51 | ||
| 48 | 52 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES \ |
| 49 | 53 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace coroutines_v1 { |
| 50 | 54 |
lib/libcxx/include/experimental/__memory+5-1| ... | ... | @@ -10,13 +10,17 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___MEMORY |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___MEMORY |
| 12 | 12 | |
| 13 | #include <__functional_base> | |
| 13 | 14 | #include <__memory/allocator_arg_t.h> |
| 14 | 15 | #include <__memory/uses_allocator.h> |
| 15 | 16 | #include <experimental/__config> |
| 16 | 17 | #include <experimental/utility> // for erased_type |
| 17 | #include <__functional_base> | |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | #pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 20 | 24 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 21 | 25 | |
| 22 | 26 | template < |
lib/libcxx/include/experimental/algorithm+3-10| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- algorithm ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -31,20 +31,15 @@ ForwardIterator search(ForwardIterator first, ForwardIterator last, |
| 31 | 31 | |
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | #include <experimental/__config> | |
| 34 | #include <__debug> | |
| 35 | 35 | #include <algorithm> |
| 36 | #include <experimental/__config> | |
| 36 | 37 | #include <type_traits> |
| 37 | 38 | |
| 38 | #include <__debug> | |
| 39 | ||
| 40 | 39 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | 40 | #pragma GCC system_header |
| 42 | 41 | #endif |
| 43 | 42 | |
| 44 | _LIBCPP_PUSH_MACROS | |
| 45 | #include <__undef_macros> | |
| 46 | ||
| 47 | ||
| 48 | 43 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 49 | 44 | |
| 50 | 45 | template <class _ForwardIterator, class _Searcher> |
| ... | ... | @@ -54,6 +49,4 @@ _ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searc |
| 54 | 49 | |
| 55 | 50 | _LIBCPP_END_NAMESPACE_LFTS |
| 56 | 51 | |
| 57 | _LIBCPP_POP_MACROS | |
| 58 | ||
| 59 | 52 | #endif /* _LIBCPP_EXPERIMENTAL_ALGORITHM */ |
lib/libcxx/include/experimental/coroutine+8-8| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- coroutine -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -45,19 +45,19 @@ template <class P> struct hash<coroutine_handle<P>>; |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__debug> | |
| 49 | #include <cstddef> | |
| 48 | 50 | #include <experimental/__config> |
| 49 | #include <new> | |
| 50 | #include <type_traits> | |
| 51 | 51 | #include <functional> |
| 52 | 52 | #include <memory> // for hash<T*> |
| 53 | #include <cstddef> | |
| 54 | #include <__debug> | |
| 53 | #include <new> | |
| 54 | #include <type_traits> | |
| 55 | 55 | |
| 56 | 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 57 | 57 | #pragma GCC system_header |
| 58 | 58 | #endif |
| 59 | 59 | |
| 60 | #ifdef _LIBCPP_HAS_NO_COROUTINES | |
| 60 | #ifdef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES | |
| 61 | 61 | # if defined(_LIBCPP_WARNING) |
| 62 | 62 | _LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler") |
| 63 | 63 | # else |
| ... | ... | @@ -65,7 +65,7 @@ template <class P> struct hash<coroutine_handle<P>>; |
| 65 | 65 | # endif |
| 66 | 66 | #endif |
| 67 | 67 | |
| 68 | #ifndef _LIBCPP_HAS_NO_COROUTINES | |
| 68 | #ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES | |
| 69 | 69 | |
| 70 | 70 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_COROUTINES |
| 71 | 71 | |
| ... | ... | @@ -329,6 +329,6 @@ struct hash<_VSTD_CORO::coroutine_handle<_Tp> > { |
| 329 | 329 | |
| 330 | 330 | _LIBCPP_END_NAMESPACE_STD |
| 331 | 331 | |
| 332 | #endif // !defined(_LIBCPP_HAS_NO_COROUTINES) | |
| 332 | #endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES) | |
| 333 | 333 | |
| 334 | 334 | #endif /* _LIBCPP_EXPERIMENTAL_COROUTINE */ |
lib/libcxx/include/experimental/deque+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- deque ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -28,8 +28,8 @@ namespace pmr { |
| 28 | 28 | |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | #include <experimental/__config> | |
| 32 | 31 | #include <deque> |
| 32 | #include <experimental/__config> | |
| 33 | 33 | #include <experimental/memory_resource> |
| 34 | 34 | |
| 35 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/experimental/filesystem+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- filesystem -------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/experimental/forward_list+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- forward_list -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -29,8 +29,8 @@ namespace pmr { |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | #include <experimental/__config> |
| 32 | #include <forward_list> | |
| 33 | 32 | #include <experimental/memory_resource> |
| 33 | #include <forward_list> | |
| 34 | 34 | |
| 35 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | 36 | #pragma GCC system_header |
lib/libcxx/include/experimental/functional+5-7| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- functional --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -86,16 +86,15 @@ inline namespace fundamentals_v1 { |
| 86 | 86 | |
| 87 | 87 | */ |
| 88 | 88 | |
| 89 | #include <__debug> | |
| 89 | 90 | #include <__memory/uses_allocator.h> |
| 91 | #include <algorithm> | |
| 92 | #include <array> | |
| 90 | 93 | #include <experimental/__config> |
| 91 | 94 | #include <functional> |
| 92 | #include <algorithm> | |
| 93 | 95 | #include <type_traits> |
| 94 | #include <vector> | |
| 95 | #include <array> | |
| 96 | 96 | #include <unordered_map> |
| 97 | ||
| 98 | #include <__debug> | |
| 97 | #include <vector> | |
| 99 | 98 | |
| 100 | 99 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 101 | 100 | #pragma GCC system_header |
| ... | ... | @@ -104,7 +103,6 @@ inline namespace fundamentals_v1 { |
| 104 | 103 | _LIBCPP_PUSH_MACROS |
| 105 | 104 | #include <__undef_macros> |
| 106 | 105 | |
| 107 | ||
| 108 | 106 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 109 | 107 | |
| 110 | 108 | #if _LIBCPP_STD_VER > 11 |
lib/libcxx/include/experimental/iterator+10-7| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- iterator -------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -52,15 +52,18 @@ namespace std { |
| 52 | 52 | |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | #include <experimental/__config> | |
| 56 | ||
| 57 | #if _LIBCPP_STD_VER > 11 | |
| 58 | ||
| 59 | 55 | #include <__memory/addressof.h> |
| 60 | #include <__utility/move.h> | |
| 61 | 56 | #include <__utility/forward.h> |
| 57 | #include <__utility/move.h> | |
| 58 | #include <experimental/__config> | |
| 62 | 59 | #include <iterator> |
| 63 | 60 | |
| 61 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 62 | #pragma GCC system_header | |
| 63 | #endif | |
| 64 | ||
| 65 | #if _LIBCPP_STD_VER > 11 | |
| 66 | ||
| 64 | 67 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 65 | 68 | |
| 66 | 69 | template <class _Delim, class _CharT = char, class _Traits = char_traits<_CharT>> |
| ... | ... | @@ -111,6 +114,6 @@ make_ostream_joiner(basic_ostream<_CharT, _Traits>& __os, _Delim && __d) |
| 111 | 114 | |
| 112 | 115 | _LIBCPP_END_NAMESPACE_LFTS |
| 113 | 116 | |
| 114 | #endif /* _LIBCPP_STD_VER > 11 */ | |
| 117 | #endif // _LIBCPP_STD_VER > 11 | |
| 115 | 118 | |
| 116 | 119 | #endif // _LIBCPP_EXPERIMENTAL_ITERATOR |
lib/libcxx/include/experimental/list+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- list ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -29,8 +29,8 @@ namespace pmr { |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | #include <experimental/__config> |
| 32 | #include <list> | |
| 33 | 32 | #include <experimental/memory_resource> |
| 33 | #include <list> | |
| 34 | 34 | |
| 35 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | 36 | #pragma GCC system_header |
lib/libcxx/include/experimental/map+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- map ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -34,8 +34,8 @@ namespace pmr { |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | 36 | #include <experimental/__config> |
| 37 | #include <map> | |
| 38 | 37 | #include <experimental/memory_resource> |
| 38 | #include <map> | |
| 39 | 39 | |
| 40 | 40 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | 41 | #pragma GCC system_header |
lib/libcxx/include/experimental/memory_resource+9-15| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ memory_resource -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -64,18 +64,18 @@ namespace pmr { |
| 64 | 64 | |
| 65 | 65 | */ |
| 66 | 66 | |
| 67 | #include <__debug> | |
| 68 | #include <__tuple> | |
| 69 | #include <cstddef> | |
| 70 | #include <cstdlib> | |
| 67 | 71 | #include <experimental/__config> |
| 68 | 72 | #include <experimental/__memory> |
| 69 | 73 | #include <limits> |
| 70 | 74 | #include <memory> |
| 71 | 75 | #include <new> |
| 72 | 76 | #include <stdexcept> |
| 73 | #include <__tuple> | |
| 74 | 77 | #include <type_traits> |
| 75 | 78 | #include <utility> |
| 76 | #include <cstddef> | |
| 77 | #include <cstdlib> | |
| 78 | #include <__debug> | |
| 79 | 79 | |
| 80 | 80 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 81 | 81 | #pragma GCC system_header |
| ... | ... | @@ -183,11 +183,8 @@ public: |
| 183 | 183 | // 8.6.3, memory.polymorphic.allocator.mem |
| 184 | 184 | _LIBCPP_INLINE_VISIBILITY |
| 185 | 185 | _ValueType* allocate(size_t __n) { |
| 186 | if (__n > __max_size()) { | |
| 187 | __throw_length_error( | |
| 188 | "std::experimental::pmr::polymorphic_allocator<T>::allocate(size_t n)" | |
| 189 | " 'n' exceeds maximum supported size"); | |
| 190 | } | |
| 186 | if (__n > __max_size()) | |
| 187 | __throw_bad_array_new_length(); | |
| 191 | 188 | return static_cast<_ValueType*>( |
| 192 | 189 | __res_->allocate(__n * sizeof(_ValueType), _LIBCPP_ALIGNOF(_ValueType)) |
| 193 | 190 | ); |
| ... | ... | @@ -384,11 +381,8 @@ public: |
| 384 | 381 | private: |
| 385 | 382 | virtual void * do_allocate(size_t __bytes, size_t) |
| 386 | 383 | { |
| 387 | if (__bytes > __max_size()) { | |
| 388 | __throw_length_error( | |
| 389 | "std::experimental::pmr::resource_adaptor<T>::do_allocate(size_t bytes, size_t align)" | |
| 390 | " 'bytes' exceeds maximum supported size"); | |
| 391 | } | |
| 384 | if (__bytes > __max_size()) | |
| 385 | __throw_bad_array_new_length(); | |
| 392 | 386 | size_t __s = __aligned_allocation_size(__bytes, _MaxAlign) / _MaxAlign; |
| 393 | 387 | return __alloc_.allocate(__s); |
| 394 | 388 | } |
lib/libcxx/include/experimental/propagate_const+5-6| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ propagate_const -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -107,19 +107,18 @@ |
| 107 | 107 | */ |
| 108 | 108 | |
| 109 | 109 | #include <experimental/__config> |
| 110 | #include <functional> | |
| 111 | #include <type_traits> | |
| 112 | #include <utility> | |
| 113 | ||
| 110 | 114 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 111 | 115 | #pragma GCC system_header |
| 112 | 116 | #endif |
| 113 | 117 | |
| 114 | 118 | #if _LIBCPP_STD_VER > 11 |
| 115 | 119 | |
| 116 | #include <type_traits> | |
| 117 | #include <utility> | |
| 118 | #include <functional> | |
| 119 | ||
| 120 | 120 | _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 |
| 121 | 121 | |
| 122 | ||
| 123 | 122 | template <class _Tp> |
| 124 | 123 | class propagate_const; |
| 125 | 124 |
lib/libcxx/include/experimental/regex+6-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- regex ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -36,9 +36,9 @@ namespace pmr { |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | 38 | #include <experimental/__config> |
| 39 | #include <regex> | |
| 40 | #include <experimental/string> | |
| 41 | 39 | #include <experimental/memory_resource> |
| 40 | #include <experimental/string> | |
| 41 | #include <regex> | |
| 42 | 42 | |
| 43 | 43 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 44 | 44 | #pragma GCC system_header |
| ... | ... | @@ -52,9 +52,11 @@ using match_results = |
| 52 | 52 | polymorphic_allocator<_VSTD::sub_match<_BiDirIter>>>; |
| 53 | 53 | |
| 54 | 54 | typedef match_results<const char*> cmatch; |
| 55 | typedef match_results<const wchar_t*> wcmatch; | |
| 56 | 55 | typedef match_results<_VSTD_LFTS_PMR::string::const_iterator> smatch; |
| 56 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 57 | typedef match_results<const wchar_t*> wcmatch; | |
| 57 | 58 | typedef match_results<_VSTD_LFTS_PMR::wstring::const_iterator> wsmatch; |
| 59 | #endif | |
| 58 | 60 | |
| 59 | 61 | _LIBCPP_END_NAMESPACE_LFTS_PMR |
| 60 | 62 |
lib/libcxx/include/experimental/set+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- list ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -34,8 +34,8 @@ namespace pmr { |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | 36 | #include <experimental/__config> |
| 37 | #include <set> | |
| 38 | 37 | #include <experimental/memory_resource> |
| 38 | #include <set> | |
| 39 | 39 | |
| 40 | 40 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | 41 | #pragma GCC system_header |
lib/libcxx/include/experimental/simd+16-18| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------- simd ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -649,10 +649,10 @@ public: |
| 649 | 649 | |
| 650 | 650 | */ |
| 651 | 651 | |
| 652 | #include <experimental/__config> | |
| 653 | 652 | #include <algorithm> |
| 654 | 653 | #include <array> |
| 655 | 654 | #include <cstddef> |
| 655 | #include <experimental/__config> | |
| 656 | 656 | #include <functional> |
| 657 | 657 | |
| 658 | 658 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -689,7 +689,7 @@ class __simd_storage<_Tp, __simd_abi<_StorageKind::_Array, __num_element>> { |
| 689 | 689 | friend struct simd_mask; |
| 690 | 690 | |
| 691 | 691 | public: |
| 692 | _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; | |
| 692 | _Tp __get(size_t __index) const noexcept { return __storage_[__index]; } | |
| 693 | 693 | void __set(size_t __index, _Tp __val) noexcept { |
| 694 | 694 | __storage_[__index] = __val; |
| 695 | 695 | } |
| ... | ... | @@ -706,7 +706,7 @@ class __simd_storage<_Tp, __simd_abi<_StorageKind::_Scalar, 1>> { |
| 706 | 706 | friend struct simd_mask; |
| 707 | 707 | |
| 708 | 708 | public: |
| 709 | _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; }; | |
| 709 | _Tp __get(size_t __index) const noexcept { return (&__storage_)[__index]; } | |
| 710 | 710 | void __set(size_t __index, _Tp __val) noexcept { |
| 711 | 711 | (&__storage_)[__index] = __val; |
| 712 | 712 | } |
| ... | ... | @@ -770,7 +770,7 @@ struct __vec_ext_traits { |
| 770 | 770 | _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 29); \ |
| 771 | 771 | _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 30); \ |
| 772 | 772 | _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 31); \ |
| 773 | _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32); | |
| 773 | _LIBCPP_SPECIALIZE_VEC_EXT(_TYPE, 32) | |
| 774 | 774 | |
| 775 | 775 | _LIBCPP_SPECIALIZE_VEC_EXT_32(char); |
| 776 | 776 | _LIBCPP_SPECIALIZE_VEC_EXT_32(char16_t); |
| ... | ... | @@ -808,7 +808,7 @@ class __simd_storage<_Tp, __simd_abi<_StorageKind::_VecExt, __num_element>> { |
| 808 | 808 | friend struct simd_mask; |
| 809 | 809 | |
| 810 | 810 | public: |
| 811 | _Tp __get(size_t __index) const noexcept { return __storage_[__index]; }; | |
| 811 | _Tp __get(size_t __index) const noexcept { return __storage_[__index]; } | |
| 812 | 812 | void __set(size_t __index, _Tp __val) noexcept { |
| 813 | 813 | __storage_[__index] = __val; |
| 814 | 814 | } |
| ... | ... | @@ -963,7 +963,7 @@ template <int _Np> |
| 963 | 963 | using fixed_size = __simd_abi<_StorageKind::_Array, _Np>; |
| 964 | 964 | |
| 965 | 965 | template <class _Tp> |
| 966 | _LIBCPP_INLINE_VAR constexpr size_t max_fixed_size = 32; | |
| 966 | inline constexpr size_t max_fixed_size = 32; | |
| 967 | 967 | |
| 968 | 968 | template <class _Tp> |
| 969 | 969 | using compatible = fixed_size<16 / sizeof(_Tp)>; |
| ... | ... | @@ -990,10 +990,10 @@ struct element_aligned_tag {}; |
| 990 | 990 | struct vector_aligned_tag {}; |
| 991 | 991 | template <size_t> |
| 992 | 992 | struct overaligned_tag {}; |
| 993 | _LIBCPP_INLINE_VAR constexpr element_aligned_tag element_aligned{}; | |
| 994 | _LIBCPP_INLINE_VAR constexpr vector_aligned_tag vector_aligned{}; | |
| 993 | inline constexpr element_aligned_tag element_aligned{}; | |
| 994 | inline constexpr vector_aligned_tag vector_aligned{}; | |
| 995 | 995 | template <size_t _Np> |
| 996 | _LIBCPP_INLINE_VAR constexpr overaligned_tag<_Np> overaligned{}; | |
| 996 | inline constexpr overaligned_tag<_Np> overaligned{}; | |
| 997 | 997 | |
| 998 | 998 | // traits [simd.traits] |
| 999 | 999 | template <class _Tp> |
| ... | ... | @@ -1032,14 +1032,13 @@ struct is_simd_flag_type<overaligned_tag<_Align>> |
| 1032 | 1032 | : std::integral_constant<bool, true> {}; |
| 1033 | 1033 | |
| 1034 | 1034 | template <class _Tp> |
| 1035 | _LIBCPP_INLINE_VAR constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value; | |
| 1035 | inline constexpr bool is_abi_tag_v = is_abi_tag<_Tp>::value; | |
| 1036 | 1036 | template <class _Tp> |
| 1037 | _LIBCPP_INLINE_VAR constexpr bool is_simd_v = is_simd<_Tp>::value; | |
| 1037 | inline constexpr bool is_simd_v = is_simd<_Tp>::value; | |
| 1038 | 1038 | template <class _Tp> |
| 1039 | _LIBCPP_INLINE_VAR constexpr bool is_simd_mask_v = is_simd_mask<_Tp>::value; | |
| 1039 | inline constexpr bool is_simd_mask_v = is_simd_mask<_Tp>::value; | |
| 1040 | 1040 | template <class _Tp> |
| 1041 | _LIBCPP_INLINE_VAR constexpr bool is_simd_flag_type_v = | |
| 1042 | is_simd_flag_type<_Tp>::value; | |
| 1041 | inline constexpr bool is_simd_flag_type_v = is_simd_flag_type<_Tp>::value; | |
| 1043 | 1042 | template <class _Tp, size_t _Np> |
| 1044 | 1043 | struct abi_for_size { |
| 1045 | 1044 | using type = simd_abi::fixed_size<_Np>; |
| ... | ... | @@ -1064,11 +1063,10 @@ template <class _Tp, class _Up = typename _Tp::value_type> |
| 1064 | 1063 | struct memory_alignment; |
| 1065 | 1064 | |
| 1066 | 1065 | template <class _Tp, class _Abi = simd_abi::compatible<_Tp>> |
| 1067 | _LIBCPP_INLINE_VAR constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value; | |
| 1066 | inline constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value; | |
| 1068 | 1067 | |
| 1069 | 1068 | template <class _Tp, class _Up = typename _Tp::value_type> |
| 1070 | _LIBCPP_INLINE_VAR constexpr size_t memory_alignment_v = | |
| 1071 | memory_alignment<_Tp, _Up>::value; | |
| 1069 | inline constexpr size_t memory_alignment_v = memory_alignment<_Tp, _Up>::value; | |
| 1072 | 1070 | |
| 1073 | 1071 | // class template simd [simd.class] |
| 1074 | 1072 | template <class _Tp> |
lib/libcxx/include/experimental/string+4-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- string ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -38,8 +38,8 @@ namespace pmr { |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | 40 | #include <experimental/__config> |
| 41 | #include <string> | |
| 42 | 41 | #include <experimental/memory_resource> |
| 42 | #include <string> | |
| 43 | 43 | |
| 44 | 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 45 | 45 | #pragma GCC system_header |
| ... | ... | @@ -54,7 +54,9 @@ using basic_string = |
| 54 | 54 | typedef basic_string<char> string; |
| 55 | 55 | typedef basic_string<char16_t> u16string; |
| 56 | 56 | typedef basic_string<char32_t> u32string; |
| 57 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 57 | 58 | typedef basic_string<wchar_t> wstring; |
| 59 | #endif | |
| 58 | 60 | |
| 59 | 61 | _LIBCPP_END_NAMESPACE_LFTS_PMR |
| 60 | 62 |
lib/libcxx/include/experimental/type_traits+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- type_traits -------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/experimental/unordered_map+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- unordered_map ------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -40,8 +40,8 @@ namespace pmr { |
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | 42 | #include <experimental/__config> |
| 43 | #include <unordered_map> | |
| 44 | 43 | #include <experimental/memory_resource> |
| 44 | #include <unordered_map> | |
| 45 | 45 | |
| 46 | 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 47 | 47 | #pragma GCC system_header |
lib/libcxx/include/experimental/unordered_set+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- unordered_set ------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -34,8 +34,8 @@ namespace pmr { |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | 36 | #include <experimental/__config> |
| 37 | #include <unordered_set> | |
| 38 | 37 | #include <experimental/memory_resource> |
| 38 | #include <unordered_set> | |
| 39 | 39 | |
| 40 | 40 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | 41 | #pragma GCC system_header |
lib/libcxx/include/experimental/utility+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- utility ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/experimental/vector+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- vector ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -29,8 +29,8 @@ namespace pmr { |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | #include <experimental/__config> |
| 32 | #include <vector> | |
| 33 | 32 | #include <experimental/memory_resource> |
| 33 | #include <vector> | |
| 34 | 34 | |
| 35 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | 36 | #pragma GCC system_header |
lib/libcxx/include/ext/__hash+3-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- hash_set ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -13,8 +13,8 @@ |
| 13 | 13 | #pragma GCC system_header |
| 14 | 14 | |
| 15 | 15 | #include <__string> |
| 16 | #include <string> | |
| 17 | 16 | #include <cstring> |
| 17 | #include <string> | |
| 18 | 18 | |
| 19 | 19 | namespace __gnu_cxx { |
| 20 | 20 | |
| ... | ... | @@ -129,6 +129,6 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> |
| 129 | 129 | return __c; |
| 130 | 130 | } |
| 131 | 131 | }; |
| 132 | } | |
| 132 | } // namespace __gnu_cxx | |
| 133 | 133 | |
| 134 | 134 | #endif // _LIBCPP_EXT_HASH |
lib/libcxx/include/ext/hash_map+3-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- hash_map ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -203,10 +203,10 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 203 | 203 | |
| 204 | 204 | #include <__config> |
| 205 | 205 | #include <__hash_table> |
| 206 | #include <ext/__hash> | |
| 206 | 207 | #include <functional> |
| 207 | 208 | #include <stdexcept> |
| 208 | 209 | #include <type_traits> |
| 209 | #include <ext/__hash> | |
| 210 | 210 | |
| 211 | 211 | #if defined(__DEPRECATED) && __DEPRECATED |
| 212 | 212 | #if defined(_LIBCPP_WARNING) |
| ... | ... | @@ -979,6 +979,6 @@ operator!=(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, |
| 979 | 979 | return !(__x == __y); |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | } // __gnu_cxx | |
| 982 | } // namespace __gnu_cxx | |
| 983 | 983 | |
| 984 | 984 | #endif // _LIBCPP_HASH_MAP |
lib/libcxx/include/ext/hash_set+7-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- hash_set ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -194,8 +194,8 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 194 | 194 | |
| 195 | 195 | #include <__config> |
| 196 | 196 | #include <__hash_table> |
| 197 | #include <functional> | |
| 198 | 197 | #include <ext/__hash> |
| 198 | #include <functional> | |
| 199 | 199 | |
| 200 | 200 | #if defined(__DEPRECATED) && __DEPRECATED |
| 201 | 201 | #if defined(_LIBCPP_WARNING) |
| ... | ... | @@ -205,6 +205,10 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 205 | 205 | #endif |
| 206 | 206 | #endif |
| 207 | 207 | |
| 208 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 209 | #pragma GCC system_header | |
| 210 | #endif | |
| 211 | ||
| 208 | 212 | namespace __gnu_cxx { |
| 209 | 213 | |
| 210 | 214 | |
| ... | ... | @@ -654,6 +658,6 @@ operator!=(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x, |
| 654 | 658 | return !(__x == __y); |
| 655 | 659 | } |
| 656 | 660 | |
| 657 | } // __gnu_cxx | |
| 661 | } // namespace __gnu_cxx | |
| 658 | 662 | |
| 659 | 663 | #endif // _LIBCPP_HASH_SET |
lib/libcxx/include/fenv.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- math.h ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/filesystem+31-2774| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- filesystem -------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | /* |
| 12 | 12 | filesystem synopsis |
| 13 | 13 | |
| 14 | namespace std { namespace filesystem { | |
| 14 | namespace std::filesystem { | |
| 15 | 15 | |
| 16 | 16 | class path; |
| 17 | 17 | |
| ... | ... | @@ -48,13 +48,13 @@ |
| 48 | 48 | |
| 49 | 49 | // enable directory_iterator range-based for statements |
| 50 | 50 | directory_iterator begin(directory_iterator iter) noexcept; |
| 51 | directory_iterator end(const directory_iterator&) noexcept; | |
| 51 | directory_iterator end(directory_iterator) noexcept; | |
| 52 | 52 | |
| 53 | 53 | class recursive_directory_iterator; |
| 54 | 54 | |
| 55 | 55 | // enable recursive_directory_iterator range-based for statements |
| 56 | 56 | recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; |
| 57 | recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; | |
| 57 | recursive_directory_iterator end(recursive_directory_iterator) noexcept; | |
| 58 | 58 | |
| 59 | 59 | class file_status; |
| 60 | 60 | |
| ... | ... | @@ -224,2789 +224,46 @@ |
| 224 | 224 | path weakly_canonical(path const& p); |
| 225 | 225 | path weakly_canonical(path const& p, error_code& ec); |
| 226 | 226 | |
| 227 | } // namespace std::filesystem | |
| 227 | 228 | |
| 228 | } } // namespaces std::filesystem | |
| 229 | template <> | |
| 230 | inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; | |
| 231 | template <> | |
| 232 | inline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; | |
| 233 | ||
| 234 | template <> | |
| 235 | inline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; | |
| 236 | template <> | |
| 237 | inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; | |
| 229 | 238 | |
| 230 | 239 | */ |
| 231 | 240 | |
| 232 | #include <__availability> | |
| 233 | 241 | #include <__config> |
| 234 | #include <__debug> | |
| 235 | #include <__utility/forward.h> | |
| 236 | #include <chrono> | |
| 242 | #include <__filesystem/copy_options.h> | |
| 243 | #include <__filesystem/directory_entry.h> | |
| 244 | #include <__filesystem/directory_iterator.h> | |
| 245 | #include <__filesystem/directory_options.h> | |
| 246 | #include <__filesystem/file_status.h> | |
| 247 | #include <__filesystem/file_time_type.h> | |
| 248 | #include <__filesystem/file_type.h> | |
| 249 | #include <__filesystem/filesystem_error.h> | |
| 250 | #include <__filesystem/operations.h> | |
| 251 | #include <__filesystem/path.h> | |
| 252 | #include <__filesystem/path_iterator.h> | |
| 253 | #include <__filesystem/perm_options.h> | |
| 254 | #include <__filesystem/perms.h> | |
| 255 | #include <__filesystem/recursive_directory_iterator.h> | |
| 256 | #include <__filesystem/space_info.h> | |
| 257 | #include <__filesystem/u8path.h> | |
| 237 | 258 | #include <compare> |
| 238 | #include <cstddef> | |
| 239 | #include <cstdlib> | |
| 240 | #include <iosfwd> | |
| 241 | #include <iterator> | |
| 242 | #include <memory> | |
| 243 | #include <stack> | |
| 244 | #include <string> | |
| 245 | #include <string_view> | |
| 246 | #include <system_error> | |
| 247 | #include <utility> | |
| 248 | 259 | #include <version> |
| 249 | 260 | |
| 250 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 251 | # include <locale> | |
| 252 | # include <iomanip> // for quoted | |
| 253 | #endif | |
| 254 | ||
| 255 | 261 | #if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) |
| 256 | # error "The Filesystem library is not supported by this configuration of libc++" | |
| 262 | # error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled" | |
| 257 | 263 | #endif |
| 258 | 264 | |
| 259 | 265 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 260 | 266 | #pragma GCC system_header |
| 261 | 267 | #endif |
| 262 | 268 | |
| 263 | _LIBCPP_PUSH_MACROS | |
| 264 | #include <__undef_macros> | |
| 265 | ||
| 266 | #ifndef _LIBCPP_CXX03_LANG | |
| 267 | ||
| 268 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM | |
| 269 | ||
| 270 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 271 | ||
| 272 | typedef chrono::time_point<_FilesystemClock> file_time_type; | |
| 273 | ||
| 274 | struct _LIBCPP_TYPE_VIS space_info { | |
| 275 | uintmax_t capacity; | |
| 276 | uintmax_t free; | |
| 277 | uintmax_t available; | |
| 278 | }; | |
| 279 | ||
| 280 | // On Windows, the library never identifies files as block, character, fifo | |
| 281 | // or socket. | |
| 282 | enum class _LIBCPP_ENUM_VIS file_type : signed char { | |
| 283 | none = 0, | |
| 284 | not_found = -1, | |
| 285 | regular = 1, | |
| 286 | directory = 2, | |
| 287 | symlink = 3, | |
| 288 | block = 4, | |
| 289 | character = 5, | |
| 290 | fifo = 6, | |
| 291 | socket = 7, | |
| 292 | unknown = 8 | |
| 293 | }; | |
| 294 | ||
| 295 | // On Windows, these permission bits map to one single readonly flag per | |
| 296 | // file, and the executable bit is always returned as set. When setting | |
| 297 | // permissions, as long as the write bit is set for either owner, group or | |
| 298 | // others, the readonly flag is cleared. | |
| 299 | enum class _LIBCPP_ENUM_VIS perms : unsigned { | |
| 300 | none = 0, | |
| 301 | ||
| 302 | owner_read = 0400, | |
| 303 | owner_write = 0200, | |
| 304 | owner_exec = 0100, | |
| 305 | owner_all = 0700, | |
| 306 | ||
| 307 | group_read = 040, | |
| 308 | group_write = 020, | |
| 309 | group_exec = 010, | |
| 310 | group_all = 070, | |
| 311 | ||
| 312 | others_read = 04, | |
| 313 | others_write = 02, | |
| 314 | others_exec = 01, | |
| 315 | others_all = 07, | |
| 316 | ||
| 317 | all = 0777, | |
| 318 | ||
| 319 | set_uid = 04000, | |
| 320 | set_gid = 02000, | |
| 321 | sticky_bit = 01000, | |
| 322 | mask = 07777, | |
| 323 | unknown = 0xFFFF, | |
| 324 | }; | |
| 325 | ||
| 326 | _LIBCPP_INLINE_VISIBILITY | |
| 327 | inline constexpr perms operator&(perms _LHS, perms _RHS) { | |
| 328 | return static_cast<perms>(static_cast<unsigned>(_LHS) & | |
| 329 | static_cast<unsigned>(_RHS)); | |
| 330 | } | |
| 331 | ||
| 332 | _LIBCPP_INLINE_VISIBILITY | |
| 333 | inline constexpr perms operator|(perms _LHS, perms _RHS) { | |
| 334 | return static_cast<perms>(static_cast<unsigned>(_LHS) | | |
| 335 | static_cast<unsigned>(_RHS)); | |
| 336 | } | |
| 337 | ||
| 338 | _LIBCPP_INLINE_VISIBILITY | |
| 339 | inline constexpr perms operator^(perms _LHS, perms _RHS) { | |
| 340 | return static_cast<perms>(static_cast<unsigned>(_LHS) ^ | |
| 341 | static_cast<unsigned>(_RHS)); | |
| 342 | } | |
| 343 | ||
| 344 | _LIBCPP_INLINE_VISIBILITY | |
| 345 | inline constexpr perms operator~(perms _LHS) { | |
| 346 | return static_cast<perms>(~static_cast<unsigned>(_LHS)); | |
| 347 | } | |
| 348 | ||
| 349 | _LIBCPP_INLINE_VISIBILITY | |
| 350 | inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; } | |
| 351 | ||
| 352 | _LIBCPP_INLINE_VISIBILITY | |
| 353 | inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; } | |
| 354 | ||
| 355 | _LIBCPP_INLINE_VISIBILITY | |
| 356 | inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } | |
| 357 | ||
| 358 | enum class _LIBCPP_ENUM_VIS perm_options : unsigned char { | |
| 359 | replace = 1, | |
| 360 | add = 2, | |
| 361 | remove = 4, | |
| 362 | nofollow = 8 | |
| 363 | }; | |
| 364 | ||
| 365 | _LIBCPP_INLINE_VISIBILITY | |
| 366 | inline constexpr perm_options operator&(perm_options _LHS, perm_options _RHS) { | |
| 367 | return static_cast<perm_options>(static_cast<unsigned>(_LHS) & | |
| 368 | static_cast<unsigned>(_RHS)); | |
| 369 | } | |
| 370 | ||
| 371 | _LIBCPP_INLINE_VISIBILITY | |
| 372 | inline constexpr perm_options operator|(perm_options _LHS, perm_options _RHS) { | |
| 373 | return static_cast<perm_options>(static_cast<unsigned>(_LHS) | | |
| 374 | static_cast<unsigned>(_RHS)); | |
| 375 | } | |
| 376 | ||
| 377 | _LIBCPP_INLINE_VISIBILITY | |
| 378 | inline constexpr perm_options operator^(perm_options _LHS, perm_options _RHS) { | |
| 379 | return static_cast<perm_options>(static_cast<unsigned>(_LHS) ^ | |
| 380 | static_cast<unsigned>(_RHS)); | |
| 381 | } | |
| 382 | ||
| 383 | _LIBCPP_INLINE_VISIBILITY | |
| 384 | inline constexpr perm_options operator~(perm_options _LHS) { | |
| 385 | return static_cast<perm_options>(~static_cast<unsigned>(_LHS)); | |
| 386 | } | |
| 387 | ||
| 388 | _LIBCPP_INLINE_VISIBILITY | |
| 389 | inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) { | |
| 390 | return _LHS = _LHS & _RHS; | |
| 391 | } | |
| 392 | ||
| 393 | _LIBCPP_INLINE_VISIBILITY | |
| 394 | inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) { | |
| 395 | return _LHS = _LHS | _RHS; | |
| 396 | } | |
| 397 | ||
| 398 | _LIBCPP_INLINE_VISIBILITY | |
| 399 | inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) { | |
| 400 | return _LHS = _LHS ^ _RHS; | |
| 401 | } | |
| 402 | ||
| 403 | enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { | |
| 404 | none = 0, | |
| 405 | skip_existing = 1, | |
| 406 | overwrite_existing = 2, | |
| 407 | update_existing = 4, | |
| 408 | recursive = 8, | |
| 409 | copy_symlinks = 16, | |
| 410 | skip_symlinks = 32, | |
| 411 | directories_only = 64, | |
| 412 | create_symlinks = 128, | |
| 413 | create_hard_links = 256, | |
| 414 | __in_recursive_copy = 512, | |
| 415 | }; | |
| 416 | ||
| 417 | _LIBCPP_INLINE_VISIBILITY | |
| 418 | inline constexpr copy_options operator&(copy_options _LHS, copy_options _RHS) { | |
| 419 | return static_cast<copy_options>(static_cast<unsigned short>(_LHS) & | |
| 420 | static_cast<unsigned short>(_RHS)); | |
| 421 | } | |
| 422 | ||
| 423 | _LIBCPP_INLINE_VISIBILITY | |
| 424 | inline constexpr copy_options operator|(copy_options _LHS, copy_options _RHS) { | |
| 425 | return static_cast<copy_options>(static_cast<unsigned short>(_LHS) | | |
| 426 | static_cast<unsigned short>(_RHS)); | |
| 427 | } | |
| 428 | ||
| 429 | _LIBCPP_INLINE_VISIBILITY | |
| 430 | inline constexpr copy_options operator^(copy_options _LHS, copy_options _RHS) { | |
| 431 | return static_cast<copy_options>(static_cast<unsigned short>(_LHS) ^ | |
| 432 | static_cast<unsigned short>(_RHS)); | |
| 433 | } | |
| 434 | ||
| 435 | _LIBCPP_INLINE_VISIBILITY | |
| 436 | inline constexpr copy_options operator~(copy_options _LHS) { | |
| 437 | return static_cast<copy_options>(~static_cast<unsigned short>(_LHS)); | |
| 438 | } | |
| 439 | ||
| 440 | _LIBCPP_INLINE_VISIBILITY | |
| 441 | inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) { | |
| 442 | return _LHS = _LHS & _RHS; | |
| 443 | } | |
| 444 | ||
| 445 | _LIBCPP_INLINE_VISIBILITY | |
| 446 | inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) { | |
| 447 | return _LHS = _LHS | _RHS; | |
| 448 | } | |
| 449 | ||
| 450 | _LIBCPP_INLINE_VISIBILITY | |
| 451 | inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) { | |
| 452 | return _LHS = _LHS ^ _RHS; | |
| 453 | } | |
| 454 | ||
| 455 | enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { | |
| 456 | none = 0, | |
| 457 | follow_directory_symlink = 1, | |
| 458 | skip_permission_denied = 2 | |
| 459 | }; | |
| 460 | ||
| 461 | _LIBCPP_INLINE_VISIBILITY | |
| 462 | inline constexpr directory_options operator&(directory_options _LHS, | |
| 463 | directory_options _RHS) { | |
| 464 | return static_cast<directory_options>(static_cast<unsigned char>(_LHS) & | |
| 465 | static_cast<unsigned char>(_RHS)); | |
| 466 | } | |
| 467 | ||
| 468 | _LIBCPP_INLINE_VISIBILITY | |
| 469 | inline constexpr directory_options operator|(directory_options _LHS, | |
| 470 | directory_options _RHS) { | |
| 471 | return static_cast<directory_options>(static_cast<unsigned char>(_LHS) | | |
| 472 | static_cast<unsigned char>(_RHS)); | |
| 473 | } | |
| 474 | ||
| 475 | _LIBCPP_INLINE_VISIBILITY | |
| 476 | inline constexpr directory_options operator^(directory_options _LHS, | |
| 477 | directory_options _RHS) { | |
| 478 | return static_cast<directory_options>(static_cast<unsigned char>(_LHS) ^ | |
| 479 | static_cast<unsigned char>(_RHS)); | |
| 480 | } | |
| 481 | ||
| 482 | _LIBCPP_INLINE_VISIBILITY | |
| 483 | inline constexpr directory_options operator~(directory_options _LHS) { | |
| 484 | return static_cast<directory_options>(~static_cast<unsigned char>(_LHS)); | |
| 485 | } | |
| 486 | ||
| 487 | _LIBCPP_INLINE_VISIBILITY | |
| 488 | inline directory_options& operator&=(directory_options& _LHS, | |
| 489 | directory_options _RHS) { | |
| 490 | return _LHS = _LHS & _RHS; | |
| 491 | } | |
| 492 | ||
| 493 | _LIBCPP_INLINE_VISIBILITY | |
| 494 | inline directory_options& operator|=(directory_options& _LHS, | |
| 495 | directory_options _RHS) { | |
| 496 | return _LHS = _LHS | _RHS; | |
| 497 | } | |
| 498 | ||
| 499 | _LIBCPP_INLINE_VISIBILITY | |
| 500 | inline directory_options& operator^=(directory_options& _LHS, | |
| 501 | directory_options _RHS) { | |
| 502 | return _LHS = _LHS ^ _RHS; | |
| 503 | } | |
| 504 | ||
| 505 | class _LIBCPP_TYPE_VIS file_status { | |
| 506 | public: | |
| 507 | // constructors | |
| 508 | _LIBCPP_INLINE_VISIBILITY | |
| 509 | file_status() noexcept : file_status(file_type::none) {} | |
| 510 | _LIBCPP_INLINE_VISIBILITY | |
| 511 | explicit file_status(file_type __ft, perms __prms = perms::unknown) noexcept | |
| 512 | : __ft_(__ft), | |
| 513 | __prms_(__prms) {} | |
| 514 | ||
| 515 | file_status(const file_status&) noexcept = default; | |
| 516 | file_status(file_status&&) noexcept = default; | |
| 517 | ||
| 518 | _LIBCPP_INLINE_VISIBILITY | |
| 519 | ~file_status() {} | |
| 520 | ||
| 521 | file_status& operator=(const file_status&) noexcept = default; | |
| 522 | file_status& operator=(file_status&&) noexcept = default; | |
| 523 | ||
| 524 | // observers | |
| 525 | _LIBCPP_INLINE_VISIBILITY | |
| 526 | file_type type() const noexcept { return __ft_; } | |
| 527 | ||
| 528 | _LIBCPP_INLINE_VISIBILITY | |
| 529 | perms permissions() const noexcept { return __prms_; } | |
| 530 | ||
| 531 | // modifiers | |
| 532 | _LIBCPP_INLINE_VISIBILITY | |
| 533 | void type(file_type __ft) noexcept { __ft_ = __ft; } | |
| 534 | ||
| 535 | _LIBCPP_INLINE_VISIBILITY | |
| 536 | void permissions(perms __p) noexcept { __prms_ = __p; } | |
| 537 | ||
| 538 | private: | |
| 539 | file_type __ft_; | |
| 540 | perms __prms_; | |
| 541 | }; | |
| 542 | ||
| 543 | class _LIBCPP_TYPE_VIS directory_entry; | |
| 544 | ||
| 545 | template <class _Tp> | |
| 546 | struct __can_convert_char { | |
| 547 | static const bool value = false; | |
| 548 | }; | |
| 549 | template <class _Tp> | |
| 550 | struct __can_convert_char<const _Tp> : public __can_convert_char<_Tp> {}; | |
| 551 | template <> | |
| 552 | struct __can_convert_char<char> { | |
| 553 | static const bool value = true; | |
| 554 | using __char_type = char; | |
| 555 | }; | |
| 556 | template <> | |
| 557 | struct __can_convert_char<wchar_t> { | |
| 558 | static const bool value = true; | |
| 559 | using __char_type = wchar_t; | |
| 560 | }; | |
| 561 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 562 | template <> | |
| 563 | struct __can_convert_char<char8_t> { | |
| 564 | static const bool value = true; | |
| 565 | using __char_type = char8_t; | |
| 566 | }; | |
| 567 | #endif | |
| 568 | template <> | |
| 569 | struct __can_convert_char<char16_t> { | |
| 570 | static const bool value = true; | |
| 571 | using __char_type = char16_t; | |
| 572 | }; | |
| 573 | template <> | |
| 574 | struct __can_convert_char<char32_t> { | |
| 575 | static const bool value = true; | |
| 576 | using __char_type = char32_t; | |
| 577 | }; | |
| 578 | ||
| 579 | template <class _ECharT> | |
| 580 | typename enable_if<__can_convert_char<_ECharT>::value, bool>::type | |
| 581 | __is_separator(_ECharT __e) { | |
| 582 | #if defined(_LIBCPP_WIN32API) | |
| 583 | return __e == _ECharT('/') || __e == _ECharT('\\'); | |
| 584 | #else | |
| 585 | return __e == _ECharT('/'); | |
| 586 | #endif | |
| 587 | } | |
| 588 | ||
| 589 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 590 | typedef u8string __u8_string; | |
| 591 | #else | |
| 592 | typedef string __u8_string; | |
| 593 | #endif | |
| 594 | ||
| 595 | struct _NullSentinel {}; | |
| 596 | ||
| 597 | template <class _Tp> | |
| 598 | using _Void = void; | |
| 599 | ||
| 600 | template <class _Tp, class = void> | |
| 601 | struct __is_pathable_string : public false_type {}; | |
| 602 | ||
| 603 | template <class _ECharT, class _Traits, class _Alloc> | |
| 604 | struct __is_pathable_string< | |
| 605 | basic_string<_ECharT, _Traits, _Alloc>, | |
| 606 | _Void<typename __can_convert_char<_ECharT>::__char_type> > | |
| 607 | : public __can_convert_char<_ECharT> { | |
| 608 | using _Str = basic_string<_ECharT, _Traits, _Alloc>; | |
| 609 | using _Base = __can_convert_char<_ECharT>; | |
| 610 | static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } | |
| 611 | static _ECharT const* __range_end(_Str const& __s) { | |
| 612 | return __s.data() + __s.length(); | |
| 613 | } | |
| 614 | static _ECharT __first_or_null(_Str const& __s) { | |
| 615 | return __s.empty() ? _ECharT{} : __s[0]; | |
| 616 | } | |
| 617 | }; | |
| 618 | ||
| 619 | template <class _ECharT, class _Traits> | |
| 620 | struct __is_pathable_string< | |
| 621 | basic_string_view<_ECharT, _Traits>, | |
| 622 | _Void<typename __can_convert_char<_ECharT>::__char_type> > | |
| 623 | : public __can_convert_char<_ECharT> { | |
| 624 | using _Str = basic_string_view<_ECharT, _Traits>; | |
| 625 | using _Base = __can_convert_char<_ECharT>; | |
| 626 | static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } | |
| 627 | static _ECharT const* __range_end(_Str const& __s) { | |
| 628 | return __s.data() + __s.length(); | |
| 629 | } | |
| 630 | static _ECharT __first_or_null(_Str const& __s) { | |
| 631 | return __s.empty() ? _ECharT{} : __s[0]; | |
| 632 | } | |
| 633 | }; | |
| 634 | ||
| 635 | template <class _Source, class _DS = typename decay<_Source>::type, | |
| 636 | class _UnqualPtrType = | |
| 637 | typename remove_const<typename remove_pointer<_DS>::type>::type, | |
| 638 | bool _IsCharPtr = is_pointer<_DS>::value&& | |
| 639 | __can_convert_char<_UnqualPtrType>::value> | |
| 640 | struct __is_pathable_char_array : false_type {}; | |
| 641 | ||
| 642 | template <class _Source, class _ECharT, class _UPtr> | |
| 643 | struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> | |
| 644 | : __can_convert_char<typename remove_const<_ECharT>::type> { | |
| 645 | using _Base = __can_convert_char<typename remove_const<_ECharT>::type>; | |
| 646 | ||
| 647 | static _ECharT const* __range_begin(const _ECharT* __b) { return __b; } | |
| 648 | static _ECharT const* __range_end(const _ECharT* __b) { | |
| 649 | using _Iter = const _ECharT*; | |
| 650 | const _ECharT __sentinel = _ECharT{}; | |
| 651 | _Iter __e = __b; | |
| 652 | for (; *__e != __sentinel; ++__e) | |
| 653 | ; | |
| 654 | return __e; | |
| 655 | } | |
| 656 | ||
| 657 | static _ECharT __first_or_null(const _ECharT* __b) { return *__b; } | |
| 658 | }; | |
| 659 | ||
| 660 | template <class _Iter, bool _IsIt = __is_cpp17_input_iterator<_Iter>::value, | |
| 661 | class = void> | |
| 662 | struct __is_pathable_iter : false_type {}; | |
| 663 | ||
| 664 | template <class _Iter> | |
| 665 | struct __is_pathable_iter< | |
| 666 | _Iter, true, | |
| 667 | _Void<typename __can_convert_char< | |
| 668 | typename iterator_traits<_Iter>::value_type>::__char_type> > | |
| 669 | : __can_convert_char<typename iterator_traits<_Iter>::value_type> { | |
| 670 | using _ECharT = typename iterator_traits<_Iter>::value_type; | |
| 671 | using _Base = __can_convert_char<_ECharT>; | |
| 672 | ||
| 673 | static _Iter __range_begin(_Iter __b) { return __b; } | |
| 674 | static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; } | |
| 675 | ||
| 676 | static _ECharT __first_or_null(_Iter __b) { return *__b; } | |
| 677 | }; | |
| 678 | ||
| 679 | template <class _Tp, bool _IsStringT = __is_pathable_string<_Tp>::value, | |
| 680 | bool _IsCharIterT = __is_pathable_char_array<_Tp>::value, | |
| 681 | bool _IsIterT = !_IsCharIterT && __is_pathable_iter<_Tp>::value> | |
| 682 | struct __is_pathable : false_type { | |
| 683 | static_assert(!_IsStringT && !_IsCharIterT && !_IsIterT, "Must all be false"); | |
| 684 | }; | |
| 685 | ||
| 686 | template <class _Tp> | |
| 687 | struct __is_pathable<_Tp, true, false, false> : __is_pathable_string<_Tp> {}; | |
| 688 | ||
| 689 | template <class _Tp> | |
| 690 | struct __is_pathable<_Tp, false, true, false> : __is_pathable_char_array<_Tp> { | |
| 691 | }; | |
| 692 | ||
| 693 | template <class _Tp> | |
| 694 | struct __is_pathable<_Tp, false, false, true> : __is_pathable_iter<_Tp> {}; | |
| 695 | ||
| 696 | #if defined(_LIBCPP_WIN32API) | |
| 697 | typedef wstring __path_string; | |
| 698 | typedef wchar_t __path_value; | |
| 699 | #else | |
| 700 | typedef string __path_string; | |
| 701 | typedef char __path_value; | |
| 702 | #endif | |
| 703 | ||
| 704 | #if defined(_LIBCPP_WIN32API) | |
| 705 | _LIBCPP_FUNC_VIS | |
| 706 | size_t __wide_to_char(const wstring&, char*, size_t); | |
| 707 | _LIBCPP_FUNC_VIS | |
| 708 | size_t __char_to_wide(const string&, wchar_t*, size_t); | |
| 709 | #endif | |
| 710 | ||
| 711 | template <class _ECharT> | |
| 712 | struct _PathCVT; | |
| 713 | ||
| 714 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 715 | template <class _ECharT> | |
| 716 | struct _PathCVT { | |
| 717 | static_assert(__can_convert_char<_ECharT>::value, | |
| 718 | "Char type not convertible"); | |
| 719 | ||
| 720 | typedef __narrow_to_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Narrower; | |
| 721 | #if defined(_LIBCPP_WIN32API) | |
| 722 | typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener; | |
| 723 | #endif | |
| 724 | ||
| 725 | static void __append_range(__path_string& __dest, _ECharT const* __b, | |
| 726 | _ECharT const* __e) { | |
| 727 | #if defined(_LIBCPP_WIN32API) | |
| 728 | string __utf8; | |
| 729 | _Narrower()(back_inserter(__utf8), __b, __e); | |
| 730 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 731 | #else | |
| 732 | _Narrower()(back_inserter(__dest), __b, __e); | |
| 733 | #endif | |
| 734 | } | |
| 735 | ||
| 736 | template <class _Iter> | |
| 737 | static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 738 | static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); | |
| 739 | if (__b == __e) | |
| 740 | return; | |
| 741 | basic_string<_ECharT> __tmp(__b, __e); | |
| 742 | #if defined(_LIBCPP_WIN32API) | |
| 743 | string __utf8; | |
| 744 | _Narrower()(back_inserter(__utf8), __tmp.data(), | |
| 745 | __tmp.data() + __tmp.length()); | |
| 746 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 747 | #else | |
| 748 | _Narrower()(back_inserter(__dest), __tmp.data(), | |
| 749 | __tmp.data() + __tmp.length()); | |
| 750 | #endif | |
| 751 | } | |
| 752 | ||
| 753 | template <class _Iter> | |
| 754 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { | |
| 755 | static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); | |
| 756 | const _ECharT __sentinel = _ECharT{}; | |
| 757 | if (*__b == __sentinel) | |
| 758 | return; | |
| 759 | basic_string<_ECharT> __tmp; | |
| 760 | for (; *__b != __sentinel; ++__b) | |
| 761 | __tmp.push_back(*__b); | |
| 762 | #if defined(_LIBCPP_WIN32API) | |
| 763 | string __utf8; | |
| 764 | _Narrower()(back_inserter(__utf8), __tmp.data(), | |
| 765 | __tmp.data() + __tmp.length()); | |
| 766 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 767 | #else | |
| 768 | _Narrower()(back_inserter(__dest), __tmp.data(), | |
| 769 | __tmp.data() + __tmp.length()); | |
| 770 | #endif | |
| 771 | } | |
| 772 | ||
| 773 | template <class _Source> | |
| 774 | static void __append_source(__path_string& __dest, _Source const& __s) { | |
| 775 | using _Traits = __is_pathable<_Source>; | |
| 776 | __append_range(__dest, _Traits::__range_begin(__s), | |
| 777 | _Traits::__range_end(__s)); | |
| 778 | } | |
| 779 | }; | |
| 780 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 781 | ||
| 782 | template <> | |
| 783 | struct _PathCVT<__path_value> { | |
| 784 | ||
| 785 | template <class _Iter> | |
| 786 | static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type | |
| 787 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 788 | for (; __b != __e; ++__b) | |
| 789 | __dest.push_back(*__b); | |
| 790 | } | |
| 791 | ||
| 792 | template <class _Iter> | |
| 793 | static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type | |
| 794 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 795 | __dest.append(__b, __e); | |
| 796 | } | |
| 797 | ||
| 798 | template <class _Iter> | |
| 799 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { | |
| 800 | const char __sentinel = char{}; | |
| 801 | for (; *__b != __sentinel; ++__b) | |
| 802 | __dest.push_back(*__b); | |
| 803 | } | |
| 804 | ||
| 805 | template <class _Source> | |
| 806 | static void __append_source(__path_string& __dest, _Source const& __s) { | |
| 807 | using _Traits = __is_pathable<_Source>; | |
| 808 | __append_range(__dest, _Traits::__range_begin(__s), | |
| 809 | _Traits::__range_end(__s)); | |
| 810 | } | |
| 811 | }; | |
| 812 | ||
| 813 | #if defined(_LIBCPP_WIN32API) | |
| 814 | template <> | |
| 815 | struct _PathCVT<char> { | |
| 816 | ||
| 817 | static void | |
| 818 | __append_string(__path_string& __dest, const basic_string<char> &__str) { | |
| 819 | size_t __size = __char_to_wide(__str, nullptr, 0); | |
| 820 | size_t __pos = __dest.size(); | |
| 821 | __dest.resize(__pos + __size); | |
| 822 | __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size); | |
| 823 | } | |
| 824 | ||
| 825 | template <class _Iter> | |
| 826 | static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type | |
| 827 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 828 | basic_string<char> __tmp(__b, __e); | |
| 829 | __append_string(__dest, __tmp); | |
| 830 | } | |
| 831 | ||
| 832 | template <class _Iter> | |
| 833 | static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type | |
| 834 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { | |
| 835 | basic_string<char> __tmp(__b, __e); | |
| 836 | __append_string(__dest, __tmp); | |
| 837 | } | |
| 838 | ||
| 839 | template <class _Iter> | |
| 840 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { | |
| 841 | const char __sentinel = char{}; | |
| 842 | basic_string<char> __tmp; | |
| 843 | for (; *__b != __sentinel; ++__b) | |
| 844 | __tmp.push_back(*__b); | |
| 845 | __append_string(__dest, __tmp); | |
| 846 | } | |
| 847 | ||
| 848 | template <class _Source> | |
| 849 | static void __append_source(__path_string& __dest, _Source const& __s) { | |
| 850 | using _Traits = __is_pathable<_Source>; | |
| 851 | __append_range(__dest, _Traits::__range_begin(__s), | |
| 852 | _Traits::__range_end(__s)); | |
| 853 | } | |
| 854 | }; | |
| 855 | ||
| 856 | template <class _ECharT> | |
| 857 | struct _PathExport { | |
| 858 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; | |
| 859 | typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener; | |
| 860 | ||
| 861 | template <class _Str> | |
| 862 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 863 | string __utf8; | |
| 864 | _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size()); | |
| 865 | _Widener()(back_inserter(__dest), __utf8.data(), __utf8.data() + __utf8.size()); | |
| 866 | } | |
| 867 | }; | |
| 868 | ||
| 869 | template <> | |
| 870 | struct _PathExport<char> { | |
| 871 | template <class _Str> | |
| 872 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 873 | size_t __size = __wide_to_char(__src, nullptr, 0); | |
| 874 | size_t __pos = __dest.size(); | |
| 875 | __dest.resize(__size); | |
| 876 | __wide_to_char(__src, const_cast<char*>(__dest.data()) + __pos, __size); | |
| 877 | } | |
| 878 | }; | |
| 879 | ||
| 880 | template <> | |
| 881 | struct _PathExport<wchar_t> { | |
| 882 | template <class _Str> | |
| 883 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 884 | __dest.append(__src.begin(), __src.end()); | |
| 885 | } | |
| 886 | }; | |
| 887 | ||
| 888 | template <> | |
| 889 | struct _PathExport<char16_t> { | |
| 890 | template <class _Str> | |
| 891 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 892 | __dest.append(__src.begin(), __src.end()); | |
| 893 | } | |
| 894 | }; | |
| 895 | ||
| 896 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 897 | template <> | |
| 898 | struct _PathExport<char8_t> { | |
| 899 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; | |
| 900 | ||
| 901 | template <class _Str> | |
| 902 | static void __append(_Str& __dest, const __path_string& __src) { | |
| 903 | _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); | |
| 904 | } | |
| 905 | }; | |
| 906 | #endif /* !_LIBCPP_HAS_NO_CHAR8_T */ | |
| 907 | #endif /* _LIBCPP_WIN32API */ | |
| 908 | ||
| 909 | class _LIBCPP_TYPE_VIS path { | |
| 910 | template <class _SourceOrIter, class _Tp = path&> | |
| 911 | using _EnableIfPathable = | |
| 912 | typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; | |
| 913 | ||
| 914 | template <class _Tp> | |
| 915 | using _SourceChar = typename __is_pathable<_Tp>::__char_type; | |
| 916 | ||
| 917 | template <class _Tp> | |
| 918 | using _SourceCVT = _PathCVT<_SourceChar<_Tp> >; | |
| 919 | ||
| 920 | public: | |
| 921 | #if defined(_LIBCPP_WIN32API) | |
| 922 | typedef wchar_t value_type; | |
| 923 | static constexpr value_type preferred_separator = L'\\'; | |
| 924 | #else | |
| 925 | typedef char value_type; | |
| 926 | static constexpr value_type preferred_separator = '/'; | |
| 927 | #endif | |
| 928 | typedef basic_string<value_type> string_type; | |
| 929 | typedef basic_string_view<value_type> __string_view; | |
| 930 | ||
| 931 | enum _LIBCPP_ENUM_VIS format : unsigned char { | |
| 932 | auto_format, | |
| 933 | native_format, | |
| 934 | generic_format | |
| 935 | }; | |
| 936 | ||
| 937 | // constructors and destructor | |
| 938 | _LIBCPP_INLINE_VISIBILITY path() noexcept {} | |
| 939 | _LIBCPP_INLINE_VISIBILITY path(const path& __p) : __pn_(__p.__pn_) {} | |
| 940 | _LIBCPP_INLINE_VISIBILITY path(path&& __p) noexcept | |
| 941 | : __pn_(_VSTD::move(__p.__pn_)) {} | |
| 942 | ||
| 943 | _LIBCPP_INLINE_VISIBILITY | |
| 944 | path(string_type&& __s, format = format::auto_format) noexcept | |
| 945 | : __pn_(_VSTD::move(__s)) {} | |
| 946 | ||
| 947 | template <class _Source, class = _EnableIfPathable<_Source, void> > | |
| 948 | path(const _Source& __src, format = format::auto_format) { | |
| 949 | _SourceCVT<_Source>::__append_source(__pn_, __src); | |
| 950 | } | |
| 951 | ||
| 952 | template <class _InputIt> | |
| 953 | path(_InputIt __first, _InputIt __last, format = format::auto_format) { | |
| 954 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 955 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); | |
| 956 | } | |
| 957 | ||
| 958 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 959 | // TODO Implement locale conversions. | |
| 960 | template <class _Source, class = _EnableIfPathable<_Source, void> > | |
| 961 | path(const _Source& __src, const locale& __loc, format = format::auto_format); | |
| 962 | template <class _InputIt> | |
| 963 | path(_InputIt __first, _InputIt _last, const locale& __loc, | |
| 964 | format = format::auto_format); | |
| 965 | #endif | |
| 966 | ||
| 967 | _LIBCPP_INLINE_VISIBILITY | |
| 968 | ~path() = default; | |
| 969 | ||
| 970 | // assignments | |
| 971 | _LIBCPP_INLINE_VISIBILITY | |
| 972 | path& operator=(const path& __p) { | |
| 973 | __pn_ = __p.__pn_; | |
| 974 | return *this; | |
| 975 | } | |
| 976 | ||
| 977 | _LIBCPP_INLINE_VISIBILITY | |
| 978 | path& operator=(path&& __p) noexcept { | |
| 979 | __pn_ = _VSTD::move(__p.__pn_); | |
| 980 | return *this; | |
| 981 | } | |
| 982 | ||
| 983 | _LIBCPP_INLINE_VISIBILITY | |
| 984 | path& operator=(string_type&& __s) noexcept { | |
| 985 | __pn_ = _VSTD::move(__s); | |
| 986 | return *this; | |
| 987 | } | |
| 988 | ||
| 989 | _LIBCPP_INLINE_VISIBILITY | |
| 990 | path& assign(string_type&& __s) noexcept { | |
| 991 | __pn_ = _VSTD::move(__s); | |
| 992 | return *this; | |
| 993 | } | |
| 994 | ||
| 995 | template <class _Source> | |
| 996 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 997 | operator=(const _Source& __src) { | |
| 998 | return this->assign(__src); | |
| 999 | } | |
| 1000 | ||
| 1001 | template <class _Source> | |
| 1002 | _EnableIfPathable<_Source> assign(const _Source& __src) { | |
| 1003 | __pn_.clear(); | |
| 1004 | _SourceCVT<_Source>::__append_source(__pn_, __src); | |
| 1005 | return *this; | |
| 1006 | } | |
| 1007 | ||
| 1008 | template <class _InputIt> | |
| 1009 | path& assign(_InputIt __first, _InputIt __last) { | |
| 1010 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 1011 | __pn_.clear(); | |
| 1012 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); | |
| 1013 | return *this; | |
| 1014 | } | |
| 1015 | ||
| 1016 | public: | |
| 1017 | // appends | |
| 1018 | #if defined(_LIBCPP_WIN32API) | |
| 1019 | path& operator/=(const path& __p) { | |
| 1020 | auto __p_root_name = __p.__root_name(); | |
| 1021 | auto __p_root_name_size = __p_root_name.size(); | |
| 1022 | if (__p.is_absolute() || | |
| 1023 | (!__p_root_name.empty() && __p_root_name != root_name())) { | |
| 1024 | __pn_ = __p.__pn_; | |
| 1025 | return *this; | |
| 1026 | } | |
| 1027 | if (__p.has_root_directory()) { | |
| 1028 | path __root_name_str = root_name(); | |
| 1029 | __pn_ = __root_name_str.native(); | |
| 1030 | __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size); | |
| 1031 | return *this; | |
| 1032 | } | |
| 1033 | if (has_filename() || (!has_root_directory() && is_absolute())) | |
| 1034 | __pn_ += preferred_separator; | |
| 1035 | __pn_ += __string_view(__p.__pn_).substr(__p_root_name_size); | |
| 1036 | return *this; | |
| 1037 | } | |
| 1038 | template <class _Source> | |
| 1039 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 1040 | operator/=(const _Source& __src) { | |
| 1041 | return operator/=(path(__src)); | |
| 1042 | } | |
| 1043 | ||
| 1044 | template <class _Source> | |
| 1045 | _EnableIfPathable<_Source> append(const _Source& __src) { | |
| 1046 | return operator/=(path(__src)); | |
| 1047 | } | |
| 1048 | ||
| 1049 | template <class _InputIt> | |
| 1050 | path& append(_InputIt __first, _InputIt __last) { | |
| 1051 | return operator/=(path(__first, __last)); | |
| 1052 | } | |
| 1053 | #else | |
| 1054 | path& operator/=(const path& __p) { | |
| 1055 | if (__p.is_absolute()) { | |
| 1056 | __pn_ = __p.__pn_; | |
| 1057 | return *this; | |
| 1058 | } | |
| 1059 | if (has_filename()) | |
| 1060 | __pn_ += preferred_separator; | |
| 1061 | __pn_ += __p.native(); | |
| 1062 | return *this; | |
| 1063 | } | |
| 1064 | ||
| 1065 | // FIXME: Use _LIBCPP_DIAGNOSE_WARNING to produce a diagnostic when __src | |
| 1066 | // is known at compile time to be "/' since the user almost certainly intended | |
| 1067 | // to append a separator instead of overwriting the path with "/" | |
| 1068 | template <class _Source> | |
| 1069 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 1070 | operator/=(const _Source& __src) { | |
| 1071 | return this->append(__src); | |
| 1072 | } | |
| 1073 | ||
| 1074 | template <class _Source> | |
| 1075 | _EnableIfPathable<_Source> append(const _Source& __src) { | |
| 1076 | using _Traits = __is_pathable<_Source>; | |
| 1077 | using _CVT = _PathCVT<_SourceChar<_Source> >; | |
| 1078 | bool __source_is_absolute = __is_separator(_Traits::__first_or_null(__src)); | |
| 1079 | if (__source_is_absolute) | |
| 1080 | __pn_.clear(); | |
| 1081 | else if (has_filename()) | |
| 1082 | __pn_ += preferred_separator; | |
| 1083 | _CVT::__append_source(__pn_, __src); | |
| 1084 | return *this; | |
| 1085 | } | |
| 1086 | ||
| 1087 | template <class _InputIt> | |
| 1088 | path& append(_InputIt __first, _InputIt __last) { | |
| 1089 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 1090 | static_assert(__can_convert_char<_ItVal>::value, "Must convertible"); | |
| 1091 | using _CVT = _PathCVT<_ItVal>; | |
| 1092 | if (__first != __last && __is_separator(*__first)) | |
| 1093 | __pn_.clear(); | |
| 1094 | else if (has_filename()) | |
| 1095 | __pn_ += preferred_separator; | |
| 1096 | _CVT::__append_range(__pn_, __first, __last); | |
| 1097 | return *this; | |
| 1098 | } | |
| 1099 | #endif | |
| 1100 | ||
| 1101 | // concatenation | |
| 1102 | _LIBCPP_INLINE_VISIBILITY | |
| 1103 | path& operator+=(const path& __x) { | |
| 1104 | __pn_ += __x.__pn_; | |
| 1105 | return *this; | |
| 1106 | } | |
| 1107 | ||
| 1108 | _LIBCPP_INLINE_VISIBILITY | |
| 1109 | path& operator+=(const string_type& __x) { | |
| 1110 | __pn_ += __x; | |
| 1111 | return *this; | |
| 1112 | } | |
| 1113 | ||
| 1114 | _LIBCPP_INLINE_VISIBILITY | |
| 1115 | path& operator+=(__string_view __x) { | |
| 1116 | __pn_ += __x; | |
| 1117 | return *this; | |
| 1118 | } | |
| 1119 | ||
| 1120 | _LIBCPP_INLINE_VISIBILITY | |
| 1121 | path& operator+=(const value_type* __x) { | |
| 1122 | __pn_ += __x; | |
| 1123 | return *this; | |
| 1124 | } | |
| 1125 | ||
| 1126 | _LIBCPP_INLINE_VISIBILITY | |
| 1127 | path& operator+=(value_type __x) { | |
| 1128 | __pn_ += __x; | |
| 1129 | return *this; | |
| 1130 | } | |
| 1131 | ||
| 1132 | template <class _ECharT> | |
| 1133 | typename enable_if<__can_convert_char<_ECharT>::value, path&>::type | |
| 1134 | operator+=(_ECharT __x) { | |
| 1135 | _PathCVT<_ECharT>::__append_source(__pn_, | |
| 1136 | basic_string_view<_ECharT>(&__x, 1)); | |
| 1137 | return *this; | |
| 1138 | } | |
| 1139 | ||
| 1140 | template <class _Source> | |
| 1141 | _EnableIfPathable<_Source> operator+=(const _Source& __x) { | |
| 1142 | return this->concat(__x); | |
| 1143 | } | |
| 1144 | ||
| 1145 | template <class _Source> | |
| 1146 | _EnableIfPathable<_Source> concat(const _Source& __x) { | |
| 1147 | _SourceCVT<_Source>::__append_source(__pn_, __x); | |
| 1148 | return *this; | |
| 1149 | } | |
| 1150 | ||
| 1151 | template <class _InputIt> | |
| 1152 | path& concat(_InputIt __first, _InputIt __last) { | |
| 1153 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; | |
| 1154 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); | |
| 1155 | return *this; | |
| 1156 | } | |
| 1157 | ||
| 1158 | // modifiers | |
| 1159 | _LIBCPP_INLINE_VISIBILITY | |
| 1160 | void clear() noexcept { __pn_.clear(); } | |
| 1161 | ||
| 1162 | path& make_preferred() { | |
| 1163 | #if defined(_LIBCPP_WIN32API) | |
| 1164 | _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\'); | |
| 1165 | #endif | |
| 1166 | return *this; | |
| 1167 | } | |
| 1168 | ||
| 1169 | _LIBCPP_INLINE_VISIBILITY | |
| 1170 | path& remove_filename() { | |
| 1171 | auto __fname = __filename(); | |
| 1172 | if (!__fname.empty()) | |
| 1173 | __pn_.erase(__fname.data() - __pn_.data()); | |
| 1174 | return *this; | |
| 1175 | } | |
| 1176 | ||
| 1177 | path& replace_filename(const path& __replacement) { | |
| 1178 | remove_filename(); | |
| 1179 | return (*this /= __replacement); | |
| 1180 | } | |
| 1181 | ||
| 1182 | path& replace_extension(const path& __replacement = path()); | |
| 1183 | ||
| 1184 | _LIBCPP_INLINE_VISIBILITY | |
| 1185 | void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); } | |
| 1186 | ||
| 1187 | // private helper to allow reserving memory in the path | |
| 1188 | _LIBCPP_INLINE_VISIBILITY | |
| 1189 | void __reserve(size_t __s) { __pn_.reserve(__s); } | |
| 1190 | ||
| 1191 | // native format observers | |
| 1192 | _LIBCPP_INLINE_VISIBILITY | |
| 1193 | const string_type& native() const noexcept { return __pn_; } | |
| 1194 | ||
| 1195 | _LIBCPP_INLINE_VISIBILITY | |
| 1196 | const value_type* c_str() const noexcept { return __pn_.c_str(); } | |
| 1197 | ||
| 1198 | _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; } | |
| 1199 | ||
| 1200 | #if defined(_LIBCPP_WIN32API) | |
| 1201 | _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; } | |
| 1202 | ||
| 1203 | _VSTD::wstring generic_wstring() const { | |
| 1204 | _VSTD::wstring __s; | |
| 1205 | __s.resize(__pn_.size()); | |
| 1206 | _VSTD::replace_copy(__pn_.begin(), __pn_.end(), __s.begin(), '\\', '/'); | |
| 1207 | return __s; | |
| 1208 | } | |
| 1209 | ||
| 1210 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 1211 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 1212 | class _Allocator = allocator<_ECharT> > | |
| 1213 | basic_string<_ECharT, _Traits, _Allocator> | |
| 1214 | string(const _Allocator& __a = _Allocator()) const { | |
| 1215 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | |
| 1216 | _Str __s(__a); | |
| 1217 | __s.reserve(__pn_.size()); | |
| 1218 | _PathExport<_ECharT>::__append(__s, __pn_); | |
| 1219 | return __s; | |
| 1220 | } | |
| 1221 | ||
| 1222 | _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { | |
| 1223 | return string<char>(); | |
| 1224 | } | |
| 1225 | _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const { | |
| 1226 | using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | |
| 1227 | __u8_string __s; | |
| 1228 | __s.reserve(__pn_.size()); | |
| 1229 | _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); | |
| 1230 | return __s; | |
| 1231 | } | |
| 1232 | ||
| 1233 | _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { | |
| 1234 | return string<char16_t>(); | |
| 1235 | } | |
| 1236 | _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { | |
| 1237 | return string<char32_t>(); | |
| 1238 | } | |
| 1239 | ||
| 1240 | // generic format observers | |
| 1241 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 1242 | class _Allocator = allocator<_ECharT> > | |
| 1243 | basic_string<_ECharT, _Traits, _Allocator> | |
| 1244 | generic_string(const _Allocator& __a = _Allocator()) const { | |
| 1245 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | |
| 1246 | _Str __s = string<_ECharT, _Traits, _Allocator>(__a); | |
| 1247 | // Note: This (and generic_u8string below) is slightly suboptimal as | |
| 1248 | // it iterates twice over the string; once to convert it to the right | |
| 1249 | // character type, and once to replace path delimiters. | |
| 1250 | _VSTD::replace(__s.begin(), __s.end(), | |
| 1251 | static_cast<_ECharT>('\\'), static_cast<_ECharT>('/')); | |
| 1252 | return __s; | |
| 1253 | } | |
| 1254 | ||
| 1255 | _VSTD::string generic_string() const { return generic_string<char>(); } | |
| 1256 | _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); } | |
| 1257 | _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); } | |
| 1258 | __u8_string generic_u8string() const { | |
| 1259 | __u8_string __s = u8string(); | |
| 1260 | _VSTD::replace(__s.begin(), __s.end(), '\\', '/'); | |
| 1261 | return __s; | |
| 1262 | } | |
| 1263 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 1264 | #else /* _LIBCPP_WIN32API */ | |
| 1265 | ||
| 1266 | _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; } | |
| 1267 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1268 | _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 1269 | #else | |
| 1270 | _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; } | |
| 1271 | #endif | |
| 1272 | ||
| 1273 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 1274 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 1275 | class _Allocator = allocator<_ECharT> > | |
| 1276 | basic_string<_ECharT, _Traits, _Allocator> | |
| 1277 | string(const _Allocator& __a = _Allocator()) const { | |
| 1278 | using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>; | |
| 1279 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; | |
| 1280 | _Str __s(__a); | |
| 1281 | __s.reserve(__pn_.size()); | |
| 1282 | _CVT()(back_inserter(__s), __pn_.data(), __pn_.data() + __pn_.size()); | |
| 1283 | return __s; | |
| 1284 | } | |
| 1285 | ||
| 1286 | _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { | |
| 1287 | return string<wchar_t>(); | |
| 1288 | } | |
| 1289 | _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { | |
| 1290 | return string<char16_t>(); | |
| 1291 | } | |
| 1292 | _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { | |
| 1293 | return string<char32_t>(); | |
| 1294 | } | |
| 1295 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 1296 | ||
| 1297 | // generic format observers | |
| 1298 | _VSTD::string generic_string() const { return __pn_; } | |
| 1299 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1300 | _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 1301 | #else | |
| 1302 | _VSTD::string generic_u8string() const { return __pn_; } | |
| 1303 | #endif | |
| 1304 | ||
| 1305 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 1306 | template <class _ECharT, class _Traits = char_traits<_ECharT>, | |
| 1307 | class _Allocator = allocator<_ECharT> > | |
| 1308 | basic_string<_ECharT, _Traits, _Allocator> | |
| 1309 | generic_string(const _Allocator& __a = _Allocator()) const { | |
| 1310 | return string<_ECharT, _Traits, _Allocator>(__a); | |
| 1311 | } | |
| 1312 | ||
| 1313 | _VSTD::wstring generic_wstring() const { return string<wchar_t>(); } | |
| 1314 | _VSTD::u16string generic_u16string() const { return string<char16_t>(); } | |
| 1315 | _VSTD::u32string generic_u32string() const { return string<char32_t>(); } | |
| 1316 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ | |
| 1317 | #endif /* !_LIBCPP_WIN32API */ | |
| 1318 | ||
| 1319 | private: | |
| 1320 | int __compare(__string_view) const; | |
| 1321 | __string_view __root_name() const; | |
| 1322 | __string_view __root_directory() const; | |
| 1323 | __string_view __root_path_raw() const; | |
| 1324 | __string_view __relative_path() const; | |
| 1325 | __string_view __parent_path() const; | |
| 1326 | __string_view __filename() const; | |
| 1327 | __string_view __stem() const; | |
| 1328 | __string_view __extension() const; | |
| 1329 | ||
| 1330 | public: | |
| 1331 | // compare | |
| 1332 | _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept { | |
| 1333 | return __compare(__p.__pn_); | |
| 1334 | } | |
| 1335 | _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { | |
| 1336 | return __compare(__s); | |
| 1337 | } | |
| 1338 | _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { | |
| 1339 | return __compare(__s); | |
| 1340 | } | |
| 1341 | _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { | |
| 1342 | return __compare(__s); | |
| 1343 | } | |
| 1344 | ||
| 1345 | // decomposition | |
| 1346 | _LIBCPP_INLINE_VISIBILITY path root_name() const { | |
| 1347 | return string_type(__root_name()); | |
| 1348 | } | |
| 1349 | _LIBCPP_INLINE_VISIBILITY path root_directory() const { | |
| 1350 | return string_type(__root_directory()); | |
| 1351 | } | |
| 1352 | _LIBCPP_INLINE_VISIBILITY path root_path() const { | |
| 1353 | #if defined(_LIBCPP_WIN32API) | |
| 1354 | return string_type(__root_path_raw()); | |
| 1355 | #else | |
| 1356 | return root_name().append(string_type(__root_directory())); | |
| 1357 | #endif | |
| 1358 | } | |
| 1359 | _LIBCPP_INLINE_VISIBILITY path relative_path() const { | |
| 1360 | return string_type(__relative_path()); | |
| 1361 | } | |
| 1362 | _LIBCPP_INLINE_VISIBILITY path parent_path() const { | |
| 1363 | return string_type(__parent_path()); | |
| 1364 | } | |
| 1365 | _LIBCPP_INLINE_VISIBILITY path filename() const { | |
| 1366 | return string_type(__filename()); | |
| 1367 | } | |
| 1368 | _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); } | |
| 1369 | _LIBCPP_INLINE_VISIBILITY path extension() const { | |
| 1370 | return string_type(__extension()); | |
| 1371 | } | |
| 1372 | ||
| 1373 | // query | |
| 1374 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool | |
| 1375 | empty() const noexcept { | |
| 1376 | return __pn_.empty(); | |
| 1377 | } | |
| 1378 | ||
| 1379 | _LIBCPP_INLINE_VISIBILITY bool has_root_name() const { | |
| 1380 | return !__root_name().empty(); | |
| 1381 | } | |
| 1382 | _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { | |
| 1383 | return !__root_directory().empty(); | |
| 1384 | } | |
| 1385 | _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { | |
| 1386 | return !__root_path_raw().empty(); | |
| 1387 | } | |
| 1388 | _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { | |
| 1389 | return !__relative_path().empty(); | |
| 1390 | } | |
| 1391 | _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { | |
| 1392 | return !__parent_path().empty(); | |
| 1393 | } | |
| 1394 | _LIBCPP_INLINE_VISIBILITY bool has_filename() const { | |
| 1395 | return !__filename().empty(); | |
| 1396 | } | |
| 1397 | _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); } | |
| 1398 | _LIBCPP_INLINE_VISIBILITY bool has_extension() const { | |
| 1399 | return !__extension().empty(); | |
| 1400 | } | |
| 1401 | ||
| 1402 | _LIBCPP_INLINE_VISIBILITY bool is_absolute() const { | |
| 1403 | #if defined(_LIBCPP_WIN32API) | |
| 1404 | __string_view __root_name_str = __root_name(); | |
| 1405 | __string_view __root_dir = __root_directory(); | |
| 1406 | if (__root_name_str.size() == 2 && __root_name_str[1] == ':') { | |
| 1407 | // A drive letter with no root directory is relative, e.g. x:example. | |
| 1408 | return !__root_dir.empty(); | |
| 1409 | } | |
| 1410 | // If no root name, it's relative, e.g. \example is relative to the current drive | |
| 1411 | if (__root_name_str.empty()) | |
| 1412 | return false; | |
| 1413 | if (__root_name_str.size() < 3) | |
| 1414 | return false; | |
| 1415 | // A server root name, like \\server, is always absolute | |
| 1416 | if (__root_name_str[0] != '/' && __root_name_str[0] != '\\') | |
| 1417 | return false; | |
| 1418 | if (__root_name_str[1] != '/' && __root_name_str[1] != '\\') | |
| 1419 | return false; | |
| 1420 | // Seems to be a server root name | |
| 1421 | return true; | |
| 1422 | #else | |
| 1423 | return has_root_directory(); | |
| 1424 | #endif | |
| 1425 | } | |
| 1426 | _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); } | |
| 1427 | ||
| 1428 | // relative paths | |
| 1429 | path lexically_normal() const; | |
| 1430 | path lexically_relative(const path& __base) const; | |
| 1431 | ||
| 1432 | _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const { | |
| 1433 | path __result = this->lexically_relative(__base); | |
| 1434 | if (__result.native().empty()) | |
| 1435 | return *this; | |
| 1436 | return __result; | |
| 1437 | } | |
| 1438 | ||
| 1439 | // iterators | |
| 1440 | class _LIBCPP_TYPE_VIS iterator; | |
| 1441 | typedef iterator const_iterator; | |
| 1442 | ||
| 1443 | iterator begin() const; | |
| 1444 | iterator end() const; | |
| 1445 | ||
| 1446 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 1447 | template <class _CharT, class _Traits> | |
| 1448 | _LIBCPP_INLINE_VISIBILITY friend | |
| 1449 | typename enable_if<is_same<_CharT, value_type>::value && | |
| 1450 | is_same<_Traits, char_traits<value_type> >::value, | |
| 1451 | basic_ostream<_CharT, _Traits>&>::type | |
| 1452 | operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { | |
| 1453 | __os << _VSTD::__quoted(__p.native()); | |
| 1454 | return __os; | |
| 1455 | } | |
| 1456 | ||
| 1457 | template <class _CharT, class _Traits> | |
| 1458 | _LIBCPP_INLINE_VISIBILITY friend | |
| 1459 | typename enable_if<!is_same<_CharT, value_type>::value || | |
| 1460 | !is_same<_Traits, char_traits<value_type> >::value, | |
| 1461 | basic_ostream<_CharT, _Traits>&>::type | |
| 1462 | operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { | |
| 1463 | __os << _VSTD::__quoted(__p.string<_CharT, _Traits>()); | |
| 1464 | return __os; | |
| 1465 | } | |
| 1466 | ||
| 1467 | template <class _CharT, class _Traits> | |
| 1468 | _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>& | |
| 1469 | operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) { | |
| 1470 | basic_string<_CharT, _Traits> __tmp; | |
| 1471 | __is >> __quoted(__tmp); | |
| 1472 | __p = __tmp; | |
| 1473 | return __is; | |
| 1474 | } | |
| 1475 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION | |
| 1476 | ||
| 1477 | friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept { | |
| 1478 | return __lhs.compare(__rhs) == 0; | |
| 1479 | } | |
| 1480 | friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept { | |
| 1481 | return __lhs.compare(__rhs) != 0; | |
| 1482 | } | |
| 1483 | friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept { | |
| 1484 | return __lhs.compare(__rhs) < 0; | |
| 1485 | } | |
| 1486 | friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept { | |
| 1487 | return __lhs.compare(__rhs) <= 0; | |
| 1488 | } | |
| 1489 | friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept { | |
| 1490 | return __lhs.compare(__rhs) > 0; | |
| 1491 | } | |
| 1492 | friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept { | |
| 1493 | return __lhs.compare(__rhs) >= 0; | |
| 1494 | } | |
| 1495 | ||
| 1496 | friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, | |
| 1497 | const path& __rhs) { | |
| 1498 | path __result(__lhs); | |
| 1499 | __result /= __rhs; | |
| 1500 | return __result; | |
| 1501 | } | |
| 1502 | private: | |
| 1503 | inline _LIBCPP_INLINE_VISIBILITY path& | |
| 1504 | __assign_view(__string_view const& __s) noexcept { | |
| 1505 | __pn_ = string_type(__s); | |
| 1506 | return *this; | |
| 1507 | } | |
| 1508 | string_type __pn_; | |
| 1509 | }; | |
| 1510 | ||
| 1511 | inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept { | |
| 1512 | __lhs.swap(__rhs); | |
| 1513 | } | |
| 1514 | ||
| 1515 | _LIBCPP_FUNC_VIS | |
| 1516 | size_t hash_value(const path& __p) noexcept; | |
| 1517 | ||
| 1518 | template <class _InputIt> | |
| 1519 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 1520 | typename enable_if<__is_pathable<_InputIt>::value, path>::type | |
| 1521 | u8path(_InputIt __f, _InputIt __l) { | |
| 1522 | static_assert( | |
| 1523 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1524 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || | |
| 1525 | #endif | |
| 1526 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, | |
| 1527 | "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" | |
| 1528 | " or 'char8_t'"); | |
| 1529 | #if defined(_LIBCPP_WIN32API) | |
| 1530 | string __tmp(__f, __l); | |
| 1531 | using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | |
| 1532 | _VSTD::wstring __w; | |
| 1533 | __w.reserve(__tmp.size()); | |
| 1534 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); | |
| 1535 | return path(__w); | |
| 1536 | #else | |
| 1537 | return path(__f, __l); | |
| 1538 | #endif /* !_LIBCPP_WIN32API */ | |
| 1539 | } | |
| 1540 | ||
| 1541 | #if defined(_LIBCPP_WIN32API) | |
| 1542 | template <class _InputIt> | |
| 1543 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 1544 | typename enable_if<__is_pathable<_InputIt>::value, path>::type | |
| 1545 | u8path(_InputIt __f, _NullSentinel) { | |
| 1546 | static_assert( | |
| 1547 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1548 | is_same<typename __is_pathable<_InputIt>::__char_type, char8_t>::value || | |
| 1549 | #endif | |
| 1550 | is_same<typename __is_pathable<_InputIt>::__char_type, char>::value, | |
| 1551 | "u8path(Iter, Iter) requires Iter have a value_type of type 'char'" | |
| 1552 | " or 'char8_t'"); | |
| 1553 | string __tmp; | |
| 1554 | const char __sentinel = char{}; | |
| 1555 | for (; *__f != __sentinel; ++__f) | |
| 1556 | __tmp.push_back(*__f); | |
| 1557 | using _CVT = __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__>; | |
| 1558 | _VSTD::wstring __w; | |
| 1559 | __w.reserve(__tmp.size()); | |
| 1560 | _CVT()(back_inserter(__w), __tmp.data(), __tmp.data() + __tmp.size()); | |
| 1561 | return path(__w); | |
| 1562 | } | |
| 1563 | #endif /* _LIBCPP_WIN32API */ | |
| 1564 | ||
| 1565 | template <class _Source> | |
| 1566 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 1567 | typename enable_if<__is_pathable<_Source>::value, path>::type | |
| 1568 | u8path(const _Source& __s) { | |
| 1569 | static_assert( | |
| 1570 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1571 | is_same<typename __is_pathable<_Source>::__char_type, char8_t>::value || | |
| 1572 | #endif | |
| 1573 | is_same<typename __is_pathable<_Source>::__char_type, char>::value, | |
| 1574 | "u8path(Source const&) requires Source have a character type of type " | |
| 1575 | "'char' or 'char8_t'"); | |
| 1576 | #if defined(_LIBCPP_WIN32API) | |
| 1577 | using _Traits = __is_pathable<_Source>; | |
| 1578 | return u8path(_VSTD::__unwrap_iter(_Traits::__range_begin(__s)), _VSTD::__unwrap_iter(_Traits::__range_end(__s))); | |
| 1579 | #else | |
| 1580 | return path(__s); | |
| 1581 | #endif | |
| 1582 | } | |
| 1583 | ||
| 1584 | class _LIBCPP_TYPE_VIS path::iterator { | |
| 1585 | public: | |
| 1586 | enum _ParserState : unsigned char { | |
| 1587 | _Singular, | |
| 1588 | _BeforeBegin, | |
| 1589 | _InRootName, | |
| 1590 | _InRootDir, | |
| 1591 | _InFilenames, | |
| 1592 | _InTrailingSep, | |
| 1593 | _AtEnd | |
| 1594 | }; | |
| 1595 | ||
| 1596 | public: | |
| 1597 | typedef bidirectional_iterator_tag iterator_category; | |
| 1598 | ||
| 1599 | typedef path value_type; | |
| 1600 | typedef ptrdiff_t difference_type; | |
| 1601 | typedef const path* pointer; | |
| 1602 | typedef const path& reference; | |
| 1603 | ||
| 1604 | typedef void | |
| 1605 | __stashing_iterator_tag; // See reverse_iterator and __is_stashing_iterator | |
| 1606 | ||
| 1607 | public: | |
| 1608 | _LIBCPP_INLINE_VISIBILITY | |
| 1609 | iterator() | |
| 1610 | : __stashed_elem_(), __path_ptr_(nullptr), __entry_(), | |
| 1611 | __state_(_Singular) {} | |
| 1612 | ||
| 1613 | iterator(const iterator&) = default; | |
| 1614 | ~iterator() = default; | |
| 1615 | ||
| 1616 | iterator& operator=(const iterator&) = default; | |
| 1617 | ||
| 1618 | _LIBCPP_INLINE_VISIBILITY | |
| 1619 | reference operator*() const { return __stashed_elem_; } | |
| 1620 | ||
| 1621 | _LIBCPP_INLINE_VISIBILITY | |
| 1622 | pointer operator->() const { return &__stashed_elem_; } | |
| 1623 | ||
| 1624 | _LIBCPP_INLINE_VISIBILITY | |
| 1625 | iterator& operator++() { | |
| 1626 | _LIBCPP_ASSERT(__state_ != _Singular, | |
| 1627 | "attempting to increment a singular iterator"); | |
| 1628 | _LIBCPP_ASSERT(__state_ != _AtEnd, | |
| 1629 | "attempting to increment the end iterator"); | |
| 1630 | return __increment(); | |
| 1631 | } | |
| 1632 | ||
| 1633 | _LIBCPP_INLINE_VISIBILITY | |
| 1634 | iterator operator++(int) { | |
| 1635 | iterator __it(*this); | |
| 1636 | this->operator++(); | |
| 1637 | return __it; | |
| 1638 | } | |
| 1639 | ||
| 1640 | _LIBCPP_INLINE_VISIBILITY | |
| 1641 | iterator& operator--() { | |
| 1642 | _LIBCPP_ASSERT(__state_ != _Singular, | |
| 1643 | "attempting to decrement a singular iterator"); | |
| 1644 | _LIBCPP_ASSERT(__entry_.data() != __path_ptr_->native().data(), | |
| 1645 | "attempting to decrement the begin iterator"); | |
| 1646 | return __decrement(); | |
| 1647 | } | |
| 1648 | ||
| 1649 | _LIBCPP_INLINE_VISIBILITY | |
| 1650 | iterator operator--(int) { | |
| 1651 | iterator __it(*this); | |
| 1652 | this->operator--(); | |
| 1653 | return __it; | |
| 1654 | } | |
| 1655 | ||
| 1656 | private: | |
| 1657 | friend class path; | |
| 1658 | ||
| 1659 | inline _LIBCPP_INLINE_VISIBILITY friend bool operator==(const iterator&, | |
| 1660 | const iterator&); | |
| 1661 | ||
| 1662 | iterator& __increment(); | |
| 1663 | iterator& __decrement(); | |
| 1664 | ||
| 1665 | path __stashed_elem_; | |
| 1666 | const path* __path_ptr_; | |
| 1667 | path::__string_view __entry_; | |
| 1668 | _ParserState __state_; | |
| 1669 | }; | |
| 1670 | ||
| 1671 | inline _LIBCPP_INLINE_VISIBILITY bool operator==(const path::iterator& __lhs, | |
| 1672 | const path::iterator& __rhs) { | |
| 1673 | return __lhs.__path_ptr_ == __rhs.__path_ptr_ && | |
| 1674 | __lhs.__entry_.data() == __rhs.__entry_.data(); | |
| 1675 | } | |
| 1676 | ||
| 1677 | inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs, | |
| 1678 | const path::iterator& __rhs) { | |
| 1679 | return !(__lhs == __rhs); | |
| 1680 | } | |
| 1681 | ||
| 1682 | // TODO(ldionne): We need to pop the pragma and push it again after | |
| 1683 | // filesystem_error to work around PR41078. | |
| 1684 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 1685 | ||
| 1686 | class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error { | |
| 1687 | public: | |
| 1688 | _LIBCPP_INLINE_VISIBILITY | |
| 1689 | filesystem_error(const string& __what, error_code __ec) | |
| 1690 | : system_error(__ec, __what), | |
| 1691 | __storage_(make_shared<_Storage>(path(), path())) { | |
| 1692 | __create_what(0); | |
| 1693 | } | |
| 1694 | ||
| 1695 | _LIBCPP_INLINE_VISIBILITY | |
| 1696 | filesystem_error(const string& __what, const path& __p1, error_code __ec) | |
| 1697 | : system_error(__ec, __what), | |
| 1698 | __storage_(make_shared<_Storage>(__p1, path())) { | |
| 1699 | __create_what(1); | |
| 1700 | } | |
| 1701 | ||
| 1702 | _LIBCPP_INLINE_VISIBILITY | |
| 1703 | filesystem_error(const string& __what, const path& __p1, const path& __p2, | |
| 1704 | error_code __ec) | |
| 1705 | : system_error(__ec, __what), | |
| 1706 | __storage_(make_shared<_Storage>(__p1, __p2)) { | |
| 1707 | __create_what(2); | |
| 1708 | } | |
| 1709 | ||
| 1710 | _LIBCPP_INLINE_VISIBILITY | |
| 1711 | const path& path1() const noexcept { return __storage_->__p1_; } | |
| 1712 | ||
| 1713 | _LIBCPP_INLINE_VISIBILITY | |
| 1714 | const path& path2() const noexcept { return __storage_->__p2_; } | |
| 1715 | ||
| 1716 | filesystem_error(const filesystem_error&) = default; | |
| 1717 | ~filesystem_error() override; // key function | |
| 1718 | ||
| 1719 | _LIBCPP_INLINE_VISIBILITY | |
| 1720 | const char* what() const noexcept override { | |
| 1721 | return __storage_->__what_.c_str(); | |
| 1722 | } | |
| 1723 | ||
| 1724 | void __create_what(int __num_paths); | |
| 1725 | ||
| 1726 | private: | |
| 1727 | struct _LIBCPP_HIDDEN _Storage { | |
| 1728 | _LIBCPP_INLINE_VISIBILITY | |
| 1729 | _Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {} | |
| 1730 | ||
| 1731 | path __p1_; | |
| 1732 | path __p2_; | |
| 1733 | string __what_; | |
| 1734 | }; | |
| 1735 | shared_ptr<_Storage> __storage_; | |
| 1736 | }; | |
| 1737 | ||
| 1738 | _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH | |
| 1739 | ||
| 1740 | template <class... _Args> | |
| 1741 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY | |
| 1742 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 1743 | void __throw_filesystem_error(_Args&&... __args) { | |
| 1744 | throw filesystem_error(_VSTD::forward<_Args>(__args)...); | |
| 1745 | } | |
| 1746 | #else | |
| 1747 | void __throw_filesystem_error(_Args&&...) { | |
| 1748 | _VSTD::abort(); | |
| 1749 | } | |
| 1750 | #endif | |
| 1751 | ||
| 1752 | // operational functions | |
| 1753 | ||
| 1754 | _LIBCPP_FUNC_VIS | |
| 1755 | path __absolute(const path&, error_code* __ec = nullptr); | |
| 1756 | _LIBCPP_FUNC_VIS | |
| 1757 | path __canonical(const path&, error_code* __ec = nullptr); | |
| 1758 | _LIBCPP_FUNC_VIS | |
| 1759 | void __copy(const path& __from, const path& __to, copy_options __opt, | |
| 1760 | error_code* __ec = nullptr); | |
| 1761 | _LIBCPP_FUNC_VIS | |
| 1762 | bool __copy_file(const path& __from, const path& __to, copy_options __opt, | |
| 1763 | error_code* __ec = nullptr); | |
| 1764 | _LIBCPP_FUNC_VIS | |
| 1765 | void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, | |
| 1766 | error_code* __ec = nullptr); | |
| 1767 | _LIBCPP_FUNC_VIS | |
| 1768 | bool __create_directories(const path& p, error_code* ec = nullptr); | |
| 1769 | _LIBCPP_FUNC_VIS | |
| 1770 | bool __create_directory(const path& p, error_code* ec = nullptr); | |
| 1771 | _LIBCPP_FUNC_VIS | |
| 1772 | bool __create_directory(const path& p, const path& attributes, | |
| 1773 | error_code* ec = nullptr); | |
| 1774 | _LIBCPP_FUNC_VIS | |
| 1775 | void __create_directory_symlink(const path& __to, const path& __new_symlink, | |
| 1776 | error_code* __ec = nullptr); | |
| 1777 | _LIBCPP_FUNC_VIS | |
| 1778 | void __create_hard_link(const path& __to, const path& __new_hard_link, | |
| 1779 | error_code* __ec = nullptr); | |
| 1780 | _LIBCPP_FUNC_VIS | |
| 1781 | void __create_symlink(const path& __to, const path& __new_symlink, | |
| 1782 | error_code* __ec = nullptr); | |
| 1783 | _LIBCPP_FUNC_VIS | |
| 1784 | path __current_path(error_code* __ec = nullptr); | |
| 1785 | _LIBCPP_FUNC_VIS | |
| 1786 | void __current_path(const path&, error_code* __ec = nullptr); | |
| 1787 | _LIBCPP_FUNC_VIS | |
| 1788 | bool __equivalent(const path&, const path&, error_code* __ec = nullptr); | |
| 1789 | _LIBCPP_FUNC_VIS | |
| 1790 | uintmax_t __file_size(const path&, error_code* __ec = nullptr); | |
| 1791 | _LIBCPP_FUNC_VIS | |
| 1792 | uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr); | |
| 1793 | _LIBCPP_FUNC_VIS | |
| 1794 | bool __fs_is_empty(const path& p, error_code* ec = nullptr); | |
| 1795 | _LIBCPP_FUNC_VIS | |
| 1796 | file_time_type __last_write_time(const path& p, error_code* ec = nullptr); | |
| 1797 | _LIBCPP_FUNC_VIS | |
| 1798 | void __last_write_time(const path& p, file_time_type new_time, | |
| 1799 | error_code* ec = nullptr); | |
| 1800 | _LIBCPP_FUNC_VIS | |
| 1801 | void __permissions(const path&, perms, perm_options, error_code* = nullptr); | |
| 1802 | _LIBCPP_FUNC_VIS | |
| 1803 | path __read_symlink(const path& p, error_code* ec = nullptr); | |
| 1804 | _LIBCPP_FUNC_VIS | |
| 1805 | bool __remove(const path& p, error_code* ec = nullptr); | |
| 1806 | _LIBCPP_FUNC_VIS | |
| 1807 | uintmax_t __remove_all(const path& p, error_code* ec = nullptr); | |
| 1808 | _LIBCPP_FUNC_VIS | |
| 1809 | void __rename(const path& from, const path& to, error_code* ec = nullptr); | |
| 1810 | _LIBCPP_FUNC_VIS | |
| 1811 | void __resize_file(const path& p, uintmax_t size, error_code* ec = nullptr); | |
| 1812 | _LIBCPP_FUNC_VIS | |
| 1813 | space_info __space(const path&, error_code* __ec = nullptr); | |
| 1814 | _LIBCPP_FUNC_VIS | |
| 1815 | file_status __status(const path&, error_code* __ec = nullptr); | |
| 1816 | _LIBCPP_FUNC_VIS | |
| 1817 | file_status __symlink_status(const path&, error_code* __ec = nullptr); | |
| 1818 | _LIBCPP_FUNC_VIS | |
| 1819 | path __system_complete(const path&, error_code* __ec = nullptr); | |
| 1820 | _LIBCPP_FUNC_VIS | |
| 1821 | path __temp_directory_path(error_code* __ec = nullptr); | |
| 1822 | _LIBCPP_FUNC_VIS | |
| 1823 | path __weakly_canonical(path const& __p, error_code* __ec = nullptr); | |
| 1824 | ||
| 1825 | inline _LIBCPP_INLINE_VISIBILITY path current_path() { | |
| 1826 | return __current_path(); | |
| 1827 | } | |
| 1828 | ||
| 1829 | inline _LIBCPP_INLINE_VISIBILITY path current_path(error_code& __ec) { | |
| 1830 | return __current_path(&__ec); | |
| 1831 | } | |
| 1832 | ||
| 1833 | inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p) { | |
| 1834 | __current_path(__p); | |
| 1835 | } | |
| 1836 | ||
| 1837 | inline _LIBCPP_INLINE_VISIBILITY void current_path(const path& __p, | |
| 1838 | error_code& __ec) noexcept { | |
| 1839 | __current_path(__p, &__ec); | |
| 1840 | } | |
| 1841 | ||
| 1842 | inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p) { | |
| 1843 | return __absolute(__p); | |
| 1844 | } | |
| 1845 | ||
| 1846 | inline _LIBCPP_INLINE_VISIBILITY path absolute(const path& __p, | |
| 1847 | error_code& __ec) { | |
| 1848 | return __absolute(__p, &__ec); | |
| 1849 | } | |
| 1850 | ||
| 1851 | inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p) { | |
| 1852 | return __canonical(__p); | |
| 1853 | } | |
| 1854 | ||
| 1855 | inline _LIBCPP_INLINE_VISIBILITY path canonical(const path& __p, | |
| 1856 | error_code& __ec) { | |
| 1857 | return __canonical(__p, &__ec); | |
| 1858 | } | |
| 1859 | ||
| 1860 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, | |
| 1861 | const path& __to) { | |
| 1862 | __copy(__from, __to, copy_options::none); | |
| 1863 | } | |
| 1864 | ||
| 1865 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, | |
| 1866 | error_code& __ec) { | |
| 1867 | __copy(__from, __to, copy_options::none, &__ec); | |
| 1868 | } | |
| 1869 | ||
| 1870 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, | |
| 1871 | copy_options __opt) { | |
| 1872 | __copy(__from, __to, __opt); | |
| 1873 | } | |
| 1874 | ||
| 1875 | inline _LIBCPP_INLINE_VISIBILITY void copy(const path& __from, const path& __to, | |
| 1876 | copy_options __opt, | |
| 1877 | error_code& __ec) { | |
| 1878 | __copy(__from, __to, __opt, &__ec); | |
| 1879 | } | |
| 1880 | ||
| 1881 | inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, | |
| 1882 | const path& __to) { | |
| 1883 | return __copy_file(__from, __to, copy_options::none); | |
| 1884 | } | |
| 1885 | ||
| 1886 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 1887 | copy_file(const path& __from, const path& __to, error_code& __ec) { | |
| 1888 | return __copy_file(__from, __to, copy_options::none, &__ec); | |
| 1889 | } | |
| 1890 | ||
| 1891 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 1892 | copy_file(const path& __from, const path& __to, copy_options __opt) { | |
| 1893 | return __copy_file(__from, __to, __opt); | |
| 1894 | } | |
| 1895 | ||
| 1896 | inline _LIBCPP_INLINE_VISIBILITY bool copy_file(const path& __from, | |
| 1897 | const path& __to, | |
| 1898 | copy_options __opt, | |
| 1899 | error_code& __ec) { | |
| 1900 | return __copy_file(__from, __to, __opt, &__ec); | |
| 1901 | } | |
| 1902 | ||
| 1903 | inline _LIBCPP_INLINE_VISIBILITY void copy_symlink(const path& __existing, | |
| 1904 | const path& __new) { | |
| 1905 | __copy_symlink(__existing, __new); | |
| 1906 | } | |
| 1907 | ||
| 1908 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 1909 | copy_symlink(const path& __ext, const path& __new, error_code& __ec) noexcept { | |
| 1910 | __copy_symlink(__ext, __new, &__ec); | |
| 1911 | } | |
| 1912 | ||
| 1913 | inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p) { | |
| 1914 | return __create_directories(__p); | |
| 1915 | } | |
| 1916 | ||
| 1917 | inline _LIBCPP_INLINE_VISIBILITY bool create_directories(const path& __p, | |
| 1918 | error_code& __ec) { | |
| 1919 | return __create_directories(__p, &__ec); | |
| 1920 | } | |
| 1921 | ||
| 1922 | inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p) { | |
| 1923 | return __create_directory(__p); | |
| 1924 | } | |
| 1925 | ||
| 1926 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 1927 | create_directory(const path& __p, error_code& __ec) noexcept { | |
| 1928 | return __create_directory(__p, &__ec); | |
| 1929 | } | |
| 1930 | ||
| 1931 | inline _LIBCPP_INLINE_VISIBILITY bool create_directory(const path& __p, | |
| 1932 | const path& __attrs) { | |
| 1933 | return __create_directory(__p, __attrs); | |
| 1934 | } | |
| 1935 | ||
| 1936 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 1937 | create_directory(const path& __p, const path& __attrs, | |
| 1938 | error_code& __ec) noexcept { | |
| 1939 | return __create_directory(__p, __attrs, &__ec); | |
| 1940 | } | |
| 1941 | ||
| 1942 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 1943 | create_directory_symlink(const path& __to, const path& __new) { | |
| 1944 | __create_directory_symlink(__to, __new); | |
| 1945 | } | |
| 1946 | ||
| 1947 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 1948 | create_directory_symlink(const path& __to, const path& __new, | |
| 1949 | error_code& __ec) noexcept { | |
| 1950 | __create_directory_symlink(__to, __new, &__ec); | |
| 1951 | } | |
| 1952 | ||
| 1953 | inline _LIBCPP_INLINE_VISIBILITY void create_hard_link(const path& __to, | |
| 1954 | const path& __new) { | |
| 1955 | __create_hard_link(__to, __new); | |
| 1956 | } | |
| 1957 | ||
| 1958 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 1959 | create_hard_link(const path& __to, const path& __new, | |
| 1960 | error_code& __ec) noexcept { | |
| 1961 | __create_hard_link(__to, __new, &__ec); | |
| 1962 | } | |
| 1963 | ||
| 1964 | inline _LIBCPP_INLINE_VISIBILITY void create_symlink(const path& __to, | |
| 1965 | const path& __new) { | |
| 1966 | __create_symlink(__to, __new); | |
| 1967 | } | |
| 1968 | ||
| 1969 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 1970 | create_symlink(const path& __to, const path& __new, error_code& __ec) noexcept { | |
| 1971 | return __create_symlink(__to, __new, &__ec); | |
| 1972 | } | |
| 1973 | ||
| 1974 | inline _LIBCPP_INLINE_VISIBILITY bool status_known(file_status __s) noexcept { | |
| 1975 | return __s.type() != file_type::none; | |
| 1976 | } | |
| 1977 | ||
| 1978 | inline _LIBCPP_INLINE_VISIBILITY bool exists(file_status __s) noexcept { | |
| 1979 | return status_known(__s) && __s.type() != file_type::not_found; | |
| 1980 | } | |
| 1981 | ||
| 1982 | inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p) { | |
| 1983 | return exists(__status(__p)); | |
| 1984 | } | |
| 1985 | ||
| 1986 | inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, | |
| 1987 | error_code& __ec) noexcept { | |
| 1988 | auto __s = __status(__p, &__ec); | |
| 1989 | if (status_known(__s)) | |
| 1990 | __ec.clear(); | |
| 1991 | return exists(__s); | |
| 1992 | } | |
| 1993 | ||
| 1994 | inline _LIBCPP_INLINE_VISIBILITY bool equivalent(const path& __p1, | |
| 1995 | const path& __p2) { | |
| 1996 | return __equivalent(__p1, __p2); | |
| 1997 | } | |
| 1998 | ||
| 1999 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2000 | equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { | |
| 2001 | return __equivalent(__p1, __p2, &__ec); | |
| 2002 | } | |
| 2003 | ||
| 2004 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t file_size(const path& __p) { | |
| 2005 | return __file_size(__p); | |
| 2006 | } | |
| 2007 | ||
| 2008 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t | |
| 2009 | file_size(const path& __p, error_code& __ec) noexcept { | |
| 2010 | return __file_size(__p, &__ec); | |
| 2011 | } | |
| 2012 | ||
| 2013 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t hard_link_count(const path& __p) { | |
| 2014 | return __hard_link_count(__p); | |
| 2015 | } | |
| 2016 | ||
| 2017 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t | |
| 2018 | hard_link_count(const path& __p, error_code& __ec) noexcept { | |
| 2019 | return __hard_link_count(__p, &__ec); | |
| 2020 | } | |
| 2021 | ||
| 2022 | inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(file_status __s) noexcept { | |
| 2023 | return __s.type() == file_type::block; | |
| 2024 | } | |
| 2025 | ||
| 2026 | inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p) { | |
| 2027 | return is_block_file(__status(__p)); | |
| 2028 | } | |
| 2029 | ||
| 2030 | inline _LIBCPP_INLINE_VISIBILITY bool is_block_file(const path& __p, | |
| 2031 | error_code& __ec) noexcept { | |
| 2032 | return is_block_file(__status(__p, &__ec)); | |
| 2033 | } | |
| 2034 | ||
| 2035 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2036 | is_character_file(file_status __s) noexcept { | |
| 2037 | return __s.type() == file_type::character; | |
| 2038 | } | |
| 2039 | ||
| 2040 | inline _LIBCPP_INLINE_VISIBILITY bool is_character_file(const path& __p) { | |
| 2041 | return is_character_file(__status(__p)); | |
| 2042 | } | |
| 2043 | ||
| 2044 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2045 | is_character_file(const path& __p, error_code& __ec) noexcept { | |
| 2046 | return is_character_file(__status(__p, &__ec)); | |
| 2047 | } | |
| 2048 | ||
| 2049 | inline _LIBCPP_INLINE_VISIBILITY bool is_directory(file_status __s) noexcept { | |
| 2050 | return __s.type() == file_type::directory; | |
| 2051 | } | |
| 2052 | ||
| 2053 | inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p) { | |
| 2054 | return is_directory(__status(__p)); | |
| 2055 | } | |
| 2056 | ||
| 2057 | inline _LIBCPP_INLINE_VISIBILITY bool is_directory(const path& __p, | |
| 2058 | error_code& __ec) noexcept { | |
| 2059 | return is_directory(__status(__p, &__ec)); | |
| 2060 | } | |
| 2061 | ||
| 2062 | inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p) { | |
| 2063 | return __fs_is_empty(__p); | |
| 2064 | } | |
| 2065 | ||
| 2066 | inline _LIBCPP_INLINE_VISIBILITY bool is_empty(const path& __p, | |
| 2067 | error_code& __ec) { | |
| 2068 | return __fs_is_empty(__p, &__ec); | |
| 2069 | } | |
| 2070 | ||
| 2071 | inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(file_status __s) noexcept { | |
| 2072 | return __s.type() == file_type::fifo; | |
| 2073 | } | |
| 2074 | inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p) { | |
| 2075 | return is_fifo(__status(__p)); | |
| 2076 | } | |
| 2077 | ||
| 2078 | inline _LIBCPP_INLINE_VISIBILITY bool is_fifo(const path& __p, | |
| 2079 | error_code& __ec) noexcept { | |
| 2080 | return is_fifo(__status(__p, &__ec)); | |
| 2081 | } | |
| 2082 | ||
| 2083 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2084 | is_regular_file(file_status __s) noexcept { | |
| 2085 | return __s.type() == file_type::regular; | |
| 2086 | } | |
| 2087 | ||
| 2088 | inline _LIBCPP_INLINE_VISIBILITY bool is_regular_file(const path& __p) { | |
| 2089 | return is_regular_file(__status(__p)); | |
| 2090 | } | |
| 2091 | ||
| 2092 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2093 | is_regular_file(const path& __p, error_code& __ec) noexcept { | |
| 2094 | return is_regular_file(__status(__p, &__ec)); | |
| 2095 | } | |
| 2096 | ||
| 2097 | inline _LIBCPP_INLINE_VISIBILITY bool is_socket(file_status __s) noexcept { | |
| 2098 | return __s.type() == file_type::socket; | |
| 2099 | } | |
| 2100 | ||
| 2101 | inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p) { | |
| 2102 | return is_socket(__status(__p)); | |
| 2103 | } | |
| 2104 | ||
| 2105 | inline _LIBCPP_INLINE_VISIBILITY bool is_socket(const path& __p, | |
| 2106 | error_code& __ec) noexcept { | |
| 2107 | return is_socket(__status(__p, &__ec)); | |
| 2108 | } | |
| 2109 | ||
| 2110 | inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(file_status __s) noexcept { | |
| 2111 | return __s.type() == file_type::symlink; | |
| 2112 | } | |
| 2113 | ||
| 2114 | inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p) { | |
| 2115 | return is_symlink(__symlink_status(__p)); | |
| 2116 | } | |
| 2117 | ||
| 2118 | inline _LIBCPP_INLINE_VISIBILITY bool is_symlink(const path& __p, | |
| 2119 | error_code& __ec) noexcept { | |
| 2120 | return is_symlink(__symlink_status(__p, &__ec)); | |
| 2121 | } | |
| 2122 | ||
| 2123 | inline _LIBCPP_INLINE_VISIBILITY bool is_other(file_status __s) noexcept { | |
| 2124 | return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && | |
| 2125 | !is_symlink(__s); | |
| 2126 | } | |
| 2127 | ||
| 2128 | inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p) { | |
| 2129 | return is_other(__status(__p)); | |
| 2130 | } | |
| 2131 | ||
| 2132 | inline _LIBCPP_INLINE_VISIBILITY bool is_other(const path& __p, | |
| 2133 | error_code& __ec) noexcept { | |
| 2134 | return is_other(__status(__p, &__ec)); | |
| 2135 | } | |
| 2136 | ||
| 2137 | inline _LIBCPP_INLINE_VISIBILITY file_time_type | |
| 2138 | last_write_time(const path& __p) { | |
| 2139 | return __last_write_time(__p); | |
| 2140 | } | |
| 2141 | ||
| 2142 | inline _LIBCPP_INLINE_VISIBILITY file_time_type | |
| 2143 | last_write_time(const path& __p, error_code& __ec) noexcept { | |
| 2144 | return __last_write_time(__p, &__ec); | |
| 2145 | } | |
| 2146 | ||
| 2147 | inline _LIBCPP_INLINE_VISIBILITY void last_write_time(const path& __p, | |
| 2148 | file_time_type __t) { | |
| 2149 | __last_write_time(__p, __t); | |
| 2150 | } | |
| 2151 | ||
| 2152 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 2153 | last_write_time(const path& __p, file_time_type __t, | |
| 2154 | error_code& __ec) noexcept { | |
| 2155 | __last_write_time(__p, __t, &__ec); | |
| 2156 | } | |
| 2157 | ||
| 2158 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 2159 | permissions(const path& __p, perms __prms, | |
| 2160 | perm_options __opts = perm_options::replace) { | |
| 2161 | __permissions(__p, __prms, __opts); | |
| 2162 | } | |
| 2163 | ||
| 2164 | inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, | |
| 2165 | error_code& __ec) noexcept { | |
| 2166 | __permissions(__p, __prms, perm_options::replace, &__ec); | |
| 2167 | } | |
| 2168 | ||
| 2169 | inline _LIBCPP_INLINE_VISIBILITY void permissions(const path& __p, perms __prms, | |
| 2170 | perm_options __opts, | |
| 2171 | error_code& __ec) { | |
| 2172 | __permissions(__p, __prms, __opts, &__ec); | |
| 2173 | } | |
| 2174 | ||
| 2175 | inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, | |
| 2176 | const path& __base, | |
| 2177 | error_code& __ec) { | |
| 2178 | path __tmp = __weakly_canonical(__p, &__ec); | |
| 2179 | if (__ec) | |
| 2180 | return {}; | |
| 2181 | path __tmp_base = __weakly_canonical(__base, &__ec); | |
| 2182 | if (__ec) | |
| 2183 | return {}; | |
| 2184 | return __tmp.lexically_proximate(__tmp_base); | |
| 2185 | } | |
| 2186 | ||
| 2187 | inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, | |
| 2188 | error_code& __ec) { | |
| 2189 | return proximate(__p, current_path(), __ec); | |
| 2190 | } | |
| 2191 | ||
| 2192 | inline _LIBCPP_INLINE_VISIBILITY path | |
| 2193 | proximate(const path& __p, const path& __base = current_path()) { | |
| 2194 | return __weakly_canonical(__p).lexically_proximate( | |
| 2195 | __weakly_canonical(__base)); | |
| 2196 | } | |
| 2197 | ||
| 2198 | inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p) { | |
| 2199 | return __read_symlink(__p); | |
| 2200 | } | |
| 2201 | ||
| 2202 | inline _LIBCPP_INLINE_VISIBILITY path read_symlink(const path& __p, | |
| 2203 | error_code& __ec) { | |
| 2204 | return __read_symlink(__p, &__ec); | |
| 2205 | } | |
| 2206 | ||
| 2207 | inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, | |
| 2208 | const path& __base, | |
| 2209 | error_code& __ec) { | |
| 2210 | path __tmp = __weakly_canonical(__p, &__ec); | |
| 2211 | if (__ec) | |
| 2212 | return path(); | |
| 2213 | path __tmpbase = __weakly_canonical(__base, &__ec); | |
| 2214 | if (__ec) | |
| 2215 | return path(); | |
| 2216 | return __tmp.lexically_relative(__tmpbase); | |
| 2217 | } | |
| 2218 | ||
| 2219 | inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, | |
| 2220 | error_code& __ec) { | |
| 2221 | return relative(__p, current_path(), __ec); | |
| 2222 | } | |
| 2223 | ||
| 2224 | inline _LIBCPP_INLINE_VISIBILITY path | |
| 2225 | relative(const path& __p, const path& __base = current_path()) { | |
| 2226 | return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); | |
| 2227 | } | |
| 2228 | ||
| 2229 | inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p) { | |
| 2230 | return __remove(__p); | |
| 2231 | } | |
| 2232 | ||
| 2233 | inline _LIBCPP_INLINE_VISIBILITY bool remove(const path& __p, | |
| 2234 | error_code& __ec) noexcept { | |
| 2235 | return __remove(__p, &__ec); | |
| 2236 | } | |
| 2237 | ||
| 2238 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p) { | |
| 2239 | return __remove_all(__p); | |
| 2240 | } | |
| 2241 | ||
| 2242 | inline _LIBCPP_INLINE_VISIBILITY uintmax_t remove_all(const path& __p, | |
| 2243 | error_code& __ec) { | |
| 2244 | return __remove_all(__p, &__ec); | |
| 2245 | } | |
| 2246 | ||
| 2247 | inline _LIBCPP_INLINE_VISIBILITY void rename(const path& __from, | |
| 2248 | const path& __to) { | |
| 2249 | return __rename(__from, __to); | |
| 2250 | } | |
| 2251 | ||
| 2252 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 2253 | rename(const path& __from, const path& __to, error_code& __ec) noexcept { | |
| 2254 | return __rename(__from, __to, &__ec); | |
| 2255 | } | |
| 2256 | ||
| 2257 | inline _LIBCPP_INLINE_VISIBILITY void resize_file(const path& __p, | |
| 2258 | uintmax_t __ns) { | |
| 2259 | return __resize_file(__p, __ns); | |
| 2260 | } | |
| 2261 | ||
| 2262 | inline _LIBCPP_INLINE_VISIBILITY void | |
| 2263 | resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { | |
| 2264 | return __resize_file(__p, __ns, &__ec); | |
| 2265 | } | |
| 2266 | ||
| 2267 | inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p) { | |
| 2268 | return __space(__p); | |
| 2269 | } | |
| 2270 | ||
| 2271 | inline _LIBCPP_INLINE_VISIBILITY space_info space(const path& __p, | |
| 2272 | error_code& __ec) noexcept { | |
| 2273 | return __space(__p, &__ec); | |
| 2274 | } | |
| 2275 | ||
| 2276 | inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p) { | |
| 2277 | return __status(__p); | |
| 2278 | } | |
| 2279 | ||
| 2280 | inline _LIBCPP_INLINE_VISIBILITY file_status status(const path& __p, | |
| 2281 | error_code& __ec) noexcept { | |
| 2282 | return __status(__p, &__ec); | |
| 2283 | } | |
| 2284 | ||
| 2285 | inline _LIBCPP_INLINE_VISIBILITY file_status symlink_status(const path& __p) { | |
| 2286 | return __symlink_status(__p); | |
| 2287 | } | |
| 2288 | ||
| 2289 | inline _LIBCPP_INLINE_VISIBILITY file_status | |
| 2290 | symlink_status(const path& __p, error_code& __ec) noexcept { | |
| 2291 | return __symlink_status(__p, &__ec); | |
| 2292 | } | |
| 2293 | ||
| 2294 | inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path() { | |
| 2295 | return __temp_directory_path(); | |
| 2296 | } | |
| 2297 | ||
| 2298 | inline _LIBCPP_INLINE_VISIBILITY path temp_directory_path(error_code& __ec) { | |
| 2299 | return __temp_directory_path(&__ec); | |
| 2300 | } | |
| 2301 | ||
| 2302 | inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p) { | |
| 2303 | return __weakly_canonical(__p); | |
| 2304 | } | |
| 2305 | ||
| 2306 | inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p, | |
| 2307 | error_code& __ec) { | |
| 2308 | return __weakly_canonical(__p, &__ec); | |
| 2309 | } | |
| 2310 | ||
| 2311 | class directory_iterator; | |
| 2312 | class recursive_directory_iterator; | |
| 2313 | class _LIBCPP_HIDDEN __dir_stream; | |
| 2314 | ||
| 2315 | class directory_entry { | |
| 2316 | typedef _VSTD_FS::path _Path; | |
| 2317 | ||
| 2318 | public: | |
| 2319 | // constructors and destructors | |
| 2320 | directory_entry() noexcept = default; | |
| 2321 | directory_entry(directory_entry const&) = default; | |
| 2322 | directory_entry(directory_entry&&) noexcept = default; | |
| 2323 | ||
| 2324 | _LIBCPP_INLINE_VISIBILITY | |
| 2325 | explicit directory_entry(_Path const& __p) : __p_(__p) { | |
| 2326 | error_code __ec; | |
| 2327 | __refresh(&__ec); | |
| 2328 | } | |
| 2329 | ||
| 2330 | _LIBCPP_INLINE_VISIBILITY | |
| 2331 | directory_entry(_Path const& __p, error_code& __ec) : __p_(__p) { | |
| 2332 | __refresh(&__ec); | |
| 2333 | } | |
| 2334 | ||
| 2335 | ~directory_entry() {} | |
| 2336 | ||
| 2337 | directory_entry& operator=(directory_entry const&) = default; | |
| 2338 | directory_entry& operator=(directory_entry&&) noexcept = default; | |
| 2339 | ||
| 2340 | _LIBCPP_INLINE_VISIBILITY | |
| 2341 | void assign(_Path const& __p) { | |
| 2342 | __p_ = __p; | |
| 2343 | error_code __ec; | |
| 2344 | __refresh(&__ec); | |
| 2345 | } | |
| 2346 | ||
| 2347 | _LIBCPP_INLINE_VISIBILITY | |
| 2348 | void assign(_Path const& __p, error_code& __ec) { | |
| 2349 | __p_ = __p; | |
| 2350 | __refresh(&__ec); | |
| 2351 | } | |
| 2352 | ||
| 2353 | _LIBCPP_INLINE_VISIBILITY | |
| 2354 | void replace_filename(_Path const& __p) { | |
| 2355 | __p_.replace_filename(__p); | |
| 2356 | error_code __ec; | |
| 2357 | __refresh(&__ec); | |
| 2358 | } | |
| 2359 | ||
| 2360 | _LIBCPP_INLINE_VISIBILITY | |
| 2361 | void replace_filename(_Path const& __p, error_code& __ec) { | |
| 2362 | __p_ = __p_.parent_path() / __p; | |
| 2363 | __refresh(&__ec); | |
| 2364 | } | |
| 2365 | ||
| 2366 | _LIBCPP_INLINE_VISIBILITY | |
| 2367 | void refresh() { __refresh(); } | |
| 2368 | ||
| 2369 | _LIBCPP_INLINE_VISIBILITY | |
| 2370 | void refresh(error_code& __ec) noexcept { __refresh(&__ec); } | |
| 2371 | ||
| 2372 | _LIBCPP_INLINE_VISIBILITY | |
| 2373 | _Path const& path() const noexcept { return __p_; } | |
| 2374 | ||
| 2375 | _LIBCPP_INLINE_VISIBILITY | |
| 2376 | operator const _Path&() const noexcept { return __p_; } | |
| 2377 | ||
| 2378 | _LIBCPP_INLINE_VISIBILITY | |
| 2379 | bool exists() const { return _VSTD_FS::exists(file_status{__get_ft()}); } | |
| 2380 | ||
| 2381 | _LIBCPP_INLINE_VISIBILITY | |
| 2382 | bool exists(error_code& __ec) const noexcept { | |
| 2383 | return _VSTD_FS::exists(file_status{__get_ft(&__ec)}); | |
| 2384 | } | |
| 2385 | ||
| 2386 | _LIBCPP_INLINE_VISIBILITY | |
| 2387 | bool is_block_file() const { return __get_ft() == file_type::block; } | |
| 2388 | ||
| 2389 | _LIBCPP_INLINE_VISIBILITY | |
| 2390 | bool is_block_file(error_code& __ec) const noexcept { | |
| 2391 | return __get_ft(&__ec) == file_type::block; | |
| 2392 | } | |
| 2393 | ||
| 2394 | _LIBCPP_INLINE_VISIBILITY | |
| 2395 | bool is_character_file() const { return __get_ft() == file_type::character; } | |
| 2396 | ||
| 2397 | _LIBCPP_INLINE_VISIBILITY | |
| 2398 | bool is_character_file(error_code& __ec) const noexcept { | |
| 2399 | return __get_ft(&__ec) == file_type::character; | |
| 2400 | } | |
| 2401 | ||
| 2402 | _LIBCPP_INLINE_VISIBILITY | |
| 2403 | bool is_directory() const { return __get_ft() == file_type::directory; } | |
| 2404 | ||
| 2405 | _LIBCPP_INLINE_VISIBILITY | |
| 2406 | bool is_directory(error_code& __ec) const noexcept { | |
| 2407 | return __get_ft(&__ec) == file_type::directory; | |
| 2408 | } | |
| 2409 | ||
| 2410 | _LIBCPP_INLINE_VISIBILITY | |
| 2411 | bool is_fifo() const { return __get_ft() == file_type::fifo; } | |
| 2412 | ||
| 2413 | _LIBCPP_INLINE_VISIBILITY | |
| 2414 | bool is_fifo(error_code& __ec) const noexcept { | |
| 2415 | return __get_ft(&__ec) == file_type::fifo; | |
| 2416 | } | |
| 2417 | ||
| 2418 | _LIBCPP_INLINE_VISIBILITY | |
| 2419 | bool is_other() const { return _VSTD_FS::is_other(file_status{__get_ft()}); } | |
| 2420 | ||
| 2421 | _LIBCPP_INLINE_VISIBILITY | |
| 2422 | bool is_other(error_code& __ec) const noexcept { | |
| 2423 | return _VSTD_FS::is_other(file_status{__get_ft(&__ec)}); | |
| 2424 | } | |
| 2425 | ||
| 2426 | _LIBCPP_INLINE_VISIBILITY | |
| 2427 | bool is_regular_file() const { return __get_ft() == file_type::regular; } | |
| 2428 | ||
| 2429 | _LIBCPP_INLINE_VISIBILITY | |
| 2430 | bool is_regular_file(error_code& __ec) const noexcept { | |
| 2431 | return __get_ft(&__ec) == file_type::regular; | |
| 2432 | } | |
| 2433 | ||
| 2434 | _LIBCPP_INLINE_VISIBILITY | |
| 2435 | bool is_socket() const { return __get_ft() == file_type::socket; } | |
| 2436 | ||
| 2437 | _LIBCPP_INLINE_VISIBILITY | |
| 2438 | bool is_socket(error_code& __ec) const noexcept { | |
| 2439 | return __get_ft(&__ec) == file_type::socket; | |
| 2440 | } | |
| 2441 | ||
| 2442 | _LIBCPP_INLINE_VISIBILITY | |
| 2443 | bool is_symlink() const { return __get_sym_ft() == file_type::symlink; } | |
| 2444 | ||
| 2445 | _LIBCPP_INLINE_VISIBILITY | |
| 2446 | bool is_symlink(error_code& __ec) const noexcept { | |
| 2447 | return __get_sym_ft(&__ec) == file_type::symlink; | |
| 2448 | } | |
| 2449 | _LIBCPP_INLINE_VISIBILITY | |
| 2450 | uintmax_t file_size() const { return __get_size(); } | |
| 2451 | ||
| 2452 | _LIBCPP_INLINE_VISIBILITY | |
| 2453 | uintmax_t file_size(error_code& __ec) const noexcept { | |
| 2454 | return __get_size(&__ec); | |
| 2455 | } | |
| 2456 | ||
| 2457 | _LIBCPP_INLINE_VISIBILITY | |
| 2458 | uintmax_t hard_link_count() const { return __get_nlink(); } | |
| 2459 | ||
| 2460 | _LIBCPP_INLINE_VISIBILITY | |
| 2461 | uintmax_t hard_link_count(error_code& __ec) const noexcept { | |
| 2462 | return __get_nlink(&__ec); | |
| 2463 | } | |
| 2464 | ||
| 2465 | _LIBCPP_INLINE_VISIBILITY | |
| 2466 | file_time_type last_write_time() const { return __get_write_time(); } | |
| 2467 | ||
| 2468 | _LIBCPP_INLINE_VISIBILITY | |
| 2469 | file_time_type last_write_time(error_code& __ec) const noexcept { | |
| 2470 | return __get_write_time(&__ec); | |
| 2471 | } | |
| 2472 | ||
| 2473 | _LIBCPP_INLINE_VISIBILITY | |
| 2474 | file_status status() const { return __get_status(); } | |
| 2475 | ||
| 2476 | _LIBCPP_INLINE_VISIBILITY | |
| 2477 | file_status status(error_code& __ec) const noexcept { | |
| 2478 | return __get_status(&__ec); | |
| 2479 | } | |
| 2480 | ||
| 2481 | _LIBCPP_INLINE_VISIBILITY | |
| 2482 | file_status symlink_status() const { return __get_symlink_status(); } | |
| 2483 | ||
| 2484 | _LIBCPP_INLINE_VISIBILITY | |
| 2485 | file_status symlink_status(error_code& __ec) const noexcept { | |
| 2486 | return __get_symlink_status(&__ec); | |
| 2487 | } | |
| 2488 | ||
| 2489 | _LIBCPP_INLINE_VISIBILITY | |
| 2490 | bool operator<(directory_entry const& __rhs) const noexcept { | |
| 2491 | return __p_ < __rhs.__p_; | |
| 2492 | } | |
| 2493 | ||
| 2494 | _LIBCPP_INLINE_VISIBILITY | |
| 2495 | bool operator==(directory_entry const& __rhs) const noexcept { | |
| 2496 | return __p_ == __rhs.__p_; | |
| 2497 | } | |
| 2498 | ||
| 2499 | _LIBCPP_INLINE_VISIBILITY | |
| 2500 | bool operator!=(directory_entry const& __rhs) const noexcept { | |
| 2501 | return __p_ != __rhs.__p_; | |
| 2502 | } | |
| 2503 | ||
| 2504 | _LIBCPP_INLINE_VISIBILITY | |
| 2505 | bool operator<=(directory_entry const& __rhs) const noexcept { | |
| 2506 | return __p_ <= __rhs.__p_; | |
| 2507 | } | |
| 2508 | ||
| 2509 | _LIBCPP_INLINE_VISIBILITY | |
| 2510 | bool operator>(directory_entry const& __rhs) const noexcept { | |
| 2511 | return __p_ > __rhs.__p_; | |
| 2512 | } | |
| 2513 | ||
| 2514 | _LIBCPP_INLINE_VISIBILITY | |
| 2515 | bool operator>=(directory_entry const& __rhs) const noexcept { | |
| 2516 | return __p_ >= __rhs.__p_; | |
| 2517 | } | |
| 2518 | ||
| 2519 | private: | |
| 2520 | friend class directory_iterator; | |
| 2521 | friend class recursive_directory_iterator; | |
| 2522 | friend class __dir_stream; | |
| 2523 | ||
| 2524 | enum _CacheType : unsigned char { | |
| 2525 | _Empty, | |
| 2526 | _IterSymlink, | |
| 2527 | _IterNonSymlink, | |
| 2528 | _RefreshSymlink, | |
| 2529 | _RefreshSymlinkUnresolved, | |
| 2530 | _RefreshNonSymlink | |
| 2531 | }; | |
| 2532 | ||
| 2533 | struct __cached_data { | |
| 2534 | uintmax_t __size_; | |
| 2535 | uintmax_t __nlink_; | |
| 2536 | file_time_type __write_time_; | |
| 2537 | perms __sym_perms_; | |
| 2538 | perms __non_sym_perms_; | |
| 2539 | file_type __type_; | |
| 2540 | _CacheType __cache_type_; | |
| 2541 | ||
| 2542 | _LIBCPP_INLINE_VISIBILITY | |
| 2543 | __cached_data() noexcept { __reset(); } | |
| 2544 | ||
| 2545 | _LIBCPP_INLINE_VISIBILITY | |
| 2546 | void __reset() { | |
| 2547 | __cache_type_ = _Empty; | |
| 2548 | __type_ = file_type::none; | |
| 2549 | __sym_perms_ = __non_sym_perms_ = perms::unknown; | |
| 2550 | __size_ = __nlink_ = uintmax_t(-1); | |
| 2551 | __write_time_ = file_time_type::min(); | |
| 2552 | } | |
| 2553 | }; | |
| 2554 | ||
| 2555 | _LIBCPP_INLINE_VISIBILITY | |
| 2556 | static __cached_data __create_iter_result(file_type __ft) { | |
| 2557 | __cached_data __data; | |
| 2558 | __data.__type_ = __ft; | |
| 2559 | __data.__cache_type_ = [&]() { | |
| 2560 | switch (__ft) { | |
| 2561 | case file_type::none: | |
| 2562 | return _Empty; | |
| 2563 | case file_type::symlink: | |
| 2564 | return _IterSymlink; | |
| 2565 | default: | |
| 2566 | return _IterNonSymlink; | |
| 2567 | } | |
| 2568 | }(); | |
| 2569 | return __data; | |
| 2570 | } | |
| 2571 | ||
| 2572 | _LIBCPP_INLINE_VISIBILITY | |
| 2573 | void __assign_iter_entry(_Path&& __p, __cached_data __dt) { | |
| 2574 | __p_ = _VSTD::move(__p); | |
| 2575 | __data_ = __dt; | |
| 2576 | } | |
| 2577 | ||
| 2578 | _LIBCPP_FUNC_VIS | |
| 2579 | error_code __do_refresh() noexcept; | |
| 2580 | ||
| 2581 | _LIBCPP_INLINE_VISIBILITY | |
| 2582 | static bool __is_dne_error(error_code const& __ec) { | |
| 2583 | if (!__ec) | |
| 2584 | return true; | |
| 2585 | switch (static_cast<errc>(__ec.value())) { | |
| 2586 | case errc::no_such_file_or_directory: | |
| 2587 | case errc::not_a_directory: | |
| 2588 | return true; | |
| 2589 | default: | |
| 2590 | return false; | |
| 2591 | } | |
| 2592 | } | |
| 2593 | ||
| 2594 | _LIBCPP_INLINE_VISIBILITY | |
| 2595 | void __handle_error(const char* __msg, error_code* __dest_ec, | |
| 2596 | error_code const& __ec, bool __allow_dne = false) const { | |
| 2597 | if (__dest_ec) { | |
| 2598 | *__dest_ec = __ec; | |
| 2599 | return; | |
| 2600 | } | |
| 2601 | if (__ec && (!__allow_dne || !__is_dne_error(__ec))) | |
| 2602 | __throw_filesystem_error(__msg, __p_, __ec); | |
| 2603 | } | |
| 2604 | ||
| 2605 | _LIBCPP_INLINE_VISIBILITY | |
| 2606 | void __refresh(error_code* __ec = nullptr) { | |
| 2607 | __handle_error("in directory_entry::refresh", __ec, __do_refresh(), | |
| 2608 | /*allow_dne*/ true); | |
| 2609 | } | |
| 2610 | ||
| 2611 | _LIBCPP_INLINE_VISIBILITY | |
| 2612 | file_type __get_sym_ft(error_code* __ec = nullptr) const { | |
| 2613 | switch (__data_.__cache_type_) { | |
| 2614 | case _Empty: | |
| 2615 | return __symlink_status(__p_, __ec).type(); | |
| 2616 | case _IterSymlink: | |
| 2617 | case _RefreshSymlink: | |
| 2618 | case _RefreshSymlinkUnresolved: | |
| 2619 | if (__ec) | |
| 2620 | __ec->clear(); | |
| 2621 | return file_type::symlink; | |
| 2622 | case _IterNonSymlink: | |
| 2623 | case _RefreshNonSymlink: | |
| 2624 | file_status __st(__data_.__type_); | |
| 2625 | if (__ec && !_VSTD_FS::exists(__st)) | |
| 2626 | *__ec = make_error_code(errc::no_such_file_or_directory); | |
| 2627 | else if (__ec) | |
| 2628 | __ec->clear(); | |
| 2629 | return __data_.__type_; | |
| 2630 | } | |
| 2631 | _LIBCPP_UNREACHABLE(); | |
| 2632 | } | |
| 2633 | ||
| 2634 | _LIBCPP_INLINE_VISIBILITY | |
| 2635 | file_type __get_ft(error_code* __ec = nullptr) const { | |
| 2636 | switch (__data_.__cache_type_) { | |
| 2637 | case _Empty: | |
| 2638 | case _IterSymlink: | |
| 2639 | case _RefreshSymlinkUnresolved: | |
| 2640 | return __status(__p_, __ec).type(); | |
| 2641 | case _IterNonSymlink: | |
| 2642 | case _RefreshNonSymlink: | |
| 2643 | case _RefreshSymlink: { | |
| 2644 | file_status __st(__data_.__type_); | |
| 2645 | if (__ec && !_VSTD_FS::exists(__st)) | |
| 2646 | *__ec = make_error_code(errc::no_such_file_or_directory); | |
| 2647 | else if (__ec) | |
| 2648 | __ec->clear(); | |
| 2649 | return __data_.__type_; | |
| 2650 | } | |
| 2651 | } | |
| 2652 | _LIBCPP_UNREACHABLE(); | |
| 2653 | } | |
| 2654 | ||
| 2655 | _LIBCPP_INLINE_VISIBILITY | |
| 2656 | file_status __get_status(error_code* __ec = nullptr) const { | |
| 2657 | switch (__data_.__cache_type_) { | |
| 2658 | case _Empty: | |
| 2659 | case _IterNonSymlink: | |
| 2660 | case _IterSymlink: | |
| 2661 | case _RefreshSymlinkUnresolved: | |
| 2662 | return __status(__p_, __ec); | |
| 2663 | case _RefreshNonSymlink: | |
| 2664 | case _RefreshSymlink: | |
| 2665 | return file_status(__get_ft(__ec), __data_.__non_sym_perms_); | |
| 2666 | } | |
| 2667 | _LIBCPP_UNREACHABLE(); | |
| 2668 | } | |
| 2669 | ||
| 2670 | _LIBCPP_INLINE_VISIBILITY | |
| 2671 | file_status __get_symlink_status(error_code* __ec = nullptr) const { | |
| 2672 | switch (__data_.__cache_type_) { | |
| 2673 | case _Empty: | |
| 2674 | case _IterNonSymlink: | |
| 2675 | case _IterSymlink: | |
| 2676 | return __symlink_status(__p_, __ec); | |
| 2677 | case _RefreshNonSymlink: | |
| 2678 | return file_status(__get_sym_ft(__ec), __data_.__non_sym_perms_); | |
| 2679 | case _RefreshSymlink: | |
| 2680 | case _RefreshSymlinkUnresolved: | |
| 2681 | return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); | |
| 2682 | } | |
| 2683 | _LIBCPP_UNREACHABLE(); | |
| 2684 | } | |
| 2685 | ||
| 2686 | _LIBCPP_INLINE_VISIBILITY | |
| 2687 | uintmax_t __get_size(error_code* __ec = nullptr) const { | |
| 2688 | switch (__data_.__cache_type_) { | |
| 2689 | case _Empty: | |
| 2690 | case _IterNonSymlink: | |
| 2691 | case _IterSymlink: | |
| 2692 | case _RefreshSymlinkUnresolved: | |
| 2693 | return _VSTD_FS::__file_size(__p_, __ec); | |
| 2694 | case _RefreshSymlink: | |
| 2695 | case _RefreshNonSymlink: { | |
| 2696 | error_code __m_ec; | |
| 2697 | file_status __st(__get_ft(&__m_ec)); | |
| 2698 | __handle_error("in directory_entry::file_size", __ec, __m_ec); | |
| 2699 | if (_VSTD_FS::exists(__st) && !_VSTD_FS::is_regular_file(__st)) { | |
| 2700 | errc __err_kind = _VSTD_FS::is_directory(__st) ? errc::is_a_directory | |
| 2701 | : errc::not_supported; | |
| 2702 | __handle_error("in directory_entry::file_size", __ec, | |
| 2703 | make_error_code(__err_kind)); | |
| 2704 | } | |
| 2705 | return __data_.__size_; | |
| 2706 | } | |
| 2707 | } | |
| 2708 | _LIBCPP_UNREACHABLE(); | |
| 2709 | } | |
| 2710 | ||
| 2711 | _LIBCPP_INLINE_VISIBILITY | |
| 2712 | uintmax_t __get_nlink(error_code* __ec = nullptr) const { | |
| 2713 | switch (__data_.__cache_type_) { | |
| 2714 | case _Empty: | |
| 2715 | case _IterNonSymlink: | |
| 2716 | case _IterSymlink: | |
| 2717 | case _RefreshSymlinkUnresolved: | |
| 2718 | return _VSTD_FS::__hard_link_count(__p_, __ec); | |
| 2719 | case _RefreshSymlink: | |
| 2720 | case _RefreshNonSymlink: { | |
| 2721 | error_code __m_ec; | |
| 2722 | (void)__get_ft(&__m_ec); | |
| 2723 | __handle_error("in directory_entry::hard_link_count", __ec, __m_ec); | |
| 2724 | return __data_.__nlink_; | |
| 2725 | } | |
| 2726 | } | |
| 2727 | _LIBCPP_UNREACHABLE(); | |
| 2728 | } | |
| 2729 | ||
| 2730 | _LIBCPP_INLINE_VISIBILITY | |
| 2731 | file_time_type __get_write_time(error_code* __ec = nullptr) const { | |
| 2732 | switch (__data_.__cache_type_) { | |
| 2733 | case _Empty: | |
| 2734 | case _IterNonSymlink: | |
| 2735 | case _IterSymlink: | |
| 2736 | case _RefreshSymlinkUnresolved: | |
| 2737 | return _VSTD_FS::__last_write_time(__p_, __ec); | |
| 2738 | case _RefreshSymlink: | |
| 2739 | case _RefreshNonSymlink: { | |
| 2740 | error_code __m_ec; | |
| 2741 | file_status __st(__get_ft(&__m_ec)); | |
| 2742 | __handle_error("in directory_entry::last_write_time", __ec, __m_ec); | |
| 2743 | if (_VSTD_FS::exists(__st) && | |
| 2744 | __data_.__write_time_ == file_time_type::min()) | |
| 2745 | __handle_error("in directory_entry::last_write_time", __ec, | |
| 2746 | make_error_code(errc::value_too_large)); | |
| 2747 | return __data_.__write_time_; | |
| 2748 | } | |
| 2749 | } | |
| 2750 | _LIBCPP_UNREACHABLE(); | |
| 2751 | } | |
| 2752 | ||
| 2753 | private: | |
| 2754 | _Path __p_; | |
| 2755 | __cached_data __data_; | |
| 2756 | }; | |
| 2757 | ||
| 2758 | class __dir_element_proxy { | |
| 2759 | public: | |
| 2760 | inline _LIBCPP_INLINE_VISIBILITY directory_entry operator*() { | |
| 2761 | return _VSTD::move(__elem_); | |
| 2762 | } | |
| 2763 | ||
| 2764 | private: | |
| 2765 | friend class directory_iterator; | |
| 2766 | friend class recursive_directory_iterator; | |
| 2767 | explicit __dir_element_proxy(directory_entry const& __e) : __elem_(__e) {} | |
| 2768 | __dir_element_proxy(__dir_element_proxy&& __o) | |
| 2769 | : __elem_(_VSTD::move(__o.__elem_)) {} | |
| 2770 | directory_entry __elem_; | |
| 2771 | }; | |
| 2772 | ||
| 2773 | class directory_iterator { | |
| 2774 | public: | |
| 2775 | typedef directory_entry value_type; | |
| 2776 | typedef ptrdiff_t difference_type; | |
| 2777 | typedef value_type const* pointer; | |
| 2778 | typedef value_type const& reference; | |
| 2779 | typedef input_iterator_tag iterator_category; | |
| 2780 | ||
| 2781 | public: | |
| 2782 | //ctor & dtor | |
| 2783 | directory_iterator() noexcept {} | |
| 2784 | ||
| 2785 | explicit directory_iterator(const path& __p) | |
| 2786 | : directory_iterator(__p, nullptr) {} | |
| 2787 | ||
| 2788 | directory_iterator(const path& __p, directory_options __opts) | |
| 2789 | : directory_iterator(__p, nullptr, __opts) {} | |
| 2790 | ||
| 2791 | directory_iterator(const path& __p, error_code& __ec) | |
| 2792 | : directory_iterator(__p, &__ec) {} | |
| 2793 | ||
| 2794 | directory_iterator(const path& __p, directory_options __opts, | |
| 2795 | error_code& __ec) | |
| 2796 | : directory_iterator(__p, &__ec, __opts) {} | |
| 2797 | ||
| 2798 | directory_iterator(const directory_iterator&) = default; | |
| 2799 | directory_iterator(directory_iterator&&) = default; | |
| 2800 | directory_iterator& operator=(const directory_iterator&) = default; | |
| 2801 | ||
| 2802 | directory_iterator& operator=(directory_iterator&& __o) noexcept { | |
| 2803 | // non-default implementation provided to support self-move assign. | |
| 2804 | if (this != &__o) { | |
| 2805 | __imp_ = _VSTD::move(__o.__imp_); | |
| 2806 | } | |
| 2807 | return *this; | |
| 2808 | } | |
| 2809 | ||
| 2810 | ~directory_iterator() = default; | |
| 2811 | ||
| 2812 | const directory_entry& operator*() const { | |
| 2813 | _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); | |
| 2814 | return __dereference(); | |
| 2815 | } | |
| 2816 | ||
| 2817 | const directory_entry* operator->() const { return &**this; } | |
| 2818 | ||
| 2819 | directory_iterator& operator++() { return __increment(); } | |
| 2820 | ||
| 2821 | __dir_element_proxy operator++(int) { | |
| 2822 | __dir_element_proxy __p(**this); | |
| 2823 | __increment(); | |
| 2824 | return __p; | |
| 2825 | } | |
| 2826 | ||
| 2827 | directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } | |
| 2828 | ||
| 2829 | private: | |
| 2830 | inline _LIBCPP_INLINE_VISIBILITY friend bool | |
| 2831 | operator==(const directory_iterator& __lhs, | |
| 2832 | const directory_iterator& __rhs) noexcept; | |
| 2833 | ||
| 2834 | // construct the dir_stream | |
| 2835 | _LIBCPP_FUNC_VIS | |
| 2836 | directory_iterator(const path&, error_code*, | |
| 2837 | directory_options = directory_options::none); | |
| 2838 | ||
| 2839 | _LIBCPP_FUNC_VIS | |
| 2840 | directory_iterator& __increment(error_code* __ec = nullptr); | |
| 2841 | ||
| 2842 | _LIBCPP_FUNC_VIS | |
| 2843 | const directory_entry& __dereference() const; | |
| 2844 | ||
| 2845 | private: | |
| 2846 | shared_ptr<__dir_stream> __imp_; | |
| 2847 | }; | |
| 2848 | ||
| 2849 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2850 | operator==(const directory_iterator& __lhs, | |
| 2851 | const directory_iterator& __rhs) noexcept { | |
| 2852 | return __lhs.__imp_ == __rhs.__imp_; | |
| 2853 | } | |
| 2854 | ||
| 2855 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2856 | operator!=(const directory_iterator& __lhs, | |
| 2857 | const directory_iterator& __rhs) noexcept { | |
| 2858 | return !(__lhs == __rhs); | |
| 2859 | } | |
| 2860 | ||
| 2861 | // enable directory_iterator range-based for statements | |
| 2862 | inline _LIBCPP_INLINE_VISIBILITY directory_iterator | |
| 2863 | begin(directory_iterator __iter) noexcept { | |
| 2864 | return __iter; | |
| 2865 | } | |
| 2866 | ||
| 2867 | inline _LIBCPP_INLINE_VISIBILITY directory_iterator | |
| 2868 | end(const directory_iterator&) noexcept { | |
| 2869 | return directory_iterator(); | |
| 2870 | } | |
| 2871 | ||
| 2872 | class recursive_directory_iterator { | |
| 2873 | public: | |
| 2874 | using value_type = directory_entry; | |
| 2875 | using difference_type = ptrdiff_t; | |
| 2876 | using pointer = directory_entry const*; | |
| 2877 | using reference = directory_entry const&; | |
| 2878 | using iterator_category = input_iterator_tag; | |
| 2879 | ||
| 2880 | public: | |
| 2881 | // constructors and destructor | |
| 2882 | _LIBCPP_INLINE_VISIBILITY | |
| 2883 | recursive_directory_iterator() noexcept : __rec_(false) {} | |
| 2884 | ||
| 2885 | _LIBCPP_INLINE_VISIBILITY | |
| 2886 | explicit recursive_directory_iterator( | |
| 2887 | const path& __p, directory_options __xoptions = directory_options::none) | |
| 2888 | : recursive_directory_iterator(__p, __xoptions, nullptr) {} | |
| 2889 | ||
| 2890 | _LIBCPP_INLINE_VISIBILITY | |
| 2891 | recursive_directory_iterator(const path& __p, directory_options __xoptions, | |
| 2892 | error_code& __ec) | |
| 2893 | : recursive_directory_iterator(__p, __xoptions, &__ec) {} | |
| 2894 | ||
| 2895 | _LIBCPP_INLINE_VISIBILITY | |
| 2896 | recursive_directory_iterator(const path& __p, error_code& __ec) | |
| 2897 | : recursive_directory_iterator(__p, directory_options::none, &__ec) {} | |
| 2898 | ||
| 2899 | recursive_directory_iterator(const recursive_directory_iterator&) = default; | |
| 2900 | recursive_directory_iterator(recursive_directory_iterator&&) = default; | |
| 2901 | ||
| 2902 | recursive_directory_iterator& | |
| 2903 | operator=(const recursive_directory_iterator&) = default; | |
| 2904 | ||
| 2905 | _LIBCPP_INLINE_VISIBILITY | |
| 2906 | recursive_directory_iterator& | |
| 2907 | operator=(recursive_directory_iterator&& __o) noexcept { | |
| 2908 | // non-default implementation provided to support self-move assign. | |
| 2909 | if (this != &__o) { | |
| 2910 | __imp_ = _VSTD::move(__o.__imp_); | |
| 2911 | __rec_ = __o.__rec_; | |
| 2912 | } | |
| 2913 | return *this; | |
| 2914 | } | |
| 2915 | ||
| 2916 | ~recursive_directory_iterator() = default; | |
| 2917 | ||
| 2918 | _LIBCPP_INLINE_VISIBILITY | |
| 2919 | const directory_entry& operator*() const { return __dereference(); } | |
| 2920 | ||
| 2921 | _LIBCPP_INLINE_VISIBILITY | |
| 2922 | const directory_entry* operator->() const { return &__dereference(); } | |
| 2923 | ||
| 2924 | recursive_directory_iterator& operator++() { return __increment(); } | |
| 2925 | ||
| 2926 | _LIBCPP_INLINE_VISIBILITY | |
| 2927 | __dir_element_proxy operator++(int) { | |
| 2928 | __dir_element_proxy __p(**this); | |
| 2929 | __increment(); | |
| 2930 | return __p; | |
| 2931 | } | |
| 2932 | ||
| 2933 | _LIBCPP_INLINE_VISIBILITY | |
| 2934 | recursive_directory_iterator& increment(error_code& __ec) { | |
| 2935 | return __increment(&__ec); | |
| 2936 | } | |
| 2937 | ||
| 2938 | _LIBCPP_FUNC_VIS directory_options options() const; | |
| 2939 | _LIBCPP_FUNC_VIS int depth() const; | |
| 2940 | ||
| 2941 | _LIBCPP_INLINE_VISIBILITY | |
| 2942 | void pop() { __pop(); } | |
| 2943 | ||
| 2944 | _LIBCPP_INLINE_VISIBILITY | |
| 2945 | void pop(error_code& __ec) { __pop(&__ec); } | |
| 2946 | ||
| 2947 | _LIBCPP_INLINE_VISIBILITY | |
| 2948 | bool recursion_pending() const { return __rec_; } | |
| 2949 | ||
| 2950 | _LIBCPP_INLINE_VISIBILITY | |
| 2951 | void disable_recursion_pending() { __rec_ = false; } | |
| 2952 | ||
| 2953 | private: | |
| 2954 | _LIBCPP_FUNC_VIS | |
| 2955 | recursive_directory_iterator(const path& __p, directory_options __opt, | |
| 2956 | error_code* __ec); | |
| 2957 | ||
| 2958 | _LIBCPP_FUNC_VIS | |
| 2959 | const directory_entry& __dereference() const; | |
| 2960 | ||
| 2961 | _LIBCPP_FUNC_VIS | |
| 2962 | bool __try_recursion(error_code* __ec); | |
| 2963 | ||
| 2964 | _LIBCPP_FUNC_VIS | |
| 2965 | void __advance(error_code* __ec = nullptr); | |
| 2966 | ||
| 2967 | _LIBCPP_FUNC_VIS | |
| 2968 | recursive_directory_iterator& __increment(error_code* __ec = nullptr); | |
| 2969 | ||
| 2970 | _LIBCPP_FUNC_VIS | |
| 2971 | void __pop(error_code* __ec = nullptr); | |
| 2972 | ||
| 2973 | inline _LIBCPP_INLINE_VISIBILITY friend bool | |
| 2974 | operator==(const recursive_directory_iterator&, | |
| 2975 | const recursive_directory_iterator&) noexcept; | |
| 2976 | ||
| 2977 | struct _LIBCPP_HIDDEN __shared_imp; | |
| 2978 | shared_ptr<__shared_imp> __imp_; | |
| 2979 | bool __rec_; | |
| 2980 | }; // class recursive_directory_iterator | |
| 2981 | ||
| 2982 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 2983 | operator==(const recursive_directory_iterator& __lhs, | |
| 2984 | const recursive_directory_iterator& __rhs) noexcept { | |
| 2985 | return __lhs.__imp_ == __rhs.__imp_; | |
| 2986 | } | |
| 2987 | ||
| 2988 | _LIBCPP_INLINE_VISIBILITY | |
| 2989 | inline bool operator!=(const recursive_directory_iterator& __lhs, | |
| 2990 | const recursive_directory_iterator& __rhs) noexcept { | |
| 2991 | return !(__lhs == __rhs); | |
| 2992 | } | |
| 2993 | // enable recursive_directory_iterator range-based for statements | |
| 2994 | inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator | |
| 2995 | begin(recursive_directory_iterator __iter) noexcept { | |
| 2996 | return __iter; | |
| 2997 | } | |
| 2998 | ||
| 2999 | inline _LIBCPP_INLINE_VISIBILITY recursive_directory_iterator | |
| 3000 | end(const recursive_directory_iterator&) noexcept { | |
| 3001 | return recursive_directory_iterator(); | |
| 3002 | } | |
| 3003 | ||
| 3004 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP | |
| 3005 | ||
| 3006 | _LIBCPP_END_NAMESPACE_FILESYSTEM | |
| 3007 | ||
| 3008 | #endif // !_LIBCPP_CXX03_LANG | |
| 3009 | ||
| 3010 | _LIBCPP_POP_MACROS | |
| 3011 | ||
| 3012 | 269 | #endif // _LIBCPP_FILESYSTEM |
lib/libcxx/include/float.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- float.h ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/format+515-37| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- format -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -13,59 +13,146 @@ |
| 13 | 13 | /* |
| 14 | 14 | |
| 15 | 15 | namespace std { |
| 16 | // [format.error], class format_error | |
| 17 | class format_error : public runtime_error { | |
| 18 | public: | |
| 19 | explicit format_error(const string& what_arg); | |
| 20 | explicit format_error(const char* what_arg); | |
| 16 | // [format.context], class template basic_format_context | |
| 17 | template<class Out, class charT> class basic_format_context; | |
| 18 | using format_context = basic_format_context<unspecified, char>; | |
| 19 | using wformat_context = basic_format_context<unspecified, wchar_t>; | |
| 20 | ||
| 21 | // [format.args], class template basic_format_args | |
| 22 | template<class Context> class basic_format_args; | |
| 23 | using format_args = basic_format_args<format_context>; | |
| 24 | using wformat_args = basic_format_args<wformat_context>; | |
| 25 | ||
| 26 | // [format.functions], formatting functions | |
| 27 | template<class... Args> | |
| 28 | string format(string_view fmt, const Args&... args); | |
| 29 | template<class... Args> | |
| 30 | wstring format(wstring_view fmt, const Args&... args); | |
| 31 | template<class... Args> | |
| 32 | string format(const locale& loc, string_view fmt, const Args&... args); | |
| 33 | template<class... Args> | |
| 34 | wstring format(const locale& loc, wstring_view fmt, const Args&... args); | |
| 35 | ||
| 36 | string vformat(string_view fmt, format_args args); | |
| 37 | wstring vformat(wstring_view fmt, wformat_args args); | |
| 38 | string vformat(const locale& loc, string_view fmt, format_args args); | |
| 39 | wstring vformat(const locale& loc, wstring_view fmt, wformat_args args); | |
| 40 | ||
| 41 | template<class Out, class... Args> | |
| 42 | Out format_to(Out out, string_view fmt, const Args&... args); | |
| 43 | template<class Out, class... Args> | |
| 44 | Out format_to(Out out, wstring_view fmt, const Args&... args); | |
| 45 | template<class Out, class... Args> | |
| 46 | Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args); | |
| 47 | template<class Out, class... Args> | |
| 48 | Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args); | |
| 49 | ||
| 50 | template<class Out> | |
| 51 | Out vformat_to(Out out, string_view fmt, format_args args); | |
| 52 | template<class Out> | |
| 53 | Out vformat_to(Out out, wstring_view fmt, wformat_args args); | |
| 54 | template<class Out> | |
| 55 | Out vformat_to(Out out, const locale& loc, string_view fmt, | |
| 56 | format_args char> args); | |
| 57 | template<class Out> | |
| 58 | Out vformat_to(Out out, const locale& loc, wstring_view fmt, | |
| 59 | wformat_args args); | |
| 60 | ||
| 61 | template<class Out> struct format_to_n_result { | |
| 62 | Out out; | |
| 63 | iter_difference_t<Out> size; | |
| 21 | 64 | }; |
| 65 | template<class Out, class... Args> | |
| 66 | format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, | |
| 67 | string_view fmt, const Args&... args); | |
| 68 | template<class Out, class... Args> | |
| 69 | format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, | |
| 70 | wstring_view fmt, const Args&... args); | |
| 71 | template<class Out, class... Args> | |
| 72 | format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, | |
| 73 | const locale& loc, string_view fmt, | |
| 74 | const Args&... args); | |
| 75 | template<class Out, class... Args> | |
| 76 | format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, | |
| 77 | const locale& loc, wstring_view fmt, | |
| 78 | const Args&... args); | |
| 79 | ||
| 80 | template<class... Args> | |
| 81 | size_t formatted_size(string_view fmt, const Args&... args); | |
| 82 | template<class... Args> | |
| 83 | size_t formatted_size(wstring_view fmt, const Args&... args); | |
| 84 | template<class... Args> | |
| 85 | size_t formatted_size(const locale& loc, string_view fmt, const Args&... args); | |
| 86 | template<class... Args> | |
| 87 | size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args); | |
| 88 | ||
| 89 | // [format.formatter], formatter | |
| 90 | template<class T, class charT = char> struct formatter; | |
| 22 | 91 | |
| 23 | 92 | // [format.parse.ctx], class template basic_format_parse_context |
| 24 | template<class charT> | |
| 25 | class basic_format_parse_context { | |
| 26 | public: | |
| 27 | using char_type = charT; | |
| 28 | using const_iterator = typename basic_string_view<charT>::const_iterator; | |
| 29 | using iterator = const_iterator; | |
| 30 | ||
| 31 | private: | |
| 32 | iterator begin_; // exposition only | |
| 33 | iterator end_; // exposition only | |
| 34 | enum indexing { unknown, manual, automatic }; // exposition only | |
| 35 | indexing indexing_; // exposition only | |
| 36 | size_t next_arg_id_; // exposition only | |
| 37 | size_t num_args_; // exposition only | |
| 38 | ||
| 39 | public: | |
| 40 | constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt, | |
| 41 | size_t num_args = 0) noexcept; | |
| 42 | basic_format_parse_context(const basic_format_parse_context&) = delete; | |
| 43 | basic_format_parse_context& operator=(const basic_format_parse_context&) = delete; | |
| 44 | ||
| 45 | constexpr const_iterator begin() const noexcept; | |
| 46 | constexpr const_iterator end() const noexcept; | |
| 47 | constexpr void advance_to(const_iterator it); | |
| 48 | ||
| 49 | constexpr size_t next_arg_id(); | |
| 50 | constexpr void check_arg_id(size_t id); | |
| 51 | }; | |
| 93 | template<class charT> class basic_format_parse_context; | |
| 52 | 94 | using format_parse_context = basic_format_parse_context<char>; |
| 53 | 95 | using wformat_parse_context = basic_format_parse_context<wchar_t>; |
| 96 | ||
| 97 | // [format.arguments], arguments | |
| 98 | // [format.arg], class template basic_format_arg | |
| 99 | template<class Context> class basic_format_arg; | |
| 100 | ||
| 101 | template<class Visitor, class Context> | |
| 102 | see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); | |
| 103 | ||
| 104 | // [format.arg.store], class template format-arg-store | |
| 105 | template<class Context, class... Args> struct format-arg-store; // exposition only | |
| 106 | ||
| 107 | template<class Context = format_context, class... Args> | |
| 108 | format-arg-store<Context, Args...> | |
| 109 | make_format_args(const Args&... args); | |
| 110 | template<class... Args> | |
| 111 | format-arg-store<wformat_context, Args...> | |
| 112 | make_wformat_args(const Args&... args); | |
| 113 | ||
| 114 | // [format.error], class format_error | |
| 115 | class format_error; | |
| 54 | 116 | } |
| 55 | 117 | |
| 56 | 118 | */ |
| 57 | 119 | |
| 58 | // Make sure all feature tests macros are always available. | |
| 120 | // Make sure all feature-test macros are available. | |
| 59 | 121 | #include <version> |
| 60 | // Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled | |
| 122 | // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. | |
| 61 | 123 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) |
| 62 | 124 | |
| 63 | 125 | #include <__config> |
| 126 | #include <__debug> | |
| 127 | #include <__format/format_arg.h> | |
| 128 | #include <__format/format_args.h> | |
| 129 | #include <__format/format_context.h> | |
| 64 | 130 | #include <__format/format_error.h> |
| 131 | #include <__format/format_fwd.h> | |
| 65 | 132 | #include <__format/format_parse_context.h> |
| 133 | #include <__format/format_string.h> | |
| 134 | #include <__format/format_to_n_result.h> | |
| 135 | #include <__format/formatter.h> | |
| 136 | #include <__format/formatter_bool.h> | |
| 137 | #include <__format/formatter_char.h> | |
| 138 | #include <__format/formatter_floating_point.h> | |
| 139 | #include <__format/formatter_integer.h> | |
| 140 | #include <__format/formatter_pointer.h> | |
| 141 | #include <__format/formatter_string.h> | |
| 142 | #include <__format/parser_std_format_spec.h> | |
| 143 | #include <__variant/monostate.h> | |
| 144 | #include <array> | |
| 145 | #include <concepts> | |
| 146 | #include <string> | |
| 147 | #include <string_view> | |
| 148 | #include <type_traits> | |
| 149 | ||
| 150 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 151 | #include <locale> | |
| 152 | #endif | |
| 66 | 153 | |
| 67 | 154 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 68 | # pragma GCC system_header | |
| 155 | #pragma GCC system_header | |
| 69 | 156 | #endif |
| 70 | 157 | |
| 71 | 158 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -75,6 +162,397 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 75 | 162 | |
| 76 | 163 | #if _LIBCPP_STD_VER > 17 |
| 77 | 164 | |
| 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. | |
| 172 | ||
| 173 | // TODO FMT Evaluate which templates should be external templates. This | |
| 174 | // improves the efficiency of the header. However since the header is still | |
| 175 | // under heavy development and not all classes are stable it makes no sense | |
| 176 | // to do this optimization now. | |
| 177 | ||
| 178 | using format_args = basic_format_args<format_context>; | |
| 179 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 180 | using wformat_args = basic_format_args<wformat_context>; | |
| 181 | #endif | |
| 182 | ||
| 183 | template <class _Context, class... _Args> | |
| 184 | struct _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 | ||
| 189 | template <class _Context = format_context, class... _Args> | |
| 190 | _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> | |
| 191 | make_format_args(const _Args&... __args) { | |
| 192 | return {basic_format_arg<_Context>(__args)...}; | |
| 193 | } | |
| 194 | ||
| 195 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 196 | template <class... _Args> | |
| 197 | _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> | |
| 198 | make_wformat_args(const _Args&... __args) { | |
| 199 | return _VSTD::make_format_args<wformat_context>(__args...); | |
| 200 | } | |
| 201 | #endif | |
| 202 | ||
| 203 | namespace __format { | |
| 204 | ||
| 205 | template <class _CharT, class _ParseCtx, class _Ctx> | |
| 206 | _LIBCPP_HIDE_FROM_ABI const _CharT* | |
| 207 | __handle_replacement_field(const _CharT* __begin, const _CharT* __end, | |
| 208 | _ParseCtx& __parse_ctx, _Ctx& __ctx) { | |
| 209 | __format::__parse_number_result __r = | |
| 210 | __format::__parse_arg_id(__begin, __end, __parse_ctx); | |
| 211 | ||
| 212 | switch (*__r.__ptr) { | |
| 213 | case _CharT(':'): | |
| 214 | // The arg-id has a format-specifier, advance the input to the format-spec. | |
| 215 | __parse_ctx.advance_to(__r.__ptr + 1); | |
| 216 | break; | |
| 217 | case _CharT('}'): | |
| 218 | // The arg-id has no format-specifier. | |
| 219 | __parse_ctx.advance_to(__r.__ptr); | |
| 220 | break; | |
| 221 | default: | |
| 222 | __throw_format_error( | |
| 223 | "The replacement field arg-id should terminate at a ':' or '}'"); | |
| 224 | } | |
| 225 | ||
| 226 | _VSTD::visit_format_arg( | |
| 227 | [&](auto __arg) { | |
| 228 | if constexpr (same_as<decltype(__arg), monostate>) | |
| 229 | __throw_format_error("Argument index out of bounds"); | |
| 230 | else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>) | |
| 231 | __arg.format(__parse_ctx, __ctx); | |
| 232 | else { | |
| 233 | formatter<decltype(__arg), _CharT> __formatter; | |
| 234 | __parse_ctx.advance_to(__formatter.parse(__parse_ctx)); | |
| 235 | __ctx.advance_to(__formatter.format(__arg, __ctx)); | |
| 236 | } | |
| 237 | }, | |
| 238 | __ctx.arg(__r.__value)); | |
| 239 | ||
| 240 | __begin = __parse_ctx.begin(); | |
| 241 | if (__begin == __end || *__begin != _CharT('}')) | |
| 242 | __throw_format_error("The replacement field misses a terminating '}'"); | |
| 243 | ||
| 244 | return ++__begin; | |
| 245 | } | |
| 246 | ||
| 247 | template <class _ParseCtx, class _Ctx> | |
| 248 | _LIBCPP_HIDE_FROM_ABI typename _Ctx::iterator | |
| 249 | __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) { | |
| 250 | using _CharT = typename _ParseCtx::char_type; | |
| 251 | static_assert(same_as<typename _Ctx::char_type, _CharT>); | |
| 252 | ||
| 253 | const _CharT* __begin = __parse_ctx.begin(); | |
| 254 | const _CharT* __end = __parse_ctx.end(); | |
| 255 | typename _Ctx::iterator __out_it = __ctx.out(); | |
| 256 | while (__begin != __end) { | |
| 257 | switch (*__begin) { | |
| 258 | case _CharT('{'): | |
| 259 | ++__begin; | |
| 260 | if (__begin == __end) | |
| 261 | __throw_format_error("The format string terminates at a '{'"); | |
| 262 | ||
| 263 | if (*__begin != _CharT('{')) [[likely]] { | |
| 264 | __ctx.advance_to(_VSTD::move(__out_it)); | |
| 265 | __begin = | |
| 266 | __handle_replacement_field(__begin, __end, __parse_ctx, __ctx); | |
| 267 | __out_it = __ctx.out(); | |
| 268 | ||
| 269 | // The output is written and __begin points to the next character. So | |
| 270 | // start the next iteration. | |
| 271 | continue; | |
| 272 | } | |
| 273 | // The string is an escape character. | |
| 274 | break; | |
| 275 | ||
| 276 | case _CharT('}'): | |
| 277 | ++__begin; | |
| 278 | if (__begin == __end || *__begin != _CharT('}')) | |
| 279 | __throw_format_error( | |
| 280 | "The format string contains an invalid escape sequence"); | |
| 281 | ||
| 282 | break; | |
| 283 | } | |
| 284 | ||
| 285 | // Copy the character to the output verbatim. | |
| 286 | *__out_it++ = *__begin++; | |
| 287 | } | |
| 288 | return __out_it; | |
| 289 | } | |
| 290 | ||
| 291 | } // namespace __format | |
| 292 | ||
| 293 | template <class _OutIt, class _CharT, class _FormatOutIt> | |
| 294 | requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt | |
| 295 | __vformat_to( | |
| 296 | _OutIt __out_it, basic_string_view<_CharT> __fmt, | |
| 297 | basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) { | |
| 298 | if constexpr (same_as<_OutIt, _FormatOutIt>) | |
| 299 | return _VSTD::__format::__vformat_to( | |
| 300 | basic_format_parse_context{__fmt, __args.__size()}, | |
| 301 | _VSTD::__format_context_create(_VSTD::move(__out_it), __args)); | |
| 302 | else { | |
| 303 | basic_string<_CharT> __str; | |
| 304 | _VSTD::__format::__vformat_to( | |
| 305 | basic_format_parse_context{__fmt, __args.__size()}, | |
| 306 | _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args)); | |
| 307 | return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it)); | |
| 308 | } | |
| 309 | } | |
| 310 | ||
| 311 | template <output_iterator<const char&> _OutIt> | |
| 312 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | |
| 313 | vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) { | |
| 314 | return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args); | |
| 315 | } | |
| 316 | ||
| 317 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 318 | template <output_iterator<const wchar_t&> _OutIt> | |
| 319 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | |
| 320 | vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) { | |
| 321 | return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args); | |
| 322 | } | |
| 323 | #endif | |
| 324 | ||
| 325 | template <output_iterator<const char&> _OutIt, class... _Args> | |
| 326 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | |
| 327 | format_to(_OutIt __out_it, string_view __fmt, const _Args&... __args) { | |
| 328 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt, | |
| 329 | _VSTD::make_format_args(__args...)); | |
| 330 | } | |
| 331 | ||
| 332 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 333 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | |
| 334 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | |
| 335 | format_to(_OutIt __out_it, wstring_view __fmt, const _Args&... __args) { | |
| 336 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt, | |
| 337 | _VSTD::make_wformat_args(__args...)); | |
| 338 | } | |
| 339 | #endif | |
| 340 | ||
| 341 | _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string | |
| 342 | vformat(string_view __fmt, format_args __args) { | |
| 343 | string __res; | |
| 344 | _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args); | |
| 345 | return __res; | |
| 346 | } | |
| 347 | ||
| 348 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 349 | _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring | |
| 350 | vformat(wstring_view __fmt, wformat_args __args) { | |
| 351 | wstring __res; | |
| 352 | _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args); | |
| 353 | return __res; | |
| 354 | } | |
| 355 | #endif | |
| 356 | ||
| 357 | template <class... _Args> | |
| 358 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string | |
| 359 | format(string_view __fmt, const _Args&... __args) { | |
| 360 | return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...)); | |
| 361 | } | |
| 362 | ||
| 363 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 364 | template <class... _Args> | |
| 365 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring | |
| 366 | format(wstring_view __fmt, const _Args&... __args) { | |
| 367 | return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...)); | |
| 368 | } | |
| 369 | #endif | |
| 370 | ||
| 371 | template <output_iterator<const char&> _OutIt, class... _Args> | |
| 372 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 373 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt, | |
| 374 | const _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 | } | |
| 383 | ||
| 384 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 385 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | |
| 386 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 387 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wstring_view __fmt, | |
| 388 | const _Args&... __args) { | |
| 389 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 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 | } | |
| 397 | #endif | |
| 398 | ||
| 399 | template <class... _Args> | |
| 400 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 401 | formatted_size(string_view __fmt, const _Args&... __args) { | |
| 402 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 403 | return _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...)).size(); | |
| 404 | } | |
| 405 | ||
| 406 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 407 | template <class... _Args> | |
| 408 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 409 | formatted_size(wstring_view __fmt, const _Args&... __args) { | |
| 410 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 411 | return _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...)).size(); | |
| 412 | } | |
| 413 | #endif | |
| 414 | ||
| 415 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 416 | ||
| 417 | template <class _OutIt, class _CharT, class _FormatOutIt> | |
| 418 | requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt | |
| 419 | __vformat_to( | |
| 420 | _OutIt __out_it, locale __loc, basic_string_view<_CharT> __fmt, | |
| 421 | basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) { | |
| 422 | if constexpr (same_as<_OutIt, _FormatOutIt>) | |
| 423 | return _VSTD::__format::__vformat_to( | |
| 424 | basic_format_parse_context{__fmt, __args.__size()}, | |
| 425 | _VSTD::__format_context_create(_VSTD::move(__out_it), __args, | |
| 426 | _VSTD::move(__loc))); | |
| 427 | else { | |
| 428 | basic_string<_CharT> __str; | |
| 429 | _VSTD::__format::__vformat_to( | |
| 430 | basic_format_parse_context{__fmt, __args.__size()}, | |
| 431 | _VSTD::__format_context_create(_VSTD::back_inserter(__str), __args, | |
| 432 | _VSTD::move(__loc))); | |
| 433 | return _VSTD::copy_n(__str.begin(), __str.size(), _VSTD::move(__out_it)); | |
| 434 | } | |
| 435 | } | |
| 436 | ||
| 437 | template <output_iterator<const char&> _OutIt> | |
| 438 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to( | |
| 439 | _OutIt __out_it, locale __loc, string_view __fmt, format_args __args) { | |
| 440 | return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt, | |
| 441 | __args); | |
| 442 | } | |
| 443 | ||
| 444 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 445 | template <output_iterator<const wchar_t&> _OutIt> | |
| 446 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to( | |
| 447 | _OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) { | |
| 448 | return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt, | |
| 449 | __args); | |
| 450 | } | |
| 451 | #endif | |
| 452 | ||
| 453 | template <output_iterator<const char&> _OutIt, class... _Args> | |
| 454 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to( | |
| 455 | _OutIt __out_it, locale __loc, string_view __fmt, const _Args&... __args) { | |
| 456 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt, | |
| 457 | _VSTD::make_format_args(__args...)); | |
| 458 | } | |
| 459 | ||
| 460 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 461 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | |
| 462 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt format_to( | |
| 463 | _OutIt __out_it, locale __loc, wstring_view __fmt, const _Args&... __args) { | |
| 464 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt, | |
| 465 | _VSTD::make_wformat_args(__args...)); | |
| 466 | } | |
| 467 | #endif | |
| 468 | ||
| 469 | _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string | |
| 470 | vformat(locale __loc, string_view __fmt, format_args __args) { | |
| 471 | string __res; | |
| 472 | _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt, | |
| 473 | __args); | |
| 474 | return __res; | |
| 475 | } | |
| 476 | ||
| 477 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 478 | _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring | |
| 479 | vformat(locale __loc, wstring_view __fmt, wformat_args __args) { | |
| 480 | wstring __res; | |
| 481 | _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt, | |
| 482 | __args); | |
| 483 | return __res; | |
| 484 | } | |
| 485 | #endif | |
| 486 | ||
| 487 | template <class... _Args> | |
| 488 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string | |
| 489 | format(locale __loc, string_view __fmt, const _Args&... __args) { | |
| 490 | return _VSTD::vformat(_VSTD::move(__loc), __fmt, | |
| 491 | _VSTD::make_format_args(__args...)); | |
| 492 | } | |
| 493 | ||
| 494 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 495 | template <class... _Args> | |
| 496 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring | |
| 497 | format(locale __loc, wstring_view __fmt, const _Args&... __args) { | |
| 498 | return _VSTD::vformat(_VSTD::move(__loc), __fmt, | |
| 499 | _VSTD::make_wformat_args(__args...)); | |
| 500 | } | |
| 501 | #endif | |
| 502 | ||
| 503 | template <output_iterator<const char&> _OutIt, class... _Args> | |
| 504 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 505 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, | |
| 506 | string_view __fmt, const _Args&... __args) { | |
| 507 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 508 | string __str = _VSTD::vformat(_VSTD::move(__loc), __fmt, | |
| 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 | } | |
| 516 | ||
| 517 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 518 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> | |
| 519 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 520 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, | |
| 521 | wstring_view __fmt, const _Args&... __args) { | |
| 522 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 523 | wstring __str = _VSTD::vformat(_VSTD::move(__loc), __fmt, | |
| 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 | } | |
| 531 | #endif | |
| 532 | ||
| 533 | template <class... _Args> | |
| 534 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 535 | formatted_size(locale __loc, string_view __fmt, const _Args&... __args) { | |
| 536 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 537 | return _VSTD::vformat(_VSTD::move(__loc), __fmt, | |
| 538 | _VSTD::make_format_args(__args...)) | |
| 539 | .size(); | |
| 540 | } | |
| 541 | ||
| 542 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 543 | template <class... _Args> | |
| 544 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 545 | formatted_size(locale __loc, wstring_view __fmt, const _Args&... __args) { | |
| 546 | // TODO FMT Improve PoC: using std::string is inefficient. | |
| 547 | return _VSTD::vformat(_VSTD::move(__loc), __fmt, | |
| 548 | _VSTD::make_wformat_args(__args...)) | |
| 549 | .size(); | |
| 550 | } | |
| 551 | #endif | |
| 552 | ||
| 553 | #endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 554 | ||
| 555 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 78 | 556 | #endif //_LIBCPP_STD_VER > 17 |
| 79 | 557 | |
| 80 | 558 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/forward_list+22-21| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------- forward_list ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -186,6 +186,7 @@ template <class T, class Allocator, class Predicate> |
| 186 | 186 | #include <iterator> |
| 187 | 187 | #include <limits> |
| 188 | 188 | #include <memory> |
| 189 | #include <type_traits> | |
| 189 | 190 | #include <version> |
| 190 | 191 | |
| 191 | 192 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -643,12 +644,12 @@ public: |
| 643 | 644 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 644 | 645 | "Allocator::value_type must be same type as value_type"); |
| 645 | 646 | |
| 646 | typedef value_type& reference; | |
| 647 | typedef const value_type& const_reference; | |
| 648 | typedef typename allocator_traits<allocator_type>::pointer pointer; | |
| 649 | typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; | |
| 650 | typedef typename allocator_traits<allocator_type>::size_type size_type; | |
| 651 | typedef typename allocator_traits<allocator_type>::difference_type difference_type; | |
| 647 | typedef value_type& reference; | |
| 648 | typedef const value_type& const_reference; | |
| 649 | typedef typename allocator_traits<allocator_type>::pointer pointer; | |
| 650 | typedef typename allocator_traits<allocator_type>::const_pointer const_pointer; | |
| 651 | typedef typename allocator_traits<allocator_type>::size_type size_type; | |
| 652 | typedef typename allocator_traits<allocator_type>::difference_type difference_type; | |
| 652 | 653 | |
| 653 | 654 | typedef typename base::iterator iterator; |
| 654 | 655 | typedef typename base::const_iterator const_iterator; |
| ... | ... | @@ -669,7 +670,13 @@ public: |
| 669 | 670 | explicit forward_list(size_type __n, const allocator_type& __a); |
| 670 | 671 | #endif |
| 671 | 672 | forward_list(size_type __n, const value_type& __v); |
| 672 | forward_list(size_type __n, const value_type& __v, const allocator_type& __a); | |
| 673 | ||
| 674 | template <class = __enable_if_t<__is_allocator<_Alloc>::value> > | |
| 675 | forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) | |
| 676 | { | |
| 677 | insert_after(cbefore_begin(), __n, __v); | |
| 678 | } | |
| 679 | ||
| 673 | 680 | template <class _InputIterator> |
| 674 | 681 | forward_list(_InputIterator __f, _InputIterator __l, |
| 675 | 682 | typename enable_if< |
| ... | ... | @@ -870,17 +877,19 @@ private: |
| 870 | 877 | }; |
| 871 | 878 | |
| 872 | 879 | |
| 873 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 880 | #if _LIBCPP_STD_VER >= 17 | |
| 874 | 881 | template<class _InputIterator, |
| 875 | 882 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 876 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 883 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 884 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 877 | 885 | > |
| 878 | 886 | forward_list(_InputIterator, _InputIterator) |
| 879 | 887 | -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; |
| 880 | 888 | |
| 881 | 889 | template<class _InputIterator, |
| 882 | 890 | class _Alloc, |
| 883 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 891 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 892 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 884 | 893 | > |
| 885 | 894 | forward_list(_InputIterator, _InputIterator, _Alloc) |
| 886 | 895 | -> forward_list<__iter_value_type<_InputIterator>, _Alloc>; |
| ... | ... | @@ -941,14 +950,6 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) |
| 941 | 950 | insert_after(cbefore_begin(), __n, __v); |
| 942 | 951 | } |
| 943 | 952 | |
| 944 | template <class _Tp, class _Alloc> | |
| 945 | forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v, | |
| 946 | const allocator_type& __a) | |
| 947 | : base(__a) | |
| 948 | { | |
| 949 | insert_after(cbefore_begin(), __n, __v); | |
| 950 | } | |
| 951 | ||
| 952 | 953 | template <class _Tp, class _Alloc> |
| 953 | 954 | template <class _InputIterator> |
| 954 | 955 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, |
| ... | ... | @@ -990,7 +991,7 @@ template <class _Tp, class _Alloc> |
| 990 | 991 | forward_list<_Tp, _Alloc>& |
| 991 | 992 | forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) |
| 992 | 993 | { |
| 993 | if (this != &__x) | |
| 994 | if (this != _VSTD::addressof(__x)) | |
| 994 | 995 | { |
| 995 | 996 | base::__copy_assign_alloc(__x); |
| 996 | 997 | assign(__x.begin(), __x.end()); |
| ... | ... | @@ -1585,7 +1586,7 @@ template <class _Compare> |
| 1585 | 1586 | void |
| 1586 | 1587 | forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) |
| 1587 | 1588 | { |
| 1588 | if (this != &__x) | |
| 1589 | if (this != _VSTD::addressof(__x)) | |
| 1589 | 1590 | { |
| 1590 | 1591 | base::__before_begin()->__next_ = __merge(base::__before_begin()->__next_, |
| 1591 | 1592 | __x.__before_begin()->__next_, |
lib/libcxx/include/fstream+2-27| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- fstream ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -187,6 +187,7 @@ typedef basic_fstream<wchar_t> wfstream; |
| 187 | 187 | #include <cstdlib> |
| 188 | 188 | #include <istream> |
| 189 | 189 | #include <ostream> |
| 190 | #include <version> | |
| 190 | 191 | |
| 191 | 192 | #if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) |
| 192 | 193 | # include <filesystem> |
| ... | ... | @@ -230,7 +231,6 @@ public: |
| 230 | 231 | // 27.9.1.4 Members: |
| 231 | 232 | _LIBCPP_INLINE_VISIBILITY |
| 232 | 233 | bool is_open() const; |
| 233 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 234 | 234 | basic_filebuf* open(const char* __s, ios_base::openmode __mode); |
| 235 | 235 | #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 236 | 236 | basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); |
| ... | ... | @@ -246,7 +246,6 @@ public: |
| 246 | 246 | #endif |
| 247 | 247 | _LIBCPP_INLINE_VISIBILITY |
| 248 | 248 | basic_filebuf* __open(int __fd, ios_base::openmode __mode); |
| 249 | #endif | |
| 250 | 249 | basic_filebuf* close(); |
| 251 | 250 | |
| 252 | 251 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -542,7 +541,6 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring( |
| 542 | 541 | _LIBCPP_UNREACHABLE(); |
| 543 | 542 | } |
| 544 | 543 | |
| 545 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 546 | 544 | template <class _CharT, class _Traits> |
| 547 | 545 | basic_filebuf<_CharT, _Traits>* |
| 548 | 546 | basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -685,7 +683,6 @@ basic_filebuf<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod |
| 685 | 683 | { |
| 686 | 684 | return open(__s.c_str(), __mode); |
| 687 | 685 | } |
| 688 | #endif | |
| 689 | 686 | |
| 690 | 687 | template <class _CharT, class _Traits> |
| 691 | 688 | basic_filebuf<_CharT, _Traits>* |
| ... | ... | @@ -1141,7 +1138,6 @@ public: |
| 1141 | 1138 | |
| 1142 | 1139 | _LIBCPP_INLINE_VISIBILITY |
| 1143 | 1140 | basic_ifstream(); |
| 1144 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1145 | 1141 | _LIBCPP_INLINE_VISIBILITY |
| 1146 | 1142 | explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in); |
| 1147 | 1143 | #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| ... | ... | @@ -1155,7 +1151,6 @@ public: |
| 1155 | 1151 | explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in) |
| 1156 | 1152 | : basic_ifstream(__p.c_str(), __mode) {} |
| 1157 | 1153 | #endif // _LIBCPP_STD_VER >= 17 |
| 1158 | #endif | |
| 1159 | 1154 | _LIBCPP_INLINE_VISIBILITY |
| 1160 | 1155 | basic_ifstream(basic_ifstream&& __rhs); |
| 1161 | 1156 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1167,7 +1162,6 @@ public: |
| 1167 | 1162 | basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1168 | 1163 | _LIBCPP_INLINE_VISIBILITY |
| 1169 | 1164 | bool is_open() const; |
| 1170 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1171 | 1165 | void open(const char* __s, ios_base::openmode __mode = ios_base::in); |
| 1172 | 1166 | #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 1173 | 1167 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); |
| ... | ... | @@ -1183,7 +1177,6 @@ public: |
| 1183 | 1177 | |
| 1184 | 1178 | _LIBCPP_INLINE_VISIBILITY |
| 1185 | 1179 | void __open(int __fd, ios_base::openmode __mode); |
| 1186 | #endif | |
| 1187 | 1180 | _LIBCPP_INLINE_VISIBILITY |
| 1188 | 1181 | void close(); |
| 1189 | 1182 | |
| ... | ... | @@ -1198,7 +1191,6 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream() |
| 1198 | 1191 | { |
| 1199 | 1192 | } |
| 1200 | 1193 | |
| 1201 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1202 | 1194 | template <class _CharT, class _Traits> |
| 1203 | 1195 | inline |
| 1204 | 1196 | basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -1227,7 +1219,6 @@ basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::ope |
| 1227 | 1219 | if (__sb_.open(__s, __mode | ios_base::in) == nullptr) |
| 1228 | 1220 | this->setstate(ios_base::failbit); |
| 1229 | 1221 | } |
| 1230 | #endif | |
| 1231 | 1222 | |
| 1232 | 1223 | template <class _CharT, class _Traits> |
| 1233 | 1224 | inline |
| ... | ... | @@ -1281,7 +1272,6 @@ basic_ifstream<_CharT, _Traits>::is_open() const |
| 1281 | 1272 | return __sb_.is_open(); |
| 1282 | 1273 | } |
| 1283 | 1274 | |
| 1284 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1285 | 1275 | template <class _CharT, class _Traits> |
| 1286 | 1276 | void |
| 1287 | 1277 | basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -1323,7 +1313,6 @@ void basic_ifstream<_CharT, _Traits>::__open(int __fd, |
| 1323 | 1313 | else |
| 1324 | 1314 | this->setstate(ios_base::failbit); |
| 1325 | 1315 | } |
| 1326 | #endif | |
| 1327 | 1316 | |
| 1328 | 1317 | template <class _CharT, class _Traits> |
| 1329 | 1318 | inline |
| ... | ... | @@ -1375,7 +1364,6 @@ public: |
| 1375 | 1364 | basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1376 | 1365 | _LIBCPP_INLINE_VISIBILITY |
| 1377 | 1366 | bool is_open() const; |
| 1378 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1379 | 1367 | void open(const char* __s, ios_base::openmode __mode = ios_base::out); |
| 1380 | 1368 | #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 1381 | 1369 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); |
| ... | ... | @@ -1390,7 +1378,6 @@ public: |
| 1390 | 1378 | |
| 1391 | 1379 | _LIBCPP_INLINE_VISIBILITY |
| 1392 | 1380 | void __open(int __fd, ios_base::openmode __mode); |
| 1393 | #endif | |
| 1394 | 1381 | _LIBCPP_INLINE_VISIBILITY |
| 1395 | 1382 | void close(); |
| 1396 | 1383 | |
| ... | ... | @@ -1405,7 +1392,6 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream() |
| 1405 | 1392 | { |
| 1406 | 1393 | } |
| 1407 | 1394 | |
| 1408 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1409 | 1395 | template <class _CharT, class _Traits> |
| 1410 | 1396 | inline |
| 1411 | 1397 | basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -1434,7 +1420,6 @@ basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::ope |
| 1434 | 1420 | if (__sb_.open(__s, __mode | ios_base::out) == nullptr) |
| 1435 | 1421 | this->setstate(ios_base::failbit); |
| 1436 | 1422 | } |
| 1437 | #endif | |
| 1438 | 1423 | |
| 1439 | 1424 | template <class _CharT, class _Traits> |
| 1440 | 1425 | inline |
| ... | ... | @@ -1488,7 +1473,6 @@ basic_ofstream<_CharT, _Traits>::is_open() const |
| 1488 | 1473 | return __sb_.is_open(); |
| 1489 | 1474 | } |
| 1490 | 1475 | |
| 1491 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1492 | 1476 | template <class _CharT, class _Traits> |
| 1493 | 1477 | void |
| 1494 | 1478 | basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -1530,7 +1514,6 @@ void basic_ofstream<_CharT, _Traits>::__open(int __fd, |
| 1530 | 1514 | else |
| 1531 | 1515 | this->setstate(ios_base::failbit); |
| 1532 | 1516 | } |
| 1533 | #endif | |
| 1534 | 1517 | |
| 1535 | 1518 | template <class _CharT, class _Traits> |
| 1536 | 1519 | inline |
| ... | ... | @@ -1556,7 +1539,6 @@ public: |
| 1556 | 1539 | |
| 1557 | 1540 | _LIBCPP_INLINE_VISIBILITY |
| 1558 | 1541 | basic_fstream(); |
| 1559 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1560 | 1542 | _LIBCPP_INLINE_VISIBILITY |
| 1561 | 1543 | explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1562 | 1544 | #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| ... | ... | @@ -1572,7 +1554,6 @@ public: |
| 1572 | 1554 | : basic_fstream(__p.c_str(), __mode) {} |
| 1573 | 1555 | #endif // _LIBCPP_STD_VER >= 17 |
| 1574 | 1556 | |
| 1575 | #endif | |
| 1576 | 1557 | _LIBCPP_INLINE_VISIBILITY |
| 1577 | 1558 | basic_fstream(basic_fstream&& __rhs); |
| 1578 | 1559 | |
| ... | ... | @@ -1586,7 +1567,6 @@ public: |
| 1586 | 1567 | basic_filebuf<char_type, traits_type>* rdbuf() const; |
| 1587 | 1568 | _LIBCPP_INLINE_VISIBILITY |
| 1588 | 1569 | bool is_open() const; |
| 1589 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1590 | 1570 | void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| 1591 | 1571 | #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 1592 | 1572 | void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); |
| ... | ... | @@ -1599,7 +1579,6 @@ public: |
| 1599 | 1579 | { return open(__p.c_str(), __mode); } |
| 1600 | 1580 | #endif // _LIBCPP_STD_VER >= 17 |
| 1601 | 1581 | |
| 1602 | #endif | |
| 1603 | 1582 | _LIBCPP_INLINE_VISIBILITY |
| 1604 | 1583 | void close(); |
| 1605 | 1584 | |
| ... | ... | @@ -1614,7 +1593,6 @@ basic_fstream<_CharT, _Traits>::basic_fstream() |
| 1614 | 1593 | { |
| 1615 | 1594 | } |
| 1616 | 1595 | |
| 1617 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1618 | 1596 | template <class _CharT, class _Traits> |
| 1619 | 1597 | inline |
| 1620 | 1598 | basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -1643,7 +1621,6 @@ basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openm |
| 1643 | 1621 | if (__sb_.open(__s, __mode) == nullptr) |
| 1644 | 1622 | this->setstate(ios_base::failbit); |
| 1645 | 1623 | } |
| 1646 | #endif | |
| 1647 | 1624 | |
| 1648 | 1625 | template <class _CharT, class _Traits> |
| 1649 | 1626 | inline |
| ... | ... | @@ -1697,7 +1674,6 @@ basic_fstream<_CharT, _Traits>::is_open() const |
| 1697 | 1674 | return __sb_.is_open(); |
| 1698 | 1675 | } |
| 1699 | 1676 | |
| 1700 | #ifndef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE | |
| 1701 | 1677 | template <class _CharT, class _Traits> |
| 1702 | 1678 | void |
| 1703 | 1679 | basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) |
| ... | ... | @@ -1729,7 +1705,6 @@ basic_fstream<_CharT, _Traits>::open(const string& __s, ios_base::openmode __mod |
| 1729 | 1705 | else |
| 1730 | 1706 | this->setstate(ios_base::failbit); |
| 1731 | 1707 | } |
| 1732 | #endif | |
| 1733 | 1708 | |
| 1734 | 1709 | template <class _CharT, class _Traits> |
| 1735 | 1710 | inline |
lib/libcxx/include/functional+7-1| ... | ... | @@ -135,6 +135,9 @@ struct less_equal { |
| 135 | 135 | bool operator()(const T& x, const T& y) const; |
| 136 | 136 | }; |
| 137 | 137 | |
| 138 | // [comparisons.three.way], class compare_three_way | |
| 139 | struct compare_three_way; | |
| 140 | ||
| 138 | 141 | template <class T> // <class T=void> in C++14 |
| 139 | 142 | struct logical_and { |
| 140 | 143 | bool operator()(const T& x, const T& y) const; |
| ... | ... | @@ -488,14 +491,17 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 488 | 491 | */ |
| 489 | 492 | |
| 490 | 493 | #include <__algorithm/search.h> |
| 494 | #include <__compare/compare_three_way.h> | |
| 491 | 495 | #include <__config> |
| 492 | 496 | #include <__debug> |
| 493 | 497 | #include <__functional/binary_function.h> // TODO: deprecate |
| 494 | 498 | #include <__functional/binary_negate.h> |
| 495 | #include <__functional/bind_front.h> | |
| 496 | 499 | #include <__functional/bind.h> |
| 500 | #include <__functional/bind_back.h> | |
| 501 | #include <__functional/bind_front.h> | |
| 497 | 502 | #include <__functional/binder1st.h> |
| 498 | 503 | #include <__functional/binder2nd.h> |
| 504 | #include <__functional/compose.h> | |
| 499 | 505 | #include <__functional/default_searcher.h> |
| 500 | 506 | #include <__functional/function.h> |
| 501 | 507 | #include <__functional/hash.h> |
lib/libcxx/include/future+7-6| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- future -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -366,7 +366,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 366 | 366 | #include <__debug> |
| 367 | 367 | #include <__memory/allocator_arg_t.h> |
| 368 | 368 | #include <__memory/uses_allocator.h> |
| 369 | #include <__utility/__decay_copy.h> | |
| 369 | #include <__utility/auto_cast.h> | |
| 370 | 370 | #include <__utility/forward.h> |
| 371 | 371 | #include <chrono> |
| 372 | 372 | #include <exception> |
| ... | ... | @@ -374,6 +374,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 374 | 374 | #include <mutex> |
| 375 | 375 | #include <system_error> |
| 376 | 376 | #include <thread> |
| 377 | #include <version> | |
| 377 | 378 | |
| 378 | 379 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 379 | 380 | #pragma GCC system_header |
| ... | ... | @@ -2207,16 +2208,16 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) |
| 2207 | 2208 | { |
| 2208 | 2209 | #endif |
| 2209 | 2210 | if (__does_policy_contain(__policy, launch::async)) |
| 2210 | return _VSTD::__make_async_assoc_state<_Rp>(_BF(_VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)), | |
| 2211 | _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...)); | |
| 2211 | return _VSTD::__make_async_assoc_state<_Rp>(_BF(_LIBCPP_AUTO_CAST(_VSTD::forward<_Fp>(__f)), | |
| 2212 | _LIBCPP_AUTO_CAST(_VSTD::forward<_Args>(__args))...)); | |
| 2212 | 2213 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2213 | 2214 | } |
| 2214 | 2215 | catch ( ... ) { if (__policy == launch::async) throw ; } |
| 2215 | 2216 | #endif |
| 2216 | 2217 | |
| 2217 | 2218 | if (__does_policy_contain(__policy, launch::deferred)) |
| 2218 | return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(_VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)), | |
| 2219 | _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...)); | |
| 2219 | return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(_LIBCPP_AUTO_CAST(_VSTD::forward<_Fp>(__f)), | |
| 2220 | _LIBCPP_AUTO_CAST(_VSTD::forward<_Args>(__args))...)); | |
| 2220 | 2221 | return future<_Rp>{}; |
| 2221 | 2222 | } |
| 2222 | 2223 |
lib/libcxx/include/initializer_list+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------- initializer_list -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -112,6 +112,6 @@ end(initializer_list<_Ep> __il) _NOEXCEPT |
| 112 | 112 | |
| 113 | 113 | #endif // !defined(_LIBCPP_CXX03_LANG) |
| 114 | 114 | |
| 115 | } // std | |
| 115 | } // namespace std | |
| 116 | 116 | |
| 117 | 117 | #endif // _LIBCPP_INITIALIZER_LIST |
lib/libcxx/include/inttypes.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- inttypes.h -------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/iomanip+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- iomanip ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/ios+4-5| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- ios -------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -214,6 +214,7 @@ storage-class-specifier const error_category& iostream_category() noexcept; |
| 214 | 214 | #include <__locale> |
| 215 | 215 | #include <iosfwd> |
| 216 | 216 | #include <system_error> |
| 217 | #include <version> | |
| 217 | 218 | |
| 218 | 219 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
| 219 | 220 | #include <atomic> // for __xindex_ |
| ... | ... | @@ -308,11 +309,9 @@ public: |
| 308 | 309 | typedef void (*event_callback)(event, ios_base&, int __index); |
| 309 | 310 | void register_callback(event_callback __fn, int __index); |
| 310 | 311 | |
| 311 | private: | |
| 312 | ios_base(const ios_base&); // = delete; | |
| 313 | ios_base& operator=(const ios_base&); // = delete; | |
| 312 | ios_base(const ios_base&) = delete; | |
| 313 | ios_base& operator=(const ios_base&) = delete; | |
| 314 | 314 | |
| 315 | public: | |
| 316 | 315 | static bool sync_with_stdio(bool __sync = true); |
| 317 | 316 | |
| 318 | 317 | _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; |
lib/libcxx/include/iosfwd+26-17| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- iosfwd -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -95,7 +95,8 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>; |
| 95 | 95 | */ |
| 96 | 96 | |
| 97 | 97 | #include <__config> |
| 98 | #include <wchar.h> // for mbstate_t | |
| 98 | #include <__mbstate_t.h> | |
| 99 | #include <version> | |
| 99 | 100 | |
| 100 | 101 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 101 | 102 | #pragma GCC system_header |
| ... | ... | @@ -112,7 +113,9 @@ template<> struct char_traits<char8_t>; |
| 112 | 113 | #endif |
| 113 | 114 | template<> struct char_traits<char16_t>; |
| 114 | 115 | template<> struct char_traits<char32_t>; |
| 116 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 115 | 117 | template<> struct char_traits<wchar_t>; |
| 118 | #endif | |
| 116 | 119 | |
| 117 | 120 | template<class _Tp> class _LIBCPP_TEMPLATE_VIS allocator; |
| 118 | 121 | |
| ... | ... | @@ -156,7 +159,9 @@ template <class _CharT, class _Traits = char_traits<_CharT> > |
| 156 | 159 | class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator; |
| 157 | 160 | |
| 158 | 161 | typedef basic_ios<char> ios; |
| 162 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 159 | 163 | typedef basic_ios<wchar_t> wios; |
| 164 | #endif | |
| 160 | 165 | |
| 161 | 166 | typedef basic_streambuf<char> streambuf; |
| 162 | 167 | typedef basic_istream<char> istream; |
| ... | ... | @@ -173,6 +178,7 @@ typedef basic_ifstream<char> ifstream; |
| 173 | 178 | typedef basic_ofstream<char> ofstream; |
| 174 | 179 | typedef basic_fstream<char> fstream; |
| 175 | 180 | |
| 181 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 176 | 182 | typedef basic_streambuf<wchar_t> wstreambuf; |
| 177 | 183 | typedef basic_istream<wchar_t> wistream; |
| 178 | 184 | typedef basic_ostream<wchar_t> wostream; |
| ... | ... | @@ -187,36 +193,37 @@ typedef basic_filebuf<wchar_t> wfilebuf; |
| 187 | 193 | typedef basic_ifstream<wchar_t> wifstream; |
| 188 | 194 | typedef basic_ofstream<wchar_t> wofstream; |
| 189 | 195 | typedef basic_fstream<wchar_t> wfstream; |
| 196 | #endif | |
| 190 | 197 | |
| 191 | 198 | template <class _CharT, class _Traits> |
| 192 | class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_PREFERRED_NAME(wios) basic_ios; | |
| 199 | class _LIBCPP_PREFERRED_NAME(ios) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wios)) basic_ios; | |
| 193 | 200 | |
| 194 | 201 | template <class _CharT, class _Traits> |
| 195 | class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_PREFERRED_NAME(wstreambuf) basic_streambuf; | |
| 202 | class _LIBCPP_PREFERRED_NAME(streambuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstreambuf)) basic_streambuf; | |
| 196 | 203 | template <class _CharT, class _Traits> |
| 197 | class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_PREFERRED_NAME(wistream) basic_istream; | |
| 204 | class _LIBCPP_PREFERRED_NAME(istream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistream)) basic_istream; | |
| 198 | 205 | template <class _CharT, class _Traits> |
| 199 | class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_PREFERRED_NAME(wostream) basic_ostream; | |
| 206 | class _LIBCPP_PREFERRED_NAME(ostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostream)) basic_ostream; | |
| 200 | 207 | template <class _CharT, class _Traits> |
| 201 | class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_PREFERRED_NAME(wiostream) basic_iostream; | |
| 208 | class _LIBCPP_PREFERRED_NAME(iostream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wiostream)) basic_iostream; | |
| 202 | 209 | |
| 203 | 210 | template <class _CharT, class _Traits, class _Allocator> |
| 204 | class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_PREFERRED_NAME(wstringbuf) basic_stringbuf; | |
| 211 | class _LIBCPP_PREFERRED_NAME(stringbuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringbuf)) basic_stringbuf; | |
| 205 | 212 | template <class _CharT, class _Traits, class _Allocator> |
| 206 | class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_PREFERRED_NAME(wistringstream) basic_istringstream; | |
| 213 | class _LIBCPP_PREFERRED_NAME(istringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wistringstream)) basic_istringstream; | |
| 207 | 214 | template <class _CharT, class _Traits, class _Allocator> |
| 208 | class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_PREFERRED_NAME(wostringstream) basic_ostringstream; | |
| 215 | class _LIBCPP_PREFERRED_NAME(ostringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wostringstream)) basic_ostringstream; | |
| 209 | 216 | template <class _CharT, class _Traits, class _Allocator> |
| 210 | class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_PREFERRED_NAME(wstringstream) basic_stringstream; | |
| 217 | class _LIBCPP_PREFERRED_NAME(stringstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstringstream)) basic_stringstream; | |
| 211 | 218 | |
| 212 | 219 | template <class _CharT, class _Traits> |
| 213 | class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_PREFERRED_NAME(wfilebuf) basic_filebuf; | |
| 220 | class _LIBCPP_PREFERRED_NAME(filebuf) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfilebuf)) basic_filebuf; | |
| 214 | 221 | template <class _CharT, class _Traits> |
| 215 | class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_PREFERRED_NAME(wifstream) basic_ifstream; | |
| 222 | class _LIBCPP_PREFERRED_NAME(ifstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wifstream)) basic_ifstream; | |
| 216 | 223 | template <class _CharT, class _Traits> |
| 217 | class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_PREFERRED_NAME(wofstream) basic_ofstream; | |
| 224 | class _LIBCPP_PREFERRED_NAME(ofstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wofstream)) basic_ofstream; | |
| 218 | 225 | template <class _CharT, class _Traits> |
| 219 | class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_PREFERRED_NAME(wfstream) basic_fstream; | |
| 226 | class _LIBCPP_PREFERRED_NAME(fstream) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wfstream)) basic_fstream; | |
| 220 | 227 | |
| 221 | 228 | template <class _State> class _LIBCPP_TEMPLATE_VIS fpos; |
| 222 | 229 | typedef fpos<mbstate_t> streampos; |
| ... | ... | @@ -227,7 +234,7 @@ typedef fpos<mbstate_t> u8streampos; |
| 227 | 234 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 228 | 235 | typedef fpos<mbstate_t> u16streampos; |
| 229 | 236 | typedef fpos<mbstate_t> u32streampos; |
| 230 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 237 | #endif | |
| 231 | 238 | |
| 232 | 239 | #if defined(_NEWLIB_VERSION) |
| 233 | 240 | // On newlib, off_t is 'long int' |
| ... | ... | @@ -241,10 +248,12 @@ template <class _CharT, // for <stdexcept> |
| 241 | 248 | class _Allocator = allocator<_CharT> > |
| 242 | 249 | class _LIBCPP_TEMPLATE_VIS basic_string; |
| 243 | 250 | typedef basic_string<char, char_traits<char>, allocator<char> > string; |
| 251 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 244 | 252 | typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring; |
| 253 | #endif | |
| 245 | 254 | |
| 246 | 255 | template <class _CharT, class _Traits, class _Allocator> |
| 247 | class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_PREFERRED_NAME(wstring) basic_string; | |
| 256 | class _LIBCPP_PREFERRED_NAME(string) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring)) basic_string; | |
| 248 | 257 | |
| 249 | 258 | // Include other forward declarations here |
| 250 | 259 | template <class _Tp, class _Alloc = allocator<_Tp> > |
lib/libcxx/include/iostream+8-8| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- iostream ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -38,6 +38,7 @@ extern wostream wclog; |
| 38 | 38 | #include <istream> |
| 39 | 39 | #include <ostream> |
| 40 | 40 | #include <streambuf> |
| 41 | #include <version> | |
| 41 | 42 | |
| 42 | 43 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 43 | 44 | #pragma GCC system_header |
| ... | ... | @@ -45,18 +46,17 @@ extern wostream wclog; |
| 45 | 46 | |
| 46 | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 47 | 48 | |
| 48 | #ifndef _LIBCPP_HAS_NO_STDIN | |
| 49 | 49 | extern _LIBCPP_FUNC_VIS istream cin; |
| 50 | extern _LIBCPP_FUNC_VIS wistream wcin; | |
| 51 | #endif | |
| 52 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 53 | 50 | extern _LIBCPP_FUNC_VIS ostream cout; |
| 54 | extern _LIBCPP_FUNC_VIS wostream wcout; | |
| 55 | #endif | |
| 56 | 51 | extern _LIBCPP_FUNC_VIS ostream cerr; |
| 57 | extern _LIBCPP_FUNC_VIS wostream wcerr; | |
| 58 | 52 | extern _LIBCPP_FUNC_VIS ostream clog; |
| 53 | ||
| 54 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 55 | extern _LIBCPP_FUNC_VIS wistream wcin; | |
| 56 | extern _LIBCPP_FUNC_VIS wostream wcout; | |
| 57 | extern _LIBCPP_FUNC_VIS wostream wcerr; | |
| 59 | 58 | extern _LIBCPP_FUNC_VIS wostream wclog; |
| 59 | #endif | |
| 60 | 60 | |
| 61 | 61 | _LIBCPP_END_NAMESPACE_STD |
| 62 | 62 |
lib/libcxx/include/istream+6-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- istream ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -291,15 +291,15 @@ class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry |
| 291 | 291 | { |
| 292 | 292 | bool __ok_; |
| 293 | 293 | |
| 294 | sentry(const sentry&); // = delete; | |
| 295 | sentry& operator=(const sentry&); // = delete; | |
| 296 | ||
| 297 | 294 | public: |
| 298 | 295 | explicit sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); |
| 299 | 296 | // ~sentry() = default; |
| 300 | 297 | |
| 301 | 298 | _LIBCPP_INLINE_VISIBILITY |
| 302 | 299 | explicit operator bool() const {return __ok_;} |
| 300 | ||
| 301 | sentry(const sentry&) = delete; | |
| 302 | sentry& operator=(const sentry&) = delete; | |
| 303 | 303 | }; |
| 304 | 304 | |
| 305 | 305 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1628,7 +1628,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) |
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | 1630 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>) |
| 1631 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1631 | 1632 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>) |
| 1633 | #endif | |
| 1632 | 1634 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>) |
| 1633 | 1635 | |
| 1634 | 1636 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/iterator+16-5| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- iterator ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -140,6 +140,11 @@ template<class In, class Out> |
| 140 | 140 | template<class I1, class I2 = I1> |
| 141 | 141 | concept indirectly_swappable = see below; // since C++20 |
| 142 | 142 | |
| 143 | template<class I1, class I2, class R, class P1 = identity, | |
| 144 | class P2 = identity> | |
| 145 | concept indirectly_comparable = | |
| 146 | indirect_binary_predicate<R, projected<I1, P1>, projected<I2, P2>>; // since C++20 | |
| 147 | ||
| 143 | 148 | template<input_or_output_iterator I, sentinel_for<I> S> |
| 144 | 149 | requires (!same_as<I, S> && copyable<I>) |
| 145 | 150 | class common_iterator; // since C++20 |
| ... | ... | @@ -410,6 +415,10 @@ template<input_iterator I> |
| 410 | 415 | requires see below |
| 411 | 416 | struct iterator_traits<counted_iterator<I>>; |
| 412 | 417 | |
| 418 | // [unreachable.sentinel], unreachable sentinel | |
| 419 | struct unreachable_sentinel_t; | |
| 420 | inline constexpr unreachable_sentinel_t unreachable_sentinel{}; | |
| 421 | ||
| 413 | 422 | template <class T, class charT = char, class traits = char_traits<charT>, class Distance = ptrdiff_t> |
| 414 | 423 | class istream_iterator |
| 415 | 424 | : public iterator<input_iterator_tag, T, Distance, const T*, const T&> // until C++17 |
| ... | ... | @@ -589,23 +598,25 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 589 | 598 | #include <__iterator/erase_if_container.h> |
| 590 | 599 | #include <__iterator/front_insert_iterator.h> |
| 591 | 600 | #include <__iterator/incrementable_traits.h> |
| 601 | #include <__iterator/indirectly_comparable.h> | |
| 592 | 602 | #include <__iterator/insert_iterator.h> |
| 593 | #include <__iterator/istreambuf_iterator.h> | |
| 594 | 603 | #include <__iterator/istream_iterator.h> |
| 595 | #include <__iterator/iterator.h> | |
| 596 | #include <__iterator/iterator_traits.h> | |
| 604 | #include <__iterator/istreambuf_iterator.h> | |
| 597 | 605 | #include <__iterator/iter_move.h> |
| 598 | 606 | #include <__iterator/iter_swap.h> |
| 607 | #include <__iterator/iterator.h> | |
| 608 | #include <__iterator/iterator_traits.h> | |
| 599 | 609 | #include <__iterator/move_iterator.h> |
| 600 | 610 | #include <__iterator/next.h> |
| 601 | #include <__iterator/ostreambuf_iterator.h> | |
| 602 | 611 | #include <__iterator/ostream_iterator.h> |
| 612 | #include <__iterator/ostreambuf_iterator.h> | |
| 603 | 613 | #include <__iterator/prev.h> |
| 604 | 614 | #include <__iterator/projected.h> |
| 605 | 615 | #include <__iterator/readable_traits.h> |
| 606 | 616 | #include <__iterator/reverse_access.h> |
| 607 | 617 | #include <__iterator/reverse_iterator.h> |
| 608 | 618 | #include <__iterator/size.h> |
| 619 | #include <__iterator/unreachable_sentinel.h> | |
| 609 | 620 | #include <__iterator/wrap_iter.h> |
| 610 | 621 | #include <__memory/addressof.h> |
| 611 | 622 | #include <__memory/pointer_traits.h> |
lib/libcxx/include/latch+2-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- latch -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -43,6 +43,7 @@ namespace std |
| 43 | 43 | #include <__availability> |
| 44 | 44 | #include <__config> |
| 45 | 45 | #include <atomic> |
| 46 | #include <version> | |
| 46 | 47 | |
| 47 | 48 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 48 | 49 | #pragma GCC system_header |
lib/libcxx/include/limits+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- limits ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/limits.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- limits.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/list+122-198| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- list ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -319,9 +319,7 @@ public: |
| 319 | 319 | _LIBCPP_INLINE_VISIBILITY |
| 320 | 320 | __list_iterator() _NOEXCEPT : __ptr_(nullptr) |
| 321 | 321 | { |
| 322 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 323 | __get_db()->__insert_i(this); | |
| 324 | #endif | |
| 322 | _VSTD::__debug_db_insert_i(this); | |
| 325 | 323 | } |
| 326 | 324 | |
| 327 | 325 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| ... | ... | @@ -330,7 +328,7 @@ public: |
| 330 | 328 | __list_iterator(const __list_iterator& __p) |
| 331 | 329 | : __ptr_(__p.__ptr_) |
| 332 | 330 | { |
| 333 | __get_db()->__iterator_copy(this, &__p); | |
| 331 | __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); | |
| 334 | 332 | } |
| 335 | 333 | |
| 336 | 334 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -342,9 +340,9 @@ public: |
| 342 | 340 | _LIBCPP_INLINE_VISIBILITY |
| 343 | 341 | __list_iterator& operator=(const __list_iterator& __p) |
| 344 | 342 | { |
| 345 | if (this != &__p) | |
| 343 | if (this != _VSTD::addressof(__p)) | |
| 346 | 344 | { |
| 347 | __get_db()->__iterator_copy(this, &__p); | |
| 345 | __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); | |
| 348 | 346 | __ptr_ = __p.__ptr_; |
| 349 | 347 | } |
| 350 | 348 | return *this; |
| ... | ... | @@ -355,29 +353,23 @@ public: |
| 355 | 353 | _LIBCPP_INLINE_VISIBILITY |
| 356 | 354 | reference operator*() const |
| 357 | 355 | { |
| 358 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 359 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 360 | "Attempted to dereference a non-dereferenceable list::iterator"); | |
| 361 | #endif | |
| 356 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 357 | "Attempted to dereference a non-dereferenceable list::iterator"); | |
| 362 | 358 | return __ptr_->__as_node()->__value_; |
| 363 | 359 | } |
| 364 | 360 | _LIBCPP_INLINE_VISIBILITY |
| 365 | 361 | pointer operator->() const |
| 366 | 362 | { |
| 367 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 368 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 369 | "Attempted to dereference a non-dereferenceable list::iterator"); | |
| 370 | #endif | |
| 363 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 364 | "Attempted to dereference a non-dereferenceable list::iterator"); | |
| 371 | 365 | return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_); |
| 372 | 366 | } |
| 373 | 367 | |
| 374 | 368 | _LIBCPP_INLINE_VISIBILITY |
| 375 | 369 | __list_iterator& operator++() |
| 376 | 370 | { |
| 377 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 378 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 379 | "Attempted to increment a non-incrementable list::iterator"); | |
| 380 | #endif | |
| 371 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 372 | "Attempted to increment a non-incrementable list::iterator"); | |
| 381 | 373 | __ptr_ = __ptr_->__next_; |
| 382 | 374 | return *this; |
| 383 | 375 | } |
| ... | ... | @@ -387,10 +379,8 @@ public: |
| 387 | 379 | _LIBCPP_INLINE_VISIBILITY |
| 388 | 380 | __list_iterator& operator--() |
| 389 | 381 | { |
| 390 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 391 | _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), | |
| 392 | "Attempted to decrement a non-decrementable list::iterator"); | |
| 393 | #endif | |
| 382 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this), | |
| 383 | "Attempted to decrement a non-decrementable list::iterator"); | |
| 394 | 384 | __ptr_ = __ptr_->__prev_; |
| 395 | 385 | return *this; |
| 396 | 386 | } |
| ... | ... | @@ -439,16 +429,14 @@ public: |
| 439 | 429 | _LIBCPP_INLINE_VISIBILITY |
| 440 | 430 | __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) |
| 441 | 431 | { |
| 442 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 443 | __get_db()->__insert_i(this); | |
| 444 | #endif | |
| 432 | _VSTD::__debug_db_insert_i(this); | |
| 445 | 433 | } |
| 446 | 434 | _LIBCPP_INLINE_VISIBILITY |
| 447 | 435 | __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT |
| 448 | 436 | : __ptr_(__p.__ptr_) |
| 449 | 437 | { |
| 450 | 438 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 451 | __get_db()->__iterator_copy(this, &__p); | |
| 439 | __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); | |
| 452 | 440 | #endif |
| 453 | 441 | } |
| 454 | 442 | |
| ... | ... | @@ -458,7 +446,7 @@ public: |
| 458 | 446 | __list_const_iterator(const __list_const_iterator& __p) |
| 459 | 447 | : __ptr_(__p.__ptr_) |
| 460 | 448 | { |
| 461 | __get_db()->__iterator_copy(this, &__p); | |
| 449 | __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); | |
| 462 | 450 | } |
| 463 | 451 | |
| 464 | 452 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -470,9 +458,9 @@ public: |
| 470 | 458 | _LIBCPP_INLINE_VISIBILITY |
| 471 | 459 | __list_const_iterator& operator=(const __list_const_iterator& __p) |
| 472 | 460 | { |
| 473 | if (this != &__p) | |
| 461 | if (this != _VSTD::addressof(__p)) | |
| 474 | 462 | { |
| 475 | __get_db()->__iterator_copy(this, &__p); | |
| 463 | __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); | |
| 476 | 464 | __ptr_ = __p.__ptr_; |
| 477 | 465 | } |
| 478 | 466 | return *this; |
| ... | ... | @@ -482,29 +470,23 @@ public: |
| 482 | 470 | _LIBCPP_INLINE_VISIBILITY |
| 483 | 471 | reference operator*() const |
| 484 | 472 | { |
| 485 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 486 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 487 | "Attempted to dereference a non-dereferenceable list::const_iterator"); | |
| 488 | #endif | |
| 473 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 474 | "Attempted to dereference a non-dereferenceable list::const_iterator"); | |
| 489 | 475 | return __ptr_->__as_node()->__value_; |
| 490 | 476 | } |
| 491 | 477 | _LIBCPP_INLINE_VISIBILITY |
| 492 | 478 | pointer operator->() const |
| 493 | 479 | { |
| 494 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 495 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 496 | "Attempted to dereference a non-dereferenceable list::const_iterator"); | |
| 497 | #endif | |
| 480 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 481 | "Attempted to dereference a non-dereferenceable list::const_iterator"); | |
| 498 | 482 | return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_); |
| 499 | 483 | } |
| 500 | 484 | |
| 501 | 485 | _LIBCPP_INLINE_VISIBILITY |
| 502 | 486 | __list_const_iterator& operator++() |
| 503 | 487 | { |
| 504 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 505 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 506 | "Attempted to increment a non-incrementable list::const_iterator"); | |
| 507 | #endif | |
| 488 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), | |
| 489 | "Attempted to increment a non-incrementable list::const_iterator"); | |
| 508 | 490 | __ptr_ = __ptr_->__next_; |
| 509 | 491 | return *this; |
| 510 | 492 | } |
| ... | ... | @@ -514,10 +496,8 @@ public: |
| 514 | 496 | _LIBCPP_INLINE_VISIBILITY |
| 515 | 497 | __list_const_iterator& operator--() |
| 516 | 498 | { |
| 517 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 518 | _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), | |
| 519 | "Attempted to decrement a non-decrementable list::const_iterator"); | |
| 520 | #endif | |
| 499 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__decrementable(this), | |
| 500 | "Attempted to decrement a non-decrementable list::const_iterator"); | |
| 521 | 501 | __ptr_ = __ptr_->__prev_; |
| 522 | 502 | return *this; |
| 523 | 503 | } |
| ... | ... | @@ -797,7 +777,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 797 | 777 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 798 | 778 | __libcpp_db* __db = __get_db(); |
| 799 | 779 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 800 | __c_node* __cn2 = __db->__find_c(&__c); | |
| 780 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); | |
| 801 | 781 | _VSTD::swap(__cn1->beg_, __cn2->beg_); |
| 802 | 782 | _VSTD::swap(__cn1->end_, __cn2->end_); |
| 803 | 783 | _VSTD::swap(__cn1->cap_, __cn2->cap_); |
| ... | ... | @@ -845,47 +825,50 @@ class _LIBCPP_TEMPLATE_VIS list |
| 845 | 825 | typedef typename base::__link_pointer __link_pointer; |
| 846 | 826 | |
| 847 | 827 | public: |
| 848 | typedef _Tp value_type; | |
| 849 | typedef _Alloc allocator_type; | |
| 828 | typedef _Tp value_type; | |
| 829 | typedef _Alloc allocator_type; | |
| 850 | 830 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), |
| 851 | 831 | "Invalid allocator::value_type"); |
| 852 | typedef value_type& reference; | |
| 853 | typedef const value_type& const_reference; | |
| 854 | typedef typename base::pointer pointer; | |
| 855 | typedef typename base::const_pointer const_pointer; | |
| 856 | typedef typename base::size_type size_type; | |
| 857 | typedef typename base::difference_type difference_type; | |
| 858 | typedef typename base::iterator iterator; | |
| 859 | typedef typename base::const_iterator const_iterator; | |
| 860 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 861 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 832 | typedef value_type& reference; | |
| 833 | typedef const value_type& const_reference; | |
| 834 | typedef typename base::pointer pointer; | |
| 835 | typedef typename base::const_pointer const_pointer; | |
| 836 | typedef typename base::size_type size_type; | |
| 837 | typedef typename base::difference_type difference_type; | |
| 838 | typedef typename base::iterator iterator; | |
| 839 | typedef typename base::const_iterator const_iterator; | |
| 840 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 841 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 862 | 842 | #if _LIBCPP_STD_VER > 17 |
| 863 | typedef size_type __remove_return_type; | |
| 843 | typedef size_type __remove_return_type; | |
| 864 | 844 | #else |
| 865 | typedef void __remove_return_type; | |
| 845 | typedef void __remove_return_type; | |
| 866 | 846 | #endif |
| 867 | 847 | |
| 868 | 848 | _LIBCPP_INLINE_VISIBILITY |
| 869 | 849 | list() |
| 870 | 850 | _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) |
| 871 | 851 | { |
| 872 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 873 | __get_db()->__insert_c(this); | |
| 874 | #endif | |
| 852 | _VSTD::__debug_db_insert_c(this); | |
| 875 | 853 | } |
| 876 | 854 | _LIBCPP_INLINE_VISIBILITY |
| 877 | 855 | explicit list(const allocator_type& __a) : base(__a) |
| 878 | 856 | { |
| 879 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 880 | __get_db()->__insert_c(this); | |
| 881 | #endif | |
| 857 | _VSTD::__debug_db_insert_c(this); | |
| 882 | 858 | } |
| 883 | 859 | explicit list(size_type __n); |
| 884 | 860 | #if _LIBCPP_STD_VER > 11 |
| 885 | 861 | explicit list(size_type __n, const allocator_type& __a); |
| 886 | 862 | #endif |
| 887 | 863 | list(size_type __n, const value_type& __x); |
| 888 | list(size_type __n, const value_type& __x, const allocator_type& __a); | |
| 864 | template <class = __enable_if_t<__is_allocator<_Alloc>::value> > | |
| 865 | list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a) | |
| 866 | { | |
| 867 | _VSTD::__debug_db_insert_c(this); | |
| 868 | for (; __n > 0; --__n) | |
| 869 | push_back(__x); | |
| 870 | } | |
| 871 | ||
| 889 | 872 | template <class _InpIter> |
| 890 | 873 | list(_InpIter __f, _InpIter __l, |
| 891 | 874 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0); |
| ... | ... | @@ -1141,17 +1124,19 @@ private: |
| 1141 | 1124 | void __move_assign(list& __c, false_type); |
| 1142 | 1125 | }; |
| 1143 | 1126 | |
| 1144 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1127 | #if _LIBCPP_STD_VER >= 17 | |
| 1145 | 1128 | template<class _InputIterator, |
| 1146 | 1129 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 1147 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 1130 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1131 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 1148 | 1132 | > |
| 1149 | 1133 | list(_InputIterator, _InputIterator) |
| 1150 | 1134 | -> list<__iter_value_type<_InputIterator>, _Alloc>; |
| 1151 | 1135 | |
| 1152 | 1136 | template<class _InputIterator, |
| 1153 | 1137 | class _Alloc, |
| 1154 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 1138 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1139 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 1155 | 1140 | > |
| 1156 | 1141 | list(_InputIterator, _InputIterator, _Alloc) |
| 1157 | 1142 | -> list<__iter_value_type<_InputIterator>, _Alloc>; |
| ... | ... | @@ -1206,9 +1191,7 @@ list<_Tp, _Alloc>::__iterator(size_type __n) |
| 1206 | 1191 | template <class _Tp, class _Alloc> |
| 1207 | 1192 | list<_Tp, _Alloc>::list(size_type __n) |
| 1208 | 1193 | { |
| 1209 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1210 | __get_db()->__insert_c(this); | |
| 1211 | #endif | |
| 1194 | _VSTD::__debug_db_insert_c(this); | |
| 1212 | 1195 | for (; __n > 0; --__n) |
| 1213 | 1196 | #ifndef _LIBCPP_CXX03_LANG |
| 1214 | 1197 | emplace_back(); |
| ... | ... | @@ -1221,9 +1204,7 @@ list<_Tp, _Alloc>::list(size_type __n) |
| 1221 | 1204 | template <class _Tp, class _Alloc> |
| 1222 | 1205 | list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) |
| 1223 | 1206 | { |
| 1224 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1225 | __get_db()->__insert_c(this); | |
| 1226 | #endif | |
| 1207 | _VSTD::__debug_db_insert_c(this); | |
| 1227 | 1208 | for (; __n > 0; --__n) |
| 1228 | 1209 | emplace_back(); |
| 1229 | 1210 | } |
| ... | ... | @@ -1232,20 +1213,7 @@ list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) |
| 1232 | 1213 | template <class _Tp, class _Alloc> |
| 1233 | 1214 | list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) |
| 1234 | 1215 | { |
| 1235 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1236 | __get_db()->__insert_c(this); | |
| 1237 | #endif | |
| 1238 | for (; __n > 0; --__n) | |
| 1239 | push_back(__x); | |
| 1240 | } | |
| 1241 | ||
| 1242 | template <class _Tp, class _Alloc> | |
| 1243 | list<_Tp, _Alloc>::list(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 1244 | : base(__a) | |
| 1245 | { | |
| 1246 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1247 | __get_db()->__insert_c(this); | |
| 1248 | #endif | |
| 1216 | _VSTD::__debug_db_insert_c(this); | |
| 1249 | 1217 | for (; __n > 0; --__n) |
| 1250 | 1218 | push_back(__x); |
| 1251 | 1219 | } |
| ... | ... | @@ -1255,9 +1223,7 @@ template <class _InpIter> |
| 1255 | 1223 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, |
| 1256 | 1224 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) |
| 1257 | 1225 | { |
| 1258 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1259 | __get_db()->__insert_c(this); | |
| 1260 | #endif | |
| 1226 | _VSTD::__debug_db_insert_c(this); | |
| 1261 | 1227 | for (; __f != __l; ++__f) |
| 1262 | 1228 | __emplace_back(*__f); |
| 1263 | 1229 | } |
| ... | ... | @@ -1268,9 +1234,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a, |
| 1268 | 1234 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) |
| 1269 | 1235 | : base(__a) |
| 1270 | 1236 | { |
| 1271 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1272 | __get_db()->__insert_c(this); | |
| 1273 | #endif | |
| 1237 | _VSTD::__debug_db_insert_c(this); | |
| 1274 | 1238 | for (; __f != __l; ++__f) |
| 1275 | 1239 | __emplace_back(*__f); |
| 1276 | 1240 | } |
| ... | ... | @@ -1279,9 +1243,7 @@ template <class _Tp, class _Alloc> |
| 1279 | 1243 | list<_Tp, _Alloc>::list(const list& __c) |
| 1280 | 1244 | : base(__node_alloc_traits::select_on_container_copy_construction( |
| 1281 | 1245 | __c.__node_alloc())) { |
| 1282 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1283 | __get_db()->__insert_c(this); | |
| 1284 | #endif | |
| 1246 | _VSTD::__debug_db_insert_c(this); | |
| 1285 | 1247 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) |
| 1286 | 1248 | push_back(*__i); |
| 1287 | 1249 | } |
| ... | ... | @@ -1290,9 +1252,7 @@ template <class _Tp, class _Alloc> |
| 1290 | 1252 | list<_Tp, _Alloc>::list(const list& __c, const __identity_t<allocator_type>& __a) |
| 1291 | 1253 | : base(__a) |
| 1292 | 1254 | { |
| 1293 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1294 | __get_db()->__insert_c(this); | |
| 1295 | #endif | |
| 1255 | _VSTD::__debug_db_insert_c(this); | |
| 1296 | 1256 | for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i) |
| 1297 | 1257 | push_back(*__i); |
| 1298 | 1258 | } |
| ... | ... | @@ -1303,9 +1263,7 @@ template <class _Tp, class _Alloc> |
| 1303 | 1263 | list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) |
| 1304 | 1264 | : base(__a) |
| 1305 | 1265 | { |
| 1306 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1307 | __get_db()->__insert_c(this); | |
| 1308 | #endif | |
| 1266 | _VSTD::__debug_db_insert_c(this); | |
| 1309 | 1267 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), |
| 1310 | 1268 | __e = __il.end(); __i != __e; ++__i) |
| 1311 | 1269 | push_back(*__i); |
| ... | ... | @@ -1314,9 +1272,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& |
| 1314 | 1272 | template <class _Tp, class _Alloc> |
| 1315 | 1273 | list<_Tp, _Alloc>::list(initializer_list<value_type> __il) |
| 1316 | 1274 | { |
| 1317 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1318 | __get_db()->__insert_c(this); | |
| 1319 | #endif | |
| 1275 | _VSTD::__debug_db_insert_c(this); | |
| 1320 | 1276 | for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), |
| 1321 | 1277 | __e = __il.end(); __i != __e; ++__i) |
| 1322 | 1278 | push_back(*__i); |
| ... | ... | @@ -1324,11 +1280,9 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) |
| 1324 | 1280 | |
| 1325 | 1281 | template <class _Tp, class _Alloc> |
| 1326 | 1282 | inline list<_Tp, _Alloc>::list(list&& __c) |
| 1327 | _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value) | |
| 1328 | : base(_VSTD::move(__c.__node_alloc())) { | |
| 1329 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1330 | __get_db()->__insert_c(this); | |
| 1331 | #endif | |
| 1283 | _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value) | |
| 1284 | : base(_VSTD::move(__c.__node_alloc())) { | |
| 1285 | _VSTD::__debug_db_insert_c(this); | |
| 1332 | 1286 | splice(end(), __c); |
| 1333 | 1287 | } |
| 1334 | 1288 | |
| ... | ... | @@ -1337,9 +1291,7 @@ inline |
| 1337 | 1291 | list<_Tp, _Alloc>::list(list&& __c, const __identity_t<allocator_type>& __a) |
| 1338 | 1292 | : base(__a) |
| 1339 | 1293 | { |
| 1340 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1341 | __get_db()->__insert_c(this); | |
| 1342 | #endif | |
| 1294 | _VSTD::__debug_db_insert_c(this); | |
| 1343 | 1295 | if (__a == __c.get_allocator()) |
| 1344 | 1296 | splice(end(), __c); |
| 1345 | 1297 | else |
| ... | ... | @@ -1392,7 +1344,7 @@ inline |
| 1392 | 1344 | list<_Tp, _Alloc>& |
| 1393 | 1345 | list<_Tp, _Alloc>::operator=(const list& __c) |
| 1394 | 1346 | { |
| 1395 | if (this != &__c) | |
| 1347 | if (this != _VSTD::addressof(__c)) | |
| 1396 | 1348 | { |
| 1397 | 1349 | base::__copy_assign_alloc(__c); |
| 1398 | 1350 | assign(__c.begin(), __c.end()); |
| ... | ... | @@ -1408,7 +1360,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l, |
| 1408 | 1360 | { |
| 1409 | 1361 | iterator __i = begin(); |
| 1410 | 1362 | iterator __e = end(); |
| 1411 | for (; __f != __l && __i != __e; ++__f, ++__i) | |
| 1363 | for (; __f != __l && __i != __e; ++__f, (void) ++__i) | |
| 1412 | 1364 | *__i = *__f; |
| 1413 | 1365 | if (__i == __e) |
| 1414 | 1366 | insert(__e, __f, __l); |
| ... | ... | @@ -1425,7 +1377,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) |
| 1425 | 1377 | { |
| 1426 | 1378 | iterator __i = begin(); |
| 1427 | 1379 | iterator __e = end(); |
| 1428 | for (; __n > 0 && __i != __e; --__n, ++__i) | |
| 1380 | for (; __n > 0 && __i != __e; --__n, (void) ++__i) | |
| 1429 | 1381 | *__i = __x; |
| 1430 | 1382 | if (__i == __e) |
| 1431 | 1383 | insert(__e, __n, __x); |
| ... | ... | @@ -1448,11 +1400,8 @@ template <class _Tp, class _Alloc> |
| 1448 | 1400 | typename list<_Tp, _Alloc>::iterator |
| 1449 | 1401 | list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) |
| 1450 | 1402 | { |
| 1451 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1452 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1453 | "list::insert(iterator, x) called with an iterator not" | |
| 1454 | " referring to this list"); | |
| 1455 | #endif | |
| 1403 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1404 | "list::insert(iterator, x) called with an iterator not referring to this list"); | |
| 1456 | 1405 | __node_allocator& __na = base::__node_alloc(); |
| 1457 | 1406 | __hold_pointer __hold = __allocate_node(__na); |
| 1458 | 1407 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); |
| ... | ... | @@ -1469,10 +1418,9 @@ template <class _Tp, class _Alloc> |
| 1469 | 1418 | typename list<_Tp, _Alloc>::iterator |
| 1470 | 1419 | list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) |
| 1471 | 1420 | { |
| 1421 | _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"); | |
| 1472 | 1423 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1473 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1474 | "list::insert(iterator, n, x) called with an iterator not" | |
| 1475 | " referring to this list"); | |
| 1476 | 1424 | iterator __r(__p.__ptr_, this); |
| 1477 | 1425 | #else |
| 1478 | 1426 | iterator __r(__p.__ptr_); |
| ... | ... | @@ -1495,7 +1443,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1495 | 1443 | try |
| 1496 | 1444 | { |
| 1497 | 1445 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 1498 | for (--__n; __n != 0; --__n, ++__e, ++__ds) | |
| 1446 | for (--__n; __n != 0; --__n, (void) ++__e, ++__ds) | |
| 1499 | 1447 | { |
| 1500 | 1448 | __hold.reset(__node_alloc_traits::allocate(__na, 1)); |
| 1501 | 1449 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); |
| ... | ... | @@ -1535,10 +1483,9 @@ typename list<_Tp, _Alloc>::iterator |
| 1535 | 1483 | list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, |
| 1536 | 1484 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) |
| 1537 | 1485 | { |
| 1486 | _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"); | |
| 1538 | 1488 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1539 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1540 | "list::insert(iterator, range) called with an iterator not" | |
| 1541 | " referring to this list"); | |
| 1542 | 1489 | iterator __r(__p.__ptr_, this); |
| 1543 | 1490 | #else |
| 1544 | 1491 | iterator __r(__p.__ptr_); |
| ... | ... | @@ -1561,7 +1508,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, |
| 1561 | 1508 | try |
| 1562 | 1509 | { |
| 1563 | 1510 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 1564 | for (++__f; __f != __l; ++__f, (void) ++__e, (void) ++__ds) | |
| 1511 | for (++__f; __f != __l; ++__f, (void) ++__e, ++__ds) | |
| 1565 | 1512 | { |
| 1566 | 1513 | __hold.reset(__node_alloc_traits::allocate(__na, 1)); |
| 1567 | 1514 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); |
| ... | ... | @@ -1694,11 +1641,8 @@ template <class... _Args> |
| 1694 | 1641 | typename list<_Tp, _Alloc>::iterator |
| 1695 | 1642 | list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) |
| 1696 | 1643 | { |
| 1697 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1698 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1699 | "list::emplace(iterator, args...) called with an iterator not" | |
| 1700 | " referring to this list"); | |
| 1701 | #endif | |
| 1644 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1645 | "list::emplace(iterator, args...) called with an iterator not referring to this list"); | |
| 1702 | 1646 | __node_allocator& __na = base::__node_alloc(); |
| 1703 | 1647 | __hold_pointer __hold = __allocate_node(__na); |
| 1704 | 1648 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); |
| ... | ... | @@ -1717,11 +1661,8 @@ template <class _Tp, class _Alloc> |
| 1717 | 1661 | typename list<_Tp, _Alloc>::iterator |
| 1718 | 1662 | list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) |
| 1719 | 1663 | { |
| 1720 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1721 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1722 | "list::insert(iterator, x) called with an iterator not" | |
| 1723 | " referring to this list"); | |
| 1724 | #endif | |
| 1664 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1665 | "list::insert(iterator, x) called with an iterator not referring to this list"); | |
| 1725 | 1666 | __node_allocator& __na = base::__node_alloc(); |
| 1726 | 1667 | __hold_pointer __hold = __allocate_node(__na); |
| 1727 | 1668 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); |
| ... | ... | @@ -1800,11 +1741,8 @@ template <class _Tp, class _Alloc> |
| 1800 | 1741 | typename list<_Tp, _Alloc>::iterator |
| 1801 | 1742 | list<_Tp, _Alloc>::erase(const_iterator __p) |
| 1802 | 1743 | { |
| 1803 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1804 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1805 | "list::erase(iterator) called with an iterator not" | |
| 1806 | " referring to this list"); | |
| 1807 | #endif | |
| 1744 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1745 | "list::erase(iterator) called with an iterator not referring to this list"); | |
| 1808 | 1746 | _LIBCPP_ASSERT(__p != end(), |
| 1809 | 1747 | "list::erase(iterator) called with a non-dereferenceable iterator"); |
| 1810 | 1748 | __node_allocator& __na = base::__node_alloc(); |
| ... | ... | @@ -1841,14 +1779,10 @@ template <class _Tp, class _Alloc> |
| 1841 | 1779 | typename list<_Tp, _Alloc>::iterator |
| 1842 | 1780 | list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) |
| 1843 | 1781 | { |
| 1844 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1845 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this, | |
| 1846 | "list::erase(iterator, iterator) called with an iterator not" | |
| 1847 | " referring to this list"); | |
| 1848 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == this, | |
| 1849 | "list::erase(iterator, iterator) called with an iterator not" | |
| 1850 | " referring to this list"); | |
| 1851 | #endif | |
| 1782 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__f)) == this, | |
| 1783 | "list::erase(iterator, iterator) called with an iterator not referring to this list"); | |
| 1784 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == this, | |
| 1785 | "list::erase(iterator, iterator) called with an iterator not referring to this list"); | |
| 1852 | 1786 | if (__f != __l) |
| 1853 | 1787 | { |
| 1854 | 1788 | __node_allocator& __na = base::__node_alloc(); |
| ... | ... | @@ -1909,7 +1843,7 @@ list<_Tp, _Alloc>::resize(size_type __n) |
| 1909 | 1843 | try |
| 1910 | 1844 | { |
| 1911 | 1845 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 1912 | for (--__n; __n != 0; --__n, ++__e, ++__ds) | |
| 1846 | for (--__n; __n != 0; --__n, (void) ++__e, ++__ds) | |
| 1913 | 1847 | { |
| 1914 | 1848 | __hold.reset(__node_alloc_traits::allocate(__na, 1)); |
| 1915 | 1849 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); |
| ... | ... | @@ -1967,7 +1901,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) |
| 1967 | 1901 | try |
| 1968 | 1902 | { |
| 1969 | 1903 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 1970 | for (--__n; __n != 0; --__n, ++__e, ++__ds) | |
| 1904 | for (--__n; __n != 0; --__n, (void) ++__e, ++__ds) | |
| 1971 | 1905 | { |
| 1972 | 1906 | __hold.reset(__node_alloc_traits::allocate(__na, 1)); |
| 1973 | 1907 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); |
| ... | ... | @@ -2004,13 +1938,10 @@ template <class _Tp, class _Alloc> |
| 2004 | 1938 | void |
| 2005 | 1939 | list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) |
| 2006 | 1940 | { |
| 2007 | _LIBCPP_ASSERT(this != &__c, | |
| 1941 | _LIBCPP_ASSERT(this != _VSTD::addressof(__c), | |
| 2008 | 1942 | "list::splice(iterator, list) called with this == &list"); |
| 2009 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2010 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 2011 | "list::splice(iterator, list) called with an iterator not" | |
| 2012 | " referring to this list"); | |
| 2013 | #endif | |
| 1943 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1944 | "list::splice(iterator, list) called with an iterator not referring to this list"); | |
| 2014 | 1945 | if (!__c.empty()) |
| 2015 | 1946 | { |
| 2016 | 1947 | __link_pointer __f = __c.__end_.__next_; |
| ... | ... | @@ -2020,10 +1951,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) |
| 2020 | 1951 | base::__sz() += __c.__sz(); |
| 2021 | 1952 | __c.__sz() = 0; |
| 2022 | 1953 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2023 | if (&__c != this) { | |
| 1954 | if (_VSTD::addressof(__c) != this) { | |
| 2024 | 1955 | __libcpp_db* __db = __get_db(); |
| 2025 | 1956 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 2026 | __c_node* __cn2 = __db->__find_c(&__c); | |
| 1957 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); | |
| 2027 | 1958 | for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;) |
| 2028 | 1959 | { |
| 2029 | 1960 | --__ip; |
| ... | ... | @@ -2046,17 +1977,13 @@ template <class _Tp, class _Alloc> |
| 2046 | 1977 | void |
| 2047 | 1978 | list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) |
| 2048 | 1979 | { |
| 2049 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2050 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 2051 | "list::splice(iterator, list, iterator) called with the first iterator" | |
| 2052 | " not referring to this list"); | |
| 2053 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__i) == &__c, | |
| 2054 | "list::splice(iterator, list, iterator) called with the second iterator" | |
| 2055 | " not referring to the list argument"); | |
| 2056 | _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(&__i), | |
| 2057 | "list::splice(iterator, list, iterator) called with the second iterator" | |
| 2058 | " not dereferenceable"); | |
| 2059 | #endif | |
| 1980 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1981 | "list::splice(iterator, list, iterator) called with the first iterator not referring to this list"); | |
| 1982 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__i)) == _VSTD::addressof(__c), | |
| 1983 | "list::splice(iterator, list, iterator) called with the second iterator not referring to the list argument"); | |
| 1984 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(_VSTD::addressof(__i)), | |
| 1985 | "list::splice(iterator, list, iterator) called with the second iterator not dereferenceable"); | |
| 1986 | ||
| 2060 | 1987 | if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) |
| 2061 | 1988 | { |
| 2062 | 1989 | __link_pointer __f = __i.__ptr_; |
| ... | ... | @@ -2065,10 +1992,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) |
| 2065 | 1992 | --__c.__sz(); |
| 2066 | 1993 | ++base::__sz(); |
| 2067 | 1994 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2068 | if (&__c != this) { | |
| 1995 | if (_VSTD::addressof(__c) != this) { | |
| 2069 | 1996 | __libcpp_db* __db = __get_db(); |
| 2070 | 1997 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 2071 | __c_node* __cn2 = __db->__find_c(&__c); | |
| 1998 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); | |
| 2072 | 1999 | for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;) |
| 2073 | 2000 | { |
| 2074 | 2001 | --__ip; |
| ... | ... | @@ -2091,23 +2018,20 @@ template <class _Tp, class _Alloc> |
| 2091 | 2018 | void |
| 2092 | 2019 | list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) |
| 2093 | 2020 | { |
| 2021 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 2022 | "list::splice(iterator, list, iterator, iterator) called with first iterator not referring to this list"); | |
| 2023 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__f)) == _VSTD::addressof(__c), | |
| 2024 | "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), | |
| 2026 | "list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument"); | |
| 2027 | ||
| 2094 | 2028 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2095 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 2096 | "list::splice(iterator, list, iterator, iterator) called with first iterator not" | |
| 2097 | " referring to this list"); | |
| 2098 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == &__c, | |
| 2099 | "list::splice(iterator, list, iterator, iterator) called with second iterator not" | |
| 2100 | " referring to the list argument"); | |
| 2101 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == &__c, | |
| 2102 | "list::splice(iterator, list, iterator, iterator) called with third iterator not" | |
| 2103 | " referring to the list argument"); | |
| 2104 | if (this == &__c) | |
| 2029 | if (this == _VSTD::addressof(__c)) | |
| 2105 | 2030 | { |
| 2106 | 2031 | for (const_iterator __i = __f; __i != __l; ++__i) |
| 2107 | _LIBCPP_ASSERT(__i != __p, | |
| 2108 | "list::splice(iterator, list, iterator, iterator)" | |
| 2109 | " called with the first iterator within the range" | |
| 2110 | " of the second and third iterators"); | |
| 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"); | |
| 2111 | 2035 | } |
| 2112 | 2036 | #endif |
| 2113 | 2037 | if (__f != __l) |
| ... | ... | @@ -2115,7 +2039,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con |
| 2115 | 2039 | __link_pointer __first = __f.__ptr_; |
| 2116 | 2040 | --__l; |
| 2117 | 2041 | __link_pointer __last = __l.__ptr_; |
| 2118 | if (this != &__c) | |
| 2042 | if (this != _VSTD::addressof(__c)) | |
| 2119 | 2043 | { |
| 2120 | 2044 | size_type __s = _VSTD::distance(__f, __l) + 1; |
| 2121 | 2045 | __c.__sz() -= __s; |
| ... | ... | @@ -2124,10 +2048,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con |
| 2124 | 2048 | base::__unlink_nodes(__first, __last); |
| 2125 | 2049 | __link_nodes(__p.__ptr_, __first, __last); |
| 2126 | 2050 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2127 | if (&__c != this) { | |
| 2051 | if (_VSTD::addressof(__c) != this) { | |
| 2128 | 2052 | __libcpp_db* __db = __get_db(); |
| 2129 | 2053 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 2130 | __c_node* __cn2 = __db->__find_c(&__c); | |
| 2054 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); | |
| 2131 | 2055 | for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;) |
| 2132 | 2056 | { |
| 2133 | 2057 | --__ip; |
| ... | ... | @@ -2244,7 +2168,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) |
| 2244 | 2168 | { |
| 2245 | 2169 | size_type __ds = 1; |
| 2246 | 2170 | iterator __m2 = _VSTD::next(__f2); |
| 2247 | for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, ++__ds) | |
| 2171 | for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2, (void) ++__ds) | |
| 2248 | 2172 | ; |
| 2249 | 2173 | base::__sz() += __ds; |
| 2250 | 2174 | __c.__sz() -= __ds; |
| ... | ... | @@ -2263,7 +2187,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) |
| 2263 | 2187 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2264 | 2188 | __libcpp_db* __db = __get_db(); |
| 2265 | 2189 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 2266 | __c_node* __cn2 = __db->__find_c(&__c); | |
| 2190 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); | |
| 2267 | 2191 | for (__i_node** __p = __cn2->end_; __p != __cn2->beg_;) |
| 2268 | 2192 | { |
| 2269 | 2193 | --__p; |
lib/libcxx/include/locale+124-172| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- locale ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -228,9 +228,9 @@ _LIBCPP_PUSH_MACROS |
| 228 | 228 | |
| 229 | 229 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 230 | 230 | |
| 231 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) | |
| 231 | #if defined(__APPLE__) || defined(__FreeBSD__) | |
| 232 | 232 | # define _LIBCPP_GET_C_LOCALE 0 |
| 233 | #elif defined(__CloudABI__) || defined(__NetBSD__) | |
| 233 | #elif defined(__NetBSD__) | |
| 234 | 234 | # define _LIBCPP_GET_C_LOCALE LC_C_LOCALE |
| 235 | 235 | #else |
| 236 | 236 | # define _LIBCPP_GET_C_LOCALE __cloc() |
| ... | ... | @@ -416,11 +416,11 @@ struct __num_get |
| 416 | 416 | unsigned& __dc, _CharT __thousands_sep, const string& __grouping, |
| 417 | 417 | unsigned* __g, unsigned*& __g_end, const _CharT* __atoms); |
| 418 | 418 | private: |
| 419 | template<typename T> | |
| 420 | const T* __do_widen_p(ios_base& __iob, T* __atoms) const | |
| 419 | template<typename _Tp> | |
| 420 | const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const | |
| 421 | 421 | { |
| 422 | 422 | locale __loc = __iob.getloc(); |
| 423 | use_facet<ctype<T> >(__loc).widen(__src, __src + 26, __atoms); | |
| 423 | use_facet<ctype<_Tp> >(__loc).widen(__src, __src + 26, __atoms); | |
| 424 | 424 | return __atoms; |
| 425 | 425 | } |
| 426 | 426 | |
| ... | ... | @@ -573,7 +573,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>) |
| 576 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 576 | 577 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>) |
| 578 | #endif | |
| 577 | 579 | |
| 578 | 580 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 579 | 581 | class _LIBCPP_TEMPLATE_VIS num_get |
| ... | ... | @@ -1111,7 +1113,9 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, |
| 1111 | 1113 | } |
| 1112 | 1114 | |
| 1113 | 1115 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>) |
| 1116 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1114 | 1117 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>) |
| 1118 | #endif | |
| 1115 | 1119 | |
| 1116 | 1120 | struct _LIBCPP_TYPE_VIS __num_put_base |
| 1117 | 1121 | { |
| ... | ... | @@ -1261,7 +1265,9 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne, |
| 1261 | 1265 | } |
| 1262 | 1266 | |
| 1263 | 1267 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>) |
| 1268 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1264 | 1269 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>) |
| 1270 | #endif | |
| 1265 | 1271 | |
| 1266 | 1272 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 1267 | 1273 | class _LIBCPP_TEMPLATE_VIS num_put |
| ... | ... | @@ -1354,6 +1360,18 @@ protected: |
| 1354 | 1360 | long double __v) const; |
| 1355 | 1361 | virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, |
| 1356 | 1362 | const void* __v) const; |
| 1363 | ||
| 1364 | template <class _Integral> | |
| 1365 | _LIBCPP_HIDE_FROM_ABI inline | |
| 1366 | _OutputIterator __do_put_integral(iter_type __s, ios_base& __iob, | |
| 1367 | char_type __fl, _Integral __v, | |
| 1368 | char const* __len) const; | |
| 1369 | ||
| 1370 | template <class _Float> | |
| 1371 | _LIBCPP_HIDE_FROM_ABI inline | |
| 1372 | _OutputIterator __do_put_floating_point(iter_type __s, ios_base& __iob, | |
| 1373 | char_type __fl, _Float __v, | |
| 1374 | char const* __len) const; | |
| 1357 | 1375 | }; |
| 1358 | 1376 | |
| 1359 | 1377 | template <class _CharT, class _OutputIterator> |
| ... | ... | @@ -1450,22 +1468,28 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1450 | 1468 | } |
| 1451 | 1469 | |
| 1452 | 1470 | template <class _CharT, class _OutputIterator> |
| 1471 | template <class _Integral> | |
| 1472 | _LIBCPP_HIDE_FROM_ABI inline | |
| 1453 | 1473 | _OutputIterator |
| 1454 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, | |
| 1455 | char_type __fl, long __v) const | |
| 1474 | num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __iob, | |
| 1475 | char_type __fl, _Integral __v, | |
| 1476 | char const* __len) const | |
| 1456 | 1477 | { |
| 1457 | 1478 | // Stage 1 - Get number in narrow char |
| 1458 | char __fmt[6] = {'%', 0}; | |
| 1459 | const char* __len = "l"; | |
| 1460 | this->__format_int(__fmt+1, __len, true, __iob.flags()); | |
| 1479 | char __fmt[8] = {'%', 0}; | |
| 1480 | this->__format_int(__fmt+1, __len, is_signed<_Integral>::value, __iob.flags()); | |
| 1461 | 1481 | // Worst case is octal, with showbase enabled. Note that octal is always |
| 1462 | 1482 | // printed as an unsigned value. |
| 1483 | using _Unsigned = typename make_unsigned<_Integral>::type; | |
| 1463 | 1484 | _LIBCPP_CONSTEXPR const unsigned __nbuf |
| 1464 | = (numeric_limits<unsigned long>::digits / 3) // 1 char per 3 bits | |
| 1465 | + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up | |
| 1485 | = (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits | |
| 1486 | + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up | |
| 1466 | 1487 | + 2; // base prefix + terminating null character |
| 1467 | 1488 | char __nar[__nbuf]; |
| 1489 | #pragma clang diagnostic push | |
| 1490 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 1468 | 1491 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); |
| 1492 | #pragma clang diagnostic pop | |
| 1469 | 1493 | char* __ne = __nar + __nc; |
| 1470 | 1494 | char* __np = this->__identify_padding(__nar, __ne, __iob); |
| 1471 | 1495 | // Stage 2 - Widen __nar while adding thousands separators |
| ... | ... | @@ -1478,33 +1502,20 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1478 | 1502 | return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); |
| 1479 | 1503 | } |
| 1480 | 1504 | |
| 1505 | template <class _CharT, class _OutputIterator> | |
| 1506 | _OutputIterator | |
| 1507 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, | |
| 1508 | char_type __fl, long __v) const | |
| 1509 | { | |
| 1510 | return this->__do_put_integral(__s, __iob, __fl, __v, "l"); | |
| 1511 | } | |
| 1512 | ||
| 1481 | 1513 | template <class _CharT, class _OutputIterator> |
| 1482 | 1514 | _OutputIterator |
| 1483 | 1515 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1484 | 1516 | char_type __fl, long long __v) const |
| 1485 | 1517 | { |
| 1486 | // Stage 1 - Get number in narrow char | |
| 1487 | char __fmt[8] = {'%', 0}; | |
| 1488 | const char* __len = "ll"; | |
| 1489 | this->__format_int(__fmt+1, __len, true, __iob.flags()); | |
| 1490 | // Worst case is octal, with showbase enabled. Note that octal is always | |
| 1491 | // printed as an unsigned value. | |
| 1492 | _LIBCPP_CONSTEXPR const unsigned __nbuf | |
| 1493 | = (numeric_limits<unsigned long long>::digits / 3) // 1 char per 3 bits | |
| 1494 | + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up | |
| 1495 | + 2; // base prefix + terminating null character | |
| 1496 | char __nar[__nbuf]; | |
| 1497 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1498 | char* __ne = __nar + __nc; | |
| 1499 | char* __np = this->__identify_padding(__nar, __ne, __iob); | |
| 1500 | // Stage 2 - Widen __nar while adding thousands separators | |
| 1501 | char_type __o[2*(__nbuf-1) - 1]; | |
| 1502 | char_type* __op; // pad here | |
| 1503 | char_type* __oe; // end of output | |
| 1504 | this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); | |
| 1505 | // [__o, __oe) contains thousands_sep'd wide number | |
| 1506 | // Stage 3 & 4 | |
| 1507 | return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); | |
| 1518 | return this->__do_put_integral(__s, __iob, __fl, __v, "ll"); | |
| 1508 | 1519 | } |
| 1509 | 1520 | |
| 1510 | 1521 | template <class _CharT, class _OutputIterator> |
| ... | ... | @@ -1512,27 +1523,7 @@ _OutputIterator |
| 1512 | 1523 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1513 | 1524 | char_type __fl, unsigned long __v) const |
| 1514 | 1525 | { |
| 1515 | // Stage 1 - Get number in narrow char | |
| 1516 | char __fmt[6] = {'%', 0}; | |
| 1517 | const char* __len = "l"; | |
| 1518 | this->__format_int(__fmt+1, __len, false, __iob.flags()); | |
| 1519 | // Worst case is octal, with showbase enabled. | |
| 1520 | _LIBCPP_CONSTEXPR const unsigned __nbuf | |
| 1521 | = (numeric_limits<unsigned long>::digits / 3) // 1 char per 3 bits | |
| 1522 | + ((numeric_limits<unsigned long>::digits % 3) != 0) // round up | |
| 1523 | + 2; // base prefix + terminating null character | |
| 1524 | char __nar[__nbuf]; | |
| 1525 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1526 | char* __ne = __nar + __nc; | |
| 1527 | char* __np = this->__identify_padding(__nar, __ne, __iob); | |
| 1528 | // Stage 2 - Widen __nar while adding thousands separators | |
| 1529 | char_type __o[2*(__nbuf-1) - 1]; | |
| 1530 | char_type* __op; // pad here | |
| 1531 | char_type* __oe; // end of output | |
| 1532 | this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); | |
| 1533 | // [__o, __oe) contains thousands_sep'd wide number | |
| 1534 | // Stage 3 & 4 | |
| 1535 | return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); | |
| 1526 | return this->__do_put_integral(__s, __iob, __fl, __v, "l"); | |
| 1536 | 1527 | } |
| 1537 | 1528 | |
| 1538 | 1529 | template <class _CharT, class _OutputIterator> |
| ... | ... | @@ -1540,42 +1531,26 @@ _OutputIterator |
| 1540 | 1531 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1541 | 1532 | char_type __fl, unsigned long long __v) const |
| 1542 | 1533 | { |
| 1543 | // Stage 1 - Get number in narrow char | |
| 1544 | char __fmt[8] = {'%', 0}; | |
| 1545 | const char* __len = "ll"; | |
| 1546 | this->__format_int(__fmt+1, __len, false, __iob.flags()); | |
| 1547 | // Worst case is octal, with showbase enabled. | |
| 1548 | _LIBCPP_CONSTEXPR const unsigned __nbuf | |
| 1549 | = (numeric_limits<unsigned long long>::digits / 3) // 1 char per 3 bits | |
| 1550 | + ((numeric_limits<unsigned long long>::digits % 3) != 0) // round up | |
| 1551 | + 2; // base prefix + terminating null character | |
| 1552 | char __nar[__nbuf]; | |
| 1553 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1554 | char* __ne = __nar + __nc; | |
| 1555 | char* __np = this->__identify_padding(__nar, __ne, __iob); | |
| 1556 | // Stage 2 - Widen __nar while adding thousands separators | |
| 1557 | char_type __o[2*(__nbuf-1) - 1]; | |
| 1558 | char_type* __op; // pad here | |
| 1559 | char_type* __oe; // end of output | |
| 1560 | this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc()); | |
| 1561 | // [__o, __oe) contains thousands_sep'd wide number | |
| 1562 | // Stage 3 & 4 | |
| 1563 | return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); | |
| 1534 | return this->__do_put_integral(__s, __iob, __fl, __v, "ll"); | |
| 1564 | 1535 | } |
| 1565 | 1536 | |
| 1566 | 1537 | template <class _CharT, class _OutputIterator> |
| 1538 | template <class _Float> | |
| 1539 | _LIBCPP_HIDE_FROM_ABI inline | |
| 1567 | 1540 | _OutputIterator |
| 1568 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, | |
| 1569 | char_type __fl, double __v) const | |
| 1541 | num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_base& __iob, | |
| 1542 | char_type __fl, _Float __v, | |
| 1543 | char const* __len) const | |
| 1570 | 1544 | { |
| 1571 | 1545 | // Stage 1 - Get number in narrow char |
| 1572 | 1546 | char __fmt[8] = {'%', 0}; |
| 1573 | const char* __len = ""; | |
| 1574 | 1547 | bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags()); |
| 1575 | 1548 | const unsigned __nbuf = 30; |
| 1576 | 1549 | char __nar[__nbuf]; |
| 1577 | 1550 | char* __nb = __nar; |
| 1578 | 1551 | int __nc; |
| 1552 | #pragma clang diagnostic push | |
| 1553 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 1579 | 1554 | if (__specify_precision) |
| 1580 | 1555 | __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, |
| 1581 | 1556 | (int)__iob.precision(), __v); |
| ... | ... | @@ -1592,6 +1567,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1592 | 1567 | __throw_bad_alloc(); |
| 1593 | 1568 | __nbh.reset(__nb); |
| 1594 | 1569 | } |
| 1570 | #pragma clang diagnostic pop | |
| 1595 | 1571 | char* __ne = __nb + __nc; |
| 1596 | 1572 | char* __np = this->__identify_padding(__nb, __ne, __iob); |
| 1597 | 1573 | // Stage 2 - Widen __nar while adding thousands separators |
| ... | ... | @@ -1614,55 +1590,20 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1614 | 1590 | return __s; |
| 1615 | 1591 | } |
| 1616 | 1592 | |
| 1593 | template <class _CharT, class _OutputIterator> | |
| 1594 | _OutputIterator | |
| 1595 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, | |
| 1596 | char_type __fl, double __v) const | |
| 1597 | { | |
| 1598 | return this->__do_put_floating_point(__s, __iob, __fl, __v, ""); | |
| 1599 | } | |
| 1600 | ||
| 1617 | 1601 | template <class _CharT, class _OutputIterator> |
| 1618 | 1602 | _OutputIterator |
| 1619 | 1603 | num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1620 | 1604 | char_type __fl, long double __v) const |
| 1621 | 1605 | { |
| 1622 | // Stage 1 - Get number in narrow char | |
| 1623 | char __fmt[8] = {'%', 0}; | |
| 1624 | const char* __len = "L"; | |
| 1625 | bool __specify_precision = this->__format_float(__fmt+1, __len, __iob.flags()); | |
| 1626 | const unsigned __nbuf = 30; | |
| 1627 | char __nar[__nbuf]; | |
| 1628 | char* __nb = __nar; | |
| 1629 | int __nc; | |
| 1630 | if (__specify_precision) | |
| 1631 | __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, | |
| 1632 | (int)__iob.precision(), __v); | |
| 1633 | else | |
| 1634 | __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1635 | unique_ptr<char, void(*)(void*)> __nbh(nullptr, free); | |
| 1636 | if (__nc > static_cast<int>(__nbuf-1)) | |
| 1637 | { | |
| 1638 | if (__specify_precision) | |
| 1639 | __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v); | |
| 1640 | else | |
| 1641 | __nc = __libcpp_asprintf_l(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1642 | if (__nc == -1) | |
| 1643 | __throw_bad_alloc(); | |
| 1644 | __nbh.reset(__nb); | |
| 1645 | } | |
| 1646 | char* __ne = __nb + __nc; | |
| 1647 | char* __np = this->__identify_padding(__nb, __ne, __iob); | |
| 1648 | // Stage 2 - Widen __nar while adding thousands separators | |
| 1649 | char_type __o[2*(__nbuf-1) - 1]; | |
| 1650 | char_type* __ob = __o; | |
| 1651 | unique_ptr<char_type, void(*)(void*)> __obh(0, free); | |
| 1652 | if (__nb != __nar) | |
| 1653 | { | |
| 1654 | __ob = (char_type*)malloc(2*static_cast<size_t>(__nc)*sizeof(char_type)); | |
| 1655 | if (__ob == 0) | |
| 1656 | __throw_bad_alloc(); | |
| 1657 | __obh.reset(__ob); | |
| 1658 | } | |
| 1659 | char_type* __op; // pad here | |
| 1660 | char_type* __oe; // end of output | |
| 1661 | this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc()); | |
| 1662 | // [__o, __oe) contains thousands_sep'd wide number | |
| 1663 | // Stage 3 & 4 | |
| 1664 | __s = __pad_and_output(__s, __ob, __op, __oe, __iob, __fl); | |
| 1665 | return __s; | |
| 1606 | return this->__do_put_floating_point(__s, __iob, __fl, __v, "L"); | |
| 1666 | 1607 | } |
| 1667 | 1608 | |
| 1668 | 1609 | template <class _CharT, class _OutputIterator> |
| ... | ... | @@ -1671,10 +1612,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1671 | 1612 | char_type __fl, const void* __v) const |
| 1672 | 1613 | { |
| 1673 | 1614 | // Stage 1 - Get pointer in narrow char |
| 1674 | char __fmt[6] = "%p"; | |
| 1675 | 1615 | const unsigned __nbuf = 20; |
| 1676 | 1616 | char __nar[__nbuf]; |
| 1677 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); | |
| 1617 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v); | |
| 1678 | 1618 | char* __ne = __nar + __nc; |
| 1679 | 1619 | char* __np = this->__identify_padding(__nar, __ne, __iob); |
| 1680 | 1620 | // Stage 2 - Widen __nar |
| ... | ... | @@ -1694,7 +1634,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1694 | 1634 | } |
| 1695 | 1635 | |
| 1696 | 1636 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>) |
| 1637 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1697 | 1638 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>) |
| 1639 | #endif | |
| 1698 | 1640 | |
| 1699 | 1641 | template <class _CharT, class _InputIterator> |
| 1700 | 1642 | _LIBCPP_HIDDEN |
| ... | ... | @@ -1761,6 +1703,7 @@ template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__r() con |
| 1761 | 1703 | template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__x() const; |
| 1762 | 1704 | template <> _LIBCPP_FUNC_VIS const string& __time_get_c_storage<char>::__X() const; |
| 1763 | 1705 | |
| 1706 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1764 | 1707 | template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage<wchar_t>::__weeks() const; |
| 1765 | 1708 | template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage<wchar_t>::__months() const; |
| 1766 | 1709 | template <> _LIBCPP_FUNC_VIS const wstring* __time_get_c_storage<wchar_t>::__am_pm() const; |
| ... | ... | @@ -1768,6 +1711,7 @@ template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__c() |
| 1768 | 1711 | template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__r() const; |
| 1769 | 1712 | template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__x() const; |
| 1770 | 1713 | template <> _LIBCPP_FUNC_VIS const wstring& __time_get_c_storage<wchar_t>::__X() const; |
| 1714 | #endif | |
| 1771 | 1715 | |
| 1772 | 1716 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 1773 | 1717 | class _LIBCPP_TEMPLATE_VIS time_get |
| ... | ... | @@ -2380,7 +2324,9 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, |
| 2380 | 2324 | } |
| 2381 | 2325 | |
| 2382 | 2326 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>) |
| 2327 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2383 | 2328 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>) |
| 2329 | #endif | |
| 2384 | 2330 | |
| 2385 | 2331 | class _LIBCPP_TYPE_VIS __time_get |
| 2386 | 2332 | { |
| ... | ... | @@ -2480,7 +2426,9 @@ private: |
| 2480 | 2426 | }; |
| 2481 | 2427 | |
| 2482 | 2428 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>) |
| 2429 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2483 | 2430 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>) |
| 2431 | #endif | |
| 2484 | 2432 | |
| 2485 | 2433 | class _LIBCPP_TYPE_VIS __time_put |
| 2486 | 2434 | { |
| ... | ... | @@ -2593,7 +2541,9 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&, |
| 2593 | 2541 | } |
| 2594 | 2542 | |
| 2595 | 2543 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>) |
| 2544 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2596 | 2545 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>) |
| 2546 | #endif | |
| 2597 | 2547 | |
| 2598 | 2548 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 2599 | 2549 | class _LIBCPP_TEMPLATE_VIS time_put_byname |
| ... | ... | @@ -2614,7 +2564,9 @@ protected: |
| 2614 | 2564 | }; |
| 2615 | 2565 | |
| 2616 | 2566 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>) |
| 2567 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2617 | 2568 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>) |
| 2569 | #endif | |
| 2618 | 2570 | |
| 2619 | 2571 | // money_base |
| 2620 | 2572 | |
| ... | ... | @@ -2682,8 +2634,10 @@ moneypunct<_CharT, _International>::intl; |
| 2682 | 2634 | |
| 2683 | 2635 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>) |
| 2684 | 2636 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>) |
| 2637 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2685 | 2638 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>) |
| 2686 | 2639 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>) |
| 2640 | #endif | |
| 2687 | 2641 | |
| 2688 | 2642 | // moneypunct_byname |
| 2689 | 2643 | |
| ... | ... | @@ -2734,13 +2688,15 @@ private: |
| 2734 | 2688 | |
| 2735 | 2689 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, false>::init(const char*); |
| 2736 | 2690 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*); |
| 2737 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*); | |
| 2738 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*); | |
| 2739 | ||
| 2740 | 2691 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>) |
| 2741 | 2692 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>) |
| 2693 | ||
| 2694 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2695 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*); | |
| 2696 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*); | |
| 2742 | 2697 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>) |
| 2743 | 2698 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>) |
| 2699 | #endif | |
| 2744 | 2700 | |
| 2745 | 2701 | // money_get |
| 2746 | 2702 | |
| ... | ... | @@ -2797,7 +2753,9 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc, |
| 2797 | 2753 | } |
| 2798 | 2754 | |
| 2799 | 2755 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>) |
| 2756 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2800 | 2757 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>) |
| 2758 | #endif | |
| 2801 | 2759 | |
| 2802 | 2760 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| 2803 | 2761 | class _LIBCPP_TEMPLATE_VIS money_get |
| ... | ... | @@ -2891,6 +2849,10 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, |
| 2891 | 2849 | unique_ptr<char_type, void(*)(void*)>& __wb, |
| 2892 | 2850 | char_type*& __wn, char_type* __we) |
| 2893 | 2851 | { |
| 2852 | if (__b == __e) { | |
| 2853 | __err |= ios_base::failbit; | |
| 2854 | return false; | |
| 2855 | } | |
| 2894 | 2856 | const unsigned __bz = 100; |
| 2895 | 2857 | unsigned __gbuf[__bz]; |
| 2896 | 2858 | unique_ptr<unsigned, void(*)(void*)> __gb(__gbuf, __do_nothing); |
| ... | ... | @@ -2935,51 +2897,31 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, |
| 2935 | 2897 | } |
| 2936 | 2898 | break; |
| 2937 | 2899 | case money_base::sign: |
| 2938 | if (__psn.size() + __nsn.size() > 0) | |
| 2900 | if (__psn.size() > 0 && *__b == __psn[0]) | |
| 2939 | 2901 | { |
| 2940 | if (__psn.size() == 0 || __nsn.size() == 0) | |
| 2941 | { // sign is optional | |
| 2942 | if (__psn.size() > 0) | |
| 2943 | { // __nsn.size() == 0 | |
| 2944 | if (*__b == __psn[0]) | |
| 2945 | { | |
| 2946 | ++__b; | |
| 2947 | if (__psn.size() > 1) | |
| 2948 | __trailing_sign = &__psn; | |
| 2949 | } | |
| 2950 | else | |
| 2951 | __neg = true; | |
| 2952 | } | |
| 2953 | else if (*__b == __nsn[0]) // __nsn.size() > 0 && __psn.size() == 0 | |
| 2954 | { | |
| 2955 | ++__b; | |
| 2956 | __neg = true; | |
| 2957 | if (__nsn.size() > 1) | |
| 2958 | __trailing_sign = &__nsn; | |
| 2959 | } | |
| 2960 | } | |
| 2961 | else // sign is required | |
| 2962 | { | |
| 2963 | if (*__b == __psn[0]) | |
| 2964 | { | |
| 2965 | ++__b; | |
| 2966 | if (__psn.size() > 1) | |
| 2967 | __trailing_sign = &__psn; | |
| 2968 | } | |
| 2969 | else if (*__b == __nsn[0]) | |
| 2970 | { | |
| 2971 | ++__b; | |
| 2972 | __neg = true; | |
| 2973 | if (__nsn.size() > 1) | |
| 2974 | __trailing_sign = &__nsn; | |
| 2975 | } | |
| 2976 | else | |
| 2977 | { | |
| 2978 | __err |= ios_base::failbit; | |
| 2979 | return false; | |
| 2980 | } | |
| 2981 | } | |
| 2902 | ++__b; | |
| 2903 | __neg = false; | |
| 2904 | if (__psn.size() > 1) | |
| 2905 | __trailing_sign = &__psn; | |
| 2906 | break; | |
| 2907 | } | |
| 2908 | if (__nsn.size() > 0 && *__b == __nsn[0]) | |
| 2909 | { | |
| 2910 | ++__b; | |
| 2911 | __neg = true; | |
| 2912 | if (__nsn.size() > 1) | |
| 2913 | __trailing_sign = &__nsn; | |
| 2914 | break; | |
| 2982 | 2915 | } |
| 2916 | if (__psn.size() > 0 && __nsn.size() > 0) | |
| 2917 | { // sign is required | |
| 2918 | __err |= ios_base::failbit; | |
| 2919 | return false; | |
| 2920 | } | |
| 2921 | if (__psn.size() == 0 && __nsn.size() == 0) | |
| 2922 | // locale has no way of specifying a sign. Use the initial value of __neg as a default | |
| 2923 | break; | |
| 2924 | __neg = (__nsn.size() == 0); | |
| 2983 | 2925 | break; |
| 2984 | 2926 | case money_base::symbol: |
| 2985 | 2927 | { |
| ... | ... | @@ -3180,7 +3122,9 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, |
| 3180 | 3122 | } |
| 3181 | 3123 | |
| 3182 | 3124 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>) |
| 3125 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3183 | 3126 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>) |
| 3127 | #endif | |
| 3184 | 3128 | |
| 3185 | 3129 | // money_put |
| 3186 | 3130 | |
| ... | ... | @@ -3355,7 +3299,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m |
| 3355 | 3299 | } |
| 3356 | 3300 | |
| 3357 | 3301 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>) |
| 3302 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3358 | 3303 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>) |
| 3304 | #endif | |
| 3359 | 3305 | |
| 3360 | 3306 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| 3361 | 3307 | class _LIBCPP_TEMPLATE_VIS money_put |
| ... | ... | @@ -3508,7 +3454,9 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, |
| 3508 | 3454 | } |
| 3509 | 3455 | |
| 3510 | 3456 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>) |
| 3457 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3511 | 3458 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>) |
| 3459 | #endif | |
| 3512 | 3460 | |
| 3513 | 3461 | // messages |
| 3514 | 3462 | |
| ... | ... | @@ -3624,7 +3572,9 @@ messages<_CharT>::do_close(catalog __c) const |
| 3624 | 3572 | } |
| 3625 | 3573 | |
| 3626 | 3574 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>) |
| 3575 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3627 | 3576 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>) |
| 3577 | #endif | |
| 3628 | 3578 | |
| 3629 | 3579 | template <class _CharT> |
| 3630 | 3580 | class _LIBCPP_TEMPLATE_VIS messages_byname |
| ... | ... | @@ -3648,7 +3598,9 @@ protected: |
| 3648 | 3598 | }; |
| 3649 | 3599 | |
| 3650 | 3600 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>) |
| 3601 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3651 | 3602 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>) |
| 3603 | #endif | |
| 3652 | 3604 | |
| 3653 | 3605 | template<class _Codecvt, class _Elem = wchar_t, |
| 3654 | 3606 | class _Wide_alloc = allocator<_Elem>, |
lib/libcxx/include/locale.h+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- locale.h --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -36,7 +36,7 @@ Functions: |
| 36 | 36 | #include <__config> |
| 37 | 37 | |
| 38 | 38 | #if defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 39 | # error "Localization is not supported by this configuration of libc++" | |
| 39 | # error "The Localization library is not supported since libc++ has been configured with LIBCXX_ENABLE_LOCALIZATION disabled" | |
| 40 | 40 | #endif |
| 41 | 41 | |
| 42 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
lib/libcxx/include/map+75-35| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- map ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -223,6 +223,25 @@ public: |
| 223 | 223 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
| 224 | 224 | }; |
| 225 | 225 | |
| 226 | template <class InputIterator, | |
| 227 | class Compare = less<iter_key_t<InputIterator>>, | |
| 228 | class Allocator = allocator<iter_to_alloc_t<InputIterator>>> | |
| 229 | map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) | |
| 230 | -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 | |
| 231 | ||
| 232 | template<class Key, class T, class Compare = less<Key>, | |
| 233 | class Allocator = allocator<pair<const Key, T>>> | |
| 234 | map(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) | |
| 235 | -> map<Key, T, Compare, Allocator>; // C++17 | |
| 236 | ||
| 237 | template <class InputIterator, class Allocator> | |
| 238 | map(InputIterator, InputIterator, Allocator) | |
| 239 | -> map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, less<iter_key_t<InputIterator>>, | |
| 240 | Allocator>; // C++17 | |
| 241 | ||
| 242 | template<class Key, class T, class Allocator> | |
| 243 | map(initializer_list<pair<const Key, T>>, Allocator) -> map<Key, T, less<Key>, Allocator>; // C++17 | |
| 244 | ||
| 226 | 245 | template <class Key, class T, class Compare, class Allocator> |
| 227 | 246 | bool |
| 228 | 247 | operator==(const map<Key, T, Compare, Allocator>& x, |
| ... | ... | @@ -444,6 +463,26 @@ public: |
| 444 | 463 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
| 445 | 464 | }; |
| 446 | 465 | |
| 466 | template <class InputIterator, | |
| 467 | class Compare = less<iter_key_t<InputIterator>>, | |
| 468 | class Allocator = allocator<iter_to_alloc_t<InputIterator>>> | |
| 469 | multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) | |
| 470 | -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Compare, Allocator>; // C++17 | |
| 471 | ||
| 472 | template<class Key, class T, class Compare = less<Key>, | |
| 473 | class Allocator = allocator<pair<const Key, T>>> | |
| 474 | multimap(initializer_list<pair<const Key, T>>, Compare = Compare(), Allocator = Allocator()) | |
| 475 | -> multimap<Key, T, Compare, Allocator>; // C++17 | |
| 476 | ||
| 477 | template <class InputIterator, class Allocator> | |
| 478 | multimap(InputIterator, InputIterator, Allocator) | |
| 479 | -> multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, | |
| 480 | less<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 481 | ||
| 482 | template<class Key, class T, class Allocator> | |
| 483 | multimap(initializer_list<pair<const Key, T>>, Allocator) | |
| 484 | -> multimap<Key, T, less<Key>, Allocator>; // C++17 | |
| 485 | ||
| 447 | 486 | template <class Key, class T, class Compare, class Allocator> |
| 448 | 487 | bool |
| 449 | 488 | operator==(const multimap<Key, T, Compare, Allocator>& x, |
| ... | ... | @@ -492,6 +531,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 492 | 531 | #include <__config> |
| 493 | 532 | #include <__debug> |
| 494 | 533 | #include <__functional/is_transparent.h> |
| 534 | #include <__iterator/iterator_traits.h> | |
| 495 | 535 | #include <__node_handle> |
| 496 | 536 | #include <__tree> |
| 497 | 537 | #include <__utility/forward.h> |
| ... | ... | @@ -535,7 +575,7 @@ public: |
| 535 | 575 | _LIBCPP_INLINE_VISIBILITY |
| 536 | 576 | bool operator()(const _Key& __x, const _CP& __y) const |
| 537 | 577 | {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);} |
| 538 | void swap(__map_value_compare&__y) | |
| 578 | void swap(__map_value_compare& __y) | |
| 539 | 579 | _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) |
| 540 | 580 | { |
| 541 | 581 | using _VSTD::swap; |
| ... | ... | @@ -545,15 +585,13 @@ public: |
| 545 | 585 | #if _LIBCPP_STD_VER > 11 |
| 546 | 586 | template <typename _K2> |
| 547 | 587 | _LIBCPP_INLINE_VISIBILITY |
| 548 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type | |
| 549 | operator () ( const _K2& __x, const _CP& __y ) const | |
| 550 | {return static_cast<const _Compare&>(*this) (__x, __y.__get_value().first);} | |
| 588 | bool operator()(const _K2& __x, const _CP& __y) const | |
| 589 | {return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);} | |
| 551 | 590 | |
| 552 | 591 | template <typename _K2> |
| 553 | 592 | _LIBCPP_INLINE_VISIBILITY |
| 554 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type | |
| 555 | operator () (const _CP& __x, const _K2& __y) const | |
| 556 | {return static_cast<const _Compare&>(*this) (__x.__get_value().first, __y);} | |
| 593 | bool operator()(const _CP& __x, const _K2& __y) const | |
| 594 | {return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);} | |
| 557 | 595 | #endif |
| 558 | 596 | }; |
| 559 | 597 | |
| ... | ... | @@ -583,7 +621,7 @@ public: |
| 583 | 621 | _LIBCPP_INLINE_VISIBILITY |
| 584 | 622 | bool operator()(const _Key& __x, const _CP& __y) const |
| 585 | 623 | {return comp(__x, __y.__get_value().first);} |
| 586 | void swap(__map_value_compare&__y) | |
| 624 | void swap(__map_value_compare& __y) | |
| 587 | 625 | _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) |
| 588 | 626 | { |
| 589 | 627 | using _VSTD::swap; |
| ... | ... | @@ -593,15 +631,13 @@ public: |
| 593 | 631 | #if _LIBCPP_STD_VER > 11 |
| 594 | 632 | template <typename _K2> |
| 595 | 633 | _LIBCPP_INLINE_VISIBILITY |
| 596 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type | |
| 597 | operator () ( const _K2& __x, const _CP& __y ) const | |
| 598 | {return comp (__x, __y.__get_value().first);} | |
| 634 | bool operator()(const _K2& __x, const _CP& __y) const | |
| 635 | {return comp(__x, __y.__get_value().first);} | |
| 599 | 636 | |
| 600 | 637 | template <typename _K2> |
| 601 | 638 | _LIBCPP_INLINE_VISIBILITY |
| 602 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type | |
| 603 | operator () (const _CP& __x, const _K2& __y) const | |
| 604 | {return comp (__x.__get_value().first, __y);} | |
| 639 | bool operator()(const _CP& __x, const _K2& __y) const | |
| 640 | {return comp(__x.__get_value().first, __y);} | |
| 605 | 641 | #endif |
| 606 | 642 | }; |
| 607 | 643 | |
| ... | ... | @@ -747,10 +783,10 @@ public: |
| 747 | 783 | } |
| 748 | 784 | |
| 749 | 785 | private: |
| 750 | __value_type() _LIBCPP_EQUAL_DELETE; | |
| 751 | ~__value_type() _LIBCPP_EQUAL_DELETE; | |
| 752 | __value_type(const __value_type& __v) _LIBCPP_EQUAL_DELETE; | |
| 753 | __value_type(__value_type&& __v) _LIBCPP_EQUAL_DELETE; | |
| 786 | __value_type() = delete; | |
| 787 | ~__value_type() = delete; | |
| 788 | __value_type(const __value_type&) = delete; | |
| 789 | __value_type(__value_type&&) = delete; | |
| 754 | 790 | }; |
| 755 | 791 | |
| 756 | 792 | #else |
| ... | ... | @@ -1040,7 +1076,7 @@ public: |
| 1040 | 1076 | #ifndef _LIBCPP_CXX03_LANG |
| 1041 | 1077 | __tree_ = __m.__tree_; |
| 1042 | 1078 | #else |
| 1043 | if (this != &__m) { | |
| 1079 | if (this != _VSTD::addressof(__m)) { | |
| 1044 | 1080 | __tree_.clear(); |
| 1045 | 1081 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1046 | 1082 | __tree_.__copy_assign_alloc(__m.__tree_); |
| ... | ... | @@ -1502,29 +1538,31 @@ private: |
| 1502 | 1538 | #endif |
| 1503 | 1539 | }; |
| 1504 | 1540 | |
| 1505 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1541 | #if _LIBCPP_STD_VER >= 17 | |
| 1506 | 1542 | template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>, |
| 1507 | 1543 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 1508 | class = _EnableIf<!__is_allocator<_Compare>::value, void>, | |
| 1509 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 1544 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 1545 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | |
| 1546 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 1510 | 1547 | map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1511 | 1548 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 1512 | 1549 | |
| 1513 | 1550 | template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>, |
| 1514 | 1551 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 1515 | class = _EnableIf<!__is_allocator<_Compare>::value, void>, | |
| 1516 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 1552 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | |
| 1553 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 1517 | 1554 | map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1518 | 1555 | -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; |
| 1519 | 1556 | |
| 1520 | 1557 | template<class _InputIterator, class _Allocator, |
| 1521 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 1558 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 1559 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 1522 | 1560 | map(_InputIterator, _InputIterator, _Allocator) |
| 1523 | 1561 | -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 1524 | 1562 | less<__iter_key_type<_InputIterator>>, _Allocator>; |
| 1525 | 1563 | |
| 1526 | 1564 | template<class _Key, class _Tp, class _Allocator, |
| 1527 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 1565 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 1528 | 1566 | map(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 1529 | 1567 | -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 1530 | 1568 | #endif |
| ... | ... | @@ -1824,7 +1862,7 @@ public: |
| 1824 | 1862 | #ifndef _LIBCPP_CXX03_LANG |
| 1825 | 1863 | __tree_ = __m.__tree_; |
| 1826 | 1864 | #else |
| 1827 | if (this != &__m) { | |
| 1865 | if (this != _VSTD::addressof(__m)) { | |
| 1828 | 1866 | __tree_.clear(); |
| 1829 | 1867 | __tree_.value_comp() = __m.__tree_.value_comp(); |
| 1830 | 1868 | __tree_.__copy_assign_alloc(__m.__tree_); |
| ... | ... | @@ -2175,29 +2213,31 @@ private: |
| 2175 | 2213 | typedef unique_ptr<__node, _Dp> __node_holder; |
| 2176 | 2214 | }; |
| 2177 | 2215 | |
| 2178 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 2216 | #if _LIBCPP_STD_VER >= 17 | |
| 2179 | 2217 | template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>, |
| 2180 | 2218 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 2181 | class = _EnableIf<!__is_allocator<_Compare>::value, void>, | |
| 2182 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 2219 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 2220 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | |
| 2221 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 2183 | 2222 | multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 2184 | 2223 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>; |
| 2185 | 2224 | |
| 2186 | 2225 | template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>, |
| 2187 | 2226 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 2188 | class = _EnableIf<!__is_allocator<_Compare>::value, void>, | |
| 2189 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 2227 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | |
| 2228 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 2190 | 2229 | multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 2191 | 2230 | -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>; |
| 2192 | 2231 | |
| 2193 | 2232 | template<class _InputIterator, class _Allocator, |
| 2194 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 2233 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 2234 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 2195 | 2235 | multimap(_InputIterator, _InputIterator, _Allocator) |
| 2196 | 2236 | -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 2197 | 2237 | less<__iter_key_type<_InputIterator>>, _Allocator>; |
| 2198 | 2238 | |
| 2199 | 2239 | template<class _Key, class _Tp, class _Allocator, |
| 2200 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 2240 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 2201 | 2241 | multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 2202 | 2242 | -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>; |
| 2203 | 2243 | #endif |
lib/libcxx/include/math.h+15-15| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- math.h ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -305,9 +305,9 @@ long double truncl(long double x); |
| 305 | 305 | // back to C++ linkage before including these C++ headers. |
| 306 | 306 | extern "C++" { |
| 307 | 307 | |
| 308 | #include <limits> | |
| 308 | 309 | #include <stdlib.h> |
| 309 | 310 | #include <type_traits> |
| 310 | #include <limits> | |
| 311 | 311 | |
| 312 | 312 | // signbit |
| 313 | 313 | |
| ... | ... | @@ -831,7 +831,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long do |
| 831 | 831 | |
| 832 | 832 | template <class _A1, class _A2> |
| 833 | 833 | inline _LIBCPP_INLINE_VISIBILITY |
| 834 | typename std::_EnableIf | |
| 834 | typename std::__enable_if_t | |
| 835 | 835 | < |
| 836 | 836 | std::is_arithmetic<_A1>::value && |
| 837 | 837 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -926,7 +926,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long dou |
| 926 | 926 | |
| 927 | 927 | template <class _A1, class _A2> |
| 928 | 928 | inline _LIBCPP_INLINE_VISIBILITY |
| 929 | typename std::_EnableIf | |
| 929 | typename std::__enable_if_t | |
| 930 | 930 | < |
| 931 | 931 | std::is_arithmetic<_A1>::value && |
| 932 | 932 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1004,7 +1004,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long doub |
| 1004 | 1004 | |
| 1005 | 1005 | template <class _A1, class _A2> |
| 1006 | 1006 | inline _LIBCPP_INLINE_VISIBILITY |
| 1007 | typename std::_EnableIf | |
| 1007 | typename std::__enable_if_t | |
| 1008 | 1008 | < |
| 1009 | 1009 | std::is_arithmetic<_A1>::value && |
| 1010 | 1010 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1158,7 +1158,7 @@ template <class _A1, class _A2> |
| 1158 | 1158 | _LIBCPP_CONSTEXPR |
| 1159 | 1159 | #endif |
| 1160 | 1160 | inline _LIBCPP_INLINE_VISIBILITY |
| 1161 | typename std::_EnableIf | |
| 1161 | typename std::__enable_if_t | |
| 1162 | 1162 | < |
| 1163 | 1163 | std::is_arithmetic<_A1>::value && |
| 1164 | 1164 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1185,7 +1185,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double copysign(long double __lcpp_x, long |
| 1185 | 1185 | |
| 1186 | 1186 | template <class _A1, class _A2> |
| 1187 | 1187 | inline _LIBCPP_INLINE_VISIBILITY |
| 1188 | typename std::_EnableIf | |
| 1188 | typename std::__enable_if_t | |
| 1189 | 1189 | < |
| 1190 | 1190 | std::is_arithmetic<_A1>::value && |
| 1191 | 1191 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1242,7 +1242,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long dou |
| 1242 | 1242 | |
| 1243 | 1243 | template <class _A1, class _A2> |
| 1244 | 1244 | inline _LIBCPP_INLINE_VISIBILITY |
| 1245 | typename std::_EnableIf | |
| 1245 | typename std::__enable_if_t | |
| 1246 | 1246 | < |
| 1247 | 1247 | std::is_arithmetic<_A1>::value && |
| 1248 | 1248 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1277,7 +1277,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long doub |
| 1277 | 1277 | |
| 1278 | 1278 | template <class _A1, class _A2, class _A3> |
| 1279 | 1279 | inline _LIBCPP_INLINE_VISIBILITY |
| 1280 | typename std::_EnableIf | |
| 1280 | typename std::__enable_if_t | |
| 1281 | 1281 | < |
| 1282 | 1282 | std::is_arithmetic<_A1>::value && |
| 1283 | 1283 | std::is_arithmetic<_A2>::value && |
| ... | ... | @@ -1304,7 +1304,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long dou |
| 1304 | 1304 | |
| 1305 | 1305 | template <class _A1, class _A2> |
| 1306 | 1306 | inline _LIBCPP_INLINE_VISIBILITY |
| 1307 | typename std::_EnableIf | |
| 1307 | typename std::__enable_if_t | |
| 1308 | 1308 | < |
| 1309 | 1309 | std::is_arithmetic<_A1>::value && |
| 1310 | 1310 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1325,7 +1325,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long dou |
| 1325 | 1325 | |
| 1326 | 1326 | template <class _A1, class _A2> |
| 1327 | 1327 | inline _LIBCPP_INLINE_VISIBILITY |
| 1328 | typename std::_EnableIf | |
| 1328 | typename std::__enable_if_t | |
| 1329 | 1329 | < |
| 1330 | 1330 | std::is_arithmetic<_A1>::value && |
| 1331 | 1331 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1346,7 +1346,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long do |
| 1346 | 1346 | |
| 1347 | 1347 | template <class _A1, class _A2> |
| 1348 | 1348 | inline _LIBCPP_INLINE_VISIBILITY |
| 1349 | typename std::_EnableIf | |
| 1349 | typename std::__enable_if_t | |
| 1350 | 1350 | < |
| 1351 | 1351 | std::is_arithmetic<_A1>::value && |
| 1352 | 1352 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1553,7 +1553,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, lon |
| 1553 | 1553 | |
| 1554 | 1554 | template <class _A1, class _A2> |
| 1555 | 1555 | inline _LIBCPP_INLINE_VISIBILITY |
| 1556 | typename std::_EnableIf | |
| 1556 | typename std::__enable_if_t | |
| 1557 | 1557 | < |
| 1558 | 1558 | std::is_arithmetic<_A1>::value && |
| 1559 | 1559 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1584,7 +1584,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, lon |
| 1584 | 1584 | |
| 1585 | 1585 | template <class _A1, class _A2> |
| 1586 | 1586 | inline _LIBCPP_INLINE_VISIBILITY |
| 1587 | typename std::_EnableIf | |
| 1587 | typename std::__enable_if_t | |
| 1588 | 1588 | < |
| 1589 | 1589 | std::is_arithmetic<_A1>::value && |
| 1590 | 1590 | std::is_arithmetic<_A2>::value, |
| ... | ... | @@ -1605,7 +1605,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long d |
| 1605 | 1605 | |
| 1606 | 1606 | template <class _A1, class _A2> |
| 1607 | 1607 | inline _LIBCPP_INLINE_VISIBILITY |
| 1608 | typename std::_EnableIf | |
| 1608 | typename std::__enable_if_t | |
| 1609 | 1609 | < |
| 1610 | 1610 | std::is_arithmetic<_A1>::value && |
| 1611 | 1611 | std::is_arithmetic<_A2>::value, |
lib/libcxx/include/memory+156-23| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- memory ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -181,47 +181,190 @@ template <class InputIterator, class ForwardIterator> |
| 181 | 181 | ForwardIterator |
| 182 | 182 | uninitialized_copy(InputIterator first, InputIterator last, ForwardIterator result); |
| 183 | 183 | |
| 184 | namespace ranges { | |
| 185 | ||
| 186 | template<class InputIterator, class OutputIterator> | |
| 187 | using uninitialized_copy_result = in_out_result<InputIterator, OutputIterator>; // since C++20 | |
| 188 | ||
| 189 | template<input_iterator InputIterator, sentinel-for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel2> | |
| 190 | requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>> | |
| 191 | uninitialized_copy_result<InputIterator, OutputIterator> | |
| 192 | uninitialized_copy(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20 | |
| 193 | ||
| 194 | template<input_range InputRange, nothrow-forward-range OutputRange> | |
| 195 | requires constructible_from<range_value_t<OutputRange>, range_reference_t<InputRange>> | |
| 196 | uninitialized_copy_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>> | |
| 197 | uninitialized_copy(InputRange&& in_range, OutputRange&& out_range); // since C++20 | |
| 198 | ||
| 199 | } | |
| 200 | ||
| 184 | 201 | template <class InputIterator, class Size, class ForwardIterator> |
| 185 | 202 | ForwardIterator |
| 186 | 203 | uninitialized_copy_n(InputIterator first, Size n, ForwardIterator result); |
| 187 | 204 | |
| 205 | namespace ranges { | |
| 206 | ||
| 207 | template<class InputIterator, class OutputIterator> | |
| 208 | using uninitialized_copy_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20 | |
| 209 | ||
| 210 | template<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel> | |
| 211 | requires constructible_from<iter_value_t<OutputIterator>, iter_reference_t<InputIterator>> | |
| 212 | uninitialized_copy_n_result<InputIterator, OutputIterator> | |
| 213 | uninitialized_copy_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20 | |
| 214 | ||
| 215 | } | |
| 216 | ||
| 188 | 217 | template <class ForwardIterator, class T> |
| 189 | 218 | void uninitialized_fill(ForwardIterator first, ForwardIterator last, const T& x); |
| 190 | 219 | |
| 220 | namespace ranges { | |
| 221 | ||
| 222 | template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel, class T> | |
| 223 | requires constructible_from<iter_value_t<ForwardIterator>, const T&> | |
| 224 | ForwardIterator uninitialized_fill(ForwardIterator first, Sentinel last, const T& x); // since C++20 | |
| 225 | ||
| 226 | template <nothrow-forward-range ForwardRange, class T> | |
| 227 | requires constructible_from<range_value_t<ForwardRange>, const T&> | |
| 228 | borrowed_iterator_t<ForwardRange> uninitialized_fill(ForwardRange&& range, const T& x); // since C++20 | |
| 229 | ||
| 230 | } | |
| 231 | ||
| 191 | 232 | template <class ForwardIterator, class Size, class T> |
| 192 | 233 | ForwardIterator |
| 193 | 234 | uninitialized_fill_n(ForwardIterator first, Size n, const T& x); |
| 194 | 235 | |
| 236 | namespace ranges { | |
| 237 | ||
| 238 | template <nothrow-forward-iterator ForwardIterator, class T> | |
| 239 | requires constructible_from<iter_value_t<ForwardIterator>, const T&> | |
| 240 | ForwardIterator uninitialized_fill_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20 | |
| 241 | ||
| 242 | } | |
| 243 | ||
| 195 | 244 | template <class T, class ...Args> |
| 196 | 245 | constexpr T* construct_at(T* location, Args&& ...args); // since C++20 |
| 197 | 246 | |
| 247 | namespace ranges { | |
| 248 | template<class T, class... Args> | |
| 249 | constexpr T* construct_at(T* location, Args&&... args); // since C++20 | |
| 250 | } | |
| 251 | ||
| 198 | 252 | template <class T> |
| 199 | 253 | void destroy_at(T* location); // constexpr in C++20 |
| 200 | 254 | |
| 255 | namespace ranges { | |
| 256 | template<destructible T> | |
| 257 | constexpr void destroy_at(T* location) noexcept; // since C++20 | |
| 258 | } | |
| 259 | ||
| 201 | 260 | template <class ForwardIterator> |
| 202 | 261 | void destroy(ForwardIterator first, ForwardIterator last); // constexpr in C++20 |
| 203 | 262 | |
| 263 | namespace ranges { | |
| 264 | template<nothrow-input-iterator InputIterator, nothrow-sentinel-for<InputIterator> Sentinel> | |
| 265 | requires destructible<iter_value_t<InputIterator>> | |
| 266 | constexpr InputIterator destroy(InputIterator first, Sentinel last) noexcept; // since C++20 | |
| 267 | template<nothrow-input-range InputRange> | |
| 268 | requires destructible<range_value_t<InputRange>> | |
| 269 | constexpr borrowed_iterator_t<InputRange> destroy(InputRange&& range) noexcept; // since C++20 | |
| 270 | } | |
| 271 | ||
| 204 | 272 | template <class ForwardIterator, class Size> |
| 205 | 273 | ForwardIterator destroy_n(ForwardIterator first, Size n); // constexpr in C++20 |
| 206 | 274 | |
| 275 | namespace ranges { | |
| 276 | template<nothrow-input-iterator InputIterator> | |
| 277 | requires destructible<iter_value_t<InputIterator>> | |
| 278 | constexpr InputIterator destroy_n(InputIterator first, iter_difference_t<InputIterator> n) noexcept; // since C++20 | |
| 279 | } | |
| 280 | ||
| 207 | 281 | template <class InputIterator, class ForwardIterator> |
| 208 | 282 | ForwardIterator uninitialized_move(InputIterator first, InputIterator last, ForwardIterator result); |
| 209 | 283 | |
| 284 | namespace ranges { | |
| 285 | ||
| 286 | template<class InputIterator, class OutputIterator> | |
| 287 | using uninitialized_move_result = in_out_result<InputIterator, OutputIterator>; // since C++20 | |
| 288 | ||
| 289 | template <input_iterator InputIterator, sentinel_for<InputIterator> Sentinel1, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<O> Sentinel2> | |
| 290 | requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>> | |
| 291 | uninitialized_move_result<InputIterator, OutputIterator> | |
| 292 | uninitialized_move(InputIterator ifirst, Sentinel1 ilast, OutputIterator ofirst, Sentinel2 olast); // since C++20 | |
| 293 | ||
| 294 | template<input_range InputRange, nothrow-forward-range OutputRange> | |
| 295 | requires constructible_from<range_value_t<OutputRange>, range_rvalue_reference_t<InputRange>> | |
| 296 | uninitialized_move_result<borrowed_iterator_t<InputRange>, borrowed_iterator_t<OutputRange>> | |
| 297 | uninitialized_move(InputRange&& in_range, OutputRange&& out_range); // since C++20 | |
| 298 | ||
| 299 | } | |
| 300 | ||
| 210 | 301 | template <class InputIterator, class Size, class ForwardIterator> |
| 211 | 302 | pair<InputIterator,ForwardIterator> uninitialized_move_n(InputIterator first, Size n, ForwardIterator result); |
| 212 | 303 | |
| 304 | namespace ranges { | |
| 305 | ||
| 306 | template<class InputIterator, class OutputIterator> | |
| 307 | using uninitialized_move_n_result = in_out_result<InputIterator, OutputIterator>; // since C++20 | |
| 308 | ||
| 309 | template<input_iterator InputIterator, nothrow-forward-iterator OutputIterator, nothrow-sentinel-for<OutputIterator> Sentinel> | |
| 310 | requires constructible_from<iter_value_t<OutputIterator>, iter_rvalue_reference_t<InputIterator>> | |
| 311 | uninitialized_move_n_result<InputIterator, OutputIterator> | |
| 312 | uninitialized_move_n(InputIterator ifirst, iter_difference_t<InputIterator> n, OutputIterator ofirst, Sentinel olast); // since C++20 | |
| 313 | ||
| 314 | } | |
| 315 | ||
| 213 | 316 | template <class ForwardIterator> |
| 214 | 317 | void uninitialized_value_construct(ForwardIterator first, ForwardIterator last); |
| 215 | 318 | |
| 319 | namespace ranges { | |
| 320 | ||
| 321 | template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel> | |
| 322 | requires default_initializable<iter_value_t<ForwardIterator>> | |
| 323 | ForwardIterator uninitialized_value_construct(ForwardIterator first, Sentinel last); // since C++20 | |
| 324 | ||
| 325 | template <nothrow-forward-range ForwardRange> | |
| 326 | requires default_initializable<range_value_t<ForwardRange>> | |
| 327 | borrowed_iterator_t<ForwardRange> uninitialized_value_construct(ForwardRange&& r); // since C++20 | |
| 328 | ||
| 329 | } | |
| 330 | ||
| 216 | 331 | template <class ForwardIterator, class Size> |
| 217 | 332 | ForwardIterator uninitialized_value_construct_n(ForwardIterator first, Size n); |
| 218 | 333 | |
| 334 | namespace ranges { | |
| 335 | ||
| 336 | template <nothrow-forward-iterator ForwardIterator> | |
| 337 | requires default_initializable<iter_value_t<ForwardIterator>> | |
| 338 | ForwardIterator uninitialized_value_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20 | |
| 339 | ||
| 340 | } | |
| 341 | ||
| 219 | 342 | template <class ForwardIterator> |
| 220 | 343 | void uninitialized_default_construct(ForwardIterator first, ForwardIterator last); |
| 221 | 344 | |
| 345 | namespace ranges { | |
| 346 | ||
| 347 | template <nothrow-forward-iterator ForwardIterator, nothrow-sentinel-for<ForwardIterator> Sentinel> | |
| 348 | requires default_initializable<iter_value_t<ForwardIterator>> | |
| 349 | ForwardIterator uninitialized_default_construct(ForwardIterator first, Sentinel last); // since C++20 | |
| 350 | ||
| 351 | template <nothrow-forward-range ForwardRange> | |
| 352 | requires default_initializable<range_value_t<ForwardRange>> | |
| 353 | borrowed_iterator_t<ForwardRange> uninitialized_default_construct(ForwardRange&& r); // since C++20 | |
| 354 | ||
| 355 | } | |
| 356 | ||
| 222 | 357 | template <class ForwardIterator, class Size> |
| 223 | 358 | ForwardIterator uninitialized_default_construct_n(ForwardIterator first, Size n); |
| 224 | 359 | |
| 360 | namespace ranges { | |
| 361 | ||
| 362 | template <nothrow-forward-iterator ForwardIterator> | |
| 363 | requires default_initializable<iter_value_t<ForwardIterator>> | |
| 364 | ForwardIterator uninitialized_default_construct_n(ForwardIterator first, iter_difference_t<ForwardIterator> n); // since C++20 | |
| 365 | ||
| 366 | } | |
| 367 | ||
| 225 | 368 | template <class Y> struct auto_ptr_ref {}; // deprecated in C++11, removed in C++17 |
| 226 | 369 | |
| 227 | 370 | template<class X> |
| ... | ... | @@ -405,7 +548,8 @@ template<class T> |
| 405 | 548 | class shared_ptr |
| 406 | 549 | { |
| 407 | 550 | public: |
| 408 | typedef T element_type; | |
| 551 | typedef T element_type; // until C++17 | |
| 552 | typedef remove_extent_t<T> element_type; // since C++17 | |
| 409 | 553 | typedef weak_ptr<T> weak_type; // C++17 |
| 410 | 554 | |
| 411 | 555 | // constructors: |
| ... | ... | @@ -525,7 +669,8 @@ template<class T> |
| 525 | 669 | class weak_ptr |
| 526 | 670 | { |
| 527 | 671 | public: |
| 528 | typedef T element_type; | |
| 672 | typedef T element_type; // until C++17 | |
| 673 | typedef remove_extent_t<T> element_type; // since C++17 | |
| 529 | 674 | |
| 530 | 675 | // constructors |
| 531 | 676 | constexpr weak_ptr() noexcept; |
| ... | ... | @@ -653,14 +798,6 @@ template <class T> struct hash<shared_ptr<T> >; |
| 653 | 798 | template <class T, class Alloc> |
| 654 | 799 | inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; |
| 655 | 800 | |
| 656 | // Pointer safety | |
| 657 | enum class pointer_safety { relaxed, preferred, strict }; // since C++11 | |
| 658 | void declare_reachable(void *p); // since C++11 | |
| 659 | template <class T> T *undeclare_reachable(T *p); // since C++11 | |
| 660 | void declare_no_pointers(char *p, size_t n); // since C++11 | |
| 661 | void undeclare_no_pointers(char *p, size_t n); // since C++11 | |
| 662 | pointer_safety get_pointer_safety() noexcept; // since C++11 | |
| 663 | ||
| 664 | 801 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space); |
| 665 | 802 | |
| 666 | 803 | } // std |
| ... | ... | @@ -675,9 +812,11 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); |
| 675 | 812 | #include <__memory/allocator_arg_t.h> |
| 676 | 813 | #include <__memory/allocator_traits.h> |
| 677 | 814 | #include <__memory/compressed_pair.h> |
| 815 | #include <__memory/concepts.h> | |
| 678 | 816 | #include <__memory/construct_at.h> |
| 679 | #include <__memory/pointer_safety.h> | |
| 680 | 817 | #include <__memory/pointer_traits.h> |
| 818 | #include <__memory/ranges_construct_at.h> | |
| 819 | #include <__memory/ranges_uninitialized_algorithms.h> | |
| 681 | 820 | #include <__memory/raw_storage_iterator.h> |
| 682 | 821 | #include <__memory/shared_ptr.h> |
| 683 | 822 | #include <__memory/temporary_buffer.h> |
| ... | ... | @@ -706,10 +845,6 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); |
| 706 | 845 | #pragma GCC system_header |
| 707 | 846 | #endif |
| 708 | 847 | |
| 709 | _LIBCPP_PUSH_MACROS | |
| 710 | #include <__undef_macros> | |
| 711 | ||
| 712 | ||
| 713 | 848 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 714 | 849 | |
| 715 | 850 | template <class _Alloc, class _Ptr> |
| ... | ... | @@ -842,9 +977,9 @@ _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& |
| 842 | 977 | |
| 843 | 978 | // --- Helper for container swap -- |
| 844 | 979 | template <typename _Alloc> |
| 845 | _LIBCPP_INLINE_VISIBILITY | |
| 980 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 846 | 981 | void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) |
| 847 | #if _LIBCPP_STD_VER >= 14 | |
| 982 | #if _LIBCPP_STD_VER > 11 | |
| 848 | 983 | _NOEXCEPT |
| 849 | 984 | #else |
| 850 | 985 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) |
| ... | ... | @@ -855,13 +990,13 @@ void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) |
| 855 | 990 | } |
| 856 | 991 | |
| 857 | 992 | template <typename _Alloc> |
| 858 | inline _LIBCPP_INLINE_VISIBILITY | |
| 993 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 859 | 994 | void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} |
| 860 | 995 | |
| 861 | 996 | template <typename _Alloc> |
| 862 | inline _LIBCPP_INLINE_VISIBILITY | |
| 997 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 863 | 998 | void __swap_allocator(_Alloc & __a1, _Alloc & __a2) |
| 864 | #if _LIBCPP_STD_VER >= 14 | |
| 999 | #if _LIBCPP_STD_VER > 11 | |
| 865 | 1000 | _NOEXCEPT |
| 866 | 1001 | #else |
| 867 | 1002 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) |
| ... | ... | @@ -960,8 +1095,6 @@ struct __builtin_new_allocator { |
| 960 | 1095 | |
| 961 | 1096 | _LIBCPP_END_NAMESPACE_STD |
| 962 | 1097 | |
| 963 | _LIBCPP_POP_MACROS | |
| 964 | ||
| 965 | 1098 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
| 966 | 1099 | # include <__pstl_memory> |
| 967 | 1100 | #endif |
lib/libcxx/include/module.modulemap+266-71| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | // since __config may be included from C headers which may create an |
| 3 | 3 | // include cycle. |
| 4 | 4 | module std_config [system] [extern_c] { |
| 5 | header "__config" | |
| 5 | textual header "__config" | |
| 6 | textual header "__config_site" | |
| 6 | 7 | } |
| 7 | 8 | |
| 8 | 9 | module std [system] { |
| ... | ... | @@ -246,6 +247,9 @@ module std [system] { |
| 246 | 247 | module generate { private header "__algorithm/generate.h" } |
| 247 | 248 | module generate_n { private header "__algorithm/generate_n.h" } |
| 248 | 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" } | |
| 249 | 253 | module includes { private header "__algorithm/includes.h" } |
| 250 | 254 | module inplace_merge { private header "__algorithm/inplace_merge.h" } |
| 251 | 255 | module is_heap { private header "__algorithm/is_heap.h" } |
| ... | ... | @@ -335,6 +339,11 @@ module std [system] { |
| 335 | 339 | module bit { |
| 336 | 340 | header "bit" |
| 337 | 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 | } | |
| 338 | 347 | } |
| 339 | 348 | module bitset { |
| 340 | 349 | header "bitset" |
| ... | ... | @@ -346,10 +355,28 @@ module std [system] { |
| 346 | 355 | module charconv { |
| 347 | 356 | header "charconv" |
| 348 | 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 | ||
| 349 | 365 | } |
| 350 | 366 | module chrono { |
| 351 | 367 | header "chrono" |
| 352 | 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 | } | |
| 353 | 380 | } |
| 354 | 381 | module codecvt { |
| 355 | 382 | header "codecvt" |
| ... | ... | @@ -358,6 +385,22 @@ module std [system] { |
| 358 | 385 | module compare { |
| 359 | 386 | header "compare" |
| 360 | 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 | } | |
| 361 | 404 | } |
| 362 | 405 | module complex { |
| 363 | 406 | header "complex" |
| ... | ... | @@ -366,11 +409,49 @@ module std [system] { |
| 366 | 409 | module concepts { |
| 367 | 410 | header "concepts" |
| 368 | 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 | } | |
| 369 | 437 | } |
| 370 | 438 | module condition_variable { |
| 371 | 439 | header "condition_variable" |
| 372 | 440 | export * |
| 373 | 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 | } | |
| 374 | 455 | module deque { |
| 375 | 456 | header "deque" |
| 376 | 457 | export initializer_list |
| ... | ... | @@ -387,14 +468,52 @@ module std [system] { |
| 387 | 468 | module filesystem { |
| 388 | 469 | header "filesystem" |
| 389 | 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 | } | |
| 390 | 490 | } |
| 391 | 491 | module format { |
| 392 | 492 | header "format" |
| 393 | 493 | export * |
| 394 | 494 | |
| 395 | 495 | module __format { |
| 396 | module format_error { private header "__format/format_error.h" } | |
| 397 | module format_parse_context { private header "__format/format_parse_context.h" } | |
| 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" } | |
| 398 | 517 | } |
| 399 | 518 | } |
| 400 | 519 | module forward_list { |
| ... | ... | @@ -414,17 +533,19 @@ module std [system] { |
| 414 | 533 | module binary_function { private header "__functional/binary_function.h" } |
| 415 | 534 | module binary_negate { private header "__functional/binary_negate.h" } |
| 416 | 535 | module bind { private header "__functional/bind.h" } |
| 536 | module bind_back { private header "__functional/bind_back.h" } | |
| 417 | 537 | module bind_front { private header "__functional/bind_front.h" } |
| 418 | 538 | module binder1st { private header "__functional/binder1st.h" } |
| 419 | 539 | module binder2nd { private header "__functional/binder2nd.h" } |
| 540 | module compose { private header "__functional/compose.h" } | |
| 420 | 541 | module default_searcher { private header "__functional/default_searcher.h" } |
| 421 | 542 | module function { private header "__functional/function.h" } |
| 422 | 543 | module hash { private header "__functional/hash.h" } |
| 423 | 544 | module identity { private header "__functional/identity.h" } |
| 424 | module is_transparent { private header "__functional/is_transparent.h" } | |
| 425 | 545 | module invoke { private header "__functional/invoke.h" } |
| 426 | module mem_fn { private header "__functional/mem_fn.h" } | |
| 427 | module mem_fun_ref { private header "__functional/mem_fun_ref.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" } | |
| 428 | 549 | module not_fn { private header "__functional/not_fn.h" } |
| 429 | 550 | module operations { private header "__functional/operations.h" } |
| 430 | 551 | module perfect_forward { private header "__functional/perfect_forward.h" } |
| ... | ... | @@ -478,10 +599,7 @@ module std [system] { |
| 478 | 599 | |
| 479 | 600 | module __iterator { |
| 480 | 601 | module access { private header "__iterator/access.h" } |
| 481 | module advance { | |
| 482 | private header "__iterator/advance.h" | |
| 483 | export __function_like | |
| 484 | } | |
| 602 | module advance { private header "__iterator/advance.h" } | |
| 485 | 603 | module back_insert_iterator { private header "__iterator/back_insert_iterator.h" } |
| 486 | 604 | module common_iterator { private header "__iterator/common_iterator.h" } |
| 487 | 605 | module concepts { private header "__iterator/concepts.h" } |
| ... | ... | @@ -493,6 +611,7 @@ module std [system] { |
| 493 | 611 | module erase_if_container { private header "__iterator/erase_if_container.h" } |
| 494 | 612 | module front_insert_iterator { private header "__iterator/front_insert_iterator.h" } |
| 495 | 613 | module incrementable_traits { private header "__iterator/incrementable_traits.h" } |
| 614 | module indirectly_comparable { private header "__iterator/indirectly_comparable.h" } | |
| 496 | 615 | module insert_iterator { private header "__iterator/insert_iterator.h" } |
| 497 | 616 | module istream_iterator { private header "__iterator/istream_iterator.h" } |
| 498 | 617 | module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" } |
| ... | ... | @@ -501,21 +620,16 @@ module std [system] { |
| 501 | 620 | module iterator { private header "__iterator/iterator.h" } |
| 502 | 621 | module iterator_traits { private header "__iterator/iterator_traits.h" } |
| 503 | 622 | module move_iterator { private header "__iterator/move_iterator.h" } |
| 504 | module next { | |
| 505 | private header "__iterator/next.h" | |
| 506 | export __function_like | |
| 507 | } | |
| 623 | module next { private header "__iterator/next.h" } | |
| 508 | 624 | module ostream_iterator { private header "__iterator/ostream_iterator.h" } |
| 509 | 625 | module ostreambuf_iterator { private header "__iterator/ostreambuf_iterator.h" } |
| 510 | module prev { | |
| 511 | private header "__iterator/prev.h" | |
| 512 | export __function_like | |
| 513 | } | |
| 626 | module prev { private header "__iterator/prev.h" } | |
| 514 | 627 | module projected { private header "__iterator/projected.h" } |
| 515 | 628 | module readable_traits { private header "__iterator/readable_traits.h" } |
| 516 | 629 | module reverse_access { private header "__iterator/reverse_access.h" } |
| 517 | 630 | module reverse_iterator { private header "__iterator/reverse_iterator.h" } |
| 518 | 631 | module size { private header "__iterator/size.h" } |
| 632 | module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" } | |
| 519 | 633 | module wrap_iter { private header "__iterator/wrap_iter.h" } |
| 520 | 634 | } |
| 521 | 635 | } |
| ... | ... | @@ -547,22 +661,25 @@ module std [system] { |
| 547 | 661 | export * |
| 548 | 662 | |
| 549 | 663 | module __memory { |
| 550 | module addressof { private header "__memory/addressof.h" } | |
| 551 | module allocation_guard { private header "__memory/allocation_guard.h" } | |
| 552 | module allocator { private header "__memory/allocator.h" } | |
| 553 | module allocator_arg_t { private header "__memory/allocator_arg_t.h" } | |
| 554 | module allocator_traits { private header "__memory/allocator_traits.h" } | |
| 555 | module auto_ptr { private header "__memory/auto_ptr.h" } | |
| 556 | module compressed_pair { private header "__memory/compressed_pair.h" } | |
| 557 | module construct_at { private header "__memory/construct_at.h" } | |
| 558 | module pointer_safety { private header "__memory/pointer_safety.h" } | |
| 559 | module pointer_traits { private header "__memory/pointer_traits.h" } | |
| 560 | module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" } | |
| 561 | module shared_ptr { private header "__memory/shared_ptr.h" } | |
| 562 | module temporary_buffer { private header "__memory/temporary_buffer.h" } | |
| 563 | module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" } | |
| 564 | module unique_ptr { private header "__memory/unique_ptr.h" } | |
| 565 | module uses_allocator { private header "__memory/uses_allocator.h" } | |
| 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" } | |
| 566 | 683 | } |
| 567 | 684 | } |
| 568 | 685 | module mutex { |
| ... | ... | @@ -580,6 +697,22 @@ module std [system] { |
| 580 | 697 | module numeric { |
| 581 | 698 | header "numeric" |
| 582 | 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 | } | |
| 583 | 716 | } |
| 584 | 717 | module optional { |
| 585 | 718 | header "optional" |
| ... | ... | @@ -601,7 +734,42 @@ module std [system] { |
| 601 | 734 | export * |
| 602 | 735 | |
| 603 | 736 | module __random { |
| 604 | module uniform_int_distribution { private header "__random/uniform_int_distribution.h" } | |
| 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" } | |
| 605 | 773 | } |
| 606 | 774 | } |
| 607 | 775 | module ranges { |
| ... | ... | @@ -612,24 +780,44 @@ module std [system] { |
| 612 | 780 | export * |
| 613 | 781 | |
| 614 | 782 | module __ranges { |
| 615 | module access { private header "__ranges/access.h" } | |
| 616 | module all { private header "__ranges/all.h" } | |
| 617 | module common_view { private header "__ranges/common_view.h" } | |
| 618 | module concepts { private header "__ranges/concepts.h" } | |
| 619 | module copyable_box { private header "__ranges/copyable_box.h" } | |
| 620 | module dangling { private header "__ranges/dangling.h" } | |
| 621 | module data { private header "__ranges/data.h" } | |
| 622 | module drop_view { private header "__ranges/drop_view.h" } | |
| 623 | module empty { private header "__ranges/empty.h" } | |
| 624 | module empty_view { private header "__ranges/empty_view.h" } | |
| 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" } | |
| 625 | 801 | module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" } |
| 626 | module enable_view { private header "__ranges/enable_view.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" } | |
| 627 | 805 | module non_propagating_cache { private header "__ranges/non_propagating_cache.h" } |
| 628 | module ref_view { private header "__ranges/ref_view.h" } | |
| 629 | module size { private header "__ranges/size.h" } | |
| 630 | module subrange { private header "__ranges/subrange.h" } | |
| 631 | module transform_view { private header "__ranges/transform_view.h" } | |
| 632 | module view_interface { private header "__ranges/view_interface.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" } | |
| 633 | 821 | } |
| 634 | 822 | } |
| 635 | 823 | module ratio { |
| ... | ... | @@ -706,6 +894,11 @@ module std [system] { |
| 706 | 894 | module thread { |
| 707 | 895 | header "thread" |
| 708 | 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 | } | |
| 709 | 902 | } |
| 710 | 903 | module tuple { |
| 711 | 904 | header "tuple" |
| ... | ... | @@ -740,20 +933,22 @@ module std [system] { |
| 740 | 933 | export * |
| 741 | 934 | |
| 742 | 935 | module __utility { |
| 743 | module __decay_copy { private header "__utility/__decay_copy.h" } | |
| 744 | module as_const { private header "__utility/as_const.h" } | |
| 745 | module cmp { private header "__utility/cmp.h" } | |
| 746 | module declval { private header "__utility/declval.h" } | |
| 747 | module exchange { private header "__utility/exchange.h" } | |
| 748 | module forward { private header "__utility/forward.h" } | |
| 749 | module in_place { private header "__utility/in_place.h" } | |
| 750 | module integer_sequence { private header "__utility/integer_sequence.h" } | |
| 751 | module move { private header "__utility/move.h" } | |
| 752 | module pair { private header "__utility/pair.h" } | |
| 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" } | |
| 753 | 946 | module piecewise_construct { private header "__utility/piecewise_construct.h" } |
| 754 | module rel_ops { private header "__utility/rel_ops.h" } | |
| 755 | module swap { private header "__utility/swap.h" } | |
| 756 | module to_underlying { private header "__utility/to_underlying.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" } | |
| 757 | 952 | } |
| 758 | 953 | } |
| 759 | 954 | module valarray { |
| ... | ... | @@ -784,21 +979,21 @@ module std [system] { |
| 784 | 979 | module __availability { private header "__availability" export * } |
| 785 | 980 | module __bit_reference { private header "__bit_reference" export * } |
| 786 | 981 | module __bits { private header "__bits" export * } |
| 787 | module __debug { header "__debug" export * } | |
| 982 | module __debug { header "__debug" export * } | |
| 788 | 983 | module __errc { private header "__errc" export * } |
| 789 | module __function_like { private header "__function_like.h" export * } | |
| 790 | module __hash_table { header "__hash_table" export * } | |
| 984 | module __hash_table { header "__hash_table" export * } | |
| 791 | 985 | module __locale { private header "__locale" export * } |
| 986 | module __mbstate_t { private header "__mbstate_t.h" export * } | |
| 792 | 987 | module __mutex_base { private header "__mutex_base" export * } |
| 793 | 988 | module __node_handle { private header "__node_handle" export * } |
| 794 | module __nullptr { header "__nullptr" export * } | |
| 989 | module __nullptr { header "__nullptr" export * } | |
| 795 | 990 | module __split_buffer { private header "__split_buffer" export * } |
| 796 | 991 | module __std_stream { private header "__std_stream" export * } |
| 797 | 992 | module __string { private header "__string" export * } |
| 798 | module __threading_support { header "__threading_support" export * } | |
| 799 | module __tree { header "__tree" export * } | |
| 993 | module __threading_support { header "__threading_support" export * } | |
| 994 | module __tree { header "__tree" export * } | |
| 800 | 995 | module __tuple { private header "__tuple" export * } |
| 801 | module __undef_macros { header "__undef_macros" export * } | |
| 996 | module __undef_macros { header "__undef_macros" export * } | |
| 802 | 997 | |
| 803 | 998 | module experimental { |
| 804 | 999 | requires cplusplus11 |
lib/libcxx/include/mutex+14-21| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- mutex ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -112,7 +112,7 @@ template <class... MutexTypes> |
| 112 | 112 | class scoped_lock // C++17 |
| 113 | 113 | { |
| 114 | 114 | public: |
| 115 | using mutex_type = Mutex; // If MutexTypes... consists of the single type Mutex | |
| 115 | using mutex_type = Mutex; // Only if sizeof...(MutexTypes) == 1 | |
| 116 | 116 | |
| 117 | 117 | explicit scoped_lock(MutexTypes&... m); |
| 118 | 118 | scoped_lock(adopt_lock_t, MutexTypes&... m); |
| ... | ... | @@ -215,14 +215,12 @@ class _LIBCPP_TYPE_VIS recursive_mutex |
| 215 | 215 | __libcpp_recursive_mutex_t __m_; |
| 216 | 216 | |
| 217 | 217 | public: |
| 218 | recursive_mutex(); | |
| 219 | ~recursive_mutex(); | |
| 218 | recursive_mutex(); | |
| 219 | ~recursive_mutex(); | |
| 220 | 220 | |
| 221 | private: | |
| 222 | recursive_mutex(const recursive_mutex&); // = delete; | |
| 223 | recursive_mutex& operator=(const recursive_mutex&); // = delete; | |
| 221 | recursive_mutex(const recursive_mutex&) = delete; | |
| 222 | recursive_mutex& operator=(const recursive_mutex&) = delete; | |
| 224 | 223 | |
| 225 | public: | |
| 226 | 224 | void lock(); |
| 227 | 225 | bool try_lock() _NOEXCEPT; |
| 228 | 226 | void unlock() _NOEXCEPT; |
| ... | ... | @@ -242,9 +240,8 @@ public: |
| 242 | 240 | timed_mutex(); |
| 243 | 241 | ~timed_mutex(); |
| 244 | 242 | |
| 245 | private: | |
| 246 | timed_mutex(const timed_mutex&); // = delete; | |
| 247 | timed_mutex& operator=(const timed_mutex&); // = delete; | |
| 243 | timed_mutex(const timed_mutex&) = delete; | |
| 244 | timed_mutex& operator=(const timed_mutex&) = delete; | |
| 248 | 245 | |
| 249 | 246 | public: |
| 250 | 247 | void lock(); |
| ... | ... | @@ -283,14 +280,12 @@ class _LIBCPP_TYPE_VIS recursive_timed_mutex |
| 283 | 280 | size_t __count_; |
| 284 | 281 | __thread_id __id_; |
| 285 | 282 | public: |
| 286 | recursive_timed_mutex(); | |
| 287 | ~recursive_timed_mutex(); | |
| 283 | recursive_timed_mutex(); | |
| 284 | ~recursive_timed_mutex(); | |
| 288 | 285 | |
| 289 | private: | |
| 290 | recursive_timed_mutex(const recursive_timed_mutex&); // = delete; | |
| 291 | recursive_timed_mutex& operator=(const recursive_timed_mutex&); // = delete; | |
| 286 | recursive_timed_mutex(const recursive_timed_mutex&) = delete; | |
| 287 | recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete; | |
| 292 | 288 | |
| 293 | public: | |
| 294 | 289 | void lock(); |
| 295 | 290 | bool try_lock() _NOEXCEPT; |
| 296 | 291 | template <class _Rep, class _Period> |
| ... | ... | @@ -576,6 +571,8 @@ struct _LIBCPP_TEMPLATE_VIS once_flag |
| 576 | 571 | _LIBCPP_INLINE_VISIBILITY |
| 577 | 572 | _LIBCPP_CONSTEXPR |
| 578 | 573 | once_flag() _NOEXCEPT : __state_(0) {} |
| 574 | once_flag(const once_flag&) = delete; | |
| 575 | once_flag& operator=(const once_flag&) = delete; | |
| 579 | 576 | |
| 580 | 577 | #if defined(_LIBCPP_ABI_MICROSOFT) |
| 581 | 578 | typedef uintptr_t _State_type; |
| ... | ... | @@ -583,11 +580,7 @@ struct _LIBCPP_TEMPLATE_VIS once_flag |
| 583 | 580 | typedef unsigned long _State_type; |
| 584 | 581 | #endif |
| 585 | 582 | |
| 586 | ||
| 587 | 583 | private: |
| 588 | once_flag(const once_flag&); // = delete; | |
| 589 | once_flag& operator=(const once_flag&); // = delete; | |
| 590 | ||
| 591 | 584 | _State_type __state_; |
| 592 | 585 | |
| 593 | 586 | #ifndef _LIBCPP_CXX03_LANG |
lib/libcxx/include/new+15-10| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===----------------------------- new ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -149,6 +149,16 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT; |
| 149 | 149 | |
| 150 | 150 | _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec |
| 151 | 151 | |
| 152 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY | |
| 153 | void __throw_bad_array_new_length() | |
| 154 | { | |
| 155 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 156 | throw bad_array_new_length(); | |
| 157 | #else | |
| 158 | _VSTD::abort(); | |
| 159 | #endif | |
| 160 | } | |
| 161 | ||
| 152 | 162 | #if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && \ |
| 153 | 163 | !defined(_LIBCPP_ABI_VCRUNTIME) |
| 154 | 164 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -164,10 +174,10 @@ enum align_val_t { __zero = 0, __max = (size_t)-1 }; |
| 164 | 174 | struct destroying_delete_t { |
| 165 | 175 | explicit destroying_delete_t() = default; |
| 166 | 176 | }; |
| 167 | _LIBCPP_INLINE_VAR constexpr destroying_delete_t destroying_delete{}; | |
| 177 | inline constexpr destroying_delete_t destroying_delete{}; | |
| 168 | 178 | #endif // _LIBCPP_STD_VER > 17 |
| 169 | 179 | |
| 170 | } // std | |
| 180 | } // namespace std | |
| 171 | 181 | |
| 172 | 182 | #if defined(_LIBCPP_CXX03_LANG) |
| 173 | 183 | #define _THROW_BAD_ALLOC throw(std::bad_alloc) |
| ... | ... | @@ -332,22 +342,17 @@ void __libcpp_aligned_free(void* __ptr) { |
| 332 | 342 | |
| 333 | 343 | |
| 334 | 344 | template <class _Tp> |
| 335 | _LIBCPP_NODISCARD_AFTER_CXX17 inline | |
| 345 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI | |
| 336 | 346 | _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT |
| 337 | 347 | { |
| 338 | 348 | static_assert (!(is_function<_Tp>::value), "can't launder functions" ); |
| 339 | 349 | static_assert (!(is_same<void, typename remove_cv<_Tp>::type>::value), "can't launder cv-void" ); |
| 340 | #ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER | |
| 341 | 350 | return __builtin_launder(__p); |
| 342 | #else | |
| 343 | return __p; | |
| 344 | #endif | |
| 345 | 351 | } |
| 346 | 352 | |
| 347 | ||
| 348 | 353 | #if _LIBCPP_STD_VER > 14 |
| 349 | 354 | template <class _Tp> |
| 350 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY | |
| 355 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI | |
| 351 | 356 | constexpr _Tp* launder(_Tp* __p) noexcept |
| 352 | 357 | { |
| 353 | 358 | return _VSTD::__launder(__p); |
lib/libcxx/include/numbers+33-38| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- numbers ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -63,55 +63,52 @@ namespace std::numbers { |
| 63 | 63 | #include <type_traits> |
| 64 | 64 | #include <version> |
| 65 | 65 | |
| 66 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 66 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 67 | 67 | |
| 68 | 68 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 69 | 69 | #pragma GCC system_header |
| 70 | 70 | #endif |
| 71 | 71 | |
| 72 | _LIBCPP_PUSH_MACROS | |
| 73 | #include <__undef_macros> | |
| 74 | ||
| 75 | 72 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 76 | 73 | |
| 77 | 74 | namespace numbers { |
| 78 | 75 | |
| 79 | template <class T> | |
| 76 | template <class _Tp> | |
| 80 | 77 | inline constexpr bool __false = false; |
| 81 | 78 | |
| 82 | template <class T> | |
| 79 | template <class _Tp> | |
| 83 | 80 | struct __illformed |
| 84 | 81 | { |
| 85 | static_assert(__false<T>, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); | |
| 82 | static_assert(__false<_Tp>, "A program that instantiates a primary template of a mathematical constant variable template is ill-formed."); | |
| 86 | 83 | }; |
| 87 | 84 | |
| 88 | template <class T> inline constexpr T e_v = __illformed<T>{}; | |
| 89 | template <class T> inline constexpr T log2e_v = __illformed<T>{}; | |
| 90 | template <class T> inline constexpr T log10e_v = __illformed<T>{}; | |
| 91 | template <class T> inline constexpr T pi_v = __illformed<T>{}; | |
| 92 | template <class T> inline constexpr T inv_pi_v = __illformed<T>{}; | |
| 93 | template <class T> inline constexpr T inv_sqrtpi_v = __illformed<T>{}; | |
| 94 | template <class T> inline constexpr T ln2_v = __illformed<T>{}; | |
| 95 | template <class T> inline constexpr T ln10_v = __illformed<T>{}; | |
| 96 | template <class T> inline constexpr T sqrt2_v = __illformed<T>{}; | |
| 97 | template <class T> inline constexpr T sqrt3_v = __illformed<T>{}; | |
| 98 | template <class T> inline constexpr T inv_sqrt3_v = __illformed<T>{}; | |
| 99 | template <class T> inline constexpr T egamma_v = __illformed<T>{}; | |
| 100 | template <class T> inline constexpr T phi_v = __illformed<T>{}; | |
| 101 | ||
| 102 | template <floating_point T> inline constexpr T e_v<T> = 2.718281828459045235360287471352662; | |
| 103 | template <floating_point T> inline constexpr T log2e_v<T> = 1.442695040888963407359924681001892; | |
| 104 | template <floating_point T> inline constexpr T log10e_v<T> = 0.434294481903251827651128918916605; | |
| 105 | template <floating_point T> inline constexpr T pi_v<T> = 3.141592653589793238462643383279502; | |
| 106 | template <floating_point T> inline constexpr T inv_pi_v<T> = 0.318309886183790671537767526745028; | |
| 107 | template <floating_point T> inline constexpr T inv_sqrtpi_v<T> = 0.564189583547756286948079451560772; | |
| 108 | template <floating_point T> inline constexpr T ln2_v<T> = 0.693147180559945309417232121458176; | |
| 109 | template <floating_point T> inline constexpr T ln10_v<T> = 2.302585092994045684017991454684364; | |
| 110 | template <floating_point T> inline constexpr T sqrt2_v<T> = 1.414213562373095048801688724209698; | |
| 111 | template <floating_point T> inline constexpr T sqrt3_v<T> = 1.732050807568877293527446341505872; | |
| 112 | template <floating_point T> inline constexpr T inv_sqrt3_v<T> = 0.577350269189625764509148780501957; | |
| 113 | template <floating_point T> inline constexpr T egamma_v<T> = 0.577215664901532860606512090082402; | |
| 114 | template <floating_point T> inline constexpr T phi_v<T> = 1.618033988749894848204586834365638; | |
| 85 | template <class _Tp> inline constexpr _Tp e_v = __illformed<_Tp>{}; | |
| 86 | template <class _Tp> inline constexpr _Tp log2e_v = __illformed<_Tp>{}; | |
| 87 | template <class _Tp> inline constexpr _Tp log10e_v = __illformed<_Tp>{}; | |
| 88 | template <class _Tp> inline constexpr _Tp pi_v = __illformed<_Tp>{}; | |
| 89 | template <class _Tp> inline constexpr _Tp inv_pi_v = __illformed<_Tp>{}; | |
| 90 | template <class _Tp> inline constexpr _Tp inv_sqrtpi_v = __illformed<_Tp>{}; | |
| 91 | template <class _Tp> inline constexpr _Tp ln2_v = __illformed<_Tp>{}; | |
| 92 | template <class _Tp> inline constexpr _Tp ln10_v = __illformed<_Tp>{}; | |
| 93 | template <class _Tp> inline constexpr _Tp sqrt2_v = __illformed<_Tp>{}; | |
| 94 | template <class _Tp> inline constexpr _Tp sqrt3_v = __illformed<_Tp>{}; | |
| 95 | template <class _Tp> inline constexpr _Tp inv_sqrt3_v = __illformed<_Tp>{}; | |
| 96 | template <class _Tp> inline constexpr _Tp egamma_v = __illformed<_Tp>{}; | |
| 97 | template <class _Tp> inline constexpr _Tp phi_v = __illformed<_Tp>{}; | |
| 98 | ||
| 99 | template <floating_point _Tp> inline constexpr _Tp e_v<_Tp> = 2.718281828459045235360287471352662; | |
| 100 | template <floating_point _Tp> inline constexpr _Tp log2e_v<_Tp> = 1.442695040888963407359924681001892; | |
| 101 | template <floating_point _Tp> inline constexpr _Tp log10e_v<_Tp> = 0.434294481903251827651128918916605; | |
| 102 | template <floating_point _Tp> inline constexpr _Tp pi_v<_Tp> = 3.141592653589793238462643383279502; | |
| 103 | template <floating_point _Tp> inline constexpr _Tp inv_pi_v<_Tp> = 0.318309886183790671537767526745028; | |
| 104 | template <floating_point _Tp> inline constexpr _Tp inv_sqrtpi_v<_Tp> = 0.564189583547756286948079451560772; | |
| 105 | template <floating_point _Tp> inline constexpr _Tp ln2_v<_Tp> = 0.693147180559945309417232121458176; | |
| 106 | template <floating_point _Tp> inline constexpr _Tp ln10_v<_Tp> = 2.302585092994045684017991454684364; | |
| 107 | template <floating_point _Tp> inline constexpr _Tp sqrt2_v<_Tp> = 1.414213562373095048801688724209698; | |
| 108 | template <floating_point _Tp> inline constexpr _Tp sqrt3_v<_Tp> = 1.732050807568877293527446341505872; | |
| 109 | template <floating_point _Tp> inline constexpr _Tp inv_sqrt3_v<_Tp> = 0.577350269189625764509148780501957; | |
| 110 | template <floating_point _Tp> inline constexpr _Tp egamma_v<_Tp> = 0.577215664901532860606512090082402; | |
| 111 | template <floating_point _Tp> inline constexpr _Tp phi_v<_Tp> = 1.618033988749894848204586834365638; | |
| 115 | 112 | |
| 116 | 113 | inline constexpr double e = e_v<double>; |
| 117 | 114 | inline constexpr double log2e = log2e_v<double>; |
| ... | ... | @@ -131,8 +128,6 @@ inline constexpr double phi = phi_v<double>; |
| 131 | 128 | |
| 132 | 129 | _LIBCPP_END_NAMESPACE_STD |
| 133 | 130 | |
| 134 | _LIBCPP_POP_MACROS | |
| 135 | ||
| 136 | #endif //_LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 131 | #endif //!defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 137 | 132 | |
| 138 | 133 | #endif // _LIBCPP_NUMBERS |
lib/libcxx/include/numeric+15-476| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- numeric ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -145,490 +145,29 @@ template<class T> |
| 145 | 145 | */ |
| 146 | 146 | |
| 147 | 147 | #include <__config> |
| 148 | #include <__debug> | |
| 149 | 148 | #include <cmath> // for isnormal |
| 150 | 149 | #include <functional> |
| 151 | 150 | #include <iterator> |
| 152 | #include <limits> // for numeric_limits | |
| 153 | 151 | #include <version> |
| 154 | 152 | |
| 153 | #include <__numeric/accumulate.h> | |
| 154 | #include <__numeric/adjacent_difference.h> | |
| 155 | #include <__numeric/exclusive_scan.h> | |
| 156 | #include <__numeric/gcd_lcm.h> | |
| 157 | #include <__numeric/inclusive_scan.h> | |
| 158 | #include <__numeric/inner_product.h> | |
| 159 | #include <__numeric/iota.h> | |
| 160 | #include <__numeric/midpoint.h> | |
| 161 | #include <__numeric/partial_sum.h> | |
| 162 | #include <__numeric/reduce.h> | |
| 163 | #include <__numeric/transform_exclusive_scan.h> | |
| 164 | #include <__numeric/transform_inclusive_scan.h> | |
| 165 | #include <__numeric/transform_reduce.h> | |
| 166 | ||
| 155 | 167 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 156 | 168 | #pragma GCC system_header |
| 157 | 169 | #endif |
| 158 | 170 | |
| 159 | _LIBCPP_PUSH_MACROS | |
| 160 | #include <__undef_macros> | |
| 161 | ||
| 162 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 163 | ||
| 164 | template <class _InputIterator, class _Tp> | |
| 165 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 166 | _Tp | |
| 167 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) | |
| 168 | { | |
| 169 | for (; __first != __last; ++__first) | |
| 170 | #if _LIBCPP_STD_VER > 17 | |
| 171 | __init = _VSTD::move(__init) + *__first; | |
| 172 | #else | |
| 173 | __init = __init + *__first; | |
| 174 | #endif | |
| 175 | return __init; | |
| 176 | } | |
| 177 | ||
| 178 | template <class _InputIterator, class _Tp, class _BinaryOperation> | |
| 179 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 180 | _Tp | |
| 181 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) | |
| 182 | { | |
| 183 | for (; __first != __last; ++__first) | |
| 184 | #if _LIBCPP_STD_VER > 17 | |
| 185 | __init = __binary_op(_VSTD::move(__init), *__first); | |
| 186 | #else | |
| 187 | __init = __binary_op(__init, *__first); | |
| 188 | #endif | |
| 189 | return __init; | |
| 190 | } | |
| 191 | ||
| 192 | #if _LIBCPP_STD_VER > 14 | |
| 193 | template <class _InputIterator, class _Tp, class _BinaryOp> | |
| 194 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 195 | _Tp | |
| 196 | reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b) | |
| 197 | { | |
| 198 | for (; __first != __last; ++__first) | |
| 199 | __init = __b(__init, *__first); | |
| 200 | return __init; | |
| 201 | } | |
| 202 | ||
| 203 | template <class _InputIterator, class _Tp> | |
| 204 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 205 | _Tp | |
| 206 | reduce(_InputIterator __first, _InputIterator __last, _Tp __init) | |
| 207 | { | |
| 208 | return _VSTD::reduce(__first, __last, __init, _VSTD::plus<>()); | |
| 209 | } | |
| 210 | ||
| 211 | template <class _InputIterator> | |
| 212 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 213 | typename iterator_traits<_InputIterator>::value_type | |
| 214 | reduce(_InputIterator __first, _InputIterator __last) | |
| 215 | { | |
| 216 | return _VSTD::reduce(__first, __last, | |
| 217 | typename iterator_traits<_InputIterator>::value_type{}); | |
| 218 | } | |
| 219 | #endif | |
| 220 | ||
| 221 | template <class _InputIterator1, class _InputIterator2, class _Tp> | |
| 222 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 223 | _Tp | |
| 224 | inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) | |
| 225 | { | |
| 226 | for (; __first1 != __last1; ++__first1, (void) ++__first2) | |
| 227 | #if _LIBCPP_STD_VER > 17 | |
| 228 | __init = _VSTD::move(__init) + *__first1 * *__first2; | |
| 229 | #else | |
| 230 | __init = __init + *__first1 * *__first2; | |
| 231 | #endif | |
| 232 | return __init; | |
| 233 | } | |
| 234 | ||
| 235 | template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2> | |
| 236 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 237 | _Tp | |
| 238 | inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, | |
| 239 | _Tp __init, _BinaryOperation1 __binary_op1, _BinaryOperation2 __binary_op2) | |
| 240 | { | |
| 241 | for (; __first1 != __last1; ++__first1, (void) ++__first2) | |
| 242 | #if _LIBCPP_STD_VER > 17 | |
| 243 | __init = __binary_op1(_VSTD::move(__init), __binary_op2(*__first1, *__first2)); | |
| 244 | #else | |
| 245 | __init = __binary_op1(__init, __binary_op2(*__first1, *__first2)); | |
| 246 | #endif | |
| 247 | return __init; | |
| 248 | } | |
| 249 | ||
| 250 | #if _LIBCPP_STD_VER > 14 | |
| 251 | template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp> | |
| 252 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 253 | _Tp | |
| 254 | transform_reduce(_InputIterator __first, _InputIterator __last, | |
| 255 | _Tp __init, _BinaryOp __b, _UnaryOp __u) | |
| 256 | { | |
| 257 | for (; __first != __last; ++__first) | |
| 258 | __init = __b(__init, __u(*__first)); | |
| 259 | return __init; | |
| 260 | } | |
| 261 | ||
| 262 | template <class _InputIterator1, class _InputIterator2, | |
| 263 | class _Tp, class _BinaryOp1, class _BinaryOp2> | |
| 264 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 265 | _Tp | |
| 266 | transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 267 | _InputIterator2 __first2, _Tp __init, _BinaryOp1 __b1, _BinaryOp2 __b2) | |
| 268 | { | |
| 269 | for (; __first1 != __last1; ++__first1, (void) ++__first2) | |
| 270 | __init = __b1(__init, __b2(*__first1, *__first2)); | |
| 271 | return __init; | |
| 272 | } | |
| 273 | ||
| 274 | template <class _InputIterator1, class _InputIterator2, class _Tp> | |
| 275 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 276 | _Tp | |
| 277 | transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 278 | _InputIterator2 __first2, _Tp __init) | |
| 279 | { | |
| 280 | return _VSTD::transform_reduce(__first1, __last1, __first2, _VSTD::move(__init), | |
| 281 | _VSTD::plus<>(), _VSTD::multiplies<>()); | |
| 282 | } | |
| 283 | #endif | |
| 284 | ||
| 285 | template <class _InputIterator, class _OutputIterator> | |
| 286 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 287 | _OutputIterator | |
| 288 | partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 289 | { | |
| 290 | if (__first != __last) | |
| 291 | { | |
| 292 | typename iterator_traits<_InputIterator>::value_type __t(*__first); | |
| 293 | *__result = __t; | |
| 294 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 295 | { | |
| 296 | #if _LIBCPP_STD_VER > 17 | |
| 297 | __t = _VSTD::move(__t) + *__first; | |
| 298 | #else | |
| 299 | __t = __t + *__first; | |
| 300 | #endif | |
| 301 | *__result = __t; | |
| 302 | } | |
| 303 | } | |
| 304 | return __result; | |
| 305 | } | |
| 306 | ||
| 307 | template <class _InputIterator, class _OutputIterator, class _BinaryOperation> | |
| 308 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 309 | _OutputIterator | |
| 310 | partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result, | |
| 311 | _BinaryOperation __binary_op) | |
| 312 | { | |
| 313 | if (__first != __last) | |
| 314 | { | |
| 315 | typename iterator_traits<_InputIterator>::value_type __t(*__first); | |
| 316 | *__result = __t; | |
| 317 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 318 | { | |
| 319 | #if _LIBCPP_STD_VER > 17 | |
| 320 | __t = __binary_op(_VSTD::move(__t), *__first); | |
| 321 | #else | |
| 322 | __t = __binary_op(__t, *__first); | |
| 323 | #endif | |
| 324 | *__result = __t; | |
| 325 | } | |
| 326 | } | |
| 327 | return __result; | |
| 328 | } | |
| 329 | ||
| 330 | #if _LIBCPP_STD_VER > 14 | |
| 331 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp> | |
| 332 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 333 | _OutputIterator | |
| 334 | exclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 335 | _OutputIterator __result, _Tp __init, _BinaryOp __b) | |
| 336 | { | |
| 337 | if (__first != __last) | |
| 338 | { | |
| 339 | _Tp __tmp(__b(__init, *__first)); | |
| 340 | while (true) | |
| 341 | { | |
| 342 | *__result = _VSTD::move(__init); | |
| 343 | ++__result; | |
| 344 | ++__first; | |
| 345 | if (__first == __last) | |
| 346 | break; | |
| 347 | __init = _VSTD::move(__tmp); | |
| 348 | __tmp = __b(__init, *__first); | |
| 349 | } | |
| 350 | } | |
| 351 | return __result; | |
| 352 | } | |
| 353 | ||
| 354 | template <class _InputIterator, class _OutputIterator, class _Tp> | |
| 355 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 356 | _OutputIterator | |
| 357 | exclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 358 | _OutputIterator __result, _Tp __init) | |
| 359 | { | |
| 360 | return _VSTD::exclusive_scan(__first, __last, __result, __init, _VSTD::plus<>()); | |
| 361 | } | |
| 362 | ||
| 363 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp> | |
| 364 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 365 | _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 366 | _OutputIterator __result, _BinaryOp __b, _Tp __init) | |
| 367 | { | |
| 368 | for (; __first != __last; ++__first, (void) ++__result) { | |
| 369 | __init = __b(__init, *__first); | |
| 370 | *__result = __init; | |
| 371 | } | |
| 372 | return __result; | |
| 373 | } | |
| 374 | ||
| 375 | template <class _InputIterator, class _OutputIterator, class _BinaryOp> | |
| 376 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 377 | _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 378 | _OutputIterator __result, _BinaryOp __b) | |
| 379 | { | |
| 380 | if (__first != __last) { | |
| 381 | typename iterator_traits<_InputIterator>::value_type __init = *__first; | |
| 382 | *__result++ = __init; | |
| 383 | if (++__first != __last) | |
| 384 | return _VSTD::inclusive_scan(__first, __last, __result, __b, __init); | |
| 385 | } | |
| 386 | ||
| 387 | return __result; | |
| 388 | } | |
| 389 | ||
| 390 | template <class _InputIterator, class _OutputIterator> | |
| 391 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 392 | _OutputIterator inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 393 | _OutputIterator __result) | |
| 394 | { | |
| 395 | return _VSTD::inclusive_scan(__first, __last, __result, _VSTD::plus<>()); | |
| 396 | } | |
| 397 | ||
| 398 | template <class _InputIterator, class _OutputIterator, class _Tp, | |
| 399 | class _BinaryOp, class _UnaryOp> | |
| 400 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 401 | _OutputIterator | |
| 402 | transform_exclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 403 | _OutputIterator __result, _Tp __init, | |
| 404 | _BinaryOp __b, _UnaryOp __u) | |
| 405 | { | |
| 406 | if (__first != __last) | |
| 407 | { | |
| 408 | _Tp __saved = __init; | |
| 409 | do | |
| 410 | { | |
| 411 | __init = __b(__init, __u(*__first)); | |
| 412 | *__result = __saved; | |
| 413 | __saved = __init; | |
| 414 | ++__result; | |
| 415 | } while (++__first != __last); | |
| 416 | } | |
| 417 | return __result; | |
| 418 | } | |
| 419 | ||
| 420 | template <class _InputIterator, class _OutputIterator, class _Tp, class _BinaryOp, class _UnaryOp> | |
| 421 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 422 | _OutputIterator | |
| 423 | transform_inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 424 | _OutputIterator __result, _BinaryOp __b, _UnaryOp __u, _Tp __init) | |
| 425 | { | |
| 426 | for (; __first != __last; ++__first, (void) ++__result) { | |
| 427 | __init = __b(__init, __u(*__first)); | |
| 428 | *__result = __init; | |
| 429 | } | |
| 430 | ||
| 431 | return __result; | |
| 432 | } | |
| 433 | ||
| 434 | template <class _InputIterator, class _OutputIterator, class _BinaryOp, class _UnaryOp> | |
| 435 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 436 | _OutputIterator | |
| 437 | transform_inclusive_scan(_InputIterator __first, _InputIterator __last, | |
| 438 | _OutputIterator __result, _BinaryOp __b, _UnaryOp __u) | |
| 439 | { | |
| 440 | if (__first != __last) { | |
| 441 | typename iterator_traits<_InputIterator>::value_type __init = __u(*__first); | |
| 442 | *__result++ = __init; | |
| 443 | if (++__first != __last) | |
| 444 | return _VSTD::transform_inclusive_scan(__first, __last, __result, __b, __u, __init); | |
| 445 | } | |
| 446 | ||
| 447 | return __result; | |
| 448 | } | |
| 449 | #endif | |
| 450 | ||
| 451 | template <class _InputIterator, class _OutputIterator> | |
| 452 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 453 | _OutputIterator | |
| 454 | adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 455 | { | |
| 456 | if (__first != __last) | |
| 457 | { | |
| 458 | typename iterator_traits<_InputIterator>::value_type __acc(*__first); | |
| 459 | *__result = __acc; | |
| 460 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 461 | { | |
| 462 | typename iterator_traits<_InputIterator>::value_type __val(*__first); | |
| 463 | #if _LIBCPP_STD_VER > 17 | |
| 464 | *__result = __val - _VSTD::move(__acc); | |
| 465 | #else | |
| 466 | *__result = __val - __acc; | |
| 467 | #endif | |
| 468 | __acc = _VSTD::move(__val); | |
| 469 | } | |
| 470 | } | |
| 471 | return __result; | |
| 472 | } | |
| 473 | ||
| 474 | template <class _InputIterator, class _OutputIterator, class _BinaryOperation> | |
| 475 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 476 | _OutputIterator | |
| 477 | adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result, | |
| 478 | _BinaryOperation __binary_op) | |
| 479 | { | |
| 480 | if (__first != __last) | |
| 481 | { | |
| 482 | typename iterator_traits<_InputIterator>::value_type __acc(*__first); | |
| 483 | *__result = __acc; | |
| 484 | for (++__first, (void) ++__result; __first != __last; ++__first, (void) ++__result) | |
| 485 | { | |
| 486 | typename iterator_traits<_InputIterator>::value_type __val(*__first); | |
| 487 | #if _LIBCPP_STD_VER > 17 | |
| 488 | *__result = __binary_op(__val, _VSTD::move(__acc)); | |
| 489 | #else | |
| 490 | *__result = __binary_op(__val, __acc); | |
| 491 | #endif | |
| 492 | __acc = _VSTD::move(__val); | |
| 493 | } | |
| 494 | } | |
| 495 | return __result; | |
| 496 | } | |
| 497 | ||
| 498 | template <class _ForwardIterator, class _Tp> | |
| 499 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 500 | void | |
| 501 | iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_) | |
| 502 | { | |
| 503 | for (; __first != __last; ++__first, (void) ++__value_) | |
| 504 | *__first = __value_; | |
| 505 | } | |
| 506 | ||
| 507 | ||
| 508 | #if _LIBCPP_STD_VER > 14 | |
| 509 | template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __ct_abs; | |
| 510 | ||
| 511 | template <typename _Result, typename _Source> | |
| 512 | struct __ct_abs<_Result, _Source, true> { | |
| 513 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 514 | _Result operator()(_Source __t) const noexcept | |
| 515 | { | |
| 516 | if (__t >= 0) return __t; | |
| 517 | if (__t == numeric_limits<_Source>::min()) return -static_cast<_Result>(__t); | |
| 518 | return -__t; | |
| 519 | } | |
| 520 | }; | |
| 521 | ||
| 522 | template <typename _Result, typename _Source> | |
| 523 | struct __ct_abs<_Result, _Source, false> { | |
| 524 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 525 | _Result operator()(_Source __t) const noexcept { return __t; } | |
| 526 | }; | |
| 527 | ||
| 528 | ||
| 529 | template<class _Tp> | |
| 530 | _LIBCPP_CONSTEXPR _LIBCPP_HIDDEN | |
| 531 | _Tp __gcd(_Tp __m, _Tp __n) | |
| 532 | { | |
| 533 | static_assert((!is_signed<_Tp>::value), ""); | |
| 534 | return __n == 0 ? __m : _VSTD::__gcd<_Tp>(__n, __m % __n); | |
| 535 | } | |
| 536 | ||
| 537 | ||
| 538 | template<class _Tp, class _Up> | |
| 539 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 540 | common_type_t<_Tp,_Up> | |
| 541 | gcd(_Tp __m, _Up __n) | |
| 542 | { | |
| 543 | static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types"); | |
| 544 | static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to gcd cannot be bool" ); | |
| 545 | static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to gcd cannot be bool" ); | |
| 546 | using _Rp = common_type_t<_Tp,_Up>; | |
| 547 | using _Wp = make_unsigned_t<_Rp>; | |
| 548 | return static_cast<_Rp>(_VSTD::__gcd( | |
| 549 | static_cast<_Wp>(__ct_abs<_Rp, _Tp>()(__m)), | |
| 550 | static_cast<_Wp>(__ct_abs<_Rp, _Up>()(__n)))); | |
| 551 | } | |
| 552 | ||
| 553 | template<class _Tp, class _Up> | |
| 554 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 555 | common_type_t<_Tp,_Up> | |
| 556 | lcm(_Tp __m, _Up __n) | |
| 557 | { | |
| 558 | static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types"); | |
| 559 | static_assert((!is_same<typename remove_cv<_Tp>::type, bool>::value), "First argument to lcm cannot be bool" ); | |
| 560 | static_assert((!is_same<typename remove_cv<_Up>::type, bool>::value), "Second argument to lcm cannot be bool" ); | |
| 561 | if (__m == 0 || __n == 0) | |
| 562 | return 0; | |
| 563 | ||
| 564 | using _Rp = common_type_t<_Tp,_Up>; | |
| 565 | _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n); | |
| 566 | _Rp __val2 = __ct_abs<_Rp, _Up>()(__n); | |
| 567 | _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm"); | |
| 568 | return __val1 * __val2; | |
| 569 | } | |
| 570 | ||
| 571 | #endif /* _LIBCPP_STD_VER > 14 */ | |
| 572 | ||
| 573 | #if _LIBCPP_STD_VER > 17 | |
| 574 | template <class _Tp> | |
| 575 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 576 | enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp> | |
| 577 | midpoint(_Tp __a, _Tp __b) noexcept | |
| 578 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 579 | { | |
| 580 | using _Up = make_unsigned_t<_Tp>; | |
| 581 | constexpr _Up __bitshift = numeric_limits<_Up>::digits - 1; | |
| 582 | ||
| 583 | _Up __diff = _Up(__b) - _Up(__a); | |
| 584 | _Up __sign_bit = __b < __a; | |
| 585 | ||
| 586 | _Up __half_diff = (__diff / 2) + (__sign_bit << __bitshift) + (__sign_bit & __diff); | |
| 587 | ||
| 588 | return __a + __half_diff; | |
| 589 | } | |
| 590 | ||
| 591 | ||
| 592 | template <class _TPtr> | |
| 593 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 594 | enable_if_t<is_pointer_v<_TPtr> | |
| 595 | && is_object_v<remove_pointer_t<_TPtr>> | |
| 596 | && ! is_void_v<remove_pointer_t<_TPtr>> | |
| 597 | && (sizeof(remove_pointer_t<_TPtr>) > 0), _TPtr> | |
| 598 | midpoint(_TPtr __a, _TPtr __b) noexcept | |
| 599 | { | |
| 600 | return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a); | |
| 601 | } | |
| 602 | ||
| 603 | ||
| 604 | template <typename _Tp> | |
| 605 | constexpr int __sign(_Tp __val) { | |
| 606 | return (_Tp(0) < __val) - (__val < _Tp(0)); | |
| 607 | } | |
| 608 | ||
| 609 | template <typename _Fp> | |
| 610 | constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; } | |
| 611 | ||
| 612 | template <class _Fp> | |
| 613 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 614 | enable_if_t<is_floating_point_v<_Fp>, _Fp> | |
| 615 | midpoint(_Fp __a, _Fp __b) noexcept | |
| 616 | { | |
| 617 | constexpr _Fp __lo = numeric_limits<_Fp>::min()*2; | |
| 618 | constexpr _Fp __hi = numeric_limits<_Fp>::max()/2; | |
| 619 | return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible | |
| 620 | (__a + __b)/2 : // always correctly rounded | |
| 621 | __fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a | |
| 622 | __fp_abs(__b) < __lo ? __a/2 + __b : // not safe to halve b | |
| 623 | __a/2 + __b/2; // otherwise correctly rounded | |
| 624 | } | |
| 625 | ||
| 626 | #endif // _LIBCPP_STD_VER > 17 | |
| 627 | ||
| 628 | _LIBCPP_END_NAMESPACE_STD | |
| 629 | ||
| 630 | _LIBCPP_POP_MACROS | |
| 631 | ||
| 632 | 171 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
| 633 | 172 | # include <__pstl_numeric> |
| 634 | 173 | #endif |
lib/libcxx/include/optional+208-69| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- optional ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -132,6 +132,18 @@ namespace std { |
| 132 | 132 | template <class U> constexpr T value_or(U &&) const &; |
| 133 | 133 | template <class U> constexpr T value_or(U &&) &&; |
| 134 | 134 | |
| 135 | // [optional.monadic], monadic operations | |
| 136 | template<class F> constexpr auto and_then(F&& f) &; // since C++23 | |
| 137 | template<class F> constexpr auto and_then(F&& f) &&; // since C++23 | |
| 138 | template<class F> constexpr auto and_then(F&& f) const&; // since C++23 | |
| 139 | template<class F> constexpr auto and_then(F&& f) const&&; // since C++23 | |
| 140 | template<class F> constexpr auto transform(F&& f) &; // since C++23 | |
| 141 | template<class F> constexpr auto transform(F&& f) &&; // since C++23 | |
| 142 | template<class F> constexpr auto transform(F&& f) const&; // since C++23 | |
| 143 | template<class F> constexpr auto transform(F&& f) const&&; // since C++23 | |
| 144 | template<class F> constexpr optional or_else(F&& f) &&; // since C++23 | |
| 145 | template<class F> constexpr optional or_else(F&& f) const&; // since C++23 | |
| 146 | ||
| 135 | 147 | // 23.6.3.6, modifiers |
| 136 | 148 | void reset() noexcept; // constexpr in C++20 |
| 137 | 149 | |
| ... | ... | @@ -147,6 +159,7 @@ template<class T> |
| 147 | 159 | */ |
| 148 | 160 | |
| 149 | 161 | #include <__availability> |
| 162 | #include <__concepts/invocable.h> | |
| 150 | 163 | #include <__config> |
| 151 | 164 | #include <__debug> |
| 152 | 165 | #include <__functional_base> |
| ... | ... | @@ -163,10 +176,6 @@ template<class T> |
| 163 | 176 | #pragma GCC system_header |
| 164 | 177 | #endif |
| 165 | 178 | |
| 166 | _LIBCPP_PUSH_MACROS | |
| 167 | #include <__undef_macros> | |
| 168 | ||
| 169 | ||
| 170 | 179 | namespace std // purposefully not using versioning namespace |
| 171 | 180 | { |
| 172 | 181 | |
| ... | ... | @@ -179,7 +188,7 @@ public: |
| 179 | 188 | virtual const char* what() const _NOEXCEPT; |
| 180 | 189 | }; |
| 181 | 190 | |
| 182 | } // std | |
| 191 | } // namespace std | |
| 183 | 192 | |
| 184 | 193 | #if _LIBCPP_STD_VER > 14 |
| 185 | 194 | |
| ... | ... | @@ -202,7 +211,9 @@ struct nullopt_t |
| 202 | 211 | _LIBCPP_INLINE_VISIBILITY constexpr explicit nullopt_t(__secret_tag, __secret_tag) noexcept {} |
| 203 | 212 | }; |
| 204 | 213 | |
| 205 | _LIBCPP_INLINE_VAR constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}}; | |
| 214 | inline constexpr nullopt_t nullopt{nullopt_t::__secret_tag{}, nullopt_t::__secret_tag{}}; | |
| 215 | ||
| 216 | struct __optional_construct_from_invoke_tag {}; | |
| 206 | 217 | |
| 207 | 218 | template <class _Tp, bool = is_trivially_destructible<_Tp>::value> |
| 208 | 219 | struct __optional_destruct_base; |
| ... | ... | @@ -238,6 +249,13 @@ struct __optional_destruct_base<_Tp, false> |
| 238 | 249 | : __val_(_VSTD::forward<_Args>(__args)...), |
| 239 | 250 | __engaged_(true) {} |
| 240 | 251 | |
| 252 | #if _LIBCPP_STD_VER > 20 | |
| 253 | template <class _Fp, class... _Args> | |
| 254 | _LIBCPP_HIDE_FROM_ABI | |
| 255 | constexpr __optional_destruct_base(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) | |
| 256 | : __val_(_VSTD::invoke(_VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...)), __engaged_(true) {} | |
| 257 | #endif | |
| 258 | ||
| 241 | 259 | _LIBCPP_INLINE_VISIBILITY |
| 242 | 260 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept |
| 243 | 261 | { |
| ... | ... | @@ -273,6 +291,13 @@ struct __optional_destruct_base<_Tp, true> |
| 273 | 291 | : __val_(_VSTD::forward<_Args>(__args)...), |
| 274 | 292 | __engaged_(true) {} |
| 275 | 293 | |
| 294 | #if _LIBCPP_STD_VER > 20 | |
| 295 | template <class _Fp, class... _Args> | |
| 296 | _LIBCPP_HIDE_FROM_ABI | |
| 297 | constexpr __optional_destruct_base(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) | |
| 298 | : __val_(_VSTD::invoke(_VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...)), __engaged_(true) {} | |
| 299 | #endif | |
| 300 | ||
| 276 | 301 | _LIBCPP_INLINE_VISIBILITY |
| 277 | 302 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void reset() noexcept |
| 278 | 303 | { |
| ... | ... | @@ -586,6 +611,12 @@ using __optional_sfinae_assign_base_t = __sfinae_assign_base< |
| 586 | 611 | (is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value) |
| 587 | 612 | >; |
| 588 | 613 | |
| 614 | template<class _Tp> | |
| 615 | class optional; | |
| 616 | template <class _Tp> | |
| 617 | struct __is_std_optional : false_type {}; | |
| 618 | template <class _Tp> struct __is_std_optional<optional<_Tp>> : true_type {}; | |
| 619 | ||
| 589 | 620 | template <class _Tp> |
| 590 | 621 | class optional |
| 591 | 622 | : private __optional_move_assign_base<_Tp> |
| ... | ... | @@ -688,6 +719,7 @@ private: |
| 688 | 719 | _CheckOptionalLikeConstructor<_QualUp>, |
| 689 | 720 | __check_tuple_constructor_fail |
| 690 | 721 | >; |
| 722 | ||
| 691 | 723 | public: |
| 692 | 724 | |
| 693 | 725 | _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {} |
| ... | ... | @@ -695,7 +727,7 @@ public: |
| 695 | 727 | _LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default; |
| 696 | 728 | _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} |
| 697 | 729 | |
| 698 | template <class _InPlaceT, class... _Args, class = _EnableIf< | |
| 730 | template <class _InPlaceT, class... _Args, class = enable_if_t< | |
| 699 | 731 | _And< |
| 700 | 732 | _IsSame<_InPlaceT, in_place_t>, |
| 701 | 733 | is_constructible<value_type, _Args...> |
| ... | ... | @@ -706,21 +738,21 @@ public: |
| 706 | 738 | constexpr explicit optional(_InPlaceT, _Args&&... __args) |
| 707 | 739 | : __base(in_place, _VSTD::forward<_Args>(__args)...) {} |
| 708 | 740 | |
| 709 | template <class _Up, class... _Args, class = _EnableIf< | |
| 741 | template <class _Up, class... _Args, class = enable_if_t< | |
| 710 | 742 | is_constructible_v<value_type, initializer_list<_Up>&, _Args...>> |
| 711 | 743 | > |
| 712 | 744 | _LIBCPP_INLINE_VISIBILITY |
| 713 | 745 | constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) |
| 714 | 746 | : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} |
| 715 | 747 | |
| 716 | template <class _Up = value_type, _EnableIf< | |
| 748 | template <class _Up = value_type, enable_if_t< | |
| 717 | 749 | _CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>() |
| 718 | 750 | , int> = 0> |
| 719 | 751 | _LIBCPP_INLINE_VISIBILITY |
| 720 | 752 | constexpr optional(_Up&& __v) |
| 721 | 753 | : __base(in_place, _VSTD::forward<_Up>(__v)) {} |
| 722 | 754 | |
| 723 | template <class _Up, _EnableIf< | |
| 755 | template <class _Up, enable_if_t< | |
| 724 | 756 | _CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>() |
| 725 | 757 | , int> = 0> |
| 726 | 758 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -728,7 +760,7 @@ public: |
| 728 | 760 | : __base(in_place, _VSTD::forward<_Up>(__v)) {} |
| 729 | 761 | |
| 730 | 762 | // LWG2756: conditionally explicit conversion from const optional<_Up>& |
| 731 | template <class _Up, _EnableIf< | |
| 763 | template <class _Up, enable_if_t< | |
| 732 | 764 | _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>() |
| 733 | 765 | , int> = 0> |
| 734 | 766 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -736,7 +768,7 @@ public: |
| 736 | 768 | { |
| 737 | 769 | this->__construct_from(__v); |
| 738 | 770 | } |
| 739 | template <class _Up, _EnableIf< | |
| 771 | template <class _Up, enable_if_t< | |
| 740 | 772 | _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>() |
| 741 | 773 | , int> = 0> |
| 742 | 774 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -746,7 +778,7 @@ public: |
| 746 | 778 | } |
| 747 | 779 | |
| 748 | 780 | // LWG2756: conditionally explicit conversion from optional<_Up>&& |
| 749 | template <class _Up, _EnableIf< | |
| 781 | template <class _Up, enable_if_t< | |
| 750 | 782 | _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>() |
| 751 | 783 | , int> = 0> |
| 752 | 784 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -754,7 +786,7 @@ public: |
| 754 | 786 | { |
| 755 | 787 | this->__construct_from(_VSTD::move(__v)); |
| 756 | 788 | } |
| 757 | template <class _Up, _EnableIf< | |
| 789 | template <class _Up, enable_if_t< | |
| 758 | 790 | _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>() |
| 759 | 791 | , int> = 0> |
| 760 | 792 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -763,6 +795,14 @@ public: |
| 763 | 795 | this->__construct_from(_VSTD::move(__v)); |
| 764 | 796 | } |
| 765 | 797 | |
| 798 | #if _LIBCPP_STD_VER > 20 | |
| 799 | template<class _Fp, class... _Args> | |
| 800 | _LIBCPP_HIDE_FROM_ABI | |
| 801 | constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) | |
| 802 | : __base(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Fp>(__f), _VSTD::forward<_Args>(__args)...) { | |
| 803 | } | |
| 804 | #endif | |
| 805 | ||
| 766 | 806 | _LIBCPP_INLINE_VISIBILITY |
| 767 | 807 | _LIBCPP_CONSTEXPR_AFTER_CXX17 optional& operator=(nullopt_t) noexcept |
| 768 | 808 | { |
| ... | ... | @@ -775,7 +815,7 @@ public: |
| 775 | 815 | |
| 776 | 816 | // LWG2756 |
| 777 | 817 | template <class _Up = value_type, |
| 778 | class = _EnableIf< | |
| 818 | class = enable_if_t< | |
| 779 | 819 | _And< |
| 780 | 820 | _IsNotSame<__uncvref_t<_Up>, optional>, |
| 781 | 821 | _Or< |
| ... | ... | @@ -798,7 +838,7 @@ public: |
| 798 | 838 | } |
| 799 | 839 | |
| 800 | 840 | // LWG2756 |
| 801 | template <class _Up, _EnableIf< | |
| 841 | template <class _Up, enable_if_t< | |
| 802 | 842 | _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>() |
| 803 | 843 | , int> = 0> |
| 804 | 844 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -810,7 +850,7 @@ public: |
| 810 | 850 | } |
| 811 | 851 | |
| 812 | 852 | // LWG2756 |
| 813 | template <class _Up, _EnableIf< | |
| 853 | template <class _Up, enable_if_t< | |
| 814 | 854 | _CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>() |
| 815 | 855 | , int> = 0> |
| 816 | 856 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -822,7 +862,7 @@ public: |
| 822 | 862 | } |
| 823 | 863 | |
| 824 | 864 | template <class... _Args, |
| 825 | class = _EnableIf | |
| 865 | class = enable_if_t | |
| 826 | 866 | < |
| 827 | 867 | is_constructible_v<value_type, _Args...> |
| 828 | 868 | > |
| ... | ... | @@ -837,7 +877,7 @@ public: |
| 837 | 877 | } |
| 838 | 878 | |
| 839 | 879 | template <class _Up, class... _Args, |
| 840 | class = _EnableIf | |
| 880 | class = enable_if_t | |
| 841 | 881 | < |
| 842 | 882 | is_constructible_v<value_type, initializer_list<_Up>&, _Args...> |
| 843 | 883 | > |
| ... | ... | @@ -883,11 +923,7 @@ public: |
| 883 | 923 | operator->() const |
| 884 | 924 | { |
| 885 | 925 | _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value"); |
| 886 | #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF | |
| 887 | 926 | return _VSTD::addressof(this->__get()); |
| 888 | #else | |
| 889 | return __operator_arrow(__has_operator_addressof<value_type>{}, this->__get()); | |
| 890 | #endif | |
| 891 | 927 | } |
| 892 | 928 | |
| 893 | 929 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -896,11 +932,7 @@ public: |
| 896 | 932 | operator->() |
| 897 | 933 | { |
| 898 | 934 | _LIBCPP_ASSERT(this->has_value(), "optional operator-> called on a disengaged value"); |
| 899 | #ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF | |
| 900 | 935 | return _VSTD::addressof(this->__get()); |
| 901 | #else | |
| 902 | return __operator_arrow(__has_operator_addressof<value_type>{}, this->__get()); | |
| 903 | #endif | |
| 904 | 936 | } |
| 905 | 937 | |
| 906 | 938 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1005,35 +1037,144 @@ public: |
| 1005 | 1037 | static_cast<value_type>(_VSTD::forward<_Up>(__v)); |
| 1006 | 1038 | } |
| 1007 | 1039 | |
| 1008 | using __base::reset; | |
| 1009 | ||
| 1010 | private: | |
| 1011 | template <class _Up> | |
| 1012 | _LIBCPP_INLINE_VISIBILITY | |
| 1013 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 _Up* | |
| 1014 | __operator_arrow(true_type, _Up& __x) | |
| 1015 | { | |
| 1016 | return _VSTD::addressof(__x); | |
| 1017 | } | |
| 1040 | #if _LIBCPP_STD_VER > 20 | |
| 1041 | template<class _Func> | |
| 1042 | _LIBCPP_HIDE_FROM_ABI | |
| 1043 | constexpr auto and_then(_Func&& __f) & { | |
| 1044 | using _Up = invoke_result_t<_Func, value_type&>; | |
| 1045 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | |
| 1046 | "Result of f(value()) must be a specialization of std::optional"); | |
| 1047 | if (*this) | |
| 1048 | return _VSTD::invoke(_VSTD::forward<_Func>(__f), value()); | |
| 1049 | return remove_cvref_t<_Up>(); | |
| 1050 | } | |
| 1051 | ||
| 1052 | template<class _Func> | |
| 1053 | _LIBCPP_HIDE_FROM_ABI | |
| 1054 | constexpr auto and_then(_Func&& __f) const& { | |
| 1055 | using _Up = invoke_result_t<_Func, const value_type&>; | |
| 1056 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | |
| 1057 | "Result of f(value()) must be a specialization of std::optional"); | |
| 1058 | if (*this) | |
| 1059 | return _VSTD::invoke(_VSTD::forward<_Func>(__f), value()); | |
| 1060 | return remove_cvref_t<_Up>(); | |
| 1061 | } | |
| 1062 | ||
| 1063 | template<class _Func> | |
| 1064 | _LIBCPP_HIDE_FROM_ABI | |
| 1065 | constexpr auto and_then(_Func&& __f) && { | |
| 1066 | using _Up = invoke_result_t<_Func, value_type&&>; | |
| 1067 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | |
| 1068 | "Result of f(std::move(value())) must be a specialization of std::optional"); | |
| 1069 | if (*this) | |
| 1070 | return _VSTD::invoke(_VSTD::forward<_Func>(__f), _VSTD::move(value())); | |
| 1071 | return remove_cvref_t<_Up>(); | |
| 1072 | } | |
| 1073 | ||
| 1074 | template<class _Func> | |
| 1075 | _LIBCPP_HIDE_FROM_ABI | |
| 1076 | constexpr auto and_then(_Func&& __f) const&& { | |
| 1077 | using _Up = invoke_result_t<_Func, const value_type&&>; | |
| 1078 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, | |
| 1079 | "Result of f(std::move(value())) must be a specialization of std::optional"); | |
| 1080 | if (*this) | |
| 1081 | return _VSTD::invoke(_VSTD::forward<_Func>(__f), _VSTD::move(value())); | |
| 1082 | return remove_cvref_t<_Up>(); | |
| 1083 | } | |
| 1084 | ||
| 1085 | template<class _Func> | |
| 1086 | _LIBCPP_HIDE_FROM_ABI | |
| 1087 | constexpr auto transform(_Func&& __f) & { | |
| 1088 | 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"); | |
| 1090 | static_assert(!is_same_v<_Up, in_place_t>, | |
| 1091 | "Result of f(value()) should not be std::in_place_t"); | |
| 1092 | static_assert(!is_same_v<_Up, nullopt_t>, | |
| 1093 | "Result of f(value()) should not be std::nullopt_t"); | |
| 1094 | static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type"); | |
| 1095 | if (*this) | |
| 1096 | return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value()); | |
| 1097 | return optional<_Up>(); | |
| 1098 | } | |
| 1099 | ||
| 1100 | template<class _Func> | |
| 1101 | _LIBCPP_HIDE_FROM_ABI | |
| 1102 | constexpr auto transform(_Func&& __f) const& { | |
| 1103 | 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"); | |
| 1105 | static_assert(!is_same_v<_Up, in_place_t>, | |
| 1106 | "Result of f(value()) should not be std::in_place_t"); | |
| 1107 | static_assert(!is_same_v<_Up, nullopt_t>, | |
| 1108 | "Result of f(value()) should not be std::nullopt_t"); | |
| 1109 | static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type"); | |
| 1110 | if (*this) | |
| 1111 | return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), value()); | |
| 1112 | return optional<_Up>(); | |
| 1113 | } | |
| 1114 | ||
| 1115 | template<class _Func> | |
| 1116 | _LIBCPP_HIDE_FROM_ABI | |
| 1117 | constexpr auto transform(_Func&& __f) && { | |
| 1118 | 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"); | |
| 1120 | static_assert(!is_same_v<_Up, in_place_t>, | |
| 1121 | "Result of f(std::move(value())) should not be std::in_place_t"); | |
| 1122 | static_assert(!is_same_v<_Up, nullopt_t>, | |
| 1123 | "Result of f(std::move(value())) should not be std::nullopt_t"); | |
| 1124 | static_assert(is_object_v<_Up>, "Result of f(std::move(value())) should be an object type"); | |
| 1125 | if (*this) | |
| 1126 | return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::move(value())); | |
| 1127 | return optional<_Up>(); | |
| 1128 | } | |
| 1129 | ||
| 1130 | template<class _Func> | |
| 1131 | _LIBCPP_HIDE_FROM_ABI | |
| 1132 | constexpr auto transform(_Func&& __f) const&& { | |
| 1133 | 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"); | |
| 1135 | static_assert(!is_same_v<_Up, in_place_t>, | |
| 1136 | "Result of f(std::move(value())) should not be std::in_place_t"); | |
| 1137 | static_assert(!is_same_v<_Up, nullopt_t>, | |
| 1138 | "Result of f(std::move(value())) should not be std::nullopt_t"); | |
| 1139 | static_assert(is_object_v<_Up>, "Result of f(std::move(value())) should be an object type"); | |
| 1140 | if (*this) | |
| 1141 | return optional<_Up>(__optional_construct_from_invoke_tag{}, _VSTD::forward<_Func>(__f), _VSTD::move(value())); | |
| 1142 | return optional<_Up>(); | |
| 1143 | } | |
| 1144 | ||
| 1145 | template<invocable _Func> | |
| 1146 | _LIBCPP_HIDE_FROM_ABI | |
| 1147 | constexpr optional or_else(_Func&& __f) const& requires is_copy_constructible_v<value_type> { | |
| 1148 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, | |
| 1149 | "Result of f() should be the same type as this optional"); | |
| 1150 | if (*this) | |
| 1151 | return *this; | |
| 1152 | return _VSTD::forward<_Func>(__f)(); | |
| 1153 | } | |
| 1154 | ||
| 1155 | template<invocable _Func> | |
| 1156 | _LIBCPP_HIDE_FROM_ABI | |
| 1157 | constexpr optional or_else(_Func&& __f) && requires is_move_constructible_v<value_type> { | |
| 1158 | static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>, | |
| 1159 | "Result of f() should be the same type as this optional"); | |
| 1160 | if (*this) | |
| 1161 | return _VSTD::move(*this); | |
| 1162 | return _VSTD::forward<_Func>(__f)(); | |
| 1163 | } | |
| 1164 | #endif // _LIBCPP_STD_VER > 20 | |
| 1018 | 1165 | |
| 1019 | template <class _Up> | |
| 1020 | _LIBCPP_INLINE_VISIBILITY | |
| 1021 | static constexpr _Up* | |
| 1022 | __operator_arrow(false_type, _Up& __x) | |
| 1023 | { | |
| 1024 | return &__x; | |
| 1025 | } | |
| 1166 | using __base::reset; | |
| 1026 | 1167 | }; |
| 1027 | 1168 | |
| 1028 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1029 | template<class T> | |
| 1030 | optional(T) -> optional<T>; | |
| 1169 | #if _LIBCPP_STD_VER >= 17 | |
| 1170 | template<class _Tp> | |
| 1171 | optional(_Tp) -> optional<_Tp>; | |
| 1031 | 1172 | #endif |
| 1032 | 1173 | |
| 1033 | 1174 | // Comparisons between optionals |
| 1034 | 1175 | template <class _Tp, class _Up> |
| 1035 | 1176 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1036 | _EnableIf< | |
| 1177 | enable_if_t< | |
| 1037 | 1178 | is_convertible_v<decltype(declval<const _Tp&>() == |
| 1038 | 1179 | declval<const _Up&>()), bool>, |
| 1039 | 1180 | bool |
| ... | ... | @@ -1049,7 +1190,7 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y) |
| 1049 | 1190 | |
| 1050 | 1191 | template <class _Tp, class _Up> |
| 1051 | 1192 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1052 | _EnableIf< | |
| 1193 | enable_if_t< | |
| 1053 | 1194 | is_convertible_v<decltype(declval<const _Tp&>() != |
| 1054 | 1195 | declval<const _Up&>()), bool>, |
| 1055 | 1196 | bool |
| ... | ... | @@ -1065,7 +1206,7 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) |
| 1065 | 1206 | |
| 1066 | 1207 | template <class _Tp, class _Up> |
| 1067 | 1208 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1068 | _EnableIf< | |
| 1209 | enable_if_t< | |
| 1069 | 1210 | is_convertible_v<decltype(declval<const _Tp&>() < |
| 1070 | 1211 | declval<const _Up&>()), bool>, |
| 1071 | 1212 | bool |
| ... | ... | @@ -1081,7 +1222,7 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y) |
| 1081 | 1222 | |
| 1082 | 1223 | template <class _Tp, class _Up> |
| 1083 | 1224 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1084 | _EnableIf< | |
| 1225 | enable_if_t< | |
| 1085 | 1226 | is_convertible_v<decltype(declval<const _Tp&>() > |
| 1086 | 1227 | declval<const _Up&>()), bool>, |
| 1087 | 1228 | bool |
| ... | ... | @@ -1097,7 +1238,7 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y) |
| 1097 | 1238 | |
| 1098 | 1239 | template <class _Tp, class _Up> |
| 1099 | 1240 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1100 | _EnableIf< | |
| 1241 | enable_if_t< | |
| 1101 | 1242 | is_convertible_v<decltype(declval<const _Tp&>() <= |
| 1102 | 1243 | declval<const _Up&>()), bool>, |
| 1103 | 1244 | bool |
| ... | ... | @@ -1113,7 +1254,7 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) |
| 1113 | 1254 | |
| 1114 | 1255 | template <class _Tp, class _Up> |
| 1115 | 1256 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1116 | _EnableIf< | |
| 1257 | enable_if_t< | |
| 1117 | 1258 | is_convertible_v<decltype(declval<const _Tp&>() >= |
| 1118 | 1259 | declval<const _Up&>()), bool>, |
| 1119 | 1260 | bool |
| ... | ... | @@ -1227,7 +1368,7 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept |
| 1227 | 1368 | // Comparisons with T |
| 1228 | 1369 | template <class _Tp, class _Up> |
| 1229 | 1370 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1230 | _EnableIf< | |
| 1371 | enable_if_t< | |
| 1231 | 1372 | is_convertible_v<decltype(declval<const _Tp&>() == |
| 1232 | 1373 | declval<const _Up&>()), bool>, |
| 1233 | 1374 | bool |
| ... | ... | @@ -1239,7 +1380,7 @@ operator==(const optional<_Tp>& __x, const _Up& __v) |
| 1239 | 1380 | |
| 1240 | 1381 | template <class _Tp, class _Up> |
| 1241 | 1382 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1242 | _EnableIf< | |
| 1383 | enable_if_t< | |
| 1243 | 1384 | is_convertible_v<decltype(declval<const _Tp&>() == |
| 1244 | 1385 | declval<const _Up&>()), bool>, |
| 1245 | 1386 | bool |
| ... | ... | @@ -1251,7 +1392,7 @@ operator==(const _Tp& __v, const optional<_Up>& __x) |
| 1251 | 1392 | |
| 1252 | 1393 | template <class _Tp, class _Up> |
| 1253 | 1394 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1254 | _EnableIf< | |
| 1395 | enable_if_t< | |
| 1255 | 1396 | is_convertible_v<decltype(declval<const _Tp&>() != |
| 1256 | 1397 | declval<const _Up&>()), bool>, |
| 1257 | 1398 | bool |
| ... | ... | @@ -1263,7 +1404,7 @@ operator!=(const optional<_Tp>& __x, const _Up& __v) |
| 1263 | 1404 | |
| 1264 | 1405 | template <class _Tp, class _Up> |
| 1265 | 1406 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1266 | _EnableIf< | |
| 1407 | enable_if_t< | |
| 1267 | 1408 | is_convertible_v<decltype(declval<const _Tp&>() != |
| 1268 | 1409 | declval<const _Up&>()), bool>, |
| 1269 | 1410 | bool |
| ... | ... | @@ -1275,7 +1416,7 @@ operator!=(const _Tp& __v, const optional<_Up>& __x) |
| 1275 | 1416 | |
| 1276 | 1417 | template <class _Tp, class _Up> |
| 1277 | 1418 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1278 | _EnableIf< | |
| 1419 | enable_if_t< | |
| 1279 | 1420 | is_convertible_v<decltype(declval<const _Tp&>() < |
| 1280 | 1421 | declval<const _Up&>()), bool>, |
| 1281 | 1422 | bool |
| ... | ... | @@ -1287,7 +1428,7 @@ operator<(const optional<_Tp>& __x, const _Up& __v) |
| 1287 | 1428 | |
| 1288 | 1429 | template <class _Tp, class _Up> |
| 1289 | 1430 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1290 | _EnableIf< | |
| 1431 | enable_if_t< | |
| 1291 | 1432 | is_convertible_v<decltype(declval<const _Tp&>() < |
| 1292 | 1433 | declval<const _Up&>()), bool>, |
| 1293 | 1434 | bool |
| ... | ... | @@ -1299,7 +1440,7 @@ operator<(const _Tp& __v, const optional<_Up>& __x) |
| 1299 | 1440 | |
| 1300 | 1441 | template <class _Tp, class _Up> |
| 1301 | 1442 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1302 | _EnableIf< | |
| 1443 | enable_if_t< | |
| 1303 | 1444 | is_convertible_v<decltype(declval<const _Tp&>() <= |
| 1304 | 1445 | declval<const _Up&>()), bool>, |
| 1305 | 1446 | bool |
| ... | ... | @@ -1311,7 +1452,7 @@ operator<=(const optional<_Tp>& __x, const _Up& __v) |
| 1311 | 1452 | |
| 1312 | 1453 | template <class _Tp, class _Up> |
| 1313 | 1454 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1314 | _EnableIf< | |
| 1455 | enable_if_t< | |
| 1315 | 1456 | is_convertible_v<decltype(declval<const _Tp&>() <= |
| 1316 | 1457 | declval<const _Up&>()), bool>, |
| 1317 | 1458 | bool |
| ... | ... | @@ -1323,7 +1464,7 @@ operator<=(const _Tp& __v, const optional<_Up>& __x) |
| 1323 | 1464 | |
| 1324 | 1465 | template <class _Tp, class _Up> |
| 1325 | 1466 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1326 | _EnableIf< | |
| 1467 | enable_if_t< | |
| 1327 | 1468 | is_convertible_v<decltype(declval<const _Tp&>() > |
| 1328 | 1469 | declval<const _Up&>()), bool>, |
| 1329 | 1470 | bool |
| ... | ... | @@ -1335,7 +1476,7 @@ operator>(const optional<_Tp>& __x, const _Up& __v) |
| 1335 | 1476 | |
| 1336 | 1477 | template <class _Tp, class _Up> |
| 1337 | 1478 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1338 | _EnableIf< | |
| 1479 | enable_if_t< | |
| 1339 | 1480 | is_convertible_v<decltype(declval<const _Tp&>() > |
| 1340 | 1481 | declval<const _Up&>()), bool>, |
| 1341 | 1482 | bool |
| ... | ... | @@ -1347,7 +1488,7 @@ operator>(const _Tp& __v, const optional<_Up>& __x) |
| 1347 | 1488 | |
| 1348 | 1489 | template <class _Tp, class _Up> |
| 1349 | 1490 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1350 | _EnableIf< | |
| 1491 | enable_if_t< | |
| 1351 | 1492 | is_convertible_v<decltype(declval<const _Tp&>() >= |
| 1352 | 1493 | declval<const _Up&>()), bool>, |
| 1353 | 1494 | bool |
| ... | ... | @@ -1359,7 +1500,7 @@ operator>=(const optional<_Tp>& __x, const _Up& __v) |
| 1359 | 1500 | |
| 1360 | 1501 | template <class _Tp, class _Up> |
| 1361 | 1502 | _LIBCPP_INLINE_VISIBILITY constexpr |
| 1362 | _EnableIf< | |
| 1503 | enable_if_t< | |
| 1363 | 1504 | is_convertible_v<decltype(declval<const _Tp&>() >= |
| 1364 | 1505 | declval<const _Up&>()), bool>, |
| 1365 | 1506 | bool |
| ... | ... | @@ -1372,7 +1513,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x) |
| 1372 | 1513 | |
| 1373 | 1514 | template <class _Tp> |
| 1374 | 1515 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1375 | _EnableIf< | |
| 1516 | enable_if_t< | |
| 1376 | 1517 | is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, |
| 1377 | 1518 | void |
| 1378 | 1519 | > |
| ... | ... | @@ -1423,6 +1564,4 @@ _LIBCPP_END_NAMESPACE_STD |
| 1423 | 1564 | |
| 1424 | 1565 | #endif // _LIBCPP_STD_VER > 14 |
| 1425 | 1566 | |
| 1426 | _LIBCPP_POP_MACROS | |
| 1427 | ||
| 1428 | 1567 | #endif // _LIBCPP_OPTIONAL |
lib/libcxx/include/ostream+14-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- ostream -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -55,6 +55,7 @@ public: |
| 55 | 55 | basic_ostream& operator<<(double f); |
| 56 | 56 | basic_ostream& operator<<(long double f); |
| 57 | 57 | basic_ostream& operator<<(const void* p); |
| 58 | basic_ostream& operator<<(const volatile void* val); // C++23 | |
| 58 | 59 | basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb); |
| 59 | 60 | basic_ostream& operator<<(nullptr_t); |
| 60 | 61 | |
| ... | ... | @@ -210,6 +211,14 @@ public: |
| 210 | 211 | basic_ostream& operator<<(double __f); |
| 211 | 212 | basic_ostream& operator<<(long double __f); |
| 212 | 213 | basic_ostream& operator<<(const void* __p); |
| 214 | ||
| 215 | #if _LIBCPP_STD_VER > 20 | |
| 216 | _LIBCPP_HIDE_FROM_ABI | |
| 217 | basic_ostream& operator<<(const volatile void* __p) { | |
| 218 | return operator<<(const_cast<const void*>(__p)); | |
| 219 | } | |
| 220 | #endif | |
| 221 | ||
| 213 | 222 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); |
| 214 | 223 | |
| 215 | 224 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -240,12 +249,11 @@ class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry |
| 240 | 249 | bool __ok_; |
| 241 | 250 | basic_ostream<_CharT, _Traits>& __os_; |
| 242 | 251 | |
| 243 | sentry(const sentry&); // = delete; | |
| 244 | sentry& operator=(const sentry&); // = delete; | |
| 245 | ||
| 246 | 252 | public: |
| 247 | 253 | explicit sentry(basic_ostream<_CharT, _Traits>& __os); |
| 248 | 254 | ~sentry(); |
| 255 | sentry(const sentry&) = delete; | |
| 256 | sentry& operator=(const sentry&) = delete; | |
| 249 | 257 | |
| 250 | 258 | _LIBCPP_INLINE_VISIBILITY |
| 251 | 259 | explicit operator bool() const {return __ok_;} |
| ... | ... | @@ -1087,7 +1095,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) |
| 1087 | 1095 | } |
| 1088 | 1096 | |
| 1089 | 1097 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>) |
| 1098 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1090 | 1099 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>) |
| 1100 | #endif | |
| 1091 | 1101 | |
| 1092 | 1102 | _LIBCPP_END_NAMESPACE_STD |
| 1093 | 1103 |
lib/libcxx/include/queue+224-49| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- queue ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -41,6 +41,8 @@ public: |
| 41 | 41 | |
| 42 | 42 | explicit queue(const container_type& c); |
| 43 | 43 | explicit queue(container_type&& c) |
| 44 | template<class InputIterator> | |
| 45 | queue(InputIterator first, InputIterator last); // since C++23 | |
| 44 | 46 | template <class Alloc> |
| 45 | 47 | explicit queue(const Alloc& a); |
| 46 | 48 | template <class Alloc> |
| ... | ... | @@ -51,6 +53,8 @@ public: |
| 51 | 53 | queue(const queue& q, const Alloc& a); |
| 52 | 54 | template <class Alloc> |
| 53 | 55 | queue(queue&& q, const Alloc& a); |
| 56 | template <class InputIterator, class Alloc> | |
| 57 | queue(InputIterator first, InputIterator last, const Alloc&); // since C++23 | |
| 54 | 58 | |
| 55 | 59 | bool empty() const; |
| 56 | 60 | size_type size() const; |
| ... | ... | @@ -71,9 +75,17 @@ public: |
| 71 | 75 | template<class Container> |
| 72 | 76 | queue(Container) -> queue<typename Container::value_type, Container>; // C++17 |
| 73 | 77 | |
| 78 | template<class InputIterator> | |
| 79 | queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23 | |
| 80 | ||
| 74 | 81 | template<class Container, class Allocator> |
| 75 | 82 | queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 |
| 76 | 83 | |
| 84 | template<class InputIterator, class Allocator> | |
| 85 | queue(InputIterator, InputIterator, Allocator) | |
| 86 | -> queue<iter-value-type<InputIterator>, | |
| 87 | deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 | |
| 88 | ||
| 77 | 89 | template <class T, class Container> |
| 78 | 90 | bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); |
| 79 | 91 | |
| ... | ... | @@ -115,27 +127,39 @@ public: |
| 115 | 127 | priority_queue() : priority_queue(Compare()) {} // C++20 |
| 116 | 128 | explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} |
| 117 | 129 | priority_queue(const Compare& x, const Container&); |
| 118 | explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20 | |
| 130 | explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 | |
| 119 | 131 | priority_queue(const Compare& x, Container&&); // C++20 |
| 120 | 132 | template <class InputIterator> |
| 121 | 133 | priority_queue(InputIterator first, InputIterator last, |
| 122 | 134 | const Compare& comp = Compare()); |
| 123 | 135 | template <class InputIterator> |
| 124 | 136 | priority_queue(InputIterator first, InputIterator last, |
| 125 | const Compare& comp, const container_type& c); | |
| 137 | const Compare& comp, const Container& c); | |
| 126 | 138 | template <class InputIterator> |
| 127 | 139 | priority_queue(InputIterator first, InputIterator last, |
| 128 | const Compare& comp, container_type&& c); | |
| 140 | const Compare& comp, Container&& c); | |
| 129 | 141 | template <class Alloc> |
| 130 | 142 | explicit priority_queue(const Alloc& a); |
| 131 | 143 | template <class Alloc> |
| 132 | 144 | priority_queue(const Compare& comp, const Alloc& a); |
| 133 | 145 | template <class Alloc> |
| 134 | priority_queue(const Compare& comp, const container_type& c, | |
| 146 | priority_queue(const Compare& comp, const Container& c, | |
| 135 | 147 | const Alloc& a); |
| 136 | 148 | template <class Alloc> |
| 137 | priority_queue(const Compare& comp, container_type&& c, | |
| 149 | priority_queue(const Compare& comp, Container&& c, | |
| 138 | 150 | const Alloc& a); |
| 151 | template <class InputIterator> | |
| 152 | priority_queue(InputIterator first, InputIterator last, | |
| 153 | const Alloc& a); | |
| 154 | template <class InputIterator> | |
| 155 | priority_queue(InputIterator first, InputIterator last, | |
| 156 | const Compare& comp, const Alloc& a); | |
| 157 | template <class InputIterator> | |
| 158 | priority_queue(InputIterator first, InputIterator last, | |
| 159 | const Compare& comp, const Container& c, const Alloc& a); | |
| 160 | template <class InputIterator> | |
| 161 | priority_queue(InputIterator first, InputIterator last, | |
| 162 | const Compare& comp, Container&& c, const Alloc& a); | |
| 139 | 163 | template <class Alloc> |
| 140 | 164 | priority_queue(const priority_queue& q, const Alloc& a); |
| 141 | 165 | template <class Alloc> |
| ... | ... | @@ -160,15 +184,30 @@ priority_queue(Compare, Container) |
| 160 | 184 | -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 |
| 161 | 185 | |
| 162 | 186 | template<class InputIterator, |
| 163 | class Compare = less<typename iterator_traits<InputIterator>::value_type>, | |
| 164 | class Container = vector<typename iterator_traits<InputIterator>::value_type>> | |
| 187 | class Compare = less<iter-value-type<InputIterator>>, | |
| 188 | class Container = vector<iter-value-type<InputIterator>>> | |
| 165 | 189 | priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) |
| 166 | -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17 | |
| 190 | -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 | |
| 167 | 191 | |
| 168 | 192 | template<class Compare, class Container, class Allocator> |
| 169 | 193 | priority_queue(Compare, Container, Allocator) |
| 170 | 194 | -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 |
| 171 | 195 | |
| 196 | template<class InputIterator, class Allocator> | |
| 197 | priority_queue(InputIterator, InputIterator, Allocator) | |
| 198 | -> priority_queue<iter-value-type<InputIterator>, | |
| 199 | vector<iter-value-type<InputIterator>, Allocator>, | |
| 200 | less<iter-value-type<InputIterator>>>; // C++17 | |
| 201 | ||
| 202 | template<class InputIterator, class Compare, class Allocator> | |
| 203 | priority_queue(InputIterator, InputIterator, Compare, Allocator) | |
| 204 | -> priority_queue<iter-value-type<InputIterator>, | |
| 205 | vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 | |
| 206 | ||
| 207 | template<class InputIterator, class Compare, class Container, class Allocator> | |
| 208 | priority_queue(InputIterator, InputIterator, Compare, Container, Allocator) | |
| 209 | -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 | |
| 210 | ||
| 172 | 211 | template <class T, class Container, class Compare> |
| 173 | 212 | void swap(priority_queue<T, Container, Compare>& x, |
| 174 | 213 | priority_queue<T, Container, Compare>& y) |
| ... | ... | @@ -179,13 +218,16 @@ template <class T, class Container, class Compare> |
| 179 | 218 | */ |
| 180 | 219 | |
| 181 | 220 | #include <__config> |
| 221 | #include <__iterator/iterator_traits.h> | |
| 182 | 222 | #include <__memory/uses_allocator.h> |
| 183 | 223 | #include <__utility/forward.h> |
| 184 | 224 | #include <algorithm> |
| 185 | 225 | #include <compare> |
| 186 | 226 | #include <deque> |
| 187 | 227 | #include <functional> |
| 228 | #include <type_traits> | |
| 188 | 229 | #include <vector> |
| 230 | #include <version> | |
| 189 | 231 | |
| 190 | 232 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 191 | 233 | #pragma GCC system_header |
| ... | ... | @@ -228,6 +270,20 @@ public: |
| 228 | 270 | _LIBCPP_INLINE_VISIBILITY |
| 229 | 271 | queue(const queue& __q) : c(__q.c) {} |
| 230 | 272 | |
| 273 | #if _LIBCPP_STD_VER > 20 | |
| 274 | template <class _InputIterator, | |
| 275 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> | |
| 276 | _LIBCPP_HIDE_FROM_ABI | |
| 277 | queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} | |
| 278 | ||
| 279 | template <class _InputIterator, | |
| 280 | class _Alloc, | |
| 281 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 282 | class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> | |
| 283 | _LIBCPP_HIDE_FROM_ABI | |
| 284 | queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc) : c(__first, __second, __alloc) {} | |
| 285 | #endif | |
| 286 | ||
| 231 | 287 | _LIBCPP_INLINE_VISIBILITY |
| 232 | 288 | queue& operator=(const queue& __q) {c = __q.c; return *this;} |
| 233 | 289 | |
| ... | ... | @@ -252,28 +308,28 @@ public: |
| 252 | 308 | template <class _Alloc> |
| 253 | 309 | _LIBCPP_INLINE_VISIBILITY |
| 254 | 310 | explicit queue(const _Alloc& __a, |
| 255 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 311 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 256 | 312 | : c(__a) {} |
| 257 | 313 | template <class _Alloc> |
| 258 | 314 | _LIBCPP_INLINE_VISIBILITY |
| 259 | 315 | queue(const queue& __q, const _Alloc& __a, |
| 260 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 316 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 261 | 317 | : c(__q.c, __a) {} |
| 262 | 318 | template <class _Alloc> |
| 263 | 319 | _LIBCPP_INLINE_VISIBILITY |
| 264 | 320 | queue(const container_type& __c, const _Alloc& __a, |
| 265 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 321 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 266 | 322 | : c(__c, __a) {} |
| 267 | 323 | #ifndef _LIBCPP_CXX03_LANG |
| 268 | 324 | template <class _Alloc> |
| 269 | 325 | _LIBCPP_INLINE_VISIBILITY |
| 270 | 326 | queue(container_type&& __c, const _Alloc& __a, |
| 271 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 327 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 272 | 328 | : c(_VSTD::move(__c), __a) {} |
| 273 | 329 | template <class _Alloc> |
| 274 | 330 | _LIBCPP_INLINE_VISIBILITY |
| 275 | 331 | queue(queue&& __q, const _Alloc& __a, |
| 276 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 332 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 277 | 333 | : c(_VSTD::move(__q.c), __a) {} |
| 278 | 334 | |
| 279 | 335 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -331,22 +387,36 @@ public: |
| 331 | 387 | operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); |
| 332 | 388 | }; |
| 333 | 389 | |
| 334 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 390 | #if _LIBCPP_STD_VER > 14 | |
| 335 | 391 | template<class _Container, |
| 336 | class = _EnableIf<!__is_allocator<_Container>::value> | |
| 392 | class = enable_if_t<!__is_allocator<_Container>::value> | |
| 337 | 393 | > |
| 338 | 394 | queue(_Container) |
| 339 | 395 | -> queue<typename _Container::value_type, _Container>; |
| 340 | 396 | |
| 341 | 397 | template<class _Container, |
| 342 | 398 | class _Alloc, |
| 343 | class = _EnableIf<!__is_allocator<_Container>::value>, | |
| 344 | class = _EnableIf<uses_allocator<_Container, _Alloc>::value> | |
| 399 | class = enable_if_t<!__is_allocator<_Container>::value>, | |
| 400 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> | |
| 345 | 401 | > |
| 346 | 402 | queue(_Container, _Alloc) |
| 347 | 403 | -> queue<typename _Container::value_type, _Container>; |
| 348 | 404 | #endif |
| 349 | 405 | |
| 406 | #if _LIBCPP_STD_VER > 20 | |
| 407 | template <class _InputIterator, | |
| 408 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> | |
| 409 | queue(_InputIterator, _InputIterator) | |
| 410 | -> queue<__iter_value_type<_InputIterator>>; | |
| 411 | ||
| 412 | template <class _InputIterator, | |
| 413 | class _Alloc, | |
| 414 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 415 | class = __enable_if_t<__is_allocator<_Alloc>::value>> | |
| 416 | queue(_InputIterator, _InputIterator, _Alloc) | |
| 417 | -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | |
| 418 | #endif | |
| 419 | ||
| 350 | 420 | template <class _Tp, class _Container> |
| 351 | 421 | inline _LIBCPP_INLINE_VISIBILITY |
| 352 | 422 | bool |
| ... | ... | @@ -397,7 +467,7 @@ operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) |
| 397 | 467 | |
| 398 | 468 | template <class _Tp, class _Container> |
| 399 | 469 | inline _LIBCPP_INLINE_VISIBILITY |
| 400 | _EnableIf<__is_swappable<_Container>::value, void> | |
| 470 | __enable_if_t<__is_swappable<_Container>::value, void> | |
| 401 | 471 | swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) |
| 402 | 472 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 403 | 473 | { |
| ... | ... | @@ -464,16 +534,16 @@ public: |
| 464 | 534 | _LIBCPP_INLINE_VISIBILITY |
| 465 | 535 | priority_queue(const value_compare& __comp, container_type&& __c); |
| 466 | 536 | #endif |
| 467 | template <class _InputIter> | |
| 537 | template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 468 | 538 | _LIBCPP_INLINE_VISIBILITY |
| 469 | 539 | priority_queue(_InputIter __f, _InputIter __l, |
| 470 | 540 | const value_compare& __comp = value_compare()); |
| 471 | template <class _InputIter> | |
| 541 | template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 472 | 542 | _LIBCPP_INLINE_VISIBILITY |
| 473 | 543 | priority_queue(_InputIter __f, _InputIter __l, |
| 474 | 544 | const value_compare& __comp, const container_type& __c); |
| 475 | 545 | #ifndef _LIBCPP_CXX03_LANG |
| 476 | template <class _InputIter> | |
| 546 | template <class _InputIter, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 477 | 547 | _LIBCPP_INLINE_VISIBILITY |
| 478 | 548 | priority_queue(_InputIter __f, _InputIter __l, |
| 479 | 549 | const value_compare& __comp, container_type&& __c); |
| ... | ... | @@ -481,32 +551,57 @@ public: |
| 481 | 551 | template <class _Alloc> |
| 482 | 552 | _LIBCPP_INLINE_VISIBILITY |
| 483 | 553 | explicit priority_queue(const _Alloc& __a, |
| 484 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 554 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 485 | 555 | template <class _Alloc> |
| 486 | 556 | _LIBCPP_INLINE_VISIBILITY |
| 487 | 557 | priority_queue(const value_compare& __comp, const _Alloc& __a, |
| 488 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 558 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 489 | 559 | template <class _Alloc> |
| 490 | 560 | _LIBCPP_INLINE_VISIBILITY |
| 491 | 561 | priority_queue(const value_compare& __comp, const container_type& __c, |
| 492 | 562 | const _Alloc& __a, |
| 493 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 563 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 494 | 564 | template <class _Alloc> |
| 495 | 565 | _LIBCPP_INLINE_VISIBILITY |
| 496 | 566 | priority_queue(const priority_queue& __q, const _Alloc& __a, |
| 497 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 567 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 498 | 568 | #ifndef _LIBCPP_CXX03_LANG |
| 499 | 569 | template <class _Alloc> |
| 500 | 570 | _LIBCPP_INLINE_VISIBILITY |
| 501 | 571 | priority_queue(const value_compare& __comp, container_type&& __c, |
| 502 | 572 | const _Alloc& __a, |
| 503 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 573 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 504 | 574 | template <class _Alloc> |
| 505 | 575 | _LIBCPP_INLINE_VISIBILITY |
| 506 | 576 | priority_queue(priority_queue&& __q, const _Alloc& __a, |
| 507 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 577 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 508 | 578 | #endif // _LIBCPP_CXX03_LANG |
| 509 | 579 | |
| 580 | template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 581 | _LIBCPP_INLINE_VISIBILITY | |
| 582 | priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, | |
| 583 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 584 | ||
| 585 | template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 586 | _LIBCPP_INLINE_VISIBILITY | |
| 587 | priority_queue(_InputIter __f, _InputIter __l, | |
| 588 | const value_compare& __comp, const _Alloc& __a, | |
| 589 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 590 | ||
| 591 | template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 592 | _LIBCPP_INLINE_VISIBILITY | |
| 593 | priority_queue(_InputIter __f, _InputIter __l, | |
| 594 | const value_compare& __comp, const container_type& __c, const _Alloc& __a, | |
| 595 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 596 | ||
| 597 | #ifndef _LIBCPP_CXX03_LANG | |
| 598 | template <class _InputIter, class _Alloc, class = __enable_if_t<__is_cpp17_input_iterator<_InputIter>::value> > | |
| 599 | _LIBCPP_INLINE_VISIBILITY | |
| 600 | priority_queue(_InputIter __f, _InputIter __l, | |
| 601 | const value_compare& __comp, container_type&& __c, const _Alloc& __a, | |
| 602 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0); | |
| 603 | #endif // _LIBCPP_CXX03_LANG | |
| 604 | ||
| 510 | 605 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 511 | 606 | bool empty() const {return c.empty();} |
| 512 | 607 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -532,11 +627,11 @@ public: |
| 532 | 627 | __is_nothrow_swappable<value_compare>::value); |
| 533 | 628 | }; |
| 534 | 629 | |
| 535 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 630 | #if _LIBCPP_STD_VER >= 17 | |
| 536 | 631 | template <class _Compare, |
| 537 | 632 | class _Container, |
| 538 | class = _EnableIf<!__is_allocator<_Compare>::value>, | |
| 539 | class = _EnableIf<!__is_allocator<_Container>::value> | |
| 633 | class = enable_if_t<!__is_allocator<_Compare>::value>, | |
| 634 | class = enable_if_t<!__is_allocator<_Container>::value> | |
| 540 | 635 | > |
| 541 | 636 | priority_queue(_Compare, _Container) |
| 542 | 637 | -> priority_queue<typename _Container::value_type, _Container, _Compare>; |
| ... | ... | @@ -544,9 +639,9 @@ priority_queue(_Compare, _Container) |
| 544 | 639 | template<class _InputIterator, |
| 545 | 640 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 546 | 641 | class _Container = vector<__iter_value_type<_InputIterator>>, |
| 547 | class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 548 | class = _EnableIf<!__is_allocator<_Compare>::value>, | |
| 549 | class = _EnableIf<!__is_allocator<_Container>::value> | |
| 642 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 643 | class = enable_if_t<!__is_allocator<_Compare>::value>, | |
| 644 | class = enable_if_t<!__is_allocator<_Container>::value> | |
| 550 | 645 | > |
| 551 | 646 | priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) |
| 552 | 647 | -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; |
| ... | ... | @@ -554,12 +649,39 @@ priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container |
| 554 | 649 | template<class _Compare, |
| 555 | 650 | class _Container, |
| 556 | 651 | class _Alloc, |
| 557 | class = _EnableIf<!__is_allocator<_Compare>::value>, | |
| 558 | class = _EnableIf<!__is_allocator<_Container>::value>, | |
| 559 | class = _EnableIf<uses_allocator<_Container, _Alloc>::value> | |
| 652 | class = enable_if_t<!__is_allocator<_Compare>::value>, | |
| 653 | class = enable_if_t<!__is_allocator<_Container>::value>, | |
| 654 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> | |
| 560 | 655 | > |
| 561 | 656 | priority_queue(_Compare, _Container, _Alloc) |
| 562 | 657 | -> priority_queue<typename _Container::value_type, _Container, _Compare>; |
| 658 | ||
| 659 | template<class _InputIterator, class _Allocator, | |
| 660 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 661 | class = enable_if_t<__is_allocator<_Allocator>::value> | |
| 662 | > | |
| 663 | priority_queue(_InputIterator, _InputIterator, _Allocator) | |
| 664 | -> priority_queue<__iter_value_type<_InputIterator>, | |
| 665 | vector<__iter_value_type<_InputIterator>, _Allocator>, | |
| 666 | less<__iter_value_type<_InputIterator>>>; | |
| 667 | ||
| 668 | template<class _InputIterator, class _Compare, class _Allocator, | |
| 669 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 670 | class = enable_if_t<!__is_allocator<_Compare>::value>, | |
| 671 | class = enable_if_t<__is_allocator<_Allocator>::value> | |
| 672 | > | |
| 673 | priority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) | |
| 674 | -> priority_queue<__iter_value_type<_InputIterator>, | |
| 675 | vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; | |
| 676 | ||
| 677 | template<class _InputIterator, class _Compare, class _Container, class _Alloc, | |
| 678 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 679 | class = enable_if_t<!__is_allocator<_Compare>::value>, | |
| 680 | class = enable_if_t<!__is_allocator<_Container>::value>, | |
| 681 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> | |
| 682 | > | |
| 683 | priority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) | |
| 684 | -> priority_queue<typename _Container::value_type, _Container, _Compare>; | |
| 563 | 685 | #endif |
| 564 | 686 | |
| 565 | 687 | template <class _Tp, class _Container, class _Compare> |
| ... | ... | @@ -587,7 +709,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& _ |
| 587 | 709 | #endif // _LIBCPP_CXX03_LANG |
| 588 | 710 | |
| 589 | 711 | template <class _Tp, class _Container, class _Compare> |
| 590 | template <class _InputIter> | |
| 712 | template <class _InputIter, class> | |
| 591 | 713 | inline |
| 592 | 714 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 593 | 715 | const value_compare& __comp) |
| ... | ... | @@ -598,7 +720,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input |
| 598 | 720 | } |
| 599 | 721 | |
| 600 | 722 | template <class _Tp, class _Container, class _Compare> |
| 601 | template <class _InputIter> | |
| 723 | template <class _InputIter, class> | |
| 602 | 724 | inline |
| 603 | 725 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 604 | 726 | const value_compare& __comp, |
| ... | ... | @@ -613,7 +735,7 @@ priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _Input |
| 613 | 735 | #ifndef _LIBCPP_CXX03_LANG |
| 614 | 736 | |
| 615 | 737 | template <class _Tp, class _Container, class _Compare> |
| 616 | template <class _InputIter> | |
| 738 | template <class _InputIter, class> | |
| 617 | 739 | inline |
| 618 | 740 | priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, |
| 619 | 741 | const value_compare& __comp, |
| ... | ... | @@ -631,7 +753,7 @@ template <class _Tp, class _Container, class _Compare> |
| 631 | 753 | template <class _Alloc> |
| 632 | 754 | inline |
| 633 | 755 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, |
| 634 | _EnableIf<uses_allocator<container_type, _Alloc>::value>*) | |
| 756 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 635 | 757 | : c(__a) |
| 636 | 758 | { |
| 637 | 759 | } |
| ... | ... | @@ -641,7 +763,7 @@ template <class _Alloc> |
| 641 | 763 | inline |
| 642 | 764 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 643 | 765 | const _Alloc& __a, |
| 644 | _EnableIf<uses_allocator<container_type, _Alloc>::value>*) | |
| 766 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 645 | 767 | : c(__a), |
| 646 | 768 | comp(__comp) |
| 647 | 769 | { |
| ... | ... | @@ -653,7 +775,7 @@ inline |
| 653 | 775 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 654 | 776 | const container_type& __c, |
| 655 | 777 | const _Alloc& __a, |
| 656 | _EnableIf<uses_allocator<container_type, _Alloc>::value>*) | |
| 778 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 657 | 779 | : c(__c, __a), |
| 658 | 780 | comp(__comp) |
| 659 | 781 | { |
| ... | ... | @@ -665,11 +787,10 @@ template <class _Alloc> |
| 665 | 787 | inline |
| 666 | 788 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, |
| 667 | 789 | const _Alloc& __a, |
| 668 | _EnableIf<uses_allocator<container_type, _Alloc>::value>*) | |
| 790 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 669 | 791 | : c(__q.c, __a), |
| 670 | 792 | comp(__q.comp) |
| 671 | 793 | { |
| 672 | _VSTD::make_heap(c.begin(), c.end(), comp); | |
| 673 | 794 | } |
| 674 | 795 | |
| 675 | 796 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -680,7 +801,7 @@ inline |
| 680 | 801 | priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, |
| 681 | 802 | container_type&& __c, |
| 682 | 803 | const _Alloc& __a, |
| 683 | _EnableIf<uses_allocator<container_type, _Alloc>::value>*) | |
| 804 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 684 | 805 | : c(_VSTD::move(__c), __a), |
| 685 | 806 | comp(__comp) |
| 686 | 807 | { |
| ... | ... | @@ -692,14 +813,68 @@ template <class _Alloc> |
| 692 | 813 | inline |
| 693 | 814 | priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, |
| 694 | 815 | const _Alloc& __a, |
| 695 | _EnableIf<uses_allocator<container_type, _Alloc>::value>*) | |
| 816 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 696 | 817 | : c(_VSTD::move(__q.c), __a), |
| 697 | 818 | comp(_VSTD::move(__q.comp)) |
| 819 | { | |
| 820 | } | |
| 821 | ||
| 822 | #endif // _LIBCPP_CXX03_LANG | |
| 823 | ||
| 824 | template <class _Tp, class _Container, class _Compare> | |
| 825 | template <class _InputIter, class _Alloc, class> | |
| 826 | inline | |
| 827 | priority_queue<_Tp, _Container, _Compare>::priority_queue( | |
| 828 | _InputIter __f, _InputIter __l, const _Alloc& __a, | |
| 829 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 830 | : c(__f, __l, __a), | |
| 831 | comp() | |
| 698 | 832 | { |
| 699 | 833 | _VSTD::make_heap(c.begin(), c.end(), comp); |
| 700 | 834 | } |
| 701 | 835 | |
| 702 | #endif // _LIBCPP_CXX03_LANG | |
| 836 | template <class _Tp, class _Container, class _Compare> | |
| 837 | template <class _InputIter, class _Alloc, class> | |
| 838 | inline | |
| 839 | priority_queue<_Tp, _Container, _Compare>::priority_queue( | |
| 840 | _InputIter __f, _InputIter __l, | |
| 841 | const value_compare& __comp, const _Alloc& __a, | |
| 842 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 843 | : c(__f, __l, __a), | |
| 844 | comp(__comp) | |
| 845 | { | |
| 846 | _VSTD::make_heap(c.begin(), c.end(), comp); | |
| 847 | } | |
| 848 | ||
| 849 | template <class _Tp, class _Container, class _Compare> | |
| 850 | template <class _InputIter, class _Alloc, class> | |
| 851 | inline | |
| 852 | priority_queue<_Tp, _Container, _Compare>::priority_queue( | |
| 853 | _InputIter __f, _InputIter __l, | |
| 854 | const value_compare& __comp, const container_type& __c, const _Alloc& __a, | |
| 855 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 856 | : c(__c, __a), | |
| 857 | comp(__comp) | |
| 858 | { | |
| 859 | c.insert(c.end(), __f, __l); | |
| 860 | _VSTD::make_heap(c.begin(), c.end(), comp); | |
| 861 | } | |
| 862 | ||
| 863 | #ifndef _LIBCPP_CXX03_LANG | |
| 864 | template <class _Tp, class _Container, class _Compare> | |
| 865 | template <class _InputIter, class _Alloc, class> | |
| 866 | inline | |
| 867 | priority_queue<_Tp, _Container, _Compare>::priority_queue( | |
| 868 | _InputIter __f, _InputIter __l, const value_compare& __comp, | |
| 869 | container_type&& __c, const _Alloc& __a, | |
| 870 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>*) | |
| 871 | : c(_VSTD::move(__c), __a), | |
| 872 | comp(__comp) | |
| 873 | { | |
| 874 | c.insert(c.end(), __f, __l); | |
| 875 | _VSTD::make_heap(c.begin(), c.end(), comp); | |
| 876 | } | |
| 877 | #endif // _LIBCPP_CXX03_LANG | |
| 703 | 878 | |
| 704 | 879 | template <class _Tp, class _Container, class _Compare> |
| 705 | 880 | inline |
| ... | ... | @@ -756,7 +931,7 @@ priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) |
| 756 | 931 | |
| 757 | 932 | template <class _Tp, class _Container, class _Compare> |
| 758 | 933 | inline _LIBCPP_INLINE_VISIBILITY |
| 759 | _EnableIf< | |
| 934 | __enable_if_t< | |
| 760 | 935 | __is_swappable<_Container>::value && __is_swappable<_Compare>::value, |
| 761 | 936 | void |
| 762 | 937 | > |
lib/libcxx/include/random+48-5320| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- random -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -1678,5330 +1678,58 @@ class piecewise_linear_distribution |
| 1678 | 1678 | */ |
| 1679 | 1679 | |
| 1680 | 1680 | #include <__config> |
| 1681 | #include <__random/bernoulli_distribution.h> | |
| 1682 | #include <__random/binomial_distribution.h> | |
| 1683 | #include <__random/cauchy_distribution.h> | |
| 1684 | #include <__random/chi_squared_distribution.h> | |
| 1685 | #include <__random/clamp_to_integral.h> | |
| 1686 | #include <__random/default_random_engine.h> | |
| 1687 | #include <__random/discard_block_engine.h> | |
| 1688 | #include <__random/discrete_distribution.h> | |
| 1689 | #include <__random/exponential_distribution.h> | |
| 1690 | #include <__random/extreme_value_distribution.h> | |
| 1691 | #include <__random/fisher_f_distribution.h> | |
| 1692 | #include <__random/gamma_distribution.h> | |
| 1693 | #include <__random/generate_canonical.h> | |
| 1694 | #include <__random/geometric_distribution.h> | |
| 1695 | #include <__random/independent_bits_engine.h> | |
| 1696 | #include <__random/is_seed_sequence.h> | |
| 1697 | #include <__random/knuth_b.h> | |
| 1698 | #include <__random/linear_congruential_engine.h> | |
| 1699 | #include <__random/log2.h> | |
| 1700 | #include <__random/lognormal_distribution.h> | |
| 1701 | #include <__random/mersenne_twister_engine.h> | |
| 1702 | #include <__random/negative_binomial_distribution.h> | |
| 1703 | #include <__random/normal_distribution.h> | |
| 1704 | #include <__random/piecewise_constant_distribution.h> | |
| 1705 | #include <__random/piecewise_linear_distribution.h> | |
| 1706 | #include <__random/poisson_distribution.h> | |
| 1707 | #include <__random/random_device.h> | |
| 1708 | #include <__random/ranlux.h> | |
| 1709 | #include <__random/seed_seq.h> | |
| 1710 | #include <__random/shuffle_order_engine.h> | |
| 1711 | #include <__random/student_t_distribution.h> | |
| 1712 | #include <__random/subtract_with_carry_engine.h> | |
| 1681 | 1713 | #include <__random/uniform_int_distribution.h> |
| 1682 | #include <algorithm> | |
| 1683 | #include <cmath> | |
| 1684 | #include <concepts> | |
| 1685 | #include <cstddef> | |
| 1686 | #include <cstdint> | |
| 1714 | #include <__random/uniform_random_bit_generator.h> | |
| 1715 | #include <__random/uniform_real_distribution.h> | |
| 1716 | #include <__random/weibull_distribution.h> | |
| 1687 | 1717 | #include <initializer_list> |
| 1688 | #include <iosfwd> | |
| 1689 | #include <limits> | |
| 1690 | #include <numeric> | |
| 1691 | #include <string> | |
| 1692 | #include <type_traits> | |
| 1693 | #include <vector> | |
| 1718 | #include <version> | |
| 1719 | ||
| 1720 | #include <algorithm> // for backward compatibility; TODO remove it | |
| 1721 | #include <cmath> // for backward compatibility; TODO remove it | |
| 1722 | #include <cstddef> // for backward compatibility; TODO remove it | |
| 1723 | #include <cstdint> // for backward compatibility; TODO remove it | |
| 1724 | #include <iosfwd> // for backward compatibility; TODO remove it | |
| 1725 | #include <limits> // for backward compatibility; TODO remove it | |
| 1726 | #include <numeric> // for backward compatibility; TODO remove it | |
| 1727 | #include <string> // for backward compatibility; TODO remove it | |
| 1728 | #include <type_traits> // for backward compatibility; TODO remove it | |
| 1729 | #include <vector> // for backward compatibility; TODO remove it | |
| 1694 | 1730 | |
| 1695 | 1731 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 1696 | 1732 | #pragma GCC system_header |
| 1697 | 1733 | #endif |
| 1698 | 1734 | |
| 1699 | _LIBCPP_PUSH_MACROS | |
| 1700 | #include <__undef_macros> | |
| 1701 | ||
| 1702 | ||
| 1703 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 1704 | ||
| 1705 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1706 | ||
| 1707 | // [rand.req.urng] | |
| 1708 | template<class _Gen> | |
| 1709 | concept uniform_random_bit_generator = | |
| 1710 | invocable<_Gen&> && unsigned_integral<invoke_result_t<_Gen&>> && | |
| 1711 | requires { | |
| 1712 | { _Gen::min() } -> same_as<invoke_result_t<_Gen&>>; | |
| 1713 | { _Gen::max() } -> same_as<invoke_result_t<_Gen&>>; | |
| 1714 | requires bool_constant<(_Gen::min() < _Gen::max())>::value; | |
| 1715 | }; | |
| 1716 | ||
| 1717 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1718 | ||
| 1719 | // __is_seed_sequence | |
| 1720 | ||
| 1721 | template <class _Sseq, class _Engine> | |
| 1722 | struct __is_seed_sequence | |
| 1723 | { | |
| 1724 | static _LIBCPP_CONSTEXPR const bool value = | |
| 1725 | !is_convertible<_Sseq, typename _Engine::result_type>::value && | |
| 1726 | !is_same<typename remove_cv<_Sseq>::type, _Engine>::value; | |
| 1727 | }; | |
| 1728 | ||
| 1729 | // linear_congruential_engine | |
| 1730 | ||
| 1731 | template <unsigned long long __a, unsigned long long __c, | |
| 1732 | unsigned long long __m, unsigned long long _Mp, | |
| 1733 | bool _MightOverflow = (__a != 0 && __m != 0 && __m-1 > (_Mp-__c)/__a), | |
| 1734 | bool _OverflowOK = ((__m | (__m-1)) > __m), // m = 2^n | |
| 1735 | bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q | |
| 1736 | struct __lce_alg_picker | |
| 1737 | { | |
| 1738 | static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK, | |
| 1739 | "The current values of a, c, and m cannot generate a number " | |
| 1740 | "within bounds of linear_congruential_engine."); | |
| 1741 | ||
| 1742 | static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow && | |
| 1743 | !_OverflowOK && | |
| 1744 | _SchrageOK; | |
| 1745 | }; | |
| 1746 | ||
| 1747 | template <unsigned long long __a, unsigned long long __c, | |
| 1748 | unsigned long long __m, unsigned long long _Mp, | |
| 1749 | bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage> | |
| 1750 | struct __lce_ta; | |
| 1751 | ||
| 1752 | // 64 | |
| 1753 | ||
| 1754 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | |
| 1755 | struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> | |
| 1756 | { | |
| 1757 | typedef unsigned long long result_type; | |
| 1758 | _LIBCPP_INLINE_VISIBILITY | |
| 1759 | static result_type next(result_type __x) | |
| 1760 | { | |
| 1761 | // Schrage's algorithm | |
| 1762 | const result_type __q = __m / __a; | |
| 1763 | const result_type __r = __m % __a; | |
| 1764 | const result_type __t0 = __a * (__x % __q); | |
| 1765 | const result_type __t1 = __r * (__x / __q); | |
| 1766 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 1767 | __x += __c - (__x >= __m - __c) * __m; | |
| 1768 | return __x; | |
| 1769 | } | |
| 1770 | }; | |
| 1771 | ||
| 1772 | template <unsigned long long __a, unsigned long long __m> | |
| 1773 | struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> | |
| 1774 | { | |
| 1775 | typedef unsigned long long result_type; | |
| 1776 | _LIBCPP_INLINE_VISIBILITY | |
| 1777 | static result_type next(result_type __x) | |
| 1778 | { | |
| 1779 | // Schrage's algorithm | |
| 1780 | const result_type __q = __m / __a; | |
| 1781 | const result_type __r = __m % __a; | |
| 1782 | const result_type __t0 = __a * (__x % __q); | |
| 1783 | const result_type __t1 = __r * (__x / __q); | |
| 1784 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 1785 | return __x; | |
| 1786 | } | |
| 1787 | }; | |
| 1788 | ||
| 1789 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m> | |
| 1790 | struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false> | |
| 1791 | { | |
| 1792 | typedef unsigned long long result_type; | |
| 1793 | _LIBCPP_INLINE_VISIBILITY | |
| 1794 | static result_type next(result_type __x) | |
| 1795 | { | |
| 1796 | return (__a * __x + __c) % __m; | |
| 1797 | } | |
| 1798 | }; | |
| 1799 | ||
| 1800 | template <unsigned long long __a, unsigned long long __c> | |
| 1801 | struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false> | |
| 1802 | { | |
| 1803 | typedef unsigned long long result_type; | |
| 1804 | _LIBCPP_INLINE_VISIBILITY | |
| 1805 | static result_type next(result_type __x) | |
| 1806 | { | |
| 1807 | return __a * __x + __c; | |
| 1808 | } | |
| 1809 | }; | |
| 1810 | ||
| 1811 | // 32 | |
| 1812 | ||
| 1813 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | |
| 1814 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> | |
| 1815 | { | |
| 1816 | typedef unsigned result_type; | |
| 1817 | _LIBCPP_INLINE_VISIBILITY | |
| 1818 | static result_type next(result_type __x) | |
| 1819 | { | |
| 1820 | const result_type __a = static_cast<result_type>(_Ap); | |
| 1821 | const result_type __c = static_cast<result_type>(_Cp); | |
| 1822 | const result_type __m = static_cast<result_type>(_Mp); | |
| 1823 | // Schrage's algorithm | |
| 1824 | const result_type __q = __m / __a; | |
| 1825 | const result_type __r = __m % __a; | |
| 1826 | const result_type __t0 = __a * (__x % __q); | |
| 1827 | const result_type __t1 = __r * (__x / __q); | |
| 1828 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 1829 | __x += __c - (__x >= __m - __c) * __m; | |
| 1830 | return __x; | |
| 1831 | } | |
| 1832 | }; | |
| 1833 | ||
| 1834 | template <unsigned long long _Ap, unsigned long long _Mp> | |
| 1835 | struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> | |
| 1836 | { | |
| 1837 | typedef unsigned result_type; | |
| 1838 | _LIBCPP_INLINE_VISIBILITY | |
| 1839 | static result_type next(result_type __x) | |
| 1840 | { | |
| 1841 | const result_type __a = static_cast<result_type>(_Ap); | |
| 1842 | const result_type __m = static_cast<result_type>(_Mp); | |
| 1843 | // Schrage's algorithm | |
| 1844 | const result_type __q = __m / __a; | |
| 1845 | const result_type __r = __m % __a; | |
| 1846 | const result_type __t0 = __a * (__x % __q); | |
| 1847 | const result_type __t1 = __r * (__x / __q); | |
| 1848 | __x = __t0 + (__t0 < __t1) * __m - __t1; | |
| 1849 | return __x; | |
| 1850 | } | |
| 1851 | }; | |
| 1852 | ||
| 1853 | template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp> | |
| 1854 | struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> | |
| 1855 | { | |
| 1856 | typedef unsigned result_type; | |
| 1857 | _LIBCPP_INLINE_VISIBILITY | |
| 1858 | static result_type next(result_type __x) | |
| 1859 | { | |
| 1860 | const result_type __a = static_cast<result_type>(_Ap); | |
| 1861 | const result_type __c = static_cast<result_type>(_Cp); | |
| 1862 | const result_type __m = static_cast<result_type>(_Mp); | |
| 1863 | return (__a * __x + __c) % __m; | |
| 1864 | } | |
| 1865 | }; | |
| 1866 | ||
| 1867 | template <unsigned long long _Ap, unsigned long long _Cp> | |
| 1868 | struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> | |
| 1869 | { | |
| 1870 | typedef unsigned result_type; | |
| 1871 | _LIBCPP_INLINE_VISIBILITY | |
| 1872 | static result_type next(result_type __x) | |
| 1873 | { | |
| 1874 | const result_type __a = static_cast<result_type>(_Ap); | |
| 1875 | const result_type __c = static_cast<result_type>(_Cp); | |
| 1876 | return __a * __x + __c; | |
| 1877 | } | |
| 1878 | }; | |
| 1879 | ||
| 1880 | // 16 | |
| 1881 | ||
| 1882 | template <unsigned long long __a, unsigned long long __c, unsigned long long __m, bool __b> | |
| 1883 | struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> | |
| 1884 | { | |
| 1885 | typedef unsigned short result_type; | |
| 1886 | _LIBCPP_INLINE_VISIBILITY | |
| 1887 | static result_type next(result_type __x) | |
| 1888 | { | |
| 1889 | return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x)); | |
| 1890 | } | |
| 1891 | }; | |
| 1892 | ||
| 1893 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 1894 | class _LIBCPP_TEMPLATE_VIS linear_congruential_engine; | |
| 1895 | ||
| 1896 | template <class _CharT, class _Traits, | |
| 1897 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 1898 | _LIBCPP_INLINE_VISIBILITY | |
| 1899 | basic_ostream<_CharT, _Traits>& | |
| 1900 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 1901 | const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); | |
| 1902 | ||
| 1903 | template <class _CharT, class _Traits, | |
| 1904 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 1905 | basic_istream<_CharT, _Traits>& | |
| 1906 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 1907 | linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); | |
| 1908 | ||
| 1909 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 1910 | class _LIBCPP_TEMPLATE_VIS linear_congruential_engine | |
| 1911 | { | |
| 1912 | public: | |
| 1913 | // types | |
| 1914 | typedef _UIntType result_type; | |
| 1915 | ||
| 1916 | private: | |
| 1917 | result_type __x_; | |
| 1918 | ||
| 1919 | static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0); | |
| 1920 | ||
| 1921 | static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters"); | |
| 1922 | static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters"); | |
| 1923 | static_assert(is_unsigned<_UIntType>::value, "_UIntType must be unsigned type"); | |
| 1924 | public: | |
| 1925 | static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u; | |
| 1926 | static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u; | |
| 1927 | static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); | |
| 1928 | ||
| 1929 | // engine characteristics | |
| 1930 | static _LIBCPP_CONSTEXPR const result_type multiplier = __a; | |
| 1931 | static _LIBCPP_CONSTEXPR const result_type increment = __c; | |
| 1932 | static _LIBCPP_CONSTEXPR const result_type modulus = __m; | |
| 1933 | _LIBCPP_INLINE_VISIBILITY | |
| 1934 | static _LIBCPP_CONSTEXPR result_type min() {return _Min;} | |
| 1935 | _LIBCPP_INLINE_VISIBILITY | |
| 1936 | static _LIBCPP_CONSTEXPR result_type max() {return _Max;} | |
| 1937 | static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; | |
| 1938 | ||
| 1939 | // constructors and seeding functions | |
| 1940 | #ifndef _LIBCPP_CXX03_LANG | |
| 1941 | _LIBCPP_INLINE_VISIBILITY | |
| 1942 | linear_congruential_engine() : linear_congruential_engine(default_seed) {} | |
| 1943 | _LIBCPP_INLINE_VISIBILITY | |
| 1944 | explicit linear_congruential_engine(result_type __s) { seed(__s); } | |
| 1945 | #else | |
| 1946 | _LIBCPP_INLINE_VISIBILITY | |
| 1947 | explicit linear_congruential_engine(result_type __s = default_seed) { | |
| 1948 | seed(__s); | |
| 1949 | } | |
| 1950 | #endif | |
| 1951 | template<class _Sseq> | |
| 1952 | _LIBCPP_INLINE_VISIBILITY | |
| 1953 | explicit linear_congruential_engine(_Sseq& __q, | |
| 1954 | typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0) | |
| 1955 | {seed(__q);} | |
| 1956 | _LIBCPP_INLINE_VISIBILITY | |
| 1957 | void seed(result_type __s = default_seed) | |
| 1958 | {seed(integral_constant<bool, __m == 0>(), | |
| 1959 | integral_constant<bool, __c == 0>(), __s);} | |
| 1960 | template<class _Sseq> | |
| 1961 | _LIBCPP_INLINE_VISIBILITY | |
| 1962 | typename enable_if | |
| 1963 | < | |
| 1964 | __is_seed_sequence<_Sseq, linear_congruential_engine>::value, | |
| 1965 | void | |
| 1966 | >::type | |
| 1967 | seed(_Sseq& __q) | |
| 1968 | {__seed(__q, integral_constant<unsigned, | |
| 1969 | 1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1)/32 | |
| 1970 | : (__m > 0x100000000ull))>());} | |
| 1971 | ||
| 1972 | // generating functions | |
| 1973 | _LIBCPP_INLINE_VISIBILITY | |
| 1974 | result_type operator()() | |
| 1975 | {return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _Mp>::next(__x_));} | |
| 1976 | _LIBCPP_INLINE_VISIBILITY | |
| 1977 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 1978 | ||
| 1979 | friend _LIBCPP_INLINE_VISIBILITY | |
| 1980 | bool operator==(const linear_congruential_engine& __x, | |
| 1981 | const linear_congruential_engine& __y) | |
| 1982 | {return __x.__x_ == __y.__x_;} | |
| 1983 | friend _LIBCPP_INLINE_VISIBILITY | |
| 1984 | bool operator!=(const linear_congruential_engine& __x, | |
| 1985 | const linear_congruential_engine& __y) | |
| 1986 | {return !(__x == __y);} | |
| 1987 | ||
| 1988 | private: | |
| 1989 | ||
| 1990 | _LIBCPP_INLINE_VISIBILITY | |
| 1991 | void seed(true_type, true_type, result_type __s) {__x_ = __s == 0 ? 1 : __s;} | |
| 1992 | _LIBCPP_INLINE_VISIBILITY | |
| 1993 | void seed(true_type, false_type, result_type __s) {__x_ = __s;} | |
| 1994 | _LIBCPP_INLINE_VISIBILITY | |
| 1995 | void seed(false_type, true_type, result_type __s) {__x_ = __s % __m == 0 ? | |
| 1996 | 1 : __s % __m;} | |
| 1997 | _LIBCPP_INLINE_VISIBILITY | |
| 1998 | void seed(false_type, false_type, result_type __s) {__x_ = __s % __m;} | |
| 1999 | ||
| 2000 | template<class _Sseq> | |
| 2001 | void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | |
| 2002 | template<class _Sseq> | |
| 2003 | void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | |
| 2004 | ||
| 2005 | template <class _CharT, class _Traits, | |
| 2006 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 2007 | friend | |
| 2008 | basic_ostream<_CharT, _Traits>& | |
| 2009 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2010 | const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&); | |
| 2011 | ||
| 2012 | template <class _CharT, class _Traits, | |
| 2013 | class _Up, _Up _Ap, _Up _Cp, _Up _Np> | |
| 2014 | friend | |
| 2015 | basic_istream<_CharT, _Traits>& | |
| 2016 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2017 | linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); | |
| 2018 | }; | |
| 2019 | ||
| 2020 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2021 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 2022 | linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier; | |
| 2023 | ||
| 2024 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2025 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 2026 | linear_congruential_engine<_UIntType, __a, __c, __m>::increment; | |
| 2027 | ||
| 2028 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2029 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 2030 | linear_congruential_engine<_UIntType, __a, __c, __m>::modulus; | |
| 2031 | ||
| 2032 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2033 | _LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type | |
| 2034 | linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed; | |
| 2035 | ||
| 2036 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2037 | template<class _Sseq> | |
| 2038 | void | |
| 2039 | linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, | |
| 2040 | integral_constant<unsigned, 1>) | |
| 2041 | { | |
| 2042 | const unsigned __k = 1; | |
| 2043 | uint32_t __ar[__k+3]; | |
| 2044 | __q.generate(__ar, __ar + __k + 3); | |
| 2045 | result_type __s = static_cast<result_type>(__ar[3] % __m); | |
| 2046 | __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; | |
| 2047 | } | |
| 2048 | ||
| 2049 | template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2050 | template<class _Sseq> | |
| 2051 | void | |
| 2052 | linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, | |
| 2053 | integral_constant<unsigned, 2>) | |
| 2054 | { | |
| 2055 | const unsigned __k = 2; | |
| 2056 | uint32_t __ar[__k+3]; | |
| 2057 | __q.generate(__ar, __ar + __k + 3); | |
| 2058 | result_type __s = static_cast<result_type>((__ar[3] + | |
| 2059 | ((uint64_t)__ar[4] << 32)) % __m); | |
| 2060 | __x_ = __c == 0 && __s == 0 ? result_type(1) : __s; | |
| 2061 | } | |
| 2062 | ||
| 2063 | template <class _CharT, class _Traits, | |
| 2064 | class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2065 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2066 | basic_ostream<_CharT, _Traits>& | |
| 2067 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2068 | const linear_congruential_engine<_UIntType, __a, __c, __m>& __x) | |
| 2069 | { | |
| 2070 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 2071 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 2072 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 2073 | __os.fill(__os.widen(' ')); | |
| 2074 | return __os << __x.__x_; | |
| 2075 | } | |
| 2076 | ||
| 2077 | template <class _CharT, class _Traits, | |
| 2078 | class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> | |
| 2079 | basic_istream<_CharT, _Traits>& | |
| 2080 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2081 | linear_congruential_engine<_UIntType, __a, __c, __m>& __x) | |
| 2082 | { | |
| 2083 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 2084 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 2085 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 2086 | _UIntType __t; | |
| 2087 | __is >> __t; | |
| 2088 | if (!__is.fail()) | |
| 2089 | __x.__x_ = __t; | |
| 2090 | return __is; | |
| 2091 | } | |
| 2092 | ||
| 2093 | typedef linear_congruential_engine<uint_fast32_t, 16807, 0, 2147483647> | |
| 2094 | minstd_rand0; | |
| 2095 | typedef linear_congruential_engine<uint_fast32_t, 48271, 0, 2147483647> | |
| 2096 | minstd_rand; | |
| 2097 | typedef minstd_rand default_random_engine; | |
| 2098 | // mersenne_twister_engine | |
| 2099 | ||
| 2100 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2101 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2102 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2103 | class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine; | |
| 2104 | ||
| 2105 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2106 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2107 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2108 | bool | |
| 2109 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2110 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 2111 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2112 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 2113 | ||
| 2114 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2115 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2116 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2117 | _LIBCPP_INLINE_VISIBILITY | |
| 2118 | bool | |
| 2119 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2120 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 2121 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2122 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 2123 | ||
| 2124 | template <class _CharT, class _Traits, | |
| 2125 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2126 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2127 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2128 | basic_ostream<_CharT, _Traits>& | |
| 2129 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2130 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2131 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 2132 | ||
| 2133 | template <class _CharT, class _Traits, | |
| 2134 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2135 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2136 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2137 | basic_istream<_CharT, _Traits>& | |
| 2138 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2139 | mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2140 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 2141 | ||
| 2142 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2143 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2144 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2145 | class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine | |
| 2146 | { | |
| 2147 | public: | |
| 2148 | // types | |
| 2149 | typedef _UIntType result_type; | |
| 2150 | ||
| 2151 | private: | |
| 2152 | result_type __x_[__n]; | |
| 2153 | size_t __i_; | |
| 2154 | ||
| 2155 | static_assert( 0 < __m, "mersenne_twister_engine invalid parameters"); | |
| 2156 | static_assert(__m <= __n, "mersenne_twister_engine invalid parameters"); | |
| 2157 | static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; | |
| 2158 | static_assert(__w <= _Dt, "mersenne_twister_engine invalid parameters"); | |
| 2159 | static_assert( 2 <= __w, "mersenne_twister_engine invalid parameters"); | |
| 2160 | static_assert(__r <= __w, "mersenne_twister_engine invalid parameters"); | |
| 2161 | static_assert(__u <= __w, "mersenne_twister_engine invalid parameters"); | |
| 2162 | static_assert(__s <= __w, "mersenne_twister_engine invalid parameters"); | |
| 2163 | static_assert(__t <= __w, "mersenne_twister_engine invalid parameters"); | |
| 2164 | static_assert(__l <= __w, "mersenne_twister_engine invalid parameters"); | |
| 2165 | public: | |
| 2166 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 2167 | static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : | |
| 2168 | (result_type(1) << __w) - result_type(1); | |
| 2169 | static_assert(_Min < _Max, "mersenne_twister_engine invalid parameters"); | |
| 2170 | static_assert(__a <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 2171 | static_assert(__b <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 2172 | static_assert(__c <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 2173 | static_assert(__d <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 2174 | static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters"); | |
| 2175 | ||
| 2176 | // engine characteristics | |
| 2177 | static _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 2178 | static _LIBCPP_CONSTEXPR const size_t state_size = __n; | |
| 2179 | static _LIBCPP_CONSTEXPR const size_t shift_size = __m; | |
| 2180 | static _LIBCPP_CONSTEXPR const size_t mask_bits = __r; | |
| 2181 | static _LIBCPP_CONSTEXPR const result_type xor_mask = __a; | |
| 2182 | static _LIBCPP_CONSTEXPR const size_t tempering_u = __u; | |
| 2183 | static _LIBCPP_CONSTEXPR const result_type tempering_d = __d; | |
| 2184 | static _LIBCPP_CONSTEXPR const size_t tempering_s = __s; | |
| 2185 | static _LIBCPP_CONSTEXPR const result_type tempering_b = __b; | |
| 2186 | static _LIBCPP_CONSTEXPR const size_t tempering_t = __t; | |
| 2187 | static _LIBCPP_CONSTEXPR const result_type tempering_c = __c; | |
| 2188 | static _LIBCPP_CONSTEXPR const size_t tempering_l = __l; | |
| 2189 | static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f; | |
| 2190 | _LIBCPP_INLINE_VISIBILITY | |
| 2191 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 2192 | _LIBCPP_INLINE_VISIBILITY | |
| 2193 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 2194 | static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; | |
| 2195 | ||
| 2196 | // constructors and seeding functions | |
| 2197 | #ifndef _LIBCPP_CXX03_LANG | |
| 2198 | _LIBCPP_INLINE_VISIBILITY | |
| 2199 | mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} | |
| 2200 | _LIBCPP_INLINE_VISIBILITY | |
| 2201 | explicit mersenne_twister_engine(result_type __sd) { seed(__sd); } | |
| 2202 | #else | |
| 2203 | _LIBCPP_INLINE_VISIBILITY | |
| 2204 | explicit mersenne_twister_engine(result_type __sd = default_seed) { | |
| 2205 | seed(__sd); | |
| 2206 | } | |
| 2207 | #endif | |
| 2208 | template<class _Sseq> | |
| 2209 | _LIBCPP_INLINE_VISIBILITY | |
| 2210 | explicit mersenne_twister_engine(_Sseq& __q, | |
| 2211 | typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0) | |
| 2212 | {seed(__q);} | |
| 2213 | void seed(result_type __sd = default_seed); | |
| 2214 | template<class _Sseq> | |
| 2215 | _LIBCPP_INLINE_VISIBILITY | |
| 2216 | typename enable_if | |
| 2217 | < | |
| 2218 | __is_seed_sequence<_Sseq, mersenne_twister_engine>::value, | |
| 2219 | void | |
| 2220 | >::type | |
| 2221 | seed(_Sseq& __q) | |
| 2222 | {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());} | |
| 2223 | ||
| 2224 | // generating functions | |
| 2225 | result_type operator()(); | |
| 2226 | _LIBCPP_INLINE_VISIBILITY | |
| 2227 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 2228 | ||
| 2229 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2230 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2231 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2232 | friend | |
| 2233 | bool | |
| 2234 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2235 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 2236 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2237 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 2238 | ||
| 2239 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2240 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2241 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2242 | friend | |
| 2243 | bool | |
| 2244 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2245 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 2246 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2247 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y); | |
| 2248 | ||
| 2249 | template <class _CharT, class _Traits, | |
| 2250 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2251 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2252 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2253 | friend | |
| 2254 | basic_ostream<_CharT, _Traits>& | |
| 2255 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2256 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2257 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 2258 | ||
| 2259 | template <class _CharT, class _Traits, | |
| 2260 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2261 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2262 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2263 | friend | |
| 2264 | basic_istream<_CharT, _Traits>& | |
| 2265 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2266 | mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2267 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x); | |
| 2268 | private: | |
| 2269 | ||
| 2270 | template<class _Sseq> | |
| 2271 | void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | |
| 2272 | template<class _Sseq> | |
| 2273 | void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | |
| 2274 | ||
| 2275 | template <size_t __count> | |
| 2276 | _LIBCPP_INLINE_VISIBILITY | |
| 2277 | static | |
| 2278 | typename enable_if | |
| 2279 | < | |
| 2280 | __count < __w, | |
| 2281 | result_type | |
| 2282 | >::type | |
| 2283 | __lshift(result_type __x) {return (__x << __count) & _Max;} | |
| 2284 | ||
| 2285 | template <size_t __count> | |
| 2286 | _LIBCPP_INLINE_VISIBILITY | |
| 2287 | static | |
| 2288 | typename enable_if | |
| 2289 | < | |
| 2290 | (__count >= __w), | |
| 2291 | result_type | |
| 2292 | >::type | |
| 2293 | __lshift(result_type) {return result_type(0);} | |
| 2294 | ||
| 2295 | template <size_t __count> | |
| 2296 | _LIBCPP_INLINE_VISIBILITY | |
| 2297 | static | |
| 2298 | typename enable_if | |
| 2299 | < | |
| 2300 | __count < _Dt, | |
| 2301 | result_type | |
| 2302 | >::type | |
| 2303 | __rshift(result_type __x) {return __x >> __count;} | |
| 2304 | ||
| 2305 | template <size_t __count> | |
| 2306 | _LIBCPP_INLINE_VISIBILITY | |
| 2307 | static | |
| 2308 | typename enable_if | |
| 2309 | < | |
| 2310 | (__count >= _Dt), | |
| 2311 | result_type | |
| 2312 | >::type | |
| 2313 | __rshift(result_type) {return result_type(0);} | |
| 2314 | }; | |
| 2315 | ||
| 2316 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2317 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2318 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2319 | _LIBCPP_CONSTEXPR const size_t | |
| 2320 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size; | |
| 2321 | ||
| 2322 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2323 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2324 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2325 | _LIBCPP_CONSTEXPR const size_t | |
| 2326 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size; | |
| 2327 | ||
| 2328 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2329 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2330 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2331 | _LIBCPP_CONSTEXPR const size_t | |
| 2332 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size; | |
| 2333 | ||
| 2334 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2335 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2336 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2337 | _LIBCPP_CONSTEXPR const size_t | |
| 2338 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits; | |
| 2339 | ||
| 2340 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2341 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2342 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2343 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 2344 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask; | |
| 2345 | ||
| 2346 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2347 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2348 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2349 | _LIBCPP_CONSTEXPR const size_t | |
| 2350 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u; | |
| 2351 | ||
| 2352 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2353 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2354 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2355 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 2356 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d; | |
| 2357 | ||
| 2358 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2359 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2360 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2361 | _LIBCPP_CONSTEXPR const size_t | |
| 2362 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s; | |
| 2363 | ||
| 2364 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2365 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2366 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2367 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 2368 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b; | |
| 2369 | ||
| 2370 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2371 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2372 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2373 | _LIBCPP_CONSTEXPR const size_t | |
| 2374 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t; | |
| 2375 | ||
| 2376 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2377 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2378 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2379 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 2380 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c; | |
| 2381 | ||
| 2382 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2383 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2384 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2385 | _LIBCPP_CONSTEXPR const size_t | |
| 2386 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l; | |
| 2387 | ||
| 2388 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2389 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2390 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2391 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 2392 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::initialization_multiplier; | |
| 2393 | ||
| 2394 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2395 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2396 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2397 | _LIBCPP_CONSTEXPR const typename mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type | |
| 2398 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed; | |
| 2399 | ||
| 2400 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2401 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2402 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2403 | void | |
| 2404 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 2405 | __t, __c, __l, __f>::seed(result_type __sd) | |
| 2406 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 2407 | { // __w >= 2 | |
| 2408 | __x_[0] = __sd & _Max; | |
| 2409 | for (size_t __i = 1; __i < __n; ++__i) | |
| 2410 | __x_[__i] = (__f * (__x_[__i-1] ^ __rshift<__w - 2>(__x_[__i-1])) + __i) & _Max; | |
| 2411 | __i_ = 0; | |
| 2412 | } | |
| 2413 | ||
| 2414 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2415 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2416 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2417 | template<class _Sseq> | |
| 2418 | void | |
| 2419 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 2420 | __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) | |
| 2421 | { | |
| 2422 | const unsigned __k = 1; | |
| 2423 | uint32_t __ar[__n * __k]; | |
| 2424 | __q.generate(__ar, __ar + __n * __k); | |
| 2425 | for (size_t __i = 0; __i < __n; ++__i) | |
| 2426 | __x_[__i] = static_cast<result_type>(__ar[__i] & _Max); | |
| 2427 | const result_type __mask = __r == _Dt ? result_type(~0) : | |
| 2428 | (result_type(1) << __r) - result_type(1); | |
| 2429 | __i_ = 0; | |
| 2430 | if ((__x_[0] & ~__mask) == 0) | |
| 2431 | { | |
| 2432 | for (size_t __i = 1; __i < __n; ++__i) | |
| 2433 | if (__x_[__i] != 0) | |
| 2434 | return; | |
| 2435 | __x_[0] = result_type(1) << (__w - 1); | |
| 2436 | } | |
| 2437 | } | |
| 2438 | ||
| 2439 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2440 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2441 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2442 | template<class _Sseq> | |
| 2443 | void | |
| 2444 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 2445 | __t, __c, __l, __f>::__seed(_Sseq& __q, integral_constant<unsigned, 2>) | |
| 2446 | { | |
| 2447 | const unsigned __k = 2; | |
| 2448 | uint32_t __ar[__n * __k]; | |
| 2449 | __q.generate(__ar, __ar + __n * __k); | |
| 2450 | for (size_t __i = 0; __i < __n; ++__i) | |
| 2451 | __x_[__i] = static_cast<result_type>( | |
| 2452 | (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); | |
| 2453 | const result_type __mask = __r == _Dt ? result_type(~0) : | |
| 2454 | (result_type(1) << __r) - result_type(1); | |
| 2455 | __i_ = 0; | |
| 2456 | if ((__x_[0] & ~__mask) == 0) | |
| 2457 | { | |
| 2458 | for (size_t __i = 1; __i < __n; ++__i) | |
| 2459 | if (__x_[__i] != 0) | |
| 2460 | return; | |
| 2461 | __x_[0] = result_type(1) << (__w - 1); | |
| 2462 | } | |
| 2463 | } | |
| 2464 | ||
| 2465 | template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, | |
| 2466 | _UIntType __a, size_t __u, _UIntType __d, size_t __s, | |
| 2467 | _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> | |
| 2468 | _UIntType | |
| 2469 | mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, | |
| 2470 | __t, __c, __l, __f>::operator()() | |
| 2471 | { | |
| 2472 | const size_t __j = (__i_ + 1) % __n; | |
| 2473 | const result_type __mask = __r == _Dt ? result_type(~0) : | |
| 2474 | (result_type(1) << __r) - result_type(1); | |
| 2475 | const result_type _Yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask); | |
| 2476 | const size_t __k = (__i_ + __m) % __n; | |
| 2477 | __x_[__i_] = __x_[__k] ^ __rshift<1>(_Yp) ^ (__a * (_Yp & 1)); | |
| 2478 | result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d); | |
| 2479 | __i_ = __j; | |
| 2480 | __z ^= __lshift<__s>(__z) & __b; | |
| 2481 | __z ^= __lshift<__t>(__z) & __c; | |
| 2482 | return __z ^ __rshift<__l>(__z); | |
| 2483 | } | |
| 2484 | ||
| 2485 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2486 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2487 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2488 | bool | |
| 2489 | operator==(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2490 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 2491 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2492 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y) | |
| 2493 | { | |
| 2494 | if (__x.__i_ == __y.__i_) | |
| 2495 | return _VSTD::equal(__x.__x_, __x.__x_ + _Np, __y.__x_); | |
| 2496 | if (__x.__i_ == 0 || __y.__i_ == 0) | |
| 2497 | { | |
| 2498 | size_t __j = _VSTD::min(_Np - __x.__i_, _Np - __y.__i_); | |
| 2499 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, | |
| 2500 | __y.__x_ + __y.__i_)) | |
| 2501 | return false; | |
| 2502 | if (__x.__i_ == 0) | |
| 2503 | return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Np, __y.__x_); | |
| 2504 | return _VSTD::equal(__x.__x_, __x.__x_ + (_Np - __j), __y.__x_ + __j); | |
| 2505 | } | |
| 2506 | if (__x.__i_ < __y.__i_) | |
| 2507 | { | |
| 2508 | size_t __j = _Np - __y.__i_; | |
| 2509 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), | |
| 2510 | __y.__x_ + __y.__i_)) | |
| 2511 | return false; | |
| 2512 | if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Np, | |
| 2513 | __y.__x_)) | |
| 2514 | return false; | |
| 2515 | return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, | |
| 2516 | __y.__x_ + (_Np - (__x.__i_ + __j))); | |
| 2517 | } | |
| 2518 | size_t __j = _Np - __x.__i_; | |
| 2519 | if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), | |
| 2520 | __x.__x_ + __x.__i_)) | |
| 2521 | return false; | |
| 2522 | if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Np, | |
| 2523 | __x.__x_)) | |
| 2524 | return false; | |
| 2525 | return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, | |
| 2526 | __x.__x_ + (_Np - (__y.__i_ + __j))); | |
| 2527 | } | |
| 2528 | ||
| 2529 | template <class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2530 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2531 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2532 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2533 | bool | |
| 2534 | operator!=(const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2535 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x, | |
| 2536 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2537 | _Bp, _Tp, _Cp, _Lp, _Fp>& __y) | |
| 2538 | { | |
| 2539 | return !(__x == __y); | |
| 2540 | } | |
| 2541 | ||
| 2542 | template <class _CharT, class _Traits, | |
| 2543 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2544 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2545 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2546 | basic_ostream<_CharT, _Traits>& | |
| 2547 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2548 | const mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2549 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x) | |
| 2550 | { | |
| 2551 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 2552 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 2553 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 2554 | _CharT __sp = __os.widen(' '); | |
| 2555 | __os.fill(__sp); | |
| 2556 | __os << __x.__x_[__x.__i_]; | |
| 2557 | for (size_t __j = __x.__i_ + 1; __j < _Np; ++__j) | |
| 2558 | __os << __sp << __x.__x_[__j]; | |
| 2559 | for (size_t __j = 0; __j < __x.__i_; ++__j) | |
| 2560 | __os << __sp << __x.__x_[__j]; | |
| 2561 | return __os; | |
| 2562 | } | |
| 2563 | ||
| 2564 | template <class _CharT, class _Traits, | |
| 2565 | class _UInt, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, | |
| 2566 | _UInt _Ap, size_t _Up, _UInt _Dp, size_t _Sp, | |
| 2567 | _UInt _Bp, size_t _Tp, _UInt _Cp, size_t _Lp, _UInt _Fp> | |
| 2568 | basic_istream<_CharT, _Traits>& | |
| 2569 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2570 | mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, | |
| 2571 | _Bp, _Tp, _Cp, _Lp, _Fp>& __x) | |
| 2572 | { | |
| 2573 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 2574 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 2575 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 2576 | _UInt __t[_Np]; | |
| 2577 | for (size_t __i = 0; __i < _Np; ++__i) | |
| 2578 | __is >> __t[__i]; | |
| 2579 | if (!__is.fail()) | |
| 2580 | { | |
| 2581 | for (size_t __i = 0; __i < _Np; ++__i) | |
| 2582 | __x.__x_[__i] = __t[__i]; | |
| 2583 | __x.__i_ = 0; | |
| 2584 | } | |
| 2585 | return __is; | |
| 2586 | } | |
| 2587 | ||
| 2588 | typedef mersenne_twister_engine<uint_fast32_t, 32, 624, 397, 31, | |
| 2589 | 0x9908b0df, 11, 0xffffffff, | |
| 2590 | 7, 0x9d2c5680, | |
| 2591 | 15, 0xefc60000, | |
| 2592 | 18, 1812433253> mt19937; | |
| 2593 | typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31, | |
| 2594 | 0xb5026f5aa96619e9ULL, 29, 0x5555555555555555ULL, | |
| 2595 | 17, 0x71d67fffeda60000ULL, | |
| 2596 | 37, 0xfff7eee000000000ULL, | |
| 2597 | 43, 6364136223846793005ULL> mt19937_64; | |
| 2598 | ||
| 2599 | // subtract_with_carry_engine | |
| 2600 | ||
| 2601 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2602 | class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine; | |
| 2603 | ||
| 2604 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2605 | bool | |
| 2606 | operator==( | |
| 2607 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 2608 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 2609 | ||
| 2610 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2611 | _LIBCPP_INLINE_VISIBILITY | |
| 2612 | bool | |
| 2613 | operator!=( | |
| 2614 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 2615 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 2616 | ||
| 2617 | template <class _CharT, class _Traits, | |
| 2618 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2619 | basic_ostream<_CharT, _Traits>& | |
| 2620 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2621 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 2622 | ||
| 2623 | template <class _CharT, class _Traits, | |
| 2624 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2625 | basic_istream<_CharT, _Traits>& | |
| 2626 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2627 | subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 2628 | ||
| 2629 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2630 | class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine | |
| 2631 | { | |
| 2632 | public: | |
| 2633 | // types | |
| 2634 | typedef _UIntType result_type; | |
| 2635 | ||
| 2636 | private: | |
| 2637 | result_type __x_[__r]; | |
| 2638 | result_type __c_; | |
| 2639 | size_t __i_; | |
| 2640 | ||
| 2641 | static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; | |
| 2642 | static_assert( 0 < __w, "subtract_with_carry_engine invalid parameters"); | |
| 2643 | static_assert(__w <= _Dt, "subtract_with_carry_engine invalid parameters"); | |
| 2644 | static_assert( 0 < __s, "subtract_with_carry_engine invalid parameters"); | |
| 2645 | static_assert(__s < __r, "subtract_with_carry_engine invalid parameters"); | |
| 2646 | public: | |
| 2647 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 2648 | static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : | |
| 2649 | (result_type(1) << __w) - result_type(1); | |
| 2650 | static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters"); | |
| 2651 | ||
| 2652 | // engine characteristics | |
| 2653 | static _LIBCPP_CONSTEXPR const size_t word_size = __w; | |
| 2654 | static _LIBCPP_CONSTEXPR const size_t short_lag = __s; | |
| 2655 | static _LIBCPP_CONSTEXPR const size_t long_lag = __r; | |
| 2656 | _LIBCPP_INLINE_VISIBILITY | |
| 2657 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 2658 | _LIBCPP_INLINE_VISIBILITY | |
| 2659 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 2660 | static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; | |
| 2661 | ||
| 2662 | // constructors and seeding functions | |
| 2663 | #ifndef _LIBCPP_CXX03_LANG | |
| 2664 | _LIBCPP_INLINE_VISIBILITY | |
| 2665 | subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} | |
| 2666 | _LIBCPP_INLINE_VISIBILITY | |
| 2667 | explicit subtract_with_carry_engine(result_type __sd) { seed(__sd); } | |
| 2668 | #else | |
| 2669 | _LIBCPP_INLINE_VISIBILITY | |
| 2670 | explicit subtract_with_carry_engine(result_type __sd = default_seed) { | |
| 2671 | seed(__sd); | |
| 2672 | } | |
| 2673 | #endif | |
| 2674 | template<class _Sseq> | |
| 2675 | _LIBCPP_INLINE_VISIBILITY | |
| 2676 | explicit subtract_with_carry_engine(_Sseq& __q, | |
| 2677 | typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0) | |
| 2678 | {seed(__q);} | |
| 2679 | _LIBCPP_INLINE_VISIBILITY | |
| 2680 | void seed(result_type __sd = default_seed) | |
| 2681 | {seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());} | |
| 2682 | template<class _Sseq> | |
| 2683 | _LIBCPP_INLINE_VISIBILITY | |
| 2684 | typename enable_if | |
| 2685 | < | |
| 2686 | __is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, | |
| 2687 | void | |
| 2688 | >::type | |
| 2689 | seed(_Sseq& __q) | |
| 2690 | {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());} | |
| 2691 | ||
| 2692 | // generating functions | |
| 2693 | result_type operator()(); | |
| 2694 | _LIBCPP_INLINE_VISIBILITY | |
| 2695 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 2696 | ||
| 2697 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2698 | friend | |
| 2699 | bool | |
| 2700 | operator==( | |
| 2701 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 2702 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 2703 | ||
| 2704 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2705 | friend | |
| 2706 | bool | |
| 2707 | operator!=( | |
| 2708 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 2709 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y); | |
| 2710 | ||
| 2711 | template <class _CharT, class _Traits, | |
| 2712 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2713 | friend | |
| 2714 | basic_ostream<_CharT, _Traits>& | |
| 2715 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2716 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 2717 | ||
| 2718 | template <class _CharT, class _Traits, | |
| 2719 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2720 | friend | |
| 2721 | basic_istream<_CharT, _Traits>& | |
| 2722 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2723 | subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x); | |
| 2724 | ||
| 2725 | private: | |
| 2726 | ||
| 2727 | void seed(result_type __sd, integral_constant<unsigned, 1>); | |
| 2728 | void seed(result_type __sd, integral_constant<unsigned, 2>); | |
| 2729 | template<class _Sseq> | |
| 2730 | void __seed(_Sseq& __q, integral_constant<unsigned, 1>); | |
| 2731 | template<class _Sseq> | |
| 2732 | void __seed(_Sseq& __q, integral_constant<unsigned, 2>); | |
| 2733 | }; | |
| 2734 | ||
| 2735 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2736 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size; | |
| 2737 | ||
| 2738 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2739 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag; | |
| 2740 | ||
| 2741 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2742 | _LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag; | |
| 2743 | ||
| 2744 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2745 | _LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type | |
| 2746 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed; | |
| 2747 | ||
| 2748 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2749 | void | |
| 2750 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, | |
| 2751 | integral_constant<unsigned, 1>) | |
| 2752 | { | |
| 2753 | linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> | |
| 2754 | __e(__sd == 0u ? default_seed : __sd); | |
| 2755 | for (size_t __i = 0; __i < __r; ++__i) | |
| 2756 | __x_[__i] = static_cast<result_type>(__e() & _Max); | |
| 2757 | __c_ = __x_[__r-1] == 0; | |
| 2758 | __i_ = 0; | |
| 2759 | } | |
| 2760 | ||
| 2761 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2762 | void | |
| 2763 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, | |
| 2764 | integral_constant<unsigned, 2>) | |
| 2765 | { | |
| 2766 | linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> | |
| 2767 | __e(__sd == 0u ? default_seed : __sd); | |
| 2768 | for (size_t __i = 0; __i < __r; ++__i) | |
| 2769 | { | |
| 2770 | result_type __e0 = __e(); | |
| 2771 | __x_[__i] = static_cast<result_type>( | |
| 2772 | (__e0 + ((uint64_t)__e() << 32)) & _Max); | |
| 2773 | } | |
| 2774 | __c_ = __x_[__r-1] == 0; | |
| 2775 | __i_ = 0; | |
| 2776 | } | |
| 2777 | ||
| 2778 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2779 | template<class _Sseq> | |
| 2780 | void | |
| 2781 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, | |
| 2782 | integral_constant<unsigned, 1>) | |
| 2783 | { | |
| 2784 | const unsigned __k = 1; | |
| 2785 | uint32_t __ar[__r * __k]; | |
| 2786 | __q.generate(__ar, __ar + __r * __k); | |
| 2787 | for (size_t __i = 0; __i < __r; ++__i) | |
| 2788 | __x_[__i] = static_cast<result_type>(__ar[__i] & _Max); | |
| 2789 | __c_ = __x_[__r-1] == 0; | |
| 2790 | __i_ = 0; | |
| 2791 | } | |
| 2792 | ||
| 2793 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2794 | template<class _Sseq> | |
| 2795 | void | |
| 2796 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, | |
| 2797 | integral_constant<unsigned, 2>) | |
| 2798 | { | |
| 2799 | const unsigned __k = 2; | |
| 2800 | uint32_t __ar[__r * __k]; | |
| 2801 | __q.generate(__ar, __ar + __r * __k); | |
| 2802 | for (size_t __i = 0; __i < __r; ++__i) | |
| 2803 | __x_[__i] = static_cast<result_type>( | |
| 2804 | (__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max); | |
| 2805 | __c_ = __x_[__r-1] == 0; | |
| 2806 | __i_ = 0; | |
| 2807 | } | |
| 2808 | ||
| 2809 | template<class _UIntType, size_t __w, size_t __s, size_t __r> | |
| 2810 | _UIntType | |
| 2811 | subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()() | |
| 2812 | { | |
| 2813 | const result_type& __xs = __x_[(__i_ + (__r - __s)) % __r]; | |
| 2814 | result_type& __xr = __x_[__i_]; | |
| 2815 | result_type __new_c = __c_ == 0 ? __xs < __xr : __xs != 0 ? __xs <= __xr : 1; | |
| 2816 | __xr = (__xs - __xr - __c_) & _Max; | |
| 2817 | __c_ = __new_c; | |
| 2818 | __i_ = (__i_ + 1) % __r; | |
| 2819 | return __xr; | |
| 2820 | } | |
| 2821 | ||
| 2822 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2823 | bool | |
| 2824 | operator==( | |
| 2825 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 2826 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y) | |
| 2827 | { | |
| 2828 | if (__x.__c_ != __y.__c_) | |
| 2829 | return false; | |
| 2830 | if (__x.__i_ == __y.__i_) | |
| 2831 | return _VSTD::equal(__x.__x_, __x.__x_ + _Rp, __y.__x_); | |
| 2832 | if (__x.__i_ == 0 || __y.__i_ == 0) | |
| 2833 | { | |
| 2834 | size_t __j = _VSTD::min(_Rp - __x.__i_, _Rp - __y.__i_); | |
| 2835 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + __x.__i_ + __j, | |
| 2836 | __y.__x_ + __y.__i_)) | |
| 2837 | return false; | |
| 2838 | if (__x.__i_ == 0) | |
| 2839 | return _VSTD::equal(__x.__x_ + __j, __x.__x_ + _Rp, __y.__x_); | |
| 2840 | return _VSTD::equal(__x.__x_, __x.__x_ + (_Rp - __j), __y.__x_ + __j); | |
| 2841 | } | |
| 2842 | if (__x.__i_ < __y.__i_) | |
| 2843 | { | |
| 2844 | size_t __j = _Rp - __y.__i_; | |
| 2845 | if (!_VSTD::equal(__x.__x_ + __x.__i_, __x.__x_ + (__x.__i_ + __j), | |
| 2846 | __y.__x_ + __y.__i_)) | |
| 2847 | return false; | |
| 2848 | if (!_VSTD::equal(__x.__x_ + (__x.__i_ + __j), __x.__x_ + _Rp, | |
| 2849 | __y.__x_)) | |
| 2850 | return false; | |
| 2851 | return _VSTD::equal(__x.__x_, __x.__x_ + __x.__i_, | |
| 2852 | __y.__x_ + (_Rp - (__x.__i_ + __j))); | |
| 2853 | } | |
| 2854 | size_t __j = _Rp - __x.__i_; | |
| 2855 | if (!_VSTD::equal(__y.__x_ + __y.__i_, __y.__x_ + (__y.__i_ + __j), | |
| 2856 | __x.__x_ + __x.__i_)) | |
| 2857 | return false; | |
| 2858 | if (!_VSTD::equal(__y.__x_ + (__y.__i_ + __j), __y.__x_ + _Rp, | |
| 2859 | __x.__x_)) | |
| 2860 | return false; | |
| 2861 | return _VSTD::equal(__y.__x_, __y.__x_ + __y.__i_, | |
| 2862 | __x.__x_ + (_Rp - (__y.__i_ + __j))); | |
| 2863 | } | |
| 2864 | ||
| 2865 | template<class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2866 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2867 | bool | |
| 2868 | operator!=( | |
| 2869 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x, | |
| 2870 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __y) | |
| 2871 | { | |
| 2872 | return !(__x == __y); | |
| 2873 | } | |
| 2874 | ||
| 2875 | template <class _CharT, class _Traits, | |
| 2876 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2877 | basic_ostream<_CharT, _Traits>& | |
| 2878 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 2879 | const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x) | |
| 2880 | { | |
| 2881 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 2882 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 2883 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 2884 | _CharT __sp = __os.widen(' '); | |
| 2885 | __os.fill(__sp); | |
| 2886 | __os << __x.__x_[__x.__i_]; | |
| 2887 | for (size_t __j = __x.__i_ + 1; __j < _Rp; ++__j) | |
| 2888 | __os << __sp << __x.__x_[__j]; | |
| 2889 | for (size_t __j = 0; __j < __x.__i_; ++__j) | |
| 2890 | __os << __sp << __x.__x_[__j]; | |
| 2891 | __os << __sp << __x.__c_; | |
| 2892 | return __os; | |
| 2893 | } | |
| 2894 | ||
| 2895 | template <class _CharT, class _Traits, | |
| 2896 | class _UInt, size_t _Wp, size_t _Sp, size_t _Rp> | |
| 2897 | basic_istream<_CharT, _Traits>& | |
| 2898 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 2899 | subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x) | |
| 2900 | { | |
| 2901 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 2902 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 2903 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 2904 | _UInt __t[_Rp+1]; | |
| 2905 | for (size_t __i = 0; __i < _Rp+1; ++__i) | |
| 2906 | __is >> __t[__i]; | |
| 2907 | if (!__is.fail()) | |
| 2908 | { | |
| 2909 | for (size_t __i = 0; __i < _Rp; ++__i) | |
| 2910 | __x.__x_[__i] = __t[__i]; | |
| 2911 | __x.__c_ = __t[_Rp]; | |
| 2912 | __x.__i_ = 0; | |
| 2913 | } | |
| 2914 | return __is; | |
| 2915 | } | |
| 2916 | ||
| 2917 | typedef subtract_with_carry_engine<uint_fast32_t, 24, 10, 24> ranlux24_base; | |
| 2918 | typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base; | |
| 2919 | ||
| 2920 | // discard_block_engine | |
| 2921 | ||
| 2922 | template<class _Engine, size_t __p, size_t __r> | |
| 2923 | class _LIBCPP_TEMPLATE_VIS discard_block_engine | |
| 2924 | { | |
| 2925 | _Engine __e_; | |
| 2926 | int __n_; | |
| 2927 | ||
| 2928 | static_assert( 0 < __r, "discard_block_engine invalid parameters"); | |
| 2929 | static_assert(__r <= __p, "discard_block_engine invalid parameters"); | |
| 2930 | static_assert(__r <= INT_MAX, "discard_block_engine invalid parameters"); | |
| 2931 | public: | |
| 2932 | // types | |
| 2933 | typedef typename _Engine::result_type result_type; | |
| 2934 | ||
| 2935 | // engine characteristics | |
| 2936 | static _LIBCPP_CONSTEXPR const size_t block_size = __p; | |
| 2937 | static _LIBCPP_CONSTEXPR const size_t used_block = __r; | |
| 2938 | ||
| 2939 | #ifdef _LIBCPP_CXX03_LANG | |
| 2940 | static const result_type _Min = _Engine::_Min; | |
| 2941 | static const result_type _Max = _Engine::_Max; | |
| 2942 | #else | |
| 2943 | static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); | |
| 2944 | static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); | |
| 2945 | #endif | |
| 2946 | ||
| 2947 | _LIBCPP_INLINE_VISIBILITY | |
| 2948 | static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); } | |
| 2949 | _LIBCPP_INLINE_VISIBILITY | |
| 2950 | static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); } | |
| 2951 | ||
| 2952 | // constructors and seeding functions | |
| 2953 | _LIBCPP_INLINE_VISIBILITY | |
| 2954 | discard_block_engine() : __n_(0) {} | |
| 2955 | _LIBCPP_INLINE_VISIBILITY | |
| 2956 | explicit discard_block_engine(const _Engine& __e) | |
| 2957 | : __e_(__e), __n_(0) {} | |
| 2958 | #ifndef _LIBCPP_CXX03_LANG | |
| 2959 | _LIBCPP_INLINE_VISIBILITY | |
| 2960 | explicit discard_block_engine(_Engine&& __e) | |
| 2961 | : __e_(_VSTD::move(__e)), __n_(0) {} | |
| 2962 | #endif // _LIBCPP_CXX03_LANG | |
| 2963 | _LIBCPP_INLINE_VISIBILITY | |
| 2964 | explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {} | |
| 2965 | template<class _Sseq> | |
| 2966 | _LIBCPP_INLINE_VISIBILITY | |
| 2967 | explicit discard_block_engine(_Sseq& __q, | |
| 2968 | typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value && | |
| 2969 | !is_convertible<_Sseq, _Engine>::value>::type* = 0) | |
| 2970 | : __e_(__q), __n_(0) {} | |
| 2971 | _LIBCPP_INLINE_VISIBILITY | |
| 2972 | void seed() {__e_.seed(); __n_ = 0;} | |
| 2973 | _LIBCPP_INLINE_VISIBILITY | |
| 2974 | void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;} | |
| 2975 | template<class _Sseq> | |
| 2976 | _LIBCPP_INLINE_VISIBILITY | |
| 2977 | typename enable_if | |
| 2978 | < | |
| 2979 | __is_seed_sequence<_Sseq, discard_block_engine>::value, | |
| 2980 | void | |
| 2981 | >::type | |
| 2982 | seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;} | |
| 2983 | ||
| 2984 | // generating functions | |
| 2985 | result_type operator()(); | |
| 2986 | _LIBCPP_INLINE_VISIBILITY | |
| 2987 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 2988 | ||
| 2989 | // property functions | |
| 2990 | _LIBCPP_INLINE_VISIBILITY | |
| 2991 | const _Engine& base() const _NOEXCEPT {return __e_;} | |
| 2992 | ||
| 2993 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 2994 | friend | |
| 2995 | bool | |
| 2996 | operator==( | |
| 2997 | const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 2998 | const discard_block_engine<_Eng, _Pp, _Rp>& __y); | |
| 2999 | ||
| 3000 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 3001 | friend | |
| 3002 | bool | |
| 3003 | operator!=( | |
| 3004 | const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 3005 | const discard_block_engine<_Eng, _Pp, _Rp>& __y); | |
| 3006 | ||
| 3007 | template <class _CharT, class _Traits, | |
| 3008 | class _Eng, size_t _Pp, size_t _Rp> | |
| 3009 | friend | |
| 3010 | basic_ostream<_CharT, _Traits>& | |
| 3011 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3012 | const discard_block_engine<_Eng, _Pp, _Rp>& __x); | |
| 3013 | ||
| 3014 | template <class _CharT, class _Traits, | |
| 3015 | class _Eng, size_t _Pp, size_t _Rp> | |
| 3016 | friend | |
| 3017 | basic_istream<_CharT, _Traits>& | |
| 3018 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3019 | discard_block_engine<_Eng, _Pp, _Rp>& __x); | |
| 3020 | }; | |
| 3021 | ||
| 3022 | template<class _Engine, size_t __p, size_t __r> | |
| 3023 | _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size; | |
| 3024 | ||
| 3025 | template<class _Engine, size_t __p, size_t __r> | |
| 3026 | _LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block; | |
| 3027 | ||
| 3028 | template<class _Engine, size_t __p, size_t __r> | |
| 3029 | typename discard_block_engine<_Engine, __p, __r>::result_type | |
| 3030 | discard_block_engine<_Engine, __p, __r>::operator()() | |
| 3031 | { | |
| 3032 | if (__n_ >= static_cast<int>(__r)) | |
| 3033 | { | |
| 3034 | __e_.discard(__p - __r); | |
| 3035 | __n_ = 0; | |
| 3036 | } | |
| 3037 | ++__n_; | |
| 3038 | return __e_(); | |
| 3039 | } | |
| 3040 | ||
| 3041 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 3042 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3043 | bool | |
| 3044 | operator==(const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 3045 | const discard_block_engine<_Eng, _Pp, _Rp>& __y) | |
| 3046 | { | |
| 3047 | return __x.__n_ == __y.__n_ && __x.__e_ == __y.__e_; | |
| 3048 | } | |
| 3049 | ||
| 3050 | template<class _Eng, size_t _Pp, size_t _Rp> | |
| 3051 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3052 | bool | |
| 3053 | operator!=(const discard_block_engine<_Eng, _Pp, _Rp>& __x, | |
| 3054 | const discard_block_engine<_Eng, _Pp, _Rp>& __y) | |
| 3055 | { | |
| 3056 | return !(__x == __y); | |
| 3057 | } | |
| 3058 | ||
| 3059 | template <class _CharT, class _Traits, | |
| 3060 | class _Eng, size_t _Pp, size_t _Rp> | |
| 3061 | basic_ostream<_CharT, _Traits>& | |
| 3062 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3063 | const discard_block_engine<_Eng, _Pp, _Rp>& __x) | |
| 3064 | { | |
| 3065 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 3066 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 3067 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 3068 | _CharT __sp = __os.widen(' '); | |
| 3069 | __os.fill(__sp); | |
| 3070 | return __os << __x.__e_ << __sp << __x.__n_; | |
| 3071 | } | |
| 3072 | ||
| 3073 | template <class _CharT, class _Traits, | |
| 3074 | class _Eng, size_t _Pp, size_t _Rp> | |
| 3075 | basic_istream<_CharT, _Traits>& | |
| 3076 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3077 | discard_block_engine<_Eng, _Pp, _Rp>& __x) | |
| 3078 | { | |
| 3079 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 3080 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 3081 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 3082 | _Eng __e; | |
| 3083 | int __n; | |
| 3084 | __is >> __e >> __n; | |
| 3085 | if (!__is.fail()) | |
| 3086 | { | |
| 3087 | __x.__e_ = __e; | |
| 3088 | __x.__n_ = __n; | |
| 3089 | } | |
| 3090 | return __is; | |
| 3091 | } | |
| 3092 | ||
| 3093 | typedef discard_block_engine<ranlux24_base, 223, 23> ranlux24; | |
| 3094 | typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48; | |
| 3095 | ||
| 3096 | // independent_bits_engine | |
| 3097 | ||
| 3098 | template<class _Engine, size_t __w, class _UIntType> | |
| 3099 | class _LIBCPP_TEMPLATE_VIS independent_bits_engine | |
| 3100 | { | |
| 3101 | template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp> | |
| 3102 | class __get_n | |
| 3103 | { | |
| 3104 | static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits; | |
| 3105 | static _LIBCPP_CONSTEXPR const size_t _Np = _Wp / _Mp + (_Wp % _Mp != 0); | |
| 3106 | static _LIBCPP_CONSTEXPR const size_t _W0 = _Wp / _Np; | |
| 3107 | static _LIBCPP_CONSTEXPR const _UInt _Y0 = _W0 >= _Dt ? 0 : (_R0 >> _W0) << _W0; | |
| 3108 | public: | |
| 3109 | static _LIBCPP_CONSTEXPR const size_t value = _R0 - _Y0 > _Y0 / _Np ? _Np + 1 : _Np; | |
| 3110 | }; | |
| 3111 | public: | |
| 3112 | // types | |
| 3113 | typedef _UIntType result_type; | |
| 3114 | ||
| 3115 | private: | |
| 3116 | _Engine __e_; | |
| 3117 | ||
| 3118 | static _LIBCPP_CONSTEXPR const result_type _Dt = numeric_limits<result_type>::digits; | |
| 3119 | static_assert( 0 < __w, "independent_bits_engine invalid parameters"); | |
| 3120 | static_assert(__w <= _Dt, "independent_bits_engine invalid parameters"); | |
| 3121 | ||
| 3122 | typedef typename _Engine::result_type _Engine_result_type; | |
| 3123 | typedef typename conditional | |
| 3124 | < | |
| 3125 | sizeof(_Engine_result_type) <= sizeof(result_type), | |
| 3126 | result_type, | |
| 3127 | _Engine_result_type | |
| 3128 | >::type _Working_result_type; | |
| 3129 | #ifdef _LIBCPP_CXX03_LANG | |
| 3130 | static const _Working_result_type _Rp = _Engine::_Max - _Engine::_Min | |
| 3131 | + _Working_result_type(1); | |
| 3132 | #else | |
| 3133 | static _LIBCPP_CONSTEXPR const _Working_result_type _Rp = _Engine::max() - _Engine::min() | |
| 3134 | + _Working_result_type(1); | |
| 3135 | #endif | |
| 3136 | static _LIBCPP_CONSTEXPR const size_t __m = __log2<_Working_result_type, _Rp>::value; | |
| 3137 | static _LIBCPP_CONSTEXPR const size_t __n = __get_n<_Working_result_type, _Rp, __w, __m>::value; | |
| 3138 | static _LIBCPP_CONSTEXPR const size_t __w0 = __w / __n; | |
| 3139 | static _LIBCPP_CONSTEXPR const size_t __n0 = __n - __w % __n; | |
| 3140 | static _LIBCPP_CONSTEXPR const size_t _WDt = numeric_limits<_Working_result_type>::digits; | |
| 3141 | static _LIBCPP_CONSTEXPR const size_t _EDt = numeric_limits<_Engine_result_type>::digits; | |
| 3142 | static _LIBCPP_CONSTEXPR const _Working_result_type __y0 = __w0 >= _WDt ? 0 : | |
| 3143 | (_Rp >> __w0) << __w0; | |
| 3144 | static _LIBCPP_CONSTEXPR const _Working_result_type __y1 = __w0 >= _WDt - 1 ? 0 : | |
| 3145 | (_Rp >> (__w0+1)) << (__w0+1); | |
| 3146 | static _LIBCPP_CONSTEXPR const _Engine_result_type __mask0 = __w0 > 0 ? | |
| 3147 | _Engine_result_type(~0) >> (_EDt - __w0) : | |
| 3148 | _Engine_result_type(0); | |
| 3149 | static _LIBCPP_CONSTEXPR const _Engine_result_type __mask1 = __w0 < _EDt - 1 ? | |
| 3150 | _Engine_result_type(~0) >> (_EDt - (__w0 + 1)) : | |
| 3151 | _Engine_result_type(~0); | |
| 3152 | public: | |
| 3153 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 3154 | static _LIBCPP_CONSTEXPR const result_type _Max = __w == _Dt ? result_type(~0) : | |
| 3155 | (result_type(1) << __w) - result_type(1); | |
| 3156 | static_assert(_Min < _Max, "independent_bits_engine invalid parameters"); | |
| 3157 | ||
| 3158 | // engine characteristics | |
| 3159 | _LIBCPP_INLINE_VISIBILITY | |
| 3160 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 3161 | _LIBCPP_INLINE_VISIBILITY | |
| 3162 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 3163 | ||
| 3164 | // constructors and seeding functions | |
| 3165 | _LIBCPP_INLINE_VISIBILITY | |
| 3166 | independent_bits_engine() {} | |
| 3167 | _LIBCPP_INLINE_VISIBILITY | |
| 3168 | explicit independent_bits_engine(const _Engine& __e) | |
| 3169 | : __e_(__e) {} | |
| 3170 | #ifndef _LIBCPP_CXX03_LANG | |
| 3171 | _LIBCPP_INLINE_VISIBILITY | |
| 3172 | explicit independent_bits_engine(_Engine&& __e) | |
| 3173 | : __e_(_VSTD::move(__e)) {} | |
| 3174 | #endif // _LIBCPP_CXX03_LANG | |
| 3175 | _LIBCPP_INLINE_VISIBILITY | |
| 3176 | explicit independent_bits_engine(result_type __sd) : __e_(__sd) {} | |
| 3177 | template<class _Sseq> | |
| 3178 | _LIBCPP_INLINE_VISIBILITY | |
| 3179 | explicit independent_bits_engine(_Sseq& __q, | |
| 3180 | typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value && | |
| 3181 | !is_convertible<_Sseq, _Engine>::value>::type* = 0) | |
| 3182 | : __e_(__q) {} | |
| 3183 | _LIBCPP_INLINE_VISIBILITY | |
| 3184 | void seed() {__e_.seed();} | |
| 3185 | _LIBCPP_INLINE_VISIBILITY | |
| 3186 | void seed(result_type __sd) {__e_.seed(__sd);} | |
| 3187 | template<class _Sseq> | |
| 3188 | _LIBCPP_INLINE_VISIBILITY | |
| 3189 | typename enable_if | |
| 3190 | < | |
| 3191 | __is_seed_sequence<_Sseq, independent_bits_engine>::value, | |
| 3192 | void | |
| 3193 | >::type | |
| 3194 | seed(_Sseq& __q) {__e_.seed(__q);} | |
| 3195 | ||
| 3196 | // generating functions | |
| 3197 | _LIBCPP_INLINE_VISIBILITY | |
| 3198 | result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());} | |
| 3199 | _LIBCPP_INLINE_VISIBILITY | |
| 3200 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 3201 | ||
| 3202 | // property functions | |
| 3203 | _LIBCPP_INLINE_VISIBILITY | |
| 3204 | const _Engine& base() const _NOEXCEPT {return __e_;} | |
| 3205 | ||
| 3206 | template<class _Eng, size_t _Wp, class _UInt> | |
| 3207 | friend | |
| 3208 | bool | |
| 3209 | operator==( | |
| 3210 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 3211 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y); | |
| 3212 | ||
| 3213 | template<class _Eng, size_t _Wp, class _UInt> | |
| 3214 | friend | |
| 3215 | bool | |
| 3216 | operator!=( | |
| 3217 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 3218 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y); | |
| 3219 | ||
| 3220 | template <class _CharT, class _Traits, | |
| 3221 | class _Eng, size_t _Wp, class _UInt> | |
| 3222 | friend | |
| 3223 | basic_ostream<_CharT, _Traits>& | |
| 3224 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3225 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x); | |
| 3226 | ||
| 3227 | template <class _CharT, class _Traits, | |
| 3228 | class _Eng, size_t _Wp, class _UInt> | |
| 3229 | friend | |
| 3230 | basic_istream<_CharT, _Traits>& | |
| 3231 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3232 | independent_bits_engine<_Eng, _Wp, _UInt>& __x); | |
| 3233 | ||
| 3234 | private: | |
| 3235 | _LIBCPP_INLINE_VISIBILITY | |
| 3236 | result_type __eval(false_type); | |
| 3237 | result_type __eval(true_type); | |
| 3238 | ||
| 3239 | template <size_t __count> | |
| 3240 | _LIBCPP_INLINE_VISIBILITY | |
| 3241 | static | |
| 3242 | typename enable_if | |
| 3243 | < | |
| 3244 | __count < _Dt, | |
| 3245 | result_type | |
| 3246 | >::type | |
| 3247 | __lshift(result_type __x) {return __x << __count;} | |
| 3248 | ||
| 3249 | template <size_t __count> | |
| 3250 | _LIBCPP_INLINE_VISIBILITY | |
| 3251 | static | |
| 3252 | typename enable_if | |
| 3253 | < | |
| 3254 | (__count >= _Dt), | |
| 3255 | result_type | |
| 3256 | >::type | |
| 3257 | __lshift(result_type) {return result_type(0);} | |
| 3258 | }; | |
| 3259 | ||
| 3260 | template<class _Engine, size_t __w, class _UIntType> | |
| 3261 | inline | |
| 3262 | _UIntType | |
| 3263 | independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) | |
| 3264 | { | |
| 3265 | return static_cast<result_type>(__e_() & __mask0); | |
| 3266 | } | |
| 3267 | ||
| 3268 | template<class _Engine, size_t __w, class _UIntType> | |
| 3269 | _UIntType | |
| 3270 | independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) | |
| 3271 | { | |
| 3272 | result_type _Sp = 0; | |
| 3273 | for (size_t __k = 0; __k < __n0; ++__k) | |
| 3274 | { | |
| 3275 | _Engine_result_type __u; | |
| 3276 | do | |
| 3277 | { | |
| 3278 | __u = __e_() - _Engine::min(); | |
| 3279 | } while (__u >= __y0); | |
| 3280 | _Sp = static_cast<result_type>(__lshift<__w0>(_Sp) + (__u & __mask0)); | |
| 3281 | } | |
| 3282 | for (size_t __k = __n0; __k < __n; ++__k) | |
| 3283 | { | |
| 3284 | _Engine_result_type __u; | |
| 3285 | do | |
| 3286 | { | |
| 3287 | __u = __e_() - _Engine::min(); | |
| 3288 | } while (__u >= __y1); | |
| 3289 | _Sp = static_cast<result_type>(__lshift<__w0+1>(_Sp) + (__u & __mask1)); | |
| 3290 | } | |
| 3291 | return _Sp; | |
| 3292 | } | |
| 3293 | ||
| 3294 | template<class _Eng, size_t _Wp, class _UInt> | |
| 3295 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3296 | bool | |
| 3297 | operator==( | |
| 3298 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 3299 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y) | |
| 3300 | { | |
| 3301 | return __x.base() == __y.base(); | |
| 3302 | } | |
| 3303 | ||
| 3304 | template<class _Eng, size_t _Wp, class _UInt> | |
| 3305 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3306 | bool | |
| 3307 | operator!=( | |
| 3308 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x, | |
| 3309 | const independent_bits_engine<_Eng, _Wp, _UInt>& __y) | |
| 3310 | { | |
| 3311 | return !(__x == __y); | |
| 3312 | } | |
| 3313 | ||
| 3314 | template <class _CharT, class _Traits, | |
| 3315 | class _Eng, size_t _Wp, class _UInt> | |
| 3316 | basic_ostream<_CharT, _Traits>& | |
| 3317 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3318 | const independent_bits_engine<_Eng, _Wp, _UInt>& __x) | |
| 3319 | { | |
| 3320 | return __os << __x.base(); | |
| 3321 | } | |
| 3322 | ||
| 3323 | template <class _CharT, class _Traits, | |
| 3324 | class _Eng, size_t _Wp, class _UInt> | |
| 3325 | basic_istream<_CharT, _Traits>& | |
| 3326 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3327 | independent_bits_engine<_Eng, _Wp, _UInt>& __x) | |
| 3328 | { | |
| 3329 | _Eng __e; | |
| 3330 | __is >> __e; | |
| 3331 | if (!__is.fail()) | |
| 3332 | __x.__e_ = __e; | |
| 3333 | return __is; | |
| 3334 | } | |
| 3335 | ||
| 3336 | // shuffle_order_engine | |
| 3337 | ||
| 3338 | template <uint64_t _Xp, uint64_t _Yp> | |
| 3339 | struct __ugcd | |
| 3340 | { | |
| 3341 | static _LIBCPP_CONSTEXPR const uint64_t value = __ugcd<_Yp, _Xp % _Yp>::value; | |
| 3342 | }; | |
| 3343 | ||
| 3344 | template <uint64_t _Xp> | |
| 3345 | struct __ugcd<_Xp, 0> | |
| 3346 | { | |
| 3347 | static _LIBCPP_CONSTEXPR const uint64_t value = _Xp; | |
| 3348 | }; | |
| 3349 | ||
| 3350 | template <uint64_t _Np, uint64_t _Dp> | |
| 3351 | class __uratio | |
| 3352 | { | |
| 3353 | static_assert(_Dp != 0, "__uratio divide by 0"); | |
| 3354 | static _LIBCPP_CONSTEXPR const uint64_t __gcd = __ugcd<_Np, _Dp>::value; | |
| 3355 | public: | |
| 3356 | static _LIBCPP_CONSTEXPR const uint64_t num = _Np / __gcd; | |
| 3357 | static _LIBCPP_CONSTEXPR const uint64_t den = _Dp / __gcd; | |
| 3358 | ||
| 3359 | typedef __uratio<num, den> type; | |
| 3360 | }; | |
| 3361 | ||
| 3362 | template<class _Engine, size_t __k> | |
| 3363 | class _LIBCPP_TEMPLATE_VIS shuffle_order_engine | |
| 3364 | { | |
| 3365 | static_assert(0 < __k, "shuffle_order_engine invalid parameters"); | |
| 3366 | public: | |
| 3367 | // types | |
| 3368 | typedef typename _Engine::result_type result_type; | |
| 3369 | ||
| 3370 | private: | |
| 3371 | _Engine __e_; | |
| 3372 | result_type _V_[__k]; | |
| 3373 | result_type _Y_; | |
| 3374 | ||
| 3375 | public: | |
| 3376 | // engine characteristics | |
| 3377 | static _LIBCPP_CONSTEXPR const size_t table_size = __k; | |
| 3378 | ||
| 3379 | #ifdef _LIBCPP_CXX03_LANG | |
| 3380 | static const result_type _Min = _Engine::_Min; | |
| 3381 | static const result_type _Max = _Engine::_Max; | |
| 3382 | #else | |
| 3383 | static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min(); | |
| 3384 | static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max(); | |
| 3385 | #endif | |
| 3386 | static_assert(_Min < _Max, "shuffle_order_engine invalid parameters"); | |
| 3387 | _LIBCPP_INLINE_VISIBILITY | |
| 3388 | static _LIBCPP_CONSTEXPR result_type min() { return _Min; } | |
| 3389 | _LIBCPP_INLINE_VISIBILITY | |
| 3390 | static _LIBCPP_CONSTEXPR result_type max() { return _Max; } | |
| 3391 | ||
| 3392 | static _LIBCPP_CONSTEXPR const unsigned long long _Rp = _Max - _Min + 1ull; | |
| 3393 | ||
| 3394 | // constructors and seeding functions | |
| 3395 | _LIBCPP_INLINE_VISIBILITY | |
| 3396 | shuffle_order_engine() {__init();} | |
| 3397 | _LIBCPP_INLINE_VISIBILITY | |
| 3398 | explicit shuffle_order_engine(const _Engine& __e) | |
| 3399 | : __e_(__e) {__init();} | |
| 3400 | #ifndef _LIBCPP_CXX03_LANG | |
| 3401 | _LIBCPP_INLINE_VISIBILITY | |
| 3402 | explicit shuffle_order_engine(_Engine&& __e) | |
| 3403 | : __e_(_VSTD::move(__e)) {__init();} | |
| 3404 | #endif // _LIBCPP_CXX03_LANG | |
| 3405 | _LIBCPP_INLINE_VISIBILITY | |
| 3406 | explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();} | |
| 3407 | template<class _Sseq> | |
| 3408 | _LIBCPP_INLINE_VISIBILITY | |
| 3409 | explicit shuffle_order_engine(_Sseq& __q, | |
| 3410 | typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value && | |
| 3411 | !is_convertible<_Sseq, _Engine>::value>::type* = 0) | |
| 3412 | : __e_(__q) {__init();} | |
| 3413 | _LIBCPP_INLINE_VISIBILITY | |
| 3414 | void seed() {__e_.seed(); __init();} | |
| 3415 | _LIBCPP_INLINE_VISIBILITY | |
| 3416 | void seed(result_type __sd) {__e_.seed(__sd); __init();} | |
| 3417 | template<class _Sseq> | |
| 3418 | _LIBCPP_INLINE_VISIBILITY | |
| 3419 | typename enable_if | |
| 3420 | < | |
| 3421 | __is_seed_sequence<_Sseq, shuffle_order_engine>::value, | |
| 3422 | void | |
| 3423 | >::type | |
| 3424 | seed(_Sseq& __q) {__e_.seed(__q); __init();} | |
| 3425 | ||
| 3426 | // generating functions | |
| 3427 | _LIBCPP_INLINE_VISIBILITY | |
| 3428 | result_type operator()() {return __eval(integral_constant<bool, _Rp != 0>());} | |
| 3429 | _LIBCPP_INLINE_VISIBILITY | |
| 3430 | void discard(unsigned long long __z) {for (; __z; --__z) operator()();} | |
| 3431 | ||
| 3432 | // property functions | |
| 3433 | _LIBCPP_INLINE_VISIBILITY | |
| 3434 | const _Engine& base() const _NOEXCEPT {return __e_;} | |
| 3435 | ||
| 3436 | private: | |
| 3437 | template<class _Eng, size_t _Kp> | |
| 3438 | friend | |
| 3439 | bool | |
| 3440 | operator==( | |
| 3441 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 3442 | const shuffle_order_engine<_Eng, _Kp>& __y); | |
| 3443 | ||
| 3444 | template<class _Eng, size_t _Kp> | |
| 3445 | friend | |
| 3446 | bool | |
| 3447 | operator!=( | |
| 3448 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 3449 | const shuffle_order_engine<_Eng, _Kp>& __y); | |
| 3450 | ||
| 3451 | template <class _CharT, class _Traits, | |
| 3452 | class _Eng, size_t _Kp> | |
| 3453 | friend | |
| 3454 | basic_ostream<_CharT, _Traits>& | |
| 3455 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3456 | const shuffle_order_engine<_Eng, _Kp>& __x); | |
| 3457 | ||
| 3458 | template <class _CharT, class _Traits, | |
| 3459 | class _Eng, size_t _Kp> | |
| 3460 | friend | |
| 3461 | basic_istream<_CharT, _Traits>& | |
| 3462 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3463 | shuffle_order_engine<_Eng, _Kp>& __x); | |
| 3464 | ||
| 3465 | _LIBCPP_INLINE_VISIBILITY | |
| 3466 | void __init() | |
| 3467 | { | |
| 3468 | for (size_t __i = 0; __i < __k; ++__i) | |
| 3469 | _V_[__i] = __e_(); | |
| 3470 | _Y_ = __e_(); | |
| 3471 | } | |
| 3472 | ||
| 3473 | _LIBCPP_INLINE_VISIBILITY | |
| 3474 | result_type __eval(false_type) {return __eval2(integral_constant<bool, __k & 1>());} | |
| 3475 | _LIBCPP_INLINE_VISIBILITY | |
| 3476 | result_type __eval(true_type) {return __eval(__uratio<__k, _Rp>());} | |
| 3477 | ||
| 3478 | _LIBCPP_INLINE_VISIBILITY | |
| 3479 | result_type __eval2(false_type) {return __eval(__uratio<__k/2, 0x8000000000000000ull>());} | |
| 3480 | _LIBCPP_INLINE_VISIBILITY | |
| 3481 | result_type __eval2(true_type) {return __evalf<__k, 0>();} | |
| 3482 | ||
| 3483 | template <uint64_t _Np, uint64_t _Dp> | |
| 3484 | _LIBCPP_INLINE_VISIBILITY | |
| 3485 | typename enable_if | |
| 3486 | < | |
| 3487 | (__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)), | |
| 3488 | result_type | |
| 3489 | >::type | |
| 3490 | __eval(__uratio<_Np, _Dp>) | |
| 3491 | {return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();} | |
| 3492 | ||
| 3493 | template <uint64_t _Np, uint64_t _Dp> | |
| 3494 | _LIBCPP_INLINE_VISIBILITY | |
| 3495 | typename enable_if | |
| 3496 | < | |
| 3497 | __uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min), | |
| 3498 | result_type | |
| 3499 | >::type | |
| 3500 | __eval(__uratio<_Np, _Dp>) | |
| 3501 | { | |
| 3502 | const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (_Y_ - _Min) | |
| 3503 | / __uratio<_Np, _Dp>::den); | |
| 3504 | _Y_ = _V_[__j]; | |
| 3505 | _V_[__j] = __e_(); | |
| 3506 | return _Y_; | |
| 3507 | } | |
| 3508 | ||
| 3509 | template <uint64_t __n, uint64_t __d> | |
| 3510 | _LIBCPP_INLINE_VISIBILITY | |
| 3511 | result_type __evalf() | |
| 3512 | { | |
| 3513 | const double _Fp = __d == 0 ? | |
| 3514 | __n / (2. * 0x8000000000000000ull) : | |
| 3515 | __n / (double)__d; | |
| 3516 | const size_t __j = static_cast<size_t>(_Fp * (_Y_ - _Min)); | |
| 3517 | _Y_ = _V_[__j]; | |
| 3518 | _V_[__j] = __e_(); | |
| 3519 | return _Y_; | |
| 3520 | } | |
| 3521 | }; | |
| 3522 | ||
| 3523 | template<class _Engine, size_t __k> | |
| 3524 | _LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size; | |
| 3525 | ||
| 3526 | template<class _Eng, size_t _Kp> | |
| 3527 | bool | |
| 3528 | operator==( | |
| 3529 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 3530 | const shuffle_order_engine<_Eng, _Kp>& __y) | |
| 3531 | { | |
| 3532 | return __x._Y_ == __y._Y_ && _VSTD::equal(__x._V_, __x._V_ + _Kp, __y._V_) && | |
| 3533 | __x.__e_ == __y.__e_; | |
| 3534 | } | |
| 3535 | ||
| 3536 | template<class _Eng, size_t _Kp> | |
| 3537 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3538 | bool | |
| 3539 | operator!=( | |
| 3540 | const shuffle_order_engine<_Eng, _Kp>& __x, | |
| 3541 | const shuffle_order_engine<_Eng, _Kp>& __y) | |
| 3542 | { | |
| 3543 | return !(__x == __y); | |
| 3544 | } | |
| 3545 | ||
| 3546 | template <class _CharT, class _Traits, | |
| 3547 | class _Eng, size_t _Kp> | |
| 3548 | basic_ostream<_CharT, _Traits>& | |
| 3549 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3550 | const shuffle_order_engine<_Eng, _Kp>& __x) | |
| 3551 | { | |
| 3552 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 3553 | typedef basic_ostream<_CharT, _Traits> _Ostream; | |
| 3554 | __os.flags(_Ostream::dec | _Ostream::left); | |
| 3555 | _CharT __sp = __os.widen(' '); | |
| 3556 | __os.fill(__sp); | |
| 3557 | __os << __x.__e_ << __sp << __x._V_[0]; | |
| 3558 | for (size_t __i = 1; __i < _Kp; ++__i) | |
| 3559 | __os << __sp << __x._V_[__i]; | |
| 3560 | return __os << __sp << __x._Y_; | |
| 3561 | } | |
| 3562 | ||
| 3563 | template <class _CharT, class _Traits, | |
| 3564 | class _Eng, size_t _Kp> | |
| 3565 | basic_istream<_CharT, _Traits>& | |
| 3566 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3567 | shuffle_order_engine<_Eng, _Kp>& __x) | |
| 3568 | { | |
| 3569 | typedef typename shuffle_order_engine<_Eng, _Kp>::result_type result_type; | |
| 3570 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 3571 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 3572 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 3573 | _Eng __e; | |
| 3574 | result_type _Vp[_Kp+1]; | |
| 3575 | __is >> __e; | |
| 3576 | for (size_t __i = 0; __i < _Kp+1; ++__i) | |
| 3577 | __is >> _Vp[__i]; | |
| 3578 | if (!__is.fail()) | |
| 3579 | { | |
| 3580 | __x.__e_ = __e; | |
| 3581 | for (size_t __i = 0; __i < _Kp; ++__i) | |
| 3582 | __x._V_[__i] = _Vp[__i]; | |
| 3583 | __x._Y_ = _Vp[_Kp]; | |
| 3584 | } | |
| 3585 | return __is; | |
| 3586 | } | |
| 3587 | ||
| 3588 | typedef shuffle_order_engine<minstd_rand0, 256> knuth_b; | |
| 3589 | ||
| 3590 | // random_device | |
| 3591 | ||
| 3592 | #if !defined(_LIBCPP_HAS_NO_RANDOM_DEVICE) | |
| 3593 | ||
| 3594 | class _LIBCPP_TYPE_VIS random_device | |
| 3595 | { | |
| 3596 | #ifdef _LIBCPP_USING_DEV_RANDOM | |
| 3597 | int __f_; | |
| 3598 | #endif // defined(_LIBCPP_USING_DEV_RANDOM) | |
| 3599 | public: | |
| 3600 | // types | |
| 3601 | typedef unsigned result_type; | |
| 3602 | ||
| 3603 | // generator characteristics | |
| 3604 | static _LIBCPP_CONSTEXPR const result_type _Min = 0; | |
| 3605 | static _LIBCPP_CONSTEXPR const result_type _Max = 0xFFFFFFFFu; | |
| 3606 | ||
| 3607 | _LIBCPP_INLINE_VISIBILITY | |
| 3608 | static _LIBCPP_CONSTEXPR result_type min() { return _Min;} | |
| 3609 | _LIBCPP_INLINE_VISIBILITY | |
| 3610 | static _LIBCPP_CONSTEXPR result_type max() { return _Max;} | |
| 3611 | ||
| 3612 | // constructors | |
| 3613 | #ifndef _LIBCPP_CXX03_LANG | |
| 3614 | random_device() : random_device("/dev/urandom") {} | |
| 3615 | explicit random_device(const string& __token); | |
| 3616 | #else | |
| 3617 | explicit random_device(const string& __token = "/dev/urandom"); | |
| 3618 | #endif | |
| 3619 | ~random_device(); | |
| 3620 | ||
| 3621 | // generating functions | |
| 3622 | result_type operator()(); | |
| 3623 | ||
| 3624 | // property functions | |
| 3625 | double entropy() const _NOEXCEPT; | |
| 3626 | ||
| 3627 | private: | |
| 3628 | // no copy functions | |
| 3629 | random_device(const random_device&); // = delete; | |
| 3630 | random_device& operator=(const random_device&); // = delete; | |
| 3631 | }; | |
| 3632 | ||
| 3633 | #endif // !_LIBCPP_HAS_NO_RANDOM_DEVICE | |
| 3634 | ||
| 3635 | // seed_seq | |
| 3636 | ||
| 3637 | class _LIBCPP_TEMPLATE_VIS seed_seq | |
| 3638 | { | |
| 3639 | public: | |
| 3640 | // types | |
| 3641 | typedef uint32_t result_type; | |
| 3642 | ||
| 3643 | private: | |
| 3644 | vector<result_type> __v_; | |
| 3645 | ||
| 3646 | template<class _InputIterator> | |
| 3647 | void init(_InputIterator __first, _InputIterator __last); | |
| 3648 | public: | |
| 3649 | // constructors | |
| 3650 | _LIBCPP_INLINE_VISIBILITY | |
| 3651 | seed_seq() _NOEXCEPT {} | |
| 3652 | #ifndef _LIBCPP_CXX03_LANG | |
| 3653 | template<class _Tp> | |
| 3654 | _LIBCPP_INLINE_VISIBILITY | |
| 3655 | seed_seq(initializer_list<_Tp> __il) {init(__il.begin(), __il.end());} | |
| 3656 | #endif // _LIBCPP_CXX03_LANG | |
| 3657 | ||
| 3658 | template<class _InputIterator> | |
| 3659 | _LIBCPP_INLINE_VISIBILITY | |
| 3660 | seed_seq(_InputIterator __first, _InputIterator __last) | |
| 3661 | {init(__first, __last);} | |
| 3662 | ||
| 3663 | // generating functions | |
| 3664 | template<class _RandomAccessIterator> | |
| 3665 | void generate(_RandomAccessIterator __first, _RandomAccessIterator __last); | |
| 3666 | ||
| 3667 | // property functions | |
| 3668 | _LIBCPP_INLINE_VISIBILITY | |
| 3669 | size_t size() const _NOEXCEPT {return __v_.size();} | |
| 3670 | template<class _OutputIterator> | |
| 3671 | _LIBCPP_INLINE_VISIBILITY | |
| 3672 | void param(_OutputIterator __dest) const | |
| 3673 | {_VSTD::copy(__v_.begin(), __v_.end(), __dest);} | |
| 3674 | ||
| 3675 | private: | |
| 3676 | // no copy functions | |
| 3677 | seed_seq(const seed_seq&); // = delete; | |
| 3678 | void operator=(const seed_seq&); // = delete; | |
| 3679 | ||
| 3680 | _LIBCPP_INLINE_VISIBILITY | |
| 3681 | static result_type _Tp(result_type __x) {return __x ^ (__x >> 27);} | |
| 3682 | }; | |
| 3683 | ||
| 3684 | template<class _InputIterator> | |
| 3685 | void | |
| 3686 | seed_seq::init(_InputIterator __first, _InputIterator __last) | |
| 3687 | { | |
| 3688 | for (_InputIterator __s = __first; __s != __last; ++__s) | |
| 3689 | __v_.push_back(*__s & 0xFFFFFFFF); | |
| 3690 | } | |
| 3691 | ||
| 3692 | template<class _RandomAccessIterator> | |
| 3693 | void | |
| 3694 | seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 3695 | { | |
| 3696 | if (__first != __last) | |
| 3697 | { | |
| 3698 | _VSTD::fill(__first, __last, 0x8b8b8b8b); | |
| 3699 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 3700 | const size_t __s = __v_.size(); | |
| 3701 | const size_t __t = (__n >= 623) ? 11 | |
| 3702 | : (__n >= 68) ? 7 | |
| 3703 | : (__n >= 39) ? 5 | |
| 3704 | : (__n >= 7) ? 3 | |
| 3705 | : (__n - 1) / 2; | |
| 3706 | const size_t __p = (__n - __t) / 2; | |
| 3707 | const size_t __q = __p + __t; | |
| 3708 | const size_t __m = _VSTD::max(__s + 1, __n); | |
| 3709 | // __k = 0; | |
| 3710 | { | |
| 3711 | result_type __r = 1664525 * _Tp(__first[0] ^ __first[__p] | |
| 3712 | ^ __first[__n - 1]); | |
| 3713 | __first[__p] += __r; | |
| 3714 | __r += __s; | |
| 3715 | __first[__q] += __r; | |
| 3716 | __first[0] = __r; | |
| 3717 | } | |
| 3718 | for (size_t __k = 1; __k <= __s; ++__k) | |
| 3719 | { | |
| 3720 | const size_t __kmodn = __k % __n; | |
| 3721 | const size_t __kpmodn = (__k + __p) % __n; | |
| 3722 | result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] | |
| 3723 | ^ __first[(__k - 1) % __n]); | |
| 3724 | __first[__kpmodn] += __r; | |
| 3725 | __r += __kmodn + __v_[__k-1]; | |
| 3726 | __first[(__k + __q) % __n] += __r; | |
| 3727 | __first[__kmodn] = __r; | |
| 3728 | } | |
| 3729 | for (size_t __k = __s + 1; __k < __m; ++__k) | |
| 3730 | { | |
| 3731 | const size_t __kmodn = __k % __n; | |
| 3732 | const size_t __kpmodn = (__k + __p) % __n; | |
| 3733 | result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] | |
| 3734 | ^ __first[(__k - 1) % __n]); | |
| 3735 | __first[__kpmodn] += __r; | |
| 3736 | __r += __kmodn; | |
| 3737 | __first[(__k + __q) % __n] += __r; | |
| 3738 | __first[__kmodn] = __r; | |
| 3739 | } | |
| 3740 | for (size_t __k = __m; __k < __m + __n; ++__k) | |
| 3741 | { | |
| 3742 | const size_t __kmodn = __k % __n; | |
| 3743 | const size_t __kpmodn = (__k + __p) % __n; | |
| 3744 | result_type __r = 1566083941 * _Tp(__first[__kmodn] + | |
| 3745 | __first[__kpmodn] + | |
| 3746 | __first[(__k - 1) % __n]); | |
| 3747 | __first[__kpmodn] ^= __r; | |
| 3748 | __r -= __kmodn; | |
| 3749 | __first[(__k + __q) % __n] ^= __r; | |
| 3750 | __first[__kmodn] = __r; | |
| 3751 | } | |
| 3752 | } | |
| 3753 | } | |
| 3754 | ||
| 3755 | // generate_canonical | |
| 3756 | ||
| 3757 | template<class _RealType, size_t __bits, class _URNG> | |
| 3758 | _RealType | |
| 3759 | generate_canonical(_URNG& __g) | |
| 3760 | { | |
| 3761 | const size_t _Dt = numeric_limits<_RealType>::digits; | |
| 3762 | const size_t __b = _Dt < __bits ? _Dt : __bits; | |
| 3763 | #ifdef _LIBCPP_CXX03_LANG | |
| 3764 | const size_t __logR = __log2<uint64_t, _URNG::_Max - _URNG::_Min + uint64_t(1)>::value; | |
| 3765 | #else | |
| 3766 | const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value; | |
| 3767 | #endif | |
| 3768 | const size_t __k = __b / __logR + (__b % __logR != 0) + (__b == 0); | |
| 3769 | const _RealType _Rp = static_cast<_RealType>(_URNG::max() - _URNG::min()) + _RealType(1); | |
| 3770 | _RealType __base = _Rp; | |
| 3771 | _RealType _Sp = __g() - _URNG::min(); | |
| 3772 | for (size_t __i = 1; __i < __k; ++__i, __base *= _Rp) | |
| 3773 | _Sp += (__g() - _URNG::min()) * __base; | |
| 3774 | return _Sp / __base; | |
| 3775 | } | |
| 3776 | ||
| 3777 | // uniform_real_distribution | |
| 3778 | ||
| 3779 | template<class _RealType = double> | |
| 3780 | class _LIBCPP_TEMPLATE_VIS uniform_real_distribution | |
| 3781 | { | |
| 3782 | public: | |
| 3783 | // types | |
| 3784 | typedef _RealType result_type; | |
| 3785 | ||
| 3786 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 3787 | { | |
| 3788 | result_type __a_; | |
| 3789 | result_type __b_; | |
| 3790 | public: | |
| 3791 | typedef uniform_real_distribution distribution_type; | |
| 3792 | ||
| 3793 | _LIBCPP_INLINE_VISIBILITY | |
| 3794 | explicit param_type(result_type __a = 0, | |
| 3795 | result_type __b = 1) | |
| 3796 | : __a_(__a), __b_(__b) {} | |
| 3797 | ||
| 3798 | _LIBCPP_INLINE_VISIBILITY | |
| 3799 | result_type a() const {return __a_;} | |
| 3800 | _LIBCPP_INLINE_VISIBILITY | |
| 3801 | result_type b() const {return __b_;} | |
| 3802 | ||
| 3803 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3804 | bool operator==(const param_type& __x, const param_type& __y) | |
| 3805 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 3806 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3807 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 3808 | {return !(__x == __y);} | |
| 3809 | }; | |
| 3810 | ||
| 3811 | private: | |
| 3812 | param_type __p_; | |
| 3813 | ||
| 3814 | public: | |
| 3815 | // constructors and reset functions | |
| 3816 | #ifndef _LIBCPP_CXX03_LANG | |
| 3817 | _LIBCPP_INLINE_VISIBILITY | |
| 3818 | uniform_real_distribution() : uniform_real_distribution(0) {} | |
| 3819 | explicit uniform_real_distribution(result_type __a, result_type __b = 1) | |
| 3820 | : __p_(param_type(__a, __b)) {} | |
| 3821 | #else | |
| 3822 | _LIBCPP_INLINE_VISIBILITY | |
| 3823 | explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1) | |
| 3824 | : __p_(param_type(__a, __b)) {} | |
| 3825 | #endif | |
| 3826 | _LIBCPP_INLINE_VISIBILITY | |
| 3827 | explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {} | |
| 3828 | _LIBCPP_INLINE_VISIBILITY | |
| 3829 | void reset() {} | |
| 3830 | ||
| 3831 | // generating functions | |
| 3832 | template<class _URNG> | |
| 3833 | _LIBCPP_INLINE_VISIBILITY | |
| 3834 | result_type operator()(_URNG& __g) | |
| 3835 | {return (*this)(__g, __p_);} | |
| 3836 | template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); | |
| 3837 | ||
| 3838 | // property functions | |
| 3839 | _LIBCPP_INLINE_VISIBILITY | |
| 3840 | result_type a() const {return __p_.a();} | |
| 3841 | _LIBCPP_INLINE_VISIBILITY | |
| 3842 | result_type b() const {return __p_.b();} | |
| 3843 | ||
| 3844 | _LIBCPP_INLINE_VISIBILITY | |
| 3845 | param_type param() const {return __p_;} | |
| 3846 | _LIBCPP_INLINE_VISIBILITY | |
| 3847 | void param(const param_type& __p) {__p_ = __p;} | |
| 3848 | ||
| 3849 | _LIBCPP_INLINE_VISIBILITY | |
| 3850 | result_type min() const {return a();} | |
| 3851 | _LIBCPP_INLINE_VISIBILITY | |
| 3852 | result_type max() const {return b();} | |
| 3853 | ||
| 3854 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3855 | bool operator==(const uniform_real_distribution& __x, | |
| 3856 | const uniform_real_distribution& __y) | |
| 3857 | {return __x.__p_ == __y.__p_;} | |
| 3858 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3859 | bool operator!=(const uniform_real_distribution& __x, | |
| 3860 | const uniform_real_distribution& __y) | |
| 3861 | {return !(__x == __y);} | |
| 3862 | }; | |
| 3863 | ||
| 3864 | template<class _RealType> | |
| 3865 | template<class _URNG> | |
| 3866 | inline | |
| 3867 | typename uniform_real_distribution<_RealType>::result_type | |
| 3868 | uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 3869 | { | |
| 3870 | return (__p.b() - __p.a()) | |
| 3871 | * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g) | |
| 3872 | + __p.a(); | |
| 3873 | } | |
| 3874 | ||
| 3875 | template <class _CharT, class _Traits, class _RT> | |
| 3876 | basic_ostream<_CharT, _Traits>& | |
| 3877 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 3878 | const uniform_real_distribution<_RT>& __x) | |
| 3879 | { | |
| 3880 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 3881 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 3882 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 3883 | _OStream::scientific); | |
| 3884 | _CharT __sp = __os.widen(' '); | |
| 3885 | __os.fill(__sp); | |
| 3886 | return __os << __x.a() << __sp << __x.b(); | |
| 3887 | } | |
| 3888 | ||
| 3889 | template <class _CharT, class _Traits, class _RT> | |
| 3890 | basic_istream<_CharT, _Traits>& | |
| 3891 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 3892 | uniform_real_distribution<_RT>& __x) | |
| 3893 | { | |
| 3894 | typedef uniform_real_distribution<_RT> _Eng; | |
| 3895 | typedef typename _Eng::result_type result_type; | |
| 3896 | typedef typename _Eng::param_type param_type; | |
| 3897 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 3898 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 3899 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 3900 | result_type __a; | |
| 3901 | result_type __b; | |
| 3902 | __is >> __a >> __b; | |
| 3903 | if (!__is.fail()) | |
| 3904 | __x.param(param_type(__a, __b)); | |
| 3905 | return __is; | |
| 3906 | } | |
| 3907 | ||
| 3908 | // bernoulli_distribution | |
| 3909 | ||
| 3910 | class _LIBCPP_TEMPLATE_VIS bernoulli_distribution | |
| 3911 | { | |
| 3912 | public: | |
| 3913 | // types | |
| 3914 | typedef bool result_type; | |
| 3915 | ||
| 3916 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 3917 | { | |
| 3918 | double __p_; | |
| 3919 | public: | |
| 3920 | typedef bernoulli_distribution distribution_type; | |
| 3921 | ||
| 3922 | _LIBCPP_INLINE_VISIBILITY | |
| 3923 | explicit param_type(double __p = 0.5) : __p_(__p) {} | |
| 3924 | ||
| 3925 | _LIBCPP_INLINE_VISIBILITY | |
| 3926 | double p() const {return __p_;} | |
| 3927 | ||
| 3928 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3929 | bool operator==(const param_type& __x, const param_type& __y) | |
| 3930 | {return __x.__p_ == __y.__p_;} | |
| 3931 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3932 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 3933 | {return !(__x == __y);} | |
| 3934 | }; | |
| 3935 | ||
| 3936 | private: | |
| 3937 | param_type __p_; | |
| 3938 | ||
| 3939 | public: | |
| 3940 | // constructors and reset functions | |
| 3941 | #ifndef _LIBCPP_CXX03_LANG | |
| 3942 | _LIBCPP_INLINE_VISIBILITY | |
| 3943 | bernoulli_distribution() : bernoulli_distribution(0.5) {} | |
| 3944 | _LIBCPP_INLINE_VISIBILITY | |
| 3945 | explicit bernoulli_distribution(double __p) : __p_(param_type(__p)) {} | |
| 3946 | #else | |
| 3947 | _LIBCPP_INLINE_VISIBILITY | |
| 3948 | explicit bernoulli_distribution(double __p = 0.5) : __p_(param_type(__p)) {} | |
| 3949 | #endif | |
| 3950 | _LIBCPP_INLINE_VISIBILITY | |
| 3951 | explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {} | |
| 3952 | _LIBCPP_INLINE_VISIBILITY | |
| 3953 | void reset() {} | |
| 3954 | ||
| 3955 | // generating functions | |
| 3956 | template<class _URNG> | |
| 3957 | _LIBCPP_INLINE_VISIBILITY | |
| 3958 | result_type operator()(_URNG& __g) | |
| 3959 | {return (*this)(__g, __p_);} | |
| 3960 | template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); | |
| 3961 | ||
| 3962 | // property functions | |
| 3963 | _LIBCPP_INLINE_VISIBILITY | |
| 3964 | double p() const {return __p_.p();} | |
| 3965 | ||
| 3966 | _LIBCPP_INLINE_VISIBILITY | |
| 3967 | param_type param() const {return __p_;} | |
| 3968 | _LIBCPP_INLINE_VISIBILITY | |
| 3969 | void param(const param_type& __p) {__p_ = __p;} | |
| 3970 | ||
| 3971 | _LIBCPP_INLINE_VISIBILITY | |
| 3972 | result_type min() const {return false;} | |
| 3973 | _LIBCPP_INLINE_VISIBILITY | |
| 3974 | result_type max() const {return true;} | |
| 3975 | ||
| 3976 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3977 | bool operator==(const bernoulli_distribution& __x, | |
| 3978 | const bernoulli_distribution& __y) | |
| 3979 | {return __x.__p_ == __y.__p_;} | |
| 3980 | friend _LIBCPP_INLINE_VISIBILITY | |
| 3981 | bool operator!=(const bernoulli_distribution& __x, | |
| 3982 | const bernoulli_distribution& __y) | |
| 3983 | {return !(__x == __y);} | |
| 3984 | }; | |
| 3985 | ||
| 3986 | template<class _URNG> | |
| 3987 | inline | |
| 3988 | bernoulli_distribution::result_type | |
| 3989 | bernoulli_distribution::operator()(_URNG& __g, const param_type& __p) | |
| 3990 | { | |
| 3991 | uniform_real_distribution<double> __gen; | |
| 3992 | return __gen(__g) < __p.p(); | |
| 3993 | } | |
| 3994 | ||
| 3995 | template <class _CharT, class _Traits> | |
| 3996 | basic_ostream<_CharT, _Traits>& | |
| 3997 | operator<<(basic_ostream<_CharT, _Traits>& __os, const bernoulli_distribution& __x) | |
| 3998 | { | |
| 3999 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 4000 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 4001 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 4002 | _OStream::scientific); | |
| 4003 | _CharT __sp = __os.widen(' '); | |
| 4004 | __os.fill(__sp); | |
| 4005 | return __os << __x.p(); | |
| 4006 | } | |
| 4007 | ||
| 4008 | template <class _CharT, class _Traits> | |
| 4009 | basic_istream<_CharT, _Traits>& | |
| 4010 | operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x) | |
| 4011 | { | |
| 4012 | typedef bernoulli_distribution _Eng; | |
| 4013 | typedef typename _Eng::param_type param_type; | |
| 4014 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 4015 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 4016 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 4017 | double __p; | |
| 4018 | __is >> __p; | |
| 4019 | if (!__is.fail()) | |
| 4020 | __x.param(param_type(__p)); | |
| 4021 | return __is; | |
| 4022 | } | |
| 4023 | ||
| 4024 | // binomial_distribution | |
| 4025 | ||
| 4026 | template<class _IntType = int> | |
| 4027 | class _LIBCPP_TEMPLATE_VIS binomial_distribution | |
| 4028 | { | |
| 4029 | public: | |
| 4030 | // types | |
| 4031 | typedef _IntType result_type; | |
| 4032 | ||
| 4033 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 4034 | { | |
| 4035 | result_type __t_; | |
| 4036 | double __p_; | |
| 4037 | double __pr_; | |
| 4038 | double __odds_ratio_; | |
| 4039 | result_type __r0_; | |
| 4040 | public: | |
| 4041 | typedef binomial_distribution distribution_type; | |
| 4042 | ||
| 4043 | explicit param_type(result_type __t = 1, double __p = 0.5); | |
| 4044 | ||
| 4045 | _LIBCPP_INLINE_VISIBILITY | |
| 4046 | result_type t() const {return __t_;} | |
| 4047 | _LIBCPP_INLINE_VISIBILITY | |
| 4048 | double p() const {return __p_;} | |
| 4049 | ||
| 4050 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4051 | bool operator==(const param_type& __x, const param_type& __y) | |
| 4052 | {return __x.__t_ == __y.__t_ && __x.__p_ == __y.__p_;} | |
| 4053 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4054 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 4055 | {return !(__x == __y);} | |
| 4056 | ||
| 4057 | friend class binomial_distribution; | |
| 4058 | }; | |
| 4059 | ||
| 4060 | private: | |
| 4061 | param_type __p_; | |
| 4062 | ||
| 4063 | public: | |
| 4064 | // constructors and reset functions | |
| 4065 | #ifndef _LIBCPP_CXX03_LANG | |
| 4066 | _LIBCPP_INLINE_VISIBILITY | |
| 4067 | binomial_distribution() : binomial_distribution(1) {} | |
| 4068 | _LIBCPP_INLINE_VISIBILITY | |
| 4069 | explicit binomial_distribution(result_type __t, double __p = 0.5) | |
| 4070 | : __p_(param_type(__t, __p)) {} | |
| 4071 | #else | |
| 4072 | _LIBCPP_INLINE_VISIBILITY | |
| 4073 | explicit binomial_distribution(result_type __t = 1, double __p = 0.5) | |
| 4074 | : __p_(param_type(__t, __p)) {} | |
| 4075 | #endif | |
| 4076 | _LIBCPP_INLINE_VISIBILITY | |
| 4077 | explicit binomial_distribution(const param_type& __p) : __p_(__p) {} | |
| 4078 | _LIBCPP_INLINE_VISIBILITY | |
| 4079 | void reset() {} | |
| 4080 | ||
| 4081 | // generating functions | |
| 4082 | template<class _URNG> | |
| 4083 | _LIBCPP_INLINE_VISIBILITY | |
| 4084 | result_type operator()(_URNG& __g) | |
| 4085 | {return (*this)(__g, __p_);} | |
| 4086 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 4087 | ||
| 4088 | // property functions | |
| 4089 | _LIBCPP_INLINE_VISIBILITY | |
| 4090 | result_type t() const {return __p_.t();} | |
| 4091 | _LIBCPP_INLINE_VISIBILITY | |
| 4092 | double p() const {return __p_.p();} | |
| 4093 | ||
| 4094 | _LIBCPP_INLINE_VISIBILITY | |
| 4095 | param_type param() const {return __p_;} | |
| 4096 | _LIBCPP_INLINE_VISIBILITY | |
| 4097 | void param(const param_type& __p) {__p_ = __p;} | |
| 4098 | ||
| 4099 | _LIBCPP_INLINE_VISIBILITY | |
| 4100 | result_type min() const {return 0;} | |
| 4101 | _LIBCPP_INLINE_VISIBILITY | |
| 4102 | result_type max() const {return t();} | |
| 4103 | ||
| 4104 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4105 | bool operator==(const binomial_distribution& __x, | |
| 4106 | const binomial_distribution& __y) | |
| 4107 | {return __x.__p_ == __y.__p_;} | |
| 4108 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4109 | bool operator!=(const binomial_distribution& __x, | |
| 4110 | const binomial_distribution& __y) | |
| 4111 | {return !(__x == __y);} | |
| 4112 | }; | |
| 4113 | ||
| 4114 | #ifndef _LIBCPP_MSVCRT_LIKE | |
| 4115 | extern "C" double lgamma_r(double, int *); | |
| 4116 | #endif | |
| 4117 | ||
| 4118 | inline _LIBCPP_INLINE_VISIBILITY double __libcpp_lgamma(double __d) { | |
| 4119 | #if defined(_LIBCPP_MSVCRT_LIKE) | |
| 4120 | return lgamma(__d); | |
| 4121 | #else | |
| 4122 | int __sign; | |
| 4123 | return lgamma_r(__d, &__sign); | |
| 4124 | #endif | |
| 4125 | } | |
| 4126 | ||
| 4127 | template<class _IntType> | |
| 4128 | binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p) | |
| 4129 | : __t_(__t), __p_(__p) | |
| 4130 | { | |
| 4131 | if (0 < __p_ && __p_ < 1) | |
| 4132 | { | |
| 4133 | __r0_ = static_cast<result_type>((__t_ + 1) * __p_); | |
| 4134 | __pr_ = _VSTD::exp(__libcpp_lgamma(__t_ + 1.) - | |
| 4135 | __libcpp_lgamma(__r0_ + 1.) - | |
| 4136 | __libcpp_lgamma(__t_ - __r0_ + 1.) + __r0_ * _VSTD::log(__p_) + | |
| 4137 | (__t_ - __r0_) * _VSTD::log(1 - __p_)); | |
| 4138 | __odds_ratio_ = __p_ / (1 - __p_); | |
| 4139 | } | |
| 4140 | } | |
| 4141 | ||
| 4142 | // Reference: Kemp, C.D. (1986). `A modal method for generating binomial | |
| 4143 | // variables', Commun. Statist. - Theor. Meth. 15(3), 805-813. | |
| 4144 | template<class _IntType> | |
| 4145 | template<class _URNG> | |
| 4146 | _IntType | |
| 4147 | binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) | |
| 4148 | { | |
| 4149 | if (__pr.__t_ == 0 || __pr.__p_ == 0) | |
| 4150 | return 0; | |
| 4151 | if (__pr.__p_ == 1) | |
| 4152 | return __pr.__t_; | |
| 4153 | uniform_real_distribution<double> __gen; | |
| 4154 | double __u = __gen(__g) - __pr.__pr_; | |
| 4155 | if (__u < 0) | |
| 4156 | return __pr.__r0_; | |
| 4157 | double __pu = __pr.__pr_; | |
| 4158 | double __pd = __pu; | |
| 4159 | result_type __ru = __pr.__r0_; | |
| 4160 | result_type __rd = __ru; | |
| 4161 | while (true) | |
| 4162 | { | |
| 4163 | bool __break = true; | |
| 4164 | if (__rd >= 1) | |
| 4165 | { | |
| 4166 | __pd *= __rd / (__pr.__odds_ratio_ * (__pr.__t_ - __rd + 1)); | |
| 4167 | __u -= __pd; | |
| 4168 | __break = false; | |
| 4169 | if (__u < 0) | |
| 4170 | return __rd - 1; | |
| 4171 | } | |
| 4172 | if ( __rd != 0 ) | |
| 4173 | --__rd; | |
| 4174 | ++__ru; | |
| 4175 | if (__ru <= __pr.__t_) | |
| 4176 | { | |
| 4177 | __pu *= (__pr.__t_ - __ru + 1) * __pr.__odds_ratio_ / __ru; | |
| 4178 | __u -= __pu; | |
| 4179 | __break = false; | |
| 4180 | if (__u < 0) | |
| 4181 | return __ru; | |
| 4182 | } | |
| 4183 | if (__break) | |
| 4184 | return 0; | |
| 4185 | } | |
| 4186 | } | |
| 4187 | ||
| 4188 | template <class _CharT, class _Traits, class _IntType> | |
| 4189 | basic_ostream<_CharT, _Traits>& | |
| 4190 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4191 | const binomial_distribution<_IntType>& __x) | |
| 4192 | { | |
| 4193 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 4194 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 4195 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 4196 | _OStream::scientific); | |
| 4197 | _CharT __sp = __os.widen(' '); | |
| 4198 | __os.fill(__sp); | |
| 4199 | return __os << __x.t() << __sp << __x.p(); | |
| 4200 | } | |
| 4201 | ||
| 4202 | template <class _CharT, class _Traits, class _IntType> | |
| 4203 | basic_istream<_CharT, _Traits>& | |
| 4204 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4205 | binomial_distribution<_IntType>& __x) | |
| 4206 | { | |
| 4207 | typedef binomial_distribution<_IntType> _Eng; | |
| 4208 | typedef typename _Eng::result_type result_type; | |
| 4209 | typedef typename _Eng::param_type param_type; | |
| 4210 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 4211 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 4212 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 4213 | result_type __t; | |
| 4214 | double __p; | |
| 4215 | __is >> __t >> __p; | |
| 4216 | if (!__is.fail()) | |
| 4217 | __x.param(param_type(__t, __p)); | |
| 4218 | return __is; | |
| 4219 | } | |
| 4220 | ||
| 4221 | // exponential_distribution | |
| 4222 | ||
| 4223 | template<class _RealType = double> | |
| 4224 | class _LIBCPP_TEMPLATE_VIS exponential_distribution | |
| 4225 | { | |
| 4226 | public: | |
| 4227 | // types | |
| 4228 | typedef _RealType result_type; | |
| 4229 | ||
| 4230 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 4231 | { | |
| 4232 | result_type __lambda_; | |
| 4233 | public: | |
| 4234 | typedef exponential_distribution distribution_type; | |
| 4235 | ||
| 4236 | _LIBCPP_INLINE_VISIBILITY | |
| 4237 | explicit param_type(result_type __lambda = 1) : __lambda_(__lambda) {} | |
| 4238 | ||
| 4239 | _LIBCPP_INLINE_VISIBILITY | |
| 4240 | result_type lambda() const {return __lambda_;} | |
| 4241 | ||
| 4242 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4243 | bool operator==(const param_type& __x, const param_type& __y) | |
| 4244 | {return __x.__lambda_ == __y.__lambda_;} | |
| 4245 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4246 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 4247 | {return !(__x == __y);} | |
| 4248 | }; | |
| 4249 | ||
| 4250 | private: | |
| 4251 | param_type __p_; | |
| 4252 | ||
| 4253 | public: | |
| 4254 | // constructors and reset functions | |
| 4255 | #ifndef _LIBCPP_CXX03_LANG | |
| 4256 | _LIBCPP_INLINE_VISIBILITY | |
| 4257 | exponential_distribution() : exponential_distribution(1) {} | |
| 4258 | _LIBCPP_INLINE_VISIBILITY | |
| 4259 | explicit exponential_distribution(result_type __lambda) | |
| 4260 | : __p_(param_type(__lambda)) {} | |
| 4261 | #else | |
| 4262 | _LIBCPP_INLINE_VISIBILITY | |
| 4263 | explicit exponential_distribution(result_type __lambda = 1) | |
| 4264 | : __p_(param_type(__lambda)) {} | |
| 4265 | #endif | |
| 4266 | _LIBCPP_INLINE_VISIBILITY | |
| 4267 | explicit exponential_distribution(const param_type& __p) : __p_(__p) {} | |
| 4268 | _LIBCPP_INLINE_VISIBILITY | |
| 4269 | void reset() {} | |
| 4270 | ||
| 4271 | // generating functions | |
| 4272 | template<class _URNG> | |
| 4273 | _LIBCPP_INLINE_VISIBILITY | |
| 4274 | result_type operator()(_URNG& __g) | |
| 4275 | {return (*this)(__g, __p_);} | |
| 4276 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 4277 | ||
| 4278 | // property functions | |
| 4279 | _LIBCPP_INLINE_VISIBILITY | |
| 4280 | result_type lambda() const {return __p_.lambda();} | |
| 4281 | ||
| 4282 | _LIBCPP_INLINE_VISIBILITY | |
| 4283 | param_type param() const {return __p_;} | |
| 4284 | _LIBCPP_INLINE_VISIBILITY | |
| 4285 | void param(const param_type& __p) {__p_ = __p;} | |
| 4286 | ||
| 4287 | _LIBCPP_INLINE_VISIBILITY | |
| 4288 | result_type min() const {return 0;} | |
| 4289 | _LIBCPP_INLINE_VISIBILITY | |
| 4290 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 4291 | ||
| 4292 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4293 | bool operator==(const exponential_distribution& __x, | |
| 4294 | const exponential_distribution& __y) | |
| 4295 | {return __x.__p_ == __y.__p_;} | |
| 4296 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4297 | bool operator!=(const exponential_distribution& __x, | |
| 4298 | const exponential_distribution& __y) | |
| 4299 | {return !(__x == __y);} | |
| 4300 | }; | |
| 4301 | ||
| 4302 | template <class _RealType> | |
| 4303 | template<class _URNG> | |
| 4304 | _RealType | |
| 4305 | exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 4306 | { | |
| 4307 | return -_VSTD::log | |
| 4308 | ( | |
| 4309 | result_type(1) - | |
| 4310 | _VSTD::generate_canonical<result_type, | |
| 4311 | numeric_limits<result_type>::digits>(__g) | |
| 4312 | ) | |
| 4313 | / __p.lambda(); | |
| 4314 | } | |
| 4315 | ||
| 4316 | template <class _CharT, class _Traits, class _RealType> | |
| 4317 | basic_ostream<_CharT, _Traits>& | |
| 4318 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4319 | const exponential_distribution<_RealType>& __x) | |
| 4320 | { | |
| 4321 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 4322 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 4323 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 4324 | _OStream::scientific); | |
| 4325 | return __os << __x.lambda(); | |
| 4326 | } | |
| 4327 | ||
| 4328 | template <class _CharT, class _Traits, class _RealType> | |
| 4329 | basic_istream<_CharT, _Traits>& | |
| 4330 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4331 | exponential_distribution<_RealType>& __x) | |
| 4332 | { | |
| 4333 | typedef exponential_distribution<_RealType> _Eng; | |
| 4334 | typedef typename _Eng::result_type result_type; | |
| 4335 | typedef typename _Eng::param_type param_type; | |
| 4336 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 4337 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 4338 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 4339 | result_type __lambda; | |
| 4340 | __is >> __lambda; | |
| 4341 | if (!__is.fail()) | |
| 4342 | __x.param(param_type(__lambda)); | |
| 4343 | return __is; | |
| 4344 | } | |
| 4345 | ||
| 4346 | // normal_distribution | |
| 4347 | ||
| 4348 | template<class _RealType = double> | |
| 4349 | class _LIBCPP_TEMPLATE_VIS normal_distribution | |
| 4350 | { | |
| 4351 | public: | |
| 4352 | // types | |
| 4353 | typedef _RealType result_type; | |
| 4354 | ||
| 4355 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 4356 | { | |
| 4357 | result_type __mean_; | |
| 4358 | result_type __stddev_; | |
| 4359 | public: | |
| 4360 | typedef normal_distribution distribution_type; | |
| 4361 | ||
| 4362 | _LIBCPP_INLINE_VISIBILITY | |
| 4363 | explicit param_type(result_type __mean = 0, result_type __stddev = 1) | |
| 4364 | : __mean_(__mean), __stddev_(__stddev) {} | |
| 4365 | ||
| 4366 | _LIBCPP_INLINE_VISIBILITY | |
| 4367 | result_type mean() const {return __mean_;} | |
| 4368 | _LIBCPP_INLINE_VISIBILITY | |
| 4369 | result_type stddev() const {return __stddev_;} | |
| 4370 | ||
| 4371 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4372 | bool operator==(const param_type& __x, const param_type& __y) | |
| 4373 | {return __x.__mean_ == __y.__mean_ && __x.__stddev_ == __y.__stddev_;} | |
| 4374 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4375 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 4376 | {return !(__x == __y);} | |
| 4377 | }; | |
| 4378 | ||
| 4379 | private: | |
| 4380 | param_type __p_; | |
| 4381 | result_type _V_; | |
| 4382 | bool _V_hot_; | |
| 4383 | ||
| 4384 | public: | |
| 4385 | // constructors and reset functions | |
| 4386 | #ifndef _LIBCPP_CXX03_LANG | |
| 4387 | _LIBCPP_INLINE_VISIBILITY | |
| 4388 | normal_distribution() : normal_distribution(0) {} | |
| 4389 | _LIBCPP_INLINE_VISIBILITY | |
| 4390 | explicit normal_distribution(result_type __mean, result_type __stddev = 1) | |
| 4391 | : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} | |
| 4392 | #else | |
| 4393 | _LIBCPP_INLINE_VISIBILITY | |
| 4394 | explicit normal_distribution(result_type __mean = 0, | |
| 4395 | result_type __stddev = 1) | |
| 4396 | : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} | |
| 4397 | #endif | |
| 4398 | _LIBCPP_INLINE_VISIBILITY | |
| 4399 | explicit normal_distribution(const param_type& __p) | |
| 4400 | : __p_(__p), _V_hot_(false) {} | |
| 4401 | _LIBCPP_INLINE_VISIBILITY | |
| 4402 | void reset() {_V_hot_ = false;} | |
| 4403 | ||
| 4404 | // generating functions | |
| 4405 | template<class _URNG> | |
| 4406 | _LIBCPP_INLINE_VISIBILITY | |
| 4407 | result_type operator()(_URNG& __g) | |
| 4408 | {return (*this)(__g, __p_);} | |
| 4409 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 4410 | ||
| 4411 | // property functions | |
| 4412 | _LIBCPP_INLINE_VISIBILITY | |
| 4413 | result_type mean() const {return __p_.mean();} | |
| 4414 | _LIBCPP_INLINE_VISIBILITY | |
| 4415 | result_type stddev() const {return __p_.stddev();} | |
| 4416 | ||
| 4417 | _LIBCPP_INLINE_VISIBILITY | |
| 4418 | param_type param() const {return __p_;} | |
| 4419 | _LIBCPP_INLINE_VISIBILITY | |
| 4420 | void param(const param_type& __p) {__p_ = __p;} | |
| 4421 | ||
| 4422 | _LIBCPP_INLINE_VISIBILITY | |
| 4423 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 4424 | _LIBCPP_INLINE_VISIBILITY | |
| 4425 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 4426 | ||
| 4427 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4428 | bool operator==(const normal_distribution& __x, | |
| 4429 | const normal_distribution& __y) | |
| 4430 | {return __x.__p_ == __y.__p_ && __x._V_hot_ == __y._V_hot_ && | |
| 4431 | (!__x._V_hot_ || __x._V_ == __y._V_);} | |
| 4432 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4433 | bool operator!=(const normal_distribution& __x, | |
| 4434 | const normal_distribution& __y) | |
| 4435 | {return !(__x == __y);} | |
| 4436 | ||
| 4437 | template <class _CharT, class _Traits, class _RT> | |
| 4438 | friend | |
| 4439 | basic_ostream<_CharT, _Traits>& | |
| 4440 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4441 | const normal_distribution<_RT>& __x); | |
| 4442 | ||
| 4443 | template <class _CharT, class _Traits, class _RT> | |
| 4444 | friend | |
| 4445 | basic_istream<_CharT, _Traits>& | |
| 4446 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4447 | normal_distribution<_RT>& __x); | |
| 4448 | }; | |
| 4449 | ||
| 4450 | template <class _RealType> | |
| 4451 | template<class _URNG> | |
| 4452 | _RealType | |
| 4453 | normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 4454 | { | |
| 4455 | result_type _Up; | |
| 4456 | if (_V_hot_) | |
| 4457 | { | |
| 4458 | _V_hot_ = false; | |
| 4459 | _Up = _V_; | |
| 4460 | } | |
| 4461 | else | |
| 4462 | { | |
| 4463 | uniform_real_distribution<result_type> _Uni(-1, 1); | |
| 4464 | result_type __u; | |
| 4465 | result_type __v; | |
| 4466 | result_type __s; | |
| 4467 | do | |
| 4468 | { | |
| 4469 | __u = _Uni(__g); | |
| 4470 | __v = _Uni(__g); | |
| 4471 | __s = __u * __u + __v * __v; | |
| 4472 | } while (__s > 1 || __s == 0); | |
| 4473 | result_type _Fp = _VSTD::sqrt(-2 * _VSTD::log(__s) / __s); | |
| 4474 | _V_ = __v * _Fp; | |
| 4475 | _V_hot_ = true; | |
| 4476 | _Up = __u * _Fp; | |
| 4477 | } | |
| 4478 | return _Up * __p.stddev() + __p.mean(); | |
| 4479 | } | |
| 4480 | ||
| 4481 | template <class _CharT, class _Traits, class _RT> | |
| 4482 | basic_ostream<_CharT, _Traits>& | |
| 4483 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4484 | const normal_distribution<_RT>& __x) | |
| 4485 | { | |
| 4486 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 4487 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 4488 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 4489 | _OStream::scientific); | |
| 4490 | _CharT __sp = __os.widen(' '); | |
| 4491 | __os.fill(__sp); | |
| 4492 | __os << __x.mean() << __sp << __x.stddev() << __sp << __x._V_hot_; | |
| 4493 | if (__x._V_hot_) | |
| 4494 | __os << __sp << __x._V_; | |
| 4495 | return __os; | |
| 4496 | } | |
| 4497 | ||
| 4498 | template <class _CharT, class _Traits, class _RT> | |
| 4499 | basic_istream<_CharT, _Traits>& | |
| 4500 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4501 | normal_distribution<_RT>& __x) | |
| 4502 | { | |
| 4503 | typedef normal_distribution<_RT> _Eng; | |
| 4504 | typedef typename _Eng::result_type result_type; | |
| 4505 | typedef typename _Eng::param_type param_type; | |
| 4506 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 4507 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 4508 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 4509 | result_type __mean; | |
| 4510 | result_type __stddev; | |
| 4511 | result_type _Vp = 0; | |
| 4512 | bool _V_hot = false; | |
| 4513 | __is >> __mean >> __stddev >> _V_hot; | |
| 4514 | if (_V_hot) | |
| 4515 | __is >> _Vp; | |
| 4516 | if (!__is.fail()) | |
| 4517 | { | |
| 4518 | __x.param(param_type(__mean, __stddev)); | |
| 4519 | __x._V_hot_ = _V_hot; | |
| 4520 | __x._V_ = _Vp; | |
| 4521 | } | |
| 4522 | return __is; | |
| 4523 | } | |
| 4524 | ||
| 4525 | // lognormal_distribution | |
| 4526 | ||
| 4527 | template<class _RealType = double> | |
| 4528 | class _LIBCPP_TEMPLATE_VIS lognormal_distribution | |
| 4529 | { | |
| 4530 | public: | |
| 4531 | // types | |
| 4532 | typedef _RealType result_type; | |
| 4533 | ||
| 4534 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 4535 | { | |
| 4536 | normal_distribution<result_type> __nd_; | |
| 4537 | public: | |
| 4538 | typedef lognormal_distribution distribution_type; | |
| 4539 | ||
| 4540 | _LIBCPP_INLINE_VISIBILITY | |
| 4541 | explicit param_type(result_type __m = 0, result_type __s = 1) | |
| 4542 | : __nd_(__m, __s) {} | |
| 4543 | ||
| 4544 | _LIBCPP_INLINE_VISIBILITY | |
| 4545 | result_type m() const {return __nd_.mean();} | |
| 4546 | _LIBCPP_INLINE_VISIBILITY | |
| 4547 | result_type s() const {return __nd_.stddev();} | |
| 4548 | ||
| 4549 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4550 | bool operator==(const param_type& __x, const param_type& __y) | |
| 4551 | {return __x.__nd_ == __y.__nd_;} | |
| 4552 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4553 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 4554 | {return !(__x == __y);} | |
| 4555 | friend class lognormal_distribution; | |
| 4556 | ||
| 4557 | template <class _CharT, class _Traits, class _RT> | |
| 4558 | friend | |
| 4559 | basic_ostream<_CharT, _Traits>& | |
| 4560 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4561 | const lognormal_distribution<_RT>& __x); | |
| 4562 | ||
| 4563 | template <class _CharT, class _Traits, class _RT> | |
| 4564 | friend | |
| 4565 | basic_istream<_CharT, _Traits>& | |
| 4566 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4567 | lognormal_distribution<_RT>& __x); | |
| 4568 | }; | |
| 4569 | ||
| 4570 | private: | |
| 4571 | param_type __p_; | |
| 4572 | ||
| 4573 | public: | |
| 4574 | // constructor and reset functions | |
| 4575 | #ifndef _LIBCPP_CXX03_LANG | |
| 4576 | _LIBCPP_INLINE_VISIBILITY | |
| 4577 | lognormal_distribution() : lognormal_distribution(0) {} | |
| 4578 | _LIBCPP_INLINE_VISIBILITY | |
| 4579 | explicit lognormal_distribution(result_type __m, result_type __s = 1) | |
| 4580 | : __p_(param_type(__m, __s)) {} | |
| 4581 | #else | |
| 4582 | _LIBCPP_INLINE_VISIBILITY | |
| 4583 | explicit lognormal_distribution(result_type __m = 0, | |
| 4584 | result_type __s = 1) | |
| 4585 | : __p_(param_type(__m, __s)) {} | |
| 4586 | #endif | |
| 4587 | _LIBCPP_INLINE_VISIBILITY | |
| 4588 | explicit lognormal_distribution(const param_type& __p) | |
| 4589 | : __p_(__p) {} | |
| 4590 | _LIBCPP_INLINE_VISIBILITY | |
| 4591 | void reset() {__p_.__nd_.reset();} | |
| 4592 | ||
| 4593 | // generating functions | |
| 4594 | template<class _URNG> | |
| 4595 | _LIBCPP_INLINE_VISIBILITY | |
| 4596 | result_type operator()(_URNG& __g) | |
| 4597 | {return (*this)(__g, __p_);} | |
| 4598 | template<class _URNG> | |
| 4599 | _LIBCPP_INLINE_VISIBILITY | |
| 4600 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 4601 | {return _VSTD::exp(const_cast<normal_distribution<result_type>&>(__p.__nd_)(__g));} | |
| 4602 | ||
| 4603 | // property functions | |
| 4604 | _LIBCPP_INLINE_VISIBILITY | |
| 4605 | result_type m() const {return __p_.m();} | |
| 4606 | _LIBCPP_INLINE_VISIBILITY | |
| 4607 | result_type s() const {return __p_.s();} | |
| 4608 | ||
| 4609 | _LIBCPP_INLINE_VISIBILITY | |
| 4610 | param_type param() const {return __p_;} | |
| 4611 | _LIBCPP_INLINE_VISIBILITY | |
| 4612 | void param(const param_type& __p) {__p_ = __p;} | |
| 4613 | ||
| 4614 | _LIBCPP_INLINE_VISIBILITY | |
| 4615 | result_type min() const {return 0;} | |
| 4616 | _LIBCPP_INLINE_VISIBILITY | |
| 4617 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 4618 | ||
| 4619 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4620 | bool operator==(const lognormal_distribution& __x, | |
| 4621 | const lognormal_distribution& __y) | |
| 4622 | {return __x.__p_ == __y.__p_;} | |
| 4623 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4624 | bool operator!=(const lognormal_distribution& __x, | |
| 4625 | const lognormal_distribution& __y) | |
| 4626 | {return !(__x == __y);} | |
| 4627 | ||
| 4628 | template <class _CharT, class _Traits, class _RT> | |
| 4629 | friend | |
| 4630 | basic_ostream<_CharT, _Traits>& | |
| 4631 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4632 | const lognormal_distribution<_RT>& __x); | |
| 4633 | ||
| 4634 | template <class _CharT, class _Traits, class _RT> | |
| 4635 | friend | |
| 4636 | basic_istream<_CharT, _Traits>& | |
| 4637 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4638 | lognormal_distribution<_RT>& __x); | |
| 4639 | }; | |
| 4640 | ||
| 4641 | template <class _CharT, class _Traits, class _RT> | |
| 4642 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4643 | basic_ostream<_CharT, _Traits>& | |
| 4644 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4645 | const lognormal_distribution<_RT>& __x) | |
| 4646 | { | |
| 4647 | return __os << __x.__p_.__nd_; | |
| 4648 | } | |
| 4649 | ||
| 4650 | template <class _CharT, class _Traits, class _RT> | |
| 4651 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4652 | basic_istream<_CharT, _Traits>& | |
| 4653 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4654 | lognormal_distribution<_RT>& __x) | |
| 4655 | { | |
| 4656 | return __is >> __x.__p_.__nd_; | |
| 4657 | } | |
| 4658 | ||
| 4659 | // poisson_distribution | |
| 4660 | ||
| 4661 | template<class _IntType = int> | |
| 4662 | class _LIBCPP_TEMPLATE_VIS poisson_distribution | |
| 4663 | { | |
| 4664 | public: | |
| 4665 | // types | |
| 4666 | typedef _IntType result_type; | |
| 4667 | ||
| 4668 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 4669 | { | |
| 4670 | double __mean_; | |
| 4671 | double __s_; | |
| 4672 | double __d_; | |
| 4673 | double __l_; | |
| 4674 | double __omega_; | |
| 4675 | double __c0_; | |
| 4676 | double __c1_; | |
| 4677 | double __c2_; | |
| 4678 | double __c3_; | |
| 4679 | double __c_; | |
| 4680 | ||
| 4681 | public: | |
| 4682 | typedef poisson_distribution distribution_type; | |
| 4683 | ||
| 4684 | explicit param_type(double __mean = 1.0); | |
| 4685 | ||
| 4686 | _LIBCPP_INLINE_VISIBILITY | |
| 4687 | double mean() const {return __mean_;} | |
| 4688 | ||
| 4689 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4690 | bool operator==(const param_type& __x, const param_type& __y) | |
| 4691 | {return __x.__mean_ == __y.__mean_;} | |
| 4692 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4693 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 4694 | {return !(__x == __y);} | |
| 4695 | ||
| 4696 | friend class poisson_distribution; | |
| 4697 | }; | |
| 4698 | ||
| 4699 | private: | |
| 4700 | param_type __p_; | |
| 4701 | ||
| 4702 | public: | |
| 4703 | // constructors and reset functions | |
| 4704 | #ifndef _LIBCPP_CXX03_LANG | |
| 4705 | _LIBCPP_INLINE_VISIBILITY | |
| 4706 | poisson_distribution() : poisson_distribution(1.0) {} | |
| 4707 | _LIBCPP_INLINE_VISIBILITY | |
| 4708 | explicit poisson_distribution(double __mean) | |
| 4709 | : __p_(__mean) {} | |
| 4710 | #else | |
| 4711 | _LIBCPP_INLINE_VISIBILITY | |
| 4712 | explicit poisson_distribution(double __mean = 1.0) | |
| 4713 | : __p_(__mean) {} | |
| 4714 | #endif | |
| 4715 | _LIBCPP_INLINE_VISIBILITY | |
| 4716 | explicit poisson_distribution(const param_type& __p) : __p_(__p) {} | |
| 4717 | _LIBCPP_INLINE_VISIBILITY | |
| 4718 | void reset() {} | |
| 4719 | ||
| 4720 | // generating functions | |
| 4721 | template<class _URNG> | |
| 4722 | _LIBCPP_INLINE_VISIBILITY | |
| 4723 | result_type operator()(_URNG& __g) | |
| 4724 | {return (*this)(__g, __p_);} | |
| 4725 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 4726 | ||
| 4727 | // property functions | |
| 4728 | _LIBCPP_INLINE_VISIBILITY | |
| 4729 | double mean() const {return __p_.mean();} | |
| 4730 | ||
| 4731 | _LIBCPP_INLINE_VISIBILITY | |
| 4732 | param_type param() const {return __p_;} | |
| 4733 | _LIBCPP_INLINE_VISIBILITY | |
| 4734 | void param(const param_type& __p) {__p_ = __p;} | |
| 4735 | ||
| 4736 | _LIBCPP_INLINE_VISIBILITY | |
| 4737 | result_type min() const {return 0;} | |
| 4738 | _LIBCPP_INLINE_VISIBILITY | |
| 4739 | result_type max() const {return numeric_limits<result_type>::max();} | |
| 4740 | ||
| 4741 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4742 | bool operator==(const poisson_distribution& __x, | |
| 4743 | const poisson_distribution& __y) | |
| 4744 | {return __x.__p_ == __y.__p_;} | |
| 4745 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4746 | bool operator!=(const poisson_distribution& __x, | |
| 4747 | const poisson_distribution& __y) | |
| 4748 | {return !(__x == __y);} | |
| 4749 | }; | |
| 4750 | ||
| 4751 | template<class _IntType> | |
| 4752 | poisson_distribution<_IntType>::param_type::param_type(double __mean) | |
| 4753 | // According to the standard `inf` is a valid input, but it causes the | |
| 4754 | // distribution to hang, so we replace it with the maximum representable | |
| 4755 | // mean. | |
| 4756 | : __mean_(isinf(__mean) ? numeric_limits<double>::max() : __mean) | |
| 4757 | { | |
| 4758 | if (__mean_ < 10) | |
| 4759 | { | |
| 4760 | __s_ = 0; | |
| 4761 | __d_ = 0; | |
| 4762 | __l_ = _VSTD::exp(-__mean_); | |
| 4763 | __omega_ = 0; | |
| 4764 | __c3_ = 0; | |
| 4765 | __c2_ = 0; | |
| 4766 | __c1_ = 0; | |
| 4767 | __c0_ = 0; | |
| 4768 | __c_ = 0; | |
| 4769 | } | |
| 4770 | else | |
| 4771 | { | |
| 4772 | __s_ = _VSTD::sqrt(__mean_); | |
| 4773 | __d_ = 6 * __mean_ * __mean_; | |
| 4774 | __l_ = _VSTD::trunc(__mean_ - 1.1484); | |
| 4775 | __omega_ = .3989423 / __s_; | |
| 4776 | double __b1_ = .4166667E-1 / __mean_; | |
| 4777 | double __b2_ = .3 * __b1_ * __b1_; | |
| 4778 | __c3_ = .1428571 * __b1_ * __b2_; | |
| 4779 | __c2_ = __b2_ - 15. * __c3_; | |
| 4780 | __c1_ = __b1_ - 6. * __b2_ + 45. * __c3_; | |
| 4781 | __c0_ = 1. - __b1_ + 3. * __b2_ - 15. * __c3_; | |
| 4782 | __c_ = .1069 / __mean_; | |
| 4783 | } | |
| 4784 | } | |
| 4785 | ||
| 4786 | template <class _IntType> | |
| 4787 | template<class _URNG> | |
| 4788 | _IntType | |
| 4789 | poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) | |
| 4790 | { | |
| 4791 | double __tx; | |
| 4792 | uniform_real_distribution<double> __urd; | |
| 4793 | if (__pr.__mean_ < 10) | |
| 4794 | { | |
| 4795 | __tx = 0; | |
| 4796 | for (double __p = __urd(__urng); __p > __pr.__l_; ++__tx) | |
| 4797 | __p *= __urd(__urng); | |
| 4798 | } | |
| 4799 | else | |
| 4800 | { | |
| 4801 | double __difmuk; | |
| 4802 | double __g = __pr.__mean_ + __pr.__s_ * normal_distribution<double>()(__urng); | |
| 4803 | double __u; | |
| 4804 | if (__g > 0) | |
| 4805 | { | |
| 4806 | __tx = _VSTD::trunc(__g); | |
| 4807 | if (__tx >= __pr.__l_) | |
| 4808 | return _VSTD::__clamp_to_integral<result_type>(__tx); | |
| 4809 | __difmuk = __pr.__mean_ - __tx; | |
| 4810 | __u = __urd(__urng); | |
| 4811 | if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk) | |
| 4812 | return _VSTD::__clamp_to_integral<result_type>(__tx); | |
| 4813 | } | |
| 4814 | exponential_distribution<double> __edist; | |
| 4815 | for (bool __using_exp_dist = false; true; __using_exp_dist = true) | |
| 4816 | { | |
| 4817 | double __e; | |
| 4818 | if (__using_exp_dist || __g <= 0) | |
| 4819 | { | |
| 4820 | double __t; | |
| 4821 | do | |
| 4822 | { | |
| 4823 | __e = __edist(__urng); | |
| 4824 | __u = __urd(__urng); | |
| 4825 | __u += __u - 1; | |
| 4826 | __t = 1.8 + (__u < 0 ? -__e : __e); | |
| 4827 | } while (__t <= -.6744); | |
| 4828 | __tx = _VSTD::trunc(__pr.__mean_ + __pr.__s_ * __t); | |
| 4829 | __difmuk = __pr.__mean_ - __tx; | |
| 4830 | __using_exp_dist = true; | |
| 4831 | } | |
| 4832 | double __px; | |
| 4833 | double __py; | |
| 4834 | if (__tx < 10 && __tx >= 0) | |
| 4835 | { | |
| 4836 | const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, | |
| 4837 | 40320, 362880}; | |
| 4838 | __px = -__pr.__mean_; | |
| 4839 | __py = _VSTD::pow(__pr.__mean_, (double)__tx) / __fac[static_cast<int>(__tx)]; | |
| 4840 | } | |
| 4841 | else | |
| 4842 | { | |
| 4843 | double __del = .8333333E-1 / __tx; | |
| 4844 | __del -= 4.8 * __del * __del * __del; | |
| 4845 | double __v = __difmuk / __tx; | |
| 4846 | if (_VSTD::abs(__v) > 0.25) | |
| 4847 | __px = __tx * _VSTD::log(1 + __v) - __difmuk - __del; | |
| 4848 | else | |
| 4849 | __px = __tx * __v * __v * (((((((.1250060 * __v + -.1384794) * | |
| 4850 | __v + .1421878) * __v + -.1661269) * __v + .2000118) * | |
| 4851 | __v + -.2500068) * __v + .3333333) * __v + -.5) - __del; | |
| 4852 | __py = .3989423 / _VSTD::sqrt(__tx); | |
| 4853 | } | |
| 4854 | double __r = (0.5 - __difmuk) / __pr.__s_; | |
| 4855 | double __r2 = __r * __r; | |
| 4856 | double __fx = -0.5 * __r2; | |
| 4857 | double __fy = __pr.__omega_ * (((__pr.__c3_ * __r2 + __pr.__c2_) * | |
| 4858 | __r2 + __pr.__c1_) * __r2 + __pr.__c0_); | |
| 4859 | if (__using_exp_dist) | |
| 4860 | { | |
| 4861 | if (__pr.__c_ * _VSTD::abs(__u) <= __py * _VSTD::exp(__px + __e) - | |
| 4862 | __fy * _VSTD::exp(__fx + __e)) | |
| 4863 | break; | |
| 4864 | } | |
| 4865 | else | |
| 4866 | { | |
| 4867 | if (__fy - __u * __fy <= __py * _VSTD::exp(__px - __fx)) | |
| 4868 | break; | |
| 4869 | } | |
| 4870 | } | |
| 4871 | } | |
| 4872 | return _VSTD::__clamp_to_integral<result_type>(__tx); | |
| 4873 | } | |
| 4874 | ||
| 4875 | template <class _CharT, class _Traits, class _IntType> | |
| 4876 | basic_ostream<_CharT, _Traits>& | |
| 4877 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4878 | const poisson_distribution<_IntType>& __x) | |
| 4879 | { | |
| 4880 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 4881 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 4882 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 4883 | _OStream::scientific); | |
| 4884 | return __os << __x.mean(); | |
| 4885 | } | |
| 4886 | ||
| 4887 | template <class _CharT, class _Traits, class _IntType> | |
| 4888 | basic_istream<_CharT, _Traits>& | |
| 4889 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 4890 | poisson_distribution<_IntType>& __x) | |
| 4891 | { | |
| 4892 | typedef poisson_distribution<_IntType> _Eng; | |
| 4893 | typedef typename _Eng::param_type param_type; | |
| 4894 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 4895 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 4896 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 4897 | double __mean; | |
| 4898 | __is >> __mean; | |
| 4899 | if (!__is.fail()) | |
| 4900 | __x.param(param_type(__mean)); | |
| 4901 | return __is; | |
| 4902 | } | |
| 4903 | ||
| 4904 | // weibull_distribution | |
| 4905 | ||
| 4906 | template<class _RealType = double> | |
| 4907 | class _LIBCPP_TEMPLATE_VIS weibull_distribution | |
| 4908 | { | |
| 4909 | public: | |
| 4910 | // types | |
| 4911 | typedef _RealType result_type; | |
| 4912 | ||
| 4913 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 4914 | { | |
| 4915 | result_type __a_; | |
| 4916 | result_type __b_; | |
| 4917 | public: | |
| 4918 | typedef weibull_distribution distribution_type; | |
| 4919 | ||
| 4920 | _LIBCPP_INLINE_VISIBILITY | |
| 4921 | explicit param_type(result_type __a = 1, result_type __b = 1) | |
| 4922 | : __a_(__a), __b_(__b) {} | |
| 4923 | ||
| 4924 | _LIBCPP_INLINE_VISIBILITY | |
| 4925 | result_type a() const {return __a_;} | |
| 4926 | _LIBCPP_INLINE_VISIBILITY | |
| 4927 | result_type b() const {return __b_;} | |
| 4928 | ||
| 4929 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4930 | bool operator==(const param_type& __x, const param_type& __y) | |
| 4931 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 4932 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4933 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 4934 | {return !(__x == __y);} | |
| 4935 | }; | |
| 4936 | ||
| 4937 | private: | |
| 4938 | param_type __p_; | |
| 4939 | ||
| 4940 | public: | |
| 4941 | // constructor and reset functions | |
| 4942 | #ifndef _LIBCPP_CXX03_LANG | |
| 4943 | _LIBCPP_INLINE_VISIBILITY | |
| 4944 | weibull_distribution() : weibull_distribution(1) {} | |
| 4945 | _LIBCPP_INLINE_VISIBILITY | |
| 4946 | explicit weibull_distribution(result_type __a, result_type __b = 1) | |
| 4947 | : __p_(param_type(__a, __b)) {} | |
| 4948 | #else | |
| 4949 | _LIBCPP_INLINE_VISIBILITY | |
| 4950 | explicit weibull_distribution(result_type __a = 1, result_type __b = 1) | |
| 4951 | : __p_(param_type(__a, __b)) {} | |
| 4952 | #endif | |
| 4953 | _LIBCPP_INLINE_VISIBILITY | |
| 4954 | explicit weibull_distribution(const param_type& __p) | |
| 4955 | : __p_(__p) {} | |
| 4956 | _LIBCPP_INLINE_VISIBILITY | |
| 4957 | void reset() {} | |
| 4958 | ||
| 4959 | // generating functions | |
| 4960 | template<class _URNG> | |
| 4961 | _LIBCPP_INLINE_VISIBILITY | |
| 4962 | result_type operator()(_URNG& __g) | |
| 4963 | {return (*this)(__g, __p_);} | |
| 4964 | template<class _URNG> | |
| 4965 | _LIBCPP_INLINE_VISIBILITY | |
| 4966 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 4967 | {return __p.b() * | |
| 4968 | _VSTD::pow(exponential_distribution<result_type>()(__g), 1/__p.a());} | |
| 4969 | ||
| 4970 | // property functions | |
| 4971 | _LIBCPP_INLINE_VISIBILITY | |
| 4972 | result_type a() const {return __p_.a();} | |
| 4973 | _LIBCPP_INLINE_VISIBILITY | |
| 4974 | result_type b() const {return __p_.b();} | |
| 4975 | ||
| 4976 | _LIBCPP_INLINE_VISIBILITY | |
| 4977 | param_type param() const {return __p_;} | |
| 4978 | _LIBCPP_INLINE_VISIBILITY | |
| 4979 | void param(const param_type& __p) {__p_ = __p;} | |
| 4980 | ||
| 4981 | _LIBCPP_INLINE_VISIBILITY | |
| 4982 | result_type min() const {return 0;} | |
| 4983 | _LIBCPP_INLINE_VISIBILITY | |
| 4984 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 4985 | ||
| 4986 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4987 | bool operator==(const weibull_distribution& __x, | |
| 4988 | const weibull_distribution& __y) | |
| 4989 | {return __x.__p_ == __y.__p_;} | |
| 4990 | friend _LIBCPP_INLINE_VISIBILITY | |
| 4991 | bool operator!=(const weibull_distribution& __x, | |
| 4992 | const weibull_distribution& __y) | |
| 4993 | {return !(__x == __y);} | |
| 4994 | }; | |
| 4995 | ||
| 4996 | template <class _CharT, class _Traits, class _RT> | |
| 4997 | basic_ostream<_CharT, _Traits>& | |
| 4998 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 4999 | const weibull_distribution<_RT>& __x) | |
| 5000 | { | |
| 5001 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5002 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5003 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5004 | _OStream::scientific); | |
| 5005 | _CharT __sp = __os.widen(' '); | |
| 5006 | __os.fill(__sp); | |
| 5007 | __os << __x.a() << __sp << __x.b(); | |
| 5008 | return __os; | |
| 5009 | } | |
| 5010 | ||
| 5011 | template <class _CharT, class _Traits, class _RT> | |
| 5012 | basic_istream<_CharT, _Traits>& | |
| 5013 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5014 | weibull_distribution<_RT>& __x) | |
| 5015 | { | |
| 5016 | typedef weibull_distribution<_RT> _Eng; | |
| 5017 | typedef typename _Eng::result_type result_type; | |
| 5018 | typedef typename _Eng::param_type param_type; | |
| 5019 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5020 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5021 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5022 | result_type __a; | |
| 5023 | result_type __b; | |
| 5024 | __is >> __a >> __b; | |
| 5025 | if (!__is.fail()) | |
| 5026 | __x.param(param_type(__a, __b)); | |
| 5027 | return __is; | |
| 5028 | } | |
| 5029 | ||
| 5030 | template<class _RealType = double> | |
| 5031 | class _LIBCPP_TEMPLATE_VIS extreme_value_distribution | |
| 5032 | { | |
| 5033 | public: | |
| 5034 | // types | |
| 5035 | typedef _RealType result_type; | |
| 5036 | ||
| 5037 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5038 | { | |
| 5039 | result_type __a_; | |
| 5040 | result_type __b_; | |
| 5041 | public: | |
| 5042 | typedef extreme_value_distribution distribution_type; | |
| 5043 | ||
| 5044 | _LIBCPP_INLINE_VISIBILITY | |
| 5045 | explicit param_type(result_type __a = 0, result_type __b = 1) | |
| 5046 | : __a_(__a), __b_(__b) {} | |
| 5047 | ||
| 5048 | _LIBCPP_INLINE_VISIBILITY | |
| 5049 | result_type a() const {return __a_;} | |
| 5050 | _LIBCPP_INLINE_VISIBILITY | |
| 5051 | result_type b() const {return __b_;} | |
| 5052 | ||
| 5053 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5054 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5055 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 5056 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5057 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5058 | {return !(__x == __y);} | |
| 5059 | }; | |
| 5060 | ||
| 5061 | private: | |
| 5062 | param_type __p_; | |
| 5063 | ||
| 5064 | public: | |
| 5065 | // constructor and reset functions | |
| 5066 | #ifndef _LIBCPP_CXX03_LANG | |
| 5067 | _LIBCPP_INLINE_VISIBILITY | |
| 5068 | extreme_value_distribution() : extreme_value_distribution(0) {} | |
| 5069 | _LIBCPP_INLINE_VISIBILITY | |
| 5070 | explicit extreme_value_distribution(result_type __a, result_type __b = 1) | |
| 5071 | : __p_(param_type(__a, __b)) {} | |
| 5072 | #else | |
| 5073 | _LIBCPP_INLINE_VISIBILITY | |
| 5074 | explicit extreme_value_distribution(result_type __a = 0, | |
| 5075 | result_type __b = 1) | |
| 5076 | : __p_(param_type(__a, __b)) {} | |
| 5077 | #endif | |
| 5078 | _LIBCPP_INLINE_VISIBILITY | |
| 5079 | explicit extreme_value_distribution(const param_type& __p) | |
| 5080 | : __p_(__p) {} | |
| 5081 | _LIBCPP_INLINE_VISIBILITY | |
| 5082 | void reset() {} | |
| 5083 | ||
| 5084 | // generating functions | |
| 5085 | template<class _URNG> | |
| 5086 | _LIBCPP_INLINE_VISIBILITY | |
| 5087 | result_type operator()(_URNG& __g) | |
| 5088 | {return (*this)(__g, __p_);} | |
| 5089 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 5090 | ||
| 5091 | // property functions | |
| 5092 | _LIBCPP_INLINE_VISIBILITY | |
| 5093 | result_type a() const {return __p_.a();} | |
| 5094 | _LIBCPP_INLINE_VISIBILITY | |
| 5095 | result_type b() const {return __p_.b();} | |
| 5096 | ||
| 5097 | _LIBCPP_INLINE_VISIBILITY | |
| 5098 | param_type param() const {return __p_;} | |
| 5099 | _LIBCPP_INLINE_VISIBILITY | |
| 5100 | void param(const param_type& __p) {__p_ = __p;} | |
| 5101 | ||
| 5102 | _LIBCPP_INLINE_VISIBILITY | |
| 5103 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 5104 | _LIBCPP_INLINE_VISIBILITY | |
| 5105 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 5106 | ||
| 5107 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5108 | bool operator==(const extreme_value_distribution& __x, | |
| 5109 | const extreme_value_distribution& __y) | |
| 5110 | {return __x.__p_ == __y.__p_;} | |
| 5111 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5112 | bool operator!=(const extreme_value_distribution& __x, | |
| 5113 | const extreme_value_distribution& __y) | |
| 5114 | {return !(__x == __y);} | |
| 5115 | }; | |
| 5116 | ||
| 5117 | template<class _RealType> | |
| 5118 | template<class _URNG> | |
| 5119 | _RealType | |
| 5120 | extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 5121 | { | |
| 5122 | return __p.a() - __p.b() * | |
| 5123 | _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g))); | |
| 5124 | } | |
| 5125 | ||
| 5126 | template <class _CharT, class _Traits, class _RT> | |
| 5127 | basic_ostream<_CharT, _Traits>& | |
| 5128 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5129 | const extreme_value_distribution<_RT>& __x) | |
| 5130 | { | |
| 5131 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5132 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5133 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5134 | _OStream::scientific); | |
| 5135 | _CharT __sp = __os.widen(' '); | |
| 5136 | __os.fill(__sp); | |
| 5137 | __os << __x.a() << __sp << __x.b(); | |
| 5138 | return __os; | |
| 5139 | } | |
| 5140 | ||
| 5141 | template <class _CharT, class _Traits, class _RT> | |
| 5142 | basic_istream<_CharT, _Traits>& | |
| 5143 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5144 | extreme_value_distribution<_RT>& __x) | |
| 5145 | { | |
| 5146 | typedef extreme_value_distribution<_RT> _Eng; | |
| 5147 | typedef typename _Eng::result_type result_type; | |
| 5148 | typedef typename _Eng::param_type param_type; | |
| 5149 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5150 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5151 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5152 | result_type __a; | |
| 5153 | result_type __b; | |
| 5154 | __is >> __a >> __b; | |
| 5155 | if (!__is.fail()) | |
| 5156 | __x.param(param_type(__a, __b)); | |
| 5157 | return __is; | |
| 5158 | } | |
| 5159 | ||
| 5160 | // gamma_distribution | |
| 5161 | ||
| 5162 | template<class _RealType = double> | |
| 5163 | class _LIBCPP_TEMPLATE_VIS gamma_distribution | |
| 5164 | { | |
| 5165 | public: | |
| 5166 | // types | |
| 5167 | typedef _RealType result_type; | |
| 5168 | ||
| 5169 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5170 | { | |
| 5171 | result_type __alpha_; | |
| 5172 | result_type __beta_; | |
| 5173 | public: | |
| 5174 | typedef gamma_distribution distribution_type; | |
| 5175 | ||
| 5176 | _LIBCPP_INLINE_VISIBILITY | |
| 5177 | explicit param_type(result_type __alpha = 1, result_type __beta = 1) | |
| 5178 | : __alpha_(__alpha), __beta_(__beta) {} | |
| 5179 | ||
| 5180 | _LIBCPP_INLINE_VISIBILITY | |
| 5181 | result_type alpha() const {return __alpha_;} | |
| 5182 | _LIBCPP_INLINE_VISIBILITY | |
| 5183 | result_type beta() const {return __beta_;} | |
| 5184 | ||
| 5185 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5186 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5187 | {return __x.__alpha_ == __y.__alpha_ && __x.__beta_ == __y.__beta_;} | |
| 5188 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5189 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5190 | {return !(__x == __y);} | |
| 5191 | }; | |
| 5192 | ||
| 5193 | private: | |
| 5194 | param_type __p_; | |
| 5195 | ||
| 5196 | public: | |
| 5197 | // constructors and reset functions | |
| 5198 | #ifndef _LIBCPP_CXX03_LANG | |
| 5199 | _LIBCPP_INLINE_VISIBILITY | |
| 5200 | gamma_distribution() : gamma_distribution(1) {} | |
| 5201 | _LIBCPP_INLINE_VISIBILITY | |
| 5202 | explicit gamma_distribution(result_type __alpha, result_type __beta = 1) | |
| 5203 | : __p_(param_type(__alpha, __beta)) {} | |
| 5204 | #else | |
| 5205 | _LIBCPP_INLINE_VISIBILITY | |
| 5206 | explicit gamma_distribution(result_type __alpha = 1, | |
| 5207 | result_type __beta = 1) | |
| 5208 | : __p_(param_type(__alpha, __beta)) {} | |
| 5209 | #endif | |
| 5210 | _LIBCPP_INLINE_VISIBILITY | |
| 5211 | explicit gamma_distribution(const param_type& __p) | |
| 5212 | : __p_(__p) {} | |
| 5213 | _LIBCPP_INLINE_VISIBILITY | |
| 5214 | void reset() {} | |
| 5215 | ||
| 5216 | // generating functions | |
| 5217 | template<class _URNG> | |
| 5218 | _LIBCPP_INLINE_VISIBILITY | |
| 5219 | result_type operator()(_URNG& __g) | |
| 5220 | {return (*this)(__g, __p_);} | |
| 5221 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 5222 | ||
| 5223 | // property functions | |
| 5224 | _LIBCPP_INLINE_VISIBILITY | |
| 5225 | result_type alpha() const {return __p_.alpha();} | |
| 5226 | _LIBCPP_INLINE_VISIBILITY | |
| 5227 | result_type beta() const {return __p_.beta();} | |
| 5228 | ||
| 5229 | _LIBCPP_INLINE_VISIBILITY | |
| 5230 | param_type param() const {return __p_;} | |
| 5231 | _LIBCPP_INLINE_VISIBILITY | |
| 5232 | void param(const param_type& __p) {__p_ = __p;} | |
| 5233 | ||
| 5234 | _LIBCPP_INLINE_VISIBILITY | |
| 5235 | result_type min() const {return 0;} | |
| 5236 | _LIBCPP_INLINE_VISIBILITY | |
| 5237 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 5238 | ||
| 5239 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5240 | bool operator==(const gamma_distribution& __x, | |
| 5241 | const gamma_distribution& __y) | |
| 5242 | {return __x.__p_ == __y.__p_;} | |
| 5243 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5244 | bool operator!=(const gamma_distribution& __x, | |
| 5245 | const gamma_distribution& __y) | |
| 5246 | {return !(__x == __y);} | |
| 5247 | }; | |
| 5248 | ||
| 5249 | template <class _RealType> | |
| 5250 | template<class _URNG> | |
| 5251 | _RealType | |
| 5252 | gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 5253 | { | |
| 5254 | result_type __a = __p.alpha(); | |
| 5255 | uniform_real_distribution<result_type> __gen(0, 1); | |
| 5256 | exponential_distribution<result_type> __egen; | |
| 5257 | result_type __x; | |
| 5258 | if (__a == 1) | |
| 5259 | __x = __egen(__g); | |
| 5260 | else if (__a > 1) | |
| 5261 | { | |
| 5262 | const result_type __b = __a - 1; | |
| 5263 | const result_type __c = 3 * __a - result_type(0.75); | |
| 5264 | while (true) | |
| 5265 | { | |
| 5266 | const result_type __u = __gen(__g); | |
| 5267 | const result_type __v = __gen(__g); | |
| 5268 | const result_type __w = __u * (1 - __u); | |
| 5269 | if (__w != 0) | |
| 5270 | { | |
| 5271 | const result_type __y = _VSTD::sqrt(__c / __w) * | |
| 5272 | (__u - result_type(0.5)); | |
| 5273 | __x = __b + __y; | |
| 5274 | if (__x >= 0) | |
| 5275 | { | |
| 5276 | const result_type __z = 64 * __w * __w * __w * __v * __v; | |
| 5277 | if (__z <= 1 - 2 * __y * __y / __x) | |
| 5278 | break; | |
| 5279 | if (_VSTD::log(__z) <= 2 * (__b * _VSTD::log(__x / __b) - __y)) | |
| 5280 | break; | |
| 5281 | } | |
| 5282 | } | |
| 5283 | } | |
| 5284 | } | |
| 5285 | else // __a < 1 | |
| 5286 | { | |
| 5287 | while (true) | |
| 5288 | { | |
| 5289 | const result_type __u = __gen(__g); | |
| 5290 | const result_type __es = __egen(__g); | |
| 5291 | if (__u <= 1 - __a) | |
| 5292 | { | |
| 5293 | __x = _VSTD::pow(__u, 1 / __a); | |
| 5294 | if (__x <= __es) | |
| 5295 | break; | |
| 5296 | } | |
| 5297 | else | |
| 5298 | { | |
| 5299 | const result_type __e = -_VSTD::log((1-__u)/__a); | |
| 5300 | __x = _VSTD::pow(1 - __a + __a * __e, 1 / __a); | |
| 5301 | if (__x <= __e + __es) | |
| 5302 | break; | |
| 5303 | } | |
| 5304 | } | |
| 5305 | } | |
| 5306 | return __x * __p.beta(); | |
| 5307 | } | |
| 5308 | ||
| 5309 | template <class _CharT, class _Traits, class _RT> | |
| 5310 | basic_ostream<_CharT, _Traits>& | |
| 5311 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5312 | const gamma_distribution<_RT>& __x) | |
| 5313 | { | |
| 5314 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5315 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5316 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5317 | _OStream::scientific); | |
| 5318 | _CharT __sp = __os.widen(' '); | |
| 5319 | __os.fill(__sp); | |
| 5320 | __os << __x.alpha() << __sp << __x.beta(); | |
| 5321 | return __os; | |
| 5322 | } | |
| 5323 | ||
| 5324 | template <class _CharT, class _Traits, class _RT> | |
| 5325 | basic_istream<_CharT, _Traits>& | |
| 5326 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5327 | gamma_distribution<_RT>& __x) | |
| 5328 | { | |
| 5329 | typedef gamma_distribution<_RT> _Eng; | |
| 5330 | typedef typename _Eng::result_type result_type; | |
| 5331 | typedef typename _Eng::param_type param_type; | |
| 5332 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5333 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5334 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5335 | result_type __alpha; | |
| 5336 | result_type __beta; | |
| 5337 | __is >> __alpha >> __beta; | |
| 5338 | if (!__is.fail()) | |
| 5339 | __x.param(param_type(__alpha, __beta)); | |
| 5340 | return __is; | |
| 5341 | } | |
| 5342 | ||
| 5343 | // negative_binomial_distribution | |
| 5344 | ||
| 5345 | template<class _IntType = int> | |
| 5346 | class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution | |
| 5347 | { | |
| 5348 | public: | |
| 5349 | // types | |
| 5350 | typedef _IntType result_type; | |
| 5351 | ||
| 5352 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5353 | { | |
| 5354 | result_type __k_; | |
| 5355 | double __p_; | |
| 5356 | public: | |
| 5357 | typedef negative_binomial_distribution distribution_type; | |
| 5358 | ||
| 5359 | _LIBCPP_INLINE_VISIBILITY | |
| 5360 | explicit param_type(result_type __k = 1, double __p = 0.5) | |
| 5361 | : __k_(__k), __p_(__p) {} | |
| 5362 | ||
| 5363 | _LIBCPP_INLINE_VISIBILITY | |
| 5364 | result_type k() const {return __k_;} | |
| 5365 | _LIBCPP_INLINE_VISIBILITY | |
| 5366 | double p() const {return __p_;} | |
| 5367 | ||
| 5368 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5369 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5370 | {return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;} | |
| 5371 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5372 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5373 | {return !(__x == __y);} | |
| 5374 | }; | |
| 5375 | ||
| 5376 | private: | |
| 5377 | param_type __p_; | |
| 5378 | ||
| 5379 | public: | |
| 5380 | // constructor and reset functions | |
| 5381 | #ifndef _LIBCPP_CXX03_LANG | |
| 5382 | _LIBCPP_INLINE_VISIBILITY | |
| 5383 | negative_binomial_distribution() : negative_binomial_distribution(1) {} | |
| 5384 | _LIBCPP_INLINE_VISIBILITY | |
| 5385 | explicit negative_binomial_distribution(result_type __k, double __p = 0.5) | |
| 5386 | : __p_(__k, __p) {} | |
| 5387 | #else | |
| 5388 | _LIBCPP_INLINE_VISIBILITY | |
| 5389 | explicit negative_binomial_distribution(result_type __k = 1, | |
| 5390 | double __p = 0.5) | |
| 5391 | : __p_(__k, __p) {} | |
| 5392 | #endif | |
| 5393 | _LIBCPP_INLINE_VISIBILITY | |
| 5394 | explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {} | |
| 5395 | _LIBCPP_INLINE_VISIBILITY | |
| 5396 | void reset() {} | |
| 5397 | ||
| 5398 | // generating functions | |
| 5399 | template<class _URNG> | |
| 5400 | _LIBCPP_INLINE_VISIBILITY | |
| 5401 | result_type operator()(_URNG& __g) | |
| 5402 | {return (*this)(__g, __p_);} | |
| 5403 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 5404 | ||
| 5405 | // property functions | |
| 5406 | _LIBCPP_INLINE_VISIBILITY | |
| 5407 | result_type k() const {return __p_.k();} | |
| 5408 | _LIBCPP_INLINE_VISIBILITY | |
| 5409 | double p() const {return __p_.p();} | |
| 5410 | ||
| 5411 | _LIBCPP_INLINE_VISIBILITY | |
| 5412 | param_type param() const {return __p_;} | |
| 5413 | _LIBCPP_INLINE_VISIBILITY | |
| 5414 | void param(const param_type& __p) {__p_ = __p;} | |
| 5415 | ||
| 5416 | _LIBCPP_INLINE_VISIBILITY | |
| 5417 | result_type min() const {return 0;} | |
| 5418 | _LIBCPP_INLINE_VISIBILITY | |
| 5419 | result_type max() const {return numeric_limits<result_type>::max();} | |
| 5420 | ||
| 5421 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5422 | bool operator==(const negative_binomial_distribution& __x, | |
| 5423 | const negative_binomial_distribution& __y) | |
| 5424 | {return __x.__p_ == __y.__p_;} | |
| 5425 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5426 | bool operator!=(const negative_binomial_distribution& __x, | |
| 5427 | const negative_binomial_distribution& __y) | |
| 5428 | {return !(__x == __y);} | |
| 5429 | }; | |
| 5430 | ||
| 5431 | template <class _IntType> | |
| 5432 | template<class _URNG> | |
| 5433 | _IntType | |
| 5434 | negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) | |
| 5435 | { | |
| 5436 | result_type __k = __pr.k(); | |
| 5437 | double __p = __pr.p(); | |
| 5438 | if (__k <= 21 * __p) | |
| 5439 | { | |
| 5440 | bernoulli_distribution __gen(__p); | |
| 5441 | result_type __f = 0; | |
| 5442 | result_type __s = 0; | |
| 5443 | while (__s < __k) | |
| 5444 | { | |
| 5445 | if (__gen(__urng)) | |
| 5446 | ++__s; | |
| 5447 | else | |
| 5448 | ++__f; | |
| 5449 | } | |
| 5450 | return __f; | |
| 5451 | } | |
| 5452 | return poisson_distribution<result_type>(gamma_distribution<double> | |
| 5453 | (__k, (1-__p)/__p)(__urng))(__urng); | |
| 5454 | } | |
| 5455 | ||
| 5456 | template <class _CharT, class _Traits, class _IntType> | |
| 5457 | basic_ostream<_CharT, _Traits>& | |
| 5458 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5459 | const negative_binomial_distribution<_IntType>& __x) | |
| 5460 | { | |
| 5461 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5462 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5463 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5464 | _OStream::scientific); | |
| 5465 | _CharT __sp = __os.widen(' '); | |
| 5466 | __os.fill(__sp); | |
| 5467 | return __os << __x.k() << __sp << __x.p(); | |
| 5468 | } | |
| 5469 | ||
| 5470 | template <class _CharT, class _Traits, class _IntType> | |
| 5471 | basic_istream<_CharT, _Traits>& | |
| 5472 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5473 | negative_binomial_distribution<_IntType>& __x) | |
| 5474 | { | |
| 5475 | typedef negative_binomial_distribution<_IntType> _Eng; | |
| 5476 | typedef typename _Eng::result_type result_type; | |
| 5477 | typedef typename _Eng::param_type param_type; | |
| 5478 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5479 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5480 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5481 | result_type __k; | |
| 5482 | double __p; | |
| 5483 | __is >> __k >> __p; | |
| 5484 | if (!__is.fail()) | |
| 5485 | __x.param(param_type(__k, __p)); | |
| 5486 | return __is; | |
| 5487 | } | |
| 5488 | ||
| 5489 | // geometric_distribution | |
| 5490 | ||
| 5491 | template<class _IntType = int> | |
| 5492 | class _LIBCPP_TEMPLATE_VIS geometric_distribution | |
| 5493 | { | |
| 5494 | public: | |
| 5495 | // types | |
| 5496 | typedef _IntType result_type; | |
| 5497 | ||
| 5498 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5499 | { | |
| 5500 | double __p_; | |
| 5501 | public: | |
| 5502 | typedef geometric_distribution distribution_type; | |
| 5503 | ||
| 5504 | _LIBCPP_INLINE_VISIBILITY | |
| 5505 | explicit param_type(double __p = 0.5) : __p_(__p) {} | |
| 5506 | ||
| 5507 | _LIBCPP_INLINE_VISIBILITY | |
| 5508 | double p() const {return __p_;} | |
| 5509 | ||
| 5510 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5511 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5512 | {return __x.__p_ == __y.__p_;} | |
| 5513 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5514 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5515 | {return !(__x == __y);} | |
| 5516 | }; | |
| 5517 | ||
| 5518 | private: | |
| 5519 | param_type __p_; | |
| 5520 | ||
| 5521 | public: | |
| 5522 | // constructors and reset functions | |
| 5523 | #ifndef _LIBCPP_CXX03_LANG | |
| 5524 | _LIBCPP_INLINE_VISIBILITY | |
| 5525 | geometric_distribution() : geometric_distribution(0.5) {} | |
| 5526 | _LIBCPP_INLINE_VISIBILITY | |
| 5527 | explicit geometric_distribution(double __p) | |
| 5528 | : __p_(__p) {} | |
| 5529 | #else | |
| 5530 | _LIBCPP_INLINE_VISIBILITY | |
| 5531 | explicit geometric_distribution(double __p = 0.5) | |
| 5532 | : __p_(__p) {} | |
| 5533 | #endif | |
| 5534 | _LIBCPP_INLINE_VISIBILITY | |
| 5535 | explicit geometric_distribution(const param_type& __p) : __p_(__p) {} | |
| 5536 | _LIBCPP_INLINE_VISIBILITY | |
| 5537 | void reset() {} | |
| 5538 | ||
| 5539 | // generating functions | |
| 5540 | template<class _URNG> | |
| 5541 | _LIBCPP_INLINE_VISIBILITY | |
| 5542 | result_type operator()(_URNG& __g) | |
| 5543 | {return (*this)(__g, __p_);} | |
| 5544 | template<class _URNG> | |
| 5545 | _LIBCPP_INLINE_VISIBILITY | |
| 5546 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 5547 | {return negative_binomial_distribution<result_type>(1, __p.p())(__g);} | |
| 5548 | ||
| 5549 | // property functions | |
| 5550 | _LIBCPP_INLINE_VISIBILITY | |
| 5551 | double p() const {return __p_.p();} | |
| 5552 | ||
| 5553 | _LIBCPP_INLINE_VISIBILITY | |
| 5554 | param_type param() const {return __p_;} | |
| 5555 | _LIBCPP_INLINE_VISIBILITY | |
| 5556 | void param(const param_type& __p) {__p_ = __p;} | |
| 5557 | ||
| 5558 | _LIBCPP_INLINE_VISIBILITY | |
| 5559 | result_type min() const {return 0;} | |
| 5560 | _LIBCPP_INLINE_VISIBILITY | |
| 5561 | result_type max() const {return numeric_limits<result_type>::max();} | |
| 5562 | ||
| 5563 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5564 | bool operator==(const geometric_distribution& __x, | |
| 5565 | const geometric_distribution& __y) | |
| 5566 | {return __x.__p_ == __y.__p_;} | |
| 5567 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5568 | bool operator!=(const geometric_distribution& __x, | |
| 5569 | const geometric_distribution& __y) | |
| 5570 | {return !(__x == __y);} | |
| 5571 | }; | |
| 5572 | ||
| 5573 | template <class _CharT, class _Traits, class _IntType> | |
| 5574 | basic_ostream<_CharT, _Traits>& | |
| 5575 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5576 | const geometric_distribution<_IntType>& __x) | |
| 5577 | { | |
| 5578 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5579 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5580 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5581 | _OStream::scientific); | |
| 5582 | return __os << __x.p(); | |
| 5583 | } | |
| 5584 | ||
| 5585 | template <class _CharT, class _Traits, class _IntType> | |
| 5586 | basic_istream<_CharT, _Traits>& | |
| 5587 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5588 | geometric_distribution<_IntType>& __x) | |
| 5589 | { | |
| 5590 | typedef geometric_distribution<_IntType> _Eng; | |
| 5591 | typedef typename _Eng::param_type param_type; | |
| 5592 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5593 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5594 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5595 | double __p; | |
| 5596 | __is >> __p; | |
| 5597 | if (!__is.fail()) | |
| 5598 | __x.param(param_type(__p)); | |
| 5599 | return __is; | |
| 5600 | } | |
| 5601 | ||
| 5602 | // chi_squared_distribution | |
| 5603 | ||
| 5604 | template<class _RealType = double> | |
| 5605 | class _LIBCPP_TEMPLATE_VIS chi_squared_distribution | |
| 5606 | { | |
| 5607 | public: | |
| 5608 | // types | |
| 5609 | typedef _RealType result_type; | |
| 5610 | ||
| 5611 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5612 | { | |
| 5613 | result_type __n_; | |
| 5614 | public: | |
| 5615 | typedef chi_squared_distribution distribution_type; | |
| 5616 | ||
| 5617 | _LIBCPP_INLINE_VISIBILITY | |
| 5618 | explicit param_type(result_type __n = 1) : __n_(__n) {} | |
| 5619 | ||
| 5620 | _LIBCPP_INLINE_VISIBILITY | |
| 5621 | result_type n() const {return __n_;} | |
| 5622 | ||
| 5623 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5624 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5625 | {return __x.__n_ == __y.__n_;} | |
| 5626 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5627 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5628 | {return !(__x == __y);} | |
| 5629 | }; | |
| 5630 | ||
| 5631 | private: | |
| 5632 | param_type __p_; | |
| 5633 | ||
| 5634 | public: | |
| 5635 | // constructor and reset functions | |
| 5636 | #ifndef _LIBCPP_CXX03_LANG | |
| 5637 | _LIBCPP_INLINE_VISIBILITY | |
| 5638 | chi_squared_distribution() : chi_squared_distribution(1) {} | |
| 5639 | _LIBCPP_INLINE_VISIBILITY | |
| 5640 | explicit chi_squared_distribution(result_type __n) | |
| 5641 | : __p_(param_type(__n)) {} | |
| 5642 | #else | |
| 5643 | _LIBCPP_INLINE_VISIBILITY | |
| 5644 | explicit chi_squared_distribution(result_type __n = 1) | |
| 5645 | : __p_(param_type(__n)) {} | |
| 5646 | #endif | |
| 5647 | _LIBCPP_INLINE_VISIBILITY | |
| 5648 | explicit chi_squared_distribution(const param_type& __p) | |
| 5649 | : __p_(__p) {} | |
| 5650 | _LIBCPP_INLINE_VISIBILITY | |
| 5651 | void reset() {} | |
| 5652 | ||
| 5653 | // generating functions | |
| 5654 | template<class _URNG> | |
| 5655 | _LIBCPP_INLINE_VISIBILITY | |
| 5656 | result_type operator()(_URNG& __g) | |
| 5657 | {return (*this)(__g, __p_);} | |
| 5658 | template<class _URNG> | |
| 5659 | _LIBCPP_INLINE_VISIBILITY | |
| 5660 | result_type operator()(_URNG& __g, const param_type& __p) | |
| 5661 | {return gamma_distribution<result_type>(__p.n() / 2, 2)(__g);} | |
| 5662 | ||
| 5663 | // property functions | |
| 5664 | _LIBCPP_INLINE_VISIBILITY | |
| 5665 | result_type n() const {return __p_.n();} | |
| 5666 | ||
| 5667 | _LIBCPP_INLINE_VISIBILITY | |
| 5668 | param_type param() const {return __p_;} | |
| 5669 | _LIBCPP_INLINE_VISIBILITY | |
| 5670 | void param(const param_type& __p) {__p_ = __p;} | |
| 5671 | ||
| 5672 | _LIBCPP_INLINE_VISIBILITY | |
| 5673 | result_type min() const {return 0;} | |
| 5674 | _LIBCPP_INLINE_VISIBILITY | |
| 5675 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 5676 | ||
| 5677 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5678 | bool operator==(const chi_squared_distribution& __x, | |
| 5679 | const chi_squared_distribution& __y) | |
| 5680 | {return __x.__p_ == __y.__p_;} | |
| 5681 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5682 | bool operator!=(const chi_squared_distribution& __x, | |
| 5683 | const chi_squared_distribution& __y) | |
| 5684 | {return !(__x == __y);} | |
| 5685 | }; | |
| 5686 | ||
| 5687 | template <class _CharT, class _Traits, class _RT> | |
| 5688 | basic_ostream<_CharT, _Traits>& | |
| 5689 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5690 | const chi_squared_distribution<_RT>& __x) | |
| 5691 | { | |
| 5692 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5693 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5694 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5695 | _OStream::scientific); | |
| 5696 | __os << __x.n(); | |
| 5697 | return __os; | |
| 5698 | } | |
| 5699 | ||
| 5700 | template <class _CharT, class _Traits, class _RT> | |
| 5701 | basic_istream<_CharT, _Traits>& | |
| 5702 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5703 | chi_squared_distribution<_RT>& __x) | |
| 5704 | { | |
| 5705 | typedef chi_squared_distribution<_RT> _Eng; | |
| 5706 | typedef typename _Eng::result_type result_type; | |
| 5707 | typedef typename _Eng::param_type param_type; | |
| 5708 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5709 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5710 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5711 | result_type __n; | |
| 5712 | __is >> __n; | |
| 5713 | if (!__is.fail()) | |
| 5714 | __x.param(param_type(__n)); | |
| 5715 | return __is; | |
| 5716 | } | |
| 5717 | ||
| 5718 | // cauchy_distribution | |
| 5719 | ||
| 5720 | template<class _RealType = double> | |
| 5721 | class _LIBCPP_TEMPLATE_VIS cauchy_distribution | |
| 5722 | { | |
| 5723 | public: | |
| 5724 | // types | |
| 5725 | typedef _RealType result_type; | |
| 5726 | ||
| 5727 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5728 | { | |
| 5729 | result_type __a_; | |
| 5730 | result_type __b_; | |
| 5731 | public: | |
| 5732 | typedef cauchy_distribution distribution_type; | |
| 5733 | ||
| 5734 | _LIBCPP_INLINE_VISIBILITY | |
| 5735 | explicit param_type(result_type __a = 0, result_type __b = 1) | |
| 5736 | : __a_(__a), __b_(__b) {} | |
| 5737 | ||
| 5738 | _LIBCPP_INLINE_VISIBILITY | |
| 5739 | result_type a() const {return __a_;} | |
| 5740 | _LIBCPP_INLINE_VISIBILITY | |
| 5741 | result_type b() const {return __b_;} | |
| 5742 | ||
| 5743 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5744 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5745 | {return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;} | |
| 5746 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5747 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5748 | {return !(__x == __y);} | |
| 5749 | }; | |
| 5750 | ||
| 5751 | private: | |
| 5752 | param_type __p_; | |
| 5753 | ||
| 5754 | public: | |
| 5755 | // constructor and reset functions | |
| 5756 | #ifndef _LIBCPP_CXX03_LANG | |
| 5757 | _LIBCPP_INLINE_VISIBILITY | |
| 5758 | cauchy_distribution() : cauchy_distribution(0) {} | |
| 5759 | _LIBCPP_INLINE_VISIBILITY | |
| 5760 | explicit cauchy_distribution(result_type __a, result_type __b = 1) | |
| 5761 | : __p_(param_type(__a, __b)) {} | |
| 5762 | #else | |
| 5763 | _LIBCPP_INLINE_VISIBILITY | |
| 5764 | explicit cauchy_distribution(result_type __a = 0, result_type __b = 1) | |
| 5765 | : __p_(param_type(__a, __b)) {} | |
| 5766 | #endif | |
| 5767 | _LIBCPP_INLINE_VISIBILITY | |
| 5768 | explicit cauchy_distribution(const param_type& __p) | |
| 5769 | : __p_(__p) {} | |
| 5770 | _LIBCPP_INLINE_VISIBILITY | |
| 5771 | void reset() {} | |
| 5772 | ||
| 5773 | // generating functions | |
| 5774 | template<class _URNG> | |
| 5775 | _LIBCPP_INLINE_VISIBILITY | |
| 5776 | result_type operator()(_URNG& __g) | |
| 5777 | {return (*this)(__g, __p_);} | |
| 5778 | template<class _URNG> _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); | |
| 5779 | ||
| 5780 | // property functions | |
| 5781 | _LIBCPP_INLINE_VISIBILITY | |
| 5782 | result_type a() const {return __p_.a();} | |
| 5783 | _LIBCPP_INLINE_VISIBILITY | |
| 5784 | result_type b() const {return __p_.b();} | |
| 5785 | ||
| 5786 | _LIBCPP_INLINE_VISIBILITY | |
| 5787 | param_type param() const {return __p_;} | |
| 5788 | _LIBCPP_INLINE_VISIBILITY | |
| 5789 | void param(const param_type& __p) {__p_ = __p;} | |
| 5790 | ||
| 5791 | _LIBCPP_INLINE_VISIBILITY | |
| 5792 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 5793 | _LIBCPP_INLINE_VISIBILITY | |
| 5794 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 5795 | ||
| 5796 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5797 | bool operator==(const cauchy_distribution& __x, | |
| 5798 | const cauchy_distribution& __y) | |
| 5799 | {return __x.__p_ == __y.__p_;} | |
| 5800 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5801 | bool operator!=(const cauchy_distribution& __x, | |
| 5802 | const cauchy_distribution& __y) | |
| 5803 | {return !(__x == __y);} | |
| 5804 | }; | |
| 5805 | ||
| 5806 | template <class _RealType> | |
| 5807 | template<class _URNG> | |
| 5808 | inline | |
| 5809 | _RealType | |
| 5810 | cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 5811 | { | |
| 5812 | uniform_real_distribution<result_type> __gen; | |
| 5813 | // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite | |
| 5814 | return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g)); | |
| 5815 | } | |
| 5816 | ||
| 5817 | template <class _CharT, class _Traits, class _RT> | |
| 5818 | basic_ostream<_CharT, _Traits>& | |
| 5819 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5820 | const cauchy_distribution<_RT>& __x) | |
| 5821 | { | |
| 5822 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5823 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5824 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5825 | _OStream::scientific); | |
| 5826 | _CharT __sp = __os.widen(' '); | |
| 5827 | __os.fill(__sp); | |
| 5828 | __os << __x.a() << __sp << __x.b(); | |
| 5829 | return __os; | |
| 5830 | } | |
| 5831 | ||
| 5832 | template <class _CharT, class _Traits, class _RT> | |
| 5833 | basic_istream<_CharT, _Traits>& | |
| 5834 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5835 | cauchy_distribution<_RT>& __x) | |
| 5836 | { | |
| 5837 | typedef cauchy_distribution<_RT> _Eng; | |
| 5838 | typedef typename _Eng::result_type result_type; | |
| 5839 | typedef typename _Eng::param_type param_type; | |
| 5840 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5841 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5842 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5843 | result_type __a; | |
| 5844 | result_type __b; | |
| 5845 | __is >> __a >> __b; | |
| 5846 | if (!__is.fail()) | |
| 5847 | __x.param(param_type(__a, __b)); | |
| 5848 | return __is; | |
| 5849 | } | |
| 5850 | ||
| 5851 | // fisher_f_distribution | |
| 5852 | ||
| 5853 | template<class _RealType = double> | |
| 5854 | class _LIBCPP_TEMPLATE_VIS fisher_f_distribution | |
| 5855 | { | |
| 5856 | public: | |
| 5857 | // types | |
| 5858 | typedef _RealType result_type; | |
| 5859 | ||
| 5860 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5861 | { | |
| 5862 | result_type __m_; | |
| 5863 | result_type __n_; | |
| 5864 | public: | |
| 5865 | typedef fisher_f_distribution distribution_type; | |
| 5866 | ||
| 5867 | _LIBCPP_INLINE_VISIBILITY | |
| 5868 | explicit param_type(result_type __m = 1, result_type __n = 1) | |
| 5869 | : __m_(__m), __n_(__n) {} | |
| 5870 | ||
| 5871 | _LIBCPP_INLINE_VISIBILITY | |
| 5872 | result_type m() const {return __m_;} | |
| 5873 | _LIBCPP_INLINE_VISIBILITY | |
| 5874 | result_type n() const {return __n_;} | |
| 5875 | ||
| 5876 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5877 | bool operator==(const param_type& __x, const param_type& __y) | |
| 5878 | {return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;} | |
| 5879 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5880 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 5881 | {return !(__x == __y);} | |
| 5882 | }; | |
| 5883 | ||
| 5884 | private: | |
| 5885 | param_type __p_; | |
| 5886 | ||
| 5887 | public: | |
| 5888 | // constructor and reset functions | |
| 5889 | #ifndef _LIBCPP_CXX03_LANG | |
| 5890 | _LIBCPP_INLINE_VISIBILITY | |
| 5891 | fisher_f_distribution() : fisher_f_distribution(1) {} | |
| 5892 | _LIBCPP_INLINE_VISIBILITY | |
| 5893 | explicit fisher_f_distribution(result_type __m, result_type __n = 1) | |
| 5894 | : __p_(param_type(__m, __n)) {} | |
| 5895 | #else | |
| 5896 | _LIBCPP_INLINE_VISIBILITY | |
| 5897 | explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1) | |
| 5898 | : __p_(param_type(__m, __n)) {} | |
| 5899 | #endif | |
| 5900 | _LIBCPP_INLINE_VISIBILITY | |
| 5901 | explicit fisher_f_distribution(const param_type& __p) | |
| 5902 | : __p_(__p) {} | |
| 5903 | _LIBCPP_INLINE_VISIBILITY | |
| 5904 | void reset() {} | |
| 5905 | ||
| 5906 | // generating functions | |
| 5907 | template<class _URNG> | |
| 5908 | _LIBCPP_INLINE_VISIBILITY | |
| 5909 | result_type operator()(_URNG& __g) | |
| 5910 | {return (*this)(__g, __p_);} | |
| 5911 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 5912 | ||
| 5913 | // property functions | |
| 5914 | _LIBCPP_INLINE_VISIBILITY | |
| 5915 | result_type m() const {return __p_.m();} | |
| 5916 | _LIBCPP_INLINE_VISIBILITY | |
| 5917 | result_type n() const {return __p_.n();} | |
| 5918 | ||
| 5919 | _LIBCPP_INLINE_VISIBILITY | |
| 5920 | param_type param() const {return __p_;} | |
| 5921 | _LIBCPP_INLINE_VISIBILITY | |
| 5922 | void param(const param_type& __p) {__p_ = __p;} | |
| 5923 | ||
| 5924 | _LIBCPP_INLINE_VISIBILITY | |
| 5925 | result_type min() const {return 0;} | |
| 5926 | _LIBCPP_INLINE_VISIBILITY | |
| 5927 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 5928 | ||
| 5929 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5930 | bool operator==(const fisher_f_distribution& __x, | |
| 5931 | const fisher_f_distribution& __y) | |
| 5932 | {return __x.__p_ == __y.__p_;} | |
| 5933 | friend _LIBCPP_INLINE_VISIBILITY | |
| 5934 | bool operator!=(const fisher_f_distribution& __x, | |
| 5935 | const fisher_f_distribution& __y) | |
| 5936 | {return !(__x == __y);} | |
| 5937 | }; | |
| 5938 | ||
| 5939 | template <class _RealType> | |
| 5940 | template<class _URNG> | |
| 5941 | _RealType | |
| 5942 | fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 5943 | { | |
| 5944 | gamma_distribution<result_type> __gdm(__p.m() * result_type(.5)); | |
| 5945 | gamma_distribution<result_type> __gdn(__p.n() * result_type(.5)); | |
| 5946 | return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g)); | |
| 5947 | } | |
| 5948 | ||
| 5949 | template <class _CharT, class _Traits, class _RT> | |
| 5950 | basic_ostream<_CharT, _Traits>& | |
| 5951 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 5952 | const fisher_f_distribution<_RT>& __x) | |
| 5953 | { | |
| 5954 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 5955 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 5956 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 5957 | _OStream::scientific); | |
| 5958 | _CharT __sp = __os.widen(' '); | |
| 5959 | __os.fill(__sp); | |
| 5960 | __os << __x.m() << __sp << __x.n(); | |
| 5961 | return __os; | |
| 5962 | } | |
| 5963 | ||
| 5964 | template <class _CharT, class _Traits, class _RT> | |
| 5965 | basic_istream<_CharT, _Traits>& | |
| 5966 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 5967 | fisher_f_distribution<_RT>& __x) | |
| 5968 | { | |
| 5969 | typedef fisher_f_distribution<_RT> _Eng; | |
| 5970 | typedef typename _Eng::result_type result_type; | |
| 5971 | typedef typename _Eng::param_type param_type; | |
| 5972 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 5973 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 5974 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 5975 | result_type __m; | |
| 5976 | result_type __n; | |
| 5977 | __is >> __m >> __n; | |
| 5978 | if (!__is.fail()) | |
| 5979 | __x.param(param_type(__m, __n)); | |
| 5980 | return __is; | |
| 5981 | } | |
| 5982 | ||
| 5983 | // student_t_distribution | |
| 5984 | ||
| 5985 | template<class _RealType = double> | |
| 5986 | class _LIBCPP_TEMPLATE_VIS student_t_distribution | |
| 5987 | { | |
| 5988 | public: | |
| 5989 | // types | |
| 5990 | typedef _RealType result_type; | |
| 5991 | ||
| 5992 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 5993 | { | |
| 5994 | result_type __n_; | |
| 5995 | public: | |
| 5996 | typedef student_t_distribution distribution_type; | |
| 5997 | ||
| 5998 | _LIBCPP_INLINE_VISIBILITY | |
| 5999 | explicit param_type(result_type __n = 1) : __n_(__n) {} | |
| 6000 | ||
| 6001 | _LIBCPP_INLINE_VISIBILITY | |
| 6002 | result_type n() const {return __n_;} | |
| 6003 | ||
| 6004 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6005 | bool operator==(const param_type& __x, const param_type& __y) | |
| 6006 | {return __x.__n_ == __y.__n_;} | |
| 6007 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6008 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 6009 | {return !(__x == __y);} | |
| 6010 | }; | |
| 6011 | ||
| 6012 | private: | |
| 6013 | param_type __p_; | |
| 6014 | normal_distribution<result_type> __nd_; | |
| 6015 | ||
| 6016 | public: | |
| 6017 | // constructor and reset functions | |
| 6018 | #ifndef _LIBCPP_CXX03_LANG | |
| 6019 | _LIBCPP_INLINE_VISIBILITY | |
| 6020 | student_t_distribution() : student_t_distribution(1) {} | |
| 6021 | _LIBCPP_INLINE_VISIBILITY | |
| 6022 | explicit student_t_distribution(result_type __n) | |
| 6023 | : __p_(param_type(__n)) {} | |
| 6024 | #else | |
| 6025 | _LIBCPP_INLINE_VISIBILITY | |
| 6026 | explicit student_t_distribution(result_type __n = 1) | |
| 6027 | : __p_(param_type(__n)) {} | |
| 6028 | #endif | |
| 6029 | _LIBCPP_INLINE_VISIBILITY | |
| 6030 | explicit student_t_distribution(const param_type& __p) | |
| 6031 | : __p_(__p) {} | |
| 6032 | _LIBCPP_INLINE_VISIBILITY | |
| 6033 | void reset() {__nd_.reset();} | |
| 6034 | ||
| 6035 | // generating functions | |
| 6036 | template<class _URNG> | |
| 6037 | _LIBCPP_INLINE_VISIBILITY | |
| 6038 | result_type operator()(_URNG& __g) | |
| 6039 | {return (*this)(__g, __p_);} | |
| 6040 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 6041 | ||
| 6042 | // property functions | |
| 6043 | _LIBCPP_INLINE_VISIBILITY | |
| 6044 | result_type n() const {return __p_.n();} | |
| 6045 | ||
| 6046 | _LIBCPP_INLINE_VISIBILITY | |
| 6047 | param_type param() const {return __p_;} | |
| 6048 | _LIBCPP_INLINE_VISIBILITY | |
| 6049 | void param(const param_type& __p) {__p_ = __p;} | |
| 6050 | ||
| 6051 | _LIBCPP_INLINE_VISIBILITY | |
| 6052 | result_type min() const {return -numeric_limits<result_type>::infinity();} | |
| 6053 | _LIBCPP_INLINE_VISIBILITY | |
| 6054 | result_type max() const {return numeric_limits<result_type>::infinity();} | |
| 6055 | ||
| 6056 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6057 | bool operator==(const student_t_distribution& __x, | |
| 6058 | const student_t_distribution& __y) | |
| 6059 | {return __x.__p_ == __y.__p_;} | |
| 6060 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6061 | bool operator!=(const student_t_distribution& __x, | |
| 6062 | const student_t_distribution& __y) | |
| 6063 | {return !(__x == __y);} | |
| 6064 | }; | |
| 6065 | ||
| 6066 | template <class _RealType> | |
| 6067 | template<class _URNG> | |
| 6068 | _RealType | |
| 6069 | student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 6070 | { | |
| 6071 | gamma_distribution<result_type> __gd(__p.n() * .5, 2); | |
| 6072 | return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g)); | |
| 6073 | } | |
| 6074 | ||
| 6075 | template <class _CharT, class _Traits, class _RT> | |
| 6076 | basic_ostream<_CharT, _Traits>& | |
| 6077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6078 | const student_t_distribution<_RT>& __x) | |
| 6079 | { | |
| 6080 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 6081 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 6082 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 6083 | _OStream::scientific); | |
| 6084 | __os << __x.n(); | |
| 6085 | return __os; | |
| 6086 | } | |
| 6087 | ||
| 6088 | template <class _CharT, class _Traits, class _RT> | |
| 6089 | basic_istream<_CharT, _Traits>& | |
| 6090 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6091 | student_t_distribution<_RT>& __x) | |
| 6092 | { | |
| 6093 | typedef student_t_distribution<_RT> _Eng; | |
| 6094 | typedef typename _Eng::result_type result_type; | |
| 6095 | typedef typename _Eng::param_type param_type; | |
| 6096 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 6097 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 6098 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 6099 | result_type __n; | |
| 6100 | __is >> __n; | |
| 6101 | if (!__is.fail()) | |
| 6102 | __x.param(param_type(__n)); | |
| 6103 | return __is; | |
| 6104 | } | |
| 6105 | ||
| 6106 | // discrete_distribution | |
| 6107 | ||
| 6108 | template<class _IntType = int> | |
| 6109 | class _LIBCPP_TEMPLATE_VIS discrete_distribution | |
| 6110 | { | |
| 6111 | public: | |
| 6112 | // types | |
| 6113 | typedef _IntType result_type; | |
| 6114 | ||
| 6115 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 6116 | { | |
| 6117 | vector<double> __p_; | |
| 6118 | public: | |
| 6119 | typedef discrete_distribution distribution_type; | |
| 6120 | ||
| 6121 | _LIBCPP_INLINE_VISIBILITY | |
| 6122 | param_type() {} | |
| 6123 | template<class _InputIterator> | |
| 6124 | _LIBCPP_INLINE_VISIBILITY | |
| 6125 | param_type(_InputIterator __f, _InputIterator __l) | |
| 6126 | : __p_(__f, __l) {__init();} | |
| 6127 | #ifndef _LIBCPP_CXX03_LANG | |
| 6128 | _LIBCPP_INLINE_VISIBILITY | |
| 6129 | param_type(initializer_list<double> __wl) | |
| 6130 | : __p_(__wl.begin(), __wl.end()) {__init();} | |
| 6131 | #endif // _LIBCPP_CXX03_LANG | |
| 6132 | template<class _UnaryOperation> | |
| 6133 | param_type(size_t __nw, double __xmin, double __xmax, | |
| 6134 | _UnaryOperation __fw); | |
| 6135 | ||
| 6136 | vector<double> probabilities() const; | |
| 6137 | ||
| 6138 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6139 | bool operator==(const param_type& __x, const param_type& __y) | |
| 6140 | {return __x.__p_ == __y.__p_;} | |
| 6141 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6142 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 6143 | {return !(__x == __y);} | |
| 6144 | ||
| 6145 | private: | |
| 6146 | void __init(); | |
| 6147 | ||
| 6148 | friend class discrete_distribution; | |
| 6149 | ||
| 6150 | template <class _CharT, class _Traits, class _IT> | |
| 6151 | friend | |
| 6152 | basic_ostream<_CharT, _Traits>& | |
| 6153 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6154 | const discrete_distribution<_IT>& __x); | |
| 6155 | ||
| 6156 | template <class _CharT, class _Traits, class _IT> | |
| 6157 | friend | |
| 6158 | basic_istream<_CharT, _Traits>& | |
| 6159 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6160 | discrete_distribution<_IT>& __x); | |
| 6161 | }; | |
| 6162 | ||
| 6163 | private: | |
| 6164 | param_type __p_; | |
| 6165 | ||
| 6166 | public: | |
| 6167 | // constructor and reset functions | |
| 6168 | _LIBCPP_INLINE_VISIBILITY | |
| 6169 | discrete_distribution() {} | |
| 6170 | template<class _InputIterator> | |
| 6171 | _LIBCPP_INLINE_VISIBILITY | |
| 6172 | discrete_distribution(_InputIterator __f, _InputIterator __l) | |
| 6173 | : __p_(__f, __l) {} | |
| 6174 | #ifndef _LIBCPP_CXX03_LANG | |
| 6175 | _LIBCPP_INLINE_VISIBILITY | |
| 6176 | discrete_distribution(initializer_list<double> __wl) | |
| 6177 | : __p_(__wl) {} | |
| 6178 | #endif // _LIBCPP_CXX03_LANG | |
| 6179 | template<class _UnaryOperation> | |
| 6180 | _LIBCPP_INLINE_VISIBILITY | |
| 6181 | discrete_distribution(size_t __nw, double __xmin, double __xmax, | |
| 6182 | _UnaryOperation __fw) | |
| 6183 | : __p_(__nw, __xmin, __xmax, __fw) {} | |
| 6184 | _LIBCPP_INLINE_VISIBILITY | |
| 6185 | explicit discrete_distribution(const param_type& __p) | |
| 6186 | : __p_(__p) {} | |
| 6187 | _LIBCPP_INLINE_VISIBILITY | |
| 6188 | void reset() {} | |
| 6189 | ||
| 6190 | // generating functions | |
| 6191 | template<class _URNG> | |
| 6192 | _LIBCPP_INLINE_VISIBILITY | |
| 6193 | result_type operator()(_URNG& __g) | |
| 6194 | {return (*this)(__g, __p_);} | |
| 6195 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 6196 | ||
| 6197 | // property functions | |
| 6198 | _LIBCPP_INLINE_VISIBILITY | |
| 6199 | vector<double> probabilities() const {return __p_.probabilities();} | |
| 6200 | ||
| 6201 | _LIBCPP_INLINE_VISIBILITY | |
| 6202 | param_type param() const {return __p_;} | |
| 6203 | _LIBCPP_INLINE_VISIBILITY | |
| 6204 | void param(const param_type& __p) {__p_ = __p;} | |
| 6205 | ||
| 6206 | _LIBCPP_INLINE_VISIBILITY | |
| 6207 | result_type min() const {return 0;} | |
| 6208 | _LIBCPP_INLINE_VISIBILITY | |
| 6209 | result_type max() const {return __p_.__p_.size();} | |
| 6210 | ||
| 6211 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6212 | bool operator==(const discrete_distribution& __x, | |
| 6213 | const discrete_distribution& __y) | |
| 6214 | {return __x.__p_ == __y.__p_;} | |
| 6215 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6216 | bool operator!=(const discrete_distribution& __x, | |
| 6217 | const discrete_distribution& __y) | |
| 6218 | {return !(__x == __y);} | |
| 6219 | ||
| 6220 | template <class _CharT, class _Traits, class _IT> | |
| 6221 | friend | |
| 6222 | basic_ostream<_CharT, _Traits>& | |
| 6223 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6224 | const discrete_distribution<_IT>& __x); | |
| 6225 | ||
| 6226 | template <class _CharT, class _Traits, class _IT> | |
| 6227 | friend | |
| 6228 | basic_istream<_CharT, _Traits>& | |
| 6229 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6230 | discrete_distribution<_IT>& __x); | |
| 6231 | }; | |
| 6232 | ||
| 6233 | template<class _IntType> | |
| 6234 | template<class _UnaryOperation> | |
| 6235 | discrete_distribution<_IntType>::param_type::param_type(size_t __nw, | |
| 6236 | double __xmin, | |
| 6237 | double __xmax, | |
| 6238 | _UnaryOperation __fw) | |
| 6239 | { | |
| 6240 | if (__nw > 1) | |
| 6241 | { | |
| 6242 | __p_.reserve(__nw - 1); | |
| 6243 | double __d = (__xmax - __xmin) / __nw; | |
| 6244 | double __d2 = __d / 2; | |
| 6245 | for (size_t __k = 0; __k < __nw; ++__k) | |
| 6246 | __p_.push_back(__fw(__xmin + __k * __d + __d2)); | |
| 6247 | __init(); | |
| 6248 | } | |
| 6249 | } | |
| 6250 | ||
| 6251 | template<class _IntType> | |
| 6252 | void | |
| 6253 | discrete_distribution<_IntType>::param_type::__init() | |
| 6254 | { | |
| 6255 | if (!__p_.empty()) | |
| 6256 | { | |
| 6257 | if (__p_.size() > 1) | |
| 6258 | { | |
| 6259 | double __s = _VSTD::accumulate(__p_.begin(), __p_.end(), 0.0); | |
| 6260 | for (vector<double>::iterator __i = __p_.begin(), __e = __p_.end(); __i < __e; ++__i) | |
| 6261 | *__i /= __s; | |
| 6262 | vector<double> __t(__p_.size() - 1); | |
| 6263 | _VSTD::partial_sum(__p_.begin(), __p_.end() - 1, __t.begin()); | |
| 6264 | swap(__p_, __t); | |
| 6265 | } | |
| 6266 | else | |
| 6267 | { | |
| 6268 | __p_.clear(); | |
| 6269 | __p_.shrink_to_fit(); | |
| 6270 | } | |
| 6271 | } | |
| 6272 | } | |
| 6273 | ||
| 6274 | template<class _IntType> | |
| 6275 | vector<double> | |
| 6276 | discrete_distribution<_IntType>::param_type::probabilities() const | |
| 6277 | { | |
| 6278 | size_t __n = __p_.size(); | |
| 6279 | vector<double> __p(__n+1); | |
| 6280 | _VSTD::adjacent_difference(__p_.begin(), __p_.end(), __p.begin()); | |
| 6281 | if (__n > 0) | |
| 6282 | __p[__n] = 1 - __p_[__n-1]; | |
| 6283 | else | |
| 6284 | __p[0] = 1; | |
| 6285 | return __p; | |
| 6286 | } | |
| 6287 | ||
| 6288 | template<class _IntType> | |
| 6289 | template<class _URNG> | |
| 6290 | _IntType | |
| 6291 | discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) | |
| 6292 | { | |
| 6293 | uniform_real_distribution<double> __gen; | |
| 6294 | return static_cast<_IntType>( | |
| 6295 | _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) - | |
| 6296 | __p.__p_.begin()); | |
| 6297 | } | |
| 6298 | ||
| 6299 | template <class _CharT, class _Traits, class _IT> | |
| 6300 | basic_ostream<_CharT, _Traits>& | |
| 6301 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6302 | const discrete_distribution<_IT>& __x) | |
| 6303 | { | |
| 6304 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 6305 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 6306 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 6307 | _OStream::scientific); | |
| 6308 | _CharT __sp = __os.widen(' '); | |
| 6309 | __os.fill(__sp); | |
| 6310 | size_t __n = __x.__p_.__p_.size(); | |
| 6311 | __os << __n; | |
| 6312 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6313 | __os << __sp << __x.__p_.__p_[__i]; | |
| 6314 | return __os; | |
| 6315 | } | |
| 6316 | ||
| 6317 | template <class _CharT, class _Traits, class _IT> | |
| 6318 | basic_istream<_CharT, _Traits>& | |
| 6319 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6320 | discrete_distribution<_IT>& __x) | |
| 6321 | { | |
| 6322 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 6323 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 6324 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 6325 | size_t __n; | |
| 6326 | __is >> __n; | |
| 6327 | vector<double> __p(__n); | |
| 6328 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6329 | __is >> __p[__i]; | |
| 6330 | if (!__is.fail()) | |
| 6331 | swap(__x.__p_.__p_, __p); | |
| 6332 | return __is; | |
| 6333 | } | |
| 6334 | ||
| 6335 | // piecewise_constant_distribution | |
| 6336 | ||
| 6337 | template<class _RealType = double> | |
| 6338 | class _LIBCPP_TEMPLATE_VIS piecewise_constant_distribution | |
| 6339 | { | |
| 6340 | public: | |
| 6341 | // types | |
| 6342 | typedef _RealType result_type; | |
| 6343 | ||
| 6344 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 6345 | { | |
| 6346 | vector<result_type> __b_; | |
| 6347 | vector<result_type> __densities_; | |
| 6348 | vector<result_type> __areas_; | |
| 6349 | public: | |
| 6350 | typedef piecewise_constant_distribution distribution_type; | |
| 6351 | ||
| 6352 | param_type(); | |
| 6353 | template<class _InputIteratorB, class _InputIteratorW> | |
| 6354 | param_type(_InputIteratorB __fB, _InputIteratorB __lB, | |
| 6355 | _InputIteratorW __fW); | |
| 6356 | #ifndef _LIBCPP_CXX03_LANG | |
| 6357 | template<class _UnaryOperation> | |
| 6358 | param_type(initializer_list<result_type> __bl, _UnaryOperation __fw); | |
| 6359 | #endif // _LIBCPP_CXX03_LANG | |
| 6360 | template<class _UnaryOperation> | |
| 6361 | param_type(size_t __nw, result_type __xmin, result_type __xmax, | |
| 6362 | _UnaryOperation __fw); | |
| 6363 | param_type(param_type const&) = default; | |
| 6364 | param_type & operator=(const param_type& __rhs); | |
| 6365 | ||
| 6366 | _LIBCPP_INLINE_VISIBILITY | |
| 6367 | vector<result_type> intervals() const {return __b_;} | |
| 6368 | _LIBCPP_INLINE_VISIBILITY | |
| 6369 | vector<result_type> densities() const {return __densities_;} | |
| 6370 | ||
| 6371 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6372 | bool operator==(const param_type& __x, const param_type& __y) | |
| 6373 | {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;} | |
| 6374 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6375 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 6376 | {return !(__x == __y);} | |
| 6377 | ||
| 6378 | private: | |
| 6379 | void __init(); | |
| 6380 | ||
| 6381 | friend class piecewise_constant_distribution; | |
| 6382 | ||
| 6383 | template <class _CharT, class _Traits, class _RT> | |
| 6384 | friend | |
| 6385 | basic_ostream<_CharT, _Traits>& | |
| 6386 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6387 | const piecewise_constant_distribution<_RT>& __x); | |
| 6388 | ||
| 6389 | template <class _CharT, class _Traits, class _RT> | |
| 6390 | friend | |
| 6391 | basic_istream<_CharT, _Traits>& | |
| 6392 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6393 | piecewise_constant_distribution<_RT>& __x); | |
| 6394 | }; | |
| 6395 | ||
| 6396 | private: | |
| 6397 | param_type __p_; | |
| 6398 | ||
| 6399 | public: | |
| 6400 | // constructor and reset functions | |
| 6401 | _LIBCPP_INLINE_VISIBILITY | |
| 6402 | piecewise_constant_distribution() {} | |
| 6403 | template<class _InputIteratorB, class _InputIteratorW> | |
| 6404 | _LIBCPP_INLINE_VISIBILITY | |
| 6405 | piecewise_constant_distribution(_InputIteratorB __fB, | |
| 6406 | _InputIteratorB __lB, | |
| 6407 | _InputIteratorW __fW) | |
| 6408 | : __p_(__fB, __lB, __fW) {} | |
| 6409 | ||
| 6410 | #ifndef _LIBCPP_CXX03_LANG | |
| 6411 | template<class _UnaryOperation> | |
| 6412 | _LIBCPP_INLINE_VISIBILITY | |
| 6413 | piecewise_constant_distribution(initializer_list<result_type> __bl, | |
| 6414 | _UnaryOperation __fw) | |
| 6415 | : __p_(__bl, __fw) {} | |
| 6416 | #endif // _LIBCPP_CXX03_LANG | |
| 6417 | ||
| 6418 | template<class _UnaryOperation> | |
| 6419 | _LIBCPP_INLINE_VISIBILITY | |
| 6420 | piecewise_constant_distribution(size_t __nw, result_type __xmin, | |
| 6421 | result_type __xmax, _UnaryOperation __fw) | |
| 6422 | : __p_(__nw, __xmin, __xmax, __fw) {} | |
| 6423 | ||
| 6424 | _LIBCPP_INLINE_VISIBILITY | |
| 6425 | explicit piecewise_constant_distribution(const param_type& __p) | |
| 6426 | : __p_(__p) {} | |
| 6427 | ||
| 6428 | _LIBCPP_INLINE_VISIBILITY | |
| 6429 | void reset() {} | |
| 6430 | ||
| 6431 | // generating functions | |
| 6432 | template<class _URNG> | |
| 6433 | _LIBCPP_INLINE_VISIBILITY | |
| 6434 | result_type operator()(_URNG& __g) | |
| 6435 | {return (*this)(__g, __p_);} | |
| 6436 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 6437 | ||
| 6438 | // property functions | |
| 6439 | _LIBCPP_INLINE_VISIBILITY | |
| 6440 | vector<result_type> intervals() const {return __p_.intervals();} | |
| 6441 | _LIBCPP_INLINE_VISIBILITY | |
| 6442 | vector<result_type> densities() const {return __p_.densities();} | |
| 6443 | ||
| 6444 | _LIBCPP_INLINE_VISIBILITY | |
| 6445 | param_type param() const {return __p_;} | |
| 6446 | _LIBCPP_INLINE_VISIBILITY | |
| 6447 | void param(const param_type& __p) {__p_ = __p;} | |
| 6448 | ||
| 6449 | _LIBCPP_INLINE_VISIBILITY | |
| 6450 | result_type min() const {return __p_.__b_.front();} | |
| 6451 | _LIBCPP_INLINE_VISIBILITY | |
| 6452 | result_type max() const {return __p_.__b_.back();} | |
| 6453 | ||
| 6454 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6455 | bool operator==(const piecewise_constant_distribution& __x, | |
| 6456 | const piecewise_constant_distribution& __y) | |
| 6457 | {return __x.__p_ == __y.__p_;} | |
| 6458 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6459 | bool operator!=(const piecewise_constant_distribution& __x, | |
| 6460 | const piecewise_constant_distribution& __y) | |
| 6461 | {return !(__x == __y);} | |
| 6462 | ||
| 6463 | template <class _CharT, class _Traits, class _RT> | |
| 6464 | friend | |
| 6465 | basic_ostream<_CharT, _Traits>& | |
| 6466 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6467 | const piecewise_constant_distribution<_RT>& __x); | |
| 6468 | ||
| 6469 | template <class _CharT, class _Traits, class _RT> | |
| 6470 | friend | |
| 6471 | basic_istream<_CharT, _Traits>& | |
| 6472 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6473 | piecewise_constant_distribution<_RT>& __x); | |
| 6474 | }; | |
| 6475 | ||
| 6476 | template<class _RealType> | |
| 6477 | typename piecewise_constant_distribution<_RealType>::param_type & | |
| 6478 | piecewise_constant_distribution<_RealType>::param_type::operator= | |
| 6479 | (const param_type& __rhs) | |
| 6480 | { | |
| 6481 | // These can throw | |
| 6482 | __b_.reserve (__rhs.__b_.size ()); | |
| 6483 | __densities_.reserve(__rhs.__densities_.size()); | |
| 6484 | __areas_.reserve (__rhs.__areas_.size()); | |
| 6485 | ||
| 6486 | // These can not throw | |
| 6487 | __b_ = __rhs.__b_; | |
| 6488 | __densities_ = __rhs.__densities_; | |
| 6489 | __areas_ = __rhs.__areas_; | |
| 6490 | return *this; | |
| 6491 | } | |
| 6492 | ||
| 6493 | template<class _RealType> | |
| 6494 | void | |
| 6495 | piecewise_constant_distribution<_RealType>::param_type::__init() | |
| 6496 | { | |
| 6497 | // __densities_ contains non-normalized areas | |
| 6498 | result_type __total_area = _VSTD::accumulate(__densities_.begin(), | |
| 6499 | __densities_.end(), | |
| 6500 | result_type()); | |
| 6501 | for (size_t __i = 0; __i < __densities_.size(); ++__i) | |
| 6502 | __densities_[__i] /= __total_area; | |
| 6503 | // __densities_ contains normalized areas | |
| 6504 | __areas_.assign(__densities_.size(), result_type()); | |
| 6505 | _VSTD::partial_sum(__densities_.begin(), __densities_.end() - 1, | |
| 6506 | __areas_.begin() + 1); | |
| 6507 | // __areas_ contains partial sums of normalized areas: [0, __densities_ - 1] | |
| 6508 | __densities_.back() = 1 - __areas_.back(); // correct round off error | |
| 6509 | for (size_t __i = 0; __i < __densities_.size(); ++__i) | |
| 6510 | __densities_[__i] /= (__b_[__i+1] - __b_[__i]); | |
| 6511 | // __densities_ now contains __densities_ | |
| 6512 | } | |
| 6513 | ||
| 6514 | template<class _RealType> | |
| 6515 | piecewise_constant_distribution<_RealType>::param_type::param_type() | |
| 6516 | : __b_(2), | |
| 6517 | __densities_(1, 1.0), | |
| 6518 | __areas_(1, 0.0) | |
| 6519 | { | |
| 6520 | __b_[1] = 1; | |
| 6521 | } | |
| 6522 | ||
| 6523 | template<class _RealType> | |
| 6524 | template<class _InputIteratorB, class _InputIteratorW> | |
| 6525 | piecewise_constant_distribution<_RealType>::param_type::param_type( | |
| 6526 | _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) | |
| 6527 | : __b_(__fB, __lB) | |
| 6528 | { | |
| 6529 | if (__b_.size() < 2) | |
| 6530 | { | |
| 6531 | __b_.resize(2); | |
| 6532 | __b_[0] = 0; | |
| 6533 | __b_[1] = 1; | |
| 6534 | __densities_.assign(1, 1.0); | |
| 6535 | __areas_.assign(1, 0.0); | |
| 6536 | } | |
| 6537 | else | |
| 6538 | { | |
| 6539 | __densities_.reserve(__b_.size() - 1); | |
| 6540 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW) | |
| 6541 | __densities_.push_back(*__fW); | |
| 6542 | __init(); | |
| 6543 | } | |
| 6544 | } | |
| 6545 | ||
| 6546 | #ifndef _LIBCPP_CXX03_LANG | |
| 6547 | ||
| 6548 | template<class _RealType> | |
| 6549 | template<class _UnaryOperation> | |
| 6550 | piecewise_constant_distribution<_RealType>::param_type::param_type( | |
| 6551 | initializer_list<result_type> __bl, _UnaryOperation __fw) | |
| 6552 | : __b_(__bl.begin(), __bl.end()) | |
| 6553 | { | |
| 6554 | if (__b_.size() < 2) | |
| 6555 | { | |
| 6556 | __b_.resize(2); | |
| 6557 | __b_[0] = 0; | |
| 6558 | __b_[1] = 1; | |
| 6559 | __densities_.assign(1, 1.0); | |
| 6560 | __areas_.assign(1, 0.0); | |
| 6561 | } | |
| 6562 | else | |
| 6563 | { | |
| 6564 | __densities_.reserve(__b_.size() - 1); | |
| 6565 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i) | |
| 6566 | __densities_.push_back(__fw((__b_[__i+1] + __b_[__i])*.5)); | |
| 6567 | __init(); | |
| 6568 | } | |
| 6569 | } | |
| 6570 | ||
| 6571 | #endif // _LIBCPP_CXX03_LANG | |
| 6572 | ||
| 6573 | template<class _RealType> | |
| 6574 | template<class _UnaryOperation> | |
| 6575 | piecewise_constant_distribution<_RealType>::param_type::param_type( | |
| 6576 | size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) | |
| 6577 | : __b_(__nw == 0 ? 2 : __nw + 1) | |
| 6578 | { | |
| 6579 | size_t __n = __b_.size() - 1; | |
| 6580 | result_type __d = (__xmax - __xmin) / __n; | |
| 6581 | __densities_.reserve(__n); | |
| 6582 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6583 | { | |
| 6584 | __b_[__i] = __xmin + __i * __d; | |
| 6585 | __densities_.push_back(__fw(__b_[__i] + __d*.5)); | |
| 6586 | } | |
| 6587 | __b_[__n] = __xmax; | |
| 6588 | __init(); | |
| 6589 | } | |
| 6590 | ||
| 6591 | template<class _RealType> | |
| 6592 | template<class _URNG> | |
| 6593 | _RealType | |
| 6594 | piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 6595 | { | |
| 6596 | typedef uniform_real_distribution<result_type> _Gen; | |
| 6597 | result_type __u = _Gen()(__g); | |
| 6598 | ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), | |
| 6599 | __u) - __p.__areas_.begin() - 1; | |
| 6600 | return (__u - __p.__areas_[__k]) / __p.__densities_[__k] + __p.__b_[__k]; | |
| 6601 | } | |
| 6602 | ||
| 6603 | template <class _CharT, class _Traits, class _RT> | |
| 6604 | basic_ostream<_CharT, _Traits>& | |
| 6605 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6606 | const piecewise_constant_distribution<_RT>& __x) | |
| 6607 | { | |
| 6608 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 6609 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 6610 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 6611 | _OStream::scientific); | |
| 6612 | _CharT __sp = __os.widen(' '); | |
| 6613 | __os.fill(__sp); | |
| 6614 | size_t __n = __x.__p_.__b_.size(); | |
| 6615 | __os << __n; | |
| 6616 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6617 | __os << __sp << __x.__p_.__b_[__i]; | |
| 6618 | __n = __x.__p_.__densities_.size(); | |
| 6619 | __os << __sp << __n; | |
| 6620 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6621 | __os << __sp << __x.__p_.__densities_[__i]; | |
| 6622 | __n = __x.__p_.__areas_.size(); | |
| 6623 | __os << __sp << __n; | |
| 6624 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6625 | __os << __sp << __x.__p_.__areas_[__i]; | |
| 6626 | return __os; | |
| 6627 | } | |
| 6628 | ||
| 6629 | template <class _CharT, class _Traits, class _RT> | |
| 6630 | basic_istream<_CharT, _Traits>& | |
| 6631 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6632 | piecewise_constant_distribution<_RT>& __x) | |
| 6633 | { | |
| 6634 | typedef piecewise_constant_distribution<_RT> _Eng; | |
| 6635 | typedef typename _Eng::result_type result_type; | |
| 6636 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 6637 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 6638 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 6639 | size_t __n; | |
| 6640 | __is >> __n; | |
| 6641 | vector<result_type> __b(__n); | |
| 6642 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6643 | __is >> __b[__i]; | |
| 6644 | __is >> __n; | |
| 6645 | vector<result_type> __densities(__n); | |
| 6646 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6647 | __is >> __densities[__i]; | |
| 6648 | __is >> __n; | |
| 6649 | vector<result_type> __areas(__n); | |
| 6650 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6651 | __is >> __areas[__i]; | |
| 6652 | if (!__is.fail()) | |
| 6653 | { | |
| 6654 | swap(__x.__p_.__b_, __b); | |
| 6655 | swap(__x.__p_.__densities_, __densities); | |
| 6656 | swap(__x.__p_.__areas_, __areas); | |
| 6657 | } | |
| 6658 | return __is; | |
| 6659 | } | |
| 6660 | ||
| 6661 | // piecewise_linear_distribution | |
| 6662 | ||
| 6663 | template<class _RealType = double> | |
| 6664 | class _LIBCPP_TEMPLATE_VIS piecewise_linear_distribution | |
| 6665 | { | |
| 6666 | public: | |
| 6667 | // types | |
| 6668 | typedef _RealType result_type; | |
| 6669 | ||
| 6670 | class _LIBCPP_TEMPLATE_VIS param_type | |
| 6671 | { | |
| 6672 | vector<result_type> __b_; | |
| 6673 | vector<result_type> __densities_; | |
| 6674 | vector<result_type> __areas_; | |
| 6675 | public: | |
| 6676 | typedef piecewise_linear_distribution distribution_type; | |
| 6677 | ||
| 6678 | param_type(); | |
| 6679 | template<class _InputIteratorB, class _InputIteratorW> | |
| 6680 | param_type(_InputIteratorB __fB, _InputIteratorB __lB, | |
| 6681 | _InputIteratorW __fW); | |
| 6682 | #ifndef _LIBCPP_CXX03_LANG | |
| 6683 | template<class _UnaryOperation> | |
| 6684 | param_type(initializer_list<result_type> __bl, _UnaryOperation __fw); | |
| 6685 | #endif // _LIBCPP_CXX03_LANG | |
| 6686 | template<class _UnaryOperation> | |
| 6687 | param_type(size_t __nw, result_type __xmin, result_type __xmax, | |
| 6688 | _UnaryOperation __fw); | |
| 6689 | param_type(param_type const&) = default; | |
| 6690 | param_type & operator=(const param_type& __rhs); | |
| 6691 | ||
| 6692 | _LIBCPP_INLINE_VISIBILITY | |
| 6693 | vector<result_type> intervals() const {return __b_;} | |
| 6694 | _LIBCPP_INLINE_VISIBILITY | |
| 6695 | vector<result_type> densities() const {return __densities_;} | |
| 6696 | ||
| 6697 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6698 | bool operator==(const param_type& __x, const param_type& __y) | |
| 6699 | {return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;} | |
| 6700 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6701 | bool operator!=(const param_type& __x, const param_type& __y) | |
| 6702 | {return !(__x == __y);} | |
| 6703 | ||
| 6704 | private: | |
| 6705 | void __init(); | |
| 6706 | ||
| 6707 | friend class piecewise_linear_distribution; | |
| 6708 | ||
| 6709 | template <class _CharT, class _Traits, class _RT> | |
| 6710 | friend | |
| 6711 | basic_ostream<_CharT, _Traits>& | |
| 6712 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6713 | const piecewise_linear_distribution<_RT>& __x); | |
| 6714 | ||
| 6715 | template <class _CharT, class _Traits, class _RT> | |
| 6716 | friend | |
| 6717 | basic_istream<_CharT, _Traits>& | |
| 6718 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6719 | piecewise_linear_distribution<_RT>& __x); | |
| 6720 | }; | |
| 6721 | ||
| 6722 | private: | |
| 6723 | param_type __p_; | |
| 6724 | ||
| 6725 | public: | |
| 6726 | // constructor and reset functions | |
| 6727 | _LIBCPP_INLINE_VISIBILITY | |
| 6728 | piecewise_linear_distribution() {} | |
| 6729 | template<class _InputIteratorB, class _InputIteratorW> | |
| 6730 | _LIBCPP_INLINE_VISIBILITY | |
| 6731 | piecewise_linear_distribution(_InputIteratorB __fB, | |
| 6732 | _InputIteratorB __lB, | |
| 6733 | _InputIteratorW __fW) | |
| 6734 | : __p_(__fB, __lB, __fW) {} | |
| 6735 | ||
| 6736 | #ifndef _LIBCPP_CXX03_LANG | |
| 6737 | template<class _UnaryOperation> | |
| 6738 | _LIBCPP_INLINE_VISIBILITY | |
| 6739 | piecewise_linear_distribution(initializer_list<result_type> __bl, | |
| 6740 | _UnaryOperation __fw) | |
| 6741 | : __p_(__bl, __fw) {} | |
| 6742 | #endif // _LIBCPP_CXX03_LANG | |
| 6743 | ||
| 6744 | template<class _UnaryOperation> | |
| 6745 | _LIBCPP_INLINE_VISIBILITY | |
| 6746 | piecewise_linear_distribution(size_t __nw, result_type __xmin, | |
| 6747 | result_type __xmax, _UnaryOperation __fw) | |
| 6748 | : __p_(__nw, __xmin, __xmax, __fw) {} | |
| 6749 | ||
| 6750 | _LIBCPP_INLINE_VISIBILITY | |
| 6751 | explicit piecewise_linear_distribution(const param_type& __p) | |
| 6752 | : __p_(__p) {} | |
| 6753 | ||
| 6754 | _LIBCPP_INLINE_VISIBILITY | |
| 6755 | void reset() {} | |
| 6756 | ||
| 6757 | // generating functions | |
| 6758 | template<class _URNG> | |
| 6759 | _LIBCPP_INLINE_VISIBILITY | |
| 6760 | result_type operator()(_URNG& __g) | |
| 6761 | {return (*this)(__g, __p_);} | |
| 6762 | template<class _URNG> result_type operator()(_URNG& __g, const param_type& __p); | |
| 6763 | ||
| 6764 | // property functions | |
| 6765 | _LIBCPP_INLINE_VISIBILITY | |
| 6766 | vector<result_type> intervals() const {return __p_.intervals();} | |
| 6767 | _LIBCPP_INLINE_VISIBILITY | |
| 6768 | vector<result_type> densities() const {return __p_.densities();} | |
| 6769 | ||
| 6770 | _LIBCPP_INLINE_VISIBILITY | |
| 6771 | param_type param() const {return __p_;} | |
| 6772 | _LIBCPP_INLINE_VISIBILITY | |
| 6773 | void param(const param_type& __p) {__p_ = __p;} | |
| 6774 | ||
| 6775 | _LIBCPP_INLINE_VISIBILITY | |
| 6776 | result_type min() const {return __p_.__b_.front();} | |
| 6777 | _LIBCPP_INLINE_VISIBILITY | |
| 6778 | result_type max() const {return __p_.__b_.back();} | |
| 6779 | ||
| 6780 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6781 | bool operator==(const piecewise_linear_distribution& __x, | |
| 6782 | const piecewise_linear_distribution& __y) | |
| 6783 | {return __x.__p_ == __y.__p_;} | |
| 6784 | friend _LIBCPP_INLINE_VISIBILITY | |
| 6785 | bool operator!=(const piecewise_linear_distribution& __x, | |
| 6786 | const piecewise_linear_distribution& __y) | |
| 6787 | {return !(__x == __y);} | |
| 6788 | ||
| 6789 | template <class _CharT, class _Traits, class _RT> | |
| 6790 | friend | |
| 6791 | basic_ostream<_CharT, _Traits>& | |
| 6792 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6793 | const piecewise_linear_distribution<_RT>& __x); | |
| 6794 | ||
| 6795 | template <class _CharT, class _Traits, class _RT> | |
| 6796 | friend | |
| 6797 | basic_istream<_CharT, _Traits>& | |
| 6798 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6799 | piecewise_linear_distribution<_RT>& __x); | |
| 6800 | }; | |
| 6801 | ||
| 6802 | template<class _RealType> | |
| 6803 | typename piecewise_linear_distribution<_RealType>::param_type & | |
| 6804 | piecewise_linear_distribution<_RealType>::param_type::operator= | |
| 6805 | (const param_type& __rhs) | |
| 6806 | { | |
| 6807 | // These can throw | |
| 6808 | __b_.reserve (__rhs.__b_.size ()); | |
| 6809 | __densities_.reserve(__rhs.__densities_.size()); | |
| 6810 | __areas_.reserve (__rhs.__areas_.size()); | |
| 6811 | ||
| 6812 | // These can not throw | |
| 6813 | __b_ = __rhs.__b_; | |
| 6814 | __densities_ = __rhs.__densities_; | |
| 6815 | __areas_ = __rhs.__areas_; | |
| 6816 | return *this; | |
| 6817 | } | |
| 6818 | ||
| 6819 | ||
| 6820 | template<class _RealType> | |
| 6821 | void | |
| 6822 | piecewise_linear_distribution<_RealType>::param_type::__init() | |
| 6823 | { | |
| 6824 | __areas_.assign(__densities_.size() - 1, result_type()); | |
| 6825 | result_type _Sp = 0; | |
| 6826 | for (size_t __i = 0; __i < __areas_.size(); ++__i) | |
| 6827 | { | |
| 6828 | __areas_[__i] = (__densities_[__i+1] + __densities_[__i]) * | |
| 6829 | (__b_[__i+1] - __b_[__i]) * .5; | |
| 6830 | _Sp += __areas_[__i]; | |
| 6831 | } | |
| 6832 | for (size_t __i = __areas_.size(); __i > 1;) | |
| 6833 | { | |
| 6834 | --__i; | |
| 6835 | __areas_[__i] = __areas_[__i-1] / _Sp; | |
| 6836 | } | |
| 6837 | __areas_[0] = 0; | |
| 6838 | for (size_t __i = 1; __i < __areas_.size(); ++__i) | |
| 6839 | __areas_[__i] += __areas_[__i-1]; | |
| 6840 | for (size_t __i = 0; __i < __densities_.size(); ++__i) | |
| 6841 | __densities_[__i] /= _Sp; | |
| 6842 | } | |
| 6843 | ||
| 6844 | template<class _RealType> | |
| 6845 | piecewise_linear_distribution<_RealType>::param_type::param_type() | |
| 6846 | : __b_(2), | |
| 6847 | __densities_(2, 1.0), | |
| 6848 | __areas_(1, 0.0) | |
| 6849 | { | |
| 6850 | __b_[1] = 1; | |
| 6851 | } | |
| 6852 | ||
| 6853 | template<class _RealType> | |
| 6854 | template<class _InputIteratorB, class _InputIteratorW> | |
| 6855 | piecewise_linear_distribution<_RealType>::param_type::param_type( | |
| 6856 | _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) | |
| 6857 | : __b_(__fB, __lB) | |
| 6858 | { | |
| 6859 | if (__b_.size() < 2) | |
| 6860 | { | |
| 6861 | __b_.resize(2); | |
| 6862 | __b_[0] = 0; | |
| 6863 | __b_[1] = 1; | |
| 6864 | __densities_.assign(2, 1.0); | |
| 6865 | __areas_.assign(1, 0.0); | |
| 6866 | } | |
| 6867 | else | |
| 6868 | { | |
| 6869 | __densities_.reserve(__b_.size()); | |
| 6870 | for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW) | |
| 6871 | __densities_.push_back(*__fW); | |
| 6872 | __init(); | |
| 6873 | } | |
| 6874 | } | |
| 6875 | ||
| 6876 | #ifndef _LIBCPP_CXX03_LANG | |
| 6877 | ||
| 6878 | template<class _RealType> | |
| 6879 | template<class _UnaryOperation> | |
| 6880 | piecewise_linear_distribution<_RealType>::param_type::param_type( | |
| 6881 | initializer_list<result_type> __bl, _UnaryOperation __fw) | |
| 6882 | : __b_(__bl.begin(), __bl.end()) | |
| 6883 | { | |
| 6884 | if (__b_.size() < 2) | |
| 6885 | { | |
| 6886 | __b_.resize(2); | |
| 6887 | __b_[0] = 0; | |
| 6888 | __b_[1] = 1; | |
| 6889 | __densities_.assign(2, 1.0); | |
| 6890 | __areas_.assign(1, 0.0); | |
| 6891 | } | |
| 6892 | else | |
| 6893 | { | |
| 6894 | __densities_.reserve(__b_.size()); | |
| 6895 | for (size_t __i = 0; __i < __b_.size(); ++__i) | |
| 6896 | __densities_.push_back(__fw(__b_[__i])); | |
| 6897 | __init(); | |
| 6898 | } | |
| 6899 | } | |
| 6900 | ||
| 6901 | #endif // _LIBCPP_CXX03_LANG | |
| 6902 | ||
| 6903 | template<class _RealType> | |
| 6904 | template<class _UnaryOperation> | |
| 6905 | piecewise_linear_distribution<_RealType>::param_type::param_type( | |
| 6906 | size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw) | |
| 6907 | : __b_(__nw == 0 ? 2 : __nw + 1) | |
| 6908 | { | |
| 6909 | size_t __n = __b_.size() - 1; | |
| 6910 | result_type __d = (__xmax - __xmin) / __n; | |
| 6911 | __densities_.reserve(__b_.size()); | |
| 6912 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6913 | { | |
| 6914 | __b_[__i] = __xmin + __i * __d; | |
| 6915 | __densities_.push_back(__fw(__b_[__i])); | |
| 6916 | } | |
| 6917 | __b_[__n] = __xmax; | |
| 6918 | __densities_.push_back(__fw(__b_[__n])); | |
| 6919 | __init(); | |
| 6920 | } | |
| 6921 | ||
| 6922 | template<class _RealType> | |
| 6923 | template<class _URNG> | |
| 6924 | _RealType | |
| 6925 | piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) | |
| 6926 | { | |
| 6927 | typedef uniform_real_distribution<result_type> _Gen; | |
| 6928 | result_type __u = _Gen()(__g); | |
| 6929 | ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), | |
| 6930 | __u) - __p.__areas_.begin() - 1; | |
| 6931 | __u -= __p.__areas_[__k]; | |
| 6932 | const result_type __dk = __p.__densities_[__k]; | |
| 6933 | const result_type __dk1 = __p.__densities_[__k+1]; | |
| 6934 | const result_type __deltad = __dk1 - __dk; | |
| 6935 | const result_type __bk = __p.__b_[__k]; | |
| 6936 | if (__deltad == 0) | |
| 6937 | return __u / __dk + __bk; | |
| 6938 | const result_type __bk1 = __p.__b_[__k+1]; | |
| 6939 | const result_type __deltab = __bk1 - __bk; | |
| 6940 | return (__bk * __dk1 - __bk1 * __dk + | |
| 6941 | _VSTD::sqrt(__deltab * (__deltab * __dk * __dk + 2 * __deltad * __u))) / | |
| 6942 | __deltad; | |
| 6943 | } | |
| 6944 | ||
| 6945 | template <class _CharT, class _Traits, class _RT> | |
| 6946 | basic_ostream<_CharT, _Traits>& | |
| 6947 | operator<<(basic_ostream<_CharT, _Traits>& __os, | |
| 6948 | const piecewise_linear_distribution<_RT>& __x) | |
| 6949 | { | |
| 6950 | __save_flags<_CharT, _Traits> __lx(__os); | |
| 6951 | typedef basic_ostream<_CharT, _Traits> _OStream; | |
| 6952 | __os.flags(_OStream::dec | _OStream::left | _OStream::fixed | | |
| 6953 | _OStream::scientific); | |
| 6954 | _CharT __sp = __os.widen(' '); | |
| 6955 | __os.fill(__sp); | |
| 6956 | size_t __n = __x.__p_.__b_.size(); | |
| 6957 | __os << __n; | |
| 6958 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6959 | __os << __sp << __x.__p_.__b_[__i]; | |
| 6960 | __n = __x.__p_.__densities_.size(); | |
| 6961 | __os << __sp << __n; | |
| 6962 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6963 | __os << __sp << __x.__p_.__densities_[__i]; | |
| 6964 | __n = __x.__p_.__areas_.size(); | |
| 6965 | __os << __sp << __n; | |
| 6966 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6967 | __os << __sp << __x.__p_.__areas_[__i]; | |
| 6968 | return __os; | |
| 6969 | } | |
| 6970 | ||
| 6971 | template <class _CharT, class _Traits, class _RT> | |
| 6972 | basic_istream<_CharT, _Traits>& | |
| 6973 | operator>>(basic_istream<_CharT, _Traits>& __is, | |
| 6974 | piecewise_linear_distribution<_RT>& __x) | |
| 6975 | { | |
| 6976 | typedef piecewise_linear_distribution<_RT> _Eng; | |
| 6977 | typedef typename _Eng::result_type result_type; | |
| 6978 | __save_flags<_CharT, _Traits> __lx(__is); | |
| 6979 | typedef basic_istream<_CharT, _Traits> _Istream; | |
| 6980 | __is.flags(_Istream::dec | _Istream::skipws); | |
| 6981 | size_t __n; | |
| 6982 | __is >> __n; | |
| 6983 | vector<result_type> __b(__n); | |
| 6984 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6985 | __is >> __b[__i]; | |
| 6986 | __is >> __n; | |
| 6987 | vector<result_type> __densities(__n); | |
| 6988 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6989 | __is >> __densities[__i]; | |
| 6990 | __is >> __n; | |
| 6991 | vector<result_type> __areas(__n); | |
| 6992 | for (size_t __i = 0; __i < __n; ++__i) | |
| 6993 | __is >> __areas[__i]; | |
| 6994 | if (!__is.fail()) | |
| 6995 | { | |
| 6996 | swap(__x.__p_.__b_, __b); | |
| 6997 | swap(__x.__p_.__densities_, __densities); | |
| 6998 | swap(__x.__p_.__areas_, __areas); | |
| 6999 | } | |
| 7000 | return __is; | |
| 7001 | } | |
| 7002 | ||
| 7003 | _LIBCPP_END_NAMESPACE_STD | |
| 7004 | ||
| 7005 | _LIBCPP_POP_MACROS | |
| 7006 | ||
| 7007 | 1735 | #endif // _LIBCPP_RANDOM |
lib/libcxx/include/ranges+50-22| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- ranges -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -36,7 +36,7 @@ namespace std::ranges { |
| 36 | 36 | inline constexpr bool enable_borrowed_range = false; |
| 37 | 37 | |
| 38 | 38 | template<class T> |
| 39 | using iterator_t = decltype(ranges::begin(declval<R&>())); | |
| 39 | using iterator_t = decltype(ranges::begin(declval<T&>())); | |
| 40 | 40 | template<range R> |
| 41 | 41 | using sentinel_t = decltype(ranges::end(declval<R&>())); |
| 42 | 42 | template<range R> |
| ... | ... | @@ -135,6 +135,13 @@ namespace std::ranges { |
| 135 | 135 | template<class T> |
| 136 | 136 | inline constexpr bool enable_borrowed_range<ref_view<T>> = true; |
| 137 | 137 | |
| 138 | template<range R> | |
| 139 | requires see below | |
| 140 | class owning_view; | |
| 141 | ||
| 142 | template<class T> | |
| 143 | inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>; | |
| 144 | ||
| 138 | 145 | // [range.drop], drop view |
| 139 | 146 | template<view V> |
| 140 | 147 | class drop_view; |
| ... | ... | @@ -149,27 +156,56 @@ namespace std::ranges { |
| 149 | 156 | can-reference<invoke_result_t<F&, range_reference_t<V>>> |
| 150 | 157 | class transform_view; |
| 151 | 158 | |
| 159 | // [range.counted], counted view | |
| 160 | namespace views { inline constexpr unspecified counted = unspecified; } | |
| 161 | ||
| 152 | 162 | // [range.common], common view |
| 153 | 163 | template<view V> |
| 154 | 164 | requires (!common_range<V> && copyable<iterator_t<V>>) |
| 155 | 165 | class common_view; |
| 156 | 166 | |
| 167 | // [range.reverse], reverse view | |
| 168 | template<view V> | |
| 169 | requires bidirectional_range<V> | |
| 170 | class reverse_view; | |
| 171 | ||
| 172 | template<class T> | |
| 173 | inline constexpr bool enable_borrowed_range<reverse_view<T>> = enable_borrowed_range<T>; | |
| 174 | ||
| 157 | 175 | template<class T> |
| 158 | 176 | inline constexpr bool enable_borrowed_range<common_view<T>> = enable_borrowed_range<T>; |
| 177 | ||
| 178 | // [range.take], take view | |
| 179 | template<view> class take_view; | |
| 180 | ||
| 181 | template<class T> | |
| 182 | inline constexpr bool enable_borrowed_range<take_view<T>> = enable_borrowed_range<T>; | |
| 183 | ||
| 184 | template<copy_constructible T> | |
| 185 | requires is_object_v<T> | |
| 186 | class single_view; | |
| 187 | ||
| 188 | template<weakly_incrementable W, semiregular Bound = unreachable_sentinel_t> | |
| 189 | requires weakly-equality-comparable-with<W, Bound> && copyable<W> | |
| 190 | class iota_view; | |
| 191 | ||
| 192 | template<class W, class Bound> | |
| 193 | inline constexpr bool enable_borrowed_range<iota_view<W, Bound>> = true; | |
| 194 | ||
| 195 | // [range.join], join view | |
| 196 | template<input_range V> | |
| 197 | requires view<V> && input_range<range_reference_t<V>> | |
| 198 | class join_view; | |
| 159 | 199 | } |
| 160 | 200 | |
| 161 | 201 | */ |
| 162 | 202 | |
| 163 | // Make sure all feature tests macros are always available. | |
| 164 | #include <version> | |
| 165 | // Only enable the contents of the header when libc++ was build with LIBCXX_ENABLE_INCOMPLETE_FEATURES enabled | |
| 166 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 167 | ||
| 168 | 203 | #include <__config> |
| 169 | 204 | #include <__ranges/access.h> |
| 170 | 205 | #include <__ranges/all.h> |
| 171 | 206 | #include <__ranges/common_view.h> |
| 172 | 207 | #include <__ranges/concepts.h> |
| 208 | #include <__ranges/counted.h> | |
| 173 | 209 | #include <__ranges/dangling.h> |
| 174 | 210 | #include <__ranges/data.h> |
| 175 | 211 | #include <__ranges/drop_view.h> |
| ... | ... | @@ -177,33 +213,25 @@ namespace std::ranges { |
| 177 | 213 | #include <__ranges/empty_view.h> |
| 178 | 214 | #include <__ranges/enable_borrowed_range.h> |
| 179 | 215 | #include <__ranges/enable_view.h> |
| 216 | #include <__ranges/iota_view.h> | |
| 217 | #include <__ranges/join_view.h> | |
| 180 | 218 | #include <__ranges/ref_view.h> |
| 219 | #include <__ranges/reverse_view.h> | |
| 220 | #include <__ranges/single_view.h> | |
| 181 | 221 | #include <__ranges/size.h> |
| 182 | 222 | #include <__ranges/subrange.h> |
| 223 | #include <__ranges/take_view.h> | |
| 183 | 224 | #include <__ranges/transform_view.h> |
| 184 | 225 | #include <__ranges/view_interface.h> |
| 226 | #include <__ranges/views.h> | |
| 185 | 227 | #include <compare> // Required by the standard. |
| 186 | 228 | #include <initializer_list> // Required by the standard. |
| 187 | 229 | #include <iterator> // Required by the standard. |
| 188 | 230 | #include <type_traits> |
| 231 | #include <version> | |
| 189 | 232 | |
| 190 | 233 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 191 | 234 | #pragma GCC system_header |
| 192 | 235 | #endif |
| 193 | 236 | |
| 194 | _LIBCPP_PUSH_MACROS | |
| 195 | #include <__undef_macros> | |
| 196 | ||
| 197 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 198 | ||
| 199 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 200 | ||
| 201 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 202 | ||
| 203 | _LIBCPP_END_NAMESPACE_STD | |
| 204 | ||
| 205 | _LIBCPP_POP_MACROS | |
| 206 | ||
| 207 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 208 | ||
| 209 | 237 | #endif // _LIBCPP_RANGES |
lib/libcxx/include/ratio+9-14| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- ratio -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -81,6 +81,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported |
| 81 | 81 | #include <climits> |
| 82 | 82 | #include <cstdint> |
| 83 | 83 | #include <type_traits> |
| 84 | #include <version> | |
| 84 | 85 | |
| 85 | 86 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 86 | 87 | #pragma GCC system_header |
| ... | ... | @@ -499,30 +500,24 @@ struct __ratio_gcd |
| 499 | 500 | __static_lcm<_R1::den, _R2::den>::value> type; |
| 500 | 501 | }; |
| 501 | 502 | |
| 502 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 503 | #if _LIBCPP_STD_VER > 14 | |
| 503 | 504 | template <class _R1, class _R2> |
| 504 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_equal_v | |
| 505 | = ratio_equal<_R1, _R2>::value; | |
| 505 | inline constexpr bool ratio_equal_v = ratio_equal<_R1, _R2>::value; | |
| 506 | 506 | |
| 507 | 507 | template <class _R1, class _R2> |
| 508 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_not_equal_v | |
| 509 | = ratio_not_equal<_R1, _R2>::value; | |
| 508 | inline constexpr bool ratio_not_equal_v = ratio_not_equal<_R1, _R2>::value; | |
| 510 | 509 | |
| 511 | 510 | template <class _R1, class _R2> |
| 512 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_less_v | |
| 513 | = ratio_less<_R1, _R2>::value; | |
| 511 | inline constexpr bool ratio_less_v = ratio_less<_R1, _R2>::value; | |
| 514 | 512 | |
| 515 | 513 | template <class _R1, class _R2> |
| 516 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_less_equal_v | |
| 517 | = ratio_less_equal<_R1, _R2>::value; | |
| 514 | inline constexpr bool ratio_less_equal_v = ratio_less_equal<_R1, _R2>::value; | |
| 518 | 515 | |
| 519 | 516 | template <class _R1, class _R2> |
| 520 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_greater_v | |
| 521 | = ratio_greater<_R1, _R2>::value; | |
| 517 | inline constexpr bool ratio_greater_v = ratio_greater<_R1, _R2>::value; | |
| 522 | 518 | |
| 523 | 519 | template <class _R1, class _R2> |
| 524 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool ratio_greater_equal_v | |
| 525 | = ratio_greater_equal<_R1, _R2>::value; | |
| 520 | inline constexpr bool ratio_greater_equal_v = ratio_greater_equal<_R1, _R2>::value; | |
| 526 | 521 | #endif |
| 527 | 522 | |
| 528 | 523 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/regex+79-21| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- regex ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -978,7 +978,7 @@ enum error_type |
| 978 | 978 | __re_err_parse |
| 979 | 979 | }; |
| 980 | 980 | |
| 981 | } // regex_constants | |
| 981 | } // namespace regex_constants | |
| 982 | 982 | |
| 983 | 983 | class _LIBCPP_EXCEPTION_ABI regex_error |
| 984 | 984 | : public runtime_error |
| ... | ... | @@ -1072,32 +1072,38 @@ private: |
| 1072 | 1072 | template <class _ForwardIterator> |
| 1073 | 1073 | string_type |
| 1074 | 1074 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 1075 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1075 | 1076 | template <class _ForwardIterator> |
| 1076 | 1077 | string_type |
| 1077 | 1078 | __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 1078 | ||
| 1079 | #endif | |
| 1079 | 1080 | template <class _ForwardIterator> |
| 1080 | 1081 | string_type |
| 1081 | 1082 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const; |
| 1083 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1082 | 1084 | template <class _ForwardIterator> |
| 1083 | 1085 | string_type |
| 1084 | 1086 | __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const; |
| 1085 | ||
| 1087 | #endif | |
| 1086 | 1088 | template <class _ForwardIterator> |
| 1087 | 1089 | char_class_type |
| 1088 | 1090 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, |
| 1089 | 1091 | bool __icase, char) const; |
| 1092 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1090 | 1093 | template <class _ForwardIterator> |
| 1091 | 1094 | char_class_type |
| 1092 | 1095 | __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, |
| 1093 | 1096 | bool __icase, wchar_t) const; |
| 1097 | #endif | |
| 1094 | 1098 | |
| 1095 | 1099 | static int __regex_traits_value(unsigned char __ch, int __radix); |
| 1096 | 1100 | _LIBCPP_INLINE_VISIBILITY |
| 1097 | 1101 | int __regex_traits_value(char __ch, int __radix) const |
| 1098 | 1102 | {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);} |
| 1103 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1099 | 1104 | _LIBCPP_INLINE_VISIBILITY |
| 1100 | 1105 | int __regex_traits_value(wchar_t __ch, int __radix) const; |
| 1106 | #endif | |
| 1101 | 1107 | }; |
| 1102 | 1108 | |
| 1103 | 1109 | template <class _CharT> |
| ... | ... | @@ -1168,6 +1174,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, |
| 1168 | 1174 | return __d; |
| 1169 | 1175 | } |
| 1170 | 1176 | |
| 1177 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1171 | 1178 | template <class _CharT> |
| 1172 | 1179 | template <class _ForwardIterator> |
| 1173 | 1180 | typename regex_traits<_CharT>::string_type |
| ... | ... | @@ -1189,6 +1196,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, |
| 1189 | 1196 | } |
| 1190 | 1197 | return __d; |
| 1191 | 1198 | } |
| 1199 | #endif | |
| 1192 | 1200 | |
| 1193 | 1201 | // lookup_collatename is very FreeBSD-specific |
| 1194 | 1202 | |
| ... | ... | @@ -1217,6 +1225,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, |
| 1217 | 1225 | return __r; |
| 1218 | 1226 | } |
| 1219 | 1227 | |
| 1228 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1220 | 1229 | template <class _CharT> |
| 1221 | 1230 | template <class _ForwardIterator> |
| 1222 | 1231 | typename regex_traits<_CharT>::string_type |
| ... | ... | @@ -1250,6 +1259,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, |
| 1250 | 1259 | } |
| 1251 | 1260 | return __r; |
| 1252 | 1261 | } |
| 1262 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1253 | 1263 | |
| 1254 | 1264 | // lookup_classname |
| 1255 | 1265 | |
| ... | ... | @@ -1268,6 +1278,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, |
| 1268 | 1278 | return __get_classname(__s.c_str(), __icase); |
| 1269 | 1279 | } |
| 1270 | 1280 | |
| 1281 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1271 | 1282 | template <class _CharT> |
| 1272 | 1283 | template <class _ForwardIterator> |
| 1273 | 1284 | typename regex_traits<_CharT>::char_class_type |
| ... | ... | @@ -1288,6 +1299,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, |
| 1288 | 1299 | } |
| 1289 | 1300 | return __get_classname(__n.c_str(), __icase); |
| 1290 | 1301 | } |
| 1302 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1291 | 1303 | |
| 1292 | 1304 | template <class _CharT> |
| 1293 | 1305 | bool |
| ... | ... | @@ -1298,19 +1310,51 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const |
| 1298 | 1310 | return (__c == '_' && (__m & __regex_word)); |
| 1299 | 1311 | } |
| 1300 | 1312 | |
| 1313 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1314 | bool __is_07(unsigned char c) | |
| 1315 | { | |
| 1316 | return (c & 0xF8u) == | |
| 1317 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1318 | 0xF0; | |
| 1319 | #else | |
| 1320 | 0x30; | |
| 1321 | #endif | |
| 1322 | } | |
| 1323 | ||
| 1324 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1325 | bool __is_89(unsigned char c) | |
| 1326 | { | |
| 1327 | return (c & 0xFEu) == | |
| 1328 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1329 | 0xF8; | |
| 1330 | #else | |
| 1331 | 0x38; | |
| 1332 | #endif | |
| 1333 | } | |
| 1334 | ||
| 1335 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1336 | unsigned char __to_lower(unsigned char c) | |
| 1337 | { | |
| 1338 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 1339 | return c & 0xBF; | |
| 1340 | #else | |
| 1341 | return c | 0x20; | |
| 1342 | #endif | |
| 1343 | } | |
| 1344 | ||
| 1301 | 1345 | template <class _CharT> |
| 1302 | 1346 | int |
| 1303 | 1347 | regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) |
| 1304 | 1348 | { |
| 1305 | if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' | |
| 1349 | if (__is_07(__ch)) // '0' <= __ch && __ch <= '7' | |
| 1306 | 1350 | return __ch - '0'; |
| 1307 | 1351 | if (__radix != 8) |
| 1308 | 1352 | { |
| 1309 | if ((__ch & 0xFEu) == 0x38) // '8' <= __ch && __ch <= '9' | |
| 1353 | if (__is_89(__ch)) // '8' <= __ch && __ch <= '9' | |
| 1310 | 1354 | return __ch - '0'; |
| 1311 | 1355 | if (__radix == 16) |
| 1312 | 1356 | { |
| 1313 | __ch |= 0x20; // tolower | |
| 1357 | __ch = __to_lower(__ch); // tolower | |
| 1314 | 1358 | if ('a' <= __ch && __ch <= 'f') |
| 1315 | 1359 | return __ch - ('a' - 10); |
| 1316 | 1360 | } |
| ... | ... | @@ -1318,6 +1362,7 @@ regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) |
| 1318 | 1362 | return -1; |
| 1319 | 1363 | } |
| 1320 | 1364 | |
| 1365 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1321 | 1366 | template <class _CharT> |
| 1322 | 1367 | inline |
| 1323 | 1368 | int |
| ... | ... | @@ -1325,6 +1370,7 @@ regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const |
| 1325 | 1370 | { |
| 1326 | 1371 | return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); |
| 1327 | 1372 | } |
| 1373 | #endif | |
| 1328 | 1374 | |
| 1329 | 1375 | template <class _CharT> class __node; |
| 1330 | 1376 | |
| ... | ... | @@ -2135,7 +2181,9 @@ public: |
| 2135 | 2181 | }; |
| 2136 | 2182 | |
| 2137 | 2183 | template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const; |
| 2184 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2138 | 2185 | template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const; |
| 2186 | #endif | |
| 2139 | 2187 | |
| 2140 | 2188 | // __match_char |
| 2141 | 2189 | |
| ... | ... | @@ -2542,13 +2590,15 @@ template <class _CharT, class _Traits = regex_traits<_CharT> > |
| 2542 | 2590 | class _LIBCPP_TEMPLATE_VIS basic_regex; |
| 2543 | 2591 | |
| 2544 | 2592 | typedef basic_regex<char> regex; |
| 2593 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2545 | 2594 | typedef basic_regex<wchar_t> wregex; |
| 2595 | #endif | |
| 2546 | 2596 | |
| 2547 | 2597 | template <class _CharT, class _Traits> |
| 2548 | 2598 | class |
| 2549 | 2599 | _LIBCPP_TEMPLATE_VIS |
| 2550 | 2600 | _LIBCPP_PREFERRED_NAME(regex) |
| 2551 | _LIBCPP_PREFERRED_NAME(wregex) | |
| 2601 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex)) | |
| 2552 | 2602 | basic_regex |
| 2553 | 2603 | { |
| 2554 | 2604 | public: |
| ... | ... | @@ -3014,7 +3064,7 @@ private: |
| 3014 | 3064 | template <class, class> friend class __lookahead; |
| 3015 | 3065 | }; |
| 3016 | 3066 | |
| 3017 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 3067 | #if _LIBCPP_STD_VER >= 17 | |
| 3018 | 3068 | template <class _ForwardIterator, |
| 3019 | 3069 | class = typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value, nullptr_t>::type |
| 3020 | 3070 | > |
| ... | ... | @@ -4897,17 +4947,19 @@ basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, |
| 4897 | 4947 | // sub_match |
| 4898 | 4948 | |
| 4899 | 4949 | typedef sub_match<const char*> csub_match; |
| 4900 | typedef sub_match<const wchar_t*> wcsub_match; | |
| 4901 | 4950 | typedef sub_match<string::const_iterator> ssub_match; |
| 4951 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4952 | typedef sub_match<const wchar_t*> wcsub_match; | |
| 4902 | 4953 | typedef sub_match<wstring::const_iterator> wssub_match; |
| 4954 | #endif | |
| 4903 | 4955 | |
| 4904 | 4956 | template <class _BidirectionalIterator> |
| 4905 | 4957 | class |
| 4906 | 4958 | _LIBCPP_TEMPLATE_VIS |
| 4907 | 4959 | _LIBCPP_PREFERRED_NAME(csub_match) |
| 4908 | _LIBCPP_PREFERRED_NAME(wcsub_match) | |
| 4960 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match)) | |
| 4909 | 4961 | _LIBCPP_PREFERRED_NAME(ssub_match) |
| 4910 | _LIBCPP_PREFERRED_NAME(wssub_match) | |
| 4962 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match)) | |
| 4911 | 4963 | sub_match |
| 4912 | 4964 | : public pair<_BidirectionalIterator, _BidirectionalIterator> |
| 4913 | 4965 | { |
| ... | ... | @@ -5326,17 +5378,19 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) |
| 5326 | 5378 | } |
| 5327 | 5379 | |
| 5328 | 5380 | typedef match_results<const char*> cmatch; |
| 5329 | typedef match_results<const wchar_t*> wcmatch; | |
| 5330 | 5381 | typedef match_results<string::const_iterator> smatch; |
| 5382 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5383 | typedef match_results<const wchar_t*> wcmatch; | |
| 5331 | 5384 | typedef match_results<wstring::const_iterator> wsmatch; |
| 5385 | #endif | |
| 5332 | 5386 | |
| 5333 | 5387 | template <class _BidirectionalIterator, class _Allocator> |
| 5334 | 5388 | class |
| 5335 | 5389 | _LIBCPP_TEMPLATE_VIS |
| 5336 | 5390 | _LIBCPP_PREFERRED_NAME(cmatch) |
| 5337 | _LIBCPP_PREFERRED_NAME(wcmatch) | |
| 5391 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch)) | |
| 5338 | 5392 | _LIBCPP_PREFERRED_NAME(smatch) |
| 5339 | _LIBCPP_PREFERRED_NAME(wsmatch) | |
| 5393 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch)) | |
| 5340 | 5394 | match_results |
| 5341 | 5395 | { |
| 5342 | 5396 | public: |
| ... | ... | @@ -6244,17 +6298,19 @@ template <class _BidirectionalIterator, |
| 6244 | 6298 | class _LIBCPP_TEMPLATE_VIS regex_iterator; |
| 6245 | 6299 | |
| 6246 | 6300 | typedef regex_iterator<const char*> cregex_iterator; |
| 6247 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | |
| 6248 | 6301 | typedef regex_iterator<string::const_iterator> sregex_iterator; |
| 6302 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 6303 | typedef regex_iterator<const wchar_t*> wcregex_iterator; | |
| 6249 | 6304 | typedef regex_iterator<wstring::const_iterator> wsregex_iterator; |
| 6305 | #endif | |
| 6250 | 6306 | |
| 6251 | 6307 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 6252 | 6308 | class |
| 6253 | 6309 | _LIBCPP_TEMPLATE_VIS |
| 6254 | 6310 | _LIBCPP_PREFERRED_NAME(cregex_iterator) |
| 6255 | _LIBCPP_PREFERRED_NAME(wcregex_iterator) | |
| 6311 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator)) | |
| 6256 | 6312 | _LIBCPP_PREFERRED_NAME(sregex_iterator) |
| 6257 | _LIBCPP_PREFERRED_NAME(wsregex_iterator) | |
| 6313 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) | |
| 6258 | 6314 | regex_iterator |
| 6259 | 6315 | { |
| 6260 | 6316 | public: |
| ... | ... | @@ -6372,17 +6428,19 @@ template <class _BidirectionalIterator, |
| 6372 | 6428 | class _LIBCPP_TEMPLATE_VIS regex_token_iterator; |
| 6373 | 6429 | |
| 6374 | 6430 | typedef regex_token_iterator<const char*> cregex_token_iterator; |
| 6375 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | |
| 6376 | 6431 | typedef regex_token_iterator<string::const_iterator> sregex_token_iterator; |
| 6432 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 6433 | typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator; | |
| 6377 | 6434 | typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 6435 | #endif | |
| 6378 | 6436 | |
| 6379 | 6437 | template <class _BidirectionalIterator, class _CharT, class _Traits> |
| 6380 | 6438 | class |
| 6381 | 6439 | _LIBCPP_TEMPLATE_VIS |
| 6382 | 6440 | _LIBCPP_PREFERRED_NAME(cregex_token_iterator) |
| 6383 | _LIBCPP_PREFERRED_NAME(wcregex_token_iterator) | |
| 6441 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator)) | |
| 6384 | 6442 | _LIBCPP_PREFERRED_NAME(sregex_token_iterator) |
| 6385 | _LIBCPP_PREFERRED_NAME(wsregex_token_iterator) | |
| 6443 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator)) | |
| 6386 | 6444 | regex_token_iterator |
| 6387 | 6445 | { |
| 6388 | 6446 | public: |
lib/libcxx/include/scoped_allocator+11-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- scoped_allocator --------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -91,6 +91,10 @@ public: |
| 91 | 91 | scoped_allocator_adaptor select_on_container_copy_construction() const noexcept; |
| 92 | 92 | }; |
| 93 | 93 | |
| 94 | template<class OuterAlloc, class... InnerAllocs> | |
| 95 | scoped_allocator_adaptor(OuterAlloc, InnerAllocs...) | |
| 96 | -> scoped_allocator_adaptor<OuterAlloc, InnerAllocs...>; | |
| 97 | ||
| 94 | 98 | template <class OuterA1, class OuterA2, class... InnerAllocs> |
| 95 | 99 | bool |
| 96 | 100 | operator==(const scoped_allocator_adaptor<OuterA1, InnerAllocs...>& a, |
| ... | ... | @@ -649,6 +653,12 @@ private: |
| 649 | 653 | template <class...> friend class __scoped_allocator_storage; |
| 650 | 654 | }; |
| 651 | 655 | |
| 656 | #if _LIBCPP_STD_VER > 14 | |
| 657 | template<class _OuterAlloc, class... _InnerAllocs> | |
| 658 | scoped_allocator_adaptor(_OuterAlloc, _InnerAllocs...) | |
| 659 | -> scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>; | |
| 660 | #endif | |
| 661 | ||
| 652 | 662 | template <class _OuterA1, class _OuterA2> |
| 653 | 663 | inline _LIBCPP_INLINE_VISIBILITY |
| 654 | 664 | bool |
lib/libcxx/include/semaphore+21-73| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- semaphore --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -47,8 +47,10 @@ using binary_semaphore = counting_semaphore<1>; |
| 47 | 47 | |
| 48 | 48 | #include <__availability> |
| 49 | 49 | #include <__config> |
| 50 | #include <__thread/timed_backoff_policy.h> | |
| 50 | 51 | #include <__threading_support> |
| 51 | 52 | #include <atomic> |
| 53 | #include <version> | |
| 52 | 54 | |
| 53 | 55 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 54 | 56 | #pragma GCC system_header |
| ... | ... | @@ -67,10 +69,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 67 | 69 | |
| 68 | 70 | /* |
| 69 | 71 | |
| 70 | __atomic_semaphore_base is the general-case implementation, to be used for | |
| 71 | user-requested least-max values that exceed the OS implementation support | |
| 72 | (incl. when the OS has no support of its own) and for binary semaphores. | |
| 73 | ||
| 72 | __atomic_semaphore_base is the general-case implementation. | |
| 74 | 73 | It is a typical Dijkstra semaphore algorithm over atomics, wait and notify |
| 75 | 74 | functions. It avoids contention against users' own use of those facilities. |
| 76 | 75 | |
| ... | ... | @@ -82,7 +81,7 @@ class __atomic_semaphore_base |
| 82 | 81 | |
| 83 | 82 | public: |
| 84 | 83 | _LIBCPP_INLINE_VISIBILITY |
| 85 | __atomic_semaphore_base(ptrdiff_t __count) : __a(__count) | |
| 84 | constexpr explicit __atomic_semaphore_base(ptrdiff_t __count) : __a(__count) | |
| 86 | 85 | { |
| 87 | 86 | } |
| 88 | 87 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -108,81 +107,30 @@ public: |
| 108 | 107 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 109 | 108 | bool try_acquire_for(chrono::duration<Rep, Period> const& __rel_time) |
| 110 | 109 | { |
| 111 | auto const __test_fn = [this]() -> bool { | |
| 112 | auto __old = __a.load(memory_order_acquire); | |
| 113 | while(1) { | |
| 114 | if (__old == 0) | |
| 115 | return false; | |
| 116 | if(__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) | |
| 117 | return true; | |
| 118 | } | |
| 119 | }; | |
| 110 | if (__rel_time == chrono::duration<Rep, Period>::zero()) | |
| 111 | return try_acquire(); | |
| 112 | auto const __test_fn = [this]() { return try_acquire(); }; | |
| 120 | 113 | return __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time); |
| 121 | 114 | } |
| 122 | }; | |
| 123 | ||
| 124 | #ifndef _LIBCPP_NO_NATIVE_SEMAPHORES | |
| 125 | ||
| 126 | /* | |
| 127 | ||
| 128 | __platform_semaphore_base a simple wrapper for the OS semaphore type. That | |
| 129 | is, every call is routed to the OS in the most direct manner possible. | |
| 130 | ||
| 131 | */ | |
| 132 | ||
| 133 | class __platform_semaphore_base | |
| 134 | { | |
| 135 | __libcpp_semaphore_t __semaphore; | |
| 136 | ||
| 137 | public: | |
| 138 | _LIBCPP_INLINE_VISIBILITY | |
| 139 | __platform_semaphore_base(ptrdiff_t __count) : | |
| 140 | __semaphore() | |
| 141 | { | |
| 142 | __libcpp_semaphore_init(&__semaphore, __count); | |
| 143 | } | |
| 144 | _LIBCPP_INLINE_VISIBILITY | |
| 145 | ~__platform_semaphore_base() { | |
| 146 | __libcpp_semaphore_destroy(&__semaphore); | |
| 147 | } | |
| 148 | _LIBCPP_INLINE_VISIBILITY | |
| 149 | void release(ptrdiff_t __update) | |
| 150 | { | |
| 151 | for(; __update; --__update) | |
| 152 | __libcpp_semaphore_post(&__semaphore); | |
| 153 | } | |
| 154 | _LIBCPP_INLINE_VISIBILITY | |
| 155 | void acquire() | |
| 156 | { | |
| 157 | __libcpp_semaphore_wait(&__semaphore); | |
| 158 | } | |
| 159 | _LIBCPP_INLINE_VISIBILITY | |
| 160 | bool try_acquire_for(chrono::nanoseconds __rel_time) | |
| 115 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY | |
| 116 | bool try_acquire() | |
| 161 | 117 | { |
| 162 | return __libcpp_semaphore_wait_timed(&__semaphore, __rel_time); | |
| 118 | auto __old = __a.load(memory_order_acquire); | |
| 119 | while (true) { | |
| 120 | if (__old == 0) | |
| 121 | return false; | |
| 122 | if (__a.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed)) | |
| 123 | return true; | |
| 124 | } | |
| 163 | 125 | } |
| 164 | 126 | }; |
| 165 | 127 | |
| 166 | template<ptrdiff_t __least_max_value> | |
| 167 | using __semaphore_base = | |
| 168 | typename conditional<(__least_max_value > 1 && __least_max_value <= _LIBCPP_SEMAPHORE_MAX), | |
| 169 | __platform_semaphore_base, | |
| 170 | __atomic_semaphore_base>::type; | |
| 171 | ||
| 172 | #else | |
| 173 | ||
| 174 | template<ptrdiff_t __least_max_value> | |
| 175 | using __semaphore_base = | |
| 176 | __atomic_semaphore_base; | |
| 177 | ||
| 178 | 128 | #define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max()) |
| 179 | 129 | |
| 180 | #endif //_LIBCPP_NO_NATIVE_SEMAPHORES | |
| 181 | ||
| 182 | 130 | template<ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX> |
| 183 | 131 | class counting_semaphore |
| 184 | 132 | { |
| 185 | __semaphore_base<__least_max_value> __semaphore; | |
| 133 | __atomic_semaphore_base __semaphore; | |
| 186 | 134 | |
| 187 | 135 | public: |
| 188 | 136 | static constexpr ptrdiff_t max() noexcept { |
| ... | ... | @@ -190,7 +138,7 @@ public: |
| 190 | 138 | } |
| 191 | 139 | |
| 192 | 140 | _LIBCPP_INLINE_VISIBILITY |
| 193 | counting_semaphore(ptrdiff_t __count = 0) : __semaphore(__count) { } | |
| 141 | constexpr explicit counting_semaphore(ptrdiff_t __count) : __semaphore(__count) { } | |
| 194 | 142 | ~counting_semaphore() = default; |
| 195 | 143 | |
| 196 | 144 | counting_semaphore(const counting_semaphore&) = delete; |
| ... | ... | @@ -215,14 +163,14 @@ public: |
| 215 | 163 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 216 | 164 | bool try_acquire() |
| 217 | 165 | { |
| 218 | return try_acquire_for(chrono::nanoseconds::zero()); | |
| 166 | return __semaphore.try_acquire(); | |
| 219 | 167 | } |
| 220 | 168 | template <class Clock, class Duration> |
| 221 | 169 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 222 | 170 | bool try_acquire_until(chrono::time_point<Clock, Duration> const& __abs_time) |
| 223 | 171 | { |
| 224 | 172 | auto const current = Clock::now(); |
| 225 | if(current >= __abs_time) | |
| 173 | if (current >= __abs_time) | |
| 226 | 174 | return try_acquire(); |
| 227 | 175 | else |
| 228 | 176 | return try_acquire_for(__abs_time - current); |
lib/libcxx/include/set+60-19| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- set -------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -183,6 +183,25 @@ public: |
| 183 | 183 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
| 184 | 184 | }; |
| 185 | 185 | |
| 186 | template <class InputIterator, | |
| 187 | class Compare = less<typename iterator_traits<InputIterator>::value_type>, | |
| 188 | class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> | |
| 189 | set(InputIterator, InputIterator, | |
| 190 | Compare = Compare(), Allocator = Allocator()) | |
| 191 | -> set<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 | |
| 192 | ||
| 193 | template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> | |
| 194 | set(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) | |
| 195 | -> set<Key, Compare, Allocator>; // C++17 | |
| 196 | ||
| 197 | template<class InputIterator, class Allocator> | |
| 198 | set(InputIterator, InputIterator, Allocator) | |
| 199 | -> set<typename iterator_traits<InputIterator>::value_type, | |
| 200 | less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 | |
| 201 | ||
| 202 | template<class Key, class Allocator> | |
| 203 | set(initializer_list<Key>, Allocator) -> set<Key, less<Key>, Allocator>; // C++17 | |
| 204 | ||
| 186 | 205 | template <class Key, class Compare, class Allocator> |
| 187 | 206 | bool |
| 188 | 207 | operator==(const set<Key, Compare, Allocator>& x, |
| ... | ... | @@ -389,6 +408,25 @@ public: |
| 389 | 408 | pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 |
| 390 | 409 | }; |
| 391 | 410 | |
| 411 | template <class InputIterator, | |
| 412 | class Compare = less<typename iterator_traits<InputIterator>::value_type>, | |
| 413 | class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> | |
| 414 | multiset(InputIterator, InputIterator, | |
| 415 | Compare = Compare(), Allocator = Allocator()) | |
| 416 | -> multiset<typename iterator_traits<InputIterator>::value_type, Compare, Allocator>; // C++17 | |
| 417 | ||
| 418 | template<class Key, class Compare = less<Key>, class Allocator = allocator<Key>> | |
| 419 | multiset(initializer_list<Key>, Compare = Compare(), Allocator = Allocator()) | |
| 420 | -> multiset<Key, Compare, Allocator>; // C++17 | |
| 421 | ||
| 422 | template<class InputIterator, class Allocator> | |
| 423 | multiset(InputIterator, InputIterator, Allocator) | |
| 424 | -> multiset<typename iterator_traits<InputIterator>::value_type, | |
| 425 | less<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 | |
| 426 | ||
| 427 | template<class Key, class Allocator> | |
| 428 | multiset(initializer_list<Key>, Allocator) -> multiset<Key, less<Key>, Allocator>; // C++17 | |
| 429 | ||
| 392 | 430 | template <class Key, class Compare, class Allocator> |
| 393 | 431 | bool |
| 394 | 432 | operator==(const multiset<Key, Compare, Allocator>& x, |
| ... | ... | @@ -436,6 +474,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 436 | 474 | #include <__config> |
| 437 | 475 | #include <__debug> |
| 438 | 476 | #include <__functional/is_transparent.h> |
| 477 | #include <__iterator/iterator_traits.h> | |
| 439 | 478 | #include <__node_handle> |
| 440 | 479 | #include <__tree> |
| 441 | 480 | #include <__utility/forward.h> |
| ... | ... | @@ -462,7 +501,7 @@ public: |
| 462 | 501 | // types: |
| 463 | 502 | typedef _Key key_type; |
| 464 | 503 | typedef key_type value_type; |
| 465 | typedef _Compare key_compare; | |
| 504 | typedef __identity_t<_Compare> key_compare; | |
| 466 | 505 | typedef key_compare value_compare; |
| 467 | 506 | typedef __identity_t<_Allocator> allocator_type; |
| 468 | 507 | typedef value_type& reference; |
| ... | ... | @@ -474,7 +513,6 @@ public: |
| 474 | 513 | private: |
| 475 | 514 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 476 | 515 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 477 | typedef typename __base::__node_holder __node_holder; | |
| 478 | 516 | |
| 479 | 517 | __base __tree_; |
| 480 | 518 | |
| ... | ... | @@ -868,30 +906,32 @@ public: |
| 868 | 906 | #endif |
| 869 | 907 | }; |
| 870 | 908 | |
| 871 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 909 | #if _LIBCPP_STD_VER >= 17 | |
| 872 | 910 | template<class _InputIterator, |
| 873 | 911 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 874 | 912 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
| 875 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, | |
| 876 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> | |
| 913 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 914 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | |
| 915 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | |
| 877 | 916 | set(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 878 | 917 | -> set<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
| 879 | 918 | |
| 880 | 919 | template<class _Key, class _Compare = less<_Key>, |
| 881 | 920 | class _Allocator = allocator<_Key>, |
| 882 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, | |
| 883 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> | |
| 921 | class = enable_if_t<!__is_allocator<_Compare>::value, void>, | |
| 922 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 884 | 923 | set(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 885 | 924 | -> set<_Key, _Compare, _Allocator>; |
| 886 | 925 | |
| 887 | 926 | template<class _InputIterator, class _Allocator, |
| 888 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 927 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 928 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 889 | 929 | set(_InputIterator, _InputIterator, _Allocator) |
| 890 | 930 | -> set<__iter_value_type<_InputIterator>, |
| 891 | 931 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
| 892 | 932 | |
| 893 | 933 | template<class _Key, class _Allocator, |
| 894 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 934 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 895 | 935 | set(initializer_list<_Key>, _Allocator) |
| 896 | 936 | -> set<_Key, less<_Key>, _Allocator>; |
| 897 | 937 | #endif |
| ... | ... | @@ -994,7 +1034,7 @@ public: |
| 994 | 1034 | // types: |
| 995 | 1035 | typedef _Key key_type; |
| 996 | 1036 | typedef key_type value_type; |
| 997 | typedef _Compare key_compare; | |
| 1037 | typedef __identity_t<_Compare> key_compare; | |
| 998 | 1038 | typedef key_compare value_compare; |
| 999 | 1039 | typedef __identity_t<_Allocator> allocator_type; |
| 1000 | 1040 | typedef value_type& reference; |
| ... | ... | @@ -1006,7 +1046,6 @@ public: |
| 1006 | 1046 | private: |
| 1007 | 1047 | typedef __tree<value_type, value_compare, allocator_type> __base; |
| 1008 | 1048 | typedef allocator_traits<allocator_type> __alloc_traits; |
| 1009 | typedef typename __base::__node_holder __node_holder; | |
| 1010 | 1049 | |
| 1011 | 1050 | __base __tree_; |
| 1012 | 1051 | |
| ... | ... | @@ -1399,30 +1438,32 @@ public: |
| 1399 | 1438 | #endif |
| 1400 | 1439 | }; |
| 1401 | 1440 | |
| 1402 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1441 | #if _LIBCPP_STD_VER >= 17 | |
| 1403 | 1442 | template<class _InputIterator, |
| 1404 | 1443 | class _Compare = less<__iter_value_type<_InputIterator>>, |
| 1405 | 1444 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
| 1406 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, | |
| 1407 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> | |
| 1445 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 1446 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | |
| 1447 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | |
| 1408 | 1448 | multiset(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1409 | 1449 | -> multiset<__iter_value_type<_InputIterator>, _Compare, _Allocator>; |
| 1410 | 1450 | |
| 1411 | 1451 | template<class _Key, class _Compare = less<_Key>, |
| 1412 | 1452 | class _Allocator = allocator<_Key>, |
| 1413 | class = _EnableIf<__is_allocator<_Allocator>::value, void>, | |
| 1414 | class = _EnableIf<!__is_allocator<_Compare>::value, void>> | |
| 1453 | class = enable_if_t<__is_allocator<_Allocator>::value, void>, | |
| 1454 | class = enable_if_t<!__is_allocator<_Compare>::value, void>> | |
| 1415 | 1455 | multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator()) |
| 1416 | 1456 | -> multiset<_Key, _Compare, _Allocator>; |
| 1417 | 1457 | |
| 1418 | 1458 | template<class _InputIterator, class _Allocator, |
| 1419 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 1459 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void>, | |
| 1460 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 1420 | 1461 | multiset(_InputIterator, _InputIterator, _Allocator) |
| 1421 | 1462 | -> multiset<__iter_value_type<_InputIterator>, |
| 1422 | 1463 | less<__iter_value_type<_InputIterator>>, _Allocator>; |
| 1423 | 1464 | |
| 1424 | 1465 | template<class _Key, class _Allocator, |
| 1425 | class = _EnableIf<__is_allocator<_Allocator>::value, void>> | |
| 1466 | class = enable_if_t<__is_allocator<_Allocator>::value, void>> | |
| 1426 | 1467 | multiset(initializer_list<_Key>, _Allocator) |
| 1427 | 1468 | -> multiset<_Key, less<_Key>, _Allocator>; |
| 1428 | 1469 | #endif |
lib/libcxx/include/setjmp.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- setjmp.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/shared_mutex+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ shared_mutex --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/span+150-89| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------ span ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -56,18 +56,18 @@ public: |
| 56 | 56 | |
| 57 | 57 | // [span.cons], span constructors, copy, assignment, and destructor |
| 58 | 58 | constexpr span() noexcept; |
| 59 | constexpr explicit(Extent != dynamic_extent) span(pointer ptr, size_type count); | |
| 60 | constexpr explicit(Extent != dynamic_extent) span(pointer firstElem, pointer lastElem); | |
| 59 | template <class It> | |
| 60 | constexpr explicit(Extent != dynamic_extent) span(It first, size_type count); | |
| 61 | template <class It, class End> | |
| 62 | constexpr explicit(Extent != dynamic_extent) span(It first, End last); | |
| 61 | 63 | template <size_t N> |
| 62 | constexpr span(element_type (&arr)[N]) noexcept; | |
| 64 | constexpr span(type_identity_t<element_type> (&arr)[N]) noexcept; | |
| 63 | 65 | template <size_t N> |
| 64 | 66 | constexpr span(array<value_type, N>& arr) noexcept; |
| 65 | 67 | template <size_t N> |
| 66 | 68 | constexpr span(const array<value_type, N>& arr) noexcept; |
| 67 | template <class Container> | |
| 68 | constexpr explicit(Extent != dynamic_extent) span(Container& cont); | |
| 69 | template <class Container> | |
| 70 | constexpr explicit(Extent != dynamic_extent) span(const Container& cont); | |
| 69 | template<class R> | |
| 70 | constexpr explicit(Extent != dynamic_extent) span(R&& r); | |
| 71 | 71 | constexpr span(const span& other) noexcept = default; |
| 72 | 72 | template <class OtherElementType, size_t OtherExtent> |
| 73 | 73 | constexpr explicit(Extent != dynamic_extent) span(const span<OtherElementType, OtherExtent>& s) noexcept; |
| ... | ... | @@ -89,7 +89,7 @@ public: |
| 89 | 89 | // [span.obs], span observers |
| 90 | 90 | constexpr size_type size() const noexcept; |
| 91 | 91 | constexpr size_type size_bytes() const noexcept; |
| 92 | constexpr bool empty() const noexcept; | |
| 92 | [[nodiscard]] constexpr bool empty() const noexcept; | |
| 93 | 93 | |
| 94 | 94 | // [span.elem], span element access |
| 95 | 95 | constexpr reference operator[](size_type idx) const; |
| ... | ... | @@ -108,6 +108,9 @@ private: |
| 108 | 108 | size_type size_; // exposition only |
| 109 | 109 | }; |
| 110 | 110 | |
| 111 | template<class It, class EndOrSize> | |
| 112 | span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; | |
| 113 | ||
| 111 | 114 | template<class T, size_t N> |
| 112 | 115 | span(T (&)[N]) -> span<T, N>; |
| 113 | 116 | |
| ... | ... | @@ -117,11 +120,8 @@ template<class T, size_t N> |
| 117 | 120 | template<class T, size_t N> |
| 118 | 121 | span(const array<T, N>&) -> span<const T, N>; |
| 119 | 122 | |
| 120 | template<class Container> | |
| 121 | span(Container&) -> span<typename Container::value_type>; | |
| 122 | ||
| 123 | template<class Container> | |
| 124 | span(const Container&) -> span<const typename Container::value_type>; | |
| 123 | template<class R> | |
| 124 | span(R&&) -> span<remove_reference_t<ranges::range_reference_t<R>>>; | |
| 125 | 125 | |
| 126 | 126 | } // namespace std |
| 127 | 127 | |
| ... | ... | @@ -129,9 +129,13 @@ template<class Container> |
| 129 | 129 | |
| 130 | 130 | #include <__config> |
| 131 | 131 | #include <__debug> |
| 132 | #include <__iterator/concepts.h> | |
| 132 | 133 | #include <__iterator/wrap_iter.h> |
| 134 | #include <__ranges/concepts.h> | |
| 135 | #include <__ranges/data.h> | |
| 133 | 136 | #include <__ranges/enable_borrowed_range.h> |
| 134 | 137 | #include <__ranges/enable_view.h> |
| 138 | #include <__ranges/size.h> | |
| 135 | 139 | #include <array> // for array |
| 136 | 140 | #include <cstddef> // for byte |
| 137 | 141 | #include <iterator> // for iterators |
| ... | ... | @@ -155,46 +159,46 @@ template <typename _Tp, size_t _Extent = dynamic_extent> class span; |
| 155 | 159 | |
| 156 | 160 | |
| 157 | 161 | template <class _Tp> |
| 158 | struct __is_span_impl : public false_type {}; | |
| 159 | ||
| 160 | template <class _Tp, size_t _Extent> | |
| 161 | struct __is_span_impl<span<_Tp, _Extent>> : public true_type {}; | |
| 162 | ||
| 163 | template <class _Tp> | |
| 164 | struct __is_span : public __is_span_impl<remove_cv_t<_Tp>> {}; | |
| 165 | ||
| 166 | template <class _Tp> | |
| 167 | struct __is_std_array_impl : public false_type {}; | |
| 162 | struct __is_std_array : false_type {}; | |
| 168 | 163 | |
| 169 | 164 | template <class _Tp, size_t _Sz> |
| 170 | struct __is_std_array_impl<array<_Tp, _Sz>> : public true_type {}; | |
| 165 | struct __is_std_array<array<_Tp, _Sz>> : true_type {}; | |
| 171 | 166 | |
| 172 | 167 | template <class _Tp> |
| 173 | struct __is_std_array : public __is_std_array_impl<remove_cv_t<_Tp>> {}; | |
| 174 | ||
| 175 | template <class _Tp, class _ElementType, class = void> | |
| 176 | struct __is_span_compatible_container : public false_type {}; | |
| 177 | ||
| 178 | template <class _Tp, class _ElementType> | |
| 179 | struct __is_span_compatible_container<_Tp, _ElementType, | |
| 180 | void_t< | |
| 181 | // is not a specialization of span | |
| 182 | typename enable_if<!__is_span<_Tp>::value, nullptr_t>::type, | |
| 183 | // is not a specialization of array | |
| 184 | typename enable_if<!__is_std_array<_Tp>::value, nullptr_t>::type, | |
| 185 | // is_array_v<Container> is false, | |
| 186 | typename enable_if<!is_array_v<_Tp>, nullptr_t>::type, | |
| 187 | // data(cont) and size(cont) are well formed | |
| 188 | decltype(data(declval<_Tp>())), | |
| 189 | decltype(size(declval<_Tp>())), | |
| 190 | // remove_pointer_t<decltype(data(cont))>(*)[] is convertible to ElementType(*)[] | |
| 191 | typename enable_if< | |
| 192 | is_convertible_v<remove_pointer_t<decltype(data(declval<_Tp &>()))>(*)[], | |
| 193 | _ElementType(*)[]>, | |
| 194 | nullptr_t>::type | |
| 195 | >> | |
| 196 | : public true_type {}; | |
| 168 | struct __is_std_span : false_type {}; | |
| 197 | 169 | |
| 170 | template <class _Tp, size_t _Sz> | |
| 171 | struct __is_std_span<span<_Tp, _Sz>> : true_type {}; | |
| 172 | ||
| 173 | #if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 174 | // 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 constructor | |
| 176 | // 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>, | |
| 178 | // we emulate the constructor requirements like this. | |
| 179 | template <class _Range, class _ElementType, class = void> | |
| 180 | struct __span_compatible_range : false_type { }; | |
| 181 | ||
| 182 | template <class _Range, class _ElementType> | |
| 183 | struct __span_compatible_range<_Range, _ElementType, void_t< | |
| 184 | enable_if_t<!__is_std_span<remove_cvref_t<_Range>>::value>, | |
| 185 | enable_if_t<!__is_std_array<remove_cvref_t<_Range>>::value>, | |
| 186 | enable_if_t<!is_array_v<remove_cvref_t<_Range>>>, | |
| 187 | decltype(data(declval<_Range>())), | |
| 188 | decltype(size(declval<_Range>())), | |
| 189 | enable_if_t<is_convertible_v<remove_pointer_t<decltype(data(declval<_Range&>()))>(*)[], _ElementType(*)[]>> | |
| 190 | >> : true_type { }; | |
| 191 | #else | |
| 192 | template <class _Range, class _ElementType> | |
| 193 | concept __span_compatible_range = | |
| 194 | ranges::contiguous_range<_Range> && | |
| 195 | ranges::sized_range<_Range> && | |
| 196 | (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && | |
| 197 | !__is_std_span<remove_cvref_t<_Range>>::value && | |
| 198 | !__is_std_array<remove_cvref_t<_Range>>::value && | |
| 199 | !is_array_v<remove_cvref_t<_Range>> && | |
| 200 | is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>; | |
| 201 | #endif | |
| 198 | 202 | |
| 199 | 203 | template <typename _Tp, size_t _Extent> |
| 200 | 204 | class _LIBCPP_TEMPLATE_VIS span { |
| ... | ... | @@ -224,12 +228,33 @@ public: |
| 224 | 228 | constexpr span (const span&) noexcept = default; |
| 225 | 229 | constexpr span& operator=(const span&) noexcept = default; |
| 226 | 230 | |
| 227 | _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __ptr, size_type __count) : __data{__ptr} | |
| 228 | { (void)__count; _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (ptr, len)"); } | |
| 229 | _LIBCPP_INLINE_VISIBILITY constexpr explicit span(pointer __f, pointer __l) : __data{__f} | |
| 230 | { (void)__l; _LIBCPP_ASSERT(_Extent == distance(__f, __l), "size mismatch in span's constructor (ptr, ptr)"); } | |
| 231 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 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_VISIBILITY | |
| 237 | constexpr explicit span(_It __first, size_type __count) | |
| 238 | : __data{_VSTD::to_address(__first)} { | |
| 239 | (void)__count; | |
| 240 | _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)"); | |
| 241 | } | |
| 242 | ||
| 243 | template < | |
| 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_VISIBILITY | |
| 249 | constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} { | |
| 250 | (void)__last; | |
| 251 | _LIBCPP_ASSERT((__last - __first >= 0), "invalid range in span's constructor (iterator, sentinel)"); | |
| 252 | _LIBCPP_ASSERT(__last - __first == _Extent, | |
| 253 | "invalid range in span's constructor (iterator, sentinel): last - first != extent"); | |
| 254 | } | |
| 255 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 231 | 256 | |
| 232 | _LIBCPP_INLINE_VISIBILITY constexpr span(element_type (&__arr)[_Extent]) noexcept : __data{__arr} {} | |
| 257 | _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {} | |
| 233 | 258 | |
| 234 | 259 | template <class _OtherElementType, |
| 235 | 260 | enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> |
| ... | ... | @@ -241,21 +266,28 @@ public: |
| 241 | 266 | _LIBCPP_INLINE_VISIBILITY |
| 242 | 267 | constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} |
| 243 | 268 | |
| 244 | template <class _Container> | |
| 269 | #if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 270 | template <class _Container, class = enable_if_t< | |
| 271 | __span_compatible_range<_Container, element_type>::value | |
| 272 | >> | |
| 245 | 273 | _LIBCPP_INLINE_VISIBILITY |
| 246 | constexpr explicit span( _Container& __c, | |
| 247 | enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr) | |
| 248 | : __data{_VSTD::data(__c)} { | |
| 249 | _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)"); | |
| 250 | } | |
| 251 | ||
| 252 | template <class _Container> | |
| 274 | constexpr explicit span(_Container& __c) : __data{std::data(__c)} { | |
| 275 | _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)"); | |
| 276 | } | |
| 277 | template <class _Container, class = enable_if_t< | |
| 278 | __span_compatible_range<const _Container, element_type>::value | |
| 279 | >> | |
| 280 | _LIBCPP_INLINE_VISIBILITY | |
| 281 | constexpr explicit span(const _Container& __c) : __data{std::data(__c)} { | |
| 282 | _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)"); | |
| 283 | } | |
| 284 | #else | |
| 285 | template <__span_compatible_range<element_type> _Range> | |
| 253 | 286 | _LIBCPP_INLINE_VISIBILITY |
| 254 | constexpr explicit span(const _Container& __c, | |
| 255 | enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr) | |
| 256 | : __data{_VSTD::data(__c)} { | |
| 257 | _LIBCPP_ASSERT(_Extent == _VSTD::size(__c), "size mismatch in span's constructor (range)"); | |
| 258 | } | |
| 287 | constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} { | |
| 288 | _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)"); | |
| 289 | } | |
| 290 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 259 | 291 | |
| 260 | 292 | template <class _OtherElementType> |
| 261 | 293 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -331,9 +363,9 @@ public: |
| 331 | 363 | return {data() + __offset, __count}; |
| 332 | 364 | } |
| 333 | 365 | |
| 334 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; } | |
| 335 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); } | |
| 336 | _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; } | |
| 366 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return _Extent; } | |
| 367 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return _Extent * sizeof(element_type); } | |
| 368 | [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return _Extent == 0; } | |
| 337 | 369 | |
| 338 | 370 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept |
| 339 | 371 | { |
| ... | ... | @@ -402,12 +434,28 @@ public: |
| 402 | 434 | constexpr span (const span&) noexcept = default; |
| 403 | 435 | constexpr span& operator=(const span&) noexcept = default; |
| 404 | 436 | |
| 405 | _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __ptr, size_type __count) : __data{__ptr}, __size{__count} {} | |
| 406 | _LIBCPP_INLINE_VISIBILITY constexpr span(pointer __f, pointer __l) : __data{__f}, __size{static_cast<size_t>(distance(__f, __l))} {} | |
| 437 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 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_VISIBILITY | |
| 443 | constexpr span(_It __first, size_type __count) | |
| 444 | : __data{_VSTD::to_address(__first)}, __size{__count} {} | |
| 445 | ||
| 446 | template < | |
| 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_VISIBILITY | |
| 452 | constexpr span(_It __first, _End __last) | |
| 453 | : __data(_VSTD::to_address(__first)), __size(__last - __first) {} | |
| 454 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 407 | 455 | |
| 408 | 456 | template <size_t _Sz> |
| 409 | 457 | _LIBCPP_INLINE_VISIBILITY |
| 410 | constexpr span(element_type (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} | |
| 458 | constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} | |
| 411 | 459 | |
| 412 | 460 | template <class _OtherElementType, size_t _Sz, |
| 413 | 461 | enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> |
| ... | ... | @@ -419,18 +467,22 @@ public: |
| 419 | 467 | _LIBCPP_INLINE_VISIBILITY |
| 420 | 468 | constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} |
| 421 | 469 | |
| 422 | template <class _Container> | |
| 470 | #if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 471 | template <class _Container, class = enable_if_t< | |
| 472 | __span_compatible_range<_Container, element_type>::value | |
| 473 | >> | |
| 423 | 474 | _LIBCPP_INLINE_VISIBILITY |
| 424 | constexpr span( _Container& __c, | |
| 425 | enable_if_t<__is_span_compatible_container<_Container, _Tp>::value, nullptr_t> = nullptr) | |
| 426 | : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {} | |
| 427 | ||
| 428 | template <class _Container> | |
| 475 | constexpr span(_Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {} | |
| 476 | template <class _Container, class = enable_if_t< | |
| 477 | __span_compatible_range<const _Container, element_type>::value | |
| 478 | >> | |
| 429 | 479 | _LIBCPP_INLINE_VISIBILITY |
| 430 | constexpr span(const _Container& __c, | |
| 431 | enable_if_t<__is_span_compatible_container<const _Container, _Tp>::value, nullptr_t> = nullptr) | |
| 432 | : __data{_VSTD::data(__c)}, __size{(size_type) _VSTD::size(__c)} {} | |
| 433 | ||
| 480 | constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {} | |
| 481 | #else | |
| 482 | template <__span_compatible_range<element_type> _Range> | |
| 483 | _LIBCPP_INLINE_VISIBILITY | |
| 484 | 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) | |
| 434 | 486 | |
| 435 | 487 | template <class _OtherElementType, size_t _OtherExtent> |
| 436 | 488 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -493,9 +545,9 @@ public: |
| 493 | 545 | return {data() + __offset, __count}; |
| 494 | 546 | } |
| 495 | 547 | |
| 496 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; } | |
| 497 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); } | |
| 498 | _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; } | |
| 548 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size() const noexcept { return __size; } | |
| 549 | _LIBCPP_INLINE_VISIBILITY constexpr size_type size_bytes() const noexcept { return __size * sizeof(element_type); } | |
| 550 | [[nodiscard]] _LIBCPP_INLINE_VISIBILITY constexpr bool empty() const noexcept { return __size == 0; } | |
| 499 | 551 | |
| 500 | 552 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept |
| 501 | 553 | { |
| ... | ... | @@ -535,13 +587,13 @@ private: |
| 535 | 587 | size_type __size; |
| 536 | 588 | }; |
| 537 | 589 | |
| 538 | #if !defined(_LIBCPP_HAS_NO_RANGES) | |
| 590 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 539 | 591 | template <class _Tp, size_t _Extent> |
| 540 | 592 | inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true; |
| 541 | 593 | |
| 542 | 594 | template <class _ElementType, size_t _Extent> |
| 543 | 595 | inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true; |
| 544 | #endif // !defined(_LIBCPP_HAS_NO_RANGES) | |
| 596 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 545 | 597 | |
| 546 | 598 | // as_bytes & as_writable_bytes |
| 547 | 599 | template <class _Tp, size_t _Extent> |
| ... | ... | @@ -556,7 +608,11 @@ auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept |
| 556 | 608 | -> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())> |
| 557 | 609 | { return __s.__as_writable_bytes(); } |
| 558 | 610 | |
| 559 | // Deduction guides | |
| 611 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 612 | template<contiguous_iterator _It, class _EndOrSize> | |
| 613 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; | |
| 614 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 615 | ||
| 560 | 616 | template<class _Tp, size_t _Sz> |
| 561 | 617 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; |
| 562 | 618 | |
| ... | ... | @@ -566,11 +622,16 @@ template<class _Tp, size_t _Sz> |
| 566 | 622 | template<class _Tp, size_t _Sz> |
| 567 | 623 | span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>; |
| 568 | 624 | |
| 625 | #if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 569 | 626 | template<class _Container> |
| 570 | 627 | span(_Container&) -> span<typename _Container::value_type>; |
| 571 | 628 | |
| 572 | 629 | template<class _Container> |
| 573 | 630 | span(const _Container&) -> span<const typename _Container::value_type>; |
| 631 | #else | |
| 632 | template<ranges::contiguous_range _Range> | |
| 633 | span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>; | |
| 634 | #endif | |
| 574 | 635 | |
| 575 | 636 | #endif // _LIBCPP_STD_VER > 17 |
| 576 | 637 |
lib/libcxx/include/sstream+2-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- sstream ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -184,6 +184,7 @@ typedef basic_stringstream<wchar_t> wstringstream; |
| 184 | 184 | #include <istream> |
| 185 | 185 | #include <ostream> |
| 186 | 186 | #include <string> |
| 187 | #include <version> | |
| 187 | 188 | |
| 188 | 189 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 189 | 190 | #pragma GCC system_header |
lib/libcxx/include/stack+53-11| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- stack -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -41,11 +41,14 @@ public: |
| 41 | 41 | |
| 42 | 42 | explicit stack(const container_type& c); |
| 43 | 43 | explicit stack(container_type&& c); |
| 44 | template <class InputIterator> stack(InputIterator first, InputIterator last); // since C++23 | |
| 44 | 45 | template <class Alloc> explicit stack(const Alloc& a); |
| 45 | 46 | template <class Alloc> stack(const container_type& c, const Alloc& a); |
| 46 | 47 | template <class Alloc> stack(container_type&& c, const Alloc& a); |
| 47 | 48 | template <class Alloc> stack(const stack& c, const Alloc& a); |
| 48 | 49 | template <class Alloc> stack(stack&& c, const Alloc& a); |
| 50 | template<class InputIterator, class Alloc> | |
| 51 | stack(InputIterator first, InputIterator last, const Alloc&); // since C++23 | |
| 49 | 52 | |
| 50 | 53 | bool empty() const; |
| 51 | 54 | size_type size() const; |
| ... | ... | @@ -63,9 +66,17 @@ public: |
| 63 | 66 | template<class Container> |
| 64 | 67 | stack(Container) -> stack<typename Container::value_type, Container>; // C++17 |
| 65 | 68 | |
| 69 | template<class InputIterator> | |
| 70 | stack(InputIterator, InputIterator) -> stack<iter-value-type<InputIterator>>; // since C++23 | |
| 71 | ||
| 66 | 72 | template<class Container, class Allocator> |
| 67 | 73 | stack(Container, Allocator) -> stack<typename Container::value_type, Container>; // C++17 |
| 68 | 74 | |
| 75 | template<class InputIterator, class Allocator> | |
| 76 | stack(InputIterator, InputIterator, Allocator) | |
| 77 | -> stack<iter-value-type<InputIterator>, | |
| 78 | deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 | |
| 79 | ||
| 69 | 80 | template <class T, class Container> |
| 70 | 81 | bool operator==(const stack<T, Container>& x, const stack<T, Container>& y); |
| 71 | 82 | template <class T, class Container> |
| ... | ... | @@ -88,9 +99,12 @@ template <class T, class Container> |
| 88 | 99 | */ |
| 89 | 100 | |
| 90 | 101 | #include <__config> |
| 102 | #include <__iterator/iterator_traits.h> | |
| 91 | 103 | #include <__memory/uses_allocator.h> |
| 92 | 104 | #include <__utility/forward.h> |
| 93 | 105 | #include <deque> |
| 106 | #include <type_traits> | |
| 107 | #include <version> | |
| 94 | 108 | |
| 95 | 109 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 96 | 110 | #pragma GCC system_header |
| ... | ... | @@ -158,31 +172,45 @@ public: |
| 158 | 172 | template <class _Alloc> |
| 159 | 173 | _LIBCPP_INLINE_VISIBILITY |
| 160 | 174 | explicit stack(const _Alloc& __a, |
| 161 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 175 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 162 | 176 | : c(__a) {} |
| 163 | 177 | template <class _Alloc> |
| 164 | 178 | _LIBCPP_INLINE_VISIBILITY |
| 165 | 179 | stack(const container_type& __c, const _Alloc& __a, |
| 166 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 180 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 167 | 181 | : c(__c, __a) {} |
| 168 | 182 | template <class _Alloc> |
| 169 | 183 | _LIBCPP_INLINE_VISIBILITY |
| 170 | 184 | stack(const stack& __s, const _Alloc& __a, |
| 171 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 185 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 172 | 186 | : c(__s.c, __a) {} |
| 173 | 187 | #ifndef _LIBCPP_CXX03_LANG |
| 174 | 188 | template <class _Alloc> |
| 175 | 189 | _LIBCPP_INLINE_VISIBILITY |
| 176 | 190 | stack(container_type&& __c, const _Alloc& __a, |
| 177 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 191 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 178 | 192 | : c(_VSTD::move(__c), __a) {} |
| 179 | 193 | template <class _Alloc> |
| 180 | 194 | _LIBCPP_INLINE_VISIBILITY |
| 181 | 195 | stack(stack&& __s, const _Alloc& __a, |
| 182 | _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 196 | __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0) | |
| 183 | 197 | : c(_VSTD::move(__s.c), __a) {} |
| 184 | 198 | #endif // _LIBCPP_CXX03_LANG |
| 185 | 199 | |
| 200 | #if _LIBCPP_STD_VER > 20 | |
| 201 | template <class _InputIterator, | |
| 202 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> | |
| 203 | _LIBCPP_HIDE_FROM_ABI | |
| 204 | stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {} | |
| 205 | ||
| 206 | template <class _InputIterator, | |
| 207 | class _Alloc, | |
| 208 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 209 | class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>> | |
| 210 | _LIBCPP_HIDE_FROM_ABI | |
| 211 | stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc) : c(__first, __last, __alloc) {} | |
| 212 | #endif | |
| 213 | ||
| 186 | 214 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 187 | 215 | bool empty() const {return c.empty();} |
| 188 | 216 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -231,22 +259,36 @@ public: |
| 231 | 259 | operator< (const stack<T1, _C1>& __x, const stack<T1, _C1>& __y); |
| 232 | 260 | }; |
| 233 | 261 | |
| 234 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 262 | #if _LIBCPP_STD_VER > 14 | |
| 235 | 263 | template<class _Container, |
| 236 | class = _EnableIf<!__is_allocator<_Container>::value> | |
| 264 | class = enable_if_t<!__is_allocator<_Container>::value> | |
| 237 | 265 | > |
| 238 | 266 | stack(_Container) |
| 239 | 267 | -> stack<typename _Container::value_type, _Container>; |
| 240 | 268 | |
| 241 | 269 | template<class _Container, |
| 242 | 270 | class _Alloc, |
| 243 | class = _EnableIf<!__is_allocator<_Container>::value>, | |
| 244 | class = _EnableIf<uses_allocator<_Container, _Alloc>::value> | |
| 271 | class = enable_if_t<!__is_allocator<_Container>::value>, | |
| 272 | class = enable_if_t<uses_allocator<_Container, _Alloc>::value> | |
| 245 | 273 | > |
| 246 | 274 | stack(_Container, _Alloc) |
| 247 | 275 | -> stack<typename _Container::value_type, _Container>; |
| 248 | 276 | #endif |
| 249 | 277 | |
| 278 | #if _LIBCPP_STD_VER > 20 | |
| 279 | template<class _InputIterator, | |
| 280 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>> | |
| 281 | stack(_InputIterator, _InputIterator) | |
| 282 | -> stack<__iter_value_type<_InputIterator>>; | |
| 283 | ||
| 284 | template<class _InputIterator, | |
| 285 | class _Alloc, | |
| 286 | class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 287 | class = __enable_if_t<__is_allocator<_Alloc>::value>> | |
| 288 | stack(_InputIterator, _InputIterator, _Alloc) | |
| 289 | -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>; | |
| 290 | #endif | |
| 291 | ||
| 250 | 292 | template <class _Tp, class _Container> |
| 251 | 293 | inline _LIBCPP_INLINE_VISIBILITY |
| 252 | 294 | bool |
| ... | ... | @@ -297,7 +339,7 @@ operator<=(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) |
| 297 | 339 | |
| 298 | 340 | template <class _Tp, class _Container> |
| 299 | 341 | inline _LIBCPP_INLINE_VISIBILITY |
| 300 | _EnableIf<__is_swappable<_Container>::value, void> | |
| 342 | __enable_if_t<__is_swappable<_Container>::value, void> | |
| 301 | 343 | swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) |
| 302 | 344 | _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) |
| 303 | 345 | { |
lib/libcxx/include/stdbool.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- stdbool.h --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/stddef.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- stddef.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/stdexcept+3-3| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- stdexcept --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -42,9 +42,9 @@ public: |
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | 44 | #include <__config> |
| 45 | #include <cstdlib> | |
| 45 | 46 | #include <exception> |
| 46 | 47 | #include <iosfwd> // for string forward decl |
| 47 | #include <cstdlib> | |
| 48 | 48 | |
| 49 | 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 50 | 50 | #pragma GCC system_header |
| ... | ... | @@ -209,7 +209,7 @@ public: |
| 209 | 209 | #endif |
| 210 | 210 | }; |
| 211 | 211 | |
| 212 | } // std | |
| 212 | } // namespace std | |
| 213 | 213 | |
| 214 | 214 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 215 | 215 |
lib/libcxx/include/stdint.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- stdint.h --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/stdio.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- stdio.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/stdlib.h+19-13| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- stdlib.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -96,10 +96,14 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 96 | 96 | extern "C++" { |
| 97 | 97 | // abs |
| 98 | 98 | |
| 99 | #undef abs | |
| 100 | #undef labs | |
| 101 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 102 | #undef llabs | |
| 99 | #ifdef abs | |
| 100 | # undef abs | |
| 101 | #endif | |
| 102 | #ifdef labs | |
| 103 | # undef labs | |
| 104 | #endif | |
| 105 | #ifdef llabs | |
| 106 | # undef llabs | |
| 103 | 107 | #endif |
| 104 | 108 | |
| 105 | 109 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined |
| ... | ... | @@ -107,11 +111,9 @@ extern "C++" { |
| 107 | 111 | inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT { |
| 108 | 112 | return __builtin_labs(__x); |
| 109 | 113 | } |
| 110 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 111 | 114 | inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT { |
| 112 | 115 | return __builtin_llabs(__x); |
| 113 | 116 | } |
| 114 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 115 | 117 | #endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) |
| 116 | 118 | |
| 117 | 119 | #if !defined(__sun__) |
| ... | ... | @@ -131,10 +133,14 @@ abs(long double __lcpp_x) _NOEXCEPT { |
| 131 | 133 | |
| 132 | 134 | // div |
| 133 | 135 | |
| 134 | #undef div | |
| 135 | #undef ldiv | |
| 136 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 137 | #undef lldiv | |
| 136 | #ifdef div | |
| 137 | # undef div | |
| 138 | #endif | |
| 139 | #ifdef ldiv | |
| 140 | # undef ldiv | |
| 141 | #endif | |
| 142 | #ifdef lldiv | |
| 143 | # undef lldiv | |
| 138 | 144 | #endif |
| 139 | 145 | |
| 140 | 146 | // MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined |
| ... | ... | @@ -142,12 +148,12 @@ abs(long double __lcpp_x) _NOEXCEPT { |
| 142 | 148 | inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT { |
| 143 | 149 | return ::ldiv(__x, __y); |
| 144 | 150 | } |
| 145 | #ifndef _LIBCPP_HAS_NO_LONG_LONG | |
| 151 | #if !(defined(__FreeBSD__) && !defined(__LONG_LONG_SUPPORTED)) | |
| 146 | 152 | inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, |
| 147 | 153 | long long __y) _NOEXCEPT { |
| 148 | 154 | return ::lldiv(__x, __y); |
| 149 | 155 | } |
| 150 | #endif // _LIBCPP_HAS_NO_LONG_LONG | |
| 156 | #endif | |
| 151 | 157 | #endif // _LIBCPP_MSVCRT / __sun__ |
| 152 | 158 | } // extern "C++" |
| 153 | 159 | #endif // __cplusplus |
lib/libcxx/include/streambuf+3-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------- streambuf ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -108,8 +108,10 @@ protected: |
| 108 | 108 | */ |
| 109 | 109 | |
| 110 | 110 | #include <__config> |
| 111 | #include <cstdint> | |
| 111 | 112 | #include <ios> |
| 112 | 113 | #include <iosfwd> |
| 114 | #include <version> | |
| 113 | 115 | |
| 114 | 116 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 115 | 117 | #pragma GCC system_header |
lib/libcxx/include/string+271-343| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- string -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -158,6 +158,9 @@ public: |
| 158 | 158 | void resize(size_type n, value_type c); |
| 159 | 159 | void resize(size_type n); |
| 160 | 160 | |
| 161 | template<class Operation> | |
| 162 | constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23 | |
| 163 | ||
| 161 | 164 | void reserve(size_type res_arg); |
| 162 | 165 | void reserve(); // deprecated in C++20 |
| 163 | 166 | void shrink_to_fit(); |
| ... | ... | @@ -524,7 +527,6 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1 |
| 524 | 527 | #include <cstdio> // EOF |
| 525 | 528 | #include <cstdlib> |
| 526 | 529 | #include <cstring> |
| 527 | #include <cwchar> | |
| 528 | 530 | #include <initializer_list> |
| 529 | 531 | #include <iosfwd> |
| 530 | 532 | #include <iterator> |
| ... | ... | @@ -535,6 +537,10 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1 |
| 535 | 537 | #include <utility> |
| 536 | 538 | #include <version> |
| 537 | 539 | |
| 540 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 541 | # include <cwchar> | |
| 542 | #endif | |
| 543 | ||
| 538 | 544 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 539 | 545 | # include <cstdint> |
| 540 | 546 | #endif |
| ... | ... | @@ -612,30 +618,6 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); |
| 612 | 618 | |
| 613 | 619 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) |
| 614 | 620 | |
| 615 | template <bool> | |
| 616 | class _LIBCPP_TEMPLATE_VIS __basic_string_common | |
| 617 | { | |
| 618 | protected: | |
| 619 | _LIBCPP_NORETURN void __throw_length_error() const; | |
| 620 | _LIBCPP_NORETURN void __throw_out_of_range() const; | |
| 621 | }; | |
| 622 | ||
| 623 | template <bool __b> | |
| 624 | void | |
| 625 | __basic_string_common<__b>::__throw_length_error() const | |
| 626 | { | |
| 627 | _VSTD::__throw_length_error("basic_string"); | |
| 628 | } | |
| 629 | ||
| 630 | template <bool __b> | |
| 631 | void | |
| 632 | __basic_string_common<__b>::__throw_out_of_range() const | |
| 633 | { | |
| 634 | _VSTD::__throw_out_of_range("basic_string"); | |
| 635 | } | |
| 636 | ||
| 637 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __basic_string_common<true>) | |
| 638 | ||
| 639 | 621 | template <class _Iter> |
| 640 | 622 | struct __string_is_trivial_iterator : public false_type {}; |
| 641 | 623 | |
| ... | ... | @@ -675,7 +657,7 @@ typedef basic_string<char8_t> u8string; |
| 675 | 657 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS |
| 676 | 658 | typedef basic_string<char16_t> u16string; |
| 677 | 659 | typedef basic_string<char32_t> u32string; |
| 678 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 660 | #endif | |
| 679 | 661 | |
| 680 | 662 | template<class _CharT, class _Traits, class _Allocator> |
| 681 | 663 | class |
| ... | ... | @@ -688,7 +670,6 @@ class |
| 688 | 670 | _LIBCPP_PREFERRED_NAME(u32string) |
| 689 | 671 | #endif |
| 690 | 672 | basic_string |
| 691 | : private __basic_string_common<true> | |
| 692 | 673 | { |
| 693 | 674 | public: |
| 694 | 675 | typedef basic_string __self; |
| ... | ... | @@ -832,17 +813,15 @@ public: |
| 832 | 813 | basic_string(basic_string&& __str, const allocator_type& __a); |
| 833 | 814 | #endif // _LIBCPP_CXX03_LANG |
| 834 | 815 | |
| 835 | template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> > | |
| 816 | template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> > | |
| 836 | 817 | _LIBCPP_INLINE_VISIBILITY |
| 837 | 818 | basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) { |
| 838 | 819 | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); |
| 839 | 820 | __init(__s, traits_type::length(__s)); |
| 840 | # if _LIBCPP_DEBUG_LEVEL == 2 | |
| 841 | __get_db()->__insert_c(this); | |
| 842 | # endif | |
| 821 | _VSTD::__debug_db_insert_c(this); | |
| 843 | 822 | } |
| 844 | 823 | |
| 845 | template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> > | |
| 824 | template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> > | |
| 846 | 825 | _LIBCPP_INLINE_VISIBILITY |
| 847 | 826 | basic_string(const _CharT* __s, const _Allocator& __a); |
| 848 | 827 | |
| ... | ... | @@ -857,7 +836,7 @@ public: |
| 857 | 836 | _LIBCPP_INLINE_VISIBILITY |
| 858 | 837 | basic_string(size_type __n, _CharT __c); |
| 859 | 838 | |
| 860 | template <class = _EnableIf<__is_allocator<_Allocator>::value, nullptr_t> > | |
| 839 | template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> > | |
| 861 | 840 | _LIBCPP_INLINE_VISIBILITY |
| 862 | 841 | basic_string(size_type __n, _CharT __c, const _Allocator& __a); |
| 863 | 842 | |
| ... | ... | @@ -867,24 +846,24 @@ public: |
| 867 | 846 | basic_string(const basic_string& __str, size_type __pos, |
| 868 | 847 | const _Allocator& __a = _Allocator()); |
| 869 | 848 | |
| 870 | template<class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > | |
| 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> > | |
| 871 | 850 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 872 | 851 | basic_string(const _Tp& __t, size_type __pos, size_type __n, |
| 873 | 852 | const allocator_type& __a = allocator_type()); |
| 874 | 853 | |
| 875 | template<class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | |
| 854 | template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | |
| 876 | 855 | !__is_same_uncvref<_Tp, basic_string>::value> > |
| 877 | 856 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 878 | 857 | explicit basic_string(const _Tp& __t); |
| 879 | 858 | |
| 880 | template<class _Tp, class = _EnableIf<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > | |
| 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> > | |
| 881 | 860 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 882 | 861 | explicit basic_string(const _Tp& __t, const allocator_type& __a); |
| 883 | 862 | |
| 884 | template<class _InputIterator, class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value> > | |
| 863 | template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> > | |
| 885 | 864 | _LIBCPP_INLINE_VISIBILITY |
| 886 | 865 | basic_string(_InputIterator __first, _InputIterator __last); |
| 887 | template<class _InputIterator, class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value> > | |
| 866 | template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> > | |
| 888 | 867 | _LIBCPP_INLINE_VISIBILITY |
| 889 | 868 | basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); |
| 890 | 869 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -901,7 +880,7 @@ public: |
| 901 | 880 | |
| 902 | 881 | basic_string& operator=(const basic_string& __str); |
| 903 | 882 | |
| 904 | template <class _Tp, class = _EnableIf<__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> > | |
| 905 | 884 | basic_string& operator=(const _Tp& __t) |
| 906 | 885 | {__self_view __sv = __t; return assign(__sv);} |
| 907 | 886 | |
| ... | ... | @@ -983,6 +962,16 @@ public: |
| 983 | 962 | _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} |
| 984 | 963 | |
| 985 | 964 | void reserve(size_type __requested_capacity); |
| 965 | ||
| 966 | #if _LIBCPP_STD_VER > 20 | |
| 967 | template <class _Op> | |
| 968 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 969 | void resize_and_overwrite(size_type __n, _Op __op) { | |
| 970 | __resize_default_init(__n); | |
| 971 | __erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); | |
| 972 | } | |
| 973 | #endif | |
| 974 | ||
| 986 | 975 | _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n); |
| 987 | 976 | |
| 988 | 977 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1004,7 +993,7 @@ public: |
| 1004 | 993 | |
| 1005 | 994 | template <class _Tp> |
| 1006 | 995 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1007 | _EnableIf | |
| 996 | __enable_if_t | |
| 1008 | 997 | < |
| 1009 | 998 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1010 | 999 | && !__is_same_uncvref<_Tp, basic_string >::value, |
| ... | ... | @@ -1022,7 +1011,7 @@ public: |
| 1022 | 1011 | |
| 1023 | 1012 | template <class _Tp> |
| 1024 | 1013 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1025 | _EnableIf< | |
| 1014 | __enable_if_t< | |
| 1026 | 1015 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1027 | 1016 | && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1028 | 1017 | basic_string& |
| ... | ... | @@ -1032,7 +1021,7 @@ public: |
| 1032 | 1021 | |
| 1033 | 1022 | template <class _Tp> |
| 1034 | 1023 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1035 | _EnableIf | |
| 1024 | __enable_if_t | |
| 1036 | 1025 | < |
| 1037 | 1026 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1038 | 1027 | && !__is_same_uncvref<_Tp, basic_string>::value, |
| ... | ... | @@ -1048,7 +1037,7 @@ public: |
| 1048 | 1037 | |
| 1049 | 1038 | template<class _InputIterator> |
| 1050 | 1039 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1051 | _EnableIf | |
| 1040 | __enable_if_t | |
| 1052 | 1041 | < |
| 1053 | 1042 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| 1054 | 1043 | basic_string& |
| ... | ... | @@ -1061,7 +1050,7 @@ public: |
| 1061 | 1050 | } |
| 1062 | 1051 | template<class _ForwardIterator> |
| 1063 | 1052 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1064 | _EnableIf | |
| 1053 | __enable_if_t | |
| 1065 | 1054 | < |
| 1066 | 1055 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 1067 | 1056 | basic_string& |
| ... | ... | @@ -1084,7 +1073,7 @@ public: |
| 1084 | 1073 | |
| 1085 | 1074 | template <class _Tp> |
| 1086 | 1075 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1087 | _EnableIf | |
| 1076 | __enable_if_t | |
| 1088 | 1077 | < |
| 1089 | 1078 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1090 | 1079 | basic_string& |
| ... | ... | @@ -1101,7 +1090,7 @@ public: |
| 1101 | 1090 | basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); |
| 1102 | 1091 | template <class _Tp> |
| 1103 | 1092 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1104 | _EnableIf | |
| 1093 | __enable_if_t | |
| 1105 | 1094 | < |
| 1106 | 1095 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1107 | 1096 | && !__is_same_uncvref<_Tp, basic_string>::value, |
| ... | ... | @@ -1113,7 +1102,7 @@ public: |
| 1113 | 1102 | basic_string& assign(size_type __n, value_type __c); |
| 1114 | 1103 | template<class _InputIterator> |
| 1115 | 1104 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1116 | _EnableIf | |
| 1105 | __enable_if_t | |
| 1117 | 1106 | < |
| 1118 | 1107 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| 1119 | 1108 | basic_string& |
| ... | ... | @@ -1121,7 +1110,7 @@ public: |
| 1121 | 1110 | assign(_InputIterator __first, _InputIterator __last); |
| 1122 | 1111 | template<class _ForwardIterator> |
| 1123 | 1112 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1124 | _EnableIf | |
| 1113 | __enable_if_t | |
| 1125 | 1114 | < |
| 1126 | 1115 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 1127 | 1116 | basic_string& |
| ... | ... | @@ -1137,7 +1126,7 @@ public: |
| 1137 | 1126 | |
| 1138 | 1127 | template <class _Tp> |
| 1139 | 1128 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1140 | _EnableIf | |
| 1129 | __enable_if_t | |
| 1141 | 1130 | < |
| 1142 | 1131 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1143 | 1132 | basic_string& |
| ... | ... | @@ -1147,7 +1136,7 @@ public: |
| 1147 | 1136 | |
| 1148 | 1137 | template <class _Tp> |
| 1149 | 1138 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1150 | _EnableIf | |
| 1139 | __enable_if_t | |
| 1151 | 1140 | < |
| 1152 | 1141 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1153 | 1142 | basic_string& |
| ... | ... | @@ -1162,7 +1151,7 @@ public: |
| 1162 | 1151 | iterator insert(const_iterator __pos, size_type __n, value_type __c); |
| 1163 | 1152 | template<class _InputIterator> |
| 1164 | 1153 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1165 | _EnableIf | |
| 1154 | __enable_if_t | |
| 1166 | 1155 | < |
| 1167 | 1156 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| 1168 | 1157 | iterator |
| ... | ... | @@ -1170,7 +1159,7 @@ public: |
| 1170 | 1159 | insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); |
| 1171 | 1160 | template<class _ForwardIterator> |
| 1172 | 1161 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1173 | _EnableIf | |
| 1162 | __enable_if_t | |
| 1174 | 1163 | < |
| 1175 | 1164 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 1176 | 1165 | iterator |
| ... | ... | @@ -1193,7 +1182,7 @@ public: |
| 1193 | 1182 | |
| 1194 | 1183 | template <class _Tp> |
| 1195 | 1184 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1196 | _EnableIf | |
| 1185 | __enable_if_t | |
| 1197 | 1186 | < |
| 1198 | 1187 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1199 | 1188 | basic_string& |
| ... | ... | @@ -1202,7 +1191,7 @@ public: |
| 1202 | 1191 | basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); |
| 1203 | 1192 | template <class _Tp> |
| 1204 | 1193 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1205 | _EnableIf | |
| 1194 | __enable_if_t | |
| 1206 | 1195 | < |
| 1207 | 1196 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1208 | 1197 | basic_string& |
| ... | ... | @@ -1216,7 +1205,7 @@ public: |
| 1216 | 1205 | |
| 1217 | 1206 | template <class _Tp> |
| 1218 | 1207 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1219 | _EnableIf | |
| 1208 | __enable_if_t | |
| 1220 | 1209 | < |
| 1221 | 1210 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1222 | 1211 | basic_string& |
| ... | ... | @@ -1231,7 +1220,7 @@ public: |
| 1231 | 1220 | basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); |
| 1232 | 1221 | template<class _InputIterator> |
| 1233 | 1222 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1234 | _EnableIf | |
| 1223 | __enable_if_t | |
| 1235 | 1224 | < |
| 1236 | 1225 | __is_cpp17_input_iterator<_InputIterator>::value, |
| 1237 | 1226 | basic_string& |
| ... | ... | @@ -1273,7 +1262,7 @@ public: |
| 1273 | 1262 | |
| 1274 | 1263 | template <class _Tp> |
| 1275 | 1264 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1276 | _EnableIf | |
| 1265 | __enable_if_t | |
| 1277 | 1266 | < |
| 1278 | 1267 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1279 | 1268 | size_type |
| ... | ... | @@ -1289,7 +1278,7 @@ public: |
| 1289 | 1278 | |
| 1290 | 1279 | template <class _Tp> |
| 1291 | 1280 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1292 | _EnableIf | |
| 1281 | __enable_if_t | |
| 1293 | 1282 | < |
| 1294 | 1283 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1295 | 1284 | size_type |
| ... | ... | @@ -1305,7 +1294,7 @@ public: |
| 1305 | 1294 | |
| 1306 | 1295 | template <class _Tp> |
| 1307 | 1296 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1308 | _EnableIf | |
| 1297 | __enable_if_t | |
| 1309 | 1298 | < |
| 1310 | 1299 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1311 | 1300 | size_type |
| ... | ... | @@ -1322,7 +1311,7 @@ public: |
| 1322 | 1311 | |
| 1323 | 1312 | template <class _Tp> |
| 1324 | 1313 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1325 | _EnableIf | |
| 1314 | __enable_if_t | |
| 1326 | 1315 | < |
| 1327 | 1316 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1328 | 1317 | size_type |
| ... | ... | @@ -1339,7 +1328,7 @@ public: |
| 1339 | 1328 | |
| 1340 | 1329 | template <class _Tp> |
| 1341 | 1330 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1342 | _EnableIf | |
| 1331 | __enable_if_t | |
| 1343 | 1332 | < |
| 1344 | 1333 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1345 | 1334 | size_type |
| ... | ... | @@ -1356,7 +1345,7 @@ public: |
| 1356 | 1345 | |
| 1357 | 1346 | template <class _Tp> |
| 1358 | 1347 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1359 | _EnableIf | |
| 1348 | __enable_if_t | |
| 1360 | 1349 | < |
| 1361 | 1350 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1362 | 1351 | size_type |
| ... | ... | @@ -1373,7 +1362,7 @@ public: |
| 1373 | 1362 | |
| 1374 | 1363 | template <class _Tp> |
| 1375 | 1364 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1376 | _EnableIf | |
| 1365 | __enable_if_t | |
| 1377 | 1366 | < |
| 1378 | 1367 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1379 | 1368 | int |
| ... | ... | @@ -1382,7 +1371,7 @@ public: |
| 1382 | 1371 | |
| 1383 | 1372 | template <class _Tp> |
| 1384 | 1373 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 1385 | _EnableIf | |
| 1374 | __enable_if_t | |
| 1386 | 1375 | < |
| 1387 | 1376 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1388 | 1377 | int |
| ... | ... | @@ -1395,7 +1384,7 @@ public: |
| 1395 | 1384 | |
| 1396 | 1385 | template <class _Tp> |
| 1397 | 1386 | inline _LIBCPP_INLINE_VISIBILITY |
| 1398 | _EnableIf | |
| 1387 | __enable_if_t | |
| 1399 | 1388 | < |
| 1400 | 1389 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1401 | 1390 | int |
| ... | ... | @@ -1406,28 +1395,28 @@ public: |
| 1406 | 1395 | int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; |
| 1407 | 1396 | |
| 1408 | 1397 | #if _LIBCPP_STD_VER > 17 |
| 1409 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1410 | bool starts_with(__self_view __sv) const _NOEXCEPT | |
| 1398 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1399 | bool starts_with(__self_view __sv) const noexcept | |
| 1411 | 1400 | { return __self_view(data(), size()).starts_with(__sv); } |
| 1412 | 1401 | |
| 1413 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1414 | bool starts_with(value_type __c) const _NOEXCEPT | |
| 1402 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1403 | bool starts_with(value_type __c) const noexcept | |
| 1415 | 1404 | { return !empty() && _Traits::eq(front(), __c); } |
| 1416 | 1405 | |
| 1417 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1418 | bool starts_with(const value_type* __s) const _NOEXCEPT | |
| 1406 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1407 | bool starts_with(const value_type* __s) const noexcept | |
| 1419 | 1408 | { return starts_with(__self_view(__s)); } |
| 1420 | 1409 | |
| 1421 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1422 | bool ends_with(__self_view __sv) const _NOEXCEPT | |
| 1410 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1411 | bool ends_with(__self_view __sv) const noexcept | |
| 1423 | 1412 | { return __self_view(data(), size()).ends_with( __sv); } |
| 1424 | 1413 | |
| 1425 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1426 | bool ends_with(value_type __c) const _NOEXCEPT | |
| 1414 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1415 | bool ends_with(value_type __c) const noexcept | |
| 1427 | 1416 | { return !empty() && _Traits::eq(back(), __c); } |
| 1428 | 1417 | |
| 1429 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1430 | bool ends_with(const value_type* __s) const _NOEXCEPT | |
| 1418 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1419 | bool ends_with(const value_type* __s) const noexcept | |
| 1431 | 1420 | { return ends_with(__self_view(__s)); } |
| 1432 | 1421 | #endif |
| 1433 | 1422 | |
| ... | ... | @@ -1465,6 +1454,11 @@ public: |
| 1465 | 1454 | #endif // _LIBCPP_DEBUG_LEVEL == 2 |
| 1466 | 1455 | |
| 1467 | 1456 | private: |
| 1457 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { | |
| 1458 | // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly | |
| 1459 | return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); | |
| 1460 | } | |
| 1461 | ||
| 1468 | 1462 | _LIBCPP_INLINE_VISIBILITY |
| 1469 | 1463 | allocator_type& __alloc() _NOEXCEPT |
| 1470 | 1464 | {return __r_.second();} |
| ... | ... | @@ -1591,7 +1585,7 @@ private: |
| 1591 | 1585 | |
| 1592 | 1586 | template <class _InputIterator> |
| 1593 | 1587 | inline |
| 1594 | _EnableIf | |
| 1588 | __enable_if_t | |
| 1595 | 1589 | < |
| 1596 | 1590 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 1597 | 1591 | > |
| ... | ... | @@ -1599,7 +1593,7 @@ private: |
| 1599 | 1593 | |
| 1600 | 1594 | template <class _ForwardIterator> |
| 1601 | 1595 | inline |
| 1602 | _EnableIf | |
| 1596 | __enable_if_t | |
| 1603 | 1597 | < |
| 1604 | 1598 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 1605 | 1599 | > |
| ... | ... | @@ -1705,6 +1699,13 @@ private: |
| 1705 | 1699 | return *this; |
| 1706 | 1700 | } |
| 1707 | 1701 | |
| 1702 | _LIBCPP_HIDE_FROM_ABI basic_string& __null_terminate_at(value_type* __p, size_type __newsz) { | |
| 1703 | __set_size(__newsz); | |
| 1704 | __invalidate_iterators_past(__newsz); | |
| 1705 | traits_type::assign(__p[__newsz], value_type()); | |
| 1706 | return *this; | |
| 1707 | } | |
| 1708 | ||
| 1708 | 1709 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); |
| 1709 | 1710 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); |
| 1710 | 1711 | |
| ... | ... | @@ -1717,20 +1718,12 @@ private: |
| 1717 | 1718 | |
| 1718 | 1719 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI |
| 1719 | 1720 | void __throw_length_error() const { |
| 1720 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 1721 | __basic_string_common<true>::__throw_length_error(); | |
| 1722 | #else | |
| 1723 | _VSTD::abort(); | |
| 1724 | #endif | |
| 1721 | _VSTD::__throw_length_error("basic_string"); | |
| 1725 | 1722 | } |
| 1726 | 1723 | |
| 1727 | 1724 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI |
| 1728 | 1725 | void __throw_out_of_range() const { |
| 1729 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 1730 | __basic_string_common<true>::__throw_out_of_range(); | |
| 1731 | #else | |
| 1732 | _VSTD::abort(); | |
| 1733 | #endif | |
| 1726 | _VSTD::__throw_out_of_range("basic_string"); | |
| 1734 | 1727 | } |
| 1735 | 1728 | |
| 1736 | 1729 | friend basic_string operator+<>(const basic_string&, const basic_string&); |
| ... | ... | @@ -1743,20 +1736,24 @@ private: |
| 1743 | 1736 | // These declarations must appear before any functions are implicitly used |
| 1744 | 1737 | // so that they have the correct visibility specifier. |
| 1745 | 1738 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 1746 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | |
| 1747 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | |
| 1739 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | |
| 1740 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1741 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | |
| 1742 | # endif | |
| 1748 | 1743 | #else |
| 1749 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | |
| 1750 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | |
| 1744 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | |
| 1745 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1746 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | |
| 1747 | # endif | |
| 1751 | 1748 | #endif |
| 1752 | 1749 | |
| 1753 | 1750 | |
| 1754 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1751 | #if _LIBCPP_STD_VER >= 17 | |
| 1755 | 1752 | template<class _InputIterator, |
| 1756 | 1753 | class _CharT = __iter_value_type<_InputIterator>, |
| 1757 | 1754 | class _Allocator = allocator<_CharT>, |
| 1758 | class = _EnableIf<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1759 | class = _EnableIf<__is_allocator<_Allocator>::value> | |
| 1755 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1756 | class = enable_if_t<__is_allocator<_Allocator>::value> | |
| 1760 | 1757 | > |
| 1761 | 1758 | basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 1762 | 1759 | -> basic_string<_CharT, char_traits<_CharT>, _Allocator>; |
| ... | ... | @@ -1764,7 +1761,7 @@ basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator()) |
| 1764 | 1761 | template<class _CharT, |
| 1765 | 1762 | class _Traits, |
| 1766 | 1763 | class _Allocator = allocator<_CharT>, |
| 1767 | class = _EnableIf<__is_allocator<_Allocator>::value> | |
| 1764 | class = enable_if_t<__is_allocator<_Allocator>::value> | |
| 1768 | 1765 | > |
| 1769 | 1766 | explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator()) |
| 1770 | 1767 | -> basic_string<_CharT, _Traits, _Allocator>; |
| ... | ... | @@ -1772,7 +1769,7 @@ explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _A |
| 1772 | 1769 | template<class _CharT, |
| 1773 | 1770 | class _Traits, |
| 1774 | 1771 | class _Allocator = allocator<_CharT>, |
| 1775 | class = _EnableIf<__is_allocator<_Allocator>::value>, | |
| 1772 | class = enable_if_t<__is_allocator<_Allocator>::value>, | |
| 1776 | 1773 | class _Sz = typename allocator_traits<_Allocator>::size_type |
| 1777 | 1774 | > |
| 1778 | 1775 | basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _Allocator()) |
| ... | ... | @@ -1785,7 +1782,8 @@ void |
| 1785 | 1782 | basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() |
| 1786 | 1783 | { |
| 1787 | 1784 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1788 | __get_db()->__invalidate_all(this); | |
| 1785 | if (!__libcpp_is_constant_evaluated()) | |
| 1786 | __get_db()->__invalidate_all(this); | |
| 1789 | 1787 | #endif |
| 1790 | 1788 | } |
| 1791 | 1789 | |
| ... | ... | @@ -1795,22 +1793,24 @@ void |
| 1795 | 1793 | basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos) |
| 1796 | 1794 | { |
| 1797 | 1795 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1798 | __c_node* __c = __get_db()->__find_c_and_lock(this); | |
| 1799 | if (__c) | |
| 1800 | { | |
| 1801 | const_pointer __new_last = __get_pointer() + __pos; | |
| 1802 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) | |
| 1796 | if (!__libcpp_is_constant_evaluated()) { | |
| 1797 | __c_node* __c = __get_db()->__find_c_and_lock(this); | |
| 1798 | if (__c) | |
| 1803 | 1799 | { |
| 1804 | --__p; | |
| 1805 | const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); | |
| 1806 | if (__i->base() > __new_last) | |
| 1800 | const_pointer __new_last = __get_pointer() + __pos; | |
| 1801 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) | |
| 1807 | 1802 | { |
| 1808 | (*__p)->__c_ = nullptr; | |
| 1809 | if (--__c->end_ != __p) | |
| 1810 | _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | |
| 1803 | --__p; | |
| 1804 | const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); | |
| 1805 | if (__i->base() > __new_last) | |
| 1806 | { | |
| 1807 | (*__p)->__c_ = nullptr; | |
| 1808 | if (--__c->end_ != __p) | |
| 1809 | _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | |
| 1810 | } | |
| 1811 | 1811 | } |
| 1812 | __get_db()->unlock(); | |
| 1812 | 1813 | } |
| 1813 | __get_db()->unlock(); | |
| 1814 | 1814 | } |
| 1815 | 1815 | #else |
| 1816 | 1816 | (void)__pos; |
| ... | ... | @@ -1823,9 +1823,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string() |
| 1823 | 1823 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 1824 | 1824 | : __r_(__default_init_tag(), __default_init_tag()) |
| 1825 | 1825 | { |
| 1826 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1827 | __get_db()->__insert_c(this); | |
| 1828 | #endif | |
| 1826 | _VSTD::__debug_db_insert_c(this); | |
| 1829 | 1827 | __zero(); |
| 1830 | 1828 | } |
| 1831 | 1829 | |
| ... | ... | @@ -1839,9 +1837,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __ |
| 1839 | 1837 | #endif |
| 1840 | 1838 | : __r_(__default_init_tag(), __a) |
| 1841 | 1839 | { |
| 1842 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1843 | __get_db()->__insert_c(this); | |
| 1844 | #endif | |
| 1840 | _VSTD::__debug_db_insert_c(this); | |
| 1845 | 1841 | __zero(); |
| 1846 | 1842 | } |
| 1847 | 1843 | |
| ... | ... | @@ -1851,9 +1847,9 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, |
| 1851 | 1847 | size_type __reserve) |
| 1852 | 1848 | { |
| 1853 | 1849 | if (__reserve > max_size()) |
| 1854 | this->__throw_length_error(); | |
| 1850 | __throw_length_error(); | |
| 1855 | 1851 | pointer __p; |
| 1856 | if (__reserve < __min_cap) | |
| 1852 | if (__fits_in_sso(__reserve)) | |
| 1857 | 1853 | { |
| 1858 | 1854 | __set_short_size(__sz); |
| 1859 | 1855 | __p = __get_short_pointer(); |
| ... | ... | @@ -1875,9 +1871,9 @@ void |
| 1875 | 1871 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) |
| 1876 | 1872 | { |
| 1877 | 1873 | if (__sz > max_size()) |
| 1878 | this->__throw_length_error(); | |
| 1874 | __throw_length_error(); | |
| 1879 | 1875 | pointer __p; |
| 1880 | if (__sz < __min_cap) | |
| 1876 | if (__fits_in_sso(__sz)) | |
| 1881 | 1877 | { |
| 1882 | 1878 | __set_short_size(__sz); |
| 1883 | 1879 | __p = __get_short_pointer(); |
| ... | ... | @@ -1901,9 +1897,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const |
| 1901 | 1897 | { |
| 1902 | 1898 | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); |
| 1903 | 1899 | __init(__s, traits_type::length(__s)); |
| 1904 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1905 | __get_db()->__insert_c(this); | |
| 1906 | #endif | |
| 1900 | _VSTD::__debug_db_insert_c(this); | |
| 1907 | 1901 | } |
| 1908 | 1902 | |
| 1909 | 1903 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -1913,9 +1907,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_ |
| 1913 | 1907 | { |
| 1914 | 1908 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); |
| 1915 | 1909 | __init(__s, __n); |
| 1916 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1917 | __get_db()->__insert_c(this); | |
| 1918 | #endif | |
| 1910 | _VSTD::__debug_db_insert_c(this); | |
| 1919 | 1911 | } |
| 1920 | 1912 | |
| 1921 | 1913 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -1925,9 +1917,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_ |
| 1925 | 1917 | { |
| 1926 | 1918 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); |
| 1927 | 1919 | __init(__s, __n); |
| 1928 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1929 | __get_db()->__insert_c(this); | |
| 1930 | #endif | |
| 1920 | _VSTD::__debug_db_insert_c(this); | |
| 1931 | 1921 | } |
| 1932 | 1922 | |
| 1933 | 1923 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -1939,10 +1929,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st |
| 1939 | 1929 | else |
| 1940 | 1930 | __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), |
| 1941 | 1931 | __str.__get_long_size()); |
| 1942 | ||
| 1943 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1944 | __get_db()->__insert_c(this); | |
| 1945 | #endif | |
| 1932 | _VSTD::__debug_db_insert_c(this); | |
| 1946 | 1933 | } |
| 1947 | 1934 | |
| 1948 | 1935 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -1955,21 +1942,19 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 1955 | 1942 | else |
| 1956 | 1943 | __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), |
| 1957 | 1944 | __str.__get_long_size()); |
| 1958 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1959 | __get_db()->__insert_c(this); | |
| 1960 | #endif | |
| 1945 | _VSTD::__debug_db_insert_c(this); | |
| 1961 | 1946 | } |
| 1962 | 1947 | |
| 1963 | 1948 | template <class _CharT, class _Traits, class _Allocator> |
| 1964 | 1949 | void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( |
| 1965 | 1950 | const value_type* __s, size_type __sz) { |
| 1966 | 1951 | pointer __p; |
| 1967 | if (__sz < __min_cap) { | |
| 1952 | if (__fits_in_sso(__sz)) { | |
| 1968 | 1953 | __p = __get_short_pointer(); |
| 1969 | 1954 | __set_short_size(__sz); |
| 1970 | 1955 | } else { |
| 1971 | 1956 | if (__sz > max_size()) |
| 1972 | this->__throw_length_error(); | |
| 1957 | __throw_length_error(); | |
| 1973 | 1958 | size_t __cap = __recommend(__sz); |
| 1974 | 1959 | __p = __alloc_traits::allocate(__alloc(), __cap + 1); |
| 1975 | 1960 | __set_long_pointer(__p); |
| ... | ... | @@ -1992,9 +1977,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) |
| 1992 | 1977 | : __r_(_VSTD::move(__str.__r_)) |
| 1993 | 1978 | { |
| 1994 | 1979 | __str.__zero(); |
| 1980 | _VSTD::__debug_db_insert_c(this); | |
| 1995 | 1981 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1996 | __get_db()->__insert_c(this); | |
| 1997 | if (__is_long()) | |
| 1982 | if (!__libcpp_is_constant_evaluated() && __is_long()) | |
| 1998 | 1983 | __get_db()->swap(this, &__str); |
| 1999 | 1984 | #endif |
| 2000 | 1985 | } |
| ... | ... | @@ -2011,9 +1996,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co |
| 2011 | 1996 | __r_.first().__r = __str.__r_.first().__r; |
| 2012 | 1997 | __str.__zero(); |
| 2013 | 1998 | } |
| 1999 | _VSTD::__debug_db_insert_c(this); | |
| 2014 | 2000 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2015 | __get_db()->__insert_c(this); | |
| 2016 | if (__is_long()) | |
| 2001 | if (!__libcpp_is_constant_evaluated() && __is_long()) | |
| 2017 | 2002 | __get_db()->swap(this, &__str); |
| 2018 | 2003 | #endif |
| 2019 | 2004 | } |
| ... | ... | @@ -2025,9 +2010,9 @@ void |
| 2025 | 2010 | basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) |
| 2026 | 2011 | { |
| 2027 | 2012 | if (__n > max_size()) |
| 2028 | this->__throw_length_error(); | |
| 2013 | __throw_length_error(); | |
| 2029 | 2014 | pointer __p; |
| 2030 | if (__n < __min_cap) | |
| 2015 | if (__fits_in_sso(__n)) | |
| 2031 | 2016 | { |
| 2032 | 2017 | __set_short_size(__n); |
| 2033 | 2018 | __p = __get_short_pointer(); |
| ... | ... | @@ -2050,9 +2035,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __ |
| 2050 | 2035 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2051 | 2036 | { |
| 2052 | 2037 | __init(__n, __c); |
| 2053 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2054 | __get_db()->__insert_c(this); | |
| 2055 | #endif | |
| 2038 | _VSTD::__debug_db_insert_c(this); | |
| 2056 | 2039 | } |
| 2057 | 2040 | |
| 2058 | 2041 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2061,9 +2044,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __ |
| 2061 | 2044 | : __r_(__default_init_tag(), __a) |
| 2062 | 2045 | { |
| 2063 | 2046 | __init(__n, __c); |
| 2064 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2065 | __get_db()->__insert_c(this); | |
| 2066 | #endif | |
| 2047 | _VSTD::__debug_db_insert_c(this); | |
| 2067 | 2048 | } |
| 2068 | 2049 | |
| 2069 | 2050 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2074,11 +2055,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st |
| 2074 | 2055 | { |
| 2075 | 2056 | size_type __str_sz = __str.size(); |
| 2076 | 2057 | if (__pos > __str_sz) |
| 2077 | this->__throw_out_of_range(); | |
| 2058 | __throw_out_of_range(); | |
| 2078 | 2059 | __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); |
| 2079 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2080 | __get_db()->__insert_c(this); | |
| 2081 | #endif | |
| 2060 | _VSTD::__debug_db_insert_c(this); | |
| 2082 | 2061 | } |
| 2083 | 2062 | |
| 2084 | 2063 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2089,11 +2068,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st |
| 2089 | 2068 | { |
| 2090 | 2069 | size_type __str_sz = __str.size(); |
| 2091 | 2070 | if (__pos > __str_sz) |
| 2092 | this->__throw_out_of_range(); | |
| 2071 | __throw_out_of_range(); | |
| 2093 | 2072 | __init(__str.data() + __pos, __str_sz - __pos); |
| 2094 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2095 | __get_db()->__insert_c(this); | |
| 2096 | #endif | |
| 2073 | _VSTD::__debug_db_insert_c(this); | |
| 2097 | 2074 | } |
| 2098 | 2075 | |
| 2099 | 2076 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2105,9 +2082,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2105 | 2082 | __self_view __sv0 = __t; |
| 2106 | 2083 | __self_view __sv = __sv0.substr(__pos, __n); |
| 2107 | 2084 | __init(__sv.data(), __sv.size()); |
| 2108 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2109 | __get_db()->__insert_c(this); | |
| 2110 | #endif | |
| 2085 | _VSTD::__debug_db_insert_c(this); | |
| 2111 | 2086 | } |
| 2112 | 2087 | |
| 2113 | 2088 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2117,9 +2092,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) |
| 2117 | 2092 | { |
| 2118 | 2093 | __self_view __sv = __t; |
| 2119 | 2094 | __init(__sv.data(), __sv.size()); |
| 2120 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2121 | __get_db()->__insert_c(this); | |
| 2122 | #endif | |
| 2095 | _VSTD::__debug_db_insert_c(this); | |
| 2123 | 2096 | } |
| 2124 | 2097 | |
| 2125 | 2098 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2129,14 +2102,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _ |
| 2129 | 2102 | { |
| 2130 | 2103 | __self_view __sv = __t; |
| 2131 | 2104 | __init(__sv.data(), __sv.size()); |
| 2132 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2133 | __get_db()->__insert_c(this); | |
| 2134 | #endif | |
| 2105 | _VSTD::__debug_db_insert_c(this); | |
| 2135 | 2106 | } |
| 2136 | 2107 | |
| 2137 | 2108 | template <class _CharT, class _Traits, class _Allocator> |
| 2138 | 2109 | template <class _InputIterator> |
| 2139 | _EnableIf | |
| 2110 | __enable_if_t | |
| 2140 | 2111 | < |
| 2141 | 2112 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 2142 | 2113 | > |
| ... | ... | @@ -2162,7 +2133,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input |
| 2162 | 2133 | |
| 2163 | 2134 | template <class _CharT, class _Traits, class _Allocator> |
| 2164 | 2135 | template <class _ForwardIterator> |
| 2165 | _EnableIf | |
| 2136 | __enable_if_t | |
| 2166 | 2137 | < |
| 2167 | 2138 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 2168 | 2139 | > |
| ... | ... | @@ -2170,9 +2141,9 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For |
| 2170 | 2141 | { |
| 2171 | 2142 | size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); |
| 2172 | 2143 | if (__sz > max_size()) |
| 2173 | this->__throw_length_error(); | |
| 2144 | __throw_length_error(); | |
| 2174 | 2145 | pointer __p; |
| 2175 | if (__sz < __min_cap) | |
| 2146 | if (__fits_in_sso(__sz)) | |
| 2176 | 2147 | { |
| 2177 | 2148 | __set_short_size(__sz); |
| 2178 | 2149 | __p = __get_short_pointer(); |
| ... | ... | @@ -2211,9 +2182,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, |
| 2211 | 2182 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2212 | 2183 | { |
| 2213 | 2184 | __init(__first, __last); |
| 2214 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2215 | __get_db()->__insert_c(this); | |
| 2216 | #endif | |
| 2185 | _VSTD::__debug_db_insert_c(this); | |
| 2217 | 2186 | } |
| 2218 | 2187 | |
| 2219 | 2188 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2224,9 +2193,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, |
| 2224 | 2193 | : __r_(__default_init_tag(), __a) |
| 2225 | 2194 | { |
| 2226 | 2195 | __init(__first, __last); |
| 2227 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2228 | __get_db()->__insert_c(this); | |
| 2229 | #endif | |
| 2196 | _VSTD::__debug_db_insert_c(this); | |
| 2230 | 2197 | } |
| 2231 | 2198 | |
| 2232 | 2199 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -2238,9 +2205,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2238 | 2205 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2239 | 2206 | { |
| 2240 | 2207 | __init(__il.begin(), __il.end()); |
| 2241 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2242 | __get_db()->__insert_c(this); | |
| 2243 | #endif | |
| 2208 | _VSTD::__debug_db_insert_c(this); | |
| 2244 | 2209 | } |
| 2245 | 2210 | |
| 2246 | 2211 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2251,9 +2216,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2251 | 2216 | : __r_(__default_init_tag(), __a) |
| 2252 | 2217 | { |
| 2253 | 2218 | __init(__il.begin(), __il.end()); |
| 2254 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2255 | __get_db()->__insert_c(this); | |
| 2256 | #endif | |
| 2219 | _VSTD::__debug_db_insert_c(this); | |
| 2257 | 2220 | } |
| 2258 | 2221 | |
| 2259 | 2222 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -2262,7 +2225,8 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2262 | 2225 | basic_string<_CharT, _Traits, _Allocator>::~basic_string() |
| 2263 | 2226 | { |
| 2264 | 2227 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2265 | __get_db()->__erase_c(this); | |
| 2228 | if (!__libcpp_is_constant_evaluated()) | |
| 2229 | __get_db()->__erase_c(this); | |
| 2266 | 2230 | #endif |
| 2267 | 2231 | if (__is_long()) |
| 2268 | 2232 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); |
| ... | ... | @@ -2276,7 +2240,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace |
| 2276 | 2240 | { |
| 2277 | 2241 | size_type __ms = max_size(); |
| 2278 | 2242 | if (__delta_cap > __ms - __old_cap - 1) |
| 2279 | this->__throw_length_error(); | |
| 2243 | __throw_length_error(); | |
| 2280 | 2244 | pointer __old_p = __get_pointer(); |
| 2281 | 2245 | size_type __cap = __old_cap < __ms / 2 - __alignment ? |
| 2282 | 2246 | __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : |
| ... | ... | @@ -2308,7 +2272,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t |
| 2308 | 2272 | { |
| 2309 | 2273 | size_type __ms = max_size(); |
| 2310 | 2274 | if (__delta_cap > __ms - __old_cap) |
| 2311 | this->__throw_length_error(); | |
| 2275 | __throw_length_error(); | |
| 2312 | 2276 | pointer __old_p = __get_pointer(); |
| 2313 | 2277 | size_type __cap = __old_cap < __ms / 2 - __alignment ? |
| 2314 | 2278 | __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : |
| ... | ... | @@ -2358,14 +2322,12 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external( |
| 2358 | 2322 | if (__cap >= __n) { |
| 2359 | 2323 | value_type* __p = _VSTD::__to_address(__get_pointer()); |
| 2360 | 2324 | traits_type::move(__p, __s, __n); |
| 2361 | traits_type::assign(__p[__n], value_type()); | |
| 2362 | __set_size(__n); | |
| 2363 | __invalidate_iterators_past(__n); | |
| 2325 | return __null_terminate_at(__p, __n); | |
| 2364 | 2326 | } else { |
| 2365 | 2327 | size_type __sz = size(); |
| 2366 | 2328 | __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s); |
| 2329 | return *this; | |
| 2367 | 2330 | } |
| 2368 | return *this; | |
| 2369 | 2331 | } |
| 2370 | 2332 | |
| 2371 | 2333 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2373,7 +2335,7 @@ basic_string<_CharT, _Traits, _Allocator>& |
| 2373 | 2335 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) |
| 2374 | 2336 | { |
| 2375 | 2337 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign received nullptr"); |
| 2376 | return (_LIBCPP_BUILTIN_CONSTANT_P(__n) && __n < __min_cap) | |
| 2338 | return (__builtin_constant_p(__n) && __fits_in_sso(__n)) | |
| 2377 | 2339 | ? __assign_short(__s, __n) |
| 2378 | 2340 | : __assign_external(__s, __n); |
| 2379 | 2341 | } |
| ... | ... | @@ -2390,10 +2352,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) |
| 2390 | 2352 | } |
| 2391 | 2353 | value_type* __p = _VSTD::__to_address(__get_pointer()); |
| 2392 | 2354 | traits_type::assign(__p, __n, __c); |
| 2393 | traits_type::assign(__p[__n], value_type()); | |
| 2394 | __set_size(__n); | |
| 2395 | __invalidate_iterators_past(__n); | |
| 2396 | return *this; | |
| 2355 | return __null_terminate_at(__p, __n); | |
| 2397 | 2356 | } |
| 2398 | 2357 | |
| 2399 | 2358 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -2491,7 +2450,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) |
| 2491 | 2450 | |
| 2492 | 2451 | template <class _CharT, class _Traits, class _Allocator> |
| 2493 | 2452 | template<class _InputIterator> |
| 2494 | _EnableIf | |
| 2453 | __enable_if_t | |
| 2495 | 2454 | < |
| 2496 | 2455 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| 2497 | 2456 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -2505,7 +2464,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input |
| 2505 | 2464 | |
| 2506 | 2465 | template <class _CharT, class _Traits, class _Allocator> |
| 2507 | 2466 | template<class _ForwardIterator> |
| 2508 | _EnableIf | |
| 2467 | __enable_if_t | |
| 2509 | 2468 | < |
| 2510 | 2469 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 2511 | 2470 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -2525,7 +2484,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For |
| 2525 | 2484 | __grow_by(__cap, __n - __cap, __sz, 0, __sz); |
| 2526 | 2485 | } |
| 2527 | 2486 | pointer __p = __get_pointer(); |
| 2528 | for (; __first != __last; ++__first, ++__p) | |
| 2487 | for (; __first != __last; ++__p, (void) ++__first) | |
| 2529 | 2488 | traits_type::assign(*__p, *__first); |
| 2530 | 2489 | traits_type::assign(*__p, value_type()); |
| 2531 | 2490 | __set_size(__n); |
| ... | ... | @@ -2545,13 +2504,13 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, siz |
| 2545 | 2504 | { |
| 2546 | 2505 | size_type __sz = __str.size(); |
| 2547 | 2506 | if (__pos > __sz) |
| 2548 | this->__throw_out_of_range(); | |
| 2507 | __throw_out_of_range(); | |
| 2549 | 2508 | return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); |
| 2550 | 2509 | } |
| 2551 | 2510 | |
| 2552 | 2511 | template <class _CharT, class _Traits, class _Allocator> |
| 2553 | 2512 | template <class _Tp> |
| 2554 | _EnableIf | |
| 2513 | __enable_if_t | |
| 2555 | 2514 | < |
| 2556 | 2515 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 2557 | 2516 | && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| ... | ... | @@ -2562,7 +2521,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p |
| 2562 | 2521 | __self_view __sv = __t; |
| 2563 | 2522 | size_type __sz = __sv.size(); |
| 2564 | 2523 | if (__pos > __sz) |
| 2565 | this->__throw_out_of_range(); | |
| 2524 | __throw_out_of_range(); | |
| 2566 | 2525 | return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); |
| 2567 | 2526 | } |
| 2568 | 2527 | |
| ... | ... | @@ -2578,8 +2537,8 @@ basic_string<_CharT, _Traits, _Allocator>& |
| 2578 | 2537 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) |
| 2579 | 2538 | { |
| 2580 | 2539 | _LIBCPP_ASSERT(__s != nullptr, "string::assign received nullptr"); |
| 2581 | return _LIBCPP_BUILTIN_CONSTANT_P(*__s) | |
| 2582 | ? (traits_type::length(__s) < __min_cap | |
| 2540 | return __builtin_constant_p(*__s) | |
| 2541 | ? (__fits_in_sso(traits_type::length(__s)) | |
| 2583 | 2542 | ? __assign_short(__s, traits_type::length(__s)) |
| 2584 | 2543 | : __assign_external(__s, traits_type::length(__s))) |
| 2585 | 2544 | : __assign_external(__s); |
| ... | ... | @@ -2665,7 +2624,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) |
| 2665 | 2624 | if (__sz == __cap) |
| 2666 | 2625 | { |
| 2667 | 2626 | __grow_by(__cap, 1, __sz, __sz, 0); |
| 2668 | __is_short = !__is_long(); | |
| 2627 | __is_short = false; // the string is always long after __grow_by | |
| 2669 | 2628 | } |
| 2670 | 2629 | pointer __p; |
| 2671 | 2630 | if (__is_short) |
| ... | ... | @@ -2684,7 +2643,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) |
| 2684 | 2643 | |
| 2685 | 2644 | template <class _CharT, class _Traits, class _Allocator> |
| 2686 | 2645 | template<class _ForwardIterator> |
| 2687 | _EnableIf | |
| 2646 | __enable_if_t | |
| 2688 | 2647 | < |
| 2689 | 2648 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 2690 | 2649 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -2703,7 +2662,7 @@ basic_string<_CharT, _Traits, _Allocator>::append( |
| 2703 | 2662 | if (__cap - __sz < __n) |
| 2704 | 2663 | __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); |
| 2705 | 2664 | pointer __p = __get_pointer() + __sz; |
| 2706 | for (; __first != __last; ++__p, ++__first) | |
| 2665 | for (; __first != __last; ++__p, (void) ++__first) | |
| 2707 | 2666 | traits_type::assign(*__p, *__first); |
| 2708 | 2667 | traits_type::assign(*__p, value_type()); |
| 2709 | 2668 | __set_size(__sz + __n); |
| ... | ... | @@ -2731,13 +2690,13 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, siz |
| 2731 | 2690 | { |
| 2732 | 2691 | size_type __sz = __str.size(); |
| 2733 | 2692 | if (__pos > __sz) |
| 2734 | this->__throw_out_of_range(); | |
| 2693 | __throw_out_of_range(); | |
| 2735 | 2694 | return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); |
| 2736 | 2695 | } |
| 2737 | 2696 | |
| 2738 | 2697 | template <class _CharT, class _Traits, class _Allocator> |
| 2739 | 2698 | template <class _Tp> |
| 2740 | _EnableIf | |
| 2699 | __enable_if_t | |
| 2741 | 2700 | < |
| 2742 | 2701 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| 2743 | 2702 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -2747,7 +2706,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p |
| 2747 | 2706 | __self_view __sv = __t; |
| 2748 | 2707 | size_type __sz = __sv.size(); |
| 2749 | 2708 | if (__pos > __sz) |
| 2750 | this->__throw_out_of_range(); | |
| 2709 | __throw_out_of_range(); | |
| 2751 | 2710 | return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); |
| 2752 | 2711 | } |
| 2753 | 2712 | |
| ... | ... | @@ -2768,7 +2727,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t |
| 2768 | 2727 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert received nullptr"); |
| 2769 | 2728 | size_type __sz = size(); |
| 2770 | 2729 | if (__pos > __sz) |
| 2771 | this->__throw_out_of_range(); | |
| 2730 | __throw_out_of_range(); | |
| 2772 | 2731 | size_type __cap = capacity(); |
| 2773 | 2732 | if (__cap - __sz >= __n) |
| 2774 | 2733 | { |
| ... | ... | @@ -2799,7 +2758,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 2799 | 2758 | { |
| 2800 | 2759 | size_type __sz = size(); |
| 2801 | 2760 | if (__pos > __sz) |
| 2802 | this->__throw_out_of_range(); | |
| 2761 | __throw_out_of_range(); | |
| 2803 | 2762 | if (__n) |
| 2804 | 2763 | { |
| 2805 | 2764 | size_type __cap = capacity(); |
| ... | ... | @@ -2826,36 +2785,33 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 2826 | 2785 | |
| 2827 | 2786 | template <class _CharT, class _Traits, class _Allocator> |
| 2828 | 2787 | template<class _InputIterator> |
| 2829 | _EnableIf | |
| 2788 | __enable_if_t | |
| 2830 | 2789 | < |
| 2831 | 2790 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| 2832 | 2791 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2833 | 2792 | > |
| 2834 | 2793 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) |
| 2835 | 2794 | { |
| 2836 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2837 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2838 | "string::insert(iterator, range) called with an iterator not" | |
| 2839 | " referring to this string"); | |
| 2840 | #endif | |
| 2841 | const basic_string __temp(__first, __last, __alloc()); | |
| 2842 | return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | |
| 2795 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2796 | "string::insert(iterator, range) called with an iterator not" | |
| 2797 | " referring to this string"); | |
| 2798 | const basic_string __temp(__first, __last, __alloc()); | |
| 2799 | return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | |
| 2843 | 2800 | } |
| 2844 | 2801 | |
| 2845 | 2802 | template <class _CharT, class _Traits, class _Allocator> |
| 2846 | 2803 | template<class _ForwardIterator> |
| 2847 | _EnableIf | |
| 2804 | __enable_if_t | |
| 2848 | 2805 | < |
| 2849 | 2806 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 2850 | 2807 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2851 | 2808 | > |
| 2852 | 2809 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) |
| 2853 | 2810 | { |
| 2854 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2855 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2856 | "string::insert(iterator, range) called with an iterator not" | |
| 2857 | " referring to this string"); | |
| 2858 | #endif | |
| 2811 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2812 | "string::insert(iterator, range) called with an iterator not" | |
| 2813 | " referring to this string"); | |
| 2814 | ||
| 2859 | 2815 | size_type __ip = static_cast<size_type>(__pos - begin()); |
| 2860 | 2816 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); |
| 2861 | 2817 | if (__n) |
| ... | ... | @@ -2881,7 +2837,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward |
| 2881 | 2837 | __sz += __n; |
| 2882 | 2838 | __set_size(__sz); |
| 2883 | 2839 | traits_type::assign(__p[__sz], value_type()); |
| 2884 | for (__p += __ip; __first != __last; ++__p, ++__first) | |
| 2840 | for (__p += __ip; __first != __last; ++__p, (void) ++__first) | |
| 2885 | 2841 | traits_type::assign(*__p, *__first); |
| 2886 | 2842 | } |
| 2887 | 2843 | else |
| ... | ... | @@ -2908,13 +2864,13 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_ |
| 2908 | 2864 | { |
| 2909 | 2865 | size_type __str_sz = __str.size(); |
| 2910 | 2866 | if (__pos2 > __str_sz) |
| 2911 | this->__throw_out_of_range(); | |
| 2867 | __throw_out_of_range(); | |
| 2912 | 2868 | return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); |
| 2913 | 2869 | } |
| 2914 | 2870 | |
| 2915 | 2871 | template <class _CharT, class _Traits, class _Allocator> |
| 2916 | 2872 | template <class _Tp> |
| 2917 | _EnableIf | |
| 2873 | __enable_if_t | |
| 2918 | 2874 | < |
| 2919 | 2875 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| 2920 | 2876 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -2925,7 +2881,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _ |
| 2925 | 2881 | __self_view __sv = __t; |
| 2926 | 2882 | size_type __str_sz = __sv.size(); |
| 2927 | 2883 | if (__pos2 > __str_sz) |
| 2928 | this->__throw_out_of_range(); | |
| 2884 | __throw_out_of_range(); | |
| 2929 | 2885 | return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); |
| 2930 | 2886 | } |
| 2931 | 2887 | |
| ... | ... | @@ -2941,6 +2897,10 @@ template <class _CharT, class _Traits, class _Allocator> |
| 2941 | 2897 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2942 | 2898 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) |
| 2943 | 2899 | { |
| 2900 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2901 | "string::insert(iterator, character) called with an iterator not" | |
| 2902 | " referring to this string"); | |
| 2903 | ||
| 2944 | 2904 | size_type __ip = static_cast<size_type>(__pos - begin()); |
| 2945 | 2905 | size_type __sz = size(); |
| 2946 | 2906 | size_type __cap = capacity(); |
| ... | ... | @@ -2968,14 +2928,12 @@ inline |
| 2968 | 2928 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2969 | 2929 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) |
| 2970 | 2930 | { |
| 2971 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2972 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2973 | "string::insert(iterator, n, value) called with an iterator not" | |
| 2974 | " referring to this string"); | |
| 2975 | #endif | |
| 2976 | difference_type __p = __pos - begin(); | |
| 2977 | insert(static_cast<size_type>(__p), __n, __c); | |
| 2978 | return begin() + __p; | |
| 2931 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2932 | "string::insert(iterator, n, value) called with an iterator not" | |
| 2933 | " referring to this string"); | |
| 2934 | difference_type __p = __pos - begin(); | |
| 2935 | insert(static_cast<size_type>(__p), __n, __c); | |
| 2936 | return begin() + __p; | |
| 2979 | 2937 | } |
| 2980 | 2938 | |
| 2981 | 2939 | // replace |
| ... | ... | @@ -2988,7 +2946,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 2988 | 2946 | _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace received nullptr"); |
| 2989 | 2947 | size_type __sz = size(); |
| 2990 | 2948 | if (__pos > __sz) |
| 2991 | this->__throw_out_of_range(); | |
| 2949 | __throw_out_of_range(); | |
| 2992 | 2950 | __n1 = _VSTD::min(__n1, __sz - __pos); |
| 2993 | 2951 | size_type __cap = capacity(); |
| 2994 | 2952 | if (__cap - __sz + __n1 >= __n2) |
| ... | ... | @@ -3003,7 +2961,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3003 | 2961 | { |
| 3004 | 2962 | traits_type::move(__p + __pos, __s, __n2); |
| 3005 | 2963 | traits_type::move(__p + __pos + __n2, __p + __pos + __n1, __n_move); |
| 3006 | goto __finish; | |
| 2964 | return __null_terminate_at(__p, __sz + (__n2 - __n1)); | |
| 3007 | 2965 | } |
| 3008 | 2966 | if (__p + __pos < __s && __s < __p + __sz) |
| 3009 | 2967 | { |
| ... | ... | @@ -3022,13 +2980,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3022 | 2980 | } |
| 3023 | 2981 | } |
| 3024 | 2982 | traits_type::move(__p + __pos, __s, __n2); |
| 3025 | __finish: | |
| 3026 | // __sz += __n2 - __n1; in this and the below function below can cause unsigned | |
| 3027 | // integer overflow, but this is a safe operation, so we disable the check. | |
| 3028 | __sz += __n2 - __n1; | |
| 3029 | __set_size(__sz); | |
| 3030 | __invalidate_iterators_past(__sz); | |
| 3031 | traits_type::assign(__p[__sz], value_type()); | |
| 2983 | return __null_terminate_at(__p, __sz + (__n2 - __n1)); | |
| 3032 | 2984 | } |
| 3033 | 2985 | else |
| 3034 | 2986 | __grow_by_and_replace(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2, __s); |
| ... | ... | @@ -3038,11 +2990,10 @@ __finish: |
| 3038 | 2990 | template <class _CharT, class _Traits, class _Allocator> |
| 3039 | 2991 | basic_string<_CharT, _Traits, _Allocator>& |
| 3040 | 2992 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) |
| 3041 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 3042 | 2993 | { |
| 3043 | 2994 | size_type __sz = size(); |
| 3044 | 2995 | if (__pos > __sz) |
| 3045 | this->__throw_out_of_range(); | |
| 2996 | __throw_out_of_range(); | |
| 3046 | 2997 | __n1 = _VSTD::min(__n1, __sz - __pos); |
| 3047 | 2998 | size_type __cap = capacity(); |
| 3048 | 2999 | value_type* __p; |
| ... | ... | @@ -3062,16 +3013,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3062 | 3013 | __p = _VSTD::__to_address(__get_long_pointer()); |
| 3063 | 3014 | } |
| 3064 | 3015 | traits_type::assign(__p + __pos, __n2, __c); |
| 3065 | __sz += __n2 - __n1; | |
| 3066 | __set_size(__sz); | |
| 3067 | __invalidate_iterators_past(__sz); | |
| 3068 | traits_type::assign(__p[__sz], value_type()); | |
| 3069 | return *this; | |
| 3016 | return __null_terminate_at(__p, __sz - (__n1 - __n2)); | |
| 3070 | 3017 | } |
| 3071 | 3018 | |
| 3072 | 3019 | template <class _CharT, class _Traits, class _Allocator> |
| 3073 | 3020 | template<class _InputIterator> |
| 3074 | _EnableIf | |
| 3021 | __enable_if_t | |
| 3075 | 3022 | < |
| 3076 | 3023 | __is_cpp17_input_iterator<_InputIterator>::value, |
| 3077 | 3024 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -3080,7 +3027,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 3080 | 3027 | _InputIterator __j1, _InputIterator __j2) |
| 3081 | 3028 | { |
| 3082 | 3029 | const basic_string __temp(__j1, __j2, __alloc()); |
| 3083 | return this->replace(__i1, __i2, __temp); | |
| 3030 | return replace(__i1, __i2, __temp); | |
| 3084 | 3031 | } |
| 3085 | 3032 | |
| 3086 | 3033 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3098,13 +3045,13 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ |
| 3098 | 3045 | { |
| 3099 | 3046 | size_type __str_sz = __str.size(); |
| 3100 | 3047 | if (__pos2 > __str_sz) |
| 3101 | this->__throw_out_of_range(); | |
| 3048 | __throw_out_of_range(); | |
| 3102 | 3049 | return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); |
| 3103 | 3050 | } |
| 3104 | 3051 | |
| 3105 | 3052 | template <class _CharT, class _Traits, class _Allocator> |
| 3106 | 3053 | template <class _Tp> |
| 3107 | _EnableIf | |
| 3054 | __enable_if_t | |
| 3108 | 3055 | < |
| 3109 | 3056 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| 3110 | 3057 | basic_string<_CharT, _Traits, _Allocator>& |
| ... | ... | @@ -3115,7 +3062,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ |
| 3115 | 3062 | __self_view __sv = __t; |
| 3116 | 3063 | size_type __str_sz = __sv.size(); |
| 3117 | 3064 | if (__pos2 > __str_sz) |
| 3118 | this->__throw_out_of_range(); | |
| 3065 | __throw_out_of_range(); | |
| 3119 | 3066 | return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); |
| 3120 | 3067 | } |
| 3121 | 3068 | |
| ... | ... | @@ -3177,10 +3124,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( |
| 3177 | 3124 | size_type __n_move = __sz - __pos - __n; |
| 3178 | 3125 | if (__n_move != 0) |
| 3179 | 3126 | traits_type::move(__p + __pos, __p + __pos + __n, __n_move); |
| 3180 | __sz -= __n; | |
| 3181 | __set_size(__sz); | |
| 3182 | __invalidate_iterators_past(__sz); | |
| 3183 | traits_type::assign(__p[__sz], value_type()); | |
| 3127 | __null_terminate_at(__p, __sz - __n); | |
| 3184 | 3128 | } |
| 3185 | 3129 | } |
| 3186 | 3130 | |
| ... | ... | @@ -3188,7 +3132,8 @@ template <class _CharT, class _Traits, class _Allocator> |
| 3188 | 3132 | basic_string<_CharT, _Traits, _Allocator>& |
| 3189 | 3133 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, |
| 3190 | 3134 | size_type __n) { |
| 3191 | if (__pos > size()) this->__throw_out_of_range(); | |
| 3135 | if (__pos > size()) | |
| 3136 | __throw_out_of_range(); | |
| 3192 | 3137 | if (__n == npos) { |
| 3193 | 3138 | __erase_to_end(__pos); |
| 3194 | 3139 | } else { |
| ... | ... | @@ -3202,17 +3147,15 @@ inline |
| 3202 | 3147 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 3203 | 3148 | basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) |
| 3204 | 3149 | { |
| 3205 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 3206 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 3207 | "string::erase(iterator) called with an iterator not" | |
| 3208 | " referring to this string"); | |
| 3209 | #endif | |
| 3210 | _LIBCPP_ASSERT(__pos != end(), | |
| 3211 | "string::erase(iterator) called with a non-dereferenceable iterator"); | |
| 3212 | iterator __b = begin(); | |
| 3213 | size_type __r = static_cast<size_type>(__pos - __b); | |
| 3214 | erase(__r, 1); | |
| 3215 | return __b + static_cast<difference_type>(__r); | |
| 3150 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 3151 | "string::erase(iterator) called with an iterator not" | |
| 3152 | " referring to this string"); | |
| 3153 | ||
| 3154 | _LIBCPP_ASSERT(__pos != end(), "string::erase(iterator) called with a non-dereferenceable iterator"); | |
| 3155 | iterator __b = begin(); | |
| 3156 | size_type __r = static_cast<size_type>(__pos - __b); | |
| 3157 | erase(__r, 1); | |
| 3158 | return __b + static_cast<difference_type>(__r); | |
| 3216 | 3159 | } |
| 3217 | 3160 | |
| 3218 | 3161 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3220,16 +3163,15 @@ inline |
| 3220 | 3163 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 3221 | 3164 | basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 3222 | 3165 | { |
| 3223 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 3224 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | |
| 3225 | "string::erase(iterator, iterator) called with an iterator not" | |
| 3226 | " referring to this string"); | |
| 3227 | #endif | |
| 3228 | _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); | |
| 3229 | iterator __b = begin(); | |
| 3230 | size_type __r = static_cast<size_type>(__first - __b); | |
| 3231 | erase(__r, static_cast<size_type>(__last - __first)); | |
| 3232 | return __b + static_cast<difference_type>(__r); | |
| 3166 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | |
| 3167 | "string::erase(iterator, iterator) called with an iterator not" | |
| 3168 | " referring to this string"); | |
| 3169 | ||
| 3170 | _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); | |
| 3171 | iterator __b = begin(); | |
| 3172 | size_type __r = static_cast<size_type>(__first - __b); | |
| 3173 | erase(__r, static_cast<size_type>(__last - __first)); | |
| 3174 | return __b + static_cast<difference_type>(__r); | |
| 3233 | 3175 | } |
| 3234 | 3176 | |
| 3235 | 3177 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3238,20 +3180,7 @@ void |
| 3238 | 3180 | basic_string<_CharT, _Traits, _Allocator>::pop_back() |
| 3239 | 3181 | { |
| 3240 | 3182 | _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); |
| 3241 | size_type __sz; | |
| 3242 | if (__is_long()) | |
| 3243 | { | |
| 3244 | __sz = __get_long_size() - 1; | |
| 3245 | __set_long_size(__sz); | |
| 3246 | traits_type::assign(*(__get_long_pointer() + __sz), value_type()); | |
| 3247 | } | |
| 3248 | else | |
| 3249 | { | |
| 3250 | __sz = __get_short_size() - 1; | |
| 3251 | __set_short_size(__sz); | |
| 3252 | traits_type::assign(*(__get_short_pointer() + __sz), value_type()); | |
| 3253 | } | |
| 3254 | __invalidate_iterators_past(__sz); | |
| 3183 | __erase_to_end(size() - 1); | |
| 3255 | 3184 | } |
| 3256 | 3185 | |
| 3257 | 3186 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3277,17 +3206,7 @@ inline |
| 3277 | 3206 | void |
| 3278 | 3207 | basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) |
| 3279 | 3208 | { |
| 3280 | if (__is_long()) | |
| 3281 | { | |
| 3282 | traits_type::assign(*(__get_long_pointer() + __pos), value_type()); | |
| 3283 | __set_long_size(__pos); | |
| 3284 | } | |
| 3285 | else | |
| 3286 | { | |
| 3287 | traits_type::assign(*(__get_short_pointer() + __pos), value_type()); | |
| 3288 | __set_short_size(__pos); | |
| 3289 | } | |
| 3290 | __invalidate_iterators_past(__pos); | |
| 3209 | __null_terminate_at(_VSTD::__to_address(__get_pointer()), __pos); | |
| 3291 | 3210 | } |
| 3292 | 3211 | |
| 3293 | 3212 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -3330,12 +3249,13 @@ void |
| 3330 | 3249 | basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) |
| 3331 | 3250 | { |
| 3332 | 3251 | if (__requested_capacity > max_size()) |
| 3333 | this->__throw_length_error(); | |
| 3252 | __throw_length_error(); | |
| 3334 | 3253 | |
| 3335 | #if _LIBCPP_STD_VER > 17 | |
| 3336 | // Reserve never shrinks as of C++20. | |
| 3337 | if (__requested_capacity <= capacity()) return; | |
| 3338 | #endif | |
| 3254 | // Make sure reserve(n) never shrinks. This is technically only required in C++20 | |
| 3255 | // and later (since P0966R1), however we provide consistent behavior in all Standard | |
| 3256 | // modes because this function is instantiated in the shared library. | |
| 3257 | if (__requested_capacity <= capacity()) | |
| 3258 | return; | |
| 3339 | 3259 | |
| 3340 | 3260 | size_type __target_capacity = _VSTD::max(__requested_capacity, size()); |
| 3341 | 3261 | __target_capacity = __recommend(__target_capacity); |
| ... | ... | @@ -3345,6 +3265,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit |
| 3345 | 3265 | } |
| 3346 | 3266 | |
| 3347 | 3267 | template <class _CharT, class _Traits, class _Allocator> |
| 3268 | inline | |
| 3348 | 3269 | void |
| 3349 | 3270 | basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 3350 | 3271 | { |
| ... | ... | @@ -3355,6 +3276,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 3355 | 3276 | } |
| 3356 | 3277 | |
| 3357 | 3278 | template <class _CharT, class _Traits, class _Allocator> |
| 3279 | inline | |
| 3358 | 3280 | void |
| 3359 | 3281 | basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) |
| 3360 | 3282 | { |
| ... | ... | @@ -3434,7 +3356,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::const_reference |
| 3434 | 3356 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const |
| 3435 | 3357 | { |
| 3436 | 3358 | if (__n >= size()) |
| 3437 | this->__throw_out_of_range(); | |
| 3359 | __throw_out_of_range(); | |
| 3438 | 3360 | return (*this)[__n]; |
| 3439 | 3361 | } |
| 3440 | 3362 | |
| ... | ... | @@ -3443,7 +3365,7 @@ typename basic_string<_CharT, _Traits, _Allocator>::reference |
| 3443 | 3365 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) |
| 3444 | 3366 | { |
| 3445 | 3367 | if (__n >= size()) |
| 3446 | this->__throw_out_of_range(); | |
| 3368 | __throw_out_of_range(); | |
| 3447 | 3369 | return (*this)[__n]; |
| 3448 | 3370 | } |
| 3449 | 3371 | |
| ... | ... | @@ -3489,7 +3411,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, |
| 3489 | 3411 | { |
| 3490 | 3412 | size_type __sz = size(); |
| 3491 | 3413 | if (__pos > __sz) |
| 3492 | this->__throw_out_of_range(); | |
| 3414 | __throw_out_of_range(); | |
| 3493 | 3415 | size_type __rlen = _VSTD::min(__n, __sz - __pos); |
| 3494 | 3416 | traits_type::copy(__s, data() + __pos, __rlen); |
| 3495 | 3417 | return __rlen; |
| ... | ... | @@ -3515,11 +3437,13 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) |
| 3515 | 3437 | #endif |
| 3516 | 3438 | { |
| 3517 | 3439 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 3518 | if (!__is_long()) | |
| 3519 | __get_db()->__invalidate_all(this); | |
| 3520 | if (!__str.__is_long()) | |
| 3521 | __get_db()->__invalidate_all(&__str); | |
| 3522 | __get_db()->swap(this, &__str); | |
| 3440 | if (!__libcpp_is_constant_evaluated()) { | |
| 3441 | if (!__is_long()) | |
| 3442 | __get_db()->__invalidate_all(this); | |
| 3443 | if (!__str.__is_long()) | |
| 3444 | __get_db()->__invalidate_all(&__str); | |
| 3445 | __get_db()->swap(this, &__str); | |
| 3446 | } | |
| 3523 | 3447 | #endif |
| 3524 | 3448 | _LIBCPP_ASSERT( |
| 3525 | 3449 | __alloc_traits::propagate_on_container_swap::value || |
| ... | ... | @@ -3563,7 +3487,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, |
| 3563 | 3487 | |
| 3564 | 3488 | template<class _CharT, class _Traits, class _Allocator> |
| 3565 | 3489 | template <class _Tp> |
| 3566 | _EnableIf | |
| 3490 | __enable_if_t | |
| 3567 | 3491 | < |
| 3568 | 3492 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3569 | 3493 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -3621,7 +3545,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, |
| 3621 | 3545 | |
| 3622 | 3546 | template<class _CharT, class _Traits, class _Allocator> |
| 3623 | 3547 | template <class _Tp> |
| 3624 | _EnableIf | |
| 3548 | __enable_if_t | |
| 3625 | 3549 | < |
| 3626 | 3550 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3627 | 3551 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -3679,7 +3603,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s |
| 3679 | 3603 | |
| 3680 | 3604 | template<class _CharT, class _Traits, class _Allocator> |
| 3681 | 3605 | template <class _Tp> |
| 3682 | _EnableIf | |
| 3606 | __enable_if_t | |
| 3683 | 3607 | < |
| 3684 | 3608 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3685 | 3609 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -3737,7 +3661,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st |
| 3737 | 3661 | |
| 3738 | 3662 | template<class _CharT, class _Traits, class _Allocator> |
| 3739 | 3663 | template <class _Tp> |
| 3740 | _EnableIf | |
| 3664 | __enable_if_t | |
| 3741 | 3665 | < |
| 3742 | 3666 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3743 | 3667 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -3795,7 +3719,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& |
| 3795 | 3719 | |
| 3796 | 3720 | template<class _CharT, class _Traits, class _Allocator> |
| 3797 | 3721 | template <class _Tp> |
| 3798 | _EnableIf | |
| 3722 | __enable_if_t | |
| 3799 | 3723 | < |
| 3800 | 3724 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3801 | 3725 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -3854,7 +3778,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& |
| 3854 | 3778 | |
| 3855 | 3779 | template<class _CharT, class _Traits, class _Allocator> |
| 3856 | 3780 | template <class _Tp> |
| 3857 | _EnableIf | |
| 3781 | __enable_if_t | |
| 3858 | 3782 | < |
| 3859 | 3783 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3860 | 3784 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| ... | ... | @@ -3892,7 +3816,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, |
| 3892 | 3816 | |
| 3893 | 3817 | template <class _CharT, class _Traits, class _Allocator> |
| 3894 | 3818 | template <class _Tp> |
| 3895 | _EnableIf | |
| 3819 | __enable_if_t | |
| 3896 | 3820 | < |
| 3897 | 3821 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3898 | 3822 | int |
| ... | ... | @@ -3931,7 +3855,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3931 | 3855 | _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr"); |
| 3932 | 3856 | size_type __sz = size(); |
| 3933 | 3857 | if (__pos1 > __sz || __n2 == npos) |
| 3934 | this->__throw_out_of_range(); | |
| 3858 | __throw_out_of_range(); | |
| 3935 | 3859 | size_type __rlen = _VSTD::min(__n1, __sz - __pos1); |
| 3936 | 3860 | int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); |
| 3937 | 3861 | if (__r == 0) |
| ... | ... | @@ -3946,7 +3870,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3946 | 3870 | |
| 3947 | 3871 | template <class _CharT, class _Traits, class _Allocator> |
| 3948 | 3872 | template <class _Tp> |
| 3949 | _EnableIf | |
| 3873 | __enable_if_t | |
| 3950 | 3874 | < |
| 3951 | 3875 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 3952 | 3876 | int |
| ... | ... | @@ -3971,7 +3895,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3971 | 3895 | |
| 3972 | 3896 | template <class _CharT, class _Traits, class _Allocator> |
| 3973 | 3897 | template <class _Tp> |
| 3974 | _EnableIf | |
| 3898 | __enable_if_t | |
| 3975 | 3899 | < |
| 3976 | 3900 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 3977 | 3901 | && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| ... | ... | @@ -3995,7 +3919,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3995 | 3919 | size_type __pos2, |
| 3996 | 3920 | size_type __n2) const |
| 3997 | 3921 | { |
| 3998 | return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); | |
| 3922 | return compare(__pos1, __n1, __self_view(__str), __pos2, __n2); | |
| 3999 | 3923 | } |
| 4000 | 3924 | |
| 4001 | 3925 | template <class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -4409,6 +4333,7 @@ _LIBCPP_FUNC_VIS string to_string(float __val); |
| 4409 | 4333 | _LIBCPP_FUNC_VIS string to_string(double __val); |
| 4410 | 4334 | _LIBCPP_FUNC_VIS string to_string(long double __val); |
| 4411 | 4335 | |
| 4336 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4412 | 4337 | _LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 4413 | 4338 | _LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| 4414 | 4339 | _LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = nullptr, int __base = 10); |
| ... | ... | @@ -4428,6 +4353,7 @@ _LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); |
| 4428 | 4353 | _LIBCPP_FUNC_VIS wstring to_wstring(float __val); |
| 4429 | 4354 | _LIBCPP_FUNC_VIS wstring to_wstring(double __val); |
| 4430 | 4355 | _LIBCPP_FUNC_VIS wstring to_wstring(long double __val); |
| 4356 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4431 | 4357 | |
| 4432 | 4358 | template<class _CharT, class _Traits, class _Allocator> |
| 4433 | 4359 | _LIBCPP_TEMPLATE_DATA_VIS |
| ... | ... | @@ -4507,16 +4433,16 @@ template<class _CharT, class _Traits, class _Allocator> |
| 4507 | 4433 | bool |
| 4508 | 4434 | basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const |
| 4509 | 4435 | { |
| 4510 | return this->data() <= _VSTD::__to_address(__i->base()) && | |
| 4511 | _VSTD::__to_address(__i->base()) < this->data() + this->size(); | |
| 4436 | return data() <= _VSTD::__to_address(__i->base()) && | |
| 4437 | _VSTD::__to_address(__i->base()) < data() + size(); | |
| 4512 | 4438 | } |
| 4513 | 4439 | |
| 4514 | 4440 | template<class _CharT, class _Traits, class _Allocator> |
| 4515 | 4441 | bool |
| 4516 | 4442 | basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const |
| 4517 | 4443 | { |
| 4518 | return this->data() < _VSTD::__to_address(__i->base()) && | |
| 4519 | _VSTD::__to_address(__i->base()) <= this->data() + this->size(); | |
| 4444 | return data() < _VSTD::__to_address(__i->base()) && | |
| 4445 | _VSTD::__to_address(__i->base()) <= data() + size(); | |
| 4520 | 4446 | } |
| 4521 | 4447 | |
| 4522 | 4448 | template<class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -4524,7 +4450,7 @@ bool |
| 4524 | 4450 | basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const |
| 4525 | 4451 | { |
| 4526 | 4452 | const value_type* __p = _VSTD::__to_address(__i->base()) + __n; |
| 4527 | return this->data() <= __p && __p <= this->data() + this->size(); | |
| 4453 | return data() <= __p && __p <= data() + size(); | |
| 4528 | 4454 | } |
| 4529 | 4455 | |
| 4530 | 4456 | template<class _CharT, class _Traits, class _Allocator> |
| ... | ... | @@ -4532,7 +4458,7 @@ bool |
| 4532 | 4458 | basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 4533 | 4459 | { |
| 4534 | 4460 | const value_type* __p = _VSTD::__to_address(__i->base()) + __n; |
| 4535 | return this->data() <= __p && __p < this->data() + this->size(); | |
| 4461 | return data() <= __p && __p < data() + size(); | |
| 4536 | 4462 | } |
| 4537 | 4463 | |
| 4538 | 4464 | #endif // _LIBCPP_DEBUG_LEVEL == 2 |
| ... | ... | @@ -4549,11 +4475,13 @@ inline namespace literals |
| 4549 | 4475 | return basic_string<char> (__str, __len); |
| 4550 | 4476 | } |
| 4551 | 4477 | |
| 4478 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4552 | 4479 | inline _LIBCPP_INLINE_VISIBILITY |
| 4553 | 4480 | basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len ) |
| 4554 | 4481 | { |
| 4555 | 4482 | return basic_string<wchar_t> (__str, __len); |
| 4556 | 4483 | } |
| 4484 | #endif | |
| 4557 | 4485 | |
| 4558 | 4486 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 4559 | 4487 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -4574,8 +4502,8 @@ inline namespace literals |
| 4574 | 4502 | { |
| 4575 | 4503 | return basic_string<char32_t> (__str, __len); |
| 4576 | 4504 | } |
| 4577 | } | |
| 4578 | } | |
| 4505 | } // namespace string_literals | |
| 4506 | } // namespace literals | |
| 4579 | 4507 | #endif |
| 4580 | 4508 | |
| 4581 | 4509 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/string.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- string.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/string_view+95-33| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ string_view ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -85,6 +85,10 @@ namespace std { |
| 85 | 85 | constexpr basic_string_view(const charT* str); |
| 86 | 86 | basic_string_view(nullptr_t) = delete; // C++2b |
| 87 | 87 | constexpr basic_string_view(const charT* str, size_type len); |
| 88 | template <class It, class End> | |
| 89 | constexpr basic_string_view(It begin, End end); // C++20 | |
| 90 | template <class Range> | |
| 91 | constexpr basic_string_view(Range&& r); // C++23 | |
| 88 | 92 | |
| 89 | 93 | // 7.4, basic_string_view iterator support |
| 90 | 94 | constexpr const_iterator begin() const noexcept; |
| ... | ... | @@ -166,6 +170,12 @@ namespace std { |
| 166 | 170 | size_type size_; // exposition only |
| 167 | 171 | }; |
| 168 | 172 | |
| 173 | // basic_string_view deduction guides | |
| 174 | template<class It, class End> | |
| 175 | basic_string_view(It, End) -> basic_string_view<iter_value_t<It>>; // C++20 | |
| 176 | template<class Range> | |
| 177 | basic_string_view(Range&&) -> basic_string_view<ranges::range_value_t<Range>>; // C++23 | |
| 178 | ||
| 169 | 179 | // 7.11, Hash support |
| 170 | 180 | template <class T> struct hash; |
| 171 | 181 | template <> struct hash<string_view>; |
| ... | ... | @@ -187,8 +197,11 @@ namespace std { |
| 187 | 197 | |
| 188 | 198 | #include <__config> |
| 189 | 199 | #include <__debug> |
| 200 | #include <__ranges/concepts.h> | |
| 201 | #include <__ranges/data.h> | |
| 190 | 202 | #include <__ranges/enable_borrowed_range.h> |
| 191 | 203 | #include <__ranges/enable_view.h> |
| 204 | #include <__ranges/size.h> | |
| 192 | 205 | #include <__string> |
| 193 | 206 | #include <algorithm> |
| 194 | 207 | #include <compare> |
| ... | ... | @@ -196,6 +209,7 @@ namespace std { |
| 196 | 209 | #include <iterator> |
| 197 | 210 | #include <limits> |
| 198 | 211 | #include <stdexcept> |
| 212 | #include <type_traits> | |
| 199 | 213 | #include <version> |
| 200 | 214 | |
| 201 | 215 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -217,7 +231,9 @@ typedef basic_string_view<char8_t> u8string_view; |
| 217 | 231 | #endif |
| 218 | 232 | typedef basic_string_view<char16_t> u16string_view; |
| 219 | 233 | typedef basic_string_view<char32_t> u32string_view; |
| 234 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 220 | 235 | typedef basic_string_view<wchar_t> wstring_view; |
| 236 | #endif | |
| 221 | 237 | |
| 222 | 238 | template<class _CharT, class _Traits> |
| 223 | 239 | class |
| ... | ... | @@ -227,7 +243,7 @@ class |
| 227 | 243 | #endif |
| 228 | 244 | _LIBCPP_PREFERRED_NAME(u16string_view) |
| 229 | 245 | _LIBCPP_PREFERRED_NAME(u32string_view) |
| 230 | _LIBCPP_PREFERRED_NAME(wstring_view) | |
| 246 | _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wstring_view)) | |
| 231 | 247 | basic_string_view { |
| 232 | 248 | public: |
| 233 | 249 | // types |
| ... | ... | @@ -255,10 +271,10 @@ public: |
| 255 | 271 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY |
| 256 | 272 | basic_string_view() _NOEXCEPT : __data (nullptr), __size(0) {} |
| 257 | 273 | |
| 258 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY | |
| 274 | _LIBCPP_INLINE_VISIBILITY | |
| 259 | 275 | basic_string_view(const basic_string_view&) _NOEXCEPT = default; |
| 260 | 276 | |
| 261 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 277 | _LIBCPP_INLINE_VISIBILITY | |
| 262 | 278 | basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default; |
| 263 | 279 | |
| 264 | 280 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -270,6 +286,35 @@ public: |
| 270 | 286 | #endif |
| 271 | 287 | } |
| 272 | 288 | |
| 289 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 290 | 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>) | |
| 292 | constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end) | |
| 293 | : __data(_VSTD::to_address(__begin)), __size(__end - __begin) | |
| 294 | { | |
| 295 | _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range"); | |
| 296 | } | |
| 297 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 298 | ||
| 299 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 300 | template <class _Range> | |
| 301 | requires ( | |
| 302 | !is_same_v<remove_cvref_t<_Range>, basic_string_view> && | |
| 303 | ranges::contiguous_range<_Range> && | |
| 304 | ranges::sized_range<_Range> && | |
| 305 | is_same_v<ranges::range_value_t<_Range>, _CharT> && | |
| 306 | !is_convertible_v<_Range, const _CharT*> && | |
| 307 | (!requires(remove_cvref_t<_Range>& d) { | |
| 308 | d.operator _VSTD::basic_string_view<_CharT, _Traits>(); | |
| 309 | }) && | |
| 310 | (!requires { | |
| 311 | typename remove_reference_t<_Range>::traits_type; | |
| 312 | } || is_same_v<typename remove_reference_t<_Range>::traits_type, _Traits>) | |
| 313 | ) | |
| 314 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 315 | basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {} | |
| 316 | #endif | |
| 317 | ||
| 273 | 318 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY |
| 274 | 319 | basic_string_view(const _CharT* __s) |
| 275 | 320 | : __data(__s), __size(_VSTD::__char_traits_length_checked<_Traits>(__s)) {} |
| ... | ... | @@ -311,7 +356,7 @@ public: |
| 311 | 356 | size_type length() const _NOEXCEPT { return __size; } |
| 312 | 357 | |
| 313 | 358 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY |
| 314 | size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max(); } | |
| 359 | size_type max_size() const _NOEXCEPT { return numeric_limits<size_type>::max() / sizeof(value_type); } | |
| 315 | 360 | |
| 316 | 361 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 317 | 362 | bool empty() const _NOEXCEPT { return __size == 0; } |
| ... | ... | @@ -618,28 +663,28 @@ public: |
| 618 | 663 | } |
| 619 | 664 | |
| 620 | 665 | #if _LIBCPP_STD_VER > 17 |
| 621 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 622 | bool starts_with(basic_string_view __s) const _NOEXCEPT | |
| 666 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 667 | bool starts_with(basic_string_view __s) const noexcept | |
| 623 | 668 | { return size() >= __s.size() && compare(0, __s.size(), __s) == 0; } |
| 624 | 669 | |
| 625 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 626 | bool starts_with(value_type __c) const _NOEXCEPT | |
| 670 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 671 | bool starts_with(value_type __c) const noexcept | |
| 627 | 672 | { return !empty() && _Traits::eq(front(), __c); } |
| 628 | 673 | |
| 629 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 630 | bool starts_with(const value_type* __s) const _NOEXCEPT | |
| 674 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 675 | bool starts_with(const value_type* __s) const noexcept | |
| 631 | 676 | { return starts_with(basic_string_view(__s)); } |
| 632 | 677 | |
| 633 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 634 | bool ends_with(basic_string_view __s) const _NOEXCEPT | |
| 678 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 679 | bool ends_with(basic_string_view __s) const noexcept | |
| 635 | 680 | { return size() >= __s.size() && compare(size() - __s.size(), npos, __s) == 0; } |
| 636 | 681 | |
| 637 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 638 | bool ends_with(value_type __c) const _NOEXCEPT | |
| 682 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 683 | bool ends_with(value_type __c) const noexcept | |
| 639 | 684 | { return !empty() && _Traits::eq(back(), __c); } |
| 640 | 685 | |
| 641 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 642 | bool ends_with(const value_type* __s) const _NOEXCEPT | |
| 686 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 687 | bool ends_with(const value_type* __s) const noexcept | |
| 643 | 688 | { return ends_with(basic_string_view(__s)); } |
| 644 | 689 | #endif |
| 645 | 690 | |
| ... | ... | @@ -662,13 +707,26 @@ private: |
| 662 | 707 | size_type __size; |
| 663 | 708 | }; |
| 664 | 709 | |
| 665 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 710 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 666 | 711 | template <class _CharT, class _Traits> |
| 667 | 712 | inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true; |
| 668 | 713 | |
| 669 | 714 | template <class _CharT, class _Traits> |
| 670 | 715 | inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true; |
| 671 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_RANGES) | |
| 716 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 717 | ||
| 718 | // [string.view.deduct] | |
| 719 | ||
| 720 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 721 | template <contiguous_iterator _It, sized_sentinel_for<_It> _End> | |
| 722 | basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>; | |
| 723 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 724 | ||
| 725 | ||
| 726 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 727 | template <ranges::contiguous_range _Range> | |
| 728 | basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>; | |
| 729 | #endif | |
| 672 | 730 | |
| 673 | 731 | // [string.view.comparison] |
| 674 | 732 | // operator == |
| ... | ... | @@ -681,7 +739,9 @@ bool operator==(basic_string_view<_CharT, _Traits> __lhs, |
| 681 | 739 | return __lhs.compare(__rhs) == 0; |
| 682 | 740 | } |
| 683 | 741 | |
| 684 | template<class _CharT, class _Traits> | |
| 742 | // The dummy default template parameters are used to work around a MSVC issue with mangling, see VSO-409326 for details. | |
| 743 | // This applies to the other sufficient overloads below for the other comparison operators. | |
| 744 | template<class _CharT, class _Traits, int = 1> | |
| 685 | 745 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 686 | 746 | bool operator==(basic_string_view<_CharT, _Traits> __lhs, |
| 687 | 747 | typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT |
| ... | ... | @@ -690,7 +750,7 @@ bool operator==(basic_string_view<_CharT, _Traits> __lhs, |
| 690 | 750 | return __lhs.compare(__rhs) == 0; |
| 691 | 751 | } |
| 692 | 752 | |
| 693 | template<class _CharT, class _Traits> | |
| 753 | template<class _CharT, class _Traits, int = 2> | |
| 694 | 754 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 695 | 755 | bool operator==(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, |
| 696 | 756 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT |
| ... | ... | @@ -710,7 +770,7 @@ bool operator!=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha |
| 710 | 770 | return __lhs.compare(__rhs) != 0; |
| 711 | 771 | } |
| 712 | 772 | |
| 713 | template<class _CharT, class _Traits> | |
| 773 | template<class _CharT, class _Traits, int = 1> | |
| 714 | 774 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 715 | 775 | bool operator!=(basic_string_view<_CharT, _Traits> __lhs, |
| 716 | 776 | typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT |
| ... | ... | @@ -720,7 +780,7 @@ bool operator!=(basic_string_view<_CharT, _Traits> __lhs, |
| 720 | 780 | return __lhs.compare(__rhs) != 0; |
| 721 | 781 | } |
| 722 | 782 | |
| 723 | template<class _CharT, class _Traits> | |
| 783 | template<class _CharT, class _Traits, int = 2> | |
| 724 | 784 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 725 | 785 | bool operator!=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, |
| 726 | 786 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT |
| ... | ... | @@ -739,7 +799,7 @@ bool operator<(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Char |
| 739 | 799 | return __lhs.compare(__rhs) < 0; |
| 740 | 800 | } |
| 741 | 801 | |
| 742 | template<class _CharT, class _Traits> | |
| 802 | template<class _CharT, class _Traits, int = 1> | |
| 743 | 803 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 744 | 804 | bool operator<(basic_string_view<_CharT, _Traits> __lhs, |
| 745 | 805 | typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT |
| ... | ... | @@ -747,7 +807,7 @@ bool operator<(basic_string_view<_CharT, _Traits> __lhs, |
| 747 | 807 | return __lhs.compare(__rhs) < 0; |
| 748 | 808 | } |
| 749 | 809 | |
| 750 | template<class _CharT, class _Traits> | |
| 810 | template<class _CharT, class _Traits, int = 2> | |
| 751 | 811 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 752 | 812 | bool operator<(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, |
| 753 | 813 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT |
| ... | ... | @@ -764,7 +824,7 @@ bool operator> (basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha |
| 764 | 824 | return __lhs.compare(__rhs) > 0; |
| 765 | 825 | } |
| 766 | 826 | |
| 767 | template<class _CharT, class _Traits> | |
| 827 | template<class _CharT, class _Traits, int = 1> | |
| 768 | 828 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 769 | 829 | bool operator>(basic_string_view<_CharT, _Traits> __lhs, |
| 770 | 830 | typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT |
| ... | ... | @@ -772,7 +832,7 @@ bool operator>(basic_string_view<_CharT, _Traits> __lhs, |
| 772 | 832 | return __lhs.compare(__rhs) > 0; |
| 773 | 833 | } |
| 774 | 834 | |
| 775 | template<class _CharT, class _Traits> | |
| 835 | template<class _CharT, class _Traits, int = 2> | |
| 776 | 836 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 777 | 837 | bool operator>(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, |
| 778 | 838 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT |
| ... | ... | @@ -789,7 +849,7 @@ bool operator<=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha |
| 789 | 849 | return __lhs.compare(__rhs) <= 0; |
| 790 | 850 | } |
| 791 | 851 | |
| 792 | template<class _CharT, class _Traits> | |
| 852 | template<class _CharT, class _Traits, int = 1> | |
| 793 | 853 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 794 | 854 | bool operator<=(basic_string_view<_CharT, _Traits> __lhs, |
| 795 | 855 | typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT |
| ... | ... | @@ -797,7 +857,7 @@ bool operator<=(basic_string_view<_CharT, _Traits> __lhs, |
| 797 | 857 | return __lhs.compare(__rhs) <= 0; |
| 798 | 858 | } |
| 799 | 859 | |
| 800 | template<class _CharT, class _Traits> | |
| 860 | template<class _CharT, class _Traits, int = 2> | |
| 801 | 861 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 802 | 862 | bool operator<=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, |
| 803 | 863 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT |
| ... | ... | @@ -815,7 +875,7 @@ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_Cha |
| 815 | 875 | } |
| 816 | 876 | |
| 817 | 877 | |
| 818 | template<class _CharT, class _Traits> | |
| 878 | template<class _CharT, class _Traits, int = 1> | |
| 819 | 879 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 820 | 880 | bool operator>=(basic_string_view<_CharT, _Traits> __lhs, |
| 821 | 881 | typename common_type<basic_string_view<_CharT, _Traits> >::type __rhs) _NOEXCEPT |
| ... | ... | @@ -823,7 +883,7 @@ bool operator>=(basic_string_view<_CharT, _Traits> __lhs, |
| 823 | 883 | return __lhs.compare(__rhs) >= 0; |
| 824 | 884 | } |
| 825 | 885 | |
| 826 | template<class _CharT, class _Traits> | |
| 886 | template<class _CharT, class _Traits, int = 2> | |
| 827 | 887 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 828 | 888 | bool operator>=(typename common_type<basic_string_view<_CharT, _Traits> >::type __lhs, |
| 829 | 889 | basic_string_view<_CharT, _Traits> __rhs) _NOEXCEPT |
| ... | ... | @@ -860,11 +920,13 @@ inline namespace literals |
| 860 | 920 | return basic_string_view<char> (__str, __len); |
| 861 | 921 | } |
| 862 | 922 | |
| 923 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 863 | 924 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 864 | 925 | basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT |
| 865 | 926 | { |
| 866 | 927 | return basic_string_view<wchar_t> (__str, __len); |
| 867 | 928 | } |
| 929 | #endif | |
| 868 | 930 | |
| 869 | 931 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 870 | 932 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| ... | ... | @@ -885,8 +947,8 @@ inline namespace literals |
| 885 | 947 | { |
| 886 | 948 | return basic_string_view<char32_t> (__str, __len); |
| 887 | 949 | } |
| 888 | } | |
| 889 | } | |
| 950 | } // namespace string_view_literals | |
| 951 | } // namespace literals | |
| 890 | 952 | #endif |
| 891 | 953 | _LIBCPP_END_NAMESPACE_STD |
| 892 | 954 |
lib/libcxx/include/strstream+2-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- strstream --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -132,6 +132,7 @@ private: |
| 132 | 132 | #include <__config> |
| 133 | 133 | #include <istream> |
| 134 | 134 | #include <ostream> |
| 135 | #include <version> | |
| 135 | 136 | |
| 136 | 137 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 137 | 138 | #pragma GCC system_header |
lib/libcxx/include/system_error+9-10| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===---------------------------- system_error ----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -46,10 +46,10 @@ template <class T> struct is_error_condition_enum |
| 46 | 46 | : public false_type {}; |
| 47 | 47 | |
| 48 | 48 | template <class _Tp> |
| 49 | inline constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 | |
| 49 | inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; // C++17 | |
| 50 | 50 | |
| 51 | 51 | template <class _Tp> |
| 52 | inline constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 | |
| 52 | inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; // C++17 | |
| 53 | 53 | |
| 54 | 54 | class error_code |
| 55 | 55 | { |
| ... | ... | @@ -150,6 +150,7 @@ template <> struct hash<std::error_condition>; |
| 150 | 150 | #include <stdexcept> |
| 151 | 151 | #include <string> |
| 152 | 152 | #include <type_traits> |
| 153 | #include <version> | |
| 153 | 154 | |
| 154 | 155 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 155 | 156 | #pragma GCC system_header |
| ... | ... | @@ -165,7 +166,7 @@ struct _LIBCPP_TEMPLATE_VIS is_error_code_enum |
| 165 | 166 | |
| 166 | 167 | #if _LIBCPP_STD_VER > 14 |
| 167 | 168 | template <class _Tp> |
| 168 | _LIBCPP_INLINE_VAR constexpr size_t is_error_code_enum_v = is_error_code_enum<_Tp>::value; | |
| 169 | inline constexpr bool is_error_code_enum_v = is_error_code_enum<_Tp>::value; | |
| 169 | 170 | #endif |
| 170 | 171 | |
| 171 | 172 | // is_error_condition_enum |
| ... | ... | @@ -176,7 +177,7 @@ struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum |
| 176 | 177 | |
| 177 | 178 | #if _LIBCPP_STD_VER > 14 |
| 178 | 179 | template <class _Tp> |
| 179 | _LIBCPP_INLINE_VAR constexpr size_t is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; | |
| 180 | inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::value; | |
| 180 | 181 | #endif |
| 181 | 182 | |
| 182 | 183 | template <> |
| ... | ... | @@ -206,13 +207,11 @@ public: |
| 206 | 207 | error_category() _NOEXCEPT; |
| 207 | 208 | #else |
| 208 | 209 | _LIBCPP_INLINE_VISIBILITY |
| 209 | _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT | |
| 210 | _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default; | |
| 210 | 211 | #endif |
| 211 | private: | |
| 212 | error_category(const error_category&);// = delete; | |
| 213 | error_category& operator=(const error_category&);// = delete; | |
| 212 | error_category(const error_category&) = delete; | |
| 213 | error_category& operator=(const error_category&) = delete; | |
| 214 | 214 | |
| 215 | public: | |
| 216 | 215 | virtual const char* name() const _NOEXCEPT = 0; |
| 217 | 216 | virtual error_condition default_error_condition(int __ev) const _NOEXCEPT; |
| 218 | 217 | virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT; |
lib/libcxx/include/tgmath.h+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- tgmath.h ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/include/thread+7-5| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- thread -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -86,8 +86,9 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
| 86 | 86 | #include <__debug> |
| 87 | 87 | #include <__functional_base> |
| 88 | 88 | #include <__mutex_base> |
| 89 | #include <__thread/poll_with_backoff.h> | |
| 90 | #include <__thread/timed_backoff_policy.h> | |
| 89 | 91 | #include <__threading_support> |
| 90 | #include <__utility/__decay_copy.h> | |
| 91 | 92 | #include <__utility/forward.h> |
| 92 | 93 | #include <chrono> |
| 93 | 94 | #include <cstddef> |
| ... | ... | @@ -97,6 +98,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
| 97 | 98 | #include <system_error> |
| 98 | 99 | #include <tuple> |
| 99 | 100 | #include <type_traits> |
| 101 | #include <version> | |
| 100 | 102 | |
| 101 | 103 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 102 | 104 | #pragma GCC system_header |
| ... | ... | @@ -302,8 +304,8 @@ thread::thread(_Fp&& __f, _Args&&... __args) |
| 302 | 304 | typedef tuple<_TSPtr, typename decay<_Fp>::type, typename decay<_Args>::type...> _Gp; |
| 303 | 305 | unique_ptr<_Gp> __p( |
| 304 | 306 | new _Gp(_VSTD::move(__tsp), |
| 305 | _VSTD::__decay_copy(_VSTD::forward<_Fp>(__f)), | |
| 306 | _VSTD::__decay_copy(_VSTD::forward<_Args>(__args))...)); | |
| 307 | _VSTD::forward<_Fp>(__f), | |
| 308 | _VSTD::forward<_Args>(__args)...)); | |
| 307 | 309 | int __ec = _VSTD::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get()); |
| 308 | 310 | if (__ec == 0) |
| 309 | 311 | __p.release(); |
| ... | ... | @@ -402,7 +404,7 @@ sleep_until(const chrono::time_point<chrono::steady_clock, _Duration>& __t) |
| 402 | 404 | inline _LIBCPP_INLINE_VISIBILITY |
| 403 | 405 | void yield() _NOEXCEPT {__libcpp_thread_yield();} |
| 404 | 406 | |
| 405 | } // this_thread | |
| 407 | } // namespace this_thread | |
| 406 | 408 | |
| 407 | 409 | _LIBCPP_END_NAMESPACE_STD |
| 408 | 410 |
lib/libcxx/include/tuple+119-60| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- tuple ------------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -73,6 +73,19 @@ public: |
| 73 | 73 | void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20 |
| 74 | 74 | }; |
| 75 | 75 | |
| 76 | ||
| 77 | template<class... TTypes, class... UTypes, template<class> class TQual, template<class> class UQual> // since C++23 | |
| 78 | requires requires { typename tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>; } | |
| 79 | struct basic_common_reference<tuple<TTypes...>, tuple<UTypes...>, TQual, UQual> { | |
| 80 | using type = tuple<common_reference_t<TQual<TTypes>, UQual<UTypes>>...>; | |
| 81 | }; | |
| 82 | ||
| 83 | template<class... TTypes, class... UTypes> // since C++23 | |
| 84 | requires requires { typename tuple<common_type_t<TTypes, UTypes>...>; } | |
| 85 | struct common_type<tuple<TTypes...>, tuple<UTypes...>> { | |
| 86 | using type = tuple<common_type_t<TTypes, UTypes>...>; | |
| 87 | }; | |
| 88 | ||
| 76 | 89 | template <class ...T> |
| 77 | 90 | tuple(T...) -> tuple<T...>; // since C++17 |
| 78 | 91 | template <class T1, class T2> |
| ... | ... | @@ -132,11 +145,14 @@ template <class T1, class... T> |
| 132 | 145 | |
| 133 | 146 | // 20.4.1.6, relational operators: |
| 134 | 147 | template<class... T, class... U> bool operator==(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 |
| 135 | template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 | |
| 136 | template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 | |
| 137 | template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 | |
| 138 | template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 | |
| 139 | template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14 | |
| 148 | template<class... T, class... U> bool operator<(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20 | |
| 149 | template<class... T, class... U> bool operator!=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20 | |
| 150 | template<class... T, class... U> bool operator>(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20 | |
| 151 | template<class... T, class... U> bool operator<=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20 | |
| 152 | template<class... T, class... U> bool operator>=(const tuple<T...>&, const tuple<U...>&); // constexpr in C++14, removed in C++20 | |
| 153 | template<class... T, class... U> | |
| 154 | constexpr common_comparison_category_t<synth-three-way-result<T, U>...> | |
| 155 | operator<=>(const tuple<T...>&, const tuple<U...>&); // since C++20 | |
| 140 | 156 | |
| 141 | 157 | template <class... Types, class Alloc> |
| 142 | 158 | struct uses_allocator<tuple<Types...>, Alloc>; |
| ... | ... | @@ -149,6 +165,8 @@ template <class... Types> |
| 149 | 165 | |
| 150 | 166 | */ |
| 151 | 167 | |
| 168 | #include <__compare/common_comparison_category.h> | |
| 169 | #include <__compare/synth_three_way.h> | |
| 152 | 170 | #include <__config> |
| 153 | 171 | #include <__functional/unwrap_ref.h> |
| 154 | 172 | #include <__functional_base> |
| ... | ... | @@ -156,6 +174,7 @@ template <class... Types> |
| 156 | 174 | #include <__memory/uses_allocator.h> |
| 157 | 175 | #include <__tuple> |
| 158 | 176 | #include <__utility/forward.h> |
| 177 | #include <__utility/integer_sequence.h> | |
| 159 | 178 | #include <__utility/move.h> |
| 160 | 179 | #include <compare> |
| 161 | 180 | #include <cstddef> |
| ... | ... | @@ -231,7 +250,7 @@ public: |
| 231 | 250 | "Attempted to default construct a reference element in a tuple");} |
| 232 | 251 | |
| 233 | 252 | template <class _Tp, |
| 234 | class = _EnableIf< | |
| 253 | class = __enable_if_t< | |
| 235 | 254 | _And< |
| 236 | 255 | _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>, |
| 237 | 256 | is_constructible<_Hp, _Tp> |
| ... | ... | @@ -304,7 +323,7 @@ public: |
| 304 | 323 | : _Hp(__a) {} |
| 305 | 324 | |
| 306 | 325 | template <class _Tp, |
| 307 | class = _EnableIf< | |
| 326 | class = __enable_if_t< | |
| 308 | 327 | _And< |
| 309 | 328 | _IsNotSame<__uncvref_t<_Tp>, __tuple_leaf>, |
| 310 | 329 | is_constructible<_Hp, _Tp> |
| ... | ... | @@ -466,7 +485,7 @@ public: |
| 466 | 485 | // [tuple.cnstr] |
| 467 | 486 | |
| 468 | 487 | // tuple() constructors (including allocator_arg_t variants) |
| 469 | template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, _EnableIf< | |
| 488 | template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t< | |
| 470 | 489 | _And< |
| 471 | 490 | _IsImpDefault<_Tp>... // explicit check |
| 472 | 491 | >::value |
| ... | ... | @@ -477,7 +496,7 @@ public: |
| 477 | 496 | { } |
| 478 | 497 | |
| 479 | 498 | template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, |
| 480 | template<class...> class _IsDefault = is_default_constructible, _EnableIf< | |
| 499 | template<class...> class _IsDefault = is_default_constructible, __enable_if_t< | |
| 481 | 500 | _And< |
| 482 | 501 | _IsDefault<_Tp>..., |
| 483 | 502 | _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check |
| ... | ... | @@ -488,7 +507,7 @@ public: |
| 488 | 507 | _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value) |
| 489 | 508 | { } |
| 490 | 509 | |
| 491 | template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, _EnableIf< | |
| 510 | template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t< | |
| 492 | 511 | _And< |
| 493 | 512 | _IsImpDefault<_Tp>... // explicit check |
| 494 | 513 | >::value |
| ... | ... | @@ -502,7 +521,7 @@ public: |
| 502 | 521 | |
| 503 | 522 | template <class _Alloc, |
| 504 | 523 | template<class...> class _IsImpDefault = __is_implicitly_default_constructible, |
| 505 | template<class...> class _IsDefault = is_default_constructible, _EnableIf< | |
| 524 | template<class...> class _IsDefault = is_default_constructible, __enable_if_t< | |
| 506 | 525 | _And< |
| 507 | 526 | _IsDefault<_Tp>..., |
| 508 | 527 | _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check |
| ... | ... | @@ -516,7 +535,7 @@ public: |
| 516 | 535 | __tuple_types<_Tp...>()) {} |
| 517 | 536 | |
| 518 | 537 | // tuple(const T&...) constructors (including allocator_arg_t variants) |
| 519 | template <template<class...> class _And = _And, _EnableIf< | |
| 538 | template <template<class...> class _And = _And, __enable_if_t< | |
| 520 | 539 | _And< |
| 521 | 540 | _BoolConstant<sizeof...(_Tp) >= 1>, |
| 522 | 541 | is_copy_constructible<_Tp>..., |
| ... | ... | @@ -533,7 +552,7 @@ public: |
| 533 | 552 | __t... |
| 534 | 553 | ) {} |
| 535 | 554 | |
| 536 | template <template<class...> class _And = _And, _EnableIf< | |
| 555 | template <template<class...> class _And = _And, __enable_if_t< | |
| 537 | 556 | _And< |
| 538 | 557 | _BoolConstant<sizeof...(_Tp) >= 1>, |
| 539 | 558 | is_copy_constructible<_Tp>..., |
| ... | ... | @@ -550,7 +569,7 @@ public: |
| 550 | 569 | __t... |
| 551 | 570 | ) {} |
| 552 | 571 | |
| 553 | template <class _Alloc, template<class...> class _And = _And, _EnableIf< | |
| 572 | template <class _Alloc, template<class...> class _And = _And, __enable_if_t< | |
| 554 | 573 | _And< |
| 555 | 574 | _BoolConstant<sizeof...(_Tp) >= 1>, |
| 556 | 575 | is_copy_constructible<_Tp>..., |
| ... | ... | @@ -567,7 +586,7 @@ public: |
| 567 | 586 | __t... |
| 568 | 587 | ) {} |
| 569 | 588 | |
| 570 | template <class _Alloc, template<class...> class _And = _And, _EnableIf< | |
| 589 | template <class _Alloc, template<class...> class _And = _And, __enable_if_t< | |
| 571 | 590 | _And< |
| 572 | 591 | _BoolConstant<sizeof...(_Tp) >= 1>, |
| 573 | 592 | is_copy_constructible<_Tp>..., |
| ... | ... | @@ -595,7 +614,7 @@ public: |
| 595 | 614 | is_constructible<_Tp, _Up>... |
| 596 | 615 | > { }; |
| 597 | 616 | |
| 598 | template <class ..._Up, _EnableIf< | |
| 617 | template <class ..._Up, __enable_if_t< | |
| 599 | 618 | _And< |
| 600 | 619 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 601 | 620 | _EnableUTypesCtor<_Up...>, |
| ... | ... | @@ -611,7 +630,7 @@ public: |
| 611 | 630 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 612 | 631 | _VSTD::forward<_Up>(__u)...) {} |
| 613 | 632 | |
| 614 | template <class ..._Up, _EnableIf< | |
| 633 | template <class ..._Up, __enable_if_t< | |
| 615 | 634 | _And< |
| 616 | 635 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 617 | 636 | _EnableUTypesCtor<_Up...>, |
| ... | ... | @@ -627,7 +646,7 @@ public: |
| 627 | 646 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 628 | 647 | _VSTD::forward<_Up>(__u)...) {} |
| 629 | 648 | |
| 630 | template <class _Alloc, class ..._Up, _EnableIf< | |
| 649 | template <class _Alloc, class ..._Up, __enable_if_t< | |
| 631 | 650 | _And< |
| 632 | 651 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 633 | 652 | _EnableUTypesCtor<_Up...>, |
| ... | ... | @@ -643,7 +662,7 @@ public: |
| 643 | 662 | typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), |
| 644 | 663 | _VSTD::forward<_Up>(__u)...) {} |
| 645 | 664 | |
| 646 | template <class _Alloc, class ..._Up, _EnableIf< | |
| 665 | template <class _Alloc, class ..._Up, __enable_if_t< | |
| 647 | 666 | _And< |
| 648 | 667 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 649 | 668 | _EnableUTypesCtor<_Up...>, |
| ... | ... | @@ -663,14 +682,14 @@ public: |
| 663 | 682 | tuple(const tuple&) = default; |
| 664 | 683 | tuple(tuple&&) = default; |
| 665 | 684 | |
| 666 | template <class _Alloc, template<class...> class _And = _And, _EnableIf< | |
| 685 | template <class _Alloc, template<class...> class _And = _And, __enable_if_t< | |
| 667 | 686 | _And<is_copy_constructible<_Tp>...>::value |
| 668 | 687 | , int> = 0> |
| 669 | 688 | tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t) |
| 670 | 689 | : __base_(allocator_arg_t(), __alloc, __t) |
| 671 | 690 | { } |
| 672 | 691 | |
| 673 | template <class _Alloc, template<class...> class _And = _And, _EnableIf< | |
| 692 | template <class _Alloc, template<class...> class _And = _And, __enable_if_t< | |
| 674 | 693 | _And<is_move_constructible<_Tp>...>::value |
| 675 | 694 | , int> = 0> |
| 676 | 695 | tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t) |
| ... | ... | @@ -693,7 +712,7 @@ public: |
| 693 | 712 | is_constructible<_Tp, const _Up&>... |
| 694 | 713 | > { }; |
| 695 | 714 | |
| 696 | template <class ..._Up, _EnableIf< | |
| 715 | template <class ..._Up, __enable_if_t< | |
| 697 | 716 | _And< |
| 698 | 717 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 699 | 718 | _EnableCopyFromOtherTuple<_Up...>, |
| ... | ... | @@ -706,7 +725,7 @@ public: |
| 706 | 725 | : __base_(__t) |
| 707 | 726 | { } |
| 708 | 727 | |
| 709 | template <class ..._Up, _EnableIf< | |
| 728 | template <class ..._Up, __enable_if_t< | |
| 710 | 729 | _And< |
| 711 | 730 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 712 | 731 | _EnableCopyFromOtherTuple<_Up...>, |
| ... | ... | @@ -719,7 +738,7 @@ public: |
| 719 | 738 | : __base_(__t) |
| 720 | 739 | { } |
| 721 | 740 | |
| 722 | template <class ..._Up, class _Alloc, _EnableIf< | |
| 741 | template <class ..._Up, class _Alloc, __enable_if_t< | |
| 723 | 742 | _And< |
| 724 | 743 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 725 | 744 | _EnableCopyFromOtherTuple<_Up...>, |
| ... | ... | @@ -731,7 +750,7 @@ public: |
| 731 | 750 | : __base_(allocator_arg_t(), __a, __t) |
| 732 | 751 | { } |
| 733 | 752 | |
| 734 | template <class ..._Up, class _Alloc, _EnableIf< | |
| 753 | template <class ..._Up, class _Alloc, __enable_if_t< | |
| 735 | 754 | _And< |
| 736 | 755 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 737 | 756 | _EnableCopyFromOtherTuple<_Up...>, |
| ... | ... | @@ -759,7 +778,7 @@ public: |
| 759 | 778 | is_constructible<_Tp, _Up>... |
| 760 | 779 | > { }; |
| 761 | 780 | |
| 762 | template <class ..._Up, _EnableIf< | |
| 781 | template <class ..._Up, __enable_if_t< | |
| 763 | 782 | _And< |
| 764 | 783 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 765 | 784 | _EnableMoveFromOtherTuple<_Up...>, |
| ... | ... | @@ -772,7 +791,7 @@ public: |
| 772 | 791 | : __base_(_VSTD::move(__t)) |
| 773 | 792 | { } |
| 774 | 793 | |
| 775 | template <class ..._Up, _EnableIf< | |
| 794 | template <class ..._Up, __enable_if_t< | |
| 776 | 795 | _And< |
| 777 | 796 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 778 | 797 | _EnableMoveFromOtherTuple<_Up...>, |
| ... | ... | @@ -785,7 +804,7 @@ public: |
| 785 | 804 | : __base_(_VSTD::move(__t)) |
| 786 | 805 | { } |
| 787 | 806 | |
| 788 | template <class _Alloc, class ..._Up, _EnableIf< | |
| 807 | template <class _Alloc, class ..._Up, __enable_if_t< | |
| 789 | 808 | _And< |
| 790 | 809 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 791 | 810 | _EnableMoveFromOtherTuple<_Up...>, |
| ... | ... | @@ -797,7 +816,7 @@ public: |
| 797 | 816 | : __base_(allocator_arg_t(), __a, _VSTD::move(__t)) |
| 798 | 817 | { } |
| 799 | 818 | |
| 800 | template <class _Alloc, class ..._Up, _EnableIf< | |
| 819 | template <class _Alloc, class ..._Up, __enable_if_t< | |
| 801 | 820 | _And< |
| 802 | 821 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, |
| 803 | 822 | _EnableMoveFromOtherTuple<_Up...>, |
| ... | ... | @@ -826,7 +845,7 @@ public: |
| 826 | 845 | _Not<is_convertible<const _Up2&, _SecondType<_DependentTp...> > > |
| 827 | 846 | > { }; |
| 828 | 847 | |
| 829 | template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 848 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 830 | 849 | _And< |
| 831 | 850 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 832 | 851 | _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -841,7 +860,7 @@ public: |
| 841 | 860 | : __base_(__p) |
| 842 | 861 | { } |
| 843 | 862 | |
| 844 | template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 863 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 845 | 864 | _And< |
| 846 | 865 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 847 | 866 | _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -856,7 +875,7 @@ public: |
| 856 | 875 | : __base_(__p) |
| 857 | 876 | { } |
| 858 | 877 | |
| 859 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 878 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 860 | 879 | _And< |
| 861 | 880 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 862 | 881 | _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -867,7 +886,7 @@ public: |
| 867 | 886 | : __base_(allocator_arg_t(), __a, __p) |
| 868 | 887 | { } |
| 869 | 888 | |
| 870 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 889 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 871 | 890 | _And< |
| 872 | 891 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 873 | 892 | _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -895,7 +914,7 @@ public: |
| 895 | 914 | _Not<is_convertible<_Up2, _SecondType<_DependentTp...> > > |
| 896 | 915 | > { }; |
| 897 | 916 | |
| 898 | template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 917 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 899 | 918 | _And< |
| 900 | 919 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 901 | 920 | _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -910,7 +929,7 @@ public: |
| 910 | 929 | : __base_(_VSTD::move(__p)) |
| 911 | 930 | { } |
| 912 | 931 | |
| 913 | template <class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 932 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 914 | 933 | _And< |
| 915 | 934 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 916 | 935 | _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -925,7 +944,7 @@ public: |
| 925 | 944 | : __base_(_VSTD::move(__p)) |
| 926 | 945 | { } |
| 927 | 946 | |
| 928 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 947 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 929 | 948 | _And< |
| 930 | 949 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 931 | 950 | _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -936,7 +955,7 @@ public: |
| 936 | 955 | : __base_(allocator_arg_t(), __a, _VSTD::move(__p)) |
| 937 | 956 | { } |
| 938 | 957 | |
| 939 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, _EnableIf< | |
| 958 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< | |
| 940 | 959 | _And< |
| 941 | 960 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 942 | 961 | _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...> |
| ... | ... | @@ -967,7 +986,7 @@ public: |
| 967 | 986 | return *this; |
| 968 | 987 | } |
| 969 | 988 | |
| 970 | template<class... _Up, _EnableIf< | |
| 989 | template<class... _Up, __enable_if_t< | |
| 971 | 990 | _And< |
| 972 | 991 | _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, |
| 973 | 992 | is_assignable<_Tp&, _Up const&>... |
| ... | ... | @@ -982,7 +1001,7 @@ public: |
| 982 | 1001 | return *this; |
| 983 | 1002 | } |
| 984 | 1003 | |
| 985 | template<class... _Up, _EnableIf< | |
| 1004 | template<class... _Up, __enable_if_t< | |
| 986 | 1005 | _And< |
| 987 | 1006 | _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, |
| 988 | 1007 | is_assignable<_Tp&, _Up>... |
| ... | ... | @@ -998,7 +1017,7 @@ public: |
| 998 | 1017 | return *this; |
| 999 | 1018 | } |
| 1000 | 1019 | |
| 1001 | template<class _Up1, class _Up2, class _Dep = true_type, _EnableIf< | |
| 1020 | template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t< | |
| 1002 | 1021 | _And<_Dep, |
| 1003 | 1022 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 1004 | 1023 | is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>, |
| ... | ... | @@ -1017,7 +1036,7 @@ public: |
| 1017 | 1036 | return *this; |
| 1018 | 1037 | } |
| 1019 | 1038 | |
| 1020 | template<class _Up1, class _Up2, class _Dep = true_type, _EnableIf< | |
| 1039 | template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t< | |
| 1021 | 1040 | _And<_Dep, |
| 1022 | 1041 | _BoolConstant<sizeof...(_Tp) == 2>, |
| 1023 | 1042 | is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>, |
| ... | ... | @@ -1037,7 +1056,7 @@ public: |
| 1037 | 1056 | } |
| 1038 | 1057 | |
| 1039 | 1058 | // EXTENSION |
| 1040 | template<class _Up, size_t _Np, class = _EnableIf< | |
| 1059 | template<class _Up, size_t _Np, class = __enable_if_t< | |
| 1041 | 1060 | _And< |
| 1042 | 1061 | _BoolConstant<_Np == sizeof...(_Tp)>, |
| 1043 | 1062 | is_assignable<_Tp&, _Up const&>... |
| ... | ... | @@ -1053,7 +1072,7 @@ public: |
| 1053 | 1072 | } |
| 1054 | 1073 | |
| 1055 | 1074 | // EXTENSION |
| 1056 | template<class _Up, size_t _Np, class = void, class = _EnableIf< | |
| 1075 | template<class _Up, size_t _Np, class = void, class = __enable_if_t< | |
| 1057 | 1076 | _And< |
| 1058 | 1077 | _BoolConstant<_Np == sizeof...(_Tp)>, |
| 1059 | 1078 | is_assignable<_Tp&, _Up>... |
| ... | ... | @@ -1097,7 +1116,21 @@ public: |
| 1097 | 1116 | void swap(tuple&) _NOEXCEPT {} |
| 1098 | 1117 | }; |
| 1099 | 1118 | |
| 1100 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1119 | #if _LIBCPP_STD_VER > 20 | |
| 1120 | template <class... _TTypes, class... _UTypes, template<class> class _TQual, template<class> class _UQual> | |
| 1121 | requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; } | |
| 1122 | struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> { | |
| 1123 | using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; | |
| 1124 | }; | |
| 1125 | ||
| 1126 | template <class... _TTypes, class... _UTypes> | |
| 1127 | requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; } | |
| 1128 | struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> { | |
| 1129 | using type = tuple<common_type_t<_TTypes, _UTypes>...>; | |
| 1130 | }; | |
| 1131 | #endif | |
| 1132 | ||
| 1133 | #if _LIBCPP_STD_VER > 14 | |
| 1101 | 1134 | template <class ..._Tp> |
| 1102 | 1135 | tuple(_Tp...) -> tuple<_Tp...>; |
| 1103 | 1136 | template <class _Tp1, class _Tp2> |
| ... | ... | @@ -1128,7 +1161,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1128 | 1161 | typename tuple_element<_Ip, tuple<_Tp...> >::type& |
| 1129 | 1162 | get(tuple<_Tp...>& __t) _NOEXCEPT |
| 1130 | 1163 | { |
| 1131 | typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1164 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1132 | 1165 | return static_cast<__tuple_leaf<_Ip, type>&>(__t.__base_).get(); |
| 1133 | 1166 | } |
| 1134 | 1167 | |
| ... | ... | @@ -1137,7 +1170,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1137 | 1170 | const typename tuple_element<_Ip, tuple<_Tp...> >::type& |
| 1138 | 1171 | get(const tuple<_Tp...>& __t) _NOEXCEPT |
| 1139 | 1172 | { |
| 1140 | typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1173 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1141 | 1174 | return static_cast<const __tuple_leaf<_Ip, type>&>(__t.__base_).get(); |
| 1142 | 1175 | } |
| 1143 | 1176 | |
| ... | ... | @@ -1146,7 +1179,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1146 | 1179 | typename tuple_element<_Ip, tuple<_Tp...> >::type&& |
| 1147 | 1180 | get(tuple<_Tp...>&& __t) _NOEXCEPT |
| 1148 | 1181 | { |
| 1149 | typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1182 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1150 | 1183 | return static_cast<type&&>( |
| 1151 | 1184 | static_cast<__tuple_leaf<_Ip, type>&&>(__t.__base_).get()); |
| 1152 | 1185 | } |
| ... | ... | @@ -1156,7 +1189,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1156 | 1189 | const typename tuple_element<_Ip, tuple<_Tp...> >::type&& |
| 1157 | 1190 | get(const tuple<_Tp...>&& __t) _NOEXCEPT |
| 1158 | 1191 | { |
| 1159 | typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1192 | typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, tuple<_Tp...> >::type type; | |
| 1160 | 1193 | return static_cast<const type&&>( |
| 1161 | 1194 | static_cast<const __tuple_leaf<_Ip, type>&&>(__t.__base_).get()); |
| 1162 | 1195 | } |
| ... | ... | @@ -1194,7 +1227,7 @@ struct __find_exactly_one_checked<_T1> { |
| 1194 | 1227 | static_assert(!is_same<_T1, _T1>::value, "type not in empty type list"); |
| 1195 | 1228 | }; |
| 1196 | 1229 | |
| 1197 | } // namespace __find_detail; | |
| 1230 | } // namespace __find_detail | |
| 1198 | 1231 | |
| 1199 | 1232 | template <typename _T1, typename... _Args> |
| 1200 | 1233 | struct __find_exactly_one_t |
| ... | ... | @@ -1250,8 +1283,8 @@ struct __ignore_t |
| 1250 | 1283 | }; |
| 1251 | 1284 | |
| 1252 | 1285 | namespace { |
| 1253 | _LIBCPP_INLINE_VAR constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); | |
| 1254 | } | |
| 1286 | constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); | |
| 1287 | } // namespace | |
| 1255 | 1288 | |
| 1256 | 1289 | template <class... _Tp> |
| 1257 | 1290 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| ... | ... | @@ -1300,6 +1333,30 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 1300 | 1333 | return __tuple_equal<sizeof...(_Tp)>()(__x, __y); |
| 1301 | 1334 | } |
| 1302 | 1335 | |
| 1336 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1337 | ||
| 1338 | // operator<=> | |
| 1339 | ||
| 1340 | template <class ..._Tp, class ..._Up, size_t ..._Is> | |
| 1341 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1342 | auto | |
| 1343 | __tuple_compare_three_way(const tuple<_Tp...>& __x, const tuple<_Up...>& __y, index_sequence<_Is...>) { | |
| 1344 | common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> __result = strong_ordering::equal; | |
| 1345 | static_cast<void>(((__result = _VSTD::__synth_three_way(_VSTD::get<_Is>(__x), _VSTD::get<_Is>(__y)), __result != 0) || ...)); | |
| 1346 | return __result; | |
| 1347 | } | |
| 1348 | ||
| 1349 | template <class ..._Tp, class ..._Up> | |
| 1350 | requires (sizeof...(_Tp) == sizeof...(_Up)) | |
| 1351 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1352 | common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...> | |
| 1353 | operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) | |
| 1354 | { | |
| 1355 | return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{}); | |
| 1356 | } | |
| 1357 | ||
| 1358 | #else // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1359 | ||
| 1303 | 1360 | template <class ..._Tp, class ..._Up> |
| 1304 | 1361 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1305 | 1362 | bool |
| ... | ... | @@ -1368,6 +1425,8 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 1368 | 1425 | return !(__y < __x); |
| 1369 | 1426 | } |
| 1370 | 1427 | |
| 1428 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1429 | ||
| 1371 | 1430 | // tuple_cat |
| 1372 | 1431 | |
| 1373 | 1432 | template <class _Tp, class _Up> struct __tuple_cat_type; |
| ... | ... | @@ -1375,7 +1434,7 @@ template <class _Tp, class _Up> struct __tuple_cat_type; |
| 1375 | 1434 | template <class ..._Ttypes, class ..._Utypes> |
| 1376 | 1435 | struct __tuple_cat_type<tuple<_Ttypes...>, __tuple_types<_Utypes...> > |
| 1377 | 1436 | { |
| 1378 | typedef _LIBCPP_NODEBUG_TYPE tuple<_Ttypes..., _Utypes...> type; | |
| 1437 | typedef _LIBCPP_NODEBUG tuple<_Ttypes..., _Utypes...> type; | |
| 1379 | 1438 | }; |
| 1380 | 1439 | |
| 1381 | 1440 | template <class _ResultTuple, bool _Is_Tuple0TupleLike, class ..._Tuples> |
| ... | ... | @@ -1386,7 +1445,7 @@ struct __tuple_cat_return_1 |
| 1386 | 1445 | template <class ..._Types, class _Tuple0> |
| 1387 | 1446 | struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> |
| 1388 | 1447 | { |
| 1389 | typedef _LIBCPP_NODEBUG_TYPE typename __tuple_cat_type<tuple<_Types...>, | |
| 1448 | typedef _LIBCPP_NODEBUG typename __tuple_cat_type<tuple<_Types...>, | |
| 1390 | 1449 | typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type |
| 1391 | 1450 | type; |
| 1392 | 1451 | }; |
| ... | ... | @@ -1416,7 +1475,7 @@ struct __tuple_cat_return<_Tuple0, _Tuples...> |
| 1416 | 1475 | template <> |
| 1417 | 1476 | struct __tuple_cat_return<> |
| 1418 | 1477 | { |
| 1419 | typedef _LIBCPP_NODEBUG_TYPE tuple<> type; | |
| 1478 | typedef _LIBCPP_NODEBUG tuple<> type; | |
| 1420 | 1479 | }; |
| 1421 | 1480 | |
| 1422 | 1481 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| ... | ... | @@ -1432,7 +1491,7 @@ struct __tuple_cat_return_ref_imp; |
| 1432 | 1491 | template <class ..._Types, size_t ..._I0, class _Tuple0> |
| 1433 | 1492 | struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> |
| 1434 | 1493 | { |
| 1435 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0; | |
| 1494 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; | |
| 1436 | 1495 | typedef tuple<_Types..., typename __apply_cv<_Tuple0, |
| 1437 | 1496 | typename tuple_element<_I0, _T0>::type>::type&&...> type; |
| 1438 | 1497 | }; |
| ... | ... | @@ -1480,8 +1539,8 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1480 | 1539 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type |
| 1481 | 1540 | operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls) |
| 1482 | 1541 | { |
| 1483 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0; | |
| 1484 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple1>::type _T1; | |
| 1542 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; | |
| 1543 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1; | |
| 1485 | 1544 | return __tuple_cat< |
| 1486 | 1545 | tuple<_Types..., |
| 1487 | 1546 | typename __apply_cv<_Tuple0, typename tuple_element< |
| ... | ... | @@ -1501,7 +1560,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 1501 | 1560 | typename __tuple_cat_return<_Tuple0, _Tuples...>::type |
| 1502 | 1561 | tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) |
| 1503 | 1562 | { |
| 1504 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0; | |
| 1563 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; | |
| 1505 | 1564 | return __tuple_cat<tuple<>, __tuple_indices<>, |
| 1506 | 1565 | typename __make_tuple_indices<tuple_size<_T0>::value>::type>() |
| 1507 | 1566 | (tuple<>(), _VSTD::forward<_Tuple0>(__t0), |
| ... | ... | @@ -1525,7 +1584,7 @@ pair<_T1, _T2>::pair(piecewise_construct_t, |
| 1525 | 1584 | |
| 1526 | 1585 | #if _LIBCPP_STD_VER > 14 |
| 1527 | 1586 | template <class _Tp> |
| 1528 | _LIBCPP_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Tp>::value; | |
| 1587 | inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value; | |
| 1529 | 1588 | |
| 1530 | 1589 | #define _LIBCPP_NOEXCEPT_RETURN(...) noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } |
| 1531 | 1590 |
lib/libcxx/include/type_traits+312-650| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------ type_traits ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -455,58 +455,63 @@ using bool_constant = integral_constant<bool, __b>; |
| 455 | 455 | #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> |
| 456 | 456 | #endif |
| 457 | 457 | |
| 458 | template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; | |
| 459 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; | |
| 460 | ||
| 461 | template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type; | |
| 462 | ||
| 463 | #if _LIBCPP_STD_VER > 11 | |
| 464 | template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; | |
| 465 | #endif | |
| 466 | ||
| 458 | 467 | typedef _LIBCPP_BOOL_CONSTANT(true) true_type; |
| 459 | 468 | typedef _LIBCPP_BOOL_CONSTANT(false) false_type; |
| 460 | 469 | |
| 461 | 470 | template <bool _Val> |
| 462 | using _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>; | |
| 471 | using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>; | |
| 463 | 472 | |
| 464 | 473 | template <bool> struct _MetaBase; |
| 465 | 474 | template <> |
| 466 | 475 | struct _MetaBase<true> { |
| 467 | 476 | template <class _Tp, class _Up> |
| 468 | using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Tp; | |
| 477 | using _SelectImpl _LIBCPP_NODEBUG = _Tp; | |
| 469 | 478 | template <template <class...> class _FirstFn, template <class...> class, class ..._Args> |
| 470 | using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _FirstFn<_Args...>; | |
| 479 | using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>; | |
| 471 | 480 | template <class _First, class...> |
| 472 | using _FirstImpl _LIBCPP_NODEBUG_TYPE = _First; | |
| 481 | using _FirstImpl _LIBCPP_NODEBUG = _First; | |
| 473 | 482 | template <class, class _Second, class...> |
| 474 | using _SecondImpl _LIBCPP_NODEBUG_TYPE = _Second; | |
| 475 | template <class _Tp = void> | |
| 476 | using _EnableIfImpl _LIBCPP_NODEBUG_TYPE = _Tp; | |
| 483 | using _SecondImpl _LIBCPP_NODEBUG = _Second; | |
| 477 | 484 | template <class _Result, class _First, class ..._Rest> |
| 478 | using _OrImpl _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>; | |
| 485 | using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>; | |
| 479 | 486 | }; |
| 480 | 487 | |
| 481 | 488 | template <> |
| 482 | 489 | struct _MetaBase<false> { |
| 483 | 490 | template <class _Tp, class _Up> |
| 484 | using _SelectImpl _LIBCPP_NODEBUG_TYPE = _Up; | |
| 491 | using _SelectImpl _LIBCPP_NODEBUG = _Up; | |
| 485 | 492 | template <template <class...> class, template <class...> class _SecondFn, class ..._Args> |
| 486 | using _SelectApplyImpl _LIBCPP_NODEBUG_TYPE = _SecondFn<_Args...>; | |
| 493 | using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>; | |
| 487 | 494 | template <class _Result, class ...> |
| 488 | using _OrImpl _LIBCPP_NODEBUG_TYPE = _Result; | |
| 495 | using _OrImpl _LIBCPP_NODEBUG = _Result; | |
| 489 | 496 | }; |
| 490 | template <bool _Cond, class _Ret = void> | |
| 491 | using _EnableIf _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _EnableIfImpl<_Ret>; | |
| 492 | 497 | template <bool _Cond, class _IfRes, class _ElseRes> |
| 493 | using _If _LIBCPP_NODEBUG_TYPE = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>; | |
| 498 | using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>; | |
| 494 | 499 | template <class ..._Rest> |
| 495 | using _Or _LIBCPP_NODEBUG_TYPE = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>; | |
| 500 | using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>; | |
| 496 | 501 | template <class _Pred> |
| 497 | 502 | struct _Not : _BoolConstant<!_Pred::value> {}; |
| 498 | 503 | template <class ..._Args> |
| 499 | using _FirstType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; | |
| 504 | using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; | |
| 500 | 505 | template <class ..._Args> |
| 501 | using _SecondType _LIBCPP_NODEBUG_TYPE = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; | |
| 506 | using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; | |
| 502 | 507 | |
| 503 | 508 | template <class ...> using __expand_to_true = true_type; |
| 504 | 509 | template <class ..._Pred> |
| 505 | __expand_to_true<_EnableIf<_Pred::value>...> __and_helper(int); | |
| 510 | __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); | |
| 506 | 511 | template <class ...> |
| 507 | 512 | false_type __and_helper(...); |
| 508 | 513 | template <class ..._Pred> |
| 509 | using _And _LIBCPP_NODEBUG_TYPE = decltype(__and_helper<_Pred...>(0)); | |
| 514 | using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0)); | |
| 510 | 515 | |
| 511 | 516 | template <template <class...> class _Func, class ..._Args> |
| 512 | 517 | struct _Lazy : _Func<_Args...> {}; |
| ... | ... | @@ -519,7 +524,7 @@ template <template <class...> class, class ...> |
| 519 | 524 | false_type __sfinae_test_impl(...); |
| 520 | 525 | |
| 521 | 526 | template <template <class ...> class _Templ, class ..._Args> |
| 522 | using _IsValidExpansion _LIBCPP_NODEBUG_TYPE = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); | |
| 527 | using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); | |
| 523 | 528 | |
| 524 | 529 | template <class> |
| 525 | 530 | struct __void_t { typedef void type; }; |
| ... | ... | @@ -528,7 +533,7 @@ template <class _Tp> |
| 528 | 533 | struct __identity { typedef _Tp type; }; |
| 529 | 534 | |
| 530 | 535 | template <class _Tp> |
| 531 | using __identity_t _LIBCPP_NODEBUG_TYPE = typename __identity<_Tp>::type; | |
| 536 | using __identity_t _LIBCPP_NODEBUG = typename __identity<_Tp>::type; | |
| 532 | 537 | |
| 533 | 538 | template <class _Tp, bool> |
| 534 | 539 | struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; |
| ... | ... | @@ -543,59 +548,31 @@ template <class _If, class _Then> |
| 543 | 548 | template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; |
| 544 | 549 | #endif |
| 545 | 550 | |
| 546 | template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; | |
| 547 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; | |
| 548 | ||
| 549 | #if _LIBCPP_STD_VER > 11 | |
| 550 | template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; | |
| 551 | #endif | |
| 552 | ||
| 553 | 551 | // is_same |
| 554 | 552 | |
| 555 | #if __has_keyword(__is_same) | |
| 556 | ||
| 557 | 553 | template <class _Tp, class _Up> |
| 558 | 554 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; |
| 559 | 555 | |
| 560 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 556 | #if _LIBCPP_STD_VER > 14 | |
| 561 | 557 | template <class _Tp, class _Up> |
| 562 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v = __is_same(_Tp, _Up); | |
| 558 | inline constexpr bool is_same_v = __is_same(_Tp, _Up); | |
| 563 | 559 | #endif |
| 564 | 560 | |
| 565 | #else | |
| 566 | ||
| 567 | template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same : public false_type {}; | |
| 568 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_same<_Tp, _Tp> : public true_type {}; | |
| 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). | |
| 569 | 567 | |
| 570 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 571 | 568 | template <class _Tp, class _Up> |
| 572 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_same_v | |
| 573 | = is_same<_Tp, _Up>::value; | |
| 574 | #endif | |
| 575 | ||
| 576 | #endif // __is_same | |
| 569 | using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; | |
| 577 | 570 | |
| 578 | 571 | template <class _Tp, class _Up> |
| 579 | using _IsSame = _BoolConstant< | |
| 580 | #ifdef __clang__ | |
| 581 | __is_same(_Tp, _Up) | |
| 582 | #else | |
| 583 | is_same<_Tp, _Up>::value | |
| 584 | #endif | |
| 585 | >; | |
| 586 | ||
| 587 | template <class _Tp, class _Up> | |
| 588 | using _IsNotSame = _BoolConstant< | |
| 589 | #ifdef __clang__ | |
| 590 | !__is_same(_Tp, _Up) | |
| 591 | #else | |
| 592 | !is_same<_Tp, _Up>::value | |
| 593 | #endif | |
| 594 | >; | |
| 595 | ||
| 572 | using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>; | |
| 596 | 573 | |
| 597 | 574 | template <class _Tp> |
| 598 | using __test_for_primary_template = _EnableIf< | |
| 575 | using __test_for_primary_template = __enable_if_t< | |
| 599 | 576 | _IsSame<_Tp, typename _Tp::__primary_template>::value |
| 600 | 577 | >; |
| 601 | 578 | template <class _Tp> |
| ... | ... | @@ -603,9 +580,9 @@ using __is_primary_template = _IsValidExpansion< |
| 603 | 580 | __test_for_primary_template, _Tp |
| 604 | 581 | >; |
| 605 | 582 | |
| 606 | struct __two {char __lx[2];}; | |
| 583 | // helper class | |
| 607 | 584 | |
| 608 | // helper class: | |
| 585 | struct __two {char __lx[2];}; | |
| 609 | 586 | |
| 610 | 587 | // is_const |
| 611 | 588 | |
| ... | ... | @@ -614,9 +591,9 @@ struct __two {char __lx[2];}; |
| 614 | 591 | template <class _Tp> |
| 615 | 592 | struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { }; |
| 616 | 593 | |
| 617 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 594 | #if _LIBCPP_STD_VER > 14 | |
| 618 | 595 | template <class _Tp> |
| 619 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v = __is_const(_Tp); | |
| 596 | inline constexpr bool is_const_v = __is_const(_Tp); | |
| 620 | 597 | #endif |
| 621 | 598 | |
| 622 | 599 | #else |
| ... | ... | @@ -624,10 +601,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v = __is_const(_Tp); |
| 624 | 601 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; |
| 625 | 602 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; |
| 626 | 603 | |
| 627 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 604 | #if _LIBCPP_STD_VER > 14 | |
| 628 | 605 | template <class _Tp> |
| 629 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v | |
| 630 | = is_const<_Tp>::value; | |
| 606 | inline constexpr bool is_const_v = is_const<_Tp>::value; | |
| 631 | 607 | #endif |
| 632 | 608 | |
| 633 | 609 | #endif // __has_keyword(__is_const) |
| ... | ... | @@ -639,9 +615,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_const_v |
| 639 | 615 | template <class _Tp> |
| 640 | 616 | struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { }; |
| 641 | 617 | |
| 642 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 618 | #if _LIBCPP_STD_VER > 14 | |
| 643 | 619 | template <class _Tp> |
| 644 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v = __is_volatile(_Tp); | |
| 620 | inline constexpr bool is_volatile_v = __is_volatile(_Tp); | |
| 645 | 621 | #endif |
| 646 | 622 | |
| 647 | 623 | #else |
| ... | ... | @@ -649,10 +625,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v = __is_volatile(_Tp); |
| 649 | 625 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; |
| 650 | 626 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; |
| 651 | 627 | |
| 652 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 628 | #if _LIBCPP_STD_VER > 14 | |
| 653 | 629 | template <class _Tp> |
| 654 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_volatile_v | |
| 655 | = is_volatile<_Tp>::value; | |
| 630 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; | |
| 656 | 631 | #endif |
| 657 | 632 | |
| 658 | 633 | #endif // __has_keyword(__is_volatile) |
| ... | ... | @@ -727,9 +702,9 @@ template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; |
| 727 | 702 | template <class _Tp> |
| 728 | 703 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { }; |
| 729 | 704 | |
| 730 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 705 | #if _LIBCPP_STD_VER > 14 | |
| 731 | 706 | template <class _Tp> |
| 732 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v = __is_void(_Tp); | |
| 707 | inline constexpr bool is_void_v = __is_void(_Tp); | |
| 733 | 708 | #endif |
| 734 | 709 | |
| 735 | 710 | #else |
| ... | ... | @@ -737,10 +712,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v = __is_void(_Tp); |
| 737 | 712 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void |
| 738 | 713 | : public is_same<typename remove_cv<_Tp>::type, void> {}; |
| 739 | 714 | |
| 740 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 715 | #if _LIBCPP_STD_VER > 14 | |
| 741 | 716 | template <class _Tp> |
| 742 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_void_v | |
| 743 | = is_void<_Tp>::value; | |
| 717 | inline constexpr bool is_void_v = is_void<_Tp>::value; | |
| 744 | 718 | #endif |
| 745 | 719 | |
| 746 | 720 | #endif // __has_keyword(__is_void) |
| ... | ... | @@ -757,10 +731,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t |
| 757 | 731 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer |
| 758 | 732 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; |
| 759 | 733 | |
| 760 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 734 | #if _LIBCPP_STD_VER > 14 | |
| 761 | 735 | template <class _Tp> |
| 762 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_null_pointer_v | |
| 763 | = is_null_pointer<_Tp>::value; | |
| 736 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; | |
| 764 | 737 | #endif |
| 765 | 738 | #endif // _LIBCPP_STD_VER > 11 |
| 766 | 739 | |
| ... | ... | @@ -773,7 +746,7 @@ struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { }; |
| 773 | 746 | |
| 774 | 747 | #if _LIBCPP_STD_VER > 14 |
| 775 | 748 | template <class _Tp> |
| 776 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v = __is_integral(_Tp); | |
| 749 | inline constexpr bool is_integral_v = __is_integral(_Tp); | |
| 777 | 750 | #endif |
| 778 | 751 | |
| 779 | 752 | #else |
| ... | ... | @@ -781,16 +754,13 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v = __is_integral(_Tp); |
| 781 | 754 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral |
| 782 | 755 | : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {}; |
| 783 | 756 | |
| 784 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 757 | #if _LIBCPP_STD_VER > 14 | |
| 785 | 758 | template <class _Tp> |
| 786 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_integral_v | |
| 787 | = is_integral<_Tp>::value; | |
| 759 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; | |
| 788 | 760 | #endif |
| 789 | 761 | |
| 790 | 762 | #endif // __has_keyword(__is_integral) |
| 791 | 763 | |
| 792 | // __libcpp_is_signed_integer, __libcpp_is_unsigned_integer | |
| 793 | ||
| 794 | 764 | // [basic.fundamental] defines five standard signed integer types; |
| 795 | 765 | // __int128_t is an extended signed integer type. |
| 796 | 766 | // The signed and unsigned integer types, plus bool and the |
| ... | ... | @@ -817,6 +787,7 @@ template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public tru |
| 817 | 787 | #endif |
| 818 | 788 | |
| 819 | 789 | // is_floating_point |
| 790 | // <concepts> implements __libcpp_floating_point | |
| 820 | 791 | |
| 821 | 792 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; |
| 822 | 793 | template <> struct __libcpp_is_floating_point<float> : public true_type {}; |
| ... | ... | @@ -826,10 +797,9 @@ template <> struct __libcpp_is_floating_point<long double> : public tru |
| 826 | 797 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point |
| 827 | 798 | : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; |
| 828 | 799 | |
| 829 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 800 | #if _LIBCPP_STD_VER > 14 | |
| 830 | 801 | template <class _Tp> |
| 831 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v | |
| 832 | = is_floating_point<_Tp>::value; | |
| 802 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; | |
| 833 | 803 | #endif |
| 834 | 804 | |
| 835 | 805 | // is_array |
| ... | ... | @@ -839,9 +809,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_floating_point_v |
| 839 | 809 | template <class _Tp> |
| 840 | 810 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; |
| 841 | 811 | |
| 842 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 812 | #if _LIBCPP_STD_VER > 14 | |
| 843 | 813 | template <class _Tp> |
| 844 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v = __is_array(_Tp); | |
| 814 | inline constexpr bool is_array_v = __is_array(_Tp); | |
| 845 | 815 | #endif |
| 846 | 816 | |
| 847 | 817 | #else |
| ... | ... | @@ -853,27 +823,25 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> |
| 853 | 823 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> |
| 854 | 824 | : public true_type {}; |
| 855 | 825 | |
| 856 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 826 | #if _LIBCPP_STD_VER > 14 | |
| 857 | 827 | template <class _Tp> |
| 858 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_array_v | |
| 859 | = is_array<_Tp>::value; | |
| 828 | inline constexpr bool is_array_v = is_array<_Tp>::value; | |
| 860 | 829 | #endif |
| 861 | 830 | |
| 862 | 831 | #endif // __has_keyword(__is_array) |
| 863 | 832 | |
| 864 | 833 | // is_pointer |
| 865 | 834 | |
| 866 | // Before Clang 11 / AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. | |
| 835 | // Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. | |
| 867 | 836 | #if __has_keyword(__is_pointer) && \ |
| 868 | !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1100) && \ | |
| 869 | 837 | !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205) |
| 870 | 838 | |
| 871 | 839 | template<class _Tp> |
| 872 | 840 | struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { }; |
| 873 | 841 | |
| 874 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 842 | #if _LIBCPP_STD_VER > 14 | |
| 875 | 843 | template <class _Tp> |
| 876 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v = __is_pointer(_Tp); | |
| 844 | inline constexpr bool is_pointer_v = __is_pointer(_Tp); | |
| 877 | 845 | #endif |
| 878 | 846 | |
| 879 | 847 | #else // __has_keyword(__is_pointer) |
| ... | ... | @@ -892,10 +860,9 @@ template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretai |
| 892 | 860 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer |
| 893 | 861 | : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {}; |
| 894 | 862 | |
| 895 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 863 | #if _LIBCPP_STD_VER > 14 | |
| 896 | 864 | template <class _Tp> |
| 897 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v | |
| 898 | = is_pointer<_Tp>::value; | |
| 865 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; | |
| 899 | 866 | #endif |
| 900 | 867 | |
| 901 | 868 | #endif // __has_keyword(__is_pointer) |
| ... | ... | @@ -915,15 +882,13 @@ struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_refe |
| 915 | 882 | template<class _Tp> |
| 916 | 883 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; |
| 917 | 884 | |
| 918 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 885 | #if _LIBCPP_STD_VER > 14 | |
| 919 | 886 | template <class _Tp> |
| 920 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v = __is_reference(_Tp); | |
| 921 | ||
| 887 | inline constexpr bool is_reference_v = __is_reference(_Tp); | |
| 922 | 888 | template <class _Tp> |
| 923 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | |
| 924 | ||
| 889 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | |
| 925 | 890 | template <class _Tp> |
| 926 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | |
| 891 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | |
| 927 | 892 | #endif |
| 928 | 893 | |
| 929 | 894 | #else // __has_keyword(__is_lvalue_reference) && etc... |
| ... | ... | @@ -938,18 +903,15 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public fa |
| 938 | 903 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; |
| 939 | 904 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; |
| 940 | 905 | |
| 941 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 906 | #if _LIBCPP_STD_VER > 14 | |
| 942 | 907 | template <class _Tp> |
| 943 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_reference_v | |
| 944 | = is_reference<_Tp>::value; | |
| 908 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; | |
| 945 | 909 | |
| 946 | 910 | template <class _Tp> |
| 947 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_lvalue_reference_v | |
| 948 | = is_lvalue_reference<_Tp>::value; | |
| 911 | inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; | |
| 949 | 912 | |
| 950 | 913 | template <class _Tp> |
| 951 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_rvalue_reference_v | |
| 952 | = is_rvalue_reference<_Tp>::value; | |
| 914 | inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; | |
| 953 | 915 | #endif |
| 954 | 916 | |
| 955 | 917 | #endif // __has_keyword(__is_lvalue_reference) && etc... |
| ... | ... | @@ -969,10 +931,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union |
| 969 | 931 | |
| 970 | 932 | #endif |
| 971 | 933 | |
| 972 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 934 | #if _LIBCPP_STD_VER > 14 | |
| 973 | 935 | template <class _Tp> |
| 974 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_union_v | |
| 975 | = is_union<_Tp>::value; | |
| 936 | inline constexpr bool is_union_v = is_union<_Tp>::value; | |
| 976 | 937 | #endif |
| 977 | 938 | |
| 978 | 939 | // is_class |
| ... | ... | @@ -995,10 +956,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class |
| 995 | 956 | |
| 996 | 957 | #endif |
| 997 | 958 | |
| 998 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 959 | #if _LIBCPP_STD_VER > 14 | |
| 999 | 960 | template <class _Tp> |
| 1000 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_class_v | |
| 1001 | = is_class<_Tp>::value; | |
| 961 | inline constexpr bool is_class_v = is_class<_Tp>::value; | |
| 1002 | 962 | #endif |
| 1003 | 963 | |
| 1004 | 964 | // is_function |
| ... | ... | @@ -1013,10 +973,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function |
| 1013 | 973 | > {}; |
| 1014 | 974 | |
| 1015 | 975 | |
| 1016 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 976 | #if _LIBCPP_STD_VER > 14 | |
| 1017 | 977 | template <class _Tp> |
| 1018 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_function_v | |
| 1019 | = is_function<_Tp>::value; | |
| 978 | inline constexpr bool is_function_v = is_function<_Tp>::value; | |
| 1020 | 979 | #endif |
| 1021 | 980 | |
| 1022 | 981 | template <class _Tp> struct __libcpp_is_member_pointer { |
| ... | ... | @@ -1040,10 +999,9 @@ template<class _Tp> |
| 1040 | 999 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer |
| 1041 | 1000 | : _BoolConstant<__is_member_function_pointer(_Tp)> { }; |
| 1042 | 1001 | |
| 1043 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1002 | #if _LIBCPP_STD_VER > 14 | |
| 1044 | 1003 | template <class _Tp> |
| 1045 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v | |
| 1046 | = __is_member_function_pointer(_Tp); | |
| 1004 | inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); | |
| 1047 | 1005 | #endif |
| 1048 | 1006 | |
| 1049 | 1007 | #else // __has_keyword(__is_member_function_pointer) |
| ... | ... | @@ -1051,10 +1009,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v |
| 1051 | 1009 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer |
| 1052 | 1010 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {}; |
| 1053 | 1011 | |
| 1054 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1012 | #if _LIBCPP_STD_VER > 14 | |
| 1055 | 1013 | template <class _Tp> |
| 1056 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v | |
| 1057 | = is_member_function_pointer<_Tp>::value; | |
| 1014 | inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; | |
| 1058 | 1015 | #endif |
| 1059 | 1016 | |
| 1060 | 1017 | #endif // __has_keyword(__is_member_function_pointer) |
| ... | ... | @@ -1066,9 +1023,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_function_pointer_v |
| 1066 | 1023 | template<class _Tp> |
| 1067 | 1024 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { }; |
| 1068 | 1025 | |
| 1069 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1026 | #if _LIBCPP_STD_VER > 14 | |
| 1070 | 1027 | template <class _Tp> |
| 1071 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v = __is_member_pointer(_Tp); | |
| 1028 | inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); | |
| 1072 | 1029 | #endif |
| 1073 | 1030 | |
| 1074 | 1031 | #else // __has_keyword(__is_member_pointer) |
| ... | ... | @@ -1076,10 +1033,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v = __is_member_poin |
| 1076 | 1033 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer |
| 1077 | 1034 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {}; |
| 1078 | 1035 | |
| 1079 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1036 | #if _LIBCPP_STD_VER > 14 | |
| 1080 | 1037 | template <class _Tp> |
| 1081 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_pointer_v | |
| 1082 | = is_member_pointer<_Tp>::value; | |
| 1038 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; | |
| 1083 | 1039 | #endif |
| 1084 | 1040 | |
| 1085 | 1041 | #endif // __has_keyword(__is_member_pointer) |
| ... | ... | @@ -1092,10 +1048,9 @@ template<class _Tp> |
| 1092 | 1048 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer |
| 1093 | 1049 | : _BoolConstant<__is_member_object_pointer(_Tp)> { }; |
| 1094 | 1050 | |
| 1095 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1051 | #if _LIBCPP_STD_VER > 14 | |
| 1096 | 1052 | template <class _Tp> |
| 1097 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v | |
| 1098 | = __is_member_object_pointer(_Tp); | |
| 1053 | inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); | |
| 1099 | 1054 | #endif |
| 1100 | 1055 | |
| 1101 | 1056 | #else // __has_keyword(__is_member_object_pointer) |
| ... | ... | @@ -1103,10 +1058,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v |
| 1103 | 1058 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer |
| 1104 | 1059 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {}; |
| 1105 | 1060 | |
| 1106 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1061 | #if _LIBCPP_STD_VER > 14 | |
| 1107 | 1062 | template <class _Tp> |
| 1108 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v | |
| 1109 | = is_member_object_pointer<_Tp>::value; | |
| 1063 | inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; | |
| 1110 | 1064 | #endif |
| 1111 | 1065 | |
| 1112 | 1066 | #endif // __has_keyword(__is_member_object_pointer) |
| ... | ... | @@ -1118,9 +1072,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_member_object_pointer_v |
| 1118 | 1072 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
| 1119 | 1073 | : public integral_constant<bool, __is_enum(_Tp)> {}; |
| 1120 | 1074 | |
| 1121 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1075 | #if _LIBCPP_STD_VER > 14 | |
| 1122 | 1076 | template <class _Tp> |
| 1123 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v = __is_enum(_Tp); | |
| 1077 | inline constexpr bool is_enum_v = __is_enum(_Tp); | |
| 1124 | 1078 | #endif |
| 1125 | 1079 | |
| 1126 | 1080 | #else |
| ... | ... | @@ -1137,10 +1091,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum |
| 1137 | 1091 | !is_class<_Tp>::value && |
| 1138 | 1092 | !is_function<_Tp>::value > {}; |
| 1139 | 1093 | |
| 1140 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1094 | #if _LIBCPP_STD_VER > 14 | |
| 1141 | 1095 | template <class _Tp> |
| 1142 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_enum_v | |
| 1143 | = is_enum<_Tp>::value; | |
| 1096 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; | |
| 1144 | 1097 | #endif |
| 1145 | 1098 | |
| 1146 | 1099 | #endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) |
| ... | ... | @@ -1152,10 +1105,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic |
| 1152 | 1105 | : public integral_constant<bool, is_integral<_Tp>::value || |
| 1153 | 1106 | is_floating_point<_Tp>::value> {}; |
| 1154 | 1107 | |
| 1155 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1108 | #if _LIBCPP_STD_VER > 14 | |
| 1156 | 1109 | template <class _Tp> |
| 1157 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v | |
| 1158 | = is_arithmetic<_Tp>::value; | |
| 1110 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; | |
| 1159 | 1111 | #endif |
| 1160 | 1112 | |
| 1161 | 1113 | // is_fundamental |
| ... | ... | @@ -1169,9 +1121,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_arithmetic_v |
| 1169 | 1121 | template<class _Tp> |
| 1170 | 1122 | struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { }; |
| 1171 | 1123 | |
| 1172 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1124 | #if _LIBCPP_STD_VER > 14 | |
| 1173 | 1125 | template <class _Tp> |
| 1174 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v = __is_fundamental(_Tp); | |
| 1126 | inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); | |
| 1175 | 1127 | #endif |
| 1176 | 1128 | |
| 1177 | 1129 | #else // __has_keyword(__is_fundamental) |
| ... | ... | @@ -1181,10 +1133,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental |
| 1181 | 1133 | __is_nullptr_t<_Tp>::value || |
| 1182 | 1134 | is_arithmetic<_Tp>::value> {}; |
| 1183 | 1135 | |
| 1184 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1136 | #if _LIBCPP_STD_VER > 14 | |
| 1185 | 1137 | template <class _Tp> |
| 1186 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v | |
| 1187 | = is_fundamental<_Tp>::value; | |
| 1138 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; | |
| 1188 | 1139 | #endif |
| 1189 | 1140 | |
| 1190 | 1141 | #endif // __has_keyword(__is_fundamental) |
| ... | ... | @@ -1197,9 +1148,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_fundamental_v |
| 1197 | 1148 | template<class _Tp> |
| 1198 | 1149 | struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { }; |
| 1199 | 1150 | |
| 1200 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1151 | #if _LIBCPP_STD_VER > 14 | |
| 1201 | 1152 | template <class _Tp> |
| 1202 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v = __is_scalar(_Tp); | |
| 1153 | inline constexpr bool is_scalar_v = __is_scalar(_Tp); | |
| 1203 | 1154 | #endif |
| 1204 | 1155 | |
| 1205 | 1156 | #else // __has_keyword(__is_scalar) |
| ... | ... | @@ -1219,10 +1170,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar |
| 1219 | 1170 | |
| 1220 | 1171 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; |
| 1221 | 1172 | |
| 1222 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1173 | #if _LIBCPP_STD_VER > 14 | |
| 1223 | 1174 | template <class _Tp> |
| 1224 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v | |
| 1225 | = is_scalar<_Tp>::value; | |
| 1175 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; | |
| 1226 | 1176 | #endif |
| 1227 | 1177 | |
| 1228 | 1178 | #endif // __has_keyword(__is_scalar) |
| ... | ... | @@ -1234,9 +1184,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scalar_v |
| 1234 | 1184 | template<class _Tp> |
| 1235 | 1185 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { }; |
| 1236 | 1186 | |
| 1237 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1187 | #if _LIBCPP_STD_VER > 14 | |
| 1238 | 1188 | template <class _Tp> |
| 1239 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v = __is_object(_Tp); | |
| 1189 | inline constexpr bool is_object_v = __is_object(_Tp); | |
| 1240 | 1190 | #endif |
| 1241 | 1191 | |
| 1242 | 1192 | #else // __has_keyword(__is_object) |
| ... | ... | @@ -1247,10 +1197,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object |
| 1247 | 1197 | is_union<_Tp>::value || |
| 1248 | 1198 | is_class<_Tp>::value > {}; |
| 1249 | 1199 | |
| 1250 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1200 | #if _LIBCPP_STD_VER > 14 | |
| 1251 | 1201 | template <class _Tp> |
| 1252 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v | |
| 1253 | = is_object<_Tp>::value; | |
| 1202 | inline constexpr bool is_object_v = is_object<_Tp>::value; | |
| 1254 | 1203 | #endif |
| 1255 | 1204 | |
| 1256 | 1205 | #endif // __has_keyword(__is_object) |
| ... | ... | @@ -1263,9 +1212,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_object_v |
| 1263 | 1212 | template<class _Tp> |
| 1264 | 1213 | struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { }; |
| 1265 | 1214 | |
| 1266 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1215 | #if _LIBCPP_STD_VER > 14 | |
| 1267 | 1216 | template <class _Tp> |
| 1268 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v = __is_compound(_Tp); | |
| 1217 | inline constexpr bool is_compound_v = __is_compound(_Tp); | |
| 1269 | 1218 | #endif |
| 1270 | 1219 | |
| 1271 | 1220 | #else // __has_keyword(__is_compound) |
| ... | ... | @@ -1273,10 +1222,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v = __is_compound(_Tp); |
| 1273 | 1222 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound |
| 1274 | 1223 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; |
| 1275 | 1224 | |
| 1276 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1225 | #if _LIBCPP_STD_VER > 14 | |
| 1277 | 1226 | template <class _Tp> |
| 1278 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_compound_v | |
| 1279 | = is_compound<_Tp>::value; | |
| 1227 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; | |
| 1280 | 1228 | #endif |
| 1281 | 1229 | |
| 1282 | 1230 | #endif // __has_keyword(__is_compound) |
| ... | ... | @@ -1296,7 +1244,7 @@ struct __is_referenceable : integral_constant<bool, |
| 1296 | 1244 | // add_const |
| 1297 | 1245 | |
| 1298 | 1246 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const { |
| 1299 | typedef _LIBCPP_NODEBUG_TYPE const _Tp type; | |
| 1247 | typedef _LIBCPP_NODEBUG const _Tp type; | |
| 1300 | 1248 | }; |
| 1301 | 1249 | |
| 1302 | 1250 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -1306,7 +1254,7 @@ template <class _Tp> using add_const_t = typename add_const<_Tp>::type; |
| 1306 | 1254 | // add_volatile |
| 1307 | 1255 | |
| 1308 | 1256 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile { |
| 1309 | typedef _LIBCPP_NODEBUG_TYPE volatile _Tp type; | |
| 1257 | typedef _LIBCPP_NODEBUG volatile _Tp type; | |
| 1310 | 1258 | }; |
| 1311 | 1259 | |
| 1312 | 1260 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -1315,7 +1263,7 @@ template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; |
| 1315 | 1263 | |
| 1316 | 1264 | // add_cv |
| 1317 | 1265 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv { |
| 1318 | typedef _LIBCPP_NODEBUG_TYPE const volatile _Tp type; | |
| 1266 | typedef _LIBCPP_NODEBUG const volatile _Tp type; | |
| 1319 | 1267 | }; |
| 1320 | 1268 | |
| 1321 | 1269 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -1331,9 +1279,9 @@ struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) t |
| 1331 | 1279 | |
| 1332 | 1280 | #else // __has_keyword(__remove_reference) |
| 1333 | 1281 | |
| 1334 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1335 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1336 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1282 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1283 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1284 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1337 | 1285 | |
| 1338 | 1286 | #if _LIBCPP_STD_VER > 11 |
| 1339 | 1287 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; |
| ... | ... | @@ -1343,21 +1291,21 @@ template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>:: |
| 1343 | 1291 | |
| 1344 | 1292 | // add_lvalue_reference |
| 1345 | 1293 | |
| 1346 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; | |
| 1347 | template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; | |
| 1294 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 1295 | template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; }; | |
| 1348 | 1296 | |
| 1349 | 1297 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference |
| 1350 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_lvalue_reference_impl<_Tp>::type type;}; | |
| 1298 | {typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;}; | |
| 1351 | 1299 | |
| 1352 | 1300 | #if _LIBCPP_STD_VER > 11 |
| 1353 | 1301 | template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; |
| 1354 | 1302 | #endif |
| 1355 | 1303 | |
| 1356 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; | |
| 1357 | template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG_TYPE _Tp&& type; }; | |
| 1304 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 1305 | template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; }; | |
| 1358 | 1306 | |
| 1359 | 1307 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference |
| 1360 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_rvalue_reference_impl<_Tp>::type type;}; | |
| 1308 | {typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;}; | |
| 1361 | 1309 | |
| 1362 | 1310 | #if _LIBCPP_STD_VER > 11 |
| 1363 | 1311 | template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; |
| ... | ... | @@ -1378,17 +1326,17 @@ declval() _NOEXCEPT; |
| 1378 | 1326 | |
| 1379 | 1327 | template <class _Tp> |
| 1380 | 1328 | struct __uncvref { |
| 1381 | typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<typename remove_reference<_Tp>::type>::type type; | |
| 1329 | typedef _LIBCPP_NODEBUG typename remove_cv<typename remove_reference<_Tp>::type>::type type; | |
| 1382 | 1330 | }; |
| 1383 | 1331 | |
| 1384 | 1332 | template <class _Tp> |
| 1385 | 1333 | struct __unconstref { |
| 1386 | typedef _LIBCPP_NODEBUG_TYPE typename remove_const<typename remove_reference<_Tp>::type>::type type; | |
| 1334 | typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type; | |
| 1387 | 1335 | }; |
| 1388 | 1336 | |
| 1389 | 1337 | #ifndef _LIBCPP_CXX03_LANG |
| 1390 | 1338 | template <class _Tp> |
| 1391 | using __uncvref_t _LIBCPP_NODEBUG_TYPE = typename __uncvref<_Tp>::type; | |
| 1339 | using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type; | |
| 1392 | 1340 | #endif |
| 1393 | 1341 | |
| 1394 | 1342 | // __is_same_uncvref |
| ... | ... | @@ -1413,11 +1361,11 @@ struct __any |
| 1413 | 1361 | |
| 1414 | 1362 | // remove_pointer |
| 1415 | 1363 | |
| 1416 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1417 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1418 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1419 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1420 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1364 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1365 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1366 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1367 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1368 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1421 | 1369 | |
| 1422 | 1370 | #if _LIBCPP_STD_VER > 11 |
| 1423 | 1371 | template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; |
| ... | ... | @@ -1429,12 +1377,12 @@ template <class _Tp, |
| 1429 | 1377 | bool = __is_referenceable<_Tp>::value || |
| 1430 | 1378 | _IsSame<typename remove_cv<_Tp>::type, void>::value> |
| 1431 | 1379 | struct __add_pointer_impl |
| 1432 | {typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type* type;}; | |
| 1380 | {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;}; | |
| 1433 | 1381 | template <class _Tp> struct __add_pointer_impl<_Tp, false> |
| 1434 | {typedef _LIBCPP_NODEBUG_TYPE _Tp type;}; | |
| 1382 | {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1435 | 1383 | |
| 1436 | 1384 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer |
| 1437 | {typedef _LIBCPP_NODEBUG_TYPE typename __add_pointer_impl<_Tp>::type type;}; | |
| 1385 | {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;}; | |
| 1438 | 1386 | |
| 1439 | 1387 | #if _LIBCPP_STD_VER > 11 |
| 1440 | 1388 | template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; |
| ... | ... | @@ -1448,16 +1396,14 @@ template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; |
| 1448 | 1396 | |
| 1449 | 1397 | // is_signed |
| 1450 | 1398 | |
| 1451 | // Before Clang 10, __is_signed didn't work for floating-point types or enums. | |
| 1452 | #if __has_keyword(__is_signed) && \ | |
| 1453 | !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) | |
| 1399 | #if __has_keyword(__is_signed) | |
| 1454 | 1400 | |
| 1455 | 1401 | template<class _Tp> |
| 1456 | 1402 | struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { }; |
| 1457 | 1403 | |
| 1458 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1404 | #if _LIBCPP_STD_VER > 14 | |
| 1459 | 1405 | template <class _Tp> |
| 1460 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v = __is_signed(_Tp); | |
| 1406 | inline constexpr bool is_signed_v = __is_signed(_Tp); | |
| 1461 | 1407 | #endif |
| 1462 | 1408 | |
| 1463 | 1409 | #else // __has_keyword(__is_signed) |
| ... | ... | @@ -1475,10 +1421,9 @@ template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type { |
| 1475 | 1421 | |
| 1476 | 1422 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; |
| 1477 | 1423 | |
| 1478 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1424 | #if _LIBCPP_STD_VER > 14 | |
| 1479 | 1425 | template <class _Tp> |
| 1480 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v | |
| 1481 | = is_signed<_Tp>::value; | |
| 1426 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; | |
| 1482 | 1427 | #endif |
| 1483 | 1428 | |
| 1484 | 1429 | #endif // __has_keyword(__is_signed) |
| ... | ... | @@ -1494,9 +1439,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_signed_v |
| 1494 | 1439 | template<class _Tp> |
| 1495 | 1440 | struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { }; |
| 1496 | 1441 | |
| 1497 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1442 | #if _LIBCPP_STD_VER > 14 | |
| 1498 | 1443 | template <class _Tp> |
| 1499 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v = __is_unsigned(_Tp); | |
| 1444 | inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); | |
| 1500 | 1445 | #endif |
| 1501 | 1446 | |
| 1502 | 1447 | #else // __has_keyword(__is_unsigned) |
| ... | ... | @@ -1514,10 +1459,9 @@ template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type |
| 1514 | 1459 | |
| 1515 | 1460 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; |
| 1516 | 1461 | |
| 1517 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1462 | #if _LIBCPP_STD_VER > 14 | |
| 1518 | 1463 | template <class _Tp> |
| 1519 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_unsigned_v | |
| 1520 | = is_unsigned<_Tp>::value; | |
| 1464 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; | |
| 1521 | 1465 | #endif |
| 1522 | 1466 | |
| 1523 | 1467 | #endif // __has_keyword(__is_unsigned) |
| ... | ... | @@ -1531,10 +1475,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> |
| 1531 | 1475 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> |
| 1532 | 1476 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; |
| 1533 | 1477 | |
| 1534 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1478 | #if _LIBCPP_STD_VER > 14 | |
| 1535 | 1479 | template <class _Tp> |
| 1536 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t rank_v | |
| 1537 | = rank<_Tp>::value; | |
| 1480 | inline constexpr size_t rank_v = rank<_Tp>::value; | |
| 1538 | 1481 | #endif |
| 1539 | 1482 | |
| 1540 | 1483 | // extent |
| ... | ... | @@ -1545,9 +1488,9 @@ template<class _Tp, size_t _Dim = 0> |
| 1545 | 1488 | struct _LIBCPP_TEMPLATE_VIS extent |
| 1546 | 1489 | : integral_constant<size_t, __array_extent(_Tp, _Dim)> { }; |
| 1547 | 1490 | |
| 1548 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1491 | #if _LIBCPP_STD_VER > 14 | |
| 1549 | 1492 | template <class _Tp, unsigned _Ip = 0> |
| 1550 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v = __array_extent(_Tp, _Ip); | |
| 1493 | inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); | |
| 1551 | 1494 | #endif |
| 1552 | 1495 | |
| 1553 | 1496 | #else // __has_keyword(__array_extent) |
| ... | ... | @@ -1563,10 +1506,9 @@ template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> |
| 1563 | 1506 | template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> |
| 1564 | 1507 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; |
| 1565 | 1508 | |
| 1566 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1509 | #if _LIBCPP_STD_VER > 14 | |
| 1567 | 1510 | template <class _Tp, unsigned _Ip = 0> |
| 1568 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t extent_v | |
| 1569 | = extent<_Tp, _Ip>::value; | |
| 1511 | inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; | |
| 1570 | 1512 | #endif |
| 1571 | 1513 | |
| 1572 | 1514 | #endif // __has_keyword(__array_extent) |
| ... | ... | @@ -1604,7 +1546,7 @@ template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array |
| 1604 | 1546 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; |
| 1605 | 1547 | |
| 1606 | 1548 | template <class _Tp> |
| 1607 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR | |
| 1549 | inline constexpr | |
| 1608 | 1550 | bool is_bounded_array_v = is_bounded_array<_Tp>::value; |
| 1609 | 1551 | |
| 1610 | 1552 | // is_unbounded_array |
| ... | ... | @@ -1613,7 +1555,7 @@ template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : fal |
| 1613 | 1555 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; |
| 1614 | 1556 | |
| 1615 | 1557 | template <class _Tp> |
| 1616 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR | |
| 1558 | inline constexpr | |
| 1617 | 1559 | bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; |
| 1618 | 1560 | #endif |
| 1619 | 1561 | |
| ... | ... | @@ -1621,13 +1563,13 @@ bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; |
| 1621 | 1563 | |
| 1622 | 1564 | template <class _Up, bool> |
| 1623 | 1565 | struct __decay { |
| 1624 | typedef _LIBCPP_NODEBUG_TYPE typename remove_cv<_Up>::type type; | |
| 1566 | typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type; | |
| 1625 | 1567 | }; |
| 1626 | 1568 | |
| 1627 | 1569 | template <class _Up> |
| 1628 | 1570 | struct __decay<_Up, true> { |
| 1629 | 1571 | public: |
| 1630 | typedef _LIBCPP_NODEBUG_TYPE typename conditional | |
| 1572 | typedef _LIBCPP_NODEBUG typename conditional | |
| 1631 | 1573 | < |
| 1632 | 1574 | is_array<_Up>::value, |
| 1633 | 1575 | typename remove_extent<_Up>::type*, |
| ... | ... | @@ -1644,9 +1586,9 @@ template <class _Tp> |
| 1644 | 1586 | struct _LIBCPP_TEMPLATE_VIS decay |
| 1645 | 1587 | { |
| 1646 | 1588 | private: |
| 1647 | typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tp>::type _Up; | |
| 1589 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up; | |
| 1648 | 1590 | public: |
| 1649 | typedef _LIBCPP_NODEBUG_TYPE typename __decay<_Up, __is_referenceable<_Up>::value>::type type; | |
| 1591 | typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type; | |
| 1650 | 1592 | }; |
| 1651 | 1593 | |
| 1652 | 1594 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -1658,10 +1600,9 @@ template <class _Tp> using decay_t = typename decay<_Tp>::type; |
| 1658 | 1600 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract |
| 1659 | 1601 | : public integral_constant<bool, __is_abstract(_Tp)> {}; |
| 1660 | 1602 | |
| 1661 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1603 | #if _LIBCPP_STD_VER > 14 | |
| 1662 | 1604 | template <class _Tp> |
| 1663 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_abstract_v | |
| 1664 | = is_abstract<_Tp>::value; | |
| 1605 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; | |
| 1665 | 1606 | #endif |
| 1666 | 1607 | |
| 1667 | 1608 | // is_final |
| ... | ... | @@ -1674,25 +1615,21 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
| 1674 | 1615 | is_final : public integral_constant<bool, __is_final(_Tp)> {}; |
| 1675 | 1616 | #endif |
| 1676 | 1617 | |
| 1677 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1618 | #if _LIBCPP_STD_VER > 14 | |
| 1678 | 1619 | template <class _Tp> |
| 1679 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_final_v | |
| 1680 | = is_final<_Tp>::value; | |
| 1620 | inline constexpr bool is_final_v = is_final<_Tp>::value; | |
| 1681 | 1621 | #endif |
| 1682 | 1622 | |
| 1683 | 1623 | // is_aggregate |
| 1684 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) | |
| 1624 | #if _LIBCPP_STD_VER > 14 | |
| 1685 | 1625 | |
| 1686 | 1626 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS |
| 1687 | 1627 | is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; |
| 1688 | 1628 | |
| 1689 | #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1690 | 1629 | template <class _Tp> |
| 1691 | _LIBCPP_INLINE_VAR constexpr bool is_aggregate_v | |
| 1692 | = is_aggregate<_Tp>::value; | |
| 1693 | #endif | |
| 1630 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; | |
| 1694 | 1631 | |
| 1695 | #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) | |
| 1632 | #endif // _LIBCPP_STD_VER > 14 | |
| 1696 | 1633 | |
| 1697 | 1634 | // is_base_of |
| 1698 | 1635 | |
| ... | ... | @@ -1700,10 +1637,9 @@ template <class _Bp, class _Dp> |
| 1700 | 1637 | struct _LIBCPP_TEMPLATE_VIS is_base_of |
| 1701 | 1638 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; |
| 1702 | 1639 | |
| 1703 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1640 | #if _LIBCPP_STD_VER > 14 | |
| 1704 | 1641 | template <class _Bp, class _Dp> |
| 1705 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_base_of_v | |
| 1706 | = is_base_of<_Bp, _Dp>::value; | |
| 1642 | inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value; | |
| 1707 | 1643 | #endif |
| 1708 | 1644 | |
| 1709 | 1645 | // __is_core_convertible |
| ... | ... | @@ -1797,10 +1733,9 @@ template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible |
| 1797 | 1733 | |
| 1798 | 1734 | #endif // __has_feature(is_convertible_to) |
| 1799 | 1735 | |
| 1800 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1736 | #if _LIBCPP_STD_VER > 14 | |
| 1801 | 1737 | template <class _From, class _To> |
| 1802 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_convertible_v | |
| 1803 | = is_convertible<_From, _To>::value; | |
| 1738 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; | |
| 1804 | 1739 | #endif |
| 1805 | 1740 | |
| 1806 | 1741 | // is_nothrow_convertible |
| ... | ... | @@ -1860,10 +1795,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empt |
| 1860 | 1795 | |
| 1861 | 1796 | #endif // __has_feature(is_empty) |
| 1862 | 1797 | |
| 1863 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1798 | #if _LIBCPP_STD_VER > 14 | |
| 1864 | 1799 | template <class _Tp> |
| 1865 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_empty_v | |
| 1866 | = is_empty<_Tp>::value; | |
| 1800 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; | |
| 1867 | 1801 | #endif |
| 1868 | 1802 | |
| 1869 | 1803 | // is_polymorphic |
| ... | ... | @@ -1886,10 +1820,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic |
| 1886 | 1820 | |
| 1887 | 1821 | #endif // __has_feature(is_polymorphic) |
| 1888 | 1822 | |
| 1889 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1823 | #if _LIBCPP_STD_VER > 14 | |
| 1890 | 1824 | template <class _Tp> |
| 1891 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_polymorphic_v | |
| 1892 | = is_polymorphic<_Tp>::value; | |
| 1825 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; | |
| 1893 | 1826 | #endif |
| 1894 | 1827 | |
| 1895 | 1828 | // has_virtual_destructor |
| ... | ... | @@ -1906,25 +1839,21 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor |
| 1906 | 1839 | |
| 1907 | 1840 | #endif |
| 1908 | 1841 | |
| 1909 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1842 | #if _LIBCPP_STD_VER > 14 | |
| 1910 | 1843 | template <class _Tp> |
| 1911 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_virtual_destructor_v | |
| 1912 | = has_virtual_destructor<_Tp>::value; | |
| 1844 | inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; | |
| 1913 | 1845 | #endif |
| 1914 | 1846 | |
| 1915 | 1847 | // has_unique_object_representations |
| 1916 | 1848 | |
| 1917 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) | |
| 1849 | #if _LIBCPP_STD_VER > 14 | |
| 1918 | 1850 | |
| 1919 | 1851 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations |
| 1920 | 1852 | : public integral_constant<bool, |
| 1921 | 1853 | __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; |
| 1922 | 1854 | |
| 1923 | #if !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1924 | 1855 | template <class _Tp> |
| 1925 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v | |
| 1926 | = has_unique_object_representations<_Tp>::value; | |
| 1927 | #endif | |
| 1856 | inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value; | |
| 1928 | 1857 | |
| 1929 | 1858 | #endif |
| 1930 | 1859 | |
| ... | ... | @@ -1933,10 +1862,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool has_unique_object_representations_v |
| 1933 | 1862 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of |
| 1934 | 1863 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; |
| 1935 | 1864 | |
| 1936 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 1865 | #if _LIBCPP_STD_VER > 14 | |
| 1937 | 1866 | template <class _Tp> |
| 1938 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR size_t alignment_of_v | |
| 1939 | = alignment_of<_Tp>::value; | |
| 1867 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; | |
| 1940 | 1868 | #endif |
| 1941 | 1869 | |
| 1942 | 1870 | // aligned_storage |
| ... | ... | @@ -2214,26 +2142,26 @@ template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeLi |
| 2214 | 2142 | template <class _Hp, class _Tp, size_t _Size> |
| 2215 | 2143 | struct __find_first<__type_list<_Hp, _Tp>, _Size, true> |
| 2216 | 2144 | { |
| 2217 | typedef _LIBCPP_NODEBUG_TYPE _Hp type; | |
| 2145 | typedef _LIBCPP_NODEBUG _Hp type; | |
| 2218 | 2146 | }; |
| 2219 | 2147 | |
| 2220 | 2148 | template <class _Hp, class _Tp, size_t _Size> |
| 2221 | 2149 | struct __find_first<__type_list<_Hp, _Tp>, _Size, false> |
| 2222 | 2150 | { |
| 2223 | typedef _LIBCPP_NODEBUG_TYPE typename __find_first<_Tp, _Size>::type type; | |
| 2151 | typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; | |
| 2224 | 2152 | }; |
| 2225 | 2153 | |
| 2226 | 2154 | template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, |
| 2227 | 2155 | bool = is_volatile<typename remove_reference<_Tp>::type>::value> |
| 2228 | 2156 | struct __apply_cv |
| 2229 | 2157 | { |
| 2230 | typedef _LIBCPP_NODEBUG_TYPE _Up type; | |
| 2158 | typedef _LIBCPP_NODEBUG _Up type; | |
| 2231 | 2159 | }; |
| 2232 | 2160 | |
| 2233 | 2161 | template <class _Tp, class _Up> |
| 2234 | 2162 | struct __apply_cv<_Tp, _Up, true, false> |
| 2235 | 2163 | { |
| 2236 | typedef _LIBCPP_NODEBUG_TYPE const _Up type; | |
| 2164 | typedef _LIBCPP_NODEBUG const _Up type; | |
| 2237 | 2165 | }; |
| 2238 | 2166 | |
| 2239 | 2167 | template <class _Tp, class _Up> |
| ... | ... | @@ -2340,7 +2268,7 @@ template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; |
| 2340 | 2268 | |
| 2341 | 2269 | #ifndef _LIBCPP_CXX03_LANG |
| 2342 | 2270 | template <class _Tp> |
| 2343 | _LIBCPP_NODISCARD_ATTRIBUTE _LIBCPP_INLINE_VISIBILITY constexpr | |
| 2271 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 2344 | 2272 | typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { |
| 2345 | 2273 | return static_cast<typename make_unsigned<_Tp>::type>(__x); |
| 2346 | 2274 | } |
| ... | ... | @@ -2379,7 +2307,7 @@ struct __common_type2_imp<_Tp, _Up, |
| 2379 | 2307 | true ? declval<_Tp>() : declval<_Up>() |
| 2380 | 2308 | )>::type> |
| 2381 | 2309 | { |
| 2382 | typedef _LIBCPP_NODEBUG_TYPE typename decay<decltype( | |
| 2310 | typedef _LIBCPP_NODEBUG typename decay<decltype( | |
| 2383 | 2311 | true ? declval<_Tp>() : declval<_Up>() |
| 2384 | 2312 | )>::type type; |
| 2385 | 2313 | }; |
| ... | ... | @@ -2390,7 +2318,7 @@ struct __common_type_impl {}; |
| 2390 | 2318 | // Clang provides variadic templates in C++03 as an extension. |
| 2391 | 2319 | #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) |
| 2392 | 2320 | # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ |
| 2393 | template <class... Tp> | |
| 2321 | template <class... _Tp> | |
| 2394 | 2322 | struct __common_types; |
| 2395 | 2323 | template <class... _Tp> |
| 2396 | 2324 | struct _LIBCPP_TEMPLATE_VIS common_type; |
| ... | ... | @@ -2514,7 +2442,7 @@ using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; |
| 2514 | 2442 | #endif // _LIBCPP_STD_VER > 11 |
| 2515 | 2443 | |
| 2516 | 2444 | // common_reference |
| 2517 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 2445 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 2518 | 2446 | // Let COND_RES(X, Y) be: |
| 2519 | 2447 | template <class _Xp, class _Yp> |
| 2520 | 2448 | using __cond_res = |
| ... | ... | @@ -2668,20 +2596,20 @@ struct common_reference<_Tp, _Up, _Vp, _Rest...> |
| 2668 | 2596 | // bullet 5 - Otherwise, there shall be no member `type`. |
| 2669 | 2597 | template <class...> struct common_reference {}; |
| 2670 | 2598 | |
| 2671 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 2599 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 2672 | 2600 | |
| 2673 | 2601 | // is_assignable |
| 2674 | 2602 | |
| 2675 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; | |
| 2603 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 2676 | 2604 | |
| 2677 | 2605 | #if __has_keyword(__is_assignable) |
| 2678 | 2606 | |
| 2679 | 2607 | template<class _Tp, class _Up> |
| 2680 | 2608 | struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { }; |
| 2681 | 2609 | |
| 2682 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2610 | #if _LIBCPP_STD_VER > 14 | |
| 2683 | 2611 | template <class _Tp, class _Arg> |
| 2684 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v = __is_assignable(_Tp, _Arg); | |
| 2612 | inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); | |
| 2685 | 2613 | #endif |
| 2686 | 2614 | |
| 2687 | 2615 | #else // __has_keyword(__is_assignable) |
| ... | ... | @@ -2708,10 +2636,9 @@ template <class _Tp, class _Arg> |
| 2708 | 2636 | struct is_assignable |
| 2709 | 2637 | : public __is_assignable_imp<_Tp, _Arg> {}; |
| 2710 | 2638 | |
| 2711 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2639 | #if _LIBCPP_STD_VER > 14 | |
| 2712 | 2640 | template <class _Tp, class _Arg> |
| 2713 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_assignable_v | |
| 2714 | = is_assignable<_Tp, _Arg>::value; | |
| 2641 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value; | |
| 2715 | 2642 | #endif |
| 2716 | 2643 | |
| 2717 | 2644 | #endif // __has_keyword(__is_assignable) |
| ... | ... | @@ -2722,10 +2649,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable |
| 2722 | 2649 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, |
| 2723 | 2650 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
| 2724 | 2651 | |
| 2725 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2652 | #if _LIBCPP_STD_VER > 14 | |
| 2726 | 2653 | template <class _Tp> |
| 2727 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_assignable_v | |
| 2728 | = is_copy_assignable<_Tp>::value; | |
| 2654 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | |
| 2729 | 2655 | #endif |
| 2730 | 2656 | |
| 2731 | 2657 | // is_move_assignable |
| ... | ... | @@ -2734,10 +2660,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable |
| 2734 | 2660 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, |
| 2735 | 2661 | typename add_rvalue_reference<_Tp>::type> {}; |
| 2736 | 2662 | |
| 2737 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2663 | #if _LIBCPP_STD_VER > 14 | |
| 2738 | 2664 | template <class _Tp> |
| 2739 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v | |
| 2740 | = is_move_assignable<_Tp>::value; | |
| 2665 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | |
| 2741 | 2666 | #endif |
| 2742 | 2667 | |
| 2743 | 2668 | // is_destructible |
| ... | ... | @@ -2747,9 +2672,9 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_assignable_v |
| 2747 | 2672 | template<class _Tp> |
| 2748 | 2673 | struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { }; |
| 2749 | 2674 | |
| 2750 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2675 | #if _LIBCPP_STD_VER > 14 | |
| 2751 | 2676 | template <class _Tp> |
| 2752 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v = __is_destructible(_Tp); | |
| 2677 | inline constexpr bool is_destructible_v = __is_destructible(_Tp); | |
| 2753 | 2678 | #endif |
| 2754 | 2679 | |
| 2755 | 2680 | #else // __has_keyword(__is_destructible) |
| ... | ... | @@ -2810,10 +2735,9 @@ template <> |
| 2810 | 2735 | struct is_destructible<void> |
| 2811 | 2736 | : public false_type {}; |
| 2812 | 2737 | |
| 2813 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2738 | #if _LIBCPP_STD_VER > 14 | |
| 2814 | 2739 | template <class _Tp> |
| 2815 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_destructible_v | |
| 2816 | = is_destructible<_Tp>::value; | |
| 2740 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; | |
| 2817 | 2741 | #endif |
| 2818 | 2742 | |
| 2819 | 2743 | #endif // __has_keyword(__is_destructible) |
| ... | ... | @@ -3049,140 +2973,14 @@ struct __member_pointer_class_type<_Ret _ClassType::*> { |
| 3049 | 2973 | |
| 3050 | 2974 | // template <class T, class... Args> struct is_constructible; |
| 3051 | 2975 | |
| 3052 | #if defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW >= 10000 | |
| 3053 | # define _LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE | |
| 3054 | #endif | |
| 3055 | ||
| 3056 | #if !defined(_LIBCPP_CXX03_LANG) && !__has_feature(is_constructible) && !defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE) | |
| 3057 | ||
| 3058 | template <class _Tp, class... _Args> | |
| 3059 | struct __libcpp_is_constructible; | |
| 3060 | ||
| 3061 | template <class _To, class _From> | |
| 3062 | struct __is_invalid_base_to_derived_cast { | |
| 3063 | static_assert(is_reference<_To>::value, "Wrong specialization"); | |
| 3064 | using _RawFrom = __uncvref_t<_From>; | |
| 3065 | using _RawTo = __uncvref_t<_To>; | |
| 3066 | static const bool value = _And< | |
| 3067 | _IsNotSame<_RawFrom, _RawTo>, | |
| 3068 | is_base_of<_RawFrom, _RawTo>, | |
| 3069 | _Not<__libcpp_is_constructible<_RawTo, _From>> | |
| 3070 | >::value; | |
| 3071 | }; | |
| 3072 | ||
| 3073 | template <class _To, class _From> | |
| 3074 | struct __is_invalid_lvalue_to_rvalue_cast : false_type { | |
| 3075 | static_assert(is_reference<_To>::value, "Wrong specialization"); | |
| 3076 | }; | |
| 3077 | ||
| 3078 | template <class _ToRef, class _FromRef> | |
| 3079 | struct __is_invalid_lvalue_to_rvalue_cast<_ToRef&&, _FromRef&> { | |
| 3080 | using _RawFrom = __uncvref_t<_FromRef>; | |
| 3081 | using _RawTo = __uncvref_t<_ToRef>; | |
| 3082 | static const bool value = _And< | |
| 3083 | _Not<is_function<_RawTo>>, | |
| 3084 | _Or< | |
| 3085 | _IsSame<_RawFrom, _RawTo>, | |
| 3086 | is_base_of<_RawTo, _RawFrom>> | |
| 3087 | >::value; | |
| 3088 | }; | |
| 3089 | ||
| 3090 | struct __is_constructible_helper | |
| 3091 | { | |
| 3092 | template <class _To> | |
| 3093 | static void __eat(_To); | |
| 3094 | ||
| 3095 | // This overload is needed to work around a Clang bug that disallows | |
| 3096 | // static_cast<T&&>(e) for non-reference-compatible types. | |
| 3097 | // Example: static_cast<int&&>(declval<double>()); | |
| 3098 | // NOTE: The static_cast implementation below is required to support | |
| 3099 | // classes with explicit conversion operators. | |
| 3100 | template <class _To, class _From, | |
| 3101 | class = decltype(__eat<_To>(declval<_From>()))> | |
| 3102 | static true_type __test_cast(int); | |
| 3103 | ||
| 3104 | template <class _To, class _From, | |
| 3105 | class = decltype(static_cast<_To>(declval<_From>()))> | |
| 3106 | static integral_constant<bool, | |
| 3107 | !__is_invalid_base_to_derived_cast<_To, _From>::value && | |
| 3108 | !__is_invalid_lvalue_to_rvalue_cast<_To, _From>::value | |
| 3109 | > __test_cast(long); | |
| 3110 | ||
| 3111 | template <class, class> | |
| 3112 | static false_type __test_cast(...); | |
| 3113 | ||
| 3114 | template <class _Tp, class ..._Args, | |
| 3115 | class = decltype(_Tp(declval<_Args>()...))> | |
| 3116 | static true_type __test_nary(int); | |
| 3117 | template <class _Tp, class...> | |
| 3118 | static false_type __test_nary(...); | |
| 3119 | ||
| 3120 | template <class _Tp, class _A0, class = decltype(::new _Tp(declval<_A0>()))> | |
| 3121 | static is_destructible<_Tp> __test_unary(int); | |
| 3122 | template <class, class> | |
| 3123 | static false_type __test_unary(...); | |
| 3124 | }; | |
| 3125 | ||
| 3126 | template <class _Tp, bool = is_void<_Tp>::value> | |
| 3127 | struct __is_default_constructible | |
| 3128 | : decltype(__is_constructible_helper::__test_nary<_Tp>(0)) | |
| 3129 | {}; | |
| 3130 | ||
| 3131 | template <class _Tp> | |
| 3132 | struct __is_default_constructible<_Tp, true> : false_type {}; | |
| 3133 | ||
| 3134 | template <class _Tp> | |
| 3135 | struct __is_default_constructible<_Tp[], false> : false_type {}; | |
| 3136 | ||
| 3137 | template <class _Tp, size_t _Nx> | |
| 3138 | struct __is_default_constructible<_Tp[_Nx], false> | |
| 3139 | : __is_default_constructible<typename remove_all_extents<_Tp>::type> {}; | |
| 3140 | ||
| 3141 | template <class _Tp, class... _Args> | |
| 3142 | struct __libcpp_is_constructible | |
| 3143 | { | |
| 3144 | static_assert(sizeof...(_Args) > 1, "Wrong specialization"); | |
| 3145 | typedef decltype(__is_constructible_helper::__test_nary<_Tp, _Args...>(0)) | |
| 3146 | type; | |
| 3147 | }; | |
| 3148 | ||
| 3149 | template <class _Tp> | |
| 3150 | struct __libcpp_is_constructible<_Tp> : __is_default_constructible<_Tp> {}; | |
| 3151 | ||
| 3152 | template <class _Tp, class _A0> | |
| 3153 | struct __libcpp_is_constructible<_Tp, _A0> | |
| 3154 | : public decltype(__is_constructible_helper::__test_unary<_Tp, _A0>(0)) | |
| 3155 | {}; | |
| 3156 | ||
| 3157 | template <class _Tp, class _A0> | |
| 3158 | struct __libcpp_is_constructible<_Tp&, _A0> | |
| 3159 | : public decltype(__is_constructible_helper:: | |
| 3160 | __test_cast<_Tp&, _A0>(0)) | |
| 3161 | {}; | |
| 3162 | ||
| 3163 | template <class _Tp, class _A0> | |
| 3164 | struct __libcpp_is_constructible<_Tp&&, _A0> | |
| 3165 | : public decltype(__is_constructible_helper:: | |
| 3166 | __test_cast<_Tp&&, _A0>(0)) | |
| 3167 | {}; | |
| 3168 | ||
| 3169 | #endif | |
| 3170 | ||
| 3171 | #if __has_feature(is_constructible) || defined(_LIBCPP_GCC_SUPPORTS_IS_CONSTRUCTIBLE) | |
| 3172 | 2976 | template <class _Tp, class ..._Args> |
| 3173 | 2977 | struct _LIBCPP_TEMPLATE_VIS is_constructible |
| 3174 | 2978 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> |
| 3175 | {}; | |
| 3176 | #else | |
| 3177 | template <class _Tp, class... _Args> | |
| 3178 | struct _LIBCPP_TEMPLATE_VIS is_constructible | |
| 3179 | : public __libcpp_is_constructible<_Tp, _Args...>::type {}; | |
| 3180 | #endif | |
| 2979 | { }; | |
| 3181 | 2980 | |
| 3182 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2981 | #if _LIBCPP_STD_VER > 14 | |
| 3183 | 2982 | template <class _Tp, class ..._Args> |
| 3184 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_constructible_v | |
| 3185 | = is_constructible<_Tp, _Args...>::value; | |
| 2983 | inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; | |
| 3186 | 2984 | #endif |
| 3187 | 2985 | |
| 3188 | 2986 | // is_default_constructible |
| ... | ... | @@ -3192,10 +2990,9 @@ struct _LIBCPP_TEMPLATE_VIS is_default_constructible |
| 3192 | 2990 | : public is_constructible<_Tp> |
| 3193 | 2991 | {}; |
| 3194 | 2992 | |
| 3195 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 2993 | #if _LIBCPP_STD_VER > 14 | |
| 3196 | 2994 | template <class _Tp> |
| 3197 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_default_constructible_v | |
| 3198 | = is_default_constructible<_Tp>::value; | |
| 2995 | inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; | |
| 3199 | 2996 | #endif |
| 3200 | 2997 | |
| 3201 | 2998 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -3229,10 +3026,9 @@ struct _LIBCPP_TEMPLATE_VIS is_copy_constructible |
| 3229 | 3026 | : public is_constructible<_Tp, |
| 3230 | 3027 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
| 3231 | 3028 | |
| 3232 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3029 | #if _LIBCPP_STD_VER > 14 | |
| 3233 | 3030 | template <class _Tp> |
| 3234 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_copy_constructible_v | |
| 3235 | = is_copy_constructible<_Tp>::value; | |
| 3031 | inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | |
| 3236 | 3032 | #endif |
| 3237 | 3033 | |
| 3238 | 3034 | // is_move_constructible |
| ... | ... | @@ -3242,65 +3038,22 @@ struct _LIBCPP_TEMPLATE_VIS is_move_constructible |
| 3242 | 3038 | : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
| 3243 | 3039 | {}; |
| 3244 | 3040 | |
| 3245 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3041 | #if _LIBCPP_STD_VER > 14 | |
| 3246 | 3042 | template <class _Tp> |
| 3247 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_move_constructible_v | |
| 3248 | = is_move_constructible<_Tp>::value; | |
| 3043 | inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | |
| 3249 | 3044 | #endif |
| 3250 | 3045 | |
| 3251 | 3046 | // is_trivially_constructible |
| 3252 | 3047 | |
| 3253 | #if __has_feature(is_trivially_constructible) || _GNUC_VER >= 501 | |
| 3254 | ||
| 3255 | 3048 | template <class _Tp, class... _Args> |
| 3256 | 3049 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible |
| 3257 | 3050 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> |
| 3258 | 3051 | { |
| 3259 | 3052 | }; |
| 3260 | 3053 | |
| 3261 | #else // !__has_feature(is_trivially_constructible) | |
| 3262 | ||
| 3263 | template <class _Tp, class... _Args> | |
| 3264 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible | |
| 3265 | : false_type | |
| 3266 | { | |
| 3267 | }; | |
| 3268 | ||
| 3269 | template <class _Tp> | |
| 3270 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp> | |
| 3271 | #if __has_feature(has_trivial_constructor) || defined(_LIBCPP_COMPILER_GCC) | |
| 3272 | : integral_constant<bool, __has_trivial_constructor(_Tp)> | |
| 3273 | #else | |
| 3274 | : integral_constant<bool, is_scalar<_Tp>::value> | |
| 3275 | #endif | |
| 3276 | { | |
| 3277 | }; | |
| 3278 | ||
| 3279 | template <class _Tp> | |
| 3280 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&&> | |
| 3281 | : integral_constant<bool, is_scalar<_Tp>::value> | |
| 3282 | { | |
| 3283 | }; | |
| 3284 | ||
| 3285 | template <class _Tp> | |
| 3286 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, const _Tp&> | |
| 3287 | : integral_constant<bool, is_scalar<_Tp>::value> | |
| 3288 | { | |
| 3289 | }; | |
| 3290 | ||
| 3291 | template <class _Tp> | |
| 3292 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible<_Tp, _Tp&> | |
| 3293 | : integral_constant<bool, is_scalar<_Tp>::value> | |
| 3294 | { | |
| 3295 | }; | |
| 3296 | ||
| 3297 | #endif // !__has_feature(is_trivially_constructible) | |
| 3298 | ||
| 3299 | ||
| 3300 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3054 | #if _LIBCPP_STD_VER > 14 | |
| 3301 | 3055 | template <class _Tp, class... _Args> |
| 3302 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_constructible_v | |
| 3303 | = is_trivially_constructible<_Tp, _Args...>::value; | |
| 3056 | inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; | |
| 3304 | 3057 | #endif |
| 3305 | 3058 | |
| 3306 | 3059 | // is_trivially_default_constructible |
| ... | ... | @@ -3309,10 +3062,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructi |
| 3309 | 3062 | : public is_trivially_constructible<_Tp> |
| 3310 | 3063 | {}; |
| 3311 | 3064 | |
| 3312 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3065 | #if _LIBCPP_STD_VER > 14 | |
| 3313 | 3066 | template <class _Tp> |
| 3314 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v | |
| 3315 | = is_trivially_default_constructible<_Tp>::value; | |
| 3067 | inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; | |
| 3316 | 3068 | #endif |
| 3317 | 3069 | |
| 3318 | 3070 | // is_trivially_copy_constructible |
| ... | ... | @@ -3321,10 +3073,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible |
| 3321 | 3073 | : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> |
| 3322 | 3074 | {}; |
| 3323 | 3075 | |
| 3324 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3076 | #if _LIBCPP_STD_VER > 14 | |
| 3325 | 3077 | template <class _Tp> |
| 3326 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v | |
| 3327 | = is_trivially_copy_constructible<_Tp>::value; | |
| 3078 | inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; | |
| 3328 | 3079 | #endif |
| 3329 | 3080 | |
| 3330 | 3081 | // is_trivially_move_constructible |
| ... | ... | @@ -3333,50 +3084,21 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible |
| 3333 | 3084 | : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
| 3334 | 3085 | {}; |
| 3335 | 3086 | |
| 3336 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3087 | #if _LIBCPP_STD_VER > 14 | |
| 3337 | 3088 | template <class _Tp> |
| 3338 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v | |
| 3339 | = is_trivially_move_constructible<_Tp>::value; | |
| 3089 | inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; | |
| 3340 | 3090 | #endif |
| 3341 | 3091 | |
| 3342 | 3092 | // is_trivially_assignable |
| 3343 | 3093 | |
| 3344 | #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 | |
| 3345 | ||
| 3346 | 3094 | template <class _Tp, class _Arg> |
| 3347 | 3095 | struct is_trivially_assignable |
| 3348 | 3096 | : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> |
| 3349 | { | |
| 3350 | }; | |
| 3351 | ||
| 3352 | #else // !__has_feature(is_trivially_assignable) | |
| 3353 | ||
| 3354 | template <class _Tp, class _Arg> | |
| 3355 | struct is_trivially_assignable | |
| 3356 | : public false_type {}; | |
| 3357 | ||
| 3358 | template <class _Tp> | |
| 3359 | struct is_trivially_assignable<_Tp&, _Tp> | |
| 3360 | : integral_constant<bool, is_scalar<_Tp>::value> {}; | |
| 3361 | ||
| 3362 | template <class _Tp> | |
| 3363 | struct is_trivially_assignable<_Tp&, _Tp&> | |
| 3364 | : integral_constant<bool, is_scalar<_Tp>::value> {}; | |
| 3365 | ||
| 3366 | template <class _Tp> | |
| 3367 | struct is_trivially_assignable<_Tp&, const _Tp&> | |
| 3368 | : integral_constant<bool, is_scalar<_Tp>::value> {}; | |
| 3369 | ||
| 3370 | template <class _Tp> | |
| 3371 | struct is_trivially_assignable<_Tp&, _Tp&&> | |
| 3372 | : integral_constant<bool, is_scalar<_Tp>::value> {}; | |
| 3373 | ||
| 3374 | #endif // !__has_feature(is_trivially_assignable) | |
| 3097 | { }; | |
| 3375 | 3098 | |
| 3376 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3099 | #if _LIBCPP_STD_VER > 14 | |
| 3377 | 3100 | template <class _Tp, class _Arg> |
| 3378 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_assignable_v | |
| 3379 | = is_trivially_assignable<_Tp, _Arg>::value; | |
| 3101 | inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value; | |
| 3380 | 3102 | #endif |
| 3381 | 3103 | |
| 3382 | 3104 | // is_trivially_copy_assignable |
| ... | ... | @@ -3385,10 +3107,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable |
| 3385 | 3107 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, |
| 3386 | 3108 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
| 3387 | 3109 | |
| 3388 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3110 | #if _LIBCPP_STD_VER > 14 | |
| 3389 | 3111 | template <class _Tp> |
| 3390 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v | |
| 3391 | = is_trivially_copy_assignable<_Tp>::value; | |
| 3112 | inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; | |
| 3392 | 3113 | #endif |
| 3393 | 3114 | |
| 3394 | 3115 | // is_trivially_move_assignable |
| ... | ... | @@ -3398,10 +3119,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable |
| 3398 | 3119 | typename add_rvalue_reference<_Tp>::type> |
| 3399 | 3120 | {}; |
| 3400 | 3121 | |
| 3401 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3122 | #if _LIBCPP_STD_VER > 14 | |
| 3402 | 3123 | template <class _Tp> |
| 3403 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v | |
| 3404 | = is_trivially_move_assignable<_Tp>::value; | |
| 3124 | inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; | |
| 3405 | 3125 | #endif |
| 3406 | 3126 | |
| 3407 | 3127 | // is_trivially_destructible |
| ... | ... | @@ -3430,10 +3150,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[] |
| 3430 | 3150 | |
| 3431 | 3151 | #endif |
| 3432 | 3152 | |
| 3433 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3153 | #if _LIBCPP_STD_VER > 14 | |
| 3434 | 3154 | template <class _Tp> |
| 3435 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_destructible_v | |
| 3436 | = is_trivially_destructible<_Tp>::value; | |
| 3155 | inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; | |
| 3437 | 3156 | #endif |
| 3438 | 3157 | |
| 3439 | 3158 | // is_nothrow_constructible |
| ... | ... | @@ -3484,10 +3203,9 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> |
| 3484 | 3203 | #endif // _LIBCPP_HAS_NO_NOEXCEPT |
| 3485 | 3204 | |
| 3486 | 3205 | |
| 3487 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3206 | #if _LIBCPP_STD_VER > 14 | |
| 3488 | 3207 | template <class _Tp, class ..._Args> |
| 3489 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v | |
| 3490 | = is_nothrow_constructible<_Tp, _Args...>::value; | |
| 3208 | inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; | |
| 3491 | 3209 | #endif |
| 3492 | 3210 | |
| 3493 | 3211 | // is_nothrow_default_constructible |
| ... | ... | @@ -3496,10 +3214,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructibl |
| 3496 | 3214 | : public is_nothrow_constructible<_Tp> |
| 3497 | 3215 | {}; |
| 3498 | 3216 | |
| 3499 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3217 | #if _LIBCPP_STD_VER > 14 | |
| 3500 | 3218 | template <class _Tp> |
| 3501 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v | |
| 3502 | = is_nothrow_default_constructible<_Tp>::value; | |
| 3219 | inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; | |
| 3503 | 3220 | #endif |
| 3504 | 3221 | |
| 3505 | 3222 | // is_nothrow_copy_constructible |
| ... | ... | @@ -3508,10 +3225,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible |
| 3508 | 3225 | : public is_nothrow_constructible<_Tp, |
| 3509 | 3226 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
| 3510 | 3227 | |
| 3511 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3228 | #if _LIBCPP_STD_VER > 14 | |
| 3512 | 3229 | template <class _Tp> |
| 3513 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v | |
| 3514 | = is_nothrow_copy_constructible<_Tp>::value; | |
| 3230 | inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; | |
| 3515 | 3231 | #endif |
| 3516 | 3232 | |
| 3517 | 3233 | // is_nothrow_move_constructible |
| ... | ... | @@ -3520,10 +3236,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible |
| 3520 | 3236 | : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> |
| 3521 | 3237 | {}; |
| 3522 | 3238 | |
| 3523 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3239 | #if _LIBCPP_STD_VER > 14 | |
| 3524 | 3240 | template <class _Tp> |
| 3525 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v | |
| 3526 | = is_nothrow_move_constructible<_Tp>::value; | |
| 3241 | inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; | |
| 3527 | 3242 | #endif |
| 3528 | 3243 | |
| 3529 | 3244 | // is_nothrow_assignable |
| ... | ... | @@ -3558,10 +3273,9 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable |
| 3558 | 3273 | |
| 3559 | 3274 | #endif // _LIBCPP_HAS_NO_NOEXCEPT |
| 3560 | 3275 | |
| 3561 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3276 | #if _LIBCPP_STD_VER > 14 | |
| 3562 | 3277 | template <class _Tp, class _Arg> |
| 3563 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v | |
| 3564 | = is_nothrow_assignable<_Tp, _Arg>::value; | |
| 3278 | inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value; | |
| 3565 | 3279 | #endif |
| 3566 | 3280 | |
| 3567 | 3281 | // is_nothrow_copy_assignable |
| ... | ... | @@ -3570,10 +3284,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable |
| 3570 | 3284 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, |
| 3571 | 3285 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; |
| 3572 | 3286 | |
| 3573 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3287 | #if _LIBCPP_STD_VER > 14 | |
| 3574 | 3288 | template <class _Tp> |
| 3575 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v | |
| 3576 | = is_nothrow_copy_assignable<_Tp>::value; | |
| 3289 | inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | |
| 3577 | 3290 | #endif |
| 3578 | 3291 | |
| 3579 | 3292 | // is_nothrow_move_assignable |
| ... | ... | @@ -3583,10 +3296,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable |
| 3583 | 3296 | typename add_rvalue_reference<_Tp>::type> |
| 3584 | 3297 | {}; |
| 3585 | 3298 | |
| 3586 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3299 | #if _LIBCPP_STD_VER > 14 | |
| 3587 | 3300 | template <class _Tp> |
| 3588 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v | |
| 3589 | = is_nothrow_move_assignable<_Tp>::value; | |
| 3301 | inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | |
| 3590 | 3302 | #endif |
| 3591 | 3303 | |
| 3592 | 3304 | // is_nothrow_destructible |
| ... | ... | @@ -3646,10 +3358,9 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> |
| 3646 | 3358 | |
| 3647 | 3359 | #endif |
| 3648 | 3360 | |
| 3649 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3361 | #if _LIBCPP_STD_VER > 14 | |
| 3650 | 3362 | template <class _Tp> |
| 3651 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v | |
| 3652 | = is_nothrow_destructible<_Tp>::value; | |
| 3363 | inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; | |
| 3653 | 3364 | #endif |
| 3654 | 3365 | |
| 3655 | 3366 | // is_pod |
| ... | ... | @@ -3669,10 +3380,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod |
| 3669 | 3380 | |
| 3670 | 3381 | #endif |
| 3671 | 3382 | |
| 3672 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3383 | #if _LIBCPP_STD_VER > 14 | |
| 3673 | 3384 | template <class _Tp> |
| 3674 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pod_v | |
| 3675 | = is_pod<_Tp>::value; | |
| 3385 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; | |
| 3676 | 3386 | #endif |
| 3677 | 3387 | |
| 3678 | 3388 | // is_literal_type; |
| ... | ... | @@ -3682,11 +3392,10 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_ |
| 3682 | 3392 | : public integral_constant<bool, __is_literal_type(_Tp)> |
| 3683 | 3393 | {}; |
| 3684 | 3394 | |
| 3685 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3395 | #if _LIBCPP_STD_VER > 14 | |
| 3686 | 3396 | template <class _Tp> |
| 3687 | _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_literal_type_v | |
| 3688 | = is_literal_type<_Tp>::value; | |
| 3689 | #endif // _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3397 | _LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; | |
| 3398 | #endif // _LIBCPP_STD_VER > 14 | |
| 3690 | 3399 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 3691 | 3400 | |
| 3692 | 3401 | // is_standard_layout; |
| ... | ... | @@ -3699,28 +3408,20 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout |
| 3699 | 3408 | #endif |
| 3700 | 3409 | {}; |
| 3701 | 3410 | |
| 3702 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3411 | #if _LIBCPP_STD_VER > 14 | |
| 3703 | 3412 | template <class _Tp> |
| 3704 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_standard_layout_v | |
| 3705 | = is_standard_layout<_Tp>::value; | |
| 3413 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; | |
| 3706 | 3414 | #endif |
| 3707 | 3415 | |
| 3708 | 3416 | // is_trivially_copyable; |
| 3709 | 3417 | |
| 3710 | 3418 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable |
| 3711 | #if __has_feature(is_trivially_copyable) | |
| 3712 | 3419 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> |
| 3713 | #elif _GNUC_VER >= 501 | |
| 3714 | : public integral_constant<bool, !is_volatile<_Tp>::value && __is_trivially_copyable(_Tp)> | |
| 3715 | #else | |
| 3716 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> | |
| 3717 | #endif | |
| 3718 | 3420 | {}; |
| 3719 | 3421 | |
| 3720 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3422 | #if _LIBCPP_STD_VER > 14 | |
| 3721 | 3423 | template <class _Tp> |
| 3722 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivially_copyable_v | |
| 3723 | = is_trivially_copyable<_Tp>::value; | |
| 3424 | inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; | |
| 3724 | 3425 | #endif |
| 3725 | 3426 | |
| 3726 | 3427 | // is_trivial; |
| ... | ... | @@ -3734,10 +3435,9 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial |
| 3734 | 3435 | #endif |
| 3735 | 3436 | {}; |
| 3736 | 3437 | |
| 3737 | #if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) | |
| 3438 | #if _LIBCPP_STD_VER > 14 | |
| 3738 | 3439 | template <class _Tp> |
| 3739 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_trivial_v | |
| 3740 | = is_trivial<_Tp>::value; | |
| 3440 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; | |
| 3741 | 3441 | #endif |
| 3742 | 3442 | |
| 3743 | 3443 | template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; |
| ... | ... | @@ -3811,10 +3511,6 @@ using __enable_if_bullet6 = typename enable_if |
| 3811 | 3511 | |
| 3812 | 3512 | // fall back - none of the bullets |
| 3813 | 3513 | |
| 3814 | #define _LIBCPP_INVOKE_RETURN(...) \ | |
| 3815 | noexcept(noexcept(__VA_ARGS__)) -> decltype(__VA_ARGS__) \ | |
| 3816 | { return __VA_ARGS__; } | |
| 3817 | ||
| 3818 | 3514 | template <class ..._Args> |
| 3819 | 3515 | auto __invoke(__any, _Args&& ...__args) -> __nat; |
| 3820 | 3516 | |
| ... | ... | @@ -3828,42 +3524,54 @@ template <class _Fp, class _A0, class ..._Args, |
| 3828 | 3524 | inline _LIBCPP_INLINE_VISIBILITY |
| 3829 | 3525 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3830 | 3526 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
| 3831 | _LIBCPP_INVOKE_RETURN((static_cast<_A0&&>(__a0).*__f)(static_cast<_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)...); } | |
| 3832 | 3530 | |
| 3833 | 3531 | template <class _Fp, class _A0, class ..._Args, |
| 3834 | 3532 | class = __enable_if_bullet1<_Fp, _A0>> |
| 3835 | 3533 | inline _LIBCPP_INLINE_VISIBILITY |
| 3836 | 3534 | _LIBCPP_CONSTEXPR auto |
| 3837 | 3535 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
| 3838 | _LIBCPP_INVOKE_RETURN((static_cast<_A0&&>(__a0).*__f)(static_cast<_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)...); } | |
| 3839 | 3539 | |
| 3840 | 3540 | template <class _Fp, class _A0, class ..._Args, |
| 3841 | 3541 | class = __enable_if_bullet2<_Fp, _A0>> |
| 3842 | 3542 | inline _LIBCPP_INLINE_VISIBILITY |
| 3843 | 3543 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3844 | 3544 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
| 3845 | _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(static_cast<_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)...); } | |
| 3846 | 3548 | |
| 3847 | 3549 | template <class _Fp, class _A0, class ..._Args, |
| 3848 | 3550 | class = __enable_if_bullet2<_Fp, _A0>> |
| 3849 | 3551 | inline _LIBCPP_INLINE_VISIBILITY |
| 3850 | 3552 | _LIBCPP_CONSTEXPR auto |
| 3851 | 3553 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
| 3852 | _LIBCPP_INVOKE_RETURN((__a0.get().*__f)(static_cast<_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)...); } | |
| 3853 | 3557 | |
| 3854 | 3558 | template <class _Fp, class _A0, class ..._Args, |
| 3855 | 3559 | class = __enable_if_bullet3<_Fp, _A0>> |
| 3856 | 3560 | inline _LIBCPP_INLINE_VISIBILITY |
| 3857 | 3561 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3858 | 3562 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
| 3859 | _LIBCPP_INVOKE_RETURN(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_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)...); } | |
| 3860 | 3566 | |
| 3861 | 3567 | template <class _Fp, class _A0, class ..._Args, |
| 3862 | 3568 | class = __enable_if_bullet3<_Fp, _A0>> |
| 3863 | 3569 | inline _LIBCPP_INLINE_VISIBILITY |
| 3864 | 3570 | _LIBCPP_CONSTEXPR auto |
| 3865 | 3571 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) |
| 3866 | _LIBCPP_INVOKE_RETURN(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_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)...); } | |
| 3867 | 3575 | |
| 3868 | 3576 | // bullets 4, 5 and 6 |
| 3869 | 3577 | |
| ... | ... | @@ -3872,42 +3580,54 @@ template <class _Fp, class _A0, |
| 3872 | 3580 | inline _LIBCPP_INLINE_VISIBILITY |
| 3873 | 3581 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3874 | 3582 | __invoke(_Fp&& __f, _A0&& __a0) |
| 3875 | _LIBCPP_INVOKE_RETURN(static_cast<_A0&&>(__a0).*__f) | |
| 3583 | noexcept(noexcept(static_cast<_A0&&>(__a0).*__f)) | |
| 3584 | -> decltype( static_cast<_A0&&>(__a0).*__f) | |
| 3585 | { return static_cast<_A0&&>(__a0).*__f; } | |
| 3876 | 3586 | |
| 3877 | 3587 | template <class _Fp, class _A0, |
| 3878 | 3588 | class = __enable_if_bullet4<_Fp, _A0>> |
| 3879 | 3589 | inline _LIBCPP_INLINE_VISIBILITY |
| 3880 | 3590 | _LIBCPP_CONSTEXPR auto |
| 3881 | 3591 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
| 3882 | _LIBCPP_INVOKE_RETURN(static_cast<_A0&&>(__a0).*__f) | |
| 3592 | noexcept(noexcept(static_cast<_A0&&>(__a0).*__f)) | |
| 3593 | -> decltype( static_cast<_A0&&>(__a0).*__f) | |
| 3594 | { return static_cast<_A0&&>(__a0).*__f; } | |
| 3883 | 3595 | |
| 3884 | 3596 | template <class _Fp, class _A0, |
| 3885 | 3597 | class = __enable_if_bullet5<_Fp, _A0>> |
| 3886 | 3598 | inline _LIBCPP_INLINE_VISIBILITY |
| 3887 | 3599 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3888 | 3600 | __invoke(_Fp&& __f, _A0&& __a0) |
| 3889 | _LIBCPP_INVOKE_RETURN(__a0.get().*__f) | |
| 3601 | noexcept(noexcept(__a0.get().*__f)) | |
| 3602 | -> decltype( __a0.get().*__f) | |
| 3603 | { return __a0.get().*__f; } | |
| 3890 | 3604 | |
| 3891 | 3605 | template <class _Fp, class _A0, |
| 3892 | 3606 | class = __enable_if_bullet5<_Fp, _A0>> |
| 3893 | 3607 | inline _LIBCPP_INLINE_VISIBILITY |
| 3894 | 3608 | _LIBCPP_CONSTEXPR auto |
| 3895 | 3609 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
| 3896 | _LIBCPP_INVOKE_RETURN(__a0.get().*__f) | |
| 3610 | noexcept(noexcept(__a0.get().*__f)) | |
| 3611 | -> decltype( __a0.get().*__f) | |
| 3612 | { return __a0.get().*__f; } | |
| 3897 | 3613 | |
| 3898 | 3614 | template <class _Fp, class _A0, |
| 3899 | 3615 | class = __enable_if_bullet6<_Fp, _A0>> |
| 3900 | 3616 | inline _LIBCPP_INLINE_VISIBILITY |
| 3901 | 3617 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3902 | 3618 | __invoke(_Fp&& __f, _A0&& __a0) |
| 3903 | _LIBCPP_INVOKE_RETURN((*static_cast<_A0&&>(__a0)).*__f) | |
| 3619 | noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f)) | |
| 3620 | -> decltype( (*static_cast<_A0&&>(__a0)).*__f) | |
| 3621 | { return (*static_cast<_A0&&>(__a0)).*__f; } | |
| 3904 | 3622 | |
| 3905 | 3623 | template <class _Fp, class _A0, |
| 3906 | 3624 | class = __enable_if_bullet6<_Fp, _A0>> |
| 3907 | 3625 | inline _LIBCPP_INLINE_VISIBILITY |
| 3908 | 3626 | _LIBCPP_CONSTEXPR auto |
| 3909 | 3627 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) |
| 3910 | _LIBCPP_INVOKE_RETURN((*static_cast<_A0&&>(__a0)).*__f) | |
| 3628 | noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f)) | |
| 3629 | -> decltype( (*static_cast<_A0&&>(__a0)).*__f) | |
| 3630 | { return (*static_cast<_A0&&>(__a0)).*__f; } | |
| 3911 | 3631 | |
| 3912 | 3632 | // bullet 7 |
| 3913 | 3633 | |
| ... | ... | @@ -3915,15 +3635,17 @@ template <class _Fp, class ..._Args> |
| 3915 | 3635 | inline _LIBCPP_INLINE_VISIBILITY |
| 3916 | 3636 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto |
| 3917 | 3637 | __invoke(_Fp&& __f, _Args&& ...__args) |
| 3918 | _LIBCPP_INVOKE_RETURN(static_cast<_Fp&&>(__f)(static_cast<_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)...); } | |
| 3919 | 3641 | |
| 3920 | 3642 | template <class _Fp, class ..._Args> |
| 3921 | 3643 | inline _LIBCPP_INLINE_VISIBILITY |
| 3922 | 3644 | _LIBCPP_CONSTEXPR auto |
| 3923 | 3645 | __invoke_constexpr(_Fp&& __f, _Args&& ...__args) |
| 3924 | _LIBCPP_INVOKE_RETURN(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)) | |
| 3925 | ||
| 3926 | #undef _LIBCPP_INVOKE_RETURN | |
| 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)...); } | |
| 3927 | 3649 | |
| 3928 | 3650 | // __invokable |
| 3929 | 3651 | template <class _Ret, class _Fp, class ..._Args> |
| ... | ... | @@ -4122,12 +3844,10 @@ struct _LIBCPP_TEMPLATE_VIS is_invocable_r |
| 4122 | 3844 | : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; |
| 4123 | 3845 | |
| 4124 | 3846 | template <class _Fn, class ..._Args> |
| 4125 | _LIBCPP_INLINE_VAR constexpr bool is_invocable_v | |
| 4126 | = is_invocable<_Fn, _Args...>::value; | |
| 3847 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
| 4127 | 3848 | |
| 4128 | 3849 | template <class _Ret, class _Fn, class ..._Args> |
| 4129 | _LIBCPP_INLINE_VAR constexpr bool is_invocable_r_v | |
| 4130 | = is_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 3850 | inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 4131 | 3851 | |
| 4132 | 3852 | // is_nothrow_invocable |
| 4133 | 3853 | |
| ... | ... | @@ -4140,12 +3860,10 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r |
| 4140 | 3860 | : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; |
| 4141 | 3861 | |
| 4142 | 3862 | template <class _Fn, class ..._Args> |
| 4143 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_v | |
| 4144 | = is_nothrow_invocable<_Fn, _Args...>::value; | |
| 3863 | inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; | |
| 4145 | 3864 | |
| 4146 | 3865 | template <class _Ret, class _Fn, class ..._Args> |
| 4147 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_invocable_r_v | |
| 4148 | = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 3866 | inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 4149 | 3867 | |
| 4150 | 3868 | #endif // _LIBCPP_STD_VER > 14 |
| 4151 | 3869 | |
| ... | ... | @@ -4215,7 +3933,7 @@ struct __nothrow_swappable_with { |
| 4215 | 3933 | template <class _Tp, class _Up> |
| 4216 | 3934 | struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {}; |
| 4217 | 3935 | |
| 4218 | } // __detail | |
| 3936 | } // namespace __detail | |
| 4219 | 3937 | |
| 4220 | 3938 | template <class _Tp> |
| 4221 | 3939 | struct __is_swappable |
| ... | ... | @@ -4268,20 +3986,16 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable |
| 4268 | 3986 | }; |
| 4269 | 3987 | |
| 4270 | 3988 | template <class _Tp, class _Up> |
| 4271 | _LIBCPP_INLINE_VAR constexpr bool is_swappable_with_v | |
| 4272 | = is_swappable_with<_Tp, _Up>::value; | |
| 3989 | inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value; | |
| 4273 | 3990 | |
| 4274 | 3991 | template <class _Tp> |
| 4275 | _LIBCPP_INLINE_VAR constexpr bool is_swappable_v | |
| 4276 | = is_swappable<_Tp>::value; | |
| 3992 | inline constexpr bool is_swappable_v = is_swappable<_Tp>::value; | |
| 4277 | 3993 | |
| 4278 | 3994 | template <class _Tp, class _Up> |
| 4279 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_with_v | |
| 4280 | = is_nothrow_swappable_with<_Tp, _Up>::value; | |
| 3995 | inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value; | |
| 4281 | 3996 | |
| 4282 | 3997 | template <class _Tp> |
| 4283 | _LIBCPP_INLINE_VAR constexpr bool is_nothrow_swappable_v | |
| 4284 | = is_nothrow_swappable<_Tp>::value; | |
| 3998 | inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; | |
| 4285 | 3999 | |
| 4286 | 4000 | #endif // _LIBCPP_STD_VER > 14 |
| 4287 | 4001 | |
| ... | ... | @@ -4349,40 +4063,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 4349 | 4063 | typename __sfinae_underlying_type<_Tp>::__promoted_type |
| 4350 | 4064 | __convert_to_integral(_Tp __val) { return __val; } |
| 4351 | 4065 | |
| 4352 | #ifndef _LIBCPP_CXX03_LANG | |
| 4353 | ||
| 4354 | template <class _Tp> | |
| 4355 | struct __has_operator_addressof_member_imp | |
| 4356 | { | |
| 4357 | template <class _Up> | |
| 4358 | static auto __test(int) | |
| 4359 | -> typename __select_2nd<decltype(declval<_Up>().operator&()), true_type>::type; | |
| 4360 | template <class> | |
| 4361 | static auto __test(long) -> false_type; | |
| 4362 | ||
| 4363 | static const bool value = decltype(__test<_Tp>(0))::value; | |
| 4364 | }; | |
| 4365 | ||
| 4366 | template <class _Tp> | |
| 4367 | struct __has_operator_addressof_free_imp | |
| 4368 | { | |
| 4369 | template <class _Up> | |
| 4370 | static auto __test(int) | |
| 4371 | -> typename __select_2nd<decltype(operator&(declval<_Up>())), true_type>::type; | |
| 4372 | template <class> | |
| 4373 | static auto __test(long) -> false_type; | |
| 4374 | ||
| 4375 | static const bool value = decltype(__test<_Tp>(0))::value; | |
| 4376 | }; | |
| 4377 | ||
| 4378 | template <class _Tp> | |
| 4379 | struct __has_operator_addressof | |
| 4380 | : public integral_constant<bool, __has_operator_addressof_member_imp<_Tp>::value | |
| 4381 | || __has_operator_addressof_free_imp<_Tp>::value> | |
| 4382 | {}; | |
| 4383 | ||
| 4384 | #endif // _LIBCPP_CXX03_LANG | |
| 4385 | ||
| 4386 | 4066 | // is_scoped_enum [meta.unary.prop] |
| 4387 | 4067 | |
| 4388 | 4068 | #if _LIBCPP_STD_VER > 20 |
| ... | ... | @@ -4398,8 +4078,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scoped_enum |
| 4398 | 4078 | : public __is_scoped_enum_helper<_Tp> {}; |
| 4399 | 4079 | |
| 4400 | 4080 | template <class _Tp> |
| 4401 | _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scoped_enum_v = | |
| 4402 | is_scoped_enum<_Tp>::value; | |
| 4081 | inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; | |
| 4403 | 4082 | #endif |
| 4404 | 4083 | |
| 4405 | 4084 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -4407,20 +4086,17 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_scoped_enum_v = |
| 4407 | 4086 | template <class... _Args> |
| 4408 | 4087 | struct conjunction : _And<_Args...> {}; |
| 4409 | 4088 | template<class... _Args> |
| 4410 | _LIBCPP_INLINE_VAR constexpr bool conjunction_v | |
| 4411 | = conjunction<_Args...>::value; | |
| 4089 | inline constexpr bool conjunction_v = conjunction<_Args...>::value; | |
| 4412 | 4090 | |
| 4413 | 4091 | template <class... _Args> |
| 4414 | 4092 | struct disjunction : _Or<_Args...> {}; |
| 4415 | 4093 | template<class... _Args> |
| 4416 | _LIBCPP_INLINE_VAR constexpr bool disjunction_v | |
| 4417 | = disjunction<_Args...>::value; | |
| 4094 | inline constexpr bool disjunction_v = disjunction<_Args...>::value; | |
| 4418 | 4095 | |
| 4419 | 4096 | template <class _Tp> |
| 4420 | 4097 | struct negation : _Not<_Tp> {}; |
| 4421 | 4098 | template<class _Tp> |
| 4422 | _LIBCPP_INLINE_VAR constexpr bool negation_v | |
| 4423 | = negation<_Tp>::value; | |
| 4099 | inline constexpr bool negation_v = negation<_Tp>::value; | |
| 4424 | 4100 | #endif // _LIBCPP_STD_VER > 14 |
| 4425 | 4101 | |
| 4426 | 4102 | // These traits are used in __tree and __hash_table |
| ... | ... | @@ -4453,7 +4129,6 @@ template <class _ValTy, class _Key, class _RawValTy> |
| 4453 | 4129 | struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> |
| 4454 | 4130 | : false_type {}; |
| 4455 | 4131 | |
| 4456 | #ifndef _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED | |
| 4457 | 4132 | #if _LIBCPP_STD_VER > 17 |
| 4458 | 4133 | _LIBCPP_INLINE_VISIBILITY |
| 4459 | 4134 | inline constexpr bool is_constant_evaluated() noexcept { |
| ... | ... | @@ -4463,10 +4138,6 @@ inline constexpr bool is_constant_evaluated() noexcept { |
| 4463 | 4138 | |
| 4464 | 4139 | inline _LIBCPP_CONSTEXPR |
| 4465 | 4140 | bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); } |
| 4466 | #else | |
| 4467 | inline _LIBCPP_CONSTEXPR | |
| 4468 | bool __libcpp_is_constant_evaluated() _NOEXCEPT { return false; } | |
| 4469 | #endif | |
| 4470 | 4141 | |
| 4471 | 4142 | template <class _CharT> |
| 4472 | 4143 | using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; |
| ... | ... | @@ -4481,13 +4152,4 @@ using __maybe_const = conditional_t<_Const, const _Tp, _Tp>; |
| 4481 | 4152 | |
| 4482 | 4153 | _LIBCPP_END_NAMESPACE_STD |
| 4483 | 4154 | |
| 4484 | #if _LIBCPP_STD_VER > 14 | |
| 4485 | // std::byte | |
| 4486 | namespace std // purposefully not versioned | |
| 4487 | { | |
| 4488 | ||
| 4489 | ||
| 4490 | } | |
| 4491 | #endif | |
| 4492 | ||
| 4493 | 4155 | #endif // _LIBCPP_TYPE_TRAITS |
lib/libcxx/include/typeindex+2-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- typeindex ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -49,6 +49,7 @@ struct hash<type_index> |
| 49 | 49 | #include <__functional_base> |
| 50 | 50 | #include <compare> |
| 51 | 51 | #include <typeinfo> |
| 52 | #include <version> | |
| 52 | 53 | |
| 53 | 54 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 54 | 55 | #pragma GCC system_header |
lib/libcxx/include/typeinfo+2-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- typeinfo ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -361,7 +361,7 @@ class _LIBCPP_EXCEPTION_ABI bad_typeid |
| 361 | 361 | virtual const char* what() const _NOEXCEPT; |
| 362 | 362 | }; |
| 363 | 363 | |
| 364 | } // std | |
| 364 | } // namespace std | |
| 365 | 365 | |
| 366 | 366 | #endif // defined(_LIBCPP_ABI_VCRUNTIME) |
| 367 | 367 |
lib/libcxx/include/unordered_map+279-256| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- unordered_map -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -216,6 +216,47 @@ public: |
| 216 | 216 | void reserve(size_type n); |
| 217 | 217 | }; |
| 218 | 218 | |
| 219 | template<class InputIterator, | |
| 220 | class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>, | |
| 221 | class Allocator = allocator<iter_to_alloc_t<InputIterator>>> | |
| 222 | unordered_map(InputIterator, InputIterator, typename see below::size_type = see below, | |
| 223 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 224 | -> unordered_map<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred, | |
| 225 | Allocator>; // C++17 | |
| 226 | ||
| 227 | template<class Key, class T, class Hash = hash<Key>, | |
| 228 | class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> | |
| 229 | unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type = see below, | |
| 230 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 231 | -> unordered_map<Key, T, Hash, Pred, Allocator>; // C++17 | |
| 232 | ||
| 233 | template<class InputIterator, class Allocator> | |
| 234 | unordered_map(InputIterator, InputIterator, typename see below::size_type, Allocator) | |
| 235 | -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, | |
| 236 | hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 237 | ||
| 238 | template<class InputIterator, class Allocator> | |
| 239 | unordered_map(InputIterator, InputIterator, Allocator) | |
| 240 | -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, | |
| 241 | hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 242 | ||
| 243 | template<class InputIterator, class Hash, class Allocator> | |
| 244 | unordered_map(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) | |
| 245 | -> unordered_map<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash, | |
| 246 | equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 247 | ||
| 248 | template<class Key, class T, typename Allocator> | |
| 249 | unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator) | |
| 250 | -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 | |
| 251 | ||
| 252 | template<class Key, class T, typename Allocator> | |
| 253 | unordered_map(initializer_list<pair<const Key, T>>, Allocator) | |
| 254 | -> unordered_map<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 | |
| 255 | ||
| 256 | template<class Key, class T, class Hash, class Allocator> | |
| 257 | unordered_map(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, Allocator) | |
| 258 | -> unordered_map<Key, T, Hash, equal_to<Key>, Allocator>; // C++17 | |
| 259 | ||
| 219 | 260 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 220 | 261 | void swap(unordered_map<Key, T, Hash, Pred, Alloc>& x, |
| 221 | 262 | unordered_map<Key, T, Hash, Pred, Alloc>& y) |
| ... | ... | @@ -404,6 +445,48 @@ public: |
| 404 | 445 | void reserve(size_type n); |
| 405 | 446 | }; |
| 406 | 447 | |
| 448 | template<class InputIterator, | |
| 449 | class Hash = hash<iter_key_t<InputIterator>>, class Pred = equal_to<iter_key_t<InputIterator>>, | |
| 450 | class Allocator = allocator<iter_to_alloc_t<InputIterator>>> | |
| 451 | unordered_multimap(InputIterator, InputIterator, typename see below::size_type = see below, | |
| 452 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 453 | -> unordered_multimap<iter_key_t<InputIterator>, iter_value_t<InputIterator>, Hash, Pred, | |
| 454 | Allocator>; // C++17 | |
| 455 | ||
| 456 | template<class Key, class T, class Hash = hash<Key>, | |
| 457 | class Pred = equal_to<Key>, class Allocator = allocator<pair<const Key, T>>> | |
| 458 | unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type = see below, | |
| 459 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 460 | -> unordered_multimap<Key, T, Hash, Pred, Allocator>; // C++17 | |
| 461 | ||
| 462 | template<class InputIterator, class Allocator> | |
| 463 | unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Allocator) | |
| 464 | -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, | |
| 465 | hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 466 | ||
| 467 | template<class InputIterator, class Allocator> | |
| 468 | unordered_multimap(InputIterator, InputIterator, Allocator) | |
| 469 | -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, | |
| 470 | hash<iter_key_t<InputIterator>>, equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 471 | ||
| 472 | template<class InputIterator, class Hash, class Allocator> | |
| 473 | unordered_multimap(InputIterator, InputIterator, typename see below::size_type, Hash, Allocator) | |
| 474 | -> unordered_multimap<iter_key_t<InputIterator>, iter_val_t<InputIterator>, Hash, | |
| 475 | equal_to<iter_key_t<InputIterator>>, Allocator>; // C++17 | |
| 476 | ||
| 477 | template<class Key, class T, typename Allocator> | |
| 478 | unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Allocator) | |
| 479 | -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 | |
| 480 | ||
| 481 | template<class Key, class T, typename Allocator> | |
| 482 | unordered_multimap(initializer_list<pair<const Key, T>>, Allocator) | |
| 483 | -> unordered_multimap<Key, T, hash<Key>, equal_to<Key>, Allocator>; // C++17 | |
| 484 | ||
| 485 | template<class Key, class T, class Hash, class Allocator> | |
| 486 | unordered_multimap(initializer_list<pair<const Key, T>>, typename see below::size_type, Hash, | |
| 487 | Allocator) | |
| 488 | -> unordered_multimap<Key, T, Hash, equal_to<Key>, Allocator>; // C++17 | |
| 489 | ||
| 407 | 490 | template <class Key, class T, class Hash, class Pred, class Alloc> |
| 408 | 491 | void swap(unordered_multimap<Key, T, Hash, Pred, Alloc>& x, |
| 409 | 492 | unordered_multimap<Key, T, Hash, Pred, Alloc>& y) |
| ... | ... | @@ -435,6 +518,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 435 | 518 | #include <__debug> |
| 436 | 519 | #include <__functional/is_transparent.h> |
| 437 | 520 | #include <__hash_table> |
| 521 | #include <__iterator/iterator_traits.h> | |
| 522 | #include <__memory/addressof.h> | |
| 438 | 523 | #include <__node_handle> |
| 439 | 524 | #include <__utility/forward.h> |
| 440 | 525 | #include <compare> |
| ... | ... | @@ -473,12 +558,13 @@ public: |
| 473 | 558 | size_t operator()(const _Key& __x) const |
| 474 | 559 | {return static_cast<const _Hash&>(*this)(__x);} |
| 475 | 560 | #if _LIBCPP_STD_VER > 17 |
| 476 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 561 | template <typename _K2> | |
| 477 | 562 | _LIBCPP_INLINE_VISIBILITY |
| 478 | 563 | size_t operator()(const _K2& __x) const |
| 479 | 564 | {return static_cast<const _Hash&>(*this)(__x);} |
| 480 | 565 | #endif |
| 481 | void swap(__unordered_map_hasher&__y) | |
| 566 | _LIBCPP_INLINE_VISIBILITY | |
| 567 | void swap(__unordered_map_hasher& __y) | |
| 482 | 568 | _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) |
| 483 | 569 | { |
| 484 | 570 | using _VSTD::swap; |
| ... | ... | @@ -508,12 +594,13 @@ public: |
| 508 | 594 | size_t operator()(const _Key& __x) const |
| 509 | 595 | {return __hash_(__x);} |
| 510 | 596 | #if _LIBCPP_STD_VER > 17 |
| 511 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 597 | template <typename _K2> | |
| 512 | 598 | _LIBCPP_INLINE_VISIBILITY |
| 513 | 599 | size_t operator()(const _K2& __x) const |
| 514 | 600 | {return __hash_(__x);} |
| 515 | 601 | #endif |
| 516 | void swap(__unordered_map_hasher&__y) | |
| 602 | _LIBCPP_INLINE_VISIBILITY | |
| 603 | void swap(__unordered_map_hasher& __y) | |
| 517 | 604 | _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) |
| 518 | 605 | { |
| 519 | 606 | using _VSTD::swap; |
| ... | ... | @@ -557,24 +644,25 @@ public: |
| 557 | 644 | bool operator()(const _Key& __x, const _Cp& __y) const |
| 558 | 645 | {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);} |
| 559 | 646 | #if _LIBCPP_STD_VER > 17 |
| 560 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 647 | template <typename _K2> | |
| 561 | 648 | _LIBCPP_INLINE_VISIBILITY |
| 562 | 649 | bool operator()(const _Cp& __x, const _K2& __y) const |
| 563 | 650 | {return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);} |
| 564 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 651 | template <typename _K2> | |
| 565 | 652 | _LIBCPP_INLINE_VISIBILITY |
| 566 | 653 | bool operator()(const _K2& __x, const _Cp& __y) const |
| 567 | 654 | {return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);} |
| 568 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 655 | template <typename _K2> | |
| 569 | 656 | _LIBCPP_INLINE_VISIBILITY |
| 570 | 657 | bool operator()(const _Key& __x, const _K2& __y) const |
| 571 | 658 | {return static_cast<const _Pred&>(*this)(__x, __y);} |
| 572 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 659 | template <typename _K2> | |
| 573 | 660 | _LIBCPP_INLINE_VISIBILITY |
| 574 | 661 | bool operator()(const _K2& __x, const _Key& __y) const |
| 575 | 662 | {return static_cast<const _Pred&>(*this)(__x, __y);} |
| 576 | 663 | #endif |
| 577 | void swap(__unordered_map_equal&__y) | |
| 664 | _LIBCPP_INLINE_VISIBILITY | |
| 665 | void swap(__unordered_map_equal& __y) | |
| 578 | 666 | _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) |
| 579 | 667 | { |
| 580 | 668 | using _VSTD::swap; |
| ... | ... | @@ -607,24 +695,25 @@ public: |
| 607 | 695 | bool operator()(const _Key& __x, const _Cp& __y) const |
| 608 | 696 | {return __pred_(__x, __y.__get_value().first);} |
| 609 | 697 | #if _LIBCPP_STD_VER > 17 |
| 610 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 698 | template <typename _K2> | |
| 611 | 699 | _LIBCPP_INLINE_VISIBILITY |
| 612 | 700 | bool operator()(const _Cp& __x, const _K2& __y) const |
| 613 | 701 | {return __pred_(__x.__get_value().first, __y);} |
| 614 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 702 | template <typename _K2> | |
| 615 | 703 | _LIBCPP_INLINE_VISIBILITY |
| 616 | 704 | bool operator()(const _K2& __x, const _Cp& __y) const |
| 617 | 705 | {return __pred_(__x, __y.__get_value().first);} |
| 618 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 706 | template <typename _K2> | |
| 619 | 707 | _LIBCPP_INLINE_VISIBILITY |
| 620 | 708 | bool operator()(const _Key& __x, const _K2& __y) const |
| 621 | 709 | {return __pred_(__x, __y);} |
| 622 | template <typename _K2, typename = _EnableIf<__is_transparent<_Hash, _K2>::value && __is_transparent<_Pred, _K2>::value>> | |
| 710 | template <typename _K2> | |
| 623 | 711 | _LIBCPP_INLINE_VISIBILITY |
| 624 | 712 | bool operator()(const _K2& __x, const _Key& __y) const |
| 625 | 713 | {return __pred_(__x, __y);} |
| 626 | 714 | #endif |
| 627 | void swap(__unordered_map_equal&__y) | |
| 715 | _LIBCPP_INLINE_VISIBILITY | |
| 716 | void swap(__unordered_map_equal& __y) | |
| 628 | 717 | _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) |
| 629 | 718 | { |
| 630 | 719 | using _VSTD::swap; |
| ... | ... | @@ -980,11 +1069,9 @@ public: |
| 980 | 1069 | _LIBCPP_INLINE_VISIBILITY |
| 981 | 1070 | unordered_map() |
| 982 | 1071 | _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) |
| 983 | { | |
| 984 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 985 | __get_db()->__insert_c(this); | |
| 986 | #endif | |
| 987 | } | |
| 1072 | { | |
| 1073 | _VSTD::__debug_db_insert_c(this); | |
| 1074 | } | |
| 988 | 1075 | explicit unordered_map(size_type __n, const hasher& __hf = hasher(), |
| 989 | 1076 | const key_equal& __eql = key_equal()); |
| 990 | 1077 | unordered_map(size_type __n, const hasher& __hf, |
| ... | ... | @@ -1052,7 +1139,7 @@ public: |
| 1052 | 1139 | #ifndef _LIBCPP_CXX03_LANG |
| 1053 | 1140 | __table_ = __u.__table_; |
| 1054 | 1141 | #else |
| 1055 | if (this != &__u) { | |
| 1142 | if (this != _VSTD::addressof(__u)) { | |
| 1056 | 1143 | __table_.clear(); |
| 1057 | 1144 | __table_.hash_function() = __u.__table_.hash_function(); |
| 1058 | 1145 | __table_.key_eq() = __u.__table_.key_eq(); |
| ... | ... | @@ -1100,13 +1187,10 @@ public: |
| 1100 | 1187 | {return __table_.__insert_unique(__x);} |
| 1101 | 1188 | |
| 1102 | 1189 | iterator insert(const_iterator __p, const value_type& __x) { |
| 1103 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1104 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1105 | "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" | |
| 1106 | " referring to this unordered_map"); | |
| 1107 | #else | |
| 1190 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1191 | "unordered_map::insert(const_iterator, const value_type&) called with an iterator not " | |
| 1192 | "referring to this unordered_map"); | |
| 1108 | 1193 | ((void)__p); |
| 1109 | #endif | |
| 1110 | 1194 | return insert(__x).first; |
| 1111 | 1195 | } |
| 1112 | 1196 | |
| ... | ... | @@ -1124,13 +1208,10 @@ public: |
| 1124 | 1208 | {return __table_.__insert_unique(_VSTD::move(__x));} |
| 1125 | 1209 | |
| 1126 | 1210 | iterator insert(const_iterator __p, value_type&& __x) { |
| 1127 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1128 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1129 | "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" | |
| 1130 | " referring to this unordered_map"); | |
| 1131 | #else | |
| 1211 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1212 | "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" | |
| 1213 | " referring to this unordered_map"); | |
| 1132 | 1214 | ((void)__p); |
| 1133 | #endif | |
| 1134 | 1215 | return __table_.__insert_unique(_VSTD::move(__x)).first; |
| 1135 | 1216 | } |
| 1136 | 1217 | |
| ... | ... | @@ -1145,13 +1226,10 @@ public: |
| 1145 | 1226 | _LIBCPP_INLINE_VISIBILITY |
| 1146 | 1227 | iterator insert(const_iterator __p, _Pp&& __x) |
| 1147 | 1228 | { |
| 1148 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1149 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1150 | "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" | |
| 1151 | " referring to this unordered_map"); | |
| 1152 | #else | |
| 1229 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1230 | "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" | |
| 1231 | " referring to this unordered_map"); | |
| 1153 | 1232 | ((void)__p); |
| 1154 | #endif | |
| 1155 | 1233 | return insert(_VSTD::forward<_Pp>(__x)).first; |
| 1156 | 1234 | } |
| 1157 | 1235 | |
| ... | ... | @@ -1164,13 +1242,10 @@ public: |
| 1164 | 1242 | template <class... _Args> |
| 1165 | 1243 | _LIBCPP_INLINE_VISIBILITY |
| 1166 | 1244 | iterator emplace_hint(const_iterator __p, _Args&&... __args) { |
| 1167 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1168 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 1169 | "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 1170 | " referring to this unordered_map"); | |
| 1171 | #else | |
| 1245 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 1246 | "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 1247 | " referring to this unordered_map"); | |
| 1172 | 1248 | ((void)__p); |
| 1173 | #endif | |
| 1174 | 1249 | return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; |
| 1175 | 1250 | } |
| 1176 | 1251 | |
| ... | ... | @@ -1199,13 +1274,10 @@ public: |
| 1199 | 1274 | _LIBCPP_INLINE_VISIBILITY |
| 1200 | 1275 | iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) |
| 1201 | 1276 | { |
| 1202 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1203 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this, | |
| 1204 | "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" | |
| 1205 | " referring to this unordered_map"); | |
| 1206 | #else | |
| 1277 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this, | |
| 1278 | "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" | |
| 1279 | " referring to this unordered_map"); | |
| 1207 | 1280 | ((void)__h); |
| 1208 | #endif | |
| 1209 | 1281 | return try_emplace(__k, _VSTD::forward<_Args>(__args)...).first; |
| 1210 | 1282 | } |
| 1211 | 1283 | |
| ... | ... | @@ -1213,13 +1285,10 @@ public: |
| 1213 | 1285 | _LIBCPP_INLINE_VISIBILITY |
| 1214 | 1286 | iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) |
| 1215 | 1287 | { |
| 1216 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1217 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__h) == this, | |
| 1218 | "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" | |
| 1219 | " referring to this unordered_map"); | |
| 1220 | #else | |
| 1288 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__h)) == this, | |
| 1289 | "unordered_map::try_emplace(const_iterator, key, args...) called with an iterator not" | |
| 1290 | " referring to this unordered_map"); | |
| 1221 | 1291 | ((void)__h); |
| 1222 | #endif | |
| 1223 | 1292 | return try_emplace(_VSTD::move(__k), _VSTD::forward<_Args>(__args)...).first; |
| 1224 | 1293 | } |
| 1225 | 1294 | |
| ... | ... | @@ -1355,51 +1424,48 @@ public: |
| 1355 | 1424 | iterator find(const key_type& __k) {return __table_.find(__k);} |
| 1356 | 1425 | _LIBCPP_INLINE_VISIBILITY |
| 1357 | 1426 | const_iterator find(const key_type& __k) const {return __table_.find(__k);} |
| 1358 | ||
| 1359 | #if _LIBCPP_STD_VER > 17 | |
| 1360 | template <typename _K2> | |
| 1361 | _LIBCPP_INLINE_VISIBILITY | |
| 1362 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator> | |
| 1363 | find(const _K2& __k) {return __table_.find(__k);} | |
| 1364 | template <typename _K2> | |
| 1365 | _LIBCPP_INLINE_VISIBILITY | |
| 1366 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator> | |
| 1367 | find(const _K2& __k) const {return __table_.find(__k);} | |
| 1368 | #endif // _LIBCPP_STD_VER > 17 | |
| 1427 | #if _LIBCPP_STD_VER > 17 | |
| 1428 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1429 | _LIBCPP_INLINE_VISIBILITY | |
| 1430 | iterator find(const _K2& __k) {return __table_.find(__k);} | |
| 1431 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1432 | _LIBCPP_INLINE_VISIBILITY | |
| 1433 | const_iterator find(const _K2& __k) const {return __table_.find(__k);} | |
| 1434 | #endif // _LIBCPP_STD_VER > 17 | |
| 1369 | 1435 | |
| 1370 | 1436 | _LIBCPP_INLINE_VISIBILITY |
| 1371 | 1437 | size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} |
| 1372 | #if _LIBCPP_STD_VER > 17 | |
| 1373 | template <typename _K2> | |
| 1374 | _LIBCPP_INLINE_VISIBILITY | |
| 1375 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type> | |
| 1376 | count(const _K2& __k) const {return __table_.__count_unique(__k);} | |
| 1377 | #endif // _LIBCPP_STD_VER > 17 | |
| 1378 | #if _LIBCPP_STD_VER > 17 | |
| 1379 | _LIBCPP_INLINE_VISIBILITY | |
| 1380 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 1438 | #if _LIBCPP_STD_VER > 17 | |
| 1439 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1440 | _LIBCPP_INLINE_VISIBILITY | |
| 1441 | size_type count(const _K2& __k) const {return __table_.__count_unique(__k);} | |
| 1442 | #endif // _LIBCPP_STD_VER > 17 | |
| 1443 | ||
| 1444 | #if _LIBCPP_STD_VER > 17 | |
| 1445 | _LIBCPP_INLINE_VISIBILITY | |
| 1446 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 1447 | ||
| 1448 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1449 | _LIBCPP_INLINE_VISIBILITY | |
| 1450 | bool contains(const _K2& __k) const {return find(__k) != end();} | |
| 1451 | #endif // _LIBCPP_STD_VER > 17 | |
| 1381 | 1452 | |
| 1382 | template <typename _K2> | |
| 1383 | _LIBCPP_INLINE_VISIBILITY | |
| 1384 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool> | |
| 1385 | contains(const _K2& __k) const {return find(__k) != end();} | |
| 1386 | #endif // _LIBCPP_STD_VER > 17 | |
| 1387 | 1453 | _LIBCPP_INLINE_VISIBILITY |
| 1388 | 1454 | pair<iterator, iterator> equal_range(const key_type& __k) |
| 1389 | 1455 | {return __table_.__equal_range_unique(__k);} |
| 1390 | 1456 | _LIBCPP_INLINE_VISIBILITY |
| 1391 | 1457 | pair<const_iterator, const_iterator> equal_range(const key_type& __k) const |
| 1392 | 1458 | {return __table_.__equal_range_unique(__k);} |
| 1393 | #if _LIBCPP_STD_VER > 17 | |
| 1394 | template <typename _K2> | |
| 1395 | _LIBCPP_INLINE_VISIBILITY | |
| 1396 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>> | |
| 1397 | equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);} | |
| 1398 | template <typename _K2> | |
| 1399 | _LIBCPP_INLINE_VISIBILITY | |
| 1400 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>> | |
| 1401 | equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);} | |
| 1402 | #endif // _LIBCPP_STD_VER > 17 | |
| 1459 | #if _LIBCPP_STD_VER > 17 | |
| 1460 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1461 | _LIBCPP_INLINE_VISIBILITY | |
| 1462 | pair<iterator, iterator> equal_range(const _K2& __k) | |
| 1463 | {return __table_.__equal_range_unique(__k);} | |
| 1464 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1465 | _LIBCPP_INLINE_VISIBILITY | |
| 1466 | pair<const_iterator, const_iterator> equal_range(const _K2& __k) const | |
| 1467 | {return __table_.__equal_range_unique(__k);} | |
| 1468 | #endif // _LIBCPP_STD_VER > 17 | |
| 1403 | 1469 | |
| 1404 | 1470 | mapped_type& operator[](const key_type& __k); |
| 1405 | 1471 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -1447,13 +1513,13 @@ public: |
| 1447 | 1513 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1448 | 1514 | |
| 1449 | 1515 | bool __dereferenceable(const const_iterator* __i) const |
| 1450 | {return __table_.__dereferenceable(&__i->__i_);} | |
| 1516 | {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));} | |
| 1451 | 1517 | bool __decrementable(const const_iterator* __i) const |
| 1452 | {return __table_.__decrementable(&__i->__i_);} | |
| 1518 | {return __table_.__decrementable(_VSTD::addressof(__i->__i_));} | |
| 1453 | 1519 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const |
| 1454 | {return __table_.__addable(&__i->__i_, __n);} | |
| 1520 | {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);} | |
| 1455 | 1521 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 1456 | {return __table_.__addable(&__i->__i_, __n);} | |
| 1522 | {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);} | |
| 1457 | 1523 | |
| 1458 | 1524 | #endif // _LIBCPP_DEBUG_LEVEL == 2 |
| 1459 | 1525 | |
| ... | ... | @@ -1464,15 +1530,16 @@ private: |
| 1464 | 1530 | #endif |
| 1465 | 1531 | }; |
| 1466 | 1532 | |
| 1467 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1533 | #if _LIBCPP_STD_VER >= 17 | |
| 1468 | 1534 | template<class _InputIterator, |
| 1469 | 1535 | class _Hash = hash<__iter_key_type<_InputIterator>>, |
| 1470 | 1536 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, |
| 1471 | 1537 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 1472 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1473 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1474 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 1475 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1538 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1539 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1540 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1541 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 1542 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1476 | 1543 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, |
| 1477 | 1544 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 1478 | 1545 | -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| ... | ... | @@ -1480,52 +1547,55 @@ unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocat |
| 1480 | 1547 | template<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>, |
| 1481 | 1548 | class _Pred = equal_to<remove_const_t<_Key>>, |
| 1482 | 1549 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 1483 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1484 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1485 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 1486 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1550 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1551 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1552 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 1553 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1487 | 1554 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0, |
| 1488 | 1555 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 1489 | 1556 | -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; |
| 1490 | 1557 | |
| 1491 | 1558 | template<class _InputIterator, class _Allocator, |
| 1492 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1559 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1560 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1493 | 1561 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1494 | 1562 | -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 1495 | 1563 | hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; |
| 1496 | 1564 | |
| 1497 | 1565 | template<class _InputIterator, class _Allocator, |
| 1498 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1566 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1567 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1499 | 1568 | unordered_map(_InputIterator, _InputIterator, _Allocator) |
| 1500 | 1569 | -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 1501 | 1570 | hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; |
| 1502 | 1571 | |
| 1503 | 1572 | template<class _InputIterator, class _Hash, class _Allocator, |
| 1504 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1505 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1506 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1573 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1574 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1575 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1576 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1507 | 1577 | unordered_map(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1508 | 1578 | -> unordered_map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 1509 | 1579 | _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; |
| 1510 | 1580 | |
| 1511 | 1581 | template<class _Key, class _Tp, class _Allocator, |
| 1512 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1582 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1513 | 1583 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1514 | 1584 | -> unordered_map<remove_const_t<_Key>, _Tp, |
| 1515 | 1585 | hash<remove_const_t<_Key>>, |
| 1516 | 1586 | equal_to<remove_const_t<_Key>>, _Allocator>; |
| 1517 | 1587 | |
| 1518 | 1588 | template<class _Key, class _Tp, class _Allocator, |
| 1519 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1589 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1520 | 1590 | unordered_map(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 1521 | 1591 | -> unordered_map<remove_const_t<_Key>, _Tp, |
| 1522 | 1592 | hash<remove_const_t<_Key>>, |
| 1523 | 1593 | equal_to<remove_const_t<_Key>>, _Allocator>; |
| 1524 | 1594 | |
| 1525 | 1595 | template<class _Key, class _Tp, class _Hash, class _Allocator, |
| 1526 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1527 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1528 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1596 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1597 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1598 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1529 | 1599 | unordered_map(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1530 | 1600 | -> unordered_map<remove_const_t<_Key>, _Tp, _Hash, |
| 1531 | 1601 | equal_to<remove_const_t<_Key>>, _Allocator>; |
| ... | ... | @@ -1536,9 +1606,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1536 | 1606 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 1537 | 1607 | : __table_(__hf, __eql) |
| 1538 | 1608 | { |
| 1539 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1540 | __get_db()->__insert_c(this); | |
| 1541 | #endif | |
| 1609 | _VSTD::__debug_db_insert_c(this); | |
| 1542 | 1610 | __table_.rehash(__n); |
| 1543 | 1611 | } |
| 1544 | 1612 | |
| ... | ... | @@ -1548,9 +1616,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1548 | 1616 | const allocator_type& __a) |
| 1549 | 1617 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 1550 | 1618 | { |
| 1551 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1552 | __get_db()->__insert_c(this); | |
| 1553 | #endif | |
| 1619 | _VSTD::__debug_db_insert_c(this); | |
| 1554 | 1620 | __table_.rehash(__n); |
| 1555 | 1621 | } |
| 1556 | 1622 | |
| ... | ... | @@ -1560,9 +1626,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1560 | 1626 | const allocator_type& __a) |
| 1561 | 1627 | : __table_(typename __table::allocator_type(__a)) |
| 1562 | 1628 | { |
| 1563 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1564 | __get_db()->__insert_c(this); | |
| 1565 | #endif | |
| 1629 | _VSTD::__debug_db_insert_c(this); | |
| 1566 | 1630 | } |
| 1567 | 1631 | |
| 1568 | 1632 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1570,9 +1634,7 @@ template <class _InputIterator> |
| 1570 | 1634 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1571 | 1635 | _InputIterator __first, _InputIterator __last) |
| 1572 | 1636 | { |
| 1573 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1574 | __get_db()->__insert_c(this); | |
| 1575 | #endif | |
| 1637 | _VSTD::__debug_db_insert_c(this); | |
| 1576 | 1638 | insert(__first, __last); |
| 1577 | 1639 | } |
| 1578 | 1640 | |
| ... | ... | @@ -1583,9 +1645,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1583 | 1645 | const hasher& __hf, const key_equal& __eql) |
| 1584 | 1646 | : __table_(__hf, __eql) |
| 1585 | 1647 | { |
| 1586 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1587 | __get_db()->__insert_c(this); | |
| 1588 | #endif | |
| 1648 | _VSTD::__debug_db_insert_c(this); | |
| 1589 | 1649 | __table_.rehash(__n); |
| 1590 | 1650 | insert(__first, __last); |
| 1591 | 1651 | } |
| ... | ... | @@ -1597,9 +1657,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1597 | 1657 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 1598 | 1658 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 1599 | 1659 | { |
| 1600 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1601 | __get_db()->__insert_c(this); | |
| 1602 | #endif | |
| 1660 | _VSTD::__debug_db_insert_c(this); | |
| 1603 | 1661 | __table_.rehash(__n); |
| 1604 | 1662 | insert(__first, __last); |
| 1605 | 1663 | } |
| ... | ... | @@ -1609,9 +1667,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1609 | 1667 | const unordered_map& __u) |
| 1610 | 1668 | : __table_(__u.__table_) |
| 1611 | 1669 | { |
| 1612 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1613 | __get_db()->__insert_c(this); | |
| 1614 | #endif | |
| 1670 | _VSTD::__debug_db_insert_c(this); | |
| 1615 | 1671 | __table_.rehash(__u.bucket_count()); |
| 1616 | 1672 | insert(__u.begin(), __u.end()); |
| 1617 | 1673 | } |
| ... | ... | @@ -1621,9 +1677,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1621 | 1677 | const unordered_map& __u, const allocator_type& __a) |
| 1622 | 1678 | : __table_(__u.__table_, typename __table::allocator_type(__a)) |
| 1623 | 1679 | { |
| 1624 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1625 | __get_db()->__insert_c(this); | |
| 1626 | #endif | |
| 1680 | _VSTD::__debug_db_insert_c(this); | |
| 1627 | 1681 | __table_.rehash(__u.bucket_count()); |
| 1628 | 1682 | insert(__u.begin(), __u.end()); |
| 1629 | 1683 | } |
| ... | ... | @@ -1637,9 +1691,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1637 | 1691 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) |
| 1638 | 1692 | : __table_(_VSTD::move(__u.__table_)) |
| 1639 | 1693 | { |
| 1694 | _VSTD::__debug_db_insert_c(this); | |
| 1640 | 1695 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1641 | __get_db()->__insert_c(this); | |
| 1642 | __get_db()->swap(this, &__u); | |
| 1696 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1643 | 1697 | #endif |
| 1644 | 1698 | } |
| 1645 | 1699 | |
| ... | ... | @@ -1648,9 +1702,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1648 | 1702 | unordered_map&& __u, const allocator_type& __a) |
| 1649 | 1703 | : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a)) |
| 1650 | 1704 | { |
| 1651 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1652 | __get_db()->__insert_c(this); | |
| 1653 | #endif | |
| 1705 | _VSTD::__debug_db_insert_c(this); | |
| 1654 | 1706 | if (__a != __u.get_allocator()) |
| 1655 | 1707 | { |
| 1656 | 1708 | iterator __i = __u.begin(); |
| ... | ... | @@ -1661,7 +1713,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1661 | 1713 | } |
| 1662 | 1714 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1663 | 1715 | else |
| 1664 | __get_db()->swap(this, &__u); | |
| 1716 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1665 | 1717 | #endif |
| 1666 | 1718 | } |
| 1667 | 1719 | |
| ... | ... | @@ -1669,9 +1721,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 1669 | 1721 | unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1670 | 1722 | initializer_list<value_type> __il) |
| 1671 | 1723 | { |
| 1672 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1673 | __get_db()->__insert_c(this); | |
| 1674 | #endif | |
| 1724 | _VSTD::__debug_db_insert_c(this); | |
| 1675 | 1725 | insert(__il.begin(), __il.end()); |
| 1676 | 1726 | } |
| 1677 | 1727 | |
| ... | ... | @@ -1681,9 +1731,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1681 | 1731 | const key_equal& __eql) |
| 1682 | 1732 | : __table_(__hf, __eql) |
| 1683 | 1733 | { |
| 1684 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1685 | __get_db()->__insert_c(this); | |
| 1686 | #endif | |
| 1734 | _VSTD::__debug_db_insert_c(this); | |
| 1687 | 1735 | __table_.rehash(__n); |
| 1688 | 1736 | insert(__il.begin(), __il.end()); |
| 1689 | 1737 | } |
| ... | ... | @@ -1694,9 +1742,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1694 | 1742 | const key_equal& __eql, const allocator_type& __a) |
| 1695 | 1743 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 1696 | 1744 | { |
| 1697 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1698 | __get_db()->__insert_c(this); | |
| 1699 | #endif | |
| 1745 | _VSTD::__debug_db_insert_c(this); | |
| 1700 | 1746 | __table_.rehash(__n); |
| 1701 | 1747 | insert(__il.begin(), __il.end()); |
| 1702 | 1748 | } |
| ... | ... | @@ -1914,11 +1960,9 @@ public: |
| 1914 | 1960 | _LIBCPP_INLINE_VISIBILITY |
| 1915 | 1961 | unordered_multimap() |
| 1916 | 1962 | _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) |
| 1917 | { | |
| 1918 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1919 | __get_db()->__insert_c(this); | |
| 1920 | #endif | |
| 1921 | } | |
| 1963 | { | |
| 1964 | _VSTD::__debug_db_insert_c(this); | |
| 1965 | } | |
| 1922 | 1966 | explicit unordered_multimap(size_type __n, const hasher& __hf = hasher(), |
| 1923 | 1967 | const key_equal& __eql = key_equal()); |
| 1924 | 1968 | unordered_multimap(size_type __n, const hasher& __hf, |
| ... | ... | @@ -1987,7 +2031,7 @@ public: |
| 1987 | 2031 | #ifndef _LIBCPP_CXX03_LANG |
| 1988 | 2032 | __table_ = __u.__table_; |
| 1989 | 2033 | #else |
| 1990 | if (this != &__u) { | |
| 2034 | if (this != _VSTD::addressof(__u)) { | |
| 1991 | 2035 | __table_.clear(); |
| 1992 | 2036 | __table_.hash_function() = __u.__table_.hash_function(); |
| 1993 | 2037 | __table_.key_eq() = __u.__table_.key_eq(); |
| ... | ... | @@ -2167,49 +2211,48 @@ public: |
| 2167 | 2211 | iterator find(const key_type& __k) {return __table_.find(__k);} |
| 2168 | 2212 | _LIBCPP_INLINE_VISIBILITY |
| 2169 | 2213 | const_iterator find(const key_type& __k) const {return __table_.find(__k);} |
| 2170 | #if _LIBCPP_STD_VER > 17 | |
| 2171 | template <typename _K2> | |
| 2172 | _LIBCPP_INLINE_VISIBILITY | |
| 2173 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator> | |
| 2174 | find(const _K2& __k) {return __table_.find(__k);} | |
| 2175 | template <typename _K2> | |
| 2176 | _LIBCPP_INLINE_VISIBILITY | |
| 2177 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator> | |
| 2178 | find(const _K2& __k) const {return __table_.find(__k);} | |
| 2179 | #endif // _LIBCPP_STD_VER > 17 | |
| 2214 | #if _LIBCPP_STD_VER > 17 | |
| 2215 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 2216 | _LIBCPP_INLINE_VISIBILITY | |
| 2217 | iterator find(const _K2& __k) {return __table_.find(__k);} | |
| 2218 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 2219 | _LIBCPP_INLINE_VISIBILITY | |
| 2220 | const_iterator find(const _K2& __k) const {return __table_.find(__k);} | |
| 2221 | #endif // _LIBCPP_STD_VER > 17 | |
| 2222 | ||
| 2180 | 2223 | _LIBCPP_INLINE_VISIBILITY |
| 2181 | 2224 | size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} |
| 2182 | #if _LIBCPP_STD_VER > 17 | |
| 2183 | template <typename _K2> | |
| 2184 | _LIBCPP_INLINE_VISIBILITY | |
| 2185 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type> | |
| 2186 | count(const _K2& __k) const {return __table_.__count_multi(__k);} | |
| 2187 | #endif // _LIBCPP_STD_VER > 17 | |
| 2188 | #if _LIBCPP_STD_VER > 17 | |
| 2189 | _LIBCPP_INLINE_VISIBILITY | |
| 2190 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 2225 | #if _LIBCPP_STD_VER > 17 | |
| 2226 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 2227 | _LIBCPP_INLINE_VISIBILITY | |
| 2228 | size_type count(const _K2& __k) const {return __table_.__count_multi(__k);} | |
| 2229 | #endif // _LIBCPP_STD_VER > 17 | |
| 2230 | ||
| 2231 | #if _LIBCPP_STD_VER > 17 | |
| 2232 | _LIBCPP_INLINE_VISIBILITY | |
| 2233 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 2234 | ||
| 2235 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 2236 | _LIBCPP_INLINE_VISIBILITY | |
| 2237 | bool contains(const _K2& __k) const {return find(__k) != end();} | |
| 2238 | #endif // _LIBCPP_STD_VER > 17 | |
| 2191 | 2239 | |
| 2192 | template <typename _K2> | |
| 2193 | _LIBCPP_INLINE_VISIBILITY | |
| 2194 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool> | |
| 2195 | contains(const _K2& __k) const {return find(__k) != end();} | |
| 2196 | #endif // _LIBCPP_STD_VER > 17 | |
| 2197 | 2240 | _LIBCPP_INLINE_VISIBILITY |
| 2198 | 2241 | pair<iterator, iterator> equal_range(const key_type& __k) |
| 2199 | 2242 | {return __table_.__equal_range_multi(__k);} |
| 2200 | 2243 | _LIBCPP_INLINE_VISIBILITY |
| 2201 | 2244 | pair<const_iterator, const_iterator> equal_range(const key_type& __k) const |
| 2202 | 2245 | {return __table_.__equal_range_multi(__k);} |
| 2203 | #if _LIBCPP_STD_VER > 17 | |
| 2204 | template <typename _K2> | |
| 2205 | _LIBCPP_INLINE_VISIBILITY | |
| 2206 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>> | |
| 2207 | equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);} | |
| 2208 | template <typename _K2> | |
| 2209 | _LIBCPP_INLINE_VISIBILITY | |
| 2210 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>> | |
| 2211 | equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);} | |
| 2212 | #endif // _LIBCPP_STD_VER > 17 | |
| 2246 | #if _LIBCPP_STD_VER > 17 | |
| 2247 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 2248 | _LIBCPP_INLINE_VISIBILITY | |
| 2249 | pair<iterator, iterator> equal_range(const _K2& __k) | |
| 2250 | {return __table_.__equal_range_multi(__k);} | |
| 2251 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 2252 | _LIBCPP_INLINE_VISIBILITY | |
| 2253 | pair<const_iterator, const_iterator> equal_range(const _K2& __k) const | |
| 2254 | {return __table_.__equal_range_multi(__k);} | |
| 2255 | #endif // _LIBCPP_STD_VER > 17 | |
| 2213 | 2256 | |
| 2214 | 2257 | _LIBCPP_INLINE_VISIBILITY |
| 2215 | 2258 | size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} |
| ... | ... | @@ -2250,28 +2293,29 @@ public: |
| 2250 | 2293 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2251 | 2294 | |
| 2252 | 2295 | bool __dereferenceable(const const_iterator* __i) const |
| 2253 | {return __table_.__dereferenceable(&__i->__i_);} | |
| 2296 | {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));} | |
| 2254 | 2297 | bool __decrementable(const const_iterator* __i) const |
| 2255 | {return __table_.__decrementable(&__i->__i_);} | |
| 2298 | {return __table_.__decrementable(_VSTD::addressof(__i->__i_));} | |
| 2256 | 2299 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const |
| 2257 | {return __table_.__addable(&__i->__i_, __n);} | |
| 2300 | {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);} | |
| 2258 | 2301 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 2259 | {return __table_.__addable(&__i->__i_, __n);} | |
| 2302 | {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);} | |
| 2260 | 2303 | |
| 2261 | 2304 | #endif // _LIBCPP_DEBUG_LEVEL == 2 |
| 2262 | 2305 | |
| 2263 | 2306 | |
| 2264 | 2307 | }; |
| 2265 | 2308 | |
| 2266 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 2309 | #if _LIBCPP_STD_VER >= 17 | |
| 2267 | 2310 | template<class _InputIterator, |
| 2268 | 2311 | class _Hash = hash<__iter_key_type<_InputIterator>>, |
| 2269 | 2312 | class _Pred = equal_to<__iter_key_type<_InputIterator>>, |
| 2270 | 2313 | class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>, |
| 2271 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 2272 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 2273 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 2274 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2314 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 2315 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 2316 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 2317 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 2318 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2275 | 2319 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, |
| 2276 | 2320 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 2277 | 2321 | -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| ... | ... | @@ -2279,52 +2323,55 @@ unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 2279 | 2323 | template<class _Key, class _Tp, class _Hash = hash<remove_const_t<_Key>>, |
| 2280 | 2324 | class _Pred = equal_to<remove_const_t<_Key>>, |
| 2281 | 2325 | class _Allocator = allocator<pair<const _Key, _Tp>>, |
| 2282 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 2283 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 2284 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 2285 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2326 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 2327 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 2328 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 2329 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2286 | 2330 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type = 0, |
| 2287 | 2331 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 2288 | 2332 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>; |
| 2289 | 2333 | |
| 2290 | 2334 | template<class _InputIterator, class _Allocator, |
| 2291 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2335 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 2336 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2292 | 2337 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 2293 | 2338 | -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 2294 | 2339 | hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; |
| 2295 | 2340 | |
| 2296 | 2341 | template<class _InputIterator, class _Allocator, |
| 2297 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2342 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 2343 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2298 | 2344 | unordered_multimap(_InputIterator, _InputIterator, _Allocator) |
| 2299 | 2345 | -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 2300 | 2346 | hash<__iter_key_type<_InputIterator>>, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; |
| 2301 | 2347 | |
| 2302 | 2348 | template<class _InputIterator, class _Hash, class _Allocator, |
| 2303 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 2304 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 2305 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2349 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 2350 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 2351 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 2352 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2306 | 2353 | unordered_multimap(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 2307 | 2354 | -> unordered_multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, |
| 2308 | 2355 | _Hash, equal_to<__iter_key_type<_InputIterator>>, _Allocator>; |
| 2309 | 2356 | |
| 2310 | 2357 | template<class _Key, class _Tp, class _Allocator, |
| 2311 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2358 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2312 | 2359 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 2313 | 2360 | -> unordered_multimap<remove_const_t<_Key>, _Tp, |
| 2314 | 2361 | hash<remove_const_t<_Key>>, |
| 2315 | 2362 | equal_to<remove_const_t<_Key>>, _Allocator>; |
| 2316 | 2363 | |
| 2317 | 2364 | template<class _Key, class _Tp, class _Allocator, |
| 2318 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2365 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2319 | 2366 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, _Allocator) |
| 2320 | 2367 | -> unordered_multimap<remove_const_t<_Key>, _Tp, |
| 2321 | 2368 | hash<remove_const_t<_Key>>, |
| 2322 | 2369 | equal_to<remove_const_t<_Key>>, _Allocator>; |
| 2323 | 2370 | |
| 2324 | 2371 | template<class _Key, class _Tp, class _Hash, class _Allocator, |
| 2325 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 2326 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 2327 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 2372 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 2373 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 2374 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 2328 | 2375 | unordered_multimap(initializer_list<pair<_Key, _Tp>>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 2329 | 2376 | -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, |
| 2330 | 2377 | equal_to<remove_const_t<_Key>>, _Allocator>; |
| ... | ... | @@ -2335,9 +2382,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2335 | 2382 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 2336 | 2383 | : __table_(__hf, __eql) |
| 2337 | 2384 | { |
| 2338 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2339 | __get_db()->__insert_c(this); | |
| 2340 | #endif | |
| 2385 | _VSTD::__debug_db_insert_c(this); | |
| 2341 | 2386 | __table_.rehash(__n); |
| 2342 | 2387 | } |
| 2343 | 2388 | |
| ... | ... | @@ -2347,9 +2392,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2347 | 2392 | const allocator_type& __a) |
| 2348 | 2393 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 2349 | 2394 | { |
| 2350 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2351 | __get_db()->__insert_c(this); | |
| 2352 | #endif | |
| 2395 | _VSTD::__debug_db_insert_c(this); | |
| 2353 | 2396 | __table_.rehash(__n); |
| 2354 | 2397 | } |
| 2355 | 2398 | |
| ... | ... | @@ -2358,9 +2401,7 @@ template <class _InputIterator> |
| 2358 | 2401 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2359 | 2402 | _InputIterator __first, _InputIterator __last) |
| 2360 | 2403 | { |
| 2361 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2362 | __get_db()->__insert_c(this); | |
| 2363 | #endif | |
| 2404 | _VSTD::__debug_db_insert_c(this); | |
| 2364 | 2405 | insert(__first, __last); |
| 2365 | 2406 | } |
| 2366 | 2407 | |
| ... | ... | @@ -2371,9 +2412,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2371 | 2412 | const hasher& __hf, const key_equal& __eql) |
| 2372 | 2413 | : __table_(__hf, __eql) |
| 2373 | 2414 | { |
| 2374 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2375 | __get_db()->__insert_c(this); | |
| 2376 | #endif | |
| 2415 | _VSTD::__debug_db_insert_c(this); | |
| 2377 | 2416 | __table_.rehash(__n); |
| 2378 | 2417 | insert(__first, __last); |
| 2379 | 2418 | } |
| ... | ... | @@ -2385,9 +2424,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2385 | 2424 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 2386 | 2425 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 2387 | 2426 | { |
| 2388 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2389 | __get_db()->__insert_c(this); | |
| 2390 | #endif | |
| 2427 | _VSTD::__debug_db_insert_c(this); | |
| 2391 | 2428 | __table_.rehash(__n); |
| 2392 | 2429 | insert(__first, __last); |
| 2393 | 2430 | } |
| ... | ... | @@ -2398,9 +2435,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2398 | 2435 | const allocator_type& __a) |
| 2399 | 2436 | : __table_(typename __table::allocator_type(__a)) |
| 2400 | 2437 | { |
| 2401 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2402 | __get_db()->__insert_c(this); | |
| 2403 | #endif | |
| 2438 | _VSTD::__debug_db_insert_c(this); | |
| 2404 | 2439 | } |
| 2405 | 2440 | |
| 2406 | 2441 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -2408,9 +2443,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2408 | 2443 | const unordered_multimap& __u) |
| 2409 | 2444 | : __table_(__u.__table_) |
| 2410 | 2445 | { |
| 2411 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2412 | __get_db()->__insert_c(this); | |
| 2413 | #endif | |
| 2446 | _VSTD::__debug_db_insert_c(this); | |
| 2414 | 2447 | __table_.rehash(__u.bucket_count()); |
| 2415 | 2448 | insert(__u.begin(), __u.end()); |
| 2416 | 2449 | } |
| ... | ... | @@ -2420,9 +2453,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2420 | 2453 | const unordered_multimap& __u, const allocator_type& __a) |
| 2421 | 2454 | : __table_(__u.__table_, typename __table::allocator_type(__a)) |
| 2422 | 2455 | { |
| 2423 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2424 | __get_db()->__insert_c(this); | |
| 2425 | #endif | |
| 2456 | _VSTD::__debug_db_insert_c(this); | |
| 2426 | 2457 | __table_.rehash(__u.bucket_count()); |
| 2427 | 2458 | insert(__u.begin(), __u.end()); |
| 2428 | 2459 | } |
| ... | ... | @@ -2436,9 +2467,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2436 | 2467 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) |
| 2437 | 2468 | : __table_(_VSTD::move(__u.__table_)) |
| 2438 | 2469 | { |
| 2470 | _VSTD::__debug_db_insert_c(this); | |
| 2439 | 2471 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2440 | __get_db()->__insert_c(this); | |
| 2441 | __get_db()->swap(this, &__u); | |
| 2472 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 2442 | 2473 | #endif |
| 2443 | 2474 | } |
| 2444 | 2475 | |
| ... | ... | @@ -2447,9 +2478,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2447 | 2478 | unordered_multimap&& __u, const allocator_type& __a) |
| 2448 | 2479 | : __table_(_VSTD::move(__u.__table_), typename __table::allocator_type(__a)) |
| 2449 | 2480 | { |
| 2450 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2451 | __get_db()->__insert_c(this); | |
| 2452 | #endif | |
| 2481 | _VSTD::__debug_db_insert_c(this); | |
| 2453 | 2482 | if (__a != __u.get_allocator()) |
| 2454 | 2483 | { |
| 2455 | 2484 | iterator __i = __u.begin(); |
| ... | ... | @@ -2461,7 +2490,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2461 | 2490 | } |
| 2462 | 2491 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2463 | 2492 | else |
| 2464 | __get_db()->swap(this, &__u); | |
| 2493 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 2465 | 2494 | #endif |
| 2466 | 2495 | } |
| 2467 | 2496 | |
| ... | ... | @@ -2469,9 +2498,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| 2469 | 2498 | unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2470 | 2499 | initializer_list<value_type> __il) |
| 2471 | 2500 | { |
| 2472 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2473 | __get_db()->__insert_c(this); | |
| 2474 | #endif | |
| 2501 | _VSTD::__debug_db_insert_c(this); | |
| 2475 | 2502 | insert(__il.begin(), __il.end()); |
| 2476 | 2503 | } |
| 2477 | 2504 | |
| ... | ... | @@ -2481,9 +2508,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2481 | 2508 | const key_equal& __eql) |
| 2482 | 2509 | : __table_(__hf, __eql) |
| 2483 | 2510 | { |
| 2484 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2485 | __get_db()->__insert_c(this); | |
| 2486 | #endif | |
| 2511 | _VSTD::__debug_db_insert_c(this); | |
| 2487 | 2512 | __table_.rehash(__n); |
| 2488 | 2513 | insert(__il.begin(), __il.end()); |
| 2489 | 2514 | } |
| ... | ... | @@ -2494,9 +2519,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2494 | 2519 | const key_equal& __eql, const allocator_type& __a) |
| 2495 | 2520 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 2496 | 2521 | { |
| 2497 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2498 | __get_db()->__insert_c(this); | |
| 2499 | #endif | |
| 2522 | _VSTD::__debug_db_insert_c(this); | |
| 2500 | 2523 | __table_.rehash(__n); |
| 2501 | 2524 | insert(__il.begin(), __il.end()); |
| 2502 | 2525 | } |
lib/libcxx/include/unordered_set+220-194| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- unordered_set -----------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -182,6 +182,43 @@ public: |
| 182 | 182 | void reserve(size_type n); |
| 183 | 183 | }; |
| 184 | 184 | |
| 185 | template<class InputIterator, | |
| 186 | class Hash = hash<typename iterator_traits<InputIterator>::value_type>, | |
| 187 | class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>, | |
| 188 | class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> | |
| 189 | unordered_set(InputIterator, InputIterator, typename see below::size_type = see below, | |
| 190 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 191 | -> unordered_set<typename iterator_traits<InputIterator>::value_type, | |
| 192 | Hash, Pred, Allocator>; // C++17 | |
| 193 | ||
| 194 | template<class T, class Hash = hash<T>, | |
| 195 | class Pred = equal_to<T>, class Allocator = allocator<T>> | |
| 196 | unordered_set(initializer_list<T>, typename see below::size_type = see below, | |
| 197 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 198 | -> unordered_set<T, Hash, Pred, Allocator>; // C++17 | |
| 199 | ||
| 200 | template<class InputIterator, class Allocator> | |
| 201 | unordered_set(InputIterator, InputIterator, typename see below::size_type, Allocator) | |
| 202 | -> unordered_set<typename iterator_traits<InputIterator>::value_type, | |
| 203 | hash<typename iterator_traits<InputIterator>::value_type>, | |
| 204 | equal_to<typename iterator_traits<InputIterator>::value_type>, | |
| 205 | Allocator>; // C++17 | |
| 206 | ||
| 207 | template<class InputIterator, class Hash, class Allocator> | |
| 208 | unordered_set(InputIterator, InputIterator, typename see below::size_type, | |
| 209 | Hash, Allocator) | |
| 210 | -> unordered_set<typename iterator_traits<InputIterator>::value_type, Hash, | |
| 211 | equal_to<typename iterator_traits<InputIterator>::value_type>, | |
| 212 | Allocator>; // C++17 | |
| 213 | ||
| 214 | template<class T, class Allocator> | |
| 215 | unordered_set(initializer_list<T>, typename see below::size_type, Allocator) | |
| 216 | -> unordered_set<T, hash<T>, equal_to<T>, Allocator>; // C++17 | |
| 217 | ||
| 218 | template<class T, class Hash, class Allocator> | |
| 219 | unordered_set(initializer_list<T>, typename see below::size_type, Hash, Allocator) | |
| 220 | -> unordered_set<T, Hash, equal_to<T>, Allocator>; // C++17 | |
| 221 | ||
| 185 | 222 | template <class Value, class Hash, class Pred, class Alloc> |
| 186 | 223 | void swap(unordered_set<Value, Hash, Pred, Alloc>& x, |
| 187 | 224 | unordered_set<Value, Hash, Pred, Alloc>& y) |
| ... | ... | @@ -359,6 +396,42 @@ public: |
| 359 | 396 | void reserve(size_type n); |
| 360 | 397 | }; |
| 361 | 398 | |
| 399 | template<class InputIterator, | |
| 400 | class Hash = hash<typename iterator_traits<InputIterator>::value_type>, | |
| 401 | class Pred = equal_to<typename iterator_traits<InputIterator>::value_type>, | |
| 402 | class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> | |
| 403 | unordered_multiset(InputIterator, InputIterator, see below::size_type = see below, | |
| 404 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 405 | -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, | |
| 406 | Hash, Pred, Allocator>; // C++17 | |
| 407 | ||
| 408 | template<class T, class Hash = hash<T>, | |
| 409 | class Pred = equal_to<T>, class Allocator = allocator<T>> | |
| 410 | unordered_multiset(initializer_list<T>, typename see below::size_type = see below, | |
| 411 | Hash = Hash(), Pred = Pred(), Allocator = Allocator()) | |
| 412 | -> unordered_multiset<T, Hash, Pred, Allocator>; // C++17 | |
| 413 | ||
| 414 | template<class InputIterator, class Allocator> | |
| 415 | unordered_multiset(InputIterator, InputIterator, typename see below::size_type, Allocator) | |
| 416 | -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, | |
| 417 | hash<typename iterator_traits<InputIterator>::value_type>, | |
| 418 | equal_to<typename iterator_traits<InputIterator>::value_type>, | |
| 419 | Allocator>; // C++17 | |
| 420 | ||
| 421 | template<class InputIterator, class Hash, class Allocator> | |
| 422 | unordered_multiset(InputIterator, InputIterator, typename see below::size_type, | |
| 423 | Hash, Allocator) | |
| 424 | -> unordered_multiset<typename iterator_traits<InputIterator>::value_type, Hash, | |
| 425 | equal_to<typename iterator_traits<InputIterator>::value_type>, Allocator>; // C++17 | |
| 426 | ||
| 427 | template<class T, class Allocator> | |
| 428 | unordered_multiset(initializer_list<T>, typename see below::size_type, Allocator) | |
| 429 | -> unordered_multiset<T, hash<T>, equal_to<T>, Allocator>; // C++17 | |
| 430 | ||
| 431 | template<class T, class Hash, class Allocator> | |
| 432 | unordered_multiset(initializer_list<T>, typename see below::size_type, Hash, Allocator) | |
| 433 | -> unordered_multiset<T, Hash, equal_to<T>, Allocator>; // C++17 | |
| 434 | ||
| 362 | 435 | template <class Value, class Hash, class Pred, class Alloc> |
| 363 | 436 | void swap(unordered_multiset<Value, Hash, Pred, Alloc>& x, |
| 364 | 437 | unordered_multiset<Value, Hash, Pred, Alloc>& y) |
| ... | ... | @@ -390,6 +463,7 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 390 | 463 | #include <__debug> |
| 391 | 464 | #include <__functional/is_transparent.h> |
| 392 | 465 | #include <__hash_table> |
| 466 | #include <__memory/addressof.h> | |
| 393 | 467 | #include <__node_handle> |
| 394 | 468 | #include <__utility/forward.h> |
| 395 | 469 | #include <compare> |
| ... | ... | @@ -451,11 +525,9 @@ public: |
| 451 | 525 | _LIBCPP_INLINE_VISIBILITY |
| 452 | 526 | unordered_set() |
| 453 | 527 | _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) |
| 454 | { | |
| 455 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 456 | __get_db()->__insert_c(this); | |
| 457 | #endif | |
| 458 | } | |
| 528 | { | |
| 529 | _VSTD::__debug_db_insert_c(this); | |
| 530 | } | |
| 459 | 531 | explicit unordered_set(size_type __n, const hasher& __hf = hasher(), |
| 460 | 532 | const key_equal& __eql = key_equal()); |
| 461 | 533 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -569,7 +641,7 @@ public: |
| 569 | 641 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 570 | 642 | iterator emplace_hint(const_iterator __p, _Args&&... __args) |
| 571 | 643 | { |
| 572 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 644 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 573 | 645 | "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not" |
| 574 | 646 | " referring to this unordered_set"); |
| 575 | 647 | return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; |
| ... | ... | @@ -586,7 +658,7 @@ public: |
| 586 | 658 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 587 | 659 | iterator insert(const_iterator __p, value_type&& __x) |
| 588 | 660 | { |
| 589 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 661 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 590 | 662 | "unordered_set::insert(const_iterator, value_type&&) called with an iterator not" |
| 591 | 663 | " referring to this unordered_set"); |
| 592 | 664 | return insert(_VSTD::move(__x)).first; |
| ... | ... | @@ -607,7 +679,7 @@ public: |
| 607 | 679 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 608 | 680 | iterator insert(const_iterator __p, const value_type& __x) |
| 609 | 681 | { |
| 610 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, | |
| 682 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 611 | 683 | "unordered_set::insert(const_iterator, const value_type&) called with an iterator not" |
| 612 | 684 | " referring to this unordered_set"); |
| 613 | 685 | return insert(__x).first; |
| ... | ... | @@ -706,49 +778,48 @@ public: |
| 706 | 778 | iterator find(const key_type& __k) {return __table_.find(__k);} |
| 707 | 779 | _LIBCPP_INLINE_VISIBILITY |
| 708 | 780 | const_iterator find(const key_type& __k) const {return __table_.find(__k);} |
| 709 | #if _LIBCPP_STD_VER > 17 | |
| 710 | template <typename _K2> | |
| 711 | _LIBCPP_INLINE_VISIBILITY | |
| 712 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator> | |
| 713 | find(const _K2& __k) {return __table_.find(__k);} | |
| 714 | template <typename _K2> | |
| 715 | _LIBCPP_INLINE_VISIBILITY | |
| 716 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator> | |
| 717 | find(const _K2& __k) const {return __table_.find(__k);} | |
| 718 | #endif // _LIBCPP_STD_VER > 17 | |
| 781 | #if _LIBCPP_STD_VER > 17 | |
| 782 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 783 | _LIBCPP_INLINE_VISIBILITY | |
| 784 | iterator find(const _K2& __k) {return __table_.find(__k);} | |
| 785 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 786 | _LIBCPP_INLINE_VISIBILITY | |
| 787 | const_iterator find(const _K2& __k) const {return __table_.find(__k);} | |
| 788 | #endif // _LIBCPP_STD_VER > 17 | |
| 789 | ||
| 719 | 790 | _LIBCPP_INLINE_VISIBILITY |
| 720 | 791 | size_type count(const key_type& __k) const {return __table_.__count_unique(__k);} |
| 721 | #if _LIBCPP_STD_VER > 17 | |
| 722 | template <typename _K2> | |
| 723 | _LIBCPP_INLINE_VISIBILITY | |
| 724 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type> | |
| 725 | count(const _K2& __k) const {return __table_.__count_unique(__k);} | |
| 726 | #endif // _LIBCPP_STD_VER > 17 | |
| 727 | #if _LIBCPP_STD_VER > 17 | |
| 728 | _LIBCPP_INLINE_VISIBILITY | |
| 729 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 792 | #if _LIBCPP_STD_VER > 17 | |
| 793 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 794 | _LIBCPP_INLINE_VISIBILITY | |
| 795 | size_type count(const _K2& __k) const {return __table_.__count_unique(__k);} | |
| 796 | #endif // _LIBCPP_STD_VER > 17 | |
| 797 | ||
| 798 | #if _LIBCPP_STD_VER > 17 | |
| 799 | _LIBCPP_INLINE_VISIBILITY | |
| 800 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 801 | ||
| 802 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 803 | _LIBCPP_INLINE_VISIBILITY | |
| 804 | bool contains(const _K2& __k) const {return find(__k) != end();} | |
| 805 | #endif // _LIBCPP_STD_VER > 17 | |
| 730 | 806 | |
| 731 | template <typename _K2> | |
| 732 | _LIBCPP_INLINE_VISIBILITY | |
| 733 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool> | |
| 734 | contains(const _K2& __k) const {return find(__k) != end();} | |
| 735 | #endif // _LIBCPP_STD_VER > 17 | |
| 736 | 807 | _LIBCPP_INLINE_VISIBILITY |
| 737 | 808 | pair<iterator, iterator> equal_range(const key_type& __k) |
| 738 | 809 | {return __table_.__equal_range_unique(__k);} |
| 739 | 810 | _LIBCPP_INLINE_VISIBILITY |
| 740 | 811 | pair<const_iterator, const_iterator> equal_range(const key_type& __k) const |
| 741 | 812 | {return __table_.__equal_range_unique(__k);} |
| 742 | #if _LIBCPP_STD_VER > 17 | |
| 743 | template <typename _K2> | |
| 744 | _LIBCPP_INLINE_VISIBILITY | |
| 745 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>> | |
| 746 | equal_range(const _K2& __k) {return __table_.__equal_range_unique(__k);} | |
| 747 | template <typename _K2> | |
| 748 | _LIBCPP_INLINE_VISIBILITY | |
| 749 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>> | |
| 750 | equal_range(const _K2& __k) const {return __table_.__equal_range_unique(__k);} | |
| 751 | #endif // _LIBCPP_STD_VER > 17 | |
| 813 | #if _LIBCPP_STD_VER > 17 | |
| 814 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 815 | _LIBCPP_INLINE_VISIBILITY | |
| 816 | pair<iterator, iterator> equal_range(const _K2& __k) | |
| 817 | {return __table_.__equal_range_unique(__k);} | |
| 818 | template <class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 819 | _LIBCPP_INLINE_VISIBILITY | |
| 820 | pair<const_iterator, const_iterator> equal_range(const _K2& __k) const | |
| 821 | {return __table_.__equal_range_unique(__k);} | |
| 822 | #endif // _LIBCPP_STD_VER > 17 | |
| 752 | 823 | |
| 753 | 824 | _LIBCPP_INLINE_VISIBILITY |
| 754 | 825 | size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} |
| ... | ... | @@ -799,15 +870,16 @@ public: |
| 799 | 870 | |
| 800 | 871 | }; |
| 801 | 872 | |
| 802 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 873 | #if _LIBCPP_STD_VER >= 17 | |
| 803 | 874 | template<class _InputIterator, |
| 804 | 875 | class _Hash = hash<__iter_value_type<_InputIterator>>, |
| 805 | 876 | class _Pred = equal_to<__iter_value_type<_InputIterator>>, |
| 806 | 877 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
| 807 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 808 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 809 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 810 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 878 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 879 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 880 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 881 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 882 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 811 | 883 | unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, |
| 812 | 884 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 813 | 885 | -> unordered_set<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| ... | ... | @@ -815,16 +887,17 @@ unordered_set(_InputIterator, _InputIterator, typename allocator_traits<_Allocat |
| 815 | 887 | template<class _Tp, class _Hash = hash<_Tp>, |
| 816 | 888 | class _Pred = equal_to<_Tp>, |
| 817 | 889 | class _Allocator = allocator<_Tp>, |
| 818 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 819 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 820 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 821 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 890 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 891 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 892 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 893 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 822 | 894 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0, |
| 823 | 895 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 824 | 896 | -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; |
| 825 | 897 | |
| 826 | 898 | template<class _InputIterator, class _Allocator, |
| 827 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 899 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 900 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 828 | 901 | unordered_set(_InputIterator, _InputIterator, |
| 829 | 902 | typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 830 | 903 | -> unordered_set<__iter_value_type<_InputIterator>, |
| ... | ... | @@ -833,9 +906,10 @@ unordered_set(_InputIterator, _InputIterator, |
| 833 | 906 | _Allocator>; |
| 834 | 907 | |
| 835 | 908 | template<class _InputIterator, class _Hash, class _Allocator, |
| 836 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 837 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 838 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 909 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 910 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 911 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 912 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 839 | 913 | unordered_set(_InputIterator, _InputIterator, |
| 840 | 914 | typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 841 | 915 | -> unordered_set<__iter_value_type<_InputIterator>, _Hash, |
| ... | ... | @@ -843,14 +917,14 @@ unordered_set(_InputIterator, _InputIterator, |
| 843 | 917 | _Allocator>; |
| 844 | 918 | |
| 845 | 919 | template<class _Tp, class _Allocator, |
| 846 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 920 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 847 | 921 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 848 | 922 | -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; |
| 849 | 923 | |
| 850 | 924 | template<class _Tp, class _Hash, class _Allocator, |
| 851 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 852 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 853 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 925 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 926 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 927 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 854 | 928 | unordered_set(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 855 | 929 | -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; |
| 856 | 930 | #endif |
| ... | ... | @@ -860,9 +934,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, |
| 860 | 934 | const hasher& __hf, const key_equal& __eql) |
| 861 | 935 | : __table_(__hf, __eql) |
| 862 | 936 | { |
| 863 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 864 | __get_db()->__insert_c(this); | |
| 865 | #endif | |
| 937 | _VSTD::__debug_db_insert_c(this); | |
| 866 | 938 | __table_.rehash(__n); |
| 867 | 939 | } |
| 868 | 940 | |
| ... | ... | @@ -871,9 +943,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, |
| 871 | 943 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 872 | 944 | : __table_(__hf, __eql, __a) |
| 873 | 945 | { |
| 874 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 875 | __get_db()->__insert_c(this); | |
| 876 | #endif | |
| 946 | _VSTD::__debug_db_insert_c(this); | |
| 877 | 947 | __table_.rehash(__n); |
| 878 | 948 | } |
| 879 | 949 | |
| ... | ... | @@ -882,9 +952,7 @@ template <class _InputIterator> |
| 882 | 952 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 883 | 953 | _InputIterator __first, _InputIterator __last) |
| 884 | 954 | { |
| 885 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 886 | __get_db()->__insert_c(this); | |
| 887 | #endif | |
| 955 | _VSTD::__debug_db_insert_c(this); | |
| 888 | 956 | insert(__first, __last); |
| 889 | 957 | } |
| 890 | 958 | |
| ... | ... | @@ -895,9 +963,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 895 | 963 | const hasher& __hf, const key_equal& __eql) |
| 896 | 964 | : __table_(__hf, __eql) |
| 897 | 965 | { |
| 898 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 899 | __get_db()->__insert_c(this); | |
| 900 | #endif | |
| 966 | _VSTD::__debug_db_insert_c(this); | |
| 901 | 967 | __table_.rehash(__n); |
| 902 | 968 | insert(__first, __last); |
| 903 | 969 | } |
| ... | ... | @@ -909,9 +975,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 909 | 975 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 910 | 976 | : __table_(__hf, __eql, __a) |
| 911 | 977 | { |
| 912 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 913 | __get_db()->__insert_c(this); | |
| 914 | #endif | |
| 978 | _VSTD::__debug_db_insert_c(this); | |
| 915 | 979 | __table_.rehash(__n); |
| 916 | 980 | insert(__first, __last); |
| 917 | 981 | } |
| ... | ... | @@ -922,9 +986,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 922 | 986 | const allocator_type& __a) |
| 923 | 987 | : __table_(__a) |
| 924 | 988 | { |
| 925 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 926 | __get_db()->__insert_c(this); | |
| 927 | #endif | |
| 989 | _VSTD::__debug_db_insert_c(this); | |
| 928 | 990 | } |
| 929 | 991 | |
| 930 | 992 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -932,9 +994,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 932 | 994 | const unordered_set& __u) |
| 933 | 995 | : __table_(__u.__table_) |
| 934 | 996 | { |
| 935 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 936 | __get_db()->__insert_c(this); | |
| 937 | #endif | |
| 997 | _VSTD::__debug_db_insert_c(this); | |
| 938 | 998 | __table_.rehash(__u.bucket_count()); |
| 939 | 999 | insert(__u.begin(), __u.end()); |
| 940 | 1000 | } |
| ... | ... | @@ -944,9 +1004,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 944 | 1004 | const unordered_set& __u, const allocator_type& __a) |
| 945 | 1005 | : __table_(__u.__table_, __a) |
| 946 | 1006 | { |
| 947 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 948 | __get_db()->__insert_c(this); | |
| 949 | #endif | |
| 1007 | _VSTD::__debug_db_insert_c(this); | |
| 950 | 1008 | __table_.rehash(__u.bucket_count()); |
| 951 | 1009 | insert(__u.begin(), __u.end()); |
| 952 | 1010 | } |
| ... | ... | @@ -960,9 +1018,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 960 | 1018 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) |
| 961 | 1019 | : __table_(_VSTD::move(__u.__table_)) |
| 962 | 1020 | { |
| 1021 | _VSTD::__debug_db_insert_c(this); | |
| 963 | 1022 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 964 | __get_db()->__insert_c(this); | |
| 965 | __get_db()->swap(this, &__u); | |
| 1023 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 966 | 1024 | #endif |
| 967 | 1025 | } |
| 968 | 1026 | |
| ... | ... | @@ -971,9 +1029,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 971 | 1029 | unordered_set&& __u, const allocator_type& __a) |
| 972 | 1030 | : __table_(_VSTD::move(__u.__table_), __a) |
| 973 | 1031 | { |
| 974 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 975 | __get_db()->__insert_c(this); | |
| 976 | #endif | |
| 1032 | _VSTD::__debug_db_insert_c(this); | |
| 977 | 1033 | if (__a != __u.get_allocator()) |
| 978 | 1034 | { |
| 979 | 1035 | iterator __i = __u.begin(); |
| ... | ... | @@ -982,7 +1038,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 982 | 1038 | } |
| 983 | 1039 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 984 | 1040 | else |
| 985 | __get_db()->swap(this, &__u); | |
| 1041 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 986 | 1042 | #endif |
| 987 | 1043 | } |
| 988 | 1044 | |
| ... | ... | @@ -990,9 +1046,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 990 | 1046 | unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 991 | 1047 | initializer_list<value_type> __il) |
| 992 | 1048 | { |
| 993 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 994 | __get_db()->__insert_c(this); | |
| 995 | #endif | |
| 1049 | _VSTD::__debug_db_insert_c(this); | |
| 996 | 1050 | insert(__il.begin(), __il.end()); |
| 997 | 1051 | } |
| 998 | 1052 | |
| ... | ... | @@ -1002,9 +1056,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1002 | 1056 | const key_equal& __eql) |
| 1003 | 1057 | : __table_(__hf, __eql) |
| 1004 | 1058 | { |
| 1005 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1006 | __get_db()->__insert_c(this); | |
| 1007 | #endif | |
| 1059 | _VSTD::__debug_db_insert_c(this); | |
| 1008 | 1060 | __table_.rehash(__n); |
| 1009 | 1061 | insert(__il.begin(), __il.end()); |
| 1010 | 1062 | } |
| ... | ... | @@ -1015,9 +1067,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1015 | 1067 | const key_equal& __eql, const allocator_type& __a) |
| 1016 | 1068 | : __table_(__hf, __eql, __a) |
| 1017 | 1069 | { |
| 1018 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1019 | __get_db()->__insert_c(this); | |
| 1020 | #endif | |
| 1070 | _VSTD::__debug_db_insert_c(this); | |
| 1021 | 1071 | __table_.rehash(__n); |
| 1022 | 1072 | insert(__il.begin(), __il.end()); |
| 1023 | 1073 | } |
| ... | ... | @@ -1148,11 +1198,9 @@ public: |
| 1148 | 1198 | _LIBCPP_INLINE_VISIBILITY |
| 1149 | 1199 | unordered_multiset() |
| 1150 | 1200 | _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) |
| 1151 | { | |
| 1152 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1153 | __get_db()->__insert_c(this); | |
| 1154 | #endif | |
| 1155 | } | |
| 1201 | { | |
| 1202 | _VSTD::__debug_db_insert_c(this); | |
| 1203 | } | |
| 1156 | 1204 | explicit unordered_multiset(size_type __n, const hasher& __hf = hasher(), |
| 1157 | 1205 | const key_equal& __eql = key_equal()); |
| 1158 | 1206 | unordered_multiset(size_type __n, const hasher& __hf, |
| ... | ... | @@ -1372,49 +1420,48 @@ public: |
| 1372 | 1420 | iterator find(const key_type& __k) {return __table_.find(__k);} |
| 1373 | 1421 | _LIBCPP_INLINE_VISIBILITY |
| 1374 | 1422 | const_iterator find(const key_type& __k) const {return __table_.find(__k);} |
| 1375 | #if _LIBCPP_STD_VER > 17 | |
| 1376 | template <typename _K2> | |
| 1377 | _LIBCPP_INLINE_VISIBILITY | |
| 1378 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, iterator> | |
| 1379 | find(const _K2& __k) {return __table_.find(__k);} | |
| 1380 | template <typename _K2> | |
| 1381 | _LIBCPP_INLINE_VISIBILITY | |
| 1382 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, const_iterator> | |
| 1383 | find(const _K2& __k) const {return __table_.find(__k);} | |
| 1384 | #endif // _LIBCPP_STD_VER > 17 | |
| 1423 | #if _LIBCPP_STD_VER > 17 | |
| 1424 | template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1425 | _LIBCPP_INLINE_VISIBILITY | |
| 1426 | iterator find(const _K2& __k) {return __table_.find(__k);} | |
| 1427 | template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1428 | _LIBCPP_INLINE_VISIBILITY | |
| 1429 | const_iterator find(const _K2& __k) const {return __table_.find(__k);} | |
| 1430 | #endif // _LIBCPP_STD_VER > 17 | |
| 1431 | ||
| 1385 | 1432 | _LIBCPP_INLINE_VISIBILITY |
| 1386 | 1433 | size_type count(const key_type& __k) const {return __table_.__count_multi(__k);} |
| 1387 | #if _LIBCPP_STD_VER > 17 | |
| 1388 | template <typename _K2> | |
| 1389 | _LIBCPP_INLINE_VISIBILITY | |
| 1390 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, size_type> | |
| 1391 | count(const _K2& __k) const {return __table_.__count_multi(__k);} | |
| 1392 | #endif // _LIBCPP_STD_VER > 17 | |
| 1393 | #if _LIBCPP_STD_VER > 17 | |
| 1394 | _LIBCPP_INLINE_VISIBILITY | |
| 1395 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 1434 | #if _LIBCPP_STD_VER > 17 | |
| 1435 | template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1436 | _LIBCPP_INLINE_VISIBILITY | |
| 1437 | size_type count(const _K2& __k) const {return __table_.__count_multi(__k);} | |
| 1438 | #endif // _LIBCPP_STD_VER > 17 | |
| 1439 | ||
| 1440 | #if _LIBCPP_STD_VER > 17 | |
| 1441 | _LIBCPP_INLINE_VISIBILITY | |
| 1442 | bool contains(const key_type& __k) const {return find(__k) != end();} | |
| 1443 | ||
| 1444 | template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1445 | _LIBCPP_INLINE_VISIBILITY | |
| 1446 | bool contains(const _K2& __k) const {return find(__k) != end();} | |
| 1447 | #endif // _LIBCPP_STD_VER > 17 | |
| 1396 | 1448 | |
| 1397 | template <typename _K2> | |
| 1398 | _LIBCPP_INLINE_VISIBILITY | |
| 1399 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, bool> | |
| 1400 | contains(const _K2& __k) const {return find(__k) != end();} | |
| 1401 | #endif // _LIBCPP_STD_VER > 17 | |
| 1402 | 1449 | _LIBCPP_INLINE_VISIBILITY |
| 1403 | 1450 | pair<iterator, iterator> equal_range(const key_type& __k) |
| 1404 | 1451 | {return __table_.__equal_range_multi(__k);} |
| 1405 | 1452 | _LIBCPP_INLINE_VISIBILITY |
| 1406 | 1453 | pair<const_iterator, const_iterator> equal_range(const key_type& __k) const |
| 1407 | 1454 | {return __table_.__equal_range_multi(__k);} |
| 1408 | #if _LIBCPP_STD_VER > 17 | |
| 1409 | template <typename _K2> | |
| 1410 | _LIBCPP_INLINE_VISIBILITY | |
| 1411 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<iterator, iterator>> | |
| 1412 | equal_range(const _K2& __k) {return __table_.__equal_range_multi(__k);} | |
| 1413 | template <typename _K2> | |
| 1414 | _LIBCPP_INLINE_VISIBILITY | |
| 1415 | _EnableIf<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value, pair<const_iterator, const_iterator>> | |
| 1416 | equal_range(const _K2& __k) const {return __table_.__equal_range_multi(__k);} | |
| 1417 | #endif // _LIBCPP_STD_VER > 17 | |
| 1455 | #if _LIBCPP_STD_VER > 17 | |
| 1456 | template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1457 | _LIBCPP_INLINE_VISIBILITY | |
| 1458 | pair<iterator, iterator> equal_range(const _K2& __k) | |
| 1459 | {return __table_.__equal_range_multi(__k);} | |
| 1460 | template<class _K2, enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr> | |
| 1461 | _LIBCPP_INLINE_VISIBILITY | |
| 1462 | pair<const_iterator, const_iterator> equal_range(const _K2& __k) const | |
| 1463 | {return __table_.__equal_range_multi(__k);} | |
| 1464 | #endif // _LIBCPP_STD_VER > 17 | |
| 1418 | 1465 | |
| 1419 | 1466 | _LIBCPP_INLINE_VISIBILITY |
| 1420 | 1467 | size_type bucket_count() const _NOEXCEPT {return __table_.bucket_count();} |
| ... | ... | @@ -1465,31 +1512,33 @@ public: |
| 1465 | 1512 | |
| 1466 | 1513 | }; |
| 1467 | 1514 | |
| 1468 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 1515 | #if _LIBCPP_STD_VER >= 17 | |
| 1469 | 1516 | template<class _InputIterator, |
| 1470 | 1517 | class _Hash = hash<__iter_value_type<_InputIterator>>, |
| 1471 | 1518 | class _Pred = equal_to<__iter_value_type<_InputIterator>>, |
| 1472 | 1519 | class _Allocator = allocator<__iter_value_type<_InputIterator>>, |
| 1473 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1474 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1475 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 1476 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1520 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1521 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1522 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1523 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 1524 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1477 | 1525 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type = 0, |
| 1478 | 1526 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 1479 | 1527 | -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, _Pred, _Allocator>; |
| 1480 | 1528 | |
| 1481 | 1529 | template<class _Tp, class _Hash = hash<_Tp>, |
| 1482 | 1530 | class _Pred = equal_to<_Tp>, class _Allocator = allocator<_Tp>, |
| 1483 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1484 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1485 | class = _EnableIf<!__is_allocator<_Pred>::value>, | |
| 1486 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1531 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1532 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1533 | class = enable_if_t<!__is_allocator<_Pred>::value>, | |
| 1534 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1487 | 1535 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type = 0, |
| 1488 | 1536 | _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) |
| 1489 | 1537 | -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; |
| 1490 | 1538 | |
| 1491 | 1539 | template<class _InputIterator, class _Allocator, |
| 1492 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1540 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1541 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1493 | 1542 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1494 | 1543 | -> unordered_multiset<__iter_value_type<_InputIterator>, |
| 1495 | 1544 | hash<__iter_value_type<_InputIterator>>, |
| ... | ... | @@ -1497,9 +1546,10 @@ unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 1497 | 1546 | _Allocator>; |
| 1498 | 1547 | |
| 1499 | 1548 | template<class _InputIterator, class _Hash, class _Allocator, |
| 1500 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1501 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1502 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1549 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 1550 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1551 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1552 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1503 | 1553 | unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Allocator>::size_type, |
| 1504 | 1554 | _Hash, _Allocator) |
| 1505 | 1555 | -> unordered_multiset<__iter_value_type<_InputIterator>, _Hash, |
| ... | ... | @@ -1507,14 +1557,14 @@ unordered_multiset(_InputIterator, _InputIterator, typename allocator_traits<_Al |
| 1507 | 1557 | _Allocator>; |
| 1508 | 1558 | |
| 1509 | 1559 | template<class _Tp, class _Allocator, |
| 1510 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1560 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1511 | 1561 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Allocator) |
| 1512 | 1562 | -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; |
| 1513 | 1563 | |
| 1514 | 1564 | template<class _Tp, class _Hash, class _Allocator, |
| 1515 | class = _EnableIf<!__is_allocator<_Hash>::value>, | |
| 1516 | class = _EnableIf<!is_integral<_Hash>::value>, | |
| 1517 | class = _EnableIf<__is_allocator<_Allocator>::value>> | |
| 1565 | class = enable_if_t<!__is_allocator<_Hash>::value>, | |
| 1566 | class = enable_if_t<!is_integral<_Hash>::value>, | |
| 1567 | class = enable_if_t<__is_allocator<_Allocator>::value>> | |
| 1518 | 1568 | unordered_multiset(initializer_list<_Tp>, typename allocator_traits<_Allocator>::size_type, _Hash, _Allocator) |
| 1519 | 1569 | -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; |
| 1520 | 1570 | #endif |
| ... | ... | @@ -1524,9 +1574,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1524 | 1574 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 1525 | 1575 | : __table_(__hf, __eql) |
| 1526 | 1576 | { |
| 1527 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1528 | __get_db()->__insert_c(this); | |
| 1529 | #endif | |
| 1577 | _VSTD::__debug_db_insert_c(this); | |
| 1530 | 1578 | __table_.rehash(__n); |
| 1531 | 1579 | } |
| 1532 | 1580 | |
| ... | ... | @@ -1536,9 +1584,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1536 | 1584 | const allocator_type& __a) |
| 1537 | 1585 | : __table_(__hf, __eql, __a) |
| 1538 | 1586 | { |
| 1539 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1540 | __get_db()->__insert_c(this); | |
| 1541 | #endif | |
| 1587 | _VSTD::__debug_db_insert_c(this); | |
| 1542 | 1588 | __table_.rehash(__n); |
| 1543 | 1589 | } |
| 1544 | 1590 | |
| ... | ... | @@ -1547,9 +1593,7 @@ template <class _InputIterator> |
| 1547 | 1593 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1548 | 1594 | _InputIterator __first, _InputIterator __last) |
| 1549 | 1595 | { |
| 1550 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1551 | __get_db()->__insert_c(this); | |
| 1552 | #endif | |
| 1596 | _VSTD::__debug_db_insert_c(this); | |
| 1553 | 1597 | insert(__first, __last); |
| 1554 | 1598 | } |
| 1555 | 1599 | |
| ... | ... | @@ -1560,9 +1604,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1560 | 1604 | const hasher& __hf, const key_equal& __eql) |
| 1561 | 1605 | : __table_(__hf, __eql) |
| 1562 | 1606 | { |
| 1563 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1564 | __get_db()->__insert_c(this); | |
| 1565 | #endif | |
| 1607 | _VSTD::__debug_db_insert_c(this); | |
| 1566 | 1608 | __table_.rehash(__n); |
| 1567 | 1609 | insert(__first, __last); |
| 1568 | 1610 | } |
| ... | ... | @@ -1574,9 +1616,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1574 | 1616 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 1575 | 1617 | : __table_(__hf, __eql, __a) |
| 1576 | 1618 | { |
| 1577 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1578 | __get_db()->__insert_c(this); | |
| 1579 | #endif | |
| 1619 | _VSTD::__debug_db_insert_c(this); | |
| 1580 | 1620 | __table_.rehash(__n); |
| 1581 | 1621 | insert(__first, __last); |
| 1582 | 1622 | } |
| ... | ... | @@ -1587,9 +1627,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1587 | 1627 | const allocator_type& __a) |
| 1588 | 1628 | : __table_(__a) |
| 1589 | 1629 | { |
| 1590 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1591 | __get_db()->__insert_c(this); | |
| 1592 | #endif | |
| 1630 | _VSTD::__debug_db_insert_c(this); | |
| 1593 | 1631 | } |
| 1594 | 1632 | |
| 1595 | 1633 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1597,9 +1635,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1597 | 1635 | const unordered_multiset& __u) |
| 1598 | 1636 | : __table_(__u.__table_) |
| 1599 | 1637 | { |
| 1600 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1601 | __get_db()->__insert_c(this); | |
| 1602 | #endif | |
| 1638 | _VSTD::__debug_db_insert_c(this); | |
| 1603 | 1639 | __table_.rehash(__u.bucket_count()); |
| 1604 | 1640 | insert(__u.begin(), __u.end()); |
| 1605 | 1641 | } |
| ... | ... | @@ -1609,9 +1645,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1609 | 1645 | const unordered_multiset& __u, const allocator_type& __a) |
| 1610 | 1646 | : __table_(__u.__table_, __a) |
| 1611 | 1647 | { |
| 1612 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1613 | __get_db()->__insert_c(this); | |
| 1614 | #endif | |
| 1648 | _VSTD::__debug_db_insert_c(this); | |
| 1615 | 1649 | __table_.rehash(__u.bucket_count()); |
| 1616 | 1650 | insert(__u.begin(), __u.end()); |
| 1617 | 1651 | } |
| ... | ... | @@ -1625,9 +1659,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1625 | 1659 | _NOEXCEPT_(is_nothrow_move_constructible<__table>::value) |
| 1626 | 1660 | : __table_(_VSTD::move(__u.__table_)) |
| 1627 | 1661 | { |
| 1662 | _VSTD::__debug_db_insert_c(this); | |
| 1628 | 1663 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1629 | __get_db()->__insert_c(this); | |
| 1630 | __get_db()->swap(this, &__u); | |
| 1664 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1631 | 1665 | #endif |
| 1632 | 1666 | } |
| 1633 | 1667 | |
| ... | ... | @@ -1636,9 +1670,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1636 | 1670 | unordered_multiset&& __u, const allocator_type& __a) |
| 1637 | 1671 | : __table_(_VSTD::move(__u.__table_), __a) |
| 1638 | 1672 | { |
| 1639 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1640 | __get_db()->__insert_c(this); | |
| 1641 | #endif | |
| 1673 | _VSTD::__debug_db_insert_c(this); | |
| 1642 | 1674 | if (__a != __u.get_allocator()) |
| 1643 | 1675 | { |
| 1644 | 1676 | iterator __i = __u.begin(); |
| ... | ... | @@ -1647,7 +1679,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1647 | 1679 | } |
| 1648 | 1680 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1649 | 1681 | else |
| 1650 | __get_db()->swap(this, &__u); | |
| 1682 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1651 | 1683 | #endif |
| 1652 | 1684 | } |
| 1653 | 1685 | |
| ... | ... | @@ -1655,9 +1687,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc> |
| 1655 | 1687 | unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1656 | 1688 | initializer_list<value_type> __il) |
| 1657 | 1689 | { |
| 1658 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1659 | __get_db()->__insert_c(this); | |
| 1660 | #endif | |
| 1690 | _VSTD::__debug_db_insert_c(this); | |
| 1661 | 1691 | insert(__il.begin(), __il.end()); |
| 1662 | 1692 | } |
| 1663 | 1693 | |
| ... | ... | @@ -1667,9 +1697,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1667 | 1697 | const key_equal& __eql) |
| 1668 | 1698 | : __table_(__hf, __eql) |
| 1669 | 1699 | { |
| 1670 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1671 | __get_db()->__insert_c(this); | |
| 1672 | #endif | |
| 1700 | _VSTD::__debug_db_insert_c(this); | |
| 1673 | 1701 | __table_.rehash(__n); |
| 1674 | 1702 | insert(__il.begin(), __il.end()); |
| 1675 | 1703 | } |
| ... | ... | @@ -1680,9 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1680 | 1708 | const key_equal& __eql, const allocator_type& __a) |
| 1681 | 1709 | : __table_(__hf, __eql, __a) |
| 1682 | 1710 | { |
| 1683 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1684 | __get_db()->__insert_c(this); | |
| 1685 | #endif | |
| 1711 | _VSTD::__debug_db_insert_c(this); | |
| 1686 | 1712 | __table_.rehash(__n); |
| 1687 | 1713 | insert(__il.begin(), __il.end()); |
| 1688 | 1714 | } |
lib/libcxx/include/utility+22-8| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- utility -----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -79,7 +79,7 @@ struct pair |
| 79 | 79 | pair(pair&&) = default; |
| 80 | 80 | explicit(see-below) constexpr pair(); |
| 81 | 81 | explicit(see-below) pair(const T1& x, const T2& y); // constexpr in C++14 |
| 82 | template <class U, class V> explicit(see-below) pair(U&& x, V&& y); // constexpr in C++14 | |
| 82 | template <class U = T1, class V = T2> explicit(see-below) pair(U&&, V&&); // constexpr in C++14 | |
| 83 | 83 | template <class U, class V> explicit(see-below) pair(const pair<U, V>& p); // constexpr in C++14 |
| 84 | 84 | template <class U, class V> explicit(see-below) pair(pair<U, V>&& p); // constexpr in C++14 |
| 85 | 85 | template <class... Args1, class... Args2> |
| ... | ... | @@ -95,12 +95,18 @@ struct pair |
| 95 | 95 | is_nothrow_swappable_v<T2>); // constexpr in C++20 |
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>; | |
| 99 | ||
| 98 | 100 | template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 |
| 99 | template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 | |
| 100 | template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 | |
| 101 | template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 | |
| 102 | template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 | |
| 103 | template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 | |
| 101 | template <class T1, class T2> bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 | |
| 102 | template <class T1, class T2> bool operator< (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 | |
| 103 | template <class T1, class T2> bool operator> (const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 | |
| 104 | template <class T1, class T2> bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 | |
| 105 | template <class T1, class T2> bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14, removed in C++20 | |
| 106 | template <class T1, class T2> | |
| 107 | constexpr common_comparison_type_t<synth-three-way-result<T1>, | |
| 108 | synth-three-way-result<T2>> | |
| 109 | operator<=>(const pair<T1,T2>&, const pair<T1,T2>&); // C++20 | |
| 104 | 110 | |
| 105 | 111 | template <class T1, class T2> pair<V1, V2> make_pair(T1&&, T2&&); // constexpr in C++14 |
| 106 | 112 | template <class T1, class T2> |
| ... | ... | @@ -179,7 +185,8 @@ template<class... T> |
| 179 | 185 | using index_sequence_for = make_index_sequence<sizeof...(T)>; |
| 180 | 186 | |
| 181 | 187 | template<class T, class U=T> |
| 182 | T exchange(T& obj, U&& new_value); | |
| 188 | constexpr T exchange(T& obj, U&& new_value) | |
| 189 | noexcept(is_nothrow_move_constructible<T>::value && is_nothrow_assignable<T&, U>::value); // constexpr in C++17, noexcept in C++23 | |
| 183 | 190 | |
| 184 | 191 | // 20.2.7, in-place construction // C++17 |
| 185 | 192 | struct in_place_t { |
| ... | ... | @@ -211,6 +218,7 @@ template <class T> |
| 211 | 218 | #include <__debug> |
| 212 | 219 | #include <__tuple> |
| 213 | 220 | #include <__utility/as_const.h> |
| 221 | #include <__utility/auto_cast.h> | |
| 214 | 222 | #include <__utility/cmp.h> |
| 215 | 223 | #include <__utility/declval.h> |
| 216 | 224 | #include <__utility/exchange.h> |
| ... | ... | @@ -220,11 +228,17 @@ template <class T> |
| 220 | 228 | #include <__utility/move.h> |
| 221 | 229 | #include <__utility/pair.h> |
| 222 | 230 | #include <__utility/piecewise_construct.h> |
| 231 | #include <__utility/priority_tag.h> | |
| 223 | 232 | #include <__utility/rel_ops.h> |
| 224 | 233 | #include <__utility/swap.h> |
| 225 | 234 | #include <__utility/to_underlying.h> |
| 235 | #include <__utility/transaction.h> | |
| 226 | 236 | #include <compare> |
| 227 | 237 | #include <initializer_list> |
| 228 | 238 | #include <version> |
| 229 | 239 | |
| 240 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 241 | #pragma GCC system_header | |
| 242 | #endif | |
| 243 | ||
| 230 | 244 | #endif // _LIBCPP_UTILITY |
lib/libcxx/include/valarray+10-2| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- valarray ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -105,6 +105,8 @@ public: |
| 105 | 105 | void resize(size_t n, value_type x = value_type()); |
| 106 | 106 | }; |
| 107 | 107 | |
| 108 | template<class T, size_t cnt> valarray(const T(&)[cnt], size_t) -> valarray<T>; | |
| 109 | ||
| 108 | 110 | class slice |
| 109 | 111 | { |
| 110 | 112 | public: |
| ... | ... | @@ -346,6 +348,7 @@ template <class T> unspecified2 end(const valarray<T>& v); |
| 346 | 348 | #include <functional> |
| 347 | 349 | #include <initializer_list> |
| 348 | 350 | #include <new> |
| 351 | #include <version> | |
| 349 | 352 | |
| 350 | 353 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 351 | 354 | #pragma GCC system_header |
| ... | ... | @@ -1081,6 +1084,11 @@ private: |
| 1081 | 1084 | valarray& __assign_range(const value_type* __f, const value_type* __l); |
| 1082 | 1085 | }; |
| 1083 | 1086 | |
| 1087 | #if _LIBCPP_STD_VER > 14 | |
| 1088 | template<class _Tp, size_t _Size> | |
| 1089 | valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; | |
| 1090 | #endif | |
| 1091 | ||
| 1084 | 1092 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t)) |
| 1085 | 1093 | |
| 1086 | 1094 | template <class _Op, class _Tp> |
| ... | ... | @@ -3048,7 +3056,7 @@ template <class _Tp> |
| 3048 | 3056 | valarray<_Tp>& |
| 3049 | 3057 | valarray<_Tp>::operator=(const valarray& __v) |
| 3050 | 3058 | { |
| 3051 | if (this != &__v) | |
| 3059 | if (this != _VSTD::addressof(__v)) | |
| 3052 | 3060 | return __assign_range(__v.__begin_, __v.__end_); |
| 3053 | 3061 | return *this; |
| 3054 | 3062 | } |
lib/libcxx/include/variant+14-18| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------ variant -------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -233,10 +233,7 @@ public: |
| 233 | 233 | |
| 234 | 234 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 235 | 235 | |
| 236 | // TODO: GCC 5 lies about its support for C++17 (it says it supports it but it | |
| 237 | // really doesn't). That breaks variant, which uses some C++17 features. | |
| 238 | // Remove this once we drop support for GCC 5. | |
| 239 | #if _LIBCPP_STD_VER > 14 && !(defined(_LIBCPP_COMPILER_GCC) && _GNUC_VER_NEW < 6000) | |
| 236 | #if _LIBCPP_STD_VER > 14 | |
| 240 | 237 | |
| 241 | 238 | // Light N-dimensional array of function pointers. Used in place of std::array to avoid |
| 242 | 239 | // adding a dependency. |
| ... | ... | @@ -269,7 +266,7 @@ template <class _Tp> |
| 269 | 266 | struct _LIBCPP_TEMPLATE_VIS variant_size; |
| 270 | 267 | |
| 271 | 268 | template <class _Tp> |
| 272 | _LIBCPP_INLINE_VAR constexpr size_t variant_size_v = variant_size<_Tp>::value; | |
| 269 | inline constexpr size_t variant_size_v = variant_size<_Tp>::value; | |
| 273 | 270 | |
| 274 | 271 | template <class _Tp> |
| 275 | 272 | struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {}; |
| ... | ... | @@ -309,7 +306,7 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> { |
| 309 | 306 | using type = __type_pack_element<_Ip, _Types...>; |
| 310 | 307 | }; |
| 311 | 308 | |
| 312 | _LIBCPP_INLINE_VAR constexpr size_t variant_npos = static_cast<size_t>(-1); | |
| 309 | inline constexpr size_t variant_npos = static_cast<size_t>(-1); | |
| 313 | 310 | |
| 314 | 311 | constexpr int __choose_index_type(unsigned int __num_elem) { |
| 315 | 312 | if (__num_elem < numeric_limits<unsigned char>::max()) |
| ... | ... | @@ -552,7 +549,7 @@ private: |
| 552 | 549 | inline _LIBCPP_INLINE_VISIBILITY |
| 553 | 550 | static constexpr auto __make_fdiagonal_impl() { |
| 554 | 551 | return __make_dispatch<_Fp, _Vs...>( |
| 555 | index_sequence<(__identity<_Vs>{}, _Ip)...>{}); | |
| 552 | index_sequence<((void)__identity<_Vs>{}, _Ip)...>{}); | |
| 556 | 553 | } |
| 557 | 554 | |
| 558 | 555 | template <class _Fp, class... _Vs, size_t... _Is> |
| ... | ... | @@ -1196,11 +1193,11 @@ struct __narrowing_check { |
| 1196 | 1193 | template <class _Dest> |
| 1197 | 1194 | static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>; |
| 1198 | 1195 | template <class _Dest, class _Source> |
| 1199 | using _Apply _LIBCPP_NODEBUG_TYPE = decltype(__test_impl<_Dest>({declval<_Source>()})); | |
| 1196 | using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()})); | |
| 1200 | 1197 | }; |
| 1201 | 1198 | |
| 1202 | 1199 | template <class _Dest, class _Source> |
| 1203 | using __check_for_narrowing _LIBCPP_NODEBUG_TYPE = | |
| 1200 | using __check_for_narrowing _LIBCPP_NODEBUG = | |
| 1204 | 1201 | typename _If< |
| 1205 | 1202 | #ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT |
| 1206 | 1203 | false && |
| ... | ... | @@ -1244,18 +1241,18 @@ struct __make_overloads_imp; |
| 1244 | 1241 | template <size_t ..._Idx> |
| 1245 | 1242 | struct __make_overloads_imp<__tuple_indices<_Idx...> > { |
| 1246 | 1243 | template <class ..._Types> |
| 1247 | using _Apply _LIBCPP_NODEBUG_TYPE = __all_overloads<__overload<_Types, _Idx>...>; | |
| 1244 | using _Apply _LIBCPP_NODEBUG = __all_overloads<__overload<_Types, _Idx>...>; | |
| 1248 | 1245 | }; |
| 1249 | 1246 | |
| 1250 | 1247 | template <class ..._Types> |
| 1251 | using _MakeOverloads _LIBCPP_NODEBUG_TYPE = typename __make_overloads_imp< | |
| 1248 | using _MakeOverloads _LIBCPP_NODEBUG = typename __make_overloads_imp< | |
| 1252 | 1249 | __make_indices_imp<sizeof...(_Types), 0> >::template _Apply<_Types...>; |
| 1253 | 1250 | |
| 1254 | 1251 | template <class _Tp, class... _Types> |
| 1255 | 1252 | using __best_match_t = |
| 1256 | 1253 | typename invoke_result_t<_MakeOverloads<_Types...>, _Tp, _Tp>::type; |
| 1257 | 1254 | |
| 1258 | } // __variant_detail | |
| 1255 | } // namespace __variant_detail | |
| 1259 | 1256 | |
| 1260 | 1257 | template <class... _Types> |
| 1261 | 1258 | class _LIBCPP_TEMPLATE_VIS variant |
| ... | ... | @@ -1718,11 +1715,10 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 1718 | 1715 | |
| 1719 | 1716 | template <class... _Types> |
| 1720 | 1717 | inline _LIBCPP_INLINE_VISIBILITY |
| 1721 | auto swap(variant<_Types...>& __lhs, | |
| 1722 | variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) | |
| 1723 | -> decltype(__lhs.swap(__rhs)) { | |
| 1724 | __lhs.swap(__rhs); | |
| 1725 | } | |
| 1718 | auto swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) | |
| 1719 | noexcept(noexcept(__lhs.swap(__rhs))) | |
| 1720 | -> decltype( __lhs.swap(__rhs)) | |
| 1721 | { return __lhs.swap(__rhs); } | |
| 1726 | 1722 | |
| 1727 | 1723 | template <class... _Types> |
| 1728 | 1724 | struct _LIBCPP_TEMPLATE_VIS hash< |
lib/libcxx/include/vector+207-349| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===------------------------------ vector --------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -245,7 +245,7 @@ public: |
| 245 | 245 | |
| 246 | 246 | template <class InputIterator, class Allocator = allocator<typename iterator_traits<InputIterator>::value_type>> |
| 247 | 247 | vector(InputIterator, InputIterator, Allocator = Allocator()) |
| 248 | -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; | |
| 248 | -> vector<typename iterator_traits<InputIterator>::value_type, Allocator>; // C++17 | |
| 249 | 249 | |
| 250 | 250 | template <class Allocator> struct hash<std::vector<bool, Allocator>>; |
| 251 | 251 | |
| ... | ... | @@ -271,10 +271,11 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 |
| 271 | 271 | |
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | #include <__config> | |
| 275 | 274 | #include <__bit_reference> |
| 275 | #include <__config> | |
| 276 | 276 | #include <__debug> |
| 277 | 277 | #include <__functional_base> |
| 278 | #include <__iterator/iterator_traits.h> | |
| 278 | 279 | #include <__iterator/wrap_iter.h> |
| 279 | 280 | #include <__split_buffer> |
| 280 | 281 | #include <__utility/forward.h> |
| ... | ... | @@ -301,245 +302,63 @@ _LIBCPP_PUSH_MACROS |
| 301 | 302 | |
| 302 | 303 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 303 | 304 | |
| 304 | template <bool> | |
| 305 | class _LIBCPP_TEMPLATE_VIS __vector_base_common | |
| 306 | { | |
| 307 | protected: | |
| 308 | _LIBCPP_INLINE_VISIBILITY __vector_base_common() {} | |
| 309 | _LIBCPP_NORETURN void __throw_length_error() const; | |
| 310 | _LIBCPP_NORETURN void __throw_out_of_range() const; | |
| 311 | }; | |
| 312 | ||
| 313 | template <bool __b> | |
| 314 | void | |
| 315 | __vector_base_common<__b>::__throw_length_error() const | |
| 316 | { | |
| 317 | _VSTD::__throw_length_error("vector"); | |
| 318 | } | |
| 319 | ||
| 320 | template <bool __b> | |
| 321 | void | |
| 322 | __vector_base_common<__b>::__throw_out_of_range() const | |
| 323 | { | |
| 324 | _VSTD::__throw_out_of_range("vector"); | |
| 325 | } | |
| 326 | ||
| 327 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __vector_base_common<true>) | |
| 328 | ||
| 329 | template <class _Tp, class _Allocator> | |
| 330 | class __vector_base | |
| 331 | : protected __vector_base_common<true> | |
| 332 | { | |
| 333 | public: | |
| 334 | typedef _Allocator allocator_type; | |
| 335 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 336 | typedef typename __alloc_traits::size_type size_type; | |
| 337 | protected: | |
| 338 | typedef _Tp value_type; | |
| 339 | typedef value_type& reference; | |
| 340 | typedef const value_type& const_reference; | |
| 341 | typedef typename __alloc_traits::difference_type difference_type; | |
| 342 | typedef typename __alloc_traits::pointer pointer; | |
| 343 | typedef typename __alloc_traits::const_pointer const_pointer; | |
| 344 | typedef pointer iterator; | |
| 345 | typedef const_pointer const_iterator; | |
| 346 | ||
| 347 | pointer __begin_; | |
| 348 | pointer __end_; | |
| 349 | __compressed_pair<pointer, allocator_type> __end_cap_; | |
| 350 | ||
| 351 | _LIBCPP_INLINE_VISIBILITY | |
| 352 | allocator_type& __alloc() _NOEXCEPT | |
| 353 | {return __end_cap_.second();} | |
| 354 | _LIBCPP_INLINE_VISIBILITY | |
| 355 | const allocator_type& __alloc() const _NOEXCEPT | |
| 356 | {return __end_cap_.second();} | |
| 357 | _LIBCPP_INLINE_VISIBILITY | |
| 358 | pointer& __end_cap() _NOEXCEPT | |
| 359 | {return __end_cap_.first();} | |
| 360 | _LIBCPP_INLINE_VISIBILITY | |
| 361 | const pointer& __end_cap() const _NOEXCEPT | |
| 362 | {return __end_cap_.first();} | |
| 363 | ||
| 364 | _LIBCPP_INLINE_VISIBILITY | |
| 365 | __vector_base() | |
| 366 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); | |
| 367 | _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a); | |
| 368 | #ifndef _LIBCPP_CXX03_LANG | |
| 369 | _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT; | |
| 370 | #endif | |
| 371 | ~__vector_base(); | |
| 372 | ||
| 373 | _LIBCPP_INLINE_VISIBILITY | |
| 374 | void clear() _NOEXCEPT {__destruct_at_end(__begin_);} | |
| 375 | _LIBCPP_INLINE_VISIBILITY | |
| 376 | size_type capacity() const _NOEXCEPT | |
| 377 | {return static_cast<size_type>(__end_cap() - __begin_);} | |
| 378 | ||
| 379 | _LIBCPP_INLINE_VISIBILITY | |
| 380 | void __destruct_at_end(pointer __new_last) _NOEXCEPT; | |
| 381 | ||
| 382 | _LIBCPP_INLINE_VISIBILITY | |
| 383 | void __copy_assign_alloc(const __vector_base& __c) | |
| 384 | {__copy_assign_alloc(__c, integral_constant<bool, | |
| 385 | __alloc_traits::propagate_on_container_copy_assignment::value>());} | |
| 386 | ||
| 387 | _LIBCPP_INLINE_VISIBILITY | |
| 388 | void __move_assign_alloc(__vector_base& __c) | |
| 389 | _NOEXCEPT_( | |
| 390 | !__alloc_traits::propagate_on_container_move_assignment::value || | |
| 391 | is_nothrow_move_assignable<allocator_type>::value) | |
| 392 | {__move_assign_alloc(__c, integral_constant<bool, | |
| 393 | __alloc_traits::propagate_on_container_move_assignment::value>());} | |
| 394 | ||
| 395 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
| 396 | void __throw_length_error() const { | |
| 397 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 398 | __vector_base_common<true>::__throw_length_error(); | |
| 399 | #else | |
| 400 | _VSTD::abort(); | |
| 401 | #endif | |
| 402 | } | |
| 403 | ||
| 404 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
| 405 | void __throw_out_of_range() const { | |
| 406 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 407 | __vector_base_common<true>::__throw_out_of_range(); | |
| 408 | #else | |
| 409 | _VSTD::abort(); | |
| 410 | #endif | |
| 411 | } | |
| 412 | ||
| 413 | private: | |
| 414 | _LIBCPP_INLINE_VISIBILITY | |
| 415 | void __copy_assign_alloc(const __vector_base& __c, true_type) | |
| 416 | { | |
| 417 | if (__alloc() != __c.__alloc()) | |
| 418 | { | |
| 419 | clear(); | |
| 420 | __alloc_traits::deallocate(__alloc(), __begin_, capacity()); | |
| 421 | __begin_ = __end_ = __end_cap() = nullptr; | |
| 422 | } | |
| 423 | __alloc() = __c.__alloc(); | |
| 424 | } | |
| 425 | ||
| 426 | _LIBCPP_INLINE_VISIBILITY | |
| 427 | void __copy_assign_alloc(const __vector_base&, false_type) | |
| 428 | {} | |
| 429 | ||
| 430 | _LIBCPP_INLINE_VISIBILITY | |
| 431 | void __move_assign_alloc(__vector_base& __c, true_type) | |
| 432 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | |
| 433 | { | |
| 434 | __alloc() = _VSTD::move(__c.__alloc()); | |
| 435 | } | |
| 436 | ||
| 437 | _LIBCPP_INLINE_VISIBILITY | |
| 438 | void __move_assign_alloc(__vector_base&, false_type) | |
| 439 | _NOEXCEPT | |
| 440 | {} | |
| 441 | }; | |
| 442 | ||
| 443 | template <class _Tp, class _Allocator> | |
| 444 | inline _LIBCPP_INLINE_VISIBILITY | |
| 445 | void | |
| 446 | __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT | |
| 447 | { | |
| 448 | pointer __soon_to_be_end = __end_; | |
| 449 | while (__new_last != __soon_to_be_end) | |
| 450 | __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end)); | |
| 451 | __end_ = __new_last; | |
| 452 | } | |
| 453 | ||
| 454 | template <class _Tp, class _Allocator> | |
| 455 | inline _LIBCPP_INLINE_VISIBILITY | |
| 456 | __vector_base<_Tp, _Allocator>::__vector_base() | |
| 457 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) | |
| 458 | : __begin_(nullptr), | |
| 459 | __end_(nullptr), | |
| 460 | __end_cap_(nullptr, __default_init_tag()) | |
| 461 | { | |
| 462 | } | |
| 463 | ||
| 464 | template <class _Tp, class _Allocator> | |
| 465 | inline _LIBCPP_INLINE_VISIBILITY | |
| 466 | __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) | |
| 467 | : __begin_(nullptr), | |
| 468 | __end_(nullptr), | |
| 469 | __end_cap_(nullptr, __a) | |
| 470 | { | |
| 471 | } | |
| 472 | ||
| 473 | #ifndef _LIBCPP_CXX03_LANG | |
| 474 | template <class _Tp, class _Allocator> | |
| 475 | inline _LIBCPP_INLINE_VISIBILITY | |
| 476 | __vector_base<_Tp, _Allocator>::__vector_base(allocator_type&& __a) _NOEXCEPT | |
| 477 | : __begin_(nullptr), | |
| 478 | __end_(nullptr), | |
| 479 | __end_cap_(nullptr, _VSTD::move(__a)) {} | |
| 480 | #endif | |
| 481 | ||
| 482 | template <class _Tp, class _Allocator> | |
| 483 | __vector_base<_Tp, _Allocator>::~__vector_base() | |
| 484 | { | |
| 485 | if (__begin_ != nullptr) | |
| 486 | { | |
| 487 | clear(); | |
| 488 | __alloc_traits::deallocate(__alloc(), __begin_, capacity()); | |
| 489 | } | |
| 490 | } | |
| 491 | ||
| 492 | 305 | template <class _Tp, class _Allocator /* = allocator<_Tp> */> |
| 493 | 306 | class _LIBCPP_TEMPLATE_VIS vector |
| 494 | : private __vector_base<_Tp, _Allocator> | |
| 495 | 307 | { |
| 496 | 308 | private: |
| 497 | typedef __vector_base<_Tp, _Allocator> __base; | |
| 498 | typedef allocator<_Tp> __default_allocator_type; | |
| 309 | typedef allocator<_Tp> __default_allocator_type; | |
| 499 | 310 | public: |
| 500 | typedef vector __self; | |
| 501 | typedef _Tp value_type; | |
| 502 | typedef _Allocator allocator_type; | |
| 503 | typedef typename __base::__alloc_traits __alloc_traits; | |
| 504 | typedef typename __base::reference reference; | |
| 505 | typedef typename __base::const_reference const_reference; | |
| 506 | typedef typename __base::size_type size_type; | |
| 507 | typedef typename __base::difference_type difference_type; | |
| 508 | typedef typename __base::pointer pointer; | |
| 509 | typedef typename __base::const_pointer const_pointer; | |
| 510 | typedef __wrap_iter<pointer> iterator; | |
| 511 | typedef __wrap_iter<const_pointer> const_iterator; | |
| 512 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 513 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 311 | typedef vector __self; | |
| 312 | typedef _Tp value_type; | |
| 313 | typedef _Allocator allocator_type; | |
| 314 | typedef allocator_traits<allocator_type> __alloc_traits; | |
| 315 | typedef value_type& reference; | |
| 316 | typedef const value_type& const_reference; | |
| 317 | typedef typename __alloc_traits::size_type size_type; | |
| 318 | typedef typename __alloc_traits::difference_type difference_type; | |
| 319 | typedef typename __alloc_traits::pointer pointer; | |
| 320 | typedef typename __alloc_traits::const_pointer const_pointer; | |
| 321 | typedef __wrap_iter<pointer> iterator; | |
| 322 | typedef __wrap_iter<const_pointer> const_iterator; | |
| 323 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 324 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 514 | 325 | |
| 515 | 326 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 516 | 327 | "Allocator::value_type must be same type as value_type"); |
| 517 | 328 | |
| 518 | 329 | _LIBCPP_INLINE_VISIBILITY |
| 519 | 330 | vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 520 | { | |
| 521 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 522 | __get_db()->__insert_c(this); | |
| 523 | #endif | |
| 524 | } | |
| 331 | { | |
| 332 | _VSTD::__debug_db_insert_c(this); | |
| 333 | } | |
| 525 | 334 | _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) |
| 526 | 335 | #if _LIBCPP_STD_VER <= 14 |
| 527 | 336 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
| 528 | 337 | #else |
| 529 | 338 | _NOEXCEPT |
| 530 | 339 | #endif |
| 531 | : __base(__a) | |
| 340 | : __end_cap_(nullptr, __a) | |
| 532 | 341 | { |
| 533 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 534 | __get_db()->__insert_c(this); | |
| 535 | #endif | |
| 342 | _VSTD::__debug_db_insert_c(this); | |
| 536 | 343 | } |
| 537 | 344 | explicit vector(size_type __n); |
| 538 | 345 | #if _LIBCPP_STD_VER > 11 |
| 539 | 346 | explicit vector(size_type __n, const allocator_type& __a); |
| 540 | 347 | #endif |
| 541 | 348 | vector(size_type __n, const value_type& __x); |
| 542 | vector(size_type __n, const value_type& __x, const allocator_type& __a); | |
| 349 | ||
| 350 | template <class = __enable_if_t<__is_allocator<_Allocator>::value> > | |
| 351 | vector(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 352 | : __end_cap_(nullptr, __a) | |
| 353 | { | |
| 354 | _VSTD::__debug_db_insert_c(this); | |
| 355 | if (__n > 0) | |
| 356 | { | |
| 357 | __vallocate(__n); | |
| 358 | __construct_at_end(__n, __x); | |
| 359 | } | |
| 360 | } | |
| 361 | ||
| 543 | 362 | template <class _InputIterator> |
| 544 | 363 | vector(_InputIterator __first, |
| 545 | 364 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && |
| ... | ... | @@ -572,10 +391,16 @@ public: |
| 572 | 391 | _LIBCPP_INLINE_VISIBILITY |
| 573 | 392 | ~vector() |
| 574 | 393 | { |
| 575 | __annotate_delete(); | |
| 394 | __annotate_delete(); | |
| 576 | 395 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 577 | __get_db()->__erase_c(this); | |
| 396 | __get_db()->__erase_c(this); | |
| 578 | 397 | #endif |
| 398 | ||
| 399 | if (this->__begin_ != nullptr) | |
| 400 | { | |
| 401 | __clear(); | |
| 402 | __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); | |
| 403 | } | |
| 579 | 404 | } |
| 580 | 405 | |
| 581 | 406 | vector(const vector& __x); |
| ... | ... | @@ -680,7 +505,7 @@ public: |
| 680 | 505 | {return static_cast<size_type>(this->__end_ - this->__begin_);} |
| 681 | 506 | _LIBCPP_INLINE_VISIBILITY |
| 682 | 507 | size_type capacity() const _NOEXCEPT |
| 683 | {return __base::capacity();} | |
| 508 | {return static_cast<size_type>(__end_cap() - this->__begin_);} | |
| 684 | 509 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY |
| 685 | 510 | bool empty() const _NOEXCEPT |
| 686 | 511 | {return this->__begin_ == this->__end_;} |
| ... | ... | @@ -793,7 +618,7 @@ public: |
| 793 | 618 | void clear() _NOEXCEPT |
| 794 | 619 | { |
| 795 | 620 | size_type __old_size = size(); |
| 796 | __base::clear(); | |
| 621 | __clear(); | |
| 797 | 622 | __annotate_shrink(__old_size); |
| 798 | 623 | __invalidate_all_iterators(); |
| 799 | 624 | } |
| ... | ... | @@ -821,6 +646,11 @@ public: |
| 821 | 646 | #endif // _LIBCPP_DEBUG_LEVEL == 2 |
| 822 | 647 | |
| 823 | 648 | private: |
| 649 | pointer __begin_ = nullptr; | |
| 650 | pointer __end_ = nullptr; | |
| 651 | __compressed_pair<pointer, allocator_type> __end_cap_ = | |
| 652 | __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag()); | |
| 653 | ||
| 824 | 654 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); |
| 825 | 655 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); |
| 826 | 656 | void __vallocate(size_type __n); |
| ... | ... | @@ -854,7 +684,7 @@ private: |
| 854 | 684 | { |
| 855 | 685 | __invalidate_iterators_past(__new_last); |
| 856 | 686 | size_type __old_size = size(); |
| 857 | __base::__destruct_at_end(__new_last); | |
| 687 | __base_destruct_at_end(__new_last); | |
| 858 | 688 | __annotate_shrink(__old_size); |
| 859 | 689 | } |
| 860 | 690 | |
| ... | ... | @@ -918,7 +748,7 @@ private: |
| 918 | 748 | |
| 919 | 749 | struct _ConstructTransaction { |
| 920 | 750 | explicit _ConstructTransaction(vector &__v, size_type __n) |
| 921 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { | |
| 751 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { | |
| 922 | 752 | #ifndef _LIBCPP_HAS_NO_ASAN |
| 923 | 753 | __v_.__annotate_increase(__n); |
| 924 | 754 | #endif |
| ... | ... | @@ -949,19 +779,96 @@ private: |
| 949 | 779 | _VSTD::forward<_Args>(__args)...); |
| 950 | 780 | ++__tx.__pos_; |
| 951 | 781 | } |
| 782 | ||
| 783 | _LIBCPP_INLINE_VISIBILITY | |
| 784 | allocator_type& __alloc() _NOEXCEPT | |
| 785 | {return this->__end_cap_.second();} | |
| 786 | _LIBCPP_INLINE_VISIBILITY | |
| 787 | const allocator_type& __alloc() const _NOEXCEPT | |
| 788 | {return this->__end_cap_.second();} | |
| 789 | _LIBCPP_INLINE_VISIBILITY | |
| 790 | pointer& __end_cap() _NOEXCEPT | |
| 791 | {return this->__end_cap_.first();} | |
| 792 | _LIBCPP_INLINE_VISIBILITY | |
| 793 | const pointer& __end_cap() const _NOEXCEPT | |
| 794 | {return this->__end_cap_.first();} | |
| 795 | ||
| 796 | _LIBCPP_INLINE_VISIBILITY | |
| 797 | void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);} | |
| 798 | ||
| 799 | _LIBCPP_INLINE_VISIBILITY | |
| 800 | void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { | |
| 801 | pointer __soon_to_be_end = this->__end_; | |
| 802 | while (__new_last != __soon_to_be_end) | |
| 803 | __alloc_traits::destroy(__alloc(), _VSTD::__to_address(--__soon_to_be_end)); | |
| 804 | this->__end_ = __new_last; | |
| 805 | } | |
| 806 | ||
| 807 | _LIBCPP_INLINE_VISIBILITY | |
| 808 | void __copy_assign_alloc(const vector& __c) | |
| 809 | {__copy_assign_alloc(__c, integral_constant<bool, | |
| 810 | __alloc_traits::propagate_on_container_copy_assignment::value>());} | |
| 811 | ||
| 812 | _LIBCPP_INLINE_VISIBILITY | |
| 813 | void __move_assign_alloc(vector& __c) | |
| 814 | _NOEXCEPT_( | |
| 815 | !__alloc_traits::propagate_on_container_move_assignment::value || | |
| 816 | is_nothrow_move_assignable<allocator_type>::value) | |
| 817 | {__move_assign_alloc(__c, integral_constant<bool, | |
| 818 | __alloc_traits::propagate_on_container_move_assignment::value>());} | |
| 819 | ||
| 820 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
| 821 | void __throw_length_error() const { | |
| 822 | _VSTD::__throw_length_error("vector"); | |
| 823 | } | |
| 824 | ||
| 825 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
| 826 | void __throw_out_of_range() const { | |
| 827 | _VSTD::__throw_out_of_range("vector"); | |
| 828 | } | |
| 829 | ||
| 830 | _LIBCPP_INLINE_VISIBILITY | |
| 831 | void __copy_assign_alloc(const vector& __c, true_type) | |
| 832 | { | |
| 833 | if (__alloc() != __c.__alloc()) | |
| 834 | { | |
| 835 | __clear(); | |
| 836 | __alloc_traits::deallocate(__alloc(), this->__begin_, capacity()); | |
| 837 | this->__begin_ = this->__end_ = __end_cap() = nullptr; | |
| 838 | } | |
| 839 | __alloc() = __c.__alloc(); | |
| 840 | } | |
| 841 | ||
| 842 | _LIBCPP_INLINE_VISIBILITY | |
| 843 | void __copy_assign_alloc(const vector&, false_type) | |
| 844 | {} | |
| 845 | ||
| 846 | _LIBCPP_INLINE_VISIBILITY | |
| 847 | void __move_assign_alloc(vector& __c, true_type) | |
| 848 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) | |
| 849 | { | |
| 850 | __alloc() = _VSTD::move(__c.__alloc()); | |
| 851 | } | |
| 852 | ||
| 853 | _LIBCPP_INLINE_VISIBILITY | |
| 854 | void __move_assign_alloc(vector&, false_type) | |
| 855 | _NOEXCEPT | |
| 856 | {} | |
| 952 | 857 | }; |
| 953 | 858 | |
| 954 | #ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES | |
| 859 | #if _LIBCPP_STD_VER >= 17 | |
| 955 | 860 | template<class _InputIterator, |
| 956 | 861 | class _Alloc = allocator<__iter_value_type<_InputIterator>>, |
| 957 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 862 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 863 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 958 | 864 | > |
| 959 | 865 | vector(_InputIterator, _InputIterator) |
| 960 | 866 | -> vector<__iter_value_type<_InputIterator>, _Alloc>; |
| 961 | 867 | |
| 962 | 868 | template<class _InputIterator, |
| 963 | 869 | class _Alloc, |
| 964 | class = _EnableIf<__is_allocator<_Alloc>::value> | |
| 870 | class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, | |
| 871 | class = enable_if_t<__is_allocator<_Alloc>::value> | |
| 965 | 872 | > |
| 966 | 873 | vector(_InputIterator, _InputIterator, _Alloc) |
| 967 | 874 | -> vector<__iter_value_type<_InputIterator>, _Alloc>; |
| ... | ... | @@ -1063,7 +970,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 1063 | 970 | { |
| 1064 | 971 | _ConstructTransaction __tx(*this, __n); |
| 1065 | 972 | const_pointer __new_end = __tx.__new_end_; |
| 1066 | for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) { | |
| 973 | for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { | |
| 1067 | 974 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos)); |
| 1068 | 975 | } |
| 1069 | 976 | } |
| ... | ... | @@ -1081,7 +988,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
| 1081 | 988 | { |
| 1082 | 989 | _ConstructTransaction __tx(*this, __n); |
| 1083 | 990 | const_pointer __new_end = __tx.__new_end_; |
| 1084 | for (pointer __pos = __tx.__pos_; __pos != __new_end; ++__pos, __tx.__pos_ = __pos) { | |
| 991 | for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) { | |
| 1085 | 992 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__pos), __x); |
| 1086 | 993 | } |
| 1087 | 994 | } |
| ... | ... | @@ -1140,9 +1047,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) |
| 1140 | 1047 | template <class _Tp, class _Allocator> |
| 1141 | 1048 | vector<_Tp, _Allocator>::vector(size_type __n) |
| 1142 | 1049 | { |
| 1143 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1144 | __get_db()->__insert_c(this); | |
| 1145 | #endif | |
| 1050 | _VSTD::__debug_db_insert_c(this); | |
| 1146 | 1051 | if (__n > 0) |
| 1147 | 1052 | { |
| 1148 | 1053 | __vallocate(__n); |
| ... | ... | @@ -1153,11 +1058,9 @@ vector<_Tp, _Allocator>::vector(size_type __n) |
| 1153 | 1058 | #if _LIBCPP_STD_VER > 11 |
| 1154 | 1059 | template <class _Tp, class _Allocator> |
| 1155 | 1060 | vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) |
| 1156 | : __base(__a) | |
| 1061 | : __end_cap_(nullptr, __a) | |
| 1157 | 1062 | { |
| 1158 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1159 | __get_db()->__insert_c(this); | |
| 1160 | #endif | |
| 1063 | _VSTD::__debug_db_insert_c(this); | |
| 1161 | 1064 | if (__n > 0) |
| 1162 | 1065 | { |
| 1163 | 1066 | __vallocate(__n); |
| ... | ... | @@ -1169,23 +1072,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) |
| 1169 | 1072 | template <class _Tp, class _Allocator> |
| 1170 | 1073 | vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) |
| 1171 | 1074 | { |
| 1172 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1173 | __get_db()->__insert_c(this); | |
| 1174 | #endif | |
| 1175 | if (__n > 0) | |
| 1176 | { | |
| 1177 | __vallocate(__n); | |
| 1178 | __construct_at_end(__n, __x); | |
| 1179 | } | |
| 1180 | } | |
| 1181 | ||
| 1182 | template <class _Tp, class _Allocator> | |
| 1183 | vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) | |
| 1184 | : __base(__a) | |
| 1185 | { | |
| 1186 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1187 | __get_db()->__insert_c(this); | |
| 1188 | #endif | |
| 1075 | _VSTD::__debug_db_insert_c(this); | |
| 1189 | 1076 | if (__n > 0) |
| 1190 | 1077 | { |
| 1191 | 1078 | __vallocate(__n); |
| ... | ... | @@ -1203,9 +1090,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, |
| 1203 | 1090 | typename iterator_traits<_InputIterator>::reference>::value, |
| 1204 | 1091 | _InputIterator>::type __last) |
| 1205 | 1092 | { |
| 1206 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1207 | __get_db()->__insert_c(this); | |
| 1208 | #endif | |
| 1093 | _VSTD::__debug_db_insert_c(this); | |
| 1209 | 1094 | for (; __first != __last; ++__first) |
| 1210 | 1095 | __emplace_back(*__first); |
| 1211 | 1096 | } |
| ... | ... | @@ -1218,11 +1103,9 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c |
| 1218 | 1103 | is_constructible< |
| 1219 | 1104 | value_type, |
| 1220 | 1105 | typename iterator_traits<_InputIterator>::reference>::value>::type*) |
| 1221 | : __base(__a) | |
| 1106 | : __end_cap_(nullptr, __a) | |
| 1222 | 1107 | { |
| 1223 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1224 | __get_db()->__insert_c(this); | |
| 1225 | #endif | |
| 1108 | _VSTD::__debug_db_insert_c(this); | |
| 1226 | 1109 | for (; __first != __last; ++__first) |
| 1227 | 1110 | __emplace_back(*__first); |
| 1228 | 1111 | } |
| ... | ... | @@ -1236,9 +1119,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, |
| 1236 | 1119 | typename iterator_traits<_ForwardIterator>::reference>::value, |
| 1237 | 1120 | _ForwardIterator>::type __last) |
| 1238 | 1121 | { |
| 1239 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1240 | __get_db()->__insert_c(this); | |
| 1241 | #endif | |
| 1122 | _VSTD::__debug_db_insert_c(this); | |
| 1242 | 1123 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); |
| 1243 | 1124 | if (__n > 0) |
| 1244 | 1125 | { |
| ... | ... | @@ -1254,11 +1135,9 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las |
| 1254 | 1135 | is_constructible< |
| 1255 | 1136 | value_type, |
| 1256 | 1137 | typename iterator_traits<_ForwardIterator>::reference>::value>::type*) |
| 1257 | : __base(__a) | |
| 1138 | : __end_cap_(nullptr, __a) | |
| 1258 | 1139 | { |
| 1259 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1260 | __get_db()->__insert_c(this); | |
| 1261 | #endif | |
| 1140 | _VSTD::__debug_db_insert_c(this); | |
| 1262 | 1141 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); |
| 1263 | 1142 | if (__n > 0) |
| 1264 | 1143 | { |
| ... | ... | @@ -1269,11 +1148,9 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las |
| 1269 | 1148 | |
| 1270 | 1149 | template <class _Tp, class _Allocator> |
| 1271 | 1150 | vector<_Tp, _Allocator>::vector(const vector& __x) |
| 1272 | : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) | |
| 1151 | : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) | |
| 1273 | 1152 | { |
| 1274 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1275 | __get_db()->__insert_c(this); | |
| 1276 | #endif | |
| 1153 | _VSTD::__debug_db_insert_c(this); | |
| 1277 | 1154 | size_type __n = __x.size(); |
| 1278 | 1155 | if (__n > 0) |
| 1279 | 1156 | { |
| ... | ... | @@ -1284,11 +1161,9 @@ vector<_Tp, _Allocator>::vector(const vector& __x) |
| 1284 | 1161 | |
| 1285 | 1162 | template <class _Tp, class _Allocator> |
| 1286 | 1163 | vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a) |
| 1287 | : __base(__a) | |
| 1164 | : __end_cap_(nullptr, __a) | |
| 1288 | 1165 | { |
| 1289 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1290 | __get_db()->__insert_c(this); | |
| 1291 | #endif | |
| 1166 | _VSTD::__debug_db_insert_c(this); | |
| 1292 | 1167 | size_type __n = __x.size(); |
| 1293 | 1168 | if (__n > 0) |
| 1294 | 1169 | { |
| ... | ... | @@ -1307,11 +1182,11 @@ vector<_Tp, _Allocator>::vector(vector&& __x) |
| 1307 | 1182 | #else |
| 1308 | 1183 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 1309 | 1184 | #endif |
| 1310 | : __base(_VSTD::move(__x.__alloc())) | |
| 1185 | : __end_cap_(nullptr, _VSTD::move(__x.__alloc())) | |
| 1311 | 1186 | { |
| 1187 | _VSTD::__debug_db_insert_c(this); | |
| 1312 | 1188 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1313 | __get_db()->__insert_c(this); | |
| 1314 | __get_db()->swap(this, &__x); | |
| 1189 | __get_db()->swap(this, _VSTD::addressof(__x)); | |
| 1315 | 1190 | #endif |
| 1316 | 1191 | this->__begin_ = __x.__begin_; |
| 1317 | 1192 | this->__end_ = __x.__end_; |
| ... | ... | @@ -1322,11 +1197,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x) |
| 1322 | 1197 | template <class _Tp, class _Allocator> |
| 1323 | 1198 | inline _LIBCPP_INLINE_VISIBILITY |
| 1324 | 1199 | vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a) |
| 1325 | : __base(__a) | |
| 1200 | : __end_cap_(nullptr, __a) | |
| 1326 | 1201 | { |
| 1327 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1328 | __get_db()->__insert_c(this); | |
| 1329 | #endif | |
| 1202 | _VSTD::__debug_db_insert_c(this); | |
| 1330 | 1203 | if (__a == __x.__alloc()) |
| 1331 | 1204 | { |
| 1332 | 1205 | this->__begin_ = __x.__begin_; |
| ... | ... | @@ -1334,7 +1207,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type> |
| 1334 | 1207 | this->__end_cap() = __x.__end_cap(); |
| 1335 | 1208 | __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; |
| 1336 | 1209 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1337 | __get_db()->swap(this, &__x); | |
| 1210 | __get_db()->swap(this, _VSTD::addressof(__x)); | |
| 1338 | 1211 | #endif |
| 1339 | 1212 | } |
| 1340 | 1213 | else |
| ... | ... | @@ -1348,9 +1221,7 @@ template <class _Tp, class _Allocator> |
| 1348 | 1221 | inline _LIBCPP_INLINE_VISIBILITY |
| 1349 | 1222 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) |
| 1350 | 1223 | { |
| 1351 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1352 | __get_db()->__insert_c(this); | |
| 1353 | #endif | |
| 1224 | _VSTD::__debug_db_insert_c(this); | |
| 1354 | 1225 | if (__il.size() > 0) |
| 1355 | 1226 | { |
| 1356 | 1227 | __vallocate(__il.size()); |
| ... | ... | @@ -1361,11 +1232,9 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) |
| 1361 | 1232 | template <class _Tp, class _Allocator> |
| 1362 | 1233 | inline _LIBCPP_INLINE_VISIBILITY |
| 1363 | 1234 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) |
| 1364 | : __base(__a) | |
| 1235 | : __end_cap_(nullptr, __a) | |
| 1365 | 1236 | { |
| 1366 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1367 | __get_db()->__insert_c(this); | |
| 1368 | #endif | |
| 1237 | _VSTD::__debug_db_insert_c(this); | |
| 1369 | 1238 | if (__il.size() > 0) |
| 1370 | 1239 | { |
| 1371 | 1240 | __vallocate(__il.size()); |
| ... | ... | @@ -1389,7 +1258,7 @@ void |
| 1389 | 1258 | vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) |
| 1390 | 1259 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) |
| 1391 | 1260 | { |
| 1392 | if (__base::__alloc() != __c.__alloc()) | |
| 1261 | if (__alloc() != __c.__alloc()) | |
| 1393 | 1262 | { |
| 1394 | 1263 | typedef move_iterator<iterator> _Ip; |
| 1395 | 1264 | assign(_Ip(__c.begin()), _Ip(__c.end())); |
| ... | ... | @@ -1404,13 +1273,13 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) |
| 1404 | 1273 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| 1405 | 1274 | { |
| 1406 | 1275 | __vdeallocate(); |
| 1407 | __base::__move_assign_alloc(__c); // this can throw | |
| 1276 | __move_assign_alloc(__c); // this can throw | |
| 1408 | 1277 | this->__begin_ = __c.__begin_; |
| 1409 | 1278 | this->__end_ = __c.__end_; |
| 1410 | 1279 | this->__end_cap() = __c.__end_cap(); |
| 1411 | 1280 | __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; |
| 1412 | 1281 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 1413 | __get_db()->swap(this, &__c); | |
| 1282 | __get_db()->swap(this, _VSTD::addressof(__c)); | |
| 1414 | 1283 | #endif |
| 1415 | 1284 | } |
| 1416 | 1285 | |
| ... | ... | @@ -1421,9 +1290,9 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 1421 | 1290 | vector<_Tp, _Allocator>& |
| 1422 | 1291 | vector<_Tp, _Allocator>::operator=(const vector& __x) |
| 1423 | 1292 | { |
| 1424 | if (this != &__x) | |
| 1293 | if (this != _VSTD::addressof(__x)) | |
| 1425 | 1294 | { |
| 1426 | __base::__copy_assign_alloc(__x); | |
| 1295 | __copy_assign_alloc(__x); | |
| 1427 | 1296 | assign(__x.__begin_, __x.__end_); |
| 1428 | 1297 | } |
| 1429 | 1298 | return *this; |
| ... | ... | @@ -1605,6 +1474,8 @@ vector<_Tp, _Allocator>::reserve(size_type __n) |
| 1605 | 1474 | { |
| 1606 | 1475 | if (__n > capacity()) |
| 1607 | 1476 | { |
| 1477 | if (__n > max_size()) | |
| 1478 | this->__throw_length_error(); | |
| 1608 | 1479 | allocator_type& __a = this->__alloc(); |
| 1609 | 1480 | __split_buffer<value_type, allocator_type&> __v(__n, size(), __a); |
| 1610 | 1481 | __swap_out_circular_buffer(__v); |
| ... | ... | @@ -1728,11 +1599,8 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 1728 | 1599 | typename vector<_Tp, _Allocator>::iterator |
| 1729 | 1600 | vector<_Tp, _Allocator>::erase(const_iterator __position) |
| 1730 | 1601 | { |
| 1731 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1732 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 1733 | "vector::erase(iterator) called with an iterator not" | |
| 1734 | " referring to this vector"); | |
| 1735 | #endif | |
| 1602 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, | |
| 1603 | "vector::erase(iterator) called with an iterator not referring to this vector"); | |
| 1736 | 1604 | _LIBCPP_ASSERT(__position != end(), |
| 1737 | 1605 | "vector::erase(iterator) called with a non-dereferenceable iterator"); |
| 1738 | 1606 | difference_type __ps = __position - cbegin(); |
| ... | ... | @@ -1747,14 +1615,11 @@ template <class _Tp, class _Allocator> |
| 1747 | 1615 | typename vector<_Tp, _Allocator>::iterator |
| 1748 | 1616 | vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 1749 | 1617 | { |
| 1750 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1751 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, | |
| 1752 | "vector::erase(iterator, iterator) called with an iterator not" | |
| 1753 | " referring to this vector"); | |
| 1754 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, | |
| 1755 | "vector::erase(iterator, iterator) called with an iterator not" | |
| 1756 | " referring to this vector"); | |
| 1757 | #endif | |
| 1618 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__first)) == this, | |
| 1619 | "vector::erase(iterator, iterator) called with an iterator not referring to this vector"); | |
| 1620 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__last)) == this, | |
| 1621 | "vector::erase(iterator, iterator) called with an iterator not referring to this vector"); | |
| 1622 | ||
| 1758 | 1623 | _LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range"); |
| 1759 | 1624 | pointer __p = this->__begin_ + (__first - begin()); |
| 1760 | 1625 | if (__first != __last) { |
| ... | ... | @@ -1775,7 +1640,7 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe |
| 1775 | 1640 | pointer __i = __from_s + __n; |
| 1776 | 1641 | _ConstructTransaction __tx(*this, __from_e - __i); |
| 1777 | 1642 | for (pointer __pos = __tx.__pos_; __i < __from_e; |
| 1778 | ++__i, ++__pos, __tx.__pos_ = __pos) { | |
| 1643 | ++__i, (void) ++__pos, __tx.__pos_ = __pos) { | |
| 1779 | 1644 | __alloc_traits::construct(this->__alloc(), |
| 1780 | 1645 | _VSTD::__to_address(__pos), |
| 1781 | 1646 | _VSTD::move(*__i)); |
| ... | ... | @@ -1788,11 +1653,8 @@ template <class _Tp, class _Allocator> |
| 1788 | 1653 | typename vector<_Tp, _Allocator>::iterator |
| 1789 | 1654 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) |
| 1790 | 1655 | { |
| 1791 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1792 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 1793 | "vector::insert(iterator, x) called with an iterator not" | |
| 1794 | " referring to this vector"); | |
| 1795 | #endif | |
| 1656 | _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"); | |
| 1796 | 1658 | pointer __p = this->__begin_ + (__position - begin()); |
| 1797 | 1659 | if (this->__end_ < this->__end_cap()) |
| 1798 | 1660 | { |
| ... | ... | @@ -1825,11 +1687,8 @@ template <class _Tp, class _Allocator> |
| 1825 | 1687 | typename vector<_Tp, _Allocator>::iterator |
| 1826 | 1688 | vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) |
| 1827 | 1689 | { |
| 1828 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1829 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 1830 | "vector::insert(iterator, x) called with an iterator not" | |
| 1831 | " referring to this vector"); | |
| 1832 | #endif | |
| 1690 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, | |
| 1691 | "vector::insert(iterator, x) called with an iterator not referring to this vector"); | |
| 1833 | 1692 | pointer __p = this->__begin_ + (__position - begin()); |
| 1834 | 1693 | if (this->__end_ < this->__end_cap()) |
| 1835 | 1694 | { |
| ... | ... | @@ -1858,11 +1717,8 @@ template <class... _Args> |
| 1858 | 1717 | typename vector<_Tp, _Allocator>::iterator |
| 1859 | 1718 | vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) |
| 1860 | 1719 | { |
| 1861 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1862 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 1863 | "vector::emplace(iterator, x) called with an iterator not" | |
| 1864 | " referring to this vector"); | |
| 1865 | #endif | |
| 1720 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, | |
| 1721 | "vector::emplace(iterator, x) called with an iterator not referring to this vector"); | |
| 1866 | 1722 | pointer __p = this->__begin_ + (__position - begin()); |
| 1867 | 1723 | if (this->__end_ < this->__end_cap()) |
| 1868 | 1724 | { |
| ... | ... | @@ -1893,11 +1749,8 @@ template <class _Tp, class _Allocator> |
| 1893 | 1749 | typename vector<_Tp, _Allocator>::iterator |
| 1894 | 1750 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) |
| 1895 | 1751 | { |
| 1896 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1897 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 1898 | "vector::insert(iterator, n, x) called with an iterator not" | |
| 1899 | " referring to this vector"); | |
| 1900 | #endif | |
| 1752 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, | |
| 1753 | "vector::insert(iterator, n, x) called with an iterator not referring to this vector"); | |
| 1901 | 1754 | pointer __p = this->__begin_ + (__position - begin()); |
| 1902 | 1755 | if (__n > 0) |
| 1903 | 1756 | { |
| ... | ... | @@ -1944,11 +1797,8 @@ typename enable_if |
| 1944 | 1797 | >::type |
| 1945 | 1798 | vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) |
| 1946 | 1799 | { |
| 1947 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1948 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 1949 | "vector::insert(iterator, range) called with an iterator not" | |
| 1950 | " referring to this vector"); | |
| 1951 | #endif | |
| 1800 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, | |
| 1801 | "vector::insert(iterator, range) called with an iterator not referring to this vector"); | |
| 1952 | 1802 | difference_type __off = __position - begin(); |
| 1953 | 1803 | pointer __p = this->__begin_ + __off; |
| 1954 | 1804 | allocator_type& __a = this->__alloc(); |
| ... | ... | @@ -1997,11 +1847,8 @@ typename enable_if |
| 1997 | 1847 | >::type |
| 1998 | 1848 | vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) |
| 1999 | 1849 | { |
| 2000 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2001 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__position) == this, | |
| 2002 | "vector::insert(iterator, range) called with an iterator not" | |
| 2003 | " referring to this vector"); | |
| 2004 | #endif | |
| 1850 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, | |
| 1851 | "vector::insert(iterator, range) called with an iterator not referring to this vector"); | |
| 2005 | 1852 | pointer __p = this->__begin_ + (__position - begin()); |
| 2006 | 1853 | difference_type __n = _VSTD::distance(__first, __last); |
| 2007 | 1854 | if (__n > 0) |
| ... | ... | @@ -2079,7 +1926,7 @@ vector<_Tp, _Allocator>::swap(vector& __x) |
| 2079 | 1926 | _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(), |
| 2080 | 1927 | integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); |
| 2081 | 1928 | #if _LIBCPP_DEBUG_LEVEL == 2 |
| 2082 | __get_db()->swap(this, &__x); | |
| 1929 | __get_db()->swap(this, _VSTD::addressof(__x)); | |
| 2083 | 1930 | #endif |
| 2084 | 1931 | } |
| 2085 | 1932 | |
| ... | ... | @@ -2184,7 +2031,6 @@ struct __has_storage_type<vector<bool, _Allocator> > |
| 2184 | 2031 | |
| 2185 | 2032 | template <class _Allocator> |
| 2186 | 2033 | class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> |
| 2187 | : private __vector_base_common<true> | |
| 2188 | 2034 | { |
| 2189 | 2035 | public: |
| 2190 | 2036 | typedef vector __self; |
| ... | ... | @@ -2453,6 +2299,16 @@ public: |
| 2453 | 2299 | bool __invariants() const; |
| 2454 | 2300 | |
| 2455 | 2301 | private: |
| 2302 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
| 2303 | void __throw_length_error() const { | |
| 2304 | _VSTD::__throw_length_error("vector"); | |
| 2305 | } | |
| 2306 | ||
| 2307 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI | |
| 2308 | void __throw_out_of_range() const { | |
| 2309 | _VSTD::__throw_out_of_range("vector"); | |
| 2310 | } | |
| 2311 | ||
| 2456 | 2312 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); |
| 2457 | 2313 | void __vallocate(size_type __n); |
| 2458 | 2314 | void __vdeallocate() _NOEXCEPT; |
| ... | ... | @@ -2874,7 +2730,7 @@ template <class _Allocator> |
| 2874 | 2730 | vector<bool, _Allocator>& |
| 2875 | 2731 | vector<bool, _Allocator>::operator=(const vector& __v) |
| 2876 | 2732 | { |
| 2877 | if (this != &__v) | |
| 2733 | if (this != _VSTD::addressof(__v)) | |
| 2878 | 2734 | { |
| 2879 | 2735 | __copy_assign_alloc(__v); |
| 2880 | 2736 | if (__v.__size_) |
| ... | ... | @@ -2978,7 +2834,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) |
| 2978 | 2834 | __size_ = __n; |
| 2979 | 2835 | else |
| 2980 | 2836 | { |
| 2981 | vector __v(__alloc()); | |
| 2837 | vector __v(get_allocator()); | |
| 2982 | 2838 | __v.reserve(__recommend(__n)); |
| 2983 | 2839 | __v.__size_ = __n; |
| 2984 | 2840 | swap(__v); |
| ... | ... | @@ -3033,7 +2889,9 @@ vector<bool, _Allocator>::reserve(size_type __n) |
| 3033 | 2889 | { |
| 3034 | 2890 | if (__n > capacity()) |
| 3035 | 2891 | { |
| 3036 | vector __v(this->__alloc()); | |
| 2892 | if (__n > max_size()) | |
| 2893 | this->__throw_length_error(); | |
| 2894 | vector __v(this->get_allocator()); | |
| 3037 | 2895 | __v.__vallocate(__n); |
| 3038 | 2896 | __v.__construct_at_end(this->begin(), this->end()); |
| 3039 | 2897 | swap(__v); |
| ... | ... | @@ -3103,7 +2961,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __ |
| 3103 | 2961 | } |
| 3104 | 2962 | else |
| 3105 | 2963 | { |
| 3106 | vector __v(__alloc()); | |
| 2964 | vector __v(get_allocator()); | |
| 3107 | 2965 | __v.reserve(__recommend(__size_ + 1)); |
| 3108 | 2966 | __v.__size_ = __size_ + 1; |
| 3109 | 2967 | __r = _VSTD::copy(cbegin(), __position, __v.begin()); |
| ... | ... | @@ -3129,7 +2987,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const |
| 3129 | 2987 | } |
| 3130 | 2988 | else |
| 3131 | 2989 | { |
| 3132 | vector __v(__alloc()); | |
| 2990 | vector __v(get_allocator()); | |
| 3133 | 2991 | __v.reserve(__recommend(__size_ + __n)); |
| 3134 | 2992 | __v.__size_ = __size_ + __n; |
| 3135 | 2993 | __r = _VSTD::copy(cbegin(), __position, __v.begin()); |
| ... | ... | @@ -3158,7 +3016,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir |
| 3158 | 3016 | ++this->__size_; |
| 3159 | 3017 | back() = *__first; |
| 3160 | 3018 | } |
| 3161 | vector __v(__alloc()); | |
| 3019 | vector __v(get_allocator()); | |
| 3162 | 3020 | if (__first != __last) |
| 3163 | 3021 | { |
| 3164 | 3022 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| ... | ... | @@ -3208,7 +3066,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f |
| 3208 | 3066 | } |
| 3209 | 3067 | else |
| 3210 | 3068 | { |
| 3211 | vector __v(__alloc()); | |
| 3069 | vector __v(get_allocator()); | |
| 3212 | 3070 | __v.reserve(__recommend(__size_ + __n)); |
| 3213 | 3071 | __v.__size_ = __size_ + __n; |
| 3214 | 3072 | __r = _VSTD::copy(cbegin(), __position, __v.begin()); |
| ... | ... | @@ -3275,7 +3133,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x) |
| 3275 | 3133 | } |
| 3276 | 3134 | else |
| 3277 | 3135 | { |
| 3278 | vector __v(__alloc()); | |
| 3136 | vector __v(get_allocator()); | |
| 3279 | 3137 | __v.reserve(__recommend(__size_ + __n)); |
| 3280 | 3138 | __v.__size_ = __size_ + __n; |
| 3281 | 3139 | __r = _VSTD::copy(cbegin(), cend(), __v.begin()); |
lib/libcxx/include/version+48-41| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- version ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -14,7 +14,9 @@ |
| 14 | 14 | version synopsis |
| 15 | 15 | |
| 16 | 16 | Macro name Value Headers |
| 17 | __cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack> | |
| 17 | 18 | __cpp_lib_addressof_constexpr 201603L <memory> |
| 19 | __cpp_lib_allocate_at_least 202106L <memory> | |
| 18 | 20 | __cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list> |
| 19 | 21 | <map> <memory> <scoped_allocator> |
| 20 | 22 | <set> <string> <unordered_map> |
| ... | ... | @@ -24,6 +26,8 @@ __cpp_lib_apply 201603L <tuple> |
| 24 | 26 | __cpp_lib_array_constexpr 201811L <array> <iterator> |
| 25 | 27 | 201603L // C++17 |
| 26 | 28 | __cpp_lib_as_const 201510L <utility> |
| 29 | __cpp_lib_associative_heterogeneous_erasure 202110L <map> <set> <unordered_map> | |
| 30 | <unordered_set> | |
| 27 | 31 | __cpp_lib_assume_aligned 201811L <memory> |
| 28 | 32 | __cpp_lib_atomic_flag_test 201907L <atomic> |
| 29 | 33 | __cpp_lib_atomic_float 201711L <atomic> |
| ... | ... | @@ -41,6 +45,7 @@ __cpp_lib_bool_constant 201505L <type_traits> |
| 41 | 45 | __cpp_lib_bounded_array_traits 201902L <type_traits> |
| 42 | 46 | __cpp_lib_boyer_moore_searcher 201603L <functional> |
| 43 | 47 | __cpp_lib_byte 201603L <cstddef> |
| 48 | __cpp_lib_byteswap 202110L <bit> | |
| 44 | 49 | __cpp_lib_char8_t 201811L <atomic> <filesystem> <istream> |
| 45 | 50 | <limits> <locale> <ostream> |
| 46 | 51 | <string> <string_view> |
| ... | ... | @@ -59,6 +64,7 @@ __cpp_lib_constexpr_numeric 201911L <numeric> |
| 59 | 64 | __cpp_lib_constexpr_string 201811L <string> |
| 60 | 65 | __cpp_lib_constexpr_string_view 201811L <string_view> |
| 61 | 66 | __cpp_lib_constexpr_tuple 201811L <tuple> |
| 67 | __cpp_lib_constexpr_typeinfo 202106L <typeinfo> | |
| 62 | 68 | __cpp_lib_constexpr_utility 201811L <utility> |
| 63 | 69 | __cpp_lib_constexpr_vector 201907L <vector> |
| 64 | 70 | __cpp_lib_coroutine 201902L <coroutine> |
| ... | ... | @@ -72,7 +78,7 @@ __cpp_lib_exchange_function 201304L <utility> |
| 72 | 78 | __cpp_lib_execution 201902L <execution> |
| 73 | 79 | 201603L // C++17 |
| 74 | 80 | __cpp_lib_filesystem 201703L <filesystem> |
| 75 | __cpp_lib_format 201907L <format> | |
| 81 | __cpp_lib_format 202106L <format> | |
| 76 | 82 | __cpp_lib_gcd_lcm 201606L <numeric> |
| 77 | 83 | __cpp_lib_generic_associative_lookup 201304L <map> <set> |
| 78 | 84 | __cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set> |
| ... | ... | @@ -86,6 +92,7 @@ __cpp_lib_integer_sequence 201304L <utility> |
| 86 | 92 | __cpp_lib_integral_constant_callable 201304L <type_traits> |
| 87 | 93 | __cpp_lib_interpolate 201902L <cmath> <numeric> |
| 88 | 94 | __cpp_lib_invoke 201411L <functional> |
| 95 | __cpp_lib_invoke_r 202106L <functional> | |
| 89 | 96 | __cpp_lib_is_aggregate 201703L <type_traits> |
| 90 | 97 | __cpp_lib_is_constant_evaluated 201811L <type_traits> |
| 91 | 98 | __cpp_lib_is_final 201402L <type_traits> |
| ... | ... | @@ -108,6 +115,8 @@ __cpp_lib_map_try_emplace 201411L <map> |
| 108 | 115 | __cpp_lib_math_constants 201907L <numbers> |
| 109 | 116 | __cpp_lib_math_special_functions 201603L <cmath> |
| 110 | 117 | __cpp_lib_memory_resource 201603L <memory_resource> |
| 118 | __cpp_lib_monadic_optional 202110L <optional> | |
| 119 | __cpp_lib_move_only_function 202110L <functional> | |
| 111 | 120 | __cpp_lib_node_extract 201606L <map> <set> <unordered_map> |
| 112 | 121 | <unordered_set> |
| 113 | 122 | __cpp_lib_nonmember_container_access 201411L <array> <deque> <forward_list> |
| ... | ... | @@ -117,11 +126,14 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque> |
| 117 | 126 | __cpp_lib_not_fn 201603L <functional> |
| 118 | 127 | __cpp_lib_null_iterators 201304L <iterator> |
| 119 | 128 | __cpp_lib_optional 201606L <optional> |
| 129 | __cpp_lib_out_ptr 202106L <memory> | |
| 120 | 130 | __cpp_lib_parallel_algorithm 201603L <algorithm> <numeric> |
| 121 | __cpp_lib_polymorphic_allocator 201902L <memory> | |
| 131 | __cpp_lib_polymorphic_allocator 201902L <memory_resource> | |
| 122 | 132 | __cpp_lib_quoted_string_io 201304L <iomanip> |
| 123 | 133 | __cpp_lib_ranges 201811L <algorithm> <functional> <iterator> |
| 124 | 134 | <memory> <ranges> |
| 135 | __cpp_lib_ranges_starts_ends_with 202106L <algorithm> | |
| 136 | __cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility> | |
| 125 | 137 | __cpp_lib_raw_memory_algorithms 201606L <memory> |
| 126 | 138 | __cpp_lib_remove_cvref 201711L <type_traits> |
| 127 | 139 | __cpp_lib_result_of_sfinae 201210L <functional> <type_traits> |
| ... | ... | @@ -137,11 +149,13 @@ __cpp_lib_shift 201806L <algorithm> |
| 137 | 149 | __cpp_lib_smart_ptr_for_overwrite 202002L <memory> |
| 138 | 150 | __cpp_lib_source_location 201907L <source_location> |
| 139 | 151 | __cpp_lib_span 202002L <span> |
| 152 | __cpp_lib_spanstream 202106L <spanstream> | |
| 140 | 153 | __cpp_lib_ssize 201902L <iterator> |
| 141 | 154 | __cpp_lib_stacktrace 202011L <stacktrace> |
| 142 | 155 | __cpp_lib_starts_ends_with 201711L <string> <string_view> |
| 143 | 156 | __cpp_lib_stdatomic_h 202011L <stdatomic.h> |
| 144 | 157 | __cpp_lib_string_contains 202011L <string> <string_view> |
| 158 | __cpp_lib_string_resize_and_overwrite 202110L <string> | |
| 145 | 159 | __cpp_lib_string_udls 201304L <string> |
| 146 | 160 | __cpp_lib_string_view 201803L <string> <string_view> |
| 147 | 161 | 201606L // C++17 |
| ... | ... | @@ -149,13 +163,14 @@ __cpp_lib_syncbuf 201803L <syncstream> |
| 149 | 163 | __cpp_lib_three_way_comparison 201907L <compare> |
| 150 | 164 | __cpp_lib_to_address 201711L <memory> |
| 151 | 165 | __cpp_lib_to_array 201907L <array> |
| 152 | __cpp_lib_to_chars 201611L <utility> | |
| 166 | __cpp_lib_to_chars 201611L <charconv> | |
| 153 | 167 | __cpp_lib_to_underlying 202102L <utility> |
| 154 | 168 | __cpp_lib_transformation_trait_aliases 201304L <type_traits> |
| 155 | 169 | __cpp_lib_transparent_operators 201510L <functional> <memory> |
| 156 | 170 | 201210L // C++14 |
| 157 | 171 | __cpp_lib_tuple_element_t 201402L <tuple> |
| 158 | 172 | __cpp_lib_tuples_by_type 201304L <tuple> <utility> |
| 173 | __cpp_lib_type_identity 201806L <type_traits> | |
| 159 | 174 | __cpp_lib_type_trait_variable_templates 201510L <type_traits> |
| 160 | 175 | __cpp_lib_uncaught_exceptions 201411L <exception> |
| 161 | 176 | __cpp_lib_unordered_map_try_emplace 201411L <unordered_map> |
| ... | ... | @@ -199,17 +214,13 @@ __cpp_lib_void_t 201411L <type_traits> |
| 199 | 214 | #endif |
| 200 | 215 | |
| 201 | 216 | #if _LIBCPP_STD_VER > 14 |
| 202 | # if !defined(_LIBCPP_HAS_NO_BUILTIN_ADDRESSOF) | |
| 203 | # define __cpp_lib_addressof_constexpr 201603L | |
| 204 | # endif | |
| 217 | # define __cpp_lib_addressof_constexpr 201603L | |
| 205 | 218 | # define __cpp_lib_allocator_traits_is_always_equal 201411L |
| 206 | 219 | # define __cpp_lib_any 201606L |
| 207 | 220 | # define __cpp_lib_apply 201603L |
| 208 | 221 | # define __cpp_lib_array_constexpr 201603L |
| 209 | 222 | # define __cpp_lib_as_const 201510L |
| 210 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 211 | # define __cpp_lib_atomic_is_always_lock_free 201603L | |
| 212 | # endif | |
| 223 | # define __cpp_lib_atomic_is_always_lock_free 201603L | |
| 213 | 224 | # define __cpp_lib_bool_constant 201505L |
| 214 | 225 | // # define __cpp_lib_boyer_moore_searcher 201603L |
| 215 | 226 | # define __cpp_lib_byte 201603L |
| ... | ... | @@ -222,15 +233,11 @@ __cpp_lib_void_t 201411L <type_traits> |
| 222 | 233 | # endif |
| 223 | 234 | # define __cpp_lib_gcd_lcm 201606L |
| 224 | 235 | // # define __cpp_lib_hardware_interference_size 201703L |
| 225 | # if defined(_LIBCPP_HAS_UNIQUE_OBJECT_REPRESENTATIONS) | |
| 226 | # define __cpp_lib_has_unique_object_representations 201606L | |
| 227 | # endif | |
| 236 | # define __cpp_lib_has_unique_object_representations 201606L | |
| 228 | 237 | # define __cpp_lib_hypot 201603L |
| 229 | 238 | # define __cpp_lib_incomplete_container_elements 201505L |
| 230 | 239 | # define __cpp_lib_invoke 201411L |
| 231 | # if !defined(_LIBCPP_HAS_NO_IS_AGGREGATE) | |
| 232 | # define __cpp_lib_is_aggregate 201703L | |
| 233 | # endif | |
| 240 | # define __cpp_lib_is_aggregate 201703L | |
| 234 | 241 | # define __cpp_lib_is_invocable 201703L |
| 235 | 242 | # define __cpp_lib_is_swappable 201603L |
| 236 | 243 | # define __cpp_lib_launder 201606L |
| ... | ... | @@ -267,32 +274,20 @@ __cpp_lib_void_t 201411L <type_traits> |
| 267 | 274 | # undef __cpp_lib_array_constexpr |
| 268 | 275 | # define __cpp_lib_array_constexpr 201811L |
| 269 | 276 | // # define __cpp_lib_assume_aligned 201811L |
| 270 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 271 | # define __cpp_lib_atomic_flag_test 201907L | |
| 272 | # endif | |
| 273 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 274 | // # define __cpp_lib_atomic_float 201711L | |
| 275 | # endif | |
| 276 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 277 | # define __cpp_lib_atomic_lock_free_type_aliases 201907L | |
| 278 | # endif | |
| 279 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 280 | // # define __cpp_lib_atomic_ref 201806L | |
| 281 | # endif | |
| 282 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 283 | // # define __cpp_lib_atomic_shared_ptr 201711L | |
| 284 | # endif | |
| 285 | # if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 286 | # define __cpp_lib_atomic_value_initialization 201911L | |
| 287 | # endif | |
| 288 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) | |
| 277 | # define __cpp_lib_atomic_flag_test 201907L | |
| 278 | // # define __cpp_lib_atomic_float 201711L | |
| 279 | # define __cpp_lib_atomic_lock_free_type_aliases 201907L | |
| 280 | // # define __cpp_lib_atomic_ref 201806L | |
| 281 | // # define __cpp_lib_atomic_shared_ptr 201711L | |
| 282 | # define __cpp_lib_atomic_value_initialization 201911L | |
| 283 | # if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait) | |
| 289 | 284 | # define __cpp_lib_atomic_wait 201907L |
| 290 | 285 | # endif |
| 291 | 286 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier) |
| 292 | 287 | # define __cpp_lib_barrier 201907L |
| 293 | 288 | # endif |
| 294 | 289 | # define __cpp_lib_bind_front 201907L |
| 295 | // # define __cpp_lib_bit_cast 201806L | |
| 290 | # define __cpp_lib_bit_cast 201806L | |
| 296 | 291 | // # define __cpp_lib_bitops 201907L |
| 297 | 292 | # define __cpp_lib_bounded_array_traits 201902L |
| 298 | 293 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) |
| ... | ... | @@ -311,7 +306,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 311 | 306 | # define __cpp_lib_constexpr_tuple 201811L |
| 312 | 307 | # define __cpp_lib_constexpr_utility 201811L |
| 313 | 308 | // # define __cpp_lib_constexpr_vector 201907L |
| 314 | // # define __cpp_lib_coroutine 201902L | |
| 309 | # define __cpp_lib_coroutine 201902L | |
| 315 | 310 | # if _LIBCPP_STD_VER > 17 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L |
| 316 | 311 | # define __cpp_lib_destroying_delete 201806L |
| 317 | 312 | # endif |
| ... | ... | @@ -320,7 +315,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 320 | 315 | # undef __cpp_lib_execution |
| 321 | 316 | // # define __cpp_lib_execution 201902L |
| 322 | 317 | # if !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format) |
| 323 | // # define __cpp_lib_format 201907L | |
| 318 | // # define __cpp_lib_format 202106L | |
| 324 | 319 | # endif |
| 325 | 320 | # define __cpp_lib_generic_unordered_lookup 201811L |
| 326 | 321 | # define __cpp_lib_int_pow2 202002L |
| ... | ... | @@ -328,9 +323,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 328 | 323 | # define __cpp_lib_integer_comparison_functions 202002L |
| 329 | 324 | # endif |
| 330 | 325 | # define __cpp_lib_interpolate 201902L |
| 331 | # if !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) | |
| 332 | # define __cpp_lib_is_constant_evaluated 201811L | |
| 333 | # endif | |
| 326 | # define __cpp_lib_is_constant_evaluated 201811L | |
| 334 | 327 | // # define __cpp_lib_is_layout_compatible 201907L |
| 335 | 328 | # define __cpp_lib_is_nothrow_convertible 201806L |
| 336 | 329 | // # define __cpp_lib_is_pointer_interconvertible 201907L |
| ... | ... | @@ -362,14 +355,28 @@ __cpp_lib_void_t 201411L <type_traits> |
| 362 | 355 | // # define __cpp_lib_three_way_comparison 201907L |
| 363 | 356 | # define __cpp_lib_to_address 201711L |
| 364 | 357 | # define __cpp_lib_to_array 201907L |
| 358 | # define __cpp_lib_type_identity 201806L | |
| 365 | 359 | # define __cpp_lib_unwrap_ref 201811L |
| 366 | 360 | #endif |
| 367 | 361 | |
| 368 | 362 | #if _LIBCPP_STD_VER > 20 |
| 363 | # define __cpp_lib_adaptor_iterator_pair_constructor 202106L | |
| 364 | // # define __cpp_lib_allocate_at_least 202106L | |
| 365 | // # define __cpp_lib_associative_heterogeneous_erasure 202110L | |
| 366 | # define __cpp_lib_byteswap 202110L | |
| 367 | // # define __cpp_lib_constexpr_typeinfo 202106L | |
| 368 | // # define __cpp_lib_invoke_r 202106L | |
| 369 | 369 | # define __cpp_lib_is_scoped_enum 202011L |
| 370 | # define __cpp_lib_monadic_optional 202110L | |
| 371 | // # define __cpp_lib_move_only_function 202110L | |
| 372 | // # define __cpp_lib_out_ptr 202106L | |
| 373 | // # define __cpp_lib_ranges_starts_ends_with 202106L | |
| 374 | // # define __cpp_lib_ranges_zip 202110L | |
| 375 | // # define __cpp_lib_spanstream 202106L | |
| 370 | 376 | // # define __cpp_lib_stacktrace 202011L |
| 371 | 377 | // # define __cpp_lib_stdatomic_h 202011L |
| 372 | 378 | # define __cpp_lib_string_contains 202011L |
| 379 | # define __cpp_lib_string_resize_and_overwrite 202110L | |
| 373 | 380 | # define __cpp_lib_to_underlying 202102L |
| 374 | 381 | #endif |
| 375 | 382 |
lib/libcxx/include/wchar.h+8-4| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- wchar.h ----------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -108,6 +108,10 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 108 | 108 | #include <__config> |
| 109 | 109 | #include <stddef.h> |
| 110 | 110 | |
| 111 | #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 112 | # error "The <wchar.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled" | |
| 113 | #endif | |
| 114 | ||
| 111 | 115 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 112 | 116 | #pragma GCC system_header |
| 113 | 117 | #endif |
| ... | ... | @@ -170,13 +174,13 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD |
| 170 | 174 | } |
| 171 | 175 | #endif |
| 172 | 176 | |
| 173 | #if defined(__cplusplus) && defined(_LIBCPP_MSVCRT_LIKE) | |
| 177 | #if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__)) | |
| 174 | 178 | extern "C" { |
| 175 | 179 | size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, |
| 176 | 180 | size_t nmc, size_t len, mbstate_t *__restrict ps); |
| 177 | 181 | size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, |
| 178 | 182 | size_t nwc, size_t len, mbstate_t *__restrict ps); |
| 179 | } // extern "C++" | |
| 180 | #endif // __cplusplus && _LIBCPP_MSVCRT | |
| 183 | } // extern "C" | |
| 184 | #endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) | |
| 181 | 185 | |
| 182 | 186 | #endif // _LIBCPP_WCHAR_H |
lib/libcxx/include/wctype.h+5-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- wctype.h ---------------------------------===// | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | 3 | // |
| 4 | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | 5 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -46,6 +46,10 @@ wctrans_t wctrans(const char* property); |
| 46 | 46 | |
| 47 | 47 | #include <__config> |
| 48 | 48 | |
| 49 | #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 50 | # error "The <wctype.h> header is not supported since libc++ has been configured with LIBCXX_ENABLE_WIDE_CHARACTERS disabled" | |
| 51 | #endif | |
| 52 | ||
| 49 | 53 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 50 | 54 | #pragma GCC system_header |
| 51 | 55 | #endif |
lib/libcxx/src/algorithm.cpp+5-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------- algorithm.cpp --------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -11,7 +11,9 @@ |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | |
| 13 | 13 | template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); |
| 14 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 14 | 15 | template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
| 16 | #endif | |
| 15 | 17 | template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); |
| 16 | 18 | template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); |
| 17 | 19 | template void __sort<__less<short>&, short*>(short*, short*, __less<short>&); |
| ... | ... | @@ -27,7 +29,9 @@ template void __sort<__less<double>&, double*>(double*, double*, __less<double>& |
| 27 | 29 | template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); |
| 28 | 30 | |
| 29 | 31 | template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&); |
| 32 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 30 | 33 | template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
| 34 | #endif | |
| 31 | 35 | template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); |
| 32 | 36 | template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); |
| 33 | 37 | template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&); |
lib/libcxx/src/any.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===---------------------------- any.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/atomic.cpp+3-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- atomic.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,9 +9,10 @@ |
| 9 | 9 | #include <__config> |
| 10 | 10 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 11 | 11 | |
| 12 | #include <climits> | |
| 13 | 12 | #include <atomic> |
| 13 | #include <climits> | |
| 14 | 14 | #include <functional> |
| 15 | #include <thread> | |
| 15 | 16 | |
| 16 | 17 | #ifdef __linux__ |
| 17 | 18 |
lib/libcxx/src/barrier.cpp+4-4| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- barrier.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -15,14 +15,14 @@ |
| 15 | 15 | |
| 16 | 16 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 17 | 17 | |
| 18 | #if !defined(_LIBCPP_HAS_NO_TREE_BARRIER) && (_LIBCPP_STD_VER > 11) | |
| 18 | #if !defined(_LIBCPP_HAS_NO_TREE_BARRIER) | |
| 19 | 19 | |
| 20 | 20 | class __barrier_algorithm_base { |
| 21 | 21 | public: |
| 22 | 22 | struct alignas(64) /* naturally-align the heap state */ __state_t |
| 23 | 23 | { |
| 24 | 24 | struct { |
| 25 | __atomic_base<__barrier_phase_t> __phase = ATOMIC_VAR_INIT(0); | |
| 25 | __atomic_base<__barrier_phase_t> __phase{0}; | |
| 26 | 26 | } __tickets[64]; |
| 27 | 27 | }; |
| 28 | 28 | |
| ... | ... | @@ -90,7 +90,7 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) |
| 90 | 90 | delete __barrier; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | #endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER) && (_LIBCPP_STD_VER >= 11) | |
| 93 | #endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER) | |
| 94 | 94 | |
| 95 | 95 | _LIBCPP_END_NAMESPACE_STD |
| 96 | 96 |
lib/libcxx/src/bind.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- bind.cpp ----------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/charconv.cpp+54-18| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- charconv.cpp -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,27 +9,14 @@ |
| 9 | 9 | #include "charconv" |
| 10 | 10 | #include <string.h> |
| 11 | 11 | |
| 12 | #include "include/ryu/digit_table.h" | |
| 13 | #include "include/to_chars_floating_point.h" | |
| 14 | ||
| 12 | 15 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 13 | 16 | |
| 14 | 17 | namespace __itoa |
| 15 | 18 | { |
| 16 | 19 | |
| 17 | static constexpr char cDigitsLut[200] = { | |
| 18 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', | |
| 19 | '7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', | |
| 20 | '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2', | |
| 21 | '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', | |
| 22 | '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', | |
| 23 | '7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', | |
| 24 | '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5', | |
| 25 | '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', | |
| 26 | '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', | |
| 27 | '7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', | |
| 28 | '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8', | |
| 29 | '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', | |
| 30 | '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', | |
| 31 | '7', '9', '8', '9', '9'}; | |
| 32 | ||
| 33 | 20 | template <typename T> |
| 34 | 21 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 35 | 22 | append1(char* buffer, T i) noexcept |
| ... | ... | @@ -42,7 +29,7 @@ template <typename T> |
| 42 | 29 | inline _LIBCPP_INLINE_VISIBILITY char* |
| 43 | 30 | append2(char* buffer, T i) noexcept |
| 44 | 31 | { |
| 45 | memcpy(buffer, &cDigitsLut[(i)*2], 2); | |
| 32 | memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2); | |
| 46 | 33 | return buffer + 2; |
| 47 | 34 | } |
| 48 | 35 | |
| ... | ... | @@ -157,4 +144,53 @@ __u64toa(uint64_t value, char* buffer) noexcept |
| 157 | 144 | |
| 158 | 145 | } // namespace __itoa |
| 159 | 146 | |
| 147 | // The original version of floating-point to_chars was written by Microsoft and | |
| 148 | // contributed with the following license. | |
| 149 | ||
| 150 | // Copyright (c) Microsoft Corporation. | |
| 151 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 152 | ||
| 153 | // This implementation is dedicated to the memory of Mary and Thavatchai. | |
| 154 | ||
| 155 | to_chars_result to_chars(char* __first, char* __last, float __value) { | |
| 156 | return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0); | |
| 157 | } | |
| 158 | ||
| 159 | to_chars_result to_chars(char* __first, char* __last, double __value) { | |
| 160 | return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, __value, chars_format{}, 0); | |
| 161 | } | |
| 162 | ||
| 163 | to_chars_result to_chars(char* __first, char* __last, long double __value) { | |
| 164 | return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value), | |
| 165 | chars_format{}, 0); | |
| 166 | } | |
| 167 | ||
| 168 | to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) { | |
| 169 | return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0); | |
| 170 | } | |
| 171 | ||
| 172 | to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt) { | |
| 173 | return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, __value, __fmt, 0); | |
| 174 | } | |
| 175 | ||
| 176 | to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) { | |
| 177 | return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value), | |
| 178 | __fmt, 0); | |
| 179 | } | |
| 180 | ||
| 181 | to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) { | |
| 182 | return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt, | |
| 183 | __precision); | |
| 184 | } | |
| 185 | ||
| 186 | to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) { | |
| 187 | return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt, | |
| 188 | __precision); | |
| 189 | } | |
| 190 | ||
| 191 | to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) { | |
| 192 | return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>( | |
| 193 | __first, __last, static_cast<double>(__value), __fmt, __precision); | |
| 194 | } | |
| 195 | ||
| 160 | 196 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/chrono.cpp+49-7| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- chrono.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -44,6 +44,10 @@ |
| 44 | 44 | # endif |
| 45 | 45 | #endif // defined(_LIBCPP_WIN32API) |
| 46 | 46 | |
| 47 | #if defined(__Fuchsia__) | |
| 48 | # include <zircon/syscalls.h> | |
| 49 | #endif | |
| 50 | ||
| 47 | 51 | #if __has_include(<mach/mach_time.h>) |
| 48 | 52 | # include <mach/mach_time.h> |
| 49 | 53 | #endif |
| ... | ... | @@ -63,6 +67,30 @@ namespace chrono |
| 63 | 67 | |
| 64 | 68 | #if defined(_LIBCPP_WIN32API) |
| 65 | 69 | |
| 70 | #if _WIN32_WINNT < _WIN32_WINNT_WIN8 | |
| 71 | ||
| 72 | namespace { | |
| 73 | ||
| 74 | typedef void(WINAPI *GetSystemTimeAsFileTimePtr)(LPFILETIME); | |
| 75 | ||
| 76 | class GetSystemTimeInit { | |
| 77 | public: | |
| 78 | GetSystemTimeInit() { | |
| 79 | fp = (GetSystemTimeAsFileTimePtr)GetProcAddress( | |
| 80 | GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime"); | |
| 81 | if (fp == nullptr) | |
| 82 | fp = GetSystemTimeAsFileTime; | |
| 83 | } | |
| 84 | GetSystemTimeAsFileTimePtr fp; | |
| 85 | }; | |
| 86 | ||
| 87 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority | |
| 88 | // attribute with a value that's reserved for the implementation (we're the implementation). | |
| 89 | #include "chrono_system_time_init.h" | |
| 90 | } // namespace | |
| 91 | ||
| 92 | #endif | |
| 93 | ||
| 66 | 94 | static system_clock::time_point __libcpp_system_clock_now() { |
| 67 | 95 | // FILETIME is in 100ns units |
| 68 | 96 | using filetime_duration = |
| ... | ... | @@ -74,10 +102,13 @@ static system_clock::time_point __libcpp_system_clock_now() { |
| 74 | 102 | static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600}; |
| 75 | 103 | |
| 76 | 104 | FILETIME ft; |
| 77 | #if _WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) | |
| 105 | #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) || \ | |
| 106 | (_WIN32_WINNT >= _WIN32_WINNT_WIN10) | |
| 78 | 107 | GetSystemTimePreciseAsFileTime(&ft); |
| 79 | #else | |
| 108 | #elif !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) | |
| 80 | 109 | GetSystemTimeAsFileTime(&ft); |
| 110 | #else | |
| 111 | GetSystemTimeAsFileTimeFunc.fp(&ft); | |
| 81 | 112 | #endif |
| 82 | 113 | |
| 83 | 114 | filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) | |
| ... | ... | @@ -239,7 +270,18 @@ static steady_clock::time_point __libcpp_steady_clock_now() { |
| 239 | 270 | return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec)); |
| 240 | 271 | } |
| 241 | 272 | |
| 242 | #elif defined(CLOCK_MONOTONIC) | |
| 273 | # elif defined(__Fuchsia__) | |
| 274 | ||
| 275 | static steady_clock::time_point __libcpp_steady_clock_now() noexcept { | |
| 276 | // Implicitly link against the vDSO system call ABI without | |
| 277 | // requiring the final link to specify -lzircon explicitly when | |
| 278 | // statically linking libc++. | |
| 279 | # pragma comment(lib, "zircon") | |
| 280 | ||
| 281 | return steady_clock::time_point(nanoseconds(_zx_clock_get_monotonic())); | |
| 282 | } | |
| 283 | ||
| 284 | # elif defined(CLOCK_MONOTONIC) | |
| 243 | 285 | |
| 244 | 286 | static steady_clock::time_point __libcpp_steady_clock_now() { |
| 245 | 287 | struct timespec tp; |
| ... | ... | @@ -248,9 +290,9 @@ static steady_clock::time_point __libcpp_steady_clock_now() { |
| 248 | 290 | return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec)); |
| 249 | 291 | } |
| 250 | 292 | |
| 251 | #else | |
| 252 | # error "Monotonic clock not implemented on this platform" | |
| 253 | #endif | |
| 293 | # else | |
| 294 | # error "Monotonic clock not implemented on this platform" | |
| 295 | # endif | |
| 254 | 296 | |
| 255 | 297 | const bool steady_clock::is_steady; |
| 256 | 298 |
lib/libcxx/src/chrono_system_time_init.h created+2| ... | ... | @@ -0,0 +1,2 @@ |
| 1 | #pragma GCC system_header | |
| 2 | GetSystemTimeInit GetSystemTimeAsFileTimeFunc _LIBCPP_INIT_PRIORITY_MAX; |
lib/libcxx/src/condition_variable.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------- condition_variable.cpp --------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/condition_variable_destructor.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===---------------- condition_variable_destructor.cpp ------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/debug.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- debug.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/exception.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ exception.cpp -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/experimental/memory_resource.cpp+5-4| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ memory_resource.cpp -------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -76,7 +76,9 @@ union ResourceInitHelper { |
| 76 | 76 | ~ResourceInitHelper() {} |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | _LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX; | |
| 79 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority | |
| 80 | // attribute with a value that's reserved for the implementation (we're the implementation). | |
| 81 | #include "memory_resource_init_helper.h" | |
| 80 | 82 | |
| 81 | 83 | } // end namespace |
| 82 | 84 | |
| ... | ... | @@ -95,8 +97,7 @@ static memory_resource * |
| 95 | 97 | __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept |
| 96 | 98 | { |
| 97 | 99 | #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 98 | _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res = | |
| 99 | ATOMIC_VAR_INIT(&res_init.resources.new_delete_res); | |
| 100 | _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res{&res_init.resources.new_delete_res}; | |
| 100 | 101 | if (set) { |
| 101 | 102 | new_res = new_res ? new_res : new_delete_resource(); |
| 102 | 103 | // TODO: Can a weaker ordering be used? |
lib/libcxx/src/experimental/memory_resource_init_helper.h created+2| ... | ... | @@ -0,0 +1,2 @@ |
| 1 | #pragma GCC system_header | |
| 2 | _LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX; |
lib/libcxx/src/filesystem/directory_iterator.cpp+5-89| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------ directory_iterator.cpp ----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -6,99 +6,15 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "filesystem" | |
| 10 | 9 | #include "__config" |
| 11 | #if defined(_LIBCPP_WIN32API) | |
| 12 | #define WIN32_LEAN_AND_MEAN | |
| 13 | #define NOMINMAX | |
| 14 | #include <windows.h> | |
| 15 | #else | |
| 16 | #include <dirent.h> | |
| 17 | #endif | |
| 10 | #include "filesystem" | |
| 11 | #include "stack" | |
| 18 | 12 | #include <errno.h> |
| 19 | 13 | |
| 20 | 14 | #include "filesystem_common.h" |
| 21 | 15 | |
| 22 | 16 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| 23 | 17 | |
| 24 | namespace detail { | |
| 25 | namespace { | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_WIN32API) | |
| 28 | ||
| 29 | #if defined(DT_BLK) | |
| 30 | template <class DirEntT, class = decltype(DirEntT::d_type)> | |
| 31 | static file_type get_file_type(DirEntT* ent, int) { | |
| 32 | switch (ent->d_type) { | |
| 33 | case DT_BLK: | |
| 34 | return file_type::block; | |
| 35 | case DT_CHR: | |
| 36 | return file_type::character; | |
| 37 | case DT_DIR: | |
| 38 | return file_type::directory; | |
| 39 | case DT_FIFO: | |
| 40 | return file_type::fifo; | |
| 41 | case DT_LNK: | |
| 42 | return file_type::symlink; | |
| 43 | case DT_REG: | |
| 44 | return file_type::regular; | |
| 45 | case DT_SOCK: | |
| 46 | return file_type::socket; | |
| 47 | // Unlike in lstat, hitting "unknown" here simply means that the underlying | |
| 48 | // filesystem doesn't support d_type. Report is as 'none' so we correctly | |
| 49 | // set the cache to empty. | |
| 50 | case DT_UNKNOWN: | |
| 51 | break; | |
| 52 | } | |
| 53 | return file_type::none; | |
| 54 | } | |
| 55 | #endif // defined(DT_BLK) | |
| 56 | ||
| 57 | template <class DirEntT> | |
| 58 | static file_type get_file_type(DirEntT* ent, long) { | |
| 59 | return file_type::none; | |
| 60 | } | |
| 61 | ||
| 62 | static pair<string_view, file_type> posix_readdir(DIR* dir_stream, | |
| 63 | error_code& ec) { | |
| 64 | struct dirent* dir_entry_ptr = nullptr; | |
| 65 | errno = 0; // zero errno in order to detect errors | |
| 66 | ec.clear(); | |
| 67 | if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) { | |
| 68 | if (errno) | |
| 69 | ec = capture_errno(); | |
| 70 | return {}; | |
| 71 | } else { | |
| 72 | return {dir_entry_ptr->d_name, get_file_type(dir_entry_ptr, 0)}; | |
| 73 | } | |
| 74 | } | |
| 75 | #else | |
| 76 | // defined(_LIBCPP_WIN32API) | |
| 77 | ||
| 78 | static file_type get_file_type(const WIN32_FIND_DATAW& data) { | |
| 79 | if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && | |
| 80 | data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) | |
| 81 | return file_type::symlink; | |
| 82 | if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | |
| 83 | return file_type::directory; | |
| 84 | return file_type::regular; | |
| 85 | } | |
| 86 | static uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { | |
| 87 | return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow; | |
| 88 | } | |
| 89 | static file_time_type get_write_time(const WIN32_FIND_DATAW& data) { | |
| 90 | ULARGE_INTEGER tmp; | |
| 91 | const FILETIME& time = data.ftLastWriteTime; | |
| 92 | tmp.u.LowPart = time.dwLowDateTime; | |
| 93 | tmp.u.HighPart = time.dwHighDateTime; | |
| 94 | return file_time_type(file_time_type::duration(tmp.QuadPart)); | |
| 95 | } | |
| 96 | ||
| 97 | #endif | |
| 98 | ||
| 99 | } // namespace | |
| 100 | } // namespace detail | |
| 101 | ||
| 102 | 18 | using detail::ErrorHandler; |
| 103 | 19 | |
| 104 | 20 | #if defined(_LIBCPP_WIN32API) |
| ... | ... | @@ -196,9 +112,9 @@ public: |
| 196 | 112 | : __stream_(nullptr), __root_(root) { |
| 197 | 113 | if ((__stream_ = ::opendir(root.c_str())) == nullptr) { |
| 198 | 114 | ec = detail::capture_errno(); |
| 199 | const bool allow_eacess = | |
| 115 | const bool allow_eacces = | |
| 200 | 116 | bool(opts & directory_options::skip_permission_denied); |
| 201 | if (allow_eacess && ec.value() == EACCES) | |
| 117 | if (allow_eacces && ec.value() == EACCES) | |
| 202 | 118 | ec.clear(); |
| 203 | 119 | return; |
| 204 | 120 | } |
lib/libcxx/src/filesystem/filesystem_common.h+88-9| ... | ... | @@ -10,19 +10,29 @@ |
| 10 | 10 | #define FILESYSTEM_COMMON_H |
| 11 | 11 | |
| 12 | 12 | #include "__config" |
| 13 | #include "filesystem" | |
| 14 | 13 | #include "array" |
| 15 | 14 | #include "chrono" |
| 16 | 15 | #include "climits" |
| 16 | #include "cstdarg" | |
| 17 | 17 | #include "cstdlib" |
| 18 | 18 | #include "ctime" |
| 19 | #include "filesystem" | |
| 20 | #include "ratio" | |
| 21 | #include "system_error" | |
| 22 | ||
| 23 | #if defined(_LIBCPP_WIN32API) | |
| 24 | # define WIN32_LEAN_AND_MEAN | |
| 25 | # define NOMINMAX | |
| 26 | # include <windows.h> | |
| 27 | #endif | |
| 19 | 28 | |
| 20 | 29 | #if !defined(_LIBCPP_WIN32API) |
| 21 | # include <unistd.h> | |
| 30 | # include <dirent.h> // for DIR & friends | |
| 31 | # include <fcntl.h> /* values for fchmodat */ | |
| 22 | 32 | # include <sys/stat.h> |
| 23 | 33 | # include <sys/statvfs.h> |
| 24 | 34 | # include <sys/time.h> // for ::utimes as used in __last_write_time |
| 25 | # include <fcntl.h> /* values for fchmodat */ | |
| 35 | # include <unistd.h> | |
| 26 | 36 | #endif |
| 27 | 37 | |
| 28 | 38 | #include "../include/apple_availability.h" |
| ... | ... | @@ -59,7 +69,7 @@ errc __win_err_to_errc(int err); |
| 59 | 69 | |
| 60 | 70 | namespace { |
| 61 | 71 | |
| 62 | static _LIBCPP_FORMAT_PRINTF(1, 0) string | |
| 72 | static _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 0) string | |
| 63 | 73 | format_string_impl(const char* msg, va_list ap) { |
| 64 | 74 | array<char, 256> buf; |
| 65 | 75 | |
| ... | ... | @@ -83,7 +93,7 @@ format_string_impl(const char* msg, va_list ap) { |
| 83 | 93 | return result; |
| 84 | 94 | } |
| 85 | 95 | |
| 86 | static _LIBCPP_FORMAT_PRINTF(1, 2) string | |
| 96 | static _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string | |
| 87 | 97 | format_string(const char* msg, ...) { |
| 88 | 98 | string ret; |
| 89 | 99 | va_list ap; |
| ... | ... | @@ -171,7 +181,7 @@ struct ErrorHandler { |
| 171 | 181 | _LIBCPP_UNREACHABLE(); |
| 172 | 182 | } |
| 173 | 183 | |
| 174 | _LIBCPP_FORMAT_PRINTF(3, 0) | |
| 184 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0) | |
| 175 | 185 | void report_impl(const error_code& ec, const char* msg, va_list ap) const { |
| 176 | 186 | if (ec_) { |
| 177 | 187 | *ec_ = ec; |
| ... | ... | @@ -190,7 +200,7 @@ struct ErrorHandler { |
| 190 | 200 | _LIBCPP_UNREACHABLE(); |
| 191 | 201 | } |
| 192 | 202 | |
| 193 | _LIBCPP_FORMAT_PRINTF(3, 4) | |
| 203 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) | |
| 194 | 204 | T report(const error_code& ec, const char* msg, ...) const { |
| 195 | 205 | va_list ap; |
| 196 | 206 | va_start(ap, msg); |
| ... | ... | @@ -212,7 +222,7 @@ struct ErrorHandler { |
| 212 | 222 | return report(make_error_code(err)); |
| 213 | 223 | } |
| 214 | 224 | |
| 215 | _LIBCPP_FORMAT_PRINTF(3, 4) | |
| 225 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) | |
| 216 | 226 | T report(errc const& err, const char* msg, ...) const { |
| 217 | 227 | va_list ap; |
| 218 | 228 | va_start(ap, msg); |
| ... | ... | @@ -524,7 +534,76 @@ bool set_file_times(const path& p, std::array<TimeSpec, 2> const& TS, |
| 524 | 534 | return posix_utimensat(p, TS, ec); |
| 525 | 535 | #endif |
| 526 | 536 | } |
| 527 | #endif /* !_LIBCPP_WIN32API */ | |
| 537 | ||
| 538 | #if defined(DT_BLK) | |
| 539 | template <class DirEntT, class = decltype(DirEntT::d_type)> | |
| 540 | static file_type get_file_type(DirEntT* ent, int) { | |
| 541 | switch (ent->d_type) { | |
| 542 | case DT_BLK: | |
| 543 | return file_type::block; | |
| 544 | case DT_CHR: | |
| 545 | return file_type::character; | |
| 546 | case DT_DIR: | |
| 547 | return file_type::directory; | |
| 548 | case DT_FIFO: | |
| 549 | return file_type::fifo; | |
| 550 | case DT_LNK: | |
| 551 | return file_type::symlink; | |
| 552 | case DT_REG: | |
| 553 | return file_type::regular; | |
| 554 | case DT_SOCK: | |
| 555 | return file_type::socket; | |
| 556 | // Unlike in lstat, hitting "unknown" here simply means that the underlying | |
| 557 | // filesystem doesn't support d_type. Report is as 'none' so we correctly | |
| 558 | // set the cache to empty. | |
| 559 | case DT_UNKNOWN: | |
| 560 | break; | |
| 561 | } | |
| 562 | return file_type::none; | |
| 563 | } | |
| 564 | #endif // defined(DT_BLK) | |
| 565 | ||
| 566 | template <class DirEntT> | |
| 567 | static file_type get_file_type(DirEntT*, long) { | |
| 568 | return file_type::none; | |
| 569 | } | |
| 570 | ||
| 571 | static pair<string_view, file_type> posix_readdir(DIR* dir_stream, | |
| 572 | error_code& ec) { | |
| 573 | struct dirent* dir_entry_ptr = nullptr; | |
| 574 | errno = 0; // zero errno in order to detect errors | |
| 575 | ec.clear(); | |
| 576 | if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) { | |
| 577 | if (errno) | |
| 578 | ec = capture_errno(); | |
| 579 | return {}; | |
| 580 | } else { | |
| 581 | return {dir_entry_ptr->d_name, get_file_type(dir_entry_ptr, 0)}; | |
| 582 | } | |
| 583 | } | |
| 584 | ||
| 585 | #else // _LIBCPP_WIN32API | |
| 586 | ||
| 587 | static file_type get_file_type(const WIN32_FIND_DATAW& data) { | |
| 588 | if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && | |
| 589 | data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) | |
| 590 | return file_type::symlink; | |
| 591 | if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) | |
| 592 | return file_type::directory; | |
| 593 | return file_type::regular; | |
| 594 | } | |
| 595 | static uintmax_t get_file_size(const WIN32_FIND_DATAW& data) { | |
| 596 | return (static_cast<uint64_t>(data.nFileSizeHigh) << 32) + data.nFileSizeLow; | |
| 597 | } | |
| 598 | static file_time_type get_write_time(const WIN32_FIND_DATAW& data) { | |
| 599 | ULARGE_INTEGER tmp; | |
| 600 | const FILETIME& time = data.ftLastWriteTime; | |
| 601 | tmp.u.LowPart = time.dwLowDateTime; | |
| 602 | tmp.u.HighPart = time.dwHighDateTime; | |
| 603 | return file_time_type(file_time_type::duration(tmp.QuadPart)); | |
| 604 | } | |
| 605 | ||
| 606 | #endif // !_LIBCPP_WIN32API | |
| 528 | 607 | |
| 529 | 608 | } // namespace |
| 530 | 609 | } // end namespace detail |
lib/libcxx/src/filesystem/operations.cpp+109-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------- filesystem/ops.cpp -----------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -24,9 +24,10 @@ |
| 24 | 24 | # define NOMINMAX |
| 25 | 25 | # include <windows.h> |
| 26 | 26 | #else |
| 27 | # include <unistd.h> | |
| 27 | # include <dirent.h> | |
| 28 | 28 | # include <sys/stat.h> |
| 29 | 29 | # include <sys/statvfs.h> |
| 30 | # include <unistd.h> | |
| 30 | 31 | #endif |
| 31 | 32 | #include <time.h> |
| 32 | 33 | #include <fcntl.h> /* values for fchmodat */ |
| ... | ... | @@ -1338,6 +1339,19 @@ bool __remove(const path& p, error_code* ec) { |
| 1338 | 1339 | return true; |
| 1339 | 1340 | } |
| 1340 | 1341 | |
| 1342 | // We currently have two implementations of `__remove_all`. The first one is general and | |
| 1343 | // used on platforms where we don't have access to the `openat()` family of POSIX functions. | |
| 1344 | // That implementation uses `directory_iterator`, however it is vulnerable to some race | |
| 1345 | // conditions, see https://reviews.llvm.org/D118134 for details. | |
| 1346 | // | |
| 1347 | // The second implementation is used on platforms where `openat()` & friends are available, | |
| 1348 | // and it threads file descriptors through recursive calls to avoid such race conditions. | |
| 1349 | #if defined(_LIBCPP_WIN32API) | |
| 1350 | # define REMOVE_ALL_USE_DIRECTORY_ITERATOR | |
| 1351 | #endif | |
| 1352 | ||
| 1353 | #if defined(REMOVE_ALL_USE_DIRECTORY_ITERATOR) | |
| 1354 | ||
| 1341 | 1355 | namespace { |
| 1342 | 1356 | |
| 1343 | 1357 | uintmax_t remove_all_impl(path const& p, error_code& ec) { |
| ... | ... | @@ -1377,6 +1391,99 @@ uintmax_t __remove_all(const path& p, error_code* ec) { |
| 1377 | 1391 | return count; |
| 1378 | 1392 | } |
| 1379 | 1393 | |
| 1394 | #else // !REMOVE_ALL_USE_DIRECTORY_ITERATOR | |
| 1395 | ||
| 1396 | namespace { | |
| 1397 | ||
| 1398 | template <class Cleanup> | |
| 1399 | struct scope_exit { | |
| 1400 | explicit scope_exit(Cleanup const& cleanup) | |
| 1401 | : cleanup_(cleanup) | |
| 1402 | { } | |
| 1403 | ||
| 1404 | ~scope_exit() { cleanup_(); } | |
| 1405 | ||
| 1406 | private: | |
| 1407 | Cleanup cleanup_; | |
| 1408 | }; | |
| 1409 | ||
| 1410 | uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) { | |
| 1411 | // First, try to open the path as a directory. | |
| 1412 | const int options = O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NOFOLLOW; | |
| 1413 | int fd = ::openat(parent_directory, p.c_str(), options); | |
| 1414 | if (fd != -1) { | |
| 1415 | // If that worked, iterate over the contents of the directory and | |
| 1416 | // remove everything in it, recursively. | |
| 1417 | DIR* stream = ::fdopendir(fd); | |
| 1418 | if (stream == nullptr) { | |
| 1419 | ::close(fd); | |
| 1420 | ec = detail::capture_errno(); | |
| 1421 | return 0; | |
| 1422 | } | |
| 1423 | // Note: `::closedir` will also close the associated file descriptor, so | |
| 1424 | // there should be no call to `close(fd)`. | |
| 1425 | scope_exit close_stream([=] { ::closedir(stream); }); | |
| 1426 | ||
| 1427 | uintmax_t count = 0; | |
| 1428 | while (true) { | |
| 1429 | auto [str, type] = detail::posix_readdir(stream, ec); | |
| 1430 | static_assert(std::is_same_v<decltype(str), std::string_view>); | |
| 1431 | if (str == "." || str == "..") { | |
| 1432 | continue; | |
| 1433 | } else if (ec || str.empty()) { | |
| 1434 | break; // we're done iterating through the directory | |
| 1435 | } else { | |
| 1436 | count += remove_all_impl(fd, str, ec); | |
| 1437 | } | |
| 1438 | } | |
| 1439 | ||
| 1440 | // Then, remove the now-empty directory itself. | |
| 1441 | if (::unlinkat(parent_directory, p.c_str(), AT_REMOVEDIR) == -1) { | |
| 1442 | ec = detail::capture_errno(); | |
| 1443 | return count; | |
| 1444 | } | |
| 1445 | ||
| 1446 | return count + 1; // the contents of the directory + the directory itself | |
| 1447 | } | |
| 1448 | ||
| 1449 | ec = detail::capture_errno(); | |
| 1450 | ||
| 1451 | // If we failed to open `p` because it didn't exist, it's not an | |
| 1452 | // error -- it might have moved or have been deleted already. | |
| 1453 | if (ec == errc::no_such_file_or_directory) { | |
| 1454 | ec.clear(); | |
| 1455 | return 0; | |
| 1456 | } | |
| 1457 | ||
| 1458 | // If opening `p` failed because it wasn't a directory, remove it as | |
| 1459 | // a normal file instead. Note that `openat()` can return either ENOTDIR | |
| 1460 | // or ELOOP depending on the exact reason of the failure. | |
| 1461 | if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) { | |
| 1462 | ec.clear(); | |
| 1463 | if (::unlinkat(parent_directory, p.c_str(), /* flags = */0) == -1) { | |
| 1464 | ec = detail::capture_errno(); | |
| 1465 | return 0; | |
| 1466 | } | |
| 1467 | return 1; | |
| 1468 | } | |
| 1469 | ||
| 1470 | // Otherwise, it's a real error -- we don't remove anything. | |
| 1471 | return 0; | |
| 1472 | } | |
| 1473 | ||
| 1474 | } // end namespace | |
| 1475 | ||
| 1476 | uintmax_t __remove_all(const path& p, error_code* ec) { | |
| 1477 | ErrorHandler<uintmax_t> err("remove_all", ec, &p); | |
| 1478 | error_code mec; | |
| 1479 | uintmax_t count = remove_all_impl(AT_FDCWD, p, mec); | |
| 1480 | if (mec) | |
| 1481 | return err.report(mec); | |
| 1482 | return count; | |
| 1483 | } | |
| 1484 | ||
| 1485 | #endif // REMOVE_ALL_USE_DIRECTORY_ITERATOR | |
| 1486 | ||
| 1380 | 1487 | void __rename(const path& from, const path& to, error_code* ec) { |
| 1381 | 1488 | ErrorHandler<void> err("rename", ec, &from, &to); |
| 1382 | 1489 | if (detail::rename(from.c_str(), to.c_str()) == -1) |
lib/libcxx/src/format.cpp+1-5| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- format.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -10,10 +10,6 @@ |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | |
| 13 | #if _LIBCPP_STD_VER > 17 | |
| 14 | ||
| 15 | 13 | format_error::~format_error() noexcept = default; |
| 16 | 14 | |
| 17 | #endif //_LIBCPP_STD_VER > 17 | |
| 18 | ||
| 19 | 15 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/functional.cpp+3-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------- functional.cpp -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -14,7 +14,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 14 | 14 | bad_function_call::~bad_function_call() noexcept |
| 15 | 15 | { |
| 16 | 16 | } |
| 17 | #endif | |
| 17 | 18 | |
| 19 | #ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | |
| 18 | 20 | const char* |
| 19 | 21 | bad_function_call::what() const noexcept |
| 20 | 22 | { |
lib/libcxx/src/future.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- future.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/hash.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- hash.cpp ----------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/include/apple_availability.h+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ apple_availability.h ------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/include/atomic_support.h+2-2| ... | ... | @@ -24,7 +24,7 @@ |
| 24 | 24 | && defined(__ATOMIC_ACQ_REL) \ |
| 25 | 25 | && defined(__ATOMIC_SEQ_CST) |
| 26 | 26 | # define _LIBCPP_HAS_ATOMIC_BUILTINS |
| 27 | #elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407 | |
| 27 | #elif defined(_LIBCPP_COMPILER_GCC) | |
| 28 | 28 | # define _LIBCPP_HAS_ATOMIC_BUILTINS |
| 29 | 29 | #endif |
| 30 | 30 | |
| ... | ... | @@ -146,7 +146,7 @@ _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, |
| 146 | 146 | template <class _ValueType> |
| 147 | 147 | inline _LIBCPP_INLINE_VISIBILITY |
| 148 | 148 | _ValueType __libcpp_atomic_exchange(_ValueType* __target, |
| 149 | _ValueType __value, int __order = _AO_Seq) | |
| 149 | _ValueType __value, int = _AO_Seq) | |
| 150 | 150 | { |
| 151 | 151 | _ValueType old = *__target; |
| 152 | 152 | *__target = __value; |
lib/libcxx/src/include/config_elast.h+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------- config_elast.h -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/include/refstring.h+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ __refstring ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/include/ryu/common.h created+107| ... | ... | @@ -0,0 +1,107 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_COMMON_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_COMMON_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __decimalLength9(const uint32_t __v) { | |
| 50 | // Function precondition: __v is not a 10-digit number. | |
| 51 | // (f2s: 9 digits are sufficient for round-tripping.) | |
| 52 | // (d2fixed: We print 9-digit blocks.) | |
| 53 | _LIBCPP_ASSERT(__v < 1000000000, ""); | |
| 54 | if (__v >= 100000000) { return 9; } | |
| 55 | if (__v >= 10000000) { return 8; } | |
| 56 | if (__v >= 1000000) { return 7; } | |
| 57 | if (__v >= 100000) { return 6; } | |
| 58 | if (__v >= 10000) { return 5; } | |
| 59 | if (__v >= 1000) { return 4; } | |
| 60 | if (__v >= 100) { return 3; } | |
| 61 | if (__v >= 10) { return 2; } | |
| 62 | return 1; | |
| 63 | } | |
| 64 | ||
| 65 | // Returns __e == 0 ? 1 : ceil(log_2(5^__e)). | |
| 66 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline int32_t __pow5bits(const int32_t __e) { | |
| 67 | // This approximation works up to the point that the multiplication overflows at __e = 3529. | |
| 68 | // If the multiplication were done in 64 bits, it would fail at 5^4004 which is just greater | |
| 69 | // than 2^9297. | |
| 70 | _LIBCPP_ASSERT(__e >= 0, ""); | |
| 71 | _LIBCPP_ASSERT(__e <= 3528, ""); | |
| 72 | return static_cast<int32_t>(((static_cast<uint32_t>(__e) * 1217359) >> 19) + 1); | |
| 73 | } | |
| 74 | ||
| 75 | // Returns floor(log_10(2^__e)). | |
| 76 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __log10Pow2(const int32_t __e) { | |
| 77 | // The first value this approximation fails for is 2^1651 which is just greater than 10^297. | |
| 78 | _LIBCPP_ASSERT(__e >= 0, ""); | |
| 79 | _LIBCPP_ASSERT(__e <= 1650, ""); | |
| 80 | return (static_cast<uint32_t>(__e) * 78913) >> 18; | |
| 81 | } | |
| 82 | ||
| 83 | // Returns floor(log_10(5^__e)). | |
| 84 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __log10Pow5(const int32_t __e) { | |
| 85 | // The first value this approximation fails for is 5^2621 which is just greater than 10^1832. | |
| 86 | _LIBCPP_ASSERT(__e >= 0, ""); | |
| 87 | _LIBCPP_ASSERT(__e <= 2620, ""); | |
| 88 | return (static_cast<uint32_t>(__e) * 732923) >> 20; | |
| 89 | } | |
| 90 | ||
| 91 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __float_to_bits(const float __f) { | |
| 92 | uint32_t __bits = 0; | |
| 93 | _VSTD::memcpy(&__bits, &__f, sizeof(float)); | |
| 94 | return __bits; | |
| 95 | } | |
| 96 | ||
| 97 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __double_to_bits(const double __d) { | |
| 98 | uint64_t __bits = 0; | |
| 99 | _VSTD::memcpy(&__bits, &__d, sizeof(double)); | |
| 100 | return __bits; | |
| 101 | } | |
| 102 | ||
| 103 | _LIBCPP_END_NAMESPACE_STD | |
| 104 | ||
| 105 | // clang-format on | |
| 106 | ||
| 107 | #endif // _LIBCPP_SRC_INCLUDE_RYU_COMMON_H |
lib/libcxx/src/include/ryu/d2fixed.h created+60| ... | ... | @@ -0,0 +1,60 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | #include "cstdint" | |
| 47 | ||
| 48 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 49 | ||
| 50 | void __append_n_digits(const uint32_t __olength, uint32_t __digits, char* const __result); | |
| 51 | void __append_nine_digits(uint32_t __digits, char* const __result); | |
| 52 | ||
| 53 | [[nodiscard]] to_chars_result __d2fixed_buffered_n(char* _First, char* const _Last, const double __d, const uint32_t __precision); | |
| 54 | [[nodiscard]] to_chars_result __d2exp_buffered_n(char* _First, char* const _Last, const double __d, uint32_t __precision); | |
| 55 | ||
| 56 | _LIBCPP_END_NAMESPACE_STD | |
| 57 | ||
| 58 | // clang-format on | |
| 59 | ||
| 60 | #endif // _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_H |
lib/libcxx/src/include/ryu/d2fixed_full_table.h created+4451| ... | ... | @@ -0,0 +1,4451 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_FULL_TABLE_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_FULL_TABLE_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | inline constexpr int __TABLE_SIZE = 64; | |
| 50 | ||
| 51 | inline constexpr uint16_t __POW10_OFFSET[__TABLE_SIZE] = { | |
| 52 | 0, 2, 5, 8, 12, 16, 21, 26, 32, 39, | |
| 53 | 46, 54, 62, 71, 80, 90, 100, 111, 122, 134, | |
| 54 | 146, 159, 173, 187, 202, 217, 233, 249, 266, 283, | |
| 55 | 301, 319, 338, 357, 377, 397, 418, 440, 462, 485, | |
| 56 | 508, 532, 556, 581, 606, 632, 658, 685, 712, 740, | |
| 57 | 769, 798, 828, 858, 889, 920, 952, 984, 1017, 1050, | |
| 58 | 1084, 1118, 1153, 1188 | |
| 59 | }; | |
| 60 | ||
| 61 | inline constexpr uint64_t __POW10_SPLIT[1224][3] = { | |
| 62 | { 1u, 72057594037927936u, 0u }, | |
| 63 | { 699646928636035157u, 72057594u, 0u }, | |
| 64 | { 1u, 0u, 256u }, | |
| 65 | { 11902091922964236229u, 4722366482869u, 0u }, | |
| 66 | { 6760415703743915872u, 4722u, 0u }, | |
| 67 | { 1u, 0u, 16777216u }, | |
| 68 | { 13369850649504950658u, 309485009821345068u, 0u }, | |
| 69 | { 15151142278969419334u, 309485009u, 0u }, | |
| 70 | { 1u, 0u, 75511627776u }, | |
| 71 | { 4635408826454083567u, 9437866644873197963u, 1099u }, | |
| 72 | { 12367138975830625353u, 20282409603651u, 0u }, | |
| 73 | { 7555853734021184432u, 20282u, 0u }, | |
| 74 | { 1u, 0u, 250037927936u }, | |
| 75 | { 5171444645924616995u, 699646928636035156u, 72057594u }, | |
| 76 | { 16672297533003297786u, 1329227995784915872u, 0u }, | |
| 77 | { 14479142226848862515u, 1329227995u, 0u }, | |
| 78 | { 1u, 0u, 181645213696u }, | |
| 79 | { 12214193123817091081u, 11902091922964236228u, 114366482869u }, | |
| 80 | { 16592893013671929435u, 6760415703743915871u, 4722u }, | |
| 81 | { 4549827147718617003u, 87112285931760u, 0u }, | |
| 82 | { 5274510003815168971u, 87112u, 0u }, | |
| 83 | { 1u, 0u, 44724781056u }, | |
| 84 | { 9794971998307800535u, 13369850649504950657u, 209821345068u }, | |
| 85 | { 14720142899209240169u, 15151142278969419333u, 309485009u }, | |
| 86 | { 4300745446091561535u, 5708990770823839524u, 0u }, | |
| 87 | { 15197156861335443364u, 5708990770u, 0u }, | |
| 88 | { 1u, 0u, 139251286016u }, | |
| 89 | { 13484604155038683037u, 4635408826454083566u, 67670423947u }, | |
| 90 | { 8356963862052375699u, 12367138975830625352u, 58409603651u }, | |
| 91 | { 5850852848337610021u, 7555853734021184431u, 20282u }, | |
| 92 | { 2712780827214982050u, 374144419156711u, 0u }, | |
| 93 | { 7732076577307618052u, 374144u, 0u }, | |
| 94 | { 1u, 0u, 84280344576u }, | |
| 95 | { 17296309485351745867u, 5171444645924616994u, 160903807060u }, | |
| 96 | { 16598859101615853088u, 16672297533003297785u, 219784915872u }, | |
| 97 | { 7469952526870444257u, 14479142226848862514u, 1329227995u }, | |
| 98 | { 13531654022114669524u, 6073184580144670117u, 1u }, | |
| 99 | { 15757609704383306943u, 24519928653u, 0u }, | |
| 100 | { 9590990814237149590u, 24u, 0u }, | |
| 101 | { 1u, 0u, 196662132736u }, | |
| 102 | { 15408590707489433890u, 12214193123817091080u, 95899502532u }, | |
| 103 | { 18332056844289122710u, 16592893013671929434u, 240246646623u }, | |
| 104 | { 11114572877353986193u, 4549827147718617002u, 72285931760u }, | |
| 105 | { 1703393793997526525u, 5274510003815168970u, 87112u }, | |
| 106 | { 5082852056285196265u, 1606938044258990u, 0u }, | |
| 107 | { 816434266573722365u, 1606938u, 0u }, | |
| 108 | { 1u, 0u, 129530986496u }, | |
| 109 | { 5736523019264798742u, 9794971998307800534u, 69797980545u }, | |
| 110 | { 10129314776268243339u, 14720142899209240168u, 36233143877u }, | |
| 111 | { 16511595775483995364u, 4300745446091561534u, 50823839524u }, | |
| 112 | { 12367293405401453325u, 15197156861335443363u, 5708990770u }, | |
| 113 | { 16934621733248854291u, 13078571300009428617u, 5u }, | |
| 114 | { 10278280417769171336u, 105312291668u, 0u }, | |
| 115 | { 5760764486226151240u, 105u, 0u }, | |
| 116 | { 1u, 0u, 238731001856u }, | |
| 117 | { 4128368337188369761u, 13484604155038683036u, 72453031918u }, | |
| 118 | { 10240941003671005056u, 8356963862052375698u, 175317175368u }, | |
| 119 | { 17933378316822368251u, 5850852848337610020u, 231147060143u }, | |
| 120 | { 8346249813075698616u, 2712780827214982049u, 128419156711u }, | |
| 121 | { 15906203609160902695u, 7732076577307618051u, 374144u }, | |
| 122 | { 14525607416135386328u, 6901746346790563u, 0u }, | |
| 123 | { 6397156777364256320u, 6901746u, 0u }, | |
| 124 | { 1u, 0u, 34937634816u }, | |
| 125 | { 16798760952716600048u, 17296309485351745866u, 249899825954u }, | |
| 126 | { 2419982808370854967u, 16598859101615853087u, 50404946937u }, | |
| 127 | { 2922947087773078956u, 7469952526870444256u, 165733552434u }, | |
| 128 | { 15419220167069510190u, 13531654022114669523u, 77854221733u }, | |
| 129 | { 3452124642157173416u, 15757609704383306942u, 24519928653u }, | |
| 130 | { 5979700067267186899u, 9590990814237149589u, 24u }, | |
| 131 | { 4913998146922579597u, 452312848583u, 0u }, | |
| 132 | { 5771037749337678924u, 452u, 0u }, | |
| 133 | { 1u, 0u, 8835301376u }, | |
| 134 | { 3464734175350698519u, 15408590707489433889u, 90993782792u }, | |
| 135 | { 9334527711335850125u, 18332056844289122709u, 170602522202u }, | |
| 136 | { 7269882896518450106u, 11114572877353986192u, 202092341162u }, | |
| 137 | { 1372511258182263196u, 1703393793997526524u, 174275541962u }, | |
| 138 | { 7571228438575951046u, 5082852056285196264u, 26044258990u }, | |
| 139 | { 2992506536646070406u, 816434266573722364u, 1606938u }, | |
| 140 | { 524517896824344606u, 29642774844752946u, 0u }, | |
| 141 | { 15582941400898702773u, 29642774u, 0u }, | |
| 142 | { 1u, 0u, 214310977536u }, | |
| 143 | { 3846112492507251066u, 5736523019264798741u, 104549111254u }, | |
| 144 | { 16681117750123089487u, 10129314776268243338u, 62895095400u }, | |
| 145 | { 14986314536556547267u, 16511595775483995363u, 163670432318u }, | |
| 146 | { 2573712825027107389u, 12367293405401453324u, 137918027683u }, | |
| 147 | { 7504855874008324928u, 16934621733248854290u, 84557186697u }, | |
| 148 | { 9572138030626879787u, 10278280417769171335u, 105312291668u }, | |
| 149 | { 8520676959353394843u, 5760764486226151239u, 105u }, | |
| 150 | { 13448984662897903496u, 1942668892225u, 0u }, | |
| 151 | { 12338883700918130648u, 1942u, 0u }, | |
| 152 | { 1u, 0u, 156223799296u }, | |
| 153 | { 2517285787892561600u, 4128368337188369760u, 146555162524u }, | |
| 154 | { 4338831817635138103u, 10240941003671005055u, 36972170386u }, | |
| 155 | { 1561495325934523196u, 17933378316822368250u, 161452451108u }, | |
| 156 | { 12262635050079398786u, 8346249813075698615u, 3862277025u }, | |
| 157 | { 11144065765517284188u, 15906203609160902694u, 163787434755u }, | |
| 158 | { 1212260522471875711u, 14525607416135386327u, 242346790563u }, | |
| 159 | { 9695352922247418869u, 6397156777364256319u, 6901746u }, | |
| 160 | { 7227025834627242948u, 127314748520905380u, 0u }, | |
| 161 | { 9609008238705447829u, 127314748u, 0u }, | |
| 162 | { 1u, 0u, 74910662656u }, | |
| 163 | { 3609144142396852269u, 16798760952716600047u, 31131187530u }, | |
| 164 | { 11568848377382068865u, 2419982808370854966u, 224158453279u }, | |
| 165 | { 10068303578029323957u, 2922947087773078955u, 211835877600u }, | |
| 166 | { 11645070846862630231u, 15419220167069510189u, 190187140051u }, | |
| 167 | { 12449386705878485055u, 3452124642157173415u, 149324160190u }, | |
| 168 | { 15025619323517318418u, 5979700067267186898u, 199266388373u }, | |
| 169 | { 14996237555047131272u, 4913998146922579596u, 196312848583u }, | |
| 170 | { 10211005638256058413u, 5771037749337678923u, 452u }, | |
| 171 | { 1014743503555840530u, 8343699359066u, 0u }, | |
| 172 | { 12900897707145290678u, 8343u, 0u }, | |
| 173 | { 1u, 0u, 33187823616u }, | |
| 174 | { 4718003016239473662u, 3464734175350698518u, 149506025761u }, | |
| 175 | { 14865830648693666725u, 9334527711335850124u, 144394101141u }, | |
| 176 | { 14754517212823091778u, 7269882896518450105u, 252074403984u }, | |
| 177 | { 11113946551474911901u, 1372511258182263195u, 232410437116u }, | |
| 178 | { 1963520352638130630u, 7571228438575951045u, 252162224104u }, | |
| 179 | { 13342587341404964200u, 2992506536646070405u, 50028434172u }, | |
| 180 | { 6240392545013573291u, 524517896824344605u, 22844752946u }, | |
| 181 | { 14377490861349714758u, 15582941400898702772u, 29642774u }, | |
| 182 | { 1717863312631397839u, 546812681195752981u, 0u }, | |
| 183 | { 3611005143890591770u, 546812681u, 0u }, | |
| 184 | { 1u, 0u, 21208498176u }, | |
| 185 | { 13168252824351245504u, 3846112492507251065u, 138904285205u }, | |
| 186 | { 735883891883379688u, 16681117750123089486u, 227812409738u }, | |
| 187 | { 10609203866866106404u, 14986314536556547266u, 12139521251u }, | |
| 188 | { 12358191111890306470u, 2573712825027107388u, 18406839052u }, | |
| 189 | { 15229916368406413528u, 7504855874008324927u, 135518906642u }, | |
| 190 | { 7241424335568075942u, 9572138030626879786u, 71461906823u }, | |
| 191 | { 6049715868779871913u, 8520676959353394842u, 65729070919u }, | |
| 192 | { 2000548404719336762u, 13448984662897903495u, 150668892225u }, | |
| 193 | { 1410974761895205301u, 12338883700918130647u, 1942u }, | |
| 194 | { 16000132467694084868u, 35835915874844u, 0u }, | |
| 195 | { 16894908866816792556u, 35835u, 0u }, | |
| 196 | { 1u, 0u, 96136462336u }, | |
| 197 | { 589096329272056762u, 2517285787892561599u, 127235208544u }, | |
| 198 | { 7097729792403256904u, 4338831817635138102u, 250084648831u }, | |
| 199 | { 8553736750439287020u, 1561495325934523195u, 183664758778u }, | |
| 200 | { 2114152625261065696u, 12262635050079398785u, 38604121015u }, | |
| 201 | { 9817523680007641224u, 11144065765517284187u, 215065716774u }, | |
| 202 | { 13047215537500048015u, 1212260522471875710u, 63525586135u }, | |
| 203 | { 16755544192002345880u, 9695352922247418868u, 164391777855u }, | |
| 204 | { 6930119832670648356u, 7227025834627242947u, 60520905380u }, | |
| 205 | { 14560698131901886167u, 9609008238705447828u, 127314748u }, | |
| 206 | { 16408020927503338035u, 2348542582773833227u, 0u }, | |
| 207 | { 14274703510609809116u, 2348542582u, 0u }, | |
| 208 | { 1u, 0u, 239195652096u }, | |
| 209 | { 16428432973129962470u, 3609144142396852268u, 54627148527u }, | |
| 210 | { 3721112279790863774u, 11568848377382068864u, 171545803830u }, | |
| 211 | { 18032764903259620753u, 10068303578029323956u, 45631280555u }, | |
| 212 | { 18058455550468776079u, 11645070846862630230u, 167674882605u }, | |
| 213 | { 15692090139033993190u, 12449386705878485054u, 210814540455u }, | |
| 214 | { 389416944300619393u, 15025619323517318417u, 140812947666u }, | |
| 215 | { 12009691357260487293u, 14996237555047131271u, 75553539724u }, | |
| 216 | { 13494259174449809900u, 10211005638256058412u, 90055009355u }, | |
| 217 | { 18288583400616279877u, 1014743503555840529u, 151699359066u }, | |
| 218 | { 7216107869057472u, 12900897707145290677u, 8343u }, | |
| 219 | { 17237061291959073878u, 153914086704665u, 0u }, | |
| 220 | { 1599418782488783273u, 153914u, 0u }, | |
| 221 | { 1u, 0u, 22255763456u }, | |
| 222 | { 9565464987240335777u, 4718003016239473661u, 140805878294u }, | |
| 223 | { 857713933775880687u, 14865830648693666724u, 185799843980u }, | |
| 224 | { 4621617820081363356u, 14754517212823091777u, 155602488249u }, | |
| 225 | { 9630162611715632528u, 11113946551474911900u, 197106442651u }, | |
| 226 | { 9283986497984645815u, 1963520352638130629u, 133723303109u }, | |
| 227 | { 8981807745082630996u, 13342587341404964199u, 29338292357u }, | |
| 228 | { 18350140531565934622u, 6240392545013573290u, 180779405341u }, | |
| 229 | { 4411619033127524143u, 14377490861349714757u, 21093125556u }, | |
| 230 | { 1852297584111266889u, 1717863312631397838u, 9195752981u }, | |
| 231 | { 11746243463811666096u, 3611005143890591769u, 546812681u }, | |
| 232 | { 6335244004343789147u, 10086913586276986678u, 0u }, | |
| 233 | { 5109502367228239844u, 10086913586u, 0u }, | |
| 234 | { 1603272682579847821u, 10u, 0u }, | |
| 235 | { 1u, 0u, 121713852416u }, | |
| 236 | { 6609546910952910052u, 13168252824351245503u, 78039892345u }, | |
| 237 | { 3911171343112928288u, 735883891883379687u, 194575126094u }, | |
| 238 | { 5254510615100863555u, 10609203866866106403u, 60669938882u }, | |
| 239 | { 3881927570803887650u, 12358191111890306469u, 63825615420u }, | |
| 240 | { 6379348759607163190u, 15229916368406413527u, 42392558399u }, | |
| 241 | { 14595733737222406466u, 7241424335568075941u, 154327955754u }, | |
| 242 | { 14670223432002373542u, 6049715868779871912u, 135108449946u }, | |
| 243 | { 4045087795619708513u, 2000548404719336761u, 215076489095u }, | |
| 244 | { 12598467307137142718u, 1410974761895205300u, 28867368919u }, | |
| 245 | { 734704388050777108u, 16000132467694084867u, 251915874844u }, | |
| 246 | { 5682201693687285822u, 16894908866816792555u, 35835u }, | |
| 247 | { 11048712694145438788u, 661055968790248u, 0u }, | |
| 248 | { 17871025777010319485u, 661055u, 0u }, | |
| 249 | { 1u, 0u, 191031934976u }, | |
| 250 | { 15268761435931663695u, 589096329272056761u, 54384768703u }, | |
| 251 | { 5016238054648555438u, 7097729792403256903u, 59463698998u }, | |
| 252 | { 14236047313993899750u, 8553736750439287019u, 129114608443u }, | |
| 253 | { 6957759675154690848u, 2114152625261065695u, 91532209025u }, | |
| 254 | { 18439367135478514473u, 9817523680007641223u, 126707290971u }, | |
| 255 | { 8539004472540641041u, 13047215537500048014u, 244908319870u }, | |
| 256 | { 1908462039431738399u, 16755544192002345879u, 195375682548u }, | |
| 257 | { 714690453250792146u, 6930119832670648355u, 148789337027u }, | |
| 258 | { 13782189447673929633u, 14560698131901886166u, 11889480596u }, | |
| 259 | { 3584742913798803164u, 16408020927503338034u, 118773833227u }, | |
| 260 | { 4347581515245125291u, 14274703510609809115u, 2348542582u }, | |
| 261 | { 16836742268156371392u, 6429475823218628948u, 2u }, | |
| 262 | { 11764082328865615308u, 43322963970u, 0u }, | |
| 263 | { 5957633711383291746u, 43u, 0u }, | |
| 264 | { 1u, 0u, 44890587136u }, | |
| 265 | { 9917186842884466953u, 16428432973129962469u, 128201721900u }, | |
| 266 | { 4751011869809829335u, 3721112279790863773u, 180977558144u }, | |
| 267 | { 11068497969931435029u, 18032764903259620752u, 86978950836u }, | |
| 268 | { 17118056985122509954u, 18058455550468776078u, 62850669910u }, | |
| 269 | { 14607066080907684459u, 15692090139033993189u, 17021110334u }, | |
| 270 | { 11768892370493391107u, 389416944300619392u, 135651046673u }, | |
| 271 | { 4043396447647747170u, 12009691357260487292u, 44731525255u }, | |
| 272 | { 1670341095362518057u, 13494259174449809899u, 17991426092u }, | |
| 273 | { 3190817644167043165u, 18288583400616279876u, 181000391185u }, | |
| 274 | { 10425820027224322486u, 7216107869057471u, 25934422965u }, | |
| 275 | { 13139964660506311565u, 17237061291959073877u, 58086704665u }, | |
| 276 | { 2297772885416059937u, 1599418782488783272u, 153914u }, | |
| 277 | { 7677687919964523763u, 2839213766779714u, 0u }, | |
| 278 | { 14144589152747892828u, 2839213u, 0u }, | |
| 279 | { 1u, 0u, 253518544896u }, | |
| 280 | { 17069730341503660290u, 9565464987240335776u, 164046496765u }, | |
| 281 | { 18167423787163077107u, 857713933775880686u, 65250538404u }, | |
| 282 | { 3765746945827805904u, 4621617820081363355u, 156522052161u }, | |
| 283 | { 10241734342430761691u, 9630162611715632527u, 197503285916u }, | |
| 284 | { 13345717282537140784u, 9283986497984645814u, 103486904773u }, | |
| 285 | { 9313926784816939953u, 8981807745082630995u, 170994763111u }, | |
| 286 | { 550974205049535019u, 18350140531565934621u, 69239154346u }, | |
| 287 | { 4494692285504086222u, 4411619033127524142u, 206100413253u }, | |
| 288 | { 1134308559863725587u, 1852297584111266888u, 25636765134u }, | |
| 289 | { 17587558045116130233u, 11746243463811666095u, 54343434265u }, | |
| 290 | { 9817142032346161594u, 6335244004343789146u, 50276986678u }, | |
| 291 | { 6071944935834172568u, 5109502367228239843u, 10086913586u }, | |
| 292 | { 11564168293299416955u, 1603272682579847820u, 10u }, | |
| 293 | { 12458266507226064437u, 186070713419u, 0u }, | |
| 294 | { 1304432355328256915u, 186u, 0u }, | |
| 295 | { 1u, 0u, 191358304256u }, | |
| 296 | { 15946798815542087355u, 6609546910952910051u, 231212025023u }, | |
| 297 | { 12082566083831286138u, 3911171343112928287u, 35284847591u }, | |
| 298 | { 11449623684706196411u, 5254510615100863554u, 165210439715u }, | |
| 299 | { 17518743620362604446u, 3881927570803887649u, 215345825189u }, | |
| 300 | { 9451061563087633805u, 6379348759607163189u, 165791236311u }, | |
| 301 | { 13191114787623314926u, 14595733737222406465u, 168795274405u }, | |
| 302 | { 8367349876734474799u, 14670223432002373541u, 57219284648u }, | |
| 303 | { 6544253801674393507u, 4045087795619708512u, 180682964281u }, | |
| 304 | { 16113906253336597498u, 12598467307137142717u, 3039828404u }, | |
| 305 | { 10294087136797312392u, 734704388050777107u, 235308032771u }, | |
| 306 | { 9127173070014462803u, 5682201693687285821u, 232598951915u }, | |
| 307 | { 16266900839595484952u, 11048712694145438787u, 63968790248u }, | |
| 308 | { 3299745387370952632u, 17871025777010319484u, 661055u }, | |
| 309 | { 12061115182604399189u, 12194330274671844u, 0u }, | |
| 310 | { 5066801222582989646u, 12194330u, 0u }, | |
| 311 | { 1u, 0u, 185827721216u }, | |
| 312 | { 7568423425299591513u, 15268761435931663694u, 71271930809u }, | |
| 313 | { 16561505984665207377u, 5016238054648555437u, 235771737671u }, | |
| 314 | { 4329114621856906245u, 14236047313993899749u, 223377180907u }, | |
| 315 | { 1477500474861899139u, 6957759675154690847u, 135999600095u }, | |
| 316 | { 16891579639263969684u, 18439367135478514472u, 142462900359u }, | |
| 317 | { 4684451357140027420u, 8539004472540641040u, 151103457934u }, | |
| 318 | { 14727186580409080709u, 1908462039431738398u, 35038743447u }, | |
| 319 | { 15864176859687308834u, 714690453250792145u, 214747133987u }, | |
| 320 | { 1755486942842684438u, 13782189447673929632u, 50194329302u }, | |
| 321 | { 17417077516652710041u, 3584742913798803163u, 219235682866u }, | |
| 322 | { 4290982361913532783u, 4347581515245125290u, 84912721627u }, | |
| 323 | { 11826659981004351409u, 16836742268156371391u, 2637732180u }, | |
| 324 | { 932930645678090820u, 11764082328865615307u, 43322963970u }, | |
| 325 | { 12707792781328052617u, 5957633711383291745u, 43u }, | |
| 326 | { 16491596426880311906u, 799167628880u, 0u }, | |
| 327 | { 3092207065214166010u, 799u, 0u }, | |
| 328 | { 1u, 0u, 229537611776u }, | |
| 329 | { 8142946531605512550u, 9917186842884466952u, 157257552869u }, | |
| 330 | { 5328402096432654515u, 4751011869809829334u, 144600024477u }, | |
| 331 | { 1932004361303814512u, 11068497969931435028u, 142927971728u }, | |
| 332 | { 2511477647985517771u, 17118056985122509953u, 229791850638u }, | |
| 333 | { 17451375493324716694u, 14607066080907684458u, 128637992933u }, | |
| 334 | { 9489266854478998489u, 11768892370493391106u, 124219192960u }, | |
| 335 | { 8803053132063235169u, 4043396447647747169u, 235090549372u }, | |
| 336 | { 16198682197142616773u, 1670341095362518056u, 68172974571u }, | |
| 337 | { 13696242485403414202u, 3190817644167043164u, 191565184836u }, | |
| 338 | { 16409082426079859931u, 10425820027224322485u, 85712318911u }, | |
| 339 | { 11653410736879597610u, 13139964660506311564u, 168124562517u }, | |
| 340 | { 13589514120653213261u, 2297772885416059936u, 66416208296u }, | |
| 341 | { 8032934885905905774u, 7677687919964523762u, 173766779714u }, | |
| 342 | { 2753021350129449273u, 14144589152747892827u, 2839213u }, | |
| 343 | { 16974897459201404133u, 52374249726338269u, 0u }, | |
| 344 | { 13398576176159101589u, 52374249u, 0u }, | |
| 345 | { 1u, 0u, 160925351936u }, | |
| 346 | { 10284586955251725351u, 17069730341503660289u, 238984858016u }, | |
| 347 | { 5294476488634150891u, 18167423787163077106u, 155204141550u }, | |
| 348 | { 15833244538135063323u, 3765746945827805903u, 143555205531u }, | |
| 349 | { 10348512742273116664u, 10241734342430761690u, 182723472783u }, | |
| 350 | { 13658504610142595663u, 13345717282537140783u, 83504908982u }, | |
| 351 | { 11956362239240850266u, 9313926784816939952u, 29029868371u }, | |
| 352 | { 13415901703662731781u, 550974205049535018u, 46243657757u }, | |
| 353 | { 5161774027546852762u, 4494692285504086221u, 72061490990u }, | |
| 354 | { 15274384838790587711u, 1134308559863725586u, 175953423432u }, | |
| 355 | { 14233354597679374929u, 17587558045116130232u, 90532188335u }, | |
| 356 | { 4274656492162486921u, 9817142032346161593u, 227329160794u }, | |
| 357 | { 12040276505541795046u, 6071944935834172567u, 140626894819u }, | |
| 358 | { 13238307206256765457u, 11564168293299416954u, 75675363980u }, | |
| 359 | { 12850161204172713271u, 12458266507226064436u, 186070713419u }, | |
| 360 | { 17531777095001445154u, 1304432355328256914u, 186u }, | |
| 361 | { 5623628114515245990u, 3432398830065u, 0u }, | |
| 362 | { 7357116143579573377u, 3432u, 0u }, | |
| 363 | { 1u, 0u, 227864477696u }, | |
| 364 | { 3555734177475596582u, 15946798815542087354u, 31654997219u }, | |
| 365 | { 14001876724756424382u, 12082566083831286137u, 66620685343u }, | |
| 366 | { 18159905057231476140u, 11449623684706196410u, 33949692994u }, | |
| 367 | { 5585207679308509467u, 17518743620362604445u, 53512343073u }, | |
| 368 | { 13948697622866724672u, 9451061563087633804u, 65715091765u }, | |
| 369 | { 9807691927739036432u, 13191114787623314925u, 165453594945u }, | |
| 370 | { 15818010096140820918u, 8367349876734474798u, 96354764709u }, | |
| 371 | { 5629845624785010943u, 6544253801674393506u, 189873536608u }, | |
| 372 | { 9517635131137734707u, 16113906253336597497u, 19558043581u }, | |
| 373 | { 619338244618780585u, 10294087136797312391u, 61494785043u }, | |
| 374 | { 11632367007491958899u, 9127173070014462802u, 67881830461u }, | |
| 375 | { 12083314261009739916u, 16266900839595484951u, 124178879555u }, | |
| 376 | { 16880538609458881650u, 3299745387370952631u, 228653834364u }, | |
| 377 | { 17404223674486504228u, 12061115182604399188u, 26274671844u }, | |
| 378 | { 7089067015287185433u, 5066801222582989645u, 12194330u }, | |
| 379 | { 2592264228029443648u, 224945689727159819u, 0u }, | |
| 380 | { 13413731084370224440u, 224945689u, 0u }, | |
| 381 | { 1u, 0u, 78410285056u }, | |
| 382 | { 9323915941641553425u, 7568423425299591512u, 173897801038u }, | |
| 383 | { 12155831029092699564u, 16561505984665207376u, 229234681773u }, | |
| 384 | { 17397171276588232676u, 4329114621856906244u, 31080095461u }, | |
| 385 | { 11874560617553253769u, 1477500474861899138u, 40915694367u }, | |
| 386 | { 13444839516837727954u, 16891579639263969683u, 16253944616u }, | |
| 387 | { 16994416043584590671u, 4684451357140027419u, 30798362384u }, | |
| 388 | { 15879694502877015730u, 14727186580409080708u, 209859998750u }, | |
| 389 | { 4234647645735263359u, 15864176859687308833u, 160095165137u }, | |
| 390 | { 7978589901512919496u, 1755486942842684437u, 219944181664u }, | |
| 391 | { 6114237175390859894u, 17417077516652710040u, 170232614619u }, | |
| 392 | { 8658612872088282708u, 4290982361913532782u, 191641124522u }, | |
| 393 | { 10253813330683324853u, 11826659981004351408u, 203050574271u }, | |
| 394 | { 13289465061747830991u, 932930645678090819u, 97688890827u }, | |
| 395 | { 4123165538545565412u, 12707792781328052616u, 80894011233u }, | |
| 396 | { 7846417485927038481u, 16491596426880311905u, 31167628880u }, | |
| 397 | { 10562273346358018864u, 3092207065214166009u, 799u }, | |
| 398 | { 2691512658346619120u, 14742040721959u, 0u }, | |
| 399 | { 751187558544605998u, 14742u, 0u }, | |
| 400 | { 1u, 0u, 8441430016u }, | |
| 401 | { 3757709791947931308u, 8142946531605512549u, 214288853256u }, | |
| 402 | { 3452755398462519465u, 5328402096432654514u, 20104734166u }, | |
| 403 | { 3105818720159874523u, 1932004361303814511u, 129136147476u }, | |
| 404 | { 16859138458894499364u, 2511477647985517770u, 106946040961u }, | |
| 405 | { 12271894740606233755u, 17451375493324716693u, 2514414186u }, | |
| 406 | { 5429638071845793701u, 9489266854478998488u, 97477214466u }, | |
| 407 | { 145278150038876889u, 8803053132063235168u, 40878132321u }, | |
| 408 | { 9050266019724932450u, 16198682197142616772u, 92742474792u }, | |
| 409 | { 11907016253451490866u, 13696242485403414201u, 181889538140u }, | |
| 410 | { 2472757296513770735u, 16409082426079859930u, 140631732661u }, | |
| 411 | { 10558733798178239360u, 11653410736879597609u, 32736689036u }, | |
| 412 | { 15917322570831255850u, 13589514120653213260u, 242435466272u }, | |
| 413 | { 12254334656791355238u, 8032934885905905773u, 91149241586u }, | |
| 414 | { 7869542424662730262u, 2753021350129449272u, 221920211035u }, | |
| 415 | { 1378558986933000253u, 16974897459201404132u, 233726338269u }, | |
| 416 | { 13521405041909411105u, 13398576176159101588u, 52374249u }, | |
| 417 | { 3206744593298092012u, 966134380754314586u, 0u }, | |
| 418 | { 13914648122214918505u, 966134380u, 0u }, | |
| 419 | { 1u, 0u, 1557528576u }, | |
| 420 | { 1235541077112082496u, 10284586955251725350u, 242287014145u }, | |
| 421 | { 12014985518315533846u, 5294476488634150890u, 207858321906u }, | |
| 422 | { 1561535086344155741u, 15833244538135063322u, 218560993999u }, | |
| 423 | { 12761747276316224577u, 10348512742273116663u, 47740429018u }, | |
| 424 | { 9745594781103966137u, 13658504610142595662u, 176648155695u }, | |
| 425 | { 17514238702394846785u, 11956362239240850265u, 42727277488u }, | |
| 426 | { 2428898913707151713u, 13415901703662731780u, 205279820330u }, | |
| 427 | { 71666709959904945u, 5161774027546852761u, 18828026061u }, | |
| 428 | { 4049380135452919193u, 15274384838790587710u, 184771591698u }, | |
| 429 | { 18422240861777453733u, 14233354597679374928u, 185231729592u }, | |
| 430 | { 2914504416394425696u, 4274656492162486920u, 151652704697u }, | |
| 431 | { 12721377795748989418u, 12040276505541795045u, 122717650071u }, | |
| 432 | { 2626074459217717422u, 13238307206256765456u, 52696608634u }, | |
| 433 | { 4261529925046307655u, 12850161204172713270u, 146950399540u }, | |
| 434 | { 11536038685430305586u, 17531777095001445153u, 241304857490u }, | |
| 435 | { 12555757789435162768u, 5623628114515245989u, 104398830065u }, | |
| 436 | { 11905178684546080059u, 7357116143579573376u, 3432u }, | |
| 437 | { 14032797718924543051u, 63316582777114u, 0u }, | |
| 438 | { 10750340288005853484u, 63316u, 0u }, | |
| 439 | { 1u, 0u, 186192756736u }, | |
| 440 | { 9660290106216358253u, 3555734177475596581u, 121759043258u }, | |
| 441 | { 14820142034615351103u, 14001876724756424381u, 186984450425u }, | |
| 442 | { 12674041783707777619u, 18159905057231476139u, 157302774714u }, | |
| 443 | { 15386686816442679994u, 5585207679308509466u, 140756160413u }, | |
| 444 | { 5679510383719146248u, 13948697622866724671u, 237531676044u }, | |
| 445 | { 1391101719248678506u, 9807691927739036431u, 46857496045u }, | |
| 446 | { 3364596672173710517u, 15818010096140820917u, 162305194542u }, | |
| 447 | { 11276509210104319732u, 5629845624785010942u, 249515952034u }, | |
| 448 | { 5316312656902630164u, 9517635131137734706u, 135033574393u }, | |
| 449 | { 17470981304473644647u, 619338244618780584u, 82630591879u }, | |
| 450 | { 7373293636384920591u, 11632367007491958898u, 23655037778u }, | |
| 451 | { 7616810902585191937u, 12083314261009739915u, 183915095831u }, | |
| 452 | { 12740295655921903924u, 16880538609458881649u, 84943484855u }, | |
| 453 | { 18366635945916526940u, 17404223674486504227u, 77384299092u }, | |
| 454 | { 4472171448243407067u, 7089067015287185432u, 11140526925u }, | |
| 455 | { 229592460858185629u, 2592264228029443647u, 25727159819u }, | |
| 456 | { 12749672866417114996u, 13413731084370224439u, 224945689u }, | |
| 457 | { 9452256722867098693u, 4149515568880992958u, 0u }, | |
| 458 | { 16251451636418604634u, 4149515568u, 0u }, | |
| 459 | { 1u, 0u, 88505450496u }, | |
| 460 | { 4515791283442995454u, 9323915941641553424u, 80658968920u }, | |
| 461 | { 13306155670047701346u, 12155831029092699563u, 4943102544u }, | |
| 462 | { 4456930152933417601u, 17397171276588232675u, 130643721220u }, | |
| 463 | { 9089157128546489637u, 11874560617553253768u, 147728846210u }, | |
| 464 | { 12437332180345515840u, 13444839516837727953u, 27921269139u }, | |
| 465 | { 3433060408790452524u, 16994416043584590670u, 132860839963u }, | |
| 466 | { 8275594526021936172u, 15879694502877015729u, 33229560708u }, | |
| 467 | { 3846512444641107689u, 4234647645735263358u, 21432520225u }, | |
| 468 | { 6210962618469046250u, 7978589901512919495u, 152331453461u }, | |
| 469 | { 7272858906616296575u, 6114237175390859893u, 110469384344u }, | |
| 470 | { 3710743300451225347u, 8658612872088282707u, 176555860334u }, | |
| 471 | { 6424677242672030600u, 10253813330683324852u, 67720423344u }, | |
| 472 | { 11485842256170301862u, 13289465061747830990u, 136223517251u }, | |
| 473 | { 7355797963557024308u, 4123165538545565411u, 97425355144u }, | |
| 474 | { 6358188982569427273u, 7846417485927038480u, 249572581985u }, | |
| 475 | { 12475094728768767402u, 10562273346358018863u, 39145907193u }, | |
| 476 | { 17288154837907896183u, 2691512658346619119u, 150040721959u }, | |
| 477 | { 2983850577727105262u, 751187558544605997u, 14742u }, | |
| 478 | { 13918604635001185935u, 271942652322184u, 0u }, | |
| 479 | { 12033220395769876327u, 271942u, 0u }, | |
| 480 | { 1u, 0u, 101203705856u }, | |
| 481 | { 5782377197813462997u, 3757709791947931307u, 178187174245u }, | |
| 482 | { 17732139848231399226u, 3452755398462519464u, 111168366770u }, | |
| 483 | { 3628839527415562921u, 3105818720159874522u, 202913935727u }, | |
| 484 | { 3188692267613601004u, 16859138458894499363u, 149665260746u }, | |
| 485 | { 5168130193478377352u, 12271894740606233754u, 216294341269u }, | |
| 486 | { 12556227529405091290u, 5429638071845793700u, 96007875544u }, | |
| 487 | { 15087090312791441192u, 145278150038876888u, 196490615904u }, | |
| 488 | { 10281804758610642494u, 9050266019724932449u, 185645480644u }, | |
| 489 | { 14238177586158586580u, 11907016253451490865u, 218134048441u }, | |
| 490 | { 7107927498217678128u, 2472757296513770734u, 41572390106u }, | |
| 491 | { 3845814658485364450u, 10558733798178239359u, 76862879785u }, | |
| 492 | { 714293333681725946u, 15917322570831255849u, 109664308812u }, | |
| 493 | { 16766172658649116982u, 12254334656791355237u, 56426608749u }, | |
| 494 | { 812461421432632215u, 7869542424662730261u, 228074731832u }, | |
| 495 | { 15218024718633799196u, 1378558986933000252u, 148732996836u }, | |
| 496 | { 8110797782612805146u, 13521405041909411104u, 90173837972u }, | |
| 497 | { 15941193964933529227u, 3206744593298092011u, 108754314586u }, | |
| 498 | { 14144280602323277933u, 13914648122214918504u, 966134380u }, | |
| 499 | { 15072402647813125245u, 17822033662586700072u, 0u }, | |
| 500 | { 10822706091283369889u, 17822033662u, 0u }, | |
| 501 | { 15163844593710966731u, 17u, 0u }, | |
| 502 | { 1u, 0u, 38066978816u }, | |
| 503 | { 2408529687792073670u, 1235541077112082495u, 234651333670u }, | |
| 504 | { 3980682212356510808u, 12014985518315533845u, 26084650986u }, | |
| 505 | { 4202670442792148519u, 1561535086344155740u, 247691815706u }, | |
| 506 | { 9419583343154651922u, 12761747276316224576u, 78528309751u }, | |
| 507 | { 16359166491570434575u, 9745594781103966136u, 89949448782u }, | |
| 508 | { 12567727056384237385u, 17514238702394846784u, 4131670873u }, | |
| 509 | { 2068388267923286639u, 2428898913707151712u, 153003885060u }, | |
| 510 | { 5689135844565021196u, 71666709959904944u, 62219517337u }, | |
| 511 | { 3104061965171139313u, 4049380135452919192u, 80998671678u }, | |
| 512 | { 7955173880156328016u, 18422240861777453732u, 136157995600u }, | |
| 513 | { 1445179403240833754u, 2914504416394425695u, 229689627272u }, | |
| 514 | { 12538201164459126715u, 12721377795748989417u, 16142359781u }, | |
| 515 | { 7580606719088482667u, 2626074459217717421u, 54231018000u }, | |
| 516 | { 8168318283218819755u, 4261529925046307654u, 33625369910u }, | |
| 517 | { 5249615277755961676u, 11536038685430305585u, 165680648993u }, | |
| 518 | { 6312997372068219831u, 12555757789435162767u, 128645381029u }, | |
| 519 | { 9183815417025176703u, 11905178684546080058u, 26760719488u }, | |
| 520 | { 10683849953373876937u, 14032797718924543050u, 84582777114u }, | |
| 521 | { 17175012155615667568u, 10750340288005853483u, 63316u }, | |
| 522 | { 18003508288378896912u, 1167984798111281u, 0u }, | |
| 523 | { 14722554560950996951u, 1167984u, 0u }, | |
| 524 | { 1u, 0u, 37523685376u }, | |
| 525 | { 15059324482416394930u, 9660290106216358252u, 189803401509u }, | |
| 526 | { 4134778595813308312u, 14820142034615351102u, 171687061181u }, | |
| 527 | { 16321118342639660948u, 12674041783707777618u, 26834113963u }, | |
| 528 | { 1523550293123468805u, 15386686816442679993u, 63307886874u }, | |
| 529 | { 8016371634569878509u, 5679510383719146247u, 15075411775u }, | |
| 530 | { 9884220139611134110u, 1391101719248678505u, 181182395151u }, | |
| 531 | { 7218073002727840414u, 3364596672173710516u, 254611300789u }, | |
| 532 | { 16062235669481359233u, 11276509210104319731u, 50288197886u }, | |
| 533 | { 15558048660560338002u, 5316312656902630163u, 168947103794u }, | |
| 534 | { 8394398745765058609u, 17470981304473644646u, 114399707048u }, | |
| 535 | { 5693296366442904274u, 7373293636384920590u, 139412908146u }, | |
| 536 | { 11783494675061161358u, 7616810902585191936u, 113690652811u }, | |
| 537 | { 13377293110865447894u, 12740295655921903923u, 35995657329u }, | |
| 538 | { 12840734051093062130u, 18366635945916526939u, 24242436899u }, | |
| 539 | { 7009868331566697505u, 4472171448243407066u, 63012446232u }, | |
| 540 | { 5019690705031194477u, 229592460858185628u, 55691161151u }, | |
| 541 | { 8608277240439804984u, 12749672866417114995u, 190512407863u }, | |
| 542 | { 12172482590657749222u, 9452256722867098692u, 48880992958u }, | |
| 543 | { 16613484892678771990u, 16251451636418604633u, 4149515568u }, | |
| 544 | { 5721488662757049244u, 2758075434182769113u, 4u }, | |
| 545 | { 386931106438877039u, 76545051729u, 0u }, | |
| 546 | { 10054429752182825659u, 76u, 0u }, | |
| 547 | { 1u, 0u, 16244801536u }, | |
| 548 | { 8634592106137071313u, 4515791283442995453u, 171721328144u }, | |
| 549 | { 12626356501369830731u, 13306155670047701345u, 227241610667u }, | |
| 550 | { 4803333258178976933u, 4456930152933417600u, 136492724195u }, | |
| 551 | { 13613083223558209297u, 9089157128546489636u, 209674229128u }, | |
| 552 | { 16106967997237446989u, 12437332180345515839u, 78186106577u }, | |
| 553 | { 14832921244380020170u, 3433060408790452523u, 177448620878u }, | |
| 554 | { 13774024637717231397u, 8275594526021936171u, 126208519857u }, | |
| 555 | { 9673012968505228885u, 3846512444641107688u, 199336696958u }, | |
| 556 | { 5391832334264815667u, 6210962618469046249u, 117394262471u }, | |
| 557 | { 16514436292632703088u, 7272858906616296574u, 83201159797u }, | |
| 558 | { 12025036352783454153u, 3710743300451225346u, 180348282451u }, | |
| 559 | { 7059867105311401050u, 6424677242672030599u, 206622648756u }, | |
| 560 | { 12769210631552594670u, 11485842256170301861u, 227398758606u }, | |
| 561 | { 8328873878884556145u, 7355797963557024307u, 16344678115u }, | |
| 562 | { 1016565892414238685u, 6358188982569427272u, 47676276240u }, | |
| 563 | { 9662978461927250281u, 12475094728768767401u, 239937192751u }, | |
| 564 | { 13729967277551868112u, 17288154837907896182u, 45161754863u }, | |
| 565 | { 6371593776693359475u, 2983850577727105261u, 136754529069u }, | |
| 566 | { 17617208110845643245u, 13918604635001185934u, 70652322184u }, | |
| 567 | { 14960960225633086797u, 12033220395769876326u, 271942u }, | |
| 568 | { 12090634301321662558u, 5016456510113118u, 0u }, | |
| 569 | { 9409926148478635503u, 5016456u, 0u }, | |
| 570 | { 1u, 0u, 171313463296u }, | |
| 571 | { 4307062684900157136u, 5782377197813462996u, 168961261227u }, | |
| 572 | { 15300759383869911853u, 17732139848231399225u, 218196719784u }, | |
| 573 | { 16007534237643445447u, 3628839527415562920u, 35172859354u }, | |
| 574 | { 7138502295759677634u, 3188692267613601003u, 154280164899u }, | |
| 575 | { 8218537071653683708u, 5168130193478377351u, 164680674458u }, | |
| 576 | { 2254219416760329296u, 12556227529405091289u, 216817872804u }, | |
| 577 | { 3057410459568460683u, 15087090312791441191u, 97557377752u }, | |
| 578 | { 8217810929938874370u, 10281804758610642493u, 49771853153u }, | |
| 579 | { 11741126472498340929u, 14238177586158586579u, 238385321521u }, | |
| 580 | { 1175325363726654805u, 7107927498217678127u, 127208482030u }, | |
| 581 | { 9428843070696730900u, 3845814658485364449u, 41038721919u }, | |
| 582 | { 12662500978715131896u, 714293333681725945u, 101908896041u }, | |
| 583 | { 6443045597035184564u, 16766172658649116981u, 21044043621u }, | |
| 584 | { 1921385512639171183u, 812461421432632214u, 60824970773u }, | |
| 585 | { 10469475094355551399u, 15218024718633799195u, 32439687228u }, | |
| 586 | { 14679174489076953574u, 8110797782612805145u, 235864173856u }, | |
| 587 | { 11853074234719825644u, 15941193964933529226u, 104766762987u }, | |
| 588 | { 8270896886596139124u, 14144280602323277932u, 40817076584u }, | |
| 589 | { 16532667046659118126u, 15072402647813125244u, 254586700072u }, | |
| 590 | { 148341279888833483u, 10822706091283369888u, 17822033662u }, | |
| 591 | { 10364629296397276041u, 15163844593710966730u, 17u }, | |
| 592 | { 14265682585545771671u, 328758493846u, 0u }, | |
| 593 | { 13991741872911347878u, 328u, 0u }, | |
| 594 | { 1u, 0u, 63130566656u }, | |
| 595 | { 14029045786848724433u, 2408529687792073669u, 21215793215u }, | |
| 596 | { 4005878521026842341u, 3980682212356510807u, 92227827221u }, | |
| 597 | { 3428326338640386488u, 4202670442792148518u, 64510636636u }, | |
| 598 | { 1010001558294829380u, 9419583343154651921u, 184886832192u }, | |
| 599 | { 2012063724327403418u, 16359166491570434574u, 64681297848u }, | |
| 600 | { 10997154538851372612u, 12567727056384237384u, 96112127552u }, | |
| 601 | { 1917749645489607898u, 2068388267923286638u, 176308408672u }, | |
| 602 | { 9763872523711218805u, 5689135844565021195u, 152168271536u }, | |
| 603 | { 15875699078454059311u, 3104061965171139312u, 164431250840u }, | |
| 604 | { 10966529452671276106u, 7955173880156328015u, 95078343332u }, | |
| 605 | { 18073244132105736913u, 1445179403240833753u, 233679697247u }, | |
| 606 | { 4435241176994913173u, 12538201164459126714u, 173410945513u }, | |
| 607 | { 5464400086219074323u, 7580606719088482666u, 70442805421u }, | |
| 608 | { 2445909179323258812u, 8168318283218819754u, 49284582214u }, | |
| 609 | { 873962058644121211u, 5249615277755961675u, 143342228273u }, | |
| 610 | { 16675872194112650857u, 6312997372068219830u, 58497855631u }, | |
| 611 | { 10680102689274800355u, 9183815417025176702u, 74579172666u }, | |
| 612 | { 2370498083108897524u, 10683849953373876936u, 43931059274u }, | |
| 613 | { 15354400521451334666u, 17175012155615667567u, 49975972139u }, | |
| 614 | { 259991949657381021u, 18003508288378896911u, 112798111281u }, | |
| 615 | { 10335286558772966917u, 14722554560950996950u, 1167984u }, | |
| 616 | { 16337526653906757263u, 21545516652742137u, 0u }, | |
| 617 | { 12040967163702784894u, 21545516u, 0u }, | |
| 618 | { 1u, 0u, 108816367616u }, | |
| 619 | { 3373309160242342187u, 15059324482416394929u, 62224146796u }, | |
| 620 | { 13639841054510584221u, 4134778595813308311u, 82884769598u }, | |
| 621 | { 15898855427739708031u, 16321118342639660947u, 185082591826u }, | |
| 622 | { 4544387940067005419u, 1523550293123468804u, 7434568377u }, | |
| 623 | { 5281598644835398575u, 8016371634569878508u, 105535824647u }, | |
| 624 | { 13675642405083408835u, 9884220139611134109u, 180391292521u }, | |
| 625 | { 3973392623768015721u, 7218073002727840413u, 243870735540u }, | |
| 626 | { 4491285101509114191u, 16062235669481359232u, 19843403507u }, | |
| 627 | { 15002304272810270500u, 15558048660560338001u, 102455061267u }, | |
| 628 | { 17325098540619893468u, 8394398745765058608u, 14308634214u }, | |
| 629 | { 1137212864974584822u, 5693296366442904273u, 638784526u }, | |
| 630 | { 2619406097224859078u, 11783494675061161357u, 51725184512u }, | |
| 631 | { 8281347529729293732u, 13377293110865447893u, 91696097587u }, | |
| 632 | { 11344719666795450104u, 12840734051093062129u, 218380005723u }, | |
| 633 | { 17283870506679425783u, 7009868331566697504u, 156272117978u }, | |
| 634 | { 11054210518010603775u, 5019690705031194476u, 115466655644u }, | |
| 635 | { 6399455551799092885u, 8608277240439804983u, 68659871603u }, | |
| 636 | { 12930529916573967170u, 12172482590657749221u, 89900618820u }, | |
| 637 | { 14550097052337552404u, 16613484892678771989u, 217310162521u }, | |
| 638 | { 12487632712206414748u, 5721488662757049243u, 81020975577u }, | |
| 639 | { 5791017277843595715u, 386931106438877038u, 76545051729u }, | |
| 640 | { 10227264183449036113u, 10054429752182825658u, 76u }, | |
| 641 | { 2006055278511721441u, 1412006979354u, 0u }, | |
| 642 | { 128746359043876333u, 1412u, 0u }, | |
| 643 | { 1u, 0u, 253468082176u }, | |
| 644 | { 7408146306870995754u, 8634592106137071312u, 97684476157u }, | |
| 645 | { 8299024588195267962u, 12626356501369830730u, 128260389217u }, | |
| 646 | { 1497052939192040881u, 4803333258178976932u, 36737966720u }, | |
| 647 | { 16771714264265803747u, 13613083223558209296u, 63873160484u }, | |
| 648 | { 142988846654429432u, 16106967997237446988u, 43804094271u }, | |
| 649 | { 11839838367716104145u, 14832921244380020169u, 43746691371u }, | |
| 650 | { 6019646776647679765u, 13774024637717231396u, 232524375083u }, | |
| 651 | { 4611972391702034948u, 9673012968505228884u, 233292291816u }, | |
| 652 | { 16447182322205429545u, 5391832334264815666u, 126895249385u }, | |
| 653 | { 2113477168726764245u, 16514436292632703087u, 2651878526u }, | |
| 654 | { 3536261187802311516u, 12025036352783454152u, 135382716162u }, | |
| 655 | { 18444381860986709854u, 7059867105311401049u, 165692220295u }, | |
| 656 | { 4734315730275909838u, 12769210631552594669u, 51451509157u }, | |
| 657 | { 9974936316849658174u, 8328873878884556144u, 72055108147u }, | |
| 658 | { 11864423681540657642u, 1016565892414238684u, 169523831112u }, | |
| 659 | { 8207245621417902667u, 9662978461927250280u, 118744303017u }, | |
| 660 | { 7992526918695295028u, 13729967277551868111u, 237345404790u }, | |
| 661 | { 8679354522130259987u, 6371593776693359474u, 142955030765u }, | |
| 662 | { 6065763799692166461u, 17617208110845643244u, 102811035278u }, | |
| 663 | { 18143341109049024976u, 14960960225633086796u, 94655434598u }, | |
| 664 | { 15242492331283350570u, 12090634301321662557u, 136510113118u }, | |
| 665 | { 9986352353182266963u, 9409926148478635502u, 5016456u }, | |
| 666 | { 17340463289911536077u, 92537289398950870u, 0u }, | |
| 667 | { 7359344614214233035u, 92537289u, 0u }, | |
| 668 | { 1u, 0u, 212233486336u }, | |
| 669 | { 419091135888749535u, 4307062684900157135u, 57829455828u }, | |
| 670 | { 1073142712661309790u, 15300759383869911852u, 168867770169u }, | |
| 671 | { 11076438902195672286u, 16007534237643445446u, 235386978984u }, | |
| 672 | { 1820390940081322073u, 7138502295759677633u, 135445527787u }, | |
| 673 | { 18417808973944523597u, 8218537071653683707u, 217122201479u }, | |
| 674 | { 10251294197731582957u, 2254219416760329295u, 39165742553u }, | |
| 675 | { 1502394029870156428u, 3057410459568460682u, 61445488423u }, | |
| 676 | { 321014853559106075u, 8217810929938874369u, 211636487741u }, | |
| 677 | { 2390953058510591778u, 11741126472498340928u, 47063714515u }, | |
| 678 | { 10685224265907994087u, 1175325363726654804u, 225511138607u }, | |
| 679 | { 5967405799190505023u, 9428843070696730899u, 249686435553u }, | |
| 680 | { 11210723659228214761u, 12662500978715131895u, 53349278201u }, | |
| 681 | { 12327123641078462773u, 6443045597035184563u, 150104158517u }, | |
| 682 | { 1709976940107894237u, 1921385512639171182u, 27567551382u }, | |
| 683 | { 16607686590938553511u, 10469475094355551398u, 25795759643u }, | |
| 684 | { 18332088094272679457u, 14679174489076953573u, 138642556441u }, | |
| 685 | { 2946170632136780882u, 11853074234719825643u, 108448366218u }, | |
| 686 | { 4824449494694383419u, 8270896886596139123u, 124896237676u }, | |
| 687 | { 17008332258693407134u, 16532667046659118125u, 160008041596u }, | |
| 688 | { 1773419466622750661u, 148341279888833482u, 202561867680u }, | |
| 689 | { 3892343466023784379u, 10364629296397276040u, 150773344202u }, | |
| 690 | { 12001571085575422796u, 14265682585545771670u, 72758493846u }, | |
| 691 | { 12933506765500977582u, 13991741872911347877u, 328u }, | |
| 692 | { 11884830007749143734u, 6064523798049u, 0u }, | |
| 693 | { 9662368568096205337u, 6064u, 0u }, | |
| 694 | { 1u, 0u, 197760516096u }, | |
| 695 | { 16801499925276664442u, 14029045786848724432u, 87217159109u }, | |
| 696 | { 10492407990787637084u, 4005878521026842340u, 38185849943u }, | |
| 697 | { 7673849751013230269u, 3428326338640386487u, 17054752294u }, | |
| 698 | { 6046724489853072367u, 1010001558294829379u, 14109074193u }, | |
| 699 | { 3723941391207507903u, 2012063724327403417u, 72596156942u }, | |
| 700 | { 16844122108860347659u, 10997154538851372611u, 110103961416u }, | |
| 701 | { 10622020182694668027u, 1917749645489607897u, 11529300590u }, | |
| 702 | { 8741198820686854862u, 9763872523711218804u, 240860623371u }, | |
| 703 | { 6855480461211306807u, 15875699078454059310u, 79594496752u }, | |
| 704 | { 10005708458011566304u, 10966529452671276105u, 217979752527u }, | |
| 705 | { 8932093106442919061u, 18073244132105736912u, 186240434905u }, | |
| 706 | { 9062763476260756743u, 4435241176994913172u, 106296225722u }, | |
| 707 | { 13664977682032775521u, 5464400086219074322u, 170132593002u }, | |
| 708 | { 1078499125430623453u, 2445909179323258811u, 75047377578u }, | |
| 709 | { 6554586738078431161u, 873962058644121210u, 182904000843u }, | |
| 710 | { 12177313698643242883u, 16675872194112650856u, 126578969526u }, | |
| 711 | { 16615072271904633953u, 10680102689274800354u, 200128504958u }, | |
| 712 | { 16375404983106569285u, 2370498083108897523u, 111832363720u }, | |
| 713 | { 13552251831473522729u, 15354400521451334665u, 15014094191u }, | |
| 714 | { 8330500218412111874u, 259991949657381020u, 214560277007u }, | |
| 715 | { 7044338079053294004u, 10335286558772966916u, 249885659094u }, | |
| 716 | { 2688849443046530184u, 16337526653906757262u, 44652742137u }, | |
| 717 | { 855940991879596845u, 12040967163702784893u, 21545516u }, | |
| 718 | { 7344363609485825662u, 397444631628981487u, 0u }, | |
| 719 | { 11602660525134634992u, 397444631u, 0u }, | |
| 720 | { 1u, 0u, 177182867456u }, | |
| 721 | { 16945343208344873835u, 3373309160242342186u, 151739417265u }, | |
| 722 | { 9617992661337889145u, 13639841054510584220u, 147861878679u }, | |
| 723 | { 18280344933262742088u, 15898855427739708030u, 4246351763u }, | |
| 724 | { 5179975582362777795u, 4544387940067005418u, 236286316036u }, | |
| 725 | { 1798918997870037130u, 5281598644835398574u, 157741358060u }, | |
| 726 | { 6327667344756325883u, 13675642405083408834u, 157215398045u }, | |
| 727 | { 18380327574124007701u, 3973392623768015720u, 128243473053u }, | |
| 728 | { 18015447557304295289u, 4491285101509114190u, 81813276544u }, | |
| 729 | { 10315590748073249878u, 15002304272810270499u, 48939195473u }, | |
| 730 | { 7697916092577993382u, 17325098540619893467u, 209061648432u }, | |
| 731 | { 3124132817942110723u, 1137212864974584821u, 141141998289u }, | |
| 732 | { 7448238998520507049u, 2619406097224859077u, 213448932749u }, | |
| 733 | { 13892823322374205297u, 8281347529729293731u, 241614998485u }, | |
| 734 | { 11042137840046332564u, 11344719666795450103u, 32936960497u }, | |
| 735 | { 10513966307445593804u, 17283870506679425782u, 108599249952u }, | |
| 736 | { 9388437460943526958u, 11054210518010603774u, 55346915180u }, | |
| 737 | { 10967228614677896228u, 6399455551799092884u, 229700965431u }, | |
| 738 | { 2310996671540235542u, 12930529916573967169u, 21788762341u }, | |
| 739 | { 4989110555003898587u, 14550097052337552403u, 155676955925u }, | |
| 740 | { 16271452421983657679u, 12487632712206414747u, 110313931675u }, | |
| 741 | { 9523160181437090473u, 5791017277843595714u, 186554421102u }, | |
| 742 | { 13137707423765072250u, 10227264183449036112u, 26108748474u }, | |
| 743 | { 16846859744221860705u, 2006055278511721440u, 132006979354u }, | |
| 744 | { 7767140033449795569u, 128746359043876332u, 1412u }, | |
| 745 | { 17169456915721160017u, 26046931378436u, 0u }, | |
| 746 | { 17180899661833327819u, 26046u, 0u }, | |
| 747 | { 1u, 0u, 208401596416u }, | |
| 748 | { 17572520700934791416u, 7408146306870995753u, 74449891024u }, | |
| 749 | { 17968798858233825417u, 8299024588195267961u, 164081155402u }, | |
| 750 | { 15338423313945305609u, 1497052939192040880u, 16909196452u }, | |
| 751 | { 17895321323836726301u, 16771714264265803746u, 76007751440u }, | |
| 752 | { 814069333008965773u, 142988846654429431u, 201641838924u }, | |
| 753 | { 7200328959852723947u, 11839838367716104144u, 36326325705u }, | |
| 754 | { 759884557248133773u, 6019646776647679764u, 84250015524u }, | |
| 755 | { 13410165861863974851u, 4611972391702034947u, 50891603540u }, | |
| 756 | { 6278452420856351570u, 16447182322205429544u, 111114571826u }, | |
| 757 | { 9072115382556676442u, 2113477168726764244u, 200191701103u }, | |
| 758 | { 2755882551854926563u, 3536261187802311515u, 89999871944u }, | |
| 759 | { 8496072611504649269u, 18444381860986709853u, 237256647769u }, | |
| 760 | { 4122009033579215815u, 4734315730275909837u, 112540742381u }, | |
| 761 | { 10222217724450527221u, 9974936316849658173u, 220643171696u }, | |
| 762 | { 2064539481554006325u, 11864423681540657641u, 104444915676u }, | |
| 763 | { 7935605886598063693u, 8207245621417902666u, 207433275752u }, | |
| 764 | { 7805147585347548429u, 7992526918695295027u, 114470508751u }, | |
| 765 | { 5709020905457661273u, 8679354522130259986u, 236328825714u }, | |
| 766 | { 16257370307404906674u, 6065763799692166460u, 76983552492u }, | |
| 767 | { 14971258192939373646u, 18143341109049024975u, 93826297164u }, | |
| 768 | { 1133404845901376390u, 15242492331283350569u, 238541361245u }, | |
| 769 | { 9460827548162822047u, 9986352353182266962u, 214940028398u }, | |
| 770 | { 1273897659779791346u, 17340463289911536076u, 201398950870u }, | |
| 771 | { 7833262224435092783u, 7359344614214233034u, 92537289u }, | |
| 772 | { 3033420566713364587u, 1707011694817242694u, 0u }, | |
| 773 | { 15075466825360349103u, 1707011694u, 0u }, | |
| 774 | { 1u, 0u, 207022718976u }, | |
| 775 | { 2484134775182816690u, 419091135888749534u, 44058175183u }, | |
| 776 | { 18400539815335991277u, 1073142712661309789u, 198600454956u }, | |
| 777 | { 485494064952118286u, 11076438902195672285u, 193098683590u }, | |
| 778 | { 17577048805241314891u, 1820390940081322072u, 251998431425u }, | |
| 779 | { 2863946907557583807u, 18417808973944523596u, 79555723771u }, | |
| 780 | { 13045307417786230800u, 10251294197731582956u, 138081444943u }, | |
| 781 | { 12032088871615097766u, 1502394029870156427u, 1017402250u }, | |
| 782 | { 8848763446997690580u, 321014853559106074u, 64129613825u }, | |
| 783 | { 10031289150307672684u, 2390953058510591777u, 84579247168u }, | |
| 784 | { 11592215575498656563u, 10685224265907994086u, 19323493716u }, | |
| 785 | { 15894436747956898388u, 5967405799190505022u, 247607734547u }, | |
| 786 | { 2091546719588500923u, 11210723659228214760u, 179668254711u }, | |
| 787 | { 5863809244813756109u, 12327123641078462772u, 110092698035u }, | |
| 788 | { 11303008753675411245u, 1709976940107894236u, 166900304494u }, | |
| 789 | { 13238426537506910532u, 16607686590938553510u, 229993784486u }, | |
| 790 | { 17258458071023005565u, 18332088094272679456u, 235159712229u }, | |
| 791 | { 8385733444777075179u, 2946170632136780881u, 115261533931u }, | |
| 792 | { 9530757096163247300u, 4824449494694383418u, 45922023539u }, | |
| 793 | { 14423000845391072217u, 17008332258693407133u, 202096137261u }, | |
| 794 | { 10953140011159884311u, 1773419466622750660u, 136211004362u }, | |
| 795 | { 12228340237948264127u, 3892343466023784378u, 150650606472u }, | |
| 796 | { 11279134946966259189u, 12001571085575422795u, 165701126806u }, | |
| 797 | { 14640097792684582651u, 12933506765500977581u, 33644277925u }, | |
| 798 | { 6232313315128656728u, 11884830007749143733u, 176523798049u }, | |
| 799 | { 16136121832933322088u, 9662368568096205336u, 6064u }, | |
| 800 | { 15074767079673358271u, 111870718431542u, 0u }, | |
| 801 | { 13252722804829281908u, 111870u, 0u }, | |
| 802 | { 1u, 0u, 208910811136u }, | |
| 803 | { 7740175894281560509u, 16801499925276664441u, 228568794576u }, | |
| 804 | { 15670495392425593226u, 10492407990787637083u, 183416000228u }, | |
| 805 | { 15152257626756992778u, 7673849751013230268u, 67327793591u }, | |
| 806 | { 4090073428152440422u, 6046724489853072366u, 153201875267u }, | |
| 807 | { 14450327772834205584u, 3723941391207507902u, 67913121689u }, | |
| 808 | { 4466091895542494216u, 16844122108860347658u, 217575820867u }, | |
| 809 | { 10454115378553795377u, 10622020182694668026u, 116473861337u }, | |
| 810 | { 2267817233475657788u, 8741198820686854861u, 46371636340u }, | |
| 811 | { 5500455702636497521u, 6855480461211306806u, 73542410542u }, | |
| 812 | { 15178768299492252549u, 10005708458011566303u, 208484209737u }, | |
| 813 | { 7062359872332045590u, 8932093106442919060u, 148491293392u }, | |
| 814 | { 12297347290027942576u, 9062763476260756742u, 18740779924u }, | |
| 815 | { 8030124596941085588u, 13664977682032775520u, 187058465554u }, | |
| 816 | { 6526656990996654843u, 1078499125430623452u, 122355324859u }, | |
| 817 | { 6254287345256979850u, 6554586738078431160u, 104660133498u }, | |
| 818 | { 6642007136244870032u, 12177313698643242882u, 226900704872u }, | |
| 819 | { 2027592955437164718u, 16615072271904633952u, 243887712482u }, | |
| 820 | { 942718349157325567u, 16375404983106569284u, 9734669043u }, | |
| 821 | { 14617066671884002278u, 13552251831473522728u, 156451597321u }, | |
| 822 | { 6831631114396133348u, 8330500218412111873u, 4381874332u }, | |
| 823 | { 14603040013386939258u, 7044338079053294003u, 142145762820u }, | |
| 824 | { 9906106765319401103u, 2688849443046530183u, 125046400654u }, | |
| 825 | { 1396179595609933063u, 855940991879596844u, 239398138749u }, | |
| 826 | { 11524884268464976417u, 7344363609485825661u, 23628981487u }, | |
| 827 | { 382929570730827274u, 11602660525134634991u, 397444631u }, | |
| 828 | { 6109721884461301381u, 7331559403129590068u, 0u }, | |
| 829 | { 2390514825000339691u, 7331559403u, 0u }, | |
| 830 | { 6116191454763441755u, 7u, 0u }, | |
| 831 | { 1u, 0u, 42918608896u }, | |
| 832 | { 11598868771099176310u, 16945343208344873834u, 156521392426u }, | |
| 833 | { 14449966445520085105u, 9617992661337889144u, 126990979484u }, | |
| 834 | { 11675595287405614726u, 18280344933262742087u, 234280807038u }, | |
| 835 | { 15860796398550489897u, 5179975582362777794u, 174097519594u }, | |
| 836 | { 16180408435245829662u, 1798918997870037129u, 194343023534u }, | |
| 837 | { 13756992797154950706u, 6327667344756325882u, 104996399554u }, | |
| 838 | { 8830551328786758466u, 18380327574124007700u, 78976619368u }, | |
| 839 | { 16699955256560951264u, 18015447557304295288u, 35559209294u }, | |
| 840 | { 10038983627153402074u, 10315590748073249877u, 219417304867u }, | |
| 841 | { 15085100736692127346u, 7697916092577993381u, 245169359579u }, | |
| 842 | { 10007783780289711125u, 3124132817942110722u, 197403769845u }, | |
| 843 | { 17596907048353602192u, 7448238998520507048u, 163753131461u }, | |
| 844 | { 13530650344896573509u, 13892823322374205296u, 247598595491u }, | |
| 845 | { 6337724853398437005u, 11042137840046332563u, 246569963255u }, | |
| 846 | { 12768885008904063297u, 10513966307445593803u, 254508948214u }, | |
| 847 | { 2759773619512884114u, 9388437460943526957u, 148594534654u }, | |
| 848 | { 8434364600126655292u, 10967228614677896227u, 65125279380u }, | |
| 849 | { 3843827521199949338u, 2310996671540235541u, 19270460225u }, | |
| 850 | { 4661660852957808994u, 4989110555003898586u, 155882077203u }, | |
| 851 | { 15298044134177324417u, 16271452421983657678u, 194516251547u }, | |
| 852 | { 7747773274913338217u, 9523160181437090472u, 80712196546u }, | |
| 853 | { 10348785912020632966u, 13137707423765072249u, 224913270096u }, | |
| 854 | { 4175372293197190170u, 16846859744221860704u, 236421057504u }, | |
| 855 | { 11326064156813083145u, 7767140033449795568u, 4930758124u }, | |
| 856 | { 8100407170505981763u, 17169456915721160016u, 190931378436u }, | |
| 857 | { 1706556116319916846u, 17180899661833327818u, 26046u }, | |
| 858 | { 15028897280749641942u, 480481077043500u, 0u }, | |
| 859 | { 1421201742071739121u, 480481u, 0u }, | |
| 860 | { 1u, 0u, 41952608256u }, | |
| 861 | { 8480737406125178272u, 17572520700934791415u, 121974090537u }, | |
| 862 | { 10947205650755620361u, 17968798858233825416u, 176831497593u }, | |
| 863 | { 868577942165647781u, 15338423313945305608u, 226970107312u }, | |
| 864 | { 16017710019091388479u, 17895321323836726300u, 247044130786u }, | |
| 865 | { 6610879150827623375u, 814069333008965772u, 208390330615u }, | |
| 866 | { 12110095866223762092u, 7200328959852723946u, 20041193424u }, | |
| 867 | { 7756802952949470775u, 759884557248133772u, 3726966548u }, | |
| 868 | { 2941800790804618759u, 13410165861863974850u, 40340355587u }, | |
| 869 | { 11703600274199927522u, 6278452420856351569u, 212491800360u }, | |
| 870 | { 806737539257940346u, 9072115382556676441u, 91149396692u }, | |
| 871 | { 14579028397110132023u, 2755882551854926562u, 93460573019u }, | |
| 872 | { 14247808875344366934u, 8496072611504649268u, 205223454557u }, | |
| 873 | { 9713379923695279513u, 4122009033579215814u, 61554147533u }, | |
| 874 | { 2246428675703313877u, 10222217724450527220u, 233111918909u }, | |
| 875 | { 3549783776592680620u, 2064539481554006324u, 74430190057u }, | |
| 876 | { 12645029747929213033u, 7935605886598063692u, 51423117898u }, | |
| 877 | { 16279009267476580506u, 7805147585347548428u, 18309486643u }, | |
| 878 | { 343358782242907186u, 5709020905457661272u, 60881313810u }, | |
| 879 | { 10077054739085890321u, 16257370307404906673u, 207811593532u }, | |
| 880 | { 10526715404712173586u, 14971258192939373645u, 41061441999u }, | |
| 881 | { 11438715865125144243u, 1133404845901376389u, 82512872489u }, | |
| 882 | { 5040916178827294801u, 9460827548162822046u, 204069058130u }, | |
| 883 | { 16643761637275849508u, 1273897659779791345u, 202424641996u }, | |
| 884 | { 4852542977279030386u, 7833262224435092782u, 70164442058u }, | |
| 885 | { 7883373066544387129u, 3033420566713364586u, 110817242694u }, | |
| 886 | { 16699064314768500978u, 15075466825360349102u, 1707011694u }, | |
| 887 | { 6805863634444817214u, 13042063791413317777u, 1u }, | |
| 888 | { 2266540253968903500u, 31488807865u, 0u }, | |
| 889 | { 9016913589137908810u, 31u, 0u }, | |
| 890 | { 1u, 0u, 222134665216u }, | |
| 891 | { 11654451024602552034u, 2484134775182816689u, 93997495262u }, | |
| 892 | { 5299013208454526793u, 18400539815335991276u, 221026318685u }, | |
| 893 | { 14918550373926182540u, 485494064952118285u, 88952853725u }, | |
| 894 | { 6225552657491071054u, 17577048805241314890u, 76155254872u }, | |
| 895 | { 10344713496596235785u, 2863946907557583806u, 236707187532u }, | |
| 896 | { 12972405634433280209u, 13045307417786230799u, 139652260844u }, | |
| 897 | { 12911885282402784945u, 12032088871615097765u, 26479692427u }, | |
| 898 | { 6934311832970995868u, 8848763446997690579u, 33543797274u }, | |
| 899 | { 9975729197003430461u, 10031289150307672683u, 230628415265u }, | |
| 900 | { 1982857556803548935u, 11592215575498656562u, 62861639142u }, | |
| 901 | { 2095735223386298223u, 15894436747956898387u, 232113382974u }, | |
| 902 | { 7110931538347639365u, 2091546719588500922u, 52317877736u }, | |
| 903 | { 15822183724630969535u, 5863809244813756108u, 220612737332u }, | |
| 904 | { 16931982690156327501u, 11303008753675411244u, 166717656540u }, | |
| 905 | { 6740069226761666110u, 13238426537506910531u, 32935582886u }, | |
| 906 | { 3138792961008474902u, 17258458071023005564u, 81454591520u }, | |
| 907 | { 12154594426971851390u, 8385733444777075178u, 58516663377u }, | |
| 908 | { 15780127219221910902u, 9530757096163247299u, 157781872442u }, | |
| 909 | { 16421541930960194381u, 14423000845391072216u, 196593770909u }, | |
| 910 | { 7485894627196740576u, 10953140011159884310u, 186662899652u }, | |
| 911 | { 8897269432694476707u, 12228340237948264126u, 75611443130u }, | |
| 912 | { 17189823634941678805u, 11279134946966259188u, 173793641291u }, | |
| 913 | { 9585582064286255216u, 14640097792684582650u, 181337854381u }, | |
| 914 | { 12835472279575022097u, 6232313315128656727u, 24874740917u }, | |
| 915 | { 6776016669542754608u, 16136121832933322087u, 54817204760u }, | |
| 916 | { 18340015775620871027u, 15074767079673358270u, 254718431542u }, | |
| 917 | { 5254188752292365830u, 13252722804829281907u, 111870u }, | |
| 918 | { 6798802596750151183u, 2063650512248692u, 0u }, | |
| 919 | { 9449320530215272000u, 2063650u, 0u }, | |
| 920 | { 1u, 0u, 121419595776u }, | |
| 921 | { 17110720482574968811u, 7740175894281560508u, 91849499257u }, | |
| 922 | { 16172441693558688213u, 15670495392425593225u, 188821405531u }, | |
| 923 | { 6234654946353717320u, 15152257626756992777u, 238221723324u }, | |
| 924 | { 11180283100679445438u, 4090073428152440421u, 190783353838u }, | |
| 925 | { 14852260031176961272u, 14450327772834205583u, 10242107326u }, | |
| 926 | { 4481533167346438750u, 4466091895542494215u, 250566718730u }, | |
| 927 | { 4269718344362365664u, 10454115378553795376u, 205122938618u }, | |
| 928 | { 11520029752381101466u, 2267817233475657787u, 54298180301u }, | |
| 929 | { 16778682550309368417u, 5500455702636497520u, 223822842678u }, | |
| 930 | { 9687587467301363608u, 15178768299492252548u, 148382851295u }, | |
| 931 | { 10093971076828497318u, 7062359872332045589u, 6666640532u }, | |
| 932 | { 1913763026490934696u, 12297347290027942575u, 96435313926u }, | |
| 933 | { 12701450127613557000u, 8030124596941085587u, 220353810784u }, | |
| 934 | { 8974572160711134644u, 6526656990996654842u, 184339045596u }, | |
| 935 | { 9890000077336694124u, 6254287345256979849u, 130360063928u }, | |
| 936 | { 4292326716201059148u, 6642007136244870031u, 96109916034u }, | |
| 937 | { 14644519175104337420u, 2027592955437164717u, 68051104864u }, | |
| 938 | { 5051178622270136798u, 942718349157325566u, 40792392772u }, | |
| 939 | { 675983118348065839u, 14617066671884002277u, 1370343464u }, | |
| 940 | { 4431647660065117244u, 6831631114396133347u, 179791632385u }, | |
| 941 | { 8316115180008411962u, 14603040013386939257u, 135537011123u }, | |
| 942 | { 9621158095544965602u, 9906106765319401102u, 44075687047u }, | |
| 943 | { 15283478958951102072u, 1396179595609933062u, 125624765228u }, | |
| 944 | { 13981553073094447813u, 11524884268464976416u, 239020758653u }, | |
| 945 | { 4558368743929911607u, 382929570730827273u, 52331208687u }, | |
| 946 | { 15217004469858477791u, 6109721884461301380u, 235129590068u }, | |
| 947 | { 11589190369996515737u, 2390514825000339690u, 7331559403u }, | |
| 948 | { 3670624237398152929u, 6116191454763441754u, 7u }, | |
| 949 | { 13471713758418039777u, 135243399970u, 0u }, | |
| 950 | { 4489936967610296411u, 135u, 0u }, | |
| 951 | { 1u, 0u, 106628775936u }, | |
| 952 | { 9052049303222747950u, 11598868771099176309u, 120783334250u }, | |
| 953 | { 1011330006193020538u, 14449966445520085104u, 71632935288u }, | |
| 954 | { 17412075644359478612u, 11675595287405614725u, 194859815495u }, | |
| 955 | { 6358678384745980468u, 15860796398550489896u, 137877141698u }, | |
| 956 | { 15262353928842850919u, 16180408435245829661u, 250745768073u }, | |
| 957 | { 11145257686438581736u, 13756992797154950705u, 20478705146u }, | |
| 958 | { 1600562031807691890u, 8830551328786758465u, 120905306388u }, | |
| 959 | { 6775147337046626724u, 16699955256560951263u, 85544214392u }, | |
| 960 | { 15772127322106297822u, 10038983627153402073u, 165817764949u }, | |
| 961 | { 4141472200527441474u, 15085100736692127345u, 2542523045u }, | |
| 962 | { 18246007807879281267u, 10007783780289711124u, 168953930242u }, | |
| 963 | { 960746958654787123u, 17596907048353602191u, 112733498024u }, | |
| 964 | { 11355981212264408477u, 13530650344896573508u, 147343568752u }, | |
| 965 | { 1573078209576251481u, 6337724853398437004u, 203692202643u }, | |
| 966 | { 6245294478780491367u, 12768885008904063296u, 45149607627u }, | |
| 967 | { 7523292955659721510u, 2759773619512884113u, 35457227821u }, | |
| 968 | { 14454736751015226505u, 8434364600126655291u, 21208374307u }, | |
| 969 | { 7219786377781411316u, 3843827521199949337u, 218252709141u }, | |
| 970 | { 10597123082209392431u, 4661660852957808993u, 206829308634u }, | |
| 971 | { 6922353544343010714u, 15298044134177324416u, 168420007630u }, | |
| 972 | { 14317523356293377430u, 7747773274913338216u, 121561008808u }, | |
| 973 | { 4057766168681892717u, 10348785912020632965u, 96226347385u }, | |
| 974 | { 15214083611901244045u, 4175372293197190169u, 240613987168u }, | |
| 975 | { 8390569016883950721u, 11326064156813083144u, 80439123952u }, | |
| 976 | { 10680472538208175055u, 8100407170505981762u, 202092512592u }, | |
| 977 | { 12173567833130544927u, 1706556116319916845u, 44814718154u }, | |
| 978 | { 1386341248286610026u, 15028897280749641941u, 225077043500u }, | |
| 979 | { 12487300952797237352u, 1421201742071739120u, 480481u }, | |
| 980 | { 2614759871804869720u, 8863311460481781u, 0u }, | |
| 981 | { 8494389567327729477u, 8863311u, 0u }, | |
| 982 | { 1u, 0u, 247459741696u }, | |
| 983 | { 6260469580539185878u, 8480737406125178271u, 136593449207u }, | |
| 984 | { 17818573101084525841u, 10947205650755620360u, 8047085704u }, | |
| 985 | { 2201029069927307150u, 868577942165647780u, 28868321800u }, | |
| 986 | { 10397997613804897039u, 16017710019091388478u, 140358376476u }, | |
| 987 | { 14269915965770103741u, 6610879150827623374u, 234656489612u }, | |
| 988 | { 16776139909196366727u, 12110095866223762091u, 140420497130u }, | |
| 989 | { 6246513436385199720u, 7756802952949470774u, 194159475340u }, | |
| 990 | { 2926026498821554288u, 2941800790804618758u, 81634453442u }, | |
| 991 | { 15725499391028340982u, 11703600274199927521u, 89043733329u }, | |
| 992 | { 8576577277771450827u, 806737539257940345u, 226790330713u }, | |
| 993 | { 15523351176022259335u, 14579028397110132022u, 52772375266u }, | |
| 994 | { 4775158829429176134u, 14247808875344366933u, 198526563380u }, | |
| 995 | { 10141817222123532462u, 9713379923695279512u, 244121779142u }, | |
| 996 | { 12847658900242624586u, 2246428675703313876u, 52192434164u }, | |
| 997 | { 13708197964460514655u, 3549783776592680619u, 76685488436u }, | |
| 998 | { 1951540006613246932u, 12645029747929213032u, 12882486860u }, | |
| 999 | { 9979297327280092199u, 16279009267476580505u, 88018613516u }, | |
| 1000 | { 15381307706282553684u, 343358782242907185u, 177546278232u }, | |
| 1001 | { 10037428657543061177u, 10077054739085890320u, 77570654385u }, | |
| 1002 | { 2584877324547208668u, 10526715404712173585u, 133620094029u }, | |
| 1003 | { 1126624732730703576u, 11438715865125144242u, 158273268613u }, | |
| 1004 | { 1501064139624981020u, 5040916178827294800u, 241902260126u }, | |
| 1005 | { 5219661484955306109u, 16643761637275849507u, 46263056881u }, | |
| 1006 | { 5336997298570282212u, 4852542977279030385u, 106427358510u }, | |
| 1007 | { 12191131175733833362u, 7883373066544387128u, 174905258090u }, | |
| 1008 | { 3707068178994436536u, 16699064314768500977u, 145368946606u }, | |
| 1009 | { 5045484691732942022u, 6805863634444817213u, 185122869393u }, | |
| 1010 | { 14847900542908711232u, 2266540253968903499u, 31488807865u }, | |
| 1011 | { 9097257915916965135u, 9016913589137908809u, 31u }, | |
| 1012 | { 2472027983230314217u, 580865979874u, 0u }, | |
| 1013 | { 15974509111133272205u, 580u, 0u }, | |
| 1014 | { 1u, 0u, 177631789056u }, | |
| 1015 | { 12099486841948187399u, 11654451024602552033u, 236287260081u }, | |
| 1016 | { 5319910566029976328u, 5299013208454526792u, 13808736236u }, | |
| 1017 | { 11549214421017285864u, 14918550373926182539u, 74337487885u }, | |
| 1018 | { 1998791413186046700u, 6225552657491071053u, 190560788042u }, | |
| 1019 | { 17075171930090011210u, 10344713496596235784u, 15703235518u }, | |
| 1020 | { 15158296003813501474u, 12972405634433280208u, 165699954703u }, | |
| 1021 | { 1360083178079384115u, 12911885282402784944u, 211375909797u }, | |
| 1022 | { 6167980558592741158u, 6934311832970995867u, 107540785363u }, | |
| 1023 | { 3630180428124865653u, 9975729197003430460u, 50107490923u }, | |
| 1024 | { 2276550099763657677u, 1982857556803548934u, 83113610034u }, | |
| 1025 | { 407006713016100655u, 2095735223386298222u, 186385484371u }, | |
| 1026 | { 14242579061653496002u, 7110931538347639364u, 204857722298u }, | |
| 1027 | { 17944493332678643704u, 15822183724630969534u, 44917884620u }, | |
| 1028 | { 987185901870869452u, 16931982690156327500u, 67365379884u }, | |
| 1029 | { 5578665155415167745u, 6740069226761666109u, 124170154307u }, | |
| 1030 | { 4849210377429577536u, 3138792961008474901u, 234658901884u }, | |
| 1031 | { 10811995403388891862u, 12154594426971851389u, 195855442410u }, | |
| 1032 | { 7051931074990177294u, 15780127219221910901u, 216890213571u }, | |
| 1033 | { 2030832259446664275u, 16421541930960194380u, 22405811160u }, | |
| 1034 | { 6069512651054767896u, 7485894627196740575u, 190482321942u }, | |
| 1035 | { 10608701253763958799u, 8897269432694476706u, 244931862206u }, | |
| 1036 | { 15700053443426906717u, 17189823634941678804u, 250519635444u }, | |
| 1037 | { 17759719234725541222u, 9585582064286255215u, 87695812346u }, | |
| 1038 | { 15187321568916405210u, 12835472279575022096u, 103367328599u }, | |
| 1039 | { 11040156458113129594u, 6776016669542754607u, 190994214247u }, | |
| 1040 | { 2800727824598008497u, 18340015775620871026u, 115284830142u }, | |
| 1041 | { 2997236166375604479u, 5254188752292365829u, 116368563827u }, | |
| 1042 | { 6260091886451512841u, 6798802596750151182u, 34512248692u }, | |
| 1043 | { 17573059315228347474u, 9449320530215271999u, 2063650u }, | |
| 1044 | { 7519453664590169251u, 38067632857031246u, 0u }, | |
| 1045 | { 15809436065653866529u, 38067632u, 0u }, | |
| 1046 | { 1u, 0u, 188927574016u }, | |
| 1047 | { 228921437623588922u, 17110720482574968810u, 137876709820u }, | |
| 1048 | { 2195862230003073884u, 16172441693558688212u, 9337981321u }, | |
| 1049 | { 960207412233973688u, 6234654946353717319u, 101606084361u }, | |
| 1050 | { 2464387149230492479u, 11180283100679445437u, 143805142629u }, | |
| 1051 | { 3631866936444955213u, 14852260031176961271u, 7242944399u }, | |
| 1052 | { 1578304441149380227u, 4481533167346438749u, 48231461895u }, | |
| 1053 | { 18190538519673445181u, 4269718344362365663u, 59624502064u }, | |
| 1054 | { 1271000736479934749u, 11520029752381101465u, 112909574203u }, | |
| 1055 | { 18292963032817745634u, 16778682550309368416u, 132525165168u }, | |
| 1056 | { 17168014021925537455u, 9687587467301363607u, 21547195268u }, | |
| 1057 | { 18046757712870378949u, 10093971076828497317u, 175103745301u }, | |
| 1058 | { 14857998893911743220u, 1913763026490934695u, 147688546991u }, | |
| 1059 | { 11933607369968684575u, 12701450127613556999u, 250486512531u }, | |
| 1060 | { 3483798509902859162u, 8974572160711134643u, 137536137978u }, | |
| 1061 | { 7378828438829845831u, 9890000077336694123u, 143232687497u }, | |
| 1062 | { 15791137430347699565u, 4292326716201059147u, 173793880975u }, | |
| 1063 | { 17044141236829932641u, 14644519175104337419u, 254273824941u }, | |
| 1064 | { 9075651910862456484u, 5051178622270136797u, 229036645118u }, | |
| 1065 | { 17811207355884564095u, 675983118348065838u, 227240240101u }, | |
| 1066 | { 4438638126207305937u, 4431647660065117243u, 121450817507u }, | |
| 1067 | { 12507972635512950185u, 8316115180008411961u, 142521564025u }, | |
| 1068 | { 14658269128098109408u, 9621158095544965601u, 6828519054u }, | |
| 1069 | { 3642436268910286111u, 15283478958951102071u, 32757941510u }, | |
| 1070 | { 3783099432964819561u, 13981553073094447812u, 9247109664u }, | |
| 1071 | { 9497579866027539638u, 4558368743929911606u, 132824915465u }, | |
| 1072 | { 3395179445046271361u, 15217004469858477790u, 234628251268u }, | |
| 1073 | { 5938502732309497276u, 11589190369996515736u, 90198984938u }, | |
| 1074 | { 5793671185917606255u, 3670624237398152928u, 34730303066u }, | |
| 1075 | { 889272970253526588u, 13471713758418039776u, 135243399970u }, | |
| 1076 | { 8594177504370135501u, 4489936967610296410u, 135u }, | |
| 1077 | { 7374354721120724712u, 2494800386918u, 0u }, | |
| 1078 | { 14764532643665507567u, 2494u, 0u }, | |
| 1079 | { 1u, 0u, 117490712576u }, | |
| 1080 | { 5392404173658087695u, 9052049303222747949u, 112054824309u }, | |
| 1081 | { 4976586473237854316u, 1011330006193020537u, 133943910512u }, | |
| 1082 | { 6308932742419013569u, 17412075644359478611u, 40344704645u }, | |
| 1083 | { 4831846642430703059u, 6358678384745980467u, 29827373864u }, | |
| 1084 | { 18139507855949846901u, 15262353928842850918u, 49604185629u }, | |
| 1085 | { 4865833876326628410u, 11145257686438581735u, 65086766641u }, | |
| 1086 | { 14296661839130179261u, 1600562031807691889u, 223367281473u }, | |
| 1087 | { 9254773150378118248u, 6775147337046626723u, 217855008735u }, | |
| 1088 | { 12174712433727875143u, 15772127322106297821u, 113224509657u }, | |
| 1089 | { 705653145340915199u, 4141472200527441473u, 20989118065u }, | |
| 1090 | { 17763928858962481812u, 18246007807879281266u, 143052082196u }, | |
| 1091 | { 3982836567612046296u, 960746958654787122u, 68615608975u }, | |
| 1092 | { 12730849277561967739u, 11355981212264408476u, 140085276740u }, | |
| 1093 | { 17314488764367235908u, 1573078209576251480u, 64338558092u }, | |
| 1094 | { 15951418930590301119u, 6245294478780491366u, 145407838528u }, | |
| 1095 | { 7193356087283467261u, 7523292955659721509u, 59783592849u }, | |
| 1096 | { 17592945625696089446u, 14454736751015226504u, 25391385403u }, | |
| 1097 | { 3554461664875361428u, 7219786377781411315u, 97574471193u }, | |
| 1098 | { 2213779057785318208u, 10597123082209392430u, 128375261537u }, | |
| 1099 | { 3880940796082421148u, 6922353544343010713u, 104776154496u }, | |
| 1100 | { 4528237545358141043u, 14317523356293377429u, 133219971944u }, | |
| 1101 | { 11681196539088147363u, 4057766168681892716u, 25824757125u }, | |
| 1102 | { 9835005502912643017u, 15214083611901244044u, 8454853657u }, | |
| 1103 | { 4964088126040986696u, 8390569016883950720u, 66578989576u }, | |
| 1104 | { 3355564873147047622u, 10680472538208175054u, 45659930434u }, | |
| 1105 | { 1853093467828272927u, 12173567833130544926u, 213075153709u }, | |
| 1106 | { 14755341584803008677u, 1386341248286610025u, 240676937941u }, | |
| 1107 | { 4701571132542556621u, 12487300952797237351u, 245141746416u }, | |
| 1108 | { 6128849686644853851u, 2614759871804869719u, 79460481781u }, | |
| 1109 | { 12026867901170202094u, 8494389567327729476u, 8863311u }, | |
| 1110 | { 17909760324981426303u, 163499238157084246u, 0u }, | |
| 1111 | { 2897692901883393664u, 163499238u, 0u }, | |
| 1112 | { 1u, 0u, 159339380736u }, | |
| 1113 | { 12323704802554838154u, 6260469580539185877u, 8965946783u }, | |
| 1114 | { 7135886931147821732u, 17818573101084525840u, 164119318024u }, | |
| 1115 | { 15341283120292884947u, 2201029069927307149u, 62563676580u }, | |
| 1116 | { 3092789040392634166u, 10397997613804897038u, 206773573694u }, | |
| 1117 | { 8811761390822097865u, 14269915965770103740u, 171909436366u }, | |
| 1118 | { 16870860798610218169u, 16776139909196366726u, 54338624171u }, | |
| 1119 | { 17452041453591904833u, 6246513436385199719u, 6158620214u }, | |
| 1120 | { 10314783684009874908u, 2926026498821554287u, 225852481030u }, | |
| 1121 | { 4932636630789274903u, 15725499391028340981u, 121464937185u }, | |
| 1122 | { 18143884346082124480u, 8576577277771450826u, 54841522553u }, | |
| 1123 | { 2823209155405527322u, 15523351176022259334u, 85258861878u }, | |
| 1124 | { 16195396106620226251u, 4775158829429176133u, 152549789013u }, | |
| 1125 | { 1150544491807648944u, 10141817222123532461u, 212696472984u }, | |
| 1126 | { 7767455475523884824u, 12847658900242624585u, 171743122900u }, | |
| 1127 | { 15204378045683991808u, 13708197964460514654u, 104105793195u }, | |
| 1128 | { 17239732561718805622u, 1951540006613246931u, 153540978792u }, | |
| 1129 | { 12886430624522800062u, 9979297327280092198u, 49833822361u }, | |
| 1130 | { 18162250541178258136u, 15381307706282553683u, 16544130097u }, | |
| 1131 | { 17028935366700158084u, 10037428657543061176u, 17140126480u }, | |
| 1132 | { 16075467823964198637u, 2584877324547208667u, 178061074449u }, | |
| 1133 | { 9803858825574498304u, 1126624732730703575u, 80081372850u }, | |
| 1134 | { 17464070808143041817u, 1501064139624981019u, 35282958416u }, | |
| 1135 | { 17682703471239266776u, 5219661484955306108u, 113289319203u }, | |
| 1136 | { 18147688354161351336u, 5336997298570282211u, 56660882545u }, | |
| 1137 | { 6663423873348080051u, 12191131175733833361u, 241200960568u }, | |
| 1138 | { 9417270363716235133u, 3707068178994436535u, 61273516273u }, | |
| 1139 | { 9295013721571344179u, 5045484691732942021u, 75804906301u }, | |
| 1140 | { 6199479138350037783u, 14847900542908711231u, 73493163339u }, | |
| 1141 | { 887603005365085688u, 9097257915916965134u, 226134008905u }, | |
| 1142 | { 333989628642975696u, 2472027983230314216u, 68865979874u }, | |
| 1143 | { 4620735991403939439u, 15974509111133272204u, 580u }, | |
| 1144 | { 12418523063962801201u, 10715086071862u, 0u }, | |
| 1145 | { 1587745622680169419u, 10715u, 0u }, | |
| 1146 | { 1u, 0u, 225655914496u }, | |
| 1147 | { 10968905082284365638u, 12099486841948187398u, 72288392929u }, | |
| 1148 | { 14076907092801977812u, 5319910566029976327u, 139626084168u }, | |
| 1149 | { 3438322122816124202u, 11549214421017285863u, 77108354699u }, | |
| 1150 | { 14645413324829073676u, 1998791413186046699u, 8925646925u }, | |
| 1151 | { 12271281439492289999u, 17075171930090011209u, 208821732872u }, | |
| 1152 | { 6233751789862708246u, 15158296003813501473u, 176073730256u }, | |
| 1153 | { 1962644459455827991u, 1360083178079384114u, 155334366896u }, | |
| 1154 | { 8726934184642952500u, 6167980558592741157u, 60196792475u }, | |
| 1155 | { 4531087719737475147u, 3630180428124865652u, 6123412028u }, | |
| 1156 | { 481513520412720775u, 2276550099763657676u, 110022063878u }, | |
| 1157 | { 992149349835802669u, 407006713016100654u, 68772091758u }, | |
| 1158 | { 11165474436676191361u, 14242579061653496001u, 190972772932u }, | |
| 1159 | { 10240785855143707184u, 17944493332678643703u, 76053515454u }, | |
| 1160 | { 10059329918238932466u, 987185901870869451u, 61302420044u }, | |
| 1161 | { 14791716450947031886u, 5578665155415167744u, 21262876221u }, | |
| 1162 | { 15378882314737417403u, 4849210377429577535u, 125586119445u }, | |
| 1163 | { 14726970229242271128u, 10811995403388891861u, 117382285949u }, | |
| 1164 | { 5090110549507128156u, 7051931074990177293u, 76110091637u }, | |
| 1165 | { 17185220781106503841u, 2030832259446664274u, 223329028940u }, | |
| 1166 | { 9858517691519529306u, 6069512651054767895u, 162575098847u }, | |
| 1167 | { 5595905546638020703u, 10608701253763958798u, 212851101602u }, | |
| 1168 | { 15555173226968030256u, 15700053443426906716u, 111962756308u }, | |
| 1169 | { 10745236628845355771u, 17759719234725541221u, 16823306351u }, | |
| 1170 | { 9973314042399760760u, 15187321568916405209u, 47598488080u }, | |
| 1171 | { 4374506813558796576u, 11040156458113129593u, 114151827759u }, | |
| 1172 | { 15960826480426749933u, 2800727824598008496u, 5162480498u }, | |
| 1173 | { 9636454862798615738u, 2997236166375604478u, 14339360261u }, | |
| 1174 | { 17973331528911319269u, 6260091886451512840u, 63952637454u }, | |
| 1175 | { 7366495200039369602u, 17573059315228347473u, 78407630399u }, | |
| 1176 | { 10505831326526933399u, 7519453664590169250u, 176857031246u }, | |
| 1177 | { 2803218632575724145u, 15809436065653866528u, 38067632u }, | |
| 1178 | { 8425731874431741636u, 702223880805592151u, 0u }, | |
| 1179 | { 14860552245711912111u, 702223880u, 0u }, | |
| 1180 | { 1u, 0u, 234012409856u }, | |
| 1181 | { 6993664200669526994u, 228921437623588921u, 212119037930u }, | |
| 1182 | { 4065363582031999356u, 2195862230003073883u, 71052052948u }, | |
| 1183 | { 6899780515342669867u, 960207412233973687u, 189133594695u }, | |
| 1184 | { 17713500890201844939u, 2464387149230492478u, 247196883901u }, | |
| 1185 | { 6445781125105107086u, 3631866936444955212u, 93085560055u }, | |
| 1186 | { 13563044070717478571u, 1578304441149380226u, 223986111069u }, | |
| 1187 | { 13167612994149348885u, 18190538519673445180u, 153068901087u }, | |
| 1188 | { 5505463469596727288u, 1271000736479934748u, 96991663513u }, | |
| 1189 | { 12125446212518819372u, 18292963032817745633u, 151930679904u }, | |
| 1190 | { 12537707724735421794u, 17168014021925537454u, 165978316695u }, | |
| 1191 | { 15173675086703777069u, 18046757712870378948u, 167805453733u }, | |
| 1192 | { 13535510174093048476u, 14857998893911743219u, 7646922151u }, | |
| 1193 | { 10698912997087096629u, 11933607369968684574u, 179188857095u }, | |
| 1194 | { 16952559548431933861u, 3483798509902859161u, 107400007091u }, | |
| 1195 | { 13528255827744249993u, 7378828438829845830u, 75856039275u }, | |
| 1196 | { 14122167436324771955u, 15791137430347699564u, 11923964747u }, | |
| 1197 | { 13071007137740038297u, 17044141236829932640u, 221491992075u }, | |
| 1198 | { 13011887609328904025u, 9075651910862456483u, 46965547485u }, | |
| 1199 | { 3116434332871336590u, 17811207355884564094u, 59240619054u }, | |
| 1200 | { 9050993820536772770u, 4438638126207305936u, 57678058555u }, | |
| 1201 | { 11993719123438634238u, 12507972635512950184u, 225794626361u }, | |
| 1202 | { 1414857165879849301u, 14658269128098109407u, 119197456865u }, | |
| 1203 | { 13819438220812375094u, 3642436268910286110u, 196205082231u }, | |
| 1204 | { 6073063033888264440u, 3783099432964819560u, 54514864836u }, | |
| 1205 | { 6828883869150720294u, 9497579866027539637u, 222184053046u }, | |
| 1206 | { 4548265621068768345u, 3395179445046271360u, 152321926878u }, | |
| 1207 | { 10422524923581371874u, 5938502732309497275u, 224314075544u }, | |
| 1208 | { 1858996082510682634u, 5793671185917606254u, 224048207584u }, | |
| 1209 | { 890276727450878316u, 889272970253526587u, 90465891296u }, | |
| 1210 | { 3886008133802710905u, 8594177504370135500u, 102399764570u }, | |
| 1211 | { 612074409233016757u, 7374354721120724711u, 190800386918u }, | |
| 1212 | { 3927020336901729264u, 14764532643665507566u, 2494u }, | |
| 1213 | { 5298603480094474942u, 46020944252475u, 0u }, | |
| 1214 | { 17418383752590430025u, 46020u, 0u }, | |
| 1215 | { 1u, 0u, 45292322816u }, | |
| 1216 | { 8973799690601597929u, 5392404173658087694u, 121269781293u }, | |
| 1217 | { 1343055462055792431u, 4976586473237854315u, 83342007929u }, | |
| 1218 | { 17425118728683169659u, 6308932742419013568u, 51261934931u }, | |
| 1219 | { 18389781726026675967u, 4831846642430703058u, 102983344691u }, | |
| 1220 | { 272526939565961561u, 18139507855949846900u, 231263777382u }, | |
| 1221 | { 11293026845930963228u, 4865833876326628409u, 113775023591u }, | |
| 1222 | { 13997416438903902597u, 14296661839130179260u, 163501702257u }, | |
| 1223 | { 6186605805999441184u, 9254773150378118247u, 221659992483u }, | |
| 1224 | { 4401776373281836138u, 12174712433727875142u, 65038253533u }, | |
| 1225 | { 16338917089754547008u, 705653145340915198u, 114962984513u }, | |
| 1226 | { 13337700757935003056u, 17763928858962481811u, 50215910002u }, | |
| 1227 | { 14612496890816348693u, 3982836567612046295u, 156690140722u }, | |
| 1228 | { 3219935399907691719u, 12730849277561967738u, 88938620316u }, | |
| 1229 | { 10887238730052330387u, 17314488764367235907u, 102864728152u }, | |
| 1230 | { 360256418697768294u, 15951418930590301118u, 37389952614u }, | |
| 1231 | { 321440824631118565u, 7193356087283467260u, 136953715493u }, | |
| 1232 | { 10069228080701402580u, 17592945625696089445u, 243192687752u }, | |
| 1233 | { 9428069607611622975u, 3554461664875361427u, 46120009203u }, | |
| 1234 | { 14736799017468812344u, 2213779057785318207u, 153210386222u }, | |
| 1235 | { 10875332567307979280u, 3880940796082421147u, 149245476249u }, | |
| 1236 | { 4611492910339012807u, 4528237545358141042u, 108633238933u }, | |
| 1237 | { 10743508637597314786u, 11681196539088147362u, 140533156716u }, | |
| 1238 | { 9356196315668016028u, 9835005502912643016u, 128269103756u }, | |
| 1239 | { 15755598617722189347u, 4964088126040986695u, 206181905536u }, | |
| 1240 | { 1275276394173375542u, 3355564873147047621u, 30100456398u }, | |
| 1241 | { 12644999363867216251u, 1853093467828272926u, 105799888670u }, | |
| 1242 | { 4553830511509832021u, 14755341584803008676u, 103254872681u }, | |
| 1243 | { 8869400642218174412u, 4701571132542556620u, 87332245607u }, | |
| 1244 | { 16570849151159054040u, 6128849686644853850u, 68651977815u }, | |
| 1245 | { 16127119334101797673u, 12026867901170202093u, 86970890052u }, | |
| 1246 | { 9686867250420930550u, 17909760324981426302u, 230157084246u }, | |
| 1247 | { 10678226869774428035u, 2897692901883393663u, 163499238u }, | |
| 1248 | { 7767227962910162068u, 3016028602530220424u, 0u }, | |
| 1249 | { 9780840471948993674u, 3016028602u, 0u }, | |
| 1250 | { 1u, 0u, 213668069376u }, | |
| 1251 | { 6288709332106746357u, 12323704802554838153u, 16386837205u }, | |
| 1252 | { 9066785620141948673u, 7135886931147821731u, 141831652624u }, | |
| 1253 | { 8442375916704414909u, 15341283120292884946u, 14167660429u }, | |
| 1254 | { 11604629218100425803u, 3092789040392634165u, 188477686542u }, | |
| 1255 | { 3877248044010875762u, 8811761390822097864u, 134914571196u }, | |
| 1256 | { 16435137704395217283u, 16870860798610218168u, 103946077062u }, | |
| 1257 | { 14994442577577813271u, 17452041453591904832u, 111559165543u }, | |
| 1258 | { 4410105917142436089u, 10314783684009874907u, 245267398767u }, | |
| 1259 | { 4632574728444936970u, 4932636630789274902u, 202983581941u }, | |
| 1260 | { 9117147535650050359u, 18143884346082124479u, 134153046474u }, | |
| 1261 | { 588939301256904809u, 2823209155405527321u, 69877954182u }, | |
| 1262 | { 324393982565305683u, 16195396106620226250u, 173062371141u }, | |
| 1263 | { 9380909186923521175u, 1150544491807648943u, 73421074605u }, | |
| 1264 | { 4463385697777230217u, 7767455475523884823u, 94824230985u }, | |
| 1265 | { 16378985502426333808u, 15204378045683991807u, 211934567774u }, | |
| 1266 | { 18210894922387834354u, 17239732561718805621u, 38698574803u }, | |
| 1267 | { 1555748035329493205u, 12886430624522800061u, 83984577574u }, | |
| 1268 | { 4277055533891898507u, 18162250541178258135u, 184923140435u }, | |
| 1269 | { 11574429772510874408u, 17028935366700158083u, 219871452856u }, | |
| 1270 | { 17391099253493808815u, 16075467823964198636u, 215531468251u }, | |
| 1271 | { 5791212393959129882u, 9803858825574498303u, 27946729175u }, | |
| 1272 | { 11254268231455680880u, 17464070808143041816u, 124958581275u }, | |
| 1273 | { 16355477587312235322u, 17682703471239266775u, 227983788156u }, | |
| 1274 | { 2411485149249320633u, 18147688354161351335u, 145361224931u }, | |
| 1275 | { 12763114642070638360u, 6663423873348080050u, 183510511249u }, | |
| 1276 | { 1147543073987366419u, 9417270363716235132u, 197503883703u }, | |
| 1277 | { 8410777835225272692u, 9295013721571344178u, 63336074437u }, | |
| 1278 | { 8134725822306818018u, 6199479138350037782u, 14048117055u }, | |
| 1279 | { 8899607004752328377u, 887603005365085687u, 232018105614u }, | |
| 1280 | { 690976506652396830u, 333989628642975695u, 140250490600u }, | |
| 1281 | { 12281570945595192074u, 4620735991403939438u, 54673209484u }, | |
| 1282 | { 12592957291365552899u, 12418523063962801200u, 219086071862u }, | |
| 1283 | { 13595807339013970272u, 1587745622680169418u, 10715u }, | |
| 1284 | { 9698096389749839992u, 197658450495420u, 0u }, | |
| 1285 | { 8310173728816391804u, 197658u, 0u }, | |
| 1286 | }; | |
| 1287 | ||
| 1288 | inline constexpr int __TABLE_SIZE_2 = 69; | |
| 1289 | inline constexpr int __ADDITIONAL_BITS_2 = 120; | |
| 1290 | ||
| 1291 | inline constexpr uint16_t __POW10_OFFSET_2[__TABLE_SIZE_2] = { | |
| 1292 | 0, 2, 6, 12, 20, 29, 40, 52, 66, 80, | |
| 1293 | 95, 112, 130, 150, 170, 192, 215, 240, 265, 292, | |
| 1294 | 320, 350, 381, 413, 446, 480, 516, 552, 590, 629, | |
| 1295 | 670, 712, 755, 799, 845, 892, 940, 989, 1040, 1092, | |
| 1296 | 1145, 1199, 1254, 1311, 1369, 1428, 1488, 1550, 1613, 1678, | |
| 1297 | 1743, 1810, 1878, 1947, 2017, 2088, 2161, 2235, 2311, 2387, | |
| 1298 | 2465, 2544, 2625, 2706, 2789, 2873, 2959, 3046, 3133 | |
| 1299 | }; | |
| 1300 | ||
| 1301 | inline constexpr uint8_t __MIN_BLOCK_2[__TABLE_SIZE_2] = { | |
| 1302 | 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, | |
| 1303 | 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, | |
| 1304 | 8, 9, 9, 10, 11, 11, 12, 12, 13, 13, | |
| 1305 | 14, 14, 15, 15, 16, 16, 17, 17, 18, 19, | |
| 1306 | 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, | |
| 1307 | 24, 25, 26, 26, 27, 27, 28, 28, 29, 29, | |
| 1308 | 30, 30, 31, 31, 32, 32, 33, 34, 0 | |
| 1309 | }; | |
| 1310 | ||
| 1311 | inline constexpr uint64_t __POW10_SPLIT_2[3133][3] = { | |
| 1312 | { 0u, 0u, 3906250u }, | |
| 1313 | { 0u, 0u, 202000000000u }, | |
| 1314 | { 0u, 11153727427136454656u, 59u }, | |
| 1315 | { 0u, 7205759403792793600u, 59604644775u }, | |
| 1316 | { 0u, 0u, 167390625000u }, | |
| 1317 | { 0u, 0u, 232000000000u }, | |
| 1318 | { 0u, 16777216000000000u, 0u }, | |
| 1319 | { 0u, 12945425605062557696u, 909494u }, | |
| 1320 | { 0u, 4388757836872548352u, 182701772928u }, | |
| 1321 | { 0u, 1152921504606846976u, 128237915039u }, | |
| 1322 | { 0u, 0u, 159062500000u }, | |
| 1323 | { 0u, 0u, 160000000000u }, | |
| 1324 | { 0u, 256000000000u, 0u }, | |
| 1325 | { 0u, 16192327041775828992u, 13u }, | |
| 1326 | { 0u, 15024075324038053888u, 13877787807u }, | |
| 1327 | { 0u, 5449091666327633920u, 159814456755u }, | |
| 1328 | { 0u, 2494994193563254784u, 179295395851u }, | |
| 1329 | { 0u, 4611686018427387904u, 11135253906u }, | |
| 1330 | { 0u, 0u, 146250000000u }, | |
| 1331 | { 0u, 0u, 128000000000u }, | |
| 1332 | { 0u, 3906250u, 0u }, | |
| 1333 | { 0u, 3906250000000000u, 0u }, | |
| 1334 | { 0u, 4368439412768899072u, 211758u }, | |
| 1335 | { 0u, 1563676642168012800u, 46236813575u }, | |
| 1336 | { 0u, 11532349341402398720u, 7084767080u }, | |
| 1337 | { 0u, 9048364970084925440u, 104625169910u }, | |
| 1338 | { 0u, 16609275425742389248u, 246490512847u }, | |
| 1339 | { 0u, 0u, 207900390625u }, | |
| 1340 | { 0u, 0u, 225000000000u }, | |
| 1341 | { 11153727427136454656u, 59u, 0u }, | |
| 1342 | { 7205759403792793600u, 59604644775u, 0u }, | |
| 1343 | { 0u, 4264412554261970152u, 3u }, | |
| 1344 | { 0u, 14485570586272534528u, 3231174267u }, | |
| 1345 | { 0u, 17827675094632103936u, 123785264354u }, | |
| 1346 | { 0u, 7347197909193981952u, 226966440203u }, | |
| 1347 | { 0u, 13677404030777688064u, 11398292396u }, | |
| 1348 | { 0u, 3810326759732150272u, 172741453558u }, | |
| 1349 | { 0u, 9943947977234055168u, 246206558227u }, | |
| 1350 | { 0u, 0u, 19539062500u }, | |
| 1351 | { 0u, 0u, 228000000000u }, | |
| 1352 | { 12945425605062557696u, 909494u, 0u }, | |
| 1353 | { 4388757836872548352u, 909494701772928u, 0u }, | |
| 1354 | { 1152921504606846976u, 14878706826214591391u, 49303u }, | |
| 1355 | { 0u, 4387341015746028192u, 151806576313u }, | |
| 1356 | { 0u, 651726680428265472u, 185237838233u }, | |
| 1357 | { 0u, 2570638187944738816u, 153035330174u }, | |
| 1358 | { 0u, 7419175577111756800u, 126139354575u }, | |
| 1359 | { 0u, 17299322326264840192u, 207402194313u }, | |
| 1360 | { 0u, 7990511638862102528u, 137937798142u }, | |
| 1361 | { 0u, 16717361816799281152u, 254433166503u }, | |
| 1362 | { 0u, 0u, 167906250000u }, | |
| 1363 | { 0u, 0u, 16000000000u }, | |
| 1364 | { 16192327041775828992u, 13u, 0u }, | |
| 1365 | { 15024075324038053888u, 13877787807u, 0u }, | |
| 1366 | { 5449091666327633920u, 13877787807814456755u, 0u }, | |
| 1367 | { 2494994193563254784u, 9707857417284919307u, 752316384u }, | |
| 1368 | { 4611686018427387904u, 1844515466944871826u, 224526264005u }, | |
| 1369 | { 0u, 15167599819856275072u, 197099991383u }, | |
| 1370 | { 0u, 14830185305589481472u, 87822237233u }, | |
| 1371 | { 0u, 6163721531743535104u, 49803945956u }, | |
| 1372 | { 0u, 14122847407012052992u, 228334136013u }, | |
| 1373 | { 0u, 335491783960035328u, 205765601092u }, | |
| 1374 | { 0u, 941252322120433664u, 68018187046u }, | |
| 1375 | { 0u, 11529215046068469760u, 38051025390u }, | |
| 1376 | { 0u, 0u, 238625000000u }, | |
| 1377 | { 0u, 0u, 64000000000u }, | |
| 1378 | { 4368439412768899072u, 211758u, 0u }, | |
| 1379 | { 1563676642168012800u, 211758236813575u, 0u }, | |
| 1380 | { 11532349341402398720u, 8061591463141767016u, 11479u }, | |
| 1381 | { 9048364970084925440u, 16628725344207857142u, 215437019748u }, | |
| 1382 | { 16609275425742389248u, 3555541870038531535u, 100901445007u }, | |
| 1383 | { 0u, 18316647450161853665u, 143192746310u }, | |
| 1384 | { 0u, 16709574568378075648u, 70992947447u }, | |
| 1385 | { 0u, 7696022835795591168u, 247905827852u }, | |
| 1386 | { 0u, 16664449640376041472u, 12417202233u }, | |
| 1387 | { 0u, 3109186955116544000u, 57903381625u }, | |
| 1388 | { 0u, 10515518101817131008u, 121168549362u }, | |
| 1389 | { 0u, 9961962375743537152u, 242570047378u }, | |
| 1390 | { 0u, 9223372036854775808u, 146540039062u }, | |
| 1391 | { 0u, 0u, 150500000000u }, | |
| 1392 | { 14485570586272534528u, 3231174267u, 0u }, | |
| 1393 | { 17827675094632103936u, 3231174267785264354u, 0u }, | |
| 1394 | { 7347197909193981952u, 748977172262750475u, 175162308u }, | |
| 1395 | { 13677404030777688064u, 15965033457315095468u, 196040602133u }, | |
| 1396 | { 3810326759732150272u, 16809402149066729206u, 21865466197u }, | |
| 1397 | { 9943947977234055168u, 7563769067065700371u, 85911239516u }, | |
| 1398 | { 0u, 13550322810840051428u, 92410032742u }, | |
| 1399 | { 0u, 8663209637545764864u, 102734564471u }, | |
| 1400 | { 0u, 8969247575312957440u, 119469633535u }, | |
| 1401 | { 0u, 6193172891660451840u, 255486223885u }, | |
| 1402 | { 0u, 3427954273864908800u, 13335732575u }, | |
| 1403 | { 0u, 10058367555266936832u, 95185829773u }, | |
| 1404 | { 0u, 13907115649320091648u, 141545265197u }, | |
| 1405 | { 0u, 0u, 45753906250u }, | |
| 1406 | { 0u, 0u, 74000000000u }, | |
| 1407 | { 14878706826214591391u, 49303u, 0u }, | |
| 1408 | { 4387341015746028192u, 49303806576313u, 0u }, | |
| 1409 | { 651726680428265472u, 14106411361315920281u, 2672u }, | |
| 1410 | { 2570638187944738816u, 3609034283485221502u, 112764710092u }, | |
| 1411 | { 7419175577111756800u, 9896072247338192335u, 204195646140u }, | |
| 1412 | { 17299322326264840192u, 8889095178479228297u, 188536467151u }, | |
| 1413 | { 7990511638862102528u, 3631796911038383102u, 207481878815u }, | |
| 1414 | { 16717361816799281152u, 898318840772166823u, 31196880105u }, | |
| 1415 | { 0u, 17293677953982795024u, 233048697961u }, | |
| 1416 | { 0u, 7353628266884669440u, 105937492160u }, | |
| 1417 | { 0u, 2404693032470315008u, 192398640987u }, | |
| 1418 | { 0u, 9191155893041889280u, 91130358670u }, | |
| 1419 | { 0u, 6353946855033798656u, 142498253559u }, | |
| 1420 | { 0u, 3767824038248841216u, 247344448149u }, | |
| 1421 | { 0u, 7205759403792793600u, 149204254150u }, | |
| 1422 | { 0u, 0u, 198390625000u }, | |
| 1423 | { 0u, 0u, 232000000000u }, | |
| 1424 | { 9707857417284919307u, 752316384u, 0u }, | |
| 1425 | { 1844515466944871826u, 752316384526264005u, 0u }, | |
| 1426 | { 15167599819856275072u, 17063068157692817751u, 40783152u }, | |
| 1427 | { 14830185305589481472u, 5385330256507239985u, 48924990778u }, | |
| 1428 | { 6163721531743535104u, 3373050282752075748u, 58291939338u }, | |
| 1429 | { 14122847407012052992u, 4116064001262906061u, 10182853422u }, | |
| 1430 | { 335491783960035328u, 11306582046748043076u, 46223132276u }, | |
| 1431 | { 941252322120433664u, 17035410946089626406u, 116612931040u }, | |
| 1432 | { 11529215046068469760u, 15618595715183448558u, 224923491477u }, | |
| 1433 | { 0u, 5141740092277295680u, 149846685770u }, | |
| 1434 | { 0u, 16973644291514990592u, 74278734288u }, | |
| 1435 | { 0u, 14625255268443750400u, 208920143100u }, | |
| 1436 | { 0u, 14021170507320131584u, 252792836676u }, | |
| 1437 | { 0u, 4451355232865091584u, 68760089176u }, | |
| 1438 | { 0u, 12891553933348044800u, 88241308450u }, | |
| 1439 | { 0u, 1152921504606846976u, 34698852539u }, | |
| 1440 | { 0u, 0u, 187062500000u }, | |
| 1441 | { 0u, 0u, 160000000000u }, | |
| 1442 | { 8061591463141767016u, 11479u, 0u }, | |
| 1443 | { 16628725344207857142u, 11479437019748u, 0u }, | |
| 1444 | { 3555541870038531535u, 5562205901560339855u, 622u }, | |
| 1445 | { 18316647450161853665u, 2106077949367544134u, 110301527786u }, | |
| 1446 | { 16709574568378075648u, 7496855998374373623u, 234114170714u }, | |
| 1447 | { 7696022835795591168u, 229183437194837004u, 90406405378u }, | |
| 1448 | { 16664449640376041472u, 465169186276472889u, 2012424059u }, | |
| 1449 | { 3109186955116544000u, 2152980561625316473u, 123025216872u }, | |
| 1450 | { 10515518101817131008u, 2059790725449340402u, 104116713310u }, | |
| 1451 | { 9961962375743537152u, 17891190926410198930u, 94111661478u }, | |
| 1452 | { 9223372036854775808u, 9930696175609809814u, 166969883403u }, | |
| 1453 | { 0u, 7276914261609005312u, 11538344118u }, | |
| 1454 | { 0u, 10539762974036983808u, 182394482312u }, | |
| 1455 | { 0u, 12851089458992250880u, 136571361695u }, | |
| 1456 | { 0u, 9449311677678878720u, 159696658955u }, | |
| 1457 | { 0u, 8699564697382289408u, 11512248212u }, | |
| 1458 | { 0u, 4224376450473525248u, 148471604347u }, | |
| 1459 | { 0u, 4611686018427387904u, 123229003906u }, | |
| 1460 | { 0u, 0u, 130250000000u }, | |
| 1461 | { 0u, 0u, 128000000000u }, | |
| 1462 | { 748977172262750475u, 175162308u, 0u }, | |
| 1463 | { 15965033457315095468u, 175162308040602133u, 0u }, | |
| 1464 | { 16809402149066729206u, 13756840147955779925u, 9495567u }, | |
| 1465 | { 7563769067065700371u, 13788447602092505948u, 15745759798u }, | |
| 1466 | { 13550322810840051428u, 4972540435632173670u, 54747473242u }, | |
| 1467 | { 8663209637545764864u, 2844874687533091959u, 90269561957u }, | |
| 1468 | { 8969247575312957440u, 15377573779532804095u, 101154220965u }, | |
| 1469 | { 6193172891660451840u, 17824715805091194381u, 165833619944u }, | |
| 1470 | { 3427954273864908800u, 18277569135638159711u, 232966279779u }, | |
| 1471 | { 10058367555266936832u, 4254645803379752845u, 99990829008u }, | |
| 1472 | { 13907115649320091648u, 2933643244178200621u, 208230644811u }, | |
| 1473 | { 0u, 17188148801879487562u, 75159033118u }, | |
| 1474 | { 0u, 11069762501163246592u, 30931771413u }, | |
| 1475 | { 0u, 11676570643941818368u, 21600093027u }, | |
| 1476 | { 0u, 17840016768744030208u, 99632988162u }, | |
| 1477 | { 0u, 16463817321652158464u, 2967109246u }, | |
| 1478 | { 0u, 6954191143357644800u, 126892505325u }, | |
| 1479 | { 0u, 5080060379673919488u, 237376987457u }, | |
| 1480 | { 0u, 0u, 65275390625u }, | |
| 1481 | { 0u, 0u, 161000000000u }, | |
| 1482 | { 14106411361315920281u, 2672u, 0u }, | |
| 1483 | { 3609034283485221502u, 2672764710092u, 0u }, | |
| 1484 | { 9896072247338192335u, 16433563478020213436u, 144u }, | |
| 1485 | { 8889095178479228297u, 4194750497955655375u, 144890865261u }, | |
| 1486 | { 3631796911038383102u, 2691539602252904735u, 109227397880u }, | |
| 1487 | { 898318840772166823u, 3775467271962795241u, 248145908654u }, | |
| 1488 | { 17293677953982795024u, 16980212613224918121u, 174204668490u }, | |
| 1489 | { 7353628266884669440u, 4172857038337333440u, 74920499170u }, | |
| 1490 | { 2404693032470315008u, 5936867627376461659u, 226226211033u }, | |
| 1491 | { 9191155893041889280u, 17856837443266866062u, 217321838238u }, | |
| 1492 | { 6353946855033798656u, 8956297047799810807u, 158968021097u }, | |
| 1493 | { 3767824038248841216u, 15356974049716912789u, 105485521835u }, | |
| 1494 | { 7205759403792793600u, 6923608913322982854u, 171832503231u }, | |
| 1495 | { 0u, 4855902993563955944u, 191375329591u }, | |
| 1496 | { 0u, 13835893222288330752u, 55263239028u }, | |
| 1497 | { 0u, 9114973913760137216u, 116750045274u }, | |
| 1498 | { 0u, 17937099003422310400u, 90494123725u }, | |
| 1499 | { 0u, 7007960010734960640u, 205972372085u }, | |
| 1500 | { 0u, 7683422439270776832u, 117379902273u }, | |
| 1501 | { 0u, 720575940379279360u, 65416519165u }, | |
| 1502 | { 0u, 0u, 253039062500u }, | |
| 1503 | { 0u, 0u, 228000000000u }, | |
| 1504 | { 17063068157692817751u, 40783152u, 0u }, | |
| 1505 | { 5385330256507239985u, 40783152924990778u, 0u }, | |
| 1506 | { 3373050282752075748u, 2768933352715741194u, 2210859u }, | |
| 1507 | { 4116064001262906061u, 15201941611824153390u, 43150104177u }, | |
| 1508 | { 11306582046748043076u, 1418128541727000180u, 113824098906u }, | |
| 1509 | { 17035410946089626406u, 5353350204565757408u, 90076876902u }, | |
| 1510 | { 15618595715183448558u, 1721001680354286741u, 102290205696u }, | |
| 1511 | { 5141740092277295680u, 637631411660453962u, 93295688u }, | |
| 1512 | { 16973644291514990592u, 1630012588870568400u, 72034566068u }, | |
| 1513 | { 14625255268443750400u, 9253063571656828156u, 180088363159u }, | |
| 1514 | { 14021170507320131584u, 6029146854993203780u, 151501609581u }, | |
| 1515 | { 4451355232865091584u, 16987401965352759896u, 109326840705u }, | |
| 1516 | { 12891553933348044800u, 14499131620542087970u, 129920888905u }, | |
| 1517 | { 1152921504606846976u, 1978417255298660539u, 73785999500u }, | |
| 1518 | { 0u, 5790079354402454176u, 140107250214u }, | |
| 1519 | { 0u, 13748918935842078720u, 38313880830u }, | |
| 1520 | { 0u, 18047438014740692992u, 254745330388u }, | |
| 1521 | { 0u, 3116889656839372800u, 212978353575u }, | |
| 1522 | { 0u, 15995952446606147584u, 167168966926u }, | |
| 1523 | { 0u, 12530140063251562496u, 14867142319u }, | |
| 1524 | { 0u, 16717361816799281152u, 175679260253u }, | |
| 1525 | { 0u, 0u, 93906250000u }, | |
| 1526 | { 0u, 0u, 16000000000u }, | |
| 1527 | { 5562205901560339855u, 622u, 0u }, | |
| 1528 | { 2106077949367544134u, 622301527786u, 0u }, | |
| 1529 | { 7496855998374373623u, 13558973353698967386u, 33u }, | |
| 1530 | { 229183437194837004u, 6228991722850501890u, 33735033418u }, | |
| 1531 | { 465169186276472889u, 16886831391703377787u, 74337674317u }, | |
| 1532 | { 2152980561625316473u, 1181713637872883048u, 77915436964u }, | |
| 1533 | { 2059790725449340402u, 12393932434925221726u, 164064060824u }, | |
| 1534 | { 17891190926410198930u, 10684799845419711910u, 152671876423u }, | |
| 1535 | { 9930696175609809814u, 4590318792215640843u, 71579224160u }, | |
| 1536 | { 7276914261609005312u, 6383712187366189238u, 96248841680u }, | |
| 1537 | { 10539762974036983808u, 1904270214927675016u, 208346061731u }, | |
| 1538 | { 12851089458992250880u, 3711506775113308575u, 163103230695u }, | |
| 1539 | { 9449311677678878720u, 8091219444738793995u, 231201201185u }, | |
| 1540 | { 8699564697382289408u, 39436684991068052u, 33438625885u }, | |
| 1541 | { 4224376450473525248u, 18025182908196512891u, 93002137866u }, | |
| 1542 | { 4611686018427387904u, 7853924592034603138u, 10977147123u }, | |
| 1543 | { 0u, 4815749283615688320u, 243425762105u }, | |
| 1544 | { 0u, 14242399906544287744u, 57261062291u }, | |
| 1545 | { 0u, 76242322576113664u, 147772082046u }, | |
| 1546 | { 0u, 10858088421377703936u, 126004133104u }, | |
| 1547 | { 0u, 14293835879041466368u, 240588618152u }, | |
| 1548 | { 0u, 12182236992037191680u, 168774870395u }, | |
| 1549 | { 0u, 11529215046068469760u, 123660400390u }, | |
| 1550 | { 0u, 0u, 6625000000u }, | |
| 1551 | { 0u, 0u, 64000000000u }, | |
| 1552 | { 13756840147955779925u, 9495567u, 0u }, | |
| 1553 | { 13788447602092505948u, 9495567745759798u, 0u }, | |
| 1554 | { 4972540435632173670u, 14000097438505379162u, 514755u }, | |
| 1555 | { 2844874687533091959u, 16451062686452429925u, 195758946802u }, | |
| 1556 | { 15377573779532804095u, 4009347599785716645u, 242891813895u }, | |
| 1557 | { 17824715805091194381u, 16544162347546196456u, 7217347168u }, | |
| 1558 | { 18277569135638159711u, 17674258299745817187u, 96896860837u }, | |
| 1559 | { 4254645803379752845u, 5215238411201214416u, 165958123462u }, | |
| 1560 | { 2933643244178200621u, 14253990228345322571u, 198282718640u }, | |
| 1561 | { 17188148801879487562u, 11214836553940194590u, 176772710358u }, | |
| 1562 | { 11069762501163246592u, 14620711348380590101u, 214607957507u }, | |
| 1563 | { 11676570643941818368u, 6638710787931587427u, 3792590350u }, | |
| 1564 | { 17840016768744030208u, 17320000343692853250u, 14359885232u }, | |
| 1565 | { 16463817321652158464u, 75147386268843646u, 176938919100u }, | |
| 1566 | { 6954191143357644800u, 17938801582125480173u, 188004073747u }, | |
| 1567 | { 5080060379673919488u, 6573358613626446145u, 19972464382u }, | |
| 1568 | { 0u, 8688505427903736481u, 254356342484u }, | |
| 1569 | { 0u, 539870168696556032u, 212471004823u }, | |
| 1570 | { 0u, 9002861336394465280u, 151029266420u }, | |
| 1571 | { 0u, 17989846818158018560u, 244488046090u }, | |
| 1572 | { 0u, 2700938287723315200u, 10975231550u }, | |
| 1573 | { 0u, 17800090499088908288u, 62146418157u }, | |
| 1574 | { 0u, 8809040871136690176u, 237964944839u }, | |
| 1575 | { 0u, 9223372036854775808u, 199477539062u }, | |
| 1576 | { 0u, 0u, 246500000000u }, | |
| 1577 | { 16433563478020213436u, 144u, 0u }, | |
| 1578 | { 4194750497955655375u, 144890865261u, 0u }, | |
| 1579 | { 2691539602252904735u, 15763656745260536568u, 7u }, | |
| 1580 | { 3775467271962795241u, 8787336846248645550u, 7854549544u }, | |
| 1581 | { 16980212613224918121u, 17584084447880694346u, 40476362484u }, | |
| 1582 | { 4172857038337333440u, 18041672551129683938u, 244953235127u }, | |
| 1583 | { 5936867627376461659u, 14025886302294509785u, 183978041028u }, | |
| 1584 | { 17856837443266866062u, 18430498103283160734u, 196760344819u }, | |
| 1585 | { 8956297047799810807u, 3292348826238025833u, 243999119304u }, | |
| 1586 | { 15356974049716912789u, 9211721212658275243u, 200178478587u }, | |
| 1587 | { 6923608913322982854u, 10233245872666307519u, 251499368407u }, | |
| 1588 | { 4855902993563955944u, 6200995035623311671u, 215554745370u }, | |
| 1589 | { 13835893222288330752u, 8480542380570450804u, 26336156614u }, | |
| 1590 | { 9114973913760137216u, 11870363864499900506u, 198459731123u }, | |
| 1591 | { 17937099003422310400u, 9301051379839581901u, 179643493714u }, | |
| 1592 | { 7007960010734960640u, 11456694803569638005u, 82504211005u }, | |
| 1593 | { 7683422439270776832u, 14327208890643983169u, 61621068669u }, | |
| 1594 | { 720575940379279360u, 4510081789599866365u, 125776679550u }, | |
| 1595 | { 0u, 13255356976020303332u, 126244492023u }, | |
| 1596 | { 0u, 9658806854127314944u, 247718574341u }, | |
| 1597 | { 0u, 13708435528809971712u, 5523604968u }, | |
| 1598 | { 0u, 1580190652103131136u, 232743135779u }, | |
| 1599 | { 0u, 16557336970347413504u, 35085662306u }, | |
| 1600 | { 0u, 12751520132434493440u, 98897575035u }, | |
| 1601 | { 0u, 9295429630892703744u, 123691261291u }, | |
| 1602 | { 0u, 0u, 107503906250u }, | |
| 1603 | { 0u, 0u, 202000000000u }, | |
| 1604 | { 2768933352715741194u, 2210859u, 0u }, | |
| 1605 | { 15201941611824153390u, 2210859150104177u, 0u }, | |
| 1606 | { 1418128541727000180u, 16872870088062921306u, 119850u }, | |
| 1607 | { 5353350204565757408u, 5112979788807802982u, 42914680120u }, | |
| 1608 | { 1721001680354286741u, 13742728082020150272u, 56277175189u }, | |
| 1609 | { 637631411660453962u, 2217110934613627976u, 149744994782u }, | |
| 1610 | { 1630012588870568400u, 11021433940188610484u, 222120189824u }, | |
| 1611 | { 9253063571656828156u, 1713669895470733463u, 128597473131u }, | |
| 1612 | { 6029146854993203780u, 3313382510572018285u, 107092898231u }, | |
| 1613 | { 16987401965352759896u, 14976595232784069505u, 183179618825u }, | |
| 1614 | { 14499131620542087970u, 7213172372862496841u, 9811882854u }, | |
| 1615 | { 1978417255298660539u, 15836474542502248588u, 102391026857u }, | |
| 1616 | { 5790079354402454176u, 3221099285878340134u, 169858497005u }, | |
| 1617 | { 13748918935842078720u, 3265814602578095358u, 237174616142u }, | |
| 1618 | { 18047438014740692992u, 6502528252282225364u, 78177040164u }, | |
| 1619 | { 3116889656839372800u, 16392476834556790183u, 36352502762u }, | |
| 1620 | { 15995952446606147584u, 15167629413417091342u, 234888637949u }, | |
| 1621 | { 12530140063251562496u, 1366763272626280111u, 253822238838u }, | |
| 1622 | { 16717361816799281152u, 8720523635169216093u, 118074092385u }, | |
| 1623 | { 0u, 9649171375767398672u, 97472740533u }, | |
| 1624 | { 0u, 7647980704001073152u, 181523082628u }, | |
| 1625 | { 0u, 13286434495608651776u, 132414597864u }, | |
| 1626 | { 0u, 4358271637167013888u, 232720259057u }, | |
| 1627 | { 0u, 15954987941890097152u, 241236262378u }, | |
| 1628 | { 0u, 7911135695429697536u, 234864921629u }, | |
| 1629 | { 0u, 7205759403792793600u, 29428863525u }, | |
| 1630 | { 0u, 0u, 37390625000u }, | |
| 1631 | { 0u, 0u, 232000000000u }, | |
| 1632 | { 13558973353698967386u, 33u, 0u }, | |
| 1633 | { 6228991722850501890u, 33735033418u, 0u }, | |
| 1634 | { 16886831391703377787u, 15288289344628122701u, 1u }, | |
| 1635 | { 1181713637872883048u, 952589339068938148u, 1828779826u }, | |
| 1636 | { 12393932434925221726u, 10058155040190817688u, 50051639971u }, | |
| 1637 | { 10684799845419711910u, 5322725640026584391u, 163545253677u }, | |
| 1638 | { 4590318792215640843u, 2269982385930389600u, 45288545535u }, | |
| 1639 | { 6383712187366189238u, 13216683679976310224u, 255123055991u }, | |
| 1640 | { 1904270214927675016u, 17417440642083494819u, 119716477857u }, | |
| 1641 | { 3711506775113308575u, 3029180749090900711u, 161944201349u }, | |
| 1642 | { 8091219444738793995u, 8315443826261908513u, 133164212217u }, | |
| 1643 | { 39436684991068052u, 1488962797247197277u, 249450781113u }, | |
| 1644 | { 18025182908196512891u, 18009099634999034122u, 185080716834u }, | |
| 1645 | { 7853924592034603138u, 8092455412807497971u, 34976275247u }, | |
| 1646 | { 4815749283615688320u, 17808458047236758329u, 47438692886u }, | |
| 1647 | { 14242399906544287744u, 3164591817527425171u, 22965398445u }, | |
| 1648 | { 76242322576113664u, 3314036340472350590u, 173171552866u }, | |
| 1649 | { 10858088421377703936u, 33234902404332784u, 98179654270u }, | |
| 1650 | { 14293835879041466368u, 12349284717857274280u, 126001801667u }, | |
| 1651 | { 12182236992037191680u, 18209607903013119355u, 195669456065u }, | |
| 1652 | { 11529215046068469760u, 7891549145984268038u, 193987144822u }, | |
| 1653 | { 0u, 7703609897518594624u, 118427801736u }, | |
| 1654 | { 0u, 6336912652634587136u, 136417613529u }, | |
| 1655 | { 0u, 4461621834659397632u, 217343524723u }, | |
| 1656 | { 0u, 5484660635557953536u, 115241865004u }, | |
| 1657 | { 0u, 15142619273265938432u, 44297324048u }, | |
| 1658 | { 0u, 12170977992968765440u, 16820883035u }, | |
| 1659 | { 0u, 1152921504606846976u, 91659790039u }, | |
| 1660 | { 0u, 0u, 215062500000u }, | |
| 1661 | { 0u, 0u, 160000000000u }, | |
| 1662 | { 14000097438505379162u, 514755u, 0u }, | |
| 1663 | { 16451062686452429925u, 514755758946802u, 0u }, | |
| 1664 | { 4009347599785716645u, 17812314011563521031u, 27904u }, | |
| 1665 | { 16544162347546196456u, 7684138864490314336u, 965607477u }, | |
| 1666 | { 17674258299745817187u, 9740522787420029605u, 53416558002u }, | |
| 1667 | { 5215238411201214416u, 6701109407732989894u, 178528034798u }, | |
| 1668 | { 14253990228345322571u, 16534886227502443952u, 238363267868u }, | |
| 1669 | { 11214836553940194590u, 8908667306968317910u, 28896357978u }, | |
| 1670 | { 14620711348380590101u, 7531472173477105155u, 90482939822u }, | |
| 1671 | { 6638710787931587427u, 11527371604834801166u, 174408281924u }, | |
| 1672 | { 17320000343692853250u, 15688593496691078576u, 68624900066u }, | |
| 1673 | { 75147386268843646u, 11394944804253312188u, 226850480357u }, | |
| 1674 | { 17938801582125480173u, 11182279880854372627u, 229617721195u }, | |
| 1675 | { 6573358613626446145u, 150579373068361470u, 107606192607u }, | |
| 1676 | { 8688505427903736481u, 3147220002440857300u, 223008162924u }, | |
| 1677 | { 539870168696556032u, 3630514817795505815u, 108170611138u }, | |
| 1678 | { 9002861336394465280u, 11708796588334233588u, 194196810602u }, | |
| 1679 | { 17989846818158018560u, 16844495466426369546u, 106634735134u }, | |
| 1680 | { 2700938287723315200u, 17636655472325475902u, 30913141928u }, | |
| 1681 | { 17800090499088908288u, 17038926655686645229u, 168956085008u }, | |
| 1682 | { 8809040871136690176u, 15602838456783529415u, 16923682064u }, | |
| 1683 | { 9223372036854775808u, 10869815869248876790u, 16845831567u }, | |
| 1684 | { 0u, 18407124180939800832u, 143589253898u }, | |
| 1685 | { 0u, 5705018517251293184u, 10997852201u }, | |
| 1686 | { 0u, 9660452258743058432u, 41309269673u }, | |
| 1687 | { 0u, 5646292272224927744u, 169523694166u }, | |
| 1688 | { 0u, 7410409304047484928u, 86306086117u }, | |
| 1689 | { 0u, 5953758707383795712u, 229401719093u }, | |
| 1690 | { 0u, 4611686018427387904u, 53322753906u }, | |
| 1691 | { 0u, 0u, 114250000000u }, | |
| 1692 | { 0u, 0u, 128000000000u }, | |
| 1693 | { 15763656745260536568u, 7u, 0u }, | |
| 1694 | { 8787336846248645550u, 7854549544u, 0u }, | |
| 1695 | { 17584084447880694346u, 7854549544476362484u, 0u }, | |
| 1696 | { 18041672551129683938u, 15035424419724983u, 425795984u }, | |
| 1697 | { 14025886302294509785u, 18280822466032836292u, 144000815071u }, | |
| 1698 | { 18430498103283160734u, 11524250747302615283u, 223991005371u }, | |
| 1699 | { 3292348826238025833u, 15212285943691810760u, 187624730884u }, | |
| 1700 | { 9211721212658275243u, 7951804027551297019u, 4824659673u }, | |
| 1701 | { 10233245872666307519u, 1706416229965221847u, 217431068160u }, | |
| 1702 | { 6200995035623311671u, 3406023111930700826u, 92505009u }, | |
| 1703 | { 8480542380570450804u, 16132696204133391302u, 177184640882u }, | |
| 1704 | { 11870363864499900506u, 11593846688794356915u, 114874555213u }, | |
| 1705 | { 9301051379839581901u, 6875759884161133906u, 77628503688u }, | |
| 1706 | { 11456694803569638005u, 3593593325323835965u, 136372735690u }, | |
| 1707 | { 14327208890643983169u, 9542049733257388925u, 202194809084u }, | |
| 1708 | { 4510081789599866365u, 9926551925937787518u, 252517275552u }, | |
| 1709 | { 13255356976020303332u, 3128491553219547895u, 160538119458u }, | |
| 1710 | { 9658806854127314944u, 17158408656931354885u, 34169595866u }, | |
| 1711 | { 13708435528809971712u, 2065169543154992616u, 218930159197u }, | |
| 1712 | { 1580190652103131136u, 4832622393556232739u, 93111953065u }, | |
| 1713 | { 16557336970347413504u, 16505930714733656162u, 169261976984u }, | |
| 1714 | { 12751520132434493440u, 18270988073492888699u, 152894788296u }, | |
| 1715 | { 9295429630892703744u, 2525111411519708523u, 200990472248u }, | |
| 1716 | { 0u, 16728989342518570442u, 56136886563u }, | |
| 1717 | { 0u, 7974052022039438336u, 35906880329u }, | |
| 1718 | { 0u, 5356554962386550784u, 73432274226u }, | |
| 1719 | { 0u, 6693869495028547584u, 50290379426u }, | |
| 1720 | { 0u, 8157517147199766528u, 162362875392u }, | |
| 1721 | { 0u, 12065776720423157760u, 442219890u }, | |
| 1722 | { 0u, 11997589407315001344u, 114654087066u }, | |
| 1723 | { 0u, 0u, 154650390625u }, | |
| 1724 | { 0u, 0u, 97000000000u }, | |
| 1725 | { 16872870088062921306u, 119850u, 0u }, | |
| 1726 | { 5112979788807802982u, 119850914680120u, 0u }, | |
| 1727 | { 13742728082020150272u, 2418433229320326037u, 6497u }, | |
| 1728 | { 2217110934613627976u, 1143911773589293534u, 97131103528u }, | |
| 1729 | { 11021433940188610484u, 9276183703610924928u, 40062011581u }, | |
| 1730 | { 1713669895470733463u, 3532180128827684715u, 189502862926u }, | |
| 1731 | { 3313382510572018285u, 8563997501322031543u, 78191479868u }, | |
| 1732 | { 14976595232784069505u, 14843890409658460681u, 60464255234u }, | |
| 1733 | { 7213172372862496841u, 9489417861634552678u, 2804688911u }, | |
| 1734 | { 15836474542502248588u, 1113198223322322089u, 15514422373u }, | |
| 1735 | { 3221099285878340134u, 11190777557146597869u, 101060346596u }, | |
| 1736 | { 3265814602578095358u, 17764553645932638286u, 228606653266u }, | |
| 1737 | { 6502528252282225364u, 14900777150991234852u, 82963018382u }, | |
| 1738 | { 16392476834556790183u, 17364899863357893610u, 142807772747u }, | |
| 1739 | { 15167629413417091342u, 15537570181590167037u, 75941353107u }, | |
| 1740 | { 1366763272626280111u, 5558052627121307766u, 147842293367u }, | |
| 1741 | { 8720523635169216093u, 12095241565795232609u, 119301302636u }, | |
| 1742 | { 9649171375767398672u, 2187936505958366389u, 108655684359u }, | |
| 1743 | { 7647980704001073152u, 12009203621325860228u, 7118608275u }, | |
| 1744 | { 13286434495608651776u, 14814842834750302952u, 147651020232u }, | |
| 1745 | { 4358271637167013888u, 5965296499605198833u, 200803114239u }, | |
| 1746 | { 15954987941890097152u, 4051026394962148842u, 255323379371u }, | |
| 1747 | { 7911135695429697536u, 16799526299141688349u, 171219606580u }, | |
| 1748 | { 7205759403792793600u, 9460214166646215205u, 52910704145u }, | |
| 1749 | { 0u, 10750736995029068008u, 17512839237u }, | |
| 1750 | { 0u, 5377963045376430080u, 69582798620u }, | |
| 1751 | { 0u, 15996910350253424640u, 28291539960u }, | |
| 1752 | { 0u, 13651157529655246848u, 248867194247u }, | |
| 1753 | { 0u, 9771305410219737088u, 135740030732u }, | |
| 1754 | { 0u, 12709439623416250368u, 12529703527u }, | |
| 1755 | { 0u, 9943947977234055168u, 103688980102u }, | |
| 1756 | { 0u, 0u, 134539062500u }, | |
| 1757 | { 0u, 0u, 228000000000u }, | |
| 1758 | { 952589339068938148u, 1828779826u, 0u }, | |
| 1759 | { 10058155040190817688u, 1828779826051639971u, 0u }, | |
| 1760 | { 5322725640026584391u, 371564423966525229u, 99138353u }, | |
| 1761 | { 2269982385930389600u, 14464859121514339583u, 49020142547u }, | |
| 1762 | { 13216683679976310224u, 3913119023023056247u, 211784141584u }, | |
| 1763 | { 17417440642083494819u, 5493396321716566945u, 16212130607u }, | |
| 1764 | { 3029180749090900711u, 5837454566818211973u, 47297797611u }, | |
| 1765 | { 8315443826261908513u, 2886670683193253881u, 235316449046u }, | |
| 1766 | { 1488962797247197277u, 5504823105587173817u, 22156486731u }, | |
| 1767 | { 18009099634999034122u, 9431834277334851106u, 75298417058u }, | |
| 1768 | { 8092455412807497971u, 12921661346456247087u, 162511300760u }, | |
| 1769 | { 17808458047236758329u, 3643076516404724246u, 152700484665u }, | |
| 1770 | { 3164591817527425171u, 12559396953196866477u, 57197491573u }, | |
| 1771 | { 3314036340472350590u, 1626880974916825698u, 117680846273u }, | |
| 1772 | { 33234902404332784u, 6806994170946429566u, 193088193394u }, | |
| 1773 | { 12349284717857274280u, 7596631230206896579u, 114369007893u }, | |
| 1774 | { 18209607903013119355u, 3100480253729502401u, 21411814204u }, | |
| 1775 | { 7891549145984268038u, 6310570748781063286u, 60168077371u }, | |
| 1776 | { 7703609897518594624u, 14251867077375744136u, 59342096725u }, | |
| 1777 | { 6336912652634587136u, 6701165793751570137u, 85772595262u }, | |
| 1778 | { 4461621834659397632u, 10856833140463959923u, 62363270925u }, | |
| 1779 | { 5484660635557953536u, 15867563727561248556u, 13588550103u }, | |
| 1780 | { 15142619273265938432u, 5048961008671491600u, 215860182353u }, | |
| 1781 | { 12170977992968765440u, 13278183119599849051u, 81273704724u }, | |
| 1782 | { 1152921504606846976u, 4547591784941053655u, 20719811749u }, | |
| 1783 | { 0u, 11815437715887182496u, 165246525444u }, | |
| 1784 | { 0u, 398495392178782208u, 4640516162u }, | |
| 1785 | { 0u, 9154841240825495552u, 66021602478u }, | |
| 1786 | { 0u, 1902683298245640192u, 174496284938u }, | |
| 1787 | { 0u, 5081900962138816512u, 10103144668u }, | |
| 1788 | { 0u, 3234710432358858752u, 220275490403u }, | |
| 1789 | { 0u, 16717361816799281152u, 99175354003u }, | |
| 1790 | { 0u, 0u, 147906250000u }, | |
| 1791 | { 0u, 0u, 16000000000u }, | |
| 1792 | { 17812314011563521031u, 27904u, 0u }, | |
| 1793 | { 7684138864490314336u, 27904965607477u, 0u }, | |
| 1794 | { 9740522787420029605u, 13488568028574514610u, 1512u }, | |
| 1795 | { 6701109407732989894u, 275784718433886190u, 232731216738u }, | |
| 1796 | { 16534886227502443952u, 10020568880357102364u, 98014950319u }, | |
| 1797 | { 8908667306968317910u, 8876397213146246746u, 175543216127u }, | |
| 1798 | { 7531472173477105155u, 2155905919114811310u, 255481190457u }, | |
| 1799 | { 11527371604834801166u, 1087100407155601220u, 57116871894u }, | |
| 1800 | { 15688593496691078576u, 2903498381705011170u, 214058931831u }, | |
| 1801 | { 11394944804253312188u, 12223476257006657765u, 119157398962u }, | |
| 1802 | { 11182279880854372627u, 12148657163736735595u, 178662635975u }, | |
| 1803 | { 150579373068361470u, 8951241323311673823u, 199658580024u }, | |
| 1804 | { 3147220002440857300u, 8463862715901576300u, 56485247764u }, | |
| 1805 | { 3630514817795505815u, 3873401978748963266u, 20458826917u }, | |
| 1806 | { 11708796588334233588u, 248364795947002730u, 165209977542u }, | |
| 1807 | { 16844495466426369546u, 10454378025404001822u, 198013463882u }, | |
| 1808 | { 17636655472325475902u, 6574176865628265640u, 74566732968u }, | |
| 1809 | { 17038926655686645229u, 16703315293848336u, 168356386842u }, | |
| 1810 | { 15602838456783529415u, 9896033222450013456u, 26000905488u }, | |
| 1811 | { 10869815869248876790u, 17311376269334085007u, 16536465035u }, | |
| 1812 | { 18407124180939800832u, 18378511316495639306u, 139938451587u }, | |
| 1813 | { 5705018517251293184u, 15120796393727584297u, 131996301094u }, | |
| 1814 | { 9660452258743058432u, 18253447805740347049u, 38819700014u }, | |
| 1815 | { 5646292272224927744u, 5842497225601731158u, 46989521388u }, | |
| 1816 | { 7410409304047484928u, 4369968404176723173u, 236316722409u }, | |
| 1817 | { 5953758707383795712u, 16142207253674488117u, 233236896461u }, | |
| 1818 | { 4611686018427387904u, 12124259227391928178u, 205875070808u }, | |
| 1819 | { 0u, 13019483264566077056u, 88657257409u }, | |
| 1820 | { 0u, 74901376448135168u, 193705787602u }, | |
| 1821 | { 0u, 13897060093813325824u, 210004060411u }, | |
| 1822 | { 0u, 4495486210810052608u, 251753361137u }, | |
| 1823 | { 0u, 14885496280087265280u, 241243700795u }, | |
| 1824 | { 0u, 4976477588244398080u, 59806944370u }, | |
| 1825 | { 0u, 11529215046068469760u, 114269775390u }, | |
| 1826 | { 0u, 0u, 30625000000u }, | |
| 1827 | { 0u, 0u, 64000000000u }, | |
| 1828 | { 15035424419724983u, 425795984u, 0u }, | |
| 1829 | { 18280822466032836292u, 425795984000815071u, 0u }, | |
| 1830 | { 11524250747302615283u, 10043594327130472635u, 23082446u }, | |
| 1831 | { 15212285943691810760u, 8336034337032909060u, 206544464339u }, | |
| 1832 | { 7951804027551297019u, 16717215784895280857u, 211451897326u }, | |
| 1833 | { 1706416229965221847u, 10968831263951212032u, 238906242083u }, | |
| 1834 | { 3406023111930700826u, 5536629379734406065u, 35594621534u }, | |
| 1835 | { 16132696204133391302u, 1618806894932332402u, 94300141280u }, | |
| 1836 | { 11593846688794356915u, 11363331325254998861u, 224087755697u }, | |
| 1837 | { 6875759884161133906u, 8775167772751754888u, 177616007425u }, | |
| 1838 | { 3593593325323835965u, 2898202945316114122u, 1475702798u }, | |
| 1839 | { 9542049733257388925u, 8868842714495185148u, 14157111896u }, | |
| 1840 | { 9926551925937787518u, 17052094667531999136u, 88480780926u }, | |
| 1841 | { 3128491553219547895u, 3658615537031138594u, 126924395904u }, | |
| 1842 | { 17158408656931354885u, 12486952437987190746u, 128198333945u }, | |
| 1843 | { 2065169543154992616u, 912079238520577629u, 249676919048u }, | |
| 1844 | { 4832622393556232739u, 10960072898031888041u, 8049443914u }, | |
| 1845 | { 16505930714733656162u, 6129550094334741912u, 74594146742u }, | |
| 1846 | { 18270988073492888699u, 7965724516573729480u, 182332283576u }, | |
| 1847 | { 2525111411519708523u, 5801761178810791992u, 184431822791u }, | |
| 1848 | { 16728989342518570442u, 13197466483098446115u, 199314514103u }, | |
| 1849 | { 7974052022039438336u, 11326268638393107273u, 183715436091u }, | |
| 1850 | { 5356554962386550784u, 3597339351794947378u, 59613998253u }, | |
| 1851 | { 6693869495028547584u, 353880726151383714u, 173195012157u }, | |
| 1852 | { 8157517147199766528u, 11154818162602073600u, 61019183912u }, | |
| 1853 | { 12065776720423157760u, 5141043976157511026u, 40604703904u }, | |
| 1854 | { 11997589407315001344u, 7188225141808859034u, 160278696552u }, | |
| 1855 | { 0u, 13894168943295705185u, 104389674465u }, | |
| 1856 | { 0u, 12176538069834828288u, 225753204407u }, | |
| 1857 | { 0u, 7994239409235165184u, 183660091451u }, | |
| 1858 | { 0u, 13707777025480065024u, 59433368586u }, | |
| 1859 | { 0u, 10120227247676719104u, 10743100081u }, | |
| 1860 | { 0u, 7358494763030413312u, 177548618618u }, | |
| 1861 | { 0u, 7656119366529843200u, 122398904800u }, | |
| 1862 | { 0u, 9223372036854775808u, 224415039062u }, | |
| 1863 | { 0u, 0u, 86500000000u }, | |
| 1864 | { 2418433229320326037u, 6497u, 0u }, | |
| 1865 | { 1143911773589293534u, 6497131103528u, 0u }, | |
| 1866 | { 9276183703610924928u, 3877189582299842749u, 352u }, | |
| 1867 | { 3532180128827684715u, 7625565791857948238u, 96210182868u }, | |
| 1868 | { 8563997501322031543u, 16568435163612007484u, 212413382749u }, | |
| 1869 | { 14843890409658460681u, 17592071940521808130u, 93898176669u }, | |
| 1870 | { 9489417861634552678u, 15158637878035490831u, 157953668130u }, | |
| 1871 | { 1113198223322322089u, 17789243229146401893u, 34821751405u }, | |
| 1872 | { 11190777557146597869u, 14677686051252896484u, 109964356807u }, | |
| 1873 | { 17764553645932638286u, 3531237481269211986u, 199795678955u }, | |
| 1874 | { 14900777150991234852u, 8074435404989280910u, 235191428767u }, | |
| 1875 | { 17364899863357893610u, 7086549341467684427u, 159437716020u }, | |
| 1876 | { 15537570181590167037u, 10556134770918626963u, 52384162609u }, | |
| 1877 | { 5558052627121307766u, 10772666134712966775u, 49572249212u }, | |
| 1878 | { 12095241565795232609u, 6195173298198112620u, 124583987401u }, | |
| 1879 | { 2187936505958366389u, 8144773843324250887u, 201335841017u }, | |
| 1880 | { 12009203621325860228u, 14144284817150924691u, 249441529074u }, | |
| 1881 | { 14814842834750302952u, 6464447844648863176u, 242766763216u }, | |
| 1882 | { 5965296499605198833u, 15760468443293179135u, 208350438419u }, | |
| 1883 | { 4051026394962148842u, 5172191224908322475u, 19854376706u }, | |
| 1884 | { 16799526299141688349u, 2357554307308969012u, 2280385048u }, | |
| 1885 | { 9460214166646215205u, 1602046917604361745u, 24127803275u }, | |
| 1886 | { 10750736995029068008u, 7830970218109515845u, 139086847137u }, | |
| 1887 | { 5377963045376430080u, 2899479134887821084u, 161424517746u }, | |
| 1888 | { 15996910350253424640u, 15792042302392017912u, 114157181078u }, | |
| 1889 | { 13651157529655246848u, 11286099112296056199u, 150856088328u }, | |
| 1890 | { 9771305410219737088u, 15161477829153947404u, 8611820658u }, | |
| 1891 | { 12709439623416250368u, 423831848142641767u, 114821905360u }, | |
| 1892 | { 9943947977234055168u, 9707413321046312582u, 208022975970u }, | |
| 1893 | { 0u, 10969483299803835620u, 226526239930u }, | |
| 1894 | { 0u, 4326479556120930304u, 186594656881u }, | |
| 1895 | { 0u, 12876227232041795584u, 113234538926u }, | |
| 1896 | { 0u, 16967986827791171584u, 174698021676u }, | |
| 1897 | { 0u, 1288146316538413056u, 44919836409u }, | |
| 1898 | { 0u, 13715290452691779584u, 249069830551u }, | |
| 1899 | { 0u, 4683743612465315840u, 151743507385u }, | |
| 1900 | { 0u, 0u, 185253906250u }, | |
| 1901 | { 0u, 0u, 74000000000u }, | |
| 1902 | { 371564423966525229u, 99138353u, 0u }, | |
| 1903 | { 14464859121514339583u, 99138353020142547u, 0u }, | |
| 1904 | { 3913119023023056247u, 16344805304534272784u, 5374300u }, | |
| 1905 | { 5493396321716566945u, 26429987091348271u, 92886053671u }, | |
| 1906 | { 5837454566818211973u, 8691371289609838059u, 39001432772u }, | |
| 1907 | { 2886670683193253881u, 12980168378493046550u, 196471160181u }, | |
| 1908 | { 5504823105587173817u, 14010125458129496139u, 117703656337u }, | |
| 1909 | { 9431834277334851106u, 17061829677031795106u, 145759490422u }, | |
| 1910 | { 12921661346456247087u, 2227928323072698520u, 118924923640u }, | |
| 1911 | { 3643076516404724246u, 7394752319272287289u, 248120776236u }, | |
| 1912 | { 12559396953196866477u, 8805771303577744757u, 44400870326u }, | |
| 1913 | { 1626880974916825698u, 16371027194302248385u, 182477361818u }, | |
| 1914 | { 6806994170946429566u, 9114324123731231602u, 154887475162u }, | |
| 1915 | { 7596631230206896579u, 14468189808746991893u, 218494088500u }, | |
| 1916 | { 3100480253729502401u, 2376054557800684348u, 52784322141u }, | |
| 1917 | { 6310570748781063286u, 12462238943546048571u, 93128806175u }, | |
| 1918 | { 14251867077375744136u, 15334855370842605909u, 31675579326u }, | |
| 1919 | { 6701165793751570137u, 7211347914013798462u, 190831304175u }, | |
| 1920 | { 10856833140463959923u, 13763642332572548877u, 239390927953u }, | |
| 1921 | { 15867563727561248556u, 16868268377740071383u, 81746128545u }, | |
| 1922 | { 5048961008671491600u, 1120013377627684177u, 161914430661u }, | |
| 1923 | { 13278183119599849051u, 15898107650717274388u, 197060716046u }, | |
| 1924 | { 4547591784941053655u, 12281923376333274277u, 14861838142u }, | |
| 1925 | { 11815437715887182496u, 6383530489286615044u, 62665804400u }, | |
| 1926 | { 398495392178782208u, 4253822060257126466u, 112346051881u }, | |
| 1927 | { 9154841240825495552u, 17614372438391501998u, 41230600155u }, | |
| 1928 | { 1902683298245640192u, 4309951310554333450u, 219954877043u }, | |
| 1929 | { 5081900962138816512u, 13106185988973773020u, 115233642928u }, | |
| 1930 | { 3234710432358858752u, 2070134359761960547u, 176710487766u }, | |
| 1931 | { 16717361816799281152u, 9399359914137865875u, 214112222208u }, | |
| 1932 | { 0u, 17415053284723541264u, 509540321u }, | |
| 1933 | { 0u, 4840502610448261120u, 225944071930u }, | |
| 1934 | { 0u, 5690599259712258048u, 250262404172u }, | |
| 1935 | { 0u, 114769594245185536u, 76308488004u }, | |
| 1936 | { 0u, 3150620882578178048u, 68006221672u }, | |
| 1937 | { 0u, 5136918324969472000u, 104170795500u }, | |
| 1938 | { 0u, 7205759403792793600u, 236278472900u }, | |
| 1939 | { 0u, 0u, 196390625000u }, | |
| 1940 | { 0u, 0u, 232000000000u }, | |
| 1941 | { 13488568028574514610u, 1512u, 0u }, | |
| 1942 | { 275784718433886190u, 1512731216738u, 0u }, | |
| 1943 | { 10020568880357102364u, 98202693831717807u, 82u }, | |
| 1944 | { 8876397213146246746u, 12909287260170414079u, 82005323578u }, | |
| 1945 | { 2155905919114811310u, 11728631949380786233u, 58699813864u }, | |
| 1946 | { 1087100407155601220u, 18263701925522197718u, 232635810411u }, | |
| 1947 | { 2903498381705011170u, 4868886449713321591u, 107990077265u }, | |
| 1948 | { 12223476257006657765u, 5870139507184082354u, 81263942863u }, | |
| 1949 | { 12148657163736735595u, 5978562500822661575u, 207318220900u }, | |
| 1950 | { 8951241323311673823u, 10821136839630268472u, 100324098522u }, | |
| 1951 | { 8463862715901576300u, 9490907630136752916u, 218586615003u }, | |
| 1952 | { 3873401978748963266u, 10564005678001613989u, 219514503133u }, | |
| 1953 | { 248364795947002730u, 5754050547468481222u, 221572675895u }, | |
| 1954 | { 10454378025404001822u, 3833909949855542602u, 55311927705u }, | |
| 1955 | { 6574176865628265640u, 15446538552665967784u, 153207836674u }, | |
| 1956 | { 16703315293848336u, 14924837848804399130u, 2837358532u }, | |
| 1957 | { 9896033222450013456u, 18140170340418344208u, 196809077080u }, | |
| 1958 | { 17311376269334085007u, 11380424819825208971u, 88983380604u }, | |
| 1959 | { 18378511316495639306u, 12416915664152252547u, 124616934065u }, | |
| 1960 | { 15120796393727584297u, 17195282241626289958u, 177673122346u }, | |
| 1961 | { 18253447805740347049u, 2649541045825281326u, 42932158118u }, | |
| 1962 | { 5842497225601731158u, 16577429864268509676u, 166143631907u }, | |
| 1963 | { 4369968404176723173u, 12051257060168107241u, 35898664273u }, | |
| 1964 | { 16142207253674488117u, 5363884561143470797u, 81653299954u }, | |
| 1965 | { 12124259227391928178u, 13054029903083620184u, 242290776764u }, | |
| 1966 | { 13019483264566077056u, 566314952158634945u, 188707660379u }, | |
| 1967 | { 74901376448135168u, 1329472079642345682u, 91030699995u }, | |
| 1968 | { 13897060093813325824u, 15686237486658857211u, 219072070825u }, | |
| 1969 | { 4495486210810052608u, 1069073549290598129u, 169850352638u }, | |
| 1970 | { 14885496280087265280u, 4323599065125928507u, 254057954593u }, | |
| 1971 | { 4976477588244398080u, 17861823329752681586u, 33234382774u }, | |
| 1972 | { 11529215046068469760u, 17220149985412802078u, 182968291382u }, | |
| 1973 | { 0u, 4344934572159429184u, 54933506201u }, | |
| 1974 | { 0u, 2252927464837120000u, 153235539375u }, | |
| 1975 | { 0u, 10910018171964489728u, 175122131442u }, | |
| 1976 | { 0u, 3597328585515335680u, 242591433270u }, | |
| 1977 | { 0u, 6972808074239148032u, 54195011573u }, | |
| 1978 | { 0u, 2227030015734710272u, 245377996683u }, | |
| 1979 | { 0u, 1152921504606846976u, 139120727539u }, | |
| 1980 | { 0u, 0u, 243062500000u }, | |
| 1981 | { 0u, 0u, 160000000000u }, | |
| 1982 | { 10043594327130472635u, 23082446u, 0u }, | |
| 1983 | { 8336034337032909060u, 23082446544464339u, 0u }, | |
| 1984 | { 16717215784895280857u, 17238287503805244910u, 1251301u }, | |
| 1985 | { 10968831263951212032u, 1434575446038410275u, 229934489438u }, | |
| 1986 | { 5536629379734406065u, 14009569747841241694u, 94077768490u }, | |
| 1987 | { 1618806894932332402u, 14938795732275951328u, 42759460297u }, | |
| 1988 | { 11363331325254998861u, 6687653542888983473u, 201809833739u }, | |
| 1989 | { 8775167772751754888u, 28238723295162625u, 11362538425u }, | |
| 1990 | { 2898202945316114122u, 4745270274832691214u, 185001530824u }, | |
| 1991 | { 8868842714495185148u, 926478968112308824u, 200257241617u }, | |
| 1992 | { 17052094667531999136u, 9213681606604198526u, 17050224525u }, | |
| 1993 | { 3658615537031138594u, 13346223820579313024u, 141499474680u }, | |
| 1994 | { 12486952437987190746u, 691642518601291257u, 248723500243u }, | |
| 1995 | { 912079238520577629u, 1153720150033789192u, 211037494016u }, | |
| 1996 | { 10960072898031888041u, 12089015034721780810u, 62543294u }, | |
| 1997 | { 6129550094334741912u, 3555868702841788854u, 190655346818u }, | |
| 1998 | { 7965724516573729480u, 11708406782758214328u, 130192764028u }, | |
| 1999 | { 5801761178810791992u, 9417497762905343943u, 124634714003u }, | |
| 2000 | { 13197466483098446115u, 12838336066957615287u, 147510523576u }, | |
| 2001 | { 11326268638393107273u, 13737708142128207419u, 184695967592u }, | |
| 2002 | { 3597339351794947378u, 11683434809834695853u, 104744722650u }, | |
| 2003 | { 353880726151383714u, 2689114340106315837u, 218633360270u }, | |
| 2004 | { 11154818162602073600u, 8859225263374261032u, 142145777180u }, | |
| 2005 | { 5141043976157511026u, 15761671984578600096u, 28480259563u }, | |
| 2006 | { 7188225141808859034u, 7087267079878005352u, 235854441950u }, | |
| 2007 | { 13894168943295705185u, 4601291730423121377u, 222384201518u }, | |
| 2008 | { 12176538069834828288u, 9559411037059581623u, 46249436524u }, | |
| 2009 | { 7994239409235165184u, 12969820289641388091u, 108518216710u }, | |
| 2010 | { 13707777025480065024u, 13628239920285957130u, 6703095366u }, | |
| 2011 | { 10120227247676719104u, 8049893933765800625u, 70738788366u }, | |
| 2012 | { 7358494763030413312u, 10391755948840250234u, 14436385624u }, | |
| 2013 | { 7656119366529843200u, 14454650777462444512u, 88563338218u }, | |
| 2014 | { 9223372036854775808u, 14244638523341127254u, 234783588188u }, | |
| 2015 | { 0u, 12246016810439753984u, 92772203401u }, | |
| 2016 | { 0u, 9382741764551081984u, 137663857901u }, | |
| 2017 | { 0u, 4608696190291148800u, 237508639450u }, | |
| 2018 | { 0u, 1696483666416369664u, 218249837921u }, | |
| 2019 | { 0u, 15416683541605384192u, 97091966563u }, | |
| 2020 | { 0u, 7683140964294066176u, 99835740089u }, | |
| 2021 | { 0u, 4611686018427387904u, 185416503906u }, | |
| 2022 | { 0u, 0u, 98250000000u }, | |
| 2023 | { 0u, 0u, 128000000000u }, | |
| 2024 | { 3877189582299842749u, 352u, 0u }, | |
| 2025 | { 7625565791857948238u, 352210182868u, 0u }, | |
| 2026 | { 16568435163612007484u, 1722045467931902045u, 19u }, | |
| 2027 | { 17592071940521808130u, 16095324008152856733u, 19093352271u }, | |
| 2028 | { 15158637878035490831u, 15216188060094280738u, 79872529262u }, | |
| 2029 | { 17789243229146401893u, 10793385929903030893u, 110824871207u }, | |
| 2030 | { 14677686051252896484u, 12613277226875940039u, 39585110623u }, | |
| 2031 | { 3531237481269211986u, 10644539625155600107u, 95683767128u }, | |
| 2032 | { 8074435404989280910u, 6181262895644173983u, 88577041649u }, | |
| 2033 | { 7086549341467684427u, 148914399627082292u, 241335086933u }, | |
| 2034 | { 10556134770918626963u, 14379289774887985969u, 85008072665u }, | |
| 2035 | { 10772666134712966775u, 11743339675582627452u, 217779502860u }, | |
| 2036 | { 6195173298198112620u, 7841621929809463497u, 12636607719u }, | |
| 2037 | { 8144773843324250887u, 11168944680251236601u, 231425095176u }, | |
| 2038 | { 14144284817150924691u, 6178560202529287410u, 8605469704u }, | |
| 2039 | { 6464447844648863176u, 13295243308201596112u, 8334940419u }, | |
| 2040 | { 15760468443293179135u, 17040673746172470291u, 3720736583u }, | |
| 2041 | { 5172191224908322475u, 14957442487039409922u, 71923776774u }, | |
| 2042 | { 2357554307308969012u, 17778155426506992152u, 6810844581u }, | |
| 2043 | { 1602046917604361745u, 14945404984219733899u, 165963755736u }, | |
| 2044 | { 7830970218109515845u, 11590754866058681505u, 216810192027u }, | |
| 2045 | { 2899479134887821084u, 6020790784469412466u, 155628336080u }, | |
| 2046 | { 15792042302392017912u, 7934351824569522326u, 208326387722u }, | |
| 2047 | { 11286099112296056199u, 5038361112172116744u, 10430122074u }, | |
| 2048 | { 15161477829153947404u, 3305187319649924210u, 90273130103u }, | |
| 2049 | { 423831848142641767u, 11470175511099161552u, 119179174563u }, | |
| 2050 | { 9707413321046312582u, 7308362160352048610u, 163621799460u }, | |
| 2051 | { 10969483299803835620u, 10666410671225576634u, 36396187106u }, | |
| 2052 | { 4326479556120930304u, 2181639019945820785u, 226578227281u }, | |
| 2053 | { 12876227232041795584u, 4615749499734847918u, 81118266888u }, | |
| 2054 | { 16967986827791171584u, 14076159200958497580u, 8250220281u }, | |
| 2055 | { 1288146316538413056u, 5470405257862074105u, 249763070119u }, | |
| 2056 | { 13715290452691779584u, 4565741478181339543u, 167296551263u }, | |
| 2057 | { 4683743612465315840u, 8901832997861862329u, 95247509341u }, | |
| 2058 | { 0u, 14190141170191714122u, 93482569333u }, | |
| 2059 | { 0u, 4240772322245764096u, 117769249094u }, | |
| 2060 | { 0u, 4422842195340951552u, 70229892728u }, | |
| 2061 | { 0u, 15448426386733137920u, 120239762755u }, | |
| 2062 | { 0u, 9203504548935630848u, 67837460872u }, | |
| 2063 | { 0u, 5936377627571912704u, 136498922981u }, | |
| 2064 | { 0u, 468374361246531584u, 229321811676u }, | |
| 2065 | { 0u, 0u, 220025390625u }, | |
| 2066 | { 0u, 0u, 33000000000u }, | |
| 2067 | { 16344805304534272784u, 5374300u, 0u }, | |
| 2068 | { 26429987091348271u, 5374300886053671u, 0u }, | |
| 2069 | { 8691371289609838059u, 8020875056524075716u, 291341u }, | |
| 2070 | { 12980168378493046550u, 1400288714762747253u, 13434812508u }, | |
| 2071 | { 14010125458129496139u, 6136037711314764689u, 92075909803u }, | |
| 2072 | { 17061829677031795106u, 15735488086392394102u, 171332635270u }, | |
| 2073 | { 2227928323072698520u, 7735094782793634552u, 134853022518u }, | |
| 2074 | { 7394752319272287289u, 7273689191766726188u, 54419320328u }, | |
| 2075 | { 8805771303577744757u, 3410634565056431030u, 8394307481u }, | |
| 2076 | { 16371027194302248385u, 4600927904885215898u, 153184890870u }, | |
| 2077 | { 9114324123731231602u, 9154871331680374746u, 246249416801u }, | |
| 2078 | { 14468189808746991893u, 6117978272461042996u, 97496286569u }, | |
| 2079 | { 2376054557800684348u, 13116904339287496285u, 105331656266u }, | |
| 2080 | { 12462238943546048571u, 867037205615660831u, 74711068809u }, | |
| 2081 | { 15334855370842605909u, 1802487145191504830u, 137047002181u }, | |
| 2082 | { 7211347914013798462u, 17242009718457409007u, 69097713023u }, | |
| 2083 | { 13763642332572548877u, 13620802355488468049u, 127934691219u }, | |
| 2084 | { 16868268377740071383u, 4442227880594435745u, 147738385175u }, | |
| 2085 | { 1120013377627684177u, 17354849212854314181u, 23240813655u }, | |
| 2086 | { 15898107650717274388u, 18202319179831567886u, 87940808260u }, | |
| 2087 | { 12281923376333274277u, 17568634016348874558u, 68986749699u }, | |
| 2088 | { 6383530489286615044u, 7496925598312450672u, 3952397558u }, | |
| 2089 | { 4253822060257126466u, 601870379496813865u, 246406409151u }, | |
| 2090 | { 17614372438391501998u, 11995106565680728027u, 191032627458u }, | |
| 2091 | { 4309951310554333450u, 16331071694764184179u, 2650256029u }, | |
| 2092 | { 13106185988973773020u, 9665962217000524208u, 157885309170u }, | |
| 2093 | { 2070134359761960547u, 13682661374415474390u, 242523992861u }, | |
| 2094 | { 9399359914137865875u, 6940361789924260864u, 29741738559u }, | |
| 2095 | { 17415053284723541264u, 9658039831644010465u, 63376237766u }, | |
| 2096 | { 4840502610448261120u, 6843715893910236922u, 198523563388u }, | |
| 2097 | { 5690599259712258048u, 47089792870595660u, 124370998582u }, | |
| 2098 | { 114769594245185536u, 14510386192097156932u, 54002552742u }, | |
| 2099 | { 3150620882578178048u, 12059931208360040296u, 166786609611u }, | |
| 2100 | { 5136918324969472000u, 14877013468459184620u, 203653770180u }, | |
| 2101 | { 7205759403792793600u, 2397668560671695044u, 196806484516u }, | |
| 2102 | { 0u, 2195572305559232232u, 36129977873u }, | |
| 2103 | { 0u, 3261686279425953792u, 17119022213u }, | |
| 2104 | { 0u, 9333850662059900928u, 133176816367u }, | |
| 2105 | { 0u, 5036522340217782272u, 239505989058u }, | |
| 2106 | { 0u, 2800120215143186432u, 194273030423u }, | |
| 2107 | { 0u, 441634238459019264u, 23151794821u }, | |
| 2108 | { 0u, 720575940379279360u, 133023941040u }, | |
| 2109 | { 0u, 0u, 176039062500u }, | |
| 2110 | { 0u, 0u, 228000000000u }, | |
| 2111 | { 98202693831717807u, 82u, 0u }, | |
| 2112 | { 12909287260170414079u, 82005323578u, 0u }, | |
| 2113 | { 11728631949380786233u, 8218347283861607400u, 4u }, | |
| 2114 | { 18263701925522197718u, 17896200385973633643u, 4445517498u }, | |
| 2115 | { 4868886449713321591u, 16333242102094352209u, 186970154966u }, | |
| 2116 | { 5870139507184082354u, 9981905728606788815u, 214885426828u }, | |
| 2117 | { 5978562500822661575u, 15219470018924839012u, 140541120193u }, | |
| 2118 | { 10821136839630268472u, 17152070168529617370u, 193825049122u }, | |
| 2119 | { 9490907630136752916u, 17841343440958328027u, 34929815586u }, | |
| 2120 | { 10564005678001613989u, 17291078023923990493u, 34967181165u }, | |
| 2121 | { 5754050547468481222u, 16744804581790759223u, 109937351217u }, | |
| 2122 | { 3833909949855542602u, 5001622214111594905u, 49907737675u }, | |
| 2123 | { 15446538552665967784u, 9676746897435398146u, 75271138483u }, | |
| 2124 | { 14924837848804399130u, 8109025833995118532u, 179524577500u }, | |
| 2125 | { 18140170340418344208u, 5495826424046694744u, 220439591171u }, | |
| 2126 | { 11380424819825208971u, 7890288164365705852u, 3297929347u }, | |
| 2127 | { 12416915664152252547u, 8616438349039895217u, 131427733378u }, | |
| 2128 | { 17195282241626289958u, 15787154801788760618u, 130467098058u }, | |
| 2129 | { 2649541045825281326u, 12418659311480782502u, 202855823376u }, | |
| 2130 | { 16577429864268509676u, 4486988874116669987u, 16673216870u }, | |
| 2131 | { 12051257060168107241u, 4828971301551875409u, 102243240154u }, | |
| 2132 | { 5363884561143470797u, 14769106422014442226u, 218261779058u }, | |
| 2133 | { 13054029903083620184u, 7763933466423188156u, 114800634863u }, | |
| 2134 | { 566314952158634945u, 10449097116253839963u, 239420883676u }, | |
| 2135 | { 1329472079642345682u, 12870692502472900571u, 220566446689u }, | |
| 2136 | { 15686237486658857211u, 11597479481311003817u, 97697721638u }, | |
| 2137 | { 1069073549290598129u, 8294994869530047486u, 38628700622u }, | |
| 2138 | { 4323599065125928507u, 16879315829924478241u, 206449672572u }, | |
| 2139 | { 17861823329752681586u, 11873324837601439670u, 124915029544u }, | |
| 2140 | { 17220149985412802078u, 3277599055636107318u, 40643654229u }, | |
| 2141 | { 4344934572159429184u, 15363467897354242201u, 85177679000u }, | |
| 2142 | { 2252927464837120000u, 10351182204479784367u, 152832855263u }, | |
| 2143 | { 10910018171964489728u, 12811517584931924466u, 223561138711u }, | |
| 2144 | { 3597328585515335680u, 16988930699558748726u, 23694513759u }, | |
| 2145 | { 6972808074239148032u, 11683499918824718325u, 95920971778u }, | |
| 2146 | { 2227030015734710272u, 13119300691281647499u, 2633363799u }, | |
| 2147 | { 1152921504606846976u, 10125549106595354099u, 87711198715u }, | |
| 2148 | { 0u, 17505352699870800544u, 251548907116u }, | |
| 2149 | { 0u, 6756039242241163264u, 108948967071u }, | |
| 2150 | { 0u, 3537338758766526464u, 159366245621u }, | |
| 2151 | { 0u, 6522626374119718912u, 245191759518u }, | |
| 2152 | { 0u, 4733294203482669056u, 158353592284u }, | |
| 2153 | { 0u, 16997710893603094528u, 220256592392u }, | |
| 2154 | { 0u, 16717361816799281152u, 8921447753u }, | |
| 2155 | { 0u, 0u, 73906250000u }, | |
| 2156 | { 0u, 0u, 16000000000u }, | |
| 2157 | { 17238287503805244910u, 1251301u, 0u }, | |
| 2158 | { 1434575446038410275u, 1251301934489438u, 0u }, | |
| 2159 | { 14009569747841241694u, 3943737498063000362u, 67833u }, | |
| 2160 | { 14938795732275951328u, 2870731037991212489u, 249213790438u }, | |
| 2161 | { 6687653542888983473u, 7389433400402095883u, 230155622641u }, | |
| 2162 | { 28238723295162625u, 5675049236146197433u, 241400581987u }, | |
| 2163 | { 4745270274832691214u, 9953779846262904264u, 99307645035u }, | |
| 2164 | { 926478968112308824u, 12691978937179636241u, 107539595486u }, | |
| 2165 | { 9213681606604198526u, 15523327331528198029u, 222688033556u }, | |
| 2166 | { 13346223820579313024u, 15722603279568118520u, 20841521260u }, | |
| 2167 | { 691642518601291257u, 11838632364171816147u, 108852324031u }, | |
| 2168 | { 1153720150033789192u, 7832751832367143680u, 191641773546u }, | |
| 2169 | { 12089015034721780810u, 12167724027162940862u, 234424614327u }, | |
| 2170 | { 3555868702841788854u, 4108211144748152962u, 183659613641u }, | |
| 2171 | { 11708406782758214328u, 7530983398136343676u, 201222706572u }, | |
| 2172 | { 9417497762905343943u, 1117587133956542355u, 140408255428u }, | |
| 2173 | { 12838336066957615287u, 17134748625149490872u, 196060584519u }, | |
| 2174 | { 13737708142128207419u, 4039918359454207848u, 71928876584u }, | |
| 2175 | { 11683434809834695853u, 1830218764589441242u, 40219004413u }, | |
| 2176 | { 2689114340106315837u, 637895981480825742u, 253099216358u }, | |
| 2177 | { 8859225263374261032u, 8246879226348334620u, 230034580410u }, | |
| 2178 | { 15761671984578600096u, 12389239568142583275u, 186447064218u }, | |
| 2179 | { 7087267079878005352u, 14041257178803154398u, 154671622022u }, | |
| 2180 | { 4601291730423121377u, 16312515716494630702u, 134761178076u }, | |
| 2181 | { 9559411037059581623u, 17088522799596987756u, 220884303248u }, | |
| 2182 | { 12969820289641388091u, 3588932524637852678u, 144926370677u }, | |
| 2183 | { 13628239920285957130u, 107218049069817414u, 117194556422u }, | |
| 2184 | { 8049893933765800625u, 1596707240462008334u, 6005812302u }, | |
| 2185 | { 10391755948840250234u, 17461913142391587672u, 78086557672u }, | |
| 2186 | { 14454650777462444512u, 4366474266651610090u, 232946612208u }, | |
| 2187 | { 14244638523341127254u, 5539304013194805084u, 240236707044u }, | |
| 2188 | { 12246016810439753984u, 4762470619211987849u, 228300286272u }, | |
| 2189 | { 9382741764551081984u, 10835638458986644717u, 64258174049u }, | |
| 2190 | { 4608696190291148800u, 16141642290510052058u, 97587401137u }, | |
| 2191 | { 1696483666416369664u, 17390568670756355425u, 177875040181u }, | |
| 2192 | { 15416683541605384192u, 12536768491333867107u, 181942744616u }, | |
| 2193 | { 7683140964294066176u, 13145148522871947193u, 40679619581u }, | |
| 2194 | { 4611686018427387904u, 5665349945233068642u, 253712599929u }, | |
| 2195 | { 0u, 17074607537751066240u, 121307119235u }, | |
| 2196 | { 0u, 6241525660962062336u, 131925616329u }, | |
| 2197 | { 0u, 1142860629783085056u, 201338353784u }, | |
| 2198 | { 0u, 16287527416870469632u, 120061954598u }, | |
| 2199 | { 0u, 9028002014738513920u, 38882948630u }, | |
| 2200 | { 0u, 16217462258161156096u, 22489408969u }, | |
| 2201 | { 0u, 11529215046068469760u, 201879150390u }, | |
| 2202 | { 0u, 0u, 54625000000u }, | |
| 2203 | { 0u, 0u, 64000000000u }, | |
| 2204 | { 1722045467931902045u, 19u, 0u }, | |
| 2205 | { 16095324008152856733u, 19093352271u, 0u }, | |
| 2206 | { 15216188060094280738u, 646608198162977646u, 1u }, | |
| 2207 | { 10793385929903030893u, 12170458846894708007u, 1035052700u }, | |
| 2208 | { 12613277226875940039u, 1797330480103086687u, 156659761896u }, | |
| 2209 | { 10644539625155600107u, 10332188564497263448u, 232097433480u }, | |
| 2210 | { 6181262895644173983u, 7524259485079594225u, 136560109064u }, | |
| 2211 | { 148914399627082292u, 62681109059153749u, 8407890924u }, | |
| 2212 | { 14379289774887985969u, 13480636451804037081u, 236003397949u }, | |
| 2213 | { 11743339675582627452u, 6948168233012789004u, 61730786766u }, | |
| 2214 | { 7841621929809463497u, 12015502974041806055u, 206376660954u }, | |
| 2215 | { 11168944680251236601u, 7343801660689004040u, 218651361721u }, | |
| 2216 | { 6178560202529287410u, 13670580858640731144u, 185398108285u }, | |
| 2217 | { 13295243308201596112u, 5605073897566574851u, 125741083673u }, | |
| 2218 | { 17040673746172470291u, 15387788940505247559u, 25303851664u }, | |
| 2219 | { 14957442487039409922u, 17565181499678113030u, 144834173709u }, | |
| 2220 | { 17778155426506992152u, 1893743623847493029u, 13952210397u }, | |
| 2221 | { 14945404984219733899u, 10243498996716269784u, 221102660047u }, | |
| 2222 | { 11590754866058681505u, 5619675836950314139u, 207555301193u }, | |
| 2223 | { 6020790784469412466u, 10224869737511515088u, 73304643237u }, | |
| 2224 | { 7934351824569522326u, 2574495974386198538u, 165554291299u }, | |
| 2225 | { 5038361112172116744u, 7825756347302873178u, 99139563706u }, | |
| 2226 | { 3305187319649924210u, 12071550103794656887u, 186424235101u }, | |
| 2227 | { 11470175511099161552u, 7195875213867606691u, 93654400042u }, | |
| 2228 | { 7308362160352048610u, 18271364438406891044u, 42390089176u }, | |
| 2229 | { 10666410671225576634u, 16966521933952564706u, 216990492650u }, | |
| 2230 | { 2181639019945820785u, 289920862029570129u, 234919756997u }, | |
| 2231 | { 4615749499734847918u, 7804199568098625032u, 197015716641u }, | |
| 2232 | { 14076159200958497580u, 5758118571242446585u, 33423066506u }, | |
| 2233 | { 5470405257862074105u, 4030788293606375591u, 138312148233u }, | |
| 2234 | { 4565741478181339543u, 4387716460037196127u, 9218509471u }, | |
| 2235 | { 8901832997861862329u, 16807506478881285981u, 159237858585u }, | |
| 2236 | { 14190141170191714122u, 17033060604413529717u, 25911136751u }, | |
| 2237 | { 4240772322245764096u, 10498418508292170054u, 239923364065u }, | |
| 2238 | { 4422842195340951552u, 13237752038744465016u, 225569120407u }, | |
| 2239 | { 15448426386733137920u, 17737618428304633155u, 151717619975u }, | |
| 2240 | { 9203504548935630848u, 13546183833248825736u, 7961558221u }, | |
| 2241 | { 5936377627571912704u, 826778452978976229u, 205734340097u }, | |
| 2242 | { 468374361246531584u, 13728076626990147292u, 1044819749u }, | |
| 2243 | { 0u, 2794860281883592225u, 37744200525u }, | |
| 2244 | { 0u, 8680705720425908736u, 77151509679u }, | |
| 2245 | { 0u, 731520517439488000u, 175470582000u }, | |
| 2246 | { 0u, 13120812320768917504u, 240039655806u }, | |
| 2247 | { 0u, 2722954908557901824u, 126711280661u }, | |
| 2248 | { 0u, 6860847004205973504u, 21147611681u }, | |
| 2249 | { 0u, 6503197861922996224u, 33371927261u }, | |
| 2250 | { 0u, 9223372036854775808u, 221352539062u }, | |
| 2251 | { 0u, 0u, 182500000000u }, | |
| 2252 | { 8020875056524075716u, 291341u, 0u }, | |
| 2253 | { 1400288714762747253u, 291341434812508u, 0u }, | |
| 2254 | { 6136037711314764689u, 12005656413127238315u, 15793u }, | |
| 2255 | { 15735488086392394102u, 4821130826186787462u, 177650827938u }, | |
| 2256 | { 7735094782793634552u, 14377899467066168118u, 162261354025u }, | |
| 2257 | { 7273689191766726188u, 16575613239625444872u, 41779427491u }, | |
| 2258 | { 3410634565056431030u, 4317827099179284377u, 163898565794u }, | |
| 2259 | { 4600927904885215898u, 1242354770412171254u, 162234069876u }, | |
| 2260 | { 9154871331680374746u, 994838588328896609u, 116067348187u }, | |
| 2261 | { 6117978272461042996u, 17283309862013060457u, 219053930307u }, | |
| 2262 | { 13116904339287496285u, 124242522249856586u, 67936930105u }, | |
| 2263 | { 867037205615660831u, 11564608014666985609u, 57006735200u }, | |
| 2264 | { 1802487145191504830u, 12401028575581654085u, 96626918656u }, | |
| 2265 | { 17242009718457409007u, 2490725392961465727u, 672261106u }, | |
| 2266 | { 13620802355488468049u, 1949482237120640915u, 242135022494u }, | |
| 2267 | { 4442227880594435745u, 15410502396166200087u, 158105681643u }, | |
| 2268 | { 17354849212854314181u, 15694919529799920727u, 235835405008u }, | |
| 2269 | { 18202319179831567886u, 10324869370171768388u, 208850823292u }, | |
| 2270 | { 17568634016348874558u, 1631866459122189059u, 124559712290u }, | |
| 2271 | { 7496925598312450672u, 172020494461226230u, 34088463658u }, | |
| 2272 | { 601870379496813865u, 12734610307908856767u, 42009325249u }, | |
| 2273 | { 11995106565680728027u, 1467513250829340930u, 193690344608u }, | |
| 2274 | { 16331071694764184179u, 13558759428494307997u, 160079554052u }, | |
| 2275 | { 9665962217000524208u, 7915355143999496434u, 4735021821u }, | |
| 2276 | { 13682661374415474390u, 2876370200608797469u, 253429092262u }, | |
| 2277 | { 6940361789924260864u, 343685370404989503u, 166155928341u }, | |
| 2278 | { 9658039831644010465u, 4837266557407634630u, 21018631221u }, | |
| 2279 | { 6843715893910236922u, 9622591415747161468u, 53262228745u }, | |
| 2280 | { 47089792870595660u, 16503783814424220982u, 9521641725u }, | |
| 2281 | { 14510386192097156932u, 5377083431343591334u, 253894671913u }, | |
| 2282 | { 12059931208360040296u, 16508482371299291595u, 41291492276u }, | |
| 2283 | { 14877013468459184620u, 10515883558812249028u, 180894926622u }, | |
| 2284 | { 2397668560671695044u, 63492062913405476u, 30570067190u }, | |
| 2285 | { 2195572305559232232u, 11571919759617799697u, 246003441911u }, | |
| 2286 | { 3261686279425953792u, 2956602334970088581u, 247627315027u }, | |
| 2287 | { 9333850662059900928u, 13604736747717849839u, 83160277733u }, | |
| 2288 | { 5036522340217782272u, 16573540719338151362u, 229737514256u }, | |
| 2289 | { 2800120215143186432u, 12620703004601168151u, 16898453442u }, | |
| 2290 | { 441634238459019264u, 14649407809089591941u, 194684169680u }, | |
| 2291 | { 720575940379279360u, 11290375247898624432u, 208794145988u }, | |
| 2292 | { 0u, 11020319450292874212u, 196612052468u }, | |
| 2293 | { 0u, 8754634933362354176u, 244597412714u }, | |
| 2294 | { 0u, 12976319450332528640u, 106474589710u }, | |
| 2295 | { 0u, 17447331119627239424u, 14703447686u }, | |
| 2296 | { 0u, 3665184902673858560u, 134945821715u }, | |
| 2297 | { 0u, 12949678516038795264u, 19198690071u }, | |
| 2298 | { 0u, 72057594037927936u, 23702003479u }, | |
| 2299 | { 0u, 0u, 23003906250u }, | |
| 2300 | { 0u, 0u, 202000000000u }, | |
| 2301 | { 8218347283861607400u, 4u, 0u }, | |
| 2302 | { 17896200385973633643u, 4445517498u, 0u }, | |
| 2303 | { 16333242102094352209u, 4445517498970154966u, 0u }, | |
| 2304 | { 9981905728606788815u, 9413159735776077452u, 240991986u }, | |
| 2305 | { 15219470018924839012u, 14279163482889998017u, 242510288411u }, | |
| 2306 | { 17152070168529617370u, 8693044629541194274u, 27774075003u }, | |
| 2307 | { 17841343440958328027u, 11863110253260222498u, 123471250893u }, | |
| 2308 | { 17291078023923990493u, 8319293368489531245u, 205643100495u }, | |
| 2309 | { 16744804581790759223u, 3376307525676489265u, 79450989797u }, | |
| 2310 | { 5001622214111594905u, 13205662254759912523u, 229183029997u }, | |
| 2311 | { 9676746897435398146u, 5276250334231686323u, 237715880385u }, | |
| 2312 | { 8109025833995118532u, 13790198520922745052u, 193286026103u }, | |
| 2313 | { 5495826424046694744u, 14195535250150996227u, 119747568159u }, | |
| 2314 | { 7890288164365705852u, 16425228796427004035u, 31769541507u }, | |
| 2315 | { 8616438349039895217u, 4295900841296269186u, 131890413437u }, | |
| 2316 | { 15787154801788760618u, 4533952595483946442u, 125232881251u }, | |
| 2317 | { 12418659311480782502u, 12885038019373447184u, 99245786062u }, | |
| 2318 | { 4486988874116669987u, 12140736240487831910u, 206698499310u }, | |
| 2319 | { 4828971301551875409u, 6927124077155322074u, 238658150630u }, | |
| 2320 | { 14769106422014442226u, 12477788342407819890u, 230375520148u }, | |
| 2321 | { 7763933466423188156u, 7980854329409711087u, 148676422261u }, | |
| 2322 | { 10449097116253839963u, 2062671021810827996u, 117432642980u }, | |
| 2323 | { 12870692502472900571u, 2739521363598172769u, 164111817620u }, | |
| 2324 | { 11597479481311003817u, 12897585686593465638u, 148148509750u }, | |
| 2325 | { 8294994869530047486u, 1127632646629044686u, 54699179521u }, | |
| 2326 | { 16879315829924478241u, 4833775019274666364u, 1061129088u }, | |
| 2327 | { 11873324837601439670u, 15867662672939849256u, 128262039468u }, | |
| 2328 | { 3277599055636107318u, 2092350330982953557u, 172860187717u }, | |
| 2329 | { 15363467897354242201u, 13330062299842493592u, 69113426538u }, | |
| 2330 | { 10351182204479784367u, 4479193352178519263u, 106722624125u }, | |
| 2331 | { 12811517584931924466u, 3149393938889064983u, 125242817558u }, | |
| 2332 | { 16988930699558748726u, 9736379904070620767u, 22170728987u }, | |
| 2333 | { 11683499918824718325u, 3816238703055069186u, 27527810212u }, | |
| 2334 | { 13119300691281647499u, 11598915938798661975u, 164206878714u }, | |
| 2335 | { 10125549106595354099u, 17821633264606555643u, 250628778492u }, | |
| 2336 | { 17505352699870800544u, 2514623558764574316u, 252966112675u }, | |
| 2337 | { 6756039242241163264u, 4976730480406253215u, 163136318016u }, | |
| 2338 | { 3537338758766526464u, 17276563697191611637u, 64269789099u }, | |
| 2339 | { 6522626374119718912u, 12524734095940998814u, 171936564394u }, | |
| 2340 | { 4733294203482669056u, 15331551308930355164u, 170678967195u }, | |
| 2341 | { 16997710893603094528u, 15417115581125943816u, 155831125061u }, | |
| 2342 | { 16717361816799281152u, 6010750237807115593u, 69835763510u }, | |
| 2343 | { 0u, 5624630987553628432u, 54325843423u }, | |
| 2344 | { 0u, 14881848243837640704u, 223304911856u }, | |
| 2345 | { 0u, 15281613886881529856u, 240806746609u }, | |
| 2346 | { 0u, 14057902358273196032u, 241828417948u }, | |
| 2347 | { 0u, 16075318494433902592u, 156762080413u }, | |
| 2348 | { 0u, 13891916000577716224u, 157871444761u }, | |
| 2349 | { 0u, 7205759403792793600u, 25753082275u }, | |
| 2350 | { 0u, 0u, 163390625000u }, | |
| 2351 | { 0u, 0u, 232000000000u }, | |
| 2352 | { 3943737498063000362u, 67833u, 0u }, | |
| 2353 | { 2870731037991212489u, 67833213790438u, 0u }, | |
| 2354 | { 7389433400402095883u, 4535831408134330609u, 3677u }, | |
| 2355 | { 5675049236146197433u, 6204770794376564579u, 93245887913u }, | |
| 2356 | { 9953779846262904264u, 13869812122751887467u, 169336361298u }, | |
| 2357 | { 12691978937179636241u, 14253229412394467550u, 82751884021u }, | |
| 2358 | { 15523327331528198029u, 12776557610216045332u, 245772669114u }, | |
| 2359 | { 15722603279568118520u, 16493640728678654060u, 186692618575u }, | |
| 2360 | { 11838632364171816147u, 9434398296825833151u, 79894122055u }, | |
| 2361 | { 7832751832367143680u, 8773374058285327850u, 71511439756u }, | |
| 2362 | { 12167724027162940862u, 12932015276748029367u, 140475605560u }, | |
| 2363 | { 4108211144748152962u, 16293958583527755209u, 56701045952u }, | |
| 2364 | { 7530983398136343676u, 13511893936143127948u, 192883297264u }, | |
| 2365 | { 1117587133956542355u, 18409936402005226436u, 240732481237u }, | |
| 2366 | { 17134748625149490872u, 2189663026458466887u, 213998004652u }, | |
| 2367 | { 4039918359454207848u, 9497725274248154664u, 172118701870u }, | |
| 2368 | { 1830218764589441242u, 14766925481127792125u, 46514872718u }, | |
| 2369 | { 637895981480825742u, 6982373971809635814u, 142800516634u }, | |
| 2370 | { 8246879226348334620u, 8616702383006884794u, 26378515251u }, | |
| 2371 | { 12389239568142583275u, 3059473300040871066u, 51467112372u }, | |
| 2372 | { 14041257178803154398u, 17123843157031495558u, 180165854379u }, | |
| 2373 | { 16312515716494630702u, 11210627174210626524u, 171928285397u }, | |
| 2374 | { 17088522799596987756u, 15868067138625928592u, 213607729316u }, | |
| 2375 | { 3588932524637852678u, 4467869511636937589u, 164860209643u }, | |
| 2376 | { 107218049069817414u, 10052108125844341766u, 235242203691u }, | |
| 2377 | { 1596707240462008334u, 7470588003218451534u, 43544925873u }, | |
| 2378 | { 17461913142391587672u, 2613527085490786280u, 177404981387u }, | |
| 2379 | { 4366474266651610090u, 3632919450036549616u, 139141679587u }, | |
| 2380 | { 5539304013194805084u, 179367907231218916u, 227196940958u }, | |
| 2381 | { 4762470619211987849u, 13553068184555874624u, 158009723553u }, | |
| 2382 | { 10835638458986644717u, 8798774862365584481u, 161734713298u }, | |
| 2383 | { 16141642290510052058u, 910911255817064881u, 210476982541u }, | |
| 2384 | { 17390568670756355425u, 2304331144765093813u, 13049380598u }, | |
| 2385 | { 12536768491333867107u, 12248937023083640360u, 246124918041u }, | |
| 2386 | { 13145148522871947193u, 10206039550662130685u, 25664016206u }, | |
| 2387 | { 5665349945233068642u, 12267881323837852537u, 78553270512u }, | |
| 2388 | { 17074607537751066240u, 2858642007937891971u, 240665043179u }, | |
| 2389 | { 6241525660962062336u, 14171330289750320841u, 235154967293u }, | |
| 2390 | { 1142860629783085056u, 6601103619749017720u, 253768229354u }, | |
| 2391 | { 16287527416870469632u, 4919573414486739494u, 234357846544u }, | |
| 2392 | { 9028002014738513920u, 3401998285294974486u, 16266690609u }, | |
| 2393 | { 16217462258161156096u, 10799436256515532233u, 49184422696u }, | |
| 2394 | { 11529215046068469760u, 10083786644665753398u, 40585438612u }, | |
| 2395 | { 0u, 6481194517685688896u, 148546643169u }, | |
| 2396 | { 0u, 15104161756860547072u, 225351346258u }, | |
| 2397 | { 0u, 9556039274244079616u, 82818798249u }, | |
| 2398 | { 0u, 1376343134954323968u, 169518033927u }, | |
| 2399 | { 0u, 15682488278596976640u, 7074611710u }, | |
| 2400 | { 0u, 1506454075355430912u, 254850149393u }, | |
| 2401 | { 0u, 1152921504606846976u, 17081665039u }, | |
| 2402 | { 0u, 0u, 15062500000u }, | |
| 2403 | { 0u, 0u, 160000000000u }, | |
| 2404 | { 12170458846894708007u, 1035052700u, 0u }, | |
| 2405 | { 1797330480103086687u, 1035052700659761896u, 0u }, | |
| 2406 | { 10332188564497263448u, 6172559441576707976u, 56110319u }, | |
| 2407 | { 7524259485079594225u, 15083329738554729992u, 239334615117u }, | |
| 2408 | { 62681109059153749u, 10013126833549229036u, 77817668943u }, | |
| 2409 | { 13480636451804037081u, 5817156823499936061u, 79542812693u }, | |
| 2410 | { 6948168233012789004u, 5282692560913632718u, 21315348703u }, | |
| 2411 | { 12015502974041806055u, 10252307034225766362u, 223286375337u }, | |
| 2412 | { 7343801660689004040u, 17981881283247669689u, 169555778677u }, | |
| 2413 | { 13670580858640731144u, 11689290159733383293u, 117974799737u }, | |
| 2414 | { 5605073897566574851u, 5530668968487988249u, 121633677689u }, | |
| 2415 | { 15387788940505247559u, 10083765740821947024u, 121299818165u }, | |
| 2416 | { 17565181499678113030u, 2798423656816843533u, 181546642036u }, | |
| 2417 | { 1893743623847493029u, 7614494481582904797u, 116151702850u }, | |
| 2418 | { 10243498996716269784u, 17811318500083423695u, 66412782572u }, | |
| 2419 | { 5619675836950314139u, 11641467412200329033u, 236965553510u }, | |
| 2420 | { 10224869737511515088u, 17733593025296340645u, 102631085212u }, | |
| 2421 | { 2574495974386198538u, 3689424000190644835u, 156961340004u }, | |
| 2422 | { 7825756347302873178u, 14966634145516728506u, 100200004075u }, | |
| 2423 | { 12071550103794656887u, 14171681941562070109u, 235811342862u }, | |
| 2424 | { 7195875213867606691u, 8130575762882608170u, 14768248417u }, | |
| 2425 | { 18271364438406891044u, 5234550794400656856u, 97440759395u }, | |
| 2426 | { 16966521933952564706u, 3020576149360486378u, 99283765567u }, | |
| 2427 | { 289920862029570129u, 3038675756589057221u, 63163745761u }, | |
| 2428 | { 7804199568098625032u, 15470260187120878369u, 225164726942u }, | |
| 2429 | { 5758118571242446585u, 3497929414841828746u, 158838644485u }, | |
| 2430 | { 4030788293606375591u, 9935840636861015305u, 5189623133u }, | |
| 2431 | { 4387716460037196127u, 3647355485153741471u, 93538623000u }, | |
| 2432 | { 16807506478881285981u, 766100215038272793u, 24197723537u }, | |
| 2433 | { 17033060604413529717u, 16128087474216800751u, 145041530375u }, | |
| 2434 | { 10498418508292170054u, 16216631732633731297u, 7874305373u }, | |
| 2435 | { 13237752038744465016u, 13760220872779997335u, 93879105367u }, | |
| 2436 | { 17737618428304633155u, 3826276262374222087u, 87745943068u }, | |
| 2437 | { 13546183833248825736u, 14938032745839181005u, 28207422851u }, | |
| 2438 | { 826778452978976229u, 14479259995009508865u, 131809792377u }, | |
| 2439 | { 13728076626990147292u, 2372033248156102437u, 121784922257u }, | |
| 2440 | { 2794860281883592225u, 792005346826701645u, 145128588180u }, | |
| 2441 | { 8680705720425908736u, 16278924527931792559u, 148042934695u }, | |
| 2442 | { 731520517439488000u, 17442516423538940144u, 167882482266u }, | |
| 2443 | { 13120812320768917504u, 13844184233048446u, 90945560710u }, | |
| 2444 | { 2722954908557901824u, 13486193870480782357u, 134000750494u }, | |
| 2445 | { 6860847004205973504u, 11931315179184648737u, 158731088034u }, | |
| 2446 | { 6503197861922996224u, 16492562205587485405u, 162646797891u }, | |
| 2447 | { 9223372036854775808u, 12128987217680380854u, 67894063588u }, | |
| 2448 | { 0u, 10568123814189138176u, 228657513714u }, | |
| 2449 | { 0u, 17007583519117541376u, 242572899139u }, | |
| 2450 | { 0u, 143791533903052800u, 67921982950u }, | |
| 2451 | { 0u, 12398714235792654336u, 230007794954u }, | |
| 2452 | { 0u, 9659957317919047680u, 10672135645u }, | |
| 2453 | { 0u, 9412523221204336640u, 221523667335u }, | |
| 2454 | { 0u, 4611686018427387904u, 135510253906u }, | |
| 2455 | { 0u, 0u, 82250000000u }, | |
| 2456 | { 0u, 0u, 128000000000u }, | |
| 2457 | { 12005656413127238315u, 15793u, 0u }, | |
| 2458 | { 4821130826186787462u, 15793650827938u, 0u }, | |
| 2459 | { 14377899467066168118u, 3237900842885170729u, 856u }, | |
| 2460 | { 16575613239625444872u, 7515893506498066595u, 88175526956u }, | |
| 2461 | { 4317827099179284377u, 7300206309181072546u, 44407437403u }, | |
| 2462 | { 1242354770412171254u, 5999737279837044u, 91395744977u }, | |
| 2463 | { 994838588328896609u, 7556839307242450651u, 209000325246u }, | |
| 2464 | { 17283309862013060457u, 12946035041643640643u, 126409657079u }, | |
| 2465 | { 124242522249856586u, 15885877642352740665u, 247701805965u }, | |
| 2466 | { 11564608014666985609u, 10770818348246089568u, 141861175152u }, | |
| 2467 | { 12401028575581654085u, 11635415503599551744u, 112583887232u }, | |
| 2468 | { 2490725392961465727u, 6248053924100826098u, 128630757138u }, | |
| 2469 | { 1949482237120640915u, 16894170802729859998u, 18338707681u }, | |
| 2470 | { 15410502396166200087u, 6143589029651889899u, 225915834834u }, | |
| 2471 | { 15694919529799920727u, 11812087701837886160u, 210333044628u }, | |
| 2472 | { 10324869370171768388u, 7306705080150829180u, 148640334557u }, | |
| 2473 | { 1631866459122189059u, 1485332570280714274u, 221396097276u }, | |
| 2474 | { 172020494461226230u, 18042602303295630634u, 252080520039u }, | |
| 2475 | { 12734610307908856767u, 13397029889257074369u, 103978091430u }, | |
| 2476 | { 1467513250829340930u, 9948104869613411488u, 166726254445u }, | |
| 2477 | { 13558759428494307997u, 10836066241170646532u, 109539287845u }, | |
| 2478 | { 7915355143999496434u, 18330574781234459389u, 37587424327u }, | |
| 2479 | { 2876370200608797469u, 666297360208433062u, 71993702450u }, | |
| 2480 | { 343685370404989503u, 5035352224889324309u, 50036120052u }, | |
| 2481 | { 4837266557407634630u, 1341745796439923765u, 244272966991u }, | |
| 2482 | { 9622591415747161468u, 6846932182653803785u, 79072736185u }, | |
| 2483 | { 16503783814424220982u, 6727685027257825533u, 185371172937u }, | |
| 2484 | { 5377083431343591334u, 2168538874806877737u, 73364708536u }, | |
| 2485 | { 16508482371299291595u, 17694936100676971444u, 184117556727u }, | |
| 2486 | { 10515883558812249028u, 2163944241059563294u, 247959244408u }, | |
| 2487 | { 63492062913405476u, 6727780864524301558u, 120117307652u }, | |
| 2488 | { 11571919759617799697u, 8599551977795002615u, 4364713731u }, | |
| 2489 | { 2956602334970088581u, 15428264807806859091u, 3466182646u }, | |
| 2490 | { 13604736747717849839u, 2126771385339683557u, 246836367911u }, | |
| 2491 | { 16573540719338151362u, 15094316562082972944u, 39115292507u }, | |
| 2492 | { 12620703004601168151u, 8111300598225956802u, 91818264540u }, | |
| 2493 | { 14649407809089591941u, 9481215200564260304u, 220439714486u }, | |
| 2494 | { 11290375247898624432u, 16836674128623424708u, 182513977705u }, | |
| 2495 | { 11020319450292874212u, 7087243115299722740u, 105912717933u }, | |
| 2496 | { 8754634933362354176u, 2343560867338408810u, 109384200219u }, | |
| 2497 | { 12976319450332528640u, 3431385749090422286u, 27127044689u }, | |
| 2498 | { 17447331119627239424u, 3504545517469224582u, 81186015794u }, | |
| 2499 | { 3665184902673858560u, 3333759805712094227u, 50189981793u }, | |
| 2500 | { 12949678516038795264u, 3595183476205994775u, 97180723481u }, | |
| 2501 | { 72057594037927936u, 14191566632569921303u, 25194895286u }, | |
| 2502 | { 0u, 12917427671358095562u, 182769326368u }, | |
| 2503 | { 0u, 3883793922738316288u, 32700255157u }, | |
| 2504 | { 0u, 7857281689266421760u, 181210540890u }, | |
| 2505 | { 0u, 15987081651486195712u, 90425944093u }, | |
| 2506 | { 0u, 16827562156399525888u, 29866661432u }, | |
| 2507 | { 0u, 7012737938513461248u, 56912223972u }, | |
| 2508 | { 0u, 7385903388887613440u, 228380161285u }, | |
| 2509 | { 0u, 0u, 5400390625u }, | |
| 2510 | { 0u, 0u, 225000000000u }, | |
| 2511 | { 9413159735776077452u, 240991986u, 0u }, | |
| 2512 | { 14279163482889998017u, 240991986510288411u, 0u }, | |
| 2513 | { 8693044629541194274u, 14135788013842776187u, 13064201u }, | |
| 2514 | { 11863110253260222498u, 13284322918167594445u, 9766302603u }, | |
| 2515 | { 8319293368489531245u, 7264587765474046287u, 139720144588u }, | |
| 2516 | { 3376307525676489265u, 16176482219778368741u, 204393814091u }, | |
| 2517 | { 13205662254759912523u, 5401983818872095469u, 75876928858u }, | |
| 2518 | { 5276250334231686323u, 11208857446851049921u, 90292842129u }, | |
| 2519 | { 13790198520922745052u, 13794690008281035639u, 145607633379u }, | |
| 2520 | { 14195535250150996227u, 14519782740993303071u, 227747811643u }, | |
| 2521 | { 16425228796427004035u, 10885858587044789123u, 59787118999u }, | |
| 2522 | { 4295900841296269186u, 8710500938899914621u, 151590123576u }, | |
| 2523 | { 4533952595483946442u, 1284182587483102819u, 56472197202u }, | |
| 2524 | { 12885038019373447184u, 10346074482131502030u, 82069615677u }, | |
| 2525 | { 12140736240487831910u, 9429804686255246574u, 61560861821u }, | |
| 2526 | { 6927124077155322074u, 6412022633845121254u, 125511190736u }, | |
| 2527 | { 12477788342407819890u, 8892351297529018260u, 208347596443u }, | |
| 2528 | { 7980854329409711087u, 14098160105983060597u, 155482055329u }, | |
| 2529 | { 2062671021810827996u, 13793833029739474340u, 161764262790u }, | |
| 2530 | { 2739521363598172769u, 16367653765996977044u, 134747765186u }, | |
| 2531 | { 12897585686593465638u, 10684788343333772342u, 194887292288u }, | |
| 2532 | { 1127632646629044686u, 13272681218705145345u, 128579223536u }, | |
| 2533 | { 4833775019274666364u, 11093568615497829248u, 240719513490u }, | |
| 2534 | { 15867662672939849256u, 12488220765137758124u, 146601383559u }, | |
| 2535 | { 2092350330982953557u, 3727114642519696453u, 135676987804u }, | |
| 2536 | { 13330062299842493592u, 11549865375695057514u, 156202047289u }, | |
| 2537 | { 4479193352178519263u, 11292809154908783229u, 57626119456u }, | |
| 2538 | { 3149393938889064983u, 17723904861837310998u, 32612184410u }, | |
| 2539 | { 9736379904070620767u, 14877674388187150875u, 90960814807u }, | |
| 2540 | { 3816238703055069186u, 12178961950105734308u, 215806520344u }, | |
| 2541 | { 11598915938798661975u, 4540604068069253114u, 24660222850u }, | |
| 2542 | { 17821633264606555643u, 13832478722153359868u, 130246146639u }, | |
| 2543 | { 2514623558764574316u, 1308046668730371491u, 79749860174u }, | |
| 2544 | { 4976730480406253215u, 18400531023544756800u, 78070909351u }, | |
| 2545 | { 17276563697191611637u, 9789823458621466539u, 167997494785u }, | |
| 2546 | { 12524734095940998814u, 1924870562610267306u, 1530707393u }, | |
| 2547 | { 15331551308930355164u, 5290016144582400923u, 193104347442u }, | |
| 2548 | { 15417115581125943816u, 15162883663174059077u, 50286772349u }, | |
| 2549 | { 6010750237807115593u, 8078086116520046390u, 125821981570u }, | |
| 2550 | { 5624630987553628432u, 15731407332173190623u, 130437913925u }, | |
| 2551 | { 14881848243837640704u, 5346389182763011056u, 69852801300u }, | |
| 2552 | { 15281613886881529856u, 6368422217216252401u, 20289828338u }, | |
| 2553 | { 14057902358273196032u, 2961453088119116188u, 242345232860u }, | |
| 2554 | { 16075318494433902592u, 10932141691610170525u, 220160540693u }, | |
| 2555 | { 13891916000577716224u, 11034016191361782553u, 21592632588u }, | |
| 2556 | { 7205759403792793600u, 5455325785621453219u, 12598155216u }, | |
| 2557 | { 0u, 7735615202566149352u, 208295733803u }, | |
| 2558 | { 0u, 7502396497775759360u, 43419348540u }, | |
| 2559 | { 0u, 1601286435751591936u, 60406705729u }, | |
| 2560 | { 0u, 11449383158571597824u, 65086805911u }, | |
| 2561 | { 0u, 13043944595690356736u, 151620672304u }, | |
| 2562 | { 0u, 7773494431818186752u, 48707113653u }, | |
| 2563 | { 0u, 9943947977234055168u, 181421401977u }, | |
| 2564 | { 0u, 0u, 121539062500u }, | |
| 2565 | { 0u, 0u, 228000000000u }, | |
| 2566 | { 4535831408134330609u, 3677u, 0u }, | |
| 2567 | { 6204770794376564579u, 3677245887913u, 0u }, | |
| 2568 | { 13869812122751887467u, 6343817245135589714u, 199u }, | |
| 2569 | { 14253229412394467550u, 17549323075660516085u, 199343899021u }, | |
| 2570 | { 12776557610216045332u, 3948641822109421754u, 141951350710u }, | |
| 2571 | { 16493640728678654060u, 1750739713693534543u, 182214056302u }, | |
| 2572 | { 9434398296825833151u, 962163898128633415u, 110094907790u }, | |
| 2573 | { 8773374058285327850u, 7967320249386531212u, 142052159009u }, | |
| 2574 | { 12932015276748029367u, 3018466665533383224u, 33431909296u }, | |
| 2575 | { 16293958583527755209u, 15076865731854945472u, 176163631405u }, | |
| 2576 | { 13511893936143127948u, 691187172844604400u, 45817318529u }, | |
| 2577 | { 18409936402005226436u, 13274492813370992341u, 129037469331u }, | |
| 2578 | { 2189663026458466887u, 6364168818499152300u, 147719611697u }, | |
| 2579 | { 9497725274248154664u, 17599380787401914158u, 49345002282u }, | |
| 2580 | { 14766925481127792125u, 3782323149461692814u, 42954064344u }, | |
| 2581 | { 6982373971809635814u, 14470163442442237466u, 216205040148u }, | |
| 2582 | { 8616702383006884794u, 476109872130437939u, 20784429132u }, | |
| 2583 | { 3059473300040871066u, 16330548844673355700u, 76025809967u }, | |
| 2584 | { 17123843157031495558u, 14089158961463739563u, 47885280826u }, | |
| 2585 | { 11210627174210626524u, 13385510793074798805u, 58763774837u }, | |
| 2586 | { 15868067138625928592u, 1549401308746959012u, 117725629994u }, | |
| 2587 | { 4467869511636937589u, 4607384943843027435u, 42083993213u }, | |
| 2588 | { 10052108125844341766u, 5157353797716093483u, 125249766838u }, | |
| 2589 | { 7470588003218451534u, 10846828782671550129u, 182279580709u }, | |
| 2590 | { 2613527085490786280u, 9915857350819131531u, 37588007766u }, | |
| 2591 | { 3632919450036549616u, 1673544973504317923u, 86537539704u }, | |
| 2592 | { 179367907231218916u, 14780986291622785694u, 120090723054u }, | |
| 2593 | { 13553068184555874624u, 8168111319515466401u, 238801278872u }, | |
| 2594 | { 8798774862365584481u, 16345760387859734482u, 152442794201u }, | |
| 2595 | { 910911255817064881u, 3177475373321281805u, 217886105446u }, | |
| 2596 | { 2304331144765093813u, 2558676822419554038u, 102172251285u }, | |
| 2597 | { 12248937023083640360u, 8813474062662382873u, 149138706148u }, | |
| 2598 | { 10206039550662130685u, 5426294560236228430u, 228477779386u }, | |
| 2599 | { 12267881323837852537u, 9919177474128333040u, 186294160017u }, | |
| 2600 | { 2858642007937891971u, 6197383943089627371u, 145537719688u }, | |
| 2601 | { 14171330289750320841u, 13673239314867423997u, 136335960856u }, | |
| 2602 | { 6601103619749017720u, 9309584098968723946u, 24741227788u }, | |
| 2603 | { 4919573414486739494u, 4647101757759615504u, 12504673565u }, | |
| 2604 | { 3401998285294974486u, 1405809295505096753u, 29251919891u }, | |
| 2605 | { 10799436256515532233u, 11332704079573859112u, 19076209074u }, | |
| 2606 | { 10083786644665753398u, 2960072434514044308u, 178614347119u }, | |
| 2607 | { 6481194517685688896u, 3887266602785432801u, 111160465848u }, | |
| 2608 | { 15104161756860547072u, 14545546084687849554u, 184210729144u }, | |
| 2609 | { 9556039274244079616u, 4617763804182385321u, 184788515633u }, | |
| 2610 | { 1376343134954323968u, 7857823815580249095u, 49250329477u }, | |
| 2611 | { 15682488278596976640u, 10939326736548364798u, 133425973482u }, | |
| 2612 | { 1506454075355430912u, 12262012446566951953u, 234593022090u }, | |
| 2613 | { 1152921504606846976u, 12555024338687723023u, 138664725026u }, | |
| 2614 | { 0u, 3332969632922829472u, 34680609233u }, | |
| 2615 | { 0u, 15535060143360327680u, 209180680645u }, | |
| 2616 | { 0u, 15794322927987458048u, 197842157297u }, | |
| 2617 | { 0u, 10571474314433921024u, 241856211961u }, | |
| 2618 | { 0u, 16679514427547975680u, 249573080770u }, | |
| 2619 | { 0u, 16925653299565166592u, 194904198288u }, | |
| 2620 | { 0u, 16717361816799281152u, 144917541503u }, | |
| 2621 | { 0u, 0u, 127906250000u }, | |
| 2622 | { 0u, 0u, 16000000000u }, | |
| 2623 | { 6172559441576707976u, 56110319u, 0u }, | |
| 2624 | { 15083329738554729992u, 56110319334615117u, 0u }, | |
| 2625 | { 10013126833549229036u, 9335385384027907407u, 3041746u }, | |
| 2626 | { 5817156823499936061u, 13237828406194798613u, 210506072255u }, | |
| 2627 | { 5282692560913632718u, 15667486867836528863u, 191717624115u }, | |
| 2628 | { 10252307034225766362u, 17982325043592934313u, 51849336164u }, | |
| 2629 | { 17981881283247669689u, 17159117626917379189u, 100974823793u }, | |
| 2630 | { 11689290159733383293u, 8336208968408929657u, 113930197630u }, | |
| 2631 | { 5530668968487988249u, 12767090573379150201u, 126451906793u }, | |
| 2632 | { 10083765740821947024u, 14736070002412246709u, 233692105366u }, | |
| 2633 | { 2798423656816843533u, 9697296975344560756u, 150798843955u }, | |
| 2634 | { 7614494481582904797u, 7291706381199103298u, 51525691522u }, | |
| 2635 | { 17811318500083423695u, 18098546597780825068u, 130395284194u }, | |
| 2636 | { 11641467412200329033u, 132913902678533478u, 226981124177u }, | |
| 2637 | { 17733593025296340645u, 1879347741692007580u, 81007205277u }, | |
| 2638 | { 3689424000190644835u, 4056624629214083684u, 157101879645u }, | |
| 2639 | { 14966634145516728506u, 14713227692042795499u, 93219910061u }, | |
| 2640 | { 14171681941562070109u, 7366415124022528526u, 173797605671u }, | |
| 2641 | { 8130575762882608170u, 825770353378039393u, 39399334164u }, | |
| 2642 | { 5234550794400656856u, 10244023944395357795u, 20044765100u }, | |
| 2643 | { 3020576149360486378u, 14302658294713551167u, 172555329650u }, | |
| 2644 | { 3038675756589057221u, 14246653166206862817u, 114775348659u }, | |
| 2645 | { 15470260187120878369u, 12404486258134291102u, 179772312615u }, | |
| 2646 | { 3497929414841828746u, 8887442218637942533u, 39672448547u }, | |
| 2647 | { 9935840636861015305u, 1186724038081863005u, 35481789208u }, | |
| 2648 | { 3647355485153741471u, 211331772484951576u, 24064332439u }, | |
| 2649 | { 766100215038272793u, 6311919513247413649u, 151011456318u }, | |
| 2650 | { 16128087474216800751u, 8131780018703965703u, 62342169842u }, | |
| 2651 | { 16216631732633731297u, 2262544347226725725u, 242440824678u }, | |
| 2652 | { 13760220872779997335u, 15318188749880522583u, 102122652774u }, | |
| 2653 | { 3826276262374222087u, 1073117094162650652u, 102830400676u }, | |
| 2654 | { 14938032745839181005u, 4447950380665871747u, 164058173794u }, | |
| 2655 | { 14479259995009508865u, 5373227185066463609u, 98241123873u }, | |
| 2656 | { 2372033248156102437u, 6739731406934274193u, 33291283229u }, | |
| 2657 | { 792005346826701645u, 12328812617001239444u, 29365361571u }, | |
| 2658 | { 16278924527931792559u, 3246111484407310759u, 163668346271u }, | |
| 2659 | { 17442516423538940144u, 3250825415176839770u, 159175972056u }, | |
| 2660 | { 13844184233048446u, 16146270540000862342u, 216176227598u }, | |
| 2661 | { 13486193870480782357u, 15686773375425916830u, 14875291079u }, | |
| 2662 | { 11931315179184648737u, 11920791905793880226u, 199850381688u }, | |
| 2663 | { 16492562205587485405u, 1853290561644080707u, 120646227424u }, | |
| 2664 | { 12128987217680380854u, 12157689141506159076u, 224100467082u }, | |
| 2665 | { 10568123814189138176u, 18100318838862562546u, 138659069648u }, | |
| 2666 | { 17007583519117541376u, 7171257882533475139u, 208981220250u }, | |
| 2667 | { 143791533903052800u, 14477550873015039462u, 154388754668u }, | |
| 2668 | { 12398714235792654336u, 8109481182495403274u, 236784829605u }, | |
| 2669 | { 9659957317919047680u, 14565395719337663965u, 165439615855u }, | |
| 2670 | { 9412523221204336640u, 1860318978161305991u, 111789591684u }, | |
| 2671 | { 4611686018427387904u, 16268646275151585618u, 132100848093u }, | |
| 2672 | { 0u, 13759019338835519104u, 221881925081u }, | |
| 2673 | { 0u, 17003783176010661888u, 217745877932u }, | |
| 2674 | { 0u, 18357489540307877888u, 172921776932u }, | |
| 2675 | { 0u, 905481790074912768u, 36995161502u }, | |
| 2676 | { 0u, 3638882110636294144u, 158049086266u }, | |
| 2677 | { 0u, 9011702854368362496u, 58197264194u }, | |
| 2678 | { 0u, 11529215046068469760u, 66488525390u }, | |
| 2679 | { 0u, 0u, 78625000000u }, | |
| 2680 | { 0u, 0u, 64000000000u }, | |
| 2681 | { 3237900842885170729u, 856u, 0u }, | |
| 2682 | { 7515893506498066595u, 856175526956u, 0u }, | |
| 2683 | { 7300206309181072546u, 7625299565768063067u, 46u }, | |
| 2684 | { 5999737279837044u, 13889021769065194705u, 46413368317u }, | |
| 2685 | { 7556839307242450651u, 14498170692313014398u, 253752925378u }, | |
| 2686 | { 12946035041643640643u, 1541631360972245751u, 194785947408u }, | |
| 2687 | { 15885877642352740665u, 9903958882920799117u, 16083572003u }, | |
| 2688 | { 10770818348246089568u, 15744148547788062576u, 35536894686u }, | |
| 2689 | { 11635415503599551744u, 17936061801321712000u, 222853492002u }, | |
| 2690 | { 6248053924100826098u, 9986394078324430610u, 34972315858u }, | |
| 2691 | { 16894170802729859998u, 13849561248103430369u, 210541363507u }, | |
| 2692 | { 6143589029651889899u, 12142378807953854930u, 51750786219u }, | |
| 2693 | { 11812087701837886160u, 2513847703931031444u, 171658239674u }, | |
| 2694 | { 7306705080150829180u, 1752183758129038045u, 186136275957u }, | |
| 2695 | { 1485332570280714274u, 15824833342220556540u, 245094986071u }, | |
| 2696 | { 18042602303295630634u, 8168747198299470695u, 87857865934u }, | |
| 2697 | { 13397029889257074369u, 17414799840149357478u, 206442828672u }, | |
| 2698 | { 9948104869613411488u, 83147520704167789u, 128944058191u }, | |
| 2699 | { 10836066241170646532u, 2383542703041471269u, 79004507436u }, | |
| 2700 | { 18330574781234459389u, 15540952725549257799u, 44129212108u }, | |
| 2701 | { 666297360208433062u, 6949835416232048690u, 204842476735u }, | |
| 2702 | { 5035352224889324309u, 15398868937585367540u, 191376751332u }, | |
| 2703 | { 1341745796439923765u, 14710915985268256079u, 228834774357u }, | |
| 2704 | { 6846932182653803785u, 9665704836873335737u, 85797480353u }, | |
| 2705 | { 6727685027257825533u, 2528789298740305993u, 161523978909u }, | |
| 2706 | { 2168538874806877737u, 10562914675687726264u, 157137085942u }, | |
| 2707 | { 17694936100676971444u, 17671658300096837111u, 246572616751u }, | |
| 2708 | { 2163944241059563294u, 356471401631698552u, 47957982516u }, | |
| 2709 | { 6727780864524301558u, 7450677157218003204u, 52019324353u }, | |
| 2710 | { 8599551977795002615u, 317174560787152643u, 193403902018u }, | |
| 2711 | { 15428264807806859091u, 7251937674440720374u, 66017194067u }, | |
| 2712 | { 2126771385339683557u, 1252631516699038247u, 83393128329u }, | |
| 2713 | { 15094316562082972944u, 10818009768860843867u, 137067905290u }, | |
| 2714 | { 8111300598225956802u, 12330114194950162396u, 10586445484u }, | |
| 2715 | { 9481215200564260304u, 15826681638261168822u, 172668416829u }, | |
| 2716 | { 16836674128623424708u, 14240150078499211625u, 61857966130u }, | |
| 2717 | { 7087243115299722740u, 10725372116242125421u, 50771960082u }, | |
| 2718 | { 2343560867338408810u, 8434925524647833627u, 18581423587u }, | |
| 2719 | { 3431385749090422286u, 17133902668520348241u, 227457258228u }, | |
| 2720 | { 3504545517469224582u, 15093996047981365810u, 244928830724u }, | |
| 2721 | { 3333759805712094227u, 6187974166976813153u, 4818247165u }, | |
| 2722 | { 3595183476205994775u, 13946144707720259865u, 253335450751u }, | |
| 2723 | { 14191566632569921303u, 9138079832881862582u, 127756022019u }, | |
| 2724 | { 12917427671358095562u, 6600697628576225568u, 3495376300u }, | |
| 2725 | { 3883793922738316288u, 8137099536646556597u, 172357824535u }, | |
| 2726 | { 7857281689266421760u, 14169855543453903706u, 23441113049u }, | |
| 2727 | { 15987081651486195712u, 3706403268650100765u, 217768149408u }, | |
| 2728 | { 16827562156399525888u, 14736932266877982264u, 160200924523u }, | |
| 2729 | { 7012737938513461248u, 18004795125138956004u, 107798890698u }, | |
| 2730 | { 7385903388887613440u, 9068489270661002501u, 202976041899u }, | |
| 2731 | { 0u, 7758835715193269217u, 171491603788u }, | |
| 2732 | { 0u, 16943947811135261184u, 76420607326u }, | |
| 2733 | { 0u, 6745843108403216384u, 94918533251u }, | |
| 2734 | { 0u, 12338229654069444608u, 131365692887u }, | |
| 2735 | { 0u, 14358176069683511296u, 215668856769u }, | |
| 2736 | { 0u, 7083775185760813056u, 193778358284u }, | |
| 2737 | { 0u, 5350276357316149248u, 12384012222u }, | |
| 2738 | { 0u, 9223372036854775808u, 190290039062u }, | |
| 2739 | { 0u, 0u, 22500000000u }, | |
| 2740 | { 14135788013842776187u, 13064201u, 0u }, | |
| 2741 | { 13284322918167594445u, 13064201766302603u, 0u }, | |
| 2742 | { 7264587765474046287u, 14699116688460625612u, 708211u }, | |
| 2743 | { 16176482219778368741u, 6684126021499623499u, 115796840712u }, | |
| 2744 | { 5401983818872095469u, 12614606079692508506u, 8362347197u }, | |
| 2745 | { 11208857446851049921u, 15358270276683001489u, 189683839165u }, | |
| 2746 | { 13794690008281035639u, 18077126190953408995u, 189832573499u }, | |
| 2747 | { 14519782740993303071u, 7864121581925945659u, 59979962974u }, | |
| 2748 | { 10885858587044789123u, 3518026639210514839u, 94426314885u }, | |
| 2749 | { 8710500938899914621u, 4698310163811252280u, 133190712606u }, | |
| 2750 | { 1284182587483102819u, 6101155398200416338u, 30254695904u }, | |
| 2751 | { 10346074482131502030u, 16049178580360033341u, 224330744296u }, | |
| 2752 | { 9429804686255246574u, 3167464649127375997u, 232870027714u }, | |
| 2753 | { 6412022633845121254u, 12778923935480989904u, 194171708602u }, | |
| 2754 | { 8892351297529018260u, 11875553912612980379u, 186692746854u }, | |
| 2755 | { 14098160105983060597u, 10628760849351697057u, 102643775067u }, | |
| 2756 | { 13793833029739474340u, 3408944711673234310u, 91576186280u }, | |
| 2757 | { 16367653765996977044u, 2102091496050506178u, 168184799263u }, | |
| 2758 | { 10684788343333772342u, 6254611118630245760u, 31113954608u }, | |
| 2759 | { 13272681218705145345u, 2647941151989776368u, 48339063148u }, | |
| 2760 | { 11093568615497829248u, 8855437735410157458u, 108143545177u }, | |
| 2761 | { 12488220765137758124u, 10184270603132180103u, 89480054241u }, | |
| 2762 | { 3727114642519696453u, 12079083162535627164u, 225552090415u }, | |
| 2763 | { 11549865375695057514u, 5952952868716156729u, 47654808410u }, | |
| 2764 | { 11292809154908783229u, 11958907037815852320u, 90322710221u }, | |
| 2765 | { 17723904861837310998u, 10101562137321697626u, 205648293649u }, | |
| 2766 | { 14877674388187150875u, 13633527411279258327u, 17547606780u }, | |
| 2767 | { 12178961950105734308u, 16555627393501768728u, 252739075001u }, | |
| 2768 | { 4540604068069253114u, 6359650463500280706u, 185897482359u }, | |
| 2769 | { 13832478722153359868u, 8093923611102181967u, 119344757342u }, | |
| 2770 | { 1308046668730371491u, 2848827352928635726u, 94438772478u }, | |
| 2771 | { 18400531023544756800u, 4686723431961561511u, 254154435240u }, | |
| 2772 | { 9789823458621466539u, 6245554925867652609u, 168254067786u }, | |
| 2773 | { 1924870562610267306u, 17527406820792516033u, 74338572210u }, | |
| 2774 | { 5290016144582400923u, 12119966834653692210u, 178950162627u }, | |
| 2775 | { 15162883663174059077u, 11606502845877928061u, 195657024718u }, | |
| 2776 | { 8078086116520046390u, 424311496652297090u, 206629189780u }, | |
| 2777 | { 15731407332173190623u, 5977664048034127173u, 148023001972u }, | |
| 2778 | { 5346389182763011056u, 6702712461535947028u, 116324049817u }, | |
| 2779 | { 6368422217216252401u, 11384349854055020018u, 153363354770u }, | |
| 2780 | { 2961453088119116188u, 3782955013294836188u, 146617146842u }, | |
| 2781 | { 10932141691610170525u, 3531805968821207061u, 218205074402u }, | |
| 2782 | { 11034016191361782553u, 3867566898657193228u, 226191459585u }, | |
| 2783 | { 5455325785621453219u, 12688734637425072080u, 1209661221u }, | |
| 2784 | { 7735615202566149352u, 18435982764454619691u, 37687857682u }, | |
| 2785 | { 7502396497775759360u, 4728836163964677692u, 18999416628u }, | |
| 2786 | { 1601286435751591936u, 2120012917348838977u, 52256350722u }, | |
| 2787 | { 11449383158571597824u, 9856965465824679831u, 2114926130u }, | |
| 2788 | { 13043944595690356736u, 11217197671061248816u, 50534347168u }, | |
| 2789 | { 7773494431818186752u, 3840562972677739189u, 160608085504u }, | |
| 2790 | { 9943947977234055168u, 17104366978925258617u, 208197335u }, | |
| 2791 | { 0u, 16177877219841993444u, 215927229591u }, | |
| 2792 | { 0u, 7338522384267208704u, 151877004481u }, | |
| 2793 | { 0u, 10935240458612244480u, 193397822095u }, | |
| 2794 | { 0u, 1732868046462124032u, 143592800573u }, | |
| 2795 | { 0u, 557965042578882560u, 61093938965u }, | |
| 2796 | { 0u, 10454684322475540480u, 21030247345u }, | |
| 2797 | { 0u, 13907115649320091648u, 177566749572u }, | |
| 2798 | { 0u, 0u, 132753906250u }, | |
| 2799 | { 0u, 0u, 74000000000u }, | |
| 2800 | { 6343817245135589714u, 199u, 0u }, | |
| 2801 | { 17549323075660516085u, 199343899021u, 0u }, | |
| 2802 | { 3948641822109421754u, 14876458284855834550u, 10u }, | |
| 2803 | { 1750739713693534543u, 10450704926982265198u, 10806454419u }, | |
| 2804 | { 962163898128633415u, 5385653213018257806u, 147566533849u }, | |
| 2805 | { 7967320249386531212u, 12735569669880147489u, 217291956845u }, | |
| 2806 | { 3018466665533383224u, 3619762560577729456u, 109690396615u }, | |
| 2807 | { 15076865731854945472u, 11123448126624084269u, 199196227721u }, | |
| 2808 | { 691187172844604400u, 4072715118852885633u, 137603003331u }, | |
| 2809 | { 13274492813370992341u, 18239087231420827283u, 195220782328u }, | |
| 2810 | { 6364168818499152300u, 423431461216085297u, 248988742900u }, | |
| 2811 | { 17599380787401914158u, 9360976716520160042u, 244022954265u }, | |
| 2812 | { 3782323149461692814u, 11655927117263208920u, 25507459564u }, | |
| 2813 | { 14470163442442237466u, 2646622721938364948u, 236631869075u }, | |
| 2814 | { 476109872130437939u, 4496462484548171852u, 147143473705u }, | |
| 2815 | { 16330548844673355700u, 13140258519803350063u, 41243753719u }, | |
| 2816 | { 14089158961463739563u, 13089764333320627770u, 247712334841u }, | |
| 2817 | { 13385510793074798805u, 6926286827289840501u, 249709597546u }, | |
| 2818 | { 1549401308746959012u, 4985580225290866218u, 106375474761u }, | |
| 2819 | { 4607384943843027435u, 10478790837359789693u, 73270268845u }, | |
| 2820 | { 5157353797716093483u, 10041191967455692214u, 173568056389u }, | |
| 2821 | { 10846828782671550129u, 5035461258013813797u, 69544334107u }, | |
| 2822 | { 9915857350819131531u, 14208759661559249750u, 27272972901u }, | |
| 2823 | { 1673544973504317923u, 12347272163241758840u, 101770258404u }, | |
| 2824 | { 14780986291622785694u, 3372534174410277614u, 228669346965u }, | |
| 2825 | { 8168111319515466401u, 17226704187274712984u, 149182825443u }, | |
| 2826 | { 16345760387859734482u, 4250480179449852121u, 227933861505u }, | |
| 2827 | { 3177475373321281805u, 4303723537755414374u, 129230418992u }, | |
| 2828 | { 2558676822419554038u, 8680503847344854165u, 48233305320u }, | |
| 2829 | { 8813474062662382873u, 8817608623911079652u, 232470571056u }, | |
| 2830 | { 5426294560236228430u, 5692030448698539450u, 48478003521u }, | |
| 2831 | { 9919177474128333040u, 16908836314686769809u, 65308565588u }, | |
| 2832 | { 6197383943089627371u, 6073762347067727240u, 84916629853u }, | |
| 2833 | { 13673239314867423997u, 10931066692585106200u, 93329259316u }, | |
| 2834 | { 9309584098968723946u, 14466591364061539596u, 52592574312u }, | |
| 2835 | { 4647101757759615504u, 4958077340960173341u, 104784235489u }, | |
| 2836 | { 1405809295505096753u, 4076890037156765715u, 225268777911u }, | |
| 2837 | { 11332704079573859112u, 14083973146609179058u, 183221008651u }, | |
| 2838 | { 2960072434514044308u, 2565183738039805295u, 11763493714u }, | |
| 2839 | { 3887266602785432801u, 1482420938751351224u, 82139058889u }, | |
| 2840 | { 14545546084687849554u, 2151089495335413944u, 201080362200u }, | |
| 2841 | { 4617763804182385321u, 3738604531753220913u, 216116610795u }, | |
| 2842 | { 7857823815580249095u, 14195686514836005765u, 235202670157u }, | |
| 2843 | { 10939326736548364798u, 17808833916231796970u, 77769549707u }, | |
| 2844 | { 12262012446566951953u, 1302384553035657354u, 139965418821u }, | |
| 2845 | { 12555024338687723023u, 1672033517974833698u, 69070602408u }, | |
| 2846 | { 3332969632922829472u, 11673925532927662545u, 168090641118u }, | |
| 2847 | { 15535060143360327680u, 3905334232240480709u, 222632844771u }, | |
| 2848 | { 15794322927987458048u, 17411087320267472625u, 227211708592u }, | |
| 2849 | { 10571474314433921024u, 16573305231063706617u, 176943856934u }, | |
| 2850 | { 16679514427547975680u, 15481103236037148354u, 38898440676u }, | |
| 2851 | { 16925653299565166592u, 907440704754420880u, 228839232288u }, | |
| 2852 | { 16717361816799281152u, 3224970785139077759u, 32049192459u }, | |
| 2853 | { 0u, 10560826509734608144u, 11174826016u }, | |
| 2854 | { 0u, 4700940027512659968u, 32572503552u }, | |
| 2855 | { 0u, 9733694683502084096u, 254838469u }, | |
| 2856 | { 0u, 1995535635724632064u, 197527664646u }, | |
| 2857 | { 0u, 10629833226245373952u, 6108178203u }, | |
| 2858 | { 0u, 15729384648544878592u, 27576244413u }, | |
| 2859 | { 0u, 7205759403792793600u, 189852691650u }, | |
| 2860 | { 0u, 0u, 194390625000u }, | |
| 2861 | { 0u, 0u, 232000000000u }, | |
| 2862 | { 9335385384027907407u, 3041746u, 0u }, | |
| 2863 | { 13237828406194798613u, 3041746506072255u, 0u }, | |
| 2864 | { 15667486867836528863u, 7535526066623007027u, 164893u }, | |
| 2865 | { 17982325043592934313u, 11302146918409311588u, 29408501686u }, | |
| 2866 | { 17159117626917379189u, 2480833299122194801u, 182612690612u }, | |
| 2867 | { 8336208968408929657u, 11513226205589330558u, 180134486242u }, | |
| 2868 | { 12767090573379150201u, 4073957068281936105u, 226624133243u }, | |
| 2869 | { 14736070002412246709u, 3729887061093812886u, 123220849655u }, | |
| 2870 | { 9697296975344560756u, 13616911779739451443u, 247202197582u }, | |
| 2871 | { 7291706381199103298u, 13039053282195777666u, 78738174266u }, | |
| 2872 | { 18098546597780825068u, 14490756113210417890u, 58706848494u }, | |
| 2873 | { 132913902678533478u, 17432486112977557585u, 238785545462u }, | |
| 2874 | { 1879347741692007580u, 14308820825344039837u, 246945016965u }, | |
| 2875 | { 4056624629214083684u, 4190949538817536349u, 133775682731u }, | |
| 2876 | { 14713227692042795499u, 13616552502810964397u, 171227191829u }, | |
| 2877 | { 7366415124022528526u, 4898145803694965031u, 21738154790u }, | |
| 2878 | { 825770353378039393u, 1399036321001644308u, 38265529016u }, | |
| 2879 | { 10244023944395357795u, 17170331128243738540u, 184075841910u }, | |
| 2880 | { 14302658294713551167u, 10641321388205367410u, 118930805515u }, | |
| 2881 | { 14246653166206862817u, 6648873641312572851u, 11576867188u }, | |
| 2882 | { 12404486258134291102u, 5988456964560374823u, 116360436162u }, | |
| 2883 | { 8887442218637942533u, 9972593758348346915u, 194324634902u }, | |
| 2884 | { 1186724038081863005u, 16709668921872818968u, 22540615390u }, | |
| 2885 | { 211331772484951576u, 6094829131503407767u, 222905832967u }, | |
| 2886 | { 6311919513247413649u, 4892016478899926334u, 7330401349u }, | |
| 2887 | { 8131780018703965703u, 13150857244079031538u, 69265196744u }, | |
| 2888 | { 2262544347226725725u, 12983943395318785894u, 200712909399u }, | |
| 2889 | { 15318188749880522583u, 15341644584614757478u, 87703860981u }, | |
| 2890 | { 1073117094162650652u, 7507635124856644772u, 245831672219u }, | |
| 2891 | { 4447950380665871747u, 11619655367084544354u, 155406989715u }, | |
| 2892 | { 5373227185066463609u, 11553116952478783009u, 147629902779u }, | |
| 2893 | { 6739731406934274193u, 17392150014233193245u, 187626295724u }, | |
| 2894 | { 12328812617001239444u, 8877887560294980515u, 172942830341u }, | |
| 2895 | { 3246111484407310759u, 18404180619915609503u, 5481271248u }, | |
| 2896 | { 3250825415176839770u, 10079413095288181976u, 208997692630u }, | |
| 2897 | { 16146270540000862342u, 14102802966539105550u, 214546406078u }, | |
| 2898 | { 15686773375425916830u, 13333966026135891399u, 190764514480u }, | |
| 2899 | { 11920791905793880226u, 12344968670173516152u, 176722835746u }, | |
| 2900 | { 1853290561644080707u, 10577007819804726752u, 34669222092u }, | |
| 2901 | { 12157689141506159076u, 15337041354031088010u, 204573380742u }, | |
| 2902 | { 18100318838862562546u, 14333607285614673616u, 134831422677u }, | |
| 2903 | { 7171257882533475139u, 17171597563219696538u, 213777026407u }, | |
| 2904 | { 14477550873015039462u, 2849642930482147564u, 103930874169u }, | |
| 2905 | { 8109481182495403274u, 14791248423979435173u, 57154479452u }, | |
| 2906 | { 14565395719337663965u, 13882371364576310127u, 92801835183u }, | |
| 2907 | { 1860318978161305991u, 11735995808941329540u, 175752564859u }, | |
| 2908 | { 16268646275151585618u, 11376996674339273181u, 123636209607u }, | |
| 2909 | { 13759019338835519104u, 9849638057168043481u, 199616748225u }, | |
| 2910 | { 17003783176010661888u, 18241520229279361964u, 193533949948u }, | |
| 2911 | { 18357489540307877888u, 1865852368526961444u, 252988874793u }, | |
| 2912 | { 905481790074912768u, 10601487369276448158u, 41101148059u }, | |
| 2913 | { 3638882110636294144u, 15999931310312762170u, 155574707781u }, | |
| 2914 | { 9011702854368362496u, 5773775867713013570u, 69867358014u }, | |
| 2915 | { 11529215046068469760u, 17726239863982547534u, 62312997016u }, | |
| 2916 | { 0u, 9711316695888316992u, 152960941388u }, | |
| 2917 | { 0u, 17872002620723724288u, 76526451532u }, | |
| 2918 | { 0u, 7429694208660733952u, 76968843203u }, | |
| 2919 | { 0u, 1782821038871019520u, 195402764530u }, | |
| 2920 | { 0u, 3225250234313474048u, 242096646922u }, | |
| 2921 | { 0u, 10009250171830927360u, 10174841165u }, | |
| 2922 | { 0u, 1152921504606846976u, 77542602539u }, | |
| 2923 | { 0u, 0u, 43062500000u }, | |
| 2924 | { 0u, 0u, 160000000000u }, | |
| 2925 | { 7625299565768063067u, 46u, 0u }, | |
| 2926 | { 13889021769065194705u, 46413368317u, 0u }, | |
| 2927 | { 14498170692313014398u, 9519880170333822146u, 2u }, | |
| 2928 | { 1541631360972245751u, 2285186318012886800u, 2516073738u }, | |
| 2929 | { 9903958882920799117u, 9706420951402272035u, 10123880198u }, | |
| 2930 | { 15744148547788062576u, 2369632031840402142u, 6526186134u }, | |
| 2931 | { 17936061801321712000u, 15599123897979399458u, 150128458009u }, | |
| 2932 | { 9986394078324430610u, 17579576584023912658u, 25845630200u }, | |
| 2933 | { 13849561248103430369u, 3480927339588501811u, 248952990756u }, | |
| 2934 | { 12142378807953854930u, 3547346616671294635u, 36188701449u }, | |
| 2935 | { 2513847703931031444u, 7705317123868384954u, 9192302045u }, | |
| 2936 | { 1752183758129038045u, 4969425237478353909u, 221417706078u }, | |
| 2937 | { 15824833342220556540u, 17043246700132217175u, 94269393081u }, | |
| 2938 | { 8168747198299470695u, 17053788362783499470u, 185923916254u }, | |
| 2939 | { 17414799840149357478u, 11102988228454224768u, 222924487719u }, | |
| 2940 | { 83147520704167789u, 16944305387801685839u, 39601894197u }, | |
| 2941 | { 2383542703041471269u, 11725142977459199276u, 53918552635u }, | |
| 2942 | { 15540952725549257799u, 8175984171998533324u, 59635621274u }, | |
| 2943 | { 6949835416232048690u, 1372352885142856895u, 154443220990u }, | |
| 2944 | { 15398868937585367540u, 17975093466502888164u, 254074395398u }, | |
| 2945 | { 14710915985268256079u, 6467823391459085653u, 6974431769u }, | |
| 2946 | { 9665704836873335737u, 11319386883146885025u, 25350621408u }, | |
| 2947 | { 2528789298740305993u, 9141999262922068637u, 224613625192u }, | |
| 2948 | { 10562914675687726264u, 1587330393383478774u, 104495588773u }, | |
| 2949 | { 17671658300096837111u, 884187548095712303u, 165086049353u }, | |
| 2950 | { 356471401631698552u, 488841225726377268u, 73047931903u }, | |
| 2951 | { 7450677157218003204u, 17462624199405856193u, 255026500135u }, | |
| 2952 | { 317174560787152643u, 13183677579115583554u, 39946650754u }, | |
| 2953 | { 7251937674440720374u, 11645015818917277779u, 130714688593u }, | |
| 2954 | { 1252631516699038247u, 8760523002035971977u, 81631277572u }, | |
| 2955 | { 10818009768860843867u, 10068817678491468042u, 4474908903u }, | |
| 2956 | { 12330114194950162396u, 1273658177787418284u, 231545831700u }, | |
| 2957 | { 15826681638261168822u, 3100019384328057661u, 20069045148u }, | |
| 2958 | { 14240150078499211625u, 10363063568089458738u, 156168052387u }, | |
| 2959 | { 10725372116242125421u, 13030756371481403666u, 163561782801u }, | |
| 2960 | { 8434925524647833627u, 6538878900684195299u, 17706398718u }, | |
| 2961 | { 17133902668520348241u, 8984884716779098868u, 254354473335u }, | |
| 2962 | { 15093996047981365810u, 8728727397070363908u, 119487071576u }, | |
| 2963 | { 6187974166976813153u, 6398650562917867005u, 88473185260u }, | |
| 2964 | { 13946144707720259865u, 1190873176164938879u, 236346871542u }, | |
| 2965 | { 9138079832881862582u, 4383628525805121795u, 246064557364u }, | |
| 2966 | { 6600697628576225568u, 10189374699734119852u, 52237636978u }, | |
| 2967 | { 8137099536646556597u, 5276291920541626391u, 114552367109u }, | |
| 2968 | { 14169855543453903706u, 2692252373800386521u, 5286028358u }, | |
| 2969 | { 3706403268650100765u, 11578684995169173920u, 70145947293u }, | |
| 2970 | { 14736932266877982264u, 5799408022254132587u, 157627681771u }, | |
| 2971 | { 18004795125138956004u, 15548569837712345290u, 235314386538u }, | |
| 2972 | { 9068489270661002501u, 15763030464322902955u, 106842889659u }, | |
| 2973 | { 7758835715193269217u, 13257749746581255500u, 187854515593u }, | |
| 2974 | { 16943947811135261184u, 16152470009188707678u, 137718704053u }, | |
| 2975 | { 6745843108403216384u, 13806790848493904003u, 181875627153u }, | |
| 2976 | { 12338229654069444608u, 11981226523265951191u, 145748467631u }, | |
| 2977 | { 14358176069683511296u, 5133628726077003713u, 175649503591u }, | |
| 2978 | { 7083775185760813056u, 16183955741910833164u, 103278294570u }, | |
| 2979 | { 5350276357316149248u, 13640425554331371454u, 42877333998u }, | |
| 2980 | { 9223372036854775808u, 18108120906868035862u, 238739448950u }, | |
| 2981 | { 0u, 6324011669895037184u, 118981643201u }, | |
| 2982 | { 0u, 10444437689515769856u, 193342825359u }, | |
| 2983 | { 0u, 12324712543665782784u, 143566194101u }, | |
| 2984 | { 0u, 13928941951563857920u, 181668124005u }, | |
| 2985 | { 0u, 3975288688270639104u, 101755089456u }, | |
| 2986 | { 0u, 11141905478114607104u, 48215500831u }, | |
| 2987 | { 0u, 4611686018427387904u, 31604003906u }, | |
| 2988 | { 0u, 0u, 66250000000u }, | |
| 2989 | { 0u, 0u, 128000000000u }, | |
| 2990 | { 14699116688460625612u, 708211u, 0u }, | |
| 2991 | { 6684126021499623499u, 708211796840712u, 0u }, | |
| 2992 | { 12614606079692508506u, 4398362855256705725u, 38392u }, | |
| 2993 | { 15358270276683001489u, 2812083125569302717u, 248238435728u }, | |
| 2994 | { 18077126190953408995u, 12868509142973100603u, 144152443331u }, | |
| 2995 | { 7864121581925945659u, 8726243776748165726u, 195697603278u }, | |
| 2996 | { 3518026639210514839u, 358304413426858117u, 206473050623u }, | |
| 2997 | { 4698310163811252280u, 3180720351566429470u, 255019423721u }, | |
| 2998 | { 6101155398200416338u, 14053818240400098784u, 233172427195u }, | |
| 2999 | { 16049178580360033341u, 7340140541492429288u, 187761859013u }, | |
| 3000 | { 3167464649127375997u, 1323571167904965058u, 197397909816u }, | |
| 3001 | { 12778923935480989904u, 14463851737583396026u, 56071750936u }, | |
| 3002 | { 11875553912612980379u, 15122784818916048486u, 24784086973u }, | |
| 3003 | { 10628760849351697057u, 13557974621377508955u, 189819807807u }, | |
| 3004 | { 3408944711673234310u, 17525172074563876264u, 63734979276u }, | |
| 3005 | { 2102091496050506178u, 15148880683074215967u, 204950041481u }, | |
| 3006 | { 6254611118630245760u, 6744828147558597936u, 137821222467u }, | |
| 3007 | { 2647941151989776368u, 9799290779647971692u, 67365637866u }, | |
| 3008 | { 8855437735410157458u, 11170890203898678105u, 234531220617u }, | |
| 3009 | { 10184270603132180103u, 7068779781287527905u, 137605575171u }, | |
| 3010 | { 12079083162535627164u, 14474741922505540911u, 3383199319u }, | |
| 3011 | { 5952952868716156729u, 17107062680405191514u, 87784677331u }, | |
| 3012 | { 11958907037815852320u, 2712598571300237005u, 211927375726u }, | |
| 3013 | { 10101562137321697626u, 3767556054903418641u, 110147050263u }, | |
| 3014 | { 13633527411279258327u, 18158239681706277628u, 23204239622u }, | |
| 3015 | { 16555627393501768728u, 10531652712128330681u, 6984360145u }, | |
| 3016 | { 6359650463500280706u, 9548395326934120567u, 209570922037u }, | |
| 3017 | { 8093923611102181967u, 15875647850297719390u, 53517619547u }, | |
| 3018 | { 2848827352928635726u, 8215825295203192574u, 91860620594u }, | |
| 3019 | { 4686723431961561511u, 12747310908260543144u, 50445380781u }, | |
| 3020 | { 6245554925867652609u, 77706528053613642u, 173691033109u }, | |
| 3021 | { 17527406820792516033u, 6024737704056756146u, 21004212479u }, | |
| 3022 | { 12119966834653692210u, 6819452388570089667u, 255326601685u }, | |
| 3023 | { 11606502845877928061u, 13695926775373186254u, 213369683254u }, | |
| 3024 | { 424311496652297090u, 3746531715392682132u, 54742457678u }, | |
| 3025 | { 5977664048034127173u, 4717376233154528116u, 78203099891u }, | |
| 3026 | { 6702712461535947028u, 385190957950313369u, 243255729478u }, | |
| 3027 | { 11384349854055020018u, 12388374310648616082u, 70020881243u }, | |
| 3028 | { 3782955013294836188u, 1078067332084407770u, 91671575117u }, | |
| 3029 | { 3531805968821207061u, 3257295319358714850u, 77058442147u }, | |
| 3030 | { 3867566898657193228u, 1545453099660723457u, 163176578333u }, | |
| 3031 | { 12688734637425072080u, 7495477664653506341u, 29083779180u }, | |
| 3032 | { 18435982764454619691u, 7225503732673614354u, 108406330658u }, | |
| 3033 | { 4728836163964677692u, 3935478326103643956u, 34391695342u }, | |
| 3034 | { 2120012917348838977u, 10082240682742686210u, 238213342707u }, | |
| 3035 | { 9856965465824679831u, 10838712705567897138u, 243546559362u }, | |
| 3036 | { 11217197671061248816u, 2142546572501643680u, 130587567793u }, | |
| 3037 | { 3840562972677739189u, 7893042119150331392u, 177116147682u }, | |
| 3038 | { 17104366978925258617u, 12084811642251302615u, 226427882670u }, | |
| 3039 | { 16177877219841993444u, 15317234482572954775u, 174655118951u }, | |
| 3040 | { 7338522384267208704u, 2283226355108359361u, 103830348945u }, | |
| 3041 | { 10935240458612244480u, 13359725152575722127u, 145123773948u }, | |
| 3042 | { 1732868046462124032u, 13126551011491594557u, 252724232151u }, | |
| 3043 | { 557965042578882560u, 3598021288691861269u, 215711591756u }, | |
| 3044 | { 10454684322475540480u, 16462621795896662961u, 76195049124u }, | |
| 3045 | { 13907115649320091648u, 14682112756964627332u, 164892440515u }, | |
| 3046 | { 0u, 7174112100896070218u, 195795918927u }, | |
| 3047 | { 0u, 5023109019590616064u, 79388909396u }, | |
| 3048 | { 0u, 10765223023086141440u, 84272303285u }, | |
| 3049 | { 0u, 8228137177297453056u, 181583583909u }, | |
| 3050 | { 0u, 2891199497780592640u, 165446048210u }, | |
| 3051 | { 0u, 15294857653247803392u, 210156732238u }, | |
| 3052 | { 0u, 14303432416528695296u, 78829135894u }, | |
| 3053 | { 0u, 0u, 22775390625u }, | |
| 3054 | { 0u, 0u, 161000000000u }, | |
| 3055 | { 14876458284855834550u, 10u, 0u }, | |
| 3056 | { 10450704926982265198u, 10806454419u, 0u }, | |
| 3057 | { 5385653213018257806u, 10806454419566533849u, 0u }, | |
| 3058 | { 12735569669880147489u, 17118225092618494573u, 585819067u }, | |
| 3059 | { 3619762560577729456u, 13385738875341807559u, 187927980841u }, | |
| 3060 | { 11123448126624084269u, 8272682717439277193u, 41725642358u }, | |
| 3061 | { 4072715118852885633u, 13402436483369350083u, 118448463028u }, | |
| 3062 | { 18239087231420827283u, 10946328903241612536u, 180726547537u }, | |
| 3063 | { 423431461216085297u, 16265808923426731252u, 81593401678u }, | |
| 3064 | { 9360976716520160042u, 11080374459871185177u, 78881771268u }, | |
| 3065 | { 11655927117263208920u, 1240761893433831916u, 4600668303u }, | |
| 3066 | { 2646622721938364948u, 367264070493390483u, 143067261837u }, | |
| 3067 | { 4496462484548171852u, 2863675693461092905u, 141019909425u }, | |
| 3068 | { 13140258519803350063u, 7511929581752138999u, 49155240170u }, | |
| 3069 | { 13089764333320627770u, 11154557789993845753u, 234407222518u }, | |
| 3070 | { 6926286827289840501u, 8325416539745948522u, 246604689789u }, | |
| 3071 | { 4985580225290866218u, 17745129874679852617u, 125451321734u }, | |
| 3072 | { 10478790837359789693u, 1074820986392253357u, 134961965418u }, | |
| 3073 | { 10041191967455692214u, 7820952682162838597u, 106058266162u }, | |
| 3074 | { 5035461258013813797u, 8215518006273528603u, 50423974694u }, | |
| 3075 | { 14208759661559249750u, 9680426791089900133u, 38445364123u }, | |
| 3076 | { 12347272163241758840u, 16128495723604797412u, 155524776987u }, | |
| 3077 | { 3372534174410277614u, 2264789053583348885u, 27874327505u }, | |
| 3078 | { 17226704187274712984u, 11175458488686298083u, 209122774460u }, | |
| 3079 | { 4250480179449852121u, 11026777810412287617u, 188605822818u }, | |
| 3080 | { 4303723537755414374u, 16199890034895598640u, 98597762822u }, | |
| 3081 | { 8680503847344854165u, 9094320719494763752u, 6878197798u }, | |
| 3082 | { 8817608623911079652u, 1250835564687222832u, 38493004114u }, | |
| 3083 | { 5692030448698539450u, 15362466642459337025u, 82067807931u }, | |
| 3084 | { 16908836314686769809u, 7831109835595423828u, 187832800985u }, | |
| 3085 | { 6073762347067727240u, 15426237284335022429u, 217424525314u }, | |
| 3086 | { 10931066692585106200u, 15636308361455434548u, 2836257998u }, | |
| 3087 | { 14466591364061539596u, 13967173875944980328u, 206847645974u }, | |
| 3088 | { 4958077340960173341u, 18245979923595824097u, 22757162012u }, | |
| 3089 | { 4076890037156765715u, 11335054479675278263u, 28989116553u }, | |
| 3090 | { 14083973146609179058u, 11165339882630461707u, 137614474534u }, | |
| 3091 | { 2565183738039805295u, 15944437408299395922u, 38605274287u }, | |
| 3092 | { 1482420938751351224u, 15806416348777321161u, 175864349683u }, | |
| 3093 | { 2151089495335413944u, 4201030477408556248u, 243856867547u }, | |
| 3094 | { 3738604531753220913u, 9485474942554588907u, 219227738318u }, | |
| 3095 | { 14195686514836005765u, 18238757647663230541u, 206514208626u }, | |
| 3096 | { 17808833916231796970u, 4642199687824746379u, 114988725033u }, | |
| 3097 | { 1302384553035657354u, 6134575894869364037u, 41251654149u }, | |
| 3098 | { 1672033517974833698u, 11524208547121316008u, 5332556025u }, | |
| 3099 | { 11673925532927662545u, 2734683241527878366u, 249624728597u }, | |
| 3100 | { 3905334232240480709u, 10629223456178675171u, 21148247475u }, | |
| 3101 | { 17411087320267472625u, 2788042336985254064u, 179576211358u }, | |
| 3102 | { 16573305231063706617u, 17285498758066142502u, 158151140077u }, | |
| 3103 | { 15481103236037148354u, 5525538192421886436u, 237937048765u }, | |
| 3104 | { 907440704754420880u, 11414325503043801888u, 189299540025u }, | |
| 3105 | { 3224970785139077759u, 7246608114685173259u, 57618771825u }, | |
| 3106 | { 10560826509734608144u, 1007884269852184608u, 113392839413u }, | |
| 3107 | { 4700940027512659968u, 13823717876510029312u, 245054637515u }, | |
| 3108 | { 9733694683502084096u, 12487410768239429317u, 203749385247u }, | |
| 3109 | { 1995535635724632064u, 3361062421598631942u, 31676943894u }, | |
| 3110 | { 10629833226245373952u, 17853337379088328475u, 22182203558u }, | |
| 3111 | { 15729384648544878592u, 11551561037491869885u, 166967831358u }, | |
| 3112 | { 7205759403792793600u, 11480877996635204802u, 62626211378u }, | |
| 3113 | { 0u, 5527488381934471912u, 50622379643u }, | |
| 3114 | { 0u, 11143438404407726080u, 123299645745u }, | |
| 3115 | { 0u, 6472279730688098304u, 49604087006u }, | |
| 3116 | { 0u, 4561816853579563008u, 222350862987u }, | |
| 3117 | { 0u, 2888714464062865408u, 139247296587u }, | |
| 3118 | { 0u, 16258276129784201216u, 75156597524u }, | |
| 3119 | { 0u, 720575940379279360u, 20881362915u }, | |
| 3120 | { 0u, 0u, 227039062500u }, | |
| 3121 | { 0u, 0u, 228000000000u }, | |
| 3122 | { 7535526066623007027u, 164893u, 0u }, | |
| 3123 | { 11302146918409311588u, 164893408501686u, 0u }, | |
| 3124 | { 2480833299122194801u, 16409970870640346804u, 8938u }, | |
| 3125 | { 11513226205589330558u, 7721907286269370594u, 234889586303u }, | |
| 3126 | { 4073957068281936105u, 14300743897882155131u, 127418605432u }, | |
| 3127 | { 3729887061093812886u, 2068482633821123575u, 120775244880u }, | |
| 3128 | { 13616911779739451443u, 4922882895416406094u, 80112132668u }, | |
| 3129 | { 13039053282195777666u, 9317632875623428410u, 60266870016u }, | |
| 3130 | { 14490756113210417890u, 5693844901999766254u, 505109890u }, | |
| 3131 | { 17432486112977557585u, 11569484900262102262u, 130308663950u }, | |
| 3132 | { 14308820825344039837u, 3138170119352085637u, 142627183033u }, | |
| 3133 | { 4190949538817536349u, 950584692575235243u, 185170120543u }, | |
| 3134 | { 13616552502810964397u, 8136430299747162645u, 95051531299u }, | |
| 3135 | { 4898145803694965031u, 6698711700804594470u, 35441076770u }, | |
| 3136 | { 1399036321001644308u, 17401191571004302008u, 34363137888u }, | |
| 3137 | { 17170331128243738540u, 4721732028538188150u, 96943320485u }, | |
| 3138 | { 10641321388205367410u, 2984214103553086219u, 165255965606u }, | |
| 3139 | { 6648873641312572851u, 13128675202005662068u, 166161774570u }, | |
| 3140 | { 5988456964560374823u, 14638512997670672834u, 234711706908u }, | |
| 3141 | { 9972593758348346915u, 12942085665769692438u, 28793555379u }, | |
| 3142 | { 16709668921872818968u, 14131134357119205086u, 179701591869u }, | |
| 3143 | { 6094829131503407767u, 8921946894736102919u, 61766050328u }, | |
| 3144 | { 4892016478899926334u, 5601522560505809989u, 24483659710u }, | |
| 3145 | { 13150857244079031538u, 8602606493507716808u, 190303659146u }, | |
| 3146 | { 12983943395318785894u, 8576789731078566487u, 138466348232u }, | |
| 3147 | { 15341644584614757478u, 17881118138842658549u, 200464948702u }, | |
| 3148 | { 7507635124856644772u, 11624372674432704923u, 222969337356u }, | |
| 3149 | { 11619655367084544354u, 6826284072848095635u, 12630158505u }, | |
| 3150 | { 11553116952478783009u, 1646466632033733563u, 169370053601u }, | |
| 3151 | { 17392150014233193245u, 17871081657060299180u, 225089255134u }, | |
| 3152 | { 8877887560294980515u, 15910893124677544709u, 222968793277u }, | |
| 3153 | { 18404180619915609503u, 11031217459450580944u, 189862531244u }, | |
| 3154 | { 10079413095288181976u, 13554987390037243094u, 172598003496u }, | |
| 3155 | { 14102802966539105550u, 15026714590903687870u, 40734817338u }, | |
| 3156 | { 13333966026135891399u, 4406379654994689200u, 58814599830u }, | |
| 3157 | { 12344968670173516152u, 13596329092861950242u, 150238870319u }, | |
| 3158 | { 10577007819804726752u, 284812388227373260u, 47737058477u }, | |
| 3159 | { 15337041354031088010u, 9285079159392309382u, 173015439710u }, | |
| 3160 | { 14333607285614673616u, 15046108141952711893u, 94503345149u }, | |
| 3161 | { 17171597563219696538u, 13795366909944958311u, 253815651156u }, | |
| 3162 | { 2849642930482147564u, 12909920641180059961u, 84747848338u }, | |
| 3163 | { 14791248423979435173u, 5333762939889788252u, 146699848200u }, | |
| 3164 | { 13882371364576310127u, 6411331390005944495u, 8289143868u }, | |
| 3165 | { 11735995808941329540u, 1447104583224217723u, 60347558971u }, | |
| 3166 | { 11376996674339273181u, 11940049226167932871u, 59078447696u }, | |
| 3167 | { 9849638057168043481u, 9772290783590472385u, 80647271365u }, | |
| 3168 | { 18241520229279361964u, 16351989577831528444u, 197529756944u }, | |
| 3169 | { 1865852368526961444u, 4376738725895725097u, 16886443131u }, | |
| 3170 | { 10601487369276448158u, 13851276297739812763u, 123237263481u }, | |
| 3171 | { 15999931310312762170u, 12641996203470333509u, 121750879192u }, | |
| 3172 | { 5773775867713013570u, 7707081716407945022u, 216685323987u }, | |
| 3173 | { 17726239863982547534u, 417638323657040024u, 211417801737u }, | |
| 3174 | { 9711316695888316992u, 16438047707692449100u, 9022640218u }, | |
| 3175 | { 17872002620723724288u, 14850108107043306316u, 90891108351u }, | |
| 3176 | { 7429694208660733952u, 10423290807904720835u, 255805025973u }, | |
| 3177 | { 1782821038871019520u, 16951162310302339314u, 181565047726u }, | |
| 3178 | { 3225250234313474048u, 2752437506572397322u, 174918924350u }, | |
| 3179 | { 10009250171830927360u, 3925815842962784589u, 62149209936u }, | |
| 3180 | { 1152921504606846976u, 5274166674003605291u, 80212818903u }, | |
| 3181 | { 0u, 5538963350863452832u, 215285913148u }, | |
| 3182 | { 0u, 16900671634439028736u, 60300267804u }, | |
| 3183 | { 0u, 2326997710751662080u, 28916187245u }, | |
| 3184 | { 0u, 12327726161625874432u, 109126146798u }, | |
| 3185 | { 0u, 5756455743825903616u, 238668287374u }, | |
| 3186 | { 0u, 3018537650245074944u, 142312058091u }, | |
| 3187 | { 0u, 16717361816799281152u, 235163635253u }, | |
| 3188 | { 0u, 0u, 53906250000u }, | |
| 3189 | { 0u, 0u, 16000000000u }, | |
| 3190 | { 2285186318012886800u, 2516073738u, 0u }, | |
| 3191 | { 9706420951402272035u, 2516073738123880198u, 0u }, | |
| 3192 | { 2369632031840402142u, 11997425759292732054u, 136396630u }, | |
| 3193 | { 15599123897979399458u, 11491152661270395161u, 86650381753u }, | |
| 3194 | { 17579576584023912658u, 18181063258234881272u, 185622936633u }, | |
| 3195 | { 3480927339588501811u, 2466921813123869732u, 57985597414u }, | |
| 3196 | { 3547346616671294635u, 8430880678232179465u, 230133732099u }, | |
| 3197 | { 7705317123868384954u, 6738034873677997533u, 3457038957u }, | |
| 3198 | { 4969425237478353909u, 7678250951042929246u, 109365269602u }, | |
| 3199 | { 17043246700132217175u, 1853560606315563193u, 98416238818u }, | |
| 3200 | { 17053788362783499470u, 14942676593409905118u, 226100481721u }, | |
| 3201 | { 11102988228454224768u, 4909892170837638183u, 185810044121u }, | |
| 3202 | { 16944305387801685839u, 16871149368312132405u, 217266165787u }, | |
| 3203 | { 11725142977459199276u, 16096130589333770811u, 27914586839u }, | |
| 3204 | { 8175984171998533324u, 12512479187631824282u, 215872572987u }, | |
| 3205 | { 1372352885142856895u, 16980304980540557310u, 59678302855u }, | |
| 3206 | { 17975093466502888164u, 8640919162749295366u, 135920504177u }, | |
| 3207 | { 6467823391459085653u, 7862382415464063513u, 113468425166u }, | |
| 3208 | { 11319386883146885025u, 14534157903009925344u, 206426220604u }, | |
| 3209 | { 9141999262922068637u, 12627464554215107944u, 60787898278u }, | |
| 3210 | { 1587330393383478774u, 2456849734836299173u, 166684536225u }, | |
| 3211 | { 884187548095712303u, 18428252197697827913u, 161133186090u }, | |
| 3212 | { 488841225726377268u, 7244734215936736255u, 42998997553u }, | |
| 3213 | { 17462624199405856193u, 14756175050504770087u, 49392737828u }, | |
| 3214 | { 13183677579115583554u, 6764116534566945922u, 36799933852u }, | |
| 3215 | { 11645015818917277779u, 1588822142405565521u, 156366683492u }, | |
| 3216 | { 8760523002035971977u, 17053265624843842052u, 100086130220u }, | |
| 3217 | { 10068817678491468042u, 16996891591759999207u, 44924459381u }, | |
| 3218 | { 1273658177787418284u, 8565556232370585876u, 117921403339u }, | |
| 3219 | { 3100019384328057661u, 14464960359145886620u, 203464339733u }, | |
| 3220 | { 10363063568089458738u, 5813189542048784035u, 21784147072u }, | |
| 3221 | { 13030756371481403666u, 9739241026882027025u, 128315133636u }, | |
| 3222 | { 6538878900684195299u, 18175068535675302910u, 196527965313u }, | |
| 3223 | { 8984884716779098868u, 10562697212061761911u, 129985272439u }, | |
| 3224 | { 8728727397070363908u, 4264834835660801368u, 119572604963u }, | |
| 3225 | { 6398650562917867005u, 13019066443690126316u, 35231197159u }, | |
| 3226 | { 1190873176164938879u, 1828040177823321846u, 231705765006u }, | |
| 3227 | { 4383628525805121795u, 11240369830376975668u, 142099098256u }, | |
| 3228 | { 10189374699734119852u, 8886938465302549874u, 144609341669u }, | |
| 3229 | { 5276291920541626391u, 9985240313589688325u, 229481761899u }, | |
| 3230 | { 2692252373800386521u, 722909126956573766u, 107541300962u }, | |
| 3231 | { 11578684995169173920u, 5493363474638452381u, 226039188982u }, | |
| 3232 | { 5799408022254132587u, 12410535279213120491u, 246297795830u }, | |
| 3233 | { 15548569837712345290u, 10543108918366869098u, 246672776465u }, | |
| 3234 | { 15763030464322902955u, 12953909016524823995u, 17571543079u }, | |
| 3235 | { 13257749746581255500u, 16505942145872588169u, 39702232814u }, | |
| 3236 | { 16152470009188707678u, 12428594380392015797u, 238894788916u }, | |
| 3237 | { 13806790848493904003u, 7528259605829768337u, 52673755451u }, | |
| 3238 | { 11981226523265951191u, 18147447600042811311u, 59408107770u }, | |
| 3239 | { 5133628726077003713u, 12021069431116183911u, 250983775105u }, | |
| 3240 | { 16183955741910833164u, 11819985069665662506u, 129651663479u }, | |
| 3241 | { 13640425554331371454u, 10401877114068152814u, 119640762674u }, | |
| 3242 | { 18108120906868035862u, 4611631138117837942u, 50563886888u }, | |
| 3243 | { 6324011669895037184u, 17200813398607252417u, 40249997024u }, | |
| 3244 | { 10444437689515769856u, 14100466137553658767u, 224932457962u }, | |
| 3245 | { 12324712543665782784u, 17887776768825509301u, 234764387800u }, | |
| 3246 | { 13928941951563857920u, 12632656857970087269u, 216969698321u }, | |
| 3247 | { 3975288688270639104u, 8923681664054686256u, 17684817700u }, | |
| 3248 | { 11141905478114607104u, 6213926103737837599u, 36483753752u }, | |
| 3249 | { 4611686018427387904u, 1233118281776157762u, 24336857609u }, | |
| 3250 | { 0u, 30716279628678784u, 9066847476u }, | |
| 3251 | { 0u, 15775734650898546688u, 244001665132u }, | |
| 3252 | { 0u, 976806005729918976u, 108855204289u }, | |
| 3253 | { 0u, 12460098853279891456u, 193052952759u }, | |
| 3254 | { 0u, 5635665595421687808u, 183675463312u }, | |
| 3255 | { 0u, 1805943450575568896u, 144305510044u }, | |
| 3256 | { 0u, 11529215046068469760u, 156097900390u }, | |
| 3257 | { 0u, 0u, 102625000000u }, | |
| 3258 | { 0u, 0u, 64000000000u }, | |
| 3259 | { 4398362855256705725u, 38392u, 0u }, | |
| 3260 | { 2812083125569302717u, 38392238435728u, 0u }, | |
| 3261 | { 12868509142973100603u, 4564018338575530435u, 2081u }, | |
| 3262 | { 8726243776748165726u, 16553437246451512014u, 33247415929u }, | |
| 3263 | { 358304413426858117u, 4339777136957372927u, 121897363631u }, | |
| 3264 | { 3180720351566429470u, 18439463366554654697u, 175235259789u }, | |
| 3265 | { 14053818240400098784u, 1370067356680643003u, 141999605312u }, | |
| 3266 | { 7340140541492429288u, 4210124040914115013u, 64074271500u }, | |
| 3267 | { 1323571167904965058u, 10692225626142609720u, 12228231281u }, | |
| 3268 | { 14463851737583396026u, 11592856673895384344u, 113579626712u }, | |
| 3269 | { 15122784818916048486u, 10284479231227406269u, 216628450019u }, | |
| 3270 | { 13557974621377508955u, 4961071383534266431u, 227557522736u }, | |
| 3271 | { 17525172074563876264u, 10960611551445686988u, 48268940218u }, | |
| 3272 | { 15148880683074215967u, 14616396723115619209u, 186594175942u }, | |
| 3273 | { 6744828147558597936u, 1025604265437492803u, 198792356454u }, | |
| 3274 | { 9799290779647971692u, 11711588454892179178u, 102055598118u }, | |
| 3275 | { 11170890203898678105u, 5580373263251565705u, 38634886482u }, | |
| 3276 | { 7068779781287527905u, 14109334653033148931u, 82302512640u }, | |
| 3277 | { 14474741922505540911u, 2899414033769399895u, 764868564u }, | |
| 3278 | { 17107062680405191514u, 13233457234892808147u, 212157177549u }, | |
| 3279 | { 2712598571300237005u, 3287946691509034862u, 205717387154u }, | |
| 3280 | { 3767556054903418641u, 5488480288717445911u, 146178239947u }, | |
| 3281 | { 18158239681706277628u, 11687233053874362630u, 203297531112u }, | |
| 3282 | { 10531652712128330681u, 6783772100089274577u, 232633566173u }, | |
| 3283 | { 9548395326934120567u, 7898291058728402485u, 221367749022u }, | |
| 3284 | { 15875647850297719390u, 4423684977486598491u, 158428167216u }, | |
| 3285 | { 8215825295203192574u, 2750833684599526706u, 48239808443u }, | |
| 3286 | { 12747310908260543144u, 15669689830489025709u, 187149122992u }, | |
| 3287 | { 77706528053613642u, 15117307274214954517u, 176849455587u }, | |
| 3288 | { 6024737704056756146u, 8148639818575698175u, 227819510869u }, | |
| 3289 | { 6819452388570089667u, 13006484426078994901u, 85441738649u }, | |
| 3290 | { 13695926775373186254u, 10287496057845513526u, 153705082933u }, | |
| 3291 | { 3746531715392682132u, 14159876032966532430u, 53557686278u }, | |
| 3292 | { 4717376233154528116u, 15742212196465548019u, 6767608417u }, | |
| 3293 | { 385190957950313369u, 2892220461917134150u, 97853387033u }, | |
| 3294 | { 12388374310648616082u, 7487151560715393883u, 25156787585u }, | |
| 3295 | { 1078067332084407770u, 7245756744165177933u, 129405879299u }, | |
| 3296 | { 3257295319358714850u, 3067122860671533987u, 3392793260u }, | |
| 3297 | { 1545453099660723457u, 8135043905834122525u, 172166269063u }, | |
| 3298 | { 7495477664653506341u, 14730019368921022572u, 135441001613u }, | |
| 3299 | { 7225503732673614354u, 495969939682055458u, 141798515950u }, | |
| 3300 | { 3935478326103643956u, 5617761407265775598u, 238026886584u }, | |
| 3301 | { 10082240682742686210u, 2087044847072781811u, 184304539456u }, | |
| 3302 | { 10838712705567897138u, 15929674232061203330u, 64113138927u }, | |
| 3303 | { 2142546572501643680u, 8658086469608285873u, 239863549370u }, | |
| 3304 | { 7893042119150331392u, 18369871790780313570u, 186469355807u }, | |
| 3305 | { 12084811642251302615u, 3545648451947416750u, 31995832745u }, | |
| 3306 | { 15317234482572954775u, 13347376792767929959u, 169192209987u }, | |
| 3307 | { 2283226355108359361u, 14482164459838203025u, 67723562745u }, | |
| 3308 | { 13359725152575722127u, 8899577765623565820u, 249785079708u }, | |
| 3309 | { 13126551011491594557u, 7095320096604405719u, 156482447077u }, | |
| 3310 | { 3598021288691861269u, 2968593824439315788u, 229384638073u }, | |
| 3311 | { 16462621795896662961u, 12621408323612585636u, 121160927793u }, | |
| 3312 | { 14682112756964627332u, 3954422936414648259u, 49684207916u }, | |
| 3313 | { 7174112100896070218u, 17143730087577690191u, 44214369696u }, | |
| 3314 | { 5023109019590616064u, 5033045529399041876u, 160929363470u }, | |
| 3315 | { 10765223023086141440u, 15857648521994521781u, 14272841944u }, | |
| 3316 | { 8228137177297453056u, 16655573486499109541u, 216859644848u }, | |
| 3317 | { 2891199497780592640u, 16652154439190075858u, 176902900447u }, | |
| 3318 | { 15294857653247803392u, 18016950600164130638u, 223902715100u }, | |
| 3319 | { 14303432416528695296u, 2086292996072613910u, 220976700849u }, | |
| 3320 | { 0u, 17324462585194799521u, 177113098169u }, | |
| 3321 | { 0u, 11079151463184927232u, 185939160998u }, | |
| 3322 | { 0u, 5239846817488961536u, 166600602004u }, | |
| 3323 | { 0u, 2778806963520143360u, 148284052665u }, | |
| 3324 | { 0u, 6240890740138835968u, 185150639427u }, | |
| 3325 | { 0u, 17250651344549707776u, 67338319364u }, | |
| 3326 | { 0u, 4197354852709302272u, 4935159683u }, | |
| 3327 | { 0u, 9223372036854775808u, 131227539062u }, | |
| 3328 | { 0u, 0u, 118500000000u }, | |
| 3329 | { 17118225092618494573u, 585819067u, 0u }, | |
| 3330 | { 13385738875341807559u, 585819067927980841u, 0u }, | |
| 3331 | { 8272682717439277193u, 5654803392547571318u, 31757315u }, | |
| 3332 | { 13402436483369350083u, 2931628102185393332u, 3306547506u }, | |
| 3333 | { 10946328903241612536u, 15964697617980212305u, 50158923877u }, | |
| 3334 | { 16265808923426731252u, 450380868305846606u, 101865447992u }, | |
| 3335 | { 11080374459871185177u, 14631133530814566148u, 56024415195u }, | |
| 3336 | { 1240761893433831916u, 31969822783742095u, 219793155338u }, | |
| 3337 | { 367264070493390483u, 10437269029385743245u, 10001733087u }, | |
| 3338 | { 2863675693461092905u, 15196146496377392433u, 223565805487u }, | |
| 3339 | { 7511929581752138999u, 4409099735137480938u, 175823784752u }, | |
| 3340 | { 11154557789993845753u, 10644987914903248118u, 48239017775u }, | |
| 3341 | { 8325416539745948522u, 3154431617534062973u, 47577065951u }, | |
| 3342 | { 17745129874679852617u, 11702056331247960454u, 223171002080u }, | |
| 3343 | { 1074820986392253357u, 15575315065965259114u, 224634369744u }, | |
| 3344 | { 7820952682162838597u, 10759747609480050226u, 208844339521u }, | |
| 3345 | { 8215518006273528603u, 12538236653960743718u, 65583287086u }, | |
| 3346 | { 9680426791089900133u, 17857942663978005403u, 46679699170u }, | |
| 3347 | { 16128495723604797412u, 11443004154750813211u, 226968081011u }, | |
| 3348 | { 2264789053583348885u, 4004313188770806737u, 115620326498u }, | |
| 3349 | { 11175458488686298083u, 17134872954824183228u, 98217074252u }, | |
| 3350 | { 11026777810412287617u, 2659553912986171234u, 76928883324u }, | |
| 3351 | { 16199890034895598640u, 9501854300969137926u, 124144174706u }, | |
| 3352 | { 9094320719494763752u, 14528169966301018150u, 114515096553u }, | |
| 3353 | { 1250835564687222832u, 18172091996515901778u, 233787573671u }, | |
| 3354 | { 15362466642459337025u, 1133541705604751035u, 167985111081u }, | |
| 3355 | { 7831109835595423828u, 18280349987988641497u, 41061449418u }, | |
| 3356 | { 15426237284335022429u, 9936015874712336386u, 202990979758u }, | |
| 3357 | { 15636308361455434548u, 15876720399740689614u, 174538632499u }, | |
| 3358 | { 13967173875944980328u, 8618117825152456982u, 51860678737u }, | |
| 3359 | { 18245979923595824097u, 8085525680745921564u, 81467189103u }, | |
| 3360 | { 11335054479675278263u, 8072355444669730953u, 111438317225u }, | |
| 3361 | { 11165339882630461707u, 9395030504766848294u, 169437603265u }, | |
| 3362 | { 15944437408299395922u, 3537903114058185903u, 193509305624u }, | |
| 3363 | { 15806416348777321161u, 2126094743961928691u, 24191790112u }, | |
| 3364 | { 4201030477408556248u, 289185362555601115u, 32115255827u }, | |
| 3365 | { 9485474942554588907u, 16909937501450129614u, 19015676769u }, | |
| 3366 | { 18238757647663230541u, 14449642060360499058u, 97916689548u }, | |
| 3367 | { 4642199687824746379u, 12433818908498244393u, 140783316665u }, | |
| 3368 | { 6134575894869364037u, 11884444034578008581u, 185674038673u }, | |
| 3369 | { 11524208547121316008u, 988625838444140793u, 145644257002u }, | |
| 3370 | { 2734683241527878366u, 1675370907158909973u, 234053593514u }, | |
| 3371 | { 10629223456178675171u, 15920186275316934067u, 170090822038u }, | |
| 3372 | { 2788042336985254064u, 5600921198503757726u, 150863035027u }, | |
| 3373 | { 17285498758066142502u, 10457357161776341741u, 147303626546u }, | |
| 3374 | { 5525538192421886436u, 12225356765775740093u, 50566894467u }, | |
| 3375 | { 11414325503043801888u, 4486633318598164537u, 131662737918u }, | |
| 3376 | { 7246608114685173259u, 10302486602879381361u, 254243220879u }, | |
| 3377 | { 1007884269852184608u, 15536428611301239541u, 143558498917u }, | |
| 3378 | { 13823717876510029312u, 12026126645955462603u, 101842231482u }, | |
| 3379 | { 12487410768239429317u, 14877968141142123551u, 186651937631u }, | |
| 3380 | { 3361062421598631942u, 734560801645383190u, 95806536269u }, | |
| 3381 | { 17853337379088328475u, 15648943144911081638u, 77039820620u }, | |
| 3382 | { 11551561037491869885u, 13664182862003235646u, 76848330907u }, | |
| 3383 | { 11480877996635204802u, 3895127525902132786u, 155740736837u }, | |
| 3384 | { 5527488381934471912u, 5249187334214137467u, 69211155286u }, | |
| 3385 | { 11143438404407726080u, 10642260063359027505u, 86284559015u }, | |
| 3386 | { 6472279730688098304u, 783598951897779422u, 167576918074u }, | |
| 3387 | { 4561816853579563008u, 5538576558607624843u, 58042478984u }, | |
| 3388 | { 2888714464062865408u, 15974581187564609611u, 136300246836u }, | |
| 3389 | { 16258276129784201216u, 7474269406918257428u, 52865983781u }, | |
| 3390 | { 720575940379279360u, 8045286838779138019u, 37405180956u }, | |
| 3391 | { 0u, 8184246376556341732u, 28436135873u }, | |
| 3392 | { 0u, 1493267152679331840u, 193443668885u }, | |
| 3393 | { 0u, 10179074811222818816u, 149080950174u }, | |
| 3394 | { 0u, 3892499202005008384u, 158551808751u }, | |
| 3395 | { 0u, 10341173215925108736u, 239211012804u }, | |
| 3396 | { 0u, 6230307872002015232u, 196560596123u }, | |
| 3397 | { 0u, 9295429630892703744u, 155337745666u }, | |
| 3398 | { 0u, 0u, 2503906250u }, | |
| 3399 | { 0u, 0u, 202000000000u }, | |
| 3400 | { 16409970870640346804u, 8938u, 0u }, | |
| 3401 | { 7721907286269370594u, 8938889586303u, 0u }, | |
| 3402 | { 14300743897882155131u, 10665454627995623288u, 484u }, | |
| 3403 | { 2068482633821123575u, 16803537892767562832u, 228578175453u }, | |
| 3404 | { 4922882895416406094u, 8099123106849104444u, 221910921614u }, | |
| 3405 | { 9317632875623428410u, 7077413686679401728u, 142439054343u }, | |
| 3406 | { 5693844901999766254u, 13536636358372449666u, 7383667364u }, | |
| 3407 | { 11569484900262102262u, 7280632235418610318u, 164733822527u }, | |
| 3408 | { 3138170119352085637u, 6187823673116858809u, 63394683864u }, | |
| 3409 | { 950584692575235243u, 8624343686231740255u, 216335442593u }, | |
| 3410 | { 8136430299747162645u, 806211610822132771u, 161467526608u }, | |
| 3411 | { 6698711700804594470u, 18388078233202190882u, 208043704818u }, | |
| 3412 | { 17401191571004302008u, 7628864426595573600u, 242996819718u }, | |
| 3413 | { 4721732028538188150u, 4530799784343874981u, 6413561569u }, | |
| 3414 | { 2984214103553086219u, 8561580552078486438u, 225245615148u }, | |
| 3415 | { 13128675202005662068u, 13349114951221999594u, 44464124211u }, | |
| 3416 | { 14638512997670672834u, 10029144738508991772u, 51723656971u }, | |
| 3417 | { 12942085665769692438u, 12601907197916268979u, 11543681025u }, | |
| 3418 | { 14131134357119205086u, 1329580921391066941u, 1683150758u }, | |
| 3419 | { 8921946894736102919u, 3198179786356761112u, 166072076726u }, | |
| 3420 | { 5601522560505809989u, 11406753413634654142u, 182173373673u }, | |
| 3421 | { 8602606493507716808u, 11131812960525182090u, 233618361341u }, | |
| 3422 | { 8576789731078566487u, 14299636753645227208u, 253603456789u }, | |
| 3423 | { 17881118138842658549u, 12964114684643663326u, 21775184861u }, | |
| 3424 | { 11624372674432704923u, 5019257593846306316u, 221702786065u }, | |
| 3425 | { 6826284072848095635u, 6929086798159998121u, 17272094499u }, | |
| 3426 | { 1646466632033733563u, 18359765766933703649u, 35375626547u }, | |
| 3427 | { 17871081657060299180u, 9993076234752063198u, 51995284896u }, | |
| 3428 | { 15910893124677544709u, 3257189215046584509u, 160541725748u }, | |
| 3429 | { 11031217459450580944u, 2905234736672690348u, 52176572581u }, | |
| 3430 | { 13554987390037243094u, 12064985302079670056u, 165157493090u }, | |
| 3431 | { 15026714590903687870u, 14315096064942799930u, 98654044163u }, | |
| 3432 | { 4406379654994689200u, 11943971043551974038u, 3776022912u }, | |
| 3433 | { 13596329092861950242u, 12472773152119929647u, 128647483967u }, | |
| 3434 | { 284812388227373260u, 7791259796982183085u, 63676150387u }, | |
| 3435 | { 9285079159392309382u, 16866829442051086686u, 115422365039u }, | |
| 3436 | { 15046108141952711893u, 3702498393844653053u, 111914352656u }, | |
| 3437 | { 13795366909944958311u, 2057239613841701716u, 16200712840u }, | |
| 3438 | { 12909920641180059961u, 17201969976738286226u, 136111523182u }, | |
| 3439 | { 5333762939889788252u, 18271566505443461640u, 110932520660u }, | |
| 3440 | { 6411331390005944495u, 18368509115417119804u, 212990503604u }, | |
| 3441 | { 1447104583224217723u, 7613923684154518587u, 180995758874u }, | |
| 3442 | { 11940049226167932871u, 17984805084714865232u, 26412751629u }, | |
| 3443 | { 9772290783590472385u, 4220802739051410373u, 13974958237u }, | |
| 3444 | { 16351989577831528444u, 17812459042810815760u, 157228810174u }, | |
| 3445 | { 4376738725895725097u, 10629526089664605307u, 190965615339u }, | |
| 3446 | { 13851276297739812763u, 17437443267816548473u, 235576227763u }, | |
| 3447 | { 12641996203470333509u, 12506371893701049304u, 179945285693u }, | |
| 3448 | { 7707081716407945022u, 15737221540003030739u, 61677971778u }, | |
| 3449 | { 417638323657040024u, 2358380859011605513u, 66853116489u }, | |
| 3450 | { 16438047707692449100u, 10042972713837039706u, 73127848082u }, | |
| 3451 | { 14850108107043306316u, 13424397272769642495u, 146544430641u }, | |
| 3452 | { 10423290807904720835u, 6867102315755663029u, 49727738034u }, | |
| 3453 | { 16951162310302339314u, 8690748404825506734u, 178372266362u }, | |
| 3454 | { 2752437506572397322u, 956229930815387710u, 122471126415u }, | |
| 3455 | { 3925815842962784589u, 7734449506297687888u, 143051837328u }, | |
| 3456 | { 5274166674003605291u, 16332184961683848151u, 144419285347u }, | |
| 3457 | { 5538963350863452832u, 15580777817612768828u, 99885369520u }, | |
| 3458 | { 16900671634439028736u, 17404245271944696092u, 176844635657u }, | |
| 3459 | { 2326997710751662080u, 13201420160494469229u, 9943486026u }, | |
| 3460 | { 12327726161625874432u, 16511717657124068078u, 74715650420u }, | |
| 3461 | { 5756455743825903616u, 14131292492116594062u, 116895102007u }, | |
| 3462 | { 3018537650245074944u, 18429136031865875691u, 55766058900u }, | |
| 3463 | { 16717361816799281152u, 2563978348305862197u, 148999045466u }, | |
| 3464 | { 0u, 14239974392147482896u, 90138993544u }, | |
| 3465 | { 0u, 11164201396098998272u, 136771950558u }, | |
| 3466 | { 0u, 7116971104932986880u, 222605212570u }, | |
| 3467 | { 0u, 12437629862867369984u, 154385811776u }, | |
| 3468 | { 0u, 16501893821638901760u, 64674245265u }, | |
| 3469 | { 0u, 10649324268870959104u, 145894569456u }, | |
| 3470 | { 0u, 7205759403792793600u, 240577301025u }, | |
| 3471 | { 0u, 0u, 33390625000u }, | |
| 3472 | { 0u, 0u, 232000000000u }, | |
| 3473 | { 11997425759292732054u, 136396630u, 0u }, | |
| 3474 | { 11491152661270395161u, 136396630650381753u, 0u }, | |
| 3475 | { 18181063258234881272u, 3016823727048309817u, 7394076u }, | |
| 3476 | { 2466921813123869732u, 17405973192644624358u, 28163542341u }, | |
| 3477 | { 8430880678232179465u, 8937219978302591747u, 69943579697u }, | |
| 3478 | { 6738034873677997533u, 15178463196824222317u, 49484487665u }, | |
| 3479 | { 7678250951042929246u, 11979404627460330594u, 241822826138u }, | |
| 3480 | { 1853560606315563193u, 2006448052689740002u, 154649404826u }, | |
| 3481 | { 14942676593409905118u, 16330465320863239865u, 154108769766u }, | |
| 3482 | { 4909892170837638183u, 17136208883957646553u, 230885276298u }, | |
| 3483 | { 16871149368312132405u, 140455118208931867u, 138928955745u }, | |
| 3484 | { 16096130589333770811u, 3964972929179372247u, 97007614087u }, | |
| 3485 | { 12512479187631824282u, 3378050330022776379u, 135214941613u }, | |
| 3486 | { 16980304980540557310u, 6065353437512901255u, 173183124475u }, | |
| 3487 | { 8640919162749295366u, 12768753059854699889u, 251328803468u }, | |
| 3488 | { 7862382415464063513u, 6848720690951013326u, 140692195490u }, | |
| 3489 | { 14534157903009925344u, 10953228058585475132u, 162371269892u }, | |
| 3490 | { 12627464554215107944u, 15539127852083296166u, 4593775682u }, | |
| 3491 | { 2456849734836299173u, 14534853647735598497u, 66842377808u }, | |
| 3492 | { 18428252197697827913u, 1506909603576368170u, 80787935995u }, | |
| 3493 | { 7244734215936736255u, 5475702579938239025u, 251081689733u }, | |
| 3494 | { 14756175050504770087u, 12039747373985783332u, 133296838431u }, | |
| 3495 | { 6764116534566945922u, 17572399137760898460u, 31652676012u }, | |
| 3496 | { 1588822142405565521u, 869552790852091236u, 172952601666u }, | |
| 3497 | { 17053265624843842052u, 4549585778048181804u, 66047138551u }, | |
| 3498 | { 16996891591759999207u, 4121918231767210357u, 247246633539u }, | |
| 3499 | { 8565556232370585876u, 1558397953312543179u, 67223449635u }, | |
| 3500 | { 14464960359145886620u, 6067524298738069781u, 35084480922u }, | |
| 3501 | { 5813189542048784035u, 5811095224555517056u, 154328921151u }, | |
| 3502 | { 9739241026882027025u, 6440894514158997188u, 63315020103u }, | |
| 3503 | { 18175068535675302910u, 4612748874388784257u, 71349161591u }, | |
| 3504 | { 10562697212061761911u, 9908101430749813367u, 119250057617u }, | |
| 3505 | { 4264834835660801368u, 15150017990912190499u, 145537119254u }, | |
| 3506 | { 13019066443690126316u, 17470426264690059239u, 22821284120u }, | |
| 3507 | { 1828040177823321846u, 9615161096851907726u, 24947073705u }, | |
| 3508 | { 11240369830376975668u, 9227932132124142224u, 169521238927u }, | |
| 3509 | { 8886938465302549874u, 4794113194321211621u, 143500247203u }, | |
| 3510 | { 9985240313589688325u, 391512698859146347u, 163259889397u }, | |
| 3511 | { 722909126956573766u, 17209658878068655842u, 245021223945u }, | |
| 3512 | { 5493363474638452381u, 3077364726606876150u, 9932937477u }, | |
| 3513 | { 12410535279213120491u, 1952989567673965814u, 5166824276u }, | |
| 3514 | { 10543108918366869098u, 11172860676923186449u, 84105871776u }, | |
| 3515 | { 12953909016524823995u, 17338078544784947239u, 160605681990u }, | |
| 3516 | { 16505942145872588169u, 4593380466519703278u, 70939899121u }, | |
| 3517 | { 12428594380392015797u, 786884753602720052u, 241249007654u }, | |
| 3518 | { 7528259605829768337u, 17848875822468020539u, 38042657107u }, | |
| 3519 | { 18147447600042811311u, 2899664567187130618u, 83967589497u }, | |
| 3520 | { 12021069431116183911u, 2973178834961857409u, 121157191131u }, | |
| 3521 | { 11819985069665662506u, 11117453141176836727u, 219161176347u }, | |
| 3522 | { 10401877114068152814u, 7535238370146462002u, 27602678342u }, | |
| 3523 | { 4611631138117837942u, 10246175467290865448u, 70408486090u }, | |
| 3524 | { 17200813398607252417u, 1203128834127050464u, 202555446285u }, | |
| 3525 | { 14100466137553658767u, 14518048959078919658u, 13065221744u }, | |
| 3526 | { 17887776768825509301u, 1553474987376920024u, 112787025011u }, | |
| 3527 | { 12632656857970087269u, 14956572380830948369u, 115084214047u }, | |
| 3528 | { 8923681664054686256u, 7594162606042048292u, 31810797413u }, | |
| 3529 | { 6213926103737837599u, 14461296147288811288u, 101411680379u }, | |
| 3530 | { 1233118281776157762u, 18305427728131488265u, 123783948434u }, | |
| 3531 | { 30716279628678784u, 10253208939347909876u, 146992339225u }, | |
| 3532 | { 15775734650898546688u, 6446028915490812012u, 25555827570u }, | |
| 3533 | { 976806005729918976u, 12986063676957432257u, 114349439927u }, | |
| 3534 | { 12460098853279891456u, 9769714697972762807u, 183703975922u }, | |
| 3535 | { 5635665595421687808u, 97429465146664592u, 242529617295u }, | |
| 3536 | { 1805943450575568896u, 16395571728207795868u, 143005281661u }, | |
| 3537 | { 11529215046068469760u, 6331668478323650406u, 125888805724u }, | |
| 3538 | { 0u, 18129911846294207040u, 92343240435u }, | |
| 3539 | { 0u, 9890094564876124160u, 243982824490u }, | |
| 3540 | { 0u, 12290856656987750400u, 42536143100u }, | |
| 3541 | { 0u, 8498454992640802816u, 252666288674u }, | |
| 3542 | { 0u, 5341660584200896512u, 34460702168u }, | |
| 3543 | { 0u, 9288674231451648000u, 216289572000u }, | |
| 3544 | { 0u, 1152921504606846976u, 160503540039u }, | |
| 3545 | { 0u, 0u, 71062500000u }, | |
| 3546 | { 0u, 0u, 160000000000u }, | |
| 3547 | { 4564018338575530435u, 2081u, 0u }, | |
| 3548 | { 16553437246451512014u, 2081247415929u, 0u }, | |
| 3549 | { 4339777136957372927u, 15212079674427582639u, 112u }, | |
| 3550 | { 18439463366554654697u, 10179808126814248333u, 112824648491u }, | |
| 3551 | { 1370067356680643003u, 6066766544199222848u, 43551848504u }, | |
| 3552 | { 4210124040914115013u, 6625308131806923532u, 56328880073u }, | |
| 3553 | { 10692225626142609720u, 9122786786400665713u, 201359158673u }, | |
| 3554 | { 11592856673895384344u, 11932880778639151320u, 145494547262u }, | |
| 3555 | { 10284479231227406269u, 3884040911779255011u, 62646882763u }, | |
| 3556 | { 4961071383534266431u, 13441817515637357872u, 203210554279u }, | |
| 3557 | { 10960611551445686988u, 11628577856022352826u, 167728682387u }, | |
| 3558 | { 14616396723115619209u, 13296656925520243654u, 147630386468u }, | |
| 3559 | { 1025604265437492803u, 5020720704545399398u, 36720813216u }, | |
| 3560 | { 11711588454892179178u, 14121973606499014694u, 160272173814u }, | |
| 3561 | { 5580373263251565705u, 3642481034345420114u, 246765553723u }, | |
| 3562 | { 14109334653033148931u, 9845536238569696768u, 59197459292u }, | |
| 3563 | { 2899414033769399895u, 17655403572195686356u, 92533727588u }, | |
| 3564 | { 13233457234892808147u, 8377495365136654029u, 100957101345u }, | |
| 3565 | { 3287946691509034862u, 13713682649609025426u, 33454144933u }, | |
| 3566 | { 5488480288717445911u, 1367709905452854731u, 165743420226u }, | |
| 3567 | { 11687233053874362630u, 9981467701727208680u, 66074143702u }, | |
| 3568 | { 6783772100089274577u, 6277920117543306205u, 214541096448u }, | |
| 3569 | { 7898291058728402485u, 9344111460418701726u, 340326731u }, | |
| 3570 | { 4423684977486598491u, 4918507011364617264u, 75506545297u }, | |
| 3571 | { 2750833684599526706u, 6554777203830755259u, 145266632799u }, | |
| 3572 | { 15669689830489025709u, 4198262173120265648u, 95355335184u }, | |
| 3573 | { 15117307274214954517u, 8080325935698446819u, 16227588248u }, | |
| 3574 | { 8148639818575698175u, 12797633874200091733u, 152438035346u }, | |
| 3575 | { 13006484426078994901u, 8376502502208665497u, 146693761122u }, | |
| 3576 | { 10287496057845513526u, 9891973386793349173u, 98454091110u }, | |
| 3577 | { 14159876032966532430u, 14877430279003795462u, 102536244951u }, | |
| 3578 | { 15742212196465548019u, 8759933935842067041u, 215806507111u }, | |
| 3579 | { 2892220461917134150u, 3753418510388703513u, 103474876970u }, | |
| 3580 | { 7487151560715393883u, 2961383332545305985u, 42203473225u }, | |
| 3581 | { 7245756744165177933u, 2497674184068629507u, 73160536912u }, | |
| 3582 | { 3067122860671533987u, 15244544070742305452u, 80135399188u }, | |
| 3583 | { 8135043905834122525u, 45953573565810823u, 20826408390u }, | |
| 3584 | { 14730019368921022572u, 3960077421351906445u, 198002491148u }, | |
| 3585 | { 495969939682055458u, 3173330011013883118u, 12214676227u }, | |
| 3586 | { 5617761407265775598u, 11026266219545759160u, 3172026564u }, | |
| 3587 | { 2087044847072781811u, 8886757764964685632u, 196597735089u }, | |
| 3588 | { 15929674232061203330u, 13952322129918090479u, 177481752103u }, | |
| 3589 | { 8658086469608285873u, 4127250666614902202u, 39756356898u }, | |
| 3590 | { 18369871790780313570u, 17649958504065306911u, 34223738706u }, | |
| 3591 | { 3545648451947416750u, 13269305359002216873u, 82956806167u }, | |
| 3592 | { 13347376792767929959u, 16236593433831947843u, 23719330484u }, | |
| 3593 | { 14482164459838203025u, 13580930396682424057u, 180880187493u }, | |
| 3594 | { 8899577765623565820u, 421976357197961116u, 101736223712u }, | |
| 3595 | { 7095320096604405719u, 2962130818798626533u, 224022875384u }, | |
| 3596 | { 2968593824439315788u, 8234383947306356345u, 248160577433u }, | |
| 3597 | { 12621408323612585636u, 4380469931801381425u, 153446386848u }, | |
| 3598 | { 3954422936414648259u, 15279887469027055916u, 160237465750u }, | |
| 3599 | { 17143730087577690191u, 8534542821713755552u, 150828324359u }, | |
| 3600 | { 5033045529399041876u, 7814613482565088782u, 7462658493u }, | |
| 3601 | { 15857648521994521781u, 13771954404705323224u, 189423631045u }, | |
| 3602 | { 16655573486499109541u, 4568173274762548144u, 197746579144u }, | |
| 3603 | { 16652154439190075858u, 8105292616250821343u, 200247641169u }, | |
| 3604 | { 18016950600164130638u, 2923678426777275612u, 81439388793u }, | |
| 3605 | { 2086292996072613910u, 1808633176918384049u, 121158492925u }, | |
| 3606 | { 17324462585194799521u, 18118642609460438969u, 253098046200u }, | |
| 3607 | { 11079151463184927232u, 18138164175864360870u, 248982213583u }, | |
| 3608 | { 5239846817488961536u, 4031433690465792404u, 207983271850u }, | |
| 3609 | { 2778806963520143360u, 5012226396942308537u, 170218544458u }, | |
| 3610 | { 6240890740138835968u, 7889712298793536835u, 74271713337u }, | |
| 3611 | { 17250651344549707776u, 13500762396543628804u, 57427702160u }, | |
| 3612 | { 4197354852709302272u, 501020624068841347u, 144731877796u }, | |
| 3613 | { 9223372036854775808u, 8370653768288261750u, 164027160382u }, | |
| 3614 | { 0u, 647579990023635200u, 62453774050u }, | |
| 3615 | { 0u, 11106569307181154304u, 226035105381u }, | |
| 3616 | { 0u, 10797461613892861952u, 101602088328u }, | |
| 3617 | { 0u, 17627230675448889344u, 136585331566u }, | |
| 3618 | { 0u, 12197735707942322176u, 110955574089u }, | |
| 3619 | { 0u, 12871287735024877568u, 73661240577u }, | |
| 3620 | { 0u, 4611686018427387904u, 1697753906u }, | |
| 3621 | { 0u, 0u, 50250000000u }, | |
| 3622 | { 0u, 0u, 128000000000u }, | |
| 3623 | { 5654803392547571318u, 31757315u, 0u }, | |
| 3624 | { 2931628102185393332u, 31757315306547506u, 0u }, | |
| 3625 | { 15964697617980212305u, 9451803574512021605u, 1721567u }, | |
| 3626 | { 450380868305846606u, 8662766454758138424u, 223512383298u }, | |
| 3627 | { 14631133530814566148u, 9207992007314947035u, 66469609510u }, | |
| 3628 | { 31969822783742095u, 17118602861291201802u, 38499166246u }, | |
| 3629 | { 10437269029385743245u, 11186560605745599967u, 38928001320u }, | |
| 3630 | { 15196146496377392433u, 10505549821532796847u, 40606424665u }, | |
| 3631 | { 4409099735137480938u, 18133667530488679216u, 89569506996u }, | |
| 3632 | { 10644987914903248118u, 10778135771244330799u, 180983028086u }, | |
| 3633 | { 3154431617534062973u, 17087985777033767391u, 118584283910u }, | |
| 3634 | { 11702056331247960454u, 2639185991757283040u, 6926341565u }, | |
| 3635 | { 15575315065965259114u, 5401720287293896400u, 189143070559u }, | |
| 3636 | { 10759747609480050226u, 9816495392633895233u, 95292827843u }, | |
| 3637 | { 12538236653960743718u, 10042051500090034990u, 195532153281u }, | |
| 3638 | { 17857942663978005403u, 11629689537856384738u, 193544380702u }, | |
| 3639 | { 11443004154750813211u, 2099086731766010483u, 30630446733u }, | |
| 3640 | { 4004313188770806737u, 13665537898516458594u, 141113791719u }, | |
| 3641 | { 17134872954824183228u, 16375672064669490764u, 231740810293u }, | |
| 3642 | { 2659553912986171234u, 7770550512184564348u, 53887726961u }, | |
| 3643 | { 9501854300969137926u, 6197048880720627314u, 113421242387u }, | |
| 3644 | { 14528169966301018150u, 17963594118523106281u, 19335942692u }, | |
| 3645 | { 18172091996515901778u, 8255454642407818663u, 36973808388u }, | |
| 3646 | { 1133541705604751035u, 16744201957549498409u, 4447529092u }, | |
| 3647 | { 18280349987988641497u, 17442505417202859722u, 132907705006u }, | |
| 3648 | { 9936015874712336386u, 6383975767786687150u, 174945560113u }, | |
| 3649 | { 15876720399740689614u, 15245442964998335795u, 49346076019u }, | |
| 3650 | { 8618117825152456982u, 2910016124519524433u, 115826457119u }, | |
| 3651 | { 8085525680745921564u, 3847913871169988463u, 31157752290u }, | |
| 3652 | { 8072355444669730953u, 17210451512590059177u, 226208595828u }, | |
| 3653 | { 9395030504766848294u, 17899408909991454145u, 116932980445u }, | |
| 3654 | { 3537903114058185903u, 5920601932753251608u, 221970328901u }, | |
| 3655 | { 2126094743961928691u, 16521781895108979744u, 69320956473u }, | |
| 3656 | { 289185362555601115u, 3697493405554698771u, 57895647591u }, | |
| 3657 | { 16909937501450129614u, 2816108280295732065u, 103200441519u }, | |
| 3658 | { 14449642060360499058u, 14251078772056398988u, 175152661535u }, | |
| 3659 | { 12433818908498244393u, 4543066550096031417u, 31772552528u }, | |
| 3660 | { 11884444034578008581u, 3099369389734296977u, 80246280131u }, | |
| 3661 | { 988625838444140793u, 5243484113636490986u, 195168017151u }, | |
| 3662 | { 1675370907158909973u, 6823370511605197226u, 255284249843u }, | |
| 3663 | { 15920186275316934067u, 11396290277624641942u, 243369895656u }, | |
| 3664 | { 5600921198503757726u, 15934361408437566099u, 232617794133u }, | |
| 3665 | { 10457357161776341741u, 14939272230935131954u, 85863803462u }, | |
| 3666 | { 12225356765775740093u, 7500666177940329347u, 70809859570u }, | |
| 3667 | { 4486633318598164537u, 4806714453065462270u, 242406611928u }, | |
| 3668 | { 10302486602879381361u, 11557851247268441487u, 216260572512u }, | |
| 3669 | { 15536428611301239541u, 10655523157206817381u, 96626552371u }, | |
| 3670 | { 12026126645955462603u, 14769600176490881210u, 51577637067u }, | |
| 3671 | { 14877968141142123551u, 16688495540925795167u, 203800661629u }, | |
| 3672 | { 734560801645383190u, 909793965395524173u, 125904685156u }, | |
| 3673 | { 15648943144911081638u, 12724590949761703756u, 100049320029u }, | |
| 3674 | { 13664182862003235646u, 10810739657314826395u, 93689801457u }, | |
| 3675 | { 3895127525902132786u, 2431218615388671301u, 241586051371u }, | |
| 3676 | { 5249187334214137467u, 4235001167959059286u, 43131796625u }, | |
| 3677 | { 10642260063359027505u, 6253317787396334247u, 145229579873u }, | |
| 3678 | { 783598951897779422u, 9534525563070371898u, 97338993036u }, | |
| 3679 | { 5538576558607624843u, 8392783992374030728u, 140516867666u }, | |
| 3680 | { 15974581187564609611u, 16356257019231647540u, 82454973731u }, | |
| 3681 | { 7474269406918257428u, 12896334001521091877u, 35886674469u }, | |
| 3682 | { 8045286838779138019u, 1427636373320877084u, 37699111667u }, | |
| 3683 | { 8184246376556341732u, 16116755731295043521u, 243077392322u }, | |
| 3684 | { 1493267152679331840u, 15945633911163986837u, 194873691078u }, | |
| 3685 | { 10179074811222818816u, 7510154241072743838u, 198864414546u }, | |
| 3686 | { 3892499202005008384u, 3571560509790395119u, 82407126277u }, | |
| 3687 | { 10341173215925108736u, 3576991649007035076u, 5193614683u }, | |
| 3688 | { 6230307872002015232u, 15509961892750732443u, 91193909105u }, | |
| 3689 | { 9295429630892703744u, 17789791359353349378u, 113840796718u }, | |
| 3690 | { 0u, 18331227331079738314u, 46964386521u }, | |
| 3691 | { 0u, 15386712883100476416u, 217993737824u }, | |
| 3692 | { 0u, 14082462055028752384u, 96834115376u }, | |
| 3693 | { 0u, 12919043128765186048u, 48763411797u }, | |
| 3694 | { 0u, 6125373368465096704u, 85700342731u }, | |
| 3695 | { 0u, 12335992698065387520u, 203332057155u }, | |
| 3696 | { 0u, 2774217370460225536u, 67668735504u }, | |
| 3697 | { 0u, 0u, 16150390625u }, | |
| 3698 | { 0u, 0u, 97000000000u }, | |
| 3699 | { 10665454627995623288u, 484u, 0u }, | |
| 3700 | { 16803537892767562832u, 484578175453u, 0u }, | |
| 3701 | { 8099123106849104444u, 4962829537462579598u, 26u }, | |
| 3702 | { 7077413686679401728u, 5711259460785241095u, 26269035528u }, | |
| 3703 | { 13536636358372449666u, 13845894607204897444u, 8309607995u }, | |
| 3704 | { 7280632235418610318u, 12116633056637003327u, 59750587450u }, | |
| 3705 | { 6187823673116858809u, 2965791047992089560u, 58656843994u }, | |
| 3706 | { 8624343686231740255u, 16021997451315962529u, 218160775854u }, | |
| 3707 | { 806211610822132771u, 3942052271663803856u, 174868554222u }, | |
| 3708 | { 18388078233202190882u, 15669876414782439922u, 238213699081u }, | |
| 3709 | { 7628864426595573600u, 10594415915406145286u, 9849465702u }, | |
| 3710 | { 4530799784343874981u, 10789820553031921377u, 102574324437u }, | |
| 3711 | { 8561580552078486438u, 3989990218583987244u, 213584917344u }, | |
| 3712 | { 13349114951221999594u, 2937341169808224563u, 96216297803u }, | |
| 3713 | { 10029144738508991772u, 16267436558584536843u, 75159233583u }, | |
| 3714 | { 12601907197916268979u, 16221580362814625793u, 47881859502u }, | |
| 3715 | { 1329580921391066941u, 9695437602320209830u, 174879373633u }, | |
| 3716 | { 3198179786356761112u, 10729753156793715126u, 65525590725u }, | |
| 3717 | { 11406753413634654142u, 2609241432056861929u, 197581661084u }, | |
| 3718 | { 11131812960525182090u, 8462663743997037565u, 156141447261u }, | |
| 3719 | { 14299636753645227208u, 14993422143908194069u, 93458761920u }, | |
| 3720 | { 12964114684643663326u, 1307443894537745373u, 192812795043u }, | |
| 3721 | { 5019257593846306316u, 10017257439419829265u, 163070876675u }, | |
| 3722 | { 6929086798159998121u, 16754772009970777891u, 3543036613u }, | |
| 3723 | { 18359765766933703649u, 11722573031602862387u, 197908278010u }, | |
| 3724 | { 9993076234752063198u, 7363764277467092384u, 250635481957u }, | |
| 3725 | { 3257189215046584509u, 6733958494847390772u, 101399190461u }, | |
| 3726 | { 2905234736672690348u, 8799796600227451045u, 189365048621u }, | |
| 3727 | { 12064985302079670056u, 10512023194742249826u, 45477037929u }, | |
| 3728 | { 14315096064942799930u, 4572542132337197059u, 105569857919u }, | |
| 3729 | { 11943971043551974038u, 12600500455757416832u, 127247878005u }, | |
| 3730 | { 12472773152119929647u, 7873789864743195199u, 117683074498u }, | |
| 3731 | { 7791259796982183085u, 15724851676325671539u, 194426839003u }, | |
| 3732 | { 16866829442051086686u, 8748017220462413167u, 219852445917u }, | |
| 3733 | { 3702498393844653053u, 14172589522760466448u, 221474230963u }, | |
| 3734 | { 2057239613841701716u, 9520545591489413768u, 179768297617u }, | |
| 3735 | { 17201969976738286226u, 12488551088392570222u, 145516109810u }, | |
| 3736 | { 18271566505443461640u, 1135798823651241684u, 242677005711u }, | |
| 3737 | { 18368509115417119804u, 11168725610120161972u, 143061571777u }, | |
| 3738 | { 7613923684154518587u, 9580104948718508826u, 193605457828u }, | |
| 3739 | { 17984805084714865232u, 16638722716909738765u, 164519338529u }, | |
| 3740 | { 4220802739051410373u, 15732724012348272797u, 33901986965u }, | |
| 3741 | { 17812459042810815760u, 12269722190021214142u, 149852872677u }, | |
| 3742 | { 10629526089664605307u, 13110655916311972587u, 229665142972u }, | |
| 3743 | { 17437443267816548473u, 6618112997062866867u, 188710730081u }, | |
| 3744 | { 12506371893701049304u, 8457936459015989309u, 97358768624u }, | |
| 3745 | { 15737221540003030739u, 3329167139937134914u, 240458505654u }, | |
| 3746 | { 2358380859011605513u, 5245511557216705097u, 182180474512u }, | |
| 3747 | { 10042972713837039706u, 5655931353280440466u, 144284359751u }, | |
| 3748 | { 13424397272769642495u, 604622132328697393u, 71306608653u }, | |
| 3749 | { 6867102315755663029u, 8673282619234652338u, 13032776631u }, | |
| 3750 | { 8690748404825506734u, 16929477433058445690u, 183470179592u }, | |
| 3751 | { 956229930815387710u, 11036952409253549455u, 8917748810u }, | |
| 3752 | { 7734449506297687888u, 18199392190170386320u, 74598314388u }, | |
| 3753 | { 16332184961683848151u, 9683116091880335715u, 148986591027u }, | |
| 3754 | { 15580777817612768828u, 2993913337608915120u, 51524922775u }, | |
| 3755 | { 17404245271944696092u, 4490779842162392585u, 151162300367u }, | |
| 3756 | { 13201420160494469229u, 946849923353644618u, 207243445663u }, | |
| 3757 | { 16511717657124068078u, 3613491058474899828u, 159051328837u }, | |
| 3758 | { 14131292492116594062u, 14624054199004410935u, 69195887742u }, | |
| 3759 | { 18429136031865875691u, 12088470271991908244u, 126792771566u }, | |
| 3760 | { 2563978348305862197u, 10071980927725011290u, 238655317286u }, | |
| 3761 | { 14239974392147482896u, 2833441711428854664u, 38546003180u }, | |
| 3762 | { 11164201396098998272u, 17655572411864340446u, 236153601182u }, | |
| 3763 | { 7116971104932986880u, 4997642792058747802u, 158957110498u }, | |
| 3764 | { 12437629862867369984u, 11489200787635734848u, 226270922758u }, | |
| 3765 | { 16501893821638901760u, 12983586226429536913u, 6622830822u }, | |
| 3766 | { 10649324268870959104u, 12311150768725063152u, 230703841619u }, | |
| 3767 | { 7205759403792793600u, 8530052476845967905u, 83667388820u }, | |
| 3768 | { 0u, 6282736361499820264u, 148462415071u }, | |
| 3769 | { 0u, 11337164765929082880u, 223340587820u }, | |
| 3770 | { 0u, 8343856200414134272u, 44614588933u }, | |
| 3771 | { 0u, 17889330377156198400u, 5452321350u }, | |
| 3772 | { 0u, 17730714064155312128u, 70969782542u }, | |
| 3773 | { 0u, 7449235258647511040u, 14961183935u }, | |
| 3774 | { 0u, 9943947977234055168u, 191403823852u }, | |
| 3775 | { 0u, 0u, 236539062500u }, | |
| 3776 | { 0u, 0u, 228000000000u }, | |
| 3777 | { 3016823727048309817u, 7394076u, 0u }, | |
| 3778 | { 17405973192644624358u, 7394076163542341u, 0u }, | |
| 3779 | { 8937219978302591747u, 12396245121240683569u, 400833u }, | |
| 3780 | { 15178463196824222317u, 10248996648596888561u, 193672001794u }, | |
| 3781 | { 11979404627460330594u, 11257495103713935002u, 2555599221u }, | |
| 3782 | { 2006448052689740002u, 7555396579247433114u, 117610270032u }, | |
| 3783 | { 16330465320863239865u, 4805022328730367462u, 80409578869u }, | |
| 3784 | { 17136208883957646553u, 7056637817080232586u, 117260480782u }, | |
| 3785 | { 140455118208931867u, 10811411483818434913u, 14382541102u }, | |
| 3786 | { 3964972929179372247u, 16962406704495245447u, 46586087790u }, | |
| 3787 | { 3378050330022776379u, 18074517319117194669u, 110919533909u }, | |
| 3788 | { 6065353437512901255u, 3702019776117654523u, 85979821547u }, | |
| 3789 | { 12768753059854699889u, 3551977551381082764u, 235200686894u }, | |
| 3790 | { 6848720690951013326u, 16442608985936005282u, 46192553088u }, | |
| 3791 | { 10953228058585475132u, 3580046275479139588u, 128891355619u }, | |
| 3792 | { 15539127852083296166u, 8737412692712715330u, 227194074697u }, | |
| 3793 | { 14534853647735598497u, 3082033243045084752u, 73473656091u }, | |
| 3794 | { 1506909603576368170u, 16401023756841128699u, 27167077356u }, | |
| 3795 | { 5475702579938239025u, 7520296082779572869u, 236889101279u }, | |
| 3796 | { 12039747373985783332u, 9854104766152464159u, 223407676067u }, | |
| 3797 | { 17572399137760898460u, 14169188802648310188u, 163534192089u }, | |
| 3798 | { 869552790852091236u, 2018609909210367042u, 217768113264u }, | |
| 3799 | { 4549585778048181804u, 8270271948267674359u, 112109429062u }, | |
| 3800 | { 4121918231767210357u, 12320338602894572099u, 70448332340u }, | |
| 3801 | { 1558397953312543179u, 17538536685990080547u, 52667886893u }, | |
| 3802 | { 6067524298738069781u, 15833914616956760474u, 45950765978u }, | |
| 3803 | { 5811095224555517056u, 6137696141415969855u, 154858358231u }, | |
| 3804 | { 6440894514158997188u, 9757490468419438919u, 215332725174u }, | |
| 3805 | { 4612748874388784257u, 3566639201356598903u, 182528954618u }, | |
| 3806 | { 9908101430749813367u, 9760900035773954449u, 250193347898u }, | |
| 3807 | { 15150017990912190499u, 3873778773990716438u, 58529139451u }, | |
| 3808 | { 17470426264690059239u, 2295668377270167832u, 251209997968u }, | |
| 3809 | { 9615161096851907726u, 1791721710912807593u, 144124448432u }, | |
| 3810 | { 9227932132124142224u, 10571009006922683279u, 176097129428u }, | |
| 3811 | { 4794113194321211621u, 9840791932778184867u, 212573055546u }, | |
| 3812 | { 391512698859146347u, 11525464956561274613u, 58533470399u }, | |
| 3813 | { 17209658878068655842u, 4435781488897895433u, 191624796707u }, | |
| 3814 | { 3077364726606876150u, 6395563367070996741u, 35240464196u }, | |
| 3815 | { 1952989567673965814u, 15538690795135662932u, 68346704184u }, | |
| 3816 | { 11172860676923186449u, 16294558813563371936u, 56842354115u }, | |
| 3817 | { 17338078544784947239u, 4942096228426070342u, 195883329803u }, | |
| 3818 | { 4593380466519703278u, 6910116424372647153u, 11267911573u }, | |
| 3819 | { 786884753602720052u, 17923400669760829478u, 149374598161u }, | |
| 3820 | { 17848875822468020539u, 4134686917293039955u, 17971629497u }, | |
| 3821 | { 2899664567187130618u, 16857102463116098681u, 185224141826u }, | |
| 3822 | { 2973178834961857409u, 11364321508775167451u, 2913825355u }, | |
| 3823 | { 11117453141176836727u, 7966947780972783899u, 75616061103u }, | |
| 3824 | { 7535238370146462002u, 11261055695926686278u, 175431889104u }, | |
| 3825 | { 10246175467290865448u, 9227040437353594058u, 208610463052u }, | |
| 3826 | { 1203128834127050464u, 7185344074282882061u, 76500198864u }, | |
| 3827 | { 14518048959078919658u, 14197856148610578032u, 208389518282u }, | |
| 3828 | { 1553474987376920024u, 885688687260429427u, 202769667324u }, | |
| 3829 | { 14956572380830948369u, 17407816160380305183u, 252048013279u }, | |
| 3830 | { 7594162606042048292u, 17812728703806357349u, 223943679604u }, | |
| 3831 | { 14461296147288811288u, 17120198191964319867u, 116965629957u }, | |
| 3832 | { 18305427728131488265u, 12091952048375408786u, 5928087803u }, | |
| 3833 | { 10253208939347909876u, 405056939269888281u, 251655506034u }, | |
| 3834 | { 6446028915490812012u, 12485440679452408690u, 114021958180u }, | |
| 3835 | { 12986063676957432257u, 8394369900823444407u, 36676837095u }, | |
| 3836 | { 9769714697972762807u, 2877421667354294258u, 231455059704u }, | |
| 3837 | { 97429465146664592u, 2676980714750756239u, 248155985341u }, | |
| 3838 | { 16395571728207795868u, 6119309228579057021u, 189145119415u }, | |
| 3839 | { 6331668478323650406u, 18203256146533333852u, 183331728417u }, | |
| 3840 | { 18129911846294207040u, 351919978865493747u, 33986800493u }, | |
| 3841 | { 9890094564876124160u, 5190010931882390570u, 109019077620u }, | |
| 3842 | { 12290856656987750400u, 6982466386088036604u, 244281351056u }, | |
| 3843 | { 8498454992640802816u, 4707293888784996898u, 144378520261u }, | |
| 3844 | { 5341660584200896512u, 690306801165964760u, 197255182913u }, | |
| 3845 | { 9288674231451648000u, 12456770961278956704u, 65037421606u }, | |
| 3846 | { 1152921504606846976u, 16946092489294063943u, 38675282906u }, | |
| 3847 | { 0u, 11098404173866185376u, 218918649514u }, | |
| 3848 | { 0u, 15152070965853306880u, 170601645695u }, | |
| 3849 | { 0u, 17370091362040414208u, 127821395412u }, | |
| 3850 | { 0u, 10141938552171134976u, 212941634539u }, | |
| 3851 | { 0u, 10586988556645826560u, 235549795590u }, | |
| 3852 | { 0u, 12169852093061922816u, 6573921799u }, | |
| 3853 | { 0u, 16717361816799281152u, 7659729003u }, | |
| 3854 | { 0u, 0u, 107906250000u }, | |
| 3855 | { 0u, 0u, 16000000000u }, | |
| 3856 | { 15212079674427582639u, 112u, 0u }, | |
| 3857 | { 10179808126814248333u, 112824648491u, 0u }, | |
| 3858 | { 6066766544199222848u, 2144184049294538808u, 6u }, | |
| 3859 | { 6625308131806923532u, 4108002197393276873u, 6116236450u }, | |
| 3860 | { 9122786786400665713u, 6446230217393892753u, 162222695245u }, | |
| 3861 | { 11932880778639151320u, 5571068025259989822u, 77349450840u }, | |
| 3862 | { 3884040911779255011u, 14804812668872528331u, 88302008202u }, | |
| 3863 | { 13441817515637357872u, 17369928488562523047u, 138802570502u }, | |
| 3864 | { 11628577856022352826u, 2967474173531035027u, 6941625710u }, | |
| 3865 | { 13296656925520243654u, 5291425437992807716u, 110160867097u }, | |
| 3866 | { 5020720704545399398u, 14219547193739388064u, 25286848747u }, | |
| 3867 | { 14121973606499014694u, 17720313647158217462u, 235770843197u }, | |
| 3868 | { 3642481034345420114u, 12334850628290578491u, 61960620127u }, | |
| 3869 | { 9845536238569696768u, 7818499847417334620u, 95668673592u }, | |
| 3870 | { 17655403572195686356u, 136007040922198372u, 56423841726u }, | |
| 3871 | { 8377495365136654029u, 8523477092112604449u, 190007372956u }, | |
| 3872 | { 13713682649609025426u, 367934822655966629u, 156462058619u }, | |
| 3873 | { 1367709905452854731u, 12964987687054730050u, 123019945786u }, | |
| 3874 | { 9981467701727208680u, 15267036012420885462u, 58702833390u }, | |
| 3875 | { 6277920117543306205u, 11142900264750765568u, 238827627680u }, | |
| 3876 | { 9344111460418701726u, 13680181547777718603u, 160604057833u }, | |
| 3877 | { 4918507011364617264u, 13001922925761426065u, 233741604127u }, | |
| 3878 | { 6554777203830755259u, 2397730045956515935u, 31704835654u }, | |
| 3879 | { 4198262173120265648u, 4482395522588406288u, 70129981206u }, | |
| 3880 | { 8080325935698446819u, 3255525722490493080u, 22242991148u }, | |
| 3881 | { 12797633874200091733u, 836222287193822098u, 44176482403u }, | |
| 3882 | { 8376502502208665497u, 420898743993182306u, 99045331701u }, | |
| 3883 | { 9891973386793349173u, 11652649973356574054u, 245022816966u }, | |
| 3884 | { 14877430279003795462u, 15058402726661910231u, 198631691420u }, | |
| 3885 | { 8759933935842067041u, 9600134495208339559u, 156816317647u }, | |
| 3886 | { 3753418510388703513u, 14626343323989004842u, 207520424333u }, | |
| 3887 | { 2961383332545305985u, 6813981265331086665u, 141792895660u }, | |
| 3888 | { 2497674184068629507u, 10281745288790487888u, 172369386664u }, | |
| 3889 | { 15244544070742305452u, 17569829347075761940u, 168557374528u }, | |
| 3890 | { 45953573565810823u, 7654580675237889478u, 64952462357u }, | |
| 3891 | { 3960077421351906445u, 16194838649686212364u, 21414955649u }, | |
| 3892 | { 3173330011013883118u, 6495102772252453635u, 129877923962u }, | |
| 3893 | { 11026266219545759160u, 14935159852819761348u, 122352100226u }, | |
| 3894 | { 8886757764964685632u, 17381879863441579697u, 130809636637u }, | |
| 3895 | { 13952322129918090479u, 9062335510435372583u, 29942273595u }, | |
| 3896 | { 4127250666614902202u, 7569219009130126626u, 59491270192u }, | |
| 3897 | { 17649958504065306911u, 12652124168176193362u, 48410328184u }, | |
| 3898 | { 13269305359002216873u, 8940200224697247767u, 120685873025u }, | |
| 3899 | { 16236593433831947843u, 5600570701927432884u, 129484649225u }, | |
| 3900 | { 13580930396682424057u, 2018432801986093157u, 9303607546u }, | |
| 3901 | { 421976357197961116u, 8235849749361824736u, 250109419461u }, | |
| 3902 | { 2962130818798626533u, 9705097287982370040u, 197446466309u }, | |
| 3903 | { 8234383947306356345u, 3517483139049842585u, 5526114378u }, | |
| 3904 | { 4380469931801381425u, 958281614186777760u, 74190683143u }, | |
| 3905 | { 15279887469027055916u, 7336473432636108950u, 7051948550u }, | |
| 3906 | { 8534542821713755552u, 12955383920176764423u, 6397711021u }, | |
| 3907 | { 7814613482565088782u, 10735469126281273789u, 173702312769u }, | |
| 3908 | { 13771954404705323224u, 8637888232514730693u, 65581970947u }, | |
| 3909 | { 4568173274762548144u, 6806336737533581000u, 3468260859u }, | |
| 3910 | { 8105292616250821343u, 16142569672872330321u, 251368972253u }, | |
| 3911 | { 2923678426777275612u, 8141285259947963513u, 221875090455u }, | |
| 3912 | { 1808633176918384049u, 5220241098754220797u, 23441339958u }, | |
| 3913 | { 18118642609460438969u, 154438799943119608u, 54282989837u }, | |
| 3914 | { 18138164175864360870u, 2226876628677628879u, 13008372144u }, | |
| 3915 | { 4031433690465792404u, 17219557081221357482u, 176120719223u }, | |
| 3916 | { 5012226396942308537u, 15401507148161015114u, 119933474059u }, | |
| 3917 | { 7889712298793536835u, 8842629766613985337u, 11834917375u }, | |
| 3918 | { 13500762396543628804u, 3180100571546071440u, 255479359920u }, | |
| 3919 | { 501020624068841347u, 7740848704392475044u, 176172393597u }, | |
| 3920 | { 8370653768288261750u, 2014314126623495998u, 125419632249u }, | |
| 3921 | { 647579990023635200u, 11209566016506885858u, 121109196187u }, | |
| 3922 | { 11106569307181154304u, 7117166613733441125u, 155607671791u }, | |
| 3923 | { 10797461613892861952u, 4197646860931880328u, 239385822375u }, | |
| 3924 | { 17627230675448889344u, 5487263271238026094u, 167227554892u }, | |
| 3925 | { 12197735707942322176u, 18148076225293562697u, 76297465137u }, | |
| 3926 | { 12871287735024877568u, 9127276943027950849u, 49983809183u }, | |
| 3927 | { 4611686018427387904u, 9691696125379324722u, 159494790674u }, | |
| 3928 | { 0u, 13102362262487705216u, 18525387899u }, | |
| 3929 | { 0u, 8929385439893192704u, 123710280481u }, | |
| 3930 | { 0u, 11891353410743566336u, 33484062954u }, | |
| 3931 | { 0u, 1587423090877399040u, 234644631560u }, | |
| 3932 | { 0u, 3489137423026225152u, 8086054378u }, | |
| 3933 | { 0u, 13046928120492326912u, 234189146518u }, | |
| 3934 | { 0u, 11529215046068469760u, 150707275390u }, | |
| 3935 | { 0u, 0u, 126625000000u }, | |
| 3936 | { 0u, 0u, 64000000000u }, | |
| 3937 | { 9451803574512021605u, 1721567u, 0u }, | |
| 3938 | { 8662766454758138424u, 1721567512383298u, 0u }, | |
| 3939 | { 9207992007314947035u, 6674960280855494694u, 93326u }, | |
| 3940 | { 17118602861291201802u, 16378845781483497510u, 142361850321u }, | |
| 3941 | { 11186560605745599967u, 17606907750956804392u, 209887899008u }, | |
| 3942 | { 10505549821532796847u, 13225609159240506969u, 128954472381u }, | |
| 3943 | { 18133667530488679216u, 2668084873338435252u, 189716961709u }, | |
| 3944 | { 10778135771244330799u, 14802814305275861366u, 173144637170u }, | |
| 3945 | { 17087985777033767391u, 8005510553372365574u, 242802462171u }, | |
| 3946 | { 2639185991757283040u, 12748500143273514429u, 219433979596u }, | |
| 3947 | { 5401720287293896400u, 10393733905569036127u, 204691097577u }, | |
| 3948 | { 9816495392633895233u, 603389089974790339u, 233563445444u }, | |
| 3949 | { 10042051500090034990u, 2033494532597735873u, 196032709788u }, | |
| 3950 | { 11629689537856384738u, 9204796763694620958u, 156110235959u }, | |
| 3951 | { 2099086731766010483u, 7826260310402107021u, 55498993032u }, | |
| 3952 | { 13665537898516458594u, 10122690201685169383u, 136424262421u }, | |
| 3953 | { 16375672064669490764u, 7438455564568110133u, 21548752135u }, | |
| 3954 | { 7770550512184564348u, 2805412574380520817u, 7403239484u }, | |
| 3955 | { 6197048880720627314u, 7250965427231182867u, 60152081720u }, | |
| 3956 | { 17963594118523106281u, 8136242944826085924u, 56393075623u }, | |
| 3957 | { 8255454642407818663u, 15357191647956011780u, 167441066613u }, | |
| 3958 | { 16744201957549498409u, 7369614426695395460u, 117832515027u }, | |
| 3959 | { 17442505417202859722u, 10886957545142526638u, 211399507598u }, | |
| 3960 | { 6383975767786687150u, 2030047207417538097u, 142590183151u }, | |
| 3961 | { 15245442964998335795u, 11557093828502314355u, 239110049079u }, | |
| 3962 | { 2910016124519524433u, 15201062539664128543u, 55626511311u }, | |
| 3963 | { 3847913871169988463u, 8846936323343880674u, 207824051251u }, | |
| 3964 | { 17210451512590059177u, 1485291750116245364u, 51479593379u }, | |
| 3965 | { 17899408909991454145u, 2076024439668322013u, 163080517827u }, | |
| 3966 | { 5920601932753251608u, 7029497773682748741u, 195112541510u }, | |
| 3967 | { 16521781895108979744u, 16333533921668749881u, 70381069837u }, | |
| 3968 | { 3697493405554698771u, 2065057316131928423u, 13885442648u }, | |
| 3969 | { 2816108280295732065u, 7800502648925570223u, 88111946981u }, | |
| 3970 | { 14251078772056398988u, 17011619967093802015u, 229422866095u }, | |
| 3971 | { 4543066550096031417u, 5368819344429198672u, 175922201766u }, | |
| 3972 | { 3099369389734296977u, 15598879366754275267u, 166291044279u }, | |
| 3973 | { 5243484113636490986u, 16393893486035835647u, 183845616944u }, | |
| 3974 | { 6823370511605197226u, 12042046205096920307u, 48888714746u }, | |
| 3975 | { 11396290277624641942u, 15437070428008474344u, 250652800632u }, | |
| 3976 | { 15934361408437566099u, 13704569163204647509u, 120836845264u }, | |
| 3977 | { 14939272230935131954u, 18192483750856993350u, 208742926182u }, | |
| 3978 | { 7500666177940329347u, 5152535865317963250u, 102986216520u }, | |
| 3979 | { 4806714453065462270u, 17512614083933854680u, 72279319528u }, | |
| 3980 | { 11557851247268441487u, 14481918350603613536u, 232949360711u }, | |
| 3981 | { 10655523157206817381u, 16124419709964004915u, 71785066366u }, | |
| 3982 | { 14769600176490881210u, 18088011566435813579u, 126874106543u }, | |
| 3983 | { 16688495540925795167u, 15008862380698848893u, 175980553071u }, | |
| 3984 | { 909793965395524173u, 18160498644611827812u, 111813632059u }, | |
| 3985 | { 12724590949761703756u, 3604680497457231965u, 59984482604u }, | |
| 3986 | { 10810739657314826395u, 5957615565551495921u, 44195410121u }, | |
| 3987 | { 2431218615388671301u, 17528455034961565995u, 201322962986u }, | |
| 3988 | { 4235001167959059286u, 8503772325120113809u, 42950219451u }, | |
| 3989 | { 6253317787396334247u, 8501492578048509537u, 187460990421u }, | |
| 3990 | { 9534525563070371898u, 2296237701094386060u, 213460866836u }, | |
| 3991 | { 8392783992374030728u, 3753593040591076946u, 20124479295u }, | |
| 3992 | { 16356257019231647540u, 8518075399775653155u, 63203482686u }, | |
| 3993 | { 12896334001521091877u, 12757855675959554597u, 62461765792u }, | |
| 3994 | { 1427636373320877084u, 121631169379748595u, 160691604742u }, | |
| 3995 | { 16116755731295043521u, 16679062494579173314u, 6006593638u }, | |
| 3996 | { 15945633911163986837u, 10739912744743898054u, 102904173789u }, | |
| 3997 | { 7510154241072743838u, 9367340677776287570u, 221582211836u }, | |
| 3998 | { 3571560509790395119u, 12227321512794715397u, 252507804555u }, | |
| 3999 | { 3576991649007035076u, 7241061891859170651u, 139662844427u }, | |
| 4000 | { 15509961892750732443u, 13148571323079237489u, 11392538751u }, | |
| 4001 | { 17789791359353349378u, 12509763434355012654u, 127712785479u }, | |
| 4002 | { 18331227331079738314u, 11812768946960181977u, 71678155634u }, | |
| 4003 | { 15386712883100476416u, 14170358803552564832u, 114640371487u }, | |
| 4004 | { 14082462055028752384u, 18179989524780635952u, 31768176689u }, | |
| 4005 | { 12919043128765186048u, 17091718978514754901u, 49985539206u }, | |
| 4006 | { 6125373368465096704u, 7394768384359232459u, 134926543942u }, | |
| 4007 | { 12335992698065387520u, 6778628272692852803u, 70400871197u }, | |
| 4008 | { 2774217370460225536u, 18193335045875234320u, 29367470174u }, | |
| 4009 | { 0u, 1378519212560967521u, 94986262669u }, | |
| 4010 | { 0u, 4677732610631043584u, 141074729676u }, | |
| 4011 | { 0u, 17296098591070486528u, 204253580392u }, | |
| 4012 | { 0u, 7343735382392963072u, 104937623383u }, | |
| 4013 | { 0u, 14525996728454217728u, 87398104692u }, | |
| 4014 | { 0u, 9691359370008330240u, 116787455860u }, | |
| 4015 | { 0u, 3044433348102455296u, 116525369644u }, | |
| 4016 | { 0u, 9223372036854775808u, 44165039062u }, | |
| 4017 | { 0u, 0u, 214500000000u }, | |
| 4018 | { 4962829537462579598u, 26u, 0u }, | |
| 4019 | { 5711259460785241095u, 26269035528u, 0u }, | |
| 4020 | { 13845894607204897444u, 7822291454600056379u, 1u }, | |
| 4021 | { 12116633056637003327u, 8201586317771250746u, 1424047269u }, | |
| 4022 | { 2965791047992089560u, 3278889188817135834u, 165444608885u }, | |
| 4023 | { 16021997451315962529u, 1710725240251040430u, 117177748939u }, | |
| 4024 | { 3942052271663803856u, 1850175733663425006u, 203092738601u }, | |
| 4025 | { 15669876414782439922u, 9147599666163914249u, 41100298227u }, | |
| 4026 | { 10594415915406145286u, 10221885933644344166u, 243495892371u }, | |
| 4027 | { 10789820553031921377u, 14901479793736678101u, 147554129546u }, | |
| 4028 | { 3989990218583987244u, 5181831442059703136u, 138807810838u }, | |
| 4029 | { 2937341169808224563u, 6396246577759793483u, 22280907645u }, | |
| 4030 | { 16267436558584536843u, 14167229556464870447u, 125346741221u }, | |
| 4031 | { 16221580362814625793u, 2969982933326311854u, 229768007053u }, | |
| 4032 | { 9695437602320209830u, 7892677766222018881u, 141161003097u }, | |
| 4033 | { 10729753156793715126u, 798698968922663621u, 89427862919u }, | |
| 4034 | { 2609241432056861929u, 15926812109043458972u, 135043297557u }, | |
| 4035 | { 8462663743997037565u, 8663842590352697437u, 21863394214u }, | |
| 4036 | { 14993422143908194069u, 17093523026636671168u, 166469667847u }, | |
| 4037 | { 1307443894537745373u, 839764004742743203u, 7926641740u }, | |
| 4038 | { 10017257439419829265u, 16894643909298232323u, 76045523697u }, | |
| 4039 | { 16754772009970777891u, 9066702926218949317u, 241915860481u }, | |
| 4040 | { 11722573031602862387u, 9119392417260546810u, 1491506950u }, | |
| 4041 | { 7363764277467092384u, 9723021096578315109u, 6494363253u }, | |
| 4042 | { 6733958494847390772u, 14787464248751217597u, 117527086029u }, | |
| 4043 | { 8799796600227451045u, 3733434565920249133u, 205801630043u }, | |
| 4044 | { 10512023194742249826u, 6643788868836820841u, 91202389893u }, | |
| 4045 | { 4572542132337197059u, 4729646697422664063u, 133360160516u }, | |
| 4046 | { 12600500455757416832u, 4090144564201555829u, 4256394661u }, | |
| 4047 | { 7873789864743195199u, 2109480737093400002u, 165221727181u }, | |
| 4048 | { 15724851676325671539u, 16577155033369419739u, 205114355179u }, | |
| 4049 | { 8748017220462413167u, 745377248603805917u, 235898649375u }, | |
| 4050 | { 14172589522760466448u, 11305561465807999667u, 31040406981u }, | |
| 4051 | { 9520545591489413768u, 2211245518782892177u, 197612875715u }, | |
| 4052 | { 12488551088392570222u, 14170095199249735666u, 195119871859u }, | |
| 4053 | { 1135798823651241684u, 17849973668116118927u, 115768162399u }, | |
| 4054 | { 11168725610120161972u, 9020960204585720001u, 95967649011u }, | |
| 4055 | { 9580104948718508826u, 10807134002871850916u, 243489027232u }, | |
| 4056 | { 16638722716909738765u, 3925122626254791201u, 160585855908u }, | |
| 4057 | { 15732724012348272797u, 17208463291312718997u, 164212781323u }, | |
| 4058 | { 12269722190021214142u, 5145077219589447653u, 11932872664u }, | |
| 4059 | { 13110655916311972587u, 17602397765035489468u, 216278915194u }, | |
| 4060 | { 6618112997062866867u, 16422643262490753377u, 122954227894u }, | |
| 4061 | { 8457936459015989309u, 2902509461400906224u, 182890273275u }, | |
| 4062 | { 3329167139937134914u, 3422418805967265206u, 251157345353u }, | |
| 4063 | { 5245511557216705097u, 4228874576277237392u, 73185529695u }, | |
| 4064 | { 5655931353280440466u, 2553488530807495751u, 95229247750u }, | |
| 4065 | { 604622132328697393u, 11546099176912486413u, 6138424890u }, | |
| 4066 | { 8673282619234652338u, 10460791037534167991u, 58625915290u }, | |
| 4067 | { 16929477433058445690u, 8127117908566000904u, 154567080618u }, | |
| 4068 | { 11036952409253549455u, 11541304458088287306u, 170440571944u }, | |
| 4069 | { 18199392190170386320u, 6249718665174839700u, 40625655368u }, | |
| 4070 | { 9683116091880335715u, 13102508413386290995u, 72338797927u }, | |
| 4071 | { 2993913337608915120u, 6274675218640661911u, 103710288404u }, | |
| 4072 | { 4490779842162392585u, 3404497118599817167u, 20340150825u }, | |
| 4073 | { 946849923353644618u, 11258566093988562335u, 41184558158u }, | |
| 4074 | { 3613491058474899828u, 16762592482501635397u, 78610328090u }, | |
| 4075 | { 14624054199004410935u, 5550125446725071998u, 26908701959u }, | |
| 4076 | { 12088470271991908244u, 6370033225258510318u, 7300872903u }, | |
| 4077 | { 10071980927725011290u, 1503521728674735398u, 199345320193u }, | |
| 4078 | { 2833441711428854664u, 4250415082606384364u, 1081506076u }, | |
| 4079 | { 17655572411864340446u, 6020091901030562974u, 28230415463u }, | |
| 4080 | { 4997642792058747802u, 16288222967151527138u, 103326349835u }, | |
| 4081 | { 11489200787635734848u, 6377016228656203782u, 11882986336u }, | |
| 4082 | { 12983586226429536913u, 8378856515587563750u, 96345698742u }, | |
| 4083 | { 12311150768725063152u, 15812881490200838483u, 182454218721u }, | |
| 4084 | { 8530052476845967905u, 4548570371183413652u, 225857218023u }, | |
| 4085 | { 6282736361499820264u, 16731431495283420383u, 231246578493u }, | |
| 4086 | { 11337164765929082880u, 14737727629551135532u, 61907012718u }, | |
| 4087 | { 8343856200414134272u, 12413722258104293893u, 110798933815u }, | |
| 4088 | { 17889330377156198400u, 800899742400762438u, 55672949232u }, | |
| 4089 | { 17730714064155312128u, 603197008376033550u, 240043416862u }, | |
| 4090 | { 7449235258647511040u, 6380777281587743935u, 30032699375u }, | |
| 4091 | { 9943947977234055168u, 10001440249018225388u, 239345902629u }, | |
| 4092 | { 0u, 5505914461980436708u, 37542179162u }, | |
| 4093 | { 0u, 1105464290051876864u, 90298476221u }, | |
| 4094 | { 0u, 4500443576769970176u, 189059927339u }, | |
| 4095 | { 0u, 2843045143185981440u, 43243969535u }, | |
| 4096 | { 0u, 660949699682893824u, 255154121786u }, | |
| 4097 | { 0u, 276549164618219520u, 58035830155u }, | |
| 4098 | { 0u, 4683743612465315840u, 139014991760u }, | |
| 4099 | { 0u, 0u, 144253906250u }, | |
| 4100 | { 0u, 0u, 74000000000u }, | |
| 4101 | { 12396245121240683569u, 400833u, 0u }, | |
| 4102 | { 10248996648596888561u, 400833672001794u, 0u }, | |
| 4103 | { 11257495103713935002u, 4370024159708535157u, 21729u }, | |
| 4104 | { 7555396579247433114u, 7166684413908503888u, 225236899484u }, | |
| 4105 | { 4805022328730367462u, 10217286283215687029u, 156388506740u }, | |
| 4106 | { 7056637817080232586u, 4767369911989629198u, 116553880199u }, | |
| 4107 | { 10811411483818434913u, 14407999214182082862u, 135258439640u }, | |
| 4108 | { 16962406704495245447u, 8472271297615317358u, 216781059202u }, | |
| 4109 | { 18074517319117194669u, 6236024012584764757u, 130459282747u }, | |
| 4110 | { 3702019776117654523u, 1951826556984620523u, 59338055539u }, | |
| 4111 | { 3551977551381082764u, 12357130551551830830u, 115105808729u }, | |
| 4112 | { 16442608985936005282u, 8927758011099278464u, 89669881389u }, | |
| 4113 | { 3580046275479139588u, 10199854049407140323u, 45483974731u }, | |
| 4114 | { 8737412692712715330u, 17895455027038549577u, 75552935195u }, | |
| 4115 | { 3082033243045084752u, 16539200343720527131u, 27970114560u }, | |
| 4116 | { 16401023756841128699u, 3536976106235802604u, 896591847u }, | |
| 4117 | { 7520296082779572869u, 16980391644793590751u, 231191739858u }, | |
| 4118 | { 9854104766152464159u, 10090294316609084067u, 210920508875u }, | |
| 4119 | { 14169188802648310188u, 17603457857266236889u, 203546995950u }, | |
| 4120 | { 2018609909210367042u, 11164962743035868272u, 238954285362u }, | |
| 4121 | { 8270271948267674359u, 1585686890718568774u, 50605253843u }, | |
| 4122 | { 12320338602894572099u, 10882524700472655412u, 211085960258u }, | |
| 4123 | { 17538536685990080547u, 2194808754940947757u, 66589942846u }, | |
| 4124 | { 15833914616956760474u, 274100791137209242u, 62118980821u }, | |
| 4125 | { 6137696141415969855u, 12203404582981010903u, 213014859033u }, | |
| 4126 | { 9757490468419438919u, 541940706340938166u, 25661547888u }, | |
| 4127 | { 3566639201356598903u, 10305434016011833594u, 112029378664u }, | |
| 4128 | { 9760900035773954449u, 7900783531944543546u, 104558658697u }, | |
| 4129 | { 3873778773990716438u, 8920818625012419323u, 137428302333u }, | |
| 4130 | { 2295668377270167832u, 12532363335400447632u, 253483598546u }, | |
| 4131 | { 1791721710912807593u, 13483507182924762800u, 210679380777u }, | |
| 4132 | { 10571009006922683279u, 415911049779278804u, 41730942389u }, | |
| 4133 | { 9840791932778184867u, 3441628281170127418u, 181022546583u }, | |
| 4134 | { 11525464956561274613u, 17830811568183566527u, 151186571042u }, | |
| 4135 | { 4435781488897895433u, 17897295813176613411u, 34966610231u }, | |
| 4136 | { 6395563367070996741u, 2086148701331574596u, 55970214350u }, | |
| 4137 | { 15538690795135662932u, 13015567826878853432u, 206113090347u }, | |
| 4138 | { 16294558813563371936u, 12944531121587846595u, 43705575345u }, | |
| 4139 | { 4942096228426070342u, 3534180912913737995u, 177701724438u }, | |
| 4140 | { 6910116424372647153u, 3447584022400118677u, 22191588331u }, | |
| 4141 | { 17923400669760829478u, 6375676813770849297u, 235186893904u }, | |
| 4142 | { 4134686917293039955u, 11580694081479200185u, 80345626132u }, | |
| 4143 | { 16857102463116098681u, 1872134358882196482u, 20627790684u }, | |
| 4144 | { 11364321508775167451u, 17602652840520938059u, 92101488606u }, | |
| 4145 | { 7966947780972783899u, 10331040597716338351u, 222954241722u }, | |
| 4146 | { 11261055695926686278u, 73785407041056976u, 186560046833u }, | |
| 4147 | { 9227040437353594058u, 17166209109167902028u, 241003999914u }, | |
| 4148 | { 7185344074282882061u, 8762475644006589904u, 170930582060u }, | |
| 4149 | { 14197856148610578032u, 8839001228645872586u, 44475014756u }, | |
| 4150 | { 885688687260429427u, 13558262784529110268u, 100479163216u }, | |
| 4151 | { 17407816160380305183u, 5640853896420358111u, 80734994898u }, | |
| 4152 | { 17812728703806357349u, 8459930353450835572u, 210305791302u }, | |
| 4153 | { 17120198191964319867u, 7643830211500171269u, 70458613743u }, | |
| 4154 | { 12091952048375408786u, 1308629115231236347u, 239414372866u }, | |
| 4155 | { 405056939269888281u, 8957268500971669618u, 2070940926u }, | |
| 4156 | { 12485440679452408690u, 7645679094277669412u, 254485574498u }, | |
| 4157 | { 8394369900823444407u, 3821107497040617191u, 98414473094u }, | |
| 4158 | { 2877421667354294258u, 8847137191985934072u, 134207142652u }, | |
| 4159 | { 2676980714750756239u, 3531126524756088253u, 252479604268u }, | |
| 4160 | { 6119309228579057021u, 8726915034124352183u, 44191422752u }, | |
| 4161 | { 18203256146533333852u, 17611136727168068641u, 32473087011u }, | |
| 4162 | { 351919978865493747u, 18017743272784259949u, 35954701634u }, | |
| 4163 | { 5190010931882390570u, 18113575006829616116u, 66976743819u }, | |
| 4164 | { 6982466386088036604u, 12805550441678740368u, 139981938868u }, | |
| 4165 | { 4707293888784996898u, 8061966093393027781u, 180694190280u }, | |
| 4166 | { 690306801165964760u, 11954593141554100801u, 200437040057u }, | |
| 4167 | { 12456770961278956704u, 14068656112359197734u, 185648059792u }, | |
| 4168 | { 16946092489294063943u, 895878255770467290u, 144762663376u }, | |
| 4169 | { 11098404173866185376u, 10319906489512197802u, 208048565657u }, | |
| 4170 | { 15152070965853306880u, 14551142616794302079u, 153559443251u }, | |
| 4171 | { 17370091362040414208u, 15933181735739307476u, 51788819021u }, | |
| 4172 | { 10141938552171134976u, 11524527334398983147u, 77863739512u }, | |
| 4173 | { 10586988556645826560u, 11828012606225556742u, 120624745878u }, | |
| 4174 | { 12169852093061922816u, 3556238869349799431u, 150641197848u }, | |
| 4175 | { 16717361816799281152u, 7403090230513381483u, 24192784095u }, | |
| 4176 | { 0u, 10172292854665622800u, 223401322325u }, | |
| 4177 | { 0u, 11240746576366182400u, 85551441100u }, | |
| 4178 | { 0u, 17021927826892259328u, 204609362092u }, | |
| 4179 | { 0u, 9046328496309141504u, 172922760556u }, | |
| 4180 | { 0u, 8038996803112140800u, 108490402450u }, | |
| 4181 | { 0u, 17098478935265509376u, 146435794889u }, | |
| 4182 | { 0u, 7205759403792793600u, 201926910400u }, | |
| 4183 | { 0u, 0u, 192390625000u }, | |
| 4184 | { 0u, 0u, 232000000000u }, | |
| 4185 | { 2144184049294538808u, 6u, 0u }, | |
| 4186 | { 4108002197393276873u, 6116236450u, 0u }, | |
| 4187 | { 6446230217393892753u, 6116236450222695245u, 0u }, | |
| 4188 | { 5571068025259989822u, 6240972538554414168u, 331561842u }, | |
| 4189 | { 14804812668872528331u, 4356262642990299018u, 114338323799u }, | |
| 4190 | { 17369928488562523047u, 1335108558830511366u, 87236153471u }, | |
| 4191 | { 2967474173531035027u, 18435704923261947246u, 127072376379u }, | |
| 4192 | { 5291425437992807716u, 8395401931972636441u, 59999401566u }, | |
| 4193 | { 14219547193739388064u, 12482665946362458347u, 94455115650u }, | |
| 4194 | { 17720313647158217462u, 16101242875289374781u, 130676686676u }, | |
| 4195 | { 12334850628290578491u, 4708983440241068127u, 84872850125u }, | |
| 4196 | { 7818499847417334620u, 14856666972541426744u, 205255274503u }, | |
| 4197 | { 136007040922198372u, 6938795288315789246u, 7805381530u }, | |
| 4198 | { 8523477092112604449u, 5556307628265073820u, 154376152846u }, | |
| 4199 | { 367934822655966629u, 1441404248927865979u, 14301208040u }, | |
| 4200 | { 12964987687054730050u, 16710378912353838906u, 232078138680u }, | |
| 4201 | { 15267036012420885462u, 18289940136919312110u, 56905871455u }, | |
| 4202 | { 11142900264750765568u, 10217414145292657824u, 95991499641u }, | |
| 4203 | { 13680181547777718603u, 12461165826430955753u, 121553887130u }, | |
| 4204 | { 13001922925761426065u, 662762458988270879u, 154675521153u }, | |
| 4205 | { 2397730045956515935u, 16488546856395302470u, 129035928424u }, | |
| 4206 | { 4482395522588406288u, 2612816787977180950u, 104893845916u }, | |
| 4207 | { 3255525722490493080u, 16446616379327454252u, 156141641081u }, | |
| 4208 | { 836222287193822098u, 7842178508581740643u, 121891572860u }, | |
| 4209 | { 420898743993182306u, 14779029861369369333u, 124425125348u }, | |
| 4210 | { 11652649973356574054u, 2697664446153849542u, 228801172814u }, | |
| 4211 | { 15058402726661910231u, 12135106444393649308u, 78146240682u }, | |
| 4212 | { 9600134495208339559u, 9550285041205189839u, 170657845438u }, | |
| 4213 | { 14626343323989004842u, 8790318168586740109u, 190517721989u }, | |
| 4214 | { 6813981265331086665u, 14038474217155846828u, 133476524102u }, | |
| 4215 | { 10281745288790487888u, 4263144264274812072u, 70761027212u }, | |
| 4216 | { 17569829347075761940u, 11940456333341715520u, 140231105513u }, | |
| 4217 | { 7654580675237889478u, 15751110736831573013u, 233647293434u }, | |
| 4218 | { 16194838649686212364u, 18384528705472318081u, 250853869423u }, | |
| 4219 | { 6495102772252453635u, 2393654818032310394u, 111996627298u }, | |
| 4220 | { 14935159852819761348u, 12812209822018626434u, 98129760287u }, | |
| 4221 | { 17381879863441579697u, 3110778569433458461u, 31694551286u }, | |
| 4222 | { 9062335510435372583u, 2860264756226872891u, 246168635644u }, | |
| 4223 | { 7569219009130126626u, 2384146980060315184u, 252155055263u }, | |
| 4224 | { 12652124168176193362u, 14117430062880324728u, 159129244866u }, | |
| 4225 | { 8940200224697247767u, 3769610173216737153u, 194765307417u }, | |
| 4226 | { 5600570701927432884u, 17731974340232672009u, 25204350976u }, | |
| 4227 | { 2018432801986093157u, 1971479303384713466u, 961252255u }, | |
| 4228 | { 8235849749361824736u, 3449462959779012549u, 159106874107u }, | |
| 4229 | { 9705097287982370040u, 13743454852043766533u, 251186995761u }, | |
| 4230 | { 3517483139049842585u, 7417711187131879498u, 49745034180u }, | |
| 4231 | { 958281614186777760u, 3650992383501007879u, 196402114929u }, | |
| 4232 | { 7336473432636108950u, 12838770342493958662u, 113197920693u }, | |
| 4233 | { 12955383920176764423u, 16025068246546338477u, 181695991134u }, | |
| 4234 | { 10735469126281273789u, 6579965938260177729u, 94868720690u }, | |
| 4235 | { 8637888232514730693u, 4742939430174291459u, 50356700668u }, | |
| 4236 | { 6806336737533581000u, 13062256857527449083u, 252257115261u }, | |
| 4237 | { 16142569672872330321u, 2301174570202439645u, 125708106363u }, | |
| 4238 | { 8141285259947963513u, 7638687886069412887u, 123124746923u }, | |
| 4239 | { 5220241098754220797u, 936322449610274358u, 171414094100u }, | |
| 4240 | { 154438799943119608u, 12926010544311283981u, 20050758141u }, | |
| 4241 | { 2226876628677628879u, 12647854908989899184u, 253700720435u }, | |
| 4242 | { 17219557081221357482u, 8862093163358513015u, 51685641588u }, | |
| 4243 | { 15401507148161015114u, 444784343917630731u, 116480415033u }, | |
| 4244 | { 8842629766613985337u, 11033952249213387263u, 57024111807u }, | |
| 4245 | { 3180100571546071440u, 18168634046363183536u, 191598151749u }, | |
| 4246 | { 7740848704392475044u, 3837904761417065597u, 69984923625u }, | |
| 4247 | { 2014314126623495998u, 111459007020906105u, 233208053234u }, | |
| 4248 | { 11209566016506885858u, 16191761957496794523u, 242006042204u }, | |
| 4249 | { 7117166613733441125u, 9856250800340378607u, 92877757174u }, | |
| 4250 | { 4197646860931880328u, 9491800102275105959u, 246534308426u }, | |
| 4251 | { 5487263271238026094u, 10777328578953608268u, 74514551514u }, | |
| 4252 | { 18148076225293562697u, 17424440628313779505u, 218584240152u }, | |
| 4253 | { 9127276943027950849u, 3285814872419755679u, 24944580819u }, | |
| 4254 | { 9691696125379324722u, 2824823424107240978u, 211178124381u }, | |
| 4255 | { 13102362262487705216u, 12271707680713669755u, 93153133984u }, | |
| 4256 | { 8929385439893192704u, 6951481875178001185u, 160665250606u }, | |
| 4257 | { 11891353410743566336u, 10202522487003824362u, 46376840587u }, | |
| 4258 | { 1587423090877399040u, 4834668463880990728u, 139553079852u }, | |
| 4259 | { 3489137423026225152u, 10871520987687904746u, 44262087902u }, | |
| 4260 | { 13046928120492326912u, 12057698794225322390u, 222589346333u }, | |
| 4261 | { 11529215046068469760u, 7263351819222681214u, 29653649161u }, | |
| 4262 | { 0u, 1778055686910650944u, 9393747091u }, | |
| 4263 | { 0u, 17108187120491986944u, 147096388591u }, | |
| 4264 | { 0u, 3067636961549221888u, 239927436682u }, | |
| 4265 | { 0u, 16702141595163557888u, 138166296932u }, | |
| 4266 | { 0u, 2432053749942845440u, 100905424910u }, | |
| 4267 | { 0u, 17791470327927144448u, 14131841897u }, | |
| 4268 | { 0u, 1152921504606846976u, 105964477539u }, | |
| 4269 | { 0u, 0u, 99062500000u }, | |
| 4270 | { 0u, 0u, 160000000000u }, | |
| 4271 | { 6674960280855494694u, 93326u, 0u }, | |
| 4272 | { 16378845781483497510u, 93326361850321u, 0u }, | |
| 4273 | { 17606907750956804392u, 4283581425266273664u, 5059u }, | |
| 4274 | { 13225609159240506969u, 6725911039793895357u, 195232213414u }, | |
| 4275 | { 2668084873338435252u, 1188689198788975021u, 166364612368u }, | |
| 4276 | { 14802814305275861366u, 10825527435847761650u, 16064438970u }, | |
| 4277 | { 8005510553372365574u, 3917696829526085083u, 186586853018u }, | |
| 4278 | { 12748500143273514429u, 12646861173976387276u, 154212378770u }, | |
| 4279 | { 10393733905569036127u, 18398576063183996905u, 146685587717u }, | |
| 4280 | { 603389089974790339u, 16919251228485834948u, 5997388806u }, | |
| 4281 | { 2033494532597735873u, 17296019588687185052u, 6917194446u }, | |
| 4282 | { 9204796763694620958u, 12365301604512770359u, 206937619100u }, | |
| 4283 | { 7826260310402107021u, 2814271599679204744u, 156670324343u }, | |
| 4284 | { 10122690201685169383u, 2154994415780170517u, 119152561969u }, | |
| 4285 | { 7438455564568110133u, 6717373824370072839u, 49116822481u }, | |
| 4286 | { 2805412574380520817u, 12709155755801344060u, 209364149564u }, | |
| 4287 | { 7250965427231182867u, 826847911966403896u, 60688964714u }, | |
| 4288 | { 8136242944826085924u, 2277322703890025383u, 106044823515u }, | |
| 4289 | { 15357191647956011780u, 2774508958389496437u, 219123453911u }, | |
| 4290 | { 7369614426695395460u, 245697774950120915u, 215150406432u }, | |
| 4291 | { 10886957545142526638u, 1268929063431863950u, 32013319303u }, | |
| 4292 | { 2030047207417538097u, 6735665673159411439u, 135068788782u }, | |
| 4293 | { 11557093828502314355u, 14734771742997073207u, 46365141167u }, | |
| 4294 | { 15201062539664128543u, 13683287077957612495u, 175798773576u }, | |
| 4295 | { 8846936323343880674u, 15370263741354826803u, 72741772478u }, | |
| 4296 | { 1485291750116245364u, 48035913070297507u, 190833223667u }, | |
| 4297 | { 2076024439668322013u, 1206547475966802115u, 243002604032u }, | |
| 4298 | { 7029497773682748741u, 13512340386605768006u, 65407069u }, | |
| 4299 | { 16333533921668749881u, 2325760467700278797u, 93732505440u }, | |
| 4300 | { 2065057316131928423u, 10848110652847753816u, 96126079727u }, | |
| 4301 | { 7800502648925570223u, 15846378960784301285u, 239588077256u }, | |
| 4302 | { 17011619967093802015u, 14121839924449844911u, 200859033924u }, | |
| 4303 | { 5368819344429198672u, 5147613424753296550u, 68765546476u }, | |
| 4304 | { 15598879366754275267u, 16817040482828810167u, 236279052682u }, | |
| 4305 | { 16393893486035835647u, 5773528746119363888u, 138911653591u }, | |
| 4306 | { 12042046205096920307u, 8716201595536184826u, 215312983620u }, | |
| 4307 | { 15437070428008474344u, 5259122109038474872u, 68472506235u }, | |
| 4308 | { 13704569163204647509u, 14744540084230155984u, 123285097580u }, | |
| 4309 | { 18192483750856993350u, 10719345477982635878u, 108799303119u }, | |
| 4310 | { 5152535865317963250u, 13698037261310555208u, 207581096882u }, | |
| 4311 | { 17512614083933854680u, 16141171632951976936u, 178742572087u }, | |
| 4312 | { 14481918350603613536u, 10060790174955808839u, 55875014667u }, | |
| 4313 | { 16124419709964004915u, 4250043307981877118u, 11545396528u }, | |
| 4314 | { 18088011566435813579u, 7075646198054337199u, 48230395309u }, | |
| 4315 | { 15008862380698848893u, 18141738384245531503u, 173383571548u }, | |
| 4316 | { 18160498644611827812u, 8174370508376809531u, 92983465608u }, | |
| 4317 | { 3604680497457231965u, 3581964982731575596u, 136443133513u }, | |
| 4318 | { 5957615565551495921u, 14798509948722114761u, 73194178710u }, | |
| 4319 | { 17528455034961565995u, 14713923334885122090u, 150802228831u }, | |
| 4320 | { 8503772325120113809u, 5042978054260414139u, 95797643382u }, | |
| 4321 | { 8501492578048509537u, 2052996319372883413u, 118273380388u }, | |
| 4322 | { 2296237701094386060u, 8825683007899981588u, 36111293153u }, | |
| 4323 | { 3753593040591076946u, 9992196755378745151u, 225478441234u }, | |
| 4324 | { 8518075399775653155u, 9301073417573669950u, 18541678071u }, | |
| 4325 | { 12757855675959554597u, 5331614769144850592u, 247504212200u }, | |
| 4326 | { 121631169379748595u, 14354009428310052102u, 232289027415u }, | |
| 4327 | { 16679062494579173314u, 5581221063029119078u, 87778132410u }, | |
| 4328 | { 10739912744743898054u, 1529260335339476189u, 186302558600u }, | |
| 4329 | { 9367340677776287570u, 16483061525949201148u, 136082901368u }, | |
| 4330 | { 12227321512794715397u, 14431217812333089675u, 120893548555u }, | |
| 4331 | { 7241061891859170651u, 3452349151135392267u, 11782317885u }, | |
| 4332 | { 13148571323079237489u, 9075317899834447999u, 61187152222u }, | |
| 4333 | { 12509763434355012654u, 2764331337978901575u, 94491973969u }, | |
| 4334 | { 11812768946960181977u, 1942890683708857202u, 81149854702u }, | |
| 4335 | { 14170358803552564832u, 165089169728028447u, 238105324315u }, | |
| 4336 | { 18179989524780635952u, 15193620741871233073u, 27008949501u }, | |
| 4337 | { 17091718978514754901u, 14995000835194145926u, 253823647830u }, | |
| 4338 | { 7394768384359232459u, 1788823614552255558u, 86812880624u }, | |
| 4339 | { 6778628272692852803u, 8384901184618498845u, 240096972322u }, | |
| 4340 | { 18193335045875234320u, 405511217862281310u, 34454546404u }, | |
| 4341 | { 1378519212560967521u, 3111530463755196557u, 228021982807u }, | |
| 4342 | { 4677732610631043584u, 7893558450035460812u, 87168676404u }, | |
| 4343 | { 17296098591070486528u, 156573858237402216u, 52427910661u }, | |
| 4344 | { 7343735382392963072u, 15915324019419451223u, 5008487885u }, | |
| 4345 | { 14525996728454217728u, 16293363012778802804u, 205862771443u }, | |
| 4346 | { 9691359370008330240u, 14342105318291351412u, 243883264978u }, | |
| 4347 | { 3044433348102455296u, 3788398842525387052u, 210777487087u }, | |
| 4348 | { 9223372036854775808u, 14118764407048307670u, 239205369512u }, | |
| 4349 | { 0u, 2705021334614720768u, 168765379752u }, | |
| 4350 | { 0u, 7017988973805568000u, 168146639500u }, | |
| 4351 | { 0u, 10956732053634154496u, 140380445944u }, | |
| 4352 | { 0u, 14657517938546835456u, 248593965634u }, | |
| 4353 | { 0u, 11268868284797157376u, 66794585639u }, | |
| 4354 | { 0u, 14600669991935148032u, 39610886573u }, | |
| 4355 | { 0u, 4611686018427387904u, 173791503906u }, | |
| 4356 | { 0u, 0u, 34250000000u }, | |
| 4357 | { 0u, 0u, 128000000000u }, | |
| 4358 | { 8201586317771250746u, 1424047269u, 0u }, | |
| 4359 | { 3278889188817135834u, 1424047269444608885u, 0u }, | |
| 4360 | { 1710725240251040430u, 3001188830946823627u, 77197757u }, | |
| 4361 | { 1850175733663425006u, 9732296932705387049u, 189162694772u }, | |
| 4362 | { 9147599666163914249u, 16337535782679529459u, 116527588873u }, | |
| 4363 | { 10221885933644344166u, 7969742269895046547u, 9885659589u }, | |
| 4364 | { 14901479793736678101u, 2923592083903829642u, 197432040594u }, | |
| 4365 | { 5181831442059703136u, 8144196241160608534u, 146158488244u }, | |
| 4366 | { 6396246577759793483u, 16431078457793424253u, 180441497762u }, | |
| 4367 | { 14167229556464870447u, 202362949592775653u, 162890730548u }, | |
| 4368 | { 2969982933326311854u, 8835125248522947981u, 52010970117u }, | |
| 4369 | { 7892677766222018881u, 7959873808777345113u, 5478953099u }, | |
| 4370 | { 798698968922663621u, 14929747122315126151u, 139431505623u }, | |
| 4371 | { 15926812109043458972u, 4310328817360515349u, 215809343213u }, | |
| 4372 | { 8663842590352697437u, 7294899422760201126u, 237233663393u }, | |
| 4373 | { 17093523026636671168u, 2047461597291187207u, 161395457290u }, | |
| 4374 | { 839764004742743203u, 10942374468813517900u, 10110993115u }, | |
| 4375 | { 16894643909298232323u, 10364795403063433969u, 219593187308u }, | |
| 4376 | { 9066702926218949317u, 12330859528790939137u, 236561876684u }, | |
| 4377 | { 9119392417260546810u, 8973160144879916806u, 204668457234u }, | |
| 4378 | { 9723021096578315109u, 2895354388547509877u, 18486435986u }, | |
| 4379 | { 14787464248751217597u, 16766844772497556429u, 146156957475u }, | |
| 4380 | { 3733434565920249133u, 7442407174620948827u, 35908932476u }, | |
| 4381 | { 6643788868836820841u, 6683013428676659077u, 124403453701u }, | |
| 4382 | { 4729646697422664063u, 16713703375071907588u, 5362286883u }, | |
| 4383 | { 4090144564201555829u, 8791044883080637861u, 35906051675u }, | |
| 4384 | { 2109480737093400002u, 602844107089214413u, 91476563498u }, | |
| 4385 | { 16577155033369419739u, 9754832281172880875u, 42032680244u }, | |
| 4386 | { 745377248603805917u, 10587846778003503903u, 52528810517u }, | |
| 4387 | { 11305561465807999667u, 17206244172922947013u, 21573968323u }, | |
| 4388 | { 2211245518782892177u, 11620628420699303875u, 195932752365u }, | |
| 4389 | { 14170095199249735666u, 17864732368219338611u, 237629955528u }, | |
| 4390 | { 17849973668116118927u, 4146383014621345887u, 200968449082u }, | |
| 4391 | { 9020960204585720001u, 11445705075042688243u, 58224775873u }, | |
| 4392 | { 10807134002871850916u, 7369147888966546592u, 193620472915u }, | |
| 4393 | { 3925122626254791201u, 9762476865090597796u, 83399482307u }, | |
| 4394 | { 17208463291312718997u, 5507001428194242827u, 195529224931u }, | |
| 4395 | { 5145077219589447653u, 11371471148365328344u, 227298535145u }, | |
| 4396 | { 17602397765035489468u, 3148788104946538618u, 233616448686u }, | |
| 4397 | { 16422643262490753377u, 3762722308424507574u, 174170696145u }, | |
| 4398 | { 2902509461400906224u, 1156171244825745915u, 209203977585u }, | |
| 4399 | { 3422418805967265206u, 14208921674868257865u, 113062676168u }, | |
| 4400 | { 4228874576277237392u, 7903080886897905503u, 200770267187u }, | |
| 4401 | { 2553488530807495751u, 6367240794154270982u, 51428426873u }, | |
| 4402 | { 11546099176912486413u, 1623672396662369850u, 121345168815u }, | |
| 4403 | { 10460791037534167991u, 18323231215381674394u, 175088019456u }, | |
| 4404 | { 8127117908566000904u, 9842279843006544554u, 993304354u }, | |
| 4405 | { 11541304458088287306u, 7376839231308610600u, 34533551059u }, | |
| 4406 | { 6249718665174839700u, 609751749293657672u, 211399899256u }, | |
| 4407 | { 13102508413386290995u, 10386457966860989799u, 120033054708u }, | |
| 4408 | { 6274675218640661911u, 11160336020836149780u, 244563051014u }, | |
| 4409 | { 3404497118599817167u, 17947559933847409193u, 6605003027u }, | |
| 4410 | { 11258566093988562335u, 10229787001712704590u, 19972939173u }, | |
| 4411 | { 16762592482501635397u, 10441677090043619866u, 165554557864u }, | |
| 4412 | { 5550125446725071998u, 4996681336392922375u, 168566044449u }, | |
| 4413 | { 6370033225258510318u, 124497102381021895u, 33270870638u }, | |
| 4414 | { 1503521728674735398u, 8180812057779384577u, 110006749001u }, | |
| 4415 | { 4250415082606384364u, 5294232873532946716u, 73443482710u }, | |
| 4416 | { 6020091901030562974u, 2885620189169448039u, 86287000939u }, | |
| 4417 | { 16288222967151527138u, 16662526875008170507u, 107156429783u }, | |
| 4418 | { 6377016228656203782u, 15663095032402672480u, 215903277391u }, | |
| 4419 | { 8378856515587563750u, 1824281504410546614u, 79849098083u }, | |
| 4420 | { 15812881490200838483u, 9506565509584809953u, 99098894498u }, | |
| 4421 | { 4548570371183413652u, 16941136942345070055u, 162515351948u }, | |
| 4422 | { 16731431495283420383u, 15924115693705937725u, 140918380873u }, | |
| 4423 | { 14737727629551135532u, 9247807690406628462u, 73863248041u }, | |
| 4424 | { 12413722258104293893u, 7993916633864834871u, 169501324659u }, | |
| 4425 | { 800899742400762438u, 1018504409177639408u, 115433351089u }, | |
| 4426 | { 603197008376033550u, 12097800686634130718u, 177055213234u }, | |
| 4427 | { 6380777281587743935u, 6221488888422637551u, 178655823089u }, | |
| 4428 | { 10001440249018225388u, 8229322865256080421u, 241337267588u }, | |
| 4429 | { 5505914461980436708u, 7927745108183101786u, 132446112486u }, | |
| 4430 | { 1105464290051876864u, 8488683721235326653u, 230429763923u }, | |
| 4431 | { 4500443576769970176u, 11165516518170922283u, 83460172466u }, | |
| 4432 | { 2843045143185981440u, 5463648141113596927u, 178605283863u }, | |
| 4433 | { 660949699682893824u, 3958440403860778042u, 23296184959u }, | |
| 4434 | { 276549164618219520u, 5091534813990256011u, 127214587484u }, | |
| 4435 | { 4683743612465315840u, 6100166970623291280u, 92276012655u }, | |
| 4436 | { 0u, 1913011027739012426u, 111330690714u }, | |
| 4437 | { 0u, 11310957650604221440u, 154103704535u }, | |
| 4438 | { 0u, 16303817257009020928u, 215613168242u }, | |
| 4439 | { 0u, 9090406322154766336u, 114883831704u }, | |
| 4440 | { 0u, 3003279315069566976u, 152492791914u }, | |
| 4441 | { 0u, 16582887146675765248u, 106162808097u }, | |
| 4442 | { 0u, 9691746398101307392u, 33898960113u }, | |
| 4443 | { 0u, 0u, 241525390625u }, | |
| 4444 | { 0u, 0u, 33000000000u }, | |
| 4445 | }; | |
| 4446 | ||
| 4447 | _LIBCPP_END_NAMESPACE_STD | |
| 4448 | ||
| 4449 | // clang-format on | |
| 4450 | ||
| 4451 | #endif // _LIBCPP_SRC_INCLUDE_RYU_D2FIXED_FULL_TABLE_H |
lib/libcxx/src/include/ryu/d2s.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 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_DS2_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_DS2_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | inline constexpr int __DOUBLE_MANTISSA_BITS = 52; | |
| 50 | inline constexpr int __DOUBLE_EXPONENT_BITS = 11; | |
| 51 | inline constexpr int __DOUBLE_BIAS = 1023; | |
| 52 | ||
| 53 | inline constexpr int __DOUBLE_POW5_INV_BITCOUNT = 122; | |
| 54 | inline constexpr int __DOUBLE_POW5_BITCOUNT = 121; | |
| 55 | ||
| 56 | [[nodiscard]] to_chars_result __d2s_buffered_n(char* const _First, char* const _Last, const double __f, const chars_format _Fmt); | |
| 57 | ||
| 58 | _LIBCPP_END_NAMESPACE_STD | |
| 59 | ||
| 60 | // clang-format on | |
| 61 | ||
| 62 | #endif // _LIBCPP_SRC_INCLUDE_RYU_DS2_H |
lib/libcxx/src/include/ryu/d2s_full_table.h created+368| ... | ... | @@ -0,0 +1,368 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_D2S_FULL_TABLE_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_D2S_FULL_TABLE_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | inline constexpr uint64_t __DOUBLE_POW5_INV_SPLIT[292][2] = { | |
| 50 | { 1u, 288230376151711744u }, { 3689348814741910324u, 230584300921369395u }, | |
| 51 | { 2951479051793528259u, 184467440737095516u }, { 17118578500402463900u, 147573952589676412u }, | |
| 52 | { 12632330341676300947u, 236118324143482260u }, { 10105864273341040758u, 188894659314785808u }, | |
| 53 | { 15463389048156653253u, 151115727451828646u }, { 17362724847566824558u, 241785163922925834u }, | |
| 54 | { 17579528692795369969u, 193428131138340667u }, { 6684925324752475329u, 154742504910672534u }, | |
| 55 | { 18074578149087781173u, 247588007857076054u }, { 18149011334012135262u, 198070406285660843u }, | |
| 56 | { 3451162622983977240u, 158456325028528675u }, { 5521860196774363583u, 253530120045645880u }, | |
| 57 | { 4417488157419490867u, 202824096036516704u }, { 7223339340677503017u, 162259276829213363u }, | |
| 58 | { 7867994130342094503u, 259614842926741381u }, { 2605046489531765280u, 207691874341393105u }, | |
| 59 | { 2084037191625412224u, 166153499473114484u }, { 10713157136084480204u, 265845599156983174u }, | |
| 60 | { 12259874523609494487u, 212676479325586539u }, { 13497248433629505913u, 170141183460469231u }, | |
| 61 | { 14216899864323388813u, 272225893536750770u }, { 11373519891458711051u, 217780714829400616u }, | |
| 62 | { 5409467098425058518u, 174224571863520493u }, { 4965798542738183305u, 278759314981632789u }, | |
| 63 | { 7661987648932456967u, 223007451985306231u }, { 2440241304404055250u, 178405961588244985u }, | |
| 64 | { 3904386087046488400u, 285449538541191976u }, { 17880904128604832013u, 228359630832953580u }, | |
| 65 | { 14304723302883865611u, 182687704666362864u }, { 15133127457049002812u, 146150163733090291u }, | |
| 66 | { 16834306301794583852u, 233840261972944466u }, { 9778096226693756759u, 187072209578355573u }, | |
| 67 | { 15201174610838826053u, 149657767662684458u }, { 2185786488890659746u, 239452428260295134u }, | |
| 68 | { 5437978005854438120u, 191561942608236107u }, { 15418428848909281466u, 153249554086588885u }, | |
| 69 | { 6222742084545298729u, 245199286538542217u }, { 16046240111861969953u, 196159429230833773u }, | |
| 70 | { 1768945645263844993u, 156927543384667019u }, { 10209010661905972635u, 251084069415467230u }, | |
| 71 | { 8167208529524778108u, 200867255532373784u }, { 10223115638361732810u, 160693804425899027u }, | |
| 72 | { 1599589762411131202u, 257110087081438444u }, { 4969020624670815285u, 205688069665150755u }, | |
| 73 | { 3975216499736652228u, 164550455732120604u }, { 13739044029062464211u, 263280729171392966u }, | |
| 74 | { 7301886408508061046u, 210624583337114373u }, { 13220206756290269483u, 168499666669691498u }, | |
| 75 | { 17462981995322520850u, 269599466671506397u }, { 6591687966774196033u, 215679573337205118u }, | |
| 76 | { 12652048002903177473u, 172543658669764094u }, { 9175230360419352987u, 276069853871622551u }, | |
| 77 | { 3650835473593572067u, 220855883097298041u }, { 17678063637842498946u, 176684706477838432u }, | |
| 78 | { 13527506561580357021u, 282695530364541492u }, { 3443307619780464970u, 226156424291633194u }, | |
| 79 | { 6443994910566282300u, 180925139433306555u }, { 5155195928453025840u, 144740111546645244u }, | |
| 80 | { 15627011115008661990u, 231584178474632390u }, { 12501608892006929592u, 185267342779705912u }, | |
| 81 | { 2622589484121723027u, 148213874223764730u }, { 4196143174594756843u, 237142198758023568u }, | |
| 82 | { 10735612169159626121u, 189713759006418854u }, { 12277838550069611220u, 151771007205135083u }, | |
| 83 | { 15955192865369467629u, 242833611528216133u }, { 1696107848069843133u, 194266889222572907u }, | |
| 84 | { 12424932722681605476u, 155413511378058325u }, { 1433148282581017146u, 248661618204893321u }, | |
| 85 | { 15903913885032455010u, 198929294563914656u }, { 9033782293284053685u, 159143435651131725u }, | |
| 86 | { 14454051669254485895u, 254629497041810760u }, { 11563241335403588716u, 203703597633448608u }, | |
| 87 | { 16629290697806691620u, 162962878106758886u }, { 781423413297334329u, 260740604970814219u }, | |
| 88 | { 4314487545379777786u, 208592483976651375u }, { 3451590036303822229u, 166873987181321100u }, | |
| 89 | { 5522544058086115566u, 266998379490113760u }, { 4418035246468892453u, 213598703592091008u }, | |
| 90 | { 10913125826658934609u, 170878962873672806u }, { 10082303693170474728u, 273406340597876490u }, | |
| 91 | { 8065842954536379782u, 218725072478301192u }, { 17520720807854834795u, 174980057982640953u }, | |
| 92 | { 5897060404116273733u, 279968092772225526u }, { 1028299508551108663u, 223974474217780421u }, | |
| 93 | { 15580034865808528224u, 179179579374224336u }, { 17549358155809824511u, 286687326998758938u }, | |
| 94 | { 2971440080422128639u, 229349861599007151u }, { 17134547323305344204u, 183479889279205720u }, | |
| 95 | { 13707637858644275364u, 146783911423364576u }, { 14553522944347019935u, 234854258277383322u }, | |
| 96 | { 4264120725993795302u, 187883406621906658u }, { 10789994210278856888u, 150306725297525326u }, | |
| 97 | { 9885293106962350374u, 240490760476040522u }, { 529536856086059653u, 192392608380832418u }, | |
| 98 | { 7802327114352668369u, 153914086704665934u }, { 1415676938738538420u, 246262538727465495u }, | |
| 99 | { 1132541550990830736u, 197010030981972396u }, { 15663428499760305882u, 157608024785577916u }, | |
| 100 | { 17682787970132668764u, 252172839656924666u }, { 10456881561364224688u, 201738271725539733u }, | |
| 101 | { 15744202878575200397u, 161390617380431786u }, { 17812026976236499989u, 258224987808690858u }, | |
| 102 | { 3181575136763469022u, 206579990246952687u }, { 13613306553636506187u, 165263992197562149u }, | |
| 103 | { 10713244041592678929u, 264422387516099439u }, { 12259944048016053467u, 211537910012879551u }, | |
| 104 | { 6118606423670932450u, 169230328010303641u }, { 2411072648389671274u, 270768524816485826u }, | |
| 105 | { 16686253377679378312u, 216614819853188660u }, { 13349002702143502650u, 173291855882550928u }, | |
| 106 | { 17669055508687693916u, 277266969412081485u }, { 14135244406950155133u, 221813575529665188u }, | |
| 107 | { 240149081334393137u, 177450860423732151u }, { 11452284974360759988u, 283921376677971441u }, | |
| 108 | { 5472479164746697667u, 227137101342377153u }, { 11756680961281178780u, 181709681073901722u }, | |
| 109 | { 2026647139541122378u, 145367744859121378u }, { 18000030682233437097u, 232588391774594204u }, | |
| 110 | { 18089373360528660001u, 186070713419675363u }, { 3403452244197197031u, 148856570735740291u }, | |
| 111 | { 16513570034941246220u, 238170513177184465u }, { 13210856027952996976u, 190536410541747572u }, | |
| 112 | { 3189987192878576934u, 152429128433398058u }, { 1414630693863812771u, 243886605493436893u }, | |
| 113 | { 8510402184574870864u, 195109284394749514u }, { 10497670562401807014u, 156087427515799611u }, | |
| 114 | { 9417575270359070576u, 249739884025279378u }, { 14912757845771077107u, 199791907220223502u }, | |
| 115 | { 4551508647133041040u, 159833525776178802u }, { 10971762650154775986u, 255733641241886083u }, | |
| 116 | { 16156107749607641435u, 204586912993508866u }, { 9235537384944202825u, 163669530394807093u }, | |
| 117 | { 11087511001168814197u, 261871248631691349u }, { 12559357615676961681u, 209496998905353079u }, | |
| 118 | { 13736834907283479668u, 167597599124282463u }, { 18289587036911657145u, 268156158598851941u }, | |
| 119 | { 10942320814787415393u, 214524926879081553u }, { 16132554281313752961u, 171619941503265242u }, | |
| 120 | { 11054691591134363444u, 274591906405224388u }, { 16222450902391311402u, 219673525124179510u }, | |
| 121 | { 12977960721913049122u, 175738820099343608u }, { 17075388340318968271u, 281182112158949773u }, | |
| 122 | { 2592264228029443648u, 224945689727159819u }, { 5763160197165465241u, 179956551781727855u }, | |
| 123 | { 9221056315464744386u, 287930482850764568u }, { 14755542681855616155u, 230344386280611654u }, | |
| 124 | { 15493782960226403247u, 184275509024489323u }, { 1326979923955391628u, 147420407219591459u }, | |
| 125 | { 9501865507812447252u, 235872651551346334u }, { 11290841220991868125u, 188698121241077067u }, | |
| 126 | { 1653975347309673853u, 150958496992861654u }, { 10025058185179298811u, 241533595188578646u }, | |
| 127 | { 4330697733401528726u, 193226876150862917u }, { 14532604630946953951u, 154581500920690333u }, | |
| 128 | { 1116074521063664381u, 247330401473104534u }, { 4582208431592841828u, 197864321178483627u }, | |
| 129 | { 14733813189500004432u, 158291456942786901u }, { 16195403473716186445u, 253266331108459042u }, | |
| 130 | { 5577625149489128510u, 202613064886767234u }, { 8151448934333213131u, 162090451909413787u }, | |
| 131 | { 16731667109675051333u, 259344723055062059u }, { 17074682502481951390u, 207475778444049647u }, | |
| 132 | { 6281048372501740465u, 165980622755239718u }, { 6360328581260874421u, 265568996408383549u }, | |
| 133 | { 8777611679750609860u, 212455197126706839u }, { 10711438158542398211u, 169964157701365471u }, | |
| 134 | { 9759603424184016492u, 271942652322184754u }, { 11497031554089123517u, 217554121857747803u }, | |
| 135 | { 16576322872755119460u, 174043297486198242u }, { 11764721337440549842u, 278469275977917188u }, | |
| 136 | { 16790474699436260520u, 222775420782333750u }, { 13432379759549008416u, 178220336625867000u }, | |
| 137 | { 3045063541568861850u, 285152538601387201u }, { 17193446092222730773u, 228122030881109760u }, | |
| 138 | { 13754756873778184618u, 182497624704887808u }, { 18382503128506368341u, 145998099763910246u }, | |
| 139 | { 3586563302416817083u, 233596959622256395u }, { 2869250641933453667u, 186877567697805116u }, | |
| 140 | { 17052795772514404226u, 149502054158244092u }, { 12527077977055405469u, 239203286653190548u }, | |
| 141 | { 17400360011128145022u, 191362629322552438u }, { 2852241564676785048u, 153090103458041951u }, | |
| 142 | { 15631632947708587046u, 244944165532867121u }, { 8815957543424959314u, 195955332426293697u }, | |
| 143 | { 18120812478965698421u, 156764265941034957u }, { 14235904707377476180u, 250822825505655932u }, | |
| 144 | { 4010026136418160298u, 200658260404524746u }, { 17965416168102169531u, 160526608323619796u }, | |
| 145 | { 2919224165770098987u, 256842573317791675u }, { 2335379332616079190u, 205474058654233340u }, | |
| 146 | { 1868303466092863352u, 164379246923386672u }, { 6678634360490491686u, 263006795077418675u }, | |
| 147 | { 5342907488392393349u, 210405436061934940u }, { 4274325990713914679u, 168324348849547952u }, | |
| 148 | { 10528270399884173809u, 269318958159276723u }, { 15801313949391159694u, 215455166527421378u }, | |
| 149 | { 1573004715287196786u, 172364133221937103u }, { 17274202803427156150u, 275782613155099364u }, | |
| 150 | { 17508711057483635243u, 220626090524079491u }, { 10317620031244997871u, 176500872419263593u }, | |
| 151 | { 12818843235250086271u, 282401395870821749u }, { 13944423402941979340u, 225921116696657399u }, | |
| 152 | { 14844887537095493795u, 180736893357325919u }, { 15565258844418305359u, 144589514685860735u }, | |
| 153 | { 6457670077359736959u, 231343223497377177u }, { 16234182506113520537u, 185074578797901741u }, | |
| 154 | { 9297997190148906106u, 148059663038321393u }, { 11187446689496339446u, 236895460861314229u }, | |
| 155 | { 12639306166338981880u, 189516368689051383u }, { 17490142562555006151u, 151613094951241106u }, | |
| 156 | { 2158786396894637579u, 242580951921985771u }, { 16484424376483351356u, 194064761537588616u }, | |
| 157 | { 9498190686444770762u, 155251809230070893u }, { 11507756283569722895u, 248402894768113429u }, | |
| 158 | { 12895553841597688639u, 198722315814490743u }, { 17695140702761971558u, 158977852651592594u }, | |
| 159 | { 17244178680193423523u, 254364564242548151u }, { 10105994129412828495u, 203491651394038521u }, | |
| 160 | { 4395446488788352473u, 162793321115230817u }, { 10722063196803274280u, 260469313784369307u }, | |
| 161 | { 1198952927958798777u, 208375451027495446u }, { 15716557601334680315u, 166700360821996356u }, | |
| 162 | { 17767794532651667857u, 266720577315194170u }, { 14214235626121334286u, 213376461852155336u }, | |
| 163 | { 7682039686155157106u, 170701169481724269u }, { 1223217053622520399u, 273121871170758831u }, | |
| 164 | { 15735968901865657612u, 218497496936607064u }, { 16278123936234436413u, 174797997549285651u }, | |
| 165 | { 219556594781725998u, 279676796078857043u }, { 7554342905309201445u, 223741436863085634u }, | |
| 166 | { 9732823138989271479u, 178993149490468507u }, { 815121763415193074u, 286389039184749612u }, | |
| 167 | { 11720143854957885429u, 229111231347799689u }, { 13065463898708218666u, 183288985078239751u }, | |
| 168 | { 6763022304224664610u, 146631188062591801u }, { 3442138057275642729u, 234609900900146882u }, | |
| 169 | { 13821756890046245153u, 187687920720117505u }, { 11057405512036996122u, 150150336576094004u }, | |
| 170 | { 6623802375033462826u, 240240538521750407u }, { 16367088344252501231u, 192192430817400325u }, | |
| 171 | { 13093670675402000985u, 153753944653920260u }, { 2503129006933649959u, 246006311446272417u }, | |
| 172 | { 13070549649772650937u, 196805049157017933u }, { 17835137349301941396u, 157444039325614346u }, | |
| 173 | { 2710778055689733971u, 251910462920982955u }, { 2168622444551787177u, 201528370336786364u }, | |
| 174 | { 5424246770383340065u, 161222696269429091u }, { 1300097203129523457u, 257956314031086546u }, | |
| 175 | { 15797473021471260058u, 206365051224869236u }, { 8948629602435097724u, 165092040979895389u }, | |
| 176 | { 3249760919670425388u, 264147265567832623u }, { 9978506365220160957u, 211317812454266098u }, | |
| 177 | { 15361502721659949412u, 169054249963412878u }, { 2442311466204457120u, 270486799941460606u }, | |
| 178 | { 16711244431931206989u, 216389439953168484u }, { 17058344360286875914u, 173111551962534787u }, | |
| 179 | { 12535955717491360170u, 276978483140055660u }, { 10028764573993088136u, 221582786512044528u }, | |
| 180 | { 15401709288678291155u, 177266229209635622u }, { 9885339602917624555u, 283625966735416996u }, | |
| 181 | { 4218922867592189321u, 226900773388333597u }, { 14443184738299482427u, 181520618710666877u }, | |
| 182 | { 4175850161155765295u, 145216494968533502u }, { 10370709072591134795u, 232346391949653603u }, | |
| 183 | { 15675264887556728482u, 185877113559722882u }, { 5161514280561562140u, 148701690847778306u }, | |
| 184 | { 879725219414678777u, 237922705356445290u }, { 703780175531743021u, 190338164285156232u }, | |
| 185 | { 11631070584651125387u, 152270531428124985u }, { 162968861732249003u, 243632850284999977u }, | |
| 186 | { 11198421533611530172u, 194906280227999981u }, { 5269388412147313814u, 155925024182399985u }, | |
| 187 | { 8431021459435702103u, 249480038691839976u }, { 3055468352806651359u, 199584030953471981u }, | |
| 188 | { 17201769941212962380u, 159667224762777584u }, { 16454785461715008838u, 255467559620444135u }, | |
| 189 | { 13163828369372007071u, 204374047696355308u }, { 17909760324981426303u, 163499238157084246u }, | |
| 190 | { 2830174816776909822u, 261598781051334795u }, { 2264139853421527858u, 209279024841067836u }, | |
| 191 | { 16568707141704863579u, 167423219872854268u }, { 4373838538276319787u, 267877151796566830u }, | |
| 192 | { 3499070830621055830u, 214301721437253464u }, { 6488605479238754987u, 171441377149802771u }, | |
| 193 | { 3003071137298187333u, 274306203439684434u }, { 6091805724580460189u, 219444962751747547u }, | |
| 194 | { 15941491023890099121u, 175555970201398037u }, { 10748990379256517301u, 280889552322236860u }, | |
| 195 | { 8599192303405213841u, 224711641857789488u }, { 14258051472207991719u, 179769313486231590u } | |
| 196 | }; | |
| 197 | ||
| 198 | inline constexpr uint64_t __DOUBLE_POW5_SPLIT[326][2] = { | |
| 199 | { 0u, 72057594037927936u }, { 0u, 90071992547409920u }, | |
| 200 | { 0u, 112589990684262400u }, { 0u, 140737488355328000u }, | |
| 201 | { 0u, 87960930222080000u }, { 0u, 109951162777600000u }, | |
| 202 | { 0u, 137438953472000000u }, { 0u, 85899345920000000u }, | |
| 203 | { 0u, 107374182400000000u }, { 0u, 134217728000000000u }, | |
| 204 | { 0u, 83886080000000000u }, { 0u, 104857600000000000u }, | |
| 205 | { 0u, 131072000000000000u }, { 0u, 81920000000000000u }, | |
| 206 | { 0u, 102400000000000000u }, { 0u, 128000000000000000u }, | |
| 207 | { 0u, 80000000000000000u }, { 0u, 100000000000000000u }, | |
| 208 | { 0u, 125000000000000000u }, { 0u, 78125000000000000u }, | |
| 209 | { 0u, 97656250000000000u }, { 0u, 122070312500000000u }, | |
| 210 | { 0u, 76293945312500000u }, { 0u, 95367431640625000u }, | |
| 211 | { 0u, 119209289550781250u }, { 4611686018427387904u, 74505805969238281u }, | |
| 212 | { 10376293541461622784u, 93132257461547851u }, { 8358680908399640576u, 116415321826934814u }, | |
| 213 | { 612489549322387456u, 72759576141834259u }, { 14600669991935148032u, 90949470177292823u }, | |
| 214 | { 13639151471491547136u, 113686837721616029u }, { 3213881284082270208u, 142108547152020037u }, | |
| 215 | { 4314518811765112832u, 88817841970012523u }, { 781462496279003136u, 111022302462515654u }, | |
| 216 | { 10200200157203529728u, 138777878078144567u }, { 13292654125893287936u, 86736173798840354u }, | |
| 217 | { 7392445620511834112u, 108420217248550443u }, { 4628871007212404736u, 135525271560688054u }, | |
| 218 | { 16728102434789916672u, 84703294725430033u }, { 7075069988205232128u, 105879118406787542u }, | |
| 219 | { 18067209522111315968u, 132348898008484427u }, { 8986162942105878528u, 82718061255302767u }, | |
| 220 | { 6621017659204960256u, 103397576569128459u }, { 3664586055578812416u, 129246970711410574u }, | |
| 221 | { 16125424340018921472u, 80779356694631608u }, { 1710036351314100224u, 100974195868289511u }, | |
| 222 | { 15972603494424788992u, 126217744835361888u }, { 9982877184015493120u, 78886090522101180u }, | |
| 223 | { 12478596480019366400u, 98607613152626475u }, { 10986559581596820096u, 123259516440783094u }, | |
| 224 | { 2254913720070624656u, 77037197775489434u }, { 12042014186943056628u, 96296497219361792u }, | |
| 225 | { 15052517733678820785u, 120370621524202240u }, { 9407823583549262990u, 75231638452626400u }, | |
| 226 | { 11759779479436578738u, 94039548065783000u }, { 14699724349295723422u, 117549435082228750u }, | |
| 227 | { 4575641699882439235u, 73468396926392969u }, { 10331238143280436948u, 91835496157991211u }, | |
| 228 | { 8302361660673158281u, 114794370197489014u }, { 1154580038986672043u, 143492962746861268u }, | |
| 229 | { 9944984561221445835u, 89683101716788292u }, { 12431230701526807293u, 112103877145985365u }, | |
| 230 | { 1703980321626345405u, 140129846432481707u }, { 17205888765512323542u, 87581154020301066u }, | |
| 231 | { 12283988920035628619u, 109476442525376333u }, { 1519928094762372062u, 136845553156720417u }, | |
| 232 | { 12479170105294952299u, 85528470722950260u }, { 15598962631618690374u, 106910588403687825u }, | |
| 233 | { 5663645234241199255u, 133638235504609782u }, { 17374836326682913246u, 83523897190381113u }, | |
| 234 | { 7883487353071477846u, 104404871487976392u }, { 9854359191339347308u, 130506089359970490u }, | |
| 235 | { 10770660513014479971u, 81566305849981556u }, { 13463325641268099964u, 101957882312476945u }, | |
| 236 | { 2994098996302961243u, 127447352890596182u }, { 15706369927971514489u, 79654595556622613u }, | |
| 237 | { 5797904354682229399u, 99568244445778267u }, { 2635694424925398845u, 124460305557222834u }, | |
| 238 | { 6258995034005762182u, 77787690973264271u }, { 3212057774079814824u, 97234613716580339u }, | |
| 239 | { 17850130272881932242u, 121543267145725423u }, { 18073860448192289507u, 75964541966078389u }, | |
| 240 | { 8757267504958198172u, 94955677457597987u }, { 6334898362770359811u, 118694596821997484u }, | |
| 241 | { 13182683513586250689u, 74184123013748427u }, { 11866668373555425458u, 92730153767185534u }, | |
| 242 | { 5609963430089506015u, 115912692208981918u }, { 17341285199088104971u, 72445432630613698u }, | |
| 243 | { 12453234462005355406u, 90556790788267123u }, { 10954857059079306353u, 113195988485333904u }, | |
| 244 | { 13693571323849132942u, 141494985606667380u }, { 17781854114260483896u, 88434366004167112u }, | |
| 245 | { 3780573569116053255u, 110542957505208891u }, { 114030942967678664u, 138178696881511114u }, | |
| 246 | { 4682955357782187069u, 86361685550944446u }, { 15077066234082509644u, 107952106938680557u }, | |
| 247 | { 5011274737320973344u, 134940133673350697u }, { 14661261756894078100u, 84337583545844185u }, | |
| 248 | { 4491519140835433913u, 105421979432305232u }, { 5614398926044292391u, 131777474290381540u }, | |
| 249 | { 12732371365632458552u, 82360921431488462u }, { 6692092170185797382u, 102951151789360578u }, | |
| 250 | { 17588487249587022536u, 128688939736700722u }, { 15604490549419276989u, 80430587335437951u }, | |
| 251 | { 14893927168346708332u, 100538234169297439u }, { 14005722942005997511u, 125672792711621799u }, | |
| 252 | { 15671105866394830300u, 78545495444763624u }, { 1142138259283986260u, 98181869305954531u }, | |
| 253 | { 15262730879387146537u, 122727336632443163u }, { 7233363790403272633u, 76704585395276977u }, | |
| 254 | { 13653390756431478696u, 95880731744096221u }, { 3231680390257184658u, 119850914680120277u }, | |
| 255 | { 4325643253124434363u, 74906821675075173u }, { 10018740084832930858u, 93633527093843966u }, | |
| 256 | { 3300053069186387764u, 117041908867304958u }, { 15897591223523656064u, 73151193042065598u }, | |
| 257 | { 10648616992549794273u, 91438991302581998u }, { 4087399203832467033u, 114298739128227498u }, | |
| 258 | { 14332621041645359599u, 142873423910284372u }, { 18181260187883125557u, 89295889943927732u }, | |
| 259 | { 4279831161144355331u, 111619862429909666u }, { 14573160988285219972u, 139524828037387082u }, | |
| 260 | { 13719911636105650386u, 87203017523366926u }, { 7926517508277287175u, 109003771904208658u }, | |
| 261 | { 684774848491833161u, 136254714880260823u }, { 7345513307948477581u, 85159196800163014u }, | |
| 262 | { 18405263671790372785u, 106448996000203767u }, { 18394893571310578077u, 133061245000254709u }, | |
| 263 | { 13802651491282805250u, 83163278125159193u }, { 3418256308821342851u, 103954097656448992u }, | |
| 264 | { 4272820386026678563u, 129942622070561240u }, { 2670512741266674102u, 81214138794100775u }, | |
| 265 | { 17173198981865506339u, 101517673492625968u }, { 3019754653622331308u, 126897091865782461u }, | |
| 266 | { 4193189667727651020u, 79310682416114038u }, { 14464859121514339583u, 99138353020142547u }, | |
| 267 | { 13469387883465536574u, 123922941275178184u }, { 8418367427165960359u, 77451838296986365u }, | |
| 268 | { 15134645302384838353u, 96814797871232956u }, { 471562554271496325u, 121018497339041196u }, | |
| 269 | { 9518098633274461011u, 75636560836900747u }, { 7285937273165688360u, 94545701046125934u }, | |
| 270 | { 18330793628311886258u, 118182126307657417u }, { 4539216990053847055u, 73863828942285886u }, | |
| 271 | { 14897393274422084627u, 92329786177857357u }, { 4786683537745442072u, 115412232722321697u }, | |
| 272 | { 14520892257159371055u, 72132645451451060u }, { 18151115321449213818u, 90165806814313825u }, | |
| 273 | { 8853836096529353561u, 112707258517892282u }, { 1843923083806916143u, 140884073147365353u }, | |
| 274 | { 12681666973447792349u, 88052545717103345u }, { 2017025661527576725u, 110065682146379182u }, | |
| 275 | { 11744654113764246714u, 137582102682973977u }, { 422879793461572340u, 85988814176858736u }, | |
| 276 | { 528599741826965425u, 107486017721073420u }, { 660749677283706782u, 134357522151341775u }, | |
| 277 | { 7330497575943398595u, 83973451344588609u }, { 13774807988356636147u, 104966814180735761u }, | |
| 278 | { 3383451930163631472u, 131208517725919702u }, { 15949715511634433382u, 82005323578699813u }, | |
| 279 | { 6102086334260878016u, 102506654473374767u }, { 3015921899398709616u, 128133318091718459u }, | |
| 280 | { 18025852251620051174u, 80083323807324036u }, { 4085571240815512351u, 100104154759155046u }, | |
| 281 | { 14330336087874166247u, 125130193448943807u }, { 15873989082562435760u, 78206370905589879u }, | |
| 282 | { 15230800334775656796u, 97757963631987349u }, { 5203442363187407284u, 122197454539984187u }, | |
| 283 | { 946308467778435600u, 76373409087490117u }, { 5794571603150432404u, 95466761359362646u }, | |
| 284 | { 16466586540792816313u, 119333451699203307u }, { 7985773578781816244u, 74583407312002067u }, | |
| 285 | { 5370530955049882401u, 93229259140002584u }, { 6713163693812353001u, 116536573925003230u }, | |
| 286 | { 18030785363914884337u, 72835358703127018u }, { 13315109668038829614u, 91044198378908773u }, | |
| 287 | { 2808829029766373305u, 113805247973635967u }, { 17346094342490130344u, 142256559967044958u }, | |
| 288 | { 6229622945628943561u, 88910349979403099u }, { 3175342663608791547u, 111137937474253874u }, | |
| 289 | { 13192550366365765242u, 138922421842817342u }, { 3633657960551215372u, 86826513651760839u }, | |
| 290 | { 18377130505971182927u, 108533142064701048u }, { 4524669058754427043u, 135666427580876311u }, | |
| 291 | { 9745447189362598758u, 84791517238047694u }, { 2958436949848472639u, 105989396547559618u }, | |
| 292 | { 12921418224165366607u, 132486745684449522u }, { 12687572408530742033u, 82804216052780951u }, | |
| 293 | { 11247779492236039638u, 103505270065976189u }, { 224666310012885835u, 129381587582470237u }, | |
| 294 | { 2446259452971747599u, 80863492239043898u }, { 12281196353069460307u, 101079365298804872u }, | |
| 295 | { 15351495441336825384u, 126349206623506090u }, { 14206370669262903769u, 78968254139691306u }, | |
| 296 | { 8534591299723853903u, 98710317674614133u }, { 15279925143082205283u, 123387897093267666u }, | |
| 297 | { 14161639232853766206u, 77117435683292291u }, { 13090363022639819853u, 96396794604115364u }, | |
| 298 | { 16362953778299774816u, 120495993255144205u }, { 12532689120651053212u, 75309995784465128u }, | |
| 299 | { 15665861400813816515u, 94137494730581410u }, { 10358954714162494836u, 117671868413226763u }, | |
| 300 | { 4168503687137865320u, 73544917758266727u }, { 598943590494943747u, 91931147197833409u }, | |
| 301 | { 5360365506546067587u, 114913933997291761u }, { 11312142901609972388u, 143642417496614701u }, | |
| 302 | { 9375932322719926695u, 89776510935384188u }, { 11719915403399908368u, 112220638669230235u }, | |
| 303 | { 10038208235822497557u, 140275798336537794u }, { 10885566165816448877u, 87672373960336121u }, | |
| 304 | { 18218643725697949000u, 109590467450420151u }, { 18161618638695048346u, 136988084313025189u }, | |
| 305 | { 13656854658398099168u, 85617552695640743u }, { 12459382304570236056u, 107021940869550929u }, | |
| 306 | { 1739169825430631358u, 133777426086938662u }, { 14922039196176308311u, 83610891304336663u }, | |
| 307 | { 14040862976792997485u, 104513614130420829u }, { 3716020665709083144u, 130642017663026037u }, | |
| 308 | { 4628355925281870917u, 81651261039391273u }, { 10397130925029726550u, 102064076299239091u }, | |
| 309 | { 8384727637859770284u, 127580095374048864u }, { 5240454773662356427u, 79737559608780540u }, | |
| 310 | { 6550568467077945534u, 99671949510975675u }, { 3576524565420044014u, 124589936888719594u }, | |
| 311 | { 6847013871814915412u, 77868710555449746u }, { 17782139376623420074u, 97335888194312182u }, | |
| 312 | { 13004302183924499284u, 121669860242890228u }, { 17351060901807587860u, 76043662651806392u }, | |
| 313 | { 3242082053549933210u, 95054578314757991u }, { 17887660622219580224u, 118818222893447488u }, | |
| 314 | { 11179787888887237640u, 74261389308404680u }, { 13974734861109047050u, 92826736635505850u }, | |
| 315 | { 8245046539531533005u, 116033420794382313u }, { 16682369133275677888u, 72520887996488945u }, | |
| 316 | { 7017903361312433648u, 90651109995611182u }, { 17995751238495317868u, 113313887494513977u }, | |
| 317 | { 8659630992836983623u, 141642359368142472u }, { 5412269370523114764u, 88526474605089045u }, | |
| 318 | { 11377022731581281359u, 110658093256361306u }, { 4997906377621825891u, 138322616570451633u }, | |
| 319 | { 14652906532082110942u, 86451635356532270u }, { 9092761128247862869u, 108064544195665338u }, | |
| 320 | { 2142579373455052779u, 135080680244581673u }, { 12868327154477877747u, 84425425152863545u }, | |
| 321 | { 2250350887815183471u, 105531781441079432u }, { 2812938609768979339u, 131914726801349290u }, | |
| 322 | { 6369772649532999991u, 82446704250843306u }, { 17185587848771025797u, 103058380313554132u }, | |
| 323 | { 3035240737254230630u, 128822975391942666u }, { 6508711479211282048u, 80514359619964166u }, | |
| 324 | { 17359261385868878368u, 100642949524955207u }, { 17087390713908710056u, 125803686906194009u }, | |
| 325 | { 3762090168551861929u, 78627304316371256u }, { 4702612710689827411u, 98284130395464070u }, | |
| 326 | { 15101637925217060072u, 122855162994330087u }, { 16356052730901744401u, 76784476871456304u }, | |
| 327 | { 1998321839917628885u, 95980596089320381u }, { 7109588318324424010u, 119975745111650476u }, | |
| 328 | { 13666864735807540814u, 74984840694781547u }, { 12471894901332038114u, 93731050868476934u }, | |
| 329 | { 6366496589810271835u, 117163813585596168u }, { 3979060368631419896u, 73227383490997605u }, | |
| 330 | { 9585511479216662775u, 91534229363747006u }, { 2758517312166052660u, 114417786704683758u }, | |
| 331 | { 12671518677062341634u, 143022233380854697u }, { 1002170145522881665u, 89388895863034186u }, | |
| 332 | { 10476084718758377889u, 111736119828792732u }, { 13095105898447972362u, 139670149785990915u }, | |
| 333 | { 5878598177316288774u, 87293843616244322u }, { 16571619758500136775u, 109117304520305402u }, | |
| 334 | { 11491152661270395161u, 136396630650381753u }, { 264441385652915120u, 85247894156488596u }, | |
| 335 | { 330551732066143900u, 106559867695610745u }, { 5024875683510067779u, 133199834619513431u }, | |
| 336 | { 10058076329834874218u, 83249896637195894u }, { 3349223375438816964u, 104062370796494868u }, | |
| 337 | { 4186529219298521205u, 130077963495618585u }, { 14145795808130045513u, 81298727184761615u }, | |
| 338 | { 13070558741735168987u, 101623408980952019u }, { 11726512408741573330u, 127029261226190024u }, | |
| 339 | { 7329070255463483331u, 79393288266368765u }, { 13773023837756742068u, 99241610332960956u }, | |
| 340 | { 17216279797195927585u, 124052012916201195u }, { 8454331864033760789u, 77532508072625747u }, | |
| 341 | { 5956228811614813082u, 96915635090782184u }, { 7445286014518516353u, 121144543863477730u }, | |
| 342 | { 9264989777501460624u, 75715339914673581u }, { 16192923240304213684u, 94644174893341976u }, | |
| 343 | { 1794409976670715490u, 118305218616677471u }, { 8039035263060279037u, 73940761635423419u }, | |
| 344 | { 5437108060397960892u, 92425952044279274u }, { 16019757112352226923u, 115532440055349092u }, | |
| 345 | { 788976158365366019u, 72207775034593183u }, { 14821278253238871236u, 90259718793241478u }, | |
| 346 | { 9303225779693813237u, 112824648491551848u }, { 11629032224617266546u, 141030810614439810u }, | |
| 347 | { 11879831158813179495u, 88144256634024881u }, { 1014730893234310657u, 110180320792531102u }, | |
| 348 | { 10491785653397664129u, 137725400990663877u }, { 8863209042587234033u, 86078375619164923u }, | |
| 349 | { 6467325284806654637u, 107597969523956154u }, { 17307528642863094104u, 134497461904945192u }, | |
| 350 | { 10817205401789433815u, 84060913690590745u }, { 18133192770664180173u, 105076142113238431u }, | |
| 351 | { 18054804944902837312u, 131345177641548039u }, { 18201782118205355176u, 82090736025967524u }, | |
| 352 | { 4305483574047142354u, 102613420032459406u }, { 14605226504413703751u, 128266775040574257u }, | |
| 353 | { 2210737537617482988u, 80166734400358911u }, { 16598479977304017447u, 100208418000448638u }, | |
| 354 | { 11524727934775246001u, 125260522500560798u }, { 2591268940807140847u, 78287826562850499u }, | |
| 355 | { 17074144231291089770u, 97859783203563123u }, { 16730994270686474309u, 122324729004453904u }, | |
| 356 | { 10456871419179046443u, 76452955627783690u }, { 3847717237119032246u, 95566194534729613u }, | |
| 357 | { 9421332564826178211u, 119457743168412016u }, { 5888332853016361382u, 74661089480257510u }, | |
| 358 | { 16583788103125227536u, 93326361850321887u }, { 16118049110479146516u, 116657952312902359u }, | |
| 359 | { 16991309721690548428u, 72911220195563974u }, { 12015765115258409727u, 91139025244454968u }, | |
| 360 | { 15019706394073012159u, 113923781555568710u }, { 9551260955736489391u, 142404726944460888u }, | |
| 361 | { 5969538097335305869u, 89002954340288055u }, { 2850236603241744433u, 111253692925360069u } | |
| 362 | }; | |
| 363 | ||
| 364 | _LIBCPP_END_NAMESPACE_STD | |
| 365 | ||
| 366 | // clang-format on | |
| 367 | ||
| 368 | #endif // _LIBCPP_SRC_INCLUDE_RYU_D2S_FULL_TABLE_H |
lib/libcxx/src/include/ryu/d2s_intrinsics.h created+257| ... | ... | @@ -0,0 +1,257 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | #if defined(_M_X64) && defined(_MSC_VER) | |
| 50 | #define _LIBCPP_INTRINSIC128 1 | |
| 51 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) { | |
| 52 | return _umul128(__a, __b, __productHi); | |
| 53 | } | |
| 54 | ||
| 55 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) { | |
| 56 | // For the __shiftright128 intrinsic, the shift value is always | |
| 57 | // modulo 64. | |
| 58 | // In the current implementation of the double-precision version | |
| 59 | // of Ryu, the shift value is always < 64. | |
| 60 | // (The shift value is in the range [49, 58].) | |
| 61 | // Check this here in case a future change requires larger shift | |
| 62 | // values. In this case this function needs to be adjusted. | |
| 63 | _LIBCPP_ASSERT(__dist < 64, ""); | |
| 64 | return __shiftright128(__lo, __hi, static_cast<unsigned char>(__dist)); | |
| 65 | } | |
| 66 | ||
| 67 | // ^^^ intrinsics available ^^^ / vvv __int128 available vvv | |
| 68 | #elif defined(__SIZEOF_INT128__) && ( \ | |
| 69 | (defined(__clang__) && !defined(_MSC_VER)) || \ | |
| 70 | (defined(__GNUC__) && !defined(__clang__) && !defined(__CUDACC__))) | |
| 71 | #define _LIBCPP_INTRINSIC128 1 | |
| 72 | // We have __uint128 support in clang or gcc | |
| 73 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) { | |
| 74 | auto __temp = __a * (unsigned __int128)__b; | |
| 75 | *__productHi = __temp >> 64; | |
| 76 | return static_cast<uint64_t>(__temp); | |
| 77 | } | |
| 78 | ||
| 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) { | |
| 80 | // In the current implementation of the double-precision version | |
| 81 | // of Ryu, the shift value is always < 64. | |
| 82 | // (The shift value is in the range [49, 58].) | |
| 83 | // Check this here in case a future change requires larger shift | |
| 84 | // values. In this case this function needs to be adjusted. | |
| 85 | _LIBCPP_ASSERT(__dist < 64, ""); | |
| 86 | auto __temp = __lo | ((unsigned __int128)__hi << 64); | |
| 87 | // For x64 128-bit shfits using the `shrd` instruction and two 64-bit | |
| 88 | // registers, the shift value is modulo 64. Thus the `& 63` is free. | |
| 89 | return static_cast<uint64_t>(__temp >> (__dist & 63)); | |
| 90 | } | |
| 91 | #else // ^^^ __int128 available ^^^ / vvv intrinsics unavailable vvv | |
| 92 | ||
| 93 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ALWAYS_INLINE uint64_t __ryu_umul128(const uint64_t __a, const uint64_t __b, uint64_t* const __productHi) { | |
| 94 | // TRANSITION, VSO-634761 | |
| 95 | // The casts here help MSVC to avoid calls to the __allmul library function. | |
| 96 | const uint32_t __aLo = static_cast<uint32_t>(__a); | |
| 97 | const uint32_t __aHi = static_cast<uint32_t>(__a >> 32); | |
| 98 | const uint32_t __bLo = static_cast<uint32_t>(__b); | |
| 99 | const uint32_t __bHi = static_cast<uint32_t>(__b >> 32); | |
| 100 | ||
| 101 | const uint64_t __b00 = static_cast<uint64_t>(__aLo) * __bLo; | |
| 102 | const uint64_t __b01 = static_cast<uint64_t>(__aLo) * __bHi; | |
| 103 | const uint64_t __b10 = static_cast<uint64_t>(__aHi) * __bLo; | |
| 104 | const uint64_t __b11 = static_cast<uint64_t>(__aHi) * __bHi; | |
| 105 | ||
| 106 | const uint32_t __b00Lo = static_cast<uint32_t>(__b00); | |
| 107 | const uint32_t __b00Hi = static_cast<uint32_t>(__b00 >> 32); | |
| 108 | ||
| 109 | const uint64_t __mid1 = __b10 + __b00Hi; | |
| 110 | const uint32_t __mid1Lo = static_cast<uint32_t>(__mid1); | |
| 111 | const uint32_t __mid1Hi = static_cast<uint32_t>(__mid1 >> 32); | |
| 112 | ||
| 113 | const uint64_t __mid2 = __b01 + __mid1Lo; | |
| 114 | const uint32_t __mid2Lo = static_cast<uint32_t>(__mid2); | |
| 115 | const uint32_t __mid2Hi = static_cast<uint32_t>(__mid2 >> 32); | |
| 116 | ||
| 117 | const uint64_t __pHi = __b11 + __mid1Hi + __mid2Hi; | |
| 118 | const uint64_t __pLo = (static_cast<uint64_t>(__mid2Lo) << 32) | __b00Lo; | |
| 119 | ||
| 120 | *__productHi = __pHi; | |
| 121 | return __pLo; | |
| 122 | } | |
| 123 | ||
| 124 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __ryu_shiftright128(const uint64_t __lo, const uint64_t __hi, const uint32_t __dist) { | |
| 125 | // We don't need to handle the case __dist >= 64 here (see above). | |
| 126 | _LIBCPP_ASSERT(__dist < 64, ""); | |
| 127 | #ifdef _LIBCPP_64_BIT | |
| 128 | _LIBCPP_ASSERT(__dist > 0, ""); | |
| 129 | return (__hi << (64 - __dist)) | (__lo >> __dist); | |
| 130 | #else // ^^^ 64-bit ^^^ / vvv 32-bit vvv | |
| 131 | // Avoid a 64-bit shift by taking advantage of the range of shift values. | |
| 132 | _LIBCPP_ASSERT(__dist >= 32, ""); | |
| 133 | return (__hi << (64 - __dist)) | (static_cast<uint32_t>(__lo >> 32) >> (__dist - 32)); | |
| 134 | #endif // ^^^ 32-bit ^^^ | |
| 135 | } | |
| 136 | ||
| 137 | #endif // ^^^ intrinsics unavailable ^^^ | |
| 138 | ||
| 139 | #ifndef _LIBCPP_64_BIT | |
| 140 | ||
| 141 | // Returns the high 64 bits of the 128-bit product of __a and __b. | |
| 142 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __umulh(const uint64_t __a, const uint64_t __b) { | |
| 143 | // Reuse the __ryu_umul128 implementation. | |
| 144 | // Optimizers will likely eliminate the instructions used to compute the | |
| 145 | // low part of the product. | |
| 146 | uint64_t __hi; | |
| 147 | (void) __ryu_umul128(__a, __b, &__hi); | |
| 148 | return __hi; | |
| 149 | } | |
| 150 | ||
| 151 | // On 32-bit platforms, compilers typically generate calls to library | |
| 152 | // functions for 64-bit divisions, even if the divisor is a constant. | |
| 153 | // | |
| 154 | // TRANSITION, LLVM-37932 | |
| 155 | // | |
| 156 | // The functions here perform division-by-constant using multiplications | |
| 157 | // in the same way as 64-bit compilers would do. | |
| 158 | // | |
| 159 | // NB: | |
| 160 | // The multipliers and shift values are the ones generated by clang x64 | |
| 161 | // for expressions like x/5, x/10, etc. | |
| 162 | ||
| 163 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div5(const uint64_t __x) { | |
| 164 | return __umulh(__x, 0xCCCCCCCCCCCCCCCDu) >> 2; | |
| 165 | } | |
| 166 | ||
| 167 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div10(const uint64_t __x) { | |
| 168 | return __umulh(__x, 0xCCCCCCCCCCCCCCCDu) >> 3; | |
| 169 | } | |
| 170 | ||
| 171 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div100(const uint64_t __x) { | |
| 172 | return __umulh(__x >> 2, 0x28F5C28F5C28F5C3u) >> 2; | |
| 173 | } | |
| 174 | ||
| 175 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e8(const uint64_t __x) { | |
| 176 | return __umulh(__x, 0xABCC77118461CEFDu) >> 26; | |
| 177 | } | |
| 178 | ||
| 179 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e9(const uint64_t __x) { | |
| 180 | return __umulh(__x >> 9, 0x44B82FA09B5A53u) >> 11; | |
| 181 | } | |
| 182 | ||
| 183 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mod1e9(const uint64_t __x) { | |
| 184 | // Avoid 64-bit math as much as possible. | |
| 185 | // Returning static_cast<uint32_t>(__x - 1000000000 * __div1e9(__x)) would | |
| 186 | // perform 32x64-bit multiplication and 64-bit subtraction. | |
| 187 | // __x and 1000000000 * __div1e9(__x) are guaranteed to differ by | |
| 188 | // less than 10^9, so their highest 32 bits must be identical, | |
| 189 | // so we can truncate both sides to uint32_t before subtracting. | |
| 190 | // We can also simplify static_cast<uint32_t>(1000000000 * __div1e9(__x)). | |
| 191 | // We can truncate before multiplying instead of after, as multiplying | |
| 192 | // the highest 32 bits of __div1e9(__x) can't affect the lowest 32 bits. | |
| 193 | return static_cast<uint32_t>(__x) - 1000000000 * static_cast<uint32_t>(__div1e9(__x)); | |
| 194 | } | |
| 195 | ||
| 196 | #else // ^^^ 32-bit ^^^ / vvv 64-bit vvv | |
| 197 | ||
| 198 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div5(const uint64_t __x) { | |
| 199 | return __x / 5; | |
| 200 | } | |
| 201 | ||
| 202 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div10(const uint64_t __x) { | |
| 203 | return __x / 10; | |
| 204 | } | |
| 205 | ||
| 206 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div100(const uint64_t __x) { | |
| 207 | return __x / 100; | |
| 208 | } | |
| 209 | ||
| 210 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e8(const uint64_t __x) { | |
| 211 | return __x / 100000000; | |
| 212 | } | |
| 213 | ||
| 214 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __div1e9(const uint64_t __x) { | |
| 215 | return __x / 1000000000; | |
| 216 | } | |
| 217 | ||
| 218 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mod1e9(const uint64_t __x) { | |
| 219 | return static_cast<uint32_t>(__x - 1000000000 * __div1e9(__x)); | |
| 220 | } | |
| 221 | ||
| 222 | #endif // ^^^ 64-bit ^^^ | |
| 223 | ||
| 224 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow5Factor(uint64_t __value) { | |
| 225 | uint32_t __count = 0; | |
| 226 | for (;;) { | |
| 227 | _LIBCPP_ASSERT(__value != 0, ""); | |
| 228 | const uint64_t __q = __div5(__value); | |
| 229 | const uint32_t __r = static_cast<uint32_t>(__value) - 5 * static_cast<uint32_t>(__q); | |
| 230 | if (__r != 0) { | |
| 231 | break; | |
| 232 | } | |
| 233 | __value = __q; | |
| 234 | ++__count; | |
| 235 | } | |
| 236 | return __count; | |
| 237 | } | |
| 238 | ||
| 239 | // Returns true if __value is divisible by 5^__p. | |
| 240 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf5(const uint64_t __value, const uint32_t __p) { | |
| 241 | // I tried a case distinction on __p, but there was no performance difference. | |
| 242 | return __pow5Factor(__value) >= __p; | |
| 243 | } | |
| 244 | ||
| 245 | // Returns true if __value is divisible by 2^__p. | |
| 246 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf2(const uint64_t __value, const uint32_t __p) { | |
| 247 | _LIBCPP_ASSERT(__value != 0, ""); | |
| 248 | _LIBCPP_ASSERT(__p < 64, ""); | |
| 249 | // __builtin_ctzll doesn't appear to be faster here. | |
| 250 | return (__value & ((1ull << __p) - 1)) == 0; | |
| 251 | } | |
| 252 | ||
| 253 | _LIBCPP_END_NAMESPACE_STD | |
| 254 | ||
| 255 | // clang-format on | |
| 256 | ||
| 257 | #endif // _LIBCPP_SRC_INCLUDE_RYU_DS2_INTRINSICS_H |
lib/libcxx/src/include/ryu/digit_table.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 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | // 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. | |
| 51 | inline constexpr char __DIGIT_TABLE[200] = { | |
| 52 | '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9', | |
| 53 | '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9', | |
| 54 | '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9', | |
| 55 | '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9', | |
| 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 | }; | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | |
| 65 | ||
| 66 | // clang-format on | |
| 67 | ||
| 68 | #endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H |
lib/libcxx/src/include/ryu/f2s.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 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_FS2_H | |
| 40 | #define _LIBCPP_SRC_INCLUDE_RYU_FS2_H | |
| 41 | ||
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 46 | ||
| 47 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 48 | ||
| 49 | [[nodiscard]] to_chars_result __f2s_buffered_n(char* const _First, char* const _Last, const float __f, const chars_format _Fmt); | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | // clang-format on | |
| 54 | ||
| 55 | #endif // _LIBCPP_SRC_INCLUDE_RYU_FS2_H |
lib/libcxx/src/include/ryu/ryu.h created+148| ... | ... | @@ -0,0 +1,148 @@ |
| 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 | // Copyright (c) Microsoft Corporation. | |
| 11 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 12 | ||
| 13 | ||
| 14 | // Copyright 2018 Ulf Adams | |
| 15 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 16 | ||
| 17 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 18 | ||
| 19 | // Permission is hereby granted, free of charge, to any person or organization | |
| 20 | // obtaining a copy of the software and accompanying documentation covered by | |
| 21 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 22 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 23 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 24 | // do so, all subject to the following: | |
| 25 | ||
| 26 | // The copyright notices in the Software and this entire statement, including | |
| 27 | // the above license grant, this restriction and the following disclaimer, | |
| 28 | // must be included in all copies of the Software, in whole or in part, and | |
| 29 | // all derivative works of the Software, unless such copies or derivative | |
| 30 | // works are solely in the form of machine-executable object code generated by | |
| 31 | // a source language processor. | |
| 32 | ||
| 33 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 34 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 35 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 36 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 37 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 38 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 39 | // DEALINGS IN THE SOFTWARE. | |
| 40 | ||
| 41 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_RYU_H | |
| 42 | #define _LIBCPP_SRC_INCLUDE_RYU_RYU_H | |
| 43 | ||
| 44 | // Avoid formatting to keep the changes with the original code minimal. | |
| 45 | // clang-format off | |
| 46 | ||
| 47 | #include "__charconv/chars_format.h" | |
| 48 | #include "__charconv/to_chars_result.h" | |
| 49 | #include "__config" | |
| 50 | #include "__debug" | |
| 51 | #include "__errc" | |
| 52 | #include "cstdint" | |
| 53 | #include "cstring" | |
| 54 | #include "type_traits" | |
| 55 | #include "include/ryu/f2s.h" | |
| 56 | #include "include/ryu/d2s.h" | |
| 57 | #include "include/ryu/d2fixed.h" | |
| 58 | ||
| 59 | #if defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC) | |
| 60 | #include <intrin0.h> // for _umul128() and __shiftright128() | |
| 61 | #endif // defined(_M_X64) && defined(_LIBCPP_COMPILER_MSVC) | |
| 62 | ||
| 63 | #if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__) | |
| 64 | #define _LIBCPP_64_BIT | |
| 65 | #endif | |
| 66 | ||
| 67 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 68 | ||
| 69 | // https://github.com/ulfjack/ryu/tree/59661c3/ryu | |
| 70 | ||
| 71 | #if !defined(_LIBCPP_COMPILER_MSVC) | |
| 72 | _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) { | |
| 73 | if (__mask == 0) { | |
| 74 | return false; | |
| 75 | } | |
| 76 | *__index = __builtin_ctzll(__mask); | |
| 77 | return true; | |
| 78 | } | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __index, unsigned int __mask) { | |
| 81 | if (__mask == 0) { | |
| 82 | return false; | |
| 83 | } | |
| 84 | *__index = __builtin_ctz(__mask); | |
| 85 | return true; | |
| 86 | } | |
| 87 | #endif // _LIBCPP_COMPILER_MSVC | |
| 88 | ||
| 89 | template <class _Floating> | |
| 90 | [[nodiscard]] to_chars_result _Floating_to_chars_ryu( | |
| 91 | char* const _First, char* const _Last, const _Floating _Value, const chars_format _Fmt) noexcept { | |
| 92 | if constexpr (_IsSame<_Floating, float>::value) { | |
| 93 | return __f2s_buffered_n(_First, _Last, _Value, _Fmt); | |
| 94 | } else { | |
| 95 | return __d2s_buffered_n(_First, _Last, _Value, _Fmt); | |
| 96 | } | |
| 97 | } | |
| 98 | ||
| 99 | template <class _Floating> | |
| 100 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI to_chars_result _Floating_to_chars_scientific_precision( | |
| 101 | char* const _First, char* const _Last, const _Floating _Value, int _Precision) noexcept { | |
| 102 | ||
| 103 | // C11 7.21.6.1 "The fprintf function"/5: | |
| 104 | // "A negative precision argument is taken as if the precision were omitted." | |
| 105 | // /8: "e,E [...] if the precision is missing, it is taken as 6" | |
| 106 | ||
| 107 | if (_Precision < 0) { | |
| 108 | _Precision = 6; | |
| 109 | } else if (_Precision < 1'000'000'000) { // Match ' to fix compilation with GCC in C++11 mode | |
| 110 | // _Precision is ok. | |
| 111 | } else { | |
| 112 | // Avoid integer overflow. | |
| 113 | // (This defensive check is slightly nonconformant; it can be carefully improved in the future.) | |
| 114 | return {_Last, errc::value_too_large}; | |
| 115 | } | |
| 116 | ||
| 117 | return __d2exp_buffered_n(_First, _Last, _Value, static_cast<uint32_t>(_Precision)); | |
| 118 | } | |
| 119 | ||
| 120 | template <class _Floating> | |
| 121 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI to_chars_result _Floating_to_chars_fixed_precision( | |
| 122 | char* const _First, char* const _Last, const _Floating _Value, int _Precision) noexcept { | |
| 123 | ||
| 124 | // C11 7.21.6.1 "The fprintf function"/5: | |
| 125 | // "A negative precision argument is taken as if the precision were omitted." | |
| 126 | // /8: "f,F [...] If the precision is missing, it is taken as 6" | |
| 127 | ||
| 128 | if (_Precision < 0) { | |
| 129 | _Precision = 6; | |
| 130 | } else if (_Precision < 1'000'000'000) { // Match ' to fix compilation with GCC in C++11 mode | |
| 131 | // _Precision is ok. | |
| 132 | } else { | |
| 133 | // Avoid integer overflow. | |
| 134 | // (This defensive check is slightly nonconformant; it can be carefully improved in the future.) | |
| 135 | return {_Last, errc::value_too_large}; | |
| 136 | } | |
| 137 | ||
| 138 | return __d2fixed_buffered_n(_First, _Last, _Value, static_cast<uint32_t>(_Precision)); | |
| 139 | } | |
| 140 | ||
| 141 | #undef _LIBCPP_64_BIT | |
| 142 | #undef _LIBCPP_INTRINSIC128 | |
| 143 | ||
| 144 | _LIBCPP_END_NAMESPACE_STD | |
| 145 | ||
| 146 | // clang-format on | |
| 147 | ||
| 148 | #endif // _LIBCPP_SRC_INCLUDE_RYU_RYU_H |
lib/libcxx/src/include/to_chars_floating_point.h created+1076| ... | ... | @@ -0,0 +1,1076 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // This implementation is dedicated to the memory of Mary and Thavatchai. | |
| 13 | ||
| 14 | #ifndef _LIBCPP_SRC_INCLUDE_TO_CHARS_FLOATING_POINT_H | |
| 15 | #define _LIBCPP_SRC_INCLUDE_TO_CHARS_FLOATING_POINT_H | |
| 16 | ||
| 17 | // Avoid formatting to keep the changes with the original code minimal. | |
| 18 | // clang-format off | |
| 19 | ||
| 20 | #include "__algorithm/find.h" | |
| 21 | #include "__algorithm/find_if.h" | |
| 22 | #include "__algorithm/lower_bound.h" | |
| 23 | #include "__algorithm/min.h" | |
| 24 | #include "__config" | |
| 25 | #include "__iterator/access.h" | |
| 26 | #include "__iterator/size.h" | |
| 27 | #include "bit" | |
| 28 | #include "cfloat" | |
| 29 | #include "climits" | |
| 30 | #include "include/ryu/ryu.h" | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace __itoa { | |
| 35 | inline constexpr char _Charconv_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', | |
| 36 | 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; | |
| 37 | static_assert(_VSTD::size(_Charconv_digits) == 36); | |
| 38 | } // __itoa | |
| 39 | ||
| 40 | // vvvvvvvvvv DERIVED FROM corecrt_internal_fltintrn.h vvvvvvvvvv | |
| 41 | ||
| 42 | template <class _FloatingType> | |
| 43 | struct _Floating_type_traits; | |
| 44 | ||
| 45 | template <> | |
| 46 | struct _Floating_type_traits<float> { | |
| 47 | static constexpr int32_t _Mantissa_bits = FLT_MANT_DIG; | |
| 48 | static constexpr int32_t _Exponent_bits = sizeof(float) * CHAR_BIT - FLT_MANT_DIG; | |
| 49 | ||
| 50 | static constexpr int32_t _Maximum_binary_exponent = FLT_MAX_EXP - 1; | |
| 51 | static constexpr int32_t _Minimum_binary_exponent = FLT_MIN_EXP - 1; | |
| 52 | ||
| 53 | static constexpr int32_t _Exponent_bias = 127; | |
| 54 | ||
| 55 | static constexpr int32_t _Sign_shift = _Exponent_bits + _Mantissa_bits - 1; | |
| 56 | static constexpr int32_t _Exponent_shift = _Mantissa_bits - 1; | |
| 57 | ||
| 58 | using _Uint_type = uint32_t; | |
| 59 | ||
| 60 | static constexpr uint32_t _Exponent_mask = (1u << _Exponent_bits) - 1; | |
| 61 | static constexpr uint32_t _Normal_mantissa_mask = (1u << _Mantissa_bits) - 1; | |
| 62 | static constexpr uint32_t _Denormal_mantissa_mask = (1u << (_Mantissa_bits - 1)) - 1; | |
| 63 | static constexpr uint32_t _Special_nan_mantissa_mask = 1u << (_Mantissa_bits - 2); | |
| 64 | static constexpr uint32_t _Shifted_sign_mask = 1u << _Sign_shift; | |
| 65 | static constexpr uint32_t _Shifted_exponent_mask = _Exponent_mask << _Exponent_shift; | |
| 66 | }; | |
| 67 | ||
| 68 | template <> | |
| 69 | struct _Floating_type_traits<double> { | |
| 70 | static constexpr int32_t _Mantissa_bits = DBL_MANT_DIG; | |
| 71 | static constexpr int32_t _Exponent_bits = sizeof(double) * CHAR_BIT - DBL_MANT_DIG; | |
| 72 | ||
| 73 | static constexpr int32_t _Maximum_binary_exponent = DBL_MAX_EXP - 1; | |
| 74 | static constexpr int32_t _Minimum_binary_exponent = DBL_MIN_EXP - 1; | |
| 75 | ||
| 76 | static constexpr int32_t _Exponent_bias = 1023; | |
| 77 | ||
| 78 | static constexpr int32_t _Sign_shift = _Exponent_bits + _Mantissa_bits - 1; | |
| 79 | static constexpr int32_t _Exponent_shift = _Mantissa_bits - 1; | |
| 80 | ||
| 81 | using _Uint_type = uint64_t; | |
| 82 | ||
| 83 | static constexpr uint64_t _Exponent_mask = (1ULL << _Exponent_bits) - 1; | |
| 84 | static constexpr uint64_t _Normal_mantissa_mask = (1ULL << _Mantissa_bits) - 1; | |
| 85 | static constexpr uint64_t _Denormal_mantissa_mask = (1ULL << (_Mantissa_bits - 1)) - 1; | |
| 86 | static constexpr uint64_t _Special_nan_mantissa_mask = 1ULL << (_Mantissa_bits - 2); | |
| 87 | static constexpr uint64_t _Shifted_sign_mask = 1ULL << _Sign_shift; | |
| 88 | static constexpr uint64_t _Shifted_exponent_mask = _Exponent_mask << _Exponent_shift; | |
| 89 | }; | |
| 90 | ||
| 91 | // ^^^^^^^^^^ DERIVED FROM corecrt_internal_fltintrn.h ^^^^^^^^^^ | |
| 92 | ||
| 93 | // FUNCTION to_chars (FLOATING-POINT TO STRING) | |
| 94 | template <class _Floating> | |
| 95 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 96 | to_chars_result _Floating_to_chars_hex_precision( | |
| 97 | char* _First, char* const _Last, const _Floating _Value, int _Precision) noexcept { | |
| 98 | ||
| 99 | // * Determine the effective _Precision. | |
| 100 | // * Later, we'll decrement _Precision when printing each hexit after the decimal point. | |
| 101 | ||
| 102 | // The hexits after the decimal point correspond to the explicitly stored fraction bits. | |
| 103 | // float explicitly stores 23 fraction bits. 23 / 4 == 5.75, which is 6 hexits. | |
| 104 | // double explicitly stores 52 fraction bits. 52 / 4 == 13, which is 13 hexits. | |
| 105 | constexpr int _Full_precision = _IsSame<_Floating, float>::value ? 6 : 13; | |
| 106 | constexpr int _Adjusted_explicit_bits = _Full_precision * 4; | |
| 107 | ||
| 108 | if (_Precision < 0) { | |
| 109 | // C11 7.21.6.1 "The fprintf function"/5: "A negative precision argument is taken as if the precision were | |
| 110 | // omitted." /8: "if the precision is missing and FLT_RADIX is a power of 2, then the precision is sufficient | |
| 111 | // for an exact representation of the value" | |
| 112 | _Precision = _Full_precision; | |
| 113 | } | |
| 114 | ||
| 115 | // * Extract the _Ieee_mantissa and _Ieee_exponent. | |
| 116 | using _Traits = _Floating_type_traits<_Floating>; | |
| 117 | using _Uint_type = typename _Traits::_Uint_type; | |
| 118 | ||
| 119 | const _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value); | |
| 120 | const _Uint_type _Ieee_mantissa = _Uint_value & _Traits::_Denormal_mantissa_mask; | |
| 121 | const int32_t _Ieee_exponent = static_cast<int32_t>(_Uint_value >> _Traits::_Exponent_shift); | |
| 122 | ||
| 123 | // * Prepare the _Adjusted_mantissa. This is aligned to hexit boundaries, | |
| 124 | // * with the implicit bit restored (0 for zero values and subnormal values, 1 for normal values). | |
| 125 | // * Also calculate the _Unbiased_exponent. This unifies the processing of zero, subnormal, and normal values. | |
| 126 | _Uint_type _Adjusted_mantissa; | |
| 127 | ||
| 128 | if constexpr (_IsSame<_Floating, float>::value) { | |
| 129 | _Adjusted_mantissa = _Ieee_mantissa << 1; // align to hexit boundary (23 isn't divisible by 4) | |
| 130 | } else { | |
| 131 | _Adjusted_mantissa = _Ieee_mantissa; // already aligned (52 is divisible by 4) | |
| 132 | } | |
| 133 | ||
| 134 | int32_t _Unbiased_exponent; | |
| 135 | ||
| 136 | if (_Ieee_exponent == 0) { // zero or subnormal | |
| 137 | // implicit bit is 0 | |
| 138 | ||
| 139 | if (_Ieee_mantissa == 0) { // zero | |
| 140 | // C11 7.21.6.1 "The fprintf function"/8: "If the value is zero, the exponent is zero." | |
| 141 | _Unbiased_exponent = 0; | |
| 142 | } else { // subnormal | |
| 143 | _Unbiased_exponent = 1 - _Traits::_Exponent_bias; | |
| 144 | } | |
| 145 | } else { // normal | |
| 146 | _Adjusted_mantissa |= _Uint_type{1} << _Adjusted_explicit_bits; // implicit bit is 1 | |
| 147 | _Unbiased_exponent = _Ieee_exponent - _Traits::_Exponent_bias; | |
| 148 | } | |
| 149 | ||
| 150 | // _Unbiased_exponent is within [-126, 127] for float, [-1022, 1023] for double. | |
| 151 | ||
| 152 | // * Decompose _Unbiased_exponent into _Sign_character and _Absolute_exponent. | |
| 153 | char _Sign_character; | |
| 154 | uint32_t _Absolute_exponent; | |
| 155 | ||
| 156 | if (_Unbiased_exponent < 0) { | |
| 157 | _Sign_character = '-'; | |
| 158 | _Absolute_exponent = static_cast<uint32_t>(-_Unbiased_exponent); | |
| 159 | } else { | |
| 160 | _Sign_character = '+'; | |
| 161 | _Absolute_exponent = static_cast<uint32_t>(_Unbiased_exponent); | |
| 162 | } | |
| 163 | ||
| 164 | // _Absolute_exponent is within [0, 127] for float, [0, 1023] for double. | |
| 165 | ||
| 166 | // * Perform a single bounds check. | |
| 167 | { | |
| 168 | int32_t _Exponent_length; | |
| 169 | ||
| 170 | if (_Absolute_exponent < 10) { | |
| 171 | _Exponent_length = 1; | |
| 172 | } else if (_Absolute_exponent < 100) { | |
| 173 | _Exponent_length = 2; | |
| 174 | } else if constexpr (_IsSame<_Floating, float>::value) { | |
| 175 | _Exponent_length = 3; | |
| 176 | } else if (_Absolute_exponent < 1000) { | |
| 177 | _Exponent_length = 3; | |
| 178 | } else { | |
| 179 | _Exponent_length = 4; | |
| 180 | } | |
| 181 | ||
| 182 | // _Precision might be enormous; avoid integer overflow by testing it separately. | |
| 183 | ptrdiff_t _Buffer_size = _Last - _First; | |
| 184 | ||
| 185 | if (_Buffer_size < _Precision) { | |
| 186 | return {_Last, errc::value_too_large}; | |
| 187 | } | |
| 188 | ||
| 189 | _Buffer_size -= _Precision; | |
| 190 | ||
| 191 | const int32_t _Length_excluding_precision = 1 // leading hexit | |
| 192 | + static_cast<int32_t>(_Precision > 0) // possible decimal point | |
| 193 | // excluding `+ _Precision`, hexits after decimal point | |
| 194 | + 2 // "p+" or "p-" | |
| 195 | + _Exponent_length; // exponent | |
| 196 | ||
| 197 | if (_Buffer_size < _Length_excluding_precision) { | |
| 198 | return {_Last, errc::value_too_large}; | |
| 199 | } | |
| 200 | } | |
| 201 | ||
| 202 | // * Perform rounding when we've been asked to omit hexits. | |
| 203 | if (_Precision < _Full_precision) { | |
| 204 | // _Precision is within [0, 5] for float, [0, 12] for double. | |
| 205 | ||
| 206 | // _Dropped_bits is within [4, 24] for float, [4, 52] for double. | |
| 207 | const int _Dropped_bits = (_Full_precision - _Precision) * 4; | |
| 208 | ||
| 209 | // Perform rounding by adding an appropriately-shifted bit. | |
| 210 | ||
| 211 | // This can propagate carries all the way into the leading hexit. Examples: | |
| 212 | // "0.ff9" rounded to a precision of 2 is "1.00". | |
| 213 | // "1.ff9" rounded to a precision of 2 is "2.00". | |
| 214 | ||
| 215 | // Note that the leading hexit participates in the rounding decision. Examples: | |
| 216 | // "0.8" rounded to a precision of 0 is "0". | |
| 217 | // "1.8" rounded to a precision of 0 is "2". | |
| 218 | ||
| 219 | // Reference implementation with suboptimal codegen: | |
| 220 | // bool _Should_round_up(bool _Lsb_bit, bool _Round_bit, bool _Has_tail_bits) { | |
| 221 | // // If there are no insignificant set bits, the value is exactly-representable and should not be rounded. | |
| 222 | // // | |
| 223 | // // If there are insignificant set bits, we need to round according to round_to_nearest. | |
| 224 | // // We need to handle two cases: we round up if either [1] the value is slightly greater | |
| 225 | // // than the midpoint between two exactly-representable values or [2] the value is exactly the midpoint | |
| 226 | // // between two exactly-representable values and the greater of the two is even (this is "round-to-even"). | |
| 227 | // return _Round_bit && (_Has_tail_bits || _Lsb_bit); | |
| 228 | //} | |
| 229 | // const bool _Lsb_bit = (_Adjusted_mantissa & (_Uint_type{1} << _Dropped_bits)) != 0; | |
| 230 | // const bool _Round_bit = (_Adjusted_mantissa & (_Uint_type{1} << (_Dropped_bits - 1))) != 0; | |
| 231 | // const bool _Has_tail_bits = (_Adjusted_mantissa & ((_Uint_type{1} << (_Dropped_bits - 1)) - 1)) != 0; | |
| 232 | // const bool _Should_round = _Should_round_up(_Lsb_bit, _Round_bit, _Has_tail_bits); | |
| 233 | // _Adjusted_mantissa += _Uint_type{_Should_round} << _Dropped_bits; | |
| 234 | ||
| 235 | // Example for optimized implementation: Let _Dropped_bits be 8. | |
| 236 | // Bit index: ...[8]76543210 | |
| 237 | // _Adjusted_mantissa: ...[L]RTTTTTTT (not depicting known details, like hexit alignment) | |
| 238 | // By focusing on the bit at index _Dropped_bits, we can avoid unnecessary branching and shifting. | |
| 239 | ||
| 240 | // Bit index: ...[8]76543210 | |
| 241 | // _Lsb_bit: ...[L]RTTTTTTT | |
| 242 | const _Uint_type _Lsb_bit = _Adjusted_mantissa; | |
| 243 | ||
| 244 | // Bit index: ...9[8]76543210 | |
| 245 | // _Round_bit: ...L[R]TTTTTTT0 | |
| 246 | const _Uint_type _Round_bit = _Adjusted_mantissa << 1; | |
| 247 | ||
| 248 | // We can detect (without branching) whether any of the trailing bits are set. | |
| 249 | // Due to _Should_round below, this computation will be used if and only if R is 1, so we can assume that here. | |
| 250 | // Bit index: ...9[8]76543210 | |
| 251 | // _Round_bit: ...L[1]TTTTTTT0 | |
| 252 | // _Has_tail_bits: ....[H]........ | |
| 253 | ||
| 254 | // If all of the trailing bits T are 0, then `_Round_bit - 1` will produce 0 for H (due to R being 1). | |
| 255 | // If any of the trailing bits T are 1, then `_Round_bit - 1` will produce 1 for H (due to R being 1). | |
| 256 | const _Uint_type _Has_tail_bits = _Round_bit - 1; | |
| 257 | ||
| 258 | // Finally, we can use _Should_round_up() logic with bitwise-AND and bitwise-OR, | |
| 259 | // selecting just the bit at index _Dropped_bits. This is the appropriately-shifted bit that we want. | |
| 260 | const _Uint_type _Should_round = _Round_bit & (_Has_tail_bits | _Lsb_bit) & (_Uint_type{1} << _Dropped_bits); | |
| 261 | ||
| 262 | // This rounding technique is dedicated to the memory of Peppermint. =^..^= | |
| 263 | _Adjusted_mantissa += _Should_round; | |
| 264 | } | |
| 265 | ||
| 266 | // * Print the leading hexit, then mask it away. | |
| 267 | { | |
| 268 | const uint32_t _Nibble = static_cast<uint32_t>(_Adjusted_mantissa >> _Adjusted_explicit_bits); | |
| 269 | _LIBCPP_ASSERT(_Nibble < 3, ""); | |
| 270 | const char _Leading_hexit = static_cast<char>('0' + _Nibble); | |
| 271 | ||
| 272 | *_First++ = _Leading_hexit; | |
| 273 | ||
| 274 | constexpr _Uint_type _Mask = (_Uint_type{1} << _Adjusted_explicit_bits) - 1; | |
| 275 | _Adjusted_mantissa &= _Mask; | |
| 276 | } | |
| 277 | ||
| 278 | // * Print the decimal point and trailing hexits. | |
| 279 | ||
| 280 | // C11 7.21.6.1 "The fprintf function"/8: | |
| 281 | // "if the precision is zero and the # flag is not specified, no decimal-point character appears." | |
| 282 | if (_Precision > 0) { | |
| 283 | *_First++ = '.'; | |
| 284 | ||
| 285 | int32_t _Number_of_bits_remaining = _Adjusted_explicit_bits; // 24 for float, 52 for double | |
| 286 | ||
| 287 | for (;;) { | |
| 288 | _LIBCPP_ASSERT(_Number_of_bits_remaining >= 4, ""); | |
| 289 | _LIBCPP_ASSERT(_Number_of_bits_remaining % 4 == 0, ""); | |
| 290 | _Number_of_bits_remaining -= 4; | |
| 291 | ||
| 292 | const uint32_t _Nibble = static_cast<uint32_t>(_Adjusted_mantissa >> _Number_of_bits_remaining); | |
| 293 | _LIBCPP_ASSERT(_Nibble < 16, ""); | |
| 294 | const char _Hexit = __itoa::_Charconv_digits[_Nibble]; | |
| 295 | ||
| 296 | *_First++ = _Hexit; | |
| 297 | ||
| 298 | // _Precision is the number of hexits that still need to be printed. | |
| 299 | --_Precision; | |
| 300 | if (_Precision == 0) { | |
| 301 | break; // We're completely done with this phase. | |
| 302 | } | |
| 303 | // Otherwise, we need to keep printing hexits. | |
| 304 | ||
| 305 | if (_Number_of_bits_remaining == 0) { | |
| 306 | // We've finished printing _Adjusted_mantissa, so all remaining hexits are '0'. | |
| 307 | _VSTD::memset(_First, '0', static_cast<size_t>(_Precision)); | |
| 308 | _First += _Precision; | |
| 309 | break; | |
| 310 | } | |
| 311 | ||
| 312 | // Mask away the hexit that we just printed, then keep looping. | |
| 313 | // (We skip this when breaking out of the loop above, because _Adjusted_mantissa isn't used later.) | |
| 314 | const _Uint_type _Mask = (_Uint_type{1} << _Number_of_bits_remaining) - 1; | |
| 315 | _Adjusted_mantissa &= _Mask; | |
| 316 | } | |
| 317 | } | |
| 318 | ||
| 319 | // * Print the exponent. | |
| 320 | ||
| 321 | // C11 7.21.6.1 "The fprintf function"/8: "The exponent always contains at least one digit, and only as many more | |
| 322 | // digits as necessary to represent the decimal exponent of 2." | |
| 323 | ||
| 324 | // Performance note: We should take advantage of the known ranges of possible exponents. | |
| 325 | ||
| 326 | *_First++ = 'p'; | |
| 327 | *_First++ = _Sign_character; | |
| 328 | ||
| 329 | // We've already printed '-' if necessary, so uint32_t _Absolute_exponent avoids testing that again. | |
| 330 | return _VSTD::to_chars(_First, _Last, _Absolute_exponent); | |
| 331 | } | |
| 332 | ||
| 333 | template <class _Floating> | |
| 334 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 335 | to_chars_result _Floating_to_chars_hex_shortest( | |
| 336 | char* _First, char* const _Last, const _Floating _Value) noexcept { | |
| 337 | ||
| 338 | // This prints "1.728p+0" instead of "2.e5p-1". | |
| 339 | // This prints "0.000002p-126" instead of "1p-149" for float. | |
| 340 | // This prints "0.0000000000001p-1022" instead of "1p-1074" for double. | |
| 341 | // This prioritizes being consistent with printf's de facto behavior (and hex-precision's behavior) | |
| 342 | // over minimizing the number of characters printed. | |
| 343 | ||
| 344 | using _Traits = _Floating_type_traits<_Floating>; | |
| 345 | using _Uint_type = typename _Traits::_Uint_type; | |
| 346 | ||
| 347 | const _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value); | |
| 348 | ||
| 349 | if (_Uint_value == 0) { // zero detected; write "0p+0" and return | |
| 350 | // C11 7.21.6.1 "The fprintf function"/8: "If the value is zero, the exponent is zero." | |
| 351 | // Special-casing zero is necessary because of the exponent. | |
| 352 | const char* const _Str = "0p+0"; | |
| 353 | const size_t _Len = 4; | |
| 354 | ||
| 355 | if (_Last - _First < static_cast<ptrdiff_t>(_Len)) { | |
| 356 | return {_Last, errc::value_too_large}; | |
| 357 | } | |
| 358 | ||
| 359 | _VSTD::memcpy(_First, _Str, _Len); | |
| 360 | ||
| 361 | return {_First + _Len, errc{}}; | |
| 362 | } | |
| 363 | ||
| 364 | const _Uint_type _Ieee_mantissa = _Uint_value & _Traits::_Denormal_mantissa_mask; | |
| 365 | const int32_t _Ieee_exponent = static_cast<int32_t>(_Uint_value >> _Traits::_Exponent_shift); | |
| 366 | ||
| 367 | char _Leading_hexit; // implicit bit | |
| 368 | int32_t _Unbiased_exponent; | |
| 369 | ||
| 370 | if (_Ieee_exponent == 0) { // subnormal | |
| 371 | _Leading_hexit = '0'; | |
| 372 | _Unbiased_exponent = 1 - _Traits::_Exponent_bias; | |
| 373 | } else { // normal | |
| 374 | _Leading_hexit = '1'; | |
| 375 | _Unbiased_exponent = _Ieee_exponent - _Traits::_Exponent_bias; | |
| 376 | } | |
| 377 | ||
| 378 | // Performance note: Consider avoiding per-character bounds checking when there's plenty of space. | |
| 379 | ||
| 380 | if (_First == _Last) { | |
| 381 | return {_Last, errc::value_too_large}; | |
| 382 | } | |
| 383 | ||
| 384 | *_First++ = _Leading_hexit; | |
| 385 | ||
| 386 | if (_Ieee_mantissa == 0) { | |
| 387 | // The fraction bits are all 0. Trim them away, including the decimal point. | |
| 388 | } else { | |
| 389 | if (_First == _Last) { | |
| 390 | return {_Last, errc::value_too_large}; | |
| 391 | } | |
| 392 | ||
| 393 | *_First++ = '.'; | |
| 394 | ||
| 395 | // The hexits after the decimal point correspond to the explicitly stored fraction bits. | |
| 396 | // float explicitly stores 23 fraction bits. 23 / 4 == 5.75, so we'll print at most 6 hexits. | |
| 397 | // double explicitly stores 52 fraction bits. 52 / 4 == 13, so we'll print at most 13 hexits. | |
| 398 | _Uint_type _Adjusted_mantissa; | |
| 399 | int32_t _Number_of_bits_remaining; | |
| 400 | ||
| 401 | if constexpr (_IsSame<_Floating, float>::value) { | |
| 402 | _Adjusted_mantissa = _Ieee_mantissa << 1; // align to hexit boundary (23 isn't divisible by 4) | |
| 403 | _Number_of_bits_remaining = 24; // 23 fraction bits + 1 alignment bit | |
| 404 | } else { | |
| 405 | _Adjusted_mantissa = _Ieee_mantissa; // already aligned (52 is divisible by 4) | |
| 406 | _Number_of_bits_remaining = 52; // 52 fraction bits | |
| 407 | } | |
| 408 | ||
| 409 | // do-while: The condition _Adjusted_mantissa != 0 is initially true - we have nonzero fraction bits and we've | |
| 410 | // printed the decimal point. Each iteration, we print a hexit, mask it away, and keep looping if we still have | |
| 411 | // nonzero fraction bits. If there would be trailing '0' hexits, this trims them. If there wouldn't be trailing | |
| 412 | // '0' hexits, the same condition works (as we print the final hexit and mask it away); we don't need to test | |
| 413 | // _Number_of_bits_remaining. | |
| 414 | do { | |
| 415 | _LIBCPP_ASSERT(_Number_of_bits_remaining >= 4, ""); | |
| 416 | _LIBCPP_ASSERT(_Number_of_bits_remaining % 4 == 0, ""); | |
| 417 | _Number_of_bits_remaining -= 4; | |
| 418 | ||
| 419 | const uint32_t _Nibble = static_cast<uint32_t>(_Adjusted_mantissa >> _Number_of_bits_remaining); | |
| 420 | _LIBCPP_ASSERT(_Nibble < 16, ""); | |
| 421 | const char _Hexit = __itoa::_Charconv_digits[_Nibble]; | |
| 422 | ||
| 423 | if (_First == _Last) { | |
| 424 | return {_Last, errc::value_too_large}; | |
| 425 | } | |
| 426 | ||
| 427 | *_First++ = _Hexit; | |
| 428 | ||
| 429 | const _Uint_type _Mask = (_Uint_type{1} << _Number_of_bits_remaining) - 1; | |
| 430 | _Adjusted_mantissa &= _Mask; | |
| 431 | ||
| 432 | } while (_Adjusted_mantissa != 0); | |
| 433 | } | |
| 434 | ||
| 435 | // C11 7.21.6.1 "The fprintf function"/8: "The exponent always contains at least one digit, and only as many more | |
| 436 | // digits as necessary to represent the decimal exponent of 2." | |
| 437 | ||
| 438 | // Performance note: We should take advantage of the known ranges of possible exponents. | |
| 439 | ||
| 440 | // float: _Unbiased_exponent is within [-126, 127]. | |
| 441 | // double: _Unbiased_exponent is within [-1022, 1023]. | |
| 442 | ||
| 443 | if (_Last - _First < 2) { | |
| 444 | return {_Last, errc::value_too_large}; | |
| 445 | } | |
| 446 | ||
| 447 | *_First++ = 'p'; | |
| 448 | ||
| 449 | if (_Unbiased_exponent < 0) { | |
| 450 | *_First++ = '-'; | |
| 451 | _Unbiased_exponent = -_Unbiased_exponent; | |
| 452 | } else { | |
| 453 | *_First++ = '+'; | |
| 454 | } | |
| 455 | ||
| 456 | // We've already printed '-' if necessary, so static_cast<uint32_t> avoids testing that again. | |
| 457 | return _VSTD::to_chars(_First, _Last, static_cast<uint32_t>(_Unbiased_exponent)); | |
| 458 | } | |
| 459 | ||
| 460 | // For general precision, we can use lookup tables to avoid performing trial formatting. | |
| 461 | ||
| 462 | // For a simple example, imagine counting the number of digits D in an integer, and needing to know | |
| 463 | // whether D is less than 3, equal to 3/4/5/6, or greater than 6. We could use a lookup table: | |
| 464 | // D | Largest integer with D digits | |
| 465 | // 2 | 99 | |
| 466 | // 3 | 999 | |
| 467 | // 4 | 9'999 | |
| 468 | // 5 | 99'999 | |
| 469 | // 6 | 999'999 | |
| 470 | // 7 | table end | |
| 471 | // Looking up an integer in this table with lower_bound() will work: | |
| 472 | // * Too-small integers, like 7, 70, and 99, will cause lower_bound() to return the D == 2 row. (If all we care | |
| 473 | // about is whether D is less than 3, then it's okay to smash the D == 1 and D == 2 cases together.) | |
| 474 | // * Integers in [100, 999] will cause lower_bound() to return the D == 3 row, and so forth. | |
| 475 | // * Too-large integers, like 1'000'000 and above, will cause lower_bound() to return the end of the table. If we | |
| 476 | // compute D from that index, this will be considered D == 7, which will activate any "greater than 6" logic. | |
| 477 | ||
| 478 | // Floating-point is slightly more complicated. | |
| 479 | ||
| 480 | // The ordinary lookup tables are for X within [-5, 38] for float, and [-5, 308] for double. | |
| 481 | // (-5 absorbs too-negative exponents, outside the P > X >= -4 criterion. 38 and 308 are the maximum exponents.) | |
| 482 | // Due to the P > X condition, we can use a subset of the table for X within [-5, P - 1], suitably clamped. | |
| 483 | ||
| 484 | // When P is small, rounding can affect X. For example: | |
| 485 | // For P == 1, the largest double with X == 0 is: 9.4999999999999982236431605997495353221893310546875 | |
| 486 | // For P == 2, the largest double with X == 0 is: 9.949999999999999289457264239899814128875732421875 | |
| 487 | // For P == 3, the largest double with X == 0 is: 9.9949999999999992184029906638897955417633056640625 | |
| 488 | ||
| 489 | // Exponent adjustment is a concern for P within [1, 7] for float, and [1, 15] for double (determined via | |
| 490 | // brute force). While larger values of P still perform rounding, they can't trigger exponent adjustment. | |
| 491 | // This is because only values with repeated '9' digits can undergo exponent adjustment during rounding, | |
| 492 | // and floating-point granularity limits the number of consecutive '9' digits that can appear. | |
| 493 | ||
| 494 | // So, we need special lookup tables for small values of P. | |
| 495 | // These tables have varying lengths due to the P > X >= -4 criterion. For example: | |
| 496 | // For P == 1, need table entries for X: -5, -4, -3, -2, -1, 0 | |
| 497 | // For P == 2, need table entries for X: -5, -4, -3, -2, -1, 0, 1 | |
| 498 | // For P == 3, need table entries for X: -5, -4, -3, -2, -1, 0, 1, 2 | |
| 499 | // For P == 4, need table entries for X: -5, -4, -3, -2, -1, 0, 1, 2, 3 | |
| 500 | ||
| 501 | // We can concatenate these tables for compact storage, using triangular numbers to access them. | |
| 502 | // The table for P begins at index (P - 1) * (P + 10) / 2 with length P + 5. | |
| 503 | ||
| 504 | // For both the ordinary and special lookup tables, after an index I is returned by lower_bound(), X is I - 5. | |
| 505 | ||
| 506 | // We need to special-case the floating-point value 0.0, which is considered to have X == 0. | |
| 507 | // Otherwise, the lookup tables would consider it to have a highly negative X. | |
| 508 | ||
| 509 | // Finally, because we're working with positive floating-point values, | |
| 510 | // representation comparisons behave identically to floating-point comparisons. | |
| 511 | ||
| 512 | // The following code generated the lookup tables for the scientific exponent X. Don't remove this code. | |
| 513 | #if 0 | |
| 514 | // cl /EHsc /nologo /W4 /MT /O2 /std:c++17 generate_tables.cpp && generate_tables | |
| 515 | ||
| 516 | #include <algorithm> | |
| 517 | #include <assert.h> | |
| 518 | #include <charconv> | |
| 519 | #include <cmath> | |
| 520 | #include <limits> | |
| 521 | #include <map> | |
| 522 | #include <stdint.h> | |
| 523 | #include <stdio.h> | |
| 524 | #include <system_error> | |
| 525 | #include <type_traits> | |
| 526 | #include <vector> | |
| 527 | using namespace std; | |
| 528 | ||
| 529 | template <typename UInt, typename Pred> | |
| 530 | [[nodiscard]] UInt uint_partition_point(UInt first, const UInt last, Pred pred) { | |
| 531 | // Find the beginning of the false partition in [first, last). | |
| 532 | // [first, last) is partitioned when all of the true values occur before all of the false values. | |
| 533 | ||
| 534 | static_assert(is_unsigned_v<UInt>); | |
| 535 | assert(first <= last); | |
| 536 | ||
| 537 | for (UInt n = last - first; n > 0;) { | |
| 538 | const UInt n2 = n / 2; | |
| 539 | const UInt mid = first + n2; | |
| 540 | ||
| 541 | if (pred(mid)) { | |
| 542 | first = mid + 1; | |
| 543 | n = n - n2 - 1; | |
| 544 | } else { | |
| 545 | n = n2; | |
| 546 | } | |
| 547 | } | |
| 548 | ||
| 549 | return first; | |
| 550 | } | |
| 551 | ||
| 552 | template <typename Floating> | |
| 553 | [[nodiscard]] int scientific_exponent_X(const int P, const Floating flt) { | |
| 554 | char buf[400]; // more than enough | |
| 555 | ||
| 556 | // C11 7.21.6.1 "The fprintf function"/8 performs trial formatting with scientific precision P - 1. | |
| 557 | const auto to_result = to_chars(buf, end(buf), flt, chars_format::scientific, P - 1); | |
| 558 | assert(to_result.ec == errc{}); | |
| 559 | ||
| 560 | const char* exp_ptr = find(buf, to_result.ptr, 'e'); | |
| 561 | assert(exp_ptr != to_result.ptr); | |
| 562 | ||
| 563 | ++exp_ptr; // advance past 'e' | |
| 564 | ||
| 565 | if (*exp_ptr == '+') { | |
| 566 | ++exp_ptr; // advance past '+' which from_chars() won't parse | |
| 567 | } | |
| 568 | ||
| 569 | int X; | |
| 570 | const auto from_result = from_chars(exp_ptr, to_result.ptr, X); | |
| 571 | assert(from_result.ec == errc{}); | |
| 572 | return X; | |
| 573 | } | |
| 574 | ||
| 575 | template <typename UInt> | |
| 576 | void print_table(const vector<UInt>& v, const char* const name) { | |
| 577 | constexpr const char* UIntName = _IsSame<UInt, uint32_t>::value ? "uint32_t" : "uint64_t"; | |
| 578 | ||
| 579 | printf("static constexpr %s %s[%zu] = {\n", UIntName, name, v.size()); | |
| 580 | ||
| 581 | for (const auto& val : v) { | |
| 582 | if constexpr (_IsSame<UInt, uint32_t>::value) { | |
| 583 | printf("0x%08Xu,\n", val); | |
| 584 | } else { | |
| 585 | printf("0x%016llXu,\n", val); | |
| 586 | } | |
| 587 | } | |
| 588 | ||
| 589 | printf("};\n"); | |
| 590 | } | |
| 591 | ||
| 592 | enum class Mode { Tables, Tests }; | |
| 593 | ||
| 594 | template <typename Floating> | |
| 595 | void generate_tables(const Mode mode) { | |
| 596 | using Limits = numeric_limits<Floating>; | |
| 597 | using UInt = conditional_t<_IsSame<Floating, float>::value, uint32_t, uint64_t>; | |
| 598 | ||
| 599 | map<int, map<int, UInt>> P_X_LargestValWithX; | |
| 600 | ||
| 601 | constexpr int MaxP = Limits::max_exponent10 + 1; // MaxP performs no rounding during trial formatting | |
| 602 | ||
| 603 | for (int P = 1; P <= MaxP; ++P) { | |
| 604 | for (int X = -5; X < P; ++X) { | |
| 605 | constexpr Floating first = static_cast<Floating>(9e-5); // well below 9.5e-5, otherwise arbitrary | |
| 606 | constexpr Floating last = Limits::infinity(); // one bit above Limits::max() | |
| 607 | ||
| 608 | const UInt val_beyond_X = uint_partition_point(reinterpret_cast<const UInt&>(first), | |
| 609 | reinterpret_cast<const UInt&>(last), | |
| 610 | [P, X](const UInt u) { return scientific_exponent_X(P, reinterpret_cast<const Floating&>(u)) <= X; }); | |
| 611 | ||
| 612 | P_X_LargestValWithX[P][X] = val_beyond_X - 1; | |
| 613 | } | |
| 614 | } | |
| 615 | ||
| 616 | constexpr const char* FloatingName = _IsSame<Floating, float>::value ? "float" : "double"; | |
| 617 | ||
| 618 | constexpr int MaxSpecialP = _IsSame<Floating, float>::value ? 7 : 15; // MaxSpecialP is affected by exponent adjustment | |
| 619 | ||
| 620 | if (mode == Mode::Tables) { | |
| 621 | printf("template <>\n"); | |
| 622 | printf("struct _General_precision_tables<%s> {\n", FloatingName); | |
| 623 | ||
| 624 | printf("static constexpr int _Max_special_P = %d;\n", MaxSpecialP); | |
| 625 | ||
| 626 | vector<UInt> special; | |
| 627 | ||
| 628 | for (int P = 1; P <= MaxSpecialP; ++P) { | |
| 629 | for (int X = -5; X < P; ++X) { | |
| 630 | const UInt val = P_X_LargestValWithX[P][X]; | |
| 631 | special.push_back(val); | |
| 632 | } | |
| 633 | } | |
| 634 | ||
| 635 | print_table(special, "_Special_X_table"); | |
| 636 | ||
| 637 | for (int P = MaxSpecialP + 1; P < MaxP; ++P) { | |
| 638 | for (int X = -5; X < P; ++X) { | |
| 639 | const UInt val = P_X_LargestValWithX[P][X]; | |
| 640 | assert(val == P_X_LargestValWithX[MaxP][X]); | |
| 641 | } | |
| 642 | } | |
| 643 | ||
| 644 | printf("static constexpr int _Max_P = %d;\n", MaxP); | |
| 645 | ||
| 646 | vector<UInt> ordinary; | |
| 647 | ||
| 648 | for (int X = -5; X < MaxP; ++X) { | |
| 649 | const UInt val = P_X_LargestValWithX[MaxP][X]; | |
| 650 | ordinary.push_back(val); | |
| 651 | } | |
| 652 | ||
| 653 | print_table(ordinary, "_Ordinary_X_table"); | |
| 654 | ||
| 655 | printf("};\n"); | |
| 656 | } else { | |
| 657 | printf("==========\n"); | |
| 658 | printf("Test cases for %s:\n", FloatingName); | |
| 659 | ||
| 660 | constexpr int Hexits = _IsSame<Floating, float>::value ? 6 : 13; | |
| 661 | constexpr const char* Suffix = _IsSame<Floating, float>::value ? "f" : ""; | |
| 662 | ||
| 663 | for (int P = 1; P <= MaxP; ++P) { | |
| 664 | for (int X = -5; X < P; ++X) { | |
| 665 | if (P <= MaxSpecialP || P == 25 || P == MaxP || X == P - 1) { | |
| 666 | const UInt val1 = P_X_LargestValWithX[P][X]; | |
| 667 | const Floating f1 = reinterpret_cast<const Floating&>(val1); | |
| 668 | const UInt val2 = val1 + 1; | |
| 669 | const Floating f2 = reinterpret_cast<const Floating&>(val2); | |
| 670 | ||
| 671 | printf("{%.*a%s, chars_format::general, %d, \"%.*g\"},\n", Hexits, f1, Suffix, P, P, f1); | |
| 672 | if (isfinite(f2)) { | |
| 673 | printf("{%.*a%s, chars_format::general, %d, \"%.*g\"},\n", Hexits, f2, Suffix, P, P, f2); | |
| 674 | } | |
| 675 | } | |
| 676 | } | |
| 677 | } | |
| 678 | } | |
| 679 | } | |
| 680 | ||
| 681 | int main() { | |
| 682 | printf("template <class _Floating>\n"); | |
| 683 | printf("struct _General_precision_tables;\n"); | |
| 684 | generate_tables<float>(Mode::Tables); | |
| 685 | generate_tables<double>(Mode::Tables); | |
| 686 | generate_tables<float>(Mode::Tests); | |
| 687 | generate_tables<double>(Mode::Tests); | |
| 688 | } | |
| 689 | #endif // 0 | |
| 690 | ||
| 691 | template <class _Floating> | |
| 692 | struct _General_precision_tables; | |
| 693 | ||
| 694 | template <> | |
| 695 | struct _General_precision_tables<float> { | |
| 696 | static constexpr int _Max_special_P = 7; | |
| 697 | ||
| 698 | static constexpr uint32_t _Special_X_table[63] = {0x38C73ABCu, 0x3A79096Bu, 0x3C1BA5E3u, 0x3DC28F5Cu, 0x3F733333u, | |
| 699 | 0x4117FFFFu, 0x38D0AAA7u, 0x3A826AA8u, 0x3C230553u, 0x3DCBC6A7u, 0x3F7EB851u, 0x411F3333u, 0x42C6FFFFu, | |
| 700 | 0x38D19C3Fu, 0x3A8301A7u, 0x3C23C211u, 0x3DCCB295u, 0x3F7FDF3Bu, 0x411FEB85u, 0x42C7E666u, 0x4479DFFFu, | |
| 701 | 0x38D1B468u, 0x3A8310C1u, 0x3C23D4F1u, 0x3DCCCA2Du, 0x3F7FFCB9u, 0x411FFDF3u, 0x42C7FD70u, 0x4479FCCCu, | |
| 702 | 0x461C3DFFu, 0x38D1B6D2u, 0x3A831243u, 0x3C23D6D4u, 0x3DCCCC89u, 0x3F7FFFACu, 0x411FFFCBu, 0x42C7FFBEu, | |
| 703 | 0x4479FFAEu, 0x461C3FCCu, 0x47C34FBFu, 0x38D1B710u, 0x3A83126Au, 0x3C23D704u, 0x3DCCCCC6u, 0x3F7FFFF7u, | |
| 704 | 0x411FFFFAu, 0x42C7FFF9u, 0x4479FFF7u, 0x461C3FFAu, 0x47C34FF9u, 0x497423F7u, 0x38D1B716u, 0x3A83126Eu, | |
| 705 | 0x3C23D709u, 0x3DCCCCCCu, 0x3F7FFFFFu, 0x411FFFFFu, 0x42C7FFFFu, 0x4479FFFFu, 0x461C3FFFu, 0x47C34FFFu, | |
| 706 | 0x497423FFu, 0x4B18967Fu}; | |
| 707 | ||
| 708 | static constexpr int _Max_P = 39; | |
| 709 | ||
| 710 | static constexpr uint32_t _Ordinary_X_table[44] = {0x38D1B717u, 0x3A83126Eu, 0x3C23D70Au, 0x3DCCCCCCu, 0x3F7FFFFFu, | |
| 711 | 0x411FFFFFu, 0x42C7FFFFu, 0x4479FFFFu, 0x461C3FFFu, 0x47C34FFFu, 0x497423FFu, 0x4B18967Fu, 0x4CBEBC1Fu, | |
| 712 | 0x4E6E6B27u, 0x501502F8u, 0x51BA43B7u, 0x5368D4A5u, 0x551184E7u, 0x56B5E620u, 0x58635FA9u, 0x5A0E1BC9u, | |
| 713 | 0x5BB1A2BCu, 0x5D5E0B6Bu, 0x5F0AC723u, 0x60AD78EBu, 0x6258D726u, 0x64078678u, 0x65A96816u, 0x6753C21Bu, | |
| 714 | 0x69045951u, 0x6AA56FA5u, 0x6C4ECB8Fu, 0x6E013F39u, 0x6FA18F07u, 0x7149F2C9u, 0x72FC6F7Cu, 0x749DC5ADu, | |
| 715 | 0x76453719u, 0x77F684DFu, 0x799A130Bu, 0x7B4097CEu, 0x7CF0BDC2u, 0x7E967699u, 0x7F7FFFFFu}; | |
| 716 | }; | |
| 717 | ||
| 718 | template <> | |
| 719 | struct _General_precision_tables<double> { | |
| 720 | static constexpr int _Max_special_P = 15; | |
| 721 | ||
| 722 | static constexpr uint64_t _Special_X_table[195] = {0x3F18E757928E0C9Du, 0x3F4F212D77318FC5u, 0x3F8374BC6A7EF9DBu, | |
| 723 | 0x3FB851EB851EB851u, 0x3FEE666666666666u, 0x4022FFFFFFFFFFFFu, 0x3F1A1554FBDAD751u, 0x3F504D551D68C692u, | |
| 724 | 0x3F8460AA64C2F837u, 0x3FB978D4FDF3B645u, 0x3FEFD70A3D70A3D7u, 0x4023E66666666666u, 0x4058DFFFFFFFFFFFu, | |
| 725 | 0x3F1A3387ECC8EB96u, 0x3F506034F3FD933Eu, 0x3F84784230FCF80Du, 0x3FB99652BD3C3611u, 0x3FEFFBE76C8B4395u, | |
| 726 | 0x4023FD70A3D70A3Du, 0x4058FCCCCCCCCCCCu, 0x408F3BFFFFFFFFFFu, 0x3F1A368D04E0BA6Au, 0x3F506218230C7482u, | |
| 727 | 0x3F847A9E2BCF91A3u, 0x3FB99945B6C3760Bu, 0x3FEFFF972474538Eu, 0x4023FFBE76C8B439u, 0x4058FFAE147AE147u, | |
| 728 | 0x408F3F9999999999u, 0x40C387BFFFFFFFFFu, 0x3F1A36DA54164F19u, 0x3F506248748DF16Fu, 0x3F847ADA91B16DCBu, | |
| 729 | 0x3FB99991361DC93Eu, 0x3FEFFFF583A53B8Eu, 0x4023FFF972474538u, 0x4058FFF7CED91687u, 0x408F3FF5C28F5C28u, | |
| 730 | 0x40C387F999999999u, 0x40F869F7FFFFFFFFu, 0x3F1A36E20F35445Du, 0x3F50624D49814ABAu, 0x3F847AE09BE19D69u, | |
| 731 | 0x3FB99998C2DA04C3u, 0x3FEFFFFEF39085F4u, 0x4023FFFF583A53B8u, 0x4058FFFF2E48E8A7u, 0x408F3FFEF9DB22D0u, | |
| 732 | 0x40C387FF5C28F5C2u, 0x40F869FF33333333u, 0x412E847EFFFFFFFFu, 0x3F1A36E2D51EC34Bu, 0x3F50624DC5333A0Eu, | |
| 733 | 0x3F847AE136800892u, 0x3FB9999984200AB7u, 0x3FEFFFFFE5280D65u, 0x4023FFFFEF39085Fu, 0x4058FFFFEB074A77u, | |
| 734 | 0x408F3FFFE5C91D14u, 0x40C387FFEF9DB22Du, 0x40F869FFEB851EB8u, 0x412E847FE6666666u, 0x416312CFEFFFFFFFu, | |
| 735 | 0x3F1A36E2E8E94FFCu, 0x3F50624DD191D1FDu, 0x3F847AE145F6467Du, 0x3FB999999773D81Cu, 0x3FEFFFFFFD50CE23u, | |
| 736 | 0x4023FFFFFE5280D6u, 0x4058FFFFFDE7210Bu, 0x408F3FFFFD60E94Eu, 0x40C387FFFE5C91D1u, 0x40F869FFFDF3B645u, | |
| 737 | 0x412E847FFD70A3D7u, 0x416312CFFE666666u, 0x4197D783FDFFFFFFu, 0x3F1A36E2EAE3F7A7u, 0x3F50624DD2CE7AC8u, | |
| 738 | 0x3F847AE14782197Bu, 0x3FB9999999629FD9u, 0x3FEFFFFFFFBB47D0u, 0x4023FFFFFFD50CE2u, 0x4058FFFFFFCA501Au, | |
| 739 | 0x408F3FFFFFBCE421u, 0x40C387FFFFD60E94u, 0x40F869FFFFCB923Au, 0x412E847FFFBE76C8u, 0x416312CFFFD70A3Du, | |
| 740 | 0x4197D783FFCCCCCCu, 0x41CDCD64FFBFFFFFu, 0x3F1A36E2EB16A205u, 0x3F50624DD2EE2543u, 0x3F847AE147A9AE94u, | |
| 741 | 0x3FB9999999941A39u, 0x3FEFFFFFFFF920C8u, 0x4023FFFFFFFBB47Du, 0x4058FFFFFFFAA19Cu, 0x408F3FFFFFF94A03u, | |
| 742 | 0x40C387FFFFFBCE42u, 0x40F869FFFFFAC1D2u, 0x412E847FFFF97247u, 0x416312CFFFFBE76Cu, 0x4197D783FFFAE147u, | |
| 743 | 0x41CDCD64FFF99999u, 0x4202A05F1FFBFFFFu, 0x3F1A36E2EB1BB30Fu, 0x3F50624DD2F14FE9u, 0x3F847AE147ADA3E3u, | |
| 744 | 0x3FB9999999990CDCu, 0x3FEFFFFFFFFF5014u, 0x4023FFFFFFFF920Cu, 0x4058FFFFFFFF768Fu, 0x408F3FFFFFFF5433u, | |
| 745 | 0x40C387FFFFFF94A0u, 0x40F869FFFFFF79C8u, 0x412E847FFFFF583Au, 0x416312CFFFFF9724u, 0x4197D783FFFF7CEDu, | |
| 746 | 0x41CDCD64FFFF5C28u, 0x4202A05F1FFF9999u, 0x42374876E7FF7FFFu, 0x3F1A36E2EB1C34C3u, 0x3F50624DD2F1A0FAu, | |
| 747 | 0x3F847AE147AE0938u, 0x3FB9999999998B86u, 0x3FEFFFFFFFFFEE68u, 0x4023FFFFFFFFF501u, 0x4058FFFFFFFFF241u, | |
| 748 | 0x408F3FFFFFFFEED1u, 0x40C387FFFFFFF543u, 0x40F869FFFFFFF294u, 0x412E847FFFFFEF39u, 0x416312CFFFFFF583u, | |
| 749 | 0x4197D783FFFFF2E4u, 0x41CDCD64FFFFEF9Du, 0x4202A05F1FFFF5C2u, 0x42374876E7FFF333u, 0x426D1A94A1FFEFFFu, | |
| 750 | 0x3F1A36E2EB1C41BBu, 0x3F50624DD2F1A915u, 0x3F847AE147AE135Au, 0x3FB9999999999831u, 0x3FEFFFFFFFFFFE3Du, | |
| 751 | 0x4023FFFFFFFFFEE6u, 0x4058FFFFFFFFFEA0u, 0x408F3FFFFFFFFE48u, 0x40C387FFFFFFFEEDu, 0x40F869FFFFFFFEA8u, | |
| 752 | 0x412E847FFFFFFE52u, 0x416312CFFFFFFEF3u, 0x4197D783FFFFFEB0u, 0x41CDCD64FFFFFE5Cu, 0x4202A05F1FFFFEF9u, | |
| 753 | 0x42374876E7FFFEB8u, 0x426D1A94A1FFFE66u, 0x42A2309CE53FFEFFu, 0x3F1A36E2EB1C4307u, 0x3F50624DD2F1A9E4u, | |
| 754 | 0x3F847AE147AE145Eu, 0x3FB9999999999975u, 0x3FEFFFFFFFFFFFD2u, 0x4023FFFFFFFFFFE3u, 0x4058FFFFFFFFFFDCu, | |
| 755 | 0x408F3FFFFFFFFFD4u, 0x40C387FFFFFFFFE4u, 0x40F869FFFFFFFFDDu, 0x412E847FFFFFFFD5u, 0x416312CFFFFFFFE5u, | |
| 756 | 0x4197D783FFFFFFDEu, 0x41CDCD64FFFFFFD6u, 0x4202A05F1FFFFFE5u, 0x42374876E7FFFFDFu, 0x426D1A94A1FFFFD7u, | |
| 757 | 0x42A2309CE53FFFE6u, 0x42D6BCC41E8FFFDFu, 0x3F1A36E2EB1C4328u, 0x3F50624DD2F1A9F9u, 0x3F847AE147AE1477u, | |
| 758 | 0x3FB9999999999995u, 0x3FEFFFFFFFFFFFFBu, 0x4023FFFFFFFFFFFDu, 0x4058FFFFFFFFFFFCu, 0x408F3FFFFFFFFFFBu, | |
| 759 | 0x40C387FFFFFFFFFDu, 0x40F869FFFFFFFFFCu, 0x412E847FFFFFFFFBu, 0x416312CFFFFFFFFDu, 0x4197D783FFFFFFFCu, | |
| 760 | 0x41CDCD64FFFFFFFBu, 0x4202A05F1FFFFFFDu, 0x42374876E7FFFFFCu, 0x426D1A94A1FFFFFBu, 0x42A2309CE53FFFFDu, | |
| 761 | 0x42D6BCC41E8FFFFCu, 0x430C6BF52633FFFBu}; | |
| 762 | ||
| 763 | static constexpr int _Max_P = 309; | |
| 764 | ||
| 765 | static constexpr uint64_t _Ordinary_X_table[314] = {0x3F1A36E2EB1C432Cu, 0x3F50624DD2F1A9FBu, 0x3F847AE147AE147Au, | |
| 766 | 0x3FB9999999999999u, 0x3FEFFFFFFFFFFFFFu, 0x4023FFFFFFFFFFFFu, 0x4058FFFFFFFFFFFFu, 0x408F3FFFFFFFFFFFu, | |
| 767 | 0x40C387FFFFFFFFFFu, 0x40F869FFFFFFFFFFu, 0x412E847FFFFFFFFFu, 0x416312CFFFFFFFFFu, 0x4197D783FFFFFFFFu, | |
| 768 | 0x41CDCD64FFFFFFFFu, 0x4202A05F1FFFFFFFu, 0x42374876E7FFFFFFu, 0x426D1A94A1FFFFFFu, 0x42A2309CE53FFFFFu, | |
| 769 | 0x42D6BCC41E8FFFFFu, 0x430C6BF52633FFFFu, 0x4341C37937E07FFFu, 0x4376345785D89FFFu, 0x43ABC16D674EC7FFu, | |
| 770 | 0x43E158E460913CFFu, 0x4415AF1D78B58C3Fu, 0x444B1AE4D6E2EF4Fu, 0x4480F0CF064DD591u, 0x44B52D02C7E14AF6u, | |
| 771 | 0x44EA784379D99DB4u, 0x45208B2A2C280290u, 0x4554ADF4B7320334u, 0x4589D971E4FE8401u, 0x45C027E72F1F1281u, | |
| 772 | 0x45F431E0FAE6D721u, 0x46293E5939A08CE9u, 0x465F8DEF8808B024u, 0x4693B8B5B5056E16u, 0x46C8A6E32246C99Cu, | |
| 773 | 0x46FED09BEAD87C03u, 0x4733426172C74D82u, 0x476812F9CF7920E2u, 0x479E17B84357691Bu, 0x47D2CED32A16A1B1u, | |
| 774 | 0x48078287F49C4A1Du, 0x483D6329F1C35CA4u, 0x48725DFA371A19E6u, 0x48A6F578C4E0A060u, 0x48DCB2D6F618C878u, | |
| 775 | 0x4911EFC659CF7D4Bu, 0x49466BB7F0435C9Eu, 0x497C06A5EC5433C6u, 0x49B18427B3B4A05Bu, 0x49E5E531A0A1C872u, | |
| 776 | 0x4A1B5E7E08CA3A8Fu, 0x4A511B0EC57E6499u, 0x4A8561D276DDFDC0u, 0x4ABABA4714957D30u, 0x4AF0B46C6CDD6E3Eu, | |
| 777 | 0x4B24E1878814C9CDu, 0x4B5A19E96A19FC40u, 0x4B905031E2503DA8u, 0x4BC4643E5AE44D12u, 0x4BF97D4DF19D6057u, | |
| 778 | 0x4C2FDCA16E04B86Du, 0x4C63E9E4E4C2F344u, 0x4C98E45E1DF3B015u, 0x4CCF1D75A5709C1Au, 0x4D03726987666190u, | |
| 779 | 0x4D384F03E93FF9F4u, 0x4D6E62C4E38FF872u, 0x4DA2FDBB0E39FB47u, 0x4DD7BD29D1C87A19u, 0x4E0DAC74463A989Fu, | |
| 780 | 0x4E428BC8ABE49F63u, 0x4E772EBAD6DDC73Cu, 0x4EACFA698C95390Bu, 0x4EE21C81F7DD43A7u, 0x4F16A3A275D49491u, | |
| 781 | 0x4F4C4C8B1349B9B5u, 0x4F81AFD6EC0E1411u, 0x4FB61BCCA7119915u, 0x4FEBA2BFD0D5FF5Bu, 0x502145B7E285BF98u, | |
| 782 | 0x50559725DB272F7Fu, 0x508AFCEF51F0FB5Eu, 0x50C0DE1593369D1Bu, 0x50F5159AF8044462u, 0x512A5B01B605557Au, | |
| 783 | 0x516078E111C3556Cu, 0x5194971956342AC7u, 0x51C9BCDFABC13579u, 0x5200160BCB58C16Cu, 0x52341B8EBE2EF1C7u, | |
| 784 | 0x526922726DBAAE39u, 0x529F6B0F092959C7u, 0x52D3A2E965B9D81Cu, 0x53088BA3BF284E23u, 0x533EAE8CAEF261ACu, | |
| 785 | 0x53732D17ED577D0Bu, 0x53A7F85DE8AD5C4Eu, 0x53DDF67562D8B362u, 0x5412BA095DC7701Du, 0x5447688BB5394C25u, | |
| 786 | 0x547D42AEA2879F2Eu, 0x54B249AD2594C37Cu, 0x54E6DC186EF9F45Cu, 0x551C931E8AB87173u, 0x5551DBF316B346E7u, | |
| 787 | 0x558652EFDC6018A1u, 0x55BBE7ABD3781ECAu, 0x55F170CB642B133Eu, 0x5625CCFE3D35D80Eu, 0x565B403DCC834E11u, | |
| 788 | 0x569108269FD210CBu, 0x56C54A3047C694FDu, 0x56FA9CBC59B83A3Du, 0x5730A1F5B8132466u, 0x5764CA732617ED7Fu, | |
| 789 | 0x5799FD0FEF9DE8DFu, 0x57D03E29F5C2B18Bu, 0x58044DB473335DEEu, 0x583961219000356Au, 0x586FB969F40042C5u, | |
| 790 | 0x58A3D3E2388029BBu, 0x58D8C8DAC6A0342Au, 0x590EFB1178484134u, 0x59435CEAEB2D28C0u, 0x59783425A5F872F1u, | |
| 791 | 0x59AE412F0F768FADu, 0x59E2E8BD69AA19CCu, 0x5A17A2ECC414A03Fu, 0x5A4D8BA7F519C84Fu, 0x5A827748F9301D31u, | |
| 792 | 0x5AB7151B377C247Eu, 0x5AECDA62055B2D9Du, 0x5B22087D4358FC82u, 0x5B568A9C942F3BA3u, 0x5B8C2D43B93B0A8Bu, | |
| 793 | 0x5BC19C4A53C4E697u, 0x5BF6035CE8B6203Du, 0x5C2B843422E3A84Cu, 0x5C6132A095CE492Fu, 0x5C957F48BB41DB7Bu, | |
| 794 | 0x5CCADF1AEA12525Au, 0x5D00CB70D24B7378u, 0x5D34FE4D06DE5056u, 0x5D6A3DE04895E46Cu, 0x5DA066AC2D5DAEC3u, | |
| 795 | 0x5DD4805738B51A74u, 0x5E09A06D06E26112u, 0x5E400444244D7CABu, 0x5E7405552D60DBD6u, 0x5EA906AA78B912CBu, | |
| 796 | 0x5EDF485516E7577Eu, 0x5F138D352E5096AFu, 0x5F48708279E4BC5Au, 0x5F7E8CA3185DEB71u, 0x5FB317E5EF3AB327u, | |
| 797 | 0x5FE7DDDF6B095FF0u, 0x601DD55745CBB7ECu, 0x6052A5568B9F52F4u, 0x60874EAC2E8727B1u, 0x60BD22573A28F19Du, | |
| 798 | 0x60F2357684599702u, 0x6126C2D4256FFCC2u, 0x615C73892ECBFBF3u, 0x6191C835BD3F7D78u, 0x61C63A432C8F5CD6u, | |
| 799 | 0x61FBC8D3F7B3340Bu, 0x62315D847AD00087u, 0x6265B4E5998400A9u, 0x629B221EFFE500D3u, 0x62D0F5535FEF2084u, | |
| 800 | 0x630532A837EAE8A5u, 0x633A7F5245E5A2CEu, 0x63708F936BAF85C1u, 0x63A4B378469B6731u, 0x63D9E056584240FDu, | |
| 801 | 0x64102C35F729689Eu, 0x6444374374F3C2C6u, 0x647945145230B377u, 0x64AF965966BCE055u, 0x64E3BDF7E0360C35u, | |
| 802 | 0x6518AD75D8438F43u, 0x654ED8D34E547313u, 0x6583478410F4C7ECu, 0x65B819651531F9E7u, 0x65EE1FBE5A7E7861u, | |
| 803 | 0x6622D3D6F88F0B3Cu, 0x665788CCB6B2CE0Cu, 0x668D6AFFE45F818Fu, 0x66C262DFEEBBB0F9u, 0x66F6FB97EA6A9D37u, | |
| 804 | 0x672CBA7DE5054485u, 0x6761F48EAF234AD3u, 0x679671B25AEC1D88u, 0x67CC0E1EF1A724EAu, 0x680188D357087712u, | |
| 805 | 0x6835EB082CCA94D7u, 0x686B65CA37FD3A0Du, 0x68A11F9E62FE4448u, 0x68D56785FBBDD55Au, 0x690AC1677AAD4AB0u, | |
| 806 | 0x6940B8E0ACAC4EAEu, 0x6974E718D7D7625Au, 0x69AA20DF0DCD3AF0u, 0x69E0548B68A044D6u, 0x6A1469AE42C8560Cu, | |
| 807 | 0x6A498419D37A6B8Fu, 0x6A7FE52048590672u, 0x6AB3EF342D37A407u, 0x6AE8EB0138858D09u, 0x6B1F25C186A6F04Cu, | |
| 808 | 0x6B537798F428562Fu, 0x6B88557F31326BBBu, 0x6BBE6ADEFD7F06AAu, 0x6BF302CB5E6F642Au, 0x6C27C37E360B3D35u, | |
| 809 | 0x6C5DB45DC38E0C82u, 0x6C9290BA9A38C7D1u, 0x6CC734E940C6F9C5u, 0x6CFD022390F8B837u, 0x6D3221563A9B7322u, | |
| 810 | 0x6D66A9ABC9424FEBu, 0x6D9C5416BB92E3E6u, 0x6DD1B48E353BCE6Fu, 0x6E0621B1C28AC20Bu, 0x6E3BAA1E332D728Eu, | |
| 811 | 0x6E714A52DFFC6799u, 0x6EA59CE797FB817Fu, 0x6EDB04217DFA61DFu, 0x6F10E294EEBC7D2Bu, 0x6F451B3A2A6B9C76u, | |
| 812 | 0x6F7A6208B5068394u, 0x6FB07D457124123Cu, 0x6FE49C96CD6D16CBu, 0x7019C3BC80C85C7Eu, 0x70501A55D07D39CFu, | |
| 813 | 0x708420EB449C8842u, 0x70B9292615C3AA53u, 0x70EF736F9B3494E8u, 0x7123A825C100DD11u, 0x7158922F31411455u, | |
| 814 | 0x718EB6BAFD91596Bu, 0x71C33234DE7AD7E2u, 0x71F7FEC216198DDBu, 0x722DFE729B9FF152u, 0x7262BF07A143F6D3u, | |
| 815 | 0x72976EC98994F488u, 0x72CD4A7BEBFA31AAu, 0x73024E8D737C5F0Au, 0x7336E230D05B76CDu, 0x736C9ABD04725480u, | |
| 816 | 0x73A1E0B622C774D0u, 0x73D658E3AB795204u, 0x740BEF1C9657A685u, 0x74417571DDF6C813u, 0x7475D2CE55747A18u, | |
| 817 | 0x74AB4781EAD1989Eu, 0x74E10CB132C2FF63u, 0x75154FDD7F73BF3Bu, 0x754AA3D4DF50AF0Au, 0x7580A6650B926D66u, | |
| 818 | 0x75B4CFFE4E7708C0u, 0x75EA03FDE214CAF0u, 0x7620427EAD4CFED6u, 0x7654531E58A03E8Bu, 0x768967E5EEC84E2Eu, | |
| 819 | 0x76BFC1DF6A7A61BAu, 0x76F3D92BA28C7D14u, 0x7728CF768B2F9C59u, 0x775F03542DFB8370u, 0x779362149CBD3226u, | |
| 820 | 0x77C83A99C3EC7EAFu, 0x77FE494034E79E5Bu, 0x7832EDC82110C2F9u, 0x7867A93A2954F3B7u, 0x789D9388B3AA30A5u, | |
| 821 | 0x78D27C35704A5E67u, 0x79071B42CC5CF601u, 0x793CE2137F743381u, 0x79720D4C2FA8A030u, 0x79A6909F3B92C83Du, | |
| 822 | 0x79DC34C70A777A4Cu, 0x7A11A0FC668AAC6Fu, 0x7A46093B802D578Bu, 0x7A7B8B8A6038AD6Eu, 0x7AB137367C236C65u, | |
| 823 | 0x7AE585041B2C477Eu, 0x7B1AE64521F7595Eu, 0x7B50CFEB353A97DAu, 0x7B8503E602893DD1u, 0x7BBA44DF832B8D45u, | |
| 824 | 0x7BF06B0BB1FB384Bu, 0x7C2485CE9E7A065Eu, 0x7C59A742461887F6u, 0x7C9008896BCF54F9u, 0x7CC40AABC6C32A38u, | |
| 825 | 0x7CF90D56B873F4C6u, 0x7D2F50AC6690F1F8u, 0x7D63926BC01A973Bu, 0x7D987706B0213D09u, 0x7DCE94C85C298C4Cu, | |
| 826 | 0x7E031CFD3999F7AFu, 0x7E37E43C8800759Bu, 0x7E6DDD4BAA009302u, 0x7EA2AA4F4A405BE1u, 0x7ED754E31CD072D9u, | |
| 827 | 0x7F0D2A1BE4048F90u, 0x7F423A516E82D9BAu, 0x7F76C8E5CA239028u, 0x7FAC7B1F3CAC7433u, 0x7FE1CCF385EBC89Fu, | |
| 828 | 0x7FEFFFFFFFFFFFFFu}; | |
| 829 | }; | |
| 830 | ||
| 831 | template <class _Floating> | |
| 832 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 833 | to_chars_result _Floating_to_chars_general_precision( | |
| 834 | char* _First, char* const _Last, const _Floating _Value, int _Precision) noexcept { | |
| 835 | ||
| 836 | using _Traits = _Floating_type_traits<_Floating>; | |
| 837 | using _Uint_type = typename _Traits::_Uint_type; | |
| 838 | ||
| 839 | const _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value); | |
| 840 | ||
| 841 | if (_Uint_value == 0) { // zero detected; write "0" and return; _Precision is irrelevant due to zero-trimming | |
| 842 | if (_First == _Last) { | |
| 843 | return {_Last, errc::value_too_large}; | |
| 844 | } | |
| 845 | ||
| 846 | *_First++ = '0'; | |
| 847 | ||
| 848 | return {_First, errc{}}; | |
| 849 | } | |
| 850 | ||
| 851 | // C11 7.21.6.1 "The fprintf function"/5: | |
| 852 | // "A negative precision argument is taken as if the precision were omitted." | |
| 853 | // /8: "g,G [...] Let P equal the precision if nonzero, 6 if the precision is omitted, | |
| 854 | // or 1 if the precision is zero." | |
| 855 | ||
| 856 | // Performance note: It's possible to rewrite this for branchless codegen, | |
| 857 | // but profiling will be necessary to determine whether that's faster. | |
| 858 | if (_Precision < 0) { | |
| 859 | _Precision = 6; | |
| 860 | } else if (_Precision == 0) { | |
| 861 | _Precision = 1; | |
| 862 | } else if (_Precision < 1'000'000) { | |
| 863 | // _Precision is ok. | |
| 864 | } else { | |
| 865 | // Avoid integer overflow. | |
| 866 | // Due to general notation's zero-trimming behavior, we can simply clamp _Precision. | |
| 867 | // This is further clamped below. | |
| 868 | _Precision = 1'000'000; | |
| 869 | } | |
| 870 | ||
| 871 | // _Precision is now the Standard's P. | |
| 872 | ||
| 873 | // /8: "Then, if a conversion with style E would have an exponent of X: | |
| 874 | // - if P > X >= -4, the conversion is with style f (or F) and precision P - (X + 1). | |
| 875 | // - otherwise, the conversion is with style e (or E) and precision P - 1." | |
| 876 | ||
| 877 | // /8: "Finally, [...] any trailing zeros are removed from the fractional portion of the result | |
| 878 | // and the decimal-point character is removed if there is no fractional portion remaining." | |
| 879 | ||
| 880 | using _Tables = _General_precision_tables<_Floating>; | |
| 881 | ||
| 882 | const _Uint_type* _Table_begin; | |
| 883 | const _Uint_type* _Table_end; | |
| 884 | ||
| 885 | if (_Precision <= _Tables::_Max_special_P) { | |
| 886 | _Table_begin = _Tables::_Special_X_table + (_Precision - 1) * (_Precision + 10) / 2; | |
| 887 | _Table_end = _Table_begin + _Precision + 5; | |
| 888 | } else { | |
| 889 | _Table_begin = _Tables::_Ordinary_X_table; | |
| 890 | _Table_end = _Table_begin + _VSTD::min(_Precision, _Tables::_Max_P) + 5; | |
| 891 | } | |
| 892 | ||
| 893 | // Profiling indicates that linear search is faster than binary search for small tables. | |
| 894 | // Performance note: lambda captures may have a small performance cost. | |
| 895 | const _Uint_type* const _Table_lower_bound = [=] { | |
| 896 | if constexpr (!_IsSame<_Floating, float>::value) { | |
| 897 | if (_Precision > 155) { // threshold determined via profiling | |
| 898 | return _VSTD::lower_bound(_Table_begin, _Table_end, _Uint_value, less{}); | |
| 899 | } | |
| 900 | } | |
| 901 | ||
| 902 | return _VSTD::find_if(_Table_begin, _Table_end, [=](const _Uint_type _Elem) { return _Uint_value <= _Elem; }); | |
| 903 | }(); | |
| 904 | ||
| 905 | const ptrdiff_t _Table_index = _Table_lower_bound - _Table_begin; | |
| 906 | const int _Scientific_exponent_X = static_cast<int>(_Table_index - 5); | |
| 907 | const bool _Use_fixed_notation = _Precision > _Scientific_exponent_X && _Scientific_exponent_X >= -4; | |
| 908 | ||
| 909 | // Performance note: it might (or might not) be faster to modify Ryu Printf to perform zero-trimming. | |
| 910 | // Such modifications would involve a fairly complicated state machine (notably, both '0' and '9' digits would | |
| 911 | // need to be buffered, due to rounding), and that would have performance costs due to increased branching. | |
| 912 | // Here, we're using a simpler approach: writing into a local buffer, manually zero-trimming, and then copying into | |
| 913 | // the output range. The necessary buffer size is reasonably small, the zero-trimming logic is simple and fast, | |
| 914 | // and the final copying is also fast. | |
| 915 | ||
| 916 | constexpr int _Max_output_length = | |
| 917 | _IsSame<_Floating, float>::value ? 117 : 773; // cases: 0x1.fffffep-126f and 0x1.fffffffffffffp-1022 | |
| 918 | constexpr int _Max_fixed_precision = | |
| 919 | _IsSame<_Floating, float>::value ? 37 : 66; // cases: 0x1.fffffep-14f and 0x1.fffffffffffffp-14 | |
| 920 | constexpr int _Max_scientific_precision = | |
| 921 | _IsSame<_Floating, float>::value ? 111 : 766; // cases: 0x1.fffffep-126f and 0x1.fffffffffffffp-1022 | |
| 922 | ||
| 923 | // Note that _Max_output_length is determined by scientific notation and is more than enough for fixed notation. | |
| 924 | // 0x1.fffffep+127f is 39 digits, plus 1 for '.', plus _Max_fixed_precision for '0' digits, equals 77. | |
| 925 | // 0x1.fffffffffffffp+1023 is 309 digits, plus 1 for '.', plus _Max_fixed_precision for '0' digits, equals 376. | |
| 926 | ||
| 927 | char _Buffer[_Max_output_length]; | |
| 928 | const char* const _Significand_first = _Buffer; // e.g. "1.234" | |
| 929 | const char* _Significand_last = nullptr; | |
| 930 | const char* _Exponent_first = nullptr; // e.g. "e-05" | |
| 931 | const char* _Exponent_last = nullptr; | |
| 932 | int _Effective_precision; // number of digits printed after the decimal point, before trimming | |
| 933 | ||
| 934 | // Write into the local buffer. | |
| 935 | // Clamping _Effective_precision allows _Buffer to be as small as possible, and increases efficiency. | |
| 936 | if (_Use_fixed_notation) { | |
| 937 | _Effective_precision = _VSTD::min(_Precision - (_Scientific_exponent_X + 1), _Max_fixed_precision); | |
| 938 | const to_chars_result _Buf_result = | |
| 939 | _Floating_to_chars_fixed_precision(_Buffer, _VSTD::end(_Buffer), _Value, _Effective_precision); | |
| 940 | _LIBCPP_ASSERT(_Buf_result.ec == errc{}, ""); | |
| 941 | _Significand_last = _Buf_result.ptr; | |
| 942 | } else { | |
| 943 | _Effective_precision = _VSTD::min(_Precision - 1, _Max_scientific_precision); | |
| 944 | const to_chars_result _Buf_result = | |
| 945 | _Floating_to_chars_scientific_precision(_Buffer, _VSTD::end(_Buffer), _Value, _Effective_precision); | |
| 946 | _LIBCPP_ASSERT(_Buf_result.ec == errc{}, ""); | |
| 947 | _Significand_last = _VSTD::find(_Buffer, _Buf_result.ptr, 'e'); | |
| 948 | _Exponent_first = _Significand_last; | |
| 949 | _Exponent_last = _Buf_result.ptr; | |
| 950 | } | |
| 951 | ||
| 952 | // If we printed a decimal point followed by digits, perform zero-trimming. | |
| 953 | if (_Effective_precision > 0) { | |
| 954 | while (_Significand_last[-1] == '0') { // will stop at '.' or a nonzero digit | |
| 955 | --_Significand_last; | |
| 956 | } | |
| 957 | ||
| 958 | if (_Significand_last[-1] == '.') { | |
| 959 | --_Significand_last; | |
| 960 | } | |
| 961 | } | |
| 962 | ||
| 963 | // Copy the significand to the output range. | |
| 964 | const ptrdiff_t _Significand_distance = _Significand_last - _Significand_first; | |
| 965 | if (_Last - _First < _Significand_distance) { | |
| 966 | return {_Last, errc::value_too_large}; | |
| 967 | } | |
| 968 | _VSTD::memcpy(_First, _Significand_first, static_cast<size_t>(_Significand_distance)); | |
| 969 | _First += _Significand_distance; | |
| 970 | ||
| 971 | // Copy the exponent to the output range. | |
| 972 | if (!_Use_fixed_notation) { | |
| 973 | const ptrdiff_t _Exponent_distance = _Exponent_last - _Exponent_first; | |
| 974 | if (_Last - _First < _Exponent_distance) { | |
| 975 | return {_Last, errc::value_too_large}; | |
| 976 | } | |
| 977 | _VSTD::memcpy(_First, _Exponent_first, static_cast<size_t>(_Exponent_distance)); | |
| 978 | _First += _Exponent_distance; | |
| 979 | } | |
| 980 | ||
| 981 | return {_First, errc{}}; | |
| 982 | } | |
| 983 | ||
| 984 | enum class _Floating_to_chars_overload { _Plain, _Format_only, _Format_precision }; | |
| 985 | ||
| 986 | template <_Floating_to_chars_overload _Overload, class _Floating> | |
| 987 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 988 | to_chars_result _Floating_to_chars( | |
| 989 | char* _First, char* const _Last, _Floating _Value, const chars_format _Fmt, const int _Precision) noexcept { | |
| 990 | ||
| 991 | if constexpr (_Overload == _Floating_to_chars_overload::_Plain) { | |
| 992 | _LIBCPP_ASSERT(_Fmt == chars_format{}, ""); // plain overload must pass chars_format{} internally | |
| 993 | } else { | |
| 994 | _LIBCPP_ASSERT(_Fmt == chars_format::general || _Fmt == chars_format::scientific || _Fmt == chars_format::fixed | |
| 995 | || _Fmt == chars_format::hex, | |
| 996 | "invalid format in to_chars()"); | |
| 997 | } | |
| 998 | ||
| 999 | using _Traits = _Floating_type_traits<_Floating>; | |
| 1000 | using _Uint_type = typename _Traits::_Uint_type; | |
| 1001 | ||
| 1002 | _Uint_type _Uint_value = _VSTD::bit_cast<_Uint_type>(_Value); | |
| 1003 | ||
| 1004 | const bool _Was_negative = (_Uint_value & _Traits::_Shifted_sign_mask) != 0; | |
| 1005 | ||
| 1006 | if (_Was_negative) { // sign bit detected; write minus sign and clear sign bit | |
| 1007 | if (_First == _Last) { | |
| 1008 | return {_Last, errc::value_too_large}; | |
| 1009 | } | |
| 1010 | ||
| 1011 | *_First++ = '-'; | |
| 1012 | ||
| 1013 | _Uint_value &= ~_Traits::_Shifted_sign_mask; | |
| 1014 | _Value = _VSTD::bit_cast<_Floating>(_Uint_value); | |
| 1015 | } | |
| 1016 | ||
| 1017 | if ((_Uint_value & _Traits::_Shifted_exponent_mask) == _Traits::_Shifted_exponent_mask) { | |
| 1018 | // inf/nan detected; write appropriate string and return | |
| 1019 | const char* _Str; | |
| 1020 | size_t _Len; | |
| 1021 | ||
| 1022 | const _Uint_type _Mantissa = _Uint_value & _Traits::_Denormal_mantissa_mask; | |
| 1023 | ||
| 1024 | if (_Mantissa == 0) { | |
| 1025 | _Str = "inf"; | |
| 1026 | _Len = 3; | |
| 1027 | } else if (_Was_negative && _Mantissa == _Traits::_Special_nan_mantissa_mask) { | |
| 1028 | // When a NaN value has the sign bit set, the quiet bit set, and all other mantissa bits cleared, | |
| 1029 | // the UCRT interprets it to mean "indeterminate", and indicates this by printing "-nan(ind)". | |
| 1030 | _Str = "nan(ind)"; | |
| 1031 | _Len = 8; | |
| 1032 | } else if ((_Mantissa & _Traits::_Special_nan_mantissa_mask) != 0) { | |
| 1033 | _Str = "nan"; | |
| 1034 | _Len = 3; | |
| 1035 | } else { | |
| 1036 | _Str = "nan(snan)"; | |
| 1037 | _Len = 9; | |
| 1038 | } | |
| 1039 | ||
| 1040 | if (_Last - _First < static_cast<ptrdiff_t>(_Len)) { | |
| 1041 | return {_Last, errc::value_too_large}; | |
| 1042 | } | |
| 1043 | ||
| 1044 | _VSTD::memcpy(_First, _Str, _Len); | |
| 1045 | ||
| 1046 | return {_First + _Len, errc{}}; | |
| 1047 | } | |
| 1048 | ||
| 1049 | if constexpr (_Overload == _Floating_to_chars_overload::_Plain) { | |
| 1050 | return _Floating_to_chars_ryu(_First, _Last, _Value, chars_format{}); | |
| 1051 | } else if constexpr (_Overload == _Floating_to_chars_overload::_Format_only) { | |
| 1052 | if (_Fmt == chars_format::hex) { | |
| 1053 | return _Floating_to_chars_hex_shortest(_First, _Last, _Value); | |
| 1054 | } | |
| 1055 | ||
| 1056 | return _Floating_to_chars_ryu(_First, _Last, _Value, _Fmt); | |
| 1057 | } else if constexpr (_Overload == _Floating_to_chars_overload::_Format_precision) { | |
| 1058 | switch (_Fmt) { | |
| 1059 | case chars_format::scientific: | |
| 1060 | return _Floating_to_chars_scientific_precision(_First, _Last, _Value, _Precision); | |
| 1061 | case chars_format::fixed: | |
| 1062 | return _Floating_to_chars_fixed_precision(_First, _Last, _Value, _Precision); | |
| 1063 | case chars_format::general: | |
| 1064 | return _Floating_to_chars_general_precision(_First, _Last, _Value, _Precision); | |
| 1065 | case chars_format::hex: | |
| 1066 | default: // avoid MSVC warning C4715: not all control paths return a value | |
| 1067 | return _Floating_to_chars_hex_precision(_First, _Last, _Value, _Precision); | |
| 1068 | } | |
| 1069 | } | |
| 1070 | } | |
| 1071 | ||
| 1072 | // clang-format on | |
| 1073 | ||
| 1074 | _LIBCPP_END_NAMESPACE_STD | |
| 1075 | ||
| 1076 | #endif // _LIBCPP_SRC_INCLUDE_TO_CHARS_FLOATING_POINT_H |
lib/libcxx/src/ios.cpp+2-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- ios.cpp -----------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -137,7 +137,7 @@ ios_base::getloc() const |
| 137 | 137 | |
| 138 | 138 | // xalloc |
| 139 | 139 | #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) |
| 140 | atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0); | |
| 140 | atomic<int> ios_base::__xindex_{0}; | |
| 141 | 141 | #else |
| 142 | 142 | int ios_base::__xindex_ = 0; |
| 143 | 143 | #endif |
lib/libcxx/src/ios.instantiations.cpp+7-4| ... | ... | @@ -19,15 +19,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | 20 | // Original explicit instantiations provided in the library |
| 21 | 21 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<char>; |
| 22 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>; | |
| 23 | 22 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<char>; |
| 24 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>; | |
| 25 | 23 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<char>; |
| 26 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>; | |
| 27 | 24 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<char>; |
| 28 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>; | |
| 29 | 25 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_iostream<char>; |
| 30 | 26 | |
| 27 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 28 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<wchar_t>; | |
| 29 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_streambuf<wchar_t>; | |
| 30 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_istream<wchar_t>; | |
| 31 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>; | |
| 32 | #endif | |
| 33 | ||
| 31 | 34 | // Additional instantiations added later. Whether programs rely on these being |
| 32 | 35 | // available is protected by _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1. |
| 33 | 36 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>; |
lib/libcxx/src/iostream.cpp+29-24| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ iostream.cpp --------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -17,7 +17,6 @@ |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | #ifndef _LIBCPP_HAS_NO_STDIN | |
| 21 | 20 | _ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin[sizeof(istream)] |
| 22 | 21 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 23 | 22 | __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| ... | ... | @@ -25,6 +24,8 @@ __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_trai |
| 25 | 24 | ; |
| 26 | 25 | _ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin[sizeof(__stdinbuf <char>)]; |
| 27 | 26 | static mbstate_t mb_cin; |
| 27 | ||
| 28 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 28 | 29 | _ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin[sizeof(wistream)] |
| 29 | 30 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 30 | 31 | __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| ... | ... | @@ -32,9 +33,8 @@ __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_tr |
| 32 | 33 | ; |
| 33 | 34 | _ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin[sizeof(__stdinbuf <wchar_t>)]; |
| 34 | 35 | static mbstate_t mb_wcin; |
| 35 | #endif | |
| 36 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 36 | 37 | |
| 37 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 38 | 38 | _ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)] |
| 39 | 39 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 40 | 40 | __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| ... | ... | @@ -42,6 +42,8 @@ __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_tra |
| 42 | 42 | ; |
| 43 | 43 | _ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)]; |
| 44 | 44 | static mbstate_t mb_cout; |
| 45 | ||
| 46 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 45 | 47 | _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)] |
| 46 | 48 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 47 | 49 | __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| ... | ... | @@ -49,7 +51,7 @@ __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_t |
| 49 | 51 | ; |
| 50 | 52 | _ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; |
| 51 | 53 | static mbstate_t mb_wcout; |
| 52 | #endif | |
| 54 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 53 | 55 | |
| 54 | 56 | _ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)] |
| 55 | 57 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| ... | ... | @@ -58,6 +60,8 @@ __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_tra |
| 58 | 60 | ; |
| 59 | 61 | _ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)]; |
| 60 | 62 | static mbstate_t mb_cerr; |
| 63 | ||
| 64 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 61 | 65 | _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)] |
| 62 | 66 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 63 | 67 | __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| ... | ... | @@ -65,19 +69,25 @@ __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_t |
| 65 | 69 | ; |
| 66 | 70 | _ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; |
| 67 | 71 | static mbstate_t mb_wcerr; |
| 72 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 68 | 73 | |
| 69 | 74 | _ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)] |
| 70 | 75 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 71 | 76 | __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| 72 | 77 | #endif |
| 73 | 78 | ; |
| 79 | ||
| 80 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 74 | 81 | _ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)] |
| 75 | 82 | #if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__) |
| 76 | 83 | __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A") |
| 77 | 84 | #endif |
| 78 | 85 | ; |
| 86 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 79 | 87 | |
| 80 | _LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX; | |
| 88 | // Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority | |
| 89 | // attribute with a value that's reserved for the implementation (we're the implementation). | |
| 90 | #include "iostream_init.h" | |
| 81 | 91 | |
| 82 | 92 | // On Windows the TLS storage for locales needs to be initialized before we create |
| 83 | 93 | // the standard streams, otherwise it may not be alive during program termination |
| ... | ... | @@ -107,44 +117,39 @@ DoIOSInit::DoIOSInit() |
| 107 | 117 | { |
| 108 | 118 | force_locale_initialization(); |
| 109 | 119 | |
| 110 | #ifndef _LIBCPP_HAS_NO_STDIN | |
| 111 | 120 | istream* cin_ptr = ::new(cin) istream(::new(__cin) __stdinbuf <char>(stdin, &mb_cin)); |
| 112 | wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin)); | |
| 113 | #endif | |
| 114 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 115 | 121 | ostream* cout_ptr = ::new(cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout)); |
| 116 | wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout)); | |
| 117 | #endif | |
| 118 | 122 | ostream* cerr_ptr = ::new(cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr)); |
| 119 | 123 | ::new(clog) ostream(cerr_ptr->rdbuf()); |
| 124 | cin_ptr->tie(cout_ptr); | |
| 125 | _VSTD::unitbuf(*cerr_ptr); | |
| 126 | cerr_ptr->tie(cout_ptr); | |
| 127 | ||
| 128 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 129 | wistream* wcin_ptr = ::new(wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin)); | |
| 130 | wostream* wcout_ptr = ::new(wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout)); | |
| 120 | 131 | wostream* wcerr_ptr = ::new(wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr)); |
| 121 | 132 | ::new(wclog) wostream(wcerr_ptr->rdbuf()); |
| 122 | 133 | |
| 123 | #if !defined(_LIBCPP_HAS_NO_STDIN) && !defined(_LIBCPP_HAS_NO_STDOUT) | |
| 124 | cin_ptr->tie(cout_ptr); | |
| 125 | 134 | wcin_ptr->tie(wcout_ptr); |
| 126 | #endif | |
| 127 | _VSTD::unitbuf(*cerr_ptr); | |
| 128 | 135 | _VSTD::unitbuf(*wcerr_ptr); |
| 129 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 130 | cerr_ptr->tie(cout_ptr); | |
| 131 | 136 | wcerr_ptr->tie(wcout_ptr); |
| 132 | 137 | #endif |
| 133 | 138 | } |
| 134 | 139 | |
| 135 | 140 | DoIOSInit::~DoIOSInit() |
| 136 | 141 | { |
| 137 | #ifndef _LIBCPP_HAS_NO_STDOUT | |
| 138 | 142 | ostream* cout_ptr = reinterpret_cast<ostream*>(cout); |
| 139 | wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout); | |
| 140 | 143 | cout_ptr->flush(); |
| 141 | wcout_ptr->flush(); | |
| 142 | #endif | |
| 143 | ||
| 144 | 144 | ostream* clog_ptr = reinterpret_cast<ostream*>(clog); |
| 145 | wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog); | |
| 146 | 145 | clog_ptr->flush(); |
| 146 | ||
| 147 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 148 | wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout); | |
| 149 | wcout_ptr->flush(); | |
| 150 | wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog); | |
| 147 | 151 | wclog_ptr->flush(); |
| 152 | #endif | |
| 148 | 153 | } |
| 149 | 154 | |
| 150 | 155 | ios_base::Init::Init() |
lib/libcxx/src/iostream_init.h created+2| ... | ... | @@ -0,0 +1,2 @@ |
| 1 | #pragma GCC system_header | |
| 2 | _LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX; |
lib/libcxx/src/legacy_pointer_safety.cpp created+23| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #include "__config" | |
| 10 | #include <memory> | |
| 11 | ||
| 12 | // Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements | |
| 13 | // that removal as an extension in all Standard versions. However, we still define the functions that | |
| 14 | // were once part of the library's ABI for backwards compatibility. | |
| 15 | ||
| 16 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 17 | ||
| 18 | _LIBCPP_FUNC_VIS void declare_reachable(void*) {} | |
| 19 | _LIBCPP_FUNC_VIS void declare_no_pointers(char*, size_t) {} | |
| 20 | _LIBCPP_FUNC_VIS void undeclare_no_pointers(char*, size_t) {} | |
| 21 | _LIBCPP_FUNC_VIS void* __undeclare_reachable(void* p) { return p; } | |
| 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/locale.cpp+363-109| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- locale.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -12,28 +12,36 @@ |
| 12 | 12 | #define _LCONV_C99 |
| 13 | 13 | #endif |
| 14 | 14 | |
| 15 | #include "string" | |
| 16 | #include "locale" | |
| 17 | #include "codecvt" | |
| 18 | #include "vector" | |
| 19 | 15 | #include "algorithm" |
| 20 | #include "typeinfo" | |
| 21 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 22 | # include "type_traits" | |
| 23 | #endif | |
| 24 | 16 | #include "clocale" |
| 17 | #include "codecvt" | |
| 18 | #include "cstdio" | |
| 19 | #include "cstdlib" | |
| 25 | 20 | #include "cstring" |
| 21 | #include "locale" | |
| 22 | #include "string" | |
| 23 | #include "type_traits" | |
| 24 | #include "typeinfo" | |
| 25 | #include "vector" | |
| 26 | ||
| 27 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 28 | # include "cwctype" | |
| 29 | #endif | |
| 30 | ||
| 31 | #if defined(_AIX) | |
| 32 | # include <sys/localedef.h> // for __lc_ctype_ptr | |
| 33 | #endif | |
| 34 | ||
| 26 | 35 | #if defined(_LIBCPP_MSVCRT) |
| 27 | #define _CTYPE_DISABLE_MACROS | |
| 36 | # define _CTYPE_DISABLE_MACROS | |
| 28 | 37 | #endif |
| 29 | #include "cwctype" | |
| 38 | ||
| 30 | 39 | #if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) |
| 31 | #include "__support/win32/locale_win32.h" | |
| 40 | # include "__support/win32/locale_win32.h" | |
| 32 | 41 | #elif !defined(__BIONIC__) && !defined(__NuttX__) |
| 33 | #include <langinfo.h> | |
| 42 | # include <langinfo.h> | |
| 34 | 43 | #endif |
| 35 | #include <stdlib.h> | |
| 36 | #include <stdio.h> | |
| 44 | ||
| 37 | 45 | #include "include/atomic_support.h" |
| 38 | 46 | #include "include/sso_allocator.h" |
| 39 | 47 | #include "__undef_macros" |
| ... | ... | @@ -81,33 +89,11 @@ struct release |
| 81 | 89 | void operator()(locale::facet* p) {p->__release_shared();} |
| 82 | 90 | }; |
| 83 | 91 | |
| 84 | template <class T, class A0> | |
| 85 | inline | |
| 86 | T& | |
| 87 | make(A0 a0) | |
| 92 | template <class T, class ...Args> | |
| 93 | T& make(Args ...args) | |
| 88 | 94 | { |
| 89 | 95 | static typename aligned_storage<sizeof(T)>::type buf; |
| 90 | auto *obj = ::new (&buf) T(a0); | |
| 91 | return *obj; | |
| 92 | } | |
| 93 | ||
| 94 | template <class T, class A0, class A1> | |
| 95 | inline | |
| 96 | T& | |
| 97 | make(A0 a0, A1 a1) | |
| 98 | { | |
| 99 | static typename aligned_storage<sizeof(T)>::type buf; | |
| 100 | ::new (&buf) T(a0, a1); | |
| 101 | return *reinterpret_cast<T*>(&buf); | |
| 102 | } | |
| 103 | ||
| 104 | template <class T, class A0, class A1, class A2> | |
| 105 | inline | |
| 106 | T& | |
| 107 | make(A0 a0, A1 a1, A2 a2) | |
| 108 | { | |
| 109 | static typename aligned_storage<sizeof(T)>::type buf; | |
| 110 | auto *obj = ::new (&buf) T(a0, a1, a2); | |
| 96 | auto *obj = ::new (&buf) T(args...); | |
| 111 | 97 | return *obj; |
| 112 | 98 | } |
| 113 | 99 | |
| ... | ... | @@ -197,11 +183,17 @@ locale::__imp::__imp(size_t refs) |
| 197 | 183 | { |
| 198 | 184 | facets_.clear(); |
| 199 | 185 | install(&make<_VSTD::collate<char> >(1u)); |
| 186 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 200 | 187 | install(&make<_VSTD::collate<wchar_t> >(1u)); |
| 188 | #endif | |
| 201 | 189 | install(&make<_VSTD::ctype<char> >(nullptr, false, 1u)); |
| 190 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 202 | 191 | install(&make<_VSTD::ctype<wchar_t> >(1u)); |
| 192 | #endif | |
| 203 | 193 | install(&make<codecvt<char, char, mbstate_t> >(1u)); |
| 194 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 204 | 195 | install(&make<codecvt<wchar_t, char, mbstate_t> >(1u)); |
| 196 | #endif | |
| 205 | 197 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 206 | 198 | install(&make<codecvt<char16_t, char, mbstate_t> >(1u)); |
| 207 | 199 | install(&make<codecvt<char32_t, char, mbstate_t> >(1u)); |
| ... | ... | @@ -211,25 +203,43 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 211 | 203 | install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u)); |
| 212 | 204 | #endif |
| 213 | 205 | install(&make<numpunct<char> >(1u)); |
| 206 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 214 | 207 | install(&make<numpunct<wchar_t> >(1u)); |
| 208 | #endif | |
| 215 | 209 | install(&make<num_get<char> >(1u)); |
| 210 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 216 | 211 | install(&make<num_get<wchar_t> >(1u)); |
| 212 | #endif | |
| 217 | 213 | install(&make<num_put<char> >(1u)); |
| 214 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 218 | 215 | install(&make<num_put<wchar_t> >(1u)); |
| 216 | #endif | |
| 219 | 217 | install(&make<moneypunct<char, false> >(1u)); |
| 220 | 218 | install(&make<moneypunct<char, true> >(1u)); |
| 219 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 221 | 220 | install(&make<moneypunct<wchar_t, false> >(1u)); |
| 222 | 221 | install(&make<moneypunct<wchar_t, true> >(1u)); |
| 222 | #endif | |
| 223 | 223 | install(&make<money_get<char> >(1u)); |
| 224 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 224 | 225 | install(&make<money_get<wchar_t> >(1u)); |
| 226 | #endif | |
| 225 | 227 | install(&make<money_put<char> >(1u)); |
| 228 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 226 | 229 | install(&make<money_put<wchar_t> >(1u)); |
| 230 | #endif | |
| 227 | 231 | install(&make<time_get<char> >(1u)); |
| 232 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 228 | 233 | install(&make<time_get<wchar_t> >(1u)); |
| 234 | #endif | |
| 229 | 235 | install(&make<time_put<char> >(1u)); |
| 236 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 230 | 237 | install(&make<time_put<wchar_t> >(1u)); |
| 238 | #endif | |
| 231 | 239 | install(&make<_VSTD::messages<char> >(1u)); |
| 240 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 232 | 241 | install(&make<_VSTD::messages<wchar_t> >(1u)); |
| 242 | #endif | |
| 233 | 243 | } |
| 234 | 244 | |
| 235 | 245 | locale::__imp::__imp(const string& name, size_t refs) |
| ... | ... | @@ -246,11 +256,17 @@ locale::__imp::__imp(const string& name, size_t refs) |
| 246 | 256 | if (facets_[i]) |
| 247 | 257 | facets_[i]->__add_shared(); |
| 248 | 258 | install(new collate_byname<char>(name_)); |
| 259 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 249 | 260 | install(new collate_byname<wchar_t>(name_)); |
| 261 | #endif | |
| 250 | 262 | install(new ctype_byname<char>(name_)); |
| 263 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 251 | 264 | install(new ctype_byname<wchar_t>(name_)); |
| 265 | #endif | |
| 252 | 266 | install(new codecvt_byname<char, char, mbstate_t>(name_)); |
| 267 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 253 | 268 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name_)); |
| 269 | #endif | |
| 254 | 270 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 255 | 271 | install(new codecvt_byname<char16_t, char, mbstate_t>(name_)); |
| 256 | 272 | install(new codecvt_byname<char32_t, char, mbstate_t>(name_)); |
| ... | ... | @@ -260,17 +276,27 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 260 | 276 | install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_)); |
| 261 | 277 | #endif |
| 262 | 278 | install(new numpunct_byname<char>(name_)); |
| 279 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 263 | 280 | install(new numpunct_byname<wchar_t>(name_)); |
| 281 | #endif | |
| 264 | 282 | install(new moneypunct_byname<char, false>(name_)); |
| 265 | 283 | install(new moneypunct_byname<char, true>(name_)); |
| 284 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 266 | 285 | install(new moneypunct_byname<wchar_t, false>(name_)); |
| 267 | 286 | install(new moneypunct_byname<wchar_t, true>(name_)); |
| 287 | #endif | |
| 268 | 288 | install(new time_get_byname<char>(name_)); |
| 289 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 269 | 290 | install(new time_get_byname<wchar_t>(name_)); |
| 291 | #endif | |
| 270 | 292 | install(new time_put_byname<char>(name_)); |
| 293 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 271 | 294 | install(new time_put_byname<wchar_t>(name_)); |
| 295 | #endif | |
| 272 | 296 | install(new messages_byname<char>(name_)); |
| 297 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 273 | 298 | install(new messages_byname<wchar_t>(name_)); |
| 299 | #endif | |
| 274 | 300 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 275 | 301 | } |
| 276 | 302 | catch (...) |
| ... | ... | @@ -283,13 +309,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 283 | 309 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 284 | 310 | } |
| 285 | 311 | |
| 286 | // NOTE avoid the `base class should be explicitly initialized in the | |
| 287 | // copy constructor` warning emitted by GCC | |
| 288 | #if defined(__clang__) || _GNUC_VER >= 406 | |
| 289 | #pragma GCC diagnostic push | |
| 290 | #pragma GCC diagnostic ignored "-Wextra" | |
| 291 | #endif | |
| 292 | ||
| 293 | 312 | locale::__imp::__imp(const __imp& other) |
| 294 | 313 | : facets_(max<size_t>(N, other.facets_.size())), |
| 295 | 314 | name_(other.name_) |
| ... | ... | @@ -300,10 +319,6 @@ locale::__imp::__imp(const __imp& other) |
| 300 | 319 | facets_[i]->__add_shared(); |
| 301 | 320 | } |
| 302 | 321 | |
| 303 | #if defined(__clang__) || _GNUC_VER >= 406 | |
| 304 | #pragma GCC diagnostic pop | |
| 305 | #endif | |
| 306 | ||
| 307 | 322 | locale::__imp::__imp(const __imp& other, const string& name, locale::category c) |
| 308 | 323 | : facets_(N), |
| 309 | 324 | name_("*") |
| ... | ... | @@ -319,14 +334,20 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) |
| 319 | 334 | if (c & locale::collate) |
| 320 | 335 | { |
| 321 | 336 | install(new collate_byname<char>(name)); |
| 337 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 322 | 338 | install(new collate_byname<wchar_t>(name)); |
| 339 | #endif | |
| 323 | 340 | } |
| 324 | 341 | if (c & locale::ctype) |
| 325 | 342 | { |
| 326 | 343 | install(new ctype_byname<char>(name)); |
| 344 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 327 | 345 | install(new ctype_byname<wchar_t>(name)); |
| 346 | #endif | |
| 328 | 347 | install(new codecvt_byname<char, char, mbstate_t>(name)); |
| 348 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 329 | 349 | install(new codecvt_byname<wchar_t, char, mbstate_t>(name)); |
| 350 | #endif | |
| 330 | 351 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 331 | 352 | install(new codecvt_byname<char16_t, char, mbstate_t>(name)); |
| 332 | 353 | install(new codecvt_byname<char32_t, char, mbstate_t>(name)); |
| ... | ... | @@ -340,25 +361,35 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 340 | 361 | { |
| 341 | 362 | install(new moneypunct_byname<char, false>(name)); |
| 342 | 363 | install(new moneypunct_byname<char, true>(name)); |
| 364 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 343 | 365 | install(new moneypunct_byname<wchar_t, false>(name)); |
| 344 | 366 | install(new moneypunct_byname<wchar_t, true>(name)); |
| 367 | #endif | |
| 345 | 368 | } |
| 346 | 369 | if (c & locale::numeric) |
| 347 | 370 | { |
| 348 | 371 | install(new numpunct_byname<char>(name)); |
| 372 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 349 | 373 | install(new numpunct_byname<wchar_t>(name)); |
| 374 | #endif | |
| 350 | 375 | } |
| 351 | 376 | if (c & locale::time) |
| 352 | 377 | { |
| 353 | 378 | install(new time_get_byname<char>(name)); |
| 379 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 354 | 380 | install(new time_get_byname<wchar_t>(name)); |
| 381 | #endif | |
| 355 | 382 | install(new time_put_byname<char>(name)); |
| 383 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 356 | 384 | install(new time_put_byname<wchar_t>(name)); |
| 385 | #endif | |
| 357 | 386 | } |
| 358 | 387 | if (c & locale::messages) |
| 359 | 388 | { |
| 360 | 389 | install(new messages_byname<char>(name)); |
| 390 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 361 | 391 | install(new messages_byname<wchar_t>(name)); |
| 392 | #endif | |
| 362 | 393 | } |
| 363 | 394 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 364 | 395 | } |
| ... | ... | @@ -396,12 +427,16 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) |
| 396 | 427 | if (c & locale::collate) |
| 397 | 428 | { |
| 398 | 429 | install_from<_VSTD::collate<char> >(one); |
| 430 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 399 | 431 | install_from<_VSTD::collate<wchar_t> >(one); |
| 432 | #endif | |
| 400 | 433 | } |
| 401 | 434 | if (c & locale::ctype) |
| 402 | 435 | { |
| 403 | 436 | install_from<_VSTD::ctype<char> >(one); |
| 437 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 404 | 438 | install_from<_VSTD::ctype<wchar_t> >(one); |
| 439 | #endif | |
| 405 | 440 | install_from<_VSTD::codecvt<char, char, mbstate_t> >(one); |
| 406 | 441 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 407 | 442 | install_from<_VSTD::codecvt<char16_t, char, mbstate_t> >(one); |
| ... | ... | @@ -411,39 +446,59 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 411 | 446 | install_from<_VSTD::codecvt<char16_t, char8_t, mbstate_t> >(one); |
| 412 | 447 | install_from<_VSTD::codecvt<char32_t, char8_t, mbstate_t> >(one); |
| 413 | 448 | #endif |
| 449 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 414 | 450 | install_from<_VSTD::codecvt<wchar_t, char, mbstate_t> >(one); |
| 451 | #endif | |
| 415 | 452 | } |
| 416 | 453 | if (c & locale::monetary) |
| 417 | 454 | { |
| 418 | 455 | install_from<moneypunct<char, false> >(one); |
| 419 | 456 | install_from<moneypunct<char, true> >(one); |
| 457 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 420 | 458 | install_from<moneypunct<wchar_t, false> >(one); |
| 421 | 459 | install_from<moneypunct<wchar_t, true> >(one); |
| 460 | #endif | |
| 422 | 461 | install_from<money_get<char> >(one); |
| 462 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 423 | 463 | install_from<money_get<wchar_t> >(one); |
| 464 | #endif | |
| 424 | 465 | install_from<money_put<char> >(one); |
| 466 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 425 | 467 | install_from<money_put<wchar_t> >(one); |
| 468 | #endif | |
| 426 | 469 | } |
| 427 | 470 | if (c & locale::numeric) |
| 428 | 471 | { |
| 429 | 472 | install_from<numpunct<char> >(one); |
| 473 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 430 | 474 | install_from<numpunct<wchar_t> >(one); |
| 475 | #endif | |
| 431 | 476 | install_from<num_get<char> >(one); |
| 477 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 432 | 478 | install_from<num_get<wchar_t> >(one); |
| 479 | #endif | |
| 433 | 480 | install_from<num_put<char> >(one); |
| 481 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 434 | 482 | install_from<num_put<wchar_t> >(one); |
| 483 | #endif | |
| 435 | 484 | } |
| 436 | 485 | if (c & locale::time) |
| 437 | 486 | { |
| 438 | 487 | install_from<time_get<char> >(one); |
| 488 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 439 | 489 | install_from<time_get<wchar_t> >(one); |
| 490 | #endif | |
| 440 | 491 | install_from<time_put<char> >(one); |
| 492 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 441 | 493 | install_from<time_put<wchar_t> >(one); |
| 494 | #endif | |
| 442 | 495 | } |
| 443 | 496 | if (c & locale::messages) |
| 444 | 497 | { |
| 445 | 498 | install_from<_VSTD::messages<char> >(one); |
| 499 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 446 | 500 | install_from<_VSTD::messages<wchar_t> >(one); |
| 501 | #endif | |
| 447 | 502 | } |
| 448 | 503 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 449 | 504 | } |
| ... | ... | @@ -734,6 +789,7 @@ collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) con |
| 734 | 789 | |
| 735 | 790 | // template <> class collate_byname<wchar_t> |
| 736 | 791 | |
| 792 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 737 | 793 | collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) |
| 738 | 794 | : collate<wchar_t>(refs), |
| 739 | 795 | __l(newlocale(LC_ALL_MASK, n, 0)) |
| ... | ... | @@ -779,8 +835,7 @@ collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) |
| 779 | 835 | wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l); |
| 780 | 836 | return out; |
| 781 | 837 | } |
| 782 | ||
| 783 | // template <> class ctype<wchar_t>; | |
| 838 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 784 | 839 | |
| 785 | 840 | const ctype_base::mask ctype_base::space; |
| 786 | 841 | const ctype_base::mask ctype_base::print; |
| ... | ... | @@ -795,6 +850,9 @@ const ctype_base::mask ctype_base::blank; |
| 795 | 850 | const ctype_base::mask ctype_base::alnum; |
| 796 | 851 | const ctype_base::mask ctype_base::graph; |
| 797 | 852 | |
| 853 | // template <> class ctype<wchar_t>; | |
| 854 | ||
| 855 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 798 | 856 | locale::id ctype<wchar_t>::id; |
| 799 | 857 | |
| 800 | 858 | ctype<wchar_t>::~ctype() |
| ... | ... | @@ -840,7 +898,7 @@ ctype<wchar_t>::do_toupper(char_type c) const |
| 840 | 898 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 841 | 899 | return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; |
| 842 | 900 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ |
| 843 | defined(__NetBSD__) | |
| 901 | defined(__NetBSD__) || defined(__MVS__) | |
| 844 | 902 | return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c; |
| 845 | 903 | #else |
| 846 | 904 | return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c; |
| ... | ... | @@ -854,7 +912,7 @@ ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const |
| 854 | 912 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 855 | 913 | *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; |
| 856 | 914 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ |
| 857 | defined(__NetBSD__) | |
| 915 | defined(__NetBSD__) || defined(__MVS__) | |
| 858 | 916 | *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low] |
| 859 | 917 | : *low; |
| 860 | 918 | #else |
| ... | ... | @@ -869,7 +927,7 @@ ctype<wchar_t>::do_tolower(char_type c) const |
| 869 | 927 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 870 | 928 | return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c; |
| 871 | 929 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ |
| 872 | defined(__NetBSD__) | |
| 930 | defined(__NetBSD__) || defined(__MVS__) | |
| 873 | 931 | return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c; |
| 874 | 932 | #else |
| 875 | 933 | return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c; |
| ... | ... | @@ -883,7 +941,7 @@ ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const |
| 883 | 941 | #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE |
| 884 | 942 | *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low; |
| 885 | 943 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ |
| 886 | defined(__NetBSD__) | |
| 944 | defined(__NetBSD__) || defined(__MVS__) | |
| 887 | 945 | *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low] |
| 888 | 946 | : *low; |
| 889 | 947 | #else |
| ... | ... | @@ -924,11 +982,14 @@ ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfau |
| 924 | 982 | *dest = dfault; |
| 925 | 983 | return low; |
| 926 | 984 | } |
| 985 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 927 | 986 | |
| 928 | 987 | // template <> class ctype<char>; |
| 929 | 988 | |
| 930 | 989 | locale::id ctype<char>::id; |
| 931 | 990 | |
| 991 | const size_t ctype<char>::table_size; | |
| 992 | ||
| 932 | 993 | ctype<char>::ctype(const mask* tab, bool del, size_t refs) |
| 933 | 994 | : locale::facet(refs), |
| 934 | 995 | __tab_(tab), |
| ... | ... | @@ -952,7 +1013,7 @@ ctype<char>::do_toupper(char_type c) const |
| 952 | 1013 | static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c; |
| 953 | 1014 | #elif defined(__NetBSD__) |
| 954 | 1015 | return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]); |
| 955 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) | |
| 1016 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | |
| 956 | 1017 | return isascii(c) ? |
| 957 | 1018 | static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c; |
| 958 | 1019 | #else |
| ... | ... | @@ -969,7 +1030,7 @@ ctype<char>::do_toupper(char_type* low, const char_type* high) const |
| 969 | 1030 | static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low; |
| 970 | 1031 | #elif defined(__NetBSD__) |
| 971 | 1032 | *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]); |
| 972 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) | |
| 1033 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | |
| 973 | 1034 | *low = isascii(*low) ? |
| 974 | 1035 | static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low; |
| 975 | 1036 | #else |
| ... | ... | @@ -986,7 +1047,7 @@ ctype<char>::do_tolower(char_type c) const |
| 986 | 1047 | static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c; |
| 987 | 1048 | #elif defined(__NetBSD__) |
| 988 | 1049 | return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]); |
| 989 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) | |
| 1050 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | |
| 990 | 1051 | return isascii(c) ? |
| 991 | 1052 | static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c; |
| 992 | 1053 | #else |
| ... | ... | @@ -1002,7 +1063,7 @@ ctype<char>::do_tolower(char_type* low, const char_type* high) const |
| 1002 | 1063 | *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low; |
| 1003 | 1064 | #elif defined(__NetBSD__) |
| 1004 | 1065 | *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]); |
| 1005 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) | |
| 1066 | #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__) | |
| 1006 | 1067 | *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low; |
| 1007 | 1068 | #else |
| 1008 | 1069 | *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low; |
| ... | ... | @@ -1133,7 +1194,7 @@ ctype<char>::classic_table() noexcept |
| 1133 | 1194 | const ctype<char>::mask* |
| 1134 | 1195 | ctype<char>::classic_table() noexcept |
| 1135 | 1196 | { |
| 1136 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) | |
| 1197 | #if defined(__APPLE__) || defined(__FreeBSD__) | |
| 1137 | 1198 | return _DefaultRuneLocale.__runetype; |
| 1138 | 1199 | #elif defined(__NetBSD__) |
| 1139 | 1200 | return _C_ctype_tab_ + 1; |
| ... | ... | @@ -1150,6 +1211,12 @@ ctype<char>::classic_table() noexcept |
| 1150 | 1211 | return _ctype_ + 1; |
| 1151 | 1212 | #elif defined(_AIX) |
| 1152 | 1213 | return (const unsigned int *)__lc_ctype_ptr->obj->mask; |
| 1214 | #elif defined(__MVS__) | |
| 1215 | # if defined(__NATIVE_ASCII_F) | |
| 1216 | return const_cast<const ctype<char>::mask*> (__OBJ_DATA(__lc_ctype_a)->mask); | |
| 1217 | # else | |
| 1218 | return const_cast<const ctype<char>::mask*> (__ctypec); | |
| 1219 | # endif | |
| 1153 | 1220 | #else |
| 1154 | 1221 | // Platform not supported: abort so the person doing the port knows what to |
| 1155 | 1222 | // fix |
| ... | ... | @@ -1198,7 +1265,26 @@ ctype<char>::__classic_upper_table() noexcept |
| 1198 | 1265 | { |
| 1199 | 1266 | return *__ctype_toupper_loc(); |
| 1200 | 1267 | } |
| 1201 | #endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ | |
| 1268 | #elif defined(__MVS__) | |
| 1269 | const unsigned short* | |
| 1270 | ctype<char>::__classic_lower_table() _NOEXCEPT | |
| 1271 | { | |
| 1272 | # if defined(__NATIVE_ASCII_F) | |
| 1273 | return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->lower); | |
| 1274 | # else | |
| 1275 | return const_cast<const unsigned short*>(__ctype + __TOLOWER_INDEX); | |
| 1276 | # endif | |
| 1277 | } | |
| 1278 | const unsigned short * | |
| 1279 | ctype<char>::__classic_upper_table() _NOEXCEPT | |
| 1280 | { | |
| 1281 | # if defined(__NATIVE_ASCII_F) | |
| 1282 | return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->upper); | |
| 1283 | # else | |
| 1284 | return const_cast<const unsigned short*>(__ctype + __TOUPPER_INDEX); | |
| 1285 | # endif | |
| 1286 | } | |
| 1287 | #endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ || __MVS__ | |
| 1202 | 1288 | |
| 1203 | 1289 | // template <> class ctype_byname<char> |
| 1204 | 1290 | |
| ... | ... | @@ -1255,6 +1341,7 @@ ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const |
| 1255 | 1341 | |
| 1256 | 1342 | // template <> class ctype_byname<wchar_t> |
| 1257 | 1343 | |
| 1344 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1258 | 1345 | ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) |
| 1259 | 1346 | : ctype<wchar_t>(refs), |
| 1260 | 1347 | __l(newlocale(LC_ALL_MASK, name, 0)) |
| ... | ... | @@ -1454,6 +1541,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch |
| 1454 | 1541 | } |
| 1455 | 1542 | return low; |
| 1456 | 1543 | } |
| 1544 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1457 | 1545 | |
| 1458 | 1546 | // template <> class codecvt<char, char, mbstate_t> |
| 1459 | 1547 | |
| ... | ... | @@ -1518,6 +1606,7 @@ codecvt<char, char, mbstate_t>::do_max_length() const noexcept |
| 1518 | 1606 | |
| 1519 | 1607 | // template <> class codecvt<wchar_t, char, mbstate_t> |
| 1520 | 1608 | |
| 1609 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1521 | 1610 | locale::id codecvt<wchar_t, char, mbstate_t>::id; |
| 1522 | 1611 | |
| 1523 | 1612 | codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) |
| ... | ... | @@ -1730,6 +1819,7 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept |
| 1730 | 1819 | { |
| 1731 | 1820 | return __l == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l)); |
| 1732 | 1821 | } |
| 1822 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1733 | 1823 | |
| 1734 | 1824 | // Valid UTF ranges |
| 1735 | 1825 | // UTF-32 UTF-16 UTF-8 # of code points |
| ... | ... | @@ -3436,6 +3526,7 @@ codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept |
| 3436 | 3526 | |
| 3437 | 3527 | // __codecvt_utf8<wchar_t> |
| 3438 | 3528 | |
| 3529 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3439 | 3530 | __codecvt_utf8<wchar_t>::result |
| 3440 | 3531 | __codecvt_utf8<wchar_t>::do_out(state_type&, |
| 3441 | 3532 | const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt, |
| ... | ... | @@ -3517,16 +3608,27 @@ __codecvt_utf8<wchar_t>::do_length(state_type&, |
| 3517 | 3608 | { |
| 3518 | 3609 | const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); |
| 3519 | 3610 | const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); |
| 3611 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3612 | return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); | |
| 3613 | #else | |
| 3520 | 3614 | return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 3615 | #endif | |
| 3521 | 3616 | } |
| 3522 | 3617 | |
| 3523 | 3618 | int |
| 3524 | 3619 | __codecvt_utf8<wchar_t>::do_max_length() const noexcept |
| 3525 | 3620 | { |
| 3621 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3622 | if (_Mode_ & consume_header) | |
| 3623 | return 6; | |
| 3624 | return 3; | |
| 3625 | #else | |
| 3526 | 3626 | if (_Mode_ & consume_header) |
| 3527 | 3627 | return 7; |
| 3528 | 3628 | return 4; |
| 3629 | #endif | |
| 3529 | 3630 | } |
| 3631 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3530 | 3632 | |
| 3531 | 3633 | // __codecvt_utf8<char16_t> |
| 3532 | 3634 | |
| ... | ... | @@ -3680,19 +3782,31 @@ __codecvt_utf8<char32_t>::do_max_length() const noexcept |
| 3680 | 3782 | |
| 3681 | 3783 | // __codecvt_utf16<wchar_t, false> |
| 3682 | 3784 | |
| 3785 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3683 | 3786 | __codecvt_utf16<wchar_t, false>::result |
| 3684 | 3787 | __codecvt_utf16<wchar_t, false>::do_out(state_type&, |
| 3685 | 3788 | const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt, |
| 3686 | 3789 | extern_type* to, extern_type* to_end, extern_type*& to_nxt) const |
| 3687 | 3790 | { |
| 3791 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3792 | const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm); | |
| 3793 | const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end); | |
| 3794 | const uint16_t* _frm_nxt = _frm; | |
| 3795 | #else | |
| 3688 | 3796 | const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm); |
| 3689 | 3797 | const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end); |
| 3690 | 3798 | const uint32_t* _frm_nxt = _frm; |
| 3799 | #endif | |
| 3691 | 3800 | uint8_t* _to = reinterpret_cast<uint8_t*>(to); |
| 3692 | 3801 | uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); |
| 3693 | 3802 | uint8_t* _to_nxt = _to; |
| 3803 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3804 | result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, | |
| 3805 | _Maxcode_, _Mode_); | |
| 3806 | #else | |
| 3694 | 3807 | result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, |
| 3695 | 3808 | _Maxcode_, _Mode_); |
| 3809 | #endif | |
| 3696 | 3810 | frm_nxt = frm + (_frm_nxt - _frm); |
| 3697 | 3811 | to_nxt = to + (_to_nxt - _to); |
| 3698 | 3812 | return r; |
| ... | ... | @@ -3706,11 +3820,19 @@ __codecvt_utf16<wchar_t, false>::do_in(state_type&, |
| 3706 | 3820 | const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); |
| 3707 | 3821 | const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); |
| 3708 | 3822 | const uint8_t* _frm_nxt = _frm; |
| 3823 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3824 | uint16_t* _to = reinterpret_cast<uint16_t*>(to); | |
| 3825 | uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); | |
| 3826 | uint16_t* _to_nxt = _to; | |
| 3827 | result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, | |
| 3828 | _Maxcode_, _Mode_); | |
| 3829 | #else | |
| 3709 | 3830 | uint32_t* _to = reinterpret_cast<uint32_t*>(to); |
| 3710 | 3831 | uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); |
| 3711 | 3832 | uint32_t* _to_nxt = _to; |
| 3712 | 3833 | result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, |
| 3713 | 3834 | _Maxcode_, _Mode_); |
| 3835 | #endif | |
| 3714 | 3836 | frm_nxt = frm + (_frm_nxt - _frm); |
| 3715 | 3837 | to_nxt = to + (_to_nxt - _to); |
| 3716 | 3838 | return r; |
| ... | ... | @@ -3742,15 +3864,25 @@ __codecvt_utf16<wchar_t, false>::do_length(state_type&, |
| 3742 | 3864 | { |
| 3743 | 3865 | const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); |
| 3744 | 3866 | const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); |
| 3867 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3868 | return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); | |
| 3869 | #else | |
| 3745 | 3870 | return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 3871 | #endif | |
| 3746 | 3872 | } |
| 3747 | 3873 | |
| 3748 | 3874 | int |
| 3749 | 3875 | __codecvt_utf16<wchar_t, false>::do_max_length() const noexcept |
| 3750 | 3876 | { |
| 3877 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3878 | if (_Mode_ & consume_header) | |
| 3879 | return 4; | |
| 3880 | return 2; | |
| 3881 | #else | |
| 3751 | 3882 | if (_Mode_ & consume_header) |
| 3752 | 3883 | return 6; |
| 3753 | 3884 | return 4; |
| 3885 | #endif | |
| 3754 | 3886 | } |
| 3755 | 3887 | |
| 3756 | 3888 | // __codecvt_utf16<wchar_t, true> |
| ... | ... | @@ -3760,14 +3892,25 @@ __codecvt_utf16<wchar_t, true>::do_out(state_type&, |
| 3760 | 3892 | const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt, |
| 3761 | 3893 | extern_type* to, extern_type* to_end, extern_type*& to_nxt) const |
| 3762 | 3894 | { |
| 3895 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3896 | const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm); | |
| 3897 | const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end); | |
| 3898 | const uint16_t* _frm_nxt = _frm; | |
| 3899 | #else | |
| 3763 | 3900 | const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm); |
| 3764 | 3901 | const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end); |
| 3765 | 3902 | const uint32_t* _frm_nxt = _frm; |
| 3903 | #endif | |
| 3766 | 3904 | uint8_t* _to = reinterpret_cast<uint8_t*>(to); |
| 3767 | 3905 | uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); |
| 3768 | 3906 | uint8_t* _to_nxt = _to; |
| 3907 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3908 | result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, | |
| 3909 | _Maxcode_, _Mode_); | |
| 3910 | #else | |
| 3769 | 3911 | result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, |
| 3770 | 3912 | _Maxcode_, _Mode_); |
| 3913 | #endif | |
| 3771 | 3914 | frm_nxt = frm + (_frm_nxt - _frm); |
| 3772 | 3915 | to_nxt = to + (_to_nxt - _to); |
| 3773 | 3916 | return r; |
| ... | ... | @@ -3781,11 +3924,19 @@ __codecvt_utf16<wchar_t, true>::do_in(state_type&, |
| 3781 | 3924 | const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); |
| 3782 | 3925 | const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); |
| 3783 | 3926 | const uint8_t* _frm_nxt = _frm; |
| 3927 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3928 | uint16_t* _to = reinterpret_cast<uint16_t*>(to); | |
| 3929 | uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); | |
| 3930 | uint16_t* _to_nxt = _to; | |
| 3931 | result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, | |
| 3932 | _Maxcode_, _Mode_); | |
| 3933 | #else | |
| 3784 | 3934 | uint32_t* _to = reinterpret_cast<uint32_t*>(to); |
| 3785 | 3935 | uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); |
| 3786 | 3936 | uint32_t* _to_nxt = _to; |
| 3787 | 3937 | result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, |
| 3788 | 3938 | _Maxcode_, _Mode_); |
| 3939 | #endif | |
| 3789 | 3940 | frm_nxt = frm + (_frm_nxt - _frm); |
| 3790 | 3941 | to_nxt = to + (_to_nxt - _to); |
| 3791 | 3942 | return r; |
| ... | ... | @@ -3817,16 +3968,27 @@ __codecvt_utf16<wchar_t, true>::do_length(state_type&, |
| 3817 | 3968 | { |
| 3818 | 3969 | const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); |
| 3819 | 3970 | const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); |
| 3971 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3972 | return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); | |
| 3973 | #else | |
| 3820 | 3974 | return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 3975 | #endif | |
| 3821 | 3976 | } |
| 3822 | 3977 | |
| 3823 | 3978 | int |
| 3824 | 3979 | __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept |
| 3825 | 3980 | { |
| 3981 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 3982 | if (_Mode_ & consume_header) | |
| 3983 | return 4; | |
| 3984 | return 2; | |
| 3985 | #else | |
| 3826 | 3986 | if (_Mode_ & consume_header) |
| 3827 | 3987 | return 6; |
| 3828 | 3988 | return 4; |
| 3989 | #endif | |
| 3829 | 3990 | } |
| 3991 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3830 | 3992 | |
| 3831 | 3993 | // __codecvt_utf16<char16_t, false> |
| 3832 | 3994 | |
| ... | ... | @@ -4130,14 +4292,21 @@ __codecvt_utf16<char32_t, true>::do_max_length() const noexcept |
| 4130 | 4292 | |
| 4131 | 4293 | // __codecvt_utf8_utf16<wchar_t> |
| 4132 | 4294 | |
| 4295 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4133 | 4296 | __codecvt_utf8_utf16<wchar_t>::result |
| 4134 | 4297 | __codecvt_utf8_utf16<wchar_t>::do_out(state_type&, |
| 4135 | 4298 | const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt, |
| 4136 | 4299 | extern_type* to, extern_type* to_end, extern_type*& to_nxt) const |
| 4137 | 4300 | { |
| 4301 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 4302 | const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm); | |
| 4303 | const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end); | |
| 4304 | const uint16_t* _frm_nxt = _frm; | |
| 4305 | #else | |
| 4138 | 4306 | const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm); |
| 4139 | 4307 | const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end); |
| 4140 | 4308 | const uint32_t* _frm_nxt = _frm; |
| 4309 | #endif | |
| 4141 | 4310 | uint8_t* _to = reinterpret_cast<uint8_t*>(to); |
| 4142 | 4311 | uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end); |
| 4143 | 4312 | uint8_t* _to_nxt = _to; |
| ... | ... | @@ -4156,9 +4325,15 @@ __codecvt_utf8_utf16<wchar_t>::do_in(state_type&, |
| 4156 | 4325 | const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm); |
| 4157 | 4326 | const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end); |
| 4158 | 4327 | const uint8_t* _frm_nxt = _frm; |
| 4328 | #if defined(_LIBCPP_SHORT_WCHAR) | |
| 4329 | uint16_t* _to = reinterpret_cast<uint16_t*>(to); | |
| 4330 | uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end); | |
| 4331 | uint16_t* _to_nxt = _to; | |
| 4332 | #else | |
| 4159 | 4333 | uint32_t* _to = reinterpret_cast<uint32_t*>(to); |
| 4160 | 4334 | uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end); |
| 4161 | 4335 | uint32_t* _to_nxt = _to; |
| 4336 | #endif | |
| 4162 | 4337 | result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, |
| 4163 | 4338 | _Maxcode_, _Mode_); |
| 4164 | 4339 | frm_nxt = frm + (_frm_nxt - _frm); |
| ... | ... | @@ -4202,6 +4377,7 @@ __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept |
| 4202 | 4377 | return 7; |
| 4203 | 4378 | return 4; |
| 4204 | 4379 | } |
| 4380 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4205 | 4381 | |
| 4206 | 4382 | // __codecvt_utf8_utf16<char16_t> |
| 4207 | 4383 | |
| ... | ... | @@ -4377,7 +4553,7 @@ __widen_from_utf8<32>::~__widen_from_utf8() |
| 4377 | 4553 | { |
| 4378 | 4554 | } |
| 4379 | 4555 | |
| 4380 | ||
| 4556 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4381 | 4557 | static bool checked_string_to_wchar_convert(wchar_t& dest, |
| 4382 | 4558 | const char* ptr, |
| 4383 | 4559 | locale_t loc) { |
| ... | ... | @@ -4392,6 +4568,19 @@ static bool checked_string_to_wchar_convert(wchar_t& dest, |
| 4392 | 4568 | dest = out; |
| 4393 | 4569 | return true; |
| 4394 | 4570 | } |
| 4571 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4572 | ||
| 4573 | #ifdef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4574 | static bool is_narrow_non_breaking_space(const char* ptr) { | |
| 4575 | // https://www.fileformat.info/info/unicode/char/202f/index.htm | |
| 4576 | return ptr[0] == '\xe2' && ptr[1] == '\x80' && ptr[2] == '\xaf'; | |
| 4577 | } | |
| 4578 | ||
| 4579 | static bool is_non_breaking_space(const char* ptr) { | |
| 4580 | // https://www.fileformat.info/info/unicode/char/0a/index.htm | |
| 4581 | return ptr[0] == '\xc2' && ptr[1] == '\xa0'; | |
| 4582 | } | |
| 4583 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4395 | 4584 | |
| 4396 | 4585 | static bool checked_string_to_char_convert(char& dest, |
| 4397 | 4586 | const char* ptr, |
| ... | ... | @@ -4402,6 +4591,8 @@ static bool checked_string_to_char_convert(char& dest, |
| 4402 | 4591 | dest = *ptr; |
| 4403 | 4592 | return true; |
| 4404 | 4593 | } |
| 4594 | ||
| 4595 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4405 | 4596 | // First convert the MBS into a wide char then attempt to narrow it using |
| 4406 | 4597 | // wctob_l. |
| 4407 | 4598 | wchar_t wout; |
| ... | ... | @@ -4412,7 +4603,7 @@ static bool checked_string_to_char_convert(char& dest, |
| 4412 | 4603 | dest = res; |
| 4413 | 4604 | return true; |
| 4414 | 4605 | } |
| 4415 | // FIXME: Work around specific multibyte sequences that we can reasonable | |
| 4606 | // FIXME: Work around specific multibyte sequences that we can reasonably | |
| 4416 | 4607 | // translate into a different single byte. |
| 4417 | 4608 | switch (wout) { |
| 4418 | 4609 | case L'\u202F': // narrow non-breaking space |
| ... | ... | @@ -4422,6 +4613,16 @@ static bool checked_string_to_char_convert(char& dest, |
| 4422 | 4613 | default: |
| 4423 | 4614 | return false; |
| 4424 | 4615 | } |
| 4616 | #else // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4617 | // FIXME: Work around specific multibyte sequences that we can reasonably | |
| 4618 | // translate into a different single byte. | |
| 4619 | if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) { | |
| 4620 | dest = ' '; | |
| 4621 | return true; | |
| 4622 | } | |
| 4623 | ||
| 4624 | return false; | |
| 4625 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4425 | 4626 | _LIBCPP_UNREACHABLE(); |
| 4426 | 4627 | } |
| 4427 | 4628 | |
| ... | ... | @@ -4429,7 +4630,9 @@ static bool checked_string_to_char_convert(char& dest, |
| 4429 | 4630 | // numpunct<char> && numpunct<wchar_t> |
| 4430 | 4631 | |
| 4431 | 4632 | locale::id numpunct< char >::id; |
| 4633 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4432 | 4634 | locale::id numpunct<wchar_t>::id; |
| 4635 | #endif | |
| 4433 | 4636 | |
| 4434 | 4637 | numpunct<char>::numpunct(size_t refs) |
| 4435 | 4638 | : locale::facet(refs), |
| ... | ... | @@ -4438,35 +4641,49 @@ numpunct<char>::numpunct(size_t refs) |
| 4438 | 4641 | { |
| 4439 | 4642 | } |
| 4440 | 4643 | |
| 4644 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4441 | 4645 | numpunct<wchar_t>::numpunct(size_t refs) |
| 4442 | 4646 | : locale::facet(refs), |
| 4443 | 4647 | __decimal_point_(L'.'), |
| 4444 | 4648 | __thousands_sep_(L',') |
| 4445 | 4649 | { |
| 4446 | 4650 | } |
| 4651 | #endif | |
| 4447 | 4652 | |
| 4448 | 4653 | numpunct<char>::~numpunct() |
| 4449 | 4654 | { |
| 4450 | 4655 | } |
| 4451 | 4656 | |
| 4657 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4452 | 4658 | numpunct<wchar_t>::~numpunct() |
| 4453 | 4659 | { |
| 4454 | 4660 | } |
| 4661 | #endif | |
| 4455 | 4662 | |
| 4456 | 4663 | char numpunct< char >::do_decimal_point() const {return __decimal_point_;} |
| 4664 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4457 | 4665 | wchar_t numpunct<wchar_t>::do_decimal_point() const {return __decimal_point_;} |
| 4666 | #endif | |
| 4458 | 4667 | |
| 4459 | 4668 | char numpunct< char >::do_thousands_sep() const {return __thousands_sep_;} |
| 4669 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4460 | 4670 | wchar_t numpunct<wchar_t>::do_thousands_sep() const {return __thousands_sep_;} |
| 4671 | #endif | |
| 4461 | 4672 | |
| 4462 | 4673 | string numpunct< char >::do_grouping() const {return __grouping_;} |
| 4674 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4463 | 4675 | string numpunct<wchar_t>::do_grouping() const {return __grouping_;} |
| 4676 | #endif | |
| 4464 | 4677 | |
| 4465 | 4678 | string numpunct< char >::do_truename() const {return "true";} |
| 4679 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4466 | 4680 | wstring numpunct<wchar_t>::do_truename() const {return L"true";} |
| 4681 | #endif | |
| 4467 | 4682 | |
| 4468 | 4683 | string numpunct< char >::do_falsename() const {return "false";} |
| 4684 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4469 | 4685 | wstring numpunct<wchar_t>::do_falsename() const {return L"false";} |
| 4686 | #endif | |
| 4470 | 4687 | |
| 4471 | 4688 | // numpunct_byname<char> |
| 4472 | 4689 | |
| ... | ... | @@ -4489,6 +4706,7 @@ numpunct_byname<char>::~numpunct_byname() |
| 4489 | 4706 | void |
| 4490 | 4707 | numpunct_byname<char>::__init(const char* nm) |
| 4491 | 4708 | { |
| 4709 | typedef numpunct<char> base; | |
| 4492 | 4710 | if (strcmp(nm, "C") != 0) |
| 4493 | 4711 | { |
| 4494 | 4712 | __libcpp_unique_locale loc(nm); |
| ... | ... | @@ -4497,10 +4715,12 @@ numpunct_byname<char>::__init(const char* nm) |
| 4497 | 4715 | " failed to construct for " + string(nm)); |
| 4498 | 4716 | |
| 4499 | 4717 | lconv* lc = __libcpp_localeconv_l(loc.get()); |
| 4500 | checked_string_to_char_convert(__decimal_point_, lc->decimal_point, | |
| 4501 | loc.get()); | |
| 4502 | checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep, | |
| 4503 | loc.get()); | |
| 4718 | if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point, | |
| 4719 | loc.get())) | |
| 4720 | __decimal_point_ = base::do_decimal_point(); | |
| 4721 | if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep, | |
| 4722 | loc.get())) | |
| 4723 | __thousands_sep_ = base::do_thousands_sep(); | |
| 4504 | 4724 | __grouping_ = lc->grouping; |
| 4505 | 4725 | // localization for truename and falsename is not available |
| 4506 | 4726 | } |
| ... | ... | @@ -4508,6 +4728,7 @@ numpunct_byname<char>::__init(const char* nm) |
| 4508 | 4728 | |
| 4509 | 4729 | // numpunct_byname<wchar_t> |
| 4510 | 4730 | |
| 4731 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4511 | 4732 | numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) |
| 4512 | 4733 | : numpunct<wchar_t>(refs) |
| 4513 | 4734 | { |
| ... | ... | @@ -4543,6 +4764,7 @@ numpunct_byname<wchar_t>::__init(const char* nm) |
| 4543 | 4764 | // localization for truename and falsename is not available |
| 4544 | 4765 | } |
| 4545 | 4766 | } |
| 4767 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4546 | 4768 | |
| 4547 | 4769 | // num_get helpers |
| 4548 | 4770 | |
| ... | ... | @@ -4718,6 +4940,7 @@ init_weeks() |
| 4718 | 4940 | return weeks; |
| 4719 | 4941 | } |
| 4720 | 4942 | |
| 4943 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4721 | 4944 | static |
| 4722 | 4945 | wstring* |
| 4723 | 4946 | init_wweeks() |
| ... | ... | @@ -4739,6 +4962,7 @@ init_wweeks() |
| 4739 | 4962 | weeks[13] = L"Sat"; |
| 4740 | 4963 | return weeks; |
| 4741 | 4964 | } |
| 4965 | #endif | |
| 4742 | 4966 | |
| 4743 | 4967 | template <> |
| 4744 | 4968 | const string* |
| ... | ... | @@ -4748,6 +4972,7 @@ __time_get_c_storage<char>::__weeks() const |
| 4748 | 4972 | return weeks; |
| 4749 | 4973 | } |
| 4750 | 4974 | |
| 4975 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4751 | 4976 | template <> |
| 4752 | 4977 | const wstring* |
| 4753 | 4978 | __time_get_c_storage<wchar_t>::__weeks() const |
| ... | ... | @@ -4755,6 +4980,7 @@ __time_get_c_storage<wchar_t>::__weeks() const |
| 4755 | 4980 | static const wstring* weeks = init_wweeks(); |
| 4756 | 4981 | return weeks; |
| 4757 | 4982 | } |
| 4983 | #endif | |
| 4758 | 4984 | |
| 4759 | 4985 | static |
| 4760 | 4986 | string* |
| ... | ... | @@ -4788,6 +5014,7 @@ init_months() |
| 4788 | 5014 | return months; |
| 4789 | 5015 | } |
| 4790 | 5016 | |
| 5017 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4791 | 5018 | static |
| 4792 | 5019 | wstring* |
| 4793 | 5020 | init_wmonths() |
| ... | ... | @@ -4819,6 +5046,7 @@ init_wmonths() |
| 4819 | 5046 | months[23] = L"Dec"; |
| 4820 | 5047 | return months; |
| 4821 | 5048 | } |
| 5049 | #endif | |
| 4822 | 5050 | |
| 4823 | 5051 | template <> |
| 4824 | 5052 | const string* |
| ... | ... | @@ -4828,6 +5056,7 @@ __time_get_c_storage<char>::__months() const |
| 4828 | 5056 | return months; |
| 4829 | 5057 | } |
| 4830 | 5058 | |
| 5059 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4831 | 5060 | template <> |
| 4832 | 5061 | const wstring* |
| 4833 | 5062 | __time_get_c_storage<wchar_t>::__months() const |
| ... | ... | @@ -4835,6 +5064,7 @@ __time_get_c_storage<wchar_t>::__months() const |
| 4835 | 5064 | static const wstring* months = init_wmonths(); |
| 4836 | 5065 | return months; |
| 4837 | 5066 | } |
| 5067 | #endif | |
| 4838 | 5068 | |
| 4839 | 5069 | static |
| 4840 | 5070 | string* |
| ... | ... | @@ -4846,6 +5076,7 @@ init_am_pm() |
| 4846 | 5076 | return am_pm; |
| 4847 | 5077 | } |
| 4848 | 5078 | |
| 5079 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4849 | 5080 | static |
| 4850 | 5081 | wstring* |
| 4851 | 5082 | init_wam_pm() |
| ... | ... | @@ -4855,6 +5086,7 @@ init_wam_pm() |
| 4855 | 5086 | am_pm[1] = L"PM"; |
| 4856 | 5087 | return am_pm; |
| 4857 | 5088 | } |
| 5089 | #endif | |
| 4858 | 5090 | |
| 4859 | 5091 | template <> |
| 4860 | 5092 | const string* |
| ... | ... | @@ -4864,6 +5096,7 @@ __time_get_c_storage<char>::__am_pm() const |
| 4864 | 5096 | return am_pm; |
| 4865 | 5097 | } |
| 4866 | 5098 | |
| 5099 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4867 | 5100 | template <> |
| 4868 | 5101 | const wstring* |
| 4869 | 5102 | __time_get_c_storage<wchar_t>::__am_pm() const |
| ... | ... | @@ -4871,6 +5104,7 @@ __time_get_c_storage<wchar_t>::__am_pm() const |
| 4871 | 5104 | static const wstring* am_pm = init_wam_pm(); |
| 4872 | 5105 | return am_pm; |
| 4873 | 5106 | } |
| 5107 | #endif | |
| 4874 | 5108 | |
| 4875 | 5109 | template <> |
| 4876 | 5110 | const string& |
| ... | ... | @@ -4880,6 +5114,7 @@ __time_get_c_storage<char>::__x() const |
| 4880 | 5114 | return s; |
| 4881 | 5115 | } |
| 4882 | 5116 | |
| 5117 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4883 | 5118 | template <> |
| 4884 | 5119 | const wstring& |
| 4885 | 5120 | __time_get_c_storage<wchar_t>::__x() const |
| ... | ... | @@ -4887,6 +5122,7 @@ __time_get_c_storage<wchar_t>::__x() const |
| 4887 | 5122 | static wstring s(L"%m/%d/%y"); |
| 4888 | 5123 | return s; |
| 4889 | 5124 | } |
| 5125 | #endif | |
| 4890 | 5126 | |
| 4891 | 5127 | template <> |
| 4892 | 5128 | const string& |
| ... | ... | @@ -4896,6 +5132,7 @@ __time_get_c_storage<char>::__X() const |
| 4896 | 5132 | return s; |
| 4897 | 5133 | } |
| 4898 | 5134 | |
| 5135 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4899 | 5136 | template <> |
| 4900 | 5137 | const wstring& |
| 4901 | 5138 | __time_get_c_storage<wchar_t>::__X() const |
| ... | ... | @@ -4903,6 +5140,7 @@ __time_get_c_storage<wchar_t>::__X() const |
| 4903 | 5140 | static wstring s(L"%H:%M:%S"); |
| 4904 | 5141 | return s; |
| 4905 | 5142 | } |
| 5143 | #endif | |
| 4906 | 5144 | |
| 4907 | 5145 | template <> |
| 4908 | 5146 | const string& |
| ... | ... | @@ -4912,6 +5150,7 @@ __time_get_c_storage<char>::__c() const |
| 4912 | 5150 | return s; |
| 4913 | 5151 | } |
| 4914 | 5152 | |
| 5153 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4915 | 5154 | template <> |
| 4916 | 5155 | const wstring& |
| 4917 | 5156 | __time_get_c_storage<wchar_t>::__c() const |
| ... | ... | @@ -4919,6 +5158,7 @@ __time_get_c_storage<wchar_t>::__c() const |
| 4919 | 5158 | static wstring s(L"%a %b %d %H:%M:%S %Y"); |
| 4920 | 5159 | return s; |
| 4921 | 5160 | } |
| 5161 | #endif | |
| 4922 | 5162 | |
| 4923 | 5163 | template <> |
| 4924 | 5164 | const string& |
| ... | ... | @@ -4928,6 +5168,7 @@ __time_get_c_storage<char>::__r() const |
| 4928 | 5168 | return s; |
| 4929 | 5169 | } |
| 4930 | 5170 | |
| 5171 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4931 | 5172 | template <> |
| 4932 | 5173 | const wstring& |
| 4933 | 5174 | __time_get_c_storage<wchar_t>::__r() const |
| ... | ... | @@ -4935,6 +5176,7 @@ __time_get_c_storage<wchar_t>::__r() const |
| 4935 | 5176 | static wstring s(L"%I:%M:%S %p"); |
| 4936 | 5177 | return s; |
| 4937 | 5178 | } |
| 5179 | #endif | |
| 4938 | 5180 | |
| 4939 | 5181 | // time_get_byname |
| 4940 | 5182 | |
| ... | ... | @@ -5113,6 +5355,7 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) |
| 5113 | 5355 | #pragma clang diagnostic ignored "-Wmissing-braces" |
| 5114 | 5356 | #endif |
| 5115 | 5357 | |
| 5358 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5116 | 5359 | template <> |
| 5117 | 5360 | wstring |
| 5118 | 5361 | __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct) |
| ... | ... | @@ -5262,6 +5505,7 @@ __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct) |
| 5262 | 5505 | } |
| 5263 | 5506 | return result; |
| 5264 | 5507 | } |
| 5508 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5265 | 5509 | |
| 5266 | 5510 | template <> |
| 5267 | 5511 | void |
| ... | ... | @@ -5300,6 +5544,7 @@ __time_get_storage<char>::init(const ctype<char>& ct) |
| 5300 | 5544 | __X_ = __analyze('X', ct); |
| 5301 | 5545 | } |
| 5302 | 5546 | |
| 5547 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5303 | 5548 | template <> |
| 5304 | 5549 | void |
| 5305 | 5550 | __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) |
| ... | ... | @@ -5375,6 +5620,7 @@ __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) |
| 5375 | 5620 | __x_ = __analyze('x', ct); |
| 5376 | 5621 | __X_ = __analyze('X', ct); |
| 5377 | 5622 | } |
| 5623 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5378 | 5624 | |
| 5379 | 5625 | template <class CharT> |
| 5380 | 5626 | struct _LIBCPP_HIDDEN __time_get_temp |
| ... | ... | @@ -5402,6 +5648,7 @@ __time_get_storage<char>::__time_get_storage(const string& __nm) |
| 5402 | 5648 | init(ct); |
| 5403 | 5649 | } |
| 5404 | 5650 | |
| 5651 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5405 | 5652 | template <> |
| 5406 | 5653 | __time_get_storage<wchar_t>::__time_get_storage(const char* __nm) |
| 5407 | 5654 | : __time_get(__nm) |
| ... | ... | @@ -5417,6 +5664,7 @@ __time_get_storage<wchar_t>::__time_get_storage(const string& __nm) |
| 5417 | 5664 | const __time_get_temp<wchar_t> ct(__nm); |
| 5418 | 5665 | init(ct); |
| 5419 | 5666 | } |
| 5667 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5420 | 5668 | |
| 5421 | 5669 | template <> |
| 5422 | 5670 | time_base::dateorder |
| ... | ... | @@ -5505,6 +5753,7 @@ __time_get_storage<char>::__do_date_order() const |
| 5505 | 5753 | return time_base::no_order; |
| 5506 | 5754 | } |
| 5507 | 5755 | |
| 5756 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5508 | 5757 | template <> |
| 5509 | 5758 | time_base::dateorder |
| 5510 | 5759 | __time_get_storage<wchar_t>::__do_date_order() const |
| ... | ... | @@ -5591,6 +5840,7 @@ __time_get_storage<wchar_t>::__do_date_order() const |
| 5591 | 5840 | } |
| 5592 | 5841 | return time_base::no_order; |
| 5593 | 5842 | } |
| 5843 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5594 | 5844 | |
| 5595 | 5845 | // time_put |
| 5596 | 5846 | |
| ... | ... | @@ -5627,6 +5877,7 @@ __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, |
| 5627 | 5877 | __ne = __nb + n; |
| 5628 | 5878 | } |
| 5629 | 5879 | |
| 5880 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5630 | 5881 | void |
| 5631 | 5882 | __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, |
| 5632 | 5883 | char __fmt, char __mod) const |
| ... | ... | @@ -5641,6 +5892,7 @@ __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, |
| 5641 | 5892 | __throw_runtime_error("locale not supported"); |
| 5642 | 5893 | __we = __wb + j; |
| 5643 | 5894 | } |
| 5895 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 5644 | 5896 | |
| 5645 | 5897 | // moneypunct_byname |
| 5646 | 5898 | |
| ... | ... | @@ -6120,6 +6372,7 @@ moneypunct_byname<char, true>::init(const char* nm) |
| 6120 | 6372 | #endif // !_LIBCPP_MSVCRT |
| 6121 | 6373 | } |
| 6122 | 6374 | |
| 6375 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 6123 | 6376 | template<> |
| 6124 | 6377 | void |
| 6125 | 6378 | moneypunct_byname<wchar_t, false>::init(const char* nm) |
| ... | ... | @@ -6267,6 +6520,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) |
| 6267 | 6520 | lc->int_n_sign_posn, L' '); |
| 6268 | 6521 | #endif // !_LIBCPP_MSVCRT |
| 6269 | 6522 | } |
| 6523 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 6270 | 6524 | |
| 6271 | 6525 | void __do_nothing(void*) {} |
| 6272 | 6526 | |
| ... | ... | @@ -6280,63 +6534,63 @@ void __throw_runtime_error(const char* msg) |
| 6280 | 6534 | #endif |
| 6281 | 6535 | } |
| 6282 | 6536 | |
| 6283 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; | |
| 6284 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>; | |
| 6537 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; | |
| 6538 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;) | |
| 6285 | 6539 | |
| 6286 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<char>; | |
| 6287 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<wchar_t>; | |
| 6540 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<char>; | |
| 6541 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<wchar_t>;) | |
| 6288 | 6542 | |
| 6289 | template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<char>; | |
| 6290 | template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<wchar_t>; | |
| 6543 | template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<char>; | |
| 6544 | _LIBCPP_IF_WIDE_CHARACTERS(template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<wchar_t>;) | |
| 6291 | 6545 | |
| 6292 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<char>; | |
| 6293 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<wchar_t>; | |
| 6546 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<char>; | |
| 6547 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<wchar_t>;) | |
| 6294 | 6548 | |
| 6295 | template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<char>; | |
| 6296 | template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<wchar_t>; | |
| 6549 | template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<char>; | |
| 6550 | _LIBCPP_IF_WIDE_CHARACTERS(template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<wchar_t>;) | |
| 6297 | 6551 | |
| 6298 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<char>; | |
| 6299 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<wchar_t>; | |
| 6552 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<char>; | |
| 6553 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<wchar_t>;) | |
| 6300 | 6554 | |
| 6301 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<char>; | |
| 6302 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<wchar_t>; | |
| 6555 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<char>; | |
| 6556 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<wchar_t>;) | |
| 6303 | 6557 | |
| 6304 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<char>; | |
| 6305 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<wchar_t>; | |
| 6558 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<char>; | |
| 6559 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<wchar_t>;) | |
| 6306 | 6560 | |
| 6307 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<char>; | |
| 6308 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<wchar_t>; | |
| 6561 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<char>; | |
| 6562 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<wchar_t>;) | |
| 6309 | 6563 | |
| 6310 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, false>; | |
| 6311 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, true>; | |
| 6312 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, false>; | |
| 6313 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, true>; | |
| 6564 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, false>; | |
| 6565 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, true>; | |
| 6566 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, false>;) | |
| 6567 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, true>;) | |
| 6314 | 6568 | |
| 6315 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, false>; | |
| 6316 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, true>; | |
| 6317 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, false>; | |
| 6318 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, true>; | |
| 6569 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, false>; | |
| 6570 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, true>; | |
| 6571 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, false>;) | |
| 6572 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, true>;) | |
| 6319 | 6573 | |
| 6320 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<char>; | |
| 6321 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<wchar_t>; | |
| 6574 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<char>; | |
| 6575 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<wchar_t>;) | |
| 6322 | 6576 | |
| 6323 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<char>; | |
| 6324 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<wchar_t>; | |
| 6577 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<char>; | |
| 6578 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<wchar_t>;) | |
| 6325 | 6579 | |
| 6326 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<char>; | |
| 6327 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<wchar_t>; | |
| 6580 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<char>; | |
| 6581 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<wchar_t>;) | |
| 6328 | 6582 | |
| 6329 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<char>; | |
| 6330 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<wchar_t>; | |
| 6583 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<char>; | |
| 6584 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<wchar_t>;) | |
| 6331 | 6585 | |
| 6332 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<char>; | |
| 6333 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<wchar_t>; | |
| 6586 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<char>; | |
| 6587 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<wchar_t>;) | |
| 6334 | 6588 | |
| 6335 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<char>; | |
| 6336 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<wchar_t>; | |
| 6589 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<char>; | |
| 6590 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<wchar_t>;) | |
| 6337 | 6591 | |
| 6338 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>; | |
| 6339 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>; | |
| 6592 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>; | |
| 6593 | _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>;) | |
| 6340 | 6594 | template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char, mbstate_t>; |
| 6341 | 6595 | template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char, mbstate_t>; |
| 6342 | 6596 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
lib/libcxx/src/memory.cpp+8-29| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ memory.cpp ----------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -8,11 +8,11 @@ |
| 8 | 8 | |
| 9 | 9 | #include "memory" |
| 10 | 10 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 11 | #include "mutex" | |
| 12 | #include "thread" | |
| 13 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 14 | #pragma comment(lib, "pthread") | |
| 15 | #endif | |
| 11 | # include "mutex" | |
| 12 | # include "thread" | |
| 13 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 14 | # pragma comment(lib, "pthread") | |
| 15 | # endif | |
| 16 | 16 | #endif |
| 17 | 17 | #include "include/atomic_support.h" |
| 18 | 18 | |
| ... | ... | @@ -130,7 +130,7 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept |
| 130 | 130 | return nullptr; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | |
| 133 | #if !defined(_LIBCPP_HAS_NO_THREADS) | |
| 134 | 134 | |
| 135 | 135 | _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16; |
| 136 | 136 | _LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] = |
| ... | ... | @@ -181,28 +181,7 @@ __get_sp_mut(const void* p) |
| 181 | 181 | return muts[hash<const void*>()(p) & (__sp_mut_count-1)]; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | #endif // !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) | |
| 185 | ||
| 186 | void | |
| 187 | declare_reachable(void*) | |
| 188 | { | |
| 189 | } | |
| 190 | ||
| 191 | void | |
| 192 | declare_no_pointers(char*, size_t) | |
| 193 | { | |
| 194 | } | |
| 195 | ||
| 196 | void | |
| 197 | undeclare_no_pointers(char*, size_t) | |
| 198 | { | |
| 199 | } | |
| 200 | ||
| 201 | void* | |
| 202 | __undeclare_reachable(void* p) | |
| 203 | { | |
| 204 | return p; | |
| 205 | } | |
| 184 | #endif // !defined(_LIBCPP_HAS_NO_THREADS) | |
| 206 | 185 | |
| 207 | 186 | void* |
| 208 | 187 | align(size_t alignment, size_t size, void*& ptr, size_t& space) |
lib/libcxx/src/mutex.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- mutex.cpp ----------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/mutex_destructor.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------- mutex_destructor.cpp ---------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/new.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------------- new.cpp ----------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/optional.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ optional.cpp --------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/random.cpp+37-16| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- random.cpp --------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #include <__config> |
| 10 | 10 | |
| 11 | 11 | #if defined(_LIBCPP_USING_WIN32_RANDOM) |
| 12 | // Must be defined before including stdlib.h to enable rand_s(). | |
| 13 | #define _CRT_RAND_S | |
| 12 | // Must be defined before including stdlib.h to enable rand_s(). | |
| 13 | # define _CRT_RAND_S | |
| 14 | 14 | #endif // defined(_LIBCPP_USING_WIN32_RANDOM) |
| 15 | 15 | |
| 16 | 16 | #include "limits" |
| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include "system_error" |
| 19 | 19 | |
| 20 | 20 | #if defined(__sun__) |
| 21 | #define rename solaris_headers_are_broken | |
| 21 | # define rename solaris_headers_are_broken | |
| 22 | 22 | #endif // defined(__sun__) |
| 23 | 23 | |
| 24 | 24 | #include <errno.h> |
| ... | ... | @@ -26,16 +26,18 @@ |
| 26 | 26 | #include <stdlib.h> |
| 27 | 27 | |
| 28 | 28 | #if defined(_LIBCPP_USING_GETENTROPY) |
| 29 | #include <sys/random.h> | |
| 29 | # include <sys/random.h> | |
| 30 | 30 | #elif defined(_LIBCPP_USING_DEV_RANDOM) |
| 31 | #include <fcntl.h> | |
| 32 | #include <unistd.h> | |
| 33 | #if __has_include(<sys/ioctl.h>) && __has_include(<linux/random.h>) | |
| 34 | #include <sys/ioctl.h> | |
| 35 | #include <linux/random.h> | |
| 36 | #endif | |
| 31 | # include <fcntl.h> | |
| 32 | # include <unistd.h> | |
| 33 | # if __has_include(<sys/ioctl.h>) && __has_include(<linux/random.h>) | |
| 34 | # include <sys/ioctl.h> | |
| 35 | # include <linux/random.h> | |
| 36 | # endif | |
| 37 | 37 | #elif defined(_LIBCPP_USING_NACL_RANDOM) |
| 38 | #include <nacl/nacl_random.h> | |
| 38 | # include <nacl/nacl_random.h> | |
| 39 | #elif defined(_LIBCPP_USING_FUCHSIA_CPRNG) | |
| 40 | # include <zircon/syscalls.h> | |
| 39 | 41 | #endif |
| 40 | 42 | |
| 41 | 43 | |
| ... | ... | @@ -66,10 +68,8 @@ random_device::operator()() |
| 66 | 68 | |
| 67 | 69 | #elif defined(_LIBCPP_USING_ARC4_RANDOM) |
| 68 | 70 | |
| 69 | random_device::random_device(const string& __token) | |
| 71 | random_device::random_device(const string&) | |
| 70 | 72 | { |
| 71 | if (__token != "/dev/urandom") | |
| 72 | __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | random_device::~random_device() |
| ... | ... | @@ -170,6 +170,27 @@ random_device::operator()() |
| 170 | 170 | return r; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | #elif defined(_LIBCPP_USING_FUCHSIA_CPRNG) | |
| 174 | ||
| 175 | random_device::random_device(const string& __token) { | |
| 176 | if (__token != "/dev/urandom") | |
| 177 | __throw_system_error(ENOENT, ("random device not supported " + __token).c_str()); | |
| 178 | } | |
| 179 | ||
| 180 | random_device::~random_device() {} | |
| 181 | ||
| 182 | unsigned random_device::operator()() { | |
| 183 | // Implicitly link against the vDSO system call ABI without | |
| 184 | // requiring the final link to specify -lzircon explicitly when | |
| 185 | // statically linking libc++. | |
| 186 | # pragma comment(lib, "zircon") | |
| 187 | ||
| 188 | // The system call cannot fail. It returns only when the bits are ready. | |
| 189 | unsigned r; | |
| 190 | _zx_cprng_draw(&r, sizeof(r)); | |
| 191 | return r; | |
| 192 | } | |
| 193 | ||
| 173 | 194 | #else |
| 174 | 195 | #error "Random device not implemented for this architecture" |
| 175 | 196 | #endif |
| ... | ... | @@ -189,7 +210,7 @@ random_device::entropy() const noexcept |
| 189 | 210 | return std::numeric_limits<result_type>::digits; |
| 190 | 211 | |
| 191 | 212 | return ent; |
| 192 | #elif defined(__OpenBSD__) | |
| 213 | #elif defined(_LIBCPP_USING_ARC4_RANDOM) || defined(_LIBCPP_USING_FUCHSIA_CPRNG) | |
| 193 | 214 | return std::numeric_limits<result_type>::digits; |
| 194 | 215 | #else |
| 195 | 216 | return 0; |
lib/libcxx/src/random_shuffle.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===----------------------- random_shuffle.cpp ---------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/regex.cpp+121-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===-------------------------- regex.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -76,6 +76,125 @@ struct collationnames |
| 76 | 76 | char char_; |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) | |
| 80 | // EBCDIC IBM-1047 | |
| 81 | // Sorted via the EBCDIC collating sequence | |
| 82 | const collationnames collatenames[] = | |
| 83 | { | |
| 84 | {"a", 0x81}, | |
| 85 | {"alert", 0x2f}, | |
| 86 | {"ampersand", 0x50}, | |
| 87 | {"apostrophe", 0x7d}, | |
| 88 | {"asterisk", 0x5c}, | |
| 89 | {"b", 0x82}, | |
| 90 | {"backslash", 0xe0}, | |
| 91 | {"backspace", 0x16}, | |
| 92 | {"c", 0x83}, | |
| 93 | {"carriage-return", 0xd}, | |
| 94 | {"circumflex", 0x5f}, | |
| 95 | {"circumflex-accent", 0x5f}, | |
| 96 | {"colon", 0x7a}, | |
| 97 | {"comma", 0x6b}, | |
| 98 | {"commercial-at", 0x7c}, | |
| 99 | {"d", 0x84}, | |
| 100 | {"dollar-sign", 0x5b}, | |
| 101 | {"e", 0x85}, | |
| 102 | {"eight", 0xf8}, | |
| 103 | {"equals-sign", 0x7e}, | |
| 104 | {"exclamation-mark", 0x5a}, | |
| 105 | {"f", 0x86}, | |
| 106 | {"five", 0xf5}, | |
| 107 | {"form-feed", 0xc}, | |
| 108 | {"four", 0xf4}, | |
| 109 | {"full-stop", 0x4b}, | |
| 110 | {"g", 0x87}, | |
| 111 | {"grave-accent", 0x79}, | |
| 112 | {"greater-than-sign", 0x6e}, | |
| 113 | {"h", 0x88}, | |
| 114 | {"hyphen", 0x60}, | |
| 115 | {"hyphen-minus", 0x60}, | |
| 116 | {"i", 0x89}, | |
| 117 | {"j", 0x91}, | |
| 118 | {"k", 0x92}, | |
| 119 | {"l", 0x93}, | |
| 120 | {"left-brace", 0xc0}, | |
| 121 | {"left-curly-bracket", 0xc0}, | |
| 122 | {"left-parenthesis", 0x4d}, | |
| 123 | {"left-square-bracket", 0xad}, | |
| 124 | {"less-than-sign", 0x4c}, | |
| 125 | {"low-line", 0x6d}, | |
| 126 | {"m", 0x94}, | |
| 127 | {"n", 0x95}, | |
| 128 | {"newline", 0x15}, | |
| 129 | {"nine", 0xf9}, | |
| 130 | {"number-sign", 0x7b}, | |
| 131 | {"o", 0x96}, | |
| 132 | {"one", 0xf1}, | |
| 133 | {"p", 0x97}, | |
| 134 | {"percent-sign", 0x6c}, | |
| 135 | {"period", 0x4b}, | |
| 136 | {"plus-sign", 0x4e}, | |
| 137 | {"q", 0x98}, | |
| 138 | {"question-mark", 0x6f}, | |
| 139 | {"quotation-mark", 0x7f}, | |
| 140 | {"r", 0x99}, | |
| 141 | {"reverse-solidus", 0xe0}, | |
| 142 | {"right-brace", 0xd0}, | |
| 143 | {"right-curly-bracket", 0xd0}, | |
| 144 | {"right-parenthesis", 0x5d}, | |
| 145 | {"right-square-bracket", 0xbd}, | |
| 146 | {"s", 0xa2}, | |
| 147 | {"semicolon", 0x5e}, | |
| 148 | {"seven", 0xf7}, | |
| 149 | {"six", 0xf6}, | |
| 150 | {"slash", 0x61}, | |
| 151 | {"solidus", 0x61}, | |
| 152 | {"space", 0x40}, | |
| 153 | {"t", 0xa3}, | |
| 154 | {"tab", 0x5}, | |
| 155 | {"three", 0xf3}, | |
| 156 | {"tilde", 0xa1}, | |
| 157 | {"two", 0xf2}, | |
| 158 | {"u", 0xa4}, | |
| 159 | {"underscore", 0x6d}, | |
| 160 | {"v", 0xa5}, | |
| 161 | {"vertical-line", 0x4f}, | |
| 162 | {"vertical-tab", 0xb}, | |
| 163 | {"w", 0xa6}, | |
| 164 | {"x", 0xa7}, | |
| 165 | {"y", 0xa8}, | |
| 166 | {"z", 0xa9}, | |
| 167 | {"zero", 0xf0}, | |
| 168 | {"A", 0xc1}, | |
| 169 | {"B", 0xc2}, | |
| 170 | {"C", 0xc3}, | |
| 171 | {"D", 0xc4}, | |
| 172 | {"E", 0xc5}, | |
| 173 | {"F", 0xc6}, | |
| 174 | {"G", 0xc7}, | |
| 175 | {"H", 0xc8}, | |
| 176 | {"I", 0xc9}, | |
| 177 | {"J", 0xd1}, | |
| 178 | {"K", 0xd2}, | |
| 179 | {"L", 0xd3}, | |
| 180 | {"M", 0xd4}, | |
| 181 | {"N", 0xd5}, | |
| 182 | {"NUL", 0}, | |
| 183 | {"O", 0xd6}, | |
| 184 | {"P", 0xd7}, | |
| 185 | {"Q", 0xd8}, | |
| 186 | {"R", 0xd9}, | |
| 187 | {"S", 0xe2}, | |
| 188 | {"T", 0xe3}, | |
| 189 | {"U", 0xe4}, | |
| 190 | {"V", 0xe5}, | |
| 191 | {"W", 0xe6}, | |
| 192 | {"X", 0xe7}, | |
| 193 | {"Y", 0xe8}, | |
| 194 | {"Z", 0xe9} | |
| 195 | }; | |
| 196 | #else | |
| 197 | // ASCII | |
| 79 | 198 | const collationnames collatenames[] = |
| 80 | 199 | { |
| 81 | 200 | {"A", 0x41}, |
| ... | ... | @@ -190,6 +309,7 @@ const collationnames collatenames[] = |
| 190 | 309 | {"z", 0x7a}, |
| 191 | 310 | {"zero", 0x30} |
| 192 | 311 | }; |
| 312 | #endif | |
| 193 | 313 | |
| 194 | 314 | struct classnames |
| 195 | 315 | { |
lib/libcxx/src/ryu/d2fixed.cpp created+669| ... | ... | @@ -0,0 +1,669 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | // Avoid formatting to keep the changes with the original code minimal. | |
| 40 | // clang-format off | |
| 41 | ||
| 42 | #include "__config" | |
| 43 | #include "charconv" | |
| 44 | #include "cstring" | |
| 45 | #include "system_error" | |
| 46 | ||
| 47 | #include "include/ryu/common.h" | |
| 48 | #include "include/ryu/d2fixed.h" | |
| 49 | #include "include/ryu/d2fixed_full_table.h" | |
| 50 | #include "include/ryu/d2s.h" | |
| 51 | #include "include/ryu/d2s_intrinsics.h" | |
| 52 | #include "include/ryu/digit_table.h" | |
| 53 | ||
| 54 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 55 | ||
| 56 | inline constexpr int __POW10_ADDITIONAL_BITS = 120; | |
| 57 | ||
| 58 | #ifdef _LIBCPP_INTRINSIC128 | |
| 59 | // Returns the low 64 bits of the high 128 bits of the 256-bit product of a and b. | |
| 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __umul256_hi128_lo64( | |
| 61 | const uint64_t __aHi, const uint64_t __aLo, const uint64_t __bHi, const uint64_t __bLo) { | |
| 62 | uint64_t __b00Hi; | |
| 63 | const uint64_t __b00Lo = __ryu_umul128(__aLo, __bLo, &__b00Hi); | |
| 64 | uint64_t __b01Hi; | |
| 65 | const uint64_t __b01Lo = __ryu_umul128(__aLo, __bHi, &__b01Hi); | |
| 66 | uint64_t __b10Hi; | |
| 67 | const uint64_t __b10Lo = __ryu_umul128(__aHi, __bLo, &__b10Hi); | |
| 68 | uint64_t __b11Hi; | |
| 69 | const uint64_t __b11Lo = __ryu_umul128(__aHi, __bHi, &__b11Hi); | |
| 70 | (void) __b00Lo; // unused | |
| 71 | (void) __b11Hi; // unused | |
| 72 | const uint64_t __temp1Lo = __b10Lo + __b00Hi; | |
| 73 | const uint64_t __temp1Hi = __b10Hi + (__temp1Lo < __b10Lo); | |
| 74 | const uint64_t __temp2Lo = __b01Lo + __temp1Lo; | |
| 75 | const uint64_t __temp2Hi = __b01Hi + (__temp2Lo < __b01Lo); | |
| 76 | return __b11Lo + __temp1Hi + __temp2Hi; | |
| 77 | } | |
| 78 | ||
| 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __uint128_mod1e9(const uint64_t __vHi, const uint64_t __vLo) { | |
| 80 | // After multiplying, we're going to shift right by 29, then truncate to uint32_t. | |
| 81 | // This means that we need only 29 + 32 = 61 bits, so we can truncate to uint64_t before shifting. | |
| 82 | const uint64_t __multiplied = __umul256_hi128_lo64(__vHi, __vLo, 0x89705F4136B4A597u, 0x31680A88F8953031u); | |
| 83 | ||
| 84 | // For uint32_t truncation, see the __mod1e9() comment in d2s_intrinsics.h. | |
| 85 | const uint32_t __shifted = static_cast<uint32_t>(__multiplied >> 29); | |
| 86 | ||
| 87 | return static_cast<uint32_t>(__vLo) - 1000000000 * __shifted; | |
| 88 | } | |
| 89 | #endif // ^^^ intrinsics available ^^^ | |
| 90 | ||
| 91 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulShift_mod1e9(const uint64_t __m, const uint64_t* const __mul, const int32_t __j) { | |
| 92 | uint64_t __high0; // 64 | |
| 93 | const uint64_t __low0 = __ryu_umul128(__m, __mul[0], &__high0); // 0 | |
| 94 | uint64_t __high1; // 128 | |
| 95 | const uint64_t __low1 = __ryu_umul128(__m, __mul[1], &__high1); // 64 | |
| 96 | uint64_t __high2; // 192 | |
| 97 | const uint64_t __low2 = __ryu_umul128(__m, __mul[2], &__high2); // 128 | |
| 98 | const uint64_t __s0low = __low0; // 0 | |
| 99 | (void) __s0low; // unused | |
| 100 | const uint64_t __s0high = __low1 + __high0; // 64 | |
| 101 | const uint32_t __c1 = __s0high < __low1; | |
| 102 | const uint64_t __s1low = __low2 + __high1 + __c1; // 128 | |
| 103 | const uint32_t __c2 = __s1low < __low2; // __high1 + __c1 can't overflow, so compare against __low2 | |
| 104 | const uint64_t __s1high = __high2 + __c2; // 192 | |
| 105 | _LIBCPP_ASSERT(__j >= 128, ""); | |
| 106 | _LIBCPP_ASSERT(__j <= 180, ""); | |
| 107 | #ifdef _LIBCPP_INTRINSIC128 | |
| 108 | const uint32_t __dist = static_cast<uint32_t>(__j - 128); // __dist: [0, 52] | |
| 109 | const uint64_t __shiftedhigh = __s1high >> __dist; | |
| 110 | const uint64_t __shiftedlow = __ryu_shiftright128(__s1low, __s1high, __dist); | |
| 111 | return __uint128_mod1e9(__shiftedhigh, __shiftedlow); | |
| 112 | #else // ^^^ intrinsics available ^^^ / vvv intrinsics unavailable vvv | |
| 113 | if (__j < 160) { // __j: [128, 160) | |
| 114 | const uint64_t __r0 = __mod1e9(__s1high); | |
| 115 | const uint64_t __r1 = __mod1e9((__r0 << 32) | (__s1low >> 32)); | |
| 116 | const uint64_t __r2 = ((__r1 << 32) | (__s1low & 0xffffffff)); | |
| 117 | return __mod1e9(__r2 >> (__j - 128)); | |
| 118 | } else { // __j: [160, 192) | |
| 119 | const uint64_t __r0 = __mod1e9(__s1high); | |
| 120 | const uint64_t __r1 = ((__r0 << 32) | (__s1low >> 32)); | |
| 121 | return __mod1e9(__r1 >> (__j - 160)); | |
| 122 | } | |
| 123 | #endif // ^^^ intrinsics unavailable ^^^ | |
| 124 | } | |
| 125 | ||
| 126 | void __append_n_digits(const uint32_t __olength, uint32_t __digits, char* const __result) { | |
| 127 | uint32_t __i = 0; | |
| 128 | while (__digits >= 10000) { | |
| 129 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 130 | const uint32_t __c = __digits - 10000 * (__digits / 10000); | |
| 131 | #else | |
| 132 | const uint32_t __c = __digits % 10000; | |
| 133 | #endif | |
| 134 | __digits /= 10000; | |
| 135 | const uint32_t __c0 = (__c % 100) << 1; | |
| 136 | const uint32_t __c1 = (__c / 100) << 1; | |
| 137 | _VSTD::memcpy(__result + __olength - __i - 2, __DIGIT_TABLE + __c0, 2); | |
| 138 | _VSTD::memcpy(__result + __olength - __i - 4, __DIGIT_TABLE + __c1, 2); | |
| 139 | __i += 4; | |
| 140 | } | |
| 141 | if (__digits >= 100) { | |
| 142 | const uint32_t __c = (__digits % 100) << 1; | |
| 143 | __digits /= 100; | |
| 144 | _VSTD::memcpy(__result + __olength - __i - 2, __DIGIT_TABLE + __c, 2); | |
| 145 | __i += 2; | |
| 146 | } | |
| 147 | if (__digits >= 10) { | |
| 148 | const uint32_t __c = __digits << 1; | |
| 149 | _VSTD::memcpy(__result + __olength - __i - 2, __DIGIT_TABLE + __c, 2); | |
| 150 | } else { | |
| 151 | __result[0] = static_cast<char>('0' + __digits); | |
| 152 | } | |
| 153 | } | |
| 154 | ||
| 155 | _LIBCPP_HIDE_FROM_ABI inline void __append_d_digits(const uint32_t __olength, uint32_t __digits, char* const __result) { | |
| 156 | uint32_t __i = 0; | |
| 157 | while (__digits >= 10000) { | |
| 158 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 159 | const uint32_t __c = __digits - 10000 * (__digits / 10000); | |
| 160 | #else | |
| 161 | const uint32_t __c = __digits % 10000; | |
| 162 | #endif | |
| 163 | __digits /= 10000; | |
| 164 | const uint32_t __c0 = (__c % 100) << 1; | |
| 165 | const uint32_t __c1 = (__c / 100) << 1; | |
| 166 | _VSTD::memcpy(__result + __olength + 1 - __i - 2, __DIGIT_TABLE + __c0, 2); | |
| 167 | _VSTD::memcpy(__result + __olength + 1 - __i - 4, __DIGIT_TABLE + __c1, 2); | |
| 168 | __i += 4; | |
| 169 | } | |
| 170 | if (__digits >= 100) { | |
| 171 | const uint32_t __c = (__digits % 100) << 1; | |
| 172 | __digits /= 100; | |
| 173 | _VSTD::memcpy(__result + __olength + 1 - __i - 2, __DIGIT_TABLE + __c, 2); | |
| 174 | __i += 2; | |
| 175 | } | |
| 176 | if (__digits >= 10) { | |
| 177 | const uint32_t __c = __digits << 1; | |
| 178 | __result[2] = __DIGIT_TABLE[__c + 1]; | |
| 179 | __result[1] = '.'; | |
| 180 | __result[0] = __DIGIT_TABLE[__c]; | |
| 181 | } else { | |
| 182 | __result[1] = '.'; | |
| 183 | __result[0] = static_cast<char>('0' + __digits); | |
| 184 | } | |
| 185 | } | |
| 186 | ||
| 187 | _LIBCPP_HIDE_FROM_ABI inline void __append_c_digits(const uint32_t __count, uint32_t __digits, char* const __result) { | |
| 188 | uint32_t __i = 0; | |
| 189 | for (; __i < __count - 1; __i += 2) { | |
| 190 | const uint32_t __c = (__digits % 100) << 1; | |
| 191 | __digits /= 100; | |
| 192 | _VSTD::memcpy(__result + __count - __i - 2, __DIGIT_TABLE + __c, 2); | |
| 193 | } | |
| 194 | if (__i < __count) { | |
| 195 | const char __c = static_cast<char>('0' + (__digits % 10)); | |
| 196 | __result[__count - __i - 1] = __c; | |
| 197 | } | |
| 198 | } | |
| 199 | ||
| 200 | void __append_nine_digits(uint32_t __digits, char* const __result) { | |
| 201 | if (__digits == 0) { | |
| 202 | _VSTD::memset(__result, '0', 9); | |
| 203 | return; | |
| 204 | } | |
| 205 | ||
| 206 | for (uint32_t __i = 0; __i < 5; __i += 4) { | |
| 207 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 208 | const uint32_t __c = __digits - 10000 * (__digits / 10000); | |
| 209 | #else | |
| 210 | const uint32_t __c = __digits % 10000; | |
| 211 | #endif | |
| 212 | __digits /= 10000; | |
| 213 | const uint32_t __c0 = (__c % 100) << 1; | |
| 214 | const uint32_t __c1 = (__c / 100) << 1; | |
| 215 | _VSTD::memcpy(__result + 7 - __i, __DIGIT_TABLE + __c0, 2); | |
| 216 | _VSTD::memcpy(__result + 5 - __i, __DIGIT_TABLE + __c1, 2); | |
| 217 | } | |
| 218 | __result[0] = static_cast<char>('0' + __digits); | |
| 219 | } | |
| 220 | ||
| 221 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __indexForExponent(const uint32_t __e) { | |
| 222 | return (__e + 15) / 16; | |
| 223 | } | |
| 224 | ||
| 225 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow10BitsForIndex(const uint32_t __idx) { | |
| 226 | return 16 * __idx + __POW10_ADDITIONAL_BITS; | |
| 227 | } | |
| 228 | ||
| 229 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __lengthForIndex(const uint32_t __idx) { | |
| 230 | // +1 for ceil, +16 for mantissa, +8 to round up when dividing by 9 | |
| 231 | return (__log10Pow2(16 * static_cast<int32_t>(__idx)) + 1 + 16 + 8) / 9; | |
| 232 | } | |
| 233 | ||
| 234 | [[nodiscard]] to_chars_result __d2fixed_buffered_n(char* _First, char* const _Last, const double __d, | |
| 235 | const uint32_t __precision) { | |
| 236 | char* const _Original_first = _First; | |
| 237 | ||
| 238 | const uint64_t __bits = __double_to_bits(__d); | |
| 239 | ||
| 240 | // Case distinction; exit early for the easy cases. | |
| 241 | if (__bits == 0) { | |
| 242 | const int32_t _Total_zero_length = 1 // leading zero | |
| 243 | + static_cast<int32_t>(__precision != 0) // possible decimal point | |
| 244 | + static_cast<int32_t>(__precision); // zeroes after decimal point | |
| 245 | ||
| 246 | if (_Last - _First < _Total_zero_length) { | |
| 247 | return { _Last, errc::value_too_large }; | |
| 248 | } | |
| 249 | ||
| 250 | *_First++ = '0'; | |
| 251 | if (__precision > 0) { | |
| 252 | *_First++ = '.'; | |
| 253 | _VSTD::memset(_First, '0', __precision); | |
| 254 | _First += __precision; | |
| 255 | } | |
| 256 | return { _First, errc{} }; | |
| 257 | } | |
| 258 | ||
| 259 | // Decode __bits into mantissa and exponent. | |
| 260 | const uint64_t __ieeeMantissa = __bits & ((1ull << __DOUBLE_MANTISSA_BITS) - 1); | |
| 261 | const uint32_t __ieeeExponent = static_cast<uint32_t>(__bits >> __DOUBLE_MANTISSA_BITS); | |
| 262 | ||
| 263 | int32_t __e2; | |
| 264 | uint64_t __m2; | |
| 265 | if (__ieeeExponent == 0) { | |
| 266 | __e2 = 1 - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; | |
| 267 | __m2 = __ieeeMantissa; | |
| 268 | } else { | |
| 269 | __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; | |
| 270 | __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa; | |
| 271 | } | |
| 272 | ||
| 273 | bool __nonzero = false; | |
| 274 | if (__e2 >= -52) { | |
| 275 | const uint32_t __idx = __e2 < 0 ? 0 : __indexForExponent(static_cast<uint32_t>(__e2)); | |
| 276 | const uint32_t __p10bits = __pow10BitsForIndex(__idx); | |
| 277 | const int32_t __len = static_cast<int32_t>(__lengthForIndex(__idx)); | |
| 278 | for (int32_t __i = __len - 1; __i >= 0; --__i) { | |
| 279 | const uint32_t __j = __p10bits - __e2; | |
| 280 | // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is | |
| 281 | // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers. | |
| 282 | const uint32_t __digits = __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT[__POW10_OFFSET[__idx] + __i], | |
| 283 | static_cast<int32_t>(__j + 8)); | |
| 284 | if (__nonzero) { | |
| 285 | if (_Last - _First < 9) { | |
| 286 | return { _Last, errc::value_too_large }; | |
| 287 | } | |
| 288 | __append_nine_digits(__digits, _First); | |
| 289 | _First += 9; | |
| 290 | } else if (__digits != 0) { | |
| 291 | const uint32_t __olength = __decimalLength9(__digits); | |
| 292 | if (_Last - _First < static_cast<ptrdiff_t>(__olength)) { | |
| 293 | return { _Last, errc::value_too_large }; | |
| 294 | } | |
| 295 | __append_n_digits(__olength, __digits, _First); | |
| 296 | _First += __olength; | |
| 297 | __nonzero = true; | |
| 298 | } | |
| 299 | } | |
| 300 | } | |
| 301 | if (!__nonzero) { | |
| 302 | if (_First == _Last) { | |
| 303 | return { _Last, errc::value_too_large }; | |
| 304 | } | |
| 305 | *_First++ = '0'; | |
| 306 | } | |
| 307 | if (__precision > 0) { | |
| 308 | if (_First == _Last) { | |
| 309 | return { _Last, errc::value_too_large }; | |
| 310 | } | |
| 311 | *_First++ = '.'; | |
| 312 | } | |
| 313 | if (__e2 < 0) { | |
| 314 | const int32_t __idx = -__e2 / 16; | |
| 315 | const uint32_t __blocks = __precision / 9 + 1; | |
| 316 | // 0 = don't round up; 1 = round up unconditionally; 2 = round up if odd. | |
| 317 | int __roundUp = 0; | |
| 318 | uint32_t __i = 0; | |
| 319 | if (__blocks <= __MIN_BLOCK_2[__idx]) { | |
| 320 | __i = __blocks; | |
| 321 | if (_Last - _First < static_cast<ptrdiff_t>(__precision)) { | |
| 322 | return { _Last, errc::value_too_large }; | |
| 323 | } | |
| 324 | _VSTD::memset(_First, '0', __precision); | |
| 325 | _First += __precision; | |
| 326 | } else if (__i < __MIN_BLOCK_2[__idx]) { | |
| 327 | __i = __MIN_BLOCK_2[__idx]; | |
| 328 | if (_Last - _First < static_cast<ptrdiff_t>(9 * __i)) { | |
| 329 | return { _Last, errc::value_too_large }; | |
| 330 | } | |
| 331 | _VSTD::memset(_First, '0', 9 * __i); | |
| 332 | _First += 9 * __i; | |
| 333 | } | |
| 334 | for (; __i < __blocks; ++__i) { | |
| 335 | const int32_t __j = __ADDITIONAL_BITS_2 + (-__e2 - 16 * __idx); | |
| 336 | const uint32_t __p = __POW10_OFFSET_2[__idx] + __i - __MIN_BLOCK_2[__idx]; | |
| 337 | if (__p >= __POW10_OFFSET_2[__idx + 1]) { | |
| 338 | // If the remaining digits are all 0, then we might as well use memset. | |
| 339 | // No rounding required in this case. | |
| 340 | const uint32_t __fill = __precision - 9 * __i; | |
| 341 | if (_Last - _First < static_cast<ptrdiff_t>(__fill)) { | |
| 342 | return { _Last, errc::value_too_large }; | |
| 343 | } | |
| 344 | _VSTD::memset(_First, '0', __fill); | |
| 345 | _First += __fill; | |
| 346 | break; | |
| 347 | } | |
| 348 | // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is | |
| 349 | // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers. | |
| 350 | uint32_t __digits = __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT_2[__p], __j + 8); | |
| 351 | if (__i < __blocks - 1) { | |
| 352 | if (_Last - _First < 9) { | |
| 353 | return { _Last, errc::value_too_large }; | |
| 354 | } | |
| 355 | __append_nine_digits(__digits, _First); | |
| 356 | _First += 9; | |
| 357 | } else { | |
| 358 | const uint32_t __maximum = __precision - 9 * __i; | |
| 359 | uint32_t __lastDigit = 0; | |
| 360 | for (uint32_t __k = 0; __k < 9 - __maximum; ++__k) { | |
| 361 | __lastDigit = __digits % 10; | |
| 362 | __digits /= 10; | |
| 363 | } | |
| 364 | if (__lastDigit != 5) { | |
| 365 | __roundUp = __lastDigit > 5; | |
| 366 | } else { | |
| 367 | // Is m * 10^(additionalDigits + 1) / 2^(-__e2) integer? | |
| 368 | const int32_t __requiredTwos = -__e2 - static_cast<int32_t>(__precision) - 1; | |
| 369 | const bool __trailingZeros = __requiredTwos <= 0 | |
| 370 | || (__requiredTwos < 60 && __multipleOfPowerOf2(__m2, static_cast<uint32_t>(__requiredTwos))); | |
| 371 | __roundUp = __trailingZeros ? 2 : 1; | |
| 372 | } | |
| 373 | if (__maximum > 0) { | |
| 374 | if (_Last - _First < static_cast<ptrdiff_t>(__maximum)) { | |
| 375 | return { _Last, errc::value_too_large }; | |
| 376 | } | |
| 377 | __append_c_digits(__maximum, __digits, _First); | |
| 378 | _First += __maximum; | |
| 379 | } | |
| 380 | break; | |
| 381 | } | |
| 382 | } | |
| 383 | if (__roundUp != 0) { | |
| 384 | char* _Round = _First; | |
| 385 | char* _Dot = _Last; | |
| 386 | while (true) { | |
| 387 | if (_Round == _Original_first) { | |
| 388 | _Round[0] = '1'; | |
| 389 | if (_Dot != _Last) { | |
| 390 | _Dot[0] = '0'; | |
| 391 | _Dot[1] = '.'; | |
| 392 | } | |
| 393 | if (_First == _Last) { | |
| 394 | return { _Last, errc::value_too_large }; | |
| 395 | } | |
| 396 | *_First++ = '0'; | |
| 397 | break; | |
| 398 | } | |
| 399 | --_Round; | |
| 400 | const char __c = _Round[0]; | |
| 401 | if (__c == '.') { | |
| 402 | _Dot = _Round; | |
| 403 | } else if (__c == '9') { | |
| 404 | _Round[0] = '0'; | |
| 405 | __roundUp = 1; | |
| 406 | } else { | |
| 407 | if (__roundUp == 1 || __c % 2 != 0) { | |
| 408 | _Round[0] = __c + 1; | |
| 409 | } | |
| 410 | break; | |
| 411 | } | |
| 412 | } | |
| 413 | } | |
| 414 | } else { | |
| 415 | if (_Last - _First < static_cast<ptrdiff_t>(__precision)) { | |
| 416 | return { _Last, errc::value_too_large }; | |
| 417 | } | |
| 418 | _VSTD::memset(_First, '0', __precision); | |
| 419 | _First += __precision; | |
| 420 | } | |
| 421 | return { _First, errc{} }; | |
| 422 | } | |
| 423 | ||
| 424 | [[nodiscard]] to_chars_result __d2exp_buffered_n(char* _First, char* const _Last, const double __d, | |
| 425 | uint32_t __precision) { | |
| 426 | char* const _Original_first = _First; | |
| 427 | ||
| 428 | const uint64_t __bits = __double_to_bits(__d); | |
| 429 | ||
| 430 | // Case distinction; exit early for the easy cases. | |
| 431 | if (__bits == 0) { | |
| 432 | const int32_t _Total_zero_length = 1 // leading zero | |
| 433 | + static_cast<int32_t>(__precision != 0) // possible decimal point | |
| 434 | + static_cast<int32_t>(__precision) // zeroes after decimal point | |
| 435 | + 4; // "e+00" | |
| 436 | if (_Last - _First < _Total_zero_length) { | |
| 437 | return { _Last, errc::value_too_large }; | |
| 438 | } | |
| 439 | *_First++ = '0'; | |
| 440 | if (__precision > 0) { | |
| 441 | *_First++ = '.'; | |
| 442 | _VSTD::memset(_First, '0', __precision); | |
| 443 | _First += __precision; | |
| 444 | } | |
| 445 | _VSTD::memcpy(_First, "e+00", 4); | |
| 446 | _First += 4; | |
| 447 | return { _First, errc{} }; | |
| 448 | } | |
| 449 | ||
| 450 | // Decode __bits into mantissa and exponent. | |
| 451 | const uint64_t __ieeeMantissa = __bits & ((1ull << __DOUBLE_MANTISSA_BITS) - 1); | |
| 452 | const uint32_t __ieeeExponent = static_cast<uint32_t>(__bits >> __DOUBLE_MANTISSA_BITS); | |
| 453 | ||
| 454 | int32_t __e2; | |
| 455 | uint64_t __m2; | |
| 456 | if (__ieeeExponent == 0) { | |
| 457 | __e2 = 1 - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; | |
| 458 | __m2 = __ieeeMantissa; | |
| 459 | } else { | |
| 460 | __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; | |
| 461 | __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa; | |
| 462 | } | |
| 463 | ||
| 464 | const bool __printDecimalPoint = __precision > 0; | |
| 465 | ++__precision; | |
| 466 | uint32_t __digits = 0; | |
| 467 | uint32_t __printedDigits = 0; | |
| 468 | uint32_t __availableDigits = 0; | |
| 469 | int32_t __exp = 0; | |
| 470 | if (__e2 >= -52) { | |
| 471 | const uint32_t __idx = __e2 < 0 ? 0 : __indexForExponent(static_cast<uint32_t>(__e2)); | |
| 472 | const uint32_t __p10bits = __pow10BitsForIndex(__idx); | |
| 473 | const int32_t __len = static_cast<int32_t>(__lengthForIndex(__idx)); | |
| 474 | for (int32_t __i = __len - 1; __i >= 0; --__i) { | |
| 475 | const uint32_t __j = __p10bits - __e2; | |
| 476 | // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is | |
| 477 | // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers. | |
| 478 | __digits = __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT[__POW10_OFFSET[__idx] + __i], | |
| 479 | static_cast<int32_t>(__j + 8)); | |
| 480 | if (__printedDigits != 0) { | |
| 481 | if (__printedDigits + 9 > __precision) { | |
| 482 | __availableDigits = 9; | |
| 483 | break; | |
| 484 | } | |
| 485 | if (_Last - _First < 9) { | |
| 486 | return { _Last, errc::value_too_large }; | |
| 487 | } | |
| 488 | __append_nine_digits(__digits, _First); | |
| 489 | _First += 9; | |
| 490 | __printedDigits += 9; | |
| 491 | } else if (__digits != 0) { | |
| 492 | __availableDigits = __decimalLength9(__digits); | |
| 493 | __exp = __i * 9 + static_cast<int32_t>(__availableDigits) - 1; | |
| 494 | if (__availableDigits > __precision) { | |
| 495 | break; | |
| 496 | } | |
| 497 | if (__printDecimalPoint) { | |
| 498 | if (_Last - _First < static_cast<ptrdiff_t>(__availableDigits + 1)) { | |
| 499 | return { _Last, errc::value_too_large }; | |
| 500 | } | |
| 501 | __append_d_digits(__availableDigits, __digits, _First); | |
| 502 | _First += __availableDigits + 1; // +1 for decimal point | |
| 503 | } else { | |
| 504 | if (_First == _Last) { | |
| 505 | return { _Last, errc::value_too_large }; | |
| 506 | } | |
| 507 | *_First++ = static_cast<char>('0' + __digits); | |
| 508 | } | |
| 509 | __printedDigits = __availableDigits; | |
| 510 | __availableDigits = 0; | |
| 511 | } | |
| 512 | } | |
| 513 | } | |
| 514 | ||
| 515 | if (__e2 < 0 && __availableDigits == 0) { | |
| 516 | const int32_t __idx = -__e2 / 16; | |
| 517 | for (int32_t __i = __MIN_BLOCK_2[__idx]; __i < 200; ++__i) { | |
| 518 | const int32_t __j = __ADDITIONAL_BITS_2 + (-__e2 - 16 * __idx); | |
| 519 | const uint32_t __p = __POW10_OFFSET_2[__idx] + static_cast<uint32_t>(__i) - __MIN_BLOCK_2[__idx]; | |
| 520 | // Temporary: __j is usually around 128, and by shifting a bit, we push it to 128 or above, which is | |
| 521 | // a slightly faster code path in __mulShift_mod1e9. Instead, we can just increase the multipliers. | |
| 522 | __digits = (__p >= __POW10_OFFSET_2[__idx + 1]) ? 0 : __mulShift_mod1e9(__m2 << 8, __POW10_SPLIT_2[__p], __j + 8); | |
| 523 | if (__printedDigits != 0) { | |
| 524 | if (__printedDigits + 9 > __precision) { | |
| 525 | __availableDigits = 9; | |
| 526 | break; | |
| 527 | } | |
| 528 | if (_Last - _First < 9) { | |
| 529 | return { _Last, errc::value_too_large }; | |
| 530 | } | |
| 531 | __append_nine_digits(__digits, _First); | |
| 532 | _First += 9; | |
| 533 | __printedDigits += 9; | |
| 534 | } else if (__digits != 0) { | |
| 535 | __availableDigits = __decimalLength9(__digits); | |
| 536 | __exp = -(__i + 1) * 9 + static_cast<int32_t>(__availableDigits) - 1; | |
| 537 | if (__availableDigits > __precision) { | |
| 538 | break; | |
| 539 | } | |
| 540 | if (__printDecimalPoint) { | |
| 541 | if (_Last - _First < static_cast<ptrdiff_t>(__availableDigits + 1)) { | |
| 542 | return { _Last, errc::value_too_large }; | |
| 543 | } | |
| 544 | __append_d_digits(__availableDigits, __digits, _First); | |
| 545 | _First += __availableDigits + 1; // +1 for decimal point | |
| 546 | } else { | |
| 547 | if (_First == _Last) { | |
| 548 | return { _Last, errc::value_too_large }; | |
| 549 | } | |
| 550 | *_First++ = static_cast<char>('0' + __digits); | |
| 551 | } | |
| 552 | __printedDigits = __availableDigits; | |
| 553 | __availableDigits = 0; | |
| 554 | } | |
| 555 | } | |
| 556 | } | |
| 557 | ||
| 558 | const uint32_t __maximum = __precision - __printedDigits; | |
| 559 | if (__availableDigits == 0) { | |
| 560 | __digits = 0; | |
| 561 | } | |
| 562 | uint32_t __lastDigit = 0; | |
| 563 | if (__availableDigits > __maximum) { | |
| 564 | for (uint32_t __k = 0; __k < __availableDigits - __maximum; ++__k) { | |
| 565 | __lastDigit = __digits % 10; | |
| 566 | __digits /= 10; | |
| 567 | } | |
| 568 | } | |
| 569 | // 0 = don't round up; 1 = round up unconditionally; 2 = round up if odd. | |
| 570 | int __roundUp = 0; | |
| 571 | if (__lastDigit != 5) { | |
| 572 | __roundUp = __lastDigit > 5; | |
| 573 | } else { | |
| 574 | // Is m * 2^__e2 * 10^(__precision + 1 - __exp) integer? | |
| 575 | // __precision was already increased by 1, so we don't need to write + 1 here. | |
| 576 | const int32_t __rexp = static_cast<int32_t>(__precision) - __exp; | |
| 577 | const int32_t __requiredTwos = -__e2 - __rexp; | |
| 578 | bool __trailingZeros = __requiredTwos <= 0 | |
| 579 | || (__requiredTwos < 60 && __multipleOfPowerOf2(__m2, static_cast<uint32_t>(__requiredTwos))); | |
| 580 | if (__rexp < 0) { | |
| 581 | const int32_t __requiredFives = -__rexp; | |
| 582 | __trailingZeros = __trailingZeros && __multipleOfPowerOf5(__m2, static_cast<uint32_t>(__requiredFives)); | |
| 583 | } | |
| 584 | __roundUp = __trailingZeros ? 2 : 1; | |
| 585 | } | |
| 586 | if (__printedDigits != 0) { | |
| 587 | if (_Last - _First < static_cast<ptrdiff_t>(__maximum)) { | |
| 588 | return { _Last, errc::value_too_large }; | |
| 589 | } | |
| 590 | if (__digits == 0) { | |
| 591 | _VSTD::memset(_First, '0', __maximum); | |
| 592 | } else { | |
| 593 | __append_c_digits(__maximum, __digits, _First); | |
| 594 | } | |
| 595 | _First += __maximum; | |
| 596 | } else { | |
| 597 | if (__printDecimalPoint) { | |
| 598 | if (_Last - _First < static_cast<ptrdiff_t>(__maximum + 1)) { | |
| 599 | return { _Last, errc::value_too_large }; | |
| 600 | } | |
| 601 | __append_d_digits(__maximum, __digits, _First); | |
| 602 | _First += __maximum + 1; // +1 for decimal point | |
| 603 | } else { | |
| 604 | if (_First == _Last) { | |
| 605 | return { _Last, errc::value_too_large }; | |
| 606 | } | |
| 607 | *_First++ = static_cast<char>('0' + __digits); | |
| 608 | } | |
| 609 | } | |
| 610 | if (__roundUp != 0) { | |
| 611 | char* _Round = _First; | |
| 612 | while (true) { | |
| 613 | if (_Round == _Original_first) { | |
| 614 | _Round[0] = '1'; | |
| 615 | ++__exp; | |
| 616 | break; | |
| 617 | } | |
| 618 | --_Round; | |
| 619 | const char __c = _Round[0]; | |
| 620 | if (__c == '.') { | |
| 621 | // Keep going. | |
| 622 | } else if (__c == '9') { | |
| 623 | _Round[0] = '0'; | |
| 624 | __roundUp = 1; | |
| 625 | } else { | |
| 626 | if (__roundUp == 1 || __c % 2 != 0) { | |
| 627 | _Round[0] = __c + 1; | |
| 628 | } | |
| 629 | break; | |
| 630 | } | |
| 631 | } | |
| 632 | } | |
| 633 | ||
| 634 | char _Sign_character; | |
| 635 | ||
| 636 | if (__exp < 0) { | |
| 637 | _Sign_character = '-'; | |
| 638 | __exp = -__exp; | |
| 639 | } else { | |
| 640 | _Sign_character = '+'; | |
| 641 | } | |
| 642 | ||
| 643 | const int _Exponent_part_length = __exp >= 100 | |
| 644 | ? 5 // "e+NNN" | |
| 645 | : 4; // "e+NN" | |
| 646 | ||
| 647 | if (_Last - _First < _Exponent_part_length) { | |
| 648 | return { _Last, errc::value_too_large }; | |
| 649 | } | |
| 650 | ||
| 651 | *_First++ = 'e'; | |
| 652 | *_First++ = _Sign_character; | |
| 653 | ||
| 654 | if (__exp >= 100) { | |
| 655 | const int32_t __c = __exp % 10; | |
| 656 | _VSTD::memcpy(_First, __DIGIT_TABLE + 2 * (__exp / 10), 2); | |
| 657 | _First[2] = static_cast<char>('0' + __c); | |
| 658 | _First += 3; | |
| 659 | } else { | |
| 660 | _VSTD::memcpy(_First, __DIGIT_TABLE + 2 * __exp, 2); | |
| 661 | _First += 2; | |
| 662 | } | |
| 663 | ||
| 664 | return { _First, errc{} }; | |
| 665 | } | |
| 666 | ||
| 667 | _LIBCPP_END_NAMESPACE_STD | |
| 668 | ||
| 669 | // clang-format on |
lib/libcxx/src/ryu/d2s.cpp created+782| ... | ... | @@ -0,0 +1,782 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | // Avoid formatting to keep the changes with the original code minimal. | |
| 40 | // clang-format off | |
| 41 | ||
| 42 | #include "__config" | |
| 43 | #include "charconv" | |
| 44 | ||
| 45 | #include "include/ryu/common.h" | |
| 46 | #include "include/ryu/d2fixed.h" | |
| 47 | #include "include/ryu/d2s.h" | |
| 48 | #include "include/ryu/d2s_full_table.h" | |
| 49 | #include "include/ryu/d2s_intrinsics.h" | |
| 50 | #include "include/ryu/digit_table.h" | |
| 51 | #include "include/ryu/ryu.h" | |
| 52 | ||
| 53 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 54 | ||
| 55 | // We need a 64x128-bit multiplication and a subsequent 128-bit shift. | |
| 56 | // Multiplication: | |
| 57 | // The 64-bit factor is variable and passed in, the 128-bit factor comes | |
| 58 | // from a lookup table. We know that the 64-bit factor only has 55 | |
| 59 | // significant bits (i.e., the 9 topmost bits are zeros). The 128-bit | |
| 60 | // factor only has 124 significant bits (i.e., the 4 topmost bits are | |
| 61 | // zeros). | |
| 62 | // Shift: | |
| 63 | // In principle, the multiplication result requires 55 + 124 = 179 bits to | |
| 64 | // represent. However, we then shift this value to the right by __j, which is | |
| 65 | // at least __j >= 115, so the result is guaranteed to fit into 179 - 115 = 64 | |
| 66 | // bits. This means that we only need the topmost 64 significant bits of | |
| 67 | // the 64x128-bit multiplication. | |
| 68 | // | |
| 69 | // There are several ways to do this: | |
| 70 | // 1. Best case: the compiler exposes a 128-bit type. | |
| 71 | // We perform two 64x64-bit multiplications, add the higher 64 bits of the | |
| 72 | // lower result to the higher result, and shift by __j - 64 bits. | |
| 73 | // | |
| 74 | // We explicitly cast from 64-bit to 128-bit, so the compiler can tell | |
| 75 | // that these are only 64-bit inputs, and can map these to the best | |
| 76 | // possible sequence of assembly instructions. | |
| 77 | // x64 machines happen to have matching assembly instructions for | |
| 78 | // 64x64-bit multiplications and 128-bit shifts. | |
| 79 | // | |
| 80 | // 2. Second best case: the compiler exposes intrinsics for the x64 assembly | |
| 81 | // instructions mentioned in 1. | |
| 82 | // | |
| 83 | // 3. We only have 64x64 bit instructions that return the lower 64 bits of | |
| 84 | // the result, i.e., we have to use plain C. | |
| 85 | // Our inputs are less than the full width, so we have three options: | |
| 86 | // a. Ignore this fact and just implement the intrinsics manually. | |
| 87 | // b. Split both into 31-bit pieces, which guarantees no internal overflow, | |
| 88 | // but requires extra work upfront (unless we change the lookup table). | |
| 89 | // c. Split only the first factor into 31-bit pieces, which also guarantees | |
| 90 | // no internal overflow, but requires extra work since the intermediate | |
| 91 | // results are not perfectly aligned. | |
| 92 | #ifdef _LIBCPP_INTRINSIC128 | |
| 93 | ||
| 94 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __mulShift(const uint64_t __m, const uint64_t* const __mul, const int32_t __j) { | |
| 95 | // __m is maximum 55 bits | |
| 96 | uint64_t __high1; // 128 | |
| 97 | const uint64_t __low1 = __ryu_umul128(__m, __mul[1], &__high1); // 64 | |
| 98 | uint64_t __high0; // 64 | |
| 99 | (void) __ryu_umul128(__m, __mul[0], &__high0); // 0 | |
| 100 | const uint64_t __sum = __high0 + __low1; | |
| 101 | if (__sum < __high0) { | |
| 102 | ++__high1; // overflow into __high1 | |
| 103 | } | |
| 104 | return __ryu_shiftright128(__sum, __high1, static_cast<uint32_t>(__j - 64)); | |
| 105 | } | |
| 106 | ||
| 107 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint64_t __mulShiftAll(const uint64_t __m, const uint64_t* const __mul, const int32_t __j, | |
| 108 | uint64_t* const __vp, uint64_t* const __vm, const uint32_t __mmShift) { | |
| 109 | *__vp = __mulShift(4 * __m + 2, __mul, __j); | |
| 110 | *__vm = __mulShift(4 * __m - 1 - __mmShift, __mul, __j); | |
| 111 | return __mulShift(4 * __m, __mul, __j); | |
| 112 | } | |
| 113 | ||
| 114 | #else // ^^^ intrinsics available ^^^ / vvv intrinsics unavailable vvv | |
| 115 | ||
| 116 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ALWAYS_INLINE uint64_t __mulShiftAll(uint64_t __m, const uint64_t* const __mul, const int32_t __j, | |
| 117 | uint64_t* const __vp, uint64_t* const __vm, const uint32_t __mmShift) { // TRANSITION, VSO-634761 | |
| 118 | __m <<= 1; | |
| 119 | // __m is maximum 55 bits | |
| 120 | uint64_t __tmp; | |
| 121 | const uint64_t __lo = __ryu_umul128(__m, __mul[0], &__tmp); | |
| 122 | uint64_t __hi; | |
| 123 | const uint64_t __mid = __tmp + __ryu_umul128(__m, __mul[1], &__hi); | |
| 124 | __hi += __mid < __tmp; // overflow into __hi | |
| 125 | ||
| 126 | const uint64_t __lo2 = __lo + __mul[0]; | |
| 127 | const uint64_t __mid2 = __mid + __mul[1] + (__lo2 < __lo); | |
| 128 | const uint64_t __hi2 = __hi + (__mid2 < __mid); | |
| 129 | *__vp = __ryu_shiftright128(__mid2, __hi2, static_cast<uint32_t>(__j - 64 - 1)); | |
| 130 | ||
| 131 | if (__mmShift == 1) { | |
| 132 | const uint64_t __lo3 = __lo - __mul[0]; | |
| 133 | const uint64_t __mid3 = __mid - __mul[1] - (__lo3 > __lo); | |
| 134 | const uint64_t __hi3 = __hi - (__mid3 > __mid); | |
| 135 | *__vm = __ryu_shiftright128(__mid3, __hi3, static_cast<uint32_t>(__j - 64 - 1)); | |
| 136 | } else { | |
| 137 | const uint64_t __lo3 = __lo + __lo; | |
| 138 | const uint64_t __mid3 = __mid + __mid + (__lo3 < __lo); | |
| 139 | const uint64_t __hi3 = __hi + __hi + (__mid3 < __mid); | |
| 140 | const uint64_t __lo4 = __lo3 - __mul[0]; | |
| 141 | const uint64_t __mid4 = __mid3 - __mul[1] - (__lo4 > __lo3); | |
| 142 | const uint64_t __hi4 = __hi3 - (__mid4 > __mid3); | |
| 143 | *__vm = __ryu_shiftright128(__mid4, __hi4, static_cast<uint32_t>(__j - 64)); | |
| 144 | } | |
| 145 | ||
| 146 | return __ryu_shiftright128(__mid, __hi, static_cast<uint32_t>(__j - 64 - 1)); | |
| 147 | } | |
| 148 | ||
| 149 | #endif // ^^^ intrinsics unavailable ^^^ | |
| 150 | ||
| 151 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __decimalLength17(const uint64_t __v) { | |
| 152 | // This is slightly faster than a loop. | |
| 153 | // The average output length is 16.38 digits, so we check high-to-low. | |
| 154 | // Function precondition: __v is not an 18, 19, or 20-digit number. | |
| 155 | // (17 digits are sufficient for round-tripping.) | |
| 156 | _LIBCPP_ASSERT(__v < 100000000000000000u, ""); | |
| 157 | if (__v >= 10000000000000000u) { return 17; } | |
| 158 | if (__v >= 1000000000000000u) { return 16; } | |
| 159 | if (__v >= 100000000000000u) { return 15; } | |
| 160 | if (__v >= 10000000000000u) { return 14; } | |
| 161 | if (__v >= 1000000000000u) { return 13; } | |
| 162 | if (__v >= 100000000000u) { return 12; } | |
| 163 | if (__v >= 10000000000u) { return 11; } | |
| 164 | if (__v >= 1000000000u) { return 10; } | |
| 165 | if (__v >= 100000000u) { return 9; } | |
| 166 | if (__v >= 10000000u) { return 8; } | |
| 167 | if (__v >= 1000000u) { return 7; } | |
| 168 | if (__v >= 100000u) { return 6; } | |
| 169 | if (__v >= 10000u) { return 5; } | |
| 170 | if (__v >= 1000u) { return 4; } | |
| 171 | if (__v >= 100u) { return 3; } | |
| 172 | if (__v >= 10u) { return 2; } | |
| 173 | return 1; | |
| 174 | } | |
| 175 | ||
| 176 | // A floating decimal representing m * 10^e. | |
| 177 | struct __floating_decimal_64 { | |
| 178 | uint64_t __mantissa; | |
| 179 | int32_t __exponent; | |
| 180 | }; | |
| 181 | ||
| 182 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline __floating_decimal_64 __d2d(const uint64_t __ieeeMantissa, const uint32_t __ieeeExponent) { | |
| 183 | int32_t __e2; | |
| 184 | uint64_t __m2; | |
| 185 | if (__ieeeExponent == 0) { | |
| 186 | // We subtract 2 so that the bounds computation has 2 additional bits. | |
| 187 | __e2 = 1 - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS - 2; | |
| 188 | __m2 = __ieeeMantissa; | |
| 189 | } else { | |
| 190 | __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS - 2; | |
| 191 | __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa; | |
| 192 | } | |
| 193 | const bool __even = (__m2 & 1) == 0; | |
| 194 | const bool __acceptBounds = __even; | |
| 195 | ||
| 196 | // Step 2: Determine the interval of valid decimal representations. | |
| 197 | const uint64_t __mv = 4 * __m2; | |
| 198 | // Implicit bool -> int conversion. True is 1, false is 0. | |
| 199 | const uint32_t __mmShift = __ieeeMantissa != 0 || __ieeeExponent <= 1; | |
| 200 | // We would compute __mp and __mm like this: | |
| 201 | // uint64_t __mp = 4 * __m2 + 2; | |
| 202 | // uint64_t __mm = __mv - 1 - __mmShift; | |
| 203 | ||
| 204 | // Step 3: Convert to a decimal power base using 128-bit arithmetic. | |
| 205 | uint64_t __vr, __vp, __vm; | |
| 206 | int32_t __e10; | |
| 207 | bool __vmIsTrailingZeros = false; | |
| 208 | bool __vrIsTrailingZeros = false; | |
| 209 | if (__e2 >= 0) { | |
| 210 | // I tried special-casing __q == 0, but there was no effect on performance. | |
| 211 | // This expression is slightly faster than max(0, __log10Pow2(__e2) - 1). | |
| 212 | const uint32_t __q = __log10Pow2(__e2) - (__e2 > 3); | |
| 213 | __e10 = static_cast<int32_t>(__q); | |
| 214 | const int32_t __k = __DOUBLE_POW5_INV_BITCOUNT + __pow5bits(static_cast<int32_t>(__q)) - 1; | |
| 215 | const int32_t __i = -__e2 + static_cast<int32_t>(__q) + __k; | |
| 216 | __vr = __mulShiftAll(__m2, __DOUBLE_POW5_INV_SPLIT[__q], __i, &__vp, &__vm, __mmShift); | |
| 217 | if (__q <= 21) { | |
| 218 | // This should use __q <= 22, but I think 21 is also safe. Smaller values | |
| 219 | // may still be safe, but it's more difficult to reason about them. | |
| 220 | // Only one of __mp, __mv, and __mm can be a multiple of 5, if any. | |
| 221 | const uint32_t __mvMod5 = static_cast<uint32_t>(__mv) - 5 * static_cast<uint32_t>(__div5(__mv)); | |
| 222 | if (__mvMod5 == 0) { | |
| 223 | __vrIsTrailingZeros = __multipleOfPowerOf5(__mv, __q); | |
| 224 | } else if (__acceptBounds) { | |
| 225 | // Same as min(__e2 + (~__mm & 1), __pow5Factor(__mm)) >= __q | |
| 226 | // <=> __e2 + (~__mm & 1) >= __q && __pow5Factor(__mm) >= __q | |
| 227 | // <=> true && __pow5Factor(__mm) >= __q, since __e2 >= __q. | |
| 228 | __vmIsTrailingZeros = __multipleOfPowerOf5(__mv - 1 - __mmShift, __q); | |
| 229 | } else { | |
| 230 | // Same as min(__e2 + 1, __pow5Factor(__mp)) >= __q. | |
| 231 | __vp -= __multipleOfPowerOf5(__mv + 2, __q); | |
| 232 | } | |
| 233 | } | |
| 234 | } else { | |
| 235 | // This expression is slightly faster than max(0, __log10Pow5(-__e2) - 1). | |
| 236 | const uint32_t __q = __log10Pow5(-__e2) - (-__e2 > 1); | |
| 237 | __e10 = static_cast<int32_t>(__q) + __e2; | |
| 238 | const int32_t __i = -__e2 - static_cast<int32_t>(__q); | |
| 239 | const int32_t __k = __pow5bits(__i) - __DOUBLE_POW5_BITCOUNT; | |
| 240 | const int32_t __j = static_cast<int32_t>(__q) - __k; | |
| 241 | __vr = __mulShiftAll(__m2, __DOUBLE_POW5_SPLIT[__i], __j, &__vp, &__vm, __mmShift); | |
| 242 | if (__q <= 1) { | |
| 243 | // {__vr,__vp,__vm} is trailing zeros if {__mv,__mp,__mm} has at least __q trailing 0 bits. | |
| 244 | // __mv = 4 * __m2, so it always has at least two trailing 0 bits. | |
| 245 | __vrIsTrailingZeros = true; | |
| 246 | if (__acceptBounds) { | |
| 247 | // __mm = __mv - 1 - __mmShift, so it has 1 trailing 0 bit iff __mmShift == 1. | |
| 248 | __vmIsTrailingZeros = __mmShift == 1; | |
| 249 | } else { | |
| 250 | // __mp = __mv + 2, so it always has at least one trailing 0 bit. | |
| 251 | --__vp; | |
| 252 | } | |
| 253 | } else if (__q < 63) { // TRANSITION(ulfjack): Use a tighter bound here. | |
| 254 | // We need to compute min(ntz(__mv), __pow5Factor(__mv) - __e2) >= __q - 1 | |
| 255 | // <=> ntz(__mv) >= __q - 1 && __pow5Factor(__mv) - __e2 >= __q - 1 | |
| 256 | // <=> ntz(__mv) >= __q - 1 (__e2 is negative and -__e2 >= __q) | |
| 257 | // <=> (__mv & ((1 << (__q - 1)) - 1)) == 0 | |
| 258 | // We also need to make sure that the left shift does not overflow. | |
| 259 | __vrIsTrailingZeros = __multipleOfPowerOf2(__mv, __q - 1); | |
| 260 | } | |
| 261 | } | |
| 262 | ||
| 263 | // Step 4: Find the shortest decimal representation in the interval of valid representations. | |
| 264 | int32_t __removed = 0; | |
| 265 | uint8_t __lastRemovedDigit = 0; | |
| 266 | uint64_t _Output; | |
| 267 | // On average, we remove ~2 digits. | |
| 268 | if (__vmIsTrailingZeros || __vrIsTrailingZeros) { | |
| 269 | // General case, which happens rarely (~0.7%). | |
| 270 | for (;;) { | |
| 271 | const uint64_t __vpDiv10 = __div10(__vp); | |
| 272 | const uint64_t __vmDiv10 = __div10(__vm); | |
| 273 | if (__vpDiv10 <= __vmDiv10) { | |
| 274 | break; | |
| 275 | } | |
| 276 | const uint32_t __vmMod10 = static_cast<uint32_t>(__vm) - 10 * static_cast<uint32_t>(__vmDiv10); | |
| 277 | const uint64_t __vrDiv10 = __div10(__vr); | |
| 278 | const uint32_t __vrMod10 = static_cast<uint32_t>(__vr) - 10 * static_cast<uint32_t>(__vrDiv10); | |
| 279 | __vmIsTrailingZeros &= __vmMod10 == 0; | |
| 280 | __vrIsTrailingZeros &= __lastRemovedDigit == 0; | |
| 281 | __lastRemovedDigit = static_cast<uint8_t>(__vrMod10); | |
| 282 | __vr = __vrDiv10; | |
| 283 | __vp = __vpDiv10; | |
| 284 | __vm = __vmDiv10; | |
| 285 | ++__removed; | |
| 286 | } | |
| 287 | if (__vmIsTrailingZeros) { | |
| 288 | for (;;) { | |
| 289 | const uint64_t __vmDiv10 = __div10(__vm); | |
| 290 | const uint32_t __vmMod10 = static_cast<uint32_t>(__vm) - 10 * static_cast<uint32_t>(__vmDiv10); | |
| 291 | if (__vmMod10 != 0) { | |
| 292 | break; | |
| 293 | } | |
| 294 | const uint64_t __vpDiv10 = __div10(__vp); | |
| 295 | const uint64_t __vrDiv10 = __div10(__vr); | |
| 296 | const uint32_t __vrMod10 = static_cast<uint32_t>(__vr) - 10 * static_cast<uint32_t>(__vrDiv10); | |
| 297 | __vrIsTrailingZeros &= __lastRemovedDigit == 0; | |
| 298 | __lastRemovedDigit = static_cast<uint8_t>(__vrMod10); | |
| 299 | __vr = __vrDiv10; | |
| 300 | __vp = __vpDiv10; | |
| 301 | __vm = __vmDiv10; | |
| 302 | ++__removed; | |
| 303 | } | |
| 304 | } | |
| 305 | if (__vrIsTrailingZeros && __lastRemovedDigit == 5 && __vr % 2 == 0) { | |
| 306 | // Round even if the exact number is .....50..0. | |
| 307 | __lastRemovedDigit = 4; | |
| 308 | } | |
| 309 | // We need to take __vr + 1 if __vr is outside bounds or we need to round up. | |
| 310 | _Output = __vr + ((__vr == __vm && (!__acceptBounds || !__vmIsTrailingZeros)) || __lastRemovedDigit >= 5); | |
| 311 | } else { | |
| 312 | // Specialized for the common case (~99.3%). Percentages below are relative to this. | |
| 313 | bool __roundUp = false; | |
| 314 | const uint64_t __vpDiv100 = __div100(__vp); | |
| 315 | const uint64_t __vmDiv100 = __div100(__vm); | |
| 316 | if (__vpDiv100 > __vmDiv100) { // Optimization: remove two digits at a time (~86.2%). | |
| 317 | const uint64_t __vrDiv100 = __div100(__vr); | |
| 318 | const uint32_t __vrMod100 = static_cast<uint32_t>(__vr) - 100 * static_cast<uint32_t>(__vrDiv100); | |
| 319 | __roundUp = __vrMod100 >= 50; | |
| 320 | __vr = __vrDiv100; | |
| 321 | __vp = __vpDiv100; | |
| 322 | __vm = __vmDiv100; | |
| 323 | __removed += 2; | |
| 324 | } | |
| 325 | // Loop iterations below (approximately), without optimization above: | |
| 326 | // 0: 0.03%, 1: 13.8%, 2: 70.6%, 3: 14.0%, 4: 1.40%, 5: 0.14%, 6+: 0.02% | |
| 327 | // Loop iterations below (approximately), with optimization above: | |
| 328 | // 0: 70.6%, 1: 27.8%, 2: 1.40%, 3: 0.14%, 4+: 0.02% | |
| 329 | for (;;) { | |
| 330 | const uint64_t __vpDiv10 = __div10(__vp); | |
| 331 | const uint64_t __vmDiv10 = __div10(__vm); | |
| 332 | if (__vpDiv10 <= __vmDiv10) { | |
| 333 | break; | |
| 334 | } | |
| 335 | const uint64_t __vrDiv10 = __div10(__vr); | |
| 336 | const uint32_t __vrMod10 = static_cast<uint32_t>(__vr) - 10 * static_cast<uint32_t>(__vrDiv10); | |
| 337 | __roundUp = __vrMod10 >= 5; | |
| 338 | __vr = __vrDiv10; | |
| 339 | __vp = __vpDiv10; | |
| 340 | __vm = __vmDiv10; | |
| 341 | ++__removed; | |
| 342 | } | |
| 343 | // We need to take __vr + 1 if __vr is outside bounds or we need to round up. | |
| 344 | _Output = __vr + (__vr == __vm || __roundUp); | |
| 345 | } | |
| 346 | const int32_t __exp = __e10 + __removed; | |
| 347 | ||
| 348 | __floating_decimal_64 __fd; | |
| 349 | __fd.__exponent = __exp; | |
| 350 | __fd.__mantissa = _Output; | |
| 351 | return __fd; | |
| 352 | } | |
| 353 | ||
| 354 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline to_chars_result __to_chars(char* const _First, char* const _Last, const __floating_decimal_64 __v, | |
| 355 | chars_format _Fmt, const double __f) { | |
| 356 | // Step 5: Print the decimal representation. | |
| 357 | uint64_t _Output = __v.__mantissa; | |
| 358 | int32_t _Ryu_exponent = __v.__exponent; | |
| 359 | const uint32_t __olength = __decimalLength17(_Output); | |
| 360 | int32_t _Scientific_exponent = _Ryu_exponent + static_cast<int32_t>(__olength) - 1; | |
| 361 | ||
| 362 | if (_Fmt == chars_format{}) { | |
| 363 | int32_t _Lower; | |
| 364 | int32_t _Upper; | |
| 365 | ||
| 366 | if (__olength == 1) { | |
| 367 | // Value | Fixed | Scientific | |
| 368 | // 1e-3 | "0.001" | "1e-03" | |
| 369 | // 1e4 | "10000" | "1e+04" | |
| 370 | _Lower = -3; | |
| 371 | _Upper = 4; | |
| 372 | } else { | |
| 373 | // Value | Fixed | Scientific | |
| 374 | // 1234e-7 | "0.0001234" | "1.234e-04" | |
| 375 | // 1234e5 | "123400000" | "1.234e+08" | |
| 376 | _Lower = -static_cast<int32_t>(__olength + 3); | |
| 377 | _Upper = 5; | |
| 378 | } | |
| 379 | ||
| 380 | if (_Lower <= _Ryu_exponent && _Ryu_exponent <= _Upper) { | |
| 381 | _Fmt = chars_format::fixed; | |
| 382 | } else { | |
| 383 | _Fmt = chars_format::scientific; | |
| 384 | } | |
| 385 | } else if (_Fmt == chars_format::general) { | |
| 386 | // C11 7.21.6.1 "The fprintf function"/8: | |
| 387 | // "Let P equal [...] 6 if the precision is omitted [...]. | |
| 388 | // Then, if a conversion with style E would have an exponent of X: | |
| 389 | // - if P > X >= -4, the conversion is with style f [...]. | |
| 390 | // - otherwise, the conversion is with style e [...]." | |
| 391 | if (-4 <= _Scientific_exponent && _Scientific_exponent < 6) { | |
| 392 | _Fmt = chars_format::fixed; | |
| 393 | } else { | |
| 394 | _Fmt = chars_format::scientific; | |
| 395 | } | |
| 396 | } | |
| 397 | ||
| 398 | if (_Fmt == chars_format::fixed) { | |
| 399 | // Example: _Output == 1729, __olength == 4 | |
| 400 | ||
| 401 | // _Ryu_exponent | Printed | _Whole_digits | _Total_fixed_length | Notes | |
| 402 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 403 | // 2 | 172900 | 6 | _Whole_digits | Ryu can't be used for printing | |
| 404 | // 1 | 17290 | 5 | (sometimes adjusted) | when the trimmed digits are nonzero. | |
| 405 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 406 | // 0 | 1729 | 4 | _Whole_digits | Unified length cases. | |
| 407 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 408 | // -1 | 172.9 | 3 | __olength + 1 | This case can't happen for | |
| 409 | // -2 | 17.29 | 2 | | __olength == 1, but no additional | |
| 410 | // -3 | 1.729 | 1 | | code is needed to avoid it. | |
| 411 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 412 | // -4 | 0.1729 | 0 | 2 - _Ryu_exponent | C11 7.21.6.1 "The fprintf function"/8: | |
| 413 | // -5 | 0.01729 | -1 | | "If a decimal-point character appears, | |
| 414 | // -6 | 0.001729 | -2 | | at least one digit appears before it." | |
| 415 | ||
| 416 | const int32_t _Whole_digits = static_cast<int32_t>(__olength) + _Ryu_exponent; | |
| 417 | ||
| 418 | uint32_t _Total_fixed_length; | |
| 419 | if (_Ryu_exponent >= 0) { // cases "172900" and "1729" | |
| 420 | _Total_fixed_length = static_cast<uint32_t>(_Whole_digits); | |
| 421 | if (_Output == 1) { | |
| 422 | // Rounding can affect the number of digits. | |
| 423 | // For example, 1e23 is exactly "99999999999999991611392" which is 23 digits instead of 24. | |
| 424 | // We can use a lookup table to detect this and adjust the total length. | |
| 425 | static constexpr uint8_t _Adjustment[309] = { | |
| 426 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,1,0,1,0,1,1,1,0,1,1,1,0,0,0,0,0, | |
| 427 | 1,1,0,0,1,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,1,0,1,0,1,1,0,0,0,0,1,1,1, | |
| 428 | 1,0,0,0,0,0,0,0,1,1,0,1,1,0,0,1,0,1,0,1,0,1,1,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,0,1,0,1,1,0,1, | |
| 429 | 1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,1,1,0,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,0,1, | |
| 430 | 0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1,0,1,1,1,0,0,0,1,0,1,1,1,1,1,1,0,1,0,1,1,0,0,0,1, | |
| 431 | 1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,0,0,1,0,1,1,0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,0,1,1,0, | |
| 432 | 0,1,0,1,1,1,0,0,1,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,1,0 }; | |
| 433 | _Total_fixed_length -= _Adjustment[_Ryu_exponent]; | |
| 434 | // _Whole_digits doesn't need to be adjusted because these cases won't refer to it later. | |
| 435 | } | |
| 436 | } else if (_Whole_digits > 0) { // case "17.29" | |
| 437 | _Total_fixed_length = __olength + 1; | |
| 438 | } else { // case "0.001729" | |
| 439 | _Total_fixed_length = static_cast<uint32_t>(2 - _Ryu_exponent); | |
| 440 | } | |
| 441 | ||
| 442 | if (_Last - _First < static_cast<ptrdiff_t>(_Total_fixed_length)) { | |
| 443 | return { _Last, errc::value_too_large }; | |
| 444 | } | |
| 445 | ||
| 446 | char* _Mid; | |
| 447 | if (_Ryu_exponent > 0) { // case "172900" | |
| 448 | bool _Can_use_ryu; | |
| 449 | ||
| 450 | if (_Ryu_exponent > 22) { // 10^22 is the largest power of 10 that's exactly representable as a double. | |
| 451 | _Can_use_ryu = false; | |
| 452 | } else { | |
| 453 | // Ryu generated X: __v.__mantissa * 10^_Ryu_exponent | |
| 454 | // __v.__mantissa == 2^_Trailing_zero_bits * (__v.__mantissa >> _Trailing_zero_bits) | |
| 455 | // 10^_Ryu_exponent == 2^_Ryu_exponent * 5^_Ryu_exponent | |
| 456 | ||
| 457 | // _Trailing_zero_bits is [0, 56] (aside: because 2^56 is the largest power of 2 | |
| 458 | // with 17 decimal digits, which is double's round-trip limit.) | |
| 459 | // _Ryu_exponent is [1, 22]. | |
| 460 | // Normalization adds [2, 52] (aside: at least 2 because the pre-normalized mantissa is at least 5). | |
| 461 | // This adds up to [3, 130], which is well below double's maximum binary exponent 1023. | |
| 462 | ||
| 463 | // Therefore, we just need to consider (__v.__mantissa >> _Trailing_zero_bits) * 5^_Ryu_exponent. | |
| 464 | ||
| 465 | // If that product would exceed 53 bits, then X can't be exactly represented as a double. | |
| 466 | // (That's not a problem for round-tripping, because X is close enough to the original double, | |
| 467 | // but X isn't mathematically equal to the original double.) This requires a high-precision fallback. | |
| 468 | ||
| 469 | // If the product is 53 bits or smaller, then X can be exactly represented as a double (and we don't | |
| 470 | // need to re-synthesize it; the original double must have been X, because Ryu wouldn't produce the | |
| 471 | // same output for two different doubles X and Y). This allows Ryu's output to be used (zero-filled). | |
| 472 | ||
| 473 | // (2^53 - 1) / 5^0 (for indexing), (2^53 - 1) / 5^1, ..., (2^53 - 1) / 5^22 | |
| 474 | static constexpr uint64_t _Max_shifted_mantissa[23] = { | |
| 475 | 9007199254740991u, 1801439850948198u, 360287970189639u, 72057594037927u, 14411518807585u, | |
| 476 | 2882303761517u, 576460752303u, 115292150460u, 23058430092u, 4611686018u, 922337203u, 184467440u, | |
| 477 | 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u }; | |
| 478 | ||
| 479 | unsigned long _Trailing_zero_bits; | |
| 480 | #ifdef _LIBCPP_HAS_BITSCAN64 | |
| 481 | (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero | |
| 482 | #else // ^^^ 64-bit ^^^ / vvv 32-bit vvv | |
| 483 | const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa); | |
| 484 | if (_Low_mantissa != 0) { | |
| 485 | (void) _BitScanForward(&_Trailing_zero_bits, _Low_mantissa); | |
| 486 | } else { | |
| 487 | const uint32_t _High_mantissa = static_cast<uint32_t>(__v.__mantissa >> 32); // nonzero here | |
| 488 | (void) _BitScanForward(&_Trailing_zero_bits, _High_mantissa); | |
| 489 | _Trailing_zero_bits += 32; | |
| 490 | } | |
| 491 | #endif // ^^^ 32-bit ^^^ | |
| 492 | const uint64_t _Shifted_mantissa = __v.__mantissa >> _Trailing_zero_bits; | |
| 493 | _Can_use_ryu = _Shifted_mantissa <= _Max_shifted_mantissa[_Ryu_exponent]; | |
| 494 | } | |
| 495 | ||
| 496 | if (!_Can_use_ryu) { | |
| 497 | // Print the integer exactly. | |
| 498 | // Performance note: This will redundantly perform bounds checking. | |
| 499 | // Performance note: This will redundantly decompose the IEEE representation. | |
| 500 | return __d2fixed_buffered_n(_First, _Last, __f, 0); | |
| 501 | } | |
| 502 | ||
| 503 | // _Can_use_ryu | |
| 504 | // Print the decimal digits, left-aligned within [_First, _First + _Total_fixed_length). | |
| 505 | _Mid = _First + __olength; | |
| 506 | } else { // cases "1729", "17.29", and "0.001729" | |
| 507 | // Print the decimal digits, right-aligned within [_First, _First + _Total_fixed_length). | |
| 508 | _Mid = _First + _Total_fixed_length; | |
| 509 | } | |
| 510 | ||
| 511 | // We prefer 32-bit operations, even on 64-bit platforms. | |
| 512 | // We have at most 17 digits, and uint32_t can store 9 digits. | |
| 513 | // If _Output doesn't fit into uint32_t, we cut off 8 digits, | |
| 514 | // so the rest will fit into uint32_t. | |
| 515 | if ((_Output >> 32) != 0) { | |
| 516 | // Expensive 64-bit division. | |
| 517 | const uint64_t __q = __div1e8(_Output); | |
| 518 | uint32_t __output2 = static_cast<uint32_t>(_Output - 100000000 * __q); | |
| 519 | _Output = __q; | |
| 520 | ||
| 521 | const uint32_t __c = __output2 % 10000; | |
| 522 | __output2 /= 10000; | |
| 523 | const uint32_t __d = __output2 % 10000; | |
| 524 | const uint32_t __c0 = (__c % 100) << 1; | |
| 525 | const uint32_t __c1 = (__c / 100) << 1; | |
| 526 | const uint32_t __d0 = (__d % 100) << 1; | |
| 527 | const uint32_t __d1 = (__d / 100) << 1; | |
| 528 | ||
| 529 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c0, 2); | |
| 530 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c1, 2); | |
| 531 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __d0, 2); | |
| 532 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __d1, 2); | |
| 533 | } | |
| 534 | uint32_t __output2 = static_cast<uint32_t>(_Output); | |
| 535 | while (__output2 >= 10000) { | |
| 536 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 537 | const uint32_t __c = __output2 - 10000 * (__output2 / 10000); | |
| 538 | #else | |
| 539 | const uint32_t __c = __output2 % 10000; | |
| 540 | #endif | |
| 541 | __output2 /= 10000; | |
| 542 | const uint32_t __c0 = (__c % 100) << 1; | |
| 543 | const uint32_t __c1 = (__c / 100) << 1; | |
| 544 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c0, 2); | |
| 545 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c1, 2); | |
| 546 | } | |
| 547 | if (__output2 >= 100) { | |
| 548 | const uint32_t __c = (__output2 % 100) << 1; | |
| 549 | __output2 /= 100; | |
| 550 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2); | |
| 551 | } | |
| 552 | if (__output2 >= 10) { | |
| 553 | const uint32_t __c = __output2 << 1; | |
| 554 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2); | |
| 555 | } else { | |
| 556 | *--_Mid = static_cast<char>('0' + __output2); | |
| 557 | } | |
| 558 | ||
| 559 | if (_Ryu_exponent > 0) { // case "172900" with _Can_use_ryu | |
| 560 | // Performance note: it might be more efficient to do this immediately after setting _Mid. | |
| 561 | _VSTD::memset(_First + __olength, '0', static_cast<size_t>(_Ryu_exponent)); | |
| 562 | } else if (_Ryu_exponent == 0) { // case "1729" | |
| 563 | // Done! | |
| 564 | } else if (_Whole_digits > 0) { // case "17.29" | |
| 565 | // Performance note: moving digits might not be optimal. | |
| 566 | _VSTD::memmove(_First, _First + 1, static_cast<size_t>(_Whole_digits)); | |
| 567 | _First[_Whole_digits] = '.'; | |
| 568 | } else { // case "0.001729" | |
| 569 | // Performance note: a larger memset() followed by overwriting '.' might be more efficient. | |
| 570 | _First[0] = '0'; | |
| 571 | _First[1] = '.'; | |
| 572 | _VSTD::memset(_First + 2, '0', static_cast<size_t>(-_Whole_digits)); | |
| 573 | } | |
| 574 | ||
| 575 | return { _First + _Total_fixed_length, errc{} }; | |
| 576 | } | |
| 577 | ||
| 578 | const uint32_t _Total_scientific_length = __olength + (__olength > 1) // digits + possible decimal point | |
| 579 | + (-100 < _Scientific_exponent && _Scientific_exponent < 100 ? 4 : 5); // + scientific exponent | |
| 580 | if (_Last - _First < static_cast<ptrdiff_t>(_Total_scientific_length)) { | |
| 581 | return { _Last, errc::value_too_large }; | |
| 582 | } | |
| 583 | char* const __result = _First; | |
| 584 | ||
| 585 | // Print the decimal digits. | |
| 586 | uint32_t __i = 0; | |
| 587 | // We prefer 32-bit operations, even on 64-bit platforms. | |
| 588 | // We have at most 17 digits, and uint32_t can store 9 digits. | |
| 589 | // If _Output doesn't fit into uint32_t, we cut off 8 digits, | |
| 590 | // so the rest will fit into uint32_t. | |
| 591 | if ((_Output >> 32) != 0) { | |
| 592 | // Expensive 64-bit division. | |
| 593 | const uint64_t __q = __div1e8(_Output); | |
| 594 | uint32_t __output2 = static_cast<uint32_t>(_Output) - 100000000 * static_cast<uint32_t>(__q); | |
| 595 | _Output = __q; | |
| 596 | ||
| 597 | const uint32_t __c = __output2 % 10000; | |
| 598 | __output2 /= 10000; | |
| 599 | const uint32_t __d = __output2 % 10000; | |
| 600 | const uint32_t __c0 = (__c % 100) << 1; | |
| 601 | const uint32_t __c1 = (__c / 100) << 1; | |
| 602 | const uint32_t __d0 = (__d % 100) << 1; | |
| 603 | const uint32_t __d1 = (__d / 100) << 1; | |
| 604 | _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c0, 2); | |
| 605 | _VSTD::memcpy(__result + __olength - __i - 3, __DIGIT_TABLE + __c1, 2); | |
| 606 | _VSTD::memcpy(__result + __olength - __i - 5, __DIGIT_TABLE + __d0, 2); | |
| 607 | _VSTD::memcpy(__result + __olength - __i - 7, __DIGIT_TABLE + __d1, 2); | |
| 608 | __i += 8; | |
| 609 | } | |
| 610 | uint32_t __output2 = static_cast<uint32_t>(_Output); | |
| 611 | while (__output2 >= 10000) { | |
| 612 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 613 | const uint32_t __c = __output2 - 10000 * (__output2 / 10000); | |
| 614 | #else | |
| 615 | const uint32_t __c = __output2 % 10000; | |
| 616 | #endif | |
| 617 | __output2 /= 10000; | |
| 618 | const uint32_t __c0 = (__c % 100) << 1; | |
| 619 | const uint32_t __c1 = (__c / 100) << 1; | |
| 620 | _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c0, 2); | |
| 621 | _VSTD::memcpy(__result + __olength - __i - 3, __DIGIT_TABLE + __c1, 2); | |
| 622 | __i += 4; | |
| 623 | } | |
| 624 | if (__output2 >= 100) { | |
| 625 | const uint32_t __c = (__output2 % 100) << 1; | |
| 626 | __output2 /= 100; | |
| 627 | _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c, 2); | |
| 628 | __i += 2; | |
| 629 | } | |
| 630 | if (__output2 >= 10) { | |
| 631 | const uint32_t __c = __output2 << 1; | |
| 632 | // We can't use memcpy here: the decimal dot goes between these two digits. | |
| 633 | __result[2] = __DIGIT_TABLE[__c + 1]; | |
| 634 | __result[0] = __DIGIT_TABLE[__c]; | |
| 635 | } else { | |
| 636 | __result[0] = static_cast<char>('0' + __output2); | |
| 637 | } | |
| 638 | ||
| 639 | // Print decimal point if needed. | |
| 640 | uint32_t __index; | |
| 641 | if (__olength > 1) { | |
| 642 | __result[1] = '.'; | |
| 643 | __index = __olength + 1; | |
| 644 | } else { | |
| 645 | __index = 1; | |
| 646 | } | |
| 647 | ||
| 648 | // Print the exponent. | |
| 649 | __result[__index++] = 'e'; | |
| 650 | if (_Scientific_exponent < 0) { | |
| 651 | __result[__index++] = '-'; | |
| 652 | _Scientific_exponent = -_Scientific_exponent; | |
| 653 | } else { | |
| 654 | __result[__index++] = '+'; | |
| 655 | } | |
| 656 | ||
| 657 | if (_Scientific_exponent >= 100) { | |
| 658 | const int32_t __c = _Scientific_exponent % 10; | |
| 659 | _VSTD::memcpy(__result + __index, __DIGIT_TABLE + 2 * (_Scientific_exponent / 10), 2); | |
| 660 | __result[__index + 2] = static_cast<char>('0' + __c); | |
| 661 | __index += 3; | |
| 662 | } else { | |
| 663 | _VSTD::memcpy(__result + __index, __DIGIT_TABLE + 2 * _Scientific_exponent, 2); | |
| 664 | __index += 2; | |
| 665 | } | |
| 666 | ||
| 667 | return { _First + _Total_scientific_length, errc{} }; | |
| 668 | } | |
| 669 | ||
| 670 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __d2d_small_int(const uint64_t __ieeeMantissa, const uint32_t __ieeeExponent, | |
| 671 | __floating_decimal_64* const __v) { | |
| 672 | const uint64_t __m2 = (1ull << __DOUBLE_MANTISSA_BITS) | __ieeeMantissa; | |
| 673 | const int32_t __e2 = static_cast<int32_t>(__ieeeExponent) - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; | |
| 674 | ||
| 675 | if (__e2 > 0) { | |
| 676 | // f = __m2 * 2^__e2 >= 2^53 is an integer. | |
| 677 | // Ignore this case for now. | |
| 678 | return false; | |
| 679 | } | |
| 680 | ||
| 681 | if (__e2 < -52) { | |
| 682 | // f < 1. | |
| 683 | return false; | |
| 684 | } | |
| 685 | ||
| 686 | // Since 2^52 <= __m2 < 2^53 and 0 <= -__e2 <= 52: 1 <= f = __m2 / 2^-__e2 < 2^53. | |
| 687 | // Test if the lower -__e2 bits of the significand are 0, i.e. whether the fraction is 0. | |
| 688 | const uint64_t __mask = (1ull << -__e2) - 1; | |
| 689 | const uint64_t __fraction = __m2 & __mask; | |
| 690 | if (__fraction != 0) { | |
| 691 | return false; | |
| 692 | } | |
| 693 | ||
| 694 | // f is an integer in the range [1, 2^53). | |
| 695 | // Note: __mantissa might contain trailing (decimal) 0's. | |
| 696 | // Note: since 2^53 < 10^16, there is no need to adjust __decimalLength17(). | |
| 697 | __v->__mantissa = __m2 >> -__e2; | |
| 698 | __v->__exponent = 0; | |
| 699 | return true; | |
| 700 | } | |
| 701 | ||
| 702 | [[nodiscard]] to_chars_result __d2s_buffered_n(char* const _First, char* const _Last, const double __f, | |
| 703 | const chars_format _Fmt) { | |
| 704 | ||
| 705 | // Step 1: Decode the floating-point number, and unify normalized and subnormal cases. | |
| 706 | const uint64_t __bits = __double_to_bits(__f); | |
| 707 | ||
| 708 | // Case distinction; exit early for the easy cases. | |
| 709 | if (__bits == 0) { | |
| 710 | if (_Fmt == chars_format::scientific) { | |
| 711 | if (_Last - _First < 5) { | |
| 712 | return { _Last, errc::value_too_large }; | |
| 713 | } | |
| 714 | ||
| 715 | _VSTD::memcpy(_First, "0e+00", 5); | |
| 716 | ||
| 717 | return { _First + 5, errc{} }; | |
| 718 | } | |
| 719 | ||
| 720 | // Print "0" for chars_format::fixed, chars_format::general, and chars_format{}. | |
| 721 | if (_First == _Last) { | |
| 722 | return { _Last, errc::value_too_large }; | |
| 723 | } | |
| 724 | ||
| 725 | *_First = '0'; | |
| 726 | ||
| 727 | return { _First + 1, errc{} }; | |
| 728 | } | |
| 729 | ||
| 730 | // Decode __bits into mantissa and exponent. | |
| 731 | const uint64_t __ieeeMantissa = __bits & ((1ull << __DOUBLE_MANTISSA_BITS) - 1); | |
| 732 | const uint32_t __ieeeExponent = static_cast<uint32_t>(__bits >> __DOUBLE_MANTISSA_BITS); | |
| 733 | ||
| 734 | if (_Fmt == chars_format::fixed) { | |
| 735 | // const uint64_t _Mantissa2 = __ieeeMantissa | (1ull << __DOUBLE_MANTISSA_BITS); // restore implicit bit | |
| 736 | const int32_t _Exponent2 = static_cast<int32_t>(__ieeeExponent) | |
| 737 | - __DOUBLE_BIAS - __DOUBLE_MANTISSA_BITS; // bias and normalization | |
| 738 | ||
| 739 | // Normal values are equal to _Mantissa2 * 2^_Exponent2. | |
| 740 | // (Subnormals are different, but they'll be rejected by the _Exponent2 test here, so they can be ignored.) | |
| 741 | ||
| 742 | // For nonzero integers, _Exponent2 >= -52. (The minimum value occurs when _Mantissa2 * 2^_Exponent2 is 1. | |
| 743 | // In that case, _Mantissa2 is the implicit 1 bit followed by 52 zeros, so _Exponent2 is -52 to shift away | |
| 744 | // the zeros.) The dense range of exactly representable integers has negative or zero exponents | |
| 745 | // (as positive exponents make the range non-dense). For that dense range, Ryu will always be used: | |
| 746 | // every digit is necessary to uniquely identify the value, so Ryu must print them all. | |
| 747 | ||
| 748 | // Positive exponents are the non-dense range of exactly representable integers. This contains all of the values | |
| 749 | // for which Ryu can't be used (and a few Ryu-friendly values). We can save time by detecting positive | |
| 750 | // exponents here and skipping Ryu. Calling __d2fixed_buffered_n() with precision 0 is valid for all integers | |
| 751 | // (so it's okay if we call it with a Ryu-friendly value). | |
| 752 | if (_Exponent2 > 0) { | |
| 753 | return __d2fixed_buffered_n(_First, _Last, __f, 0); | |
| 754 | } | |
| 755 | } | |
| 756 | ||
| 757 | __floating_decimal_64 __v; | |
| 758 | const bool __isSmallInt = __d2d_small_int(__ieeeMantissa, __ieeeExponent, &__v); | |
| 759 | if (__isSmallInt) { | |
| 760 | // For small integers in the range [1, 2^53), __v.__mantissa might contain trailing (decimal) zeros. | |
| 761 | // For scientific notation we need to move these zeros into the exponent. | |
| 762 | // (This is not needed for fixed-point notation, so it might be beneficial to trim | |
| 763 | // trailing zeros in __to_chars only if needed - once fixed-point notation output is implemented.) | |
| 764 | for (;;) { | |
| 765 | const uint64_t __q = __div10(__v.__mantissa); | |
| 766 | const uint32_t __r = static_cast<uint32_t>(__v.__mantissa) - 10 * static_cast<uint32_t>(__q); | |
| 767 | if (__r != 0) { | |
| 768 | break; | |
| 769 | } | |
| 770 | __v.__mantissa = __q; | |
| 771 | ++__v.__exponent; | |
| 772 | } | |
| 773 | } else { | |
| 774 | __v = __d2d(__ieeeMantissa, __ieeeExponent); | |
| 775 | } | |
| 776 | ||
| 777 | return __to_chars(_First, _Last, __v, _Fmt, __f); | |
| 778 | } | |
| 779 | ||
| 780 | _LIBCPP_END_NAMESPACE_STD | |
| 781 | ||
| 782 | // clang-format on |
lib/libcxx/src/ryu/f2s.cpp created+715| ... | ... | @@ -0,0 +1,715 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | // Copyright (c) Microsoft Corporation. | |
| 10 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 11 | ||
| 12 | // Copyright 2018 Ulf Adams | |
| 13 | // Copyright (c) Microsoft Corporation. All rights reserved. | |
| 14 | ||
| 15 | // Boost Software License - Version 1.0 - August 17th, 2003 | |
| 16 | ||
| 17 | // Permission is hereby granted, free of charge, to any person or organization | |
| 18 | // obtaining a copy of the software and accompanying documentation covered by | |
| 19 | // this license (the "Software") to use, reproduce, display, distribute, | |
| 20 | // execute, and transmit the Software, and to prepare derivative works of the | |
| 21 | // Software, and to permit third-parties to whom the Software is furnished to | |
| 22 | // do so, all subject to the following: | |
| 23 | ||
| 24 | // The copyright notices in the Software and this entire statement, including | |
| 25 | // the above license grant, this restriction and the following disclaimer, | |
| 26 | // must be included in all copies of the Software, in whole or in part, and | |
| 27 | // all derivative works of the Software, unless such copies or derivative | |
| 28 | // works are solely in the form of machine-executable object code generated by | |
| 29 | // a source language processor. | |
| 30 | ||
| 31 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| 32 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| 33 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT | |
| 34 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE | |
| 35 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, | |
| 36 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
| 37 | // DEALINGS IN THE SOFTWARE. | |
| 38 | ||
| 39 | // Avoid formatting to keep the changes with the original code minimal. | |
| 40 | // clang-format off | |
| 41 | ||
| 42 | #include "__config" | |
| 43 | #include "charconv" | |
| 44 | ||
| 45 | #include "include/ryu/common.h" | |
| 46 | #include "include/ryu/d2fixed.h" | |
| 47 | #include "include/ryu/d2s_intrinsics.h" | |
| 48 | #include "include/ryu/digit_table.h" | |
| 49 | #include "include/ryu/f2s.h" | |
| 50 | #include "include/ryu/ryu.h" | |
| 51 | ||
| 52 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 53 | ||
| 54 | inline constexpr int __FLOAT_MANTISSA_BITS = 23; | |
| 55 | inline constexpr int __FLOAT_EXPONENT_BITS = 8; | |
| 56 | inline constexpr int __FLOAT_BIAS = 127; | |
| 57 | ||
| 58 | inline constexpr int __FLOAT_POW5_INV_BITCOUNT = 59; | |
| 59 | inline constexpr uint64_t __FLOAT_POW5_INV_SPLIT[31] = { | |
| 60 | 576460752303423489u, 461168601842738791u, 368934881474191033u, 295147905179352826u, | |
| 61 | 472236648286964522u, 377789318629571618u, 302231454903657294u, 483570327845851670u, | |
| 62 | 386856262276681336u, 309485009821345069u, 495176015714152110u, 396140812571321688u, | |
| 63 | 316912650057057351u, 507060240091291761u, 405648192073033409u, 324518553658426727u, | |
| 64 | 519229685853482763u, 415383748682786211u, 332306998946228969u, 531691198313966350u, | |
| 65 | 425352958651173080u, 340282366920938464u, 544451787073501542u, 435561429658801234u, | |
| 66 | 348449143727040987u, 557518629963265579u, 446014903970612463u, 356811923176489971u, | |
| 67 | 570899077082383953u, 456719261665907162u, 365375409332725730u | |
| 68 | }; | |
| 69 | inline constexpr int __FLOAT_POW5_BITCOUNT = 61; | |
| 70 | inline constexpr uint64_t __FLOAT_POW5_SPLIT[47] = { | |
| 71 | 1152921504606846976u, 1441151880758558720u, 1801439850948198400u, 2251799813685248000u, | |
| 72 | 1407374883553280000u, 1759218604441600000u, 2199023255552000000u, 1374389534720000000u, | |
| 73 | 1717986918400000000u, 2147483648000000000u, 1342177280000000000u, 1677721600000000000u, | |
| 74 | 2097152000000000000u, 1310720000000000000u, 1638400000000000000u, 2048000000000000000u, | |
| 75 | 1280000000000000000u, 1600000000000000000u, 2000000000000000000u, 1250000000000000000u, | |
| 76 | 1562500000000000000u, 1953125000000000000u, 1220703125000000000u, 1525878906250000000u, | |
| 77 | 1907348632812500000u, 1192092895507812500u, 1490116119384765625u, 1862645149230957031u, | |
| 78 | 1164153218269348144u, 1455191522836685180u, 1818989403545856475u, 2273736754432320594u, | |
| 79 | 1421085471520200371u, 1776356839400250464u, 2220446049250313080u, 1387778780781445675u, | |
| 80 | 1734723475976807094u, 2168404344971008868u, 1355252715606880542u, 1694065894508600678u, | |
| 81 | 2117582368135750847u, 1323488980084844279u, 1654361225106055349u, 2067951531382569187u, | |
| 82 | 1292469707114105741u, 1615587133892632177u, 2019483917365790221u | |
| 83 | }; | |
| 84 | ||
| 85 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __pow5Factor(uint32_t __value) { | |
| 86 | uint32_t __count = 0; | |
| 87 | for (;;) { | |
| 88 | _LIBCPP_ASSERT(__value != 0, ""); | |
| 89 | const uint32_t __q = __value / 5; | |
| 90 | const uint32_t __r = __value % 5; | |
| 91 | if (__r != 0) { | |
| 92 | break; | |
| 93 | } | |
| 94 | __value = __q; | |
| 95 | ++__count; | |
| 96 | } | |
| 97 | return __count; | |
| 98 | } | |
| 99 | ||
| 100 | // Returns true if __value is divisible by 5^__p. | |
| 101 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf5(const uint32_t __value, const uint32_t __p) { | |
| 102 | return __pow5Factor(__value) >= __p; | |
| 103 | } | |
| 104 | ||
| 105 | // Returns true if __value is divisible by 2^__p. | |
| 106 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline bool __multipleOfPowerOf2(const uint32_t __value, const uint32_t __p) { | |
| 107 | _LIBCPP_ASSERT(__value != 0, ""); | |
| 108 | _LIBCPP_ASSERT(__p < 32, ""); | |
| 109 | // __builtin_ctz doesn't appear to be faster here. | |
| 110 | return (__value & ((1u << __p) - 1)) == 0; | |
| 111 | } | |
| 112 | ||
| 113 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulShift(const uint32_t __m, const uint64_t __factor, const int32_t __shift) { | |
| 114 | _LIBCPP_ASSERT(__shift > 32, ""); | |
| 115 | ||
| 116 | // The casts here help MSVC to avoid calls to the __allmul library | |
| 117 | // function. | |
| 118 | const uint32_t __factorLo = static_cast<uint32_t>(__factor); | |
| 119 | const uint32_t __factorHi = static_cast<uint32_t>(__factor >> 32); | |
| 120 | const uint64_t __bits0 = static_cast<uint64_t>(__m) * __factorLo; | |
| 121 | const uint64_t __bits1 = static_cast<uint64_t>(__m) * __factorHi; | |
| 122 | ||
| 123 | #ifndef _LIBCPP_64_BIT | |
| 124 | // On 32-bit platforms we can avoid a 64-bit shift-right since we only | |
| 125 | // need the upper 32 bits of the result and the shift value is > 32. | |
| 126 | const uint32_t __bits0Hi = static_cast<uint32_t>(__bits0 >> 32); | |
| 127 | uint32_t __bits1Lo = static_cast<uint32_t>(__bits1); | |
| 128 | uint32_t __bits1Hi = static_cast<uint32_t>(__bits1 >> 32); | |
| 129 | __bits1Lo += __bits0Hi; | |
| 130 | __bits1Hi += (__bits1Lo < __bits0Hi); | |
| 131 | const int32_t __s = __shift - 32; | |
| 132 | return (__bits1Hi << (32 - __s)) | (__bits1Lo >> __s); | |
| 133 | #else // ^^^ 32-bit ^^^ / vvv 64-bit vvv | |
| 134 | const uint64_t __sum = (__bits0 >> 32) + __bits1; | |
| 135 | const uint64_t __shiftedSum = __sum >> (__shift - 32); | |
| 136 | _LIBCPP_ASSERT(__shiftedSum <= UINT32_MAX, ""); | |
| 137 | return static_cast<uint32_t>(__shiftedSum); | |
| 138 | #endif // ^^^ 64-bit ^^^ | |
| 139 | } | |
| 140 | ||
| 141 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulPow5InvDivPow2(const uint32_t __m, const uint32_t __q, const int32_t __j) { | |
| 142 | return __mulShift(__m, __FLOAT_POW5_INV_SPLIT[__q], __j); | |
| 143 | } | |
| 144 | ||
| 145 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline uint32_t __mulPow5divPow2(const uint32_t __m, const uint32_t __i, const int32_t __j) { | |
| 146 | return __mulShift(__m, __FLOAT_POW5_SPLIT[__i], __j); | |
| 147 | } | |
| 148 | ||
| 149 | // A floating decimal representing m * 10^e. | |
| 150 | struct __floating_decimal_32 { | |
| 151 | uint32_t __mantissa; | |
| 152 | int32_t __exponent; | |
| 153 | }; | |
| 154 | ||
| 155 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline __floating_decimal_32 __f2d(const uint32_t __ieeeMantissa, const uint32_t __ieeeExponent) { | |
| 156 | int32_t __e2; | |
| 157 | uint32_t __m2; | |
| 158 | if (__ieeeExponent == 0) { | |
| 159 | // We subtract 2 so that the bounds computation has 2 additional bits. | |
| 160 | __e2 = 1 - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS - 2; | |
| 161 | __m2 = __ieeeMantissa; | |
| 162 | } else { | |
| 163 | __e2 = static_cast<int32_t>(__ieeeExponent) - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS - 2; | |
| 164 | __m2 = (1u << __FLOAT_MANTISSA_BITS) | __ieeeMantissa; | |
| 165 | } | |
| 166 | const bool __even = (__m2 & 1) == 0; | |
| 167 | const bool __acceptBounds = __even; | |
| 168 | ||
| 169 | // Step 2: Determine the interval of valid decimal representations. | |
| 170 | const uint32_t __mv = 4 * __m2; | |
| 171 | const uint32_t __mp = 4 * __m2 + 2; | |
| 172 | // Implicit bool -> int conversion. True is 1, false is 0. | |
| 173 | const uint32_t __mmShift = __ieeeMantissa != 0 || __ieeeExponent <= 1; | |
| 174 | const uint32_t __mm = 4 * __m2 - 1 - __mmShift; | |
| 175 | ||
| 176 | // Step 3: Convert to a decimal power base using 64-bit arithmetic. | |
| 177 | uint32_t __vr, __vp, __vm; | |
| 178 | int32_t __e10; | |
| 179 | bool __vmIsTrailingZeros = false; | |
| 180 | bool __vrIsTrailingZeros = false; | |
| 181 | uint8_t __lastRemovedDigit = 0; | |
| 182 | if (__e2 >= 0) { | |
| 183 | const uint32_t __q = __log10Pow2(__e2); | |
| 184 | __e10 = static_cast<int32_t>(__q); | |
| 185 | const int32_t __k = __FLOAT_POW5_INV_BITCOUNT + __pow5bits(static_cast<int32_t>(__q)) - 1; | |
| 186 | const int32_t __i = -__e2 + static_cast<int32_t>(__q) + __k; | |
| 187 | __vr = __mulPow5InvDivPow2(__mv, __q, __i); | |
| 188 | __vp = __mulPow5InvDivPow2(__mp, __q, __i); | |
| 189 | __vm = __mulPow5InvDivPow2(__mm, __q, __i); | |
| 190 | if (__q != 0 && (__vp - 1) / 10 <= __vm / 10) { | |
| 191 | // We need to know one removed digit even if we are not going to loop below. We could use | |
| 192 | // __q = X - 1 above, except that would require 33 bits for the result, and we've found that | |
| 193 | // 32-bit arithmetic is faster even on 64-bit machines. | |
| 194 | const int32_t __l = __FLOAT_POW5_INV_BITCOUNT + __pow5bits(static_cast<int32_t>(__q - 1)) - 1; | |
| 195 | __lastRemovedDigit = static_cast<uint8_t>(__mulPow5InvDivPow2(__mv, __q - 1, | |
| 196 | -__e2 + static_cast<int32_t>(__q) - 1 + __l) % 10); | |
| 197 | } | |
| 198 | if (__q <= 9) { | |
| 199 | // The largest power of 5 that fits in 24 bits is 5^10, but __q <= 9 seems to be safe as well. | |
| 200 | // Only one of __mp, __mv, and __mm can be a multiple of 5, if any. | |
| 201 | if (__mv % 5 == 0) { | |
| 202 | __vrIsTrailingZeros = __multipleOfPowerOf5(__mv, __q); | |
| 203 | } else if (__acceptBounds) { | |
| 204 | __vmIsTrailingZeros = __multipleOfPowerOf5(__mm, __q); | |
| 205 | } else { | |
| 206 | __vp -= __multipleOfPowerOf5(__mp, __q); | |
| 207 | } | |
| 208 | } | |
| 209 | } else { | |
| 210 | const uint32_t __q = __log10Pow5(-__e2); | |
| 211 | __e10 = static_cast<int32_t>(__q) + __e2; | |
| 212 | const int32_t __i = -__e2 - static_cast<int32_t>(__q); | |
| 213 | const int32_t __k = __pow5bits(__i) - __FLOAT_POW5_BITCOUNT; | |
| 214 | int32_t __j = static_cast<int32_t>(__q) - __k; | |
| 215 | __vr = __mulPow5divPow2(__mv, static_cast<uint32_t>(__i), __j); | |
| 216 | __vp = __mulPow5divPow2(__mp, static_cast<uint32_t>(__i), __j); | |
| 217 | __vm = __mulPow5divPow2(__mm, static_cast<uint32_t>(__i), __j); | |
| 218 | if (__q != 0 && (__vp - 1) / 10 <= __vm / 10) { | |
| 219 | __j = static_cast<int32_t>(__q) - 1 - (__pow5bits(__i + 1) - __FLOAT_POW5_BITCOUNT); | |
| 220 | __lastRemovedDigit = static_cast<uint8_t>(__mulPow5divPow2(__mv, static_cast<uint32_t>(__i + 1), __j) % 10); | |
| 221 | } | |
| 222 | if (__q <= 1) { | |
| 223 | // {__vr,__vp,__vm} is trailing zeros if {__mv,__mp,__mm} has at least __q trailing 0 bits. | |
| 224 | // __mv = 4 * __m2, so it always has at least two trailing 0 bits. | |
| 225 | __vrIsTrailingZeros = true; | |
| 226 | if (__acceptBounds) { | |
| 227 | // __mm = __mv - 1 - __mmShift, so it has 1 trailing 0 bit iff __mmShift == 1. | |
| 228 | __vmIsTrailingZeros = __mmShift == 1; | |
| 229 | } else { | |
| 230 | // __mp = __mv + 2, so it always has at least one trailing 0 bit. | |
| 231 | --__vp; | |
| 232 | } | |
| 233 | } else if (__q < 31) { // TRANSITION(ulfjack): Use a tighter bound here. | |
| 234 | __vrIsTrailingZeros = __multipleOfPowerOf2(__mv, __q - 1); | |
| 235 | } | |
| 236 | } | |
| 237 | ||
| 238 | // Step 4: Find the shortest decimal representation in the interval of valid representations. | |
| 239 | int32_t __removed = 0; | |
| 240 | uint32_t _Output; | |
| 241 | if (__vmIsTrailingZeros || __vrIsTrailingZeros) { | |
| 242 | // General case, which happens rarely (~4.0%). | |
| 243 | while (__vp / 10 > __vm / 10) { | |
| 244 | #ifdef __clang__ // TRANSITION, LLVM-23106 | |
| 245 | __vmIsTrailingZeros &= __vm - (__vm / 10) * 10 == 0; | |
| 246 | #else | |
| 247 | __vmIsTrailingZeros &= __vm % 10 == 0; | |
| 248 | #endif | |
| 249 | __vrIsTrailingZeros &= __lastRemovedDigit == 0; | |
| 250 | __lastRemovedDigit = static_cast<uint8_t>(__vr % 10); | |
| 251 | __vr /= 10; | |
| 252 | __vp /= 10; | |
| 253 | __vm /= 10; | |
| 254 | ++__removed; | |
| 255 | } | |
| 256 | if (__vmIsTrailingZeros) { | |
| 257 | while (__vm % 10 == 0) { | |
| 258 | __vrIsTrailingZeros &= __lastRemovedDigit == 0; | |
| 259 | __lastRemovedDigit = static_cast<uint8_t>(__vr % 10); | |
| 260 | __vr /= 10; | |
| 261 | __vp /= 10; | |
| 262 | __vm /= 10; | |
| 263 | ++__removed; | |
| 264 | } | |
| 265 | } | |
| 266 | if (__vrIsTrailingZeros && __lastRemovedDigit == 5 && __vr % 2 == 0) { | |
| 267 | // Round even if the exact number is .....50..0. | |
| 268 | __lastRemovedDigit = 4; | |
| 269 | } | |
| 270 | // We need to take __vr + 1 if __vr is outside bounds or we need to round up. | |
| 271 | _Output = __vr + ((__vr == __vm && (!__acceptBounds || !__vmIsTrailingZeros)) || __lastRemovedDigit >= 5); | |
| 272 | } else { | |
| 273 | // Specialized for the common case (~96.0%). Percentages below are relative to this. | |
| 274 | // Loop iterations below (approximately): | |
| 275 | // 0: 13.6%, 1: 70.7%, 2: 14.1%, 3: 1.39%, 4: 0.14%, 5+: 0.01% | |
| 276 | while (__vp / 10 > __vm / 10) { | |
| 277 | __lastRemovedDigit = static_cast<uint8_t>(__vr % 10); | |
| 278 | __vr /= 10; | |
| 279 | __vp /= 10; | |
| 280 | __vm /= 10; | |
| 281 | ++__removed; | |
| 282 | } | |
| 283 | // We need to take __vr + 1 if __vr is outside bounds or we need to round up. | |
| 284 | _Output = __vr + (__vr == __vm || __lastRemovedDigit >= 5); | |
| 285 | } | |
| 286 | const int32_t __exp = __e10 + __removed; | |
| 287 | ||
| 288 | __floating_decimal_32 __fd; | |
| 289 | __fd.__exponent = __exp; | |
| 290 | __fd.__mantissa = _Output; | |
| 291 | return __fd; | |
| 292 | } | |
| 293 | ||
| 294 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline to_chars_result _Large_integer_to_chars(char* const _First, char* const _Last, | |
| 295 | const uint32_t _Mantissa2, const int32_t _Exponent2) { | |
| 296 | ||
| 297 | // Print the integer _Mantissa2 * 2^_Exponent2 exactly. | |
| 298 | ||
| 299 | // For nonzero integers, _Exponent2 >= -23. (The minimum value occurs when _Mantissa2 * 2^_Exponent2 is 1. | |
| 300 | // In that case, _Mantissa2 is the implicit 1 bit followed by 23 zeros, so _Exponent2 is -23 to shift away | |
| 301 | // the zeros.) The dense range of exactly representable integers has negative or zero exponents | |
| 302 | // (as positive exponents make the range non-dense). For that dense range, Ryu will always be used: | |
| 303 | // every digit is necessary to uniquely identify the value, so Ryu must print them all. | |
| 304 | ||
| 305 | // Positive exponents are the non-dense range of exactly representable integers. | |
| 306 | // This contains all of the values for which Ryu can't be used (and a few Ryu-friendly values). | |
| 307 | ||
| 308 | // Performance note: Long division appears to be faster than losslessly widening float to double and calling | |
| 309 | // __d2fixed_buffered_n(). If __f2fixed_buffered_n() is implemented, it might be faster than long division. | |
| 310 | ||
| 311 | _LIBCPP_ASSERT(_Exponent2 > 0, ""); | |
| 312 | _LIBCPP_ASSERT(_Exponent2 <= 104, ""); // because __ieeeExponent <= 254 | |
| 313 | ||
| 314 | // Manually represent _Mantissa2 * 2^_Exponent2 as a large integer. _Mantissa2 is always 24 bits | |
| 315 | // (due to the implicit bit), while _Exponent2 indicates a shift of at most 104 bits. | |
| 316 | // 24 + 104 equals 128 equals 4 * 32, so we need exactly 4 32-bit elements. | |
| 317 | // We use a little-endian representation, visualized like this: | |
| 318 | ||
| 319 | // << left shift << | |
| 320 | // most significant | |
| 321 | // _Data[3] _Data[2] _Data[1] _Data[0] | |
| 322 | // least significant | |
| 323 | // >> right shift >> | |
| 324 | ||
| 325 | constexpr uint32_t _Data_size = 4; | |
| 326 | uint32_t _Data[_Data_size]{}; | |
| 327 | ||
| 328 | // _Maxidx is the index of the most significant nonzero element. | |
| 329 | uint32_t _Maxidx = ((24 + static_cast<uint32_t>(_Exponent2) + 31) / 32) - 1; | |
| 330 | _LIBCPP_ASSERT(_Maxidx < _Data_size, ""); | |
| 331 | ||
| 332 | const uint32_t _Bit_shift = static_cast<uint32_t>(_Exponent2) % 32; | |
| 333 | if (_Bit_shift <= 8) { // _Mantissa2's 24 bits don't cross an element boundary | |
| 334 | _Data[_Maxidx] = _Mantissa2 << _Bit_shift; | |
| 335 | } else { // _Mantissa2's 24 bits cross an element boundary | |
| 336 | _Data[_Maxidx - 1] = _Mantissa2 << _Bit_shift; | |
| 337 | _Data[_Maxidx] = _Mantissa2 >> (32 - _Bit_shift); | |
| 338 | } | |
| 339 | ||
| 340 | // If Ryu hasn't determined the total output length, we need to buffer the digits generated from right to left | |
| 341 | // by long division. The largest possible float is: 340'282346638'528859811'704183484'516925440 | |
| 342 | uint32_t _Blocks[4]; | |
| 343 | int32_t _Filled_blocks = 0; | |
| 344 | // From left to right, we're going to print: | |
| 345 | // _Data[0] will be [1, 10] digits. | |
| 346 | // Then if _Filled_blocks > 0: | |
| 347 | // _Blocks[_Filled_blocks - 1], ..., _Blocks[0] will be 0-filled 9-digit blocks. | |
| 348 | ||
| 349 | if (_Maxidx != 0) { // If the integer is actually large, perform long division. | |
| 350 | // Otherwise, skip to printing _Data[0]. | |
| 351 | for (;;) { | |
| 352 | // Loop invariant: _Maxidx != 0 (i.e. the integer is actually large) | |
| 353 | ||
| 354 | const uint32_t _Most_significant_elem = _Data[_Maxidx]; | |
| 355 | const uint32_t _Initial_remainder = _Most_significant_elem % 1000000000; | |
| 356 | const uint32_t _Initial_quotient = _Most_significant_elem / 1000000000; | |
| 357 | _Data[_Maxidx] = _Initial_quotient; | |
| 358 | uint64_t _Remainder = _Initial_remainder; | |
| 359 | ||
| 360 | // Process less significant elements. | |
| 361 | uint32_t _Idx = _Maxidx; | |
| 362 | do { | |
| 363 | --_Idx; // Initially, _Remainder is at most 10^9 - 1. | |
| 364 | ||
| 365 | // Now, _Remainder is at most (10^9 - 1) * 2^32 + 2^32 - 1, simplified to 10^9 * 2^32 - 1. | |
| 366 | _Remainder = (_Remainder << 32) | _Data[_Idx]; | |
| 367 | ||
| 368 | // floor((10^9 * 2^32 - 1) / 10^9) == 2^32 - 1, so uint32_t _Quotient is lossless. | |
| 369 | const uint32_t _Quotient = static_cast<uint32_t>(__div1e9(_Remainder)); | |
| 370 | ||
| 371 | // _Remainder is at most 10^9 - 1 again. | |
| 372 | // For uint32_t truncation, see the __mod1e9() comment in d2s_intrinsics.h. | |
| 373 | _Remainder = static_cast<uint32_t>(_Remainder) - 1000000000u * _Quotient; | |
| 374 | ||
| 375 | _Data[_Idx] = _Quotient; | |
| 376 | } while (_Idx != 0); | |
| 377 | ||
| 378 | // Store a 0-filled 9-digit block. | |
| 379 | _Blocks[_Filled_blocks++] = static_cast<uint32_t>(_Remainder); | |
| 380 | ||
| 381 | if (_Initial_quotient == 0) { // Is the large integer shrinking? | |
| 382 | --_Maxidx; // log2(10^9) is 29.9, so we can't shrink by more than one element. | |
| 383 | if (_Maxidx == 0) { | |
| 384 | break; // We've finished long division. Now we need to print _Data[0]. | |
| 385 | } | |
| 386 | } | |
| 387 | } | |
| 388 | } | |
| 389 | ||
| 390 | _LIBCPP_ASSERT(_Data[0] != 0, ""); | |
| 391 | for (uint32_t _Idx = 1; _Idx < _Data_size; ++_Idx) { | |
| 392 | _LIBCPP_ASSERT(_Data[_Idx] == 0, ""); | |
| 393 | } | |
| 394 | ||
| 395 | const uint32_t _Data_olength = _Data[0] >= 1000000000 ? 10 : __decimalLength9(_Data[0]); | |
| 396 | const uint32_t _Total_fixed_length = _Data_olength + 9 * _Filled_blocks; | |
| 397 | ||
| 398 | if (_Last - _First < static_cast<ptrdiff_t>(_Total_fixed_length)) { | |
| 399 | return { _Last, errc::value_too_large }; | |
| 400 | } | |
| 401 | ||
| 402 | char* _Result = _First; | |
| 403 | ||
| 404 | // Print _Data[0]. While it's up to 10 digits, | |
| 405 | // which is more than Ryu generates, the code below can handle this. | |
| 406 | __append_n_digits(_Data_olength, _Data[0], _Result); | |
| 407 | _Result += _Data_olength; | |
| 408 | ||
| 409 | // Print 0-filled 9-digit blocks. | |
| 410 | for (int32_t _Idx = _Filled_blocks - 1; _Idx >= 0; --_Idx) { | |
| 411 | __append_nine_digits(_Blocks[_Idx], _Result); | |
| 412 | _Result += 9; | |
| 413 | } | |
| 414 | ||
| 415 | return { _Result, errc{} }; | |
| 416 | } | |
| 417 | ||
| 418 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline to_chars_result __to_chars(char* const _First, char* const _Last, const __floating_decimal_32 __v, | |
| 419 | chars_format _Fmt, const uint32_t __ieeeMantissa, const uint32_t __ieeeExponent) { | |
| 420 | // Step 5: Print the decimal representation. | |
| 421 | uint32_t _Output = __v.__mantissa; | |
| 422 | int32_t _Ryu_exponent = __v.__exponent; | |
| 423 | const uint32_t __olength = __decimalLength9(_Output); | |
| 424 | int32_t _Scientific_exponent = _Ryu_exponent + static_cast<int32_t>(__olength) - 1; | |
| 425 | ||
| 426 | if (_Fmt == chars_format{}) { | |
| 427 | int32_t _Lower; | |
| 428 | int32_t _Upper; | |
| 429 | ||
| 430 | if (__olength == 1) { | |
| 431 | // Value | Fixed | Scientific | |
| 432 | // 1e-3 | "0.001" | "1e-03" | |
| 433 | // 1e4 | "10000" | "1e+04" | |
| 434 | _Lower = -3; | |
| 435 | _Upper = 4; | |
| 436 | } else { | |
| 437 | // Value | Fixed | Scientific | |
| 438 | // 1234e-7 | "0.0001234" | "1.234e-04" | |
| 439 | // 1234e5 | "123400000" | "1.234e+08" | |
| 440 | _Lower = -static_cast<int32_t>(__olength + 3); | |
| 441 | _Upper = 5; | |
| 442 | } | |
| 443 | ||
| 444 | if (_Lower <= _Ryu_exponent && _Ryu_exponent <= _Upper) { | |
| 445 | _Fmt = chars_format::fixed; | |
| 446 | } else { | |
| 447 | _Fmt = chars_format::scientific; | |
| 448 | } | |
| 449 | } else if (_Fmt == chars_format::general) { | |
| 450 | // C11 7.21.6.1 "The fprintf function"/8: | |
| 451 | // "Let P equal [...] 6 if the precision is omitted [...]. | |
| 452 | // Then, if a conversion with style E would have an exponent of X: | |
| 453 | // - if P > X >= -4, the conversion is with style f [...]. | |
| 454 | // - otherwise, the conversion is with style e [...]." | |
| 455 | if (-4 <= _Scientific_exponent && _Scientific_exponent < 6) { | |
| 456 | _Fmt = chars_format::fixed; | |
| 457 | } else { | |
| 458 | _Fmt = chars_format::scientific; | |
| 459 | } | |
| 460 | } | |
| 461 | ||
| 462 | if (_Fmt == chars_format::fixed) { | |
| 463 | // Example: _Output == 1729, __olength == 4 | |
| 464 | ||
| 465 | // _Ryu_exponent | Printed | _Whole_digits | _Total_fixed_length | Notes | |
| 466 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 467 | // 2 | 172900 | 6 | _Whole_digits | Ryu can't be used for printing | |
| 468 | // 1 | 17290 | 5 | (sometimes adjusted) | when the trimmed digits are nonzero. | |
| 469 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 470 | // 0 | 1729 | 4 | _Whole_digits | Unified length cases. | |
| 471 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 472 | // -1 | 172.9 | 3 | __olength + 1 | This case can't happen for | |
| 473 | // -2 | 17.29 | 2 | | __olength == 1, but no additional | |
| 474 | // -3 | 1.729 | 1 | | code is needed to avoid it. | |
| 475 | // --------------|----------|---------------|----------------------|--------------------------------------- | |
| 476 | // -4 | 0.1729 | 0 | 2 - _Ryu_exponent | C11 7.21.6.1 "The fprintf function"/8: | |
| 477 | // -5 | 0.01729 | -1 | | "If a decimal-point character appears, | |
| 478 | // -6 | 0.001729 | -2 | | at least one digit appears before it." | |
| 479 | ||
| 480 | const int32_t _Whole_digits = static_cast<int32_t>(__olength) + _Ryu_exponent; | |
| 481 | ||
| 482 | uint32_t _Total_fixed_length; | |
| 483 | if (_Ryu_exponent >= 0) { // cases "172900" and "1729" | |
| 484 | _Total_fixed_length = static_cast<uint32_t>(_Whole_digits); | |
| 485 | if (_Output == 1) { | |
| 486 | // Rounding can affect the number of digits. | |
| 487 | // For example, 1e11f is exactly "99999997952" which is 11 digits instead of 12. | |
| 488 | // We can use a lookup table to detect this and adjust the total length. | |
| 489 | static constexpr uint8_t _Adjustment[39] = { | |
| 490 | 0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1,0,0,1,1,0,1,0,1,1,0,0,1,0,1,1,0,1,1,1 }; | |
| 491 | _Total_fixed_length -= _Adjustment[_Ryu_exponent]; | |
| 492 | // _Whole_digits doesn't need to be adjusted because these cases won't refer to it later. | |
| 493 | } | |
| 494 | } else if (_Whole_digits > 0) { // case "17.29" | |
| 495 | _Total_fixed_length = __olength + 1; | |
| 496 | } else { // case "0.001729" | |
| 497 | _Total_fixed_length = static_cast<uint32_t>(2 - _Ryu_exponent); | |
| 498 | } | |
| 499 | ||
| 500 | if (_Last - _First < static_cast<ptrdiff_t>(_Total_fixed_length)) { | |
| 501 | return { _Last, errc::value_too_large }; | |
| 502 | } | |
| 503 | ||
| 504 | char* _Mid; | |
| 505 | if (_Ryu_exponent > 0) { // case "172900" | |
| 506 | bool _Can_use_ryu; | |
| 507 | ||
| 508 | if (_Ryu_exponent > 10) { // 10^10 is the largest power of 10 that's exactly representable as a float. | |
| 509 | _Can_use_ryu = false; | |
| 510 | } else { | |
| 511 | // Ryu generated X: __v.__mantissa * 10^_Ryu_exponent | |
| 512 | // __v.__mantissa == 2^_Trailing_zero_bits * (__v.__mantissa >> _Trailing_zero_bits) | |
| 513 | // 10^_Ryu_exponent == 2^_Ryu_exponent * 5^_Ryu_exponent | |
| 514 | ||
| 515 | // _Trailing_zero_bits is [0, 29] (aside: because 2^29 is the largest power of 2 | |
| 516 | // with 9 decimal digits, which is float's round-trip limit.) | |
| 517 | // _Ryu_exponent is [1, 10]. | |
| 518 | // Normalization adds [2, 23] (aside: at least 2 because the pre-normalized mantissa is at least 5). | |
| 519 | // This adds up to [3, 62], which is well below float's maximum binary exponent 127. | |
| 520 | ||
| 521 | // Therefore, we just need to consider (__v.__mantissa >> _Trailing_zero_bits) * 5^_Ryu_exponent. | |
| 522 | ||
| 523 | // If that product would exceed 24 bits, then X can't be exactly represented as a float. | |
| 524 | // (That's not a problem for round-tripping, because X is close enough to the original float, | |
| 525 | // but X isn't mathematically equal to the original float.) This requires a high-precision fallback. | |
| 526 | ||
| 527 | // If the product is 24 bits or smaller, then X can be exactly represented as a float (and we don't | |
| 528 | // need to re-synthesize it; the original float must have been X, because Ryu wouldn't produce the | |
| 529 | // same output for two different floats X and Y). This allows Ryu's output to be used (zero-filled). | |
| 530 | ||
| 531 | // (2^24 - 1) / 5^0 (for indexing), (2^24 - 1) / 5^1, ..., (2^24 - 1) / 5^10 | |
| 532 | static constexpr uint32_t _Max_shifted_mantissa[11] = { | |
| 533 | 16777215, 3355443, 671088, 134217, 26843, 5368, 1073, 214, 42, 8, 1 }; | |
| 534 | ||
| 535 | unsigned long _Trailing_zero_bits; | |
| 536 | (void) _BitScanForward(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero | |
| 537 | const uint32_t _Shifted_mantissa = __v.__mantissa >> _Trailing_zero_bits; | |
| 538 | _Can_use_ryu = _Shifted_mantissa <= _Max_shifted_mantissa[_Ryu_exponent]; | |
| 539 | } | |
| 540 | ||
| 541 | if (!_Can_use_ryu) { | |
| 542 | const uint32_t _Mantissa2 = __ieeeMantissa | (1u << __FLOAT_MANTISSA_BITS); // restore implicit bit | |
| 543 | const int32_t _Exponent2 = static_cast<int32_t>(__ieeeExponent) | |
| 544 | - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS; // bias and normalization | |
| 545 | ||
| 546 | // Performance note: We've already called Ryu, so this will redundantly perform buffering and bounds checking. | |
| 547 | return _Large_integer_to_chars(_First, _Last, _Mantissa2, _Exponent2); | |
| 548 | } | |
| 549 | ||
| 550 | // _Can_use_ryu | |
| 551 | // Print the decimal digits, left-aligned within [_First, _First + _Total_fixed_length). | |
| 552 | _Mid = _First + __olength; | |
| 553 | } else { // cases "1729", "17.29", and "0.001729" | |
| 554 | // Print the decimal digits, right-aligned within [_First, _First + _Total_fixed_length). | |
| 555 | _Mid = _First + _Total_fixed_length; | |
| 556 | } | |
| 557 | ||
| 558 | while (_Output >= 10000) { | |
| 559 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 560 | const uint32_t __c = _Output - 10000 * (_Output / 10000); | |
| 561 | #else | |
| 562 | const uint32_t __c = _Output % 10000; | |
| 563 | #endif | |
| 564 | _Output /= 10000; | |
| 565 | const uint32_t __c0 = (__c % 100) << 1; | |
| 566 | const uint32_t __c1 = (__c / 100) << 1; | |
| 567 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c0, 2); | |
| 568 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c1, 2); | |
| 569 | } | |
| 570 | if (_Output >= 100) { | |
| 571 | const uint32_t __c = (_Output % 100) << 1; | |
| 572 | _Output /= 100; | |
| 573 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2); | |
| 574 | } | |
| 575 | if (_Output >= 10) { | |
| 576 | const uint32_t __c = _Output << 1; | |
| 577 | _VSTD::memcpy(_Mid -= 2, __DIGIT_TABLE + __c, 2); | |
| 578 | } else { | |
| 579 | *--_Mid = static_cast<char>('0' + _Output); | |
| 580 | } | |
| 581 | ||
| 582 | if (_Ryu_exponent > 0) { // case "172900" with _Can_use_ryu | |
| 583 | // Performance note: it might be more efficient to do this immediately after setting _Mid. | |
| 584 | _VSTD::memset(_First + __olength, '0', static_cast<size_t>(_Ryu_exponent)); | |
| 585 | } else if (_Ryu_exponent == 0) { // case "1729" | |
| 586 | // Done! | |
| 587 | } else if (_Whole_digits > 0) { // case "17.29" | |
| 588 | // Performance note: moving digits might not be optimal. | |
| 589 | _VSTD::memmove(_First, _First + 1, static_cast<size_t>(_Whole_digits)); | |
| 590 | _First[_Whole_digits] = '.'; | |
| 591 | } else { // case "0.001729" | |
| 592 | // Performance note: a larger memset() followed by overwriting '.' might be more efficient. | |
| 593 | _First[0] = '0'; | |
| 594 | _First[1] = '.'; | |
| 595 | _VSTD::memset(_First + 2, '0', static_cast<size_t>(-_Whole_digits)); | |
| 596 | } | |
| 597 | ||
| 598 | return { _First + _Total_fixed_length, errc{} }; | |
| 599 | } | |
| 600 | ||
| 601 | const uint32_t _Total_scientific_length = | |
| 602 | __olength + (__olength > 1) + 4; // digits + possible decimal point + scientific exponent | |
| 603 | if (_Last - _First < static_cast<ptrdiff_t>(_Total_scientific_length)) { | |
| 604 | return { _Last, errc::value_too_large }; | |
| 605 | } | |
| 606 | char* const __result = _First; | |
| 607 | ||
| 608 | // Print the decimal digits. | |
| 609 | uint32_t __i = 0; | |
| 610 | while (_Output >= 10000) { | |
| 611 | #ifdef __clang__ // TRANSITION, LLVM-38217 | |
| 612 | const uint32_t __c = _Output - 10000 * (_Output / 10000); | |
| 613 | #else | |
| 614 | const uint32_t __c = _Output % 10000; | |
| 615 | #endif | |
| 616 | _Output /= 10000; | |
| 617 | const uint32_t __c0 = (__c % 100) << 1; | |
| 618 | const uint32_t __c1 = (__c / 100) << 1; | |
| 619 | _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c0, 2); | |
| 620 | _VSTD::memcpy(__result + __olength - __i - 3, __DIGIT_TABLE + __c1, 2); | |
| 621 | __i += 4; | |
| 622 | } | |
| 623 | if (_Output >= 100) { | |
| 624 | const uint32_t __c = (_Output % 100) << 1; | |
| 625 | _Output /= 100; | |
| 626 | _VSTD::memcpy(__result + __olength - __i - 1, __DIGIT_TABLE + __c, 2); | |
| 627 | __i += 2; | |
| 628 | } | |
| 629 | if (_Output >= 10) { | |
| 630 | const uint32_t __c = _Output << 1; | |
| 631 | // We can't use memcpy here: the decimal dot goes between these two digits. | |
| 632 | __result[2] = __DIGIT_TABLE[__c + 1]; | |
| 633 | __result[0] = __DIGIT_TABLE[__c]; | |
| 634 | } else { | |
| 635 | __result[0] = static_cast<char>('0' + _Output); | |
| 636 | } | |
| 637 | ||
| 638 | // Print decimal point if needed. | |
| 639 | uint32_t __index; | |
| 640 | if (__olength > 1) { | |
| 641 | __result[1] = '.'; | |
| 642 | __index = __olength + 1; | |
| 643 | } else { | |
| 644 | __index = 1; | |
| 645 | } | |
| 646 | ||
| 647 | // Print the exponent. | |
| 648 | __result[__index++] = 'e'; | |
| 649 | if (_Scientific_exponent < 0) { | |
| 650 | __result[__index++] = '-'; | |
| 651 | _Scientific_exponent = -_Scientific_exponent; | |
| 652 | } else { | |
| 653 | __result[__index++] = '+'; | |
| 654 | } | |
| 655 | ||
| 656 | _VSTD::memcpy(__result + __index, __DIGIT_TABLE + 2 * _Scientific_exponent, 2); | |
| 657 | __index += 2; | |
| 658 | ||
| 659 | return { _First + _Total_scientific_length, errc{} }; | |
| 660 | } | |
| 661 | ||
| 662 | [[nodiscard]] to_chars_result __f2s_buffered_n(char* const _First, char* const _Last, const float __f, | |
| 663 | const chars_format _Fmt) { | |
| 664 | ||
| 665 | // Step 1: Decode the floating-point number, and unify normalized and subnormal cases. | |
| 666 | const uint32_t __bits = __float_to_bits(__f); | |
| 667 | ||
| 668 | // Case distinction; exit early for the easy cases. | |
| 669 | if (__bits == 0) { | |
| 670 | if (_Fmt == chars_format::scientific) { | |
| 671 | if (_Last - _First < 5) { | |
| 672 | return { _Last, errc::value_too_large }; | |
| 673 | } | |
| 674 | ||
| 675 | _VSTD::memcpy(_First, "0e+00", 5); | |
| 676 | ||
| 677 | return { _First + 5, errc{} }; | |
| 678 | } | |
| 679 | ||
| 680 | // Print "0" for chars_format::fixed, chars_format::general, and chars_format{}. | |
| 681 | if (_First == _Last) { | |
| 682 | return { _Last, errc::value_too_large }; | |
| 683 | } | |
| 684 | ||
| 685 | *_First = '0'; | |
| 686 | ||
| 687 | return { _First + 1, errc{} }; | |
| 688 | } | |
| 689 | ||
| 690 | // Decode __bits into mantissa and exponent. | |
| 691 | const uint32_t __ieeeMantissa = __bits & ((1u << __FLOAT_MANTISSA_BITS) - 1); | |
| 692 | const uint32_t __ieeeExponent = __bits >> __FLOAT_MANTISSA_BITS; | |
| 693 | ||
| 694 | // When _Fmt == chars_format::fixed and the floating-point number is a large integer, | |
| 695 | // it's faster to skip Ryu and immediately print the integer exactly. | |
| 696 | if (_Fmt == chars_format::fixed) { | |
| 697 | const uint32_t _Mantissa2 = __ieeeMantissa | (1u << __FLOAT_MANTISSA_BITS); // restore implicit bit | |
| 698 | const int32_t _Exponent2 = static_cast<int32_t>(__ieeeExponent) | |
| 699 | - __FLOAT_BIAS - __FLOAT_MANTISSA_BITS; // bias and normalization | |
| 700 | ||
| 701 | // Normal values are equal to _Mantissa2 * 2^_Exponent2. | |
| 702 | // (Subnormals are different, but they'll be rejected by the _Exponent2 test here, so they can be ignored.) | |
| 703 | ||
| 704 | if (_Exponent2 > 0) { | |
| 705 | return _Large_integer_to_chars(_First, _Last, _Mantissa2, _Exponent2); | |
| 706 | } | |
| 707 | } | |
| 708 | ||
| 709 | const __floating_decimal_32 __v = __f2d(__ieeeMantissa, __ieeeExponent); | |
| 710 | return __to_chars(_First, _Last, __v, _Fmt, __ieeeMantissa, __ieeeExponent); | |
| 711 | } | |
| 712 | ||
| 713 | _LIBCPP_END_NAMESPACE_STD | |
| 714 | ||
| 715 | // clang-format on |
lib/libcxx/src/shared_mutex.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===---------------------- shared_mutex.cpp ------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/stdexcept.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ stdexcept.cpp -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/string.cpp+59-8| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- string.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -9,24 +9,50 @@ |
| 9 | 9 | #include "string" |
| 10 | 10 | #include "charconv" |
| 11 | 11 | #include "cstdlib" |
| 12 | #include "cwchar" | |
| 13 | 12 | #include "cerrno" |
| 14 | 13 | #include "limits" |
| 15 | 14 | #include "stdexcept" |
| 16 | 15 | #include <stdio.h> |
| 17 | 16 | #include "__debug" |
| 18 | 17 | |
| 18 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 19 | # include "cwchar" | |
| 20 | #endif | |
| 21 | ||
| 19 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 23 | |
| 21 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __basic_string_common<true>; | |
| 24 | #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | |
| 25 | ||
| 26 | template <bool> | |
| 27 | struct __basic_string_common; | |
| 28 | ||
| 29 | // The struct isn't declared anymore in the headers. It's only here for ABI compatibility. | |
| 30 | template <> | |
| 31 | struct __basic_string_common<true> { | |
| 32 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; | |
| 33 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; | |
| 34 | }; | |
| 35 | ||
| 36 | void __basic_string_common<true>::__throw_length_error() const { | |
| 37 | std::__throw_length_error("basic_string"); | |
| 38 | } | |
| 39 | void __basic_string_common<true>::__throw_out_of_range() const { | |
| 40 | std::__throw_out_of_range("basic_string"); | |
| 41 | } | |
| 42 | ||
| 43 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | |
| 22 | 44 | |
| 23 | 45 | #define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__; |
| 24 | 46 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 25 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) | |
| 26 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) | |
| 47 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) | |
| 48 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 49 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) | |
| 50 | # endif | |
| 27 | 51 | #else |
| 28 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) | |
| 29 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) | |
| 52 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char) | |
| 53 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 54 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t) | |
| 55 | # endif | |
| 30 | 56 | #endif |
| 31 | 57 | #undef _LIBCPP_EXTERN_TEMPLATE_DEFINE |
| 32 | 58 | |
| ... | ... | @@ -131,6 +157,7 @@ as_integer( const string& func, const string& s, size_t* idx, int base ) |
| 131 | 157 | return as_integer_helper<unsigned long long>( func, s, idx, base, strtoull ); |
| 132 | 158 | } |
| 133 | 159 | |
| 160 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 134 | 161 | // wstring |
| 135 | 162 | template<> |
| 136 | 163 | inline |
| ... | ... | @@ -175,6 +202,7 @@ as_integer( const string& func, const wstring& s, size_t* idx, int base ) |
| 175 | 202 | { |
| 176 | 203 | return as_integer_helper<unsigned long long>( func, s, idx, base, wcstoull ); |
| 177 | 204 | } |
| 205 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 178 | 206 | |
| 179 | 207 | // as_float |
| 180 | 208 | |
| ... | ... | @@ -226,6 +254,7 @@ as_float( const string& func, const string& s, size_t* idx ) |
| 226 | 254 | return as_float_helper<long double>( func, s, idx, strtold ); |
| 227 | 255 | } |
| 228 | 256 | |
| 257 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 229 | 258 | template<> |
| 230 | 259 | inline |
| 231 | 260 | float |
| ... | ... | @@ -249,6 +278,7 @@ as_float( const string& func, const wstring& s, size_t* idx ) |
| 249 | 278 | { |
| 250 | 279 | return as_float_helper<long double>( func, s, idx, wcstold ); |
| 251 | 280 | } |
| 281 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 252 | 282 | |
| 253 | 283 | } // unnamed namespace |
| 254 | 284 | |
| ... | ... | @@ -258,11 +288,13 @@ stoi(const string& str, size_t* idx, int base) |
| 258 | 288 | return as_integer<int>( "stoi", str, idx, base ); |
| 259 | 289 | } |
| 260 | 290 | |
| 291 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 261 | 292 | int |
| 262 | 293 | stoi(const wstring& str, size_t* idx, int base) |
| 263 | 294 | { |
| 264 | 295 | return as_integer<int>( "stoi", str, idx, base ); |
| 265 | 296 | } |
| 297 | #endif | |
| 266 | 298 | |
| 267 | 299 | long |
| 268 | 300 | stol(const string& str, size_t* idx, int base) |
| ... | ... | @@ -270,11 +302,13 @@ stol(const string& str, size_t* idx, int base) |
| 270 | 302 | return as_integer<long>( "stol", str, idx, base ); |
| 271 | 303 | } |
| 272 | 304 | |
| 305 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 273 | 306 | long |
| 274 | 307 | stol(const wstring& str, size_t* idx, int base) |
| 275 | 308 | { |
| 276 | 309 | return as_integer<long>( "stol", str, idx, base ); |
| 277 | 310 | } |
| 311 | #endif | |
| 278 | 312 | |
| 279 | 313 | unsigned long |
| 280 | 314 | stoul(const string& str, size_t* idx, int base) |
| ... | ... | @@ -282,11 +316,13 @@ stoul(const string& str, size_t* idx, int base) |
| 282 | 316 | return as_integer<unsigned long>( "stoul", str, idx, base ); |
| 283 | 317 | } |
| 284 | 318 | |
| 319 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 285 | 320 | unsigned long |
| 286 | 321 | stoul(const wstring& str, size_t* idx, int base) |
| 287 | 322 | { |
| 288 | 323 | return as_integer<unsigned long>( "stoul", str, idx, base ); |
| 289 | 324 | } |
| 325 | #endif | |
| 290 | 326 | |
| 291 | 327 | long long |
| 292 | 328 | stoll(const string& str, size_t* idx, int base) |
| ... | ... | @@ -294,11 +330,13 @@ stoll(const string& str, size_t* idx, int base) |
| 294 | 330 | return as_integer<long long>( "stoll", str, idx, base ); |
| 295 | 331 | } |
| 296 | 332 | |
| 333 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 297 | 334 | long long |
| 298 | 335 | stoll(const wstring& str, size_t* idx, int base) |
| 299 | 336 | { |
| 300 | 337 | return as_integer<long long>( "stoll", str, idx, base ); |
| 301 | 338 | } |
| 339 | #endif | |
| 302 | 340 | |
| 303 | 341 | unsigned long long |
| 304 | 342 | stoull(const string& str, size_t* idx, int base) |
| ... | ... | @@ -306,11 +344,13 @@ stoull(const string& str, size_t* idx, int base) |
| 306 | 344 | return as_integer<unsigned long long>( "stoull", str, idx, base ); |
| 307 | 345 | } |
| 308 | 346 | |
| 347 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 309 | 348 | unsigned long long |
| 310 | 349 | stoull(const wstring& str, size_t* idx, int base) |
| 311 | 350 | { |
| 312 | 351 | return as_integer<unsigned long long>( "stoull", str, idx, base ); |
| 313 | 352 | } |
| 353 | #endif | |
| 314 | 354 | |
| 315 | 355 | float |
| 316 | 356 | stof(const string& str, size_t* idx) |
| ... | ... | @@ -318,11 +358,13 @@ stof(const string& str, size_t* idx) |
| 318 | 358 | return as_float<float>( "stof", str, idx ); |
| 319 | 359 | } |
| 320 | 360 | |
| 361 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 321 | 362 | float |
| 322 | 363 | stof(const wstring& str, size_t* idx) |
| 323 | 364 | { |
| 324 | 365 | return as_float<float>( "stof", str, idx ); |
| 325 | 366 | } |
| 367 | #endif | |
| 326 | 368 | |
| 327 | 369 | double |
| 328 | 370 | stod(const string& str, size_t* idx) |
| ... | ... | @@ -330,11 +372,13 @@ stod(const string& str, size_t* idx) |
| 330 | 372 | return as_float<double>( "stod", str, idx ); |
| 331 | 373 | } |
| 332 | 374 | |
| 375 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 333 | 376 | double |
| 334 | 377 | stod(const wstring& str, size_t* idx) |
| 335 | 378 | { |
| 336 | 379 | return as_float<double>( "stod", str, idx ); |
| 337 | 380 | } |
| 381 | #endif | |
| 338 | 382 | |
| 339 | 383 | long double |
| 340 | 384 | stold(const string& str, size_t* idx) |
| ... | ... | @@ -342,11 +386,13 @@ stold(const string& str, size_t* idx) |
| 342 | 386 | return as_float<long double>( "stold", str, idx ); |
| 343 | 387 | } |
| 344 | 388 | |
| 389 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 345 | 390 | long double |
| 346 | 391 | stold(const wstring& str, size_t* idx) |
| 347 | 392 | { |
| 348 | 393 | return as_float<long double>( "stold", str, idx ); |
| 349 | 394 | } |
| 395 | #endif | |
| 350 | 396 | |
| 351 | 397 | // to_string |
| 352 | 398 | |
| ... | ... | @@ -397,6 +443,7 @@ struct initial_string<string> |
| 397 | 443 | } |
| 398 | 444 | }; |
| 399 | 445 | |
| 446 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 400 | 447 | template <> |
| 401 | 448 | struct initial_string<wstring> |
| 402 | 449 | { |
| ... | ... | @@ -421,6 +468,7 @@ get_swprintf() |
| 421 | 468 | return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(_snwprintf); |
| 422 | 469 | #endif |
| 423 | 470 | } |
| 471 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 424 | 472 | |
| 425 | 473 | template <typename S, typename V> |
| 426 | 474 | S i_to_string(V v) |
| ... | ... | @@ -444,20 +492,23 @@ string to_string (unsigned val) { return i_to_string< string>(val); } |
| 444 | 492 | string to_string (unsigned long val) { return i_to_string< string>(val); } |
| 445 | 493 | string to_string (unsigned long long val) { return i_to_string< string>(val); } |
| 446 | 494 | |
| 495 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 447 | 496 | wstring to_wstring(int val) { return i_to_string<wstring>(val); } |
| 448 | 497 | wstring to_wstring(long val) { return i_to_string<wstring>(val); } |
| 449 | 498 | wstring to_wstring(long long val) { return i_to_string<wstring>(val); } |
| 450 | 499 | wstring to_wstring(unsigned val) { return i_to_string<wstring>(val); } |
| 451 | 500 | wstring to_wstring(unsigned long val) { return i_to_string<wstring>(val); } |
| 452 | 501 | wstring to_wstring(unsigned long long val) { return i_to_string<wstring>(val); } |
| 453 | ||
| 502 | #endif | |
| 454 | 503 | |
| 455 | 504 | string to_string (float val) { return as_string(snprintf, initial_string< string>()(), "%f", val); } |
| 456 | 505 | string to_string (double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); } |
| 457 | 506 | string to_string (long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); } |
| 458 | 507 | |
| 508 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 459 | 509 | wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); } |
| 460 | 510 | wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); } |
| 461 | 511 | wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); } |
| 512 | #endif | |
| 462 | 513 | |
| 463 | 514 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/strstream.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ strstream.cpp -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/support/ibm/mbsnrtowcs.cpp 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 | #include <cstddef> // size_t | |
| 10 | #include <cwchar> // mbstate_t | |
| 11 | #include <limits.h> // MB_LEN_MAX | |
| 12 | #include <string.h> // wmemcpy | |
| 13 | ||
| 14 | // Returns the number of wide characters found in the multi byte sequence `src` | |
| 15 | // (of `src_size_bytes`), that fit in the buffer `dst` (of `max_dest_chars` | |
| 16 | // elements size). The count returned excludes the null terminator. | |
| 17 | // When `dst` is NULL, no characters are copied to `dst`. | |
| 18 | // Returns (size_t) -1 when an invalid sequence is encountered. | |
| 19 | // Leaves *`src` pointing to the next character to convert or NULL | |
| 20 | // if a null character was converted from *`src`. | |
| 21 | _LIBCPP_FUNC_VIS | |
| 22 | size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, | |
| 23 | size_t src_size_bytes, size_t max_dest_chars, | |
| 24 | mbstate_t *__restrict ps) { | |
| 25 | const size_t terminated_sequence = static_cast<size_t>(0); | |
| 26 | const size_t invalid_sequence = static_cast<size_t>(-1); | |
| 27 | const size_t incomplete_sequence = static_cast<size_t>(-2); | |
| 28 | ||
| 29 | size_t source_converted; | |
| 30 | size_t dest_converted; | |
| 31 | size_t result = 0; | |
| 32 | ||
| 33 | // If `dst` is null then `max_dest_chars` should be ignored according to the | |
| 34 | // standard. Setting `max_dest_chars` to a large value has this effect. | |
| 35 | if (dst == nullptr) | |
| 36 | max_dest_chars = static_cast<size_t>(-1); | |
| 37 | ||
| 38 | for (dest_converted = source_converted = 0; | |
| 39 | source_converted < src_size_bytes && (!dst || dest_converted < max_dest_chars); | |
| 40 | ++dest_converted, source_converted += result) { | |
| 41 | // Converts one multi byte character. | |
| 42 | // If result (char_size) is greater than 0, it's the size in bytes of that character. | |
| 43 | // If result (char_size) is zero, it indicates that the null character has been found. | |
| 44 | // Otherwise, it's an error and errno may be set. | |
| 45 | size_t source_remaining = src_size_bytes - source_converted; | |
| 46 | size_t dest_remaining = max_dest_chars - dest_converted; | |
| 47 | ||
| 48 | if (dst == nullptr) { | |
| 49 | result = mbrtowc(NULL, *src + source_converted, source_remaining, ps); | |
| 50 | } else if (dest_remaining >= source_remaining) { | |
| 51 | // dst has enough space to translate in-place. | |
| 52 | result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps); | |
| 53 | } else { | |
| 54 | /* | |
| 55 | * dst may not have enough space, so use a temporary buffer. | |
| 56 | * | |
| 57 | * We need to save a copy of the conversion state | |
| 58 | * here so we can restore it if the multibyte | |
| 59 | * character is too long for the buffer. | |
| 60 | */ | |
| 61 | wchar_t buff[MB_LEN_MAX]; | |
| 62 | mbstate_t mbstate_tmp; | |
| 63 | ||
| 64 | if (ps != nullptr) | |
| 65 | mbstate_tmp = *ps; | |
| 66 | result = mbrtowc(buff, *src + source_converted, source_remaining, ps); | |
| 67 | ||
| 68 | if (result > dest_remaining) { | |
| 69 | // Multi-byte sequence for character won't fit. | |
| 70 | if (ps != nullptr) | |
| 71 | *ps = mbstate_tmp; | |
| 72 | break; | |
| 73 | } else { | |
| 74 | // The buffer was used, so we need copy the translation to dst. | |
| 75 | wmemcpy(dst, buff, result); | |
| 76 | } | |
| 77 | } | |
| 78 | ||
| 79 | // Don't do anything to change errno from here on. | |
| 80 | if (result == invalid_sequence || result == terminated_sequence || result == incomplete_sequence) { | |
| 81 | break; | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | if (dst) { | |
| 86 | if (result == terminated_sequence) | |
| 87 | *src = NULL; | |
| 88 | else | |
| 89 | *src += source_converted; | |
| 90 | } | |
| 91 | if (result == invalid_sequence) | |
| 92 | return invalid_sequence; | |
| 93 | ||
| 94 | return dest_converted; | |
| 95 | } |
lib/libcxx/src/support/ibm/wcsnrtombs.cpp 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 | #include <cwchar> // mbstate_t | |
| 10 | #include <limits.h> // MB_LEN_MAX | |
| 11 | #include <stdlib.h> // MB_CUR_MAX, size_t | |
| 12 | #include <string.h> // memcpy | |
| 13 | ||
| 14 | // Converts `max_source_chars` from the wide character buffer pointer to by *`src`, | |
| 15 | // into the multi byte character sequence buffer stored at `dst`, which must be | |
| 16 | // `dst_size_bytes` bytes in size. Returns the number of bytes in the sequence | |
| 17 | // converted from *src, excluding the null terminator. | |
| 18 | // Returns (size_t) -1 if an error occurs and sets errno. | |
| 19 | // If `dst` is NULL, `dst_size_bytes` is ignored and no bytes are copied to `dst`. | |
| 20 | _LIBCPP_FUNC_VIS | |
| 21 | size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, | |
| 22 | size_t max_source_chars, size_t dst_size_bytes, | |
| 23 | mbstate_t *__restrict ps) { | |
| 24 | ||
| 25 | const size_t invalid_wchar = static_cast<size_t>(-1); | |
| 26 | ||
| 27 | size_t source_converted; | |
| 28 | size_t dest_converted; | |
| 29 | size_t result = 0; | |
| 30 | ||
| 31 | // If `dst` is null then `dst_size_bytes` should be ignored according to the | |
| 32 | // standard. Setting dst_size_bytes to a large value has this effect. | |
| 33 | if (dst == nullptr) | |
| 34 | dst_size_bytes = static_cast<size_t>(-1); | |
| 35 | ||
| 36 | for (dest_converted = source_converted = 0; | |
| 37 | source_converted < max_source_chars && (!dst || dest_converted < dst_size_bytes); | |
| 38 | ++source_converted, dest_converted += result) { | |
| 39 | wchar_t c = (*src)[source_converted]; | |
| 40 | size_t dest_remaining = dst_size_bytes - dest_converted; | |
| 41 | ||
| 42 | if (dst == nullptr) { | |
| 43 | result = wcrtomb(NULL, c, ps); | |
| 44 | } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) { | |
| 45 | // dst has enough space to translate in-place. | |
| 46 | result = wcrtomb(dst + dest_converted, c, ps); | |
| 47 | } else { | |
| 48 | /* | |
| 49 | * dst may not have enough space, so use a temporary buffer. | |
| 50 | * | |
| 51 | * We need to save a copy of the conversion state | |
| 52 | * here so we can restore it if the multibyte | |
| 53 | * character is too long for the buffer. | |
| 54 | */ | |
| 55 | char buff[MB_LEN_MAX]; | |
| 56 | mbstate_t mbstate_tmp; | |
| 57 | ||
| 58 | if (ps != nullptr) | |
| 59 | mbstate_tmp = *ps; | |
| 60 | result = wcrtomb(buff, c, ps); | |
| 61 | ||
| 62 | if (result > dest_remaining) { | |
| 63 | // Multi-byte sequence for character won't fit. | |
| 64 | if (ps != nullptr) | |
| 65 | *ps = mbstate_tmp; | |
| 66 | if (result != invalid_wchar) | |
| 67 | break; | |
| 68 | } else { | |
| 69 | // The buffer was used, so we need copy the translation to dst. | |
| 70 | memcpy(dst, buff, result); | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 74 | // result (char_size) contains the size of the multi-byte-sequence converted. | |
| 75 | // Otherwise, result (char_size) is (size_t) -1 and wcrtomb() sets the errno. | |
| 76 | if (result == invalid_wchar) { | |
| 77 | if (dst) | |
| 78 | *src = *src + source_converted; | |
| 79 | return invalid_wchar; | |
| 80 | } | |
| 81 | ||
| 82 | if (c == L'\0') { | |
| 83 | if (dst) | |
| 84 | *src = NULL; | |
| 85 | return dest_converted; | |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | if (dst) | |
| 90 | *src = *src + source_converted; | |
| 91 | ||
| 92 | return dest_converted; | |
| 93 | } |
lib/libcxx/src/support/runtime/stdexcept_default.ipp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===--------------------- stdexcept_default.ipp --------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/support/runtime/stdexcept_vcruntime.ipp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------- stdexcept_vcruntime.ipp --------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/support/win32/locale_win32.cpp+3-1| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | // -*- C++ -*- | |
| 2 | 1 | //===----------------------------------------------------------------------===// |
| 3 | 2 | // |
| 4 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| ... | ... | @@ -98,7 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...) |
| 98 | 97 | ret, n, format, loc, ap); |
| 99 | 98 | #else |
| 100 | 99 | __libcpp_locale_guard __current(loc); |
| 100 | #pragma clang diagnostic push | |
| 101 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 101 | 102 | int result = vsnprintf( ret, n, format, ap ); |
| 103 | #pragma clang diagnostic pop | |
| 102 | 104 | #endif |
| 103 | 105 | va_end(ap); |
| 104 | 106 | return result; |
lib/libcxx/src/support/win32/support.cpp+8-3| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | // -*- C++ -*- | |
| 2 | 1 | //===----------------------------------------------------------------------===// |
| 3 | 2 | // |
| 4 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| ... | ... | @@ -24,7 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap ) |
| 24 | 23 | // Query the count required. |
| 25 | 24 | va_list ap_copy; |
| 26 | 25 | va_copy(ap_copy, ap); |
| 27 | int count = _vsnprintf( NULL, 0, format, ap_copy ); | |
| 26 | #pragma clang diagnostic push | |
| 27 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 28 | int count = vsnprintf( NULL, 0, format, ap_copy ); | |
| 29 | #pragma clang diagnostic pop | |
| 28 | 30 | va_end(ap_copy); |
| 29 | 31 | if (count < 0) |
| 30 | 32 | return count; |
| ... | ... | @@ -34,7 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap ) |
| 34 | 36 | return -1; |
| 35 | 37 | // If we haven't used exactly what was required, something is wrong. |
| 36 | 38 | // Maybe bug in vsnprintf. Report the error and return. |
| 37 | if (_vsnprintf(p, buffer_size, format, ap) != count) { | |
| 39 | #pragma clang diagnostic push | |
| 40 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 41 | if (vsnprintf(p, buffer_size, format, ap) != count) { | |
| 42 | #pragma clang diagnostic pop | |
| 38 | 43 | free(p); |
| 39 | 44 | return -1; |
| 40 | 45 | } |
lib/libcxx/src/support/win32/thread_win32.cpp-37| ... | ... | @@ -1,4 +1,3 @@ |
| 1 | // -*- C++ -*- | |
| 2 | 1 | //===----------------------------------------------------------------------===// |
| 3 | 2 | // |
| 4 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| ... | ... | @@ -39,9 +38,6 @@ static_assert(alignof(__libcpp_thread_t) == alignof(HANDLE), ""); |
| 39 | 38 | static_assert(sizeof(__libcpp_tls_key) == sizeof(DWORD), ""); |
| 40 | 39 | static_assert(alignof(__libcpp_tls_key) == alignof(DWORD), ""); |
| 41 | 40 | |
| 42 | static_assert(sizeof(__libcpp_semaphore_t) == sizeof(HANDLE), ""); | |
| 43 | static_assert(alignof(__libcpp_semaphore_t) == alignof(HANDLE), ""); | |
| 44 | ||
| 45 | 41 | // Mutex |
| 46 | 42 | int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m) |
| 47 | 43 | { |
| ... | ... | @@ -275,37 +271,4 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p) |
| 275 | 271 | return 0; |
| 276 | 272 | } |
| 277 | 273 | |
| 278 | // Semaphores | |
| 279 | bool __libcpp_semaphore_init(__libcpp_semaphore_t* __sem, int __init) | |
| 280 | { | |
| 281 | *(PHANDLE)__sem = CreateSemaphoreEx(nullptr, __init, _LIBCPP_SEMAPHORE_MAX, | |
| 282 | nullptr, 0, SEMAPHORE_ALL_ACCESS); | |
| 283 | return *__sem != nullptr; | |
| 284 | } | |
| 285 | ||
| 286 | bool __libcpp_semaphore_destroy(__libcpp_semaphore_t* __sem) | |
| 287 | { | |
| 288 | CloseHandle(*(PHANDLE)__sem); | |
| 289 | return true; | |
| 290 | } | |
| 291 | ||
| 292 | bool __libcpp_semaphore_post(__libcpp_semaphore_t* __sem) | |
| 293 | { | |
| 294 | return ReleaseSemaphore(*(PHANDLE)__sem, 1, nullptr); | |
| 295 | } | |
| 296 | ||
| 297 | bool __libcpp_semaphore_wait(__libcpp_semaphore_t* __sem) | |
| 298 | { | |
| 299 | return WaitForSingleObjectEx(*(PHANDLE)__sem, INFINITE, false) == | |
| 300 | WAIT_OBJECT_0; | |
| 301 | } | |
| 302 | ||
| 303 | bool __libcpp_semaphore_wait_timed(__libcpp_semaphore_t* __sem, | |
| 304 | chrono::nanoseconds const& __ns) | |
| 305 | { | |
| 306 | chrono::milliseconds __ms = chrono::ceil<chrono::milliseconds>(__ns); | |
| 307 | return WaitForSingleObjectEx(*(PHANDLE)__sem, __ms.count(), false) == | |
| 308 | WAIT_OBJECT_0; | |
| 309 | } | |
| 310 | ||
| 311 | 274 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/system_error.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===---------------------- system_error.cpp ------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/typeinfo.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- typeinfo.cpp -------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/utility.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ utility.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/valarray.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ valarray.cpp --------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/variant.cpp+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------ variant.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
lib/libcxx/src/vector.cpp+21-2| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | //===------------------------- vector.cpp ---------------------------------===// | |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | 2 | // |
| 3 | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | 4 | // See https://llvm.org/LICENSE.txt for license information. |
| ... | ... | @@ -10,6 +10,25 @@ |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | |
| 13 | template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __vector_base_common<true>; | |
| 13 | #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | |
| 14 | ||
| 15 | template <bool> | |
| 16 | struct __vector_base_common; | |
| 17 | ||
| 18 | template <> | |
| 19 | struct __vector_base_common<true> { | |
| 20 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; | |
| 21 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; | |
| 22 | }; | |
| 23 | ||
| 24 | void __vector_base_common<true>::__throw_length_error() const { | |
| 25 | _VSTD::__throw_length_error("vector"); | |
| 26 | } | |
| 27 | ||
| 28 | void __vector_base_common<true>::__throw_out_of_range() const { | |
| 29 | _VSTD::__throw_out_of_range("vector"); | |
| 30 | } | |
| 31 | ||
| 32 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | |
| 14 | 33 | |
| 15 | 34 | _LIBCPP_END_NAMESPACE_STD |
src/libcxx.zig+6| ... | ... | @@ -54,6 +54,7 @@ const libcxx_files = [_][]const u8{ |
| 54 | 54 | "src/ios.cpp", |
| 55 | 55 | "src/ios.instantiations.cpp", |
| 56 | 56 | "src/iostream.cpp", |
| 57 | "src/legacy_pointer_safety.cpp", | |
| 57 | 58 | "src/locale.cpp", |
| 58 | 59 | "src/memory.cpp", |
| 59 | 60 | "src/mutex.cpp", |
| ... | ... | @@ -63,10 +64,15 @@ const libcxx_files = [_][]const u8{ |
| 63 | 64 | "src/random.cpp", |
| 64 | 65 | "src/random_shuffle.cpp", |
| 65 | 66 | "src/regex.cpp", |
| 67 | "src/ryu/d2fixed.cpp", | |
| 68 | "src/ryu/d2s.cpp", | |
| 69 | "src/ryu/f2s.cpp", | |
| 66 | 70 | "src/shared_mutex.cpp", |
| 67 | 71 | "src/stdexcept.cpp", |
| 68 | 72 | "src/string.cpp", |
| 69 | 73 | "src/strstream.cpp", |
| 74 | "src/support/ibm/mbsnrtowcs.cpp", | |
| 75 | "src/support/ibm/wcsnrtombs.cpp", | |
| 70 | 76 | "src/support/ibm/xlocale_zos.cpp", |
| 71 | 77 | "src/support/solaris/xlocale.cpp", |
| 72 | 78 | "src/support/win32/locale_win32.cpp", |