| author | |
| committer | |
| log | 8278eb88376341420817f15791fe7c1715e04a4f |
| tree | 4195bafa4e21a5787cb3ada46bc0816d67d487dd |
| parent | ac5c6b6061c6454a891c22a8258069370b57c05b |
release/15.x commit 134fd359a5d884f16662a9edd22ab24feeb1498c841 files changed, 37007 insertions(+), 20860 deletions(-)
lib/libcxx/include/__algorithm/adjacent_find.h+21-13| ... | ... | @@ -11,34 +11,42 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_ADJACENT_FIND_H |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/move.h> | |
| 16 | 18 | |
| 17 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 19 | 21 | #endif |
| 20 | 22 | |
| 21 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 24 | |
| 25 | template <class _Iter, class _Sent, class _BinaryPredicate> | |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter | |
| 27 | __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | |
| 28 | if (__first == __last) | |
| 29 | return __first; | |
| 30 | _Iter __i = __first; | |
| 31 | while (++__i != __last) { | |
| 32 | if (__pred(*__first, *__i)) | |
| 33 | return __first; | |
| 34 | __first = __i; | |
| 35 | } | |
| 36 | return __i; | |
| 37 | } | |
| 38 | ||
| 23 | 39 | template <class _ForwardIterator, class _BinaryPredicate> |
| 24 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 40 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 25 | 41 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { |
| 26 | if (__first != __last) { | |
| 27 | _ForwardIterator __i = __first; | |
| 28 | while (++__i != __last) { | |
| 29 | if (__pred(*__first, *__i)) | |
| 30 | return __first; | |
| 31 | __first = __i; | |
| 32 | } | |
| 33 | } | |
| 34 | return __last; | |
| 42 | return std::__adjacent_find(std::move(__first), std::move(__last), __pred); | |
| 35 | 43 | } |
| 36 | 44 | |
| 37 | 45 | template <class _ForwardIterator> |
| 38 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 46 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 39 | 47 | adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { |
| 40 | 48 | typedef typename iterator_traits<_ForwardIterator>::value_type __v; |
| 41 | return _VSTD::adjacent_find(__first, __last, __equal_to<__v>()); | |
| 49 | return std::adjacent_find(std::move(__first), std::move(__last), __equal_to<__v>()); | |
| 42 | 50 | } |
| 43 | 51 | |
| 44 | 52 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/algorithm_family.h created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H | |
| 10 | #define _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/move.h> | |
| 14 | #include <__algorithm/ranges_move.h> | |
| 15 | #include <__config> | |
| 16 | #include <__utility/move.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _AlgPolicy> | |
| 25 | struct _AlgFamily; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | template <> | |
| 30 | struct _AlgFamily<_RangeAlgPolicy> { | |
| 31 | static constexpr auto __move = ranges::move; | |
| 32 | }; | |
| 33 | ||
| 34 | #endif | |
| 35 | ||
| 36 | template <> | |
| 37 | struct _AlgFamily<_ClassicAlgPolicy> { | |
| 38 | ||
| 39 | // move | |
| 40 | template <class _InputIterator, class _OutputIterator> | |
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 static _OutputIterator | |
| 42 | __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | |
| 43 | return std::move( | |
| 44 | std::move(__first), | |
| 45 | std::move(__last), | |
| 46 | std::move(__result)); | |
| 47 | } | |
| 48 | }; | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___ALGORITHM_ALGORITHM_FAMILY_H |
lib/libcxx/include/__algorithm/all_of.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/any_of.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/binary_search.h+8-16| ... | ... | @@ -16,38 +16,30 @@ |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | template <class _Compare, class _ForwardIterator, class _Tp> | |
| 25 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 26 | bool | |
| 27 | __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 28 | { | |
| 29 | __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp); | |
| 30 | return __first != __last && !__comp(__value_, *__first); | |
| 31 | } | |
| 32 | ||
| 33 | 24 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 34 | 25 | _LIBCPP_NODISCARD_EXT inline |
| 35 | 26 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 36 | 27 | bool |
| 37 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 28 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) | |
| 38 | 29 | { |
| 39 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 40 | return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp); | |
| 30 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; | |
| 31 | __first = std::lower_bound<_ForwardIterator, _Tp, _Comp_ref>(__first, __last, __value, __comp); | |
| 32 | return __first != __last && !__comp(__value, *__first); | |
| 41 | 33 | } |
| 42 | 34 | |
| 43 | 35 | template <class _ForwardIterator, class _Tp> |
| 44 | 36 | _LIBCPP_NODISCARD_EXT inline |
| 45 | 37 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 46 | 38 | bool |
| 47 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) | |
| 39 | binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | |
| 48 | 40 | { |
| 49 | return _VSTD::binary_search(__first, __last, __value_, | |
| 50 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | |
| 41 | return std::binary_search(__first, __last, __value, | |
| 42 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | |
| 51 | 43 | } |
| 52 | 44 | |
| 53 | 45 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/clamp.h+2-2| ... | ... | @@ -10,11 +10,11 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_CLAMP_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/comp.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/comp_ref_type.h+9-14| ... | ... | @@ -10,20 +10,15 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | ||
| 14 | #ifdef _LIBCPP_DEBUG | |
| 15 | # include <__debug> | |
| 16 | # include <__utility/declval.h> | |
| 17 | #endif | |
| 13 | #include <__debug> | |
| 14 | #include <__utility/declval.h> | |
| 18 | 15 | |
| 19 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 21 | 18 | #endif |
| 22 | 19 | |
| 23 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 21 | |
| 25 | #ifdef _LIBCPP_DEBUG | |
| 26 | ||
| 27 | 22 | template <class _Compare> |
| 28 | 23 | struct __debug_less |
| 29 | 24 | { |
| ... | ... | @@ -57,8 +52,10 @@ struct __debug_less |
| 57 | 52 | decltype((void)declval<_Compare&>()( |
| 58 | 53 | declval<_LHS &>(), declval<_RHS &>())) |
| 59 | 54 | __do_compare_assert(int, _LHS & __l, _RHS & __r) { |
| 60 | _LIBCPP_ASSERT(!__comp_(__l, __r), | |
| 55 | _LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r), | |
| 61 | 56 | "Comparator does not induce a strict weak ordering"); |
| 57 | (void)__l; | |
| 58 | (void)__r; | |
| 62 | 59 | } |
| 63 | 60 | |
| 64 | 61 | template <class _LHS, class _RHS> |
| ... | ... | @@ -67,16 +64,14 @@ struct __debug_less |
| 67 | 64 | void __do_compare_assert(long, _LHS &, _RHS &) {} |
| 68 | 65 | }; |
| 69 | 66 | |
| 70 | #endif // _LIBCPP_DEBUG | |
| 71 | ||
| 72 | 67 | template <class _Comp> |
| 73 | 68 | struct __comp_ref_type { |
| 74 | 69 | // Pass the comparator by lvalue reference. Or in debug mode, using a |
| 75 | 70 | // debugging wrapper that stores a reference. |
| 76 | #ifndef _LIBCPP_DEBUG | |
| 77 | typedef _Comp& type; | |
| 78 | #else | |
| 71 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 79 | 72 | typedef __debug_less<_Comp> type; |
| 73 | #else | |
| 74 | typedef _Comp& type; | |
| 80 | 75 | #endif |
| 81 | 76 | }; |
| 82 | 77 |
lib/libcxx/include/__algorithm/copy.h+70-39| ... | ... | @@ -10,66 +10,97 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | #include <__algorithm/unwrap_range.h> | |
| 13 | 14 | #include <__config> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <__iterator/reverse_iterator.h> | |
| 17 | #include <__utility/move.h> | |
| 18 | #include <__utility/pair.h> | |
| 15 | 19 | #include <cstring> |
| 16 | 20 | #include <type_traits> |
| 17 | 21 | |
| 18 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 20 | 24 | #endif |
| 21 | 25 | |
| 22 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 27 | |
| 24 | 28 | // copy |
| 25 | 29 | |
| 26 | template <class _InputIterator, class _OutputIterator> | |
| 27 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 28 | _OutputIterator | |
| 29 | __copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 30 | { | |
| 31 | for (; __first != __last; ++__first, (void) ++__result) | |
| 32 | *__result = *__first; | |
| 33 | return __result; | |
| 30 | template <class _InIter, class _Sent, class _OutIter> | |
| 31 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 32 | pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __result) { | |
| 33 | while (__first != __last) { | |
| 34 | *__result = *__first; | |
| 35 | ++__first; | |
| 36 | ++__result; | |
| 37 | } | |
| 38 | return pair<_InIter, _OutIter>(std::move(__first), std::move(__result)); | |
| 34 | 39 | } |
| 35 | 40 | |
| 36 | template <class _InputIterator, class _OutputIterator> | |
| 37 | inline _LIBCPP_INLINE_VISIBILITY | |
| 38 | _OutputIterator | |
| 39 | __copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 40 | { | |
| 41 | return _VSTD::__copy_constexpr(__first, __last, __result); | |
| 41 | template <class _InValueT, | |
| 42 | class _OutValueT, | |
| 43 | class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value | |
| 44 | && is_trivially_copy_assignable<_OutValueT>::value> > | |
| 45 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 46 | pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) { | |
| 47 | if (__libcpp_is_constant_evaluated() | |
| 48 | // TODO: Remove this once GCC supports __builtin_memmove during constant evaluation | |
| 49 | #ifndef _LIBCPP_COMPILER_GCC | |
| 50 | && !is_trivially_copyable<_InValueT>::value | |
| 51 | #endif | |
| 52 | ) | |
| 53 | return std::__copy_impl<_InValueT*, _InValueT*, _OutValueT*>(__first, __last, __result); | |
| 54 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 55 | if (__n > 0) | |
| 56 | ::__builtin_memmove(__result, __first, __n * sizeof(_OutValueT)); | |
| 57 | return std::make_pair(__first + __n, __result + __n); | |
| 58 | } | |
| 59 | ||
| 60 | template <class _InIter, class _OutIter, | |
| 61 | __enable_if_t<is_same<typename remove_const<__iter_value_type<_InIter> >::type, __iter_value_type<_OutIter> >::value | |
| 62 | && __is_cpp17_contiguous_iterator<typename _InIter::iterator_type>::value | |
| 63 | && __is_cpp17_contiguous_iterator<typename _OutIter::iterator_type>::value | |
| 64 | && is_trivially_copy_assignable<__iter_value_type<_OutIter> >::value | |
| 65 | && __is_reverse_iterator<_InIter>::value | |
| 66 | && __is_reverse_iterator<_OutIter>::value, int> = 0> | |
| 67 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 68 | pair<_InIter, _OutIter> | |
| 69 | __copy_impl(_InIter __first, _InIter __last, _OutIter __result) { | |
| 70 | auto __first_base = std::__unwrap_iter(__first.base()); | |
| 71 | auto __last_base = std::__unwrap_iter(__last.base()); | |
| 72 | auto __result_base = std::__unwrap_iter(__result.base()); | |
| 73 | auto __result_first = __result_base - (__first_base - __last_base); | |
| 74 | std::__copy_impl(__last_base, __first_base, __result_first); | |
| 75 | return std::make_pair(__last, _OutIter(std::__rewrap_iter(__result.base(), __result_first))); | |
| 76 | } | |
| 77 | ||
| 78 | template <class _InIter, class _Sent, class _OutIter, | |
| 79 | __enable_if_t<!(is_copy_constructible<_InIter>::value | |
| 80 | && is_copy_constructible<_Sent>::value | |
| 81 | && is_copy_constructible<_OutIter>::value), int> = 0 > | |
| 82 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 83 | pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) { | |
| 84 | return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result)); | |
| 42 | 85 | } |
| 43 | 86 | |
| 44 | template <class _Tp, class _Up> | |
| 45 | inline _LIBCPP_INLINE_VISIBILITY | |
| 46 | typename enable_if | |
| 47 | < | |
| 48 | is_same<typename remove_const<_Tp>::type, _Up>::value && | |
| 49 | is_trivially_copy_assignable<_Up>::value, | |
| 50 | _Up* | |
| 51 | >::type | |
| 52 | __copy(_Tp* __first, _Tp* __last, _Up* __result) | |
| 53 | { | |
| 54 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 55 | if (__n > 0) | |
| 56 | _VSTD::memmove(__result, __first, __n * sizeof(_Up)); | |
| 57 | return __result + __n; | |
| 87 | template <class _InIter, class _Sent, class _OutIter, | |
| 88 | __enable_if_t<is_copy_constructible<_InIter>::value | |
| 89 | && is_copy_constructible<_Sent>::value | |
| 90 | && is_copy_constructible<_OutIter>::value, int> = 0> | |
| 91 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 92 | pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) { | |
| 93 | auto __range = std::__unwrap_range(__first, __last); | |
| 94 | auto __ret = std::__copy_impl(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__result)); | |
| 95 | return std::make_pair( | |
| 96 | std::__rewrap_range<_Sent>(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); | |
| 58 | 97 | } |
| 59 | 98 | |
| 60 | 99 | template <class _InputIterator, class _OutputIterator> |
| 61 | 100 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 62 | 101 | _OutputIterator |
| 63 | copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 64 | { | |
| 65 | if (__libcpp_is_constant_evaluated()) { | |
| 66 | return _VSTD::__copy_constexpr(__first, __last, __result); | |
| 67 | } else { | |
| 68 | return _VSTD::__rewrap_iter(__result, | |
| 69 | _VSTD::__copy(_VSTD::__unwrap_iter(__first), | |
| 70 | _VSTD::__unwrap_iter(__last), | |
| 71 | _VSTD::__unwrap_iter(__result))); | |
| 72 | } | |
| 102 | copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | |
| 103 | return std::__copy(__first, __last, __result).second; | |
| 73 | 104 | } |
| 74 | 105 | |
| 75 | 106 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/copy_backward.h+29-47| ... | ... | @@ -9,69 +9,51 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
| 11 | 11 | |
| 12 | #include <__algorithm/copy.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__algorithm/ranges_copy.h> | |
| 12 | 15 | #include <__algorithm/unwrap_iter.h> |
| 16 | #include <__concepts/same_as.h> | |
| 13 | 17 | #include <__config> |
| 14 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__iterator/reverse_iterator.h> | |
| 20 | #include <__ranges/subrange.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | #include <__utility/pair.h> | |
| 15 | 23 | #include <cstring> |
| 16 | 24 | #include <type_traits> |
| 17 | 25 | |
| 18 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 27 | # pragma GCC system_header | |
| 20 | 28 | #endif |
| 21 | 29 | |
| 22 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 31 | |
| 24 | template <class _BidirectionalIterator, class _OutputIterator> | |
| 25 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 26 | _OutputIterator | |
| 27 | __copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) | |
| 28 | { | |
| 29 | while (__first != __last) | |
| 30 | *--__result = *--__last; | |
| 31 | return __result; | |
| 32 | template <class _AlgPolicy, class _InputIterator, class _OutputIterator, | |
| 33 | __enable_if_t<is_same<_AlgPolicy, _ClassicAlgPolicy>::value, int> = 0> | |
| 34 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_InputIterator, _OutputIterator> | |
| 35 | __copy_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | |
| 36 | auto __ret = std::__copy( | |
| 37 | __unconstrained_reverse_iterator<_InputIterator>(__last), | |
| 38 | __unconstrained_reverse_iterator<_InputIterator>(__first), | |
| 39 | __unconstrained_reverse_iterator<_OutputIterator>(__result)); | |
| 40 | return pair<_InputIterator, _OutputIterator>(__ret.first.base(), __ret.second.base()); | |
| 32 | 41 | } |
| 33 | 42 | |
| 34 | template <class _BidirectionalIterator, class _OutputIterator> | |
| 35 | inline _LIBCPP_INLINE_VISIBILITY | |
| 36 | _OutputIterator | |
| 37 | __copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) | |
| 38 | { | |
| 39 | return _VSTD::__copy_backward_constexpr(__first, __last, __result); | |
| 40 | } | |
| 41 | ||
| 42 | template <class _Tp, class _Up> | |
| 43 | inline _LIBCPP_INLINE_VISIBILITY | |
| 44 | typename enable_if | |
| 45 | < | |
| 46 | is_same<typename remove_const<_Tp>::type, _Up>::value && | |
| 47 | is_trivially_copy_assignable<_Up>::value, | |
| 48 | _Up* | |
| 49 | >::type | |
| 50 | __copy_backward(_Tp* __first, _Tp* __last, _Up* __result) | |
| 51 | { | |
| 52 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 53 | if (__n > 0) | |
| 54 | { | |
| 55 | __result -= __n; | |
| 56 | _VSTD::memmove(__result, __first, __n * sizeof(_Up)); | |
| 57 | } | |
| 58 | return __result; | |
| 43 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 44 | template <class _AlgPolicy, class _Iter1, class _Sent1, class _Iter2, | |
| 45 | __enable_if_t<is_same<_AlgPolicy, _RangeAlgPolicy>::value, int> = 0> | |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) { | |
| 47 | auto __reverse_range = std::__reverse_range(std::ranges::subrange(std::move(__first), std::move(__last))); | |
| 48 | auto __ret = ranges::copy(std::move(__reverse_range), std::make_reverse_iterator(__result)); | |
| 49 | return std::make_pair(__ret.in.base(), __ret.out.base()); | |
| 59 | 50 | } |
| 51 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 60 | 52 | |
| 61 | 53 | template <class _BidirectionalIterator1, class _BidirectionalIterator2> |
| 62 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 63 | _BidirectionalIterator2 | |
| 64 | copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, | |
| 65 | _BidirectionalIterator2 __result) | |
| 66 | { | |
| 67 | if (__libcpp_is_constant_evaluated()) { | |
| 68 | return _VSTD::__copy_backward_constexpr(__first, __last, __result); | |
| 69 | } else { | |
| 70 | return _VSTD::__rewrap_iter(__result, | |
| 71 | _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first), | |
| 72 | _VSTD::__unwrap_iter(__last), | |
| 73 | _VSTD::__unwrap_iter(__result))); | |
| 74 | } | |
| 54 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator2 | |
| 55 | copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) { | |
| 56 | return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result).second; | |
| 75 | 57 | } |
| 76 | 58 | |
| 77 | 59 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/copy_if.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/copy_n.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/count.h+3-3| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -22,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | template <class _InputIterator, class _Tp> |
| 23 | 23 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 24 | 24 | typename iterator_traits<_InputIterator>::difference_type |
| 25 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { | |
| 25 | count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | |
| 26 | 26 | typename iterator_traits<_InputIterator>::difference_type __r(0); |
| 27 | 27 | for (; __first != __last; ++__first) |
| 28 | if (*__first == __value_) | |
| 28 | if (*__first == __value) | |
| 29 | 29 | ++__r; |
| 30 | 30 | return __r; |
| 31 | 31 | } |
lib/libcxx/include/__algorithm/count_if.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/equal.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/equal_range.h+49-47| ... | ... | @@ -12,69 +12,71 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/half_positive.h> |
| 15 | #include <__algorithm/iterator_operations.h> | |
| 15 | 16 | #include <__algorithm/lower_bound.h> |
| 16 | 17 | #include <__algorithm/upper_bound.h> |
| 17 | 18 | #include <__config> |
| 18 | #include <iterator> | |
| 19 | #include <__functional/identity.h> | |
| 20 | #include <__functional/invoke.h> | |
| 21 | #include <__iterator/advance.h> | |
| 22 | #include <__iterator/distance.h> | |
| 23 | #include <__iterator/iterator_traits.h> | |
| 24 | #include <__iterator/next.h> | |
| 25 | #include <__type_traits/is_callable.h> | |
| 26 | #include <__type_traits/is_copy_constructible.h> | |
| 27 | #include <__utility/move.h> | |
| 28 | #include <__utility/pair.h> | |
| 19 | 29 | |
| 20 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 31 | # pragma GCC system_header | |
| 22 | 32 | #endif |
| 23 | 33 | |
| 24 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 35 | |
| 26 | template <class _Compare, class _ForwardIterator, class _Tp> | |
| 27 | _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> | |
| 28 | __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 29 | { | |
| 30 | typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; | |
| 31 | difference_type __len = _VSTD::distance(__first, __last); | |
| 32 | while (__len != 0) | |
| 33 | { | |
| 34 | difference_type __l2 = _VSTD::__half_positive(__len); | |
| 35 | _ForwardIterator __m = __first; | |
| 36 | _VSTD::advance(__m, __l2); | |
| 37 | if (__comp(*__m, __value_)) | |
| 38 | { | |
| 39 | __first = ++__m; | |
| 40 | __len -= __l2 + 1; | |
| 41 | } | |
| 42 | else if (__comp(__value_, *__m)) | |
| 43 | { | |
| 44 | __last = __m; | |
| 45 | __len = __l2; | |
| 46 | } | |
| 47 | else | |
| 48 | { | |
| 49 | _ForwardIterator __mp1 = __m; | |
| 50 | return pair<_ForwardIterator, _ForwardIterator> | |
| 51 | ( | |
| 52 | _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp), | |
| 53 | _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp) | |
| 54 | ); | |
| 55 | } | |
| 36 | template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj> | |
| 37 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_Iter, _Iter> | |
| 38 | __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) { | |
| 39 | auto __len = _IterOps<_AlgPolicy>::distance(__first, __last); | |
| 40 | _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last); | |
| 41 | while (__len != 0) { | |
| 42 | auto __half_len = std::__half_positive(__len); | |
| 43 | _Iter __mid = _IterOps<_AlgPolicy>::next(__first, __half_len); | |
| 44 | if (std::__invoke(__comp, std::__invoke(__proj, *__mid), __value)) { | |
| 45 | __first = ++__mid; | |
| 46 | __len -= __half_len + 1; | |
| 47 | } else if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid))) { | |
| 48 | __end = __mid; | |
| 49 | __len = __half_len; | |
| 50 | } else { | |
| 51 | _Iter __mp1 = __mid; | |
| 52 | return pair<_Iter, _Iter>( | |
| 53 | std::__lower_bound_impl<_AlgPolicy>(__first, __mid, __value, __comp, __proj), | |
| 54 | std::__upper_bound<_AlgPolicy>(++__mp1, __end, __value, __comp, __proj)); | |
| 56 | 55 | } |
| 57 | return pair<_ForwardIterator, _ForwardIterator>(__first, __first); | |
| 56 | } | |
| 57 | return pair<_Iter, _Iter>(__first, __first); | |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 61 | _LIBCPP_NODISCARD_EXT inline | |
| 62 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 63 | pair<_ForwardIterator, _ForwardIterator> | |
| 64 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 65 | { | |
| 66 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 67 | return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp); | |
| 61 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> | |
| 62 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | |
| 63 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, | |
| 64 | "The comparator has to be callable"); | |
| 65 | static_assert(is_copy_constructible<_ForwardIterator>::value, | |
| 66 | "Iterator has to be copy constructible"); | |
| 67 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 68 | return std::__equal_range<_ClassicAlgPolicy>( | |
| 69 | std::move(__first), std::move(__last), __value, static_cast<_Comp_ref>(__comp), std::__identity()); | |
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | template <class _ForwardIterator, class _Tp> |
| 71 | _LIBCPP_NODISCARD_EXT inline | |
| 72 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 73 | pair<_ForwardIterator, _ForwardIterator> | |
| 74 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) | |
| 75 | { | |
| 76 | return _VSTD::equal_range(__first, __last, __value_, | |
| 77 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | |
| 73 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> | |
| 74 | equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | |
| 75 | return std::equal_range( | |
| 76 | std::move(__first), | |
| 77 | std::move(__last), | |
| 78 | __value, | |
| 79 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | |
| 78 | 80 | } |
| 79 | 81 | |
| 80 | 82 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/fill.h+9-7| ... | ... | @@ -15,34 +15,36 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | // fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | |
| 24 | ||
| 23 | 25 | template <class _ForwardIterator, class _Tp> |
| 24 | 26 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 25 | 27 | void |
| 26 | __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag) | |
| 28 | __fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag) | |
| 27 | 29 | { |
| 28 | 30 | for (; __first != __last; ++__first) |
| 29 | *__first = __value_; | |
| 31 | *__first = __value; | |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | 34 | template <class _RandomAccessIterator, class _Tp> |
| 33 | 35 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 34 | 36 | void |
| 35 | __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag) | |
| 37 | __fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag) | |
| 36 | 38 | { |
| 37 | _VSTD::fill_n(__first, __last - __first, __value_); | |
| 39 | _VSTD::fill_n(__first, __last - __first, __value); | |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | 42 | template <class _ForwardIterator, class _Tp> |
| 41 | 43 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 42 | 44 | void |
| 43 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) | |
| 45 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | |
| 44 | 46 | { |
| 45 | _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 47 | _VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 46 | 48 | } |
| 47 | 49 | |
| 48 | 50 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/fill_n.h+7-5| ... | ... | @@ -14,27 +14,29 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | // fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | |
| 23 | ||
| 22 | 24 | template <class _OutputIterator, class _Size, class _Tp> |
| 23 | 25 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 24 | 26 | _OutputIterator |
| 25 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) | |
| 27 | __fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) | |
| 26 | 28 | { |
| 27 | 29 | for (; __n > 0; ++__first, (void) --__n) |
| 28 | *__first = __value_; | |
| 30 | *__first = __value; | |
| 29 | 31 | return __first; |
| 30 | 32 | } |
| 31 | 33 | |
| 32 | 34 | template <class _OutputIterator, class _Size, class _Tp> |
| 33 | 35 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 34 | 36 | _OutputIterator |
| 35 | fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) | |
| 37 | fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) | |
| 36 | 38 | { |
| 37 | return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_); | |
| 39 | return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value); | |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | 42 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/find.h+3-3| ... | ... | @@ -13,16 +13,16 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | 21 | template <class _InputIterator, class _Tp> |
| 22 | 22 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator |
| 23 | find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { | |
| 23 | find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | |
| 24 | 24 | for (; __first != __last; ++__first) |
| 25 | if (*__first == __value_) | |
| 25 | if (*__first == __value) | |
| 26 | 26 | break; |
| 27 | 27 | return __first; |
| 28 | 28 | } |
lib/libcxx/include/__algorithm/find_end.h+131-52| ... | ... | @@ -11,44 +11,69 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_FIND_END_OF_H |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | #include <__algorithm/search.h> | |
| 14 | 16 | #include <__config> |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__iterator/advance.h> | |
| 15 | 19 | #include <__iterator/iterator_traits.h> |
| 20 | #include <__iterator/next.h> | |
| 21 | #include <__iterator/reverse_iterator.h> | |
| 22 | #include <__utility/pair.h> | |
| 23 | #include <type_traits> | |
| 16 | 24 | |
| 17 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 19 | 27 | #endif |
| 20 | 28 | |
| 21 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 30 | |
| 23 | template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2> | |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 25 | _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 26 | _BinaryPredicate __pred, forward_iterator_tag, | |
| 27 | forward_iterator_tag) { | |
| 31 | template < | |
| 32 | class _AlgPolicy, | |
| 33 | class _Iter1, | |
| 34 | class _Sent1, | |
| 35 | class _Iter2, | |
| 36 | class _Sent2, | |
| 37 | class _Pred, | |
| 38 | class _Proj1, | |
| 39 | class _Proj2> | |
| 40 | _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_Iter1, _Iter1> __find_end_impl( | |
| 41 | _Iter1 __first1, | |
| 42 | _Sent1 __last1, | |
| 43 | _Iter2 __first2, | |
| 44 | _Sent2 __last2, | |
| 45 | _Pred& __pred, | |
| 46 | _Proj1& __proj1, | |
| 47 | _Proj2& __proj2, | |
| 48 | forward_iterator_tag, | |
| 49 | forward_iterator_tag) { | |
| 28 | 50 | // modeled after search algorithm |
| 29 | _ForwardIterator1 __r = __last1; // __last1 is the "default" answer | |
| 51 | _Iter1 __match_first = _IterOps<_AlgPolicy>::next(__first1, __last1); // __last1 is the "default" answer | |
| 52 | _Iter1 __match_last = __match_first; | |
| 30 | 53 | if (__first2 == __last2) |
| 31 | return __r; | |
| 54 | return pair<_Iter1, _Iter1>(__match_last, __match_last); | |
| 32 | 55 | while (true) { |
| 33 | 56 | while (true) { |
| 34 | if (__first1 == __last1) // if source exhausted return last correct answer | |
| 35 | return __r; // (or __last1 if never found) | |
| 36 | if (__pred(*__first1, *__first2)) | |
| 57 | if (__first1 == __last1) // if source exhausted return last correct answer (or __last1 if never found) | |
| 58 | return pair<_Iter1, _Iter1>(__match_first, __match_last); | |
| 59 | if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | |
| 37 | 60 | break; |
| 38 | 61 | ++__first1; |
| 39 | 62 | } |
| 40 | 63 | // *__first1 matches *__first2, now match elements after here |
| 41 | _ForwardIterator1 __m1 = __first1; | |
| 42 | _ForwardIterator2 __m2 = __first2; | |
| 64 | _Iter1 __m1 = __first1; | |
| 65 | _Iter2 __m2 = __first2; | |
| 43 | 66 | while (true) { |
| 44 | 67 | if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one |
| 45 | __r = __first1; | |
| 68 | __match_first = __first1; | |
| 69 | __match_last = ++__m1; | |
| 46 | 70 | ++__first1; |
| 47 | 71 | break; |
| 48 | 72 | } |
| 49 | 73 | if (++__m1 == __last1) // Source exhausted, return last answer |
| 50 | return __r; | |
| 51 | if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first | |
| 74 | return pair<_Iter1, _Iter1>(__match_first, __match_last); | |
| 75 | // mismatch, restart with a new __first | |
| 76 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2))) | |
| 52 | 77 | { |
| 53 | 78 | ++__first1; |
| 54 | 79 | break; |
| ... | ... | @@ -57,33 +82,52 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __f |
| 57 | 82 | } |
| 58 | 83 | } |
| 59 | 84 | |
| 60 | template <class _BinaryPredicate, class _BidirectionalIterator1, class _BidirectionalIterator2> | |
| 61 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end( | |
| 62 | _BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, | |
| 63 | _BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) { | |
| 85 | template < | |
| 86 | class _IterOps, | |
| 87 | class _Pred, | |
| 88 | class _Iter1, | |
| 89 | class _Sent1, | |
| 90 | class _Iter2, | |
| 91 | class _Sent2, | |
| 92 | class _Proj1, | |
| 93 | class _Proj2> | |
| 94 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1 __find_end( | |
| 95 | _Iter1 __first1, | |
| 96 | _Sent1 __sent1, | |
| 97 | _Iter2 __first2, | |
| 98 | _Sent2 __sent2, | |
| 99 | _Pred& __pred, | |
| 100 | _Proj1& __proj1, | |
| 101 | _Proj2& __proj2, | |
| 102 | bidirectional_iterator_tag, | |
| 103 | bidirectional_iterator_tag) { | |
| 104 | auto __last1 = _IterOps::next(__first1, __sent1); | |
| 105 | auto __last2 = _IterOps::next(__first2, __sent2); | |
| 64 | 106 | // modeled after search algorithm (in reverse) |
| 65 | 107 | if (__first2 == __last2) |
| 66 | 108 | return __last1; // Everything matches an empty sequence |
| 67 | _BidirectionalIterator1 __l1 = __last1; | |
| 68 | _BidirectionalIterator2 __l2 = __last2; | |
| 109 | _Iter1 __l1 = __last1; | |
| 110 | _Iter2 __l2 = __last2; | |
| 69 | 111 | --__l2; |
| 70 | 112 | while (true) { |
| 71 | 113 | // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks |
| 72 | 114 | while (true) { |
| 73 | 115 | if (__first1 == __l1) // return __last1 if no element matches *__first2 |
| 74 | 116 | return __last1; |
| 75 | if (__pred(*--__l1, *__l2)) | |
| 117 | if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | |
| 76 | 118 | break; |
| 77 | 119 | } |
| 78 | 120 | // *__l1 matches *__l2, now match elements before here |
| 79 | _BidirectionalIterator1 __m1 = __l1; | |
| 80 | _BidirectionalIterator2 __m2 = __l2; | |
| 121 | _Iter1 __m1 = __l1; | |
| 122 | _Iter2 __m2 = __l2; | |
| 81 | 123 | while (true) { |
| 82 | 124 | if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) |
| 83 | 125 | return __m1; |
| 84 | 126 | if (__m1 == __first1) // Otherwise if source exhaused, pattern not found |
| 85 | 127 | return __last1; |
| 86 | if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1 | |
| 128 | ||
| 129 | // if there is a mismatch, restart with a new __l1 | |
| 130 | if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) | |
| 87 | 131 | { |
| 88 | 132 | break; |
| 89 | 133 | } // else there is a match, check next elements |
| ... | ... | @@ -91,37 +135,53 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end( |
| 91 | 135 | } |
| 92 | 136 | } |
| 93 | 137 | |
| 94 | template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2> | |
| 95 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end( | |
| 96 | _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, | |
| 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; | |
| 138 | template < | |
| 139 | class _AlgPolicy, | |
| 140 | class _Pred, | |
| 141 | class _Iter1, | |
| 142 | class _Sent1, | |
| 143 | class _Iter2, | |
| 144 | class _Sent2, | |
| 145 | class _Proj1, | |
| 146 | class _Proj2> | |
| 147 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _Iter1 __find_end( | |
| 148 | _Iter1 __first1, | |
| 149 | _Sent1 __sent1, | |
| 150 | _Iter2 __first2, | |
| 151 | _Sent2 __sent2, | |
| 152 | _Pred& __pred, | |
| 153 | _Proj1& __proj1, | |
| 154 | _Proj2& __proj2, | |
| 155 | random_access_iterator_tag, | |
| 156 | random_access_iterator_tag) { | |
| 157 | typedef typename iterator_traits<_Iter1>::difference_type _D1; | |
| 158 | auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1); | |
| 159 | auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2); | |
| 100 | 160 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern |
| 101 | _D2 __len2 = __last2 - __first2; | |
| 161 | auto __len2 = __last2 - __first2; | |
| 102 | 162 | if (__len2 == 0) |
| 103 | 163 | return __last1; |
| 104 | _D1 __len1 = __last1 - __first1; | |
| 164 | auto __len1 = __last1 - __first1; | |
| 105 | 165 | if (__len1 < __len2) |
| 106 | 166 | return __last1; |
| 107 | const _RandomAccessIterator1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here | |
| 108 | _RandomAccessIterator1 __l1 = __last1; | |
| 109 | _RandomAccessIterator2 __l2 = __last2; | |
| 167 | const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here | |
| 168 | _Iter1 __l1 = __last1; | |
| 169 | _Iter2 __l2 = __last2; | |
| 110 | 170 | --__l2; |
| 111 | 171 | while (true) { |
| 112 | 172 | while (true) { |
| 113 | 173 | if (__s == __l1) |
| 114 | 174 | return __last1; |
| 115 | if (__pred(*--__l1, *__l2)) | |
| 175 | if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | |
| 116 | 176 | break; |
| 117 | 177 | } |
| 118 | _RandomAccessIterator1 __m1 = __l1; | |
| 119 | _RandomAccessIterator2 __m2 = __l2; | |
| 178 | _Iter1 __m1 = __l1; | |
| 179 | _Iter2 __m2 = __l2; | |
| 120 | 180 | while (true) { |
| 121 | 181 | if (__m2 == __first2) |
| 122 | 182 | return __m1; |
| 123 | 183 | // no need to check range on __m1 because __s guarantees we have enough source |
| 124 | if (!__pred(*--__m1, *--__m2)) { | |
| 184 | if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) { | |
| 125 | 185 | break; |
| 126 | 186 | } |
| 127 | 187 | } |
| ... | ... | @@ -129,20 +189,39 @@ _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end( |
| 129 | 189 | } |
| 130 | 190 | |
| 131 | 191 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 132 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 | |
| 133 | find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 134 | _BinaryPredicate __pred) { | |
| 135 | return _VSTD::__find_end<_BinaryPredicate&>( | |
| 136 | __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), | |
| 137 | typename iterator_traits<_ForwardIterator2>::iterator_category()); | |
| 192 | _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 193 | _ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 194 | _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 195 | _BinaryPredicate& __pred) { | |
| 196 | auto __proj = __identity(); | |
| 197 | return std::__find_end_impl<_ClassicAlgPolicy>( | |
| 198 | __first1, | |
| 199 | __last1, | |
| 200 | __first2, | |
| 201 | __last2, | |
| 202 | __pred, | |
| 203 | __proj, | |
| 204 | __proj, | |
| 205 | typename iterator_traits<_ForwardIterator1>::iterator_category(), | |
| 206 | typename iterator_traits<_ForwardIterator2>::iterator_category()) | |
| 207 | .first; | |
| 208 | } | |
| 209 | ||
| 210 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | |
| 211 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 212 | _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 213 | _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 214 | _BinaryPredicate __pred) { | |
| 215 | return std::__find_end_classic(__first1, __last1, __first2, __last2, __pred); | |
| 138 | 216 | } |
| 139 | 217 | |
| 140 | 218 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 141 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 | |
| 142 | find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | |
| 143 | typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; | |
| 144 | typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; | |
| 145 | return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); | |
| 219 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 220 | _ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 221 | _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | |
| 222 | using __v1 = typename iterator_traits<_ForwardIterator1>::value_type; | |
| 223 | using __v2 = typename iterator_traits<_ForwardIterator2>::value_type; | |
| 224 | return std::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); | |
| 146 | 225 | } |
| 147 | 226 | |
| 148 | 227 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/find_first_of.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/find_if.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/find_if_not.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/for_each.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/for_each_n.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/generate.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/generate_n.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/half_positive.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/in_found_result.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H | |
| 12 | ||
| 13 | #include <__concepts/convertible_to.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/move.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | template <class _InIter1> | |
| 27 | struct in_found_result { | |
| 28 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | |
| 29 | bool found; | |
| 30 | ||
| 31 | template <class _InIter2> | |
| 32 | requires convertible_to<const _InIter1&, _InIter2> | |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() const & { | |
| 34 | return {in, found}; | |
| 35 | } | |
| 36 | ||
| 37 | template <class _InIter2> | |
| 38 | requires convertible_to<_InIter1, _InIter2> | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() && { | |
| 40 | return {std::move(in), found}; | |
| 41 | } | |
| 42 | }; | |
| 43 | } // namespace ranges | |
| 44 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | |
| 46 | ||
| 47 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 48 | ||
| 49 | #endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H |
lib/libcxx/include/__algorithm/in_fun_result.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ALGORITHM_IN_FUN_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_IN_FUN_RESULT_H | |
| 12 | ||
| 13 | #include <__concepts/convertible_to.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/move.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | template <class _InIter1, class _Func1> | |
| 27 | struct in_fun_result { | |
| 28 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | |
| 29 | _LIBCPP_NO_UNIQUE_ADDRESS _Func1 fun; | |
| 30 | ||
| 31 | template <class _InIter2, class _Func2> | |
| 32 | requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _Func1&, _Func2> | |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() const & { | |
| 34 | return {in, fun}; | |
| 35 | } | |
| 36 | ||
| 37 | template <class _InIter2, class _Func2> | |
| 38 | requires convertible_to<_InIter1, _InIter2> && convertible_to<_Func1, _Func2> | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() && { | |
| 40 | return {std::move(in), std::move(fun)}; | |
| 41 | } | |
| 42 | }; | |
| 43 | } // namespace ranges | |
| 44 | ||
| 45 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 46 | ||
| 47 | _LIBCPP_END_NAMESPACE_STD | |
| 48 | ||
| 49 | #endif // _LIBCPP___ALGORITHM_IN_FUN_RESULT_H |
lib/libcxx/include/__algorithm/in_in_out_result.h+16-14| ... | ... | @@ -15,39 +15,41 @@ |
| 15 | 15 | #include <__utility/move.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | 24 | |
| 25 | 25 | namespace ranges { |
| 26 | 26 | |
| 27 | template <class _I1, class _I2, class _O1> | |
| 27 | template <class _InIter1, class _InIter2, class _OutIter1> | |
| 28 | 28 | struct in_in_out_result { |
| 29 | [[no_unique_address]] _I1 in1; | |
| 30 | [[no_unique_address]] _I2 in2; | |
| 31 | [[no_unique_address]] _O1 out; | |
| 29 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1; | |
| 30 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2; | |
| 31 | _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out; | |
| 32 | 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> | |
| 33 | template <class _InIter3, class _InIter4, class _OutIter2> | |
| 34 | requires convertible_to<const _InIter1&, _InIter3> | |
| 35 | && convertible_to<const _InIter2&, _InIter4> && convertible_to<const _OutIter1&, _OutIter2> | |
| 35 | 36 | _LIBCPP_HIDE_FROM_ABI constexpr |
| 36 | operator in_in_out_result<_II1, _II2, _OO1>() const& { | |
| 37 | operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() const& { | |
| 37 | 38 | return {in1, in2, out}; |
| 38 | 39 | } |
| 39 | 40 | |
| 40 | template <class _II1, class _II2, class _OO1> | |
| 41 | requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> && convertible_to<_O1, _OO1> | |
| 41 | template <class _InIter3, class _InIter4, class _OutIter2> | |
| 42 | requires convertible_to<_InIter1, _InIter3> | |
| 43 | && convertible_to<_InIter2, _InIter4> && convertible_to<_OutIter1, _OutIter2> | |
| 42 | 44 | _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 | operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() && { | |
| 46 | return {std::move(in1), std::move(in2), std::move(out)}; | |
| 45 | 47 | } |
| 46 | 48 | }; |
| 47 | 49 | |
| 48 | 50 | } // namespace ranges |
| 49 | 51 | |
| 50 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 52 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 51 | 53 | |
| 52 | 54 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 55 |
lib/libcxx/include/__algorithm/in_in_result.h+14-12| ... | ... | @@ -15,36 +15,38 @@ |
| 15 | 15 | #include <__utility/move.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | 24 | |
| 25 | 25 | namespace ranges { |
| 26 | 26 | |
| 27 | template <class _I1, class _I2> | |
| 27 | template <class _InIter1, class _InIter2> | |
| 28 | 28 | struct in_in_result { |
| 29 | [[no_unique_address]] _I1 in1; | |
| 30 | [[no_unique_address]] _I2 in2; | |
| 29 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1; | |
| 30 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2; | |
| 31 | 31 | |
| 32 | template <class _II1, class _II2> | |
| 33 | requires convertible_to<const _I1&, _II1> && convertible_to<const _I2&, _II2> | |
| 32 | template <class _InIter3, class _InIter4> | |
| 33 | requires convertible_to<const _InIter1&, _InIter3> && convertible_to<const _InIter2&, _InIter4> | |
| 34 | 34 | _LIBCPP_HIDE_FROM_ABI constexpr |
| 35 | operator in_in_result<_II1, _II2>() const & { | |
| 35 | operator in_in_result<_InIter3, _InIter4>() const & { | |
| 36 | 36 | return {in1, in2}; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | template <class _II1, class _II2> | |
| 40 | requires convertible_to<_I1, _II1> && convertible_to<_I2, _II2> | |
| 39 | template <class _InIter3, class _InIter4> | |
| 40 | requires convertible_to<_InIter1, _InIter3> && convertible_to<_InIter2, _InIter4> | |
| 41 | 41 | _LIBCPP_HIDE_FROM_ABI constexpr |
| 42 | operator in_in_result<_II1, _II2>() && { return {_VSTD::move(in1), _VSTD::move(in2)}; } | |
| 42 | operator in_in_result<_InIter3, _InIter4>() && { | |
| 43 | return {std::move(in1), std::move(in2)}; | |
| 44 | } | |
| 43 | 45 | }; |
| 44 | 46 | |
| 45 | 47 | } // namespace ranges |
| 46 | 48 | |
| 47 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 49 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 48 | 50 | |
| 49 | 51 | _LIBCPP_END_NAMESPACE_STD |
| 50 | 52 |
lib/libcxx/include/__algorithm/in_out_out_result.h created+54| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H | |
| 12 | ||
| 13 | #include <__concepts/convertible_to.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/move.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | template <class _InIter1, class _OutIter1, class _OutIter2> | |
| 27 | struct in_out_out_result { | |
| 28 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | |
| 29 | _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out1; | |
| 30 | _LIBCPP_NO_UNIQUE_ADDRESS _OutIter2 out2; | |
| 31 | ||
| 32 | template <class _InIter2, class _OutIter3, class _OutIter4> | |
| 33 | requires convertible_to<const _InIter1&, _InIter2> | |
| 34 | && convertible_to<const _OutIter1&, _OutIter3> && convertible_to<const _OutIter2&, _OutIter4> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 36 | operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() const& { | |
| 37 | return {in, out1, out2}; | |
| 38 | } | |
| 39 | ||
| 40 | template <class _InIter2, class _OutIter3, class _OutIter4> | |
| 41 | requires convertible_to<_InIter1, _InIter2> | |
| 42 | && convertible_to<_OutIter1, _OutIter3> && convertible_to<_OutIter2, _OutIter4> | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 44 | operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() && { | |
| 45 | return {std::move(in), std::move(out1), std::move(out2)}; | |
| 46 | } | |
| 47 | }; | |
| 48 | } // namespace ranges | |
| 49 | ||
| 50 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | #endif // _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H |
lib/libcxx/include/__algorithm/in_out_result.h+13-14| ... | ... | @@ -15,39 +15,38 @@ |
| 15 | 15 | #include <__utility/move.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | 24 | |
| 25 | 25 | namespace ranges { |
| 26 | 26 | |
| 27 | template<class _InputIterator, class _OutputIterator> | |
| 27 | template<class _InIter1, class _OutIter1> | |
| 28 | 28 | struct in_out_result { |
| 29 | [[no_unique_address]] _InputIterator in; | |
| 30 | [[no_unique_address]] _OutputIterator out; | |
| 29 | _LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | |
| 30 | _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out; | |
| 31 | 31 | |
| 32 | template <class _InputIterator2, class _OutputIterator2> | |
| 33 | requires convertible_to<const _InputIterator&, _InputIterator2> && convertible_to<const _OutputIterator&, | |
| 34 | _OutputIterator2> | |
| 32 | template <class _InIter2, class _OutIter2> | |
| 33 | requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _OutIter1&, _OutIter2> | |
| 35 | 34 | _LIBCPP_HIDE_FROM_ABI |
| 36 | constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() const & { | |
| 35 | constexpr operator in_out_result<_InIter2, _OutIter2>() const & { | |
| 37 | 36 | return {in, out}; |
| 38 | 37 | } |
| 39 | 38 | |
| 40 | template <class _InputIterator2, class _OutputIterator2> | |
| 41 | requires convertible_to<_InputIterator, _InputIterator2> && convertible_to<_OutputIterator, _OutputIterator2> | |
| 39 | template <class _InIter2, class _OutIter2> | |
| 40 | requires convertible_to<_InIter1, _InIter2> && convertible_to<_OutIter1, _OutIter2> | |
| 42 | 41 | _LIBCPP_HIDE_FROM_ABI |
| 43 | constexpr operator in_out_result<_InputIterator2, _OutputIterator2>() && { | |
| 44 | return {_VSTD::move(in), _VSTD::move(out)}; | |
| 42 | constexpr operator in_out_result<_InIter2, _OutIter2>() && { | |
| 43 | return {std::move(in), std::move(out)}; | |
| 45 | 44 | } |
| 46 | 45 | }; |
| 47 | 46 | |
| 48 | 47 | } // namespace ranges |
| 49 | 48 | |
| 50 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 49 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 51 | 50 | |
| 52 | 51 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 52 |
lib/libcxx/include/__algorithm/includes.h+39-30| ... | ... | @@ -12,49 +12,58 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 15 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__type_traits/is_callable.h> | |
| 19 | #include <__utility/move.h> | |
| 16 | 20 | |
| 17 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 19 | 23 | #endif |
| 20 | 24 | |
| 21 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 26 | |
| 23 | template <class _Compare, class _InputIterator1, class _InputIterator2> | |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | |
| 25 | __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, | |
| 26 | _Compare __comp) | |
| 27 | { | |
| 28 | for (; __first2 != __last2; ++__first1) | |
| 29 | { | |
| 30 | if (__first1 == __last1 || __comp(*__first2, *__first1)) | |
| 31 | return false; | |
| 32 | if (!__comp(*__first1, *__first2)) | |
| 33 | ++__first2; | |
| 34 | } | |
| 35 | return true; | |
| 27 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2> | |
| 28 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | |
| 29 | __includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, | |
| 30 | _Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) { | |
| 31 | for (; __first2 != __last2; ++__first1) { | |
| 32 | if (__first1 == __last1 || std::__invoke( | |
| 33 | __comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1))) | |
| 34 | return false; | |
| 35 | if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | |
| 36 | ++__first2; | |
| 37 | } | |
| 38 | return true; | |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | 41 | template <class _InputIterator1, class _InputIterator2, class _Compare> |
| 39 | _LIBCPP_NODISCARD_EXT inline | |
| 40 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 41 | bool | |
| 42 | includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, | |
| 43 | _Compare __comp) | |
| 44 | { | |
| 45 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 46 | return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); | |
| 42 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool includes( | |
| 43 | _InputIterator1 __first1, | |
| 44 | _InputIterator1 __last1, | |
| 45 | _InputIterator2 __first2, | |
| 46 | _InputIterator2 __last2, | |
| 47 | _Compare __comp) { | |
| 48 | static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, | |
| 49 | "Comparator has to be callable"); | |
| 50 | ||
| 51 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 52 | return std::__includes( | |
| 53 | std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), | |
| 54 | static_cast<_Comp_ref>(__comp), __identity(), __identity()); | |
| 47 | 55 | } |
| 48 | 56 | |
| 49 | 57 | template <class _InputIterator1, class _InputIterator2> |
| 50 | _LIBCPP_NODISCARD_EXT inline | |
| 51 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 52 | bool | |
| 53 | includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) | |
| 54 | { | |
| 55 | return _VSTD::includes(__first1, __last1, __first2, __last2, | |
| 56 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 57 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 58 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | |
| 59 | includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | |
| 60 | return std::includes( | |
| 61 | std::move(__first1), | |
| 62 | std::move(__last1), | |
| 63 | std::move(__first2), | |
| 64 | std::move(__last2), | |
| 65 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 66 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 58 | 67 | } |
| 59 | 68 | |
| 60 | 69 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/inplace_merge.h+77-54| ... | ... | @@ -9,20 +9,25 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
| 11 | 11 | |
| 12 | #include <__algorithm/algorithm_family.h> | |
| 12 | 13 | #include <__algorithm/comp.h> |
| 13 | 14 | #include <__algorithm/comp_ref_type.h> |
| 15 | #include <__algorithm/iterator_operations.h> | |
| 14 | 16 | #include <__algorithm/lower_bound.h> |
| 15 | 17 | #include <__algorithm/min.h> |
| 16 | 18 | #include <__algorithm/move.h> |
| 17 | 19 | #include <__algorithm/rotate.h> |
| 18 | 20 | #include <__algorithm/upper_bound.h> |
| 19 | 21 | #include <__config> |
| 22 | #include <__functional/identity.h> | |
| 23 | #include <__iterator/advance.h> | |
| 24 | #include <__iterator/distance.h> | |
| 20 | 25 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__utility/swap.h> | |
| 26 | #include <__iterator/reverse_iterator.h> | |
| 22 | 27 | #include <memory> |
| 23 | 28 | |
| 24 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 30 | # pragma GCC system_header | |
| 26 | 31 | #endif |
| 27 | 32 | |
| 28 | 33 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -50,72 +55,79 @@ public: |
| 50 | 55 | bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);} |
| 51 | 56 | }; |
| 52 | 57 | |
| 53 | template <class _Compare, class _InputIterator1, class _InputIterator2, | |
| 54 | class _OutputIterator> | |
| 55 | void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 56 | _InputIterator2 __first2, _InputIterator2 __last2, | |
| 57 | _OutputIterator __result, _Compare __comp) | |
| 58 | template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1, | |
| 59 | class _InputIterator2, class _Sent2, class _OutputIterator> | |
| 60 | void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1, | |
| 61 | _InputIterator2 __first2, _Sent2 __last2, | |
| 62 | _OutputIterator __result, _Compare&& __comp) | |
| 58 | 63 | { |
| 59 | 64 | for (; __first1 != __last1; ++__result) |
| 60 | 65 | { |
| 61 | 66 | if (__first2 == __last2) |
| 62 | 67 | { |
| 63 | _VSTD::move(__first1, __last1, __result); | |
| 68 | _AlgFamily<_AlgPolicy>::__move(__first1, __last1, __result); | |
| 64 | 69 | return; |
| 65 | 70 | } |
| 66 | 71 | |
| 67 | 72 | if (__comp(*__first2, *__first1)) |
| 68 | 73 | { |
| 69 | *__result = _VSTD::move(*__first2); | |
| 74 | *__result = _IterOps<_AlgPolicy>::__iter_move(__first2); | |
| 70 | 75 | ++__first2; |
| 71 | 76 | } |
| 72 | 77 | else |
| 73 | 78 | { |
| 74 | *__result = _VSTD::move(*__first1); | |
| 79 | *__result = _IterOps<_AlgPolicy>::__iter_move(__first1); | |
| 75 | 80 | ++__first1; |
| 76 | 81 | } |
| 77 | 82 | } |
| 78 | 83 | // __first2 through __last2 are already in the right spot. |
| 79 | 84 | } |
| 80 | 85 | |
| 81 | template <class _Compare, class _BidirectionalIterator> | |
| 82 | void | |
| 83 | __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | |
| 84 | _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1, | |
| 85 | typename iterator_traits<_BidirectionalIterator>::difference_type __len2, | |
| 86 | typename iterator_traits<_BidirectionalIterator>::value_type* __buff) | |
| 87 | { | |
| 88 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | |
| 86 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | |
| 87 | void __buffered_inplace_merge( | |
| 88 | _BidirectionalIterator __first, | |
| 89 | _BidirectionalIterator __middle, | |
| 90 | _BidirectionalIterator __last, | |
| 91 | _Compare&& __comp, | |
| 92 | typename iterator_traits<_BidirectionalIterator>::difference_type __len1, | |
| 93 | typename iterator_traits<_BidirectionalIterator>::difference_type __len2, | |
| 94 | typename iterator_traits<_BidirectionalIterator>::value_type* __buff) { | |
| 95 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | |
| 89 | 96 | __destruct_n __d(0); |
| 90 | 97 | unique_ptr<value_type, __destruct_n&> __h2(__buff, __d); |
| 91 | 98 | if (__len1 <= __len2) |
| 92 | 99 | { |
| 93 | 100 | value_type* __p = __buff; |
| 94 | 101 | for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p) |
| 95 | ::new ((void*)__p) value_type(_VSTD::move(*__i)); | |
| 96 | _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp); | |
| 102 | ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | |
| 103 | std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp); | |
| 97 | 104 | } |
| 98 | 105 | else |
| 99 | 106 | { |
| 100 | 107 | value_type* __p = __buff; |
| 101 | 108 | for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p) |
| 102 | ::new ((void*)__p) value_type(_VSTD::move(*__i)); | |
| 103 | typedef reverse_iterator<_BidirectionalIterator> _RBi; | |
| 104 | typedef reverse_iterator<value_type*> _Rv; | |
| 109 | ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | |
| 110 | typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi; | |
| 111 | typedef __unconstrained_reverse_iterator<value_type*> _Rv; | |
| 105 | 112 | typedef __invert<_Compare> _Inverted; |
| 106 | _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff), | |
| 113 | std::__half_inplace_merge<_AlgPolicy>(_Rv(__p), _Rv(__buff), | |
| 107 | 114 | _RBi(__middle), _RBi(__first), |
| 108 | 115 | _RBi(__last), _Inverted(__comp)); |
| 109 | 116 | } |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | template <class _Compare, class _BidirectionalIterator> | |
| 113 | void | |
| 114 | __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | |
| 115 | _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1, | |
| 116 | typename iterator_traits<_BidirectionalIterator>::difference_type __len2, | |
| 117 | typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size) | |
| 118 | { | |
| 119 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | |
| 120 | void __inplace_merge( | |
| 121 | _BidirectionalIterator __first, | |
| 122 | _BidirectionalIterator __middle, | |
| 123 | _BidirectionalIterator __last, | |
| 124 | _Compare&& __comp, | |
| 125 | typename iterator_traits<_BidirectionalIterator>::difference_type __len1, | |
| 126 | typename iterator_traits<_BidirectionalIterator>::difference_type __len2, | |
| 127 | typename iterator_traits<_BidirectionalIterator>::value_type* __buff, | |
| 128 | ptrdiff_t __buff_size) { | |
| 129 | using _Ops = _IterOps<_AlgPolicy>; | |
| 130 | ||
| 119 | 131 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; |
| 120 | 132 | while (true) |
| 121 | 133 | { |
| ... | ... | @@ -123,7 +135,7 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, |
| 123 | 135 | if (__len2 == 0) |
| 124 | 136 | return; |
| 125 | 137 | if (__len1 <= __buff_size || __len2 <= __buff_size) |
| 126 | return _VSTD::__buffered_inplace_merge<_Compare> | |
| 138 | return std::__buffered_inplace_merge<_AlgPolicy> | |
| 127 | 139 | (__first, __middle, __last, __comp, __len1, __len2, __buff); |
| 128 | 140 | // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 |
| 129 | 141 | for (; true; ++__first, (void) --__len1) |
| ... | ... | @@ -150,36 +162,37 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, |
| 150 | 162 | { // __len >= 1, __len2 >= 2 |
| 151 | 163 | __len21 = __len2 / 2; |
| 152 | 164 | __m2 = __middle; |
| 153 | _VSTD::advance(__m2, __len21); | |
| 154 | __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp); | |
| 155 | __len11 = _VSTD::distance(__first, __m1); | |
| 165 | _Ops::advance(__m2, __len21); | |
| 166 | __m1 = std::__upper_bound<_AlgPolicy>(__first, __middle, *__m2, __comp, std::__identity()); | |
| 167 | __len11 = _Ops::distance(__first, __m1); | |
| 156 | 168 | } |
| 157 | 169 | else |
| 158 | 170 | { |
| 159 | 171 | if (__len1 == 1) |
| 160 | 172 | { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1 |
| 161 | 173 | // It is known *__first > *__middle |
| 162 | swap(*__first, *__middle); | |
| 174 | _Ops::iter_swap(__first, __middle); | |
| 163 | 175 | return; |
| 164 | 176 | } |
| 165 | 177 | // __len1 >= 2, __len2 >= 1 |
| 166 | 178 | __len11 = __len1 / 2; |
| 167 | 179 | __m1 = __first; |
| 168 | _VSTD::advance(__m1, __len11); | |
| 169 | __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp); | |
| 170 | __len21 = _VSTD::distance(__middle, __m2); | |
| 180 | _Ops::advance(__m1, __len11); | |
| 181 | __m2 = std::lower_bound(__middle, __last, *__m1, __comp); | |
| 182 | __len21 = _Ops::distance(__middle, __m2); | |
| 171 | 183 | } |
| 172 | 184 | difference_type __len12 = __len1 - __len11; // distance(__m1, __middle) |
| 173 | 185 | difference_type __len22 = __len2 - __len21; // distance(__m2, __last) |
| 174 | 186 | // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) |
| 175 | 187 | // swap middle two partitions |
| 188 | // TODO(alg-policy): pass `_AlgPolicy` once it's supported by `rotate`. | |
| 176 | 189 | __middle = _VSTD::rotate(__m1, __middle, __m2); |
| 177 | 190 | // __len12 and __len21 now have swapped meanings |
| 178 | 191 | // merge smaller range with recursive call and larger with tail recursion elimination |
| 179 | 192 | if (__len11 + __len21 < __len12 + __len22) |
| 180 | 193 | { |
| 181 | _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); | |
| 182 | // _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); | |
| 194 | std::__inplace_merge<_AlgPolicy>( | |
| 195 | __first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); | |
| 183 | 196 | __first = __middle; |
| 184 | 197 | __middle = __m2; |
| 185 | 198 | __len1 = __len12; |
| ... | ... | @@ -187,8 +200,8 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, |
| 187 | 200 | } |
| 188 | 201 | else |
| 189 | 202 | { |
| 190 | _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); | |
| 191 | // _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); | |
| 203 | std::__inplace_merge<_AlgPolicy>( | |
| 204 | __middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); | |
| 192 | 205 | __last = __middle; |
| 193 | 206 | __middle = __m1; |
| 194 | 207 | __len1 = __len11; |
| ... | ... | @@ -197,30 +210,40 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, |
| 197 | 210 | } |
| 198 | 211 | } |
| 199 | 212 | |
| 200 | template <class _BidirectionalIterator, class _Compare> | |
| 201 | inline _LIBCPP_INLINE_VISIBILITY | |
| 213 | template <class _AlgPolicy, class _BidirectionalIterator, class _Compare> | |
| 214 | _LIBCPP_HIDE_FROM_ABI | |
| 202 | 215 | void |
| 203 | inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | |
| 204 | _Compare __comp) | |
| 216 | __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | |
| 217 | _Compare&& __comp) | |
| 205 | 218 | { |
| 206 | 219 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| 207 | 220 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; |
| 208 | difference_type __len1 = _VSTD::distance(__first, __middle); | |
| 209 | difference_type __len2 = _VSTD::distance(__middle, __last); | |
| 221 | difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle); | |
| 222 | difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last); | |
| 210 | 223 | difference_type __buf_size = _VSTD::min(__len1, __len2); |
| 224 | // TODO: Remove the use of std::get_temporary_buffer | |
| 225 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 211 | 226 | pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size); |
| 227 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 212 | 228 | unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first); |
| 213 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 214 | return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, | |
| 215 | __buf.first, __buf.second); | |
| 229 | return std::__inplace_merge<_AlgPolicy>( | |
| 230 | std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second); | |
| 231 | } | |
| 232 | ||
| 233 | template <class _BidirectionalIterator, class _Compare> | |
| 234 | inline _LIBCPP_HIDE_FROM_ABI void inplace_merge( | |
| 235 | _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { | |
| 236 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 237 | std::__inplace_merge<_ClassicAlgPolicy>( | |
| 238 | std::move(__first), std::move(__middle), std::move(__last), static_cast<_Comp_ref>(__comp)); | |
| 216 | 239 | } |
| 217 | 240 | |
| 218 | 241 | template <class _BidirectionalIterator> |
| 219 | inline _LIBCPP_INLINE_VISIBILITY | |
| 242 | inline _LIBCPP_HIDE_FROM_ABI | |
| 220 | 243 | void |
| 221 | 244 | inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) |
| 222 | 245 | { |
| 223 | _VSTD::inplace_merge(__first, __middle, __last, | |
| 246 | std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last), | |
| 224 | 247 | __less<typename iterator_traits<_BidirectionalIterator>::value_type>()); |
| 225 | 248 | } |
| 226 | 249 |
lib/libcxx/include/__algorithm/is_heap.h+2-2| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -28,7 +28,7 @@ bool |
| 28 | 28 | is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) |
| 29 | 29 | { |
| 30 | 30 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; |
| 31 | return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last; | |
| 31 | return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)) == __last; | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | template<class _RandomAccessIterator> |
lib/libcxx/include/__algorithm/is_heap_until.h+3-3| ... | ... | @@ -15,14 +15,14 @@ |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _Compare, class _RandomAccessIterator> |
| 24 | 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator |
| 25 | __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 25 | __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) | |
| 26 | 26 | { |
| 27 | 27 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 28 | 28 | difference_type __len = __last - __first; |
| ... | ... | @@ -52,7 +52,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 52 | 52 | is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) |
| 53 | 53 | { |
| 54 | 54 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; |
| 55 | return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp); | |
| 55 | return std::__is_heap_until(__first, __last, static_cast<_Comp_ref>(__comp)); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | template<class _RandomAccessIterator> |
lib/libcxx/include/__algorithm/is_partitioned.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/is_permutation.h+1-1| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <__iterator/next.h> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/is_sorted.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/is_sorted_until.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/iter_swap.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__utility/swap.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/iterator_operations.h created+148| ... | ... | @@ -0,0 +1,148 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H | |
| 10 | #define _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H | |
| 11 | ||
| 12 | #include <__algorithm/iter_swap.h> | |
| 13 | #include <__config> | |
| 14 | #include <__iterator/advance.h> | |
| 15 | #include <__iterator/distance.h> | |
| 16 | #include <__iterator/iter_move.h> | |
| 17 | #include <__iterator/iter_swap.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/next.h> | |
| 20 | #include <__iterator/readable_traits.h> | |
| 21 | #include <__utility/declval.h> | |
| 22 | #include <__utility/forward.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | #include <type_traits> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | template <class _AlgPolicy> struct _IterOps; | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | struct _RangeAlgPolicy {}; | |
| 36 | ||
| 37 | template <> | |
| 38 | struct _IterOps<_RangeAlgPolicy> { | |
| 39 | ||
| 40 | template <class _Iter> | |
| 41 | using __value_type = iter_value_t<_Iter>; | |
| 42 | ||
| 43 | static constexpr auto advance = ranges::advance; | |
| 44 | static constexpr auto distance = ranges::distance; | |
| 45 | static constexpr auto __iter_move = ranges::iter_move; | |
| 46 | static constexpr auto iter_swap = ranges::iter_swap; | |
| 47 | static constexpr auto next = ranges::next; | |
| 48 | static constexpr auto __advance_to = ranges::advance; | |
| 49 | }; | |
| 50 | ||
| 51 | #endif | |
| 52 | ||
| 53 | struct _ClassicAlgPolicy {}; | |
| 54 | ||
| 55 | template <> | |
| 56 | struct _IterOps<_ClassicAlgPolicy> { | |
| 57 | ||
| 58 | template <class _Iter> | |
| 59 | using __value_type = typename iterator_traits<_Iter>::value_type; | |
| 60 | ||
| 61 | // advance | |
| 62 | template <class _Iter, class _Distance> | |
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 64 | static void advance(_Iter& __iter, _Distance __count) { | |
| 65 | std::advance(__iter, __count); | |
| 66 | } | |
| 67 | ||
| 68 | // distance | |
| 69 | template <class _Iter> | |
| 70 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 71 | static typename iterator_traits<_Iter>::difference_type distance(_Iter __first, _Iter __last) { | |
| 72 | return std::distance(__first, __last); | |
| 73 | } | |
| 74 | ||
| 75 | template <class _Iter> | |
| 76 | using __deref_t = decltype(*std::declval<_Iter&>()); | |
| 77 | ||
| 78 | template <class _Iter> | |
| 79 | using __move_t = decltype(std::move(*std::declval<_Iter&>())); | |
| 80 | ||
| 81 | template <class _Iter> | |
| 82 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 83 | static void __validate_iter_reference() { | |
| 84 | static_assert(is_same<__deref_t<_Iter>, typename iterator_traits<__uncvref_t<_Iter> >::reference>::value, | |
| 85 | "It looks like your iterator's `iterator_traits<It>::reference` does not match the return type of " | |
| 86 | "dereferencing the iterator, i.e., calling `*it`. This is undefined behavior according to [input.iterators] " | |
| 87 | "and can lead to dangling reference issues at runtime, so we are flagging this."); | |
| 88 | } | |
| 89 | ||
| 90 | // iter_move | |
| 91 | template <class _Iter> | |
| 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static | |
| 93 | // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note | |
| 94 | // that the C++03 mode doesn't support `decltype(auto)` as the return type. | |
| 95 | __enable_if_t< | |
| 96 | is_reference<__deref_t<_Iter> >::value, | |
| 97 | __move_t<_Iter> > | |
| 98 | __iter_move(_Iter&& __i) { | |
| 99 | __validate_iter_reference<_Iter>(); | |
| 100 | ||
| 101 | return std::move(*std::forward<_Iter>(__i)); | |
| 102 | } | |
| 103 | ||
| 104 | template <class _Iter> | |
| 105 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static | |
| 106 | // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a | |
| 107 | // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that | |
| 108 | // temporary. Note that the C++03 mode doesn't support `auto` as the return type. | |
| 109 | __enable_if_t< | |
| 110 | !is_reference<__deref_t<_Iter> >::value, | |
| 111 | __deref_t<_Iter> > | |
| 112 | __iter_move(_Iter&& __i) { | |
| 113 | __validate_iter_reference<_Iter>(); | |
| 114 | ||
| 115 | return *std::forward<_Iter>(__i); | |
| 116 | } | |
| 117 | ||
| 118 | // iter_swap | |
| 119 | template <class _Iter1, class _Iter2> | |
| 120 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 121 | static void iter_swap(_Iter1&& __a, _Iter2&& __b) { | |
| 122 | std::iter_swap(std::forward<_Iter1>(__a), std::forward<_Iter2>(__b)); | |
| 123 | } | |
| 124 | ||
| 125 | // next | |
| 126 | template <class _Iterator> | |
| 127 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 128 | _Iterator next(_Iterator, _Iterator __last) { | |
| 129 | return __last; | |
| 130 | } | |
| 131 | ||
| 132 | template <class _Iter> | |
| 133 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 134 | __uncvref_t<_Iter> next(_Iter&& __it, | |
| 135 | typename iterator_traits<__uncvref_t<_Iter> >::difference_type __n = 1){ | |
| 136 | return std::next(std::forward<_Iter>(__it), __n); | |
| 137 | } | |
| 138 | ||
| 139 | template <class _Iter> | |
| 140 | _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 141 | void __advance_to(_Iter& __first, _Iter __last) { | |
| 142 | __first = __last; | |
| 143 | } | |
| 144 | }; | |
| 145 | ||
| 146 | _LIBCPP_END_NAMESPACE_STD | |
| 147 | ||
| 148 | #endif // _LIBCPP___ALGORITHM_ITERATOR_OPERATIONS_H |
lib/libcxx/include/__algorithm/lexicographical_compare.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/lower_bound.h+36-34| ... | ... | @@ -11,54 +11,56 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/half_positive.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <iterator> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__iterator/advance.h> | |
| 19 | #include <__iterator/distance.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__type_traits/is_callable.h> | |
| 22 | #include <__type_traits/remove_reference.h> | |
| 23 | #include <type_traits> | |
| 16 | 24 | |
| 17 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 19 | 27 | #endif |
| 20 | 28 | |
| 21 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 30 | |
| 23 | template <class _Compare, class _ForwardIterator, class _Tp> | |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 25 | __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 26 | { | |
| 27 | typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; | |
| 28 | difference_type __len = _VSTD::distance(__first, __last); | |
| 29 | while (__len != 0) | |
| 30 | { | |
| 31 | difference_type __l2 = _VSTD::__half_positive(__len); | |
| 32 | _ForwardIterator __m = __first; | |
| 33 | _VSTD::advance(__m, __l2); | |
| 34 | if (__comp(*__m, __value_)) | |
| 35 | { | |
| 36 | __first = ++__m; | |
| 37 | __len -= __l2 + 1; | |
| 38 | } | |
| 39 | else | |
| 40 | __len = __l2; | |
| 31 | template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp> | |
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 33 | _Iter __lower_bound_impl(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) { | |
| 34 | auto __len = _IterOps<_AlgPolicy>::distance(__first, __last); | |
| 35 | ||
| 36 | while (__len != 0) { | |
| 37 | auto __l2 = std::__half_positive(__len); | |
| 38 | _Iter __m = __first; | |
| 39 | _IterOps<_AlgPolicy>::advance(__m, __l2); | |
| 40 | if (std::__invoke(__comp, std::__invoke(__proj, *__m), __value)) { | |
| 41 | __first = ++__m; | |
| 42 | __len -= __l2 + 1; | |
| 43 | } else { | |
| 44 | __len = __l2; | |
| 41 | 45 | } |
| 42 | return __first; | |
| 46 | } | |
| 47 | return __first; | |
| 43 | 48 | } |
| 44 | 49 | |
| 45 | 50 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 46 | _LIBCPP_NODISCARD_EXT inline | |
| 47 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 48 | _ForwardIterator | |
| 49 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 50 | { | |
| 51 | return _VSTD::__lower_bound<_Compare&>(__first, __last, __value_, __comp); | |
| 51 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 52 | _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | |
| 53 | static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, | |
| 54 | "The comparator has to be callable"); | |
| 55 | auto __proj = std::__identity(); | |
| 56 | return std::__lower_bound_impl<_ClassicAlgPolicy>(__first, __last, __value, __comp, __proj); | |
| 52 | 57 | } |
| 53 | 58 | |
| 54 | 59 | template <class _ForwardIterator, class _Tp> |
| 55 | _LIBCPP_NODISCARD_EXT inline | |
| 56 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 57 | _ForwardIterator | |
| 58 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) | |
| 59 | { | |
| 60 | return _VSTD::lower_bound(__first, __last, __value_, | |
| 61 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | |
| 60 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 61 | _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | |
| 62 | return std::lower_bound(__first, __last, __value, | |
| 63 | __less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | 66 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/make_heap.h+23-25| ... | ... | @@ -11,47 +11,45 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__algorithm/sift_down.h> |
| 15 | 16 | #include <__config> |
| 16 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__utility/move.h> | |
| 17 | 19 | |
| 18 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 20 | 22 | #endif |
| 21 | 23 | |
| 22 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 25 | |
| 24 | template <class _Compare, class _RandomAccessIterator> | |
| 25 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void | |
| 26 | __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 27 | { | |
| 28 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 29 | difference_type __n = __last - __first; | |
| 30 | if (__n > 1) | |
| 31 | { | |
| 32 | // start from the first parent, there is no need to consider children | |
| 33 | for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) | |
| 34 | { | |
| 35 | _VSTD::__sift_down<_Compare>(__first, __comp, __n, __first + __start); | |
| 36 | } | |
| 26 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 27 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 28 | void __make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) { | |
| 29 | using _CompRef = typename __comp_ref_type<_Compare>::type; | |
| 30 | _CompRef __comp_ref = __comp; | |
| 31 | ||
| 32 | using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; | |
| 33 | difference_type __n = __last - __first; | |
| 34 | if (__n > 1) { | |
| 35 | // start from the first parent, there is no need to consider children | |
| 36 | for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) { | |
| 37 | std::__sift_down<_AlgPolicy>(__first, __comp_ref, __n, __first + __start); | |
| 37 | 38 | } |
| 39 | } | |
| 38 | 40 | } |
| 39 | 41 | |
| 40 | 42 | template <class _RandomAccessIterator, class _Compare> |
| 41 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 42 | void | |
| 43 | make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 44 | { | |
| 45 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 46 | _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp); | |
| 43 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 44 | void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 45 | std::__make_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp); | |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | template <class _RandomAccessIterator> |
| 50 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 51 | void | |
| 52 | make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 53 | { | |
| 54 | _VSTD::make_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 49 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 50 | void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 51 | std::make_heap(std::move(__first), std::move(__last), | |
| 52 | __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 55 | 53 | } |
| 56 | 54 | |
| 57 | 55 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/make_projected.h created+126| ... | ... | @@ -0,0 +1,126 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_MAKE_PROJECTED_H | |
| 10 | #define _LIBCPP___ALGORITHM_MAKE_PROJECTED_H | |
| 11 | ||
| 12 | #include <__concepts/same_as.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__type_traits/decay.h> | |
| 17 | #include <__type_traits/enable_if.h> | |
| 18 | #include <__type_traits/integral_constant.h> | |
| 19 | #include <__type_traits/is_member_pointer.h> | |
| 20 | #include <__type_traits/is_same.h> | |
| 21 | #include <__utility/declval.h> | |
| 22 | #include <__utility/forward.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | template <class _Pred, class _Proj> | |
| 31 | struct _ProjectedPred { | |
| 32 | _Pred& __pred; // Can be a unary or a binary predicate. | |
| 33 | _Proj& __proj; | |
| 34 | ||
| 35 | _LIBCPP_CONSTEXPR _ProjectedPred(_Pred& __pred_arg, _Proj& __proj_arg) : __pred(__pred_arg), __proj(__proj_arg) {} | |
| 36 | ||
| 37 | template <class _Tp> | |
| 38 | typename __invoke_of<_Pred&, | |
| 39 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>())) | |
| 40 | >::type | |
| 41 | _LIBCPP_CONSTEXPR operator()(_Tp&& __v) const { | |
| 42 | return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v))); | |
| 43 | } | |
| 44 | ||
| 45 | template <class _T1, class _T2> | |
| 46 | typename __invoke_of<_Pred&, | |
| 47 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())), | |
| 48 | decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>())) | |
| 49 | >::type | |
| 50 | _LIBCPP_CONSTEXPR operator()(_T1&& __lhs, _T2&& __rhs) const { | |
| 51 | return std::__invoke(__pred, | |
| 52 | std::__invoke(__proj, std::forward<_T1>(__lhs)), | |
| 53 | std::__invoke(__proj, std::forward<_T2>(__rhs))); | |
| 54 | } | |
| 55 | ||
| 56 | }; | |
| 57 | ||
| 58 | template <class _Pred, class _Proj, class = void> | |
| 59 | struct __can_use_pristine_comp : false_type {}; | |
| 60 | ||
| 61 | template <class _Pred, class _Proj> | |
| 62 | struct __can_use_pristine_comp<_Pred, _Proj, __enable_if_t< | |
| 63 | !is_member_pointer<typename decay<_Pred>::type>::value && ( | |
| 64 | #if _LIBCPP_STD_VER > 17 | |
| 65 | is_same<typename decay<_Proj>::type, identity>::value || | |
| 66 | #endif | |
| 67 | is_same<typename decay<_Proj>::type, __identity>::value | |
| 68 | ) | |
| 69 | > > : true_type {}; | |
| 70 | ||
| 71 | template <class _Pred, class _Proj> | |
| 72 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static | |
| 73 | __enable_if_t< | |
| 74 | !__can_use_pristine_comp<_Pred, _Proj>::value, | |
| 75 | _ProjectedPred<_Pred, _Proj> | |
| 76 | > | |
| 77 | __make_projected(_Pred& __pred, _Proj& __proj) { | |
| 78 | return _ProjectedPred<_Pred, _Proj>(__pred, __proj); | |
| 79 | } | |
| 80 | ||
| 81 | // Avoid creating the functor and just use the pristine comparator -- for certain algorithms, this would enable | |
| 82 | // optimizations that rely on the type of the comparator. Additionally, this results in less layers of indirection in | |
| 83 | // the call stack when the comparator is invoked, even in an unoptimized build. | |
| 84 | template <class _Pred, class _Proj> | |
| 85 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static | |
| 86 | __enable_if_t< | |
| 87 | __can_use_pristine_comp<_Pred, _Proj>::value, | |
| 88 | _Pred& | |
| 89 | > | |
| 90 | __make_projected(_Pred& __pred, _Proj&) { | |
| 91 | return __pred; | |
| 92 | } | |
| 93 | ||
| 94 | _LIBCPP_END_NAMESPACE_STD | |
| 95 | ||
| 96 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 97 | ||
| 98 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 99 | ||
| 100 | namespace ranges { | |
| 101 | ||
| 102 | template <class _Comp, class _Proj1, class _Proj2> | |
| 103 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 104 | decltype(auto) __make_projected_comp(_Comp& __comp, _Proj1& __proj1, _Proj2& __proj2) { | |
| 105 | if constexpr (same_as<decay_t<_Proj1>, identity> && same_as<decay_t<_Proj2>, identity> && | |
| 106 | !is_member_pointer_v<decay_t<_Comp>>) { | |
| 107 | // Avoid creating the lambda and just use the pristine comparator -- for certain algorithms, this would enable | |
| 108 | // optimizations that rely on the type of the comparator. | |
| 109 | return __comp; | |
| 110 | ||
| 111 | } else { | |
| 112 | return [&](auto&& __lhs, auto&& __rhs) { | |
| 113 | return std::invoke(__comp, | |
| 114 | std::invoke(__proj1, std::forward<decltype(__lhs)>(__lhs)), | |
| 115 | std::invoke(__proj2, std::forward<decltype(__rhs)>(__rhs))); | |
| 116 | }; | |
| 117 | } | |
| 118 | } | |
| 119 | ||
| 120 | } // namespace ranges | |
| 121 | ||
| 122 | _LIBCPP_END_NAMESPACE_STD | |
| 123 | ||
| 124 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 125 | ||
| 126 | #endif // _LIBCPP___ALGORITHM_MAKE_PROJECTED_H |
lib/libcxx/include/__algorithm/max.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <initializer_list> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__algorithm/max_element.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/merge.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/min.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <initializer_list> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__algorithm/min_element.h+30-16| ... | ... | @@ -12,36 +12,50 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 15 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__type_traits/is_callable.h> | |
| 19 | #include <__utility/move.h> | |
| 16 | 20 | |
| 17 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 19 | 23 | #endif |
| 20 | 24 | |
| 21 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 26 | |
| 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) | |
| 26 | { | |
| 27 | static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, | |
| 28 | "std::min_element requires a ForwardIterator"); | |
| 29 | if (__first != __last) | |
| 30 | { | |
| 31 | _ForwardIterator __i = __first; | |
| 32 | while (++__i != __last) | |
| 33 | if (__comp(*__i, *__first)) | |
| 34 | __first = __i; | |
| 35 | } | |
| 27 | template <class _Comp, class _Iter, class _Sent, class _Proj> | |
| 28 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 29 | _Iter __min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) { | |
| 30 | if (__first == __last) | |
| 36 | 31 | return __first; |
| 32 | ||
| 33 | _Iter __i = __first; | |
| 34 | while (++__i != __last) | |
| 35 | if (std::__invoke(__comp, std::__invoke(__proj, *__i), std::__invoke(__proj, *__first))) | |
| 36 | __first = __i; | |
| 37 | ||
| 38 | return __first; | |
| 39 | } | |
| 40 | ||
| 41 | template <class _Comp, class _Iter, class _Sent> | |
| 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 43 | _Iter __min_element(_Iter __first, _Sent __last, _Comp __comp) { | |
| 44 | auto __proj = __identity(); | |
| 45 | return std::__min_element<_Comp>(std::move(__first), std::move(__last), __comp, __proj); | |
| 37 | 46 | } |
| 38 | 47 | |
| 39 | 48 | template <class _ForwardIterator, class _Compare> |
| 40 | 49 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator |
| 41 | 50 | min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) |
| 42 | 51 | { |
| 43 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 44 | return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp); | |
| 52 | static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, | |
| 53 | "std::min_element requires a ForwardIterator"); | |
| 54 | static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, | |
| 55 | "The comparator has to be callable"); | |
| 56 | ||
| 57 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 58 | return std::__min_element<_Comp_ref>(std::move(__first), std::move(__last), __comp); | |
| 45 | 59 | } |
| 46 | 60 | |
| 47 | 61 | template <class _ForwardIterator> |
lib/libcxx/include/__algorithm/min_max_result.h created+56| ... | ... | @@ -0,0 +1,56 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H | |
| 11 | #define _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H | |
| 12 | ||
| 13 | #include <__concepts/convertible_to.h> | |
| 14 | #include <__config> | |
| 15 | #include <__utility/move.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | namespace ranges { | |
| 29 | ||
| 30 | template <class _T1> | |
| 31 | struct min_max_result { | |
| 32 | _LIBCPP_NO_UNIQUE_ADDRESS _T1 min; | |
| 33 | _LIBCPP_NO_UNIQUE_ADDRESS _T1 max; | |
| 34 | ||
| 35 | template <class _T2> | |
| 36 | requires convertible_to<const _T1&, _T2> | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr operator min_max_result<_T2>() const & { | |
| 38 | return {min, max}; | |
| 39 | } | |
| 40 | ||
| 41 | template <class _T2> | |
| 42 | requires convertible_to<_T1, _T2> | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr operator min_max_result<_T2>() && { | |
| 44 | return {std::move(min), std::move(max)}; | |
| 45 | } | |
| 46 | }; | |
| 47 | ||
| 48 | } // namespace ranges | |
| 49 | ||
| 50 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | #endif // _LIBCPP___ALGORITHM_MIN_MAX_RESULT_H |
lib/libcxx/include/__algorithm/minmax.h+13-39| ... | ... | @@ -10,12 +10,15 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_MINMAX_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/minmax_element.h> | |
| 13 | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__type_traits/is_callable.h> | |
| 17 | #include <__utility/pair.h> | |
| 14 | 18 | #include <initializer_list> |
| 15 | #include <utility> | |
| 16 | 19 | |
| 17 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 19 | 22 | #endif |
| 20 | 23 | |
| 21 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -36,47 +39,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 36 | 39 | pair<const _Tp&, const _Tp&> |
| 37 | 40 | minmax(const _Tp& __a, const _Tp& __b) |
| 38 | 41 | { |
| 39 | return _VSTD::minmax(__a, __b, __less<_Tp>()); | |
| 42 | return std::minmax(__a, __b, __less<_Tp>()); | |
| 40 | 43 | } |
| 41 | 44 | |
| 42 | 45 | #ifndef _LIBCPP_CXX03_LANG |
| 43 | 46 | |
| 44 | 47 | template<class _Tp, class _Compare> |
| 45 | _LIBCPP_NODISCARD_EXT inline | |
| 46 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 47 | pair<_Tp, _Tp> | |
| 48 | minmax(initializer_list<_Tp> __t, _Compare __comp) | |
| 49 | { | |
| 50 | typedef typename initializer_list<_Tp>::const_iterator _Iter; | |
| 51 | _Iter __first = __t.begin(); | |
| 52 | _Iter __last = __t.end(); | |
| 53 | pair<_Tp, _Tp> __result(*__first, *__first); | |
| 54 | ||
| 55 | ++__first; | |
| 56 | if (__t.size() % 2 == 0) | |
| 57 | { | |
| 58 | if (__comp(*__first, __result.first)) | |
| 59 | __result.first = *__first; | |
| 60 | else | |
| 61 | __result.second = *__first; | |
| 62 | ++__first; | |
| 63 | } | |
| 64 | ||
| 65 | while (__first != __last) | |
| 66 | { | |
| 67 | _Tp __prev = *__first++; | |
| 68 | if (__comp(*__first, __prev)) { | |
| 69 | if ( __comp(*__first, __result.first)) __result.first = *__first; | |
| 70 | if (!__comp(__prev, __result.second)) __result.second = __prev; | |
| 71 | } | |
| 72 | else { | |
| 73 | if ( __comp(__prev, __result.first)) __result.first = __prev; | |
| 74 | if (!__comp(*__first, __result.second)) __result.second = *__first; | |
| 75 | } | |
| 76 | ||
| 77 | __first++; | |
| 78 | } | |
| 79 | return __result; | |
| 48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 49 | pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) { | |
| 50 | static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable"); | |
| 51 | __identity __proj; | |
| 52 | auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj); | |
| 53 | return pair<_Tp, _Tp>(*__ret.first, *__ret.second); | |
| 80 | 54 | } |
| 81 | 55 | |
| 82 | 56 | template<class _Tp> |
| ... | ... | @@ -85,7 +59,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 85 | 59 | pair<_Tp, _Tp> |
| 86 | 60 | minmax(initializer_list<_Tp> __t) |
| 87 | 61 | { |
| 88 | return _VSTD::minmax(__t, __less<_Tp>()); | |
| 62 | return std::minmax(__t, __less<_Tp>()); | |
| 89 | 63 | } |
| 90 | 64 | |
| 91 | 65 | #endif // _LIBCPP_CXX03_LANG |
lib/libcxx/include/__algorithm/minmax_element.h+69-53| ... | ... | @@ -11,73 +11,89 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/identity.h> | |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | #include <utility> | |
| 16 | #include <__utility/pair.h> | |
| 17 | #include <type_traits> | |
| 16 | 18 | |
| 17 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 19 | 21 | #endif |
| 20 | 22 | |
| 21 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 24 | |
| 25 | template <class _Comp, class _Proj> | |
| 26 | class _MinmaxElementLessFunc { | |
| 27 | _Comp& __comp_; | |
| 28 | _Proj& __proj_; | |
| 29 | ||
| 30 | public: | |
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 32 | _MinmaxElementLessFunc(_Comp& __comp, _Proj& __proj) : __comp_(__comp), __proj_(__proj) {} | |
| 33 | ||
| 34 | template <class _Iter> | |
| 35 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 36 | bool operator()(_Iter& __it1, _Iter& __it2) { | |
| 37 | return std::__invoke(__comp_, std::__invoke(__proj_, *__it1), std::__invoke(__proj_, *__it2)); | |
| 38 | } | |
| 39 | }; | |
| 40 | ||
| 41 | template <class _Iter, class _Sent, class _Proj, class _Comp> | |
| 42 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 43 | pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 44 | auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj); | |
| 45 | ||
| 46 | pair<_Iter, _Iter> __result(__first, __first); | |
| 47 | if (__first == __last || ++__first == __last) | |
| 48 | return __result; | |
| 49 | ||
| 50 | if (__less(__first, __result.first)) | |
| 51 | __result.first = __first; | |
| 52 | else | |
| 53 | __result.second = __first; | |
| 54 | ||
| 55 | while (++__first != __last) { | |
| 56 | _Iter __i = __first; | |
| 57 | if (++__first == __last) { | |
| 58 | if (__less(__i, __result.first)) | |
| 59 | __result.first = __i; | |
| 60 | else if (!__less(__i, __result.second)) | |
| 61 | __result.second = __i; | |
| 62 | return __result; | |
| 63 | } | |
| 64 | ||
| 65 | if (__less(__first, __i)) { | |
| 66 | if (__less(__first, __result.first)) | |
| 67 | __result.first = __first; | |
| 68 | if (!__less(__i, __result.second)) | |
| 69 | __result.second = __i; | |
| 70 | } else { | |
| 71 | if (__less(__i, __result.first)) | |
| 72 | __result.first = __i; | |
| 73 | if (!__less(__first, __result.second)) | |
| 74 | __result.second = __first; | |
| 75 | } | |
| 76 | } | |
| 77 | ||
| 78 | return __result; | |
| 79 | } | |
| 80 | ||
| 23 | 81 | template <class _ForwardIterator, class _Compare> |
| 24 | 82 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 25 | 83 | pair<_ForwardIterator, _ForwardIterator> |
| 26 | minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) | |
| 27 | { | |
| 84 | minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) { | |
| 28 | 85 | static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 29 | "std::minmax_element requires a ForwardIterator"); | |
| 30 | pair<_ForwardIterator, _ForwardIterator> __result(__first, __first); | |
| 31 | if (__first != __last) | |
| 32 | { | |
| 33 | if (++__first != __last) | |
| 34 | { | |
| 35 | if (__comp(*__first, *__result.first)) | |
| 36 | __result.first = __first; | |
| 37 | else | |
| 38 | __result.second = __first; | |
| 39 | while (++__first != __last) | |
| 40 | { | |
| 41 | _ForwardIterator __i = __first; | |
| 42 | if (++__first == __last) | |
| 43 | { | |
| 44 | if (__comp(*__i, *__result.first)) | |
| 45 | __result.first = __i; | |
| 46 | else if (!__comp(*__i, *__result.second)) | |
| 47 | __result.second = __i; | |
| 48 | break; | |
| 49 | } | |
| 50 | else | |
| 51 | { | |
| 52 | if (__comp(*__first, *__i)) | |
| 53 | { | |
| 54 | if (__comp(*__first, *__result.first)) | |
| 55 | __result.first = __first; | |
| 56 | if (!__comp(*__i, *__result.second)) | |
| 57 | __result.second = __i; | |
| 58 | } | |
| 59 | else | |
| 60 | { | |
| 61 | if (__comp(*__i, *__result.first)) | |
| 62 | __result.first = __i; | |
| 63 | if (!__comp(*__first, *__result.second)) | |
| 64 | __result.second = __first; | |
| 65 | } | |
| 66 | } | |
| 67 | } | |
| 68 | } | |
| 69 | } | |
| 70 | return __result; | |
| 86 | "std::minmax_element requires a ForwardIterator"); | |
| 87 | static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value, | |
| 88 | "The comparator has to be callable"); | |
| 89 | auto __proj = __identity(); | |
| 90 | return std::__minmax_element_impl(__first, __last, __comp, __proj); | |
| 71 | 91 | } |
| 72 | 92 | |
| 73 | 93 | template <class _ForwardIterator> |
| 74 | _LIBCPP_NODISCARD_EXT inline | |
| 75 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 76 | pair<_ForwardIterator, _ForwardIterator> | |
| 77 | minmax_element(_ForwardIterator __first, _ForwardIterator __last) | |
| 78 | { | |
| 79 | return _VSTD::minmax_element(__first, __last, | |
| 80 | __less<typename iterator_traits<_ForwardIterator>::value_type>()); | |
| 94 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 95 | pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) { | |
| 96 | return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>()); | |
| 81 | 97 | } |
| 82 | 98 | |
| 83 | 99 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/mismatch.h+2-2| ... | ... | @@ -13,10 +13,10 @@ |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <utility> | |
| 16 | #include <__utility/pair.h> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/move.h+78-41| ... | ... | @@ -11,66 +11,103 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__iterator/iterator_traits.h> | |
| 15 | #include <__iterator/reverse_iterator.h> | |
| 14 | 16 | #include <__utility/move.h> |
| 17 | #include <__utility/pair.h> | |
| 15 | 18 | #include <cstring> |
| 16 | 19 | #include <type_traits> |
| 17 | #include <utility> | |
| 18 | 20 | |
| 19 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 21 | 23 | #endif |
| 22 | 24 | |
| 23 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 26 | |
| 25 | 27 | // move |
| 26 | 28 | |
| 27 | template <class _InputIterator, class _OutputIterator> | |
| 29 | template <class _InIter, class _Sent, class _OutIter> | |
| 28 | 30 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 29 | _OutputIterator | |
| 30 | __move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 31 | { | |
| 32 | for (; __first != __last; ++__first, (void) ++__result) | |
| 33 | *__result = _VSTD::move(*__first); | |
| 34 | return __result; | |
| 31 | pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { | |
| 32 | while (__first != __last) { | |
| 33 | *__result = std::move(*__first); | |
| 34 | ++__first; | |
| 35 | ++__result; | |
| 36 | } | |
| 37 | return std::make_pair(std::move(__first), std::move(__result)); | |
| 35 | 38 | } |
| 36 | 39 | |
| 37 | template <class _InputIterator, class _OutputIterator> | |
| 38 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 39 | _OutputIterator | |
| 40 | __move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 41 | { | |
| 42 | return _VSTD::__move_constexpr(__first, __last, __result); | |
| 40 | template <class _InType, | |
| 41 | class _OutType, | |
| 42 | class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value | |
| 43 | && is_trivially_move_assignable<_OutType>::value> > | |
| 44 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 45 | pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) { | |
| 46 | if (__libcpp_is_constant_evaluated() | |
| 47 | // TODO: Remove this once GCC supports __builtin_memmove during constant evaluation | |
| 48 | #ifndef _LIBCPP_COMPILER_GCC | |
| 49 | && !is_trivially_copyable<_InType>::value | |
| 50 | #endif | |
| 51 | ) | |
| 52 | return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result); | |
| 53 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 54 | ::__builtin_memmove(__result, __first, __n * sizeof(_OutType)); | |
| 55 | return std::make_pair(__first + __n, __result + __n); | |
| 43 | 56 | } |
| 44 | 57 | |
| 45 | template <class _Tp, class _Up> | |
| 46 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 47 | typename enable_if | |
| 48 | < | |
| 49 | is_same<typename remove_const<_Tp>::type, _Up>::value && | |
| 50 | is_trivially_move_assignable<_Up>::value, | |
| 51 | _Up* | |
| 52 | >::type | |
| 53 | __move(_Tp* __first, _Tp* __last, _Up* __result) | |
| 54 | { | |
| 55 | const size_t __n = static_cast<size_t>(__last - __first); | |
| 56 | if (__n > 0) | |
| 57 | _VSTD::memmove(__result, __first, __n * sizeof(_Up)); | |
| 58 | return __result + __n; | |
| 58 | template <class> | |
| 59 | struct __is_trivially_move_assignable_unwrapped_impl : false_type {}; | |
| 60 | ||
| 61 | template <class _Type> | |
| 62 | struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {}; | |
| 63 | ||
| 64 | template <class _Iter> | |
| 65 | struct __is_trivially_move_assignable_unwrapped | |
| 66 | : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {}; | |
| 67 | ||
| 68 | template <class _InIter, | |
| 69 | class _OutIter, | |
| 70 | __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type, | |
| 71 | typename iterator_traits<_OutIter>::value_type>::value | |
| 72 | && __is_cpp17_contiguous_iterator<_InIter>::value | |
| 73 | && __is_cpp17_contiguous_iterator<_OutIter>::value | |
| 74 | && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0> | |
| 75 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 76 | pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> > | |
| 77 | __move_impl(reverse_iterator<_InIter> __first, | |
| 78 | reverse_iterator<_InIter> __last, | |
| 79 | reverse_iterator<_OutIter> __result) { | |
| 80 | auto __first_base = std::__unwrap_iter(__first.base()); | |
| 81 | auto __last_base = std::__unwrap_iter(__last.base()); | |
| 82 | auto __result_base = std::__unwrap_iter(__result.base()); | |
| 83 | auto __result_first = __result_base - (__first_base - __last_base); | |
| 84 | std::__move_impl(__last_base, __first_base, __result_first); | |
| 85 | return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first))); | |
| 86 | } | |
| 87 | ||
| 88 | template <class _InIter, class _Sent, class _OutIter> | |
| 89 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 90 | __enable_if_t<is_copy_constructible<_InIter>::value | |
| 91 | && is_copy_constructible<_Sent>::value | |
| 92 | && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > | |
| 93 | __move(_InIter __first, _Sent __last, _OutIter __result) { | |
| 94 | auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result)); | |
| 95 | return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); | |
| 96 | } | |
| 97 | ||
| 98 | template <class _InIter, class _Sent, class _OutIter> | |
| 99 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 100 | __enable_if_t<!is_copy_constructible<_InIter>::value | |
| 101 | || !is_copy_constructible<_Sent>::value | |
| 102 | || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > | |
| 103 | __move(_InIter __first, _Sent __last, _OutIter __result) { | |
| 104 | return std::__move_impl(std::move(__first), std::move(__last), std::move(__result)); | |
| 59 | 105 | } |
| 60 | 106 | |
| 61 | 107 | template <class _InputIterator, class _OutputIterator> |
| 62 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 63 | _OutputIterator | |
| 64 | move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 65 | { | |
| 66 | if (__libcpp_is_constant_evaluated()) { | |
| 67 | return _VSTD::__move_constexpr(__first, __last, __result); | |
| 68 | } else { | |
| 69 | return _VSTD::__rewrap_iter(__result, | |
| 70 | _VSTD::__move(_VSTD::__unwrap_iter(__first), | |
| 71 | _VSTD::__unwrap_iter(__last), | |
| 72 | _VSTD::__unwrap_iter(__result))); | |
| 73 | } | |
| 108 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 109 | _OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | |
| 110 | return std::__move(__first, __last, __result).second; | |
| 74 | 111 | } |
| 75 | 112 | |
| 76 | 113 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/move_backward.h+2-2| ... | ... | @@ -11,12 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/unwrap_iter.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__utility/move.h> | |
| 14 | 15 | #include <cstring> |
| 15 | 16 | #include <type_traits> |
| 16 | #include <utility> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/next_permutation.h+1-1| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <__utility/swap.h> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/none_of.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/nth_element.h+42-31| ... | ... | @@ -11,17 +11,16 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__algorithm/sort.h> |
| 15 | 16 | #include <__config> |
| 17 | #include <__debug> | |
| 18 | #include <__debug_utils/randomize_range.h> | |
| 16 | 19 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/swap.h> | |
| 18 | ||
| 19 | #if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 20 | # include <__algorithm/shuffle.h> | |
| 21 | #endif | |
| 20 | #include <__utility/move.h> | |
| 22 | 21 | |
| 23 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 25 | 24 | #endif |
| 26 | 25 | |
| 27 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -42,10 +41,12 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j, |
| 42 | 41 | } |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | template <class _Compare, class _RandomAccessIterator> | |
| 44 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 46 | 45 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void |
| 47 | 46 | __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) |
| 48 | 47 | { |
| 48 | using _Ops = _IterOps<_AlgPolicy>; | |
| 49 | ||
| 49 | 50 | // _Compare is known to be a reference type |
| 50 | 51 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 51 | 52 | const difference_type __limit = 7; |
| ... | ... | @@ -61,24 +62,24 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 61 | 62 | return; |
| 62 | 63 | case 2: |
| 63 | 64 | if (__comp(*--__last, *__first)) |
| 64 | swap(*__first, *__last); | |
| 65 | _Ops::iter_swap(__first, __last); | |
| 65 | 66 | return; |
| 66 | 67 | case 3: |
| 67 | 68 | { |
| 68 | 69 | _RandomAccessIterator __m = __first; |
| 69 | _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp); | |
| 70 | std::__sort3<_AlgPolicy, _Compare>(__first, ++__m, --__last, __comp); | |
| 70 | 71 | return; |
| 71 | 72 | } |
| 72 | 73 | } |
| 73 | 74 | if (__len <= __limit) |
| 74 | 75 | { |
| 75 | _VSTD::__selection_sort<_Compare>(__first, __last, __comp); | |
| 76 | std::__selection_sort<_AlgPolicy, _Compare>(__first, __last, __comp); | |
| 76 | 77 | return; |
| 77 | 78 | } |
| 78 | 79 | // __len > __limit >= 3 |
| 79 | 80 | _RandomAccessIterator __m = __first + __len/2; |
| 80 | 81 | _RandomAccessIterator __lm1 = __last; |
| 81 | unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp); | |
| 82 | unsigned __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, --__lm1, __comp); | |
| 82 | 83 | // *__m is median |
| 83 | 84 | // partition [__first, __m) < *__m and *__m <= [__m, __last) |
| 84 | 85 | // (this inhibits tossing elements equivalent to __m around unnecessarily) |
| ... | ... | @@ -91,7 +92,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 91 | 92 | { |
| 92 | 93 | // *__first == *__m, *__first doesn't go in first part |
| 93 | 94 | if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) { |
| 94 | swap(*__i, *__j); | |
| 95 | _Ops::iter_swap(__i, __j); | |
| 95 | 96 | ++__n_swaps; |
| 96 | 97 | } else { |
| 97 | 98 | // *__first == *__m, *__m <= all other elements |
| ... | ... | @@ -103,7 +104,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 103 | 104 | if (__i == __j) { |
| 104 | 105 | return; // [__first, __last) all equivalent elements |
| 105 | 106 | } else if (__comp(*__first, *__i)) { |
| 106 | swap(*__i, *__j); | |
| 107 | _Ops::iter_swap(__i, __j); | |
| 107 | 108 | ++__n_swaps; |
| 108 | 109 | ++__i; |
| 109 | 110 | break; |
| ... | ... | @@ -122,7 +123,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 122 | 123 | ; |
| 123 | 124 | if (__i >= __j) |
| 124 | 125 | break; |
| 125 | swap(*__i, *__j); | |
| 126 | _Ops::iter_swap(__i, __j); | |
| 126 | 127 | ++__n_swaps; |
| 127 | 128 | ++__i; |
| 128 | 129 | } |
| ... | ... | @@ -153,7 +154,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 153 | 154 | ; |
| 154 | 155 | if (__i >= __j) |
| 155 | 156 | break; |
| 156 | swap(*__i, *__j); | |
| 157 | _Ops::iter_swap(__i, __j); | |
| 157 | 158 | ++__n_swaps; |
| 158 | 159 | // It is known that __m != __j |
| 159 | 160 | // If __m just moved, follow it |
| ... | ... | @@ -165,7 +166,7 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 165 | 166 | // [__first, __i) < *__m and *__m <= [__i, __last) |
| 166 | 167 | if (__i != __m && __comp(*__m, *__i)) |
| 167 | 168 | { |
| 168 | swap(*__i, *__m); | |
| 169 | _Ops::iter_swap(__i, __m); | |
| 169 | 170 | ++__n_swaps; |
| 170 | 171 | } |
| 171 | 172 | // [__first, __i) < *__i and *__i <= [__i+1, __last) |
| ... | ... | @@ -221,26 +222,36 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando |
| 221 | 222 | } |
| 222 | 223 | } |
| 223 | 224 | |
| 224 | template <class _RandomAccessIterator, class _Compare> | |
| 225 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 226 | void | |
| 227 | nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) | |
| 228 | { | |
| 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); | |
| 225 | template <class _AlgPolicy, class _RandomAccessIterator, class _Compare> | |
| 226 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 227 | void __nth_element_impl(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, | |
| 228 | _Compare& __comp) { | |
| 229 | if (__nth == __last) | |
| 230 | return; | |
| 231 | ||
| 232 | std::__debug_randomize_range<_AlgPolicy>(__first, __last); | |
| 233 | ||
| 234 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; | |
| 235 | std::__nth_element<_AlgPolicy, _Comp_ref>(__first, __nth, __last, __comp); | |
| 236 | ||
| 237 | std::__debug_randomize_range<_AlgPolicy>(__first, __nth); | |
| 233 | 238 | if (__nth != __last) { |
| 234 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(++__nth, __last); | |
| 239 | std::__debug_randomize_range<_AlgPolicy>(++__nth, __last); | |
| 235 | 240 | } |
| 236 | 241 | } |
| 237 | 242 | |
| 243 | template <class _RandomAccessIterator, class _Compare> | |
| 244 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 245 | void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, | |
| 246 | _Compare __comp) { | |
| 247 | std::__nth_element_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__nth), std::move(__last), __comp); | |
| 248 | } | |
| 249 | ||
| 238 | 250 | template <class _RandomAccessIterator> |
| 239 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 240 | void | |
| 241 | nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) | |
| 242 | { | |
| 243 | _VSTD::nth_element(__first, __nth, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 251 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 252 | void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) { | |
| 253 | std::nth_element(std::move(__first), std::move(__nth), std::move(__last), __less<typename | |
| 254 | iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 244 | 255 | } |
| 245 | 256 | |
| 246 | 257 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/partial_sort.h+51-28| ... | ... | @@ -11,41 +11,64 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__algorithm/make_heap.h> |
| 15 | 16 | #include <__algorithm/sift_down.h> |
| 16 | 17 | #include <__algorithm/sort_heap.h> |
| 17 | 18 | #include <__config> |
| 19 | #include <__debug> | |
| 20 | #include <__debug_utils/randomize_range.h> | |
| 18 | 21 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__utility/swap.h> | |
| 20 | ||
| 21 | #if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 22 | # include <__algorithm/shuffle.h> | |
| 23 | #endif | |
| 22 | #include <__utility/move.h> | |
| 23 | #include <type_traits> | |
| 24 | 24 | |
| 25 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | |
| 31 | template <class _Compare, class _RandomAccessIterator> | |
| 32 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 33 | __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, | |
| 34 | _Compare __comp) | |
| 35 | { | |
| 36 | if (__first == __middle) | |
| 37 | return; | |
| 38 | _VSTD::__make_heap<_Compare>(__first, __middle, __comp); | |
| 39 | typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; | |
| 40 | for (_RandomAccessIterator __i = __middle; __i != __last; ++__i) | |
| 41 | { | |
| 42 | if (__comp(*__i, *__first)) | |
| 43 | { | |
| 44 | swap(*__i, *__first); | |
| 45 | _VSTD::__sift_down<_Compare>(__first, __comp, __len, __first); | |
| 46 | } | |
| 47 | } | |
| 48 | _VSTD::__sort_heap<_Compare>(__first, __middle, __comp); | |
| 31 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel> | |
| 32 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 33 | _RandomAccessIterator __partial_sort_impl( | |
| 34 | _RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, _Compare&& __comp) { | |
| 35 | if (__first == __middle) { | |
| 36 | return _IterOps<_AlgPolicy>::next(__middle, __last); | |
| 37 | } | |
| 38 | ||
| 39 | std::__make_heap<_AlgPolicy>(__first, __middle, __comp); | |
| 40 | ||
| 41 | typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; | |
| 42 | _RandomAccessIterator __i = __middle; | |
| 43 | for (; __i != __last; ++__i) | |
| 44 | { | |
| 45 | if (__comp(*__i, *__first)) | |
| 46 | { | |
| 47 | _IterOps<_AlgPolicy>::iter_swap(__i, __first); | |
| 48 | std::__sift_down<_AlgPolicy>(__first, __comp, __len, __first); | |
| 49 | } | |
| 50 | ||
| 51 | } | |
| 52 | std::__sort_heap<_AlgPolicy>(std::move(__first), std::move(__middle), __comp); | |
| 53 | ||
| 54 | return __i; | |
| 55 | } | |
| 56 | ||
| 57 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, class _Sentinel> | |
| 58 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 59 | _RandomAccessIterator __partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Sentinel __last, | |
| 60 | _Compare& __comp) { | |
| 61 | if (__first == __middle) | |
| 62 | return _IterOps<_AlgPolicy>::next(__middle, __last); | |
| 63 | ||
| 64 | std::__debug_randomize_range<_AlgPolicy>(__first, __last); | |
| 65 | ||
| 66 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; | |
| 67 | auto __last_iter = std::__partial_sort_impl<_AlgPolicy>(__first, __middle, __last, static_cast<_Comp_ref>(__comp)); | |
| 68 | ||
| 69 | std::__debug_randomize_range<_AlgPolicy>(__middle, __last); | |
| 70 | ||
| 71 | return __last_iter; | |
| 49 | 72 | } |
| 50 | 73 | |
| 51 | 74 | template <class _RandomAccessIterator, class _Compare> |
| ... | ... | @@ -54,10 +77,10 @@ void |
| 54 | 77 | partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, |
| 55 | 78 | _Compare __comp) |
| 56 | 79 | { |
| 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); | |
| 80 | static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible."); | |
| 81 | static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable."); | |
| 82 | ||
| 83 | (void)std::__partial_sort<_ClassicAlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __comp); | |
| 61 | 84 | } |
| 62 | 85 | |
| 63 | 86 | template <class _RandomAccessIterator> |
lib/libcxx/include/__algorithm/partial_sort_copy.h+31-13| ... | ... | @@ -11,39 +11,52 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__algorithm/make_heap.h> |
| 16 | #include <__algorithm/make_projected.h> | |
| 15 | 17 | #include <__algorithm/sift_down.h> |
| 16 | 18 | #include <__algorithm/sort_heap.h> |
| 17 | 19 | #include <__config> |
| 20 | #include <__functional/identity.h> | |
| 21 | #include <__functional/invoke.h> | |
| 18 | 22 | #include <__iterator/iterator_traits.h> |
| 23 | #include <__type_traits/is_callable.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | #include <__utility/pair.h> | |
| 19 | 26 | |
| 20 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 28 | # pragma GCC system_header | |
| 22 | 29 | #endif |
| 23 | 30 | |
| 24 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 32 | |
| 26 | template <class _Compare, class _InputIterator, class _RandomAccessIterator> | |
| 27 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator | |
| 28 | __partial_sort_copy(_InputIterator __first, _InputIterator __last, | |
| 29 | _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) | |
| 33 | template <class _AlgPolicy, class _Compare, | |
| 34 | class _InputIterator, class _Sentinel1, class _RandomAccessIterator, class _Sentinel2, | |
| 35 | class _Proj1, class _Proj2> | |
| 36 | _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator, _RandomAccessIterator> | |
| 37 | __partial_sort_copy(_InputIterator __first, _Sentinel1 __last, | |
| 38 | _RandomAccessIterator __result_first, _Sentinel2 __result_last, | |
| 39 | _Compare&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) | |
| 30 | 40 | { |
| 31 | 41 | _RandomAccessIterator __r = __result_first; |
| 42 | auto&& __projected_comp = std::__make_projected(__comp, __proj2); | |
| 43 | ||
| 32 | 44 | if (__r != __result_last) |
| 33 | 45 | { |
| 34 | 46 | for (; __first != __last && __r != __result_last; ++__first, (void) ++__r) |
| 35 | 47 | *__r = *__first; |
| 36 | _VSTD::__make_heap<_Compare>(__result_first, __r, __comp); | |
| 48 | std::__make_heap<_AlgPolicy>(__result_first, __r, __projected_comp); | |
| 37 | 49 | typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first; |
| 38 | 50 | for (; __first != __last; ++__first) |
| 39 | if (__comp(*__first, *__result_first)) | |
| 40 | { | |
| 51 | if (std::__invoke(__comp, std::__invoke(__proj1, *__first), std::__invoke(__proj2, *__result_first))) { | |
| 41 | 52 | *__result_first = *__first; |
| 42 | _VSTD::__sift_down<_Compare>(__result_first, __comp, __len, __result_first); | |
| 53 | std::__sift_down<_AlgPolicy>(__result_first, __projected_comp, __len, __result_first); | |
| 43 | 54 | } |
| 44 | _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp); | |
| 55 | std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp); | |
| 45 | 56 | } |
| 46 | return __r; | |
| 57 | ||
| 58 | return pair<_InputIterator, _RandomAccessIterator>( | |
| 59 | _IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r)); | |
| 47 | 60 | } |
| 48 | 61 | |
| 49 | 62 | template <class _InputIterator, class _RandomAccessIterator, class _Compare> |
| ... | ... | @@ -52,8 +65,13 @@ _RandomAccessIterator |
| 52 | 65 | partial_sort_copy(_InputIterator __first, _InputIterator __last, |
| 53 | 66 | _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) |
| 54 | 67 | { |
| 55 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 56 | return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); | |
| 68 | static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__result_first)>::value, | |
| 69 | "Comparator has to be callable"); | |
| 70 | ||
| 71 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; | |
| 72 | auto __result = std::__partial_sort_copy<_ClassicAlgPolicy>(__first, __last, __result_first, __result_last, | |
| 73 | static_cast<_Comp_ref>(__comp), __identity(), __identity()); | |
| 74 | return __result.second; | |
| 57 | 75 | } |
| 58 | 76 | |
| 59 | 77 | template <class _InputIterator, class _RandomAccessIterator> |
lib/libcxx/include/__algorithm/partition.h+34-17| ... | ... | @@ -9,50 +9,58 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_PARTITION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_PARTITION_H |
| 11 | 11 | |
| 12 | #include <__algorithm/iterator_operations.h> | |
| 12 | 13 | #include <__config> |
| 13 | 14 | #include <__iterator/iterator_traits.h> |
| 14 | #include <__utility/swap.h> | |
| 15 | #include <__utility/move.h> | |
| 16 | #include <__utility/pair.h> | |
| 17 | #include <type_traits> | |
| 15 | 18 | |
| 16 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 18 | 21 | #endif |
| 19 | 22 | |
| 20 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 24 | |
| 22 | template <class _Predicate, class _ForwardIterator> | |
| 23 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 24 | __partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) | |
| 25 | template <class _Predicate, class _AlgPolicy, class _ForwardIterator, class _Sentinel> | |
| 26 | _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> | |
| 27 | __partition_impl(_ForwardIterator __first, _Sentinel __last, _Predicate __pred, forward_iterator_tag) | |
| 25 | 28 | { |
| 26 | 29 | while (true) |
| 27 | 30 | { |
| 28 | 31 | if (__first == __last) |
| 29 | return __first; | |
| 32 | return std::make_pair(std::move(__first), std::move(__first)); | |
| 30 | 33 | if (!__pred(*__first)) |
| 31 | 34 | break; |
| 32 | 35 | ++__first; |
| 33 | 36 | } |
| 34 | for (_ForwardIterator __p = __first; ++__p != __last;) | |
| 37 | ||
| 38 | _ForwardIterator __p = __first; | |
| 39 | while (++__p != __last) | |
| 35 | 40 | { |
| 36 | 41 | if (__pred(*__p)) |
| 37 | 42 | { |
| 38 | swap(*__first, *__p); | |
| 43 | _IterOps<_AlgPolicy>::iter_swap(__first, __p); | |
| 39 | 44 | ++__first; |
| 40 | 45 | } |
| 41 | 46 | } |
| 42 | return __first; | |
| 47 | return std::make_pair(std::move(__first), std::move(__p)); | |
| 43 | 48 | } |
| 44 | 49 | |
| 45 | template <class _Predicate, class _BidirectionalIterator> | |
| 46 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator | |
| 47 | __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, | |
| 50 | template <class _Predicate, class _AlgPolicy, class _BidirectionalIterator, class _Sentinel> | |
| 51 | _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_BidirectionalIterator, _BidirectionalIterator> | |
| 52 | __partition_impl(_BidirectionalIterator __first, _Sentinel __sentinel, _Predicate __pred, | |
| 48 | 53 | bidirectional_iterator_tag) |
| 49 | 54 | { |
| 55 | _BidirectionalIterator __original_last = _IterOps<_AlgPolicy>::next(__first, __sentinel); | |
| 56 | _BidirectionalIterator __last = __original_last; | |
| 57 | ||
| 50 | 58 | while (true) |
| 51 | 59 | { |
| 52 | 60 | while (true) |
| 53 | 61 | { |
| 54 | 62 | if (__first == __last) |
| 55 | return __first; | |
| 63 | return std::make_pair(std::move(__first), std::move(__original_last)); | |
| 56 | 64 | if (!__pred(*__first)) |
| 57 | 65 | break; |
| 58 | 66 | ++__first; |
| ... | ... | @@ -60,20 +68,29 @@ __partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Pred |
| 60 | 68 | do |
| 61 | 69 | { |
| 62 | 70 | if (__first == --__last) |
| 63 | return __first; | |
| 71 | return std::make_pair(std::move(__first), std::move(__original_last)); | |
| 64 | 72 | } while (!__pred(*__last)); |
| 65 | swap(*__first, *__last); | |
| 73 | _IterOps<_AlgPolicy>::iter_swap(__first, __last); | |
| 66 | 74 | ++__first; |
| 67 | 75 | } |
| 68 | 76 | } |
| 69 | 77 | |
| 78 | template <class _AlgPolicy, class _ForwardIterator, class _Sentinel, class _Predicate, class _IterCategory> | |
| 79 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 80 | pair<_ForwardIterator, _ForwardIterator> __partition( | |
| 81 | _ForwardIterator __first, _Sentinel __last, _Predicate&& __pred, _IterCategory __iter_category) { | |
| 82 | return std::__partition_impl<__uncvref_t<_Predicate>&, _AlgPolicy>( | |
| 83 | std::move(__first), std::move(__last), __pred, __iter_category); | |
| 84 | } | |
| 85 | ||
| 70 | 86 | template <class _ForwardIterator, class _Predicate> |
| 71 | 87 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 72 | 88 | _ForwardIterator |
| 73 | 89 | partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) |
| 74 | 90 | { |
| 75 | return _VSTD::__partition<_Predicate&>( | |
| 76 | __first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 91 | using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category; | |
| 92 | auto __result = std::__partition<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred, _IterCategory()); | |
| 93 | return __result.first; | |
| 77 | 94 | } |
| 78 | 95 | |
| 79 | 96 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/partition_copy.h+2-2| ... | ... | @@ -11,10 +11,10 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__iterator/iterator_traits.h> |
| 14 | #include <utility> // pair | |
| 14 | #include <__utility/pair.h> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/partition_point.h+4-2| ... | ... | @@ -11,10 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/half_positive.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <iterator> | |
| 14 | #include <__iterator/advance.h> | |
| 15 | #include <__iterator/distance.h> | |
| 16 | #include <__iterator/iterator_traits.h> | |
| 15 | 17 | |
| 16 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 18 | 20 | #endif |
| 19 | 21 | |
| 20 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/pop_heap.h+40-23| ... | ... | @@ -11,45 +11,62 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | #include <__algorithm/push_heap.h> | |
| 14 | 16 | #include <__algorithm/sift_down.h> |
| 17 | #include <__assert> | |
| 15 | 18 | #include <__config> |
| 16 | 19 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/swap.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | #include <type_traits> | |
| 18 | 22 | |
| 19 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 21 | 25 | #endif |
| 22 | 26 | |
| 23 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 28 | |
| 25 | template <class _Compare, class _RandomAccessIterator> | |
| 26 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 27 | void | |
| 28 | __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, | |
| 29 | typename iterator_traits<_RandomAccessIterator>::difference_type __len) | |
| 30 | { | |
| 31 | if (__len > 1) | |
| 32 | { | |
| 33 | swap(*__first, *--__last); | |
| 34 | _VSTD::__sift_down<_Compare>(__first, __comp, __len - 1, __first); | |
| 29 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 30 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 31 | void __pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp, | |
| 32 | typename iterator_traits<_RandomAccessIterator>::difference_type __len) { | |
| 33 | _LIBCPP_ASSERT(__len > 0, "The heap given to pop_heap must be non-empty"); | |
| 34 | ||
| 35 | using _CompRef = typename __comp_ref_type<_Compare>::type; | |
| 36 | _CompRef __comp_ref = __comp; | |
| 37 | ||
| 38 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; | |
| 39 | if (__len > 1) { | |
| 40 | value_type __top = _IterOps<_AlgPolicy>::__iter_move(__first); // create a hole at __first | |
| 41 | _RandomAccessIterator __hole = std::__floyd_sift_down<_AlgPolicy>(__first, __comp_ref, __len); | |
| 42 | --__last; | |
| 43 | ||
| 44 | if (__hole == __last) { | |
| 45 | *__hole = std::move(__top); | |
| 46 | } else { | |
| 47 | *__hole = _IterOps<_AlgPolicy>::__iter_move(__last); | |
| 48 | ++__hole; | |
| 49 | *__last = std::move(__top); | |
| 50 | std::__sift_up<_AlgPolicy>(__first, __hole, __comp_ref, __hole - __first); | |
| 35 | 51 | } |
| 52 | } | |
| 36 | 53 | } |
| 37 | 54 | |
| 38 | 55 | template <class _RandomAccessIterator, class _Compare> |
| 39 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 40 | void | |
| 41 | pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 42 | { | |
| 43 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 44 | _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); | |
| 56 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 57 | void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 58 | static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible."); | |
| 59 | static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable."); | |
| 60 | ||
| 61 | typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first; | |
| 62 | std::__pop_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp, __len); | |
| 45 | 63 | } |
| 46 | 64 | |
| 47 | 65 | template <class _RandomAccessIterator> |
| 48 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 49 | void | |
| 50 | pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 51 | { | |
| 52 | _VSTD::pop_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 66 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 67 | void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 68 | std::pop_heap(std::move(__first), std::move(__last), | |
| 69 | __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 53 | 70 | } |
| 54 | 71 | |
| 55 | 72 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/prev_permutation.h+1-1| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <__utility/swap.h> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/push_heap.h+44-36| ... | ... | @@ -11,58 +11,66 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__utility/move.h> |
| 18 | #include <type_traits> | |
| 17 | 19 | |
| 18 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 20 | 22 | #endif |
| 21 | 23 | |
| 22 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 25 | |
| 24 | template <class _Compare, class _RandomAccessIterator> | |
| 25 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void | |
| 26 | __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, | |
| 27 | typename iterator_traits<_RandomAccessIterator>::difference_type __len) | |
| 28 | { | |
| 29 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 30 | if (__len > 1) | |
| 31 | { | |
| 32 | __len = (__len - 2) / 2; | |
| 33 | _RandomAccessIterator __ptr = __first + __len; | |
| 34 | if (__comp(*__ptr, *--__last)) | |
| 35 | { | |
| 36 | value_type __t(_VSTD::move(*__last)); | |
| 37 | do | |
| 38 | { | |
| 39 | *__last = _VSTD::move(*__ptr); | |
| 40 | __last = __ptr; | |
| 41 | if (__len == 0) | |
| 42 | break; | |
| 43 | __len = (__len - 1) / 2; | |
| 44 | __ptr = __first + __len; | |
| 45 | } while (__comp(*__ptr, __t)); | |
| 46 | *__last = _VSTD::move(__t); | |
| 47 | } | |
| 26 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 27 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 28 | void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp, | |
| 29 | typename iterator_traits<_RandomAccessIterator>::difference_type __len) { | |
| 30 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; | |
| 31 | ||
| 32 | if (__len > 1) { | |
| 33 | __len = (__len - 2) / 2; | |
| 34 | _RandomAccessIterator __ptr = __first + __len; | |
| 35 | ||
| 36 | if (__comp(*__ptr, *--__last)) { | |
| 37 | value_type __t(_IterOps<_AlgPolicy>::__iter_move(__last)); | |
| 38 | do { | |
| 39 | *__last = _IterOps<_AlgPolicy>::__iter_move(__ptr); | |
| 40 | __last = __ptr; | |
| 41 | if (__len == 0) | |
| 42 | break; | |
| 43 | __len = (__len - 1) / 2; | |
| 44 | __ptr = __first + __len; | |
| 45 | } while (__comp(*__ptr, __t)); | |
| 46 | ||
| 47 | *__last = std::move(__t); | |
| 48 | 48 | } |
| 49 | } | |
| 50 | } | |
| 51 | ||
| 52 | template <class _AlgPolicy, class _RandomAccessIterator, class _Compare> | |
| 53 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 54 | void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) { | |
| 55 | using _CompRef = typename __comp_ref_type<_Compare>::type; | |
| 56 | typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first; | |
| 57 | std::__sift_up<_AlgPolicy, _CompRef>(std::move(__first), std::move(__last), __comp, __len); | |
| 49 | 58 | } |
| 50 | 59 | |
| 51 | 60 | template <class _RandomAccessIterator, class _Compare> |
| 52 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 53 | void | |
| 54 | push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 55 | { | |
| 56 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 57 | _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first); | |
| 61 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 62 | void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 63 | static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible."); | |
| 64 | static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable."); | |
| 65 | ||
| 66 | std::__push_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp); | |
| 58 | 67 | } |
| 59 | 68 | |
| 60 | 69 | template <class _RandomAccessIterator> |
| 61 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 62 | void | |
| 63 | push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 64 | { | |
| 65 | _VSTD::push_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 70 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 71 | void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 72 | std::push_heap(std::move(__first), std::move(__last), | |
| 73 | __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 66 | 74 | } |
| 67 | 75 | |
| 68 | 76 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/ranges_adjacent_find.h created+78| ... | ... | @@ -0,0 +1,78 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __adjacent_find { | |
| 33 | struct __fn { | |
| 34 | ||
| 35 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 37 | _Iter __adjacent_find_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 38 | if (__first == __last) | |
| 39 | return __first; | |
| 40 | ||
| 41 | auto __i = __first; | |
| 42 | while (++__i != __last) { | |
| 43 | if (std::invoke(__pred, std::invoke(__proj, *__first), std::invoke(__proj, *__i))) | |
| 44 | return __first; | |
| 45 | __first = __i; | |
| 46 | } | |
| 47 | return __i; | |
| 48 | } | |
| 49 | ||
| 50 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 51 | class _Proj = identity, | |
| 52 | indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to> | |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 54 | _Iter operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { | |
| 55 | return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 56 | } | |
| 57 | ||
| 58 | template <forward_range _Range, | |
| 59 | class _Proj = identity, | |
| 60 | indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>, | |
| 61 | projected<iterator_t<_Range>, _Proj>> _Pred = ranges::equal_to> | |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 63 | borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const { | |
| 64 | return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 65 | } | |
| 66 | }; | |
| 67 | } // namespace __adjacent_find | |
| 68 | ||
| 69 | inline namespace __cpo { | |
| 70 | inline constexpr auto adjacent_find = __adjacent_find::__fn{}; | |
| 71 | } // namespace __cpo | |
| 72 | } // namespace ranges | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_STD | |
| 75 | ||
| 76 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 77 | ||
| 78 | #endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H |
lib/libcxx/include/__algorithm/ranges_all_of.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ALL_OF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_ALL_OF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/projected.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__utility/move.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | namespace ranges { | |
| 30 | namespace __all_of { | |
| 31 | struct __fn { | |
| 32 | ||
| 33 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 35 | bool __all_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 36 | for (; __first != __last; ++__first) { | |
| 37 | if (!std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 38 | return false; | |
| 39 | } | |
| 40 | return true; | |
| 41 | } | |
| 42 | ||
| 43 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 44 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 46 | bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | |
| 47 | return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 48 | } | |
| 49 | ||
| 50 | template <input_range _Range, class _Proj = identity, | |
| 51 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 53 | bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 54 | return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 55 | } | |
| 56 | }; | |
| 57 | } // namespace __all_of | |
| 58 | ||
| 59 | inline namespace __cpo { | |
| 60 | inline constexpr auto all_of = __all_of::__fn{}; | |
| 61 | } // namespace __cpo | |
| 62 | } // namespace ranges | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | |
| 65 | ||
| 66 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 67 | ||
| 68 | #endif // _LIBCPP___ALGORITHM_RANGES_ALL_OF_H |
lib/libcxx/include/__algorithm/ranges_any_of.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ANY_OF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_ANY_OF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/projected.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__utility/move.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | namespace ranges { | |
| 30 | namespace __any_of { | |
| 31 | struct __fn { | |
| 32 | ||
| 33 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 35 | bool __any_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 36 | for (; __first != __last; ++__first) { | |
| 37 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 38 | return true; | |
| 39 | } | |
| 40 | return false; | |
| 41 | } | |
| 42 | ||
| 43 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 44 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 46 | bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { | |
| 47 | return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 48 | } | |
| 49 | ||
| 50 | template <input_range _Range, class _Proj = identity, | |
| 51 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 53 | bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 54 | return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 55 | } | |
| 56 | }; | |
| 57 | } // namespace __any_of | |
| 58 | ||
| 59 | inline namespace __cpo { | |
| 60 | inline constexpr auto any_of = __any_of::__fn{}; | |
| 61 | } // namespace __cpo | |
| 62 | } // namespace ranges | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | |
| 65 | ||
| 66 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 67 | ||
| 68 | #endif // _LIBCPP___ALGORITHM_RANGES_ANY_OF_H |
lib/libcxx/include/__algorithm/ranges_binary_search.h created+63| ... | ... | @@ -0,0 +1,63 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/lower_bound.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __binary_search { | |
| 33 | struct __fn { | |
| 34 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity, | |
| 35 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 37 | bool operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 38 | auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); | |
| 39 | return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first)); | |
| 40 | } | |
| 41 | ||
| 42 | template <forward_range _Range, class _Type, class _Proj = identity, | |
| 43 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 45 | bool operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 46 | auto __first = ranges::begin(__r); | |
| 47 | auto __last = ranges::end(__r); | |
| 48 | auto __ret = std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); | |
| 49 | return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__first)); | |
| 50 | } | |
| 51 | }; | |
| 52 | } // namespace __binary_search | |
| 53 | ||
| 54 | inline namespace __cpo { | |
| 55 | inline constexpr auto binary_search = __binary_search::__fn{}; | |
| 56 | } // namespace __cpo | |
| 57 | } // namespace ranges | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 62 | ||
| 63 | #endif // _LIBCPP___ALGORITHM_RANGES_BINARY_SEARCH_H |
lib/libcxx/include/__algorithm/ranges_copy.h created+65| ... | ... | @@ -0,0 +1,65 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/copy.h> | |
| 13 | #include <__algorithm/in_out_result.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__ranges/dangling.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | ||
| 32 | template <class _InIter, class _OutIter> | |
| 33 | using copy_result = in_out_result<_InIter, _OutIter>; | |
| 34 | ||
| 35 | namespace __copy { | |
| 36 | struct __fn { | |
| 37 | ||
| 38 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> | |
| 39 | requires indirectly_copyable<_InIter, _OutIter> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 41 | copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { | |
| 42 | auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result)); | |
| 43 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 44 | } | |
| 45 | ||
| 46 | template <input_range _Range, weakly_incrementable _OutIter> | |
| 47 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const { | |
| 50 | auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result)); | |
| 51 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 52 | } | |
| 53 | }; | |
| 54 | } // namespace __copy | |
| 55 | ||
| 56 | inline namespace __cpo { | |
| 57 | inline constexpr auto copy = __copy::__fn{}; | |
| 58 | } // namespace __cpo | |
| 59 | } // namespace ranges | |
| 60 | ||
| 61 | _LIBCPP_END_NAMESPACE_STD | |
| 62 | ||
| 63 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 64 | ||
| 65 | #endif // _LIBCPP___ALGORITHM_RANGES_COPY_H |
lib/libcxx/include/__algorithm/ranges_copy_backward.h created+66| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H | |
| 11 | ||
| 12 | #include <__algorithm/copy_backward.h> | |
| 13 | #include <__algorithm/in_out_result.h> | |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 15 | #include <__config> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/reverse_iterator.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template<class _Ip, class _Op> | |
| 34 | using copy_backward_result = in_out_result<_Ip, _Op>; | |
| 35 | ||
| 36 | namespace __copy_backward { | |
| 37 | struct __fn { | |
| 38 | ||
| 39 | template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2> | |
| 40 | requires indirectly_copyable<_InIter1, _InIter2> | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 42 | copy_backward_result<_InIter1, _InIter2> operator()(_InIter1 __first, _Sent1 __last, _InIter2 __result) const { | |
| 43 | auto __ret = std::__copy_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)); | |
| 44 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 45 | } | |
| 46 | ||
| 47 | template <bidirectional_range _Range, bidirectional_iterator _Iter> | |
| 48 | requires indirectly_copyable<iterator_t<_Range>, _Iter> | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 50 | copy_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __r, _Iter __result) const { | |
| 51 | auto __ret = std::__copy_backward<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result)); | |
| 52 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 53 | } | |
| 54 | }; | |
| 55 | } // namespace __copy_backward | |
| 56 | ||
| 57 | inline namespace __cpo { | |
| 58 | inline constexpr auto copy_backward = __copy_backward::__fn{}; | |
| 59 | } // namespace __cpo | |
| 60 | } // namespace ranges | |
| 61 | ||
| 62 | _LIBCPP_END_NAMESPACE_STD | |
| 63 | ||
| 64 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 65 | ||
| 66 | #endif // _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H |
lib/libcxx/include/__algorithm/ranges_copy_if.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template<class _Ip, class _Op> | |
| 34 | using copy_if_result = in_out_result<_Ip, _Op>; | |
| 35 | ||
| 36 | namespace __copy_if { | |
| 37 | struct __fn { | |
| 38 | ||
| 39 | template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred> | |
| 40 | _LIBCPP_HIDE_FROM_ABI static constexpr | |
| 41 | copy_if_result <_InIter, _OutIter> | |
| 42 | __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) { | |
| 43 | for (; __first != __last; ++__first) { | |
| 44 | if (std::invoke(__pred, std::invoke(__proj, *__first))) { | |
| 45 | *__result = *__first; | |
| 46 | ++__result; | |
| 47 | } | |
| 48 | } | |
| 49 | return {std::move(__first), std::move(__result)}; | |
| 50 | } | |
| 51 | ||
| 52 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Proj = identity, | |
| 53 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 54 | requires indirectly_copyable<_Iter, _OutIter> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 56 | copy_if_result<_Iter, _OutIter> | |
| 57 | operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | |
| 58 | return __copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj); | |
| 59 | } | |
| 60 | ||
| 61 | template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity, | |
| 62 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 63 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | |
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 65 | copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 66 | operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | |
| 67 | return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj); | |
| 68 | } | |
| 69 | }; | |
| 70 | } // namespace __copy_if | |
| 71 | ||
| 72 | inline namespace __cpo { | |
| 73 | inline constexpr auto copy_if = __copy_if::__fn{}; | |
| 74 | } // namespace __cpo | |
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | |
| 78 | ||
| 79 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 80 | ||
| 81 | #endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H |
lib/libcxx/include/__algorithm/ranges_copy_n.h created+76| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COPY_N_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COPY_N_H | |
| 11 | ||
| 12 | #include <__algorithm/copy.h> | |
| 13 | #include <__algorithm/in_out_result.h> | |
| 14 | #include <__algorithm/ranges_copy.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/incrementable_traits.h> | |
| 19 | #include <__iterator/unreachable_sentinel.h> | |
| 20 | #include <__iterator/wrap_iter.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template <class _Ip, class _Op> | |
| 34 | using copy_n_result = in_out_result<_Ip, _Op>; | |
| 35 | ||
| 36 | namespace __copy_n { | |
| 37 | struct __fn { | |
| 38 | ||
| 39 | template <class _InIter, class _DiffType, class _OutIter> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 41 | copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) { | |
| 42 | while (__n != 0) { | |
| 43 | *__result = *__first; | |
| 44 | ++__first; | |
| 45 | ++__result; | |
| 46 | --__n; | |
| 47 | } | |
| 48 | return {std::move(__first), std::move(__result)}; | |
| 49 | } | |
| 50 | ||
| 51 | template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 53 | copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) { | |
| 54 | auto __ret = std::__copy(__first, __first + __n, __result); | |
| 55 | return {__ret.first, __ret.second}; | |
| 56 | } | |
| 57 | ||
| 58 | template <input_iterator _Ip, weakly_incrementable _Op> | |
| 59 | requires indirectly_copyable<_Ip, _Op> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 61 | copy_n_result<_Ip, _Op> operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const { | |
| 62 | return __go(std::move(__first), __n, std::move(__result)); | |
| 63 | } | |
| 64 | }; | |
| 65 | } // namespace __copy_n | |
| 66 | ||
| 67 | inline namespace __cpo { | |
| 68 | inline constexpr auto copy_n = __copy_n::__fn{}; | |
| 69 | } // namespace __cpo | |
| 70 | } // namespace ranges | |
| 71 | ||
| 72 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_STD | |
| 75 | ||
| 76 | #endif // _LIBCPP___ALGORITHM_RANGES_COPY_N_H |
lib/libcxx/include/__algorithm/ranges_count.h created+62| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COUNT_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_count_if.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/incrementable_traits.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | namespace __count { | |
| 34 | struct __fn { | |
| 35 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> | |
| 36 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 38 | iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { | |
| 39 | auto __pred = [&](auto&& __e) { return __e == __value; }; | |
| 40 | return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 41 | } | |
| 42 | ||
| 43 | template <input_range _Range, class _Type, class _Proj = identity> | |
| 44 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 46 | range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const { | |
| 47 | auto __pred = [&](auto&& __e) { return __e == __value; }; | |
| 48 | return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | |
| 49 | } | |
| 50 | }; | |
| 51 | } // namespace __count | |
| 52 | ||
| 53 | inline namespace __cpo { | |
| 54 | inline constexpr auto count = __count::__fn{}; | |
| 55 | } // namespace __cpo | |
| 56 | } // namespace ranges | |
| 57 | ||
| 58 | _LIBCPP_END_NAMESPACE_STD | |
| 59 | ||
| 60 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 61 | ||
| 62 | #endif // _LIBCPP___ALGORITHM_RANGES_COUNT_H |
lib/libcxx/include/__algorithm/ranges_count_if.h created+72| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/incrementable_traits.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 35 | iter_difference_t<_Iter> __count_if_impl(_Iter __first, _Sent __last, | |
| 36 | _Pred& __pred, _Proj& __proj) { | |
| 37 | iter_difference_t<_Iter> __counter(0); | |
| 38 | for (; __first != __last; ++__first) { | |
| 39 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 40 | ++__counter; | |
| 41 | } | |
| 42 | return __counter; | |
| 43 | } | |
| 44 | ||
| 45 | namespace __count_if { | |
| 46 | struct __fn { | |
| 47 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 48 | indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate> | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 50 | iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const { | |
| 51 | return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 52 | } | |
| 53 | ||
| 54 | template <input_range _Range, class _Proj = identity, | |
| 55 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 57 | range_difference_t<_Range> operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const { | |
| 58 | return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | |
| 59 | } | |
| 60 | }; | |
| 61 | } // namespace __count_if | |
| 62 | ||
| 63 | inline namespace __cpo { | |
| 64 | inline constexpr auto count_if = __count_if::__fn{}; | |
| 65 | } // namespace __cpo | |
| 66 | } // namespace ranges | |
| 67 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | |
| 69 | ||
| 70 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 71 | ||
| 72 | #endif // _LIBCPP___ALGORITHM_RANGES_COUNT_IF_H |
lib/libcxx/include/__algorithm/ranges_equal.h created+115| ... | ... | @@ -0,0 +1,115 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_EQUAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/distance.h> | |
| 18 | #include <__iterator/indirectly_comparable.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __equal { | |
| 33 | struct __fn { | |
| 34 | private: | |
| 35 | template <class _Iter1, class _Sent1, | |
| 36 | class _Iter2, class _Sent2, | |
| 37 | class _Pred, | |
| 38 | class _Proj1, | |
| 39 | class _Proj2> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 41 | bool __equal_impl(_Iter1 __first1, _Sent1 __last1, | |
| 42 | _Iter2 __first2, _Sent2 __last2, | |
| 43 | _Pred& __pred, | |
| 44 | _Proj1& __proj1, | |
| 45 | _Proj2& __proj2) { | |
| 46 | while (__first1 != __last1 && __first2 != __last2) { | |
| 47 | if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2))) | |
| 48 | return false; | |
| 49 | ++__first1; | |
| 50 | ++__first2; | |
| 51 | } | |
| 52 | return __first1 == __last1 && __first2 == __last2; | |
| 53 | } | |
| 54 | ||
| 55 | public: | |
| 56 | ||
| 57 | template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | |
| 58 | input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | |
| 59 | class _Pred = ranges::equal_to, | |
| 60 | class _Proj1 = identity, | |
| 61 | class _Proj2 = identity> | |
| 62 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 64 | bool operator()(_Iter1 __first1, _Sent1 __last1, | |
| 65 | _Iter2 __first2, _Sent2 __last2, | |
| 66 | _Pred __pred = {}, | |
| 67 | _Proj1 __proj1 = {}, | |
| 68 | _Proj2 __proj2 = {}) const { | |
| 69 | if constexpr (sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>) { | |
| 70 | if (__last1 - __first1 != __last2 - __first2) | |
| 71 | return false; | |
| 72 | } | |
| 73 | return __equal_impl(std::move(__first1), std::move(__last1), | |
| 74 | std::move(__first2), std::move(__last2), | |
| 75 | __pred, | |
| 76 | __proj1, | |
| 77 | __proj2); | |
| 78 | } | |
| 79 | ||
| 80 | template <input_range _Range1, | |
| 81 | input_range _Range2, | |
| 82 | class _Pred = ranges::equal_to, | |
| 83 | class _Proj1 = identity, | |
| 84 | class _Proj2 = identity> | |
| 85 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | |
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 87 | bool operator()(_Range1&& __range1, | |
| 88 | _Range2&& __range2, | |
| 89 | _Pred __pred = {}, | |
| 90 | _Proj1 __proj1 = {}, | |
| 91 | _Proj2 __proj2 = {}) const { | |
| 92 | if constexpr (sized_range<_Range1> && sized_range<_Range2>) { | |
| 93 | if (ranges::distance(__range1) != ranges::distance(__range2)) | |
| 94 | return false; | |
| 95 | } | |
| 96 | return __equal_impl(ranges::begin(__range1), ranges::end(__range1), | |
| 97 | ranges::begin(__range2), ranges::end(__range2), | |
| 98 | __pred, | |
| 99 | __proj1, | |
| 100 | __proj2); | |
| 101 | return false; | |
| 102 | } | |
| 103 | }; | |
| 104 | } // namespace __equal | |
| 105 | ||
| 106 | inline namespace __cpo { | |
| 107 | inline constexpr auto equal = __equal::__fn{}; | |
| 108 | } // namespace __cpo | |
| 109 | } // namespace ranges | |
| 110 | ||
| 111 | _LIBCPP_END_NAMESPACE_STD | |
| 112 | ||
| 113 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 114 | ||
| 115 | #endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_H |
lib/libcxx/include/__algorithm/ranges_equal_range.h created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM __project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H | |
| 11 | ||
| 12 | #include <__algorithm/equal_range.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/iterator_traits.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/dangling.h> | |
| 24 | #include <__ranges/subrange.h> | |
| 25 | #include <__utility/forward.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | namespace __equal_range { | |
| 38 | ||
| 39 | struct __fn { | |
| 40 | template < | |
| 41 | forward_iterator _Iter, | |
| 42 | sentinel_for<_Iter> _Sent, | |
| 43 | class _Tp, | |
| 44 | class _Proj = identity, | |
| 45 | indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | |
| 47 | operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 48 | auto __ret = std::__equal_range<_RangeAlgPolicy>( | |
| 49 | std::move(__first), std::move(__last), __value, __comp, __proj); | |
| 50 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 51 | } | |
| 52 | ||
| 53 | template < | |
| 54 | forward_range _Range, | |
| 55 | class _Tp, | |
| 56 | class _Proj = identity, | |
| 57 | indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> | |
| 59 | operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 60 | auto __ret = std::__equal_range<_RangeAlgPolicy>( | |
| 61 | ranges::begin(__range), ranges::end(__range), __value, __comp, __proj); | |
| 62 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 63 | } | |
| 64 | }; | |
| 65 | ||
| 66 | } // namespace __equal_range | |
| 67 | ||
| 68 | inline namespace __cpo { | |
| 69 | inline constexpr auto equal_range = __equal_range::__fn{}; | |
| 70 | } // namespace __cpo | |
| 71 | } // namespace ranges | |
| 72 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | |
| 74 | ||
| 75 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 76 | ||
| 77 | #endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H |
lib/libcxx/include/__algorithm/ranges_fill.h created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FILL_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_fill_n.h> | |
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__ranges/access.h> | |
| 16 | #include <__ranges/concepts.h> | |
| 17 | #include <__ranges/dangling.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | namespace ranges { | |
| 28 | namespace __fill { | |
| 29 | struct __fn { | |
| 30 | template <class _Type, output_iterator<const _Type&> _Iter, sentinel_for<_Iter> _Sent> | |
| 31 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 32 | _Iter operator()(_Iter __first, _Sent __last, const _Type& __value) const { | |
| 33 | if constexpr(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) { | |
| 34 | return ranges::fill_n(__first, __last - __first, __value); | |
| 35 | } else { | |
| 36 | for (; __first != __last; ++__first) | |
| 37 | *__first = __value; | |
| 38 | return __first; | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| 42 | template <class _Type, output_range<const _Type&> _Range> | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 44 | borrowed_iterator_t<_Range> operator()(_Range&& __range, const _Type& __value) const { | |
| 45 | return (*this)(ranges::begin(__range), ranges::end(__range), __value); | |
| 46 | } | |
| 47 | }; | |
| 48 | } // namespace __fill | |
| 49 | ||
| 50 | inline namespace __cpo { | |
| 51 | inline constexpr auto fill = __fill::__fn{}; | |
| 52 | } // namespace __cpo | |
| 53 | } // namespace ranges | |
| 54 | ||
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 56 | ||
| 57 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 58 | ||
| 59 | #endif // _LIBCPP___ALGORITHM_RANGES_FILL_H |
lib/libcxx/include/__algorithm/ranges_fill_n.h created+48| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FILL_N_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FILL_N_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__iterator/concepts.h> | |
| 14 | #include <__iterator/incrementable_traits.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | namespace ranges { | |
| 25 | namespace __fill_n { | |
| 26 | struct __fn { | |
| 27 | template <class _Type, output_iterator<const _Type&> _Iter> | |
| 28 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 29 | _Iter operator()(_Iter __first, iter_difference_t<_Iter> __n, const _Type& __value) const { | |
| 30 | for (; __n != 0; --__n) { | |
| 31 | *__first = __value; | |
| 32 | ++__first; | |
| 33 | } | |
| 34 | return __first; | |
| 35 | } | |
| 36 | }; | |
| 37 | } // namespace __fill_n | |
| 38 | ||
| 39 | inline namespace __cpo { | |
| 40 | inline constexpr auto fill_n = __fill_n::__fn{}; | |
| 41 | } // namespace __cpo | |
| 42 | } // namespace ranges | |
| 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | |
| 45 | ||
| 46 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 47 | ||
| 48 | #endif // _LIBCPP___ALGORITHM_RANGES_FILL_N_H |
lib/libcxx/include/__algorithm/ranges_find.h created+63| ... | ... | @@ -0,0 +1,63 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FIND_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_find_if.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/projected.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | #include <__utility/forward.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | namespace __find { | |
| 35 | struct __fn { | |
| 36 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity> | |
| 37 | requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*> | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 39 | _Ip operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const { | |
| 40 | auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; }; | |
| 41 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 42 | } | |
| 43 | ||
| 44 | template <input_range _Rp, class _Tp, class _Proj = identity> | |
| 45 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*> | |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 47 | borrowed_iterator_t<_Rp> operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const { | |
| 48 | auto __pred = [&](auto&& __e) { return std::forward<decltype(__e)>(__e) == __value; }; | |
| 49 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | |
| 50 | } | |
| 51 | }; | |
| 52 | } // namespace __find | |
| 53 | ||
| 54 | inline namespace __cpo { | |
| 55 | inline constexpr auto find = __find::__fn{}; | |
| 56 | } // namespace __cpo | |
| 57 | } // namespace ranges | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 62 | ||
| 63 | #endif // _LIBCPP___ALGORITHM_RANGES_FIND_H |
lib/libcxx/include/__algorithm/ranges_find_end.h created+97| ... | ... | @@ -0,0 +1,97 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_END_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FIND_END_H | |
| 11 | ||
| 12 | #include <__algorithm/find_end.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__algorithm/ranges_iterator_concept.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/indirectly_comparable.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/subrange.h> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | namespace __find_end { | |
| 35 | struct __fn { | |
| 36 | template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | |
| 37 | forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | |
| 38 | class _Pred = ranges::equal_to, | |
| 39 | class _Proj1 = identity, | |
| 40 | class _Proj2 = identity> | |
| 41 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 43 | subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1, | |
| 44 | _Iter2 __first2, _Sent2 __last2, | |
| 45 | _Pred __pred = {}, | |
| 46 | _Proj1 __proj1 = {}, | |
| 47 | _Proj2 __proj2 = {}) const { | |
| 48 | auto __ret = std::__find_end_impl<_RangeAlgPolicy>( | |
| 49 | __first1, | |
| 50 | __last1, | |
| 51 | __first2, | |
| 52 | __last2, | |
| 53 | __pred, | |
| 54 | __proj1, | |
| 55 | __proj2, | |
| 56 | __iterator_concept<_Iter1>(), | |
| 57 | __iterator_concept<_Iter2>()); | |
| 58 | return {__ret.first, __ret.second}; | |
| 59 | } | |
| 60 | ||
| 61 | template <forward_range _Range1, | |
| 62 | forward_range _Range2, | |
| 63 | class _Pred = ranges::equal_to, | |
| 64 | class _Proj1 = identity, | |
| 65 | class _Proj2 = identity> | |
| 66 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 68 | borrowed_subrange_t<_Range1> operator()(_Range1&& __range1, | |
| 69 | _Range2&& __range2, | |
| 70 | _Pred __pred = {}, | |
| 71 | _Proj1 __proj1 = {}, | |
| 72 | _Proj2 __proj2 = {}) const { | |
| 73 | auto __ret = std::__find_end_impl<_RangeAlgPolicy>( | |
| 74 | ranges::begin(__range1), | |
| 75 | ranges::end(__range1), | |
| 76 | ranges::begin(__range2), | |
| 77 | ranges::end(__range2), | |
| 78 | __pred, | |
| 79 | __proj1, | |
| 80 | __proj2, | |
| 81 | __iterator_concept<iterator_t<_Range1>>(), | |
| 82 | __iterator_concept<iterator_t<_Range2>>()); | |
| 83 | return {__ret.first, __ret.second}; | |
| 84 | } | |
| 85 | }; | |
| 86 | } // namespace __find_end | |
| 87 | ||
| 88 | inline namespace __cpo { | |
| 89 | inline constexpr auto find_end = __find_end::__fn{}; | |
| 90 | } // namespace __cpo | |
| 91 | } // namespace ranges | |
| 92 | ||
| 93 | _LIBCPP_END_NAMESPACE_STD | |
| 94 | ||
| 95 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 96 | ||
| 97 | #endif // _LIBCPP___ALGORITHM_RANGES_FIND_END_H |
lib/libcxx/include/__algorithm/ranges_find_first_of.h created+101| ... | ... | @@ -0,0 +1,101 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/indirectly_comparable.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __find_first_of { | |
| 33 | struct __fn { | |
| 34 | ||
| 35 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 37 | _Iter1 __find_first_of_impl(_Iter1 __first1, _Sent1 __last1, | |
| 38 | _Iter2 __first2, _Sent2 __last2, | |
| 39 | _Pred& __pred, | |
| 40 | _Proj1& __proj1, | |
| 41 | _Proj2& __proj2) { | |
| 42 | for (; __first1 != __last1; ++__first1) { | |
| 43 | for (auto __j = __first2; __j != __last2; ++__j) { | |
| 44 | if (std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__j))) | |
| 45 | return __first1; | |
| 46 | } | |
| 47 | } | |
| 48 | return __first1; | |
| 49 | } | |
| 50 | ||
| 51 | template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | |
| 52 | forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | |
| 53 | class _Pred = ranges::equal_to, | |
| 54 | class _Proj1 = identity, | |
| 55 | class _Proj2 = identity> | |
| 56 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 58 | _Iter1 operator()(_Iter1 __first1, _Sent1 __last1, | |
| 59 | _Iter2 __first2, _Sent2 __last2, | |
| 60 | _Pred __pred = {}, | |
| 61 | _Proj1 __proj1 = {}, | |
| 62 | _Proj2 __proj2 = {}) const { | |
| 63 | return __find_first_of_impl(std::move(__first1), std::move(__last1), | |
| 64 | std::move(__first2), std::move(__last2), | |
| 65 | __pred, | |
| 66 | __proj1, | |
| 67 | __proj2); | |
| 68 | } | |
| 69 | ||
| 70 | template <input_range _Range1, | |
| 71 | forward_range _Range2, | |
| 72 | class _Pred = ranges::equal_to, | |
| 73 | class _Proj1 = identity, | |
| 74 | class _Proj2 = identity> | |
| 75 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | |
| 76 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 77 | borrowed_iterator_t<_Range1> operator()(_Range1&& __range1, | |
| 78 | _Range2&& __range2, | |
| 79 | _Pred __pred = {}, | |
| 80 | _Proj1 __proj1 = {}, | |
| 81 | _Proj2 __proj2 = {}) const { | |
| 82 | return __find_first_of_impl(ranges::begin(__range1), ranges::end(__range1), | |
| 83 | ranges::begin(__range2), ranges::end(__range2), | |
| 84 | __pred, | |
| 85 | __proj1, | |
| 86 | __proj2); | |
| 87 | } | |
| 88 | ||
| 89 | }; | |
| 90 | } // namespace __find_first_of | |
| 91 | ||
| 92 | inline namespace __cpo { | |
| 93 | inline constexpr auto find_first_of = __find_first_of::__fn{}; | |
| 94 | } // namespace __cpo | |
| 95 | } // namespace ranges | |
| 96 | ||
| 97 | _LIBCPP_END_NAMESPACE_STD | |
| 98 | ||
| 99 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 100 | ||
| 101 | #endif // _LIBCPP___ALGORITHM_RANGES_FIND_FIRST_OF_H |
lib/libcxx/include/__algorithm/ranges_find_if.h created+71| ... | ... | @@ -0,0 +1,71 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FIND_IF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template <class _Ip, class _Sp, class _Pred, class _Proj> | |
| 34 | _LIBCPP_HIDE_FROM_ABI static constexpr | |
| 35 | _Ip __find_if_impl(_Ip __first, _Sp __last, _Pred& __pred, _Proj& __proj) { | |
| 36 | for (; __first != __last; ++__first) { | |
| 37 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 38 | break; | |
| 39 | } | |
| 40 | return __first; | |
| 41 | } | |
| 42 | ||
| 43 | namespace __find_if { | |
| 44 | struct __fn { | |
| 45 | ||
| 46 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, | |
| 47 | indirect_unary_predicate<projected<_Ip, _Proj>> _Pred> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { | |
| 50 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 51 | } | |
| 52 | ||
| 53 | template <input_range _Rp, class _Proj = identity, | |
| 54 | indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 56 | borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { | |
| 57 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); | |
| 58 | } | |
| 59 | }; | |
| 60 | } // namespace __find_if | |
| 61 | ||
| 62 | inline namespace __cpo { | |
| 63 | inline constexpr auto find_if = __find_if::__fn{}; | |
| 64 | } // namespace __cpo | |
| 65 | } // namespace ranges | |
| 66 | ||
| 67 | _LIBCPP_END_NAMESPACE_STD | |
| 68 | ||
| 69 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 70 | ||
| 71 | #endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_H |
lib/libcxx/include/__algorithm/ranges_find_if_not.h created+63| ... | ... | @@ -0,0 +1,63 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_find_if.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/projected.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | #include <__utility/forward.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | namespace __find_if_not { | |
| 35 | struct __fn { | |
| 36 | template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, | |
| 37 | indirect_unary_predicate<projected<_Ip, _Proj>> _Pred> | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 39 | _Ip operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const { | |
| 40 | auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); }; | |
| 41 | return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj); | |
| 42 | } | |
| 43 | ||
| 44 | template <input_range _Rp, class _Proj = identity, | |
| 45 | indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred> | |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 47 | borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const { | |
| 48 | auto __pred2 = [&](auto&& __e) { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); }; | |
| 49 | return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj); | |
| 50 | } | |
| 51 | }; | |
| 52 | } // namespace __find_if_not | |
| 53 | ||
| 54 | inline namespace __cpo { | |
| 55 | inline constexpr auto find_if_not = __find_if_not::__fn{}; | |
| 56 | } // namespace __cpo | |
| 57 | } // namespace ranges | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 62 | ||
| 63 | #endif // _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H |
lib/libcxx/include/__algorithm/ranges_for_each.h created+78| ... | ... | @@ -0,0 +1,78 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H | |
| 11 | ||
| 12 | #include <__algorithm/in_fun_result.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template <class _Iter, class _Func> | |
| 34 | using for_each_result = in_fun_result<_Iter, _Func>; | |
| 35 | ||
| 36 | namespace __for_each { | |
| 37 | struct __fn { | |
| 38 | private: | |
| 39 | template <class _Iter, class _Sent, class _Proj, class _Func> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 41 | for_each_result<_Iter, _Func> __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) { | |
| 42 | for (; __first != __last; ++__first) | |
| 43 | std::invoke(__func, std::invoke(__proj, *__first)); | |
| 44 | return {std::move(__first), std::move(__func)}; | |
| 45 | } | |
| 46 | ||
| 47 | public: | |
| 48 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 49 | class _Proj = identity, | |
| 50 | indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 52 | for_each_result<_Iter, _Func> operator()(_Iter __first, _Sent __last, _Func __func, _Proj __proj = {}) const { | |
| 53 | return __for_each_impl(std::move(__first), std::move(__last), __func, __proj); | |
| 54 | } | |
| 55 | ||
| 56 | template <input_range _Range, | |
| 57 | class _Proj = identity, | |
| 58 | indirectly_unary_invocable<projected<iterator_t<_Range>, _Proj>> _Func> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 60 | for_each_result<borrowed_iterator_t<_Range>, _Func> operator()(_Range&& __range, | |
| 61 | _Func __func, | |
| 62 | _Proj __proj = {}) const { | |
| 63 | return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); | |
| 64 | } | |
| 65 | ||
| 66 | }; | |
| 67 | } // namespace __for_each | |
| 68 | ||
| 69 | inline namespace __cpo { | |
| 70 | inline constexpr auto for_each = __for_each::__fn{}; | |
| 71 | } // namespace __cpo | |
| 72 | } // namespace ranges | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_STD | |
| 75 | ||
| 76 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 77 | ||
| 78 | #endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H |
lib/libcxx/include/__algorithm/ranges_for_each_n.h created+66| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H | |
| 11 | ||
| 12 | #include <__algorithm/in_fun_result.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/incrementable_traits.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template <class _Iter, class _Func> | |
| 34 | using for_each_n_result = in_fun_result<_Iter, _Func>; | |
| 35 | ||
| 36 | namespace __for_each_n { | |
| 37 | struct __fn { | |
| 38 | ||
| 39 | template <input_iterator _Iter, | |
| 40 | class _Proj = identity, | |
| 41 | indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 43 | for_each_n_result<_Iter, _Func> operator()(_Iter __first, | |
| 44 | iter_difference_t<_Iter> __count, | |
| 45 | _Func __func, | |
| 46 | _Proj __proj = {}) const { | |
| 47 | while (__count-- > 0) { | |
| 48 | std::invoke(__func, std::invoke(__proj, *__first)); | |
| 49 | ++__first; | |
| 50 | } | |
| 51 | return {std::move(__first), std::move(__func)}; | |
| 52 | } | |
| 53 | ||
| 54 | }; | |
| 55 | } // namespace __for_each_n | |
| 56 | ||
| 57 | inline namespace __cpo { | |
| 58 | inline constexpr auto for_each_n = __for_each_n::__fn{}; | |
| 59 | } // namespace __cpo | |
| 60 | } // namespace ranges | |
| 61 | ||
| 62 | _LIBCPP_END_NAMESPACE_STD | |
| 63 | ||
| 64 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 65 | ||
| 66 | #endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H |
lib/libcxx/include/__algorithm/ranges_generate.h created+73| ... | ... | @@ -0,0 +1,73 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_GENERATE_H | |
| 11 | ||
| 12 | #include <__concepts/constructible.h> | |
| 13 | #include <__concepts/invocable.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/iterator_traits.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __generate { | |
| 33 | ||
| 34 | struct __fn { | |
| 35 | ||
| 36 | template <class _OutIter, class _Sent, class _Func> | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 38 | static _OutIter __generate_fn_impl(_OutIter __first, _Sent __last, _Func& __gen) { | |
| 39 | for (; __first != __last; ++__first) { | |
| 40 | *__first = __gen(); | |
| 41 | } | |
| 42 | ||
| 43 | return __first; | |
| 44 | } | |
| 45 | ||
| 46 | template <input_or_output_iterator _OutIter, sentinel_for<_OutIter> _Sent, copy_constructible _Func> | |
| 47 | requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | _OutIter operator()(_OutIter __first, _Sent __last, _Func __gen) const { | |
| 50 | return __generate_fn_impl(std::move(__first), std::move(__last), __gen); | |
| 51 | } | |
| 52 | ||
| 53 | template <class _Range, copy_constructible _Func> | |
| 54 | requires invocable<_Func&> && output_range<_Range, invoke_result_t<_Func&>> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 56 | borrowed_iterator_t<_Range> operator()(_Range&& __range, _Func __gen) const { | |
| 57 | return __generate_fn_impl(ranges::begin(__range), ranges::end(__range), __gen); | |
| 58 | } | |
| 59 | ||
| 60 | }; | |
| 61 | ||
| 62 | } // namespace __generate | |
| 63 | ||
| 64 | inline namespace __cpo { | |
| 65 | inline constexpr auto generate = __generate::__fn{}; | |
| 66 | } // namespace __cpo | |
| 67 | } // namespace ranges | |
| 68 | ||
| 69 | _LIBCPP_END_NAMESPACE_STD | |
| 70 | ||
| 71 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 72 | ||
| 73 | #endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_H |
lib/libcxx/include/__algorithm/ranges_generate_n.h created+62| ... | ... | @@ -0,0 +1,62 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H | |
| 11 | ||
| 12 | #include <__concepts/constructible.h> | |
| 13 | #include <__concepts/invocable.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/incrementable_traits.h> | |
| 19 | #include <__iterator/iterator_traits.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | namespace __generate_n { | |
| 34 | ||
| 35 | struct __fn { | |
| 36 | ||
| 37 | template <input_or_output_iterator _OutIter, copy_constructible _Func> | |
| 38 | requires invocable<_Func&> && indirectly_writable<_OutIter, invoke_result_t<_Func&>> | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 40 | _OutIter operator()(_OutIter __first, iter_difference_t<_OutIter> __n, _Func __gen) const { | |
| 41 | for (; __n > 0; --__n) { | |
| 42 | *__first = __gen(); | |
| 43 | ++__first; | |
| 44 | } | |
| 45 | ||
| 46 | return __first; | |
| 47 | } | |
| 48 | ||
| 49 | }; | |
| 50 | ||
| 51 | } // namespace __generate_n | |
| 52 | ||
| 53 | inline namespace __cpo { | |
| 54 | inline constexpr auto generate_n = __generate_n::__fn{}; | |
| 55 | } // namespace __cpo | |
| 56 | } // namespace ranges | |
| 57 | ||
| 58 | _LIBCPP_END_NAMESPACE_STD | |
| 59 | ||
| 60 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 61 | ||
| 62 | #endif // _LIBCPP___ALGORITHM_RANGES_GENERATE_N_H |
lib/libcxx/include/__algorithm/ranges_includes.h created+95| ... | ... | @@ -0,0 +1,95 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_INCLUDES_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_INCLUDES_H | |
| 11 | ||
| 12 | #include <__algorithm/includes.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/iterator_traits.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__utility/forward.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | namespace __includes { | |
| 36 | ||
| 37 | struct __fn { | |
| 38 | template < | |
| 39 | input_iterator _Iter1, | |
| 40 | sentinel_for<_Iter1> _Sent1, | |
| 41 | input_iterator _Iter2, | |
| 42 | sentinel_for<_Iter2> _Sent2, | |
| 43 | class _Proj1 = identity, | |
| 44 | class _Proj2 = identity, | |
| 45 | indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less> | |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | |
| 47 | _Iter1 __first1, | |
| 48 | _Sent1 __last1, | |
| 49 | _Iter2 __first2, | |
| 50 | _Sent2 __last2, | |
| 51 | _Comp __comp = {}, | |
| 52 | _Proj1 __proj1 = {}, | |
| 53 | _Proj2 __proj2 = {}) const { | |
| 54 | return std::__includes( | |
| 55 | std::move(__first1), | |
| 56 | std::move(__last1), | |
| 57 | std::move(__first2), | |
| 58 | std::move(__last2), | |
| 59 | std::move(__comp), | |
| 60 | std::move(__proj1), | |
| 61 | std::move(__proj2)); | |
| 62 | } | |
| 63 | ||
| 64 | template < | |
| 65 | input_range _Range1, | |
| 66 | input_range _Range2, | |
| 67 | class _Proj1 = identity, | |
| 68 | class _Proj2 = identity, | |
| 69 | indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>> | |
| 70 | _Comp = ranges::less> | |
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( | |
| 72 | _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | |
| 73 | return std::__includes( | |
| 74 | ranges::begin(__range1), | |
| 75 | ranges::end(__range1), | |
| 76 | ranges::begin(__range2), | |
| 77 | ranges::end(__range2), | |
| 78 | std::move(__comp), | |
| 79 | std::move(__proj1), | |
| 80 | std::move(__proj2)); | |
| 81 | } | |
| 82 | }; | |
| 83 | ||
| 84 | } // namespace __includes | |
| 85 | ||
| 86 | inline namespace __cpo { | |
| 87 | inline constexpr auto includes = __includes::__fn{}; | |
| 88 | } // namespace __cpo | |
| 89 | } // namespace ranges | |
| 90 | ||
| 91 | _LIBCPP_END_NAMESPACE_STD | |
| 92 | ||
| 93 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 94 | ||
| 95 | #endif // _LIBCPP___ALGORITHM_RANGES_INCLUDES_H |
lib/libcxx/include/__algorithm/ranges_inplace_merge.h created+85| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H | |
| 11 | ||
| 12 | #include <__algorithm/inplace_merge.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__algorithm/make_projected.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/next.h> | |
| 22 | #include <__iterator/projected.h> | |
| 23 | #include <__iterator/sortable.h> | |
| 24 | #include <__ranges/access.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/dangling.h> | |
| 27 | #include <__utility/forward.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | namespace __inplace_merge { | |
| 40 | ||
| 41 | struct __fn { | |
| 42 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 43 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 44 | __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) { | |
| 45 | auto __last_iter = ranges::next(__middle, __last); | |
| 46 | std::__inplace_merge<_RangeAlgPolicy>( | |
| 47 | std::move(__first), std::move(__middle), __last_iter, std::__make_projected(__comp, __proj)); | |
| 48 | return __last_iter; | |
| 49 | } | |
| 50 | ||
| 51 | template < | |
| 52 | bidirectional_iterator _Iter, | |
| 53 | sentinel_for<_Iter> _Sent, | |
| 54 | class _Comp = ranges::less, | |
| 55 | class _Proj = identity> | |
| 56 | requires sortable<_Iter, _Comp, _Proj> | |
| 57 | _LIBCPP_HIDE_FROM_ABI _Iter | |
| 58 | operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 59 | return __inplace_merge_impl( | |
| 60 | std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj)); | |
| 61 | } | |
| 62 | ||
| 63 | template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 64 | requires sortable< | |
| 65 | iterator_t<_Range>, | |
| 66 | _Comp, | |
| 67 | _Proj> _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range> | |
| 68 | operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 69 | return __inplace_merge_impl( | |
| 70 | ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj)); | |
| 71 | } | |
| 72 | }; | |
| 73 | ||
| 74 | } // namespace __inplace_merge | |
| 75 | ||
| 76 | inline namespace __cpo { | |
| 77 | inline constexpr auto inplace_merge = __inplace_merge::__fn{}; | |
| 78 | } // namespace __cpo | |
| 79 | } // namespace ranges | |
| 80 | ||
| 81 | _LIBCPP_END_NAMESPACE_STD | |
| 82 | ||
| 83 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 84 | ||
| 85 | #endif // _LIBCPP___ALGORITHM_RANGES_INPLACE_MERGE_H |
lib/libcxx/include/__algorithm/ranges_is_heap.h created+74| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H | |
| 11 | ||
| 12 | #include <__algorithm/is_heap_until.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/next.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | namespace __is_heap { | |
| 35 | ||
| 36 | struct __fn { | |
| 37 | ||
| 38 | template <class _Iter, class _Sent, class _Proj, class _Comp> | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 40 | static bool __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 41 | auto __last_iter = ranges::next(__first, __last); | |
| 42 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 43 | ||
| 44 | auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp); | |
| 45 | return __result == __last; | |
| 46 | } | |
| 47 | ||
| 48 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 49 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 51 | bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 52 | return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 53 | } | |
| 54 | ||
| 55 | template <random_access_range _Range, class _Proj = identity, | |
| 56 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 58 | bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 59 | return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); | |
| 60 | } | |
| 61 | }; | |
| 62 | ||
| 63 | } // namespace __is_heap | |
| 64 | ||
| 65 | inline namespace __cpo { | |
| 66 | inline constexpr auto is_heap = __is_heap::__fn{}; | |
| 67 | } // namespace __cpo | |
| 68 | } // namespace ranges | |
| 69 | ||
| 70 | _LIBCPP_END_NAMESPACE_STD | |
| 71 | ||
| 72 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 73 | ||
| 74 | #endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H |
lib/libcxx/include/__algorithm/ranges_is_heap_until.h created+75| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H | |
| 11 | ||
| 12 | #include <__algorithm/is_heap_until.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/next.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/dangling.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | namespace __is_heap_until { | |
| 36 | ||
| 37 | struct __fn { | |
| 38 | ||
| 39 | template <class _Iter, class _Sent, class _Proj, class _Comp> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 41 | static _Iter __is_heap_until_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 42 | auto __last_iter = ranges::next(__first, __last); | |
| 43 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 44 | ||
| 45 | return std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp); | |
| 46 | } | |
| 47 | ||
| 48 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 49 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 51 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 52 | return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 53 | } | |
| 54 | ||
| 55 | template <random_access_range _Range, class _Proj = identity, | |
| 56 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 58 | borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 59 | return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); | |
| 60 | } | |
| 61 | ||
| 62 | }; | |
| 63 | ||
| 64 | } // namespace __is_heap_until | |
| 65 | ||
| 66 | inline namespace __cpo { | |
| 67 | inline constexpr auto is_heap_until = __is_heap_until::__fn{}; | |
| 68 | } // namespace __cpo | |
| 69 | } // namespace ranges | |
| 70 | ||
| 71 | _LIBCPP_END_NAMESPACE_STD | |
| 72 | ||
| 73 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 74 | ||
| 75 | #endif // _LIBCPP___ALGORITHM_RANGES_IS_HEAP_UNTIL_H |
lib/libcxx/include/__algorithm/ranges_is_partitioned.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/indirectly_comparable.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | namespace __is_partitioned { | |
| 32 | struct __fn { | |
| 33 | ||
| 34 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 36 | bool __is_parititioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 37 | for (; __first != __last; ++__first) { | |
| 38 | if (!std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 39 | break; | |
| 40 | } | |
| 41 | ||
| 42 | if (__first == __last) | |
| 43 | return true; | |
| 44 | ++__first; | |
| 45 | ||
| 46 | for (; __first != __last; ++__first) { | |
| 47 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 48 | return false; | |
| 49 | } | |
| 50 | ||
| 51 | return true; | |
| 52 | } | |
| 53 | ||
| 54 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 55 | class _Proj = identity, | |
| 56 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 58 | bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | |
| 59 | return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 60 | } | |
| 61 | ||
| 62 | template <input_range _Range, | |
| 63 | class _Proj = identity, | |
| 64 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 65 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 66 | bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 67 | return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 68 | } | |
| 69 | }; | |
| 70 | } // namespace __is_partitioned | |
| 71 | ||
| 72 | inline namespace __cpo { | |
| 73 | inline constexpr auto is_partitioned = __is_partitioned::__fn{}; | |
| 74 | } // namespace __cpo | |
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | |
| 78 | ||
| 79 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 80 | ||
| 81 | #endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H |
lib/libcxx/include/__algorithm/ranges_is_sorted.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H | |
| 10 | #define _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_is_sorted_until.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | namespace __is_sorted { | |
| 32 | struct __fn { | |
| 33 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 34 | class _Proj = identity, | |
| 35 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 37 | bool operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 38 | return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last; | |
| 39 | } | |
| 40 | ||
| 41 | template <forward_range _Range, | |
| 42 | class _Proj = identity, | |
| 43 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 45 | bool operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 46 | auto __last = ranges::end(__range); | |
| 47 | return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last; | |
| 48 | } | |
| 49 | }; | |
| 50 | } // namespace __is_sorted | |
| 51 | ||
| 52 | inline namespace __cpo { | |
| 53 | inline constexpr auto is_sorted = __is_sorted::__fn{}; | |
| 54 | } // namespace __cpo | |
| 55 | } // namespace ranges | |
| 56 | ||
| 57 | _LIBCPP_END_NAMESPACE_STD | |
| 58 | ||
| 59 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 60 | ||
| 61 | #endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_H |
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h created+76| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H | |
| 10 | #define _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | template <class _Iter, class _Sent, class _Proj, class _Comp> | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 35 | _Iter __is_sorted_until_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 36 | if (__first == __last) | |
| 37 | return __first; | |
| 38 | auto __i = __first; | |
| 39 | while (++__i != __last) { | |
| 40 | if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first))) | |
| 41 | return __i; | |
| 42 | __first = __i; | |
| 43 | } | |
| 44 | return __i; | |
| 45 | } | |
| 46 | ||
| 47 | namespace __is_sorted_until { | |
| 48 | struct __fn { | |
| 49 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 50 | class _Proj = identity, | |
| 51 | indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 53 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 54 | return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 55 | } | |
| 56 | ||
| 57 | template <forward_range _Range, | |
| 58 | class _Proj = identity, | |
| 59 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 61 | borrowed_iterator_t<_Range> operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 62 | return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj); | |
| 63 | } | |
| 64 | }; | |
| 65 | } // namespace __is_sorted_until | |
| 66 | ||
| 67 | inline namespace __cpo { | |
| 68 | inline constexpr auto is_sorted_until = __is_sorted_until::__fn{}; | |
| 69 | } // namespace __cpo | |
| 70 | } // namespace ranges | |
| 71 | ||
| 72 | _LIBCPP_END_NAMESPACE_STD | |
| 73 | ||
| 74 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 75 | ||
| 76 | #endif // _LIBCPP__ALGORITHM_RANGES_IS_SORTED_UNTIL_H |
lib/libcxx/include/__algorithm/ranges_iterator_concept.h created+51| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__iterator/concepts.h> | |
| 14 | #include <__iterator/iterator_traits.h> | |
| 15 | #include <type_traits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | namespace ranges { | |
| 26 | ||
| 27 | template <class _IterMaybeQualified> | |
| 28 | consteval auto __get_iterator_concept() { | |
| 29 | using _Iter = __uncvref_t<_IterMaybeQualified>; | |
| 30 | ||
| 31 | if constexpr (contiguous_iterator<_Iter>) | |
| 32 | return contiguous_iterator_tag(); | |
| 33 | else if constexpr (random_access_iterator<_Iter>) | |
| 34 | return random_access_iterator_tag(); | |
| 35 | else if constexpr (bidirectional_iterator<_Iter>) | |
| 36 | return bidirectional_iterator_tag(); | |
| 37 | else if constexpr (forward_iterator<_Iter>) | |
| 38 | return forward_iterator_tag(); | |
| 39 | else if constexpr (input_iterator<_Iter>) | |
| 40 | return input_iterator_tag(); | |
| 41 | } | |
| 42 | ||
| 43 | template <class _Iter> | |
| 44 | using __iterator_concept = decltype(__get_iterator_concept<_Iter>()); | |
| 45 | ||
| 46 | } // namespace ranges | |
| 47 | _LIBCPP_END_NAMESPACE_STD | |
| 48 | ||
| 49 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 50 | ||
| 51 | #endif // _LIBCPP___ALGORITHM_RANGES_ITERATOR_CONCEPT_H |
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h created+98| ... | ... | @@ -0,0 +1,98 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | namespace __lexicographical_compare { | |
| 32 | struct __fn { | |
| 33 | ||
| 34 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Proj1, class _Proj2, class _Comp> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 36 | bool __lexicographical_compare_impl(_Iter1 __first1, _Sent1 __last1, | |
| 37 | _Iter2 __first2, _Sent2 __last2, | |
| 38 | _Comp& __comp, | |
| 39 | _Proj1& __proj1, | |
| 40 | _Proj2& __proj2) { | |
| 41 | while (__first2 != __last2) { | |
| 42 | if (__first1 == __last1 | |
| 43 | || std::invoke(__comp, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2))) | |
| 44 | return true; | |
| 45 | if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) | |
| 46 | return false; | |
| 47 | ++__first1; | |
| 48 | ++__first2; | |
| 49 | } | |
| 50 | return false; | |
| 51 | } | |
| 52 | ||
| 53 | template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | |
| 54 | input_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | |
| 55 | class _Proj1 = identity, | |
| 56 | class _Proj2 = identity, | |
| 57 | indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 59 | bool operator()(_Iter1 __first1, _Sent1 __last1, | |
| 60 | _Iter2 __first2, _Sent2 __last2, | |
| 61 | _Comp __comp = {}, | |
| 62 | _Proj1 __proj1 = {}, | |
| 63 | _Proj2 __proj2 = {}) const { | |
| 64 | return __lexicographical_compare_impl(std::move(__first1), std::move(__last1), | |
| 65 | std::move(__first2), std::move(__last2), | |
| 66 | __comp, | |
| 67 | __proj1, | |
| 68 | __proj2); | |
| 69 | } | |
| 70 | ||
| 71 | template <input_range _Range1, | |
| 72 | input_range _Range2, | |
| 73 | class _Proj1 = identity, | |
| 74 | class _Proj2 = identity, | |
| 75 | indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, | |
| 76 | projected<iterator_t<_Range2>, _Proj2>> _Comp = ranges::less> | |
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 78 | bool operator()(_Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | |
| 79 | return __lexicographical_compare_impl(ranges::begin(__range1), ranges::end(__range1), | |
| 80 | ranges::begin(__range2), ranges::end(__range2), | |
| 81 | __comp, | |
| 82 | __proj1, | |
| 83 | __proj2); | |
| 84 | } | |
| 85 | ||
| 86 | }; | |
| 87 | } // namespace __lexicographical_compare | |
| 88 | ||
| 89 | inline namespace __cpo { | |
| 90 | inline constexpr auto lexicographical_compare = __lexicographical_compare::__fn{}; | |
| 91 | } // namespace __cpo | |
| 92 | } // namespace ranges | |
| 93 | ||
| 94 | _LIBCPP_END_NAMESPACE_STD | |
| 95 | ||
| 96 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 97 | ||
| 98 | #endif // _LIBCPP___ALGORITHM_RANGES_LEXICOGRAPHICAL_COMPARE_H |
lib/libcxx/include/__algorithm/ranges_lower_bound.h created+66| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/lower_bound.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/advance.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | ||
| 36 | namespace __lower_bound { | |
| 37 | struct __fn { | |
| 38 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity, | |
| 39 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 41 | _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 42 | return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj); | |
| 43 | } | |
| 44 | ||
| 45 | template <forward_range _Range, class _Type, class _Proj = identity, | |
| 46 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 48 | borrowed_iterator_t<_Range> operator()(_Range&& __r, | |
| 49 | const _Type& __value, | |
| 50 | _Comp __comp = {}, | |
| 51 | _Proj __proj = {}) const { | |
| 52 | return std::__lower_bound_impl<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj); | |
| 53 | } | |
| 54 | }; | |
| 55 | } // namespace __lower_bound | |
| 56 | ||
| 57 | inline namespace __cpo { | |
| 58 | inline constexpr auto lower_bound = __lower_bound::__fn{}; | |
| 59 | } // namespace __cpo | |
| 60 | } // namespace ranges | |
| 61 | ||
| 62 | _LIBCPP_END_NAMESPACE_STD | |
| 63 | ||
| 64 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 65 | ||
| 66 | #endif // _LIBCPP___ALGORITHM_RANGES_LOWER_BOUND_H |
lib/libcxx/include/__algorithm/ranges_make_heap.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_heap.h> | |
| 14 | #include <__algorithm/make_projected.h> | |
| 15 | #include <__concepts/same_as.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__iterator/sortable.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | namespace __make_heap { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 45 | _Iter __make_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 46 | auto __last_iter = ranges::next(__first, __last); | |
| 47 | ||
| 48 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 49 | std::__make_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp); | |
| 50 | ||
| 51 | return __last_iter; | |
| 52 | } | |
| 53 | ||
| 54 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 55 | requires sortable<_Iter, _Comp, _Proj> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 57 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 58 | return __make_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 59 | } | |
| 60 | ||
| 61 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 62 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 64 | borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 65 | return __make_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 66 | } | |
| 67 | }; | |
| 68 | ||
| 69 | } // namespace __make_heap | |
| 70 | ||
| 71 | inline namespace __cpo { | |
| 72 | inline constexpr auto make_heap = __make_heap::__fn{}; | |
| 73 | } // namespace __cpo | |
| 74 | } // namespace ranges | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | |
| 77 | ||
| 78 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | ||
| 80 | #endif // _LIBCPP___ALGORITHM_RANGES_MAKE_HEAP_H |
lib/libcxx/include/__algorithm/ranges_max.h created+93| ... | ... | @@ -0,0 +1,93 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MAX_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_min_element.h> | |
| 13 | #include <__assert> | |
| 14 | #include <__concepts/copyable.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | #include <initializer_list> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_PUSH_MACROS | |
| 33 | #include <__undef_macros> | |
| 34 | ||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 36 | ||
| 37 | namespace ranges { | |
| 38 | namespace __max { | |
| 39 | struct __fn { | |
| 40 | template <class _Tp, class _Proj = identity, | |
| 41 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 43 | const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 44 | return std::invoke(__comp, std::invoke(__proj, __a), std::invoke(__proj, __b)) ? __b : __a; | |
| 45 | } | |
| 46 | ||
| 47 | template <copyable _Tp, class _Proj = identity, | |
| 48 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 50 | _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 51 | _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element"); | |
| 52 | ||
| 53 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); }; | |
| 54 | return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj); | |
| 55 | } | |
| 56 | ||
| 57 | template <input_range _Rp, class _Proj = identity, | |
| 58 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | |
| 59 | requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 61 | range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 62 | auto __first = ranges::begin(__r); | |
| 63 | auto __last = ranges::end(__r); | |
| 64 | ||
| 65 | _LIBCPP_ASSERT(__first != __last, "range must contain at least one element"); | |
| 66 | ||
| 67 | if constexpr (forward_range<_Rp>) { | |
| 68 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); }; | |
| 69 | return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj); | |
| 70 | } else { | |
| 71 | range_value_t<_Rp> __result = *__first; | |
| 72 | while (++__first != __last) { | |
| 73 | if (std::invoke(__comp, std::invoke(__proj, __result), std::invoke(__proj, *__first))) | |
| 74 | __result = *__first; | |
| 75 | } | |
| 76 | return __result; | |
| 77 | } | |
| 78 | } | |
| 79 | }; | |
| 80 | } // namespace __max | |
| 81 | ||
| 82 | inline namespace __cpo { | |
| 83 | inline constexpr auto max = __max::__fn{}; | |
| 84 | } // namespace __cpo | |
| 85 | } // namespace ranges | |
| 86 | ||
| 87 | _LIBCPP_END_NAMESPACE_STD | |
| 88 | ||
| 89 | _LIBCPP_POP_MACROS | |
| 90 | ||
| 91 | #endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 92 | ||
| 93 | #endif // _LIBCPP___ALGORITHM_RANGES_MAX_H |
lib/libcxx/include/__algorithm/ranges_max_element.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_min_element.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/projected.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __max_element { | |
| 33 | struct __fn { | |
| 34 | template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, | |
| 35 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 37 | _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 38 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); }; | |
| 39 | return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj); | |
| 40 | } | |
| 41 | ||
| 42 | template <forward_range _Rp, class _Proj = identity, | |
| 43 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 45 | borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 46 | auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) { return std::invoke(__comp, __rhs, __lhs); }; | |
| 47 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj); | |
| 48 | } | |
| 49 | }; | |
| 50 | } // namespace __max_element | |
| 51 | ||
| 52 | inline namespace __cpo { | |
| 53 | inline constexpr auto max_element = __max_element::__fn{}; | |
| 54 | } // namespace __cpo | |
| 55 | } // namespace ranges | |
| 56 | ||
| 57 | _LIBCPP_END_NAMESPACE_STD | |
| 58 | ||
| 59 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 60 | ||
| 61 | #endif // _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H |
lib/libcxx/include/__algorithm/ranges_merge.h created+142| ... | ... | @@ -0,0 +1,142 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MERGE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MERGE_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_out_result.h> | |
| 13 | #include <__algorithm/ranges_copy.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/mergeable.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__ranges/dangling.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | #include <type_traits> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | ||
| 36 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 37 | using merge_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; | |
| 38 | ||
| 39 | namespace __merge { | |
| 40 | ||
| 41 | template < | |
| 42 | class _InIter1, | |
| 43 | class _Sent1, | |
| 44 | class _InIter2, | |
| 45 | class _Sent2, | |
| 46 | class _OutIter, | |
| 47 | class _Comp, | |
| 48 | class _Proj1, | |
| 49 | class _Proj2> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr merge_result<__uncvref_t<_InIter1>, __uncvref_t<_InIter2>, __uncvref_t<_OutIter>> | |
| 51 | __merge_impl( | |
| 52 | _InIter1&& __first1, | |
| 53 | _Sent1&& __last1, | |
| 54 | _InIter2&& __first2, | |
| 55 | _Sent2&& __last2, | |
| 56 | _OutIter&& __result, | |
| 57 | _Comp&& __comp, | |
| 58 | _Proj1&& __proj1, | |
| 59 | _Proj2&& __proj2) { | |
| 60 | for (; __first1 != __last1 && __first2 != __last2; ++__result) { | |
| 61 | if (std::invoke(__comp, std::invoke(__proj2, *__first2), std::invoke(__proj1, *__first1))) { | |
| 62 | *__result = *__first2; | |
| 63 | ++__first2; | |
| 64 | } else { | |
| 65 | *__result = *__first1; | |
| 66 | ++__first1; | |
| 67 | } | |
| 68 | } | |
| 69 | auto __ret1 = ranges::copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 70 | auto __ret2 = ranges::copy(std::move(__first2), std::move(__last2), std::move(__ret1.out)); | |
| 71 | return {std::move(__ret1.in), std::move(__ret2.in), std::move(__ret2.out)}; | |
| 72 | } | |
| 73 | ||
| 74 | struct __fn { | |
| 75 | template < | |
| 76 | input_iterator _InIter1, | |
| 77 | sentinel_for<_InIter1> _Sent1, | |
| 78 | input_iterator _InIter2, | |
| 79 | sentinel_for<_InIter2> _Sent2, | |
| 80 | weakly_incrementable _OutIter, | |
| 81 | class _Comp = less, | |
| 82 | class _Proj1 = identity, | |
| 83 | class _Proj2 = identity> | |
| 84 | requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> | |
| 85 | _LIBCPP_HIDE_FROM_ABI constexpr merge_result<_InIter1, _InIter2, _OutIter> operator()( | |
| 86 | _InIter1 __first1, | |
| 87 | _Sent1 __last1, | |
| 88 | _InIter2 __first2, | |
| 89 | _Sent2 __last2, | |
| 90 | _OutIter __result, | |
| 91 | _Comp __comp = {}, | |
| 92 | _Proj1 __proj1 = {}, | |
| 93 | _Proj2 __proj2 = {}) const { | |
| 94 | return __merge::__merge_impl(__first1, __last1, __first2, __last2, __result, __comp, __proj1, __proj2); | |
| 95 | } | |
| 96 | ||
| 97 | template < | |
| 98 | input_range _Range1, | |
| 99 | input_range _Range2, | |
| 100 | weakly_incrementable _OutIter, | |
| 101 | class _Comp = less, | |
| 102 | class _Proj1 = identity, | |
| 103 | class _Proj2 = identity> | |
| 104 | requires mergeable< | |
| 105 | iterator_t<_Range1>, | |
| 106 | iterator_t<_Range2>, | |
| 107 | _OutIter, | |
| 108 | _Comp, | |
| 109 | _Proj1, | |
| 110 | _Proj2> | |
| 111 | _LIBCPP_HIDE_FROM_ABI constexpr merge_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter> | |
| 112 | operator()( | |
| 113 | _Range1&& __range1, | |
| 114 | _Range2&& __range2, | |
| 115 | _OutIter __result, | |
| 116 | _Comp __comp = {}, | |
| 117 | _Proj1 __proj1 = {}, | |
| 118 | _Proj2 __proj2 = {}) const { | |
| 119 | return __merge::__merge_impl( | |
| 120 | ranges::begin(__range1), | |
| 121 | ranges::end(__range1), | |
| 122 | ranges::begin(__range2), | |
| 123 | ranges::end(__range2), | |
| 124 | __result, | |
| 125 | __comp, | |
| 126 | __proj1, | |
| 127 | __proj2); | |
| 128 | } | |
| 129 | }; | |
| 130 | ||
| 131 | } // namespace __merge | |
| 132 | ||
| 133 | inline namespace __cpo { | |
| 134 | inline constexpr auto merge = __merge::__fn{}; | |
| 135 | } // namespace __cpo | |
| 136 | } // namespace ranges | |
| 137 | ||
| 138 | _LIBCPP_END_NAMESPACE_STD | |
| 139 | ||
| 140 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 141 | ||
| 142 | #endif // _LIBCPP___ALGORITHM_RANGES_MERGE_H |
lib/libcxx/include/__algorithm/ranges_min.h created+89| ... | ... | @@ -0,0 +1,89 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MIN_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_min_element.h> | |
| 13 | #include <__assert> | |
| 14 | #include <__concepts/copyable.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <initializer_list> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_PUSH_MACROS | |
| 32 | #include <__undef_macros> | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | namespace __min { | |
| 38 | struct __fn { | |
| 39 | template <class _Tp, class _Proj = identity, | |
| 40 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 42 | const _Tp& operator()(const _Tp& __a, const _Tp& __b, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 43 | return std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)) ? __b : __a; | |
| 44 | } | |
| 45 | ||
| 46 | template <copyable _Tp, class _Proj = identity, | |
| 47 | indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | _Tp operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 50 | _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list must contain at least one element"); | |
| 51 | return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj); | |
| 52 | } | |
| 53 | ||
| 54 | template <input_range _Rp, class _Proj = identity, | |
| 55 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | |
| 56 | requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 58 | range_value_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 59 | auto __first = ranges::begin(__r); | |
| 60 | auto __last = ranges::end(__r); | |
| 61 | ||
| 62 | _LIBCPP_ASSERT(__first != __last, "range must contain at least one element"); | |
| 63 | ||
| 64 | if constexpr (forward_range<_Rp>) { | |
| 65 | return *ranges::__min_element_impl(__first, __last, __comp, __proj); | |
| 66 | } else { | |
| 67 | range_value_t<_Rp> __result = *__first; | |
| 68 | while (++__first != __last) { | |
| 69 | if (std::invoke(__comp, std::invoke(__proj, *__first), std::invoke(__proj, __result))) | |
| 70 | __result = *__first; | |
| 71 | } | |
| 72 | return __result; | |
| 73 | } | |
| 74 | } | |
| 75 | }; | |
| 76 | } // namespace __min | |
| 77 | ||
| 78 | inline namespace __cpo { | |
| 79 | inline constexpr auto min = __min::__fn{}; | |
| 80 | } // namespace __cpo | |
| 81 | } // namespace ranges | |
| 82 | ||
| 83 | _LIBCPP_END_NAMESPACE_STD | |
| 84 | ||
| 85 | _LIBCPP_POP_MACROS | |
| 86 | ||
| 87 | #endif // _LIBCPP_STD_VER > 17 && && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 88 | ||
| 89 | #endif // _LIBCPP___ALGORITHM_RANGES_MIN_H |
lib/libcxx/include/__algorithm/ranges_min_element.h created+74| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/forward.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | ||
| 33 | // TODO(ranges): `ranges::min_element` can now simply delegate to `std::__min_element`. | |
| 34 | template <class _Ip, class _Sp, class _Proj, class _Comp> | |
| 35 | _LIBCPP_HIDE_FROM_ABI static constexpr | |
| 36 | _Ip __min_element_impl(_Ip __first, _Sp __last, _Comp& __comp, _Proj& __proj) { | |
| 37 | if (__first == __last) | |
| 38 | return __first; | |
| 39 | ||
| 40 | _Ip __i = __first; | |
| 41 | while (++__i != __last) | |
| 42 | if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first))) | |
| 43 | __first = __i; | |
| 44 | return __first; | |
| 45 | } | |
| 46 | ||
| 47 | namespace __min_element { | |
| 48 | struct __fn { | |
| 49 | template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, | |
| 50 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 52 | _Ip operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 53 | return ranges::__min_element_impl(__first, __last, __comp, __proj); | |
| 54 | } | |
| 55 | ||
| 56 | template <forward_range _Rp, class _Proj = identity, | |
| 57 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 59 | borrowed_iterator_t<_Rp> operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 60 | return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 61 | } | |
| 62 | }; | |
| 63 | } // namespace __min_element | |
| 64 | ||
| 65 | inline namespace __cpo { | |
| 66 | inline constexpr auto min_element = __min_element::__fn{}; | |
| 67 | } // namespace __cpo | |
| 68 | } // namespace ranges | |
| 69 | ||
| 70 | _LIBCPP_END_NAMESPACE_STD | |
| 71 | ||
| 72 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 73 | ||
| 74 | #endif // _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H |
lib/libcxx/include/__algorithm/ranges_minmax.h created+133| ... | ... | @@ -0,0 +1,133 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MINMAX_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MINMAX_H | |
| 11 | ||
| 12 | #include <__algorithm/min_max_result.h> | |
| 13 | #include <__algorithm/minmax_element.h> | |
| 14 | #include <__assert> | |
| 15 | #include <__concepts/copyable.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__utility/forward.h> | |
| 25 | #include <__utility/move.h> | |
| 26 | #include <initializer_list> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_PUSH_MACROS | |
| 35 | #include <__undef_macros> | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | template <class _T1> | |
| 41 | using minmax_result = min_max_result<_T1>; | |
| 42 | ||
| 43 | namespace __minmax { | |
| 44 | struct __fn { | |
| 45 | template <class _Type, class _Proj = identity, | |
| 46 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> | |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&> | |
| 48 | operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 49 | if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a))) | |
| 50 | return {__b, __a}; | |
| 51 | return {__a, __b}; | |
| 52 | } | |
| 53 | ||
| 54 | template <copyable _Type, class _Proj = identity, | |
| 55 | indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 57 | ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 58 | _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element"); | |
| 59 | auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj); | |
| 60 | return ranges::minmax_result<_Type> { *__iters.first, *__iters.second }; | |
| 61 | } | |
| 62 | ||
| 63 | template <input_range _Range, class _Proj = identity, | |
| 64 | indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 65 | requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*> | |
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 67 | ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 68 | auto __first = ranges::begin(__r); | |
| 69 | auto __last = ranges::end(__r); | |
| 70 | using _ValueT = range_value_t<_Range>; | |
| 71 | ||
| 72 | _LIBCPP_ASSERT(__first != __last, "range has to contain at least one element"); | |
| 73 | ||
| 74 | if constexpr (forward_range<_Range>) { | |
| 75 | auto __result = std::__minmax_element_impl(__first, __last, __comp, __proj); | |
| 76 | return {*__result.first, *__result.second}; | |
| 77 | } else { | |
| 78 | // input_iterators can't be copied, so the implementation for input_iterators has to store | |
| 79 | // the values instead of a pointer to the correct values | |
| 80 | auto __less = [&](auto&& __a, auto&& __b) -> bool { | |
| 81 | return std::invoke(__comp, std::invoke(__proj, std::forward<decltype(__a)>(__a)), | |
| 82 | std::invoke(__proj, std::forward<decltype(__b)>(__b))); | |
| 83 | }; | |
| 84 | ||
| 85 | ranges::minmax_result<_ValueT> __result = {*__first, __result.min}; | |
| 86 | if (__first == __last || ++__first == __last) | |
| 87 | return __result; | |
| 88 | ||
| 89 | if (__less(*__first, __result.min)) | |
| 90 | __result.min = *__first; | |
| 91 | else | |
| 92 | __result.max = *__first; | |
| 93 | ||
| 94 | while (++__first != __last) { | |
| 95 | _ValueT __i = *__first; | |
| 96 | if (++__first == __last) { | |
| 97 | if (__less(__i, __result.min)) | |
| 98 | __result.min = __i; | |
| 99 | else if (!__less(__i, __result.max)) | |
| 100 | __result.max = __i; | |
| 101 | return __result; | |
| 102 | } | |
| 103 | ||
| 104 | if (__less(*__first, __i)) { | |
| 105 | if (__less(*__first, __result.min)) | |
| 106 | __result.min = *__first; | |
| 107 | if (!__less(__i, __result.max)) | |
| 108 | __result.max = std::move(__i); | |
| 109 | } else { | |
| 110 | if (__less(__i, __result.min)) | |
| 111 | __result.min = std::move(__i); | |
| 112 | if (!__less(*__first, __result.max)) | |
| 113 | __result.max = *__first; | |
| 114 | } | |
| 115 | } | |
| 116 | return __result; | |
| 117 | } | |
| 118 | } | |
| 119 | }; | |
| 120 | } // namespace __minmax | |
| 121 | ||
| 122 | inline namespace __cpo { | |
| 123 | inline constexpr auto minmax = __minmax::__fn{}; | |
| 124 | } // namespace __cpo | |
| 125 | } // namespace ranges | |
| 126 | ||
| 127 | _LIBCPP_END_NAMESPACE_STD | |
| 128 | ||
| 129 | _LIBCPP_POP_MACROS | |
| 130 | ||
| 131 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 132 | ||
| 133 | #endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H |
lib/libcxx/include/__algorithm/ranges_minmax_element.h created+72| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H | |
| 11 | ||
| 12 | #include <__algorithm/min_max_result.h> | |
| 13 | #include <__algorithm/minmax_element.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__ranges/dangling.h> | |
| 23 | #include <__utility/forward.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | #include <__utility/pair.h> | |
| 26 | #include <type_traits> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | ||
| 38 | template <class _T1> | |
| 39 | using minmax_element_result = min_max_result<_T1>; | |
| 40 | ||
| 41 | namespace __minmax_element { | |
| 42 | struct __fn { | |
| 43 | template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity, | |
| 44 | indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less> | |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 46 | ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 47 | auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 48 | return {__ret.first, __ret.second}; | |
| 49 | } | |
| 50 | ||
| 51 | template <forward_range _Rp, class _Proj = identity, | |
| 52 | indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less> | |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 54 | ranges::minmax_element_result<borrowed_iterator_t<_Rp>> | |
| 55 | operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 56 | auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 57 | return {__ret.first, __ret.second}; | |
| 58 | } | |
| 59 | }; | |
| 60 | } // namespace __minmax_element | |
| 61 | ||
| 62 | inline namespace __cpo { | |
| 63 | inline constexpr auto minmax_element = __minmax_element::__fn{}; | |
| 64 | } // namespace __cpo | |
| 65 | ||
| 66 | } // namespace ranges | |
| 67 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | |
| 69 | ||
| 70 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 71 | ||
| 72 | #endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H |
lib/libcxx/include/__algorithm/ranges_mismatch.h created+85| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MISMATCH_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MISMATCH_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_result.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/indirectly_comparable.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | ||
| 34 | template <class _I1, class _I2> | |
| 35 | using mismatch_result = in_in_result<_I1, _I2>; | |
| 36 | ||
| 37 | namespace __mismatch { | |
| 38 | struct __fn { | |
| 39 | template <class _I1, class _S1, class _I2, class _S2, | |
| 40 | class _Pred, class _Proj1, class _Proj2> | |
| 41 | static _LIBCPP_HIDE_FROM_ABI constexpr | |
| 42 | mismatch_result<_I1, _I2> | |
| 43 | __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, | |
| 44 | _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) { | |
| 45 | while (__first1 != __last1 && __first2 != __last2) { | |
| 46 | if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2))) | |
| 47 | break; | |
| 48 | ++__first1; | |
| 49 | ++__first2; | |
| 50 | } | |
| 51 | return {std::move(__first1), std::move(__first2)}; | |
| 52 | } | |
| 53 | ||
| 54 | template <input_iterator _I1, sentinel_for<_I1> _S1, | |
| 55 | input_iterator _I2, sentinel_for<_I2> _S2, | |
| 56 | class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity> | |
| 57 | requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 59 | mismatch_result<_I1, _I2> operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, | |
| 60 | _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | |
| 61 | return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2); | |
| 62 | } | |
| 63 | ||
| 64 | template <input_range _R1, input_range _R2, | |
| 65 | class _Pred = ranges::equal_to, class _Proj1 = identity, class _Proj2 = identity> | |
| 66 | requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2> | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 68 | mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>> | |
| 69 | operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | |
| 70 | return __go(ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), | |
| 71 | __pred, __proj1, __proj2); | |
| 72 | } | |
| 73 | }; | |
| 74 | } // namespace __mismatch | |
| 75 | ||
| 76 | inline namespace __cpo { | |
| 77 | constexpr inline auto mismatch = __mismatch::__fn{}; | |
| 78 | } // namespace __cpo | |
| 79 | } // namespace ranges | |
| 80 | ||
| 81 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 82 | ||
| 83 | _LIBCPP_END_NAMESPACE_STD | |
| 84 | ||
| 85 | #endif // _LIBCPP___ALGORITHM_RANGES_MISMATCH_H |
lib/libcxx/include/__algorithm/ranges_move.h created+83| ... | ... | @@ -0,0 +1,83 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MOVE_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/move.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/iter_move.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__ranges/dangling.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | ||
| 32 | template <class _InIter, class _OutIter> | |
| 33 | using move_result = in_out_result<_InIter, _OutIter>; | |
| 34 | ||
| 35 | namespace __move { | |
| 36 | struct __fn { | |
| 37 | ||
| 38 | template <class _InIter, class _Sent, class _OutIter> | |
| 39 | requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 41 | move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { | |
| 42 | auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result)); | |
| 43 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 44 | } | |
| 45 | ||
| 46 | template <class _InIter, class _Sent, class _OutIter> | |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 48 | move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { | |
| 49 | while (__first != __last) { | |
| 50 | *__result = ranges::iter_move(__first); | |
| 51 | ++__first; | |
| 52 | ++__result; | |
| 53 | } | |
| 54 | return {std::move(__first), std::move(__result)}; | |
| 55 | } | |
| 56 | ||
| 57 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> | |
| 58 | requires indirectly_movable<_InIter, _OutIter> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 60 | move_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { | |
| 61 | return __move_impl(std::move(__first), std::move(__last), std::move(__result)); | |
| 62 | } | |
| 63 | ||
| 64 | template <input_range _Range, weakly_incrementable _OutIter> | |
| 65 | requires indirectly_movable<iterator_t<_Range>, _OutIter> | |
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 67 | move_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const { | |
| 68 | return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); | |
| 69 | } | |
| 70 | ||
| 71 | }; | |
| 72 | } // namespace __move | |
| 73 | ||
| 74 | inline namespace __cpo { | |
| 75 | inline constexpr auto move = __move::__fn{}; | |
| 76 | } // namespace __cpo | |
| 77 | } // namespace ranges | |
| 78 | ||
| 79 | _LIBCPP_END_NAMESPACE_STD | |
| 80 | ||
| 81 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 82 | ||
| 83 | #endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H |
lib/libcxx/include/__algorithm/ranges_move_backward.h created+75| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/ranges_move.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/iter_move.h> | |
| 17 | #include <__iterator/next.h> | |
| 18 | #include <__iterator/reverse_iterator.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | ||
| 34 | template <class _InIter, class _OutIter> | |
| 35 | using move_backward_result = in_out_result<_InIter, _OutIter>; | |
| 36 | ||
| 37 | namespace __move_backward { | |
| 38 | struct __fn { | |
| 39 | ||
| 40 | template <class _InIter, class _Sent, class _OutIter> | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 42 | move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { | |
| 43 | auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)), | |
| 44 | std::make_reverse_iterator(__first), | |
| 45 | std::make_reverse_iterator(__result)); | |
| 46 | return {std::move(__ret.in.base()), std::move(__ret.out.base())}; | |
| 47 | } | |
| 48 | ||
| 49 | template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter> | |
| 50 | requires indirectly_movable<_InIter, _OutIter> | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 52 | move_backward_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { | |
| 53 | return __move_backward_impl(std::move(__first), std::move(__last), std::move(__result)); | |
| 54 | } | |
| 55 | ||
| 56 | template <bidirectional_range _Range, bidirectional_iterator _Iter> | |
| 57 | requires indirectly_movable<iterator_t<_Range>, _Iter> | |
| 58 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 59 | move_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __range, _Iter __result) const { | |
| 60 | return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); | |
| 61 | } | |
| 62 | ||
| 63 | }; | |
| 64 | } // namespace __move_backward | |
| 65 | ||
| 66 | inline namespace __cpo { | |
| 67 | inline constexpr auto move_backward = __move_backward::__fn{}; | |
| 68 | } // namespace __cpo | |
| 69 | } // namespace ranges | |
| 70 | ||
| 71 | _LIBCPP_END_NAMESPACE_STD | |
| 72 | ||
| 73 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 74 | ||
| 75 | #endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H |
lib/libcxx/include/__algorithm/ranges_none_of.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_NONE_OF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_NONE_OF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/projected.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__utility/move.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | namespace ranges { | |
| 30 | namespace __none_of { | |
| 31 | struct __fn { | |
| 32 | ||
| 33 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 35 | bool __none_of_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 36 | for (; __first != __last; ++__first) { | |
| 37 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 38 | return false; | |
| 39 | } | |
| 40 | return true; | |
| 41 | } | |
| 42 | ||
| 43 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 44 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 45 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 46 | bool operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const { | |
| 47 | return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 48 | } | |
| 49 | ||
| 50 | template <input_range _Range, class _Proj = identity, | |
| 51 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 53 | bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 54 | return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 55 | } | |
| 56 | }; | |
| 57 | } // namespace __none_of | |
| 58 | ||
| 59 | inline namespace __cpo { | |
| 60 | inline constexpr auto none_of = __none_of::__fn{}; | |
| 61 | } // namespace __cpo | |
| 62 | } // namespace ranges | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | |
| 65 | ||
| 66 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 67 | ||
| 68 | #endif // _LIBCPP___ALGORITHM_RANGES_NONE_OF_H |
lib/libcxx/include/__algorithm/ranges_nth_element.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/nth_element.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/next.h> | |
| 22 | #include <__iterator/projected.h> | |
| 23 | #include <__iterator/sortable.h> | |
| 24 | #include <__ranges/access.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/dangling.h> | |
| 27 | #include <__utility/forward.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | namespace __nth_element { | |
| 40 | ||
| 41 | struct __fn { | |
| 42 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 44 | _Iter __nth_element_fn_impl(_Iter __first, _Iter __nth, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 45 | auto __last_iter = ranges::next(__first, __last); | |
| 46 | ||
| 47 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 48 | std::__nth_element_impl<_RangeAlgPolicy>(std::move(__first), std::move(__nth), __last_iter, __projected_comp); | |
| 49 | ||
| 50 | return __last_iter; | |
| 51 | } | |
| 52 | ||
| 53 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 54 | requires sortable<_Iter, _Comp, _Proj> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 56 | _Iter operator()(_Iter __first, _Iter __nth, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 57 | return __nth_element_fn_impl(std::move(__first), std::move(__nth), std::move(__last), __comp, __proj); | |
| 58 | } | |
| 59 | ||
| 60 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 61 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 63 | borrowed_iterator_t<_Range> operator()(_Range&& __r, iterator_t<_Range> __nth, _Comp __comp = {}, | |
| 64 | _Proj __proj = {}) const { | |
| 65 | return __nth_element_fn_impl(ranges::begin(__r), std::move(__nth), ranges::end(__r), __comp, __proj); | |
| 66 | } | |
| 67 | }; | |
| 68 | ||
| 69 | } // namespace __nth_element | |
| 70 | ||
| 71 | inline namespace __cpo { | |
| 72 | inline constexpr auto nth_element = __nth_element::__fn{}; | |
| 73 | } // namespace __cpo | |
| 74 | } // namespace ranges | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | |
| 77 | ||
| 78 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | ||
| 80 | #endif // _LIBCPP___ALGORITHM_RANGES_NTH_ELEMENT_H |
lib/libcxx/include/__algorithm/ranges_partial_sort.h created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/partial_sort.h> | |
| 15 | #include <__concepts/same_as.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__iterator/sortable.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | namespace __partial_sort { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 45 | _Iter __partial_sort_fn_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 46 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 47 | return std::__partial_sort<_RangeAlgPolicy>(std::move(__first), std::move(__middle), __last, __projected_comp); | |
| 48 | } | |
| 49 | ||
| 50 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 51 | requires sortable<_Iter, _Comp, _Proj> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 53 | _Iter operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 54 | return __partial_sort_fn_impl(std::move(__first), std::move(__middle), std::move(__last), __comp, __proj); | |
| 55 | } | |
| 56 | ||
| 57 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 58 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 60 | borrowed_iterator_t<_Range> operator()(_Range&& __r, iterator_t<_Range> __middle, _Comp __comp = {}, | |
| 61 | _Proj __proj = {}) const { | |
| 62 | return __partial_sort_fn_impl(ranges::begin(__r), std::move(__middle), ranges::end(__r), __comp, __proj); | |
| 63 | } | |
| 64 | }; | |
| 65 | ||
| 66 | } // namespace __partial_sort | |
| 67 | ||
| 68 | inline namespace __cpo { | |
| 69 | inline constexpr auto partial_sort = __partial_sort::__fn{}; | |
| 70 | } // namespace __cpo | |
| 71 | } // namespace ranges | |
| 72 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | |
| 74 | ||
| 75 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 76 | ||
| 77 | #endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_H |
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h created+91| ... | ... | @@ -0,0 +1,91 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__algorithm/make_projected.h> | |
| 15 | #include <__algorithm/partial_sort_copy.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__iterator/sortable.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/concepts.h> | |
| 25 | #include <__ranges/dangling.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | ||
| 38 | template <class _InIter, class _OutIter> | |
| 39 | using partial_sort_copy_result = in_out_result<_InIter, _OutIter>; | |
| 40 | ||
| 41 | namespace __partial_sort_copy { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | ||
| 45 | template <input_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | |
| 46 | random_access_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | |
| 47 | class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity> | |
| 48 | requires indirectly_copyable<_Iter1, _Iter2> && sortable<_Iter2, _Comp, _Proj2> && | |
| 49 | indirect_strict_weak_order<_Comp, projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 51 | partial_sort_copy_result<_Iter1, _Iter2> | |
| 52 | operator()(_Iter1 __first, _Sent1 __last, _Iter2 __result_first, _Sent2 __result_last, | |
| 53 | _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | |
| 54 | auto __result = std::__partial_sort_copy<_RangeAlgPolicy>( | |
| 55 | std::move(__first), std::move(__last), std::move(__result_first), std::move(__result_last), | |
| 56 | __comp, __proj1, __proj2 | |
| 57 | ); | |
| 58 | return {std::move(__result.first), std::move(__result.second)}; | |
| 59 | } | |
| 60 | ||
| 61 | template <input_range _Range1, random_access_range _Range2, class _Comp = ranges::less, | |
| 62 | class _Proj1 = identity, class _Proj2 = identity> | |
| 63 | requires indirectly_copyable<iterator_t<_Range1>, iterator_t<_Range2>> && | |
| 64 | sortable<iterator_t<_Range2>, _Comp, _Proj2> && | |
| 65 | indirect_strict_weak_order<_Comp, projected<iterator_t<_Range1>, _Proj1>, | |
| 66 | projected<iterator_t<_Range2>, _Proj2>> | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 68 | partial_sort_copy_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>> | |
| 69 | operator()(_Range1&& __range, _Range2&& __result_range, _Comp __comp = {}, | |
| 70 | _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { | |
| 71 | auto __result = std::__partial_sort_copy<_RangeAlgPolicy>( | |
| 72 | ranges::begin(__range), ranges::end(__range), ranges::begin(__result_range), ranges::end(__result_range), | |
| 73 | __comp, __proj1, __proj2 | |
| 74 | ); | |
| 75 | return {std::move(__result.first), std::move(__result.second)}; | |
| 76 | } | |
| 77 | ||
| 78 | }; | |
| 79 | ||
| 80 | } // namespace __partial_sort_copy | |
| 81 | ||
| 82 | inline namespace __cpo { | |
| 83 | inline constexpr auto partial_sort_copy = __partial_sort_copy::__fn{}; | |
| 84 | } // namespace __cpo | |
| 85 | } // namespace ranges | |
| 86 | ||
| 87 | _LIBCPP_END_NAMESPACE_STD | |
| 88 | ||
| 89 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 90 | ||
| 91 | #endif // _LIBCPP___ALGORITHM_RANGES_PARTIAL_SORT_COPY_H |
lib/libcxx/include/__algorithm/ranges_partition.h created+82| ... | ... | @@ -0,0 +1,82 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PARTITION_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/partition.h> | |
| 15 | #include <__algorithm/ranges_iterator_concept.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/permutable.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__ranges/access.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/subrange.h> | |
| 27 | #include <__utility/forward.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | #include <type_traits> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | namespace __partition { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | ||
| 44 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 45 | _LIBCPP_HIDE_FROM_ABI static constexpr | |
| 46 | subrange<__uncvref_t<_Iter>> __partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { | |
| 47 | auto&& __projected_pred = std::__make_projected(__pred, __proj); | |
| 48 | auto __result = std::__partition<_RangeAlgPolicy>( | |
| 49 | std::move(__first), std::move(__last), __projected_pred, __iterator_concept<_Iter>()); | |
| 50 | ||
| 51 | return {std::move(__result.first), std::move(__result.second)}; | |
| 52 | } | |
| 53 | ||
| 54 | template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 55 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 57 | subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | |
| 58 | return __partition_fn_impl(__first, __last, __pred, __proj); | |
| 59 | } | |
| 60 | ||
| 61 | template <forward_range _Range, class _Proj = identity, | |
| 62 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 63 | requires permutable<iterator_t<_Range>> | |
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 65 | borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 66 | return __partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 67 | } | |
| 68 | ||
| 69 | }; | |
| 70 | ||
| 71 | } // namespace __partition | |
| 72 | ||
| 73 | inline namespace __cpo { | |
| 74 | inline constexpr auto partition = __partition::__fn{}; | |
| 75 | } // namespace __cpo | |
| 76 | } // namespace ranges | |
| 77 | ||
| 78 | _LIBCPP_END_NAMESPACE_STD | |
| 79 | ||
| 80 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 81 | ||
| 82 | #endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_H |
lib/libcxx/include/__algorithm/ranges_partition_copy.h created+98| ... | ... | @@ -0,0 +1,98 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_out_result.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/iterator_traits.h> | |
| 18 | #include <__iterator/projected.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/dangling.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | #include <type_traits> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | ||
| 35 | template <class _InIter, class _OutIter1, class _OutIter2> | |
| 36 | using partition_copy_result = in_out_out_result<_InIter, _OutIter1, _OutIter2>; | |
| 37 | ||
| 38 | namespace __partition_copy { | |
| 39 | ||
| 40 | struct __fn { | |
| 41 | ||
| 42 | // TODO(ranges): delegate to the classic algorithm. | |
| 43 | template <class _InIter, class _Sent, class _OutIter1, class _OutIter2, class _Proj, class _Pred> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 45 | static partition_copy_result< | |
| 46 | __uncvref_t<_InIter>, __uncvref_t<_OutIter1>, __uncvref_t<_OutIter2> | |
| 47 | > __partition_copy_fn_impl( _InIter&& __first, _Sent&& __last, _OutIter1&& __out_true, _OutIter2&& __out_false, | |
| 48 | _Pred& __pred, _Proj& __proj) { | |
| 49 | for (; __first != __last; ++__first) { | |
| 50 | if (std::invoke(__pred, std::invoke(__proj, *__first))) { | |
| 51 | *__out_true = *__first; | |
| 52 | ++__out_true; | |
| 53 | ||
| 54 | } else { | |
| 55 | *__out_false = *__first; | |
| 56 | ++__out_false; | |
| 57 | } | |
| 58 | } | |
| 59 | ||
| 60 | return {std::move(__first), std::move(__out_true), std::move(__out_false)}; | |
| 61 | } | |
| 62 | ||
| 63 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, | |
| 64 | weakly_incrementable _OutIter1, weakly_incrementable _OutIter2, | |
| 65 | class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | |
| 66 | requires indirectly_copyable<_InIter, _OutIter1> && indirectly_copyable<_InIter, _OutIter2> | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 68 | partition_copy_result<_InIter, _OutIter1, _OutIter2> | |
| 69 | operator()(_InIter __first, _Sent __last, _OutIter1 __out_true, _OutIter2 __out_false, | |
| 70 | _Pred __pred, _Proj __proj = {}) const { | |
| 71 | return __partition_copy_fn_impl( | |
| 72 | std::move(__first), std::move(__last), std::move(__out_true), std::move(__out_false), __pred, __proj); | |
| 73 | } | |
| 74 | ||
| 75 | template <input_range _Range, weakly_incrementable _OutIter1, weakly_incrementable _OutIter2, | |
| 76 | class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 77 | requires indirectly_copyable<iterator_t<_Range>, _OutIter1> && indirectly_copyable<iterator_t<_Range>, _OutIter2> | |
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 79 | partition_copy_result<borrowed_iterator_t<_Range>, _OutIter1, _OutIter2> | |
| 80 | operator()(_Range&& __range, _OutIter1 __out_true, _OutIter2 __out_false, _Pred __pred, _Proj __proj = {}) const { | |
| 81 | return __partition_copy_fn_impl( | |
| 82 | ranges::begin(__range), ranges::end(__range), std::move(__out_true), std::move(__out_false), __pred, __proj); | |
| 83 | } | |
| 84 | ||
| 85 | }; | |
| 86 | ||
| 87 | } // namespace __partition_copy | |
| 88 | ||
| 89 | inline namespace __cpo { | |
| 90 | inline constexpr auto partition_copy = __partition_copy::__fn{}; | |
| 91 | } // namespace __cpo | |
| 92 | } // namespace ranges | |
| 93 | ||
| 94 | _LIBCPP_END_NAMESPACE_STD | |
| 95 | ||
| 96 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 97 | ||
| 98 | #endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_COPY_H |
lib/libcxx/include/__algorithm/ranges_partition_point.h created+88| ... | ... | @@ -0,0 +1,88 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H | |
| 11 | ||
| 12 | #include <__algorithm/half_positive.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/distance.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/next.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/dangling.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | namespace __partition_point { | |
| 36 | ||
| 37 | struct __fn { | |
| 38 | ||
| 39 | // TODO(ranges): delegate to the classic algorithm. | |
| 40 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 42 | static _Iter __partition_point_fn_impl(_Iter&& __first, _Sent&& __last, _Pred& __pred, _Proj& __proj) { | |
| 43 | auto __len = ranges::distance(__first, __last); | |
| 44 | ||
| 45 | while (__len != 0) { | |
| 46 | auto __half_len = std::__half_positive(__len); | |
| 47 | auto __mid = ranges::next(__first, __half_len); | |
| 48 | ||
| 49 | if (std::invoke(__pred, std::invoke(__proj, *__mid))) { | |
| 50 | __first = ++__mid; | |
| 51 | __len -= __half_len + 1; | |
| 52 | ||
| 53 | } else { | |
| 54 | __len = __half_len; | |
| 55 | } | |
| 56 | } | |
| 57 | ||
| 58 | return __first; | |
| 59 | } | |
| 60 | ||
| 61 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 62 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 64 | _Iter operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | |
| 65 | return __partition_point_fn_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 66 | } | |
| 67 | ||
| 68 | template <forward_range _Range, class _Proj = identity, | |
| 69 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 71 | borrowed_iterator_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 72 | return __partition_point_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 73 | } | |
| 74 | ||
| 75 | }; | |
| 76 | ||
| 77 | } // namespace __partition_point | |
| 78 | ||
| 79 | inline namespace __cpo { | |
| 80 | inline constexpr auto partition_point = __partition_point::__fn{}; | |
| 81 | } // namespace __cpo | |
| 82 | } // namespace ranges | |
| 83 | ||
| 84 | _LIBCPP_END_NAMESPACE_STD | |
| 85 | ||
| 86 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 87 | ||
| 88 | #endif // _LIBCPP___ALGORITHM_RANGES_PARTITION_POINT_H |
lib/libcxx/include/__algorithm/ranges_pop_heap.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/pop_heap.h> | |
| 15 | #include <__concepts/same_as.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__iterator/sortable.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | namespace __pop_heap { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 45 | _Iter __pop_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 46 | auto __last_iter = ranges::next(__first, __last); | |
| 47 | auto __len = __last_iter - __first; | |
| 48 | ||
| 49 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 50 | std::__pop_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp, __len); | |
| 51 | ||
| 52 | return __last_iter; | |
| 53 | } | |
| 54 | ||
| 55 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 56 | requires sortable<_Iter, _Comp, _Proj> | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 58 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 59 | return __pop_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 60 | } | |
| 61 | ||
| 62 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 63 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 65 | borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 66 | return __pop_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 67 | } | |
| 68 | }; | |
| 69 | ||
| 70 | } // namespace __pop_heap | |
| 71 | ||
| 72 | inline namespace __cpo { | |
| 73 | inline constexpr auto pop_heap = __pop_heap::__fn{}; | |
| 74 | } // namespace __cpo | |
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | |
| 78 | ||
| 79 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 80 | ||
| 81 | #endif // _LIBCPP___ALGORITHM_RANGES_POP_HEAP_H |
lib/libcxx/include/__algorithm/ranges_push_heap.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/push_heap.h> | |
| 15 | #include <__concepts/same_as.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__iterator/sortable.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | namespace __push_heap { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 45 | _Iter __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 46 | auto __last_iter = ranges::next(__first, __last); | |
| 47 | ||
| 48 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 49 | std::__push_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp); | |
| 50 | ||
| 51 | return __last_iter; | |
| 52 | } | |
| 53 | ||
| 54 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 55 | requires sortable<_Iter, _Comp, _Proj> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 57 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 58 | return __push_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 59 | } | |
| 60 | ||
| 61 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 62 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 64 | borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 65 | return __push_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 66 | } | |
| 67 | }; | |
| 68 | ||
| 69 | } // namespace __push_heap | |
| 70 | ||
| 71 | inline namespace __cpo { | |
| 72 | inline constexpr auto push_heap = __push_heap::__fn{}; | |
| 73 | } // namespace __cpo | |
| 74 | } // namespace ranges | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | |
| 77 | ||
| 78 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | ||
| 80 | #endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H |
lib/libcxx/include/__algorithm/ranges_remove.h created+64| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REMOVE_H | |
| 11 | #include <__config> | |
| 12 | ||
| 13 | #include <__algorithm/ranges_remove_if.h> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/permutable.h> | |
| 18 | #include <__iterator/projected.h> | |
| 19 | #include <__ranges/access.h> | |
| 20 | #include <__ranges/concepts.h> | |
| 21 | #include <__ranges/subrange.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | namespace __remove { | |
| 34 | struct __fn { | |
| 35 | ||
| 36 | template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity> | |
| 37 | requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 39 | subrange<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { | |
| 40 | auto __pred = [&](auto&& __other) { return __value == __other; }; | |
| 41 | return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 42 | } | |
| 43 | ||
| 44 | template <forward_range _Range, class _Type, class _Proj = identity> | |
| 45 | requires permutable<iterator_t<_Range>> | |
| 46 | && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 48 | borrowed_subrange_t<_Range> operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const { | |
| 49 | auto __pred = [&](auto&& __other) { return __value == __other; }; | |
| 50 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 51 | } | |
| 52 | }; | |
| 53 | } // namespace __remove | |
| 54 | ||
| 55 | inline namespace __cpo { | |
| 56 | inline constexpr auto remove = __remove::__fn{}; | |
| 57 | } // namespace __cpo | |
| 58 | } // namespace ranges | |
| 59 | ||
| 60 | _LIBCPP_END_NAMESPACE_STD | |
| 61 | ||
| 62 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 63 | ||
| 64 | #endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_H |
lib/libcxx/include/__algorithm/ranges_remove_copy.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/remove_copy.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | #include <__utility/forward.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | ||
| 38 | template <class _InIter, class _OutIter> | |
| 39 | using remove_copy_result = in_out_result<_InIter, _OutIter>; | |
| 40 | ||
| 41 | namespace __remove_copy { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | ||
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, class _Type, | |
| 46 | class _Proj = identity> | |
| 47 | requires indirectly_copyable<_InIter, _OutIter> && | |
| 48 | indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type*> | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 50 | remove_copy_result<_InIter, _OutIter> | |
| 51 | operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type& __value, _Proj __proj = {}) const { | |
| 52 | // TODO: implement | |
| 53 | (void)__first; (void)__last; (void)__result; (void)__value; (void)__proj; | |
| 54 | return {}; | |
| 55 | } | |
| 56 | ||
| 57 | template <input_range _Range, weakly_incrementable _OutIter, class _Type, class _Proj = identity> | |
| 58 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && | |
| 59 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 61 | remove_copy_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 62 | operator()(_Range&& __range, _OutIter __result, const _Type& __value, _Proj __proj = {}) const { | |
| 63 | // TODO: implement | |
| 64 | (void)__range; (void)__result; (void)__value; (void)__proj; | |
| 65 | return {}; | |
| 66 | } | |
| 67 | ||
| 68 | }; | |
| 69 | ||
| 70 | } // namespace __remove_copy | |
| 71 | ||
| 72 | inline namespace __cpo { | |
| 73 | inline constexpr auto remove_copy = __remove_copy::__fn{}; | |
| 74 | } // namespace __cpo | |
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | |
| 78 | ||
| 79 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 80 | ||
| 81 | #endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_H |
lib/libcxx/include/__algorithm/ranges_remove_copy_if.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/remove_copy_if.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | #include <__utility/forward.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | ||
| 38 | template <class _InIter, class _OutIter> | |
| 39 | using remove_copy_if_result = in_out_result<_InIter, _OutIter>; | |
| 40 | ||
| 41 | namespace __remove_copy_if { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | ||
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter, | |
| 46 | class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | |
| 47 | requires indirectly_copyable<_InIter, _OutIter> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | remove_copy_if_result<_InIter, _OutIter> | |
| 50 | operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | |
| 51 | // TODO: implement | |
| 52 | (void)__first; (void)__last; (void)__result; (void)__pred; (void)__proj; | |
| 53 | return {}; | |
| 54 | } | |
| 55 | ||
| 56 | template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity, | |
| 57 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 58 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 60 | remove_copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 61 | operator()(_Range&& __range, _OutIter __result, _Pred __pred, _Proj __proj = {}) const { | |
| 62 | // TODO: implement | |
| 63 | (void)__range; (void)__result; (void)__pred; (void)__proj; | |
| 64 | return {}; | |
| 65 | } | |
| 66 | ||
| 67 | }; | |
| 68 | ||
| 69 | } // namespace __remove_copy_if | |
| 70 | ||
| 71 | inline namespace __cpo { | |
| 72 | inline constexpr auto remove_copy_if = __remove_copy_if::__fn{}; | |
| 73 | } // namespace __cpo | |
| 74 | } // namespace ranges | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | |
| 77 | ||
| 78 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | ||
| 80 | #endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_COPY_IF_H |
lib/libcxx/include/__algorithm/ranges_remove_if.h created+85| ... | ... | @@ -0,0 +1,85 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H | |
| 11 | #include <__config> | |
| 12 | ||
| 13 | #include <__algorithm/ranges_find_if.h> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/iter_move.h> | |
| 19 | #include <__iterator/permutable.h> | |
| 20 | #include <__iterator/projected.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/subrange.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | ||
| 36 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 38 | subrange<_Iter> __remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { | |
| 39 | auto __new_end = ranges::__find_if_impl(__first, __last, __pred, __proj); | |
| 40 | if (__new_end == __last) | |
| 41 | return {__new_end, __new_end}; | |
| 42 | ||
| 43 | _Iter __i = __new_end; | |
| 44 | while (++__i != __last) { | |
| 45 | if (!std::invoke(__pred, std::invoke(__proj, *__i))) { | |
| 46 | *__new_end = ranges::iter_move(__i); | |
| 47 | ++__new_end; | |
| 48 | } | |
| 49 | } | |
| 50 | return {__new_end, __i}; | |
| 51 | } | |
| 52 | ||
| 53 | namespace __remove_if { | |
| 54 | struct __fn { | |
| 55 | ||
| 56 | template <permutable _Iter, sentinel_for<_Iter> _Sent, | |
| 57 | class _Proj = identity, | |
| 58 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 60 | subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | |
| 61 | return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj); | |
| 62 | } | |
| 63 | ||
| 64 | template <forward_range _Range, | |
| 65 | class _Proj = identity, | |
| 66 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 67 | requires permutable<iterator_t<_Range>> | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 69 | borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 70 | return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 71 | } | |
| 72 | ||
| 73 | }; | |
| 74 | } // namespace __remove_if | |
| 75 | ||
| 76 | inline namespace __cpo { | |
| 77 | inline constexpr auto remove_if = __remove_if::__fn{}; | |
| 78 | } // namespace __cpo | |
| 79 | } // namespace ranges | |
| 80 | ||
| 81 | _LIBCPP_END_NAMESPACE_STD | |
| 82 | ||
| 83 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 84 | ||
| 85 | #endif // _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H |
lib/libcxx/include/__algorithm/ranges_replace.h created+74| ... | ... | @@ -0,0 +1,74 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_replace_if.h> | |
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | namespace ranges { | |
| 32 | namespace __replace { | |
| 33 | struct __fn { | |
| 34 | ||
| 35 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 36 | class _Type1, | |
| 37 | class _Type2, | |
| 38 | class _Proj = identity> | |
| 39 | requires indirectly_writable<_Iter, const _Type2&> | |
| 40 | && indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type1*> | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 42 | _Iter operator()(_Iter __first, _Sent __last, | |
| 43 | const _Type1& __old_value, | |
| 44 | const _Type2& __new_value, | |
| 45 | _Proj __proj = {}) const { | |
| 46 | auto __pred = [&](const auto& __val) { return __val == __old_value; }; | |
| 47 | return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj); | |
| 48 | } | |
| 49 | ||
| 50 | template <input_range _Range, | |
| 51 | class _Type1, | |
| 52 | class _Type2, | |
| 53 | class _Proj = identity> | |
| 54 | requires indirectly_writable<iterator_t<_Range>, const _Type2&> | |
| 55 | && indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | |
| 57 | operator()(_Range&& __range, const _Type1& __old_value, const _Type2& __new_value, _Proj __proj = {}) const { | |
| 58 | auto __pred = [&](auto&& __val) { return __val == __old_value; }; | |
| 59 | return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); | |
| 60 | } | |
| 61 | ||
| 62 | }; | |
| 63 | } // namespace __replace | |
| 64 | ||
| 65 | inline namespace __cpo { | |
| 66 | inline constexpr auto replace = __replace::__fn{}; | |
| 67 | } // namespace __cpo | |
| 68 | } // namespace ranges | |
| 69 | ||
| 70 | _LIBCPP_END_NAMESPACE_STD | |
| 71 | ||
| 72 | #endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 73 | ||
| 74 | #endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_H |
lib/libcxx/include/__algorithm/ranges_replace_copy.h created+84| ... | ... | @@ -0,0 +1,84 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/replace_copy.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | #include <__utility/forward.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | ||
| 38 | template <class _InIter, class _OutIter> | |
| 39 | using replace_copy_result = in_out_result<_InIter, _OutIter>; | |
| 40 | ||
| 41 | namespace __replace_copy { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | ||
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type1, class _Type2, | |
| 46 | output_iterator<const _Type2&> _OutIter, class _Proj = identity> | |
| 47 | requires indirectly_copyable<_InIter, _OutIter> && | |
| 48 | indirect_binary_predicate<ranges::equal_to, projected<_InIter, _Proj>, const _Type1*> | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 50 | replace_copy_result<_InIter, _OutIter> | |
| 51 | operator()(_InIter __first, _Sent __last, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value, | |
| 52 | _Proj __proj = {}) const { | |
| 53 | // TODO: implement | |
| 54 | (void)__first; (void)__last; (void)__result; (void)__old_value; (void)__new_value; (void)__proj; | |
| 55 | return {}; | |
| 56 | } | |
| 57 | ||
| 58 | template <input_range _Range, class _Type1, class _Type2, output_iterator<const _Type2&> _OutIter, | |
| 59 | class _Proj = identity> | |
| 60 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && | |
| 61 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type1*> | |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 63 | replace_copy_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 64 | operator()(_Range&& __range, _OutIter __result, const _Type1& __old_value, const _Type2& __new_value, | |
| 65 | _Proj __proj = {}) const { | |
| 66 | // TODO: implement | |
| 67 | (void)__range; (void)__result; (void)__old_value; (void)__new_value; (void)__proj; | |
| 68 | return {}; | |
| 69 | } | |
| 70 | ||
| 71 | }; | |
| 72 | ||
| 73 | } // namespace __replace_copy | |
| 74 | ||
| 75 | inline namespace __cpo { | |
| 76 | inline constexpr auto replace_copy = __replace_copy::__fn{}; | |
| 77 | } // namespace __cpo | |
| 78 | } // namespace ranges | |
| 79 | ||
| 80 | _LIBCPP_END_NAMESPACE_STD | |
| 81 | ||
| 82 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 83 | ||
| 84 | #endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_H |
lib/libcxx/include/__algorithm/ranges_replace_copy_if.h created+81| ... | ... | @@ -0,0 +1,81 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/replace_copy_if.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/projected.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | #include <__utility/forward.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | # pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | ||
| 34 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 35 | ||
| 36 | namespace ranges { | |
| 37 | ||
| 38 | template <class _InIter, class _OutIter> | |
| 39 | using replace_copy_if_result = in_out_result<_InIter, _OutIter>; | |
| 40 | ||
| 41 | namespace __replace_copy_if { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | ||
| 45 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, class _Type, output_iterator<const _Type&> _OutIter, | |
| 46 | class _Proj = identity, indirect_unary_predicate<projected<_InIter, _Proj>> _Pred> | |
| 47 | requires indirectly_copyable<_InIter, _OutIter> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | replace_copy_if_result<_InIter, _OutIter> | |
| 50 | operator()(_InIter __first, _Sent __last, _OutIter __result, _Pred __pred, const _Type& __new_value, | |
| 51 | _Proj __proj = {}) const { | |
| 52 | // TODO: implement | |
| 53 | (void)__first; (void)__last; (void)__result; (void)__pred; (void)__new_value; (void)__proj; | |
| 54 | return {}; | |
| 55 | } | |
| 56 | ||
| 57 | template <input_range _Range, class _Type, output_iterator<const _Type&> _OutIter, class _Proj = identity, | |
| 58 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 59 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 61 | replace_copy_if_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 62 | operator()(_Range&& __range, _OutIter __result, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const { | |
| 63 | // TODO: implement | |
| 64 | (void)__range; (void)__result; (void)__pred; (void)__new_value; (void)__proj; | |
| 65 | return {}; | |
| 66 | } | |
| 67 | ||
| 68 | }; | |
| 69 | ||
| 70 | } // namespace __replace_copy_if | |
| 71 | ||
| 72 | inline namespace __cpo { | |
| 73 | inline constexpr auto replace_copy_if = __replace_copy_if::__fn{}; | |
| 74 | } // namespace __cpo | |
| 75 | } // namespace ranges | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | |
| 78 | ||
| 79 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 80 | ||
| 81 | #endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_COPY_IF_H |
lib/libcxx/include/__algorithm/ranges_replace_if.h created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__functional/identity.h> | |
| 14 | #include <__functional/invoke.h> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/projected.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__ranges/dangling.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | ||
| 32 | template <class _Iter, class _Sent, class _Type, class _Proj, class _Pred> | |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 34 | _Iter __replace_if_impl(_Iter __first, _Sent __last, _Pred& __pred, const _Type& __new_value, _Proj& __proj) { | |
| 35 | for (; __first != __last; ++__first) { | |
| 36 | if (std::invoke(__pred, std::invoke(__proj, *__first))) | |
| 37 | *__first = __new_value; | |
| 38 | } | |
| 39 | return __first; | |
| 40 | } | |
| 41 | ||
| 42 | namespace __replace_if { | |
| 43 | struct __fn { | |
| 44 | ||
| 45 | template <input_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 46 | class _Type, | |
| 47 | class _Proj = identity, | |
| 48 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 49 | requires indirectly_writable<_Iter, const _Type&> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 51 | _Iter operator()(_Iter __first, _Sent __last, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const { | |
| 52 | return ranges::__replace_if_impl(std::move(__first), std::move(__last), __pred, __new_value, __proj); | |
| 53 | } | |
| 54 | ||
| 55 | template <input_range _Range, | |
| 56 | class _Type, | |
| 57 | class _Proj = identity, | |
| 58 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 59 | requires indirectly_writable<iterator_t<_Range>, const _Type&> | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range> | |
| 61 | operator()(_Range&& __range, _Pred __pred, const _Type& __new_value, _Proj __proj = {}) const { | |
| 62 | return ranges::__replace_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __new_value, __proj); | |
| 63 | } | |
| 64 | ||
| 65 | }; | |
| 66 | } // namespace __replace_if | |
| 67 | ||
| 68 | inline namespace __cpo { | |
| 69 | inline constexpr auto replace_if = __replace_if::__fn{}; | |
| 70 | } // namespace __cpo | |
| 71 | } // namespace ranges | |
| 72 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | |
| 74 | ||
| 75 | #endif // _LIBCPP_STD_VER > 17 && !defined (_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 76 | ||
| 77 | #endif // _LIBCPP___ALGORITHM_RANGES_REPLACE_IF_H |
lib/libcxx/include/__algorithm/ranges_reverse.h created+83| ... | ... | @@ -0,0 +1,83 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REVERSE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REVERSE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__iterator/concepts.h> | |
| 14 | #include <__iterator/iter_swap.h> | |
| 15 | #include <__iterator/next.h> | |
| 16 | #include <__iterator/permutable.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__ranges/dangling.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | namespace ranges { | |
| 30 | namespace __reverse { | |
| 31 | struct __fn { | |
| 32 | ||
| 33 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent> | |
| 34 | requires permutable<_Iter> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 36 | _Iter operator()(_Iter __first, _Sent __last) const { | |
| 37 | if constexpr (random_access_iterator<_Iter>) { | |
| 38 | if (__first == __last) | |
| 39 | return __first; | |
| 40 | ||
| 41 | auto __end = ranges::next(__first, __last); | |
| 42 | auto __ret = __end; | |
| 43 | ||
| 44 | while (__first < --__end) { | |
| 45 | ranges::iter_swap(__first, __end); | |
| 46 | ++__first; | |
| 47 | } | |
| 48 | return __ret; | |
| 49 | } else { | |
| 50 | auto __end = ranges::next(__first, __last); | |
| 51 | auto __ret = __end; | |
| 52 | ||
| 53 | while (__first != __end) { | |
| 54 | if (__first == --__end) | |
| 55 | break; | |
| 56 | ||
| 57 | ranges::iter_swap(__first, __end); | |
| 58 | ++__first; | |
| 59 | } | |
| 60 | return __ret; | |
| 61 | } | |
| 62 | } | |
| 63 | ||
| 64 | template <bidirectional_range _Range> | |
| 65 | requires permutable<iterator_t<_Range>> | |
| 66 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 67 | borrowed_iterator_t<_Range> operator()(_Range&& __range) const { | |
| 68 | return (*this)(ranges::begin(__range), ranges::end(__range)); | |
| 69 | } | |
| 70 | ||
| 71 | }; | |
| 72 | } // namespace __reverse | |
| 73 | ||
| 74 | inline namespace __cpo { | |
| 75 | inline constexpr auto reverse = __reverse::__fn{}; | |
| 76 | } // namespace __cpo | |
| 77 | } // namespace ranges | |
| 78 | ||
| 79 | _LIBCPP_END_NAMESPACE_STD | |
| 80 | ||
| 81 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 82 | ||
| 83 | #endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_H |
lib/libcxx/include/__algorithm/ranges_reverse_copy.h created+67| ... | ... | @@ -0,0 +1,67 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/ranges_copy.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/next.h> | |
| 17 | #include <__iterator/reverse_iterator.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/concepts.h> | |
| 20 | #include <__ranges/dangling.h> | |
| 21 | #include <__ranges/subrange.h> | |
| 22 | #include <__utility/move.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | ||
| 34 | template <class _InIter, class _OutIter> | |
| 35 | using reverse_copy_result = in_out_result<_InIter, _OutIter>; | |
| 36 | ||
| 37 | namespace __reverse_copy { | |
| 38 | struct __fn { | |
| 39 | ||
| 40 | template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> | |
| 41 | requires indirectly_copyable<_InIter, _OutIter> | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 43 | reverse_copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { | |
| 44 | return (*this)(subrange(std::move(__first), std::move(__last)), std::move(__result)); | |
| 45 | } | |
| 46 | ||
| 47 | template <bidirectional_range _Range, weakly_incrementable _OutIter> | |
| 48 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 50 | reverse_copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const { | |
| 51 | auto __ret = ranges::copy(std::__reverse_range(__range), std::move(__result)); | |
| 52 | return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)}; | |
| 53 | } | |
| 54 | ||
| 55 | }; | |
| 56 | } // namespace __reverse_copy | |
| 57 | ||
| 58 | inline namespace __cpo { | |
| 59 | inline constexpr auto reverse_copy = __reverse_copy::__fn{}; | |
| 60 | } // namespace __cpo | |
| 61 | } // namespace ranges | |
| 62 | ||
| 63 | _LIBCPP_END_NAMESPACE_STD | |
| 64 | ||
| 65 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 66 | ||
| 67 | #endif // _LIBCPP___ALGORITHM_RANGES_REVERSE_COPY_H |
lib/libcxx/include/__algorithm/ranges_rotate_copy.h created+68| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/ranges_copy.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/reverse_iterator.h> | |
| 17 | #include <__ranges/access.h> | |
| 18 | #include <__ranges/concepts.h> | |
| 19 | #include <__ranges/dangling.h> | |
| 20 | #include <__utility/move.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | ||
| 28 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | ||
| 30 | namespace ranges { | |
| 31 | ||
| 32 | template <class _InIter, class _OutIter> | |
| 33 | using rotate_copy_result = in_out_result<_InIter, _OutIter>; | |
| 34 | ||
| 35 | namespace __rotate_copy { | |
| 36 | struct __fn { | |
| 37 | ||
| 38 | template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> | |
| 39 | requires indirectly_copyable<_InIter, _OutIter> | |
| 40 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 41 | rotate_copy_result<_InIter, _OutIter> | |
| 42 | operator()(_InIter __first, _InIter __middle, _Sent __last, _OutIter __result) const { | |
| 43 | auto __res1 = ranges::copy(__middle, __last, std::move(__result)); | |
| 44 | auto __res2 = ranges::copy(__first, __middle, std::move(__res1.out)); | |
| 45 | return {std::move(__res1.in), std::move(__res2.out)}; | |
| 46 | } | |
| 47 | ||
| 48 | template <bidirectional_range _Range, weakly_incrementable _OutIter> | |
| 49 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 51 | rotate_copy_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 52 | operator()(_Range&& __range, iterator_t<_Range> __middle, _OutIter __result) const { | |
| 53 | return (*this)(ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__result)); | |
| 54 | } | |
| 55 | ||
| 56 | }; | |
| 57 | } // namespace __rotate_copy | |
| 58 | ||
| 59 | inline namespace __cpo { | |
| 60 | inline constexpr auto rotate_copy = __rotate_copy::__fn{}; | |
| 61 | } // namespace __cpo | |
| 62 | } // namespace ranges | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | |
| 65 | ||
| 66 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 67 | ||
| 68 | #endif // _LIBCPP___ALGORITHM_RANGES_ROTATE_COPY_H |
lib/libcxx/include/__algorithm/ranges_search.h created+134| ... | ... | @@ -0,0 +1,134 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SEARCH_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SEARCH_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/search.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/advance.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/distance.h> | |
| 20 | #include <__iterator/indirectly_comparable.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/size.h> | |
| 24 | #include <__ranges/subrange.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | namespace __search { | |
| 36 | struct __fn { | |
| 37 | template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> | |
| 38 | _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_impl( | |
| 39 | _Iter1 __first1, | |
| 40 | _Sent1 __last1, | |
| 41 | _Iter2 __first2, | |
| 42 | _Sent2 __last2, | |
| 43 | _Pred& __pred, | |
| 44 | _Proj1& __proj1, | |
| 45 | _Proj2& __proj2) { | |
| 46 | if constexpr (sized_sentinel_for<_Sent2, _Iter2>) { | |
| 47 | auto __size2 = ranges::distance(__first2, __last2); | |
| 48 | if (__size2 == 0) | |
| 49 | return {__first1, __first1}; | |
| 50 | ||
| 51 | if constexpr (sized_sentinel_for<_Sent1, _Iter1>) { | |
| 52 | auto __size1 = ranges::distance(__first1, __last1); | |
| 53 | if (__size1 < __size2) { | |
| 54 | ranges::advance(__first1, __last1); | |
| 55 | return {__first1, __first1}; | |
| 56 | } | |
| 57 | ||
| 58 | if constexpr (random_access_iterator<_Iter1> && random_access_iterator<_Iter2>) { | |
| 59 | auto __ret = std::__search_random_access_impl<_RangeAlgPolicy>( | |
| 60 | __first1, __last1, __first2, __last2, __pred, __proj1, __proj2, __size1, __size2); | |
| 61 | return {__ret.first, __ret.second}; | |
| 62 | } | |
| 63 | } | |
| 64 | } | |
| 65 | ||
| 66 | auto __ret = | |
| 67 | std::__search_forward_impl<_RangeAlgPolicy>(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); | |
| 68 | return {__ret.first, __ret.second}; | |
| 69 | } | |
| 70 | ||
| 71 | template <forward_iterator _Iter1, sentinel_for<_Iter1> _Sent1, | |
| 72 | forward_iterator _Iter2, sentinel_for<_Iter2> _Sent2, | |
| 73 | class _Pred = ranges::equal_to, | |
| 74 | class _Proj1 = identity, | |
| 75 | class _Proj2 = identity> | |
| 76 | requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> | |
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 78 | subrange<_Iter1> operator()(_Iter1 __first1, _Sent1 __last1, | |
| 79 | _Iter2 __first2, _Sent2 __last2, | |
| 80 | _Pred __pred = {}, | |
| 81 | _Proj1 __proj1 = {}, | |
| 82 | _Proj2 __proj2 = {}) const { | |
| 83 | return __ranges_search_impl(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); | |
| 84 | } | |
| 85 | ||
| 86 | template <forward_range _Range1, | |
| 87 | forward_range _Range2, | |
| 88 | class _Pred = ranges::equal_to, | |
| 89 | class _Proj1 = identity, | |
| 90 | class _Proj2 = identity> | |
| 91 | requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> | |
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 93 | borrowed_subrange_t<_Range1> operator()(_Range1&& __range1, | |
| 94 | _Range2&& __range2, | |
| 95 | _Pred __pred = {}, | |
| 96 | _Proj1 __proj1 = {}, | |
| 97 | _Proj2 __proj2 = {}) const { | |
| 98 | auto __first1 = ranges::begin(__range1); | |
| 99 | if constexpr (sized_range<_Range2>) { | |
| 100 | auto __size2 = ranges::size(__range2); | |
| 101 | if (__size2 == 0) | |
| 102 | return {__first1, __first1}; | |
| 103 | if constexpr (sized_range<_Range1>) { | |
| 104 | auto __size1 = ranges::size(__range1); | |
| 105 | if (__size1 < __size2) { | |
| 106 | ranges::advance(__first1, ranges::end(__range1)); | |
| 107 | return {__first1, __first1}; | |
| 108 | } | |
| 109 | } | |
| 110 | } | |
| 111 | ||
| 112 | return __ranges_search_impl( | |
| 113 | ranges::begin(__range1), | |
| 114 | ranges::end(__range1), | |
| 115 | ranges::begin(__range2), | |
| 116 | ranges::end(__range2), | |
| 117 | __pred, | |
| 118 | __proj1, | |
| 119 | __proj2); | |
| 120 | } | |
| 121 | ||
| 122 | }; | |
| 123 | } // namespace __search | |
| 124 | ||
| 125 | inline namespace __cpo { | |
| 126 | inline constexpr auto search = __search::__fn{}; | |
| 127 | } // namespace __cpo | |
| 128 | } // namespace ranges | |
| 129 | ||
| 130 | _LIBCPP_END_NAMESPACE_STD | |
| 131 | ||
| 132 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 133 | ||
| 134 | #endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_H |
lib/libcxx/include/__algorithm/ranges_search_n.h created+120| ... | ... | @@ -0,0 +1,120 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/search_n.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/advance.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/distance.h> | |
| 20 | #include <__iterator/incrementable_traits.h> | |
| 21 | #include <__iterator/indirectly_comparable.h> | |
| 22 | #include <__iterator/iterator_traits.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/concepts.h> | |
| 25 | #include <__ranges/size.h> | |
| 26 | #include <__ranges/subrange.h> | |
| 27 | #include <__utility/move.h> | |
| 28 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | ||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 36 | ||
| 37 | namespace ranges { | |
| 38 | namespace __search_n { | |
| 39 | struct __fn { | |
| 40 | ||
| 41 | template <class _Iter1, class _Sent1, class _SizeT, class _Type, class _Pred, class _Proj> | |
| 42 | _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter1> __ranges_search_n_impl( | |
| 43 | _Iter1 __first, _Sent1 __last, _SizeT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) { | |
| 44 | if (__count == 0) | |
| 45 | return {__first, __first}; | |
| 46 | ||
| 47 | if constexpr (sized_sentinel_for<_Sent1, _Iter1>) { | |
| 48 | auto __size = ranges::distance(__first, __last); | |
| 49 | if (__size < __count) { | |
| 50 | ranges::advance(__first, __last); | |
| 51 | return {__first, __first}; | |
| 52 | } | |
| 53 | ||
| 54 | if constexpr (random_access_iterator<_Iter1>) { | |
| 55 | auto __ret = __search_n_random_access_impl<_RangeAlgPolicy>(__first, __last, | |
| 56 | __count, | |
| 57 | __value, | |
| 58 | __pred, | |
| 59 | __proj, | |
| 60 | __size); | |
| 61 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 62 | } | |
| 63 | } | |
| 64 | ||
| 65 | auto __ret = std::__search_n_forward_impl<_RangeAlgPolicy>(__first, __last, | |
| 66 | __count, | |
| 67 | __value, | |
| 68 | __pred, | |
| 69 | __proj); | |
| 70 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 71 | } | |
| 72 | ||
| 73 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, | |
| 74 | class _Type, | |
| 75 | class _Pred = ranges::equal_to, | |
| 76 | class _Proj = identity> | |
| 77 | requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj> | |
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 79 | subrange<_Iter> operator()(_Iter __first, _Sent __last, | |
| 80 | iter_difference_t<_Iter> __count, | |
| 81 | const _Type& __value, | |
| 82 | _Pred __pred = {}, | |
| 83 | _Proj __proj = _Proj{}) const { | |
| 84 | return __ranges_search_n_impl(__first, __last, __count, __value, __pred, __proj); | |
| 85 | } | |
| 86 | ||
| 87 | template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity> | |
| 88 | requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj> | |
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 90 | borrowed_subrange_t<_Range> operator()(_Range&& __range, | |
| 91 | range_difference_t<_Range> __count, | |
| 92 | const _Type& __value, | |
| 93 | _Pred __pred = {}, | |
| 94 | _Proj __proj = {}) const { | |
| 95 | auto __first = ranges::begin(__range); | |
| 96 | if (__count <= 0) | |
| 97 | return {__first, __first}; | |
| 98 | if constexpr (sized_range<_Range>) { | |
| 99 | auto __size1 = ranges::size(__range); | |
| 100 | if (__size1 < static_cast<range_size_t<_Range>>(__count)) { | |
| 101 | ranges::advance(__first, ranges::end(__range)); | |
| 102 | return {__first, __first}; | |
| 103 | } | |
| 104 | } | |
| 105 | ||
| 106 | return __ranges_search_n_impl(ranges::begin(__range), ranges::end(__range), __count, __value, __pred, __proj); | |
| 107 | } | |
| 108 | }; | |
| 109 | } // namespace __search_n | |
| 110 | ||
| 111 | inline namespace __cpo { | |
| 112 | inline constexpr auto search_n = __search_n::__fn{}; | |
| 113 | } // namespace __cpo | |
| 114 | } // namespace ranges | |
| 115 | ||
| 116 | _LIBCPP_END_NAMESPACE_STD | |
| 117 | ||
| 118 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 119 | ||
| 120 | #endif // _LIBCPP___ALGORITHM_RANGES_SEARCH_N_H |
lib/libcxx/include/__algorithm/ranges_set_difference.h created+104| ... | ... | @@ -0,0 +1,104 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/set_difference.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/mergeable.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/dangling.h> | |
| 24 | #include <__type_traits/decay.h> | |
| 25 | #include <__utility/move.h> | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | #endif | |
| 30 | ||
| 31 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | ||
| 35 | namespace ranges { | |
| 36 | ||
| 37 | template <class _InIter, class _OutIter> | |
| 38 | using set_difference_result = in_out_result<_InIter, _OutIter>; | |
| 39 | ||
| 40 | namespace __set_difference { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template < | |
| 44 | input_iterator _InIter1, | |
| 45 | sentinel_for<_InIter1> _Sent1, | |
| 46 | input_iterator _InIter2, | |
| 47 | sentinel_for<_InIter2> _Sent2, | |
| 48 | weakly_incrementable _OutIter, | |
| 49 | class _Comp = less, | |
| 50 | class _Proj1 = identity, | |
| 51 | class _Proj2 = identity> | |
| 52 | requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> | |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<_InIter1, _OutIter> operator()( | |
| 54 | _InIter1 __first1, | |
| 55 | _Sent1 __last1, | |
| 56 | _InIter2 __first2, | |
| 57 | _Sent2 __last2, | |
| 58 | _OutIter __result, | |
| 59 | _Comp __comp = {}, | |
| 60 | _Proj1 __proj1 = {}, | |
| 61 | _Proj2 __proj2 = {}) const { | |
| 62 | auto __ret = std::__set_difference( | |
| 63 | __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 64 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 65 | } | |
| 66 | ||
| 67 | template < | |
| 68 | input_range _Range1, | |
| 69 | input_range _Range2, | |
| 70 | weakly_incrementable _OutIter, | |
| 71 | class _Comp = less, | |
| 72 | class _Proj1 = identity, | |
| 73 | class _Proj2 = identity> | |
| 74 | requires mergeable<iterator_t<_Range1>, iterator_t<_Range2>, _OutIter, _Comp, _Proj1, _Proj2> | |
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr set_difference_result<borrowed_iterator_t<_Range1>, _OutIter> | |
| 76 | operator()( | |
| 77 | _Range1&& __range1, | |
| 78 | _Range2&& __range2, | |
| 79 | _OutIter __result, | |
| 80 | _Comp __comp = {}, | |
| 81 | _Proj1 __proj1 = {}, | |
| 82 | _Proj2 __proj2 = {}) const { | |
| 83 | auto __ret = std::__set_difference( | |
| 84 | ranges::begin(__range1), | |
| 85 | ranges::end(__range1), | |
| 86 | ranges::begin(__range2), | |
| 87 | ranges::end(__range2), | |
| 88 | __result, | |
| 89 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 90 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 91 | } | |
| 92 | }; | |
| 93 | ||
| 94 | } // namespace __set_difference | |
| 95 | ||
| 96 | inline namespace __cpo { | |
| 97 | inline constexpr auto set_difference = __set_difference::__fn{}; | |
| 98 | } // namespace __cpo | |
| 99 | } // namespace ranges | |
| 100 | ||
| 101 | _LIBCPP_END_NAMESPACE_STD | |
| 102 | ||
| 103 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 104 | #endif // _LIBCPP___ALGORITHM_RANGES_SET_DIFFERENCE_H |
lib/libcxx/include/__algorithm/ranges_set_intersection.h created+117| ... | ... | @@ -0,0 +1,117 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_out_result.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__algorithm/make_projected.h> | |
| 15 | #include <__algorithm/set_intersection.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/mergeable.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | #include <__utility/move.h> | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | #endif | |
| 30 | ||
| 31 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | ||
| 35 | namespace ranges { | |
| 36 | ||
| 37 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 38 | using set_intersection_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; | |
| 39 | ||
| 40 | namespace __set_intersection { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template < | |
| 44 | input_iterator _InIter1, | |
| 45 | sentinel_for<_InIter1> _Sent1, | |
| 46 | input_iterator _InIter2, | |
| 47 | sentinel_for<_InIter2> _Sent2, | |
| 48 | weakly_incrementable _OutIter, | |
| 49 | class _Comp = less, | |
| 50 | class _Proj1 = identity, | |
| 51 | class _Proj2 = identity> | |
| 52 | requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> | |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<_InIter1, _InIter2, _OutIter> operator()( | |
| 54 | _InIter1 __first1, | |
| 55 | _Sent1 __last1, | |
| 56 | _InIter2 __first2, | |
| 57 | _Sent2 __last2, | |
| 58 | _OutIter __result, | |
| 59 | _Comp __comp = {}, | |
| 60 | _Proj1 __proj1 = {}, | |
| 61 | _Proj2 __proj2 = {}) const { | |
| 62 | auto __ret = std::__set_intersection<_RangeAlgPolicy>( | |
| 63 | std::move(__first1), | |
| 64 | std::move(__last1), | |
| 65 | std::move(__first2), | |
| 66 | std::move(__last2), | |
| 67 | std::move(__result), | |
| 68 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 69 | return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; | |
| 70 | } | |
| 71 | ||
| 72 | template < | |
| 73 | input_range _Range1, | |
| 74 | input_range _Range2, | |
| 75 | weakly_incrementable _OutIter, | |
| 76 | class _Comp = less, | |
| 77 | class _Proj1 = identity, | |
| 78 | class _Proj2 = identity> | |
| 79 | requires mergeable< | |
| 80 | iterator_t<_Range1>, | |
| 81 | iterator_t<_Range2>, | |
| 82 | _OutIter, | |
| 83 | _Comp, | |
| 84 | _Proj1, | |
| 85 | _Proj2> | |
| 86 | _LIBCPP_HIDE_FROM_ABI constexpr set_intersection_result<borrowed_iterator_t<_Range1>, | |
| 87 | borrowed_iterator_t<_Range2>, | |
| 88 | _OutIter> | |
| 89 | operator()( | |
| 90 | _Range1&& __range1, | |
| 91 | _Range2&& __range2, | |
| 92 | _OutIter __result, | |
| 93 | _Comp __comp = {}, | |
| 94 | _Proj1 __proj1 = {}, | |
| 95 | _Proj2 __proj2 = {}) const { | |
| 96 | auto __ret = std::__set_intersection<_RangeAlgPolicy>( | |
| 97 | ranges::begin(__range1), | |
| 98 | ranges::end(__range1), | |
| 99 | ranges::begin(__range2), | |
| 100 | ranges::end(__range2), | |
| 101 | std::move(__result), | |
| 102 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 103 | return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; | |
| 104 | } | |
| 105 | }; | |
| 106 | ||
| 107 | } // namespace __set_intersection | |
| 108 | ||
| 109 | inline namespace __cpo { | |
| 110 | inline constexpr auto set_intersection = __set_intersection::__fn{}; | |
| 111 | } // namespace __cpo | |
| 112 | } // namespace ranges | |
| 113 | ||
| 114 | _LIBCPP_END_NAMESPACE_STD | |
| 115 | ||
| 116 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 117 | #endif // _LIBCPP___ALGORITHM_RANGES_SET_INTERSECTION_H |
lib/libcxx/include/__algorithm/ranges_set_symmetric_difference.h created+116| ... | ... | @@ -0,0 +1,116 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/set_symmetric_difference.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/mergeable.h> | |
| 21 | #include <__ranges/access.h> | |
| 22 | #include <__ranges/concepts.h> | |
| 23 | #include <__ranges/dangling.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace ranges { | |
| 35 | ||
| 36 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 37 | using set_symmetric_difference_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; | |
| 38 | ||
| 39 | namespace __set_symmetric_difference { | |
| 40 | ||
| 41 | struct __fn { | |
| 42 | template < | |
| 43 | input_iterator _InIter1, | |
| 44 | sentinel_for<_InIter1> _Sent1, | |
| 45 | input_iterator _InIter2, | |
| 46 | sentinel_for<_InIter2> _Sent2, | |
| 47 | weakly_incrementable _OutIter, | |
| 48 | class _Comp = ranges::less, | |
| 49 | class _Proj1 = identity, | |
| 50 | class _Proj2 = identity> | |
| 51 | requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<_InIter1, _InIter2, _OutIter> operator()( | |
| 53 | _InIter1 __first1, | |
| 54 | _Sent1 __last1, | |
| 55 | _InIter2 __first2, | |
| 56 | _Sent2 __last2, | |
| 57 | _OutIter __result, | |
| 58 | _Comp __comp = {}, | |
| 59 | _Proj1 __proj1 = {}, | |
| 60 | _Proj2 __proj2 = {}) const { | |
| 61 | auto __ret = std::__set_symmetric_difference( | |
| 62 | std::move(__first1), | |
| 63 | std::move(__last1), | |
| 64 | std::move(__first2), | |
| 65 | std::move(__last2), | |
| 66 | std::move(__result), | |
| 67 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 68 | return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; | |
| 69 | } | |
| 70 | ||
| 71 | template < | |
| 72 | input_range _Range1, | |
| 73 | input_range _Range2, | |
| 74 | weakly_incrementable _OutIter, | |
| 75 | class _Comp = ranges::less, | |
| 76 | class _Proj1 = identity, | |
| 77 | class _Proj2 = identity> | |
| 78 | requires mergeable< | |
| 79 | iterator_t<_Range1>, | |
| 80 | iterator_t<_Range2>, | |
| 81 | _OutIter, | |
| 82 | _Comp, | |
| 83 | _Proj1, | |
| 84 | _Proj2> | |
| 85 | _LIBCPP_HIDE_FROM_ABI constexpr set_symmetric_difference_result<borrowed_iterator_t<_Range1>, | |
| 86 | borrowed_iterator_t<_Range2>, | |
| 87 | _OutIter> | |
| 88 | operator()( | |
| 89 | _Range1&& __range1, | |
| 90 | _Range2&& __range2, | |
| 91 | _OutIter __result, | |
| 92 | _Comp __comp = {}, | |
| 93 | _Proj1 __proj1 = {}, | |
| 94 | _Proj2 __proj2 = {}) const { | |
| 95 | auto __ret = std::__set_symmetric_difference( | |
| 96 | ranges::begin(__range1), | |
| 97 | ranges::end(__range1), | |
| 98 | ranges::begin(__range2), | |
| 99 | ranges::end(__range2), | |
| 100 | std::move(__result), | |
| 101 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 102 | return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; | |
| 103 | } | |
| 104 | }; | |
| 105 | ||
| 106 | } // namespace __set_symmetric_difference | |
| 107 | ||
| 108 | inline namespace __cpo { | |
| 109 | inline constexpr auto set_symmetric_difference = __set_symmetric_difference::__fn{}; | |
| 110 | } // namespace __cpo | |
| 111 | } // namespace ranges | |
| 112 | ||
| 113 | _LIBCPP_END_NAMESPACE_STD | |
| 114 | ||
| 115 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 116 | #endif // _LIBCPP___ALGORITHM_RANGES_SET_SYMMETRIC_DIFFERENCE_H |
lib/libcxx/include/__algorithm/ranges_set_union.h created+120| ... | ... | @@ -0,0 +1,120 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SET_UNION_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SET_UNION_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_out_result.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/set_union.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/mergeable.h> | |
| 22 | #include <__iterator/projected.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/concepts.h> | |
| 25 | #include <__ranges/dangling.h> | |
| 26 | #include <__utility/forward.h> | |
| 27 | #include <__utility/move.h> | |
| 28 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | ||
| 35 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 36 | ||
| 37 | namespace ranges { | |
| 38 | ||
| 39 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 40 | using set_union_result = in_in_out_result<_InIter1, _InIter2, _OutIter>; | |
| 41 | ||
| 42 | namespace __set_union { | |
| 43 | ||
| 44 | struct __fn { | |
| 45 | template < | |
| 46 | input_iterator _InIter1, | |
| 47 | sentinel_for<_InIter1> _Sent1, | |
| 48 | input_iterator _InIter2, | |
| 49 | sentinel_for<_InIter2> _Sent2, | |
| 50 | weakly_incrementable _OutIter, | |
| 51 | class _Comp = ranges::less, | |
| 52 | class _Proj1 = identity, | |
| 53 | class _Proj2 = identity> | |
| 54 | requires mergeable<_InIter1, _InIter2, _OutIter, _Comp, _Proj1, _Proj2> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<_InIter1, _InIter2, _OutIter> operator()( | |
| 56 | _InIter1 __first1, | |
| 57 | _Sent1 __last1, | |
| 58 | _InIter2 __first2, | |
| 59 | _Sent2 __last2, | |
| 60 | _OutIter __result, | |
| 61 | _Comp __comp = {}, | |
| 62 | _Proj1 __proj1 = {}, | |
| 63 | _Proj2 __proj2 = {}) const { | |
| 64 | auto __ret = std::__set_union( | |
| 65 | std::move(__first1), | |
| 66 | std::move(__last1), | |
| 67 | std::move(__first2), | |
| 68 | std::move(__last2), | |
| 69 | std::move(__result), | |
| 70 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 71 | return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; | |
| 72 | } | |
| 73 | ||
| 74 | template < | |
| 75 | input_range _Range1, | |
| 76 | input_range _Range2, | |
| 77 | weakly_incrementable _OutIter, | |
| 78 | class _Comp = ranges::less, | |
| 79 | class _Proj1 = identity, | |
| 80 | class _Proj2 = identity> | |
| 81 | requires mergeable< | |
| 82 | iterator_t<_Range1>, | |
| 83 | iterator_t<_Range2>, | |
| 84 | _OutIter, | |
| 85 | _Comp, | |
| 86 | _Proj1, | |
| 87 | _Proj2> | |
| 88 | _LIBCPP_HIDE_FROM_ABI constexpr set_union_result<borrowed_iterator_t<_Range1>, | |
| 89 | borrowed_iterator_t<_Range2>, | |
| 90 | _OutIter> | |
| 91 | operator()( | |
| 92 | _Range1&& __range1, | |
| 93 | _Range2&& __range2, | |
| 94 | _OutIter __result, | |
| 95 | _Comp __comp = {}, | |
| 96 | _Proj1 __proj1 = {}, | |
| 97 | _Proj2 __proj2 = {}) const { | |
| 98 | auto __ret = std::__set_union( | |
| 99 | ranges::begin(__range1), | |
| 100 | ranges::end(__range1), | |
| 101 | ranges::begin(__range2), | |
| 102 | ranges::end(__range2), | |
| 103 | std::move(__result), | |
| 104 | ranges::__make_projected_comp(__comp, __proj1, __proj2)); | |
| 105 | return {std::move(__ret.__in1_), std::move(__ret.__in2_), std::move(__ret.__out_)}; | |
| 106 | } | |
| 107 | }; | |
| 108 | ||
| 109 | } // namespace __set_union | |
| 110 | ||
| 111 | inline namespace __cpo { | |
| 112 | inline constexpr auto set_union = __set_union::__fn{}; | |
| 113 | } // namespace __cpo | |
| 114 | } // namespace ranges | |
| 115 | ||
| 116 | _LIBCPP_END_NAMESPACE_STD | |
| 117 | ||
| 118 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 119 | ||
| 120 | #endif // _LIBCPP___ALGORITHM_RANGES_SET_UNION_H |
lib/libcxx/include/__algorithm/ranges_shuffle.h created+103| ... | ... | @@ -0,0 +1,103 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/shuffle.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/ranges_operations.h> | |
| 17 | #include <__iterator/concepts.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/next.h> | |
| 20 | #include <__iterator/permutable.h> | |
| 21 | #include <__random/uniform_random_bit_generator.h> | |
| 22 | #include <__ranges/access.h> | |
| 23 | #include <__ranges/concepts.h> | |
| 24 | #include <__ranges/dangling.h> | |
| 25 | #include <__utility/forward.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | #include <type_traits> | |
| 28 | ||
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | ||
| 35 | _LIBCPP_PUSH_MACROS | |
| 36 | #include <__undef_macros> | |
| 37 | ||
| 38 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 39 | ||
| 40 | namespace ranges { | |
| 41 | namespace __shuffle { | |
| 42 | ||
| 43 | struct __fn { | |
| 44 | // `std::shuffle` is more constrained than `std::ranges::shuffle`. `std::ranges::shuffle` only requires the given | |
| 45 | // generator to satisfy the `std::uniform_random_bit_generator` concept. `std::shuffle` requires the given | |
| 46 | // generator to meet the uniform random bit generator requirements; these requirements include satisfying | |
| 47 | // `std::uniform_random_bit_generator` and add a requirement for the generator to provide a nested `result_type` | |
| 48 | // typedef (see `[rand.req.urng]`). | |
| 49 | // | |
| 50 | // To reuse the implementation from `std::shuffle`, make the given generator meet the classic requirements by wrapping | |
| 51 | // it into an adaptor type that forwards all of its interface and adds the required typedef. | |
| 52 | template <class _Gen> | |
| 53 | class _ClassicGenAdaptor { | |
| 54 | private: | |
| 55 | // The generator is not required to be copyable or movable, so it has to be stored as a reference. | |
| 56 | _Gen& __gen; | |
| 57 | ||
| 58 | public: | |
| 59 | using result_type = invoke_result_t<_Gen&>; | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | static constexpr auto min() { return __uncvref_t<_Gen>::min(); } | |
| 63 | _LIBCPP_HIDE_FROM_ABI | |
| 64 | static constexpr auto max() { return __uncvref_t<_Gen>::max(); } | |
| 65 | ||
| 66 | _LIBCPP_HIDE_FROM_ABI | |
| 67 | constexpr explicit _ClassicGenAdaptor(_Gen& __g) : __gen(__g) {} | |
| 68 | ||
| 69 | _LIBCPP_HIDE_FROM_ABI | |
| 70 | constexpr auto operator()() const { return __gen(); } | |
| 71 | }; | |
| 72 | ||
| 73 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Gen> | |
| 74 | requires permutable<_Iter> && uniform_random_bit_generator<remove_reference_t<_Gen>> | |
| 75 | _LIBCPP_HIDE_FROM_ABI | |
| 76 | _Iter operator()(_Iter __first, _Sent __last, _Gen&& __gen) const { | |
| 77 | _ClassicGenAdaptor<_Gen> __adapted_gen(__gen); | |
| 78 | return std::__shuffle<_RangeAlgPolicy>(std::move(__first), std::move(__last), __adapted_gen); | |
| 79 | } | |
| 80 | ||
| 81 | template<random_access_range _Range, class _Gen> | |
| 82 | requires permutable<iterator_t<_Range>> && uniform_random_bit_generator<remove_reference_t<_Gen>> | |
| 83 | _LIBCPP_HIDE_FROM_ABI | |
| 84 | borrowed_iterator_t<_Range> operator()(_Range&& __range, _Gen&& __gen) const { | |
| 85 | return (*this)(ranges::begin(__range), ranges::end(__range), std::forward<_Gen>(__gen)); | |
| 86 | } | |
| 87 | ||
| 88 | }; | |
| 89 | ||
| 90 | } // namespace __shuffle | |
| 91 | ||
| 92 | inline namespace __cpo { | |
| 93 | inline constexpr auto shuffle = __shuffle::__fn{}; | |
| 94 | } // namespace __cpo | |
| 95 | } // namespace ranges | |
| 96 | ||
| 97 | _LIBCPP_END_NAMESPACE_STD | |
| 98 | ||
| 99 | _LIBCPP_POP_MACROS | |
| 100 | ||
| 101 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 102 | ||
| 103 | #endif // _LIBCPP___ALGORITHM_RANGES_SHUFFLE_H |
lib/libcxx/include/__algorithm/ranges_sort.h created+79| ... | ... | @@ -0,0 +1,79 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SORT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SORT_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/sort.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/next.h> | |
| 22 | #include <__iterator/projected.h> | |
| 23 | #include <__iterator/sortable.h> | |
| 24 | #include <__ranges/access.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/dangling.h> | |
| 27 | #include <__utility/forward.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | namespace __sort { | |
| 40 | ||
| 41 | struct __fn { | |
| 42 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 44 | _Iter __sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 45 | auto __last_iter = ranges::next(__first, __last); | |
| 46 | ||
| 47 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 48 | std::__sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp); | |
| 49 | ||
| 50 | return __last_iter; | |
| 51 | } | |
| 52 | ||
| 53 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 54 | requires sortable<_Iter, _Comp, _Proj> | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 56 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 57 | return __sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 58 | } | |
| 59 | ||
| 60 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 61 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 62 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 63 | borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 64 | return __sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 65 | } | |
| 66 | }; | |
| 67 | ||
| 68 | } // namespace __sort | |
| 69 | ||
| 70 | inline namespace __cpo { | |
| 71 | inline constexpr auto sort = __sort::__fn{}; | |
| 72 | } // namespace __cpo | |
| 73 | } // namespace ranges | |
| 74 | ||
| 75 | _LIBCPP_END_NAMESPACE_STD | |
| 76 | ||
| 77 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | ||
| 79 | #endif // _LIBCPP___ALGORITHM_RANGES_SORT_H |
lib/libcxx/include/__algorithm/ranges_sort_heap.h created+80| ... | ... | @@ -0,0 +1,80 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/sort_heap.h> | |
| 15 | #include <__concepts/same_as.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__iterator/sortable.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | namespace __sort_heap { | |
| 41 | ||
| 42 | struct __fn { | |
| 43 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 44 | _LIBCPP_HIDE_FROM_ABI constexpr static | |
| 45 | _Iter __sort_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 46 | auto __last_iter = ranges::next(__first, __last); | |
| 47 | ||
| 48 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 49 | std::__sort_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp); | |
| 50 | ||
| 51 | return __last_iter; | |
| 52 | } | |
| 53 | ||
| 54 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 55 | requires sortable<_Iter, _Comp, _Proj> | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 57 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 58 | return __sort_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 59 | } | |
| 60 | ||
| 61 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 62 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 63 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 64 | borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 65 | return __sort_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 66 | } | |
| 67 | }; | |
| 68 | ||
| 69 | } // namespace __sort_heap | |
| 70 | ||
| 71 | inline namespace __cpo { | |
| 72 | inline constexpr auto sort_heap = __sort_heap::__fn{}; | |
| 73 | } // namespace __cpo | |
| 74 | } // namespace ranges | |
| 75 | ||
| 76 | _LIBCPP_END_NAMESPACE_STD | |
| 77 | ||
| 78 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | ||
| 80 | #endif // _LIBCPP___ALGORITHM_RANGES_SORT_HEAP_H |
lib/libcxx/include/__algorithm/ranges_stable_partition.h created+88| ... | ... | @@ -0,0 +1,88 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/ranges_iterator_concept.h> | |
| 15 | #include <__algorithm/stable_partition.h> | |
| 16 | #include <__config> | |
| 17 | #include <__functional/identity.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/ranges_operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__iterator/next.h> | |
| 23 | #include <__iterator/permutable.h> | |
| 24 | #include <__iterator/projected.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__ranges/subrange.h> | |
| 29 | #include <__utility/forward.h> | |
| 30 | #include <__utility/move.h> | |
| 31 | #include <type_traits> | |
| 32 | ||
| 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 34 | # pragma GCC system_header | |
| 35 | #endif | |
| 36 | ||
| 37 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | ||
| 39 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 40 | ||
| 41 | namespace ranges { | |
| 42 | namespace __stable_partition { | |
| 43 | ||
| 44 | struct __fn { | |
| 45 | ||
| 46 | template <class _Iter, class _Sent, class _Proj, class _Pred> | |
| 47 | _LIBCPP_HIDE_FROM_ABI static | |
| 48 | subrange<__uncvref_t<_Iter>> __stable_partition_fn_impl( | |
| 49 | _Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) { | |
| 50 | auto __last_iter = ranges::next(__first, __last); | |
| 51 | ||
| 52 | auto&& __projected_pred = std::__make_projected(__pred, __proj); | |
| 53 | auto __result = std::__stable_partition<_RangeAlgPolicy>( | |
| 54 | std::move(__first), __last_iter, __projected_pred, __iterator_concept<_Iter>()); | |
| 55 | ||
| 56 | return {std::move(__result), std::move(__last_iter)}; | |
| 57 | } | |
| 58 | ||
| 59 | template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Proj = identity, | |
| 60 | indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> | |
| 61 | requires permutable<_Iter> | |
| 62 | _LIBCPP_HIDE_FROM_ABI | |
| 63 | subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { | |
| 64 | return __stable_partition_fn_impl(__first, __last, __pred, __proj); | |
| 65 | } | |
| 66 | ||
| 67 | template <bidirectional_range _Range, class _Proj = identity, | |
| 68 | indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> | |
| 69 | requires permutable<iterator_t<_Range>> | |
| 70 | _LIBCPP_HIDE_FROM_ABI | |
| 71 | borrowed_subrange_t<_Range> operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { | |
| 72 | return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); | |
| 73 | } | |
| 74 | ||
| 75 | }; | |
| 76 | ||
| 77 | } // namespace __stable_partition | |
| 78 | ||
| 79 | inline namespace __cpo { | |
| 80 | inline constexpr auto stable_partition = __stable_partition::__fn{}; | |
| 81 | } // namespace __cpo | |
| 82 | } // namespace ranges | |
| 83 | ||
| 84 | _LIBCPP_END_NAMESPACE_STD | |
| 85 | ||
| 86 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 87 | ||
| 88 | #endif // _LIBCPP___ALGORITHM_RANGES_STABLE_PARTITION_H |
lib/libcxx/include/__algorithm/ranges_stable_sort.h created+79| ... | ... | @@ -0,0 +1,79 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/stable_sort.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/next.h> | |
| 22 | #include <__iterator/projected.h> | |
| 23 | #include <__iterator/sortable.h> | |
| 24 | #include <__ranges/access.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/dangling.h> | |
| 27 | #include <__utility/forward.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | namespace __stable_sort { | |
| 40 | ||
| 41 | struct __fn { | |
| 42 | template <class _Iter, class _Sent, class _Comp, class _Proj> | |
| 43 | _LIBCPP_HIDE_FROM_ABI | |
| 44 | static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) { | |
| 45 | auto __last_iter = ranges::next(__first, __last); | |
| 46 | ||
| 47 | auto&& __projected_comp = std::__make_projected(__comp, __proj); | |
| 48 | std::__stable_sort_impl<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp); | |
| 49 | ||
| 50 | return __last_iter; | |
| 51 | } | |
| 52 | ||
| 53 | template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity> | |
| 54 | requires sortable<_Iter, _Comp, _Proj> | |
| 55 | _LIBCPP_HIDE_FROM_ABI | |
| 56 | _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 57 | return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj); | |
| 58 | } | |
| 59 | ||
| 60 | template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity> | |
| 61 | requires sortable<iterator_t<_Range>, _Comp, _Proj> | |
| 62 | _LIBCPP_HIDE_FROM_ABI | |
| 63 | borrowed_iterator_t<_Range> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 64 | return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj); | |
| 65 | } | |
| 66 | }; | |
| 67 | ||
| 68 | } // namespace __stable_sort | |
| 69 | ||
| 70 | inline namespace __cpo { | |
| 71 | inline constexpr auto stable_sort = __stable_sort::__fn{}; | |
| 72 | } // namespace __cpo | |
| 73 | } // namespace ranges | |
| 74 | ||
| 75 | _LIBCPP_END_NAMESPACE_STD | |
| 76 | ||
| 77 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | ||
| 79 | #endif // _LIBCPP___ALGORITHM_RANGES_STABLE_SORT_H |
lib/libcxx/include/__algorithm/ranges_swap_ranges.h created+69| ... | ... | @@ -0,0 +1,69 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_result.h> | |
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/iter_swap.h> | |
| 16 | #include <__ranges/access.h> | |
| 17 | #include <__ranges/concepts.h> | |
| 18 | #include <__ranges/dangling.h> | |
| 19 | #include <__utility/move.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | namespace ranges { | |
| 30 | ||
| 31 | template <class _I1, class _I2> | |
| 32 | using swap_ranges_result = in_in_result<_I1, _I2>; | |
| 33 | ||
| 34 | namespace __swap_ranges { | |
| 35 | struct __fn { | |
| 36 | template <input_iterator _I1, sentinel_for<_I1> _S1, | |
| 37 | input_iterator _I2, sentinel_for<_I2> _S2> | |
| 38 | requires indirectly_swappable<_I1, _I2> | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2> | |
| 40 | operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const { | |
| 41 | while (__first1 != __last1 && __first2 != __last2) { | |
| 42 | ranges::iter_swap(__first1, __first2); | |
| 43 | ++__first1; | |
| 44 | ++__first2; | |
| 45 | } | |
| 46 | return {_VSTD::move(__first1), _VSTD::move(__first2)}; | |
| 47 | } | |
| 48 | ||
| 49 | template <input_range _R1, input_range _R2> | |
| 50 | requires indirectly_swappable<iterator_t<_R1>, iterator_t<_R2>> | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 52 | swap_ranges_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>> | |
| 53 | operator()(_R1&& __r1, _R2&& __r2) const { | |
| 54 | return operator()(ranges::begin(__r1), ranges::end(__r1), | |
| 55 | ranges::begin(__r2), ranges::end(__r2)); | |
| 56 | } | |
| 57 | }; | |
| 58 | } // namespace __swap_ranges | |
| 59 | ||
| 60 | inline namespace __cpo { | |
| 61 | inline constexpr auto swap_ranges = __swap_ranges::__fn{}; | |
| 62 | } // namespace __cpo | |
| 63 | } // namespace ranges | |
| 64 | ||
| 65 | _LIBCPP_END_NAMESPACE_STD | |
| 66 | ||
| 67 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 68 | ||
| 69 | #endif // _LIBCPP___ALGORITHM_RANGES_SWAP_RANGES_H |
lib/libcxx/include/__algorithm/ranges_transform.h created+170| ... | ... | @@ -0,0 +1,170 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H | |
| 11 | ||
| 12 | #include <__algorithm/in_in_out_result.h> | |
| 13 | #include <__algorithm/in_out_result.h> | |
| 14 | #include <__concepts/constructible.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__ranges/dangling.h> | |
| 23 | #include <__utility/move.h> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | ||
| 35 | template <class _Ip, class _Op> | |
| 36 | using unary_transform_result = in_out_result<_Ip, _Op>; | |
| 37 | ||
| 38 | template <class _I1, class _I2, class _O1> | |
| 39 | using binary_transform_result = in_in_out_result<_I1, _I2, _O1>; | |
| 40 | ||
| 41 | namespace __transform { | |
| 42 | struct __fn { | |
| 43 | private: | |
| 44 | template <class _InIter, class _Sent, | |
| 45 | class _OutIter, | |
| 46 | class _Func, | |
| 47 | class _Proj> | |
| 48 | _LIBCPP_HIDE_FROM_ABI static constexpr | |
| 49 | unary_transform_result<_InIter, _OutIter> __unary(_InIter __first, _Sent __last, | |
| 50 | _OutIter __result, | |
| 51 | _Func& __operation, | |
| 52 | _Proj& __projection) { | |
| 53 | while (__first != __last) { | |
| 54 | *__result = std::invoke(__operation, std::invoke(__projection, *__first)); | |
| 55 | ++__first; | |
| 56 | ++__result; | |
| 57 | } | |
| 58 | ||
| 59 | return {std::move(__first), std::move(__result)}; | |
| 60 | } | |
| 61 | ||
| 62 | template <class _InIter1, class _Sent1, | |
| 63 | class _InIter2, class _Sent2, | |
| 64 | class _OutIter, | |
| 65 | class _Func, | |
| 66 | class _Proj1, | |
| 67 | class _Proj2> | |
| 68 | _LIBCPP_HIDE_FROM_ABI static constexpr binary_transform_result<_InIter1, _InIter2, _OutIter> | |
| 69 | __binary(_InIter1 __first1, _Sent1 __last1, | |
| 70 | _InIter2 __first2, _Sent2 __last2, | |
| 71 | _OutIter __result, | |
| 72 | _Func& __binary_operation, | |
| 73 | _Proj1& __projection1, | |
| 74 | _Proj2& __projection2) { | |
| 75 | while (__first1 != __last1 && __first2 != __last2) { | |
| 76 | *__result = std::invoke(__binary_operation, std::invoke(__projection1, *__first1), | |
| 77 | std::invoke(__projection2, *__first2)); | |
| 78 | ++__first1; | |
| 79 | ++__first2; | |
| 80 | ++__result; | |
| 81 | } | |
| 82 | return {std::move(__first1), std::move(__first2), std::move(__result)}; | |
| 83 | } | |
| 84 | public: | |
| 85 | template <input_iterator _InIter, sentinel_for<_InIter> _Sent, | |
| 86 | weakly_incrementable _OutIter, | |
| 87 | copy_constructible _Func, | |
| 88 | class _Proj = identity> | |
| 89 | requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter, _Proj>>> | |
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 91 | unary_transform_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, | |
| 92 | _OutIter __result, | |
| 93 | _Func __operation, | |
| 94 | _Proj __proj = {}) const { | |
| 95 | return __unary(std::move(__first), std::move(__last), std::move(__result), __operation, __proj); | |
| 96 | } | |
| 97 | ||
| 98 | template <input_range _Range, | |
| 99 | weakly_incrementable _OutIter, | |
| 100 | copy_constructible _Func, | |
| 101 | class _Proj = identity> | |
| 102 | requires indirectly_writable<_OutIter, indirect_result_t<_Func, projected<iterator_t<_Range>, _Proj>>> | |
| 103 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 104 | unary_transform_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, | |
| 105 | _OutIter __result, | |
| 106 | _Func __operation, | |
| 107 | _Proj __projection = {}) const { | |
| 108 | return __unary(ranges::begin(__range), ranges::end(__range), std::move(__result), __operation, __projection); | |
| 109 | } | |
| 110 | ||
| 111 | template <input_iterator _InIter1, sentinel_for<_InIter1> _Sent1, | |
| 112 | input_iterator _InIter2, sentinel_for<_InIter2> _Sent2, | |
| 113 | weakly_incrementable _OutIter, | |
| 114 | copy_constructible _Func, | |
| 115 | class _Proj1 = identity, | |
| 116 | class _Proj2 = identity> | |
| 117 | requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<_InIter1, _Proj1>, | |
| 118 | projected<_InIter2, _Proj2>>> | |
| 119 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 120 | binary_transform_result<_InIter1, _InIter2, _OutIter> operator()(_InIter1 __first1, _Sent1 __last1, | |
| 121 | _InIter2 __first2, _Sent2 __last2, | |
| 122 | _OutIter __result, | |
| 123 | _Func __binary_operation, | |
| 124 | _Proj1 __projection1 = {}, | |
| 125 | _Proj2 __projection2 = {}) const { | |
| 126 | return __binary(std::move(__first1), std::move(__last1), | |
| 127 | std::move(__first2), std::move(__last2), | |
| 128 | std::move(__result), | |
| 129 | __binary_operation, | |
| 130 | __projection1, | |
| 131 | __projection2); | |
| 132 | } | |
| 133 | ||
| 134 | template <input_range _Range1, | |
| 135 | input_range _Range2, | |
| 136 | weakly_incrementable _OutIter, | |
| 137 | copy_constructible _Func, | |
| 138 | class _Proj1 = identity, | |
| 139 | class _Proj2 = identity> | |
| 140 | requires indirectly_writable<_OutIter, indirect_result_t<_Func&, projected<iterator_t<_Range1>, _Proj1>, | |
| 141 | projected<iterator_t<_Range2>, _Proj2>>> | |
| 142 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 143 | binary_transform_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>, _OutIter> | |
| 144 | operator()(_Range1&& __range1, | |
| 145 | _Range2&& __range2, | |
| 146 | _OutIter __result, | |
| 147 | _Func __binary_operation, | |
| 148 | _Proj1 __projection1 = {}, | |
| 149 | _Proj2 __projection2 = {}) const { | |
| 150 | return __binary(ranges::begin(__range1), ranges::end(__range1), | |
| 151 | ranges::begin(__range2), ranges::end(__range2), | |
| 152 | std::move(__result), | |
| 153 | __binary_operation, | |
| 154 | __projection1, | |
| 155 | __projection2); | |
| 156 | } | |
| 157 | ||
| 158 | }; | |
| 159 | } // namespace __transform | |
| 160 | ||
| 161 | inline namespace __cpo { | |
| 162 | inline constexpr auto transform = __transform::__fn{}; | |
| 163 | } // namespace __cpo | |
| 164 | } // namespace ranges | |
| 165 | ||
| 166 | _LIBCPP_END_NAMESPACE_STD | |
| 167 | ||
| 168 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 169 | ||
| 170 | #endif // _LIBCPP___ALGORITHM_RANGES_TRANSFORM_H |
lib/libcxx/include/__algorithm/ranges_unique.h created+78| ... | ... | @@ -0,0 +1,78 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_UNIQUE_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/make_projected.h> | |
| 14 | #include <__algorithm/unique.h> | |
| 15 | #include <__config> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__functional/ranges_operations.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__iterator/permutable.h> | |
| 22 | #include <__iterator/projected.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/concepts.h> | |
| 25 | #include <__ranges/dangling.h> | |
| 26 | #include <__ranges/subrange.h> | |
| 27 | #include <__utility/forward.h> | |
| 28 | #include <__utility/move.h> | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | ||
| 36 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 37 | ||
| 38 | namespace ranges { | |
| 39 | namespace __unique { | |
| 40 | ||
| 41 | struct __fn { | |
| 42 | template < | |
| 43 | permutable _Iter, | |
| 44 | sentinel_for<_Iter> _Sent, | |
| 45 | class _Proj = identity, | |
| 46 | indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to> | |
| 47 | _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter> | |
| 48 | operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 49 | auto __ret = std::__unique<_RangeAlgPolicy>( | |
| 50 | std::move(__first), std::move(__last), std::__make_projected(__comp, __proj)); | |
| 51 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 52 | } | |
| 53 | ||
| 54 | template < | |
| 55 | forward_range _Range, | |
| 56 | class _Proj = identity, | |
| 57 | indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to> | |
| 58 | requires permutable<iterator_t<_Range>> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> | |
| 60 | operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 61 | auto __ret = std::__unique<_RangeAlgPolicy>( | |
| 62 | ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj)); | |
| 63 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 64 | } | |
| 65 | }; | |
| 66 | ||
| 67 | } // namespace __unique | |
| 68 | ||
| 69 | inline namespace __cpo { | |
| 70 | inline constexpr auto unique = __unique::__fn{}; | |
| 71 | } // namespace __cpo | |
| 72 | } // namespace ranges | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_STD | |
| 75 | ||
| 76 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 77 | ||
| 78 | #endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_H |
lib/libcxx/include/__algorithm/ranges_unique_copy.h created+115| ... | ... | @@ -0,0 +1,115 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H | |
| 11 | ||
| 12 | #include <__algorithm/in_out_result.h> | |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 14 | #include <__algorithm/make_projected.h> | |
| 15 | #include <__algorithm/unique_copy.h> | |
| 16 | #include <__concepts/same_as.h> | |
| 17 | #include <__config> | |
| 18 | #include <__functional/identity.h> | |
| 19 | #include <__functional/invoke.h> | |
| 20 | #include <__functional/ranges_operations.h> | |
| 21 | #include <__iterator/concepts.h> | |
| 22 | #include <__iterator/iterator_traits.h> | |
| 23 | #include <__iterator/projected.h> | |
| 24 | #include <__iterator/readable_traits.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/concepts.h> | |
| 27 | #include <__ranges/dangling.h> | |
| 28 | #include <__utility/forward.h> | |
| 29 | #include <__utility/move.h> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | namespace ranges { | |
| 40 | ||
| 41 | template <class _InIter, class _OutIter> | |
| 42 | using unique_copy_result = in_out_result<_InIter, _OutIter>; | |
| 43 | ||
| 44 | namespace __unique_copy { | |
| 45 | ||
| 46 | template <class _InIter, class _OutIter> | |
| 47 | concept __can_reread_from_output = (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>); | |
| 48 | ||
| 49 | struct __fn { | |
| 50 | template <class _InIter, class _OutIter> | |
| 51 | static consteval auto __get_algo_tag() { | |
| 52 | if constexpr (forward_iterator<_InIter>) { | |
| 53 | return __unique_copy_tags::__reread_from_input_tag{}; | |
| 54 | } else if constexpr (__can_reread_from_output<_InIter, _OutIter>) { | |
| 55 | return __unique_copy_tags::__reread_from_output_tag{}; | |
| 56 | } else if constexpr (indirectly_copyable_storable<_InIter, _OutIter>) { | |
| 57 | return __unique_copy_tags::__read_from_tmp_value_tag{}; | |
| 58 | } | |
| 59 | } | |
| 60 | ||
| 61 | template <class _InIter, class _OutIter> | |
| 62 | using __algo_tag_t = decltype(__get_algo_tag<_InIter, _OutIter>()); | |
| 63 | ||
| 64 | template <input_iterator _InIter, | |
| 65 | sentinel_for<_InIter> _Sent, | |
| 66 | weakly_incrementable _OutIter, | |
| 67 | class _Proj = identity, | |
| 68 | indirect_equivalence_relation<projected<_InIter, _Proj>> _Comp = ranges::equal_to> | |
| 69 | requires indirectly_copyable<_InIter, _OutIter> && | |
| 70 | (forward_iterator<_InIter> || | |
| 71 | (input_iterator<_OutIter> && same_as<iter_value_t<_InIter>, iter_value_t<_OutIter>>) || | |
| 72 | indirectly_copyable_storable<_InIter, _OutIter>) | |
| 73 | _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<_InIter, _OutIter> | |
| 74 | operator()(_InIter __first, _Sent __last, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 75 | auto __ret = std::__unique_copy<_RangeAlgPolicy>( | |
| 76 | std::move(__first), | |
| 77 | std::move(__last), | |
| 78 | std::move(__result), | |
| 79 | std::__make_projected(__comp, __proj), | |
| 80 | __algo_tag_t<_InIter, _OutIter>()); | |
| 81 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 82 | } | |
| 83 | ||
| 84 | template <input_range _Range, | |
| 85 | weakly_incrementable _OutIter, | |
| 86 | class _Proj = identity, | |
| 87 | indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to> | |
| 88 | requires indirectly_copyable<iterator_t<_Range>, _OutIter> && | |
| 89 | (forward_iterator<iterator_t<_Range>> || | |
| 90 | (input_iterator<_OutIter> && same_as<range_value_t<_Range>, iter_value_t<_OutIter>>) || | |
| 91 | indirectly_copyable_storable<iterator_t<_Range>, _OutIter>) | |
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<borrowed_iterator_t<_Range>, _OutIter> | |
| 93 | operator()(_Range&& __range, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 94 | auto __ret = std::__unique_copy<_RangeAlgPolicy>( | |
| 95 | ranges::begin(__range), | |
| 96 | ranges::end(__range), | |
| 97 | std::move(__result), | |
| 98 | std::__make_projected(__comp, __proj), | |
| 99 | __algo_tag_t<iterator_t<_Range>, _OutIter>()); | |
| 100 | return {std::move(__ret.first), std::move(__ret.second)}; | |
| 101 | } | |
| 102 | }; | |
| 103 | ||
| 104 | } // namespace __unique_copy | |
| 105 | ||
| 106 | inline namespace __cpo { | |
| 107 | inline constexpr auto unique_copy = __unique_copy::__fn{}; | |
| 108 | } // namespace __cpo | |
| 109 | } // namespace ranges | |
| 110 | ||
| 111 | _LIBCPP_END_NAMESPACE_STD | |
| 112 | ||
| 113 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 114 | ||
| 115 | #endif // _LIBCPP___ALGORITHM_RANGES_UNIQUE_COPY_H |
lib/libcxx/include/__algorithm/ranges_upper_bound.h created+75| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H | |
| 10 | #define _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H | |
| 11 | ||
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__algorithm/lower_bound.h> | |
| 14 | #include <__config> | |
| 15 | #include <__functional/identity.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/ranges_operations.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/projected.h> | |
| 20 | #include <__ranges/access.h> | |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__ranges/dangling.h> | |
| 23 | ||
| 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 25 | # pragma GCC system_header | |
| 26 | #endif | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | namespace __upper_bound { | |
| 34 | struct __fn { | |
| 35 | template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity, | |
| 36 | indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less> | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 38 | _Iter operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const { | |
| 39 | auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) { | |
| 40 | return !std::invoke(__comp, __rhs, __lhs); | |
| 41 | }; | |
| 42 | ||
| 43 | return std::__lower_bound_impl<_RangeAlgPolicy>(__first, __last, __value, __comp_lhs_rhs_swapped, __proj); | |
| 44 | } | |
| 45 | ||
| 46 | template <forward_range _Range, class _Type, class _Proj = identity, | |
| 47 | indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less> | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 49 | borrowed_iterator_t<_Range> operator()(_Range&& __r, | |
| 50 | const _Type& __value, | |
| 51 | _Comp __comp = {}, | |
| 52 | _Proj __proj = {}) const { | |
| 53 | auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) { | |
| 54 | return !std::invoke(__comp, __rhs, __lhs); | |
| 55 | }; | |
| 56 | ||
| 57 | return std::__lower_bound_impl<_RangeAlgPolicy>(ranges::begin(__r), | |
| 58 | ranges::end(__r), | |
| 59 | __value, | |
| 60 | __comp_lhs_rhs_swapped, | |
| 61 | __proj); | |
| 62 | } | |
| 63 | }; | |
| 64 | } // namespace __upper_bound | |
| 65 | ||
| 66 | inline namespace __cpo { | |
| 67 | inline constexpr auto upper_bound = __upper_bound::__fn{}; | |
| 68 | } // namespace __cpo | |
| 69 | } // namespace ranges | |
| 70 | ||
| 71 | _LIBCPP_END_NAMESPACE_STD | |
| 72 | ||
| 73 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 74 | ||
| 75 | #endif // _LIBCPP___ALGORITHM_RANGES_UPPER_BOUND_H |
lib/libcxx/include/__algorithm/remove.h+4-4| ... | ... | @@ -15,22 +15,22 @@ |
| 15 | 15 | #include <__utility/move.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | template <class _ForwardIterator, class _Tp> |
| 24 | 24 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator |
| 25 | remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) | |
| 25 | remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | |
| 26 | 26 | { |
| 27 | __first = _VSTD::find(__first, __last, __value_); | |
| 27 | __first = _VSTD::find(__first, __last, __value); | |
| 28 | 28 | if (__first != __last) |
| 29 | 29 | { |
| 30 | 30 | _ForwardIterator __i = __first; |
| 31 | 31 | while (++__i != __last) |
| 32 | 32 | { |
| 33 | if (!(*__i == __value_)) | |
| 33 | if (!(*__i == __value)) | |
| 34 | 34 | { |
| 35 | 35 | *__first = _VSTD::move(*__i); |
| 36 | 36 | ++__first; |
lib/libcxx/include/__algorithm/remove_copy.h+3-3| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -20,11 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | template <class _InputIterator, class _OutputIterator, class _Tp> |
| 21 | 21 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 22 | 22 | _OutputIterator |
| 23 | remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_) | |
| 23 | remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value) | |
| 24 | 24 | { |
| 25 | 25 | for (; __first != __last; ++__first) |
| 26 | 26 | { |
| 27 | if (!(*__first == __value_)) | |
| 27 | if (!(*__first == __value)) | |
| 28 | 28 | { |
| 29 | 29 | *__result = *__first; |
| 30 | 30 | ++__result; |
lib/libcxx/include/__algorithm/remove_copy_if.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/remove_if.h+2-2| ... | ... | @@ -11,10 +11,10 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/find_if.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <utility> | |
| 14 | #include <__utility/move.h> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/replace.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/replace_copy.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/replace_copy_if.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/replace_if.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/reverse.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__iterator/iterator_traits.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/reverse_copy.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/rotate.h+52-38| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_ROTATE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_ROTATE_H |
| 11 | 11 | |
| 12 | #include <__algorithm/iterator_operations.h> | |
| 12 | 13 | #include <__algorithm/move.h> |
| 13 | 14 | #include <__algorithm/move_backward.h> |
| 14 | 15 | #include <__algorithm/swap_ranges.h> |
| ... | ... | @@ -16,46 +17,50 @@ |
| 16 | 17 | #include <__iterator/iterator_traits.h> |
| 17 | 18 | #include <__iterator/next.h> |
| 18 | 19 | #include <__iterator/prev.h> |
| 20 | #include <__utility/move.h> | |
| 19 | 21 | #include <__utility/swap.h> |
| 20 | #include <iterator> | |
| 22 | #include <type_traits> | |
| 21 | 23 | |
| 22 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 24 | 26 | #endif |
| 25 | 27 | |
| 26 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 29 | |
| 28 | template <class _ForwardIterator> | |
| 30 | template <class _AlgPolicy, class _ForwardIterator> | |
| 29 | 31 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator |
| 30 | 32 | __rotate_left(_ForwardIterator __first, _ForwardIterator __last) |
| 31 | 33 | { |
| 32 | 34 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; |
| 33 | value_type __tmp = _VSTD::move(*__first); | |
| 35 | value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__first); | |
| 36 | // TODO(ranges): pass `_AlgPolicy` to `move`. | |
| 34 | 37 | _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first); |
| 35 | 38 | *__lm1 = _VSTD::move(__tmp); |
| 36 | 39 | return __lm1; |
| 37 | 40 | } |
| 38 | 41 | |
| 39 | template <class _BidirectionalIterator> | |
| 42 | template <class _AlgPolicy, class _BidirectionalIterator> | |
| 40 | 43 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator |
| 41 | 44 | __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) |
| 42 | 45 | { |
| 43 | 46 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| 47 | // TODO(ranges): pass `_AlgPolicy` to `prev`. | |
| 44 | 48 | _BidirectionalIterator __lm1 = _VSTD::prev(__last); |
| 45 | value_type __tmp = _VSTD::move(*__lm1); | |
| 49 | value_type __tmp = _IterOps<_AlgPolicy>::__iter_move(__lm1); | |
| 50 | // TODO(ranges): pass `_AlgPolicy` to `move_backward`. | |
| 46 | 51 | _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last); |
| 47 | 52 | *__first = _VSTD::move(__tmp); |
| 48 | 53 | return __fp1; |
| 49 | 54 | } |
| 50 | 55 | |
| 51 | template <class _ForwardIterator> | |
| 56 | template <class _AlgPolicy, class _ForwardIterator> | |
| 52 | 57 | _LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator |
| 53 | 58 | __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) |
| 54 | 59 | { |
| 55 | 60 | _ForwardIterator __i = __middle; |
| 56 | 61 | while (true) |
| 57 | 62 | { |
| 58 | swap(*__first, *__i); | |
| 63 | _IterOps<_AlgPolicy>::iter_swap(__first, __i); | |
| 59 | 64 | ++__first; |
| 60 | 65 | if (++__i == __last) |
| 61 | 66 | break; |
| ... | ... | @@ -68,7 +73,7 @@ __rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIt |
| 68 | 73 | __i = __middle; |
| 69 | 74 | while (true) |
| 70 | 75 | { |
| 71 | swap(*__first, *__i); | |
| 76 | _IterOps<_AlgPolicy>::iter_swap(__first, __i); | |
| 72 | 77 | ++__first; |
| 73 | 78 | if (++__i == __last) |
| 74 | 79 | { |
| ... | ... | @@ -97,7 +102,7 @@ __algo_gcd(_Integral __x, _Integral __y) |
| 97 | 102 | return __x; |
| 98 | 103 | } |
| 99 | 104 | |
| 100 | template<typename _RandomAccessIterator> | |
| 105 | template <class _AlgPolicy, typename _RandomAccessIterator> | |
| 101 | 106 | _LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator |
| 102 | 107 | __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) |
| 103 | 108 | { |
| ... | ... | @@ -108,18 +113,19 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran |
| 108 | 113 | const difference_type __m2 = __last - __middle; |
| 109 | 114 | if (__m1 == __m2) |
| 110 | 115 | { |
| 116 | // TODO(ranges): pass `_AlgPolicy` to `swap_ranges`. | |
| 111 | 117 | _VSTD::swap_ranges(__first, __middle, __middle); |
| 112 | 118 | return __middle; |
| 113 | 119 | } |
| 114 | 120 | const difference_type __g = _VSTD::__algo_gcd(__m1, __m2); |
| 115 | 121 | for (_RandomAccessIterator __p = __first + __g; __p != __first;) |
| 116 | 122 | { |
| 117 | value_type __t(_VSTD::move(*--__p)); | |
| 123 | value_type __t(_IterOps<_AlgPolicy>::__iter_move(--__p)); | |
| 118 | 124 | _RandomAccessIterator __p1 = __p; |
| 119 | 125 | _RandomAccessIterator __p2 = __p1 + __m1; |
| 120 | 126 | do |
| 121 | 127 | { |
| 122 | *__p1 = _VSTD::move(*__p2); | |
| 128 | *__p1 = _IterOps<_AlgPolicy>::__iter_move(__p2); | |
| 123 | 129 | __p1 = __p2; |
| 124 | 130 | const difference_type __d = __last - __p2; |
| 125 | 131 | if (__m1 < __d) |
| ... | ... | @@ -132,54 +138,66 @@ __rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _Ran |
| 132 | 138 | return __first + __m2; |
| 133 | 139 | } |
| 134 | 140 | |
| 135 | template <class _ForwardIterator> | |
| 141 | template <class _AlgPolicy, class _ForwardIterator> | |
| 136 | 142 | inline _LIBCPP_INLINE_VISIBILITY |
| 137 | 143 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator |
| 138 | __rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, | |
| 144 | __rotate_impl(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, | |
| 139 | 145 | _VSTD::forward_iterator_tag) |
| 140 | 146 | { |
| 141 | 147 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; |
| 142 | 148 | if (is_trivially_move_assignable<value_type>::value) |
| 143 | 149 | { |
| 144 | if (_VSTD::next(__first) == __middle) | |
| 145 | return _VSTD::__rotate_left(__first, __last); | |
| 150 | if (_IterOps<_AlgPolicy>::next(__first) == __middle) | |
| 151 | return std::__rotate_left<_AlgPolicy>(__first, __last); | |
| 146 | 152 | } |
| 147 | return _VSTD::__rotate_forward(__first, __middle, __last); | |
| 153 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); | |
| 148 | 154 | } |
| 149 | 155 | |
| 150 | template <class _BidirectionalIterator> | |
| 156 | template <class _AlgPolicy, class _BidirectionalIterator> | |
| 151 | 157 | inline _LIBCPP_INLINE_VISIBILITY |
| 152 | 158 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator |
| 153 | __rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | |
| 159 | __rotate_impl(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | |
| 154 | 160 | bidirectional_iterator_tag) |
| 155 | 161 | { |
| 156 | 162 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; |
| 157 | 163 | if (is_trivially_move_assignable<value_type>::value) |
| 158 | 164 | { |
| 159 | if (_VSTD::next(__first) == __middle) | |
| 160 | return _VSTD::__rotate_left(__first, __last); | |
| 161 | if (_VSTD::next(__middle) == __last) | |
| 162 | return _VSTD::__rotate_right(__first, __last); | |
| 165 | if (_IterOps<_AlgPolicy>::next(__first) == __middle) | |
| 166 | return std::__rotate_left<_AlgPolicy>(__first, __last); | |
| 167 | if (_IterOps<_AlgPolicy>::next(__middle) == __last) | |
| 168 | return std::__rotate_right<_AlgPolicy>(__first, __last); | |
| 163 | 169 | } |
| 164 | return _VSTD::__rotate_forward(__first, __middle, __last); | |
| 170 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); | |
| 165 | 171 | } |
| 166 | 172 | |
| 167 | template <class _RandomAccessIterator> | |
| 173 | template <class _AlgPolicy, class _RandomAccessIterator> | |
| 168 | 174 | inline _LIBCPP_INLINE_VISIBILITY |
| 169 | 175 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator |
| 170 | __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, | |
| 176 | __rotate_impl(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, | |
| 171 | 177 | random_access_iterator_tag) |
| 172 | 178 | { |
| 173 | 179 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 174 | 180 | if (is_trivially_move_assignable<value_type>::value) |
| 175 | 181 | { |
| 176 | if (_VSTD::next(__first) == __middle) | |
| 177 | return _VSTD::__rotate_left(__first, __last); | |
| 178 | if (_VSTD::next(__middle) == __last) | |
| 179 | return _VSTD::__rotate_right(__first, __last); | |
| 180 | return _VSTD::__rotate_gcd(__first, __middle, __last); | |
| 182 | if (_IterOps<_AlgPolicy>::next(__first) == __middle) | |
| 183 | return std::__rotate_left<_AlgPolicy>(__first, __last); | |
| 184 | if (_IterOps<_AlgPolicy>::next(__middle) == __last) | |
| 185 | return std::__rotate_right<_AlgPolicy>(__first, __last); | |
| 186 | return std::__rotate_gcd<_AlgPolicy>(__first, __middle, __last); | |
| 181 | 187 | } |
| 182 | return _VSTD::__rotate_forward(__first, __middle, __last); | |
| 188 | return std::__rotate_forward<_AlgPolicy>(__first, __middle, __last); | |
| 189 | } | |
| 190 | ||
| 191 | template <class _AlgPolicy, class _RandomAccessIterator, class _IterCategory> | |
| 192 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 193 | _RandomAccessIterator __rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, | |
| 194 | _RandomAccessIterator __last, _IterCategory __iter_category) { | |
| 195 | if (__first == __middle) | |
| 196 | return __last; | |
| 197 | if (__middle == __last) | |
| 198 | return __first; | |
| 199 | ||
| 200 | return std::__rotate_impl<_AlgPolicy>(std::move(__first), std::move(__middle), std::move(__last), __iter_category); | |
| 183 | 201 | } |
| 184 | 202 | |
| 185 | 203 | template <class _ForwardIterator> |
| ... | ... | @@ -187,12 +205,8 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 187 | 205 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator |
| 188 | 206 | rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) |
| 189 | 207 | { |
| 190 | if (__first == __middle) | |
| 191 | return __last; | |
| 192 | if (__middle == __last) | |
| 193 | return __first; | |
| 194 | return _VSTD::__rotate(__first, __middle, __last, | |
| 195 | typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 208 | return std::__rotate<_ClassicAlgPolicy>(__first, __middle, __last, | |
| 209 | typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 196 | 210 | } |
| 197 | 211 | |
| 198 | 212 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/rotate_copy.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/sample.h+5-3| ... | ... | @@ -10,13 +10,15 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SAMPLE_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/min.h> |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | #include <__iterator/distance.h> | |
| 16 | #include <__iterator/iterator_traits.h> | |
| 15 | 17 | #include <__random/uniform_int_distribution.h> |
| 16 | #include <iterator> | |
| 18 | #include <type_traits> | |
| 17 | 19 | |
| 18 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 20 | 22 | #endif |
| 21 | 23 | |
| 22 | 24 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__algorithm/search.h+129-51| ... | ... | @@ -11,41 +11,59 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_SEARCH_H |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__iterator/advance.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 15 | 19 | #include <__iterator/iterator_traits.h> |
| 16 | #include <utility> | |
| 20 | #include <__type_traits/is_callable.h> | |
| 21 | #include <__utility/pair.h> | |
| 22 | #include <type_traits> | |
| 17 | 23 | |
| 18 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 20 | 26 | #endif |
| 21 | 27 | |
| 22 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 29 | |
| 24 | template <class _BinaryPredicate, class _ForwardIterator1, class _ForwardIterator2> | |
| 25 | pair<_ForwardIterator1, _ForwardIterator1> | |
| 26 | _LIBCPP_CONSTEXPR_AFTER_CXX11 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 27 | _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 28 | _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) { | |
| 30 | template <class _AlgPolicy, | |
| 31 | class _Iter1, class _Sent1, | |
| 32 | class _Iter2, class _Sent2, | |
| 33 | class _Pred, | |
| 34 | class _Proj1, | |
| 35 | class _Proj2> | |
| 36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 37 | pair<_Iter1, _Iter1> __search_forward_impl(_Iter1 __first1, _Sent1 __last1, | |
| 38 | _Iter2 __first2, _Sent2 __last2, | |
| 39 | _Pred& __pred, | |
| 40 | _Proj1& __proj1, | |
| 41 | _Proj2& __proj2) { | |
| 29 | 42 | if (__first2 == __last2) |
| 30 | return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence | |
| 43 | return std::make_pair(__first1, __first1); // Everything matches an empty sequence | |
| 31 | 44 | while (true) { |
| 32 | 45 | // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks |
| 33 | 46 | while (true) { |
| 34 | if (__first1 == __last1) // return __last1 if no element matches *__first2 | |
| 35 | return _VSTD::make_pair(__last1, __last1); | |
| 36 | if (__pred(*__first1, *__first2)) | |
| 47 | if (__first1 == __last1) { // return __last1 if no element matches *__first2 | |
| 48 | _IterOps<_AlgPolicy>::__advance_to(__first1, __last1); | |
| 49 | return std::make_pair(__first1, __first1); | |
| 50 | } | |
| 51 | if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | |
| 37 | 52 | break; |
| 38 | 53 | ++__first1; |
| 39 | 54 | } |
| 40 | 55 | // *__first1 matches *__first2, now match elements after here |
| 41 | _ForwardIterator1 __m1 = __first1; | |
| 42 | _ForwardIterator2 __m2 = __first2; | |
| 56 | _Iter1 __m1 = __first1; | |
| 57 | _Iter2 __m2 = __first2; | |
| 43 | 58 | while (true) { |
| 44 | 59 | if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) |
| 45 | return _VSTD::make_pair(__first1, __m1); | |
| 46 | if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found | |
| 47 | return _VSTD::make_pair(__last1, __last1); | |
| 48 | if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 | |
| 60 | return std::make_pair(__first1, ++__m1); | |
| 61 | if (++__m1 == __last1) { // Otherwise if source exhaused, pattern not found | |
| 62 | return std::make_pair(__m1, __m1); | |
| 63 | } | |
| 64 | ||
| 65 | // if there is a mismatch, restart with a new __first1 | |
| 66 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2))) | |
| 49 | 67 | { |
| 50 | 68 | ++__first1; |
| 51 | 69 | break; |
| ... | ... | @@ -54,38 +72,42 @@ pair<_ForwardIterator1, _ForwardIterator1> |
| 54 | 72 | } |
| 55 | 73 | } |
| 56 | 74 | |
| 57 | template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2> | |
| 58 | _LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_RandomAccessIterator1, _RandomAccessIterator1> | |
| 59 | __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, | |
| 60 | _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, | |
| 61 | random_access_iterator_tag) { | |
| 62 | typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1; | |
| 63 | typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2; | |
| 64 | // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern | |
| 65 | const _D2 __len2 = __last2 - __first2; | |
| 66 | if (__len2 == 0) | |
| 67 | return _VSTD::make_pair(__first1, __first1); | |
| 68 | const _D1 __len1 = __last1 - __first1; | |
| 69 | if (__len1 < __len2) | |
| 70 | return _VSTD::make_pair(__last1, __last1); | |
| 71 | const _RandomAccessIterator1 __s = __last1 - _D1(__len2 - 1); // Start of pattern match can't go beyond here | |
| 75 | template <class _AlgPolicy, | |
| 76 | class _Iter1, class _Sent1, | |
| 77 | class _Iter2, class _Sent2, | |
| 78 | class _Pred, | |
| 79 | class _Proj1, | |
| 80 | class _Proj2, | |
| 81 | class _DiffT1, | |
| 82 | class _DiffT2> | |
| 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 84 | pair<_Iter1, _Iter1> __search_random_access_impl(_Iter1 __first1, _Sent1 __last1, | |
| 85 | _Iter2 __first2, _Sent2 __last2, | |
| 86 | _Pred& __pred, | |
| 87 | _Proj1& __proj1, | |
| 88 | _Proj2& __proj2, | |
| 89 | _DiffT1 __size1, | |
| 90 | _DiffT2 __size2) { | |
| 91 | const _Iter1 __s = __first1 + __size1 - _DiffT1(__size2 - 1); // Start of pattern match can't go beyond here | |
| 72 | 92 | |
| 73 | 93 | while (true) { |
| 74 | 94 | while (true) { |
| 75 | if (__first1 == __s) | |
| 76 | return _VSTD::make_pair(__last1, __last1); | |
| 77 | if (__pred(*__first1, *__first2)) | |
| 95 | if (__first1 == __s) { | |
| 96 | _IterOps<_AlgPolicy>::__advance_to(__first1, __last1); | |
| 97 | return std::make_pair(__first1, __first1); | |
| 98 | } | |
| 99 | if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | |
| 78 | 100 | break; |
| 79 | 101 | ++__first1; |
| 80 | 102 | } |
| 81 | 103 | |
| 82 | _RandomAccessIterator1 __m1 = __first1; | |
| 83 | _RandomAccessIterator2 __m2 = __first2; | |
| 104 | _Iter1 __m1 = __first1; | |
| 105 | _Iter2 __m2 = __first2; | |
| 84 | 106 | while (true) { |
| 85 | 107 | if (++__m2 == __last2) |
| 86 | return _VSTD::make_pair(__first1, __first1 + _D1(__len2)); | |
| 108 | return std::make_pair(__first1, __first1 + _DiffT1(__size2)); | |
| 87 | 109 | ++__m1; // no need to check range on __m1 because __s guarantees we have enough source |
| 88 | if (!__pred(*__m1, *__m2)) { | |
| 110 | if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2))) { | |
| 89 | 111 | ++__first1; |
| 90 | 112 | break; |
| 91 | 113 | } |
| ... | ... | @@ -93,22 +115,78 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando |
| 93 | 115 | } |
| 94 | 116 | } |
| 95 | 117 | |
| 118 | template <class _Iter1, class _Sent1, | |
| 119 | class _Iter2, class _Sent2, | |
| 120 | class _Pred, | |
| 121 | class _Proj1, | |
| 122 | class _Proj2> | |
| 123 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 124 | pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1, | |
| 125 | _Iter2 __first2, _Sent2 __last2, | |
| 126 | _Pred& __pred, | |
| 127 | _Proj1& __proj1, | |
| 128 | _Proj2& __proj2, | |
| 129 | __enable_if_t<__is_cpp17_random_access_iterator<_Iter1>::value | |
| 130 | && __is_cpp17_random_access_iterator<_Iter2>::value>* = nullptr) { | |
| 131 | ||
| 132 | auto __size2 = __last2 - __first2; | |
| 133 | if (__size2 == 0) | |
| 134 | return std::make_pair(__first1, __first1); | |
| 135 | ||
| 136 | auto __size1 = __last1 - __first1; | |
| 137 | if (__size1 < __size2) { | |
| 138 | return std::make_pair(__last1, __last1); | |
| 139 | } | |
| 140 | ||
| 141 | return std::__search_random_access_impl<_ClassicAlgPolicy>(__first1, __last1, | |
| 142 | __first2, __last2, | |
| 143 | __pred, | |
| 144 | __proj1, | |
| 145 | __proj2, | |
| 146 | __size1, | |
| 147 | __size2); | |
| 148 | } | |
| 149 | ||
| 150 | template <class _Iter1, class _Sent1, | |
| 151 | class _Iter2, class _Sent2, | |
| 152 | class _Pred, | |
| 153 | class _Proj1, | |
| 154 | class _Proj2> | |
| 155 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 156 | pair<_Iter1, _Iter1> __search_impl(_Iter1 __first1, _Sent1 __last1, | |
| 157 | _Iter2 __first2, _Sent2 __last2, | |
| 158 | _Pred& __pred, | |
| 159 | _Proj1& __proj1, | |
| 160 | _Proj2& __proj2, | |
| 161 | __enable_if_t<__is_cpp17_forward_iterator<_Iter1>::value | |
| 162 | && __is_cpp17_forward_iterator<_Iter2>::value | |
| 163 | && !(__is_cpp17_random_access_iterator<_Iter1>::value | |
| 164 | && __is_cpp17_random_access_iterator<_Iter2>::value)>* = nullptr) { | |
| 165 | return std::__search_forward_impl<_ClassicAlgPolicy>(__first1, __last1, | |
| 166 | __first2, __last2, | |
| 167 | __pred, | |
| 168 | __proj1, | |
| 169 | __proj2); | |
| 170 | } | |
| 171 | ||
| 96 | 172 | template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> |
| 97 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 | |
| 98 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 99 | _BinaryPredicate __pred) { | |
| 100 | return _VSTD::__search<_BinaryPredicate&>( | |
| 101 | __first1, __last1, __first2, __last2, __pred, | |
| 102 | typename iterator_traits<_ForwardIterator1>::iterator_category(), | |
| 103 | typename iterator_traits<_ForwardIterator2>::iterator_category()).first; | |
| 173 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 174 | _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 175 | _ForwardIterator2 __first2, _ForwardIterator2 __last2, | |
| 176 | _BinaryPredicate __pred) { | |
| 177 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value, | |
| 178 | "BinaryPredicate has to be callable"); | |
| 179 | auto __proj = __identity(); | |
| 180 | return std::__search_impl(__first1, __last1, __first2, __last2, __pred, __proj, __proj).first; | |
| 104 | 181 | } |
| 105 | 182 | |
| 106 | 183 | template <class _ForwardIterator1, class _ForwardIterator2> |
| 107 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 | |
| 108 | search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | |
| 109 | typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; | |
| 110 | typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; | |
| 111 | return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); | |
| 184 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 185 | _ForwardIterator1 search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | |
| 186 | _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | |
| 187 | using __v1 = typename iterator_traits<_ForwardIterator1>::value_type; | |
| 188 | using __v2 = typename iterator_traits<_ForwardIterator2>::value_type; | |
| 189 | return std::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); | |
| 112 | 190 | } |
| 113 | 191 | |
| 114 | 192 | #if _LIBCPP_STD_VER > 14 |
lib/libcxx/include/__algorithm/search_n.h+115-46| ... | ... | @@ -11,40 +11,56 @@ |
| 11 | 11 | #define _LIBCPP___ALGORITHM_SEARCH_N_H |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__iterator/advance.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/distance.h> | |
| 15 | 20 | #include <__iterator/iterator_traits.h> |
| 21 | #include <__ranges/concepts.h> | |
| 22 | #include <__utility/pair.h> | |
| 16 | 23 | #include <type_traits> // __convert_to_integral |
| 17 | 24 | |
| 18 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 20 | 27 | #endif |
| 21 | 28 | |
| 22 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 30 | |
| 24 | template <class _BinaryPredicate, class _ForwardIterator, class _Size, class _Tp> | |
| 25 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, | |
| 26 | _Size __count, const _Tp& __value_, _BinaryPredicate __pred, | |
| 27 | forward_iterator_tag) { | |
| 31 | template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj> | |
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 33 | pair<_Iter, _Iter> __search_n_forward_impl(_Iter __first, _Sent __last, | |
| 34 | _SizeT __count, | |
| 35 | const _Type& __value, | |
| 36 | _Pred& __pred, | |
| 37 | _Proj& __proj) { | |
| 28 | 38 | if (__count <= 0) |
| 29 | return __first; | |
| 39 | return std::make_pair(__first, __first); | |
| 30 | 40 | while (true) { |
| 31 | // Find first element in sequence that matchs __value_, with a mininum of loop checks | |
| 41 | // Find first element in sequence that matchs __value, with a mininum of loop checks | |
| 32 | 42 | while (true) { |
| 33 | if (__first == __last) // return __last if no element matches __value_ | |
| 34 | return __last; | |
| 35 | if (__pred(*__first, __value_)) | |
| 43 | if (__first == __last) { // return __last if no element matches __value | |
| 44 | _IterOps<_AlgPolicy>::__advance_to(__first, __last); | |
| 45 | return std::make_pair(__first, __first); | |
| 46 | } | |
| 47 | if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value)) | |
| 36 | 48 | break; |
| 37 | 49 | ++__first; |
| 38 | 50 | } |
| 39 | // *__first matches __value_, now match elements after here | |
| 40 | _ForwardIterator __m = __first; | |
| 41 | _Size __c(0); | |
| 51 | // *__first matches __value, now match elements after here | |
| 52 | _Iter __m = __first; | |
| 53 | _SizeT __c(0); | |
| 42 | 54 | while (true) { |
| 43 | 55 | if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) |
| 44 | return __first; | |
| 45 | if (++__m == __last) // Otherwise if source exhaused, pattern not found | |
| 46 | return __last; | |
| 47 | if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first | |
| 56 | return std::make_pair(__first, ++__m); | |
| 57 | if (++__m == __last) { // Otherwise if source exhaused, pattern not found | |
| 58 | _IterOps<_AlgPolicy>::__advance_to(__first, __last); | |
| 59 | return std::make_pair(__first, __first); | |
| 60 | } | |
| 61 | ||
| 62 | // if there is a mismatch, restart with a new __first | |
| 63 | if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value)) | |
| 48 | 64 | { |
| 49 | 65 | __first = __m; |
| 50 | 66 | ++__first; |
| ... | ... | @@ -54,35 +70,44 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __fir |
| 54 | 70 | } |
| 55 | 71 | } |
| 56 | 72 | |
| 57 | template <class _BinaryPredicate, class _RandomAccessIterator, class _Size, class _Tp> | |
| 58 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIterator __first, | |
| 59 | _RandomAccessIterator __last, _Size __count, | |
| 60 | const _Tp& __value_, _BinaryPredicate __pred, | |
| 61 | random_access_iterator_tag) { | |
| 62 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 63 | if (__count <= 0) | |
| 64 | return __first; | |
| 65 | _Size __len = static_cast<_Size>(__last - __first); | |
| 66 | if (__len < __count) | |
| 67 | return __last; | |
| 68 | const _RandomAccessIterator __s = __last - difference_type(__count - 1); // Start of pattern match can't go beyond here | |
| 73 | template <class _AlgPolicy, class _Pred, class _Iter, class _Sent, class _SizeT, class _Type, class _Proj, class _DiffT> | |
| 74 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 75 | std::pair<_Iter, _Iter> __search_n_random_access_impl(_Iter __first, _Sent __last, | |
| 76 | _SizeT __count, | |
| 77 | const _Type& __value, | |
| 78 | _Pred& __pred, | |
| 79 | _Proj& __proj, | |
| 80 | _DiffT __size1) { | |
| 81 | using difference_type = typename iterator_traits<_Iter>::difference_type; | |
| 82 | if (__count == 0) | |
| 83 | return std::make_pair(__first, __first); | |
| 84 | if (__size1 < static_cast<_DiffT>(__count)) { | |
| 85 | _IterOps<_AlgPolicy>::__advance_to(__first, __last); | |
| 86 | return std::make_pair(__first, __first); | |
| 87 | } | |
| 88 | ||
| 89 | const auto __s = __first + __size1 - difference_type(__count - 1); // Start of pattern match can't go beyond here | |
| 69 | 90 | while (true) { |
| 70 | // Find first element in sequence that matchs __value_, with a mininum of loop checks | |
| 91 | // Find first element in sequence that matchs __value, with a mininum of loop checks | |
| 71 | 92 | while (true) { |
| 72 | if (__first >= __s) // return __last if no element matches __value_ | |
| 73 | return __last; | |
| 74 | if (__pred(*__first, __value_)) | |
| 93 | if (__first >= __s) { // return __last if no element matches __value | |
| 94 | _IterOps<_AlgPolicy>::__advance_to(__first, __last); | |
| 95 | return std::make_pair(__first, __first); | |
| 96 | } | |
| 97 | if (std::__invoke(__pred, std::__invoke(__proj, *__first), __value)) | |
| 75 | 98 | break; |
| 76 | 99 | ++__first; |
| 77 | 100 | } |
| 78 | 101 | // *__first matches __value_, now match elements after here |
| 79 | _RandomAccessIterator __m = __first; | |
| 80 | _Size __c(0); | |
| 102 | auto __m = __first; | |
| 103 | _SizeT __c(0); | |
| 81 | 104 | while (true) { |
| 82 | 105 | if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) |
| 83 | return __first; | |
| 84 | ++__m; // no need to check range on __m because __s guarantees we have enough source | |
| 85 | if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first | |
| 106 | return std::make_pair(__first, __first + _DiffT(__count)); | |
| 107 | ++__m; // no need to check range on __m because __s guarantees we have enough source | |
| 108 | ||
| 109 | // if there is a mismatch, restart with a new __first | |
| 110 | if (!std::__invoke(__pred, std::__invoke(__proj, *__m), __value)) | |
| 86 | 111 | { |
| 87 | 112 | __first = __m; |
| 88 | 113 | ++__first; |
| ... | ... | @@ -92,19 +117,63 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter |
| 92 | 117 | } |
| 93 | 118 | } |
| 94 | 119 | |
| 120 | template <class _Iter, class _Sent, | |
| 121 | class _DiffT, | |
| 122 | class _Type, | |
| 123 | class _Pred, | |
| 124 | class _Proj> | |
| 125 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 126 | pair<_Iter, _Iter> __search_n_impl(_Iter __first, _Sent __last, | |
| 127 | _DiffT __count, | |
| 128 | const _Type& __value, | |
| 129 | _Pred& __pred, | |
| 130 | _Proj& __proj, | |
| 131 | __enable_if_t<__is_cpp17_random_access_iterator<_Iter>::value>* = nullptr) { | |
| 132 | return std::__search_n_random_access_impl<_ClassicAlgPolicy>(__first, __last, | |
| 133 | __count, | |
| 134 | __value, | |
| 135 | __pred, | |
| 136 | __proj, | |
| 137 | __last - __first); | |
| 138 | } | |
| 139 | ||
| 140 | template <class _Iter1, class _Sent1, | |
| 141 | class _DiffT, | |
| 142 | class _Type, | |
| 143 | class _Pred, | |
| 144 | class _Proj> | |
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 146 | pair<_Iter1, _Iter1> __search_n_impl(_Iter1 __first, _Sent1 __last, | |
| 147 | _DiffT __count, | |
| 148 | const _Type& __value, | |
| 149 | _Pred& __pred, | |
| 150 | _Proj& __proj, | |
| 151 | __enable_if_t<__is_cpp17_forward_iterator<_Iter1>::value | |
| 152 | && !__is_cpp17_random_access_iterator<_Iter1>::value>* = nullptr) { | |
| 153 | return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last, | |
| 154 | __count, | |
| 155 | __value, | |
| 156 | __pred, | |
| 157 | __proj); | |
| 158 | } | |
| 159 | ||
| 95 | 160 | template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate> |
| 96 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator search_n( | |
| 97 | _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_, _BinaryPredicate __pred) { | |
| 98 | return _VSTD::__search_n<_BinaryPredicate&>( | |
| 99 | __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred, | |
| 100 | typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 161 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 162 | _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, | |
| 163 | _Size __count, | |
| 164 | const _Tp& __value, | |
| 165 | _BinaryPredicate __pred) { | |
| 166 | static_assert(__is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, | |
| 167 | "BinaryPredicate has to be callable"); | |
| 168 | auto __proj = __identity(); | |
| 169 | return std::__search_n_impl(__first, __last, std::__convert_to_integral(__count), __value, __pred, __proj).first; | |
| 101 | 170 | } |
| 102 | 171 | |
| 103 | 172 | template <class _ForwardIterator, class _Size, class _Tp> |
| 104 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 105 | search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) { | |
| 173 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 174 | _ForwardIterator search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) { | |
| 106 | 175 | typedef typename iterator_traits<_ForwardIterator>::value_type __v; |
| 107 | return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count), __value_, __equal_to<__v, _Tp>()); | |
| 176 | return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to<__v, _Tp>()); | |
| 108 | 177 | } |
| 109 | 178 | |
| 110 | 179 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/set_difference.h+45-38| ... | ... | @@ -13,58 +13,65 @@ |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | 15 | #include <__config> |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 16 | 18 | #include <__iterator/iterator_traits.h> |
| 19 | #include <__utility/move.h> | |
| 20 | #include <__utility/pair.h> | |
| 21 | #include <type_traits> | |
| 17 | 22 | |
| 18 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 20 | 25 | #endif |
| 21 | 26 | |
| 22 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 28 | |
| 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> | |
| 25 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 26 | __set_difference(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 27 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 28 | { | |
| 29 | while (__first1 != __last1) | |
| 30 | { | |
| 31 | if (__first2 == __last2) | |
| 32 | return _VSTD::copy(__first1, __last1, __result); | |
| 33 | if (__comp(*__first1, *__first2)) | |
| 34 | { | |
| 35 | *__result = *__first1; | |
| 36 | ++__result; | |
| 37 | ++__first1; | |
| 38 | } | |
| 39 | else | |
| 40 | { | |
| 41 | if (!__comp(*__first2, *__first1)) | |
| 42 | ++__first1; | |
| 43 | ++__first2; | |
| 44 | } | |
| 29 | template < class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 30 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<__uncvref_t<_InIter1>, __uncvref_t<_OutIter> > | |
| 31 | __set_difference( | |
| 32 | _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) { | |
| 33 | while (__first1 != __last1 && __first2 != __last2) { | |
| 34 | if (__comp(*__first1, *__first2)) { | |
| 35 | *__result = *__first1; | |
| 36 | ++__first1; | |
| 37 | ++__result; | |
| 38 | } else if (__comp(*__first2, *__first1)) { | |
| 39 | ++__first2; | |
| 40 | } else { | |
| 41 | ++__first1; | |
| 42 | ++__first2; | |
| 45 | 43 | } |
| 46 | return __result; | |
| 44 | } | |
| 45 | return std::__copy(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> |
| 50 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 51 | _OutputIterator | |
| 52 | set_difference(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 53 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 54 | { | |
| 55 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 56 | return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); | |
| 49 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference( | |
| 50 | _InputIterator1 __first1, | |
| 51 | _InputIterator1 __last1, | |
| 52 | _InputIterator2 __first2, | |
| 53 | _InputIterator2 __last2, | |
| 54 | _OutputIterator __result, | |
| 55 | _Compare __comp) { | |
| 56 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 57 | return std::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp).second; | |
| 57 | 58 | } |
| 58 | 59 | |
| 59 | 60 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| 60 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 61 | _OutputIterator | |
| 62 | set_difference(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 63 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) | |
| 64 | { | |
| 65 | return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result, | |
| 66 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 67 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 61 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_difference( | |
| 62 | _InputIterator1 __first1, | |
| 63 | _InputIterator1 __last1, | |
| 64 | _InputIterator2 __first2, | |
| 65 | _InputIterator2 __last2, | |
| 66 | _OutputIterator __result) { | |
| 67 | return std::__set_difference( | |
| 68 | __first1, | |
| 69 | __last1, | |
| 70 | __first2, | |
| 71 | __last2, | |
| 72 | __result, | |
| 73 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 74 | typename iterator_traits<_InputIterator2>::value_type>()).second; | |
| 68 | 75 | } |
| 69 | 76 | |
| 70 | 77 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/set_intersection.h+67-36| ... | ... | @@ -11,57 +11,88 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__iterator/next.h> | |
| 18 | #include <__utility/move.h> | |
| 16 | 19 | |
| 17 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 19 | 22 | #endif |
| 20 | 23 | |
| 21 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 25 | |
| 23 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> | |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 25 | __set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 26 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 27 | { | |
| 28 | while (__first1 != __last1 && __first2 != __last2) | |
| 29 | { | |
| 30 | if (__comp(*__first1, *__first2)) | |
| 31 | ++__first1; | |
| 32 | else | |
| 33 | { | |
| 34 | if (!__comp(*__first2, *__first1)) | |
| 35 | { | |
| 36 | *__result = *__first1; | |
| 37 | ++__result; | |
| 38 | ++__first1; | |
| 39 | } | |
| 40 | ++__first2; | |
| 41 | } | |
| 26 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 27 | struct __set_intersection_result { | |
| 28 | _InIter1 __in1_; | |
| 29 | _InIter2 __in2_; | |
| 30 | _OutIter __out_; | |
| 31 | ||
| 32 | // need a constructor as C++03 aggregate init is hard | |
| 33 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 34 | __set_intersection_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter) | |
| 35 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} | |
| 36 | }; | |
| 37 | ||
| 38 | template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_intersection_result<_InIter1, _InIter2, _OutIter> | |
| 40 | __set_intersection( | |
| 41 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { | |
| 42 | while (__first1 != __last1 && __first2 != __last2) { | |
| 43 | if (__comp(*__first1, *__first2)) | |
| 44 | ++__first1; | |
| 45 | else { | |
| 46 | if (!__comp(*__first2, *__first1)) { | |
| 47 | *__result = *__first1; | |
| 48 | ++__result; | |
| 49 | ++__first1; | |
| 50 | } | |
| 51 | ++__first2; | |
| 42 | 52 | } |
| 43 | return __result; | |
| 53 | } | |
| 54 | ||
| 55 | return __set_intersection_result<_InIter1, _InIter2, _OutIter>( | |
| 56 | _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)), | |
| 57 | _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)), | |
| 58 | std::move(__result)); | |
| 44 | 59 | } |
| 45 | 60 | |
| 46 | 61 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> |
| 47 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 48 | _OutputIterator | |
| 49 | set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 50 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 51 | { | |
| 52 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 53 | return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); | |
| 62 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection( | |
| 63 | _InputIterator1 __first1, | |
| 64 | _InputIterator1 __last1, | |
| 65 | _InputIterator2 __first2, | |
| 66 | _InputIterator2 __last2, | |
| 67 | _OutputIterator __result, | |
| 68 | _Compare __comp) { | |
| 69 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 70 | return std::__set_intersection<_ClassicAlgPolicy, _Comp_ref>( | |
| 71 | std::move(__first1), | |
| 72 | std::move(__last1), | |
| 73 | std::move(__first2), | |
| 74 | std::move(__last2), | |
| 75 | std::move(__result), | |
| 76 | __comp) | |
| 77 | .__out_; | |
| 54 | 78 | } |
| 55 | 79 | |
| 56 | 80 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| 57 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 58 | _OutputIterator | |
| 59 | set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 60 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) | |
| 61 | { | |
| 62 | return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result, | |
| 63 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 64 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 81 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_intersection( | |
| 82 | _InputIterator1 __first1, | |
| 83 | _InputIterator1 __last1, | |
| 84 | _InputIterator2 __first2, | |
| 85 | _InputIterator2 __last2, | |
| 86 | _OutputIterator __result) { | |
| 87 | return std::__set_intersection<_ClassicAlgPolicy>( | |
| 88 | std::move(__first1), | |
| 89 | std::move(__last1), | |
| 90 | std::move(__first2), | |
| 91 | std::move(__last2), | |
| 92 | std::move(__result), | |
| 93 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 94 | typename iterator_traits<_InputIterator2>::value_type>()) | |
| 95 | .__out_; | |
| 65 | 96 | } |
| 66 | 97 | |
| 67 | 98 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/set_symmetric_difference.h+70-43| ... | ... | @@ -14,62 +14,89 @@ |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/move.h> | |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | |
| 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> | |
| 25 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 26 | __set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 27 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 28 | { | |
| 29 | while (__first1 != __last1) | |
| 30 | { | |
| 31 | if (__first2 == __last2) | |
| 32 | return _VSTD::copy(__first1, __last1, __result); | |
| 33 | if (__comp(*__first1, *__first2)) | |
| 34 | { | |
| 35 | *__result = *__first1; | |
| 36 | ++__result; | |
| 37 | ++__first1; | |
| 38 | } | |
| 39 | else | |
| 40 | { | |
| 41 | if (__comp(*__first2, *__first1)) | |
| 42 | { | |
| 43 | *__result = *__first2; | |
| 44 | ++__result; | |
| 45 | } | |
| 46 | else | |
| 47 | ++__first1; | |
| 48 | ++__first2; | |
| 49 | } | |
| 25 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 26 | struct __set_symmetric_difference_result { | |
| 27 | _InIter1 __in1_; | |
| 28 | _InIter2 __in2_; | |
| 29 | _OutIter __out_; | |
| 30 | ||
| 31 | // need a constructor as C++03 aggregate init is hard | |
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 33 | __set_symmetric_difference_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter) | |
| 34 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} | |
| 35 | }; | |
| 36 | ||
| 37 | template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter> | |
| 39 | __set_symmetric_difference( | |
| 40 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { | |
| 41 | while (__first1 != __last1) { | |
| 42 | if (__first2 == __last2) { | |
| 43 | auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 44 | return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>( | |
| 45 | std::move(__ret1.first), std::move(__first2), std::move((__ret1.second))); | |
| 46 | } | |
| 47 | if (__comp(*__first1, *__first2)) { | |
| 48 | *__result = *__first1; | |
| 49 | ++__result; | |
| 50 | ++__first1; | |
| 51 | } else { | |
| 52 | if (__comp(*__first2, *__first1)) { | |
| 53 | *__result = *__first2; | |
| 54 | ++__result; | |
| 55 | } else { | |
| 56 | ++__first1; | |
| 57 | } | |
| 58 | ++__first2; | |
| 50 | 59 | } |
| 51 | return _VSTD::copy(__first2, __last2, __result); | |
| 60 | } | |
| 61 | auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result)); | |
| 62 | return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>( | |
| 63 | std::move(__first1), std::move(__ret2.first), std::move((__ret2.second))); | |
| 52 | 64 | } |
| 53 | 65 | |
| 54 | 66 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> |
| 55 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 56 | _OutputIterator | |
| 57 | set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 58 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 59 | { | |
| 60 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 61 | return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); | |
| 67 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference( | |
| 68 | _InputIterator1 __first1, | |
| 69 | _InputIterator1 __last1, | |
| 70 | _InputIterator2 __first2, | |
| 71 | _InputIterator2 __last2, | |
| 72 | _OutputIterator __result, | |
| 73 | _Compare __comp) { | |
| 74 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 75 | return std::__set_symmetric_difference<_Comp_ref>( | |
| 76 | std::move(__first1), | |
| 77 | std::move(__last1), | |
| 78 | std::move(__first2), | |
| 79 | std::move(__last2), | |
| 80 | std::move(__result), | |
| 81 | __comp) | |
| 82 | .__out_; | |
| 62 | 83 | } |
| 63 | 84 | |
| 64 | 85 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| 65 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 66 | _OutputIterator | |
| 67 | set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 68 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) | |
| 69 | { | |
| 70 | return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result, | |
| 71 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 72 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_symmetric_difference( | |
| 87 | _InputIterator1 __first1, | |
| 88 | _InputIterator1 __last1, | |
| 89 | _InputIterator2 __first2, | |
| 90 | _InputIterator2 __last2, | |
| 91 | _OutputIterator __result) { | |
| 92 | return std::set_symmetric_difference( | |
| 93 | std::move(__first1), | |
| 94 | std::move(__last1), | |
| 95 | std::move(__first2), | |
| 96 | std::move(__last2), | |
| 97 | std::move(__result), | |
| 98 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 99 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 73 | 100 | } |
| 74 | 101 | |
| 75 | 102 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/set_union.h+66-38| ... | ... | @@ -14,57 +14,85 @@ |
| 14 | 14 | #include <__algorithm/copy.h> |
| 15 | 15 | #include <__config> |
| 16 | 16 | #include <__iterator/iterator_traits.h> |
| 17 | #include <__utility/move.h> | |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | |
| 24 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> | |
| 25 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 26 | __set_union(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 27 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 28 | { | |
| 29 | for (; __first1 != __last1; ++__result) | |
| 30 | { | |
| 31 | if (__first2 == __last2) | |
| 32 | return _VSTD::copy(__first1, __last1, __result); | |
| 33 | if (__comp(*__first2, *__first1)) | |
| 34 | { | |
| 35 | *__result = *__first2; | |
| 36 | ++__first2; | |
| 37 | } | |
| 38 | else | |
| 39 | { | |
| 40 | if (!__comp(*__first1, *__first2)) | |
| 41 | ++__first2; | |
| 42 | *__result = *__first1; | |
| 43 | ++__first1; | |
| 44 | } | |
| 25 | template <class _InIter1, class _InIter2, class _OutIter> | |
| 26 | struct __set_union_result { | |
| 27 | _InIter1 __in1_; | |
| 28 | _InIter2 __in2_; | |
| 29 | _OutIter __out_; | |
| 30 | ||
| 31 | // need a constructor as C++03 aggregate init is hard | |
| 32 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 33 | __set_union_result(_InIter1&& __in_iter1, _InIter2&& __in_iter2, _OutIter&& __out_iter) | |
| 34 | : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {} | |
| 35 | }; | |
| 36 | ||
| 37 | template <class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter> | |
| 38 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 __set_union_result<_InIter1, _InIter2, _OutIter> __set_union( | |
| 39 | _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) { | |
| 40 | for (; __first1 != __last1; ++__result) { | |
| 41 | if (__first2 == __last2) { | |
| 42 | auto __ret1 = std::__copy_impl(std::move(__first1), std::move(__last1), std::move(__result)); | |
| 43 | return __set_union_result<_InIter1, _InIter2, _OutIter>( | |
| 44 | std::move(__ret1.first), std::move(__first2), std::move((__ret1.second))); | |
| 45 | } | |
| 46 | if (__comp(*__first2, *__first1)) { | |
| 47 | *__result = *__first2; | |
| 48 | ++__first2; | |
| 49 | } else { | |
| 50 | if (!__comp(*__first1, *__first2)) { | |
| 51 | ++__first2; | |
| 52 | } | |
| 53 | *__result = *__first1; | |
| 54 | ++__first1; | |
| 45 | 55 | } |
| 46 | return _VSTD::copy(__first2, __last2, __result); | |
| 56 | } | |
| 57 | auto __ret2 = std::__copy_impl(std::move(__first2), std::move(__last2), std::move(__result)); | |
| 58 | return __set_union_result<_InIter1, _InIter2, _OutIter>( | |
| 59 | std::move(__first1), std::move(__ret2.first), std::move((__ret2.second))); | |
| 47 | 60 | } |
| 48 | 61 | |
| 49 | 62 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare> |
| 50 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 51 | _OutputIterator | |
| 52 | set_union(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 53 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) | |
| 54 | { | |
| 55 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 56 | return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); | |
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union( | |
| 64 | _InputIterator1 __first1, | |
| 65 | _InputIterator1 __last1, | |
| 66 | _InputIterator2 __first2, | |
| 67 | _InputIterator2 __last2, | |
| 68 | _OutputIterator __result, | |
| 69 | _Compare __comp) { | |
| 70 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 71 | return std::__set_union<_Comp_ref>( | |
| 72 | std::move(__first1), | |
| 73 | std::move(__last1), | |
| 74 | std::move(__first2), | |
| 75 | std::move(__last2), | |
| 76 | std::move(__result), | |
| 77 | __comp) | |
| 78 | .__out_; | |
| 57 | 79 | } |
| 58 | 80 | |
| 59 | 81 | template <class _InputIterator1, class _InputIterator2, class _OutputIterator> |
| 60 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 61 | _OutputIterator | |
| 62 | set_union(_InputIterator1 __first1, _InputIterator1 __last1, | |
| 63 | _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) | |
| 64 | { | |
| 65 | return _VSTD::set_union(__first1, __last1, __first2, __last2, __result, | |
| 66 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 67 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 82 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator set_union( | |
| 83 | _InputIterator1 __first1, | |
| 84 | _InputIterator1 __last1, | |
| 85 | _InputIterator2 __first2, | |
| 86 | _InputIterator2 __last2, | |
| 87 | _OutputIterator __result) { | |
| 88 | return std::set_union( | |
| 89 | std::move(__first1), | |
| 90 | std::move(__last1), | |
| 91 | std::move(__first2), | |
| 92 | std::move(__last2), | |
| 93 | std::move(__result), | |
| 94 | __less<typename iterator_traits<_InputIterator1>::value_type, | |
| 95 | typename iterator_traits<_InputIterator2>::value_type>()); | |
| 68 | 96 | } |
| 69 | 97 | |
| 70 | 98 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/shift_left.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/shift_right.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/shuffle.h+21-7| ... | ... | @@ -9,15 +9,18 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SHUFFLE_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SHUFFLE_H |
| 11 | 11 | |
| 12 | #include <__algorithm/iterator_operations.h> | |
| 12 | 13 | #include <__config> |
| 14 | #include <__debug> | |
| 13 | 15 | #include <__iterator/iterator_traits.h> |
| 14 | 16 | #include <__random/uniform_int_distribution.h> |
| 15 | #include <__utility/swap.h> | |
| 17 | #include <__utility/forward.h> | |
| 18 | #include <__utility/move.h> | |
| 16 | 19 | #include <cstddef> |
| 17 | 20 | #include <cstdint> |
| 18 | 21 | |
| 19 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 21 | 24 | #endif |
| 22 | 25 | |
| 23 | 26 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -133,13 +136,15 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, |
| 133 | 136 | } |
| 134 | 137 | #endif |
| 135 | 138 | |
| 136 | template<class _RandomAccessIterator, class _UniformRandomNumberGenerator> | |
| 137 | void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, | |
| 138 | _UniformRandomNumberGenerator&& __g) | |
| 139 | { | |
| 139 | template <class _AlgPolicy, class _RandomAccessIterator, class _Sentinel, class _UniformRandomNumberGenerator> | |
| 140 | _RandomAccessIterator __shuffle( | |
| 141 | _RandomAccessIterator __first, _Sentinel __last_sentinel, _UniformRandomNumberGenerator&& __g) { | |
| 140 | 142 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 141 | 143 | typedef uniform_int_distribution<ptrdiff_t> _Dp; |
| 142 | 144 | typedef typename _Dp::param_type _Pp; |
| 145 | ||
| 146 | auto __original_last = _IterOps<_AlgPolicy>::next(__first, __last_sentinel); | |
| 147 | auto __last = __original_last; | |
| 143 | 148 | difference_type __d = __last - __first; |
| 144 | 149 | if (__d > 1) |
| 145 | 150 | { |
| ... | ... | @@ -148,9 +153,18 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator> |
| 148 | 153 | { |
| 149 | 154 | difference_type __i = __uid(__g, _Pp(0, __d)); |
| 150 | 155 | if (__i != difference_type(0)) |
| 151 | swap(*__first, *(__first + __i)); | |
| 156 | _IterOps<_AlgPolicy>::iter_swap(__first, __first + __i); | |
| 152 | 157 | } |
| 153 | 158 | } |
| 159 | ||
| 160 | return __original_last; | |
| 161 | } | |
| 162 | ||
| 163 | template <class _RandomAccessIterator, class _UniformRandomNumberGenerator> | |
| 164 | void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, | |
| 165 | _UniformRandomNumberGenerator&& __g) { | |
| 166 | (void)std::__shuffle<_ClassicAlgPolicy>( | |
| 167 | std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g)); | |
| 154 | 168 | } |
| 155 | 169 | |
| 156 | 170 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/sift_down.h+41-5| ... | ... | @@ -9,22 +9,26 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_SIFT_DOWN_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_SIFT_DOWN_H |
| 11 | 11 | |
| 12 | #include <__algorithm/iterator_operations.h> | |
| 13 | #include <__assert> | |
| 12 | 14 | #include <__config> |
| 13 | 15 | #include <__iterator/iterator_traits.h> |
| 14 | 16 | #include <__utility/move.h> |
| 15 | 17 | |
| 16 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 18 | 20 | #endif |
| 19 | 21 | |
| 20 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 23 | |
| 22 | template <class _Compare, class _RandomAccessIterator> | |
| 24 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 23 | 25 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void |
| 24 | __sift_down(_RandomAccessIterator __first, _Compare __comp, | |
| 26 | __sift_down(_RandomAccessIterator __first, _Compare&& __comp, | |
| 25 | 27 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, |
| 26 | 28 | _RandomAccessIterator __start) |
| 27 | 29 | { |
| 30 | using _Ops = _IterOps<_AlgPolicy>; | |
| 31 | ||
| 28 | 32 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 29 | 33 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 30 | 34 | // left-child of __start is at 2 * __start + 1 |
| ... | ... | @@ -48,11 +52,11 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp, |
| 48 | 52 | // we are, __start is larger than its largest child |
| 49 | 53 | return; |
| 50 | 54 | |
| 51 | value_type __top(_VSTD::move(*__start)); | |
| 55 | value_type __top(_Ops::__iter_move(__start)); | |
| 52 | 56 | do |
| 53 | 57 | { |
| 54 | 58 | // we are not in heap-order, swap the parent with its largest child |
| 55 | *__start = _VSTD::move(*__child_i); | |
| 59 | *__start = _Ops::__iter_move(__child_i); | |
| 56 | 60 | __start = __child_i; |
| 57 | 61 | |
| 58 | 62 | if ((__len - 2) / 2 < __child) |
| ... | ... | @@ -73,6 +77,38 @@ __sift_down(_RandomAccessIterator __first, _Compare __comp, |
| 73 | 77 | *__start = _VSTD::move(__top); |
| 74 | 78 | } |
| 75 | 79 | |
| 80 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 81 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator | |
| 82 | __floyd_sift_down(_RandomAccessIterator __first, _Compare&& __comp, | |
| 83 | typename iterator_traits<_RandomAccessIterator>::difference_type __len) | |
| 84 | { | |
| 85 | using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; | |
| 86 | _LIBCPP_ASSERT(__len >= 2, "shouldn't be called unless __len >= 2"); | |
| 87 | ||
| 88 | _RandomAccessIterator __hole = __first; | |
| 89 | _RandomAccessIterator __child_i = __first; | |
| 90 | difference_type __child = 0; | |
| 91 | ||
| 92 | while (true) { | |
| 93 | __child_i += difference_type(__child + 1); | |
| 94 | __child = 2 * __child + 1; | |
| 95 | ||
| 96 | if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) { | |
| 97 | // right-child exists and is greater than left-child | |
| 98 | ++__child_i; | |
| 99 | ++__child; | |
| 100 | } | |
| 101 | ||
| 102 | // swap __hole with its largest child | |
| 103 | *__hole = _IterOps<_AlgPolicy>::__iter_move(__child_i); | |
| 104 | __hole = __child_i; | |
| 105 | ||
| 106 | // if __hole is now a leaf, we're done | |
| 107 | if (__child > (__len - 2) / 2) | |
| 108 | return __hole; | |
| 109 | } | |
| 110 | } | |
| 111 | ||
| 76 | 112 | _LIBCPP_END_NAMESPACE_STD |
| 77 | 113 | |
| 78 | 114 | #endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H |
lib/libcxx/include/__algorithm/sort.h+598-449| ... | ... | @@ -11,462 +11,602 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__algorithm/min_element.h> |
| 15 | 16 | #include <__algorithm/partial_sort.h> |
| 16 | 17 | #include <__algorithm/unwrap_iter.h> |
| 18 | #include <__bits> | |
| 17 | 19 | #include <__config> |
| 18 | #include <__utility/swap.h> | |
| 20 | #include <__debug> | |
| 21 | #include <__debug_utils/randomize_range.h> | |
| 22 | #include <__functional/operations.h> | |
| 23 | #include <__functional/ranges_operations.h> | |
| 24 | #include <__iterator/iterator_traits.h> | |
| 25 | #include <climits> | |
| 19 | 26 | #include <memory> |
| 20 | 27 | |
| 21 | #if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 22 | # include <__algorithm/shuffle.h> | |
| 23 | #endif | |
| 24 | ||
| 25 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | #pragma GCC system_header | |
| 29 | # pragma GCC system_header | |
| 27 | 30 | #endif |
| 28 | 31 | |
| 29 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 33 | |
| 34 | // Wraps an algorithm policy tag and a comparator in a single struct, used to pass the policy tag around without | |
| 35 | // changing the number of template arguments (to keep the ABI stable). This is only used for the "range" policy tag. | |
| 36 | // | |
| 37 | // To create an object of this type, use `_WrapAlgPolicy<T, C>::type` -- see the specialization below for the rationale. | |
| 38 | template <class _PolicyT, class _CompT, class = void> | |
| 39 | struct _WrapAlgPolicy { | |
| 40 | using type = _WrapAlgPolicy; | |
| 41 | ||
| 42 | using _AlgPolicy = _PolicyT; | |
| 43 | using _Comp = _CompT; | |
| 44 | _Comp& __comp; | |
| 45 | ||
| 46 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 47 | _WrapAlgPolicy(_Comp& __c) : __comp(__c) {} | |
| 48 | }; | |
| 49 | ||
| 50 | // Specialization for the "classic" policy tag that avoids creating a struct and simply defines an alias for the | |
| 51 | // comparator. When unwrapping, a pristine comparator is always considered to have the "classic" tag attached. Passing | |
| 52 | // the pristine comparator where possible allows using template instantiations from the dylib. | |
| 53 | template <class _PolicyT, class _CompT> | |
| 54 | struct _WrapAlgPolicy<_PolicyT, _CompT, __enable_if_t<std::is_same<_PolicyT, _ClassicAlgPolicy>::value> > { | |
| 55 | using type = _CompT; | |
| 56 | }; | |
| 57 | ||
| 58 | // Unwraps a pristine functor (e.g. `std::less`) as if it were wrapped using `_WrapAlgPolicy`. The policy tag is always | |
| 59 | // set to "classic". | |
| 60 | template <class _CompT> | |
| 61 | struct _UnwrapAlgPolicy { | |
| 62 | using _AlgPolicy = _ClassicAlgPolicy; | |
| 63 | using _Comp = _CompT; | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static | |
| 66 | _Comp __get_comp(_Comp __comp) { return __comp; } | |
| 67 | }; | |
| 68 | ||
| 69 | // Unwraps a `_WrapAlgPolicy` struct. | |
| 70 | template <class... _Ts> | |
| 71 | struct _UnwrapAlgPolicy<_WrapAlgPolicy<_Ts...> > { | |
| 72 | using _Wrapped = _WrapAlgPolicy<_Ts...>; | |
| 73 | using _AlgPolicy = typename _Wrapped::_AlgPolicy; | |
| 74 | using _Comp = typename _Wrapped::_Comp; | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 static | |
| 77 | _Comp __get_comp(_Wrapped& __w) { return __w.__comp; } | |
| 78 | }; | |
| 79 | ||
| 31 | 80 | // stable, 2-3 compares, 0-2 swaps |
| 32 | 81 | |
| 33 | template <class _Compare, class _ForwardIterator> | |
| 34 | _LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned | |
| 35 | __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c) | |
| 36 | { | |
| 37 | unsigned __r = 0; | |
| 38 | if (!__c(*__y, *__x)) // if x <= y | |
| 39 | { | |
| 40 | if (!__c(*__z, *__y)) // if y <= z | |
| 41 | return __r; // x <= y && y <= z | |
| 42 | // x <= y && y > z | |
| 43 | swap(*__y, *__z); // x <= z && y < z | |
| 44 | __r = 1; | |
| 45 | if (__c(*__y, *__x)) // if x > y | |
| 46 | { | |
| 47 | swap(*__x, *__y); // x < y && y <= z | |
| 48 | __r = 2; | |
| 49 | } | |
| 50 | return __r; // x <= y && y < z | |
| 51 | } | |
| 52 | if (__c(*__z, *__y)) // x > y, if y > z | |
| 53 | { | |
| 54 | swap(*__x, *__z); // x < y && y < z | |
| 55 | __r = 1; | |
| 56 | return __r; | |
| 57 | } | |
| 58 | swap(*__x, *__y); // x > y && y <= z | |
| 59 | __r = 1; // x < y && x <= z | |
| 60 | if (__c(*__z, *__y)) // if y > z | |
| 82 | template <class _AlgPolicy, class _Compare, class _ForwardIterator> | |
| 83 | _LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned __sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, | |
| 84 | _Compare __c) { | |
| 85 | using _Ops = _IterOps<_AlgPolicy>; | |
| 86 | ||
| 87 | unsigned __r = 0; | |
| 88 | if (!__c(*__y, *__x)) // if x <= y | |
| 89 | { | |
| 90 | if (!__c(*__z, *__y)) // if y <= z | |
| 91 | return __r; // x <= y && y <= z | |
| 92 | // x <= y && y > z | |
| 93 | _Ops::iter_swap(__y, __z); // x <= z && y < z | |
| 94 | __r = 1; | |
| 95 | if (__c(*__y, *__x)) // if x > y | |
| 61 | 96 | { |
| 62 | swap(*__y, *__z); // x <= y && y < z | |
| 63 | __r = 2; | |
| 97 | _Ops::iter_swap(__x, __y); // x < y && y <= z | |
| 98 | __r = 2; | |
| 64 | 99 | } |
| 100 | return __r; // x <= y && y < z | |
| 101 | } | |
| 102 | if (__c(*__z, *__y)) // x > y, if y > z | |
| 103 | { | |
| 104 | _Ops::iter_swap(__x, __z); // x < y && y < z | |
| 105 | __r = 1; | |
| 65 | 106 | return __r; |
| 66 | } // x <= y && y <= z | |
| 107 | } | |
| 108 | _Ops::iter_swap(__x, __y); // x > y && y <= z | |
| 109 | __r = 1; // x < y && x <= z | |
| 110 | if (__c(*__z, *__y)) // if y > z | |
| 111 | { | |
| 112 | _Ops::iter_swap(__y, __z); // x <= y && y < z | |
| 113 | __r = 2; | |
| 114 | } | |
| 115 | return __r; | |
| 116 | } // x <= y && y <= z | |
| 67 | 117 | |
| 68 | 118 | // stable, 3-6 compares, 0-5 swaps |
| 69 | 119 | |
| 70 | template <class _Compare, class _ForwardIterator> | |
| 71 | unsigned | |
| 72 | __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, | |
| 73 | _ForwardIterator __x4, _Compare __c) | |
| 74 | { | |
| 75 | unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c); | |
| 76 | if (__c(*__x4, *__x3)) | |
| 77 | { | |
| 78 | swap(*__x3, *__x4); | |
| 120 | template <class _AlgPolicy, class _Compare, class _ForwardIterator> | |
| 121 | unsigned __sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, | |
| 122 | _Compare __c) { | |
| 123 | using _Ops = _IterOps<_AlgPolicy>; | |
| 124 | ||
| 125 | unsigned __r = std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c); | |
| 126 | if (__c(*__x4, *__x3)) { | |
| 127 | _Ops::iter_swap(__x3, __x4); | |
| 128 | ++__r; | |
| 129 | if (__c(*__x3, *__x2)) { | |
| 130 | _Ops::iter_swap(__x2, __x3); | |
| 131 | ++__r; | |
| 132 | if (__c(*__x2, *__x1)) { | |
| 133 | _Ops::iter_swap(__x1, __x2); | |
| 79 | 134 | ++__r; |
| 80 | if (__c(*__x3, *__x2)) | |
| 81 | { | |
| 82 | swap(*__x2, *__x3); | |
| 83 | ++__r; | |
| 84 | if (__c(*__x2, *__x1)) | |
| 85 | { | |
| 86 | swap(*__x1, *__x2); | |
| 87 | ++__r; | |
| 88 | } | |
| 89 | } | |
| 135 | } | |
| 90 | 136 | } |
| 91 | return __r; | |
| 137 | } | |
| 138 | return __r; | |
| 92 | 139 | } |
| 93 | 140 | |
| 94 | 141 | // stable, 4-10 compares, 0-9 swaps |
| 95 | 142 | |
| 96 | template <class _Compare, class _ForwardIterator> | |
| 97 | _LIBCPP_HIDDEN | |
| 98 | unsigned | |
| 99 | __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, | |
| 100 | _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c) | |
| 101 | { | |
| 102 | unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c); | |
| 103 | if (__c(*__x5, *__x4)) | |
| 104 | { | |
| 105 | swap(*__x4, *__x5); | |
| 143 | template <class _WrappedComp, class _ForwardIterator> | |
| 144 | _LIBCPP_HIDDEN unsigned __sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, | |
| 145 | _ForwardIterator __x4, _ForwardIterator __x5, _WrappedComp __wrapped_comp) { | |
| 146 | using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>; | |
| 147 | using _AlgPolicy = typename _Unwrap::_AlgPolicy; | |
| 148 | using _Ops = _IterOps<_AlgPolicy>; | |
| 149 | ||
| 150 | using _Compare = typename _Unwrap::_Comp; | |
| 151 | _Compare __c = _Unwrap::__get_comp(__wrapped_comp); | |
| 152 | ||
| 153 | unsigned __r = std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c); | |
| 154 | if (__c(*__x5, *__x4)) { | |
| 155 | _Ops::iter_swap(__x4, __x5); | |
| 156 | ++__r; | |
| 157 | if (__c(*__x4, *__x3)) { | |
| 158 | _Ops::iter_swap(__x3, __x4); | |
| 159 | ++__r; | |
| 160 | if (__c(*__x3, *__x2)) { | |
| 161 | _Ops::iter_swap(__x2, __x3); | |
| 106 | 162 | ++__r; |
| 107 | if (__c(*__x4, *__x3)) | |
| 108 | { | |
| 109 | swap(*__x3, *__x4); | |
| 110 | ++__r; | |
| 111 | if (__c(*__x3, *__x2)) | |
| 112 | { | |
| 113 | swap(*__x2, *__x3); | |
| 114 | ++__r; | |
| 115 | if (__c(*__x2, *__x1)) | |
| 116 | { | |
| 117 | swap(*__x1, *__x2); | |
| 118 | ++__r; | |
| 119 | } | |
| 120 | } | |
| 163 | if (__c(*__x2, *__x1)) { | |
| 164 | _Ops::iter_swap(__x1, __x2); | |
| 165 | ++__r; | |
| 121 | 166 | } |
| 167 | } | |
| 122 | 168 | } |
| 123 | return __r; | |
| 169 | } | |
| 170 | return __r; | |
| 171 | } | |
| 172 | ||
| 173 | template <class _AlgPolicy, class _Compare, class _ForwardIterator> | |
| 174 | _LIBCPP_HIDDEN unsigned __sort5_wrap_policy( | |
| 175 | _ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, _ForwardIterator __x4, _ForwardIterator __x5, | |
| 176 | _Compare __c) { | |
| 177 | using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type; | |
| 178 | _WrappedComp __wrapped_comp(__c); | |
| 179 | return std::__sort5<_WrappedComp>( | |
| 180 | std::move(__x1), std::move(__x2), std::move(__x3), std::move(__x4), std::move(__x5), __wrapped_comp); | |
| 181 | } | |
| 182 | ||
| 183 | // The comparator being simple is a prerequisite for using the branchless optimization. | |
| 184 | template <class _Tp> | |
| 185 | struct __is_simple_comparator : false_type {}; | |
| 186 | template <class _Tp> | |
| 187 | struct __is_simple_comparator<__less<_Tp>&> : true_type {}; | |
| 188 | template <class _Tp> | |
| 189 | struct __is_simple_comparator<less<_Tp>&> : true_type {}; | |
| 190 | template <class _Tp> | |
| 191 | struct __is_simple_comparator<greater<_Tp>&> : true_type {}; | |
| 192 | #if _LIBCPP_STD_VER > 17 | |
| 193 | template <> | |
| 194 | struct __is_simple_comparator<ranges::less&> : true_type {}; | |
| 195 | template <> | |
| 196 | struct __is_simple_comparator<ranges::greater&> : true_type {}; | |
| 197 | #endif | |
| 198 | ||
| 199 | template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type> | |
| 200 | using __use_branchless_sort = | |
| 201 | integral_constant<bool, __is_cpp17_contiguous_iterator<_Iter>::value && sizeof(_Tp) <= sizeof(void*) && | |
| 202 | is_arithmetic<_Tp>::value && __is_simple_comparator<_Compare>::value>; | |
| 203 | ||
| 204 | // Ensures that __c(*__x, *__y) is true by swapping *__x and *__y if necessary. | |
| 205 | template <class _Compare, class _RandomAccessIterator> | |
| 206 | inline _LIBCPP_HIDE_FROM_ABI void __cond_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, _Compare __c) { | |
| 207 | // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`). | |
| 208 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; | |
| 209 | bool __r = __c(*__x, *__y); | |
| 210 | value_type __tmp = __r ? *__x : *__y; | |
| 211 | *__y = __r ? *__y : *__x; | |
| 212 | *__x = __tmp; | |
| 213 | } | |
| 214 | ||
| 215 | // Ensures that *__x, *__y and *__z are ordered according to the comparator __c, | |
| 216 | // under the assumption that *__y and *__z are already ordered. | |
| 217 | template <class _Compare, class _RandomAccessIterator> | |
| 218 | inline _LIBCPP_HIDE_FROM_ABI void __partially_sorted_swap(_RandomAccessIterator __x, _RandomAccessIterator __y, | |
| 219 | _RandomAccessIterator __z, _Compare __c) { | |
| 220 | // Note: this function behaves correctly even with proxy iterators (because it relies on `value_type`). | |
| 221 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; | |
| 222 | bool __r = __c(*__z, *__x); | |
| 223 | value_type __tmp = __r ? *__z : *__x; | |
| 224 | *__z = __r ? *__x : *__z; | |
| 225 | __r = __c(__tmp, *__y); | |
| 226 | *__x = __r ? *__x : *__y; | |
| 227 | *__y = __r ? *__y : __tmp; | |
| 228 | } | |
| 229 | ||
| 230 | template <class, class _Compare, class _RandomAccessIterator> | |
| 231 | inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> | |
| 232 | __sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, | |
| 233 | _Compare __c) { | |
| 234 | _VSTD::__cond_swap<_Compare>(__x2, __x3, __c); | |
| 235 | _VSTD::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c); | |
| 236 | } | |
| 237 | ||
| 238 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 239 | inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> | |
| 240 | __sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, | |
| 241 | _Compare __c) { | |
| 242 | std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c); | |
| 243 | } | |
| 244 | ||
| 245 | template <class, class _Compare, class _RandomAccessIterator> | |
| 246 | inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> | |
| 247 | __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, | |
| 248 | _RandomAccessIterator __x4, _Compare __c) { | |
| 249 | _VSTD::__cond_swap<_Compare>(__x1, __x3, __c); | |
| 250 | _VSTD::__cond_swap<_Compare>(__x2, __x4, __c); | |
| 251 | _VSTD::__cond_swap<_Compare>(__x1, __x2, __c); | |
| 252 | _VSTD::__cond_swap<_Compare>(__x3, __x4, __c); | |
| 253 | _VSTD::__cond_swap<_Compare>(__x2, __x3, __c); | |
| 254 | } | |
| 255 | ||
| 256 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 257 | inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> | |
| 258 | __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, | |
| 259 | _RandomAccessIterator __x4, _Compare __c) { | |
| 260 | std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c); | |
| 261 | } | |
| 262 | ||
| 263 | template <class, class _Compare, class _RandomAccessIterator> | |
| 264 | inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> | |
| 265 | __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, | |
| 266 | _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) { | |
| 267 | _VSTD::__cond_swap<_Compare>(__x1, __x2, __c); | |
| 268 | _VSTD::__cond_swap<_Compare>(__x4, __x5, __c); | |
| 269 | _VSTD::__partially_sorted_swap<_Compare>(__x3, __x4, __x5, __c); | |
| 270 | _VSTD::__cond_swap<_Compare>(__x2, __x5, __c); | |
| 271 | _VSTD::__partially_sorted_swap<_Compare>(__x1, __x3, __x4, __c); | |
| 272 | _VSTD::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c); | |
| 273 | } | |
| 274 | ||
| 275 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 276 | inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> | |
| 277 | __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, | |
| 278 | _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) { | |
| 279 | std::__sort5_wrap_policy<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __x5, __c); | |
| 124 | 280 | } |
| 125 | 281 | |
| 126 | 282 | // Assumes size > 0 |
| 127 | template <class _Compare, class _BidirectionalIterator> | |
| 128 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void | |
| 129 | __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) | |
| 130 | { | |
| 131 | _BidirectionalIterator __lm1 = __last; | |
| 132 | for (--__lm1; __first != __lm1; ++__first) | |
| 133 | { | |
| 134 | _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp); | |
| 135 | if (__i != __first) | |
| 136 | swap(*__first, *__i); | |
| 283 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | |
| 284 | _LIBCPP_CONSTEXPR_AFTER_CXX11 void __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, | |
| 285 | _Compare __comp) { | |
| 286 | _BidirectionalIterator __lm1 = __last; | |
| 287 | for (--__lm1; __first != __lm1; ++__first) { | |
| 288 | _BidirectionalIterator __i = std::__min_element<_Compare>(__first, __last, __comp); | |
| 289 | if (__i != __first) | |
| 290 | _IterOps<_AlgPolicy>::iter_swap(__first, __i); | |
| 291 | } | |
| 292 | } | |
| 293 | ||
| 294 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | |
| 295 | void __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { | |
| 296 | using _Ops = _IterOps<_AlgPolicy>; | |
| 297 | ||
| 298 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | |
| 299 | if (__first != __last) { | |
| 300 | _BidirectionalIterator __i = __first; | |
| 301 | for (++__i; __i != __last; ++__i) { | |
| 302 | _BidirectionalIterator __j = __i; | |
| 303 | value_type __t(_Ops::__iter_move(__j)); | |
| 304 | for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j) | |
| 305 | *__j = _Ops::__iter_move(__k); | |
| 306 | *__j = _VSTD::move(__t); | |
| 137 | 307 | } |
| 308 | } | |
| 138 | 309 | } |
| 139 | 310 | |
| 140 | template <class _Compare, class _BidirectionalIterator> | |
| 141 | void | |
| 142 | __insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) | |
| 143 | { | |
| 144 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | |
| 145 | if (__first != __last) | |
| 146 | { | |
| 147 | _BidirectionalIterator __i = __first; | |
| 148 | for (++__i; __i != __last; ++__i) | |
| 149 | { | |
| 150 | _BidirectionalIterator __j = __i; | |
| 151 | value_type __t(_VSTD::move(*__j)); | |
| 152 | for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j) | |
| 153 | *__j = _VSTD::move(*__k); | |
| 154 | *__j = _VSTD::move(__t); | |
| 155 | } | |
| 311 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 312 | void __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 313 | using _Ops = _IterOps<_AlgPolicy>; | |
| 314 | ||
| 315 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 316 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 317 | _RandomAccessIterator __j = __first + difference_type(2); | |
| 318 | std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp); | |
| 319 | for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) { | |
| 320 | if (__comp(*__i, *__j)) { | |
| 321 | value_type __t(_Ops::__iter_move(__i)); | |
| 322 | _RandomAccessIterator __k = __j; | |
| 323 | __j = __i; | |
| 324 | do { | |
| 325 | *__j = _Ops::__iter_move(__k); | |
| 326 | __j = __k; | |
| 327 | } while (__j != __first && __comp(__t, *--__k)); | |
| 328 | *__j = _VSTD::move(__t); | |
| 156 | 329 | } |
| 330 | __j = __i; | |
| 331 | } | |
| 157 | 332 | } |
| 158 | 333 | |
| 159 | template <class _Compare, class _RandomAccessIterator> | |
| 160 | void | |
| 161 | __insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 162 | { | |
| 163 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 164 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 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) | |
| 168 | { | |
| 169 | if (__comp(*__i, *__j)) | |
| 170 | { | |
| 171 | value_type __t(_VSTD::move(*__i)); | |
| 172 | _RandomAccessIterator __k = __j; | |
| 173 | __j = __i; | |
| 174 | do | |
| 175 | { | |
| 176 | *__j = _VSTD::move(*__k); | |
| 177 | __j = __k; | |
| 178 | } while (__j != __first && __comp(__t, *--__k)); | |
| 179 | *__j = _VSTD::move(__t); | |
| 180 | } | |
| 181 | __j = __i; | |
| 334 | template <class _WrappedComp, class _RandomAccessIterator> | |
| 335 | bool __insertion_sort_incomplete( | |
| 336 | _RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) { | |
| 337 | using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>; | |
| 338 | using _AlgPolicy = typename _Unwrap::_AlgPolicy; | |
| 339 | using _Ops = _IterOps<_AlgPolicy>; | |
| 340 | ||
| 341 | using _Compare = typename _Unwrap::_Comp; | |
| 342 | _Compare __comp = _Unwrap::__get_comp(__wrapped_comp); | |
| 343 | ||
| 344 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 345 | switch (__last - __first) { | |
| 346 | case 0: | |
| 347 | case 1: | |
| 348 | return true; | |
| 349 | case 2: | |
| 350 | if (__comp(*--__last, *__first)) | |
| 351 | _IterOps<_AlgPolicy>::iter_swap(__first, __last); | |
| 352 | return true; | |
| 353 | case 3: | |
| 354 | std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp); | |
| 355 | return true; | |
| 356 | case 4: | |
| 357 | std::__sort4_maybe_branchless<_AlgPolicy, _Compare>( | |
| 358 | __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp); | |
| 359 | return true; | |
| 360 | case 5: | |
| 361 | std::__sort5_maybe_branchless<_AlgPolicy, _Compare>( | |
| 362 | __first, __first + difference_type(1), __first + difference_type(2), __first + difference_type(3), | |
| 363 | --__last, __comp); | |
| 364 | return true; | |
| 365 | } | |
| 366 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 367 | _RandomAccessIterator __j = __first + difference_type(2); | |
| 368 | std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), __j, __comp); | |
| 369 | const unsigned __limit = 8; | |
| 370 | unsigned __count = 0; | |
| 371 | for (_RandomAccessIterator __i = __j + difference_type(1); __i != __last; ++__i) { | |
| 372 | if (__comp(*__i, *__j)) { | |
| 373 | value_type __t(_Ops::__iter_move(__i)); | |
| 374 | _RandomAccessIterator __k = __j; | |
| 375 | __j = __i; | |
| 376 | do { | |
| 377 | *__j = _Ops::__iter_move(__k); | |
| 378 | __j = __k; | |
| 379 | } while (__j != __first && __comp(__t, *--__k)); | |
| 380 | *__j = _VSTD::move(__t); | |
| 381 | if (++__count == __limit) | |
| 382 | return ++__i == __last; | |
| 182 | 383 | } |
| 384 | __j = __i; | |
| 385 | } | |
| 386 | return true; | |
| 183 | 387 | } |
| 184 | 388 | |
| 185 | template <class _Compare, class _RandomAccessIterator> | |
| 186 | bool | |
| 187 | __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 188 | { | |
| 189 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 190 | switch (__last - __first) | |
| 191 | { | |
| 389 | template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | |
| 390 | void __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1, | |
| 391 | typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) { | |
| 392 | using _Ops = _IterOps<_AlgPolicy>; | |
| 393 | ||
| 394 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | |
| 395 | if (__first1 != __last1) { | |
| 396 | __destruct_n __d(0); | |
| 397 | unique_ptr<value_type, __destruct_n&> __h(__first2, __d); | |
| 398 | value_type* __last2 = __first2; | |
| 399 | ::new ((void*)__last2) value_type(_Ops::__iter_move(__first1)); | |
| 400 | __d.template __incr<value_type>(); | |
| 401 | for (++__last2; ++__first1 != __last1; ++__last2) { | |
| 402 | value_type* __j2 = __last2; | |
| 403 | value_type* __i2 = __j2; | |
| 404 | if (__comp(*__first1, *--__i2)) { | |
| 405 | ::new ((void*)__j2) value_type(std::move(*__i2)); | |
| 406 | __d.template __incr<value_type>(); | |
| 407 | for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2) | |
| 408 | *__j2 = std::move(*__i2); | |
| 409 | *__j2 = _Ops::__iter_move(__first1); | |
| 410 | } else { | |
| 411 | ::new ((void*)__j2) value_type(_Ops::__iter_move(__first1)); | |
| 412 | __d.template __incr<value_type>(); | |
| 413 | } | |
| 414 | } | |
| 415 | __h.release(); | |
| 416 | } | |
| 417 | } | |
| 418 | ||
| 419 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 420 | void __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, | |
| 421 | typename iterator_traits<_RandomAccessIterator>::difference_type __depth) { | |
| 422 | using _Ops = _IterOps<_AlgPolicy>; | |
| 423 | ||
| 424 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 425 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 426 | const difference_type __limit = | |
| 427 | is_trivially_copy_constructible<value_type>::value && is_trivially_copy_assignable<value_type>::value ? 30 : 6; | |
| 428 | while (true) { | |
| 429 | __restart: | |
| 430 | difference_type __len = __last - __first; | |
| 431 | switch (__len) { | |
| 192 | 432 | case 0: |
| 193 | 433 | case 1: |
| 194 | return true; | |
| 434 | return; | |
| 195 | 435 | case 2: |
| 196 | if (__comp(*--__last, *__first)) | |
| 197 | swap(*__first, *__last); | |
| 198 | return true; | |
| 436 | if (__comp(*--__last, *__first)) | |
| 437 | _IterOps<_AlgPolicy>::iter_swap(__first, __last); | |
| 438 | return; | |
| 199 | 439 | case 3: |
| 200 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp); | |
| 201 | return true; | |
| 440 | std::__sort3_maybe_branchless<_AlgPolicy, _Compare>(__first, __first + difference_type(1), --__last, __comp); | |
| 441 | return; | |
| 202 | 442 | case 4: |
| 203 | _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp); | |
| 204 | return true; | |
| 443 | std::__sort4_maybe_branchless<_AlgPolicy, _Compare>( | |
| 444 | __first, __first + difference_type(1), __first + difference_type(2), --__last, __comp); | |
| 445 | return; | |
| 205 | 446 | case 5: |
| 206 | _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp); | |
| 207 | return true; | |
| 447 | std::__sort5_maybe_branchless<_AlgPolicy, _Compare>( | |
| 448 | __first, __first + difference_type(1), __first + difference_type(2), __first + difference_type(3), | |
| 449 | --__last, __comp); | |
| 450 | return; | |
| 208 | 451 | } |
| 209 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 210 | _RandomAccessIterator __j = __first+difference_type(2); | |
| 211 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp); | |
| 212 | const unsigned __limit = 8; | |
| 213 | unsigned __count = 0; | |
| 214 | for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i) | |
| 215 | { | |
| 216 | if (__comp(*__i, *__j)) | |
| 217 | { | |
| 218 | value_type __t(_VSTD::move(*__i)); | |
| 219 | _RandomAccessIterator __k = __j; | |
| 220 | __j = __i; | |
| 221 | do | |
| 222 | { | |
| 223 | *__j = _VSTD::move(*__k); | |
| 224 | __j = __k; | |
| 225 | } while (__j != __first && __comp(__t, *--__k)); | |
| 226 | *__j = _VSTD::move(__t); | |
| 227 | if (++__count == __limit) | |
| 228 | return ++__i == __last; | |
| 229 | } | |
| 230 | __j = __i; | |
| 452 | if (__len <= __limit) { | |
| 453 | std::__insertion_sort_3<_AlgPolicy, _Compare>(__first, __last, __comp); | |
| 454 | return; | |
| 231 | 455 | } |
| 232 | return true; | |
| 233 | } | |
| 234 | ||
| 235 | template <class _Compare, class _BidirectionalIterator> | |
| 236 | void | |
| 237 | __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1, | |
| 238 | typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) | |
| 239 | { | |
| 240 | typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | |
| 241 | if (__first1 != __last1) | |
| 456 | // __len > 5 | |
| 457 | if (__depth == 0) { | |
| 458 | // Fallback to heap sort as Introsort suggests. | |
| 459 | std::__partial_sort<_AlgPolicy, _Compare>(__first, __last, __last, __comp); | |
| 460 | return; | |
| 461 | } | |
| 462 | --__depth; | |
| 463 | _RandomAccessIterator __m = __first; | |
| 464 | _RandomAccessIterator __lm1 = __last; | |
| 465 | --__lm1; | |
| 466 | unsigned __n_swaps; | |
| 242 | 467 | { |
| 243 | __destruct_n __d(0); | |
| 244 | unique_ptr<value_type, __destruct_n&> __h(__first2, __d); | |
| 245 | value_type* __last2 = __first2; | |
| 246 | ::new ((void*)__last2) value_type(_VSTD::move(*__first1)); | |
| 247 | __d.template __incr<value_type>(); | |
| 248 | for (++__last2; ++__first1 != __last1; ++__last2) | |
| 249 | { | |
| 250 | value_type* __j2 = __last2; | |
| 251 | value_type* __i2 = __j2; | |
| 252 | if (__comp(*__first1, *--__i2)) | |
| 253 | { | |
| 254 | ::new ((void*)__j2) value_type(_VSTD::move(*__i2)); | |
| 255 | __d.template __incr<value_type>(); | |
| 256 | for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2) | |
| 257 | *__j2 = _VSTD::move(*__i2); | |
| 258 | *__j2 = _VSTD::move(*__first1); | |
| 259 | } | |
| 260 | else | |
| 261 | { | |
| 262 | ::new ((void*)__j2) value_type(_VSTD::move(*__first1)); | |
| 263 | __d.template __incr<value_type>(); | |
| 264 | } | |
| 265 | } | |
| 266 | __h.release(); | |
| 468 | difference_type __delta; | |
| 469 | if (__len >= 1000) { | |
| 470 | __delta = __len / 2; | |
| 471 | __m += __delta; | |
| 472 | __delta /= 2; | |
| 473 | __n_swaps = std::__sort5_wrap_policy<_AlgPolicy, _Compare>( | |
| 474 | __first, __first + __delta, __m, __m + __delta, __lm1, __comp); | |
| 475 | } else { | |
| 476 | __delta = __len / 2; | |
| 477 | __m += __delta; | |
| 478 | __n_swaps = std::__sort3<_AlgPolicy, _Compare>(__first, __m, __lm1, __comp); | |
| 479 | } | |
| 267 | 480 | } |
| 268 | } | |
| 269 | ||
| 270 | template <class _Compare, class _RandomAccessIterator> | |
| 271 | void | |
| 272 | __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, | |
| 273 | typename iterator_traits<_RandomAccessIterator>::difference_type __depth) | |
| 274 | { | |
| 275 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 276 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 277 | const difference_type __limit = is_trivially_copy_constructible<value_type>::value && | |
| 278 | is_trivially_copy_assignable<value_type>::value ? 30 : 6; | |
| 279 | while (true) | |
| 481 | // *__m is median | |
| 482 | // partition [__first, __m) < *__m and *__m <= [__m, __last) | |
| 483 | // (this inhibits tossing elements equivalent to __m around unnecessarily) | |
| 484 | _RandomAccessIterator __i = __first; | |
| 485 | _RandomAccessIterator __j = __lm1; | |
| 486 | // j points beyond range to be tested, *__m is known to be <= *__lm1 | |
| 487 | // The search going up is known to be guarded but the search coming down isn't. | |
| 488 | // Prime the downward search with a guard. | |
| 489 | if (!__comp(*__i, *__m)) // if *__first == *__m | |
| 280 | 490 | { |
| 281 | __restart: | |
| 282 | difference_type __len = __last - __first; | |
| 283 | switch (__len) | |
| 284 | { | |
| 285 | case 0: | |
| 286 | case 1: | |
| 287 | return; | |
| 288 | case 2: | |
| 289 | if (__comp(*--__last, *__first)) | |
| 290 | swap(*__first, *__last); | |
| 291 | return; | |
| 292 | case 3: | |
| 293 | _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp); | |
| 294 | return; | |
| 295 | case 4: | |
| 296 | _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp); | |
| 297 | return; | |
| 298 | case 5: | |
| 299 | _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp); | |
| 300 | return; | |
| 301 | } | |
| 302 | if (__len <= __limit) | |
| 303 | { | |
| 304 | _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp); | |
| 305 | return; | |
| 306 | } | |
| 307 | // __len > 5 | |
| 308 | if (__depth == 0) | |
| 309 | { | |
| 310 | // Fallback to heap sort as Introsort suggests. | |
| 311 | _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp); | |
| 312 | return; | |
| 313 | } | |
| 314 | --__depth; | |
| 315 | _RandomAccessIterator __m = __first; | |
| 316 | _RandomAccessIterator __lm1 = __last; | |
| 317 | --__lm1; | |
| 318 | unsigned __n_swaps; | |
| 319 | { | |
| 320 | difference_type __delta; | |
| 321 | if (__len >= 1000) | |
| 322 | { | |
| 323 | __delta = __len/2; | |
| 324 | __m += __delta; | |
| 325 | __delta /= 2; | |
| 326 | __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp); | |
| 327 | } | |
| 328 | else | |
| 329 | { | |
| 330 | __delta = __len/2; | |
| 331 | __m += __delta; | |
| 332 | __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp); | |
| 333 | } | |
| 334 | } | |
| 335 | // *__m is median | |
| 336 | // partition [__first, __m) < *__m and *__m <= [__m, __last) | |
| 337 | // (this inhibits tossing elements equivalent to __m around unnecessarily) | |
| 338 | _RandomAccessIterator __i = __first; | |
| 339 | _RandomAccessIterator __j = __lm1; | |
| 340 | // j points beyond range to be tested, *__m is known to be <= *__lm1 | |
| 341 | // The search going up is known to be guarded but the search coming down isn't. | |
| 342 | // Prime the downward search with a guard. | |
| 343 | if (!__comp(*__i, *__m)) // if *__first == *__m | |
| 344 | { | |
| 345 | // *__first == *__m, *__first doesn't go in first part | |
| 346 | // manually guard downward moving __j against __i | |
| 347 | while (true) | |
| 348 | { | |
| 349 | if (__i == --__j) | |
| 350 | { | |
| 351 | // *__first == *__m, *__m <= all other elements | |
| 352 | // Parition instead into [__first, __i) == *__first and *__first < [__i, __last) | |
| 353 | ++__i; // __first + 1 | |
| 354 | __j = __last; | |
| 355 | if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1) | |
| 356 | { | |
| 357 | while (true) | |
| 358 | { | |
| 359 | if (__i == __j) | |
| 360 | return; // [__first, __last) all equivalent elements | |
| 361 | if (__comp(*__first, *__i)) | |
| 362 | { | |
| 363 | swap(*__i, *__j); | |
| 364 | ++__n_swaps; | |
| 365 | ++__i; | |
| 366 | break; | |
| 367 | } | |
| 368 | ++__i; | |
| 369 | } | |
| 370 | } | |
| 371 | // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1 | |
| 372 | if (__i == __j) | |
| 373 | return; | |
| 374 | while (true) | |
| 375 | { | |
| 376 | while (!__comp(*__first, *__i)) | |
| 377 | ++__i; | |
| 378 | while (__comp(*__first, *--__j)) | |
| 379 | ; | |
| 380 | if (__i >= __j) | |
| 381 | break; | |
| 382 | swap(*__i, *__j); | |
| 383 | ++__n_swaps; | |
| 384 | ++__i; | |
| 385 | } | |
| 386 | // [__first, __i) == *__first and *__first < [__i, __last) | |
| 387 | // The first part is sorted, sort the second part | |
| 388 | // _VSTD::__sort<_Compare>(__i, __last, __comp); | |
| 389 | __first = __i; | |
| 390 | goto __restart; | |
| 391 | } | |
| 392 | if (__comp(*__j, *__m)) | |
| 393 | { | |
| 394 | swap(*__i, *__j); | |
| 395 | ++__n_swaps; | |
| 396 | break; // found guard for downward moving __j, now use unguarded partition | |
| 397 | } | |
| 398 | } | |
| 399 | } | |
| 400 | // It is known that *__i < *__m | |
| 401 | ++__i; | |
| 402 | // j points beyond range to be tested, *__m is known to be <= *__lm1 | |
| 403 | // if not yet partitioned... | |
| 404 | if (__i < __j) | |
| 405 | { | |
| 406 | // known that *(__i - 1) < *__m | |
| 407 | // known that __i <= __m | |
| 408 | while (true) | |
| 409 | { | |
| 410 | // __m still guards upward moving __i | |
| 411 | while (__comp(*__i, *__m)) | |
| 412 | ++__i; | |
| 413 | // It is now known that a guard exists for downward moving __j | |
| 414 | while (!__comp(*--__j, *__m)) | |
| 415 | ; | |
| 416 | if (__i > __j) | |
| 417 | break; | |
| 418 | swap(*__i, *__j); | |
| 491 | // *__first == *__m, *__first doesn't go in first part | |
| 492 | // manually guard downward moving __j against __i | |
| 493 | while (true) { | |
| 494 | if (__i == --__j) { | |
| 495 | // *__first == *__m, *__m <= all other elements | |
| 496 | // Parition instead into [__first, __i) == *__first and *__first < [__i, __last) | |
| 497 | ++__i; // __first + 1 | |
| 498 | __j = __last; | |
| 499 | if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1) | |
| 500 | { | |
| 501 | while (true) { | |
| 502 | if (__i == __j) | |
| 503 | return; // [__first, __last) all equivalent elements | |
| 504 | if (__comp(*__first, *__i)) { | |
| 505 | _Ops::iter_swap(__i, __j); | |
| 419 | 506 | ++__n_swaps; |
| 420 | // It is known that __m != __j | |
| 421 | // If __m just moved, follow it | |
| 422 | if (__m == __i) | |
| 423 | __m = __j; | |
| 424 | 507 | ++__i; |
| 508 | break; | |
| 509 | } | |
| 510 | ++__i; | |
| 425 | 511 | } |
| 426 | } | |
| 427 | // [__first, __i) < *__m and *__m <= [__i, __last) | |
| 428 | if (__i != __m && __comp(*__m, *__i)) | |
| 429 | { | |
| 430 | swap(*__i, *__m); | |
| 512 | } | |
| 513 | // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1 | |
| 514 | if (__i == __j) | |
| 515 | return; | |
| 516 | while (true) { | |
| 517 | while (!__comp(*__first, *__i)) | |
| 518 | ++__i; | |
| 519 | while (__comp(*__first, *--__j)) | |
| 520 | ; | |
| 521 | if (__i >= __j) | |
| 522 | break; | |
| 523 | _Ops::iter_swap(__i, __j); | |
| 431 | 524 | ++__n_swaps; |
| 525 | ++__i; | |
| 526 | } | |
| 527 | // [__first, __i) == *__first and *__first < [__i, __last) | |
| 528 | // The first part is sorted, sort the second part | |
| 529 | // _VSTD::__sort<_Compare>(__i, __last, __comp); | |
| 530 | __first = __i; | |
| 531 | goto __restart; | |
| 432 | 532 | } |
| 433 | // [__first, __i) < *__i and *__i <= [__i+1, __last) | |
| 434 | // If we were given a perfect partition, see if insertion sort is quick... | |
| 435 | if (__n_swaps == 0) | |
| 436 | { | |
| 437 | bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp); | |
| 438 | if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+difference_type(1), __last, __comp)) | |
| 439 | { | |
| 440 | if (__fs) | |
| 441 | return; | |
| 442 | __last = __i; | |
| 443 | continue; | |
| 444 | } | |
| 445 | else | |
| 446 | { | |
| 447 | if (__fs) | |
| 448 | { | |
| 449 | __first = ++__i; | |
| 450 | continue; | |
| 451 | } | |
| 452 | } | |
| 533 | if (__comp(*__j, *__m)) { | |
| 534 | _Ops::iter_swap(__i, __j); | |
| 535 | ++__n_swaps; | |
| 536 | break; // found guard for downward moving __j, now use unguarded partition | |
| 453 | 537 | } |
| 454 | // sort smaller range with recursive call and larger with tail recursion elimination | |
| 455 | if (__i - __first < __last - __i) | |
| 456 | { | |
| 457 | _VSTD::__introsort<_Compare>(__first, __i, __comp, __depth); | |
| 538 | } | |
| 539 | } | |
| 540 | // It is known that *__i < *__m | |
| 541 | ++__i; | |
| 542 | // j points beyond range to be tested, *__m is known to be <= *__lm1 | |
| 543 | // if not yet partitioned... | |
| 544 | if (__i < __j) { | |
| 545 | // known that *(__i - 1) < *__m | |
| 546 | // known that __i <= __m | |
| 547 | while (true) { | |
| 548 | // __m still guards upward moving __i | |
| 549 | while (__comp(*__i, *__m)) | |
| 550 | ++__i; | |
| 551 | // It is now known that a guard exists for downward moving __j | |
| 552 | while (!__comp(*--__j, *__m)) | |
| 553 | ; | |
| 554 | if (__i > __j) | |
| 555 | break; | |
| 556 | _Ops::iter_swap(__i, __j); | |
| 557 | ++__n_swaps; | |
| 558 | // It is known that __m != __j | |
| 559 | // If __m just moved, follow it | |
| 560 | if (__m == __i) | |
| 561 | __m = __j; | |
| 562 | ++__i; | |
| 563 | } | |
| 564 | } | |
| 565 | // [__first, __i) < *__m and *__m <= [__i, __last) | |
| 566 | if (__i != __m && __comp(*__m, *__i)) { | |
| 567 | _Ops::iter_swap(__i, __m); | |
| 568 | ++__n_swaps; | |
| 569 | } | |
| 570 | // [__first, __i) < *__i and *__i <= [__i+1, __last) | |
| 571 | // If we were given a perfect partition, see if insertion sort is quick... | |
| 572 | if (__n_swaps == 0) { | |
| 573 | using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Compare>::type; | |
| 574 | _WrappedComp __wrapped_comp(__comp); | |
| 575 | bool __fs = std::__insertion_sort_incomplete<_WrappedComp>(__first, __i, __wrapped_comp); | |
| 576 | if (std::__insertion_sort_incomplete<_WrappedComp>(__i + difference_type(1), __last, __wrapped_comp)) { | |
| 577 | if (__fs) | |
| 578 | return; | |
| 579 | __last = __i; | |
| 580 | continue; | |
| 581 | } else { | |
| 582 | if (__fs) { | |
| 458 | 583 | __first = ++__i; |
| 584 | continue; | |
| 459 | 585 | } |
| 460 | else | |
| 461 | { | |
| 462 | _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth); | |
| 463 | __last = __i; | |
| 464 | } | |
| 586 | } | |
| 465 | 587 | } |
| 588 | // sort smaller range with recursive call and larger with tail recursion elimination | |
| 589 | if (__i - __first < __last - __i) { | |
| 590 | std::__introsort<_AlgPolicy, _Compare>(__first, __i, __comp, __depth); | |
| 591 | __first = ++__i; | |
| 592 | } else { | |
| 593 | std::__introsort<_AlgPolicy, _Compare>(__i + difference_type(1), __last, __comp, __depth); | |
| 594 | __last = __i; | |
| 595 | } | |
| 596 | } | |
| 466 | 597 | } |
| 467 | 598 | |
| 468 | 599 | template <typename _Number> |
| 469 | 600 | inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) { |
| 601 | if (__n == 0) | |
| 602 | return 0; | |
| 603 | if (sizeof(__n) <= sizeof(unsigned)) | |
| 604 | return sizeof(unsigned) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned>(__n)); | |
| 605 | if (sizeof(__n) <= sizeof(unsigned long)) | |
| 606 | return sizeof(unsigned long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long>(__n)); | |
| 607 | if (sizeof(__n) <= sizeof(unsigned long long)) | |
| 608 | return sizeof(unsigned long long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long long>(__n)); | |
| 609 | ||
| 470 | 610 | _Number __log2 = 0; |
| 471 | 611 | while (__n > 1) { |
| 472 | 612 | __log2++; |
| ... | ... | @@ -475,80 +615,89 @@ inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) { |
| 475 | 615 | return __log2; |
| 476 | 616 | } |
| 477 | 617 | |
| 478 | template <class _Compare, class _RandomAccessIterator> | |
| 479 | void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 618 | template <class _WrappedComp, class _RandomAccessIterator> | |
| 619 | void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _WrappedComp __wrapped_comp) { | |
| 480 | 620 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; |
| 481 | 621 | difference_type __depth_limit = 2 * __log2i(__last - __first); |
| 482 | _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit); | |
| 622 | ||
| 623 | using _Unwrap = _UnwrapAlgPolicy<_WrappedComp>; | |
| 624 | using _AlgPolicy = typename _Unwrap::_AlgPolicy; | |
| 625 | using _Compare = typename _Unwrap::_Comp; | |
| 626 | _Compare __comp = _Unwrap::__get_comp(__wrapped_comp); | |
| 627 | std::__introsort<_AlgPolicy, _Compare>(__first, __last, __comp, __depth_limit); | |
| 483 | 628 | } |
| 484 | 629 | |
| 485 | 630 | template <class _Compare, class _Tp> |
| 486 | inline _LIBCPP_INLINE_VISIBILITY | |
| 487 | void | |
| 488 | __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) | |
| 489 | { | |
| 490 | __less<uintptr_t> __comp; | |
| 491 | _VSTD::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp); | |
| 631 | inline _LIBCPP_INLINE_VISIBILITY void __sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) { | |
| 632 | __less<uintptr_t> __comp; | |
| 633 | std::__sort<__less<uintptr_t>&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp); | |
| 492 | 634 | } |
| 493 | 635 | |
| 494 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&)) | |
| 636 | extern template _LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&); | |
| 495 | 637 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 496 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) | |
| 638 | extern template _LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); | |
| 497 | 639 | #endif |
| 498 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) | |
| 499 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) | |
| 500 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&)) | |
| 501 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) | |
| 502 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&)) | |
| 503 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) | |
| 504 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&)) | |
| 505 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) | |
| 506 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) | |
| 507 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) | |
| 508 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&)) | |
| 509 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&)) | |
| 510 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) | |
| 511 | ||
| 512 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&)) | |
| 640 | extern template _LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); | |
| 641 | extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); | |
| 642 | extern template _LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&); | |
| 643 | extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); | |
| 644 | extern template _LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&); | |
| 645 | extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); | |
| 646 | extern template _LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&); | |
| 647 | extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); | |
| 648 | extern template _LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); | |
| 649 | extern template _LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); | |
| 650 | extern template _LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&); | |
| 651 | extern template _LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&); | |
| 652 | extern template _LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); | |
| 653 | ||
| 654 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&); | |
| 513 | 655 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 514 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) | |
| 656 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); | |
| 515 | 657 | #endif |
| 516 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) | |
| 517 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) | |
| 518 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&)) | |
| 519 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) | |
| 520 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&)) | |
| 521 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) | |
| 522 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&)) | |
| 523 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) | |
| 524 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) | |
| 525 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) | |
| 526 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&)) | |
| 527 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&)) | |
| 528 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) | |
| 529 | ||
| 530 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&)) | |
| 531 | ||
| 532 | template <class _RandomAccessIterator, class _Compare> | |
| 533 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 534 | void | |
| 535 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 536 | { | |
| 537 | _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last); | |
| 538 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 658 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&); | |
| 659 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&); | |
| 660 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&); | |
| 661 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&); | |
| 662 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&); | |
| 663 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&); | |
| 664 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&); | |
| 665 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&); | |
| 666 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&); | |
| 667 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&); | |
| 668 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&); | |
| 669 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&); | |
| 670 | extern template _LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&); | |
| 671 | ||
| 672 | extern template _LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&); | |
| 673 | ||
| 674 | template <class _AlgPolicy, class _RandomAccessIterator, class _Comp> | |
| 675 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 676 | void __sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) { | |
| 677 | std::__debug_randomize_range<_AlgPolicy>(__first, __last); | |
| 678 | ||
| 679 | using _Comp_ref = typename __comp_ref_type<_Comp>::type; | |
| 539 | 680 | if (__libcpp_is_constant_evaluated()) { |
| 540 | _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp)); | |
| 681 | std::__partial_sort<_AlgPolicy>(__first, __last, __last, __comp); | |
| 682 | ||
| 541 | 683 | } else { |
| 542 | _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp)); | |
| 684 | using _WrappedComp = typename _WrapAlgPolicy<_AlgPolicy, _Comp_ref>::type; | |
| 685 | _Comp_ref __comp_ref(__comp); | |
| 686 | _WrappedComp __wrapped_comp(__comp_ref); | |
| 687 | std::__sort<_WrappedComp>(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __wrapped_comp); | |
| 543 | 688 | } |
| 544 | 689 | } |
| 545 | 690 | |
| 691 | template <class _RandomAccessIterator, class _Comp> | |
| 692 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 693 | void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { | |
| 694 | std::__sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp); | |
| 695 | } | |
| 696 | ||
| 546 | 697 | template <class _RandomAccessIterator> |
| 547 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 548 | void | |
| 549 | sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 550 | { | |
| 551 | _VSTD::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 698 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 699 | void sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 700 | std::sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 552 | 701 | } |
| 553 | 702 | |
| 554 | 703 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/sort_heap.h+23-20| ... | ... | @@ -11,41 +11,44 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__algorithm/pop_heap.h> |
| 15 | 16 | #include <__config> |
| 16 | 17 | #include <__iterator/iterator_traits.h> |
| 17 | #include <type_traits> // swap | |
| 18 | #include <__utility/move.h> | |
| 19 | #include <type_traits> | |
| 18 | 20 | |
| 19 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 21 | 23 | #endif |
| 22 | 24 | |
| 23 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 26 | |
| 25 | template <class _Compare, class _RandomAccessIterator> | |
| 26 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 27 | __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 28 | { | |
| 29 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 30 | for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n) | |
| 31 | _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n); | |
| 27 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 28 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 29 | void __sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) { | |
| 30 | using _CompRef = typename __comp_ref_type<_Compare>::type; | |
| 31 | _CompRef __comp_ref = __comp; | |
| 32 | ||
| 33 | using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; | |
| 34 | for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n) | |
| 35 | std::__pop_heap<_AlgPolicy>(__first, __last, __comp_ref, __n); | |
| 32 | 36 | } |
| 33 | 37 | |
| 34 | 38 | template <class _RandomAccessIterator, class _Compare> |
| 35 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 36 | void | |
| 37 | sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 38 | { | |
| 39 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 40 | _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp); | |
| 39 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 40 | void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 41 | static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible."); | |
| 42 | static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable."); | |
| 43 | ||
| 44 | std::__sort_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp); | |
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | template <class _RandomAccessIterator> |
| 44 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 45 | void | |
| 46 | sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 47 | { | |
| 48 | _VSTD::sort_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 48 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 49 | void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 50 | std::sort_heap(std::move(__first), std::move(__last), | |
| 51 | __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 49 | 52 | } |
| 50 | 53 | |
| 51 | 54 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/stable_partition.h+67-38| ... | ... | @@ -9,23 +9,28 @@ |
| 9 | 9 | #ifndef _LIBCPP___ALGORITHM_STABLE_PARTITION_H |
| 10 | 10 | #define _LIBCPP___ALGORITHM_STABLE_PARTITION_H |
| 11 | 11 | |
| 12 | #include <__algorithm/iterator_operations.h> | |
| 12 | 13 | #include <__algorithm/rotate.h> |
| 13 | 14 | #include <__config> |
| 15 | #include <__iterator/advance.h> | |
| 16 | #include <__iterator/distance.h> | |
| 14 | 17 | #include <__iterator/iterator_traits.h> |
| 15 | #include <__utility/swap.h> | |
| 16 | 18 | #include <memory> |
| 19 | #include <type_traits> | |
| 17 | 20 | |
| 18 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 20 | 23 | #endif |
| 21 | 24 | |
| 22 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 26 | |
| 24 | template <class _Predicate, class _ForwardIterator, class _Distance, class _Pair> | |
| 27 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair> | |
| 25 | 28 | _ForwardIterator |
| 26 | __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, | |
| 29 | __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, | |
| 27 | 30 | _Distance __len, _Pair __p, forward_iterator_tag __fit) |
| 28 | 31 | { |
| 32 | using _Ops = _IterOps<_AlgPolicy>; | |
| 33 | ||
| 29 | 34 | // *__first is known to be false |
| 30 | 35 | // __len >= 1 |
| 31 | 36 | if (__len == 1) |
| ... | ... | @@ -35,7 +40,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 35 | 40 | _ForwardIterator __m = __first; |
| 36 | 41 | if (__pred(*++__m)) |
| 37 | 42 | { |
| 38 | swap(*__first, *__m); | |
| 43 | _Ops::iter_swap(__first, __m); | |
| 39 | 44 | return __m; |
| 40 | 45 | } |
| 41 | 46 | return __first; |
| ... | ... | @@ -48,7 +53,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 48 | 53 | // Move the falses into the temporary buffer, and the trues to the front of the line |
| 49 | 54 | // Update __first to always point to the end of the trues |
| 50 | 55 | value_type* __t = __p.first; |
| 51 | ::new ((void*)__t) value_type(_VSTD::move(*__first)); | |
| 56 | ::new ((void*)__t) value_type(_Ops::__iter_move(__first)); | |
| 52 | 57 | __d.template __incr<value_type>(); |
| 53 | 58 | ++__t; |
| 54 | 59 | _ForwardIterator __i = __first; |
| ... | ... | @@ -56,12 +61,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 56 | 61 | { |
| 57 | 62 | if (__pred(*__i)) |
| 58 | 63 | { |
| 59 | *__first = _VSTD::move(*__i); | |
| 64 | *__first = _Ops::__iter_move(__i); | |
| 60 | 65 | ++__first; |
| 61 | 66 | } |
| 62 | 67 | else |
| 63 | 68 | { |
| 64 | ::new ((void*)__t) value_type(_VSTD::move(*__i)); | |
| 69 | ::new ((void*)__t) value_type(_Ops::__iter_move(__i)); | |
| 65 | 70 | __d.template __incr<value_type>(); |
| 66 | 71 | ++__t; |
| 67 | 72 | } |
| ... | ... | @@ -70,7 +75,7 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 70 | 75 | // Move falses back into range, but don't mess up __first which points to first false |
| 71 | 76 | __i = __first; |
| 72 | 77 | for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i) |
| 73 | *__i = _VSTD::move(*__t2); | |
| 78 | *__i = _Ops::__iter_move(__t2); | |
| 74 | 79 | // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer |
| 75 | 80 | return __first; |
| 76 | 81 | } |
| ... | ... | @@ -78,11 +83,12 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 78 | 83 | // __len >= 3 |
| 79 | 84 | _ForwardIterator __m = __first; |
| 80 | 85 | _Distance __len2 = __len / 2; // __len2 >= 2 |
| 81 | _VSTD::advance(__m, __len2); | |
| 86 | _Ops::advance(__m, __len2); | |
| 82 | 87 | // recurse on [__first, __m), *__first know to be false |
| 83 | 88 | // F????????????????? |
| 84 | 89 | // f m l |
| 85 | _ForwardIterator __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m, __pred, __len2, __p, __fit); | |
| 90 | _ForwardIterator __first_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>( | |
| 91 | __first, __m, __pred, __len2, __p, __fit); | |
| 86 | 92 | // TTTFFFFF?????????? |
| 87 | 93 | // f ff m l |
| 88 | 94 | // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true |
| ... | ... | @@ -97,18 +103,19 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 97 | 103 | } |
| 98 | 104 | // TTTFFFFFTTTF?????? |
| 99 | 105 | // f ff m m1 l |
| 100 | __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __fit); | |
| 106 | __second_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>( | |
| 107 | __m1, __last, __pred, __len_half, __p, __fit); | |
| 101 | 108 | __second_half_done: |
| 102 | 109 | // TTTFFFFFTTTTTFFFFF |
| 103 | 110 | // f ff m sf l |
| 104 | return _VSTD::rotate(__first_false, __m, __second_false); | |
| 111 | return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __fit); | |
| 105 | 112 | // TTTTTTTTFFFFFFFFFF |
| 106 | 113 | // | |
| 107 | 114 | } |
| 108 | 115 | |
| 109 | template <class _Predicate, class _ForwardIterator> | |
| 116 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator> | |
| 110 | 117 | _ForwardIterator |
| 111 | __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, | |
| 118 | __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, | |
| 112 | 119 | forward_iterator_tag) |
| 113 | 120 | { |
| 114 | 121 | const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment |
| ... | ... | @@ -125,28 +132,34 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate |
| 125 | 132 | // *__first is known to be false |
| 126 | 133 | typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; |
| 127 | 134 | typedef typename iterator_traits<_ForwardIterator>::value_type value_type; |
| 128 | difference_type __len = _VSTD::distance(__first, __last); | |
| 135 | difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last); | |
| 129 | 136 | pair<value_type*, ptrdiff_t> __p(0, 0); |
| 130 | 137 | unique_ptr<value_type, __return_temporary_buffer> __h; |
| 131 | 138 | if (__len >= __alloc_limit) |
| 132 | 139 | { |
| 140 | // TODO: Remove the use of std::get_temporary_buffer | |
| 141 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 133 | 142 | __p = _VSTD::get_temporary_buffer<value_type>(__len); |
| 143 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 134 | 144 | __h.reset(__p.first); |
| 135 | 145 | } |
| 136 | return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag()); | |
| 146 | return std::__stable_partition_impl<_AlgPolicy, _Predicate&>( | |
| 147 | std::move(__first), std::move(__last), __pred, __len, __p, forward_iterator_tag()); | |
| 137 | 148 | } |
| 138 | 149 | |
| 139 | template <class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair> | |
| 150 | template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair> | |
| 140 | 151 | _BidirectionalIterator |
| 141 | __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, | |
| 152 | __stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, | |
| 142 | 153 | _Distance __len, _Pair __p, bidirectional_iterator_tag __bit) |
| 143 | 154 | { |
| 155 | using _Ops = _IterOps<_AlgPolicy>; | |
| 156 | ||
| 144 | 157 | // *__first is known to be false |
| 145 | 158 | // *__last is known to be true |
| 146 | 159 | // __len >= 2 |
| 147 | 160 | if (__len == 2) |
| 148 | 161 | { |
| 149 | swap(*__first, *__last); | |
| 162 | _Ops::iter_swap(__first, __last); | |
| 150 | 163 | return __last; |
| 151 | 164 | } |
| 152 | 165 | if (__len == 3) |
| ... | ... | @@ -154,12 +167,12 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 154 | 167 | _BidirectionalIterator __m = __first; |
| 155 | 168 | if (__pred(*++__m)) |
| 156 | 169 | { |
| 157 | swap(*__first, *__m); | |
| 158 | swap(*__m, *__last); | |
| 170 | _Ops::iter_swap(__first, __m); | |
| 171 | _Ops::iter_swap(__m, __last); | |
| 159 | 172 | return __last; |
| 160 | 173 | } |
| 161 | swap(*__m, *__last); | |
| 162 | swap(*__first, *__m); | |
| 174 | _Ops::iter_swap(__m, __last); | |
| 175 | _Ops::iter_swap(__first, __m); | |
| 163 | 176 | return __m; |
| 164 | 177 | } |
| 165 | 178 | if (__len <= __p.second) |
| ... | ... | @@ -170,7 +183,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 170 | 183 | // Move the falses into the temporary buffer, and the trues to the front of the line |
| 171 | 184 | // Update __first to always point to the end of the trues |
| 172 | 185 | value_type* __t = __p.first; |
| 173 | ::new ((void*)__t) value_type(_VSTD::move(*__first)); | |
| 186 | ::new ((void*)__t) value_type(_Ops::__iter_move(__first)); | |
| 174 | 187 | __d.template __incr<value_type>(); |
| 175 | 188 | ++__t; |
| 176 | 189 | _BidirectionalIterator __i = __first; |
| ... | ... | @@ -178,23 +191,23 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 178 | 191 | { |
| 179 | 192 | if (__pred(*__i)) |
| 180 | 193 | { |
| 181 | *__first = _VSTD::move(*__i); | |
| 194 | *__first = _Ops::__iter_move(__i); | |
| 182 | 195 | ++__first; |
| 183 | 196 | } |
| 184 | 197 | else |
| 185 | 198 | { |
| 186 | ::new ((void*)__t) value_type(_VSTD::move(*__i)); | |
| 199 | ::new ((void*)__t) value_type(_Ops::__iter_move(__i)); | |
| 187 | 200 | __d.template __incr<value_type>(); |
| 188 | 201 | ++__t; |
| 189 | 202 | } |
| 190 | 203 | } |
| 191 | 204 | // move *__last, known to be true |
| 192 | *__first = _VSTD::move(*__i); | |
| 205 | *__first = _Ops::__iter_move(__i); | |
| 193 | 206 | __i = ++__first; |
| 194 | 207 | // All trues now at start of range, all falses in buffer |
| 195 | 208 | // Move falses back into range, but don't mess up __first which points to first false |
| 196 | 209 | for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i) |
| 197 | *__i = _VSTD::move(*__t2); | |
| 210 | *__i = _Ops::__iter_move(__t2); | |
| 198 | 211 | // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer |
| 199 | 212 | return __first; |
| 200 | 213 | } |
| ... | ... | @@ -202,7 +215,7 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 202 | 215 | // __len >= 4 |
| 203 | 216 | _BidirectionalIterator __m = __first; |
| 204 | 217 | _Distance __len2 = __len / 2; // __len2 >= 2 |
| 205 | _VSTD::advance(__m, __len2); | |
| 218 | _Ops::advance(__m, __len2); | |
| 206 | 219 | // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false |
| 207 | 220 | // F????????????????T |
| 208 | 221 | // f m l |
| ... | ... | @@ -217,7 +230,8 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 217 | 230 | } |
| 218 | 231 | // F???TFFF?????????T |
| 219 | 232 | // f m1 m l |
| 220 | __first_false = _VSTD::__stable_partition<_Predicate&>(__first, __m1, __pred, __len_half, __p, __bit); | |
| 233 | __first_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>( | |
| 234 | __first, __m1, __pred, __len_half, __p, __bit); | |
| 221 | 235 | __first_half_done: |
| 222 | 236 | // TTTFFFFF?????????T |
| 223 | 237 | // f ff m l |
| ... | ... | @@ -234,18 +248,19 @@ __first_half_done: |
| 234 | 248 | } |
| 235 | 249 | // TTTFFFFFTTTF?????T |
| 236 | 250 | // f ff m m1 l |
| 237 | __second_false = _VSTD::__stable_partition<_Predicate&>(__m1, __last, __pred, __len_half, __p, __bit); | |
| 251 | __second_false = std::__stable_partition_impl<_AlgPolicy, _Predicate&>( | |
| 252 | __m1, __last, __pred, __len_half, __p, __bit); | |
| 238 | 253 | __second_half_done: |
| 239 | 254 | // TTTFFFFFTTTTTFFFFF |
| 240 | 255 | // f ff m sf l |
| 241 | return _VSTD::rotate(__first_false, __m, __second_false); | |
| 256 | return std::__rotate<_AlgPolicy>(__first_false, __m, __second_false, __bit); | |
| 242 | 257 | // TTTTTTTTFFFFFFFFFF |
| 243 | 258 | // | |
| 244 | 259 | } |
| 245 | 260 | |
| 246 | template <class _Predicate, class _BidirectionalIterator> | |
| 261 | template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator> | |
| 247 | 262 | _BidirectionalIterator |
| 248 | __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, | |
| 263 | __stable_partition_impl(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, | |
| 249 | 264 | bidirectional_iterator_tag) |
| 250 | 265 | { |
| 251 | 266 | typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; |
| ... | ... | @@ -271,15 +286,27 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last |
| 271 | 286 | // *__first is known to be false |
| 272 | 287 | // *__last is known to be true |
| 273 | 288 | // __len >= 2 |
| 274 | difference_type __len = _VSTD::distance(__first, __last) + 1; | |
| 289 | difference_type __len = _IterOps<_AlgPolicy>::distance(__first, __last) + 1; | |
| 275 | 290 | pair<value_type*, ptrdiff_t> __p(0, 0); |
| 276 | 291 | unique_ptr<value_type, __return_temporary_buffer> __h; |
| 277 | 292 | if (__len >= __alloc_limit) |
| 278 | 293 | { |
| 294 | // TODO: Remove the use of std::get_temporary_buffer | |
| 295 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 279 | 296 | __p = _VSTD::get_temporary_buffer<value_type>(__len); |
| 297 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 280 | 298 | __h.reset(__p.first); |
| 281 | 299 | } |
| 282 | return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); | |
| 300 | return std::__stable_partition_impl<_AlgPolicy, _Predicate&>( | |
| 301 | std::move(__first), std::move(__last), __pred, __len, __p, bidirectional_iterator_tag()); | |
| 302 | } | |
| 303 | ||
| 304 | template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory> | |
| 305 | _LIBCPP_HIDE_FROM_ABI | |
| 306 | _ForwardIterator __stable_partition( | |
| 307 | _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) { | |
| 308 | return std::__stable_partition_impl<_AlgPolicy, __uncvref_t<_Predicate>&>( | |
| 309 | std::move(__first), std::move(__last), __pred, __iter_category); | |
| 283 | 310 | } |
| 284 | 311 | |
| 285 | 312 | template <class _ForwardIterator, class _Predicate> |
| ... | ... | @@ -287,7 +314,9 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 287 | 314 | _ForwardIterator |
| 288 | 315 | stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) |
| 289 | 316 | { |
| 290 | return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); | |
| 317 | using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category; | |
| 318 | return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>( | |
| 319 | std::move(__first), std::move(__last), __pred, _IterCategory()); | |
| 291 | 320 | } |
| 292 | 321 | |
| 293 | 322 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/stable_sort.h+67-53| ... | ... | @@ -12,25 +12,28 @@ |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/comp_ref_type.h> |
| 14 | 14 | #include <__algorithm/inplace_merge.h> |
| 15 | #include <__algorithm/iterator_operations.h> | |
| 15 | 16 | #include <__algorithm/sort.h> |
| 16 | 17 | #include <__config> |
| 17 | 18 | #include <__iterator/iterator_traits.h> |
| 18 | #include <__utility/swap.h> | |
| 19 | #include <__utility/move.h> | |
| 19 | 20 | #include <memory> |
| 20 | 21 | #include <type_traits> |
| 21 | 22 | |
| 22 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 24 | 25 | #endif |
| 25 | 26 | |
| 26 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 28 | |
| 28 | template <class _Compare, class _InputIterator1, class _InputIterator2> | |
| 29 | template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2> | |
| 29 | 30 | void |
| 30 | 31 | __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1, |
| 31 | 32 | _InputIterator2 __first2, _InputIterator2 __last2, |
| 32 | 33 | typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp) |
| 33 | 34 | { |
| 35 | using _Ops = _IterOps<_AlgPolicy>; | |
| 36 | ||
| 34 | 37 | typedef typename iterator_traits<_InputIterator1>::value_type value_type; |
| 35 | 38 | __destruct_n __d(0); |
| 36 | 39 | unique_ptr<value_type, __destruct_n&> __h(__result, __d); |
| ... | ... | @@ -39,111 +42,115 @@ __merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1, |
| 39 | 42 | if (__first1 == __last1) |
| 40 | 43 | { |
| 41 | 44 | for (; __first2 != __last2; ++__first2, (void) ++__result, __d.template __incr<value_type>()) |
| 42 | ::new ((void*)__result) value_type(_VSTD::move(*__first2)); | |
| 45 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first2)); | |
| 43 | 46 | __h.release(); |
| 44 | 47 | return; |
| 45 | 48 | } |
| 46 | 49 | if (__first2 == __last2) |
| 47 | 50 | { |
| 48 | 51 | for (; __first1 != __last1; ++__first1, (void) ++__result, __d.template __incr<value_type>()) |
| 49 | ::new ((void*)__result) value_type(_VSTD::move(*__first1)); | |
| 52 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first1)); | |
| 50 | 53 | __h.release(); |
| 51 | 54 | return; |
| 52 | 55 | } |
| 53 | 56 | if (__comp(*__first2, *__first1)) |
| 54 | 57 | { |
| 55 | ::new ((void*)__result) value_type(_VSTD::move(*__first2)); | |
| 58 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first2)); | |
| 56 | 59 | __d.template __incr<value_type>(); |
| 57 | 60 | ++__first2; |
| 58 | 61 | } |
| 59 | 62 | else |
| 60 | 63 | { |
| 61 | ::new ((void*)__result) value_type(_VSTD::move(*__first1)); | |
| 64 | ::new ((void*)__result) value_type(_Ops::__iter_move(__first1)); | |
| 62 | 65 | __d.template __incr<value_type>(); |
| 63 | 66 | ++__first1; |
| 64 | 67 | } |
| 65 | 68 | } |
| 66 | 69 | } |
| 67 | 70 | |
| 68 | template <class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> | |
| 71 | template <class _AlgPolicy, class _Compare, class _InputIterator1, class _InputIterator2, class _OutputIterator> | |
| 69 | 72 | void |
| 70 | 73 | __merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1, |
| 71 | 74 | _InputIterator2 __first2, _InputIterator2 __last2, |
| 72 | 75 | _OutputIterator __result, _Compare __comp) |
| 73 | 76 | { |
| 77 | using _Ops = _IterOps<_AlgPolicy>; | |
| 78 | ||
| 74 | 79 | for (; __first1 != __last1; ++__result) |
| 75 | 80 | { |
| 76 | 81 | if (__first2 == __last2) |
| 77 | 82 | { |
| 78 | 83 | for (; __first1 != __last1; ++__first1, (void) ++__result) |
| 79 | *__result = _VSTD::move(*__first1); | |
| 84 | *__result = _Ops::__iter_move(__first1); | |
| 80 | 85 | return; |
| 81 | 86 | } |
| 82 | 87 | if (__comp(*__first2, *__first1)) |
| 83 | 88 | { |
| 84 | *__result = _VSTD::move(*__first2); | |
| 89 | *__result = _Ops::__iter_move(__first2); | |
| 85 | 90 | ++__first2; |
| 86 | 91 | } |
| 87 | 92 | else |
| 88 | 93 | { |
| 89 | *__result = _VSTD::move(*__first1); | |
| 94 | *__result = _Ops::__iter_move(__first1); | |
| 90 | 95 | ++__first1; |
| 91 | 96 | } |
| 92 | 97 | } |
| 93 | 98 | for (; __first2 != __last2; ++__first2, (void) ++__result) |
| 94 | *__result = _VSTD::move(*__first2); | |
| 99 | *__result = _Ops::__iter_move(__first2); | |
| 95 | 100 | } |
| 96 | 101 | |
| 97 | template <class _Compare, class _RandomAccessIterator> | |
| 102 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 98 | 103 | void |
| 99 | 104 | __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, |
| 100 | 105 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, |
| 101 | 106 | typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size); |
| 102 | 107 | |
| 103 | template <class _Compare, class _RandomAccessIterator> | |
| 108 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 104 | 109 | void |
| 105 | 110 | __stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp, |
| 106 | 111 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, |
| 107 | 112 | typename iterator_traits<_RandomAccessIterator>::value_type* __first2) |
| 108 | 113 | { |
| 114 | using _Ops = _IterOps<_AlgPolicy>; | |
| 115 | ||
| 109 | 116 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; |
| 110 | 117 | switch (__len) |
| 111 | 118 | { |
| 112 | 119 | case 0: |
| 113 | 120 | return; |
| 114 | 121 | case 1: |
| 115 | ::new ((void*)__first2) value_type(_VSTD::move(*__first1)); | |
| 122 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1)); | |
| 116 | 123 | return; |
| 117 | 124 | case 2: |
| 118 | 125 | __destruct_n __d(0); |
| 119 | 126 | unique_ptr<value_type, __destruct_n&> __h2(__first2, __d); |
| 120 | 127 | if (__comp(*--__last1, *__first1)) |
| 121 | 128 | { |
| 122 | ::new ((void*)__first2) value_type(_VSTD::move(*__last1)); | |
| 129 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1)); | |
| 123 | 130 | __d.template __incr<value_type>(); |
| 124 | 131 | ++__first2; |
| 125 | ::new ((void*)__first2) value_type(_VSTD::move(*__first1)); | |
| 132 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1)); | |
| 126 | 133 | } |
| 127 | 134 | else |
| 128 | 135 | { |
| 129 | ::new ((void*)__first2) value_type(_VSTD::move(*__first1)); | |
| 136 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__first1)); | |
| 130 | 137 | __d.template __incr<value_type>(); |
| 131 | 138 | ++__first2; |
| 132 | ::new ((void*)__first2) value_type(_VSTD::move(*__last1)); | |
| 139 | ::new ((void*)__first2) value_type(_Ops::__iter_move(__last1)); | |
| 133 | 140 | } |
| 134 | 141 | __h2.release(); |
| 135 | 142 | return; |
| 136 | 143 | } |
| 137 | 144 | if (__len <= 8) |
| 138 | 145 | { |
| 139 | _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp); | |
| 146 | std::__insertion_sort_move<_AlgPolicy, _Compare>(__first1, __last1, __first2, __comp); | |
| 140 | 147 | return; |
| 141 | 148 | } |
| 142 | 149 | typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; |
| 143 | 150 | _RandomAccessIterator __m = __first1 + __l2; |
| 144 | _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2); | |
| 145 | _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2); | |
| 146 | _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp); | |
| 151 | std::__stable_sort<_AlgPolicy, _Compare>(__first1, __m, __comp, __l2, __first2, __l2); | |
| 152 | std::__stable_sort<_AlgPolicy, _Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2); | |
| 153 | std::__merge_move_construct<_AlgPolicy, _Compare>(__first1, __m, __m, __last1, __first2, __comp); | |
| 147 | 154 | } |
| 148 | 155 | |
| 149 | 156 | template <class _Tp> |
| ... | ... | @@ -152,7 +159,7 @@ struct __stable_sort_switch |
| 152 | 159 | static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value; |
| 153 | 160 | }; |
| 154 | 161 | |
| 155 | template <class _Compare, class _RandomAccessIterator> | |
| 162 | template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> | |
| 156 | 163 | void |
| 157 | 164 | __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, |
| 158 | 165 | typename iterator_traits<_RandomAccessIterator>::difference_type __len, |
| ... | ... | @@ -167,12 +174,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp |
| 167 | 174 | return; |
| 168 | 175 | case 2: |
| 169 | 176 | if (__comp(*--__last, *__first)) |
| 170 | swap(*__first, *__last); | |
| 177 | _IterOps<_AlgPolicy>::iter_swap(__first, __last); | |
| 171 | 178 | return; |
| 172 | 179 | } |
| 173 | 180 | if (__len <= static_cast<difference_type>(__stable_sort_switch<value_type>::value)) |
| 174 | 181 | { |
| 175 | _VSTD::__insertion_sort<_Compare>(__first, __last, __comp); | |
| 182 | std::__insertion_sort<_AlgPolicy, _Compare>(__first, __last, __comp); | |
| 176 | 183 | return; |
| 177 | 184 | } |
| 178 | 185 | typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; |
| ... | ... | @@ -181,11 +188,12 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp |
| 181 | 188 | { |
| 182 | 189 | __destruct_n __d(0); |
| 183 | 190 | unique_ptr<value_type, __destruct_n&> __h2(__buff, __d); |
| 184 | _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff); | |
| 191 | std::__stable_sort_move<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff); | |
| 185 | 192 | __d.__set(__l2, (value_type*)nullptr); |
| 186 | _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2); | |
| 193 | std::__stable_sort_move<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff + __l2); | |
| 187 | 194 | __d.__set(__len, (value_type*)nullptr); |
| 188 | _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp); | |
| 195 | std::__merge_move_assign<_AlgPolicy, _Compare>( | |
| 196 | __buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp); | |
| 189 | 197 | // _VSTD::__merge<_Compare>(move_iterator<value_type*>(__buff), |
| 190 | 198 | // move_iterator<value_type*>(__buff + __l2), |
| 191 | 199 | // move_iterator<_RandomAccessIterator>(__buff + __l2), |
| ... | ... | @@ -193,36 +201,42 @@ __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp |
| 193 | 201 | // __first, __comp); |
| 194 | 202 | return; |
| 195 | 203 | } |
| 196 | _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size); | |
| 197 | _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size); | |
| 198 | _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size); | |
| 204 | std::__stable_sort<_AlgPolicy, _Compare>(__first, __m, __comp, __l2, __buff, __buff_size); | |
| 205 | std::__stable_sort<_AlgPolicy, _Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size); | |
| 206 | std::__inplace_merge<_AlgPolicy>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size); | |
| 207 | } | |
| 208 | ||
| 209 | template <class _AlgPolicy, class _RandomAccessIterator, class _Compare> | |
| 210 | inline _LIBCPP_HIDE_FROM_ABI | |
| 211 | void __stable_sort_impl(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) { | |
| 212 | using value_type = typename iterator_traits<_RandomAccessIterator>::value_type; | |
| 213 | using difference_type = typename iterator_traits<_RandomAccessIterator>::difference_type; | |
| 214 | ||
| 215 | difference_type __len = __last - __first; | |
| 216 | pair<value_type*, ptrdiff_t> __buf(0, 0); | |
| 217 | unique_ptr<value_type, __return_temporary_buffer> __h; | |
| 218 | if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) { | |
| 219 | // TODO: Remove the use of std::get_temporary_buffer | |
| 220 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 221 | __buf = std::get_temporary_buffer<value_type>(__len); | |
| 222 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 223 | __h.reset(__buf.first); | |
| 224 | } | |
| 225 | ||
| 226 | using _Comp_ref = typename __comp_ref_type<_Compare>::type; | |
| 227 | std::__stable_sort<_AlgPolicy, _Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); | |
| 199 | 228 | } |
| 200 | 229 | |
| 201 | 230 | template <class _RandomAccessIterator, class _Compare> |
| 202 | inline _LIBCPP_INLINE_VISIBILITY | |
| 203 | void | |
| 204 | stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | |
| 205 | { | |
| 206 | typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; | |
| 207 | typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | |
| 208 | difference_type __len = __last - __first; | |
| 209 | pair<value_type*, ptrdiff_t> __buf(0, 0); | |
| 210 | unique_ptr<value_type, __return_temporary_buffer> __h; | |
| 211 | if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) | |
| 212 | { | |
| 213 | __buf = _VSTD::get_temporary_buffer<value_type>(__len); | |
| 214 | __h.reset(__buf.first); | |
| 215 | } | |
| 216 | typedef typename __comp_ref_type<_Compare>::type _Comp_ref; | |
| 217 | _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); | |
| 231 | inline _LIBCPP_HIDE_FROM_ABI | |
| 232 | void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { | |
| 233 | std::__stable_sort_impl<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp); | |
| 218 | 234 | } |
| 219 | 235 | |
| 220 | 236 | template <class _RandomAccessIterator> |
| 221 | inline _LIBCPP_INLINE_VISIBILITY | |
| 222 | void | |
| 223 | stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) | |
| 224 | { | |
| 225 | _VSTD::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 237 | inline _LIBCPP_HIDE_FROM_ABI | |
| 238 | void stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) { | |
| 239 | std::stable_sort(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | |
| 226 | 240 | } |
| 227 | 241 | |
| 228 | 242 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/swap_ranges.h+1-2| ... | ... | @@ -11,10 +11,9 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__utility/swap.h> |
| 14 | #include <type_traits> | |
| 15 | 14 | |
| 16 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 18 | 17 | #endif |
| 19 | 18 | |
| 20 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/transform.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__algorithm/unique.h+27-23| ... | ... | @@ -11,44 +11,48 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/adjacent_find.h> |
| 13 | 13 | #include <__algorithm/comp.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__utility/move.h> |
| 18 | #include <__utility/pair.h> | |
| 17 | 19 | |
| 18 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 20 | 22 | #endif |
| 21 | 23 | |
| 22 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 25 | |
| 24 | 26 | // unique |
| 25 | 27 | |
| 28 | template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate> | |
| 29 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 std::pair<_Iter, _Iter> | |
| 30 | __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | |
| 31 | __first = std::__adjacent_find(__first, __last, __pred); | |
| 32 | if (__first != __last) { | |
| 33 | // ... a a ? ... | |
| 34 | // f i | |
| 35 | _Iter __i = __first; | |
| 36 | for (++__i; ++__i != __last;) | |
| 37 | if (!__pred(*__first, *__i)) | |
| 38 | *++__first = _IterOps<_AlgPolicy>::__iter_move(__i); | |
| 39 | ++__first; | |
| 40 | return std::pair<_Iter, _Iter>(std::move(__first), std::move(__i)); | |
| 41 | } | |
| 42 | return std::pair<_Iter, _Iter>(__first, __first); | |
| 43 | } | |
| 44 | ||
| 26 | 45 | template <class _ForwardIterator, class _BinaryPredicate> |
| 27 | _LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 28 | unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) | |
| 29 | { | |
| 30 | __first = _VSTD::adjacent_find<_ForwardIterator, _BinaryPredicate&>(__first, __last, __pred); | |
| 31 | if (__first != __last) | |
| 32 | { | |
| 33 | // ... a a ? ... | |
| 34 | // f i | |
| 35 | _ForwardIterator __i = __first; | |
| 36 | for (++__i; ++__i != __last;) | |
| 37 | if (!__pred(*__first, *__i)) | |
| 38 | *++__first = _VSTD::move(*__i); | |
| 39 | ++__first; | |
| 40 | } | |
| 41 | return __first; | |
| 46 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 47 | unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { | |
| 48 | return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first; | |
| 42 | 49 | } |
| 43 | 50 | |
| 44 | 51 | template <class _ForwardIterator> |
| 45 | _LIBCPP_NODISCARD_EXT inline | |
| 46 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 47 | _ForwardIterator | |
| 48 | unique(_ForwardIterator __first, _ForwardIterator __last) | |
| 49 | { | |
| 50 | typedef typename iterator_traits<_ForwardIterator>::value_type __v; | |
| 51 | return _VSTD::unique(__first, __last, __equal_to<__v>()); | |
| 52 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 53 | unique(_ForwardIterator __first, _ForwardIterator __last) { | |
| 54 | typedef typename iterator_traits<_ForwardIterator>::value_type __v; | |
| 55 | return std::unique(__first, __last, __equal_to<__v>()); | |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | 58 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/unique_copy.h+83-67| ... | ... | @@ -10,98 +10,114 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_UNIQUE_COPY_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | #include <__algorithm/iterator_operations.h> | |
| 13 | 14 | #include <__config> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | #include <utility> | |
| 16 | #include <__type_traits/conditional.h> | |
| 17 | #include <__type_traits/is_base_of.h> | |
| 18 | #include <__type_traits/is_same.h> | |
| 19 | #include <__utility/move.h> | |
| 20 | #include <__utility/pair.h> | |
| 16 | 21 | |
| 17 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 19 | 24 | #endif |
| 20 | 25 | |
| 21 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 27 | |
| 23 | template <class _BinaryPredicate, class _InputIterator, class _OutputIterator> | |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 25 | __unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred, | |
| 26 | input_iterator_tag, output_iterator_tag) | |
| 27 | { | |
| 28 | if (__first != __last) | |
| 29 | { | |
| 30 | typename iterator_traits<_InputIterator>::value_type __t(*__first); | |
| 28 | namespace __unique_copy_tags { | |
| 29 | ||
| 30 | struct __reread_from_input_tag {}; | |
| 31 | struct __reread_from_output_tag {}; | |
| 32 | struct __read_from_tmp_value_tag {}; | |
| 33 | ||
| 34 | } // namespace __unique_copy_tags | |
| 35 | ||
| 36 | template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator> | |
| 37 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator> | |
| 38 | __unique_copy(_InputIterator __first, | |
| 39 | _Sent __last, | |
| 40 | _OutputIterator __result, | |
| 41 | _BinaryPredicate&& __pred, | |
| 42 | __unique_copy_tags::__read_from_tmp_value_tag) { | |
| 43 | if (__first != __last) { | |
| 44 | typename _IterOps<_AlgPolicy>::template __value_type<_InputIterator> __t(*__first); | |
| 45 | *__result = __t; | |
| 46 | ++__result; | |
| 47 | while (++__first != __last) { | |
| 48 | if (!__pred(__t, *__first)) { | |
| 49 | __t = *__first; | |
| 31 | 50 | *__result = __t; |
| 32 | 51 | ++__result; |
| 33 | while (++__first != __last) | |
| 34 | { | |
| 35 | if (!__pred(__t, *__first)) | |
| 36 | { | |
| 37 | __t = *__first; | |
| 38 | *__result = __t; | |
| 39 | ++__result; | |
| 40 | } | |
| 41 | } | |
| 52 | } | |
| 42 | 53 | } |
| 43 | return __result; | |
| 54 | } | |
| 55 | return pair<_InputIterator, _OutputIterator>(std::move(__first), std::move(__result)); | |
| 44 | 56 | } |
| 45 | 57 | |
| 46 | template <class _BinaryPredicate, class _ForwardIterator, class _OutputIterator> | |
| 47 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 48 | __unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred, | |
| 49 | forward_iterator_tag, output_iterator_tag) | |
| 50 | { | |
| 51 | if (__first != __last) | |
| 52 | { | |
| 53 | _ForwardIterator __i = __first; | |
| 54 | *__result = *__i; | |
| 58 | template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator> | |
| 59 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator> | |
| 60 | __unique_copy(_ForwardIterator __first, | |
| 61 | _Sent __last, | |
| 62 | _OutputIterator __result, | |
| 63 | _BinaryPredicate&& __pred, | |
| 64 | __unique_copy_tags::__reread_from_input_tag) { | |
| 65 | if (__first != __last) { | |
| 66 | _ForwardIterator __i = __first; | |
| 67 | *__result = *__i; | |
| 68 | ++__result; | |
| 69 | while (++__first != __last) { | |
| 70 | if (!__pred(*__i, *__first)) { | |
| 71 | *__result = *__first; | |
| 55 | 72 | ++__result; |
| 56 | while (++__first != __last) | |
| 57 | { | |
| 58 | if (!__pred(*__i, *__first)) | |
| 59 | { | |
| 60 | *__result = *__first; | |
| 61 | ++__result; | |
| 62 | __i = __first; | |
| 63 | } | |
| 64 | } | |
| 73 | __i = __first; | |
| 74 | } | |
| 65 | 75 | } |
| 66 | return __result; | |
| 76 | } | |
| 77 | return pair<_ForwardIterator, _OutputIterator>(std::move(__first), std::move(__result)); | |
| 67 | 78 | } |
| 68 | 79 | |
| 69 | template <class _BinaryPredicate, class _InputIterator, class _ForwardIterator> | |
| 70 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 71 | __unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred, | |
| 72 | input_iterator_tag, forward_iterator_tag) | |
| 73 | { | |
| 74 | if (__first != __last) | |
| 75 | { | |
| 76 | *__result = *__first; | |
| 77 | while (++__first != __last) | |
| 78 | if (!__pred(*__result, *__first)) | |
| 79 | *++__result = *__first; | |
| 80 | ++__result; | |
| 81 | } | |
| 82 | return __result; | |
| 80 | template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator> | |
| 81 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator> | |
| 82 | __unique_copy(_InputIterator __first, | |
| 83 | _Sent __last, | |
| 84 | _InputAndOutputIterator __result, | |
| 85 | _BinaryPredicate&& __pred, | |
| 86 | __unique_copy_tags::__reread_from_output_tag) { | |
| 87 | if (__first != __last) { | |
| 88 | *__result = *__first; | |
| 89 | while (++__first != __last) | |
| 90 | if (!__pred(*__result, *__first)) | |
| 91 | *++__result = *__first; | |
| 92 | ++__result; | |
| 93 | } | |
| 94 | return pair<_InputIterator, _InputAndOutputIterator>(std::move(__first), std::move(__result)); | |
| 83 | 95 | } |
| 84 | 96 | |
| 85 | 97 | template <class _InputIterator, class _OutputIterator, class _BinaryPredicate> |
| 86 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 87 | _OutputIterator | |
| 88 | unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) | |
| 89 | { | |
| 90 | return _VSTD::__unique_copy<_BinaryPredicate&>(__first, __last, __result, __pred, | |
| 91 | typename iterator_traits<_InputIterator>::iterator_category(), | |
| 92 | typename iterator_traits<_OutputIterator>::iterator_category()); | |
| 98 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 99 | unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) { | |
| 100 | using __algo_tag = typename conditional< | |
| 101 | is_base_of<forward_iterator_tag, typename iterator_traits<_InputIterator>::iterator_category>::value, | |
| 102 | __unique_copy_tags::__reread_from_input_tag, | |
| 103 | typename conditional< | |
| 104 | is_base_of<forward_iterator_tag, typename iterator_traits<_OutputIterator>::iterator_category>::value && | |
| 105 | is_same< typename iterator_traits<_InputIterator>::value_type, | |
| 106 | typename iterator_traits<_OutputIterator>::value_type>::value, | |
| 107 | __unique_copy_tags::__reread_from_output_tag, | |
| 108 | __unique_copy_tags::__read_from_tmp_value_tag>::type >::type; | |
| 109 | return std::__unique_copy<_ClassicAlgPolicy>( | |
| 110 | std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag()) | |
| 111 | .second; | |
| 93 | 112 | } |
| 94 | 113 | |
| 95 | 114 | template <class _InputIterator, class _OutputIterator> |
| 96 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 97 | _OutputIterator | |
| 98 | unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) | |
| 99 | { | |
| 100 | typedef typename iterator_traits<_InputIterator>::value_type __v; | |
| 101 | return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>()); | |
| 115 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator | |
| 116 | unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | |
| 117 | typedef typename iterator_traits<_InputIterator>::value_type __v; | |
| 118 | return std::unique_copy(std::move(__first), std::move(__last), std::move(__result), __equal_to<__v>()); | |
| 102 | 119 | } |
| 103 | 120 | |
| 104 | ||
| 105 | 121 | _LIBCPP_END_NAMESPACE_STD |
| 106 | 122 | |
| 107 | 123 | #endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H |
lib/libcxx/include/__algorithm/unwrap_iter.h+31-43| ... | ... | @@ -10,73 +10,61 @@ |
| 10 | 10 | #define _LIBCPP___ALGORITHM_UNWRAP_ITER_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__iterator/iterator_traits.h> | |
| 13 | 14 | #include <__memory/pointer_traits.h> |
| 14 | #include <iterator> | |
| 15 | #include <__utility/move.h> | |
| 15 | 16 | #include <type_traits> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 23 | |
| 23 | // The job of __unwrap_iter is to lower contiguous iterators (such as | |
| 24 | // vector<T>::iterator) into pointers, to reduce the number of template | |
| 25 | // instantiations and to enable pointer-based optimizations e.g. in std::copy. | |
| 26 | // For iterators that are not contiguous, it must be a no-op. | |
| 24 | // TODO: Change the name of __unwrap_iter_impl to something more appropriate | |
| 25 | // The job of __unwrap_iter is to remove iterator wrappers (like reverse_iterator or __wrap_iter), | |
| 26 | // to reduce the number of template instantiations and to enable pointer-based optimizations e.g. in std::copy. | |
| 27 | 27 | // In debug mode, we don't do this. |
| 28 | 28 | // |
| 29 | // __unwrap_iter is non-constexpr for user-defined iterators whose | |
| 30 | // `to_address` and/or `operator->` is non-constexpr. This is okay; but we | |
| 31 | // try to avoid doing __unwrap_iter in constant-evaluated contexts anyway. | |
| 32 | // | |
| 33 | 29 | // Some algorithms (e.g. std::copy, but not std::sort) need to convert an |
| 34 | // "unwrapped" result back into a contiguous iterator. Since contiguous iterators | |
| 35 | // are random-access, we can do this portably using iterator arithmetic; this | |
| 36 | // is the job of __rewrap_iter. | |
| 30 | // "unwrapped" result back into the original iterator type. Doing that is the job of __rewrap_iter. | |
| 37 | 31 | |
| 32 | // Default case - we can't unwrap anything | |
| 38 | 33 | template <class _Iter, bool = __is_cpp17_contiguous_iterator<_Iter>::value> |
| 39 | 34 | struct __unwrap_iter_impl { |
| 40 | static _LIBCPP_CONSTEXPR _Iter | |
| 41 | __apply(_Iter __i) _NOEXCEPT { | |
| 42 | return __i; | |
| 43 | } | |
| 35 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter, _Iter __iter) { return __iter; } | |
| 36 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __unwrap(_Iter __i) _NOEXCEPT { return __i; } | |
| 44 | 37 | }; |
| 45 | 38 | |
| 46 | #if _LIBCPP_DEBUG_LEVEL < 2 | |
| 39 | #ifndef _LIBCPP_ENABLE_DEBUG_MODE | |
| 47 | 40 | |
| 41 | // It's a contiguous iterator, so we can use a raw pointer instead | |
| 48 | 42 | template <class _Iter> |
| 49 | 43 | struct __unwrap_iter_impl<_Iter, true> { |
| 50 | static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>())) | |
| 51 | __apply(_Iter __i) _NOEXCEPT { | |
| 52 | return _VSTD::__to_address(__i); | |
| 53 | } | |
| 54 | }; | |
| 44 | using _ToAddressT = decltype(std::__to_address(std::declval<_Iter>())); | |
| 55 | 45 | |
| 56 | #endif // _LIBCPP_DEBUG_LEVEL < 2 | |
| 46 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap(_Iter __orig_iter, _ToAddressT __unwrapped_iter) { | |
| 47 | return __orig_iter + (__unwrapped_iter - std::__to_address(__orig_iter)); | |
| 48 | } | |
| 57 | 49 | |
| 58 | template<class _Iter, class _Impl = __unwrap_iter_impl<_Iter> > | |
| 59 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 60 | decltype(_Impl::__apply(declval<_Iter>())) | |
| 61 | __unwrap_iter(_Iter __i) _NOEXCEPT | |
| 62 | { | |
| 63 | return _Impl::__apply(__i); | |
| 64 | } | |
| 50 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToAddressT __unwrap(_Iter __i) _NOEXCEPT { | |
| 51 | return std::__to_address(__i); | |
| 52 | } | |
| 53 | }; | |
| 54 | ||
| 55 | #endif // !_LIBCPP_ENABLE_DEBUG_MODE | |
| 65 | 56 | |
| 66 | template<class _OrigIter> | |
| 67 | _LIBCPP_HIDE_FROM_ABI | |
| 68 | _OrigIter __rewrap_iter(_OrigIter, _OrigIter __result) | |
| 69 | { | |
| 70 | return __result; | |
| 57 | template<class _Iter, | |
| 58 | class _Impl = __unwrap_iter_impl<_Iter>, | |
| 59 | __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0> | |
| 60 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 61 | decltype(_Impl::__unwrap(std::declval<_Iter>())) __unwrap_iter(_Iter __i) _NOEXCEPT { | |
| 62 | return _Impl::__unwrap(__i); | |
| 71 | 63 | } |
| 72 | 64 | |
| 73 | template<class _OrigIter, class _UnwrappedIter> | |
| 74 | _LIBCPP_HIDE_FROM_ABI | |
| 75 | _OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result) | |
| 76 | { | |
| 77 | // Precondition: __result is reachable from __first | |
| 78 | // Precondition: _OrigIter is a contiguous iterator | |
| 79 | return __first + (__result - _VSTD::__unwrap_iter(__first)); | |
| 65 | template <class _OrigIter, class _Iter, class _Impl = __unwrap_iter_impl<_OrigIter> > | |
| 66 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _OrigIter __rewrap_iter(_OrigIter __orig_iter, _Iter __iter) _NOEXCEPT { | |
| 67 | return _Impl::__rewrap(std::move(__orig_iter), std::move(__iter)); | |
| 80 | 68 | } |
| 81 | 69 | |
| 82 | 70 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__algorithm/unwrap_range.h created+97| ... | ... | @@ -0,0 +1,97 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ALGORITHM_UNWRAP_RANGE_H | |
| 10 | #define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H | |
| 11 | ||
| 12 | #include <__algorithm/unwrap_iter.h> | |
| 13 | #include <__concepts/constructible.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/next.h> | |
| 17 | #include <__utility/declval.h> | |
| 18 | #include <__utility/move.h> | |
| 19 | #include <__utility/pair.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | // __unwrap_range and __rewrap_range are used to unwrap ranges which may have different iterator and sentinel types. | |
| 28 | // __unwrap_iter and __rewrap_iter don't work for this, because they assume that the iterator and sentinel have | |
| 29 | // the same type. __unwrap_range tries to get two iterators and then forward to __unwrap_iter. | |
| 30 | ||
| 31 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | template <class _Iter, class _Sent> | |
| 33 | struct __unwrap_range_impl { | |
| 34 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent) | |
| 35 | requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter> | |
| 36 | { | |
| 37 | auto __last = ranges::next(__first, __sent); | |
| 38 | return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))}; | |
| 39 | } | |
| 40 | ||
| 41 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) { | |
| 42 | return pair{std::move(__first), std::move(__last)}; | |
| 43 | } | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 46 | __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) | |
| 47 | requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter> | |
| 48 | { | |
| 49 | return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter)); | |
| 50 | } | |
| 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter) | |
| 53 | requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>)) | |
| 54 | { | |
| 55 | return __iter; | |
| 56 | } | |
| 57 | }; | |
| 58 | ||
| 59 | template <class _Iter> | |
| 60 | struct __unwrap_range_impl<_Iter, _Iter> { | |
| 61 | _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) { | |
| 62 | return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))}; | |
| 63 | } | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI static constexpr auto | |
| 66 | __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) { | |
| 67 | return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter)); | |
| 68 | } | |
| 69 | }; | |
| 70 | ||
| 71 | template <class _Iter, class _Sent> | |
| 72 | _LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) { | |
| 73 | return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last)); | |
| 74 | } | |
| 75 | ||
| 76 | template < | |
| 77 | class _Sent, | |
| 78 | class _Iter, | |
| 79 | class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))> | |
| 80 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) { | |
| 81 | return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter)); | |
| 82 | } | |
| 83 | #else // _LIBCPP_STD_VER > 17 | |
| 84 | template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))> | |
| 85 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_range(_Iter __first, _Iter __last) { | |
| 86 | return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))); | |
| 87 | } | |
| 88 | ||
| 89 | template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))> | |
| 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) { | |
| 91 | return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter)); | |
| 92 | } | |
| 93 | #endif // _LIBCPP_STD_VER > 17 | |
| 94 | ||
| 95 | _LIBCPP_END_NAMESPACE_STD | |
| 96 | ||
| 97 | #endif // _LIBCPP___ALGORITHM_UNWRAP_RANGE_H |
lib/libcxx/include/__algorithm/upper_bound.h+36-34| ... | ... | @@ -11,54 +11,56 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/comp.h> |
| 13 | 13 | #include <__algorithm/half_positive.h> |
| 14 | #include <__algorithm/iterator_operations.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <iterator> | |
| 16 | #include <__functional/identity.h> | |
| 17 | #include <__functional/invoke.h> | |
| 18 | #include <__iterator/advance.h> | |
| 19 | #include <__iterator/distance.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__type_traits/is_copy_constructible.h> | |
| 22 | #include <__utility/move.h> | |
| 16 | 23 | |
| 17 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 19 | 26 | #endif |
| 20 | 27 | |
| 21 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 29 | |
| 23 | template <class _Compare, class _ForwardIterator, class _Tp> | |
| 24 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 25 | __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 26 | { | |
| 27 | typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; | |
| 28 | difference_type __len = _VSTD::distance(__first, __last); | |
| 29 | while (__len != 0) | |
| 30 | { | |
| 31 | difference_type __l2 = _VSTD::__half_positive(__len); | |
| 32 | _ForwardIterator __m = __first; | |
| 33 | _VSTD::advance(__m, __l2); | |
| 34 | if (__comp(__value_, *__m)) | |
| 35 | __len = __l2; | |
| 36 | else | |
| 37 | { | |
| 38 | __first = ++__m; | |
| 39 | __len -= __l2 + 1; | |
| 40 | } | |
| 30 | template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj> | |
| 31 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter | |
| 32 | __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) { | |
| 33 | auto __len = _IterOps<_AlgPolicy>::distance(__first, __last); | |
| 34 | while (__len != 0) { | |
| 35 | auto __half_len = std::__half_positive(__len); | |
| 36 | auto __mid = _IterOps<_AlgPolicy>::next(__first, __half_len); | |
| 37 | if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid))) | |
| 38 | __len = __half_len; | |
| 39 | else { | |
| 40 | __first = ++__mid; | |
| 41 | __len -= __half_len + 1; | |
| 41 | 42 | } |
| 42 | return __first; | |
| 43 | } | |
| 44 | return __first; | |
| 43 | 45 | } |
| 44 | 46 | |
| 45 | 47 | template <class _ForwardIterator, class _Tp, class _Compare> |
| 46 | _LIBCPP_NODISCARD_EXT inline | |
| 47 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 48 | _ForwardIterator | |
| 49 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) | |
| 50 | { | |
| 51 | return _VSTD::__upper_bound<_Compare&>(__first, __last, __value_, __comp); | |
| 48 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 49 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | |
| 50 | static_assert(is_copy_constructible<_ForwardIterator>::value, | |
| 51 | "Iterator has to be copy constructible"); | |
| 52 | return std::__upper_bound<_ClassicAlgPolicy>( | |
| 53 | std::move(__first), std::move(__last), __value, std::move(__comp), std::__identity()); | |
| 52 | 54 | } |
| 53 | 55 | |
| 54 | 56 | template <class _ForwardIterator, class _Tp> |
| 55 | _LIBCPP_NODISCARD_EXT inline | |
| 56 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 57 | _ForwardIterator | |
| 58 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) | |
| 59 | { | |
| 60 | return _VSTD::upper_bound(__first, __last, __value_, | |
| 61 | __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>()); | |
| 57 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator | |
| 58 | upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | |
| 59 | return std::upper_bound( | |
| 60 | std::move(__first), | |
| 61 | std::move(__last), | |
| 62 | __value, | |
| 63 | __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>()); | |
| 62 | 64 | } |
| 63 | 65 | |
| 64 | 66 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__assert created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ASSERT | |
| 11 | #define _LIBCPP___ASSERT | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__verbose_abort> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | // This is for backwards compatibility with code that might have been enabling | |
| 21 | // assertions through the Debug mode previously. | |
| 22 | // TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG | |
| 23 | #if defined(_LIBCPP_DEBUG) | |
| 24 | # ifndef _LIBCPP_ENABLE_ASSERTIONS | |
| 25 | # define _LIBCPP_ENABLE_ASSERTIONS 1 | |
| 26 | # endif | |
| 27 | #endif | |
| 28 | ||
| 29 | // Automatically enable assertions when the debug mode is enabled. | |
| 30 | #if defined(_LIBCPP_ENABLE_DEBUG_MODE) | |
| 31 | # ifndef _LIBCPP_ENABLE_ASSERTIONS | |
| 32 | # define _LIBCPP_ENABLE_ASSERTIONS 1 | |
| 33 | # endif | |
| 34 | #endif | |
| 35 | ||
| 36 | #ifndef _LIBCPP_ENABLE_ASSERTIONS | |
| 37 | # define _LIBCPP_ENABLE_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS_DEFAULT | |
| 38 | #endif | |
| 39 | ||
| 40 | #if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 | |
| 41 | # error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" | |
| 42 | #endif | |
| 43 | ||
| 44 | #if _LIBCPP_ENABLE_ASSERTIONS | |
| 45 | # define _LIBCPP_ASSERT(expression, message) \ | |
| 46 | (__builtin_expect(static_cast<bool>(expression), 1) ? \ | |
| 47 | (void)0 : \ | |
| 48 | ::std::__libcpp_verbose_abort("%s:%d: assertion %s failed: %s", __FILE__, __LINE__, #expression, message)) | |
| 49 | #elif !defined(_LIBCPP_ASSERTIONS_DISABLE_ASSUME) && __has_builtin(__builtin_assume) | |
| 50 | # define _LIBCPP_ASSERT(expression, message) \ | |
| 51 | (_LIBCPP_DIAGNOSTIC_PUSH \ | |
| 52 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wassume") \ | |
| 53 | __builtin_assume(static_cast<bool>(expression)) \ | |
| 54 | _LIBCPP_DIAGNOSTIC_POP) | |
| 55 | #else | |
| 56 | # define _LIBCPP_ASSERT(expression, message) ((void)0) | |
| 57 | #endif | |
| 58 | ||
| 59 | #endif // _LIBCPP___ASSERT |
lib/libcxx/include/__availability+60-28| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | // Libc++ is shipped by various vendors. In particular, it is used as a system |
| ... | ... | @@ -91,6 +91,10 @@ |
| 91 | 91 | // other exception types. These were put in the shared library to prevent |
| 92 | 92 | // code bloat from every user program defining the vtable for these exception |
| 93 | 93 | // types. |
| 94 | // | |
| 95 | // Note that when exceptions are disabled, the methods that normally throw | |
| 96 | // these exceptions can be used even on older deployment targets, but those | |
| 97 | // methods will abort instead of throwing. | |
| 94 | 98 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS |
| 95 | 99 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS |
| 96 | 100 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST |
| ... | ... | @@ -99,10 +103,15 @@ |
| 99 | 103 | # define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS |
| 100 | 104 | |
| 101 | 105 | // This controls the availability of the sized version of ::operator delete, |
| 102 | // which was added to the dylib later. | |
| 106 | // ::operator delete[], and their align_val_t variants, which were all added | |
| 107 | // in C++17, and hence not present in early dylibs. | |
| 103 | 108 | # define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE |
| 104 | 109 | |
| 105 | 110 | // This controls the availability of the std::future_error exception. |
| 111 | // | |
| 112 | // Note that when exceptions are disabled, the methods that normally throw | |
| 113 | // std::future_error can be used even on older deployment targets, but those | |
| 114 | // methods will abort instead of throwing. | |
| 106 | 115 | # define _LIBCPP_AVAILABILITY_FUTURE_ERROR |
| 107 | 116 | |
| 108 | 117 | // This controls the availability of std::type_info's vtable. |
| ... | ... | @@ -126,16 +135,14 @@ |
| 126 | 135 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
| 127 | 136 | // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem |
| 128 | 137 | |
| 129 | // This controls the availability of std::to_chars. | |
| 130 | # define _LIBCPP_AVAILABILITY_TO_CHARS | |
| 131 | ||
| 132 | 138 | // This controls the availability of floating-point std::to_chars functions. |
| 133 | 139 | // These overloads were added later than the integer overloads. |
| 134 | 140 | # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT |
| 135 | 141 | |
| 136 | 142 | // This controls the availability of the C++20 synchronization library, |
| 137 | 143 | // which requires shared library support for various operations |
| 138 | // (see libcxx/src/atomic.cpp). | |
| 144 | // (see libcxx/src/atomic.cpp). This includes <barier>, <latch>, | |
| 145 | // <semaphore>, and notification functions on std::atomic. | |
| 139 | 146 | # define _LIBCPP_AVAILABILITY_SYNC |
| 140 | 147 | // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait |
| 141 | 148 | // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier |
| ... | ... | @@ -149,10 +156,26 @@ |
| 149 | 156 | # define _LIBCPP_AVAILABILITY_FORMAT |
| 150 | 157 | // # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format |
| 151 | 158 | |
| 159 | // This controls whether the default verbose termination function is | |
| 160 | // provided by the library. | |
| 161 | // | |
| 162 | // Note that when users provide their own custom function, it doesn't | |
| 163 | // matter whether the dylib provides a default function, and the | |
| 164 | // availability markup can actually give a false positive diagnostic | |
| 165 | // (it will think that no function is provided, when in reality the | |
| 166 | // user has provided their own). | |
| 167 | // | |
| 168 | // Users can pass -D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED | |
| 169 | // to the compiler to tell the library to ignore the fact that the | |
| 170 | // default function isn't available on their deployment target. Note that | |
| 171 | // defining this macro but failing to define a custom function will lead to | |
| 172 | // a load-time error on back-deployment targets, so it should be avoided. | |
| 173 | # define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT | |
| 174 | ||
| 152 | 175 | #elif defined(__APPLE__) |
| 153 | 176 | |
| 154 | 177 | # define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ |
| 155 | __attribute__((availability(macosx,strict,introduced=10.12))) \ | |
| 178 | __attribute__((availability(macos,strict,introduced=10.12))) \ | |
| 156 | 179 | __attribute__((availability(ios,strict,introduced=10.0))) \ |
| 157 | 180 | __attribute__((availability(tvos,strict,introduced=10.0))) \ |
| 158 | 181 | __attribute__((availability(watchos,strict,introduced=3.0))) |
| ... | ... | @@ -164,24 +187,27 @@ |
| 164 | 187 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex |
| 165 | 188 | # endif |
| 166 | 189 | |
| 190 | // Note: bad_optional_access & friends were not introduced in the matching | |
| 191 | // macOS and iOS versions, so the version mismatch between macOS and others | |
| 192 | // is intended. | |
| 167 | 193 | # define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \ |
| 168 | __attribute__((availability(macosx,strict,introduced=10.13))) \ | |
| 169 | __attribute__((availability(ios,strict,introduced=11.0))) \ | |
| 170 | __attribute__((availability(tvos,strict,introduced=11.0))) \ | |
| 171 | __attribute__((availability(watchos,strict,introduced=4.0))) | |
| 194 | __attribute__((availability(macos,strict,introduced=10.13))) \ | |
| 195 | __attribute__((availability(ios,strict,introduced=12.0))) \ | |
| 196 | __attribute__((availability(tvos,strict,introduced=12.0))) \ | |
| 197 | __attribute__((availability(watchos,strict,introduced=5.0))) | |
| 172 | 198 | # define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \ |
| 173 | 199 | _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS |
| 174 | 200 | # define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ |
| 175 | 201 | _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS |
| 176 | 202 | |
| 177 | 203 | # define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ |
| 178 | __attribute__((availability(macosx,strict,introduced=10.12))) \ | |
| 204 | __attribute__((availability(macos,strict,introduced=10.12))) \ | |
| 179 | 205 | __attribute__((availability(ios,strict,introduced=10.0))) \ |
| 180 | 206 | __attribute__((availability(tvos,strict,introduced=10.0))) \ |
| 181 | 207 | __attribute__((availability(watchos,strict,introduced=3.0))) |
| 182 | 208 | |
| 183 | 209 | # define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ |
| 184 | __attribute__((availability(macosx,strict,introduced=10.12))) \ | |
| 210 | __attribute__((availability(macos,strict,introduced=10.12))) \ | |
| 185 | 211 | __attribute__((availability(ios,strict,introduced=10.0))) \ |
| 186 | 212 | __attribute__((availability(tvos,strict,introduced=10.0))) \ |
| 187 | 213 | __attribute__((availability(watchos,strict,introduced=3.0))) |
| ... | ... | @@ -190,26 +216,26 @@ |
| 190 | 216 | __attribute__((availability(ios,strict,introduced=6.0))) |
| 191 | 217 | |
| 192 | 218 | # define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ |
| 193 | __attribute__((availability(macosx,strict,introduced=10.9))) \ | |
| 219 | __attribute__((availability(macos,strict,introduced=10.9))) \ | |
| 194 | 220 | __attribute__((availability(ios,strict,introduced=7.0))) |
| 195 | 221 | |
| 196 | 222 | # define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ |
| 197 | __attribute__((availability(macosx,strict,introduced=10.9))) \ | |
| 223 | __attribute__((availability(macos,strict,introduced=10.9))) \ | |
| 198 | 224 | __attribute__((availability(ios,strict,introduced=7.0))) |
| 199 | 225 | |
| 200 | 226 | # define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \ |
| 201 | __attribute__((availability(macosx,strict,introduced=10.9))) \ | |
| 227 | __attribute__((availability(macos,strict,introduced=10.9))) \ | |
| 202 | 228 | __attribute__((availability(ios,strict,introduced=7.0))) |
| 203 | 229 | |
| 204 | 230 | # define _LIBCPP_AVAILABILITY_FILESYSTEM \ |
| 205 | __attribute__((availability(macosx,strict,introduced=10.15))) \ | |
| 231 | __attribute__((availability(macos,strict,introduced=10.15))) \ | |
| 206 | 232 | __attribute__((availability(ios,strict,introduced=13.0))) \ |
| 207 | 233 | __attribute__((availability(tvos,strict,introduced=13.0))) \ |
| 208 | 234 | __attribute__((availability(watchos,strict,introduced=6.0))) |
| 209 | 235 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \ |
| 210 | _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \ | |
| 211 | _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ | |
| 212 | _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ | |
| 236 | _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \ | |
| 237 | _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \ | |
| 238 | _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \ | |
| 213 | 239 | _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))") |
| 214 | 240 | # define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \ |
| 215 | 241 | _Pragma("clang attribute pop") \ |
| ... | ... | @@ -223,14 +249,11 @@ |
| 223 | 249 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem |
| 224 | 250 | # endif |
| 225 | 251 | |
| 226 | # define _LIBCPP_AVAILABILITY_TO_CHARS \ | |
| 227 | _LIBCPP_AVAILABILITY_FILESYSTEM | |
| 228 | ||
| 229 | 252 | # define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \ |
| 230 | 253 | __attribute__((unavailable)) |
| 231 | 254 | |
| 232 | 255 | # define _LIBCPP_AVAILABILITY_SYNC \ |
| 233 | __attribute__((availability(macosx,strict,introduced=11.0))) \ | |
| 256 | __attribute__((availability(macos,strict,introduced=11.0))) \ | |
| 234 | 257 | __attribute__((availability(ios,strict,introduced=14.0))) \ |
| 235 | 258 | __attribute__((availability(tvos,strict,introduced=14.0))) \ |
| 236 | 259 | __attribute__((availability(watchos,strict,introduced=7.0))) |
| ... | ... | @@ -244,13 +267,12 @@ |
| 244 | 267 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore |
| 245 | 268 | # endif |
| 246 | 269 | |
| 247 | // This controls the availability of the C++20 format library. | |
| 248 | // The library is in development and not ABI stable yet. P2216 is | |
| 249 | // retroactively accepted in C++20. This paper contains ABI breaking | |
| 250 | // changes. | |
| 251 | 270 | # define _LIBCPP_AVAILABILITY_FORMAT \ |
| 252 | 271 | __attribute__((unavailable)) |
| 253 | 272 | # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format |
| 273 | ||
| 274 | # define _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT \ | |
| 275 | __attribute__((unavailable)) | |
| 254 | 276 | #else |
| 255 | 277 | |
| 256 | 278 | // ...New vendors can add availability markup here... |
| ... | ... | @@ -274,4 +296,14 @@ |
| 274 | 296 | # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS |
| 275 | 297 | #endif |
| 276 | 298 | |
| 299 | // Define the special verbose termination function availability attribute, which can be silenced by | |
| 300 | // users if they provide their own custom function. The rest of the code should not use the | |
| 301 | // *_DEFAULT_* macro directly, since that would make it ignore the fact that the user provided | |
| 302 | // a custom function. | |
| 303 | #if defined(_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED) | |
| 304 | # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT /* nothing */ | |
| 305 | #else | |
| 306 | # define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_AVAILABILITY_DEFAULT_VERBOSE_ABORT | |
| 307 | #endif | |
| 308 | ||
| 277 | 309 | #endif // _LIBCPP___AVAILABILITY |
lib/libcxx/include/__bit/bit_cast.h+7-9| ... | ... | @@ -14,21 +14,19 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | #if _LIBCPP_STD_VER > 17 |
| 23 | 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); | |
| 24 | template <class _ToType, class _FromType> | |
| 25 | requires(sizeof(_ToType) == sizeof(_FromType) && | |
| 26 | is_trivially_copyable_v<_ToType> && | |
| 27 | is_trivially_copyable_v<_FromType>) | |
| 28 | _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept { | |
| 29 | return __builtin_bit_cast(_ToType, __from); | |
| 32 | 30 | } |
| 33 | 31 | |
| 34 | 32 | #endif // _LIBCPP_STD_VER > 17 |
lib/libcxx/include/__bit/byteswap.h+2-2| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 20 | |
| 25 | 25 | |
| 26 | 26 | template <integral _Tp> |
| 27 | 27 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept { |
| ... | ... | @@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept { |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | #endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 51 | #endif // _LIBCPP_STD_VER > 20 | |
| 52 | 52 | |
| 53 | 53 | _LIBCPP_END_NAMESPACE_STD |
| 54 | 54 |
lib/libcxx/include/__bit_reference+172-117| ... | ... | @@ -10,12 +10,19 @@ |
| 10 | 10 | #ifndef _LIBCPP___BIT_REFERENCE |
| 11 | 11 | #define _LIBCPP___BIT_REFERENCE |
| 12 | 12 | |
| 13 | #include <__algorithm/copy_n.h> | |
| 14 | #include <__algorithm/fill_n.h> | |
| 15 | #include <__algorithm/min.h> | |
| 13 | 16 | #include <__bits> |
| 14 | 17 | #include <__config> |
| 15 | #include <algorithm> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__memory/construct_at.h> | |
| 20 | #include <__memory/pointer_traits.h> | |
| 21 | #include <cstring> | |
| 22 | #include <type_traits> | |
| 16 | 23 | |
| 17 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 19 | 26 | #endif |
| 20 | 27 | |
| 21 | 28 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -47,15 +54,15 @@ class __bit_reference |
| 47 | 54 | friend class __bit_const_reference<_Cp>; |
| 48 | 55 | friend class __bit_iterator<_Cp, false>; |
| 49 | 56 | public: |
| 50 | _LIBCPP_INLINE_VISIBILITY | |
| 57 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 51 | 58 | __bit_reference(const __bit_reference&) = default; |
| 52 | 59 | |
| 53 | _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT | |
| 60 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT | |
| 54 | 61 | {return static_cast<bool>(*__seg_ & __mask_);} |
| 55 | _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT | |
| 62 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT | |
| 56 | 63 | {return !static_cast<bool>(*this);} |
| 57 | 64 | |
| 58 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 59 | 66 | __bit_reference& operator=(bool __x) _NOEXCEPT |
| 60 | 67 | { |
| 61 | 68 | if (__x) |
| ... | ... | @@ -65,16 +72,26 @@ public: |
| 65 | 72 | return *this; |
| 66 | 73 | } |
| 67 | 74 | |
| 68 | _LIBCPP_INLINE_VISIBILITY | |
| 75 | #if _LIBCPP_STD_VER > 20 | |
| 76 | _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept { | |
| 77 | if (__x) | |
| 78 | *__seg_ |= __mask_; | |
| 79 | else | |
| 80 | *__seg_ &= ~__mask_; | |
| 81 | return *this; | |
| 82 | } | |
| 83 | #endif | |
| 84 | ||
| 85 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 69 | 86 | __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT |
| 70 | 87 | {return operator=(static_cast<bool>(__x));} |
| 71 | 88 | |
| 72 | _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;} | |
| 73 | _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT | |
| 89 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;} | |
| 90 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT | |
| 74 | 91 | {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));} |
| 75 | 92 | private: |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 77 | __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT | |
| 93 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 94 | explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT | |
| 78 | 95 | : __seg_(__s), __mask_(__m) {} |
| 79 | 96 | }; |
| 80 | 97 | |
| ... | ... | @@ -84,7 +101,7 @@ class __bit_reference<_Cp, false> |
| 84 | 101 | }; |
| 85 | 102 | |
| 86 | 103 | template <class _Cp> |
| 87 | inline _LIBCPP_INLINE_VISIBILITY | |
| 104 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 88 | 105 | void |
| 89 | 106 | swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT |
| 90 | 107 | { |
| ... | ... | @@ -94,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT |
| 94 | 111 | } |
| 95 | 112 | |
| 96 | 113 | template <class _Cp, class _Dp> |
| 97 | inline _LIBCPP_INLINE_VISIBILITY | |
| 114 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 98 | 115 | void |
| 99 | 116 | swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT |
| 100 | 117 | { |
| ... | ... | @@ -104,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT |
| 104 | 121 | } |
| 105 | 122 | |
| 106 | 123 | template <class _Cp> |
| 107 | inline _LIBCPP_INLINE_VISIBILITY | |
| 124 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 108 | 125 | void |
| 109 | 126 | swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT |
| 110 | 127 | { |
| ... | ... | @@ -114,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT |
| 114 | 131 | } |
| 115 | 132 | |
| 116 | 133 | template <class _Cp> |
| 117 | inline _LIBCPP_INLINE_VISIBILITY | |
| 134 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 118 | 135 | void |
| 119 | 136 | swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT |
| 120 | 137 | { |
| ... | ... | @@ -138,19 +155,19 @@ public: |
| 138 | 155 | _LIBCPP_INLINE_VISIBILITY |
| 139 | 156 | __bit_const_reference(const __bit_const_reference&) = default; |
| 140 | 157 | |
| 141 | _LIBCPP_INLINE_VISIBILITY | |
| 158 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 142 | 159 | __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT |
| 143 | 160 | : __seg_(__x.__seg_), __mask_(__x.__mask_) {} |
| 144 | 161 | |
| 145 | 162 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT |
| 146 | 163 | {return static_cast<bool>(*__seg_ & __mask_);} |
| 147 | 164 | |
| 148 | _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT | |
| 165 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT | |
| 149 | 166 | {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));} |
| 150 | 167 | private: |
| 151 | 168 | _LIBCPP_INLINE_VISIBILITY |
| 152 | 169 | _LIBCPP_CONSTEXPR |
| 153 | __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT | |
| 170 | explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT | |
| 154 | 171 | : __seg_(__s), __mask_(__m) {} |
| 155 | 172 | |
| 156 | 173 | __bit_const_reference& operator=(const __bit_const_reference&) = delete; |
| ... | ... | @@ -159,12 +176,12 @@ private: |
| 159 | 176 | // find |
| 160 | 177 | |
| 161 | 178 | template <class _Cp, bool _IsConst> |
| 162 | __bit_iterator<_Cp, _IsConst> | |
| 179 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst> | |
| 163 | 180 | __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) |
| 164 | 181 | { |
| 165 | 182 | typedef __bit_iterator<_Cp, _IsConst> _It; |
| 166 | 183 | typedef typename _It::__storage_type __storage_type; |
| 167 | static const int __bits_per_word = _It::__bits_per_word; | |
| 184 | const int __bits_per_word = _It::__bits_per_word; | |
| 168 | 185 | // do first partial word |
| 169 | 186 | if (__first.__ctz_ != 0) |
| 170 | 187 | { |
| ... | ... | @@ -195,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type |
| 195 | 212 | } |
| 196 | 213 | |
| 197 | 214 | template <class _Cp, bool _IsConst> |
| 198 | __bit_iterator<_Cp, _IsConst> | |
| 215 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst> | |
| 199 | 216 | __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) |
| 200 | 217 | { |
| 201 | 218 | typedef __bit_iterator<_Cp, _IsConst> _It; |
| ... | ... | @@ -234,11 +251,11 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type |
| 234 | 251 | } |
| 235 | 252 | |
| 236 | 253 | template <class _Cp, bool _IsConst, class _Tp> |
| 237 | inline _LIBCPP_INLINE_VISIBILITY | |
| 254 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 238 | 255 | __bit_iterator<_Cp, _IsConst> |
| 239 | find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) | |
| 256 | find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) | |
| 240 | 257 | { |
| 241 | if (static_cast<bool>(__value_)) | |
| 258 | if (static_cast<bool>(__value)) | |
| 242 | 259 | return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first)); |
| 243 | 260 | return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first)); |
| 244 | 261 | } |
| ... | ... | @@ -310,9 +327,9 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ |
| 310 | 327 | template <class _Cp, bool _IsConst, class _Tp> |
| 311 | 328 | inline _LIBCPP_INLINE_VISIBILITY |
| 312 | 329 | typename __bit_iterator<_Cp, _IsConst>::difference_type |
| 313 | count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) | |
| 330 | count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) | |
| 314 | 331 | { |
| 315 | if (static_cast<bool>(__value_)) | |
| 332 | if (static_cast<bool>(__value)) | |
| 316 | 333 | return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first)); |
| 317 | 334 | return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first)); |
| 318 | 335 | } |
| ... | ... | @@ -320,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las |
| 320 | 337 | // fill_n |
| 321 | 338 | |
| 322 | 339 | template <class _Cp> |
| 323 | void | |
| 340 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 324 | 341 | __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) |
| 325 | 342 | { |
| 326 | 343 | typedef __bit_iterator<_Cp, false> _It; |
| ... | ... | @@ -338,7 +355,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) |
| 338 | 355 | } |
| 339 | 356 | // do middle whole words |
| 340 | 357 | __storage_type __nw = __n / __bits_per_word; |
| 341 | _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type)); | |
| 358 | std::fill_n(std::__to_address(__first.__seg_), __nw, 0); | |
| 342 | 359 | __n -= __nw * __bits_per_word; |
| 343 | 360 | // do last partial word |
| 344 | 361 | if (__n > 0) |
| ... | ... | @@ -350,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) |
| 350 | 367 | } |
| 351 | 368 | |
| 352 | 369 | template <class _Cp> |
| 353 | void | |
| 370 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 354 | 371 | __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) |
| 355 | 372 | { |
| 356 | 373 | typedef __bit_iterator<_Cp, false> _It; |
| ... | ... | @@ -368,7 +385,8 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) |
| 368 | 385 | } |
| 369 | 386 | // do middle whole words |
| 370 | 387 | __storage_type __nw = __n / __bits_per_word; |
| 371 | _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type)); | |
| 388 | // __storage_type is always an unsigned type, so -1 sets all bits | |
| 389 | std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1)); | |
| 372 | 390 | __n -= __nw * __bits_per_word; |
| 373 | 391 | // do last partial word |
| 374 | 392 | if (__n > 0) |
| ... | ... | @@ -380,13 +398,13 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) |
| 380 | 398 | } |
| 381 | 399 | |
| 382 | 400 | template <class _Cp> |
| 383 | inline _LIBCPP_INLINE_VISIBILITY | |
| 401 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 384 | 402 | void |
| 385 | fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_) | |
| 403 | fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value) | |
| 386 | 404 | { |
| 387 | 405 | if (__n > 0) |
| 388 | 406 | { |
| 389 | if (__value_) | |
| 407 | if (__value) | |
| 390 | 408 | _VSTD::__fill_n_true(__first, __n); |
| 391 | 409 | else |
| 392 | 410 | _VSTD::__fill_n_false(__first, __n); |
| ... | ... | @@ -396,16 +414,17 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v |
| 396 | 414 | // fill |
| 397 | 415 | |
| 398 | 416 | template <class _Cp> |
| 399 | inline _LIBCPP_INLINE_VISIBILITY | |
| 417 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 400 | 418 | void |
| 401 | fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value_) | |
| 419 | fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value) | |
| 402 | 420 | { |
| 403 | _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value_); | |
| 421 | _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value); | |
| 404 | 422 | } |
| 405 | 423 | |
| 406 | 424 | // copy |
| 407 | 425 | |
| 408 | 426 | template <class _Cp, bool _IsConst> |
| 427 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 409 | 428 | __bit_iterator<_Cp, false> |
| 410 | 429 | __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, |
| 411 | 430 | __bit_iterator<_Cp, false> __result) |
| ... | ... | @@ -435,9 +454,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon |
| 435 | 454 | // __first.__ctz_ == 0; |
| 436 | 455 | // do middle words |
| 437 | 456 | __storage_type __nw = __n / __bits_per_word; |
| 438 | _VSTD::memmove(_VSTD::__to_address(__result.__seg_), | |
| 439 | _VSTD::__to_address(__first.__seg_), | |
| 440 | __nw * sizeof(__storage_type)); | |
| 457 | std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_)); | |
| 441 | 458 | __n -= __nw * __bits_per_word; |
| 442 | 459 | __result.__seg_ += __nw; |
| 443 | 460 | // do last word |
| ... | ... | @@ -455,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon |
| 455 | 472 | } |
| 456 | 473 | |
| 457 | 474 | template <class _Cp, bool _IsConst> |
| 475 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 458 | 476 | __bit_iterator<_Cp, false> |
| 459 | 477 | __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, |
| 460 | 478 | __bit_iterator<_Cp, false> __result) |
| ... | ... | @@ -462,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC |
| 462 | 480 | typedef __bit_iterator<_Cp, _IsConst> _In; |
| 463 | 481 | typedef typename _In::difference_type difference_type; |
| 464 | 482 | typedef typename _In::__storage_type __storage_type; |
| 465 | static const int __bits_per_word = _In::__bits_per_word; | |
| 483 | const int __bits_per_word = _In::__bits_per_word; | |
| 466 | 484 | difference_type __n = __last - __first; |
| 467 | 485 | if (__n > 0) |
| 468 | 486 | { |
| ... | ... | @@ -533,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC |
| 533 | 551 | } |
| 534 | 552 | |
| 535 | 553 | template <class _Cp, bool _IsConst> |
| 536 | inline _LIBCPP_INLINE_VISIBILITY | |
| 554 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 537 | 555 | __bit_iterator<_Cp, false> |
| 538 | 556 | copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) |
| 539 | 557 | { |
| ... | ... | @@ -545,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last |
| 545 | 563 | // copy_backward |
| 546 | 564 | |
| 547 | 565 | template <class _Cp, bool _IsConst> |
| 548 | __bit_iterator<_Cp, false> | |
| 566 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> | |
| 549 | 567 | __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, |
| 550 | 568 | __bit_iterator<_Cp, false> __result) |
| 551 | 569 | { |
| ... | ... | @@ -576,9 +594,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C |
| 576 | 594 | __storage_type __nw = __n / __bits_per_word; |
| 577 | 595 | __result.__seg_ -= __nw; |
| 578 | 596 | __last.__seg_ -= __nw; |
| 579 | _VSTD::memmove(_VSTD::__to_address(__result.__seg_), | |
| 580 | _VSTD::__to_address(__last.__seg_), | |
| 581 | __nw * sizeof(__storage_type)); | |
| 597 | std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_)); | |
| 582 | 598 | __n -= __nw * __bits_per_word; |
| 583 | 599 | // do last word |
| 584 | 600 | if (__n > 0) |
| ... | ... | @@ -594,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C |
| 594 | 610 | } |
| 595 | 611 | |
| 596 | 612 | template <class _Cp, bool _IsConst> |
| 597 | __bit_iterator<_Cp, false> | |
| 613 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> | |
| 598 | 614 | __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, |
| 599 | 615 | __bit_iterator<_Cp, false> __result) |
| 600 | 616 | { |
| ... | ... | @@ -680,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator< |
| 680 | 696 | } |
| 681 | 697 | |
| 682 | 698 | template <class _Cp, bool _IsConst> |
| 683 | inline _LIBCPP_INLINE_VISIBILITY | |
| 699 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 684 | 700 | __bit_iterator<_Cp, false> |
| 685 | 701 | copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) |
| 686 | 702 | { |
| ... | ... | @@ -887,14 +903,19 @@ struct __bit_array |
| 887 | 903 | difference_type __size_; |
| 888 | 904 | __storage_type __word_[_Np]; |
| 889 | 905 | |
| 890 | _LIBCPP_INLINE_VISIBILITY static difference_type capacity() | |
| 906 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static difference_type capacity() | |
| 891 | 907 | {return static_cast<difference_type>(_Np * __bits_per_word);} |
| 892 | _LIBCPP_INLINE_VISIBILITY explicit __bit_array(difference_type __s) : __size_(__s) {} | |
| 893 | _LIBCPP_INLINE_VISIBILITY iterator begin() | |
| 908 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(difference_type __s) : __size_(__s) { | |
| 909 | if (__libcpp_is_constant_evaluated()) { | |
| 910 | for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i) | |
| 911 | std::__construct_at(__word_ + __i, 0); | |
| 912 | } | |
| 913 | } | |
| 914 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin() | |
| 894 | 915 | { |
| 895 | 916 | return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); |
| 896 | 917 | } |
| 897 | _LIBCPP_INLINE_VISIBILITY iterator end() | |
| 918 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end() | |
| 898 | 919 | { |
| 899 | 920 | return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, |
| 900 | 921 | static_cast<unsigned>(__size_ % __bits_per_word)); |
| ... | ... | @@ -902,7 +923,7 @@ struct __bit_array |
| 902 | 923 | }; |
| 903 | 924 | |
| 904 | 925 | template <class _Cp> |
| 905 | __bit_iterator<_Cp, false> | |
| 926 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> | |
| 906 | 927 | rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) |
| 907 | 928 | { |
| 908 | 929 | typedef __bit_iterator<_Cp, false> _I1; |
| ... | ... | @@ -953,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, |
| 953 | 974 | // equal |
| 954 | 975 | |
| 955 | 976 | template <class _Cp, bool _IC1, bool _IC2> |
| 956 | bool | |
| 977 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | |
| 957 | 978 | __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, |
| 958 | 979 | __bit_iterator<_Cp, _IC2> __first2) |
| 959 | 980 | { |
| 960 | 981 | typedef __bit_iterator<_Cp, _IC1> _It; |
| 961 | 982 | typedef typename _It::difference_type difference_type; |
| 962 | 983 | typedef typename _It::__storage_type __storage_type; |
| 963 | static const int __bits_per_word = _It::__bits_per_word; | |
| 984 | const int __bits_per_word = _It::__bits_per_word; | |
| 964 | 985 | difference_type __n = __last1 - __first1; |
| 965 | 986 | if (__n > 0) |
| 966 | 987 | { |
| ... | ... | @@ -1035,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> |
| 1035 | 1056 | } |
| 1036 | 1057 | |
| 1037 | 1058 | template <class _Cp, bool _IC1, bool _IC2> |
| 1038 | bool | |
| 1059 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | |
| 1039 | 1060 | __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, |
| 1040 | 1061 | __bit_iterator<_Cp, _IC2> __first2) |
| 1041 | 1062 | { |
| 1042 | 1063 | typedef __bit_iterator<_Cp, _IC1> _It; |
| 1043 | 1064 | typedef typename _It::difference_type difference_type; |
| 1044 | 1065 | typedef typename _It::__storage_type __storage_type; |
| 1045 | static const int __bits_per_word = _It::__bits_per_word; | |
| 1066 | const int __bits_per_word = _It::__bits_per_word; | |
| 1046 | 1067 | difference_type __n = __last1 - __first1; |
| 1047 | 1068 | if (__n > 0) |
| 1048 | 1069 | { |
| ... | ... | @@ -1078,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __ |
| 1078 | 1099 | } |
| 1079 | 1100 | |
| 1080 | 1101 | template <class _Cp, bool _IC1, bool _IC2> |
| 1081 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1102 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1082 | 1103 | bool |
| 1083 | 1104 | equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) |
| 1084 | 1105 | { |
| ... | ... | @@ -1095,7 +1116,11 @@ public: |
| 1095 | 1116 | typedef typename _Cp::difference_type difference_type; |
| 1096 | 1117 | typedef bool value_type; |
| 1097 | 1118 | typedef __bit_iterator pointer; |
| 1119 | #ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 1098 | 1120 | typedef typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >::type reference; |
| 1121 | #else | |
| 1122 | using reference = typename conditional<_IsConst, bool, __bit_reference<_Cp> >::type; | |
| 1123 | #endif | |
| 1099 | 1124 | typedef random_access_iterator_tag iterator_category; |
| 1100 | 1125 | |
| 1101 | 1126 | private: |
| ... | ... | @@ -1108,7 +1133,7 @@ private: |
| 1108 | 1133 | unsigned __ctz_; |
| 1109 | 1134 | |
| 1110 | 1135 | public: |
| 1111 | _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT | |
| 1136 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT | |
| 1112 | 1137 | #if _LIBCPP_STD_VER > 11 |
| 1113 | 1138 | : __seg_(nullptr), __ctz_(0) |
| 1114 | 1139 | #endif |
| ... | ... | @@ -1119,7 +1144,7 @@ public: |
| 1119 | 1144 | // When _IsConst=true, this is a converting constructor; |
| 1120 | 1145 | // the copy and move constructors are implicitly generated |
| 1121 | 1146 | // and trivial. |
| 1122 | _LIBCPP_INLINE_VISIBILITY | |
| 1147 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1123 | 1148 | __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT |
| 1124 | 1149 | : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} |
| 1125 | 1150 | |
| ... | ... | @@ -1128,17 +1153,19 @@ public: |
| 1128 | 1153 | // the implicit generation of a defaulted one is deprecated. |
| 1129 | 1154 | // When _IsConst=true, the assignment operators are |
| 1130 | 1155 | // implicitly generated and trivial. |
| 1131 | _LIBCPP_INLINE_VISIBILITY | |
| 1156 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1132 | 1157 | __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) { |
| 1133 | 1158 | __seg_ = __it.__seg_; |
| 1134 | 1159 | __ctz_ = __it.__ctz_; |
| 1135 | 1160 | return *this; |
| 1136 | 1161 | } |
| 1137 | 1162 | |
| 1138 | _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT | |
| 1139 | {return reference(__seg_, __storage_type(1) << __ctz_);} | |
| 1163 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT { | |
| 1164 | return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> > | |
| 1165 | ::type(__seg_, __storage_type(1) << __ctz_); | |
| 1166 | } | |
| 1140 | 1167 | |
| 1141 | _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++() | |
| 1168 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++() | |
| 1142 | 1169 | { |
| 1143 | 1170 | if (__ctz_ != __bits_per_word-1) |
| 1144 | 1171 | ++__ctz_; |
| ... | ... | @@ -1150,14 +1177,14 @@ public: |
| 1150 | 1177 | return *this; |
| 1151 | 1178 | } |
| 1152 | 1179 | |
| 1153 | _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int) | |
| 1180 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int) | |
| 1154 | 1181 | { |
| 1155 | 1182 | __bit_iterator __tmp = *this; |
| 1156 | 1183 | ++(*this); |
| 1157 | 1184 | return __tmp; |
| 1158 | 1185 | } |
| 1159 | 1186 | |
| 1160 | _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--() | |
| 1187 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--() | |
| 1161 | 1188 | { |
| 1162 | 1189 | if (__ctz_ != 0) |
| 1163 | 1190 | --__ctz_; |
| ... | ... | @@ -1169,14 +1196,14 @@ public: |
| 1169 | 1196 | return *this; |
| 1170 | 1197 | } |
| 1171 | 1198 | |
| 1172 | _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int) | |
| 1199 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int) | |
| 1173 | 1200 | { |
| 1174 | 1201 | __bit_iterator __tmp = *this; |
| 1175 | 1202 | --(*this); |
| 1176 | 1203 | return __tmp; |
| 1177 | 1204 | } |
| 1178 | 1205 | |
| 1179 | _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(difference_type __n) | |
| 1206 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(difference_type __n) | |
| 1180 | 1207 | { |
| 1181 | 1208 | if (__n >= 0) |
| 1182 | 1209 | __seg_ += (__n + __ctz_) / __bits_per_word; |
| ... | ... | @@ -1188,55 +1215,55 @@ public: |
| 1188 | 1215 | return *this; |
| 1189 | 1216 | } |
| 1190 | 1217 | |
| 1191 | _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(difference_type __n) | |
| 1218 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(difference_type __n) | |
| 1192 | 1219 | { |
| 1193 | 1220 | return *this += -__n; |
| 1194 | 1221 | } |
| 1195 | 1222 | |
| 1196 | _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(difference_type __n) const | |
| 1223 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(difference_type __n) const | |
| 1197 | 1224 | { |
| 1198 | 1225 | __bit_iterator __t(*this); |
| 1199 | 1226 | __t += __n; |
| 1200 | 1227 | return __t; |
| 1201 | 1228 | } |
| 1202 | 1229 | |
| 1203 | _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(difference_type __n) const | |
| 1230 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(difference_type __n) const | |
| 1204 | 1231 | { |
| 1205 | 1232 | __bit_iterator __t(*this); |
| 1206 | 1233 | __t -= __n; |
| 1207 | 1234 | return __t; |
| 1208 | 1235 | } |
| 1209 | 1236 | |
| 1210 | _LIBCPP_INLINE_VISIBILITY | |
| 1237 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1211 | 1238 | friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;} |
| 1212 | 1239 | |
| 1213 | _LIBCPP_INLINE_VISIBILITY | |
| 1240 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1214 | 1241 | friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y) |
| 1215 | 1242 | {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;} |
| 1216 | 1243 | |
| 1217 | _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const {return *(*this + __n);} | |
| 1244 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](difference_type __n) const {return *(*this + __n);} | |
| 1218 | 1245 | |
| 1219 | _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1246 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1220 | 1247 | {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;} |
| 1221 | 1248 | |
| 1222 | _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1249 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1223 | 1250 | {return !(__x == __y);} |
| 1224 | 1251 | |
| 1225 | _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1252 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1226 | 1253 | {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);} |
| 1227 | 1254 | |
| 1228 | _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1255 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1229 | 1256 | {return __y < __x;} |
| 1230 | 1257 | |
| 1231 | _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1258 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1232 | 1259 | {return !(__y < __x);} |
| 1233 | 1260 | |
| 1234 | _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1261 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) | |
| 1235 | 1262 | {return !(__x < __y);} |
| 1236 | 1263 | |
| 1237 | 1264 | private: |
| 1238 | _LIBCPP_INLINE_VISIBILITY | |
| 1239 | __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT | |
| 1265 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1266 | explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT | |
| 1240 | 1267 | : __seg_(__s), __ctz_(__ctz) {} |
| 1241 | 1268 | |
| 1242 | 1269 | friend typename _Cp::__self; |
| ... | ... | @@ -1245,26 +1272,44 @@ private: |
| 1245 | 1272 | friend class __bit_const_reference<_Cp>; |
| 1246 | 1273 | friend class __bit_iterator<_Cp, true>; |
| 1247 | 1274 | template <class _Dp> friend struct __bit_array; |
| 1248 | template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | |
| 1249 | template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | |
| 1250 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, | |
| 1251 | __bit_iterator<_Dp, _IC> __last, | |
| 1252 | __bit_iterator<_Dp, false> __result); | |
| 1253 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, | |
| 1254 | __bit_iterator<_Dp, _IC> __last, | |
| 1255 | __bit_iterator<_Dp, false> __result); | |
| 1256 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, | |
| 1257 | __bit_iterator<_Dp, _IC> __last, | |
| 1258 | __bit_iterator<_Dp, false> __result); | |
| 1259 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, | |
| 1260 | __bit_iterator<_Dp, _IC> __last, | |
| 1261 | __bit_iterator<_Dp, false> __result); | |
| 1262 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, | |
| 1263 | __bit_iterator<_Dp, _IC> __last, | |
| 1264 | __bit_iterator<_Dp, false> __result); | |
| 1265 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, | |
| 1266 | __bit_iterator<_Dp, _IC> __last, | |
| 1267 | __bit_iterator<_Dp, false> __result); | |
| 1275 | template <class _Dp> | |
| 1276 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1277 | friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | |
| 1278 | ||
| 1279 | template <class _Dp> | |
| 1280 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1281 | friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); | |
| 1282 | ||
| 1283 | template <class _Dp, bool _IC> | |
| 1284 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1285 | friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, | |
| 1286 | __bit_iterator<_Dp, _IC> __last, | |
| 1287 | __bit_iterator<_Dp, false> __result); | |
| 1288 | template <class _Dp, bool _IC> | |
| 1289 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1290 | friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, | |
| 1291 | __bit_iterator<_Dp, _IC> __last, | |
| 1292 | __bit_iterator<_Dp, false> __result); | |
| 1293 | template <class _Dp, bool _IC> | |
| 1294 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1295 | friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, | |
| 1296 | __bit_iterator<_Dp, _IC> __last, | |
| 1297 | __bit_iterator<_Dp, false> __result); | |
| 1298 | template <class _Dp, bool _IC> | |
| 1299 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1300 | friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, | |
| 1301 | __bit_iterator<_Dp, _IC> __last, | |
| 1302 | __bit_iterator<_Dp, false> __result); | |
| 1303 | template <class _Dp, bool _IC> | |
| 1304 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1305 | friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, | |
| 1306 | __bit_iterator<_Dp, _IC> __last, | |
| 1307 | __bit_iterator<_Dp, false> __result); | |
| 1308 | template <class _Dp, bool _IC> | |
| 1309 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1310 | friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, | |
| 1311 | __bit_iterator<_Dp, _IC> __last, | |
| 1312 | __bit_iterator<_Dp, false> __result); | |
| 1268 | 1313 | template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>, |
| 1269 | 1314 | __bit_iterator<__C1, false>, |
| 1270 | 1315 | __bit_iterator<__C2, false>); |
| ... | ... | @@ -1274,22 +1319,32 @@ private: |
| 1274 | 1319 | template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>, |
| 1275 | 1320 | __bit_iterator<__C1, false>, |
| 1276 | 1321 | __bit_iterator<__C2, false>); |
| 1277 | template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, | |
| 1278 | __bit_iterator<_Dp, false>, | |
| 1279 | __bit_iterator<_Dp, false>); | |
| 1280 | template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, | |
| 1281 | __bit_iterator<_Dp, _IC1>, | |
| 1282 | __bit_iterator<_Dp, _IC2>); | |
| 1283 | template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, | |
| 1284 | __bit_iterator<_Dp, _IC1>, | |
| 1285 | __bit_iterator<_Dp, _IC2>); | |
| 1286 | template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>, | |
| 1287 | __bit_iterator<_Dp, _IC1>, | |
| 1288 | __bit_iterator<_Dp, _IC2>); | |
| 1289 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, | |
| 1290 | typename _Dp::size_type); | |
| 1291 | template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, | |
| 1292 | typename _Dp::size_type); | |
| 1322 | template <class _Dp> | |
| 1323 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1324 | friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, | |
| 1325 | __bit_iterator<_Dp, false>, | |
| 1326 | __bit_iterator<_Dp, false>); | |
| 1327 | template <class _Dp, bool _IC1, bool _IC2> | |
| 1328 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1329 | friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, | |
| 1330 | __bit_iterator<_Dp, _IC1>, | |
| 1331 | __bit_iterator<_Dp, _IC2>); | |
| 1332 | template <class _Dp, bool _IC1, bool _IC2> | |
| 1333 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1334 | friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, | |
| 1335 | __bit_iterator<_Dp, _IC1>, | |
| 1336 | __bit_iterator<_Dp, _IC2>); | |
| 1337 | template <class _Dp, bool _IC1, bool _IC2> | |
| 1338 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1339 | friend bool equal(__bit_iterator<_Dp, _IC1>, | |
| 1340 | __bit_iterator<_Dp, _IC1>, | |
| 1341 | __bit_iterator<_Dp, _IC2>); | |
| 1342 | template <class _Dp, bool _IC> | |
| 1343 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1344 | friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); | |
| 1345 | template <class _Dp, bool _IC> | |
| 1346 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1347 | friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); | |
| 1293 | 1348 | template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type |
| 1294 | 1349 | __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); |
| 1295 | 1350 | template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type |
lib/libcxx/include/__bits+18-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -43,6 +43,23 @@ int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); |
| 43 | 43 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 44 | 44 | int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); } |
| 45 | 45 | |
| 46 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 47 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 48 | int __libcpp_clz(__uint128_t __x) _NOEXCEPT { | |
| 49 | // The function is written in this form due to C++ constexpr limitations. | |
| 50 | // The algorithm: | |
| 51 | // - Test whether any bit in the high 64-bits is set | |
| 52 | // - No bits set: | |
| 53 | // - The high 64-bits contain 64 leading zeros, | |
| 54 | // - Add the result of the low 64-bits. | |
| 55 | // - Any bits set: | |
| 56 | // - The number of leading zeros of the input is the number of leading | |
| 57 | // zeros in the high 64-bits. | |
| 58 | return ((__x >> 64) == 0) | |
| 59 | ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x))) | |
| 60 | : __builtin_clzll(static_cast<unsigned long long>(__x >> 64)); | |
| 61 | } | |
| 62 | # endif | |
| 46 | 63 | |
| 47 | 64 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 48 | 65 | int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); } |
lib/libcxx/include/__bsd_locale_defaults.h+4-4| ... | ... | @@ -11,11 +11,11 @@ |
| 11 | 11 | // we will define the mapping from an internal macro to the real BSD symbol. |
| 12 | 12 | //===----------------------------------------------------------------------===// |
| 13 | 13 | |
| 14 | #ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H | |
| 15 | #define _LIBCPP_BSD_LOCALE_DEFAULTS_H | |
| 14 | #ifndef _LIBCPP___BSD_LOCALE_DEFAULTS_H | |
| 15 | #define _LIBCPP___BSD_LOCALE_DEFAULTS_H | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | #define __libcpp_mb_cur_max_l(loc) MB_CUR_MAX_L(loc) |
| ... | ... | @@ -33,4 +33,4 @@ |
| 33 | 33 | #define __libcpp_asprintf_l(...) asprintf_l(__VA_ARGS__) |
| 34 | 34 | #define __libcpp_sscanf_l(...) sscanf_l(__VA_ARGS__) |
| 35 | 35 | |
| 36 | #endif // _LIBCPP_BSD_LOCALE_DEFAULTS_H | |
| 36 | #endif // _LIBCPP___BSD_LOCALE_DEFAULTS_H |
lib/libcxx/include/__bsd_locale_fallbacks.h+4-4| ... | ... | @@ -10,15 +10,15 @@ |
| 10 | 10 | // of those functions for non-BSD platforms. |
| 11 | 11 | //===----------------------------------------------------------------------===// |
| 12 | 12 | |
| 13 | #ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H | |
| 14 | #define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H | |
| 13 | #ifndef _LIBCPP___BSD_LOCALE_FALLBACKS_H | |
| 14 | #define _LIBCPP___BSD_LOCALE_FALLBACKS_H | |
| 15 | 15 | |
| 16 | 16 | #include <memory> |
| 17 | 17 | #include <stdarg.h> |
| 18 | 18 | #include <stdlib.h> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -140,4 +140,4 @@ int __libcpp_sscanf_l(const char *__s, locale_t __l, const char *__format, ...) |
| 140 | 140 | |
| 141 | 141 | _LIBCPP_END_NAMESPACE_STD |
| 142 | 142 | |
| 143 | #endif // _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H | |
| 143 | #endif // _LIBCPP___BSD_LOCALE_FALLBACKS_H |
lib/libcxx/include/__charconv/chars_format.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__utility/to_underlying.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__charconv/from_chars_result.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__errc> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__charconv/tables.h created+180| ... | ... | @@ -0,0 +1,180 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHARCONV_TABLES | |
| 11 | #define _LIBCPP___CHARCONV_TABLES | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <cstdint> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #ifndef _LIBCPP_CXX03_LANG | |
| 23 | ||
| 24 | namespace __itoa { | |
| 25 | ||
| 26 | /// Contains the charconv helper tables. | |
| 27 | /// | |
| 28 | /// In C++17 these could be inline constexpr variable, but libc++ supports | |
| 29 | /// charconv for integrals in C++11 mode. | |
| 30 | template <class = void> | |
| 31 | struct __table { | |
| 32 | static const char __base_2_lut[64]; | |
| 33 | static const char __base_8_lut[128]; | |
| 34 | static const char __base_16_lut[512]; | |
| 35 | ||
| 36 | static const uint32_t __pow10_32[10]; | |
| 37 | static const uint64_t __pow10_64[20]; | |
| 38 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 39 | // TODO FMT Reduce the number of entries in this table. | |
| 40 | static const __uint128_t __pow10_128[40]; | |
| 41 | static const int __pow10_128_offset = 0; | |
| 42 | # endif | |
| 43 | static const char __digits_base_10[200]; | |
| 44 | }; | |
| 45 | ||
| 46 | template <class _Tp> | |
| 47 | const char __table<_Tp>::__base_2_lut[64] = { | |
| 48 | '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1', | |
| 49 | '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0', | |
| 50 | '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'}; | |
| 51 | ||
| 52 | template <class _Tp> | |
| 53 | const char __table<_Tp>::__base_8_lut[128] = { | |
| 54 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2', | |
| 55 | '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', | |
| 56 | '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0', | |
| 57 | '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3', | |
| 58 | '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', | |
| 59 | '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'}; | |
| 60 | ||
| 61 | template <class _Tp> | |
| 62 | const char __table<_Tp>::__base_16_lut[512] = { | |
| 63 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0', | |
| 64 | 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', | |
| 65 | '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2', | |
| 66 | '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', '2', 'c', '2', 'd', | |
| 67 | '2', 'e', '2', 'f', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', | |
| 68 | '9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', | |
| 69 | '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', '4', 'd', '4', 'e', '4', 'f', '5', | |
| 70 | '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'a', '5', 'b', | |
| 71 | '5', 'c', '5', 'd', '5', 'e', '5', 'f', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', | |
| 72 | '7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', '6', 'e', '6', 'f', '7', '0', '7', '1', '7', '2', | |
| 73 | '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7', | |
| 74 | 'e', '7', 'f', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', | |
| 75 | '8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', '8', 'f', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', | |
| 76 | '5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', 'a', '0', | |
| 77 | 'a', '1', 'a', '2', 'a', '3', 'a', '4', 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a', | |
| 78 | 'c', 'a', 'd', 'a', 'e', 'a', 'f', 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7', | |
| 79 | 'b', '8', 'b', '9', 'b', 'a', 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', 'c', '0', 'c', '1', 'c', '2', 'c', | |
| 80 | '3', 'c', '4', 'c', '5', 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e', | |
| 81 | 'c', 'f', 'd', '0', 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd', | |
| 82 | 'a', 'd', 'b', 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5', | |
| 83 | 'e', '6', 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', 'f', '0', 'f', | |
| 84 | '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c', | |
| 85 | 'f', 'd', 'f', 'e', 'f', 'f'}; | |
| 86 | ||
| 87 | template <class _Tp> | |
| 88 | const uint32_t __table<_Tp>::__pow10_32[10] = { | |
| 89 | UINT32_C(0), UINT32_C(10), UINT32_C(100), UINT32_C(1000), UINT32_C(10000), | |
| 90 | UINT32_C(100000), UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), UINT32_C(1000000000)}; | |
| 91 | ||
| 92 | template <class _Tp> | |
| 93 | const uint64_t __table<_Tp>::__pow10_64[20] = {UINT64_C(0), | |
| 94 | UINT64_C(10), | |
| 95 | UINT64_C(100), | |
| 96 | UINT64_C(1000), | |
| 97 | UINT64_C(10000), | |
| 98 | UINT64_C(100000), | |
| 99 | UINT64_C(1000000), | |
| 100 | UINT64_C(10000000), | |
| 101 | UINT64_C(100000000), | |
| 102 | UINT64_C(1000000000), | |
| 103 | UINT64_C(10000000000), | |
| 104 | UINT64_C(100000000000), | |
| 105 | UINT64_C(1000000000000), | |
| 106 | UINT64_C(10000000000000), | |
| 107 | UINT64_C(100000000000000), | |
| 108 | UINT64_C(1000000000000000), | |
| 109 | UINT64_C(10000000000000000), | |
| 110 | UINT64_C(100000000000000000), | |
| 111 | UINT64_C(1000000000000000000), | |
| 112 | UINT64_C(10000000000000000000)}; | |
| 113 | ||
| 114 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 115 | template <class _Tp> | |
| 116 | const __uint128_t __table<_Tp>::__pow10_128[40] = { | |
| 117 | UINT64_C(0), | |
| 118 | UINT64_C(10), | |
| 119 | UINT64_C(100), | |
| 120 | UINT64_C(1000), | |
| 121 | UINT64_C(10000), | |
| 122 | UINT64_C(100000), | |
| 123 | UINT64_C(1000000), | |
| 124 | UINT64_C(10000000), | |
| 125 | UINT64_C(100000000), | |
| 126 | UINT64_C(1000000000), | |
| 127 | UINT64_C(10000000000), | |
| 128 | UINT64_C(100000000000), | |
| 129 | UINT64_C(1000000000000), | |
| 130 | UINT64_C(10000000000000), | |
| 131 | UINT64_C(100000000000000), | |
| 132 | UINT64_C(1000000000000000), | |
| 133 | UINT64_C(10000000000000000), | |
| 134 | UINT64_C(100000000000000000), | |
| 135 | UINT64_C(1000000000000000000), | |
| 136 | UINT64_C(10000000000000000000), | |
| 137 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10), | |
| 138 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100), | |
| 139 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000), | |
| 140 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000), | |
| 141 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000), | |
| 142 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000), | |
| 143 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000), | |
| 144 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000), | |
| 145 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000), | |
| 146 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000), | |
| 147 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000), | |
| 148 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000), | |
| 149 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000), | |
| 150 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000), | |
| 151 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000), | |
| 152 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000), | |
| 153 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000000), | |
| 154 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000000), | |
| 155 | __uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000), | |
| 156 | (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10}; | |
| 157 | # endif | |
| 158 | ||
| 159 | template <class _Tp> | |
| 160 | const char __table<_Tp>::__digits_base_10[200] = { | |
| 161 | // clang-format off | |
| 162 | '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', | |
| 163 | '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', | |
| 164 | '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', | |
| 165 | '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', | |
| 166 | '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', | |
| 167 | '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', | |
| 168 | '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', | |
| 169 | '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', | |
| 170 | '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', | |
| 171 | '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'}; | |
| 172 | // clang-format on | |
| 173 | ||
| 174 | } // namespace __itoa | |
| 175 | ||
| 176 | #endif // _LIBCPP_CXX03_LANG | |
| 177 | ||
| 178 | _LIBCPP_END_NAMESPACE_STD | |
| 179 | ||
| 180 | #endif // _LIBCPP___CHARCONV_TABLES |
lib/libcxx/include/__charconv/to_chars_base_10.h created+185| ... | ... | @@ -0,0 +1,185 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H | |
| 11 | #define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H | |
| 12 | ||
| 13 | #include <__algorithm/copy_n.h> | |
| 14 | #include <__charconv/tables.h> | |
| 15 | #include <__config> | |
| 16 | #include <cstdint> | |
| 17 | #include <limits> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_PUSH_MACROS | |
| 24 | #include <__undef_macros> | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | #ifndef _LIBCPP_CXX03_LANG | |
| 29 | ||
| 30 | namespace __itoa { | |
| 31 | ||
| 32 | _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept { | |
| 33 | *__first = '0' + static_cast<char>(__value); | |
| 34 | return __first + 1; | |
| 35 | } | |
| 36 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept { | |
| 38 | return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first); | |
| 39 | } | |
| 40 | ||
| 41 | _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept { | |
| 42 | return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100); | |
| 43 | } | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept { | |
| 46 | return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100); | |
| 47 | } | |
| 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept { | |
| 50 | return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000); | |
| 51 | } | |
| 52 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept { | |
| 54 | return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000); | |
| 55 | } | |
| 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept { | |
| 58 | return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000); | |
| 59 | } | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept { | |
| 62 | return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000); | |
| 63 | } | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept { | |
| 66 | return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000); | |
| 67 | } | |
| 68 | ||
| 69 | template <class _Tp> | |
| 70 | _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept { | |
| 71 | return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)), | |
| 72 | static_cast<uint32_t>(__value % 100000000)); | |
| 73 | } | |
| 74 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept { | |
| 76 | if (__value < 1000000) { | |
| 77 | if (__value < 10000) { | |
| 78 | if (__value < 100) { | |
| 79 | // 0 <= __value < 100 | |
| 80 | if (__value < 10) | |
| 81 | return __itoa::__append1(__first, __value); | |
| 82 | return __itoa::__append2(__first, __value); | |
| 83 | } | |
| 84 | // 100 <= __value < 10'000 | |
| 85 | if (__value < 1000) | |
| 86 | return __itoa::__append3(__first, __value); | |
| 87 | return __itoa::__append4(__first, __value); | |
| 88 | } | |
| 89 | ||
| 90 | // 10'000 <= __value < 1'000'000 | |
| 91 | if (__value < 100000) | |
| 92 | return __itoa::__append5(__first, __value); | |
| 93 | return __itoa::__append6(__first, __value); | |
| 94 | } | |
| 95 | ||
| 96 | // __value => 1'000'000 | |
| 97 | if (__value < 100000000) { | |
| 98 | // 1'000'000 <= __value < 100'000'000 | |
| 99 | if (__value < 10000000) | |
| 100 | return __itoa::__append7(__first, __value); | |
| 101 | return __itoa::__append8(__first, __value); | |
| 102 | } | |
| 103 | ||
| 104 | // 100'000'000 <= __value < max | |
| 105 | if (__value < 1000000000) | |
| 106 | return __itoa::__append9(__first, __value); | |
| 107 | return __itoa::__append10(__first, __value); | |
| 108 | } | |
| 109 | ||
| 110 | _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept { | |
| 111 | if (__value <= UINT32_MAX) | |
| 112 | return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value)); | |
| 113 | ||
| 114 | // Numbers in the range UINT32_MAX <= val < 10'000'000'000 always contain 10 | |
| 115 | // digits and are outputted after this if statement. | |
| 116 | if (__value >= 10000000000) { | |
| 117 | // This function properly deterimines the first non-zero leading digit. | |
| 118 | __buffer = __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value / 10000000000)); | |
| 119 | __value %= 10000000000; | |
| 120 | } | |
| 121 | return __itoa::__append10(__buffer, __value); | |
| 122 | } | |
| 123 | ||
| 124 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 125 | /// \returns 10^\a exp | |
| 126 | /// | |
| 127 | /// \pre \a exp [19, 39] | |
| 128 | /// | |
| 129 | /// \note The lookup table contains a partial set of exponents limiting the | |
| 130 | /// range that can be used. However the range is sufficient for | |
| 131 | /// \ref __base_10_u128. | |
| 132 | _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept { | |
| 133 | _LIBCPP_ASSERT(__exp >= __table<>::__pow10_128_offset, "Index out of bounds"); | |
| 134 | return __table<>::__pow10_128[__exp - __table<>::__pow10_128_offset]; | |
| 135 | } | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI inline char* __base_10_u128(char* __buffer, __uint128_t __value) noexcept { | |
| 138 | _LIBCPP_ASSERT( | |
| 139 | __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true."); | |
| 140 | ||
| 141 | // Unlike the 64 to 32 bit case the 128 bit case the "upper half" can't be | |
| 142 | // stored in the "lower half". Instead we first need to handle the top most | |
| 143 | // digits separately. | |
| 144 | // | |
| 145 | // Maximum unsigned values | |
| 146 | // 64 bit 18'446'744'073'709'551'615 (20 digits) | |
| 147 | // 128 bit 340'282'366'920'938'463'463'374'607'431'768'211'455 (39 digits) | |
| 148 | // step 1 ^ ([0-1] digits) | |
| 149 | // step 2 ^^^^^^^^^^^^^^^^^^^^^^^^^ ([0-19] digits) | |
| 150 | // step 3 ^^^^^^^^^^^^^^^^^^^^^^^^^ (19 digits) | |
| 151 | if (__value >= __itoa::__pow_10(38)) { | |
| 152 | // step 1 | |
| 153 | __buffer = __itoa::__append1(__buffer, static_cast<uint32_t>(__value / __itoa::__pow_10(38))); | |
| 154 | __value %= __itoa::__pow_10(38); | |
| 155 | ||
| 156 | // step 2 always 19 digits. | |
| 157 | // They are handled here since leading zeros need to be appended to the buffer, | |
| 158 | __buffer = __itoa::__append9(__buffer, static_cast<uint32_t>(__value / __itoa::__pow_10(29))); | |
| 159 | __value %= __itoa::__pow_10(29); | |
| 160 | __buffer = __itoa::__append10(__buffer, static_cast<uint64_t>(__value / __itoa::__pow_10(19))); | |
| 161 | __value %= __itoa::__pow_10(19); | |
| 162 | } | |
| 163 | else { | |
| 164 | // step 2 | |
| 165 | // This version needs to determine the position of the leading non-zero digit. | |
| 166 | __buffer = __base_10_u64(__buffer, static_cast<uint64_t>(__value / __itoa::__pow_10(19))); | |
| 167 | __value %= __itoa::__pow_10(19); | |
| 168 | } | |
| 169 | ||
| 170 | // Step 3 | |
| 171 | __buffer = __itoa::__append9(__buffer, static_cast<uint32_t>(__value / 10000000000)); | |
| 172 | __buffer = __itoa::__append10(__buffer, static_cast<uint64_t>(__value % 10000000000)); | |
| 173 | ||
| 174 | return __buffer; | |
| 175 | } | |
| 176 | # endif | |
| 177 | } // namespace __itoa | |
| 178 | ||
| 179 | #endif // _LIBCPP_CXX03_LANG | |
| 180 | ||
| 181 | _LIBCPP_END_NAMESPACE_STD | |
| 182 | ||
| 183 | _LIBCPP_POP_MACROS | |
| 184 | ||
| 185 | #endif // _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H |
lib/libcxx/include/__charconv/to_chars_result.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__errc> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__chrono/calendar.h+2-1234| ... | ... | @@ -11,20 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___CHRONO_CALENDAR_H |
| 12 | 12 | |
| 13 | 13 | #include <__chrono/duration.h> |
| 14 | #include <__chrono/system_clock.h> | |
| 15 | 14 | #include <__chrono/time_point.h> |
| 16 | 15 | #include <__config> |
| 17 | #include <limits> | |
| 18 | #include <ratio> | |
| 19 | #include <type_traits> | |
| 20 | 16 | |
| 21 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 23 | 19 | #endif |
| 24 | 20 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 21 | #if _LIBCPP_STD_VER > 17 |
| 29 | 22 | |
| 30 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -38,1239 +31,14 @@ using local_time = time_point<local_t, Duration>; |
| 38 | 31 | using local_seconds = local_time<seconds>; |
| 39 | 32 | using local_days = local_time<days>; |
| 40 | 33 | |
| 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 | ||
| 34 | struct last_spec { _LIBCPP_HIDE_FROM_ABI explicit last_spec() = default; }; | |
| 389 | 35 | 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 | 36 | |
| 505 | inline constexpr | |
| 506 | bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 507 | { return __lhs.month() < __rhs.month(); } | |
| 508 | 37 | |
| 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 | 38 | } // namespace chrono |
| 1269 | 39 | |
| 1270 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 1271 | 41 | |
| 1272 | 42 | #endif // _LIBCPP_STD_VER > 17 |
| 1273 | 43 | |
| 1274 | _LIBCPP_POP_MACROS | |
| 1275 | ||
| 1276 | 44 | #endif // _LIBCPP___CHRONO_CALENDAR_H |
lib/libcxx/include/__chrono/convert_to_timespec.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <limits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__chrono/day.h created+84| ... | ... | @@ -0,0 +1,84 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_DAY_H | |
| 11 | #define _LIBCPP___CHRONO_DAY_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__config> | |
| 15 | #include <compare> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | namespace chrono | |
| 26 | { | |
| 27 | ||
| 28 | class day { | |
| 29 | private: | |
| 30 | unsigned char __d; | |
| 31 | public: | |
| 32 | _LIBCPP_HIDE_FROM_ABI day() = default; | |
| 33 | _LIBCPP_HIDE_FROM_ABI explicit inline constexpr day(unsigned __val) noexcept : __d(static_cast<unsigned char>(__val)) {} | |
| 34 | _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator++() noexcept { ++__d; return *this; } | |
| 35 | _LIBCPP_HIDE_FROM_ABI inline constexpr day operator++(int) noexcept { day __tmp = *this; ++(*this); return __tmp; } | |
| 36 | _LIBCPP_HIDE_FROM_ABI inline constexpr day& operator--() noexcept { --__d; return *this; } | |
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr day operator--(int) noexcept { day __tmp = *this; --(*this); return __tmp; } | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept; | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept; | |
| 40 | _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d; } | |
| 41 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d >= 1 && __d <= 31; } | |
| 42 | }; | |
| 43 | ||
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 46 | bool operator==(const day& __lhs, const day& __rhs) noexcept | |
| 47 | { return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); } | |
| 48 | ||
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const day& __lhs, const day& __rhs) noexcept { | |
| 50 | return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs); | |
| 51 | } | |
| 52 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 54 | day operator+ (const day& __lhs, const days& __rhs) noexcept | |
| 55 | { return day(static_cast<unsigned>(__lhs) + __rhs.count()); } | |
| 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 58 | day operator+ (const days& __lhs, const day& __rhs) noexcept | |
| 59 | { return __rhs + __lhs; } | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 62 | day operator- (const day& __lhs, const days& __rhs) noexcept | |
| 63 | { return __lhs + -__rhs; } | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 66 | days operator-(const day& __lhs, const day& __rhs) noexcept | |
| 67 | { return days(static_cast<int>(static_cast<unsigned>(__lhs)) - | |
| 68 | static_cast<int>(static_cast<unsigned>(__rhs))); } | |
| 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 71 | day& day::operator+=(const days& __dd) noexcept | |
| 72 | { *this = *this + __dd; return *this; } | |
| 73 | ||
| 74 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 75 | day& day::operator-=(const days& __dd) noexcept | |
| 76 | { *this = *this - __dd; return *this; } | |
| 77 | ||
| 78 | } // namespace chrono | |
| 79 | ||
| 80 | _LIBCPP_END_NAMESPACE_STD | |
| 81 | ||
| 82 | #endif // _LIBCPP_STD_VER > 17 | |
| 83 | ||
| 84 | #endif // _LIBCPP___CHRONO_DAY_H |
lib/libcxx/include/__chrono/duration.h+5-5| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -286,10 +286,10 @@ public: |
| 286 | 286 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator+=(const duration& __d) {__rep_ += __d.count(); return *this;} |
| 287 | 287 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 duration& operator-=(const duration& __d) {__rep_ -= __d.count(); return *this;} |
| 288 | 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;} | |
| 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 | 293 | |
| 294 | 294 | // special values |
| 295 | 295 |
lib/libcxx/include/__chrono/file_clock.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <ratio> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | #ifndef _LIBCPP_CXX03_LANG |
lib/libcxx/include/__chrono/hh_mm_ss.h created+112| ... | ... | @@ -0,0 +1,112 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_HH_MM_SS_H | |
| 11 | #define _LIBCPP___CHRONO_HH_MM_SS_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/time_point.h> | |
| 15 | #include <__config> | |
| 16 | #include <ratio> | |
| 17 | #include <type_traits> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | namespace chrono | |
| 28 | { | |
| 29 | ||
| 30 | template <class _Duration> | |
| 31 | class hh_mm_ss | |
| 32 | { | |
| 33 | private: | |
| 34 | static_assert(__is_duration<_Duration>::value, "template parameter of hh_mm_ss must be a std::chrono::duration"); | |
| 35 | using __CommonType = common_type_t<_Duration, chrono::seconds>; | |
| 36 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI static constexpr uint64_t __pow10(unsigned __exp) | |
| 38 | { | |
| 39 | uint64_t __ret = 1; | |
| 40 | for (unsigned __i = 0; __i < __exp; ++__i) | |
| 41 | __ret *= 10U; | |
| 42 | return __ret; | |
| 43 | } | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI static constexpr unsigned __width(uint64_t __n, uint64_t __d = 10, unsigned __w = 0) | |
| 46 | { | |
| 47 | if (__n >= 2 && __d != 0 && __w < 19) | |
| 48 | return 1 + __width(__n, __d % __n * 10, __w+1); | |
| 49 | return 0; | |
| 50 | } | |
| 51 | ||
| 52 | public: | |
| 53 | _LIBCPP_HIDE_FROM_ABI static unsigned constexpr fractional_width = __width(__CommonType::period::den) < 19 ? | |
| 54 | __width(__CommonType::period::den) : 6u; | |
| 55 | using precision = duration<typename __CommonType::rep, ratio<1, __pow10(fractional_width)>>; | |
| 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr hh_mm_ss() noexcept : hh_mm_ss{_Duration::zero()} {} | |
| 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr explicit hh_mm_ss(_Duration __d) noexcept : | |
| 60 | __is_neg(__d < _Duration(0)), | |
| 61 | __h(duration_cast<chrono::hours> (abs(__d))), | |
| 62 | __m(duration_cast<chrono::minutes>(abs(__d) - hours())), | |
| 63 | __s(duration_cast<chrono::seconds>(abs(__d) - hours() - minutes())), | |
| 64 | __f(duration_cast<precision> (abs(__d) - hours() - minutes() - seconds())) | |
| 65 | {} | |
| 66 | ||
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg; } | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h; } | |
| 69 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m; } | |
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s; } | |
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f; } | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept | |
| 74 | { | |
| 75 | auto __dur = __h + __m + __s + __f; | |
| 76 | return __is_neg ? -__dur : __dur; | |
| 77 | } | |
| 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI constexpr explicit operator precision() const noexcept { return to_duration(); } | |
| 80 | ||
| 81 | private: | |
| 82 | bool __is_neg; | |
| 83 | chrono::hours __h; | |
| 84 | chrono::minutes __m; | |
| 85 | chrono::seconds __s; | |
| 86 | precision __f; | |
| 87 | }; | |
| 88 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI constexpr bool is_am(const hours& __h) noexcept { return __h >= hours( 0) && __h < hours(12); } | |
| 90 | _LIBCPP_HIDE_FROM_ABI constexpr bool is_pm(const hours& __h) noexcept { return __h >= hours(12) && __h < hours(24); } | |
| 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr hours make12(const hours& __h) noexcept | |
| 93 | { | |
| 94 | if (__h == hours( 0)) return hours(12); | |
| 95 | else if (__h <= hours(12)) return __h; | |
| 96 | else return __h - hours(12); | |
| 97 | } | |
| 98 | ||
| 99 | _LIBCPP_HIDE_FROM_ABI constexpr hours make24(const hours& __h, bool __is_pm) noexcept | |
| 100 | { | |
| 101 | if (__is_pm) | |
| 102 | return __h == hours(12) ? __h : __h + hours(12); | |
| 103 | else | |
| 104 | return __h == hours(12) ? hours(0) : __h; | |
| 105 | } | |
| 106 | } // namespace chrono | |
| 107 | ||
| 108 | _LIBCPP_END_NAMESPACE_STD | |
| 109 | ||
| 110 | #endif // _LIBCPP_STD_VER > 17 | |
| 111 | ||
| 112 | #endif // _LIBCPP___CHRONO_HH_MM_SS_H |
lib/libcxx/include/__chrono/high_resolution_clock.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__config> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__chrono/literals.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_LITERALS_H | |
| 11 | #define _LIBCPP___CHRONO_LITERALS_H | |
| 12 | ||
| 13 | #include <__chrono/day.h> | |
| 14 | #include <__chrono/year.h> | |
| 15 | #include <__config> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | inline namespace literals | |
| 26 | { | |
| 27 | inline namespace chrono_literals | |
| 28 | { | |
| 29 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator ""d(unsigned long long __d) noexcept | |
| 30 | { | |
| 31 | return chrono::day(static_cast<unsigned>(__d)); | |
| 32 | } | |
| 33 | ||
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator ""y(unsigned long long __y) noexcept | |
| 35 | { | |
| 36 | return chrono::year(static_cast<int>(__y)); | |
| 37 | } | |
| 38 | } // namespace chrono_literals | |
| 39 | } // namespace literals | |
| 40 | ||
| 41 | namespace chrono { // hoist the literals into namespace std::chrono | |
| 42 | using namespace literals::chrono_literals; | |
| 43 | } // namespace chrono | |
| 44 | ||
| 45 | _LIBCPP_END_NAMESPACE_STD | |
| 46 | ||
| 47 | #endif // _LIBCPP_STD_VER > 17 | |
| 48 | ||
| 49 | #endif // _LIBCPP___CHRONO_LITERALS_H |
lib/libcxx/include/__chrono/month.h created+118| ... | ... | @@ -0,0 +1,118 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_MONTH_H | |
| 11 | #define _LIBCPP___CHRONO_MONTH_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | #if _LIBCPP_STD_VER > 17 | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | namespace chrono | |
| 25 | { | |
| 26 | ||
| 27 | class month { | |
| 28 | private: | |
| 29 | unsigned char __m; | |
| 30 | public: | |
| 31 | _LIBCPP_HIDE_FROM_ABI month() = default; | |
| 32 | _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept : __m(static_cast<unsigned char>(__val)) {} | |
| 33 | _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept { ++__m; return *this; } | |
| 34 | _LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept { month __tmp = *this; ++(*this); return __tmp; } | |
| 35 | _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept { --__m; return *this; } | |
| 36 | _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept { month __tmp = *this; --(*this); return __tmp; } | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept; | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept; | |
| 39 | _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m; } | |
| 40 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m >= 1 && __m <= 12; } | |
| 41 | }; | |
| 42 | ||
| 43 | ||
| 44 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 45 | bool operator==(const month& __lhs, const month& __rhs) noexcept | |
| 46 | { return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs); } | |
| 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 49 | bool operator!=(const month& __lhs, const month& __rhs) noexcept | |
| 50 | { return !(__lhs == __rhs); } | |
| 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 53 | bool operator< (const month& __lhs, const month& __rhs) noexcept | |
| 54 | { return static_cast<unsigned>(__lhs) < static_cast<unsigned>(__rhs); } | |
| 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 57 | bool operator> (const month& __lhs, const month& __rhs) noexcept | |
| 58 | { return __rhs < __lhs; } | |
| 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 61 | bool operator<=(const month& __lhs, const month& __rhs) noexcept | |
| 62 | { return !(__rhs < __lhs); } | |
| 63 | ||
| 64 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 65 | bool operator>=(const month& __lhs, const month& __rhs) noexcept | |
| 66 | { return !(__lhs < __rhs); } | |
| 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 69 | month operator+ (const month& __lhs, const months& __rhs) noexcept | |
| 70 | { | |
| 71 | auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1); | |
| 72 | auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12; | |
| 73 | return month{static_cast<unsigned>(__mu - __yr * 12 + 1)}; | |
| 74 | } | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 77 | month operator+ (const months& __lhs, const month& __rhs) noexcept | |
| 78 | { return __rhs + __lhs; } | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 81 | month operator- (const month& __lhs, const months& __rhs) noexcept | |
| 82 | { return __lhs + -__rhs; } | |
| 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 85 | months operator-(const month& __lhs, const month& __rhs) noexcept | |
| 86 | { | |
| 87 | auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs); | |
| 88 | return months(__dm <= 11 ? __dm : __dm + 12); | |
| 89 | } | |
| 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 92 | month& month::operator+=(const months& __dm) noexcept | |
| 93 | { *this = *this + __dm; return *this; } | |
| 94 | ||
| 95 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 96 | month& month::operator-=(const months& __dm) noexcept | |
| 97 | { *this = *this - __dm; return *this; } | |
| 98 | ||
| 99 | inline constexpr month January{1}; | |
| 100 | inline constexpr month February{2}; | |
| 101 | inline constexpr month March{3}; | |
| 102 | inline constexpr month April{4}; | |
| 103 | inline constexpr month May{5}; | |
| 104 | inline constexpr month June{6}; | |
| 105 | inline constexpr month July{7}; | |
| 106 | inline constexpr month August{8}; | |
| 107 | inline constexpr month September{9}; | |
| 108 | inline constexpr month October{10}; | |
| 109 | inline constexpr month November{11}; | |
| 110 | inline constexpr month December{12}; | |
| 111 | ||
| 112 | } // namespace chrono | |
| 113 | ||
| 114 | _LIBCPP_END_NAMESPACE_STD | |
| 115 | ||
| 116 | #endif // _LIBCPP_STD_VER > 17 | |
| 117 | ||
| 118 | #endif // _LIBCPP___CHRONO_MONTH_H |
lib/libcxx/include/__chrono/month_weekday.h created+106| ... | ... | @@ -0,0 +1,106 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_MONTH_WEEKDAY_H | |
| 11 | #define _LIBCPP___CHRONO_MONTH_WEEKDAY_H | |
| 12 | ||
| 13 | #include <__chrono/month.h> | |
| 14 | #include <__chrono/weekday.h> | |
| 15 | #include <__config> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | namespace chrono | |
| 26 | { | |
| 27 | ||
| 28 | class month_weekday { | |
| 29 | private: | |
| 30 | chrono::month __m; | |
| 31 | chrono::weekday_indexed __wdi; | |
| 32 | public: | |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval, const chrono::weekday_indexed& __wdival) noexcept | |
| 34 | : __m{__mval}, __wdi{__wdival} {} | |
| 35 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 36 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; } | |
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdi.ok(); } | |
| 38 | }; | |
| 39 | ||
| 40 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 41 | bool operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept | |
| 42 | { return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } | |
| 43 | ||
| 44 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 45 | bool operator!=(const month_weekday& __lhs, const month_weekday& __rhs) noexcept | |
| 46 | { return !(__lhs == __rhs); } | |
| 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 49 | month_weekday operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept | |
| 50 | { return month_weekday{__lhs, __rhs}; } | |
| 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 53 | month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept | |
| 54 | { return month_weekday{month(__lhs), __rhs}; } | |
| 55 | ||
| 56 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 57 | month_weekday operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept | |
| 58 | { return month_weekday{__rhs, __lhs}; } | |
| 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 61 | month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept | |
| 62 | { return month_weekday{month(__rhs), __lhs}; } | |
| 63 | ||
| 64 | ||
| 65 | class month_weekday_last { | |
| 66 | chrono::month __m; | |
| 67 | chrono::weekday_last __wdl; | |
| 68 | public: | |
| 69 | _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval, const chrono::weekday_last& __wdlval) noexcept | |
| 70 | : __m{__mval}, __wdl{__wdlval} {} | |
| 71 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 72 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; } | |
| 73 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok() && __wdl.ok(); } | |
| 74 | }; | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 77 | bool operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept | |
| 78 | { return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 81 | bool operator!=(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noexcept | |
| 82 | { return !(__lhs == __rhs); } | |
| 83 | ||
| 84 | ||
| 85 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 86 | month_weekday_last operator/(const month& __lhs, const weekday_last& __rhs) noexcept | |
| 87 | { return month_weekday_last{__lhs, __rhs}; } | |
| 88 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 90 | month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept | |
| 91 | { return month_weekday_last{month(__lhs), __rhs}; } | |
| 92 | ||
| 93 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 94 | month_weekday_last operator/(const weekday_last& __lhs, const month& __rhs) noexcept | |
| 95 | { return month_weekday_last{__rhs, __lhs}; } | |
| 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 98 | month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept | |
| 99 | { return month_weekday_last{month(__rhs), __lhs}; } | |
| 100 | } // namespace chrono | |
| 101 | ||
| 102 | _LIBCPP_END_NAMESPACE_STD | |
| 103 | ||
| 104 | #endif // _LIBCPP_STD_VER > 17 | |
| 105 | ||
| 106 | #endif // _LIBCPP___CHRONO_MONTH_WEEKDAY_H |
lib/libcxx/include/__chrono/monthday.h created+160| ... | ... | @@ -0,0 +1,160 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_MONTHDAY_H | |
| 11 | #define _LIBCPP___CHRONO_MONTHDAY_H | |
| 12 | ||
| 13 | #include <__chrono/calendar.h> | |
| 14 | #include <__chrono/day.h> | |
| 15 | #include <__chrono/month.h> | |
| 16 | #include <__config> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | namespace chrono | |
| 27 | { | |
| 28 | ||
| 29 | class month_day { | |
| 30 | private: | |
| 31 | chrono::month __m; | |
| 32 | chrono::day __d; | |
| 33 | public: | |
| 34 | _LIBCPP_HIDE_FROM_ABI month_day() = default; | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept | |
| 36 | : __m{__mval}, __d{__dval} {} | |
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 38 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; } | |
| 39 | _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept; | |
| 40 | }; | |
| 41 | ||
| 42 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 43 | bool month_day::ok() const noexcept | |
| 44 | { | |
| 45 | if (!__m.ok()) return false; | |
| 46 | const unsigned __dval = static_cast<unsigned>(__d); | |
| 47 | if (__dval < 1 || __dval > 31) return false; | |
| 48 | if (__dval <= 29) return true; | |
| 49 | // Now we've got either 30 or 31 | |
| 50 | const unsigned __mval = static_cast<unsigned>(__m); | |
| 51 | if (__mval == 2) return false; | |
| 52 | if (__mval == 4 || __mval == 6 || __mval == 9 || __mval == 11) | |
| 53 | return __dval == 30; | |
| 54 | return true; | |
| 55 | } | |
| 56 | ||
| 57 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 58 | bool operator==(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 59 | { return __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 62 | bool operator!=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 63 | { return !(__lhs == __rhs); } | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 66 | month_day operator/(const month& __lhs, const day& __rhs) noexcept | |
| 67 | { return month_day{__lhs, __rhs}; } | |
| 68 | ||
| 69 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 70 | month_day operator/(const day& __lhs, const month& __rhs) noexcept | |
| 71 | { return __rhs / __lhs; } | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 74 | month_day operator/(const month& __lhs, int __rhs) noexcept | |
| 75 | { return __lhs / day(__rhs); } | |
| 76 | ||
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 78 | month_day operator/(int __lhs, const day& __rhs) noexcept | |
| 79 | { return month(__lhs) / __rhs; } | |
| 80 | ||
| 81 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 82 | month_day operator/(const day& __lhs, int __rhs) noexcept | |
| 83 | { return month(__rhs) / __lhs; } | |
| 84 | ||
| 85 | ||
| 86 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 87 | bool operator< (const month_day& __lhs, const month_day& __rhs) noexcept | |
| 88 | { return __lhs.month() != __rhs.month() ? __lhs.month() < __rhs.month() : __lhs.day() < __rhs.day(); } | |
| 89 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 91 | bool operator> (const month_day& __lhs, const month_day& __rhs) noexcept | |
| 92 | { return __rhs < __lhs; } | |
| 93 | ||
| 94 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 95 | bool operator<=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 96 | { return !(__rhs < __lhs);} | |
| 97 | ||
| 98 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 99 | bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept | |
| 100 | { return !(__lhs < __rhs); } | |
| 101 | ||
| 102 | ||
| 103 | ||
| 104 | class month_day_last { | |
| 105 | private: | |
| 106 | chrono::month __m; | |
| 107 | public: | |
| 108 | _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept | |
| 109 | : __m{__val} {} | |
| 110 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 111 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m.ok(); } | |
| 112 | }; | |
| 113 | ||
| 114 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 115 | bool operator==(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 116 | { return __lhs.month() == __rhs.month(); } | |
| 117 | ||
| 118 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 119 | bool operator!=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 120 | { return !(__lhs == __rhs); } | |
| 121 | ||
| 122 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 123 | bool operator< (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 124 | { return __lhs.month() < __rhs.month(); } | |
| 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 127 | bool operator> (const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 128 | { return __rhs < __lhs; } | |
| 129 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 131 | bool operator<=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 132 | { return !(__rhs < __lhs);} | |
| 133 | ||
| 134 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 135 | bool operator>=(const month_day_last& __lhs, const month_day_last& __rhs) noexcept | |
| 136 | { return !(__lhs < __rhs); } | |
| 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 139 | month_day_last operator/(const month& __lhs, last_spec) noexcept | |
| 140 | { return month_day_last{__lhs}; } | |
| 141 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 143 | month_day_last operator/(last_spec, const month& __rhs) noexcept | |
| 144 | { return month_day_last{__rhs}; } | |
| 145 | ||
| 146 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 147 | month_day_last operator/(int __lhs, last_spec) noexcept | |
| 148 | { return month_day_last{month(__lhs)}; } | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 151 | month_day_last operator/(last_spec, int __rhs) noexcept | |
| 152 | { return month_day_last{month(__rhs)}; } | |
| 153 | ||
| 154 | } // namespace chrono | |
| 155 | ||
| 156 | _LIBCPP_END_NAMESPACE_STD | |
| 157 | ||
| 158 | #endif // _LIBCPP_STD_VER > 17 | |
| 159 | ||
| 160 | #endif // _LIBCPP___CHRONO_MONTHDAY_H |
lib/libcxx/include/__chrono/steady_clock.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__config> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__chrono/system_clock.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <ctime> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__chrono/time_point.h+3-3| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -47,12 +47,12 @@ public: |
| 47 | 47 | // conversions |
| 48 | 48 | template <class _Duration2> |
| 49 | 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 50 | time_point(const time_point<clock, _Duration2>& t, | |
| 50 | time_point(const time_point<clock, _Duration2>& __t, | |
| 51 | 51 | typename enable_if |
| 52 | 52 | < |
| 53 | 53 | is_convertible<_Duration2, duration>::value |
| 54 | 54 | >::type* = nullptr) |
| 55 | : __d_(t.time_since_epoch()) {} | |
| 55 | : __d_(__t.time_since_epoch()) {} | |
| 56 | 56 | |
| 57 | 57 | // observer |
| 58 | 58 |
lib/libcxx/include/__chrono/weekday.h created+185| ... | ... | @@ -0,0 +1,185 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_WEEKDAY_H | |
| 11 | #define _LIBCPP___CHRONO_WEEKDAY_H | |
| 12 | ||
| 13 | #include <__chrono/calendar.h> | |
| 14 | #include <__chrono/duration.h> | |
| 15 | #include <__chrono/system_clock.h> | |
| 16 | #include <__chrono/time_point.h> | |
| 17 | #include <__config> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | namespace chrono | |
| 28 | { | |
| 29 | ||
| 30 | class weekday_indexed; | |
| 31 | class weekday_last; | |
| 32 | ||
| 33 | class weekday { | |
| 34 | private: | |
| 35 | unsigned char __wd; | |
| 36 | _LIBCPP_HIDE_FROM_ABI static constexpr unsigned char __weekday_from_days(int __days) noexcept; | |
| 37 | public: | |
| 38 | _LIBCPP_HIDE_FROM_ABI weekday() = default; | |
| 39 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(unsigned __val) noexcept : __wd(static_cast<unsigned char>(__val == 7 ? 0 : __val)) {} | |
| 40 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday(const sys_days& __sysd) noexcept | |
| 41 | : __wd(__weekday_from_days(__sysd.time_since_epoch().count())) {} | |
| 42 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr weekday(const local_days& __locd) noexcept | |
| 43 | : __wd(__weekday_from_days(__locd.time_since_epoch().count())) {} | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator++() noexcept { __wd = (__wd == 6 ? 0 : __wd + 1); return *this; } | |
| 46 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator++(int) noexcept { weekday __tmp = *this; ++(*this); return __tmp; } | |
| 47 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday& operator--() noexcept { __wd = (__wd == 0 ? 6 : __wd - 1); return *this; } | |
| 48 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator--(int) noexcept { weekday __tmp = *this; --(*this); return __tmp; } | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept; | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept; | |
| 51 | _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd; } | |
| 52 | _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd == 0u ? 7 : __wd; } | |
| 53 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd <= 6; } | |
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept; | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept; | |
| 56 | }; | |
| 57 | ||
| 58 | ||
| 59 | // https://howardhinnant.github.io/date_algorithms.html#weekday_from_days | |
| 60 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 61 | unsigned char weekday::__weekday_from_days(int __days) noexcept | |
| 62 | { | |
| 63 | return static_cast<unsigned char>( | |
| 64 | static_cast<unsigned>(__days >= -4 ? (__days+4) % 7 : (__days+5) % 7 + 6) | |
| 65 | ); | |
| 66 | } | |
| 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 69 | bool operator==(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 70 | { return __lhs.c_encoding() == __rhs.c_encoding(); } | |
| 71 | ||
| 72 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 73 | bool operator!=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 74 | { return !(__lhs == __rhs); } | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 77 | bool operator< (const weekday& __lhs, const weekday& __rhs) noexcept | |
| 78 | { return __lhs.c_encoding() < __rhs.c_encoding(); } | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 81 | bool operator> (const weekday& __lhs, const weekday& __rhs) noexcept | |
| 82 | { return __rhs < __lhs; } | |
| 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 85 | bool operator<=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 86 | { return !(__rhs < __lhs);} | |
| 87 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 89 | bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 90 | { return !(__lhs < __rhs); } | |
| 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 93 | weekday operator+(const weekday& __lhs, const days& __rhs) noexcept | |
| 94 | { | |
| 95 | auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count(); | |
| 96 | auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7; | |
| 97 | return weekday{static_cast<unsigned>(__mu - __yr * 7)}; | |
| 98 | } | |
| 99 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 101 | weekday operator+(const days& __lhs, const weekday& __rhs) noexcept | |
| 102 | { return __rhs + __lhs; } | |
| 103 | ||
| 104 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 105 | weekday operator-(const weekday& __lhs, const days& __rhs) noexcept | |
| 106 | { return __lhs + -__rhs; } | |
| 107 | ||
| 108 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 109 | days operator-(const weekday& __lhs, const weekday& __rhs) noexcept | |
| 110 | { | |
| 111 | const int __wdu = __lhs.c_encoding() - __rhs.c_encoding(); | |
| 112 | const int __wk = (__wdu >= 0 ? __wdu : __wdu-6) / 7; | |
| 113 | return days{__wdu - __wk * 7}; | |
| 114 | } | |
| 115 | ||
| 116 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 117 | weekday& weekday::operator+=(const days& __dd) noexcept | |
| 118 | { *this = *this + __dd; return *this; } | |
| 119 | ||
| 120 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 121 | weekday& weekday::operator-=(const days& __dd) noexcept | |
| 122 | { *this = *this - __dd; return *this; } | |
| 123 | ||
| 124 | class weekday_indexed { | |
| 125 | private: | |
| 126 | chrono::weekday __wd; | |
| 127 | unsigned char __idx; | |
| 128 | public: | |
| 129 | _LIBCPP_HIDE_FROM_ABI weekday_indexed() = default; | |
| 130 | _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept | |
| 131 | : __wd{__wdval}, __idx(__idxval) {} | |
| 132 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd; } | |
| 133 | _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx; } | |
| 134 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd.ok() && __idx >= 1 && __idx <= 5; } | |
| 135 | }; | |
| 136 | ||
| 137 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 138 | bool operator==(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept | |
| 139 | { return __lhs.weekday() == __rhs.weekday() && __lhs.index() == __rhs.index(); } | |
| 140 | ||
| 141 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 142 | bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noexcept | |
| 143 | { return !(__lhs == __rhs); } | |
| 144 | ||
| 145 | ||
| 146 | class weekday_last { | |
| 147 | private: | |
| 148 | chrono::weekday __wd; | |
| 149 | public: | |
| 150 | _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept | |
| 151 | : __wd{__val} {} | |
| 152 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd; } | |
| 153 | _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd.ok(); } | |
| 154 | }; | |
| 155 | ||
| 156 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 157 | bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept | |
| 158 | { return __lhs.weekday() == __rhs.weekday(); } | |
| 159 | ||
| 160 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 161 | bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept | |
| 162 | { return !(__lhs == __rhs); } | |
| 163 | ||
| 164 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 165 | weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; } | |
| 166 | ||
| 167 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 168 | weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; } | |
| 169 | ||
| 170 | ||
| 171 | inline constexpr weekday Sunday{0}; | |
| 172 | inline constexpr weekday Monday{1}; | |
| 173 | inline constexpr weekday Tuesday{2}; | |
| 174 | inline constexpr weekday Wednesday{3}; | |
| 175 | inline constexpr weekday Thursday{4}; | |
| 176 | inline constexpr weekday Friday{5}; | |
| 177 | inline constexpr weekday Saturday{6}; | |
| 178 | ||
| 179 | } // namespace chrono | |
| 180 | ||
| 181 | _LIBCPP_END_NAMESPACE_STD | |
| 182 | ||
| 183 | #endif // _LIBCPP_STD_VER > 17 | |
| 184 | ||
| 185 | #endif // _LIBCPP___CHRONO_WEEKDAY_H |
lib/libcxx/include/__chrono/year.h created+117| ... | ... | @@ -0,0 +1,117 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_YEAR_H | |
| 11 | #define _LIBCPP___CHRONO_YEAR_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__config> | |
| 15 | #include <limits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | namespace chrono | |
| 29 | { | |
| 30 | ||
| 31 | class year { | |
| 32 | private: | |
| 33 | short __y; | |
| 34 | public: | |
| 35 | _LIBCPP_HIDE_FROM_ABI year() = default; | |
| 36 | _LIBCPP_HIDE_FROM_ABI explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {} | |
| 37 | ||
| 38 | _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator++() noexcept { ++__y; return *this; } | |
| 39 | _LIBCPP_HIDE_FROM_ABI inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; } | |
| 40 | _LIBCPP_HIDE_FROM_ABI inline constexpr year& operator--() noexcept { --__y; return *this; } | |
| 41 | _LIBCPP_HIDE_FROM_ABI inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; } | |
| 42 | _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept; | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept; | |
| 44 | _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; } | |
| 45 | _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y}; } | |
| 46 | ||
| 47 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); } | |
| 48 | _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y; } | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept; | |
| 50 | _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; } | |
| 51 | _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{ 32767}; } | |
| 52 | }; | |
| 53 | ||
| 54 | ||
| 55 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 56 | bool operator==(const year& __lhs, const year& __rhs) noexcept | |
| 57 | { return static_cast<int>(__lhs) == static_cast<int>(__rhs); } | |
| 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 60 | bool operator!=(const year& __lhs, const year& __rhs) noexcept | |
| 61 | { return !(__lhs == __rhs); } | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 64 | bool operator< (const year& __lhs, const year& __rhs) noexcept | |
| 65 | { return static_cast<int>(__lhs) < static_cast<int>(__rhs); } | |
| 66 | ||
| 67 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 68 | bool operator> (const year& __lhs, const year& __rhs) noexcept | |
| 69 | { return __rhs < __lhs; } | |
| 70 | ||
| 71 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 72 | bool operator<=(const year& __lhs, const year& __rhs) noexcept | |
| 73 | { return !(__rhs < __lhs); } | |
| 74 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 76 | bool operator>=(const year& __lhs, const year& __rhs) noexcept | |
| 77 | { return !(__lhs < __rhs); } | |
| 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 80 | year operator+ (const year& __lhs, const years& __rhs) noexcept | |
| 81 | { return year(static_cast<int>(__lhs) + __rhs.count()); } | |
| 82 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 84 | year operator+ (const years& __lhs, const year& __rhs) noexcept | |
| 85 | { return __rhs + __lhs; } | |
| 86 | ||
| 87 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 88 | year operator- (const year& __lhs, const years& __rhs) noexcept | |
| 89 | { return __lhs + -__rhs; } | |
| 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 92 | years operator-(const year& __lhs, const year& __rhs) noexcept | |
| 93 | { return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)}; } | |
| 94 | ||
| 95 | ||
| 96 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 97 | year& year::operator+=(const years& __dy) noexcept | |
| 98 | { *this = *this + __dy; return *this; } | |
| 99 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 101 | year& year::operator-=(const years& __dy) noexcept | |
| 102 | { *this = *this - __dy; return *this; } | |
| 103 | ||
| 104 | _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept { | |
| 105 | static_assert(static_cast<int>(std::numeric_limits<decltype(__y)>::max()) == static_cast<int>(max())); | |
| 106 | return static_cast<int>(min()) <= __y; | |
| 107 | } | |
| 108 | ||
| 109 | } // namespace chrono | |
| 110 | ||
| 111 | _LIBCPP_END_NAMESPACE_STD | |
| 112 | ||
| 113 | #endif // _LIBCPP_STD_VER > 17 | |
| 114 | ||
| 115 | _LIBCPP_POP_MACROS | |
| 116 | ||
| 117 | #endif // _LIBCPP___CHRONO_YEAR_H |
lib/libcxx/include/__chrono/year_month.h created+114| ... | ... | @@ -0,0 +1,114 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_YEAR_MONTH_H | |
| 11 | #define _LIBCPP___CHRONO_YEAR_MONTH_H | |
| 12 | ||
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/month.h> | |
| 15 | #include <__chrono/year.h> | |
| 16 | #include <__config> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | namespace chrono | |
| 27 | { | |
| 28 | ||
| 29 | class year_month { | |
| 30 | chrono::year __y; | |
| 31 | chrono::month __m; | |
| 32 | public: | |
| 33 | _LIBCPP_HIDE_FROM_ABI year_month() = default; | |
| 34 | _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept | |
| 35 | : __y{__yval}, __m{__mval} {} | |
| 36 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; } | |
| 37 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 38 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept { this->__m += __dm; return *this; } | |
| 39 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept { this->__m -= __dm; return *this; } | |
| 40 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept { this->__y += __dy; return *this; } | |
| 41 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept { this->__y -= __dy; return *this; } | |
| 42 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok(); } | |
| 43 | }; | |
| 44 | ||
| 45 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 46 | year_month operator/(const year& __y, const month& __m) noexcept { return year_month{__y, __m}; } | |
| 47 | ||
| 48 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 49 | year_month operator/(const year& __y, int __m) noexcept { return year_month{__y, month(__m)}; } | |
| 50 | ||
| 51 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 52 | bool operator==(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 53 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month(); } | |
| 54 | ||
| 55 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 56 | bool operator!=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 57 | { return !(__lhs == __rhs); } | |
| 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 60 | bool operator< (const year_month& __lhs, const year_month& __rhs) noexcept | |
| 61 | { return __lhs.year() != __rhs.year() ? __lhs.year() < __rhs.year() : __lhs.month() < __rhs.month(); } | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 64 | bool operator> (const year_month& __lhs, const year_month& __rhs) noexcept | |
| 65 | { return __rhs < __lhs; } | |
| 66 | ||
| 67 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 68 | bool operator<=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 69 | { return !(__rhs < __lhs);} | |
| 70 | ||
| 71 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 72 | bool operator>=(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 73 | { return !(__lhs < __rhs); } | |
| 74 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 76 | year_month operator+(const year_month& __lhs, const months& __rhs) noexcept | |
| 77 | { | |
| 78 | int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count(); | |
| 79 | const int __dy = (__dmi >= 0 ? __dmi : __dmi-11) / 12; | |
| 80 | __dmi = __dmi - __dy * 12 + 1; | |
| 81 | return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi)); | |
| 82 | } | |
| 83 | ||
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 85 | year_month operator+(const months& __lhs, const year_month& __rhs) noexcept | |
| 86 | { return __rhs + __lhs; } | |
| 87 | ||
| 88 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 89 | year_month operator+(const year_month& __lhs, const years& __rhs) noexcept | |
| 90 | { return (__lhs.year() + __rhs) / __lhs.month(); } | |
| 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 93 | year_month operator+(const years& __lhs, const year_month& __rhs) noexcept | |
| 94 | { return __rhs + __lhs; } | |
| 95 | ||
| 96 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 97 | months operator-(const year_month& __lhs, const year_month& __rhs) noexcept | |
| 98 | { return (__lhs.year() - __rhs.year()) + months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month())); } | |
| 99 | ||
| 100 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 101 | year_month operator-(const year_month& __lhs, const months& __rhs) noexcept | |
| 102 | { return __lhs + -__rhs; } | |
| 103 | ||
| 104 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 105 | year_month operator-(const year_month& __lhs, const years& __rhs) noexcept | |
| 106 | { return __lhs + -__rhs; } | |
| 107 | ||
| 108 | } // namespace chrono | |
| 109 | ||
| 110 | _LIBCPP_END_NAMESPACE_STD | |
| 111 | ||
| 112 | #endif // _LIBCPP_STD_VER > 17 | |
| 113 | ||
| 114 | #endif // _LIBCPP___CHRONO_YEAR_MONTH_H |
lib/libcxx/include/__chrono/year_month_day.h created+323| ... | ... | @@ -0,0 +1,323 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_YEAR_MONTH_DAY_H | |
| 11 | #define _LIBCPP___CHRONO_YEAR_MONTH_DAY_H | |
| 12 | ||
| 13 | #include <__chrono/calendar.h> | |
| 14 | #include <__chrono/day.h> | |
| 15 | #include <__chrono/duration.h> | |
| 16 | #include <__chrono/month.h> | |
| 17 | #include <__chrono/monthday.h> | |
| 18 | #include <__chrono/system_clock.h> | |
| 19 | #include <__chrono/time_point.h> | |
| 20 | #include <__chrono/year.h> | |
| 21 | #include <__chrono/year_month.h> | |
| 22 | #include <__config> | |
| 23 | #include <limits> | |
| 24 | ||
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | namespace chrono | |
| 34 | { | |
| 35 | ||
| 36 | class year_month_day_last; | |
| 37 | ||
| 38 | class year_month_day { | |
| 39 | private: | |
| 40 | chrono::year __y; | |
| 41 | chrono::month __m; | |
| 42 | chrono::day __d; | |
| 43 | public: | |
| 44 | _LIBCPP_HIDE_FROM_ABI year_month_day() = default; | |
| 45 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day( | |
| 46 | const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept | |
| 47 | : __y{__yval}, __m{__mval}, __d{__dval} {} | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day(const year_month_day_last& __ymdl) noexcept; | |
| 49 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day(const sys_days& __sysd) noexcept | |
| 50 | : year_month_day(__from_days(__sysd.time_since_epoch())) {} | |
| 51 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_day(const local_days& __locd) noexcept | |
| 52 | : year_month_day(__from_days(__locd.time_since_epoch())) {} | |
| 53 | ||
| 54 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const months& __dm) noexcept; | |
| 55 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const months& __dm) noexcept; | |
| 56 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept; | |
| 57 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept; | |
| 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; } | |
| 60 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 61 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d; } | |
| 62 | _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } | |
| 63 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept; | |
| 66 | ||
| 67 | _LIBCPP_HIDE_FROM_ABI static constexpr year_month_day __from_days(days __d) noexcept; | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept; | |
| 69 | }; | |
| 70 | ||
| 71 | ||
| 72 | // https://howardhinnant.github.io/date_algorithms.html#civil_from_days | |
| 73 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 74 | year_month_day year_month_day::__from_days(days __d) noexcept | |
| 75 | { | |
| 76 | static_assert(numeric_limits<unsigned>::digits >= 18, ""); | |
| 77 | static_assert(numeric_limits<int>::digits >= 20 , ""); | |
| 78 | const int __z = __d.count() + 719468; | |
| 79 | const int __era = (__z >= 0 ? __z : __z - 146096) / 146097; | |
| 80 | const unsigned __doe = static_cast<unsigned>(__z - __era * 146097); // [0, 146096] | |
| 81 | const unsigned __yoe = (__doe - __doe/1460 + __doe/36524 - __doe/146096) / 365; // [0, 399] | |
| 82 | const int __yr = static_cast<int>(__yoe) + __era * 400; | |
| 83 | const unsigned __doy = __doe - (365 * __yoe + __yoe/4 - __yoe/100); // [0, 365] | |
| 84 | const unsigned __mp = (5 * __doy + 2)/153; // [0, 11] | |
| 85 | const unsigned __dy = __doy - (153 * __mp + 2)/5 + 1; // [1, 31] | |
| 86 | const unsigned __mth = __mp + (__mp < 10 ? 3 : -9); // [1, 12] | |
| 87 | return year_month_day{chrono::year{__yr + (__mth <= 2)}, chrono::month{__mth}, chrono::day{__dy}}; | |
| 88 | } | |
| 89 | ||
| 90 | // https://howardhinnant.github.io/date_algorithms.html#days_from_civil | |
| 91 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 92 | days year_month_day::__to_days() const noexcept | |
| 93 | { | |
| 94 | static_assert(numeric_limits<unsigned>::digits >= 18, ""); | |
| 95 | static_assert(numeric_limits<int>::digits >= 20 , ""); | |
| 96 | ||
| 97 | const int __yr = static_cast<int>(__y) - (__m <= February); | |
| 98 | const unsigned __mth = static_cast<unsigned>(__m); | |
| 99 | const unsigned __dy = static_cast<unsigned>(__d); | |
| 100 | ||
| 101 | const int __era = (__yr >= 0 ? __yr : __yr - 399) / 400; | |
| 102 | const unsigned __yoe = static_cast<unsigned>(__yr - __era * 400); // [0, 399] | |
| 103 | const unsigned __doy = (153 * (__mth + (__mth > 2 ? -3 : 9)) + 2) / 5 + __dy-1; // [0, 365] | |
| 104 | const unsigned __doe = __yoe * 365 + __yoe/4 - __yoe/100 + __doy; // [0, 146096] | |
| 105 | return days{__era * 146097 + static_cast<int>(__doe) - 719468}; | |
| 106 | } | |
| 107 | ||
| 108 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 109 | bool operator==(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 110 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.day() == __rhs.day(); } | |
| 111 | ||
| 112 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 113 | bool operator!=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 114 | { return !(__lhs == __rhs); } | |
| 115 | ||
| 116 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 117 | bool operator< (const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 118 | { | |
| 119 | if (__lhs.year() < __rhs.year()) return true; | |
| 120 | if (__lhs.year() > __rhs.year()) return false; | |
| 121 | if (__lhs.month() < __rhs.month()) return true; | |
| 122 | if (__lhs.month() > __rhs.month()) return false; | |
| 123 | return __lhs.day() < __rhs.day(); | |
| 124 | } | |
| 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 127 | bool operator> (const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 128 | { return __rhs < __lhs; } | |
| 129 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 131 | bool operator<=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 132 | { return !(__rhs < __lhs);} | |
| 133 | ||
| 134 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 135 | bool operator>=(const year_month_day& __lhs, const year_month_day& __rhs) noexcept | |
| 136 | { return !(__lhs < __rhs); } | |
| 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 139 | year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept | |
| 140 | { return year_month_day{__lhs.year(), __lhs.month(), __rhs}; } | |
| 141 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 143 | year_month_day operator/(const year_month& __lhs, int __rhs) noexcept | |
| 144 | { return __lhs / day(__rhs); } | |
| 145 | ||
| 146 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 147 | year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept | |
| 148 | { return __lhs / __rhs.month() / __rhs.day(); } | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 151 | year_month_day operator/(int __lhs, const month_day& __rhs) noexcept | |
| 152 | { return year(__lhs) / __rhs; } | |
| 153 | ||
| 154 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 155 | year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept | |
| 156 | { return __rhs / __lhs; } | |
| 157 | ||
| 158 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 159 | year_month_day operator/(const month_day& __lhs, int __rhs) noexcept | |
| 160 | { return year(__rhs) / __lhs; } | |
| 161 | ||
| 162 | ||
| 163 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 164 | year_month_day operator+(const year_month_day& __lhs, const months& __rhs) noexcept | |
| 165 | { return (__lhs.year()/__lhs.month() + __rhs)/__lhs.day(); } | |
| 166 | ||
| 167 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 168 | year_month_day operator+(const months& __lhs, const year_month_day& __rhs) noexcept | |
| 169 | { return __rhs + __lhs; } | |
| 170 | ||
| 171 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 172 | year_month_day operator-(const year_month_day& __lhs, const months& __rhs) noexcept | |
| 173 | { return __lhs + -__rhs; } | |
| 174 | ||
| 175 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 176 | year_month_day operator+(const year_month_day& __lhs, const years& __rhs) noexcept | |
| 177 | { return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day(); } | |
| 178 | ||
| 179 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 180 | year_month_day operator+(const years& __lhs, const year_month_day& __rhs) noexcept | |
| 181 | { return __rhs + __lhs; } | |
| 182 | ||
| 183 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 184 | year_month_day operator-(const year_month_day& __lhs, const years& __rhs) noexcept | |
| 185 | { return __lhs + -__rhs; } | |
| 186 | ||
| 187 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 188 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 189 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 190 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 191 | ||
| 192 | class year_month_day_last { | |
| 193 | private: | |
| 194 | chrono::year __y; | |
| 195 | chrono::month_day_last __mdl; | |
| 196 | public: | |
| 197 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last(const year& __yval, const month_day_last& __mdlval) noexcept | |
| 198 | : __y{__yval}, __mdl{__mdlval} {} | |
| 199 | ||
| 200 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const months& __m) noexcept; | |
| 201 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const months& __m) noexcept; | |
| 202 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept; | |
| 203 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept; | |
| 204 | ||
| 205 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; } | |
| 206 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl.month(); } | |
| 207 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl; } | |
| 208 | _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept; | |
| 209 | _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{year()/month()/day()}; } | |
| 210 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{year()/month()/day()}; } | |
| 211 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __mdl.ok(); } | |
| 212 | }; | |
| 213 | ||
| 214 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 215 | chrono::day year_month_day_last::day() const noexcept | |
| 216 | { | |
| 217 | constexpr chrono::day __d[] = | |
| 218 | { | |
| 219 | chrono::day(31), chrono::day(28), chrono::day(31), | |
| 220 | chrono::day(30), chrono::day(31), chrono::day(30), | |
| 221 | chrono::day(31), chrono::day(31), chrono::day(30), | |
| 222 | chrono::day(31), chrono::day(30), chrono::day(31) | |
| 223 | }; | |
| 224 | return (month() != February || !__y.is_leap()) && month().ok() ? | |
| 225 | __d[static_cast<unsigned>(month()) - 1] : chrono::day{29}; | |
| 226 | } | |
| 227 | ||
| 228 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 229 | bool operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 230 | { return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last(); } | |
| 231 | ||
| 232 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 233 | bool operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 234 | { return !(__lhs == __rhs); } | |
| 235 | ||
| 236 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 237 | bool operator< (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 238 | { | |
| 239 | if (__lhs.year() < __rhs.year()) return true; | |
| 240 | if (__lhs.year() > __rhs.year()) return false; | |
| 241 | return __lhs.month_day_last() < __rhs.month_day_last(); | |
| 242 | } | |
| 243 | ||
| 244 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 245 | bool operator> (const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 246 | { return __rhs < __lhs; } | |
| 247 | ||
| 248 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 249 | bool operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 250 | { return !(__rhs < __lhs);} | |
| 251 | ||
| 252 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 253 | bool operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept | |
| 254 | { return !(__lhs < __rhs); } | |
| 255 | ||
| 256 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 257 | year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept | |
| 258 | { return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}}; } | |
| 259 | ||
| 260 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 261 | year_month_day_last operator/(const year& __lhs, const month_day_last& __rhs) noexcept | |
| 262 | { return year_month_day_last{__lhs, __rhs}; } | |
| 263 | ||
| 264 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 265 | year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept | |
| 266 | { return year_month_day_last{year{__lhs}, __rhs}; } | |
| 267 | ||
| 268 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last | |
| 269 | operator/(const month_day_last& __lhs, const year& __rhs) noexcept | |
| 270 | { return __rhs / __lhs; } | |
| 271 | ||
| 272 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 273 | year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept | |
| 274 | { return year{__rhs} / __lhs; } | |
| 275 | ||
| 276 | ||
| 277 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 278 | year_month_day_last operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept | |
| 279 | { return (__lhs.year() / __lhs.month() + __rhs) / last; } | |
| 280 | ||
| 281 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 282 | year_month_day_last operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept | |
| 283 | { return __rhs + __lhs; } | |
| 284 | ||
| 285 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 286 | year_month_day_last operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept | |
| 287 | { return __lhs + (-__rhs); } | |
| 288 | ||
| 289 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 290 | year_month_day_last operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept | |
| 291 | { return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()}; } | |
| 292 | ||
| 293 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 294 | year_month_day_last operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept | |
| 295 | { return __rhs + __lhs; } | |
| 296 | ||
| 297 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 298 | year_month_day_last operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept | |
| 299 | { return __lhs + (-__rhs); } | |
| 300 | ||
| 301 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 302 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 303 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 304 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 305 | ||
| 306 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 307 | year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept | |
| 308 | : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {} | |
| 309 | ||
| 310 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 311 | bool year_month_day::ok() const noexcept | |
| 312 | { | |
| 313 | if (!__y.ok() || !__m.ok()) return false; | |
| 314 | return chrono::day{1} <= __d && __d <= (__y / __m / last).day(); | |
| 315 | } | |
| 316 | ||
| 317 | } // namespace chrono | |
| 318 | ||
| 319 | _LIBCPP_END_NAMESPACE_STD | |
| 320 | ||
| 321 | #endif // _LIBCPP_STD_VER > 17 | |
| 322 | ||
| 323 | #endif // _LIBCPP___CHRONO_YEAR_MONTH_DAY_H |
lib/libcxx/include/__chrono/year_month_weekday.h created+255| ... | ... | @@ -0,0 +1,255 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H | |
| 11 | #define _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H | |
| 12 | ||
| 13 | #include <__chrono/calendar.h> | |
| 14 | #include <__chrono/day.h> | |
| 15 | #include <__chrono/duration.h> | |
| 16 | #include <__chrono/month.h> | |
| 17 | #include <__chrono/month_weekday.h> | |
| 18 | #include <__chrono/system_clock.h> | |
| 19 | #include <__chrono/time_point.h> | |
| 20 | #include <__chrono/weekday.h> | |
| 21 | #include <__chrono/year.h> | |
| 22 | #include <__chrono/year_month.h> | |
| 23 | #include <__chrono/year_month_day.h> | |
| 24 | #include <__config> | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 17 | |
| 31 | ||
| 32 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 33 | ||
| 34 | namespace chrono | |
| 35 | { | |
| 36 | ||
| 37 | class year_month_weekday { | |
| 38 | chrono::year __y; | |
| 39 | chrono::month __m; | |
| 40 | chrono::weekday_indexed __wdi; | |
| 41 | public: | |
| 42 | _LIBCPP_HIDE_FROM_ABI year_month_weekday() = default; | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const chrono::year& __yval, const chrono::month& __mval, | |
| 44 | const chrono::weekday_indexed& __wdival) noexcept | |
| 45 | : __y{__yval}, __m{__mval}, __wdi{__wdival} {} | |
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday(const sys_days& __sysd) noexcept | |
| 47 | : year_month_weekday(__from_days(__sysd.time_since_epoch())) {} | |
| 48 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr year_month_weekday(const local_days& __locd) noexcept | |
| 49 | : year_month_weekday(__from_days(__locd.time_since_epoch())) {} | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const months&) noexcept; | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const months&) noexcept; | |
| 52 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept; | |
| 53 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept; | |
| 54 | ||
| 55 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; } | |
| 56 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 57 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi.weekday(); } | |
| 58 | _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi.index(); } | |
| 59 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi; } | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } | |
| 62 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } | |
| 63 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept | |
| 64 | { | |
| 65 | if (!__y.ok() || !__m.ok() || !__wdi.ok()) return false; | |
| 66 | if (__wdi.index() <= 4) return true; | |
| 67 | auto __nth_weekday_day = | |
| 68 | __wdi.weekday() - | |
| 69 | chrono::weekday{static_cast<sys_days>(__y / __m / 1)} + | |
| 70 | days{(__wdi.index() - 1) * 7 + 1}; | |
| 71 | return static_cast<unsigned>(__nth_weekday_day.count()) <= | |
| 72 | static_cast<unsigned>((__y / __m / last).day()); | |
| 73 | } | |
| 74 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI static constexpr year_month_weekday __from_days(days __d) noexcept; | |
| 76 | _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept; | |
| 77 | }; | |
| 78 | ||
| 79 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 80 | year_month_weekday year_month_weekday::__from_days(days __d) noexcept | |
| 81 | { | |
| 82 | const sys_days __sysd{__d}; | |
| 83 | const chrono::weekday __wd = chrono::weekday(__sysd); | |
| 84 | const year_month_day __ymd = year_month_day(__sysd); | |
| 85 | return year_month_weekday{__ymd.year(), __ymd.month(), | |
| 86 | __wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]}; | |
| 87 | } | |
| 88 | ||
| 89 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 90 | days year_month_weekday::__to_days() const noexcept | |
| 91 | { | |
| 92 | const sys_days __sysd = sys_days(__y/__m/1); | |
| 93 | return (__sysd + (__wdi.weekday() - chrono::weekday(__sysd) + days{(__wdi.index()-1)*7})) | |
| 94 | .time_since_epoch(); | |
| 95 | } | |
| 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 98 | bool operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept | |
| 99 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed(); } | |
| 100 | ||
| 101 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 102 | bool operator!=(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noexcept | |
| 103 | { return !(__lhs == __rhs); } | |
| 104 | ||
| 105 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 106 | year_month_weekday operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept | |
| 107 | { return year_month_weekday{__lhs.year(), __lhs.month(), __rhs}; } | |
| 108 | ||
| 109 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 110 | year_month_weekday operator/(const year& __lhs, const month_weekday& __rhs) noexcept | |
| 111 | { return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()}; } | |
| 112 | ||
| 113 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 114 | year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept | |
| 115 | { return year(__lhs) / __rhs; } | |
| 116 | ||
| 117 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 118 | year_month_weekday operator/(const month_weekday& __lhs, const year& __rhs) noexcept | |
| 119 | { return __rhs / __lhs; } | |
| 120 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 122 | year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept | |
| 123 | { return year(__rhs) / __lhs; } | |
| 124 | ||
| 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 127 | year_month_weekday operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept | |
| 128 | { return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed(); } | |
| 129 | ||
| 130 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 131 | year_month_weekday operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept | |
| 132 | { return __rhs + __lhs; } | |
| 133 | ||
| 134 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 135 | year_month_weekday operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept | |
| 136 | { return __lhs + (-__rhs); } | |
| 137 | ||
| 138 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 139 | year_month_weekday operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept | |
| 140 | { return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()}; } | |
| 141 | ||
| 142 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 143 | year_month_weekday operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept | |
| 144 | { return __rhs + __lhs; } | |
| 145 | ||
| 146 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 147 | year_month_weekday operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept | |
| 148 | { return __lhs + (-__rhs); } | |
| 149 | ||
| 150 | ||
| 151 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 152 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 153 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 154 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 155 | ||
| 156 | class year_month_weekday_last { | |
| 157 | private: | |
| 158 | chrono::year __y; | |
| 159 | chrono::month __m; | |
| 160 | chrono::weekday_last __wdl; | |
| 161 | public: | |
| 162 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last(const chrono::year& __yval, const chrono::month& __mval, | |
| 163 | const chrono::weekday_last& __wdlval) noexcept | |
| 164 | : __y{__yval}, __m{__mval}, __wdl{__wdlval} {} | |
| 165 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const months& __dm) noexcept; | |
| 166 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const months& __dm) noexcept; | |
| 167 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept; | |
| 168 | _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept; | |
| 169 | ||
| 170 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y; } | |
| 171 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m; } | |
| 172 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl.weekday(); } | |
| 173 | _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl; } | |
| 174 | _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; } | |
| 175 | _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; } | |
| 176 | _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); } | |
| 177 | ||
| 178 | _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept; | |
| 179 | ||
| 180 | }; | |
| 181 | ||
| 182 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 183 | days year_month_weekday_last::__to_days() const noexcept | |
| 184 | { | |
| 185 | const sys_days __last = sys_days{__y/__m/last}; | |
| 186 | return (__last - (chrono::weekday{__last} - __wdl.weekday())).time_since_epoch(); | |
| 187 | ||
| 188 | } | |
| 189 | ||
| 190 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 191 | bool operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 192 | { return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last(); } | |
| 193 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 195 | bool operator!=(const year_month_weekday_last& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 196 | { return !(__lhs == __rhs); } | |
| 197 | ||
| 198 | ||
| 199 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 200 | year_month_weekday_last operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept | |
| 201 | { return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs}; } | |
| 202 | ||
| 203 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 204 | year_month_weekday_last operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept | |
| 205 | { return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()}; } | |
| 206 | ||
| 207 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 208 | year_month_weekday_last operator/(int __lhs, const month_weekday_last& __rhs) noexcept | |
| 209 | { return year(__lhs) / __rhs; } | |
| 210 | ||
| 211 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 212 | year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept | |
| 213 | { return __rhs / __lhs; } | |
| 214 | ||
| 215 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 216 | year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept | |
| 217 | { return year(__rhs) / __lhs; } | |
| 218 | ||
| 219 | ||
| 220 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 221 | year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept | |
| 222 | { return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last(); } | |
| 223 | ||
| 224 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 225 | year_month_weekday_last operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 226 | { return __rhs + __lhs; } | |
| 227 | ||
| 228 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 229 | year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept | |
| 230 | { return __lhs + (-__rhs); } | |
| 231 | ||
| 232 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 233 | year_month_weekday_last operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept | |
| 234 | { return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()}; } | |
| 235 | ||
| 236 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 237 | year_month_weekday_last operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept | |
| 238 | { return __rhs + __lhs; } | |
| 239 | ||
| 240 | _LIBCPP_HIDE_FROM_ABI inline constexpr | |
| 241 | year_month_weekday_last operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept | |
| 242 | { return __lhs + (-__rhs); } | |
| 243 | ||
| 244 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const months& __dm) noexcept { *this = *this + __dm; return *this; } | |
| 245 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const months& __dm) noexcept { *this = *this - __dm; return *this; } | |
| 246 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; } | |
| 247 | _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last& year_month_weekday_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; } | |
| 248 | ||
| 249 | } // namespace chrono | |
| 250 | ||
| 251 | _LIBCPP_END_NAMESPACE_STD | |
| 252 | ||
| 253 | #endif // _LIBCPP_STD_VER > 17 | |
| 254 | ||
| 255 | #endif // _LIBCPP___CHRONO_YEAR_MONTH_WEEKDAY_H |
lib/libcxx/include/__compare/common_comparison_category.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__compare/compare_partial_order_fallback.h+3-3| ... | ... | @@ -17,12 +17,12 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | 26 | |
| 27 | 27 | // [cmp.alg] |
| 28 | 28 | namespace __compare_partial_order_fallback { |
| ... | ... | @@ -66,7 +66,7 @@ inline namespace __cpo { |
| 66 | 66 | inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{}; |
| 67 | 67 | } // namespace __cpo |
| 68 | 68 | |
| 69 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 69 | #endif // _LIBCPP_STD_VER > 17 | |
| 70 | 70 | |
| 71 | 71 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 72 |
lib/libcxx/include/__compare/compare_strong_order_fallback.h+3-3| ... | ... | @@ -17,12 +17,12 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | 26 | |
| 27 | 27 | // [cmp.alg] |
| 28 | 28 | namespace __compare_strong_order_fallback { |
| ... | ... | @@ -63,7 +63,7 @@ inline namespace __cpo { |
| 63 | 63 | inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{}; |
| 64 | 64 | } // namespace __cpo |
| 65 | 65 | |
| 66 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 66 | #endif // _LIBCPP_STD_VER > 17 | |
| 67 | 67 | |
| 68 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 69 | 69 |
lib/libcxx/include/__compare/compare_three_way.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <__utility/forward.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | struct _LIBCPP_TEMPLATE_VIS compare_three_way |
| 26 | 26 | { |
| ... | ... | @@ -34,7 +34,7 @@ struct _LIBCPP_TEMPLATE_VIS compare_three_way |
| 34 | 34 | using is_transparent = void; |
| 35 | 35 | }; |
| 36 | 36 | |
| 37 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 37 | #endif // _LIBCPP_STD_VER > 17 | |
| 38 | 38 | |
| 39 | 39 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 40 |
lib/libcxx/include/__compare/compare_three_way_result.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__compare/compare_weak_order_fallback.h+3-3| ... | ... | @@ -17,12 +17,12 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | 26 | |
| 27 | 27 | // [cmp.alg] |
| 28 | 28 | namespace __compare_weak_order_fallback { |
| ... | ... | @@ -63,7 +63,7 @@ inline namespace __cpo { |
| 63 | 63 | inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{}; |
| 64 | 64 | } // namespace __cpo |
| 65 | 65 | |
| 66 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 66 | #endif // _LIBCPP_STD_VER > 17 | |
| 67 | 67 | |
| 68 | 68 | _LIBCPP_END_NAMESPACE_STD |
| 69 | 69 |
lib/libcxx/include/__compare/is_eq.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__compare/ordering.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__compare/partial_order.h+3-3| ... | ... | @@ -18,12 +18,12 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | 27 | |
| 28 | 28 | // [cmp.alg] |
| 29 | 29 | namespace __partial_order { |
| ... | ... | @@ -64,7 +64,7 @@ inline namespace __cpo { |
| 64 | 64 | inline constexpr auto partial_order = __partial_order::__fn{}; |
| 65 | 65 | } // namespace __cpo |
| 66 | 66 | |
| 67 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 67 | #endif // _LIBCPP_STD_VER > 17 | |
| 68 | 68 | |
| 69 | 69 | _LIBCPP_END_NAMESPACE_STD |
| 70 | 70 |
lib/libcxx/include/__compare/strong_order.h+3-3| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | #include <type_traits> |
| 22 | 22 | |
| 23 | 23 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 24 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 25 | 25 | #endif |
| 26 | 26 | |
| 27 | 27 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS |
| 29 | 29 | |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 32 | #if _LIBCPP_STD_VER > 17 | |
| 33 | 33 | |
| 34 | 34 | // [cmp.alg] |
| 35 | 35 | namespace __strong_order { |
| ... | ... | @@ -127,7 +127,7 @@ inline namespace __cpo { |
| 127 | 127 | inline constexpr auto strong_order = __strong_order::__fn{}; |
| 128 | 128 | } // namespace __cpo |
| 129 | 129 | |
| 130 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 130 | #endif // _LIBCPP_STD_VER > 17 | |
| 131 | 131 | |
| 132 | 132 | _LIBCPP_END_NAMESPACE_STD |
| 133 | 133 |
lib/libcxx/include/__compare/synth_three_way.h+4-4| ... | ... | @@ -16,12 +16,12 @@ |
| 16 | 16 | #include <__utility/declval.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | 25 | |
| 26 | 26 | // [expos.only.func] |
| 27 | 27 | |
| ... | ... | @@ -42,9 +42,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | 44 | template <class _Tp, class _Up = _Tp> |
| 45 | using __synth_three_way_result = decltype(__synth_three_way(declval<_Tp&>(), declval<_Up&>())); | |
| 45 | using __synth_three_way_result = decltype(std::__synth_three_way(declval<_Tp&>(), declval<_Up&>())); | |
| 46 | 46 | |
| 47 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 47 | #endif // _LIBCPP_STD_VER > 17 | |
| 48 | 48 | |
| 49 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 50 | 50 |
lib/libcxx/include/__compare/three_way_comparable.h+3-3| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | 28 | |
| 29 | 29 | template<class _Tp, class _Cat> |
| 30 | 30 | concept __compares_as = |
| ... | ... | @@ -51,7 +51,7 @@ concept three_way_comparable_with = |
| 51 | 51 | { __u <=> __t } -> __compares_as<_Cat>; |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 54 | #endif // _LIBCPP_STD_VER > 17 | |
| 55 | 55 | |
| 56 | 56 | _LIBCPP_END_NAMESPACE_STD |
| 57 | 57 |
lib/libcxx/include/__compare/weak_order.h+3-3| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | 28 | |
| 29 | 29 | // [cmp.alg] |
| 30 | 30 | namespace __weak_order { |
| ... | ... | @@ -93,7 +93,7 @@ inline namespace __cpo { |
| 93 | 93 | inline constexpr auto weak_order = __weak_order::__fn{}; |
| 94 | 94 | } // namespace __cpo |
| 95 | 95 | |
| 96 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 96 | #endif // _LIBCPP_STD_VER > 17 | |
| 97 | 97 | |
| 98 | 98 | _LIBCPP_END_NAMESPACE_STD |
| 99 | 99 |
lib/libcxx/include/__concepts/arithmetic.h+5-3| ... | ... | @@ -10,15 +10,17 @@ |
| 10 | 10 | #define _LIBCPP___CONCEPTS_ARITHMETIC_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__type_traits/is_signed_integer.h> | |
| 14 | #include <__type_traits/is_unsigned_integer.h> | |
| 13 | 15 | #include <type_traits> |
| 14 | 16 | |
| 15 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 17 | 19 | #endif |
| 18 | 20 | |
| 19 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 22 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 24 | |
| 23 | 25 | // [concepts.arithmetic], arithmetic concepts |
| 24 | 26 | |
| ... | ... | @@ -41,7 +43,7 @@ concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value; |
| 41 | 43 | template <class _Tp> |
| 42 | 44 | concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value; |
| 43 | 45 | |
| 44 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 46 | #endif // _LIBCPP_STD_VER > 17 | |
| 45 | 47 | |
| 46 | 48 | _LIBCPP_END_NAMESPACE_STD |
| 47 | 49 |
lib/libcxx/include/__concepts/assignable.h+3-3| ... | ... | @@ -16,12 +16,12 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | 25 | |
| 26 | 26 | // [concept.assignable] |
| 27 | 27 | |
| ... | ... | @@ -33,7 +33,7 @@ concept assignable_from = |
| 33 | 33 | { __lhs = _VSTD::forward<_Rhs>(__rhs) } -> same_as<_Lhs>; |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 36 | #endif // _LIBCPP_STD_VER > 17 | |
| 37 | 37 | |
| 38 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 39 | 39 |
lib/libcxx/include/__concepts/boolean_testable.h+3-3| ... | ... | @@ -14,12 +14,12 @@ |
| 14 | 14 | #include <__utility/forward.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | 23 | |
| 24 | 24 | // [concepts.booleantestable] |
| 25 | 25 | |
| ... | ... | @@ -31,7 +31,7 @@ concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t) |
| 31 | 31 | { !_VSTD::forward<_Tp>(__t) } -> __boolean_testable_impl; |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 34 | #endif // _LIBCPP_STD_VER > 17 | |
| 35 | 35 | |
| 36 | 36 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 37 |
lib/libcxx/include/__concepts/class_or_enum.h+4-3| ... | ... | @@ -13,12 +13,12 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 22 | |
| 23 | 23 | // Whether a type is a class type or enumeration type according to the Core wording. |
| 24 | 24 | |
| ... | ... | @@ -26,10 +26,11 @@ template<class _Tp> |
| 26 | 26 | concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>; |
| 27 | 27 | |
| 28 | 28 | // Work around Clang bug https://llvm.org/PR52970 |
| 29 | // TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14). | |
| 29 | 30 | template<class _Tp> |
| 30 | 31 | concept __workaround_52970 = is_class_v<__uncvref_t<_Tp>> || is_union_v<__uncvref_t<_Tp>>; |
| 31 | 32 | |
| 32 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | #endif // _LIBCPP_STD_VER > 17 | |
| 33 | 34 | |
| 34 | 35 | _LIBCPP_END_NAMESPACE_STD |
| 35 | 36 |
lib/libcxx/include/__concepts/common_reference_with.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.commonref] |
| 26 | 26 | |
| ... | ... | @@ -30,7 +30,7 @@ concept common_reference_with = |
| 30 | 30 | convertible_to<_Tp, common_reference_t<_Tp, _Up>> && |
| 31 | 31 | convertible_to<_Up, common_reference_t<_Tp, _Up>>; |
| 32 | 32 | |
| 33 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | #endif // _LIBCPP_STD_VER > 17 | |
| 34 | 34 | |
| 35 | 35 | _LIBCPP_END_NAMESPACE_STD |
| 36 | 36 |
lib/libcxx/include/__concepts/common_with.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.common] |
| 26 | 26 | |
| ... | ... | @@ -40,7 +40,7 @@ concept common_with = |
| 40 | 40 | add_lvalue_reference_t<const _Tp>, |
| 41 | 41 | add_lvalue_reference_t<const _Up>>>; |
| 42 | 42 | |
| 43 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 43 | #endif // _LIBCPP_STD_VER > 17 | |
| 44 | 44 | |
| 45 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 46 |
lib/libcxx/include/__concepts/constructible.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.constructible] |
| 26 | 26 | template<class _Tp, class... _Args> |
| ... | ... | @@ -49,7 +49,7 @@ concept copy_constructible = |
| 49 | 49 | constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> && |
| 50 | 50 | constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>; |
| 51 | 51 | |
| 52 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 52 | #endif // _LIBCPP_STD_VER > 17 | |
| 53 | 53 | |
| 54 | 54 | _LIBCPP_END_NAMESPACE_STD |
| 55 | 55 |
lib/libcxx/include/__concepts/convertible_to.h+3-3| ... | ... | @@ -14,12 +14,12 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | 23 | |
| 24 | 24 | // [concept.convertible] |
| 25 | 25 | |
| ... | ... | @@ -30,7 +30,7 @@ concept convertible_to = |
| 30 | 30 | static_cast<_To>(declval<_From>()); |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | #endif // _LIBCPP_STD_VER > 17 | |
| 34 | 34 | |
| 35 | 35 | _LIBCPP_END_NAMESPACE_STD |
| 36 | 36 |
lib/libcxx/include/__concepts/copyable.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <__config> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concepts.object] |
| 26 | 26 | |
| ... | ... | @@ -32,7 +32,7 @@ concept copyable = |
| 32 | 32 | assignable_from<_Tp&, const _Tp&> && |
| 33 | 33 | assignable_from<_Tp&, const _Tp>; |
| 34 | 34 | |
| 35 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | #endif // _LIBCPP_STD_VER > 17 | |
| 36 | 36 | |
| 37 | 37 | _LIBCPP_END_NAMESPACE_STD |
| 38 | 38 |
lib/libcxx/include/__concepts/derived_from.h+3-3| ... | ... | @@ -13,12 +13,12 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 22 | |
| 23 | 23 | // [concept.derived] |
| 24 | 24 | |
| ... | ... | @@ -27,7 +27,7 @@ concept derived_from = |
| 27 | 27 | is_base_of_v<_Bp, _Dp> && |
| 28 | 28 | is_convertible_v<const volatile _Dp*, const volatile _Bp*>; |
| 29 | 29 | |
| 30 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | #endif // _LIBCPP_STD_VER > 17 | |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_END_NAMESPACE_STD |
| 33 | 33 |
lib/libcxx/include/__concepts/destructible.h+3-3| ... | ... | @@ -13,19 +13,19 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 22 | |
| 23 | 23 | // [concept.destructible] |
| 24 | 24 | |
| 25 | 25 | template<class _Tp> |
| 26 | 26 | concept destructible = is_nothrow_destructible_v<_Tp>; |
| 27 | 27 | |
| 28 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | #endif // _LIBCPP_STD_VER > 17 | |
| 29 | 29 | |
| 30 | 30 | _LIBCPP_END_NAMESPACE_STD |
| 31 | 31 |
lib/libcxx/include/__concepts/different_from.h+3-3| ... | ... | @@ -14,17 +14,17 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | 23 | |
| 24 | 24 | template<class _Tp, class _Up> |
| 25 | 25 | concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>; |
| 26 | 26 | |
| 27 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #endif // _LIBCPP_STD_VER > 17 | |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 30 |
lib/libcxx/include/__concepts/equality_comparable.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.equalitycomparable] |
| 26 | 26 | |
| ... | ... | @@ -46,7 +46,7 @@ concept equality_comparable_with = |
| 46 | 46 | __make_const_lvalue_ref<_Up>>> && |
| 47 | 47 | __weakly_equality_comparable_with<_Tp, _Up>; |
| 48 | 48 | |
| 49 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 49 | #endif // _LIBCPP_STD_VER > 17 | |
| 50 | 50 | |
| 51 | 51 | _LIBCPP_END_NAMESPACE_STD |
| 52 | 52 |
lib/libcxx/include/__concepts/invocable.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.invocable] |
| 26 | 26 | |
| ... | ... | @@ -34,7 +34,7 @@ concept invocable = requires(_Fn&& __fn, _Args&&... __args) { |
| 34 | 34 | template<class _Fn, class... _Args> |
| 35 | 35 | concept regular_invocable = invocable<_Fn, _Args...>; |
| 36 | 36 | |
| 37 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 37 | #endif // _LIBCPP_STD_VER > 17 | |
| 38 | 38 | |
| 39 | 39 | _LIBCPP_END_NAMESPACE_STD |
| 40 | 40 |
lib/libcxx/include/__concepts/movable.h+3-3| ... | ... | @@ -16,12 +16,12 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | 25 | |
| 26 | 26 | // [concepts.object] |
| 27 | 27 | |
| ... | ... | @@ -32,7 +32,7 @@ concept movable = |
| 32 | 32 | assignable_from<_Tp&, _Tp> && |
| 33 | 33 | swappable<_Tp>; |
| 34 | 34 | |
| 35 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | #endif // _LIBCPP_STD_VER > 17 | |
| 36 | 36 | |
| 37 | 37 | _LIBCPP_END_NAMESPACE_STD |
| 38 | 38 |
lib/libcxx/include/__concepts/predicate.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.predicate] |
| 26 | 26 | |
| ... | ... | @@ -28,7 +28,7 @@ template<class _Fn, class... _Args> |
| 28 | 28 | concept predicate = |
| 29 | 29 | regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>; |
| 30 | 30 | |
| 31 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 31 | #endif // _LIBCPP_STD_VER > 17 | |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 34 |
lib/libcxx/include/__concepts/regular.h+3-3| ... | ... | @@ -14,19 +14,19 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | 23 | |
| 24 | 24 | // [concept.object] |
| 25 | 25 | |
| 26 | 26 | template<class _Tp> |
| 27 | 27 | concept regular = semiregular<_Tp> && equality_comparable<_Tp>; |
| 28 | 28 | |
| 29 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | #endif // _LIBCPP_STD_VER > 17 | |
| 30 | 30 | |
| 31 | 31 | _LIBCPP_END_NAMESPACE_STD |
| 32 | 32 |
lib/libcxx/include/__concepts/relation.h+3-3| ... | ... | @@ -13,12 +13,12 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 22 | |
| 23 | 23 | // [concept.relation] |
| 24 | 24 | |
| ... | ... | @@ -37,7 +37,7 @@ concept equivalence_relation = relation<_Rp, _Tp, _Up>; |
| 37 | 37 | template<class _Rp, class _Tp, class _Up> |
| 38 | 38 | concept strict_weak_order = relation<_Rp, _Tp, _Up>; |
| 39 | 39 | |
| 40 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 40 | #endif // _LIBCPP_STD_VER > 17 | |
| 41 | 41 | |
| 42 | 42 | _LIBCPP_END_NAMESPACE_STD |
| 43 | 43 |
lib/libcxx/include/__concepts/same_as.h+3-3| ... | ... | @@ -13,12 +13,12 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 22 | |
| 23 | 23 | // [concept.same] |
| 24 | 24 | |
| ... | ... | @@ -28,7 +28,7 @@ concept __same_as_impl = _IsSame<_Tp, _Up>::value; |
| 28 | 28 | template<class _Tp, class _Up> |
| 29 | 29 | concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>; |
| 30 | 30 | |
| 31 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 31 | #endif // _LIBCPP_STD_VER > 17 | |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_END_NAMESPACE_STD |
| 34 | 34 |
lib/libcxx/include/__concepts/semiregular.h+3-3| ... | ... | @@ -14,19 +14,19 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | 23 | |
| 24 | 24 | // [concept.object] |
| 25 | 25 | |
| 26 | 26 | template<class _Tp> |
| 27 | 27 | concept semiregular = copyable<_Tp> && default_initializable<_Tp>; |
| 28 | 28 | |
| 29 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | #endif // _LIBCPP_STD_VER > 17 | |
| 30 | 30 | |
| 31 | 31 | _LIBCPP_END_NAMESPACE_STD |
| 32 | 32 |
lib/libcxx/include/__concepts/swappable.h+3-3| ... | ... | @@ -20,12 +20,12 @@ |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | 29 | |
| 30 | 30 | // [concept.swappable] |
| 31 | 31 | |
| ... | ... | @@ -109,7 +109,7 @@ concept swappable_with = |
| 109 | 109 | ranges::swap(_VSTD::forward<_Up>(__u), _VSTD::forward<_Tp>(__t)); |
| 110 | 110 | }; |
| 111 | 111 | |
| 112 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 112 | #endif // _LIBCPP_STD_VER > 17 | |
| 113 | 113 | |
| 114 | 114 | _LIBCPP_END_NAMESPACE_STD |
| 115 | 115 |
lib/libcxx/include/__concepts/totally_ordered.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [concept.totallyordered] |
| 26 | 26 | |
| ... | ... | @@ -50,7 +50,7 @@ concept totally_ordered_with = |
| 50 | 50 | __make_const_lvalue_ref<_Up>>> && |
| 51 | 51 | __partially_ordered_with<_Tp, _Up>; |
| 52 | 52 | |
| 53 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 53 | #endif // _LIBCPP_STD_VER > 17 | |
| 54 | 54 | |
| 55 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 56 | 56 |
lib/libcxx/include/__config+872-1083| ... | ... | @@ -7,8 +7,8 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP_CONFIG | |
| 11 | #define _LIBCPP_CONFIG | |
| 10 | #ifndef _LIBCPP___CONFIG | |
| 11 | #define _LIBCPP___CONFIG | |
| 12 | 12 | |
| 13 | 13 | #if defined(_MSC_VER) && !defined(__clang__) |
| 14 | 14 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -17,334 +17,326 @@ |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | #ifdef __cplusplus |
| 24 | 24 | |
| 25 | #define _LIBCPP_VERSION 14000 | |
| 25 | # define _LIBCPP_VERSION 15000 | |
| 26 | 26 | |
| 27 | #ifndef _LIBCPP_ABI_VERSION | |
| 28 | # define _LIBCPP_ABI_VERSION 1 | |
| 29 | #endif | |
| 27 | # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y | |
| 28 | # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) | |
| 30 | 29 | |
| 31 | #if __STDC_HOSTED__ == 0 | |
| 32 | # define _LIBCPP_FREESTANDING | |
| 33 | #endif | |
| 30 | // Valid C++ identifier that revs with every libc++ version. This can be used to | |
| 31 | // generate identifiers that must be unique for every released libc++ version. | |
| 32 | # define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION) | |
| 33 | ||
| 34 | # if __STDC_HOSTED__ == 0 | |
| 35 | # define _LIBCPP_FREESTANDING | |
| 36 | # endif | |
| 34 | 37 | |
| 35 | #ifndef _LIBCPP_STD_VER | |
| 36 | # if __cplusplus <= 201103L | |
| 37 | # define _LIBCPP_STD_VER 11 | |
| 38 | # elif __cplusplus <= 201402L | |
| 39 | # define _LIBCPP_STD_VER 14 | |
| 40 | # elif __cplusplus <= 201703L | |
| 41 | # define _LIBCPP_STD_VER 17 | |
| 42 | # elif __cplusplus <= 202002L | |
| 43 | # define _LIBCPP_STD_VER 20 | |
| 38 | # ifndef _LIBCPP_STD_VER | |
| 39 | # if __cplusplus <= 201103L | |
| 40 | # define _LIBCPP_STD_VER 11 | |
| 41 | # elif __cplusplus <= 201402L | |
| 42 | # define _LIBCPP_STD_VER 14 | |
| 43 | # elif __cplusplus <= 201703L | |
| 44 | # define _LIBCPP_STD_VER 17 | |
| 45 | # elif __cplusplus <= 202002L | |
| 46 | # define _LIBCPP_STD_VER 20 | |
| 47 | # else | |
| 48 | # define _LIBCPP_STD_VER 22 // current year, or date of c++2b ratification | |
| 49 | # endif | |
| 50 | # endif // _LIBCPP_STD_VER | |
| 51 | ||
| 52 | # if defined(__ELF__) | |
| 53 | # define _LIBCPP_OBJECT_FORMAT_ELF 1 | |
| 54 | # elif defined(__MACH__) | |
| 55 | # define _LIBCPP_OBJECT_FORMAT_MACHO 1 | |
| 56 | # elif defined(_WIN32) | |
| 57 | # define _LIBCPP_OBJECT_FORMAT_COFF 1 | |
| 58 | # elif defined(__wasm__) | |
| 59 | # define _LIBCPP_OBJECT_FORMAT_WASM 1 | |
| 60 | # elif defined(_AIX) | |
| 61 | # define _LIBCPP_OBJECT_FORMAT_XCOFF 1 | |
| 44 | 62 | # else |
| 45 | # define _LIBCPP_STD_VER 21 // current year, or date of c++2b ratification | |
| 46 | # endif | |
| 47 | #endif // _LIBCPP_STD_VER | |
| 48 | ||
| 49 | #if defined(__ELF__) | |
| 50 | # define _LIBCPP_OBJECT_FORMAT_ELF 1 | |
| 51 | #elif defined(__MACH__) | |
| 52 | # define _LIBCPP_OBJECT_FORMAT_MACHO 1 | |
| 53 | #elif defined(_WIN32) | |
| 54 | # define _LIBCPP_OBJECT_FORMAT_COFF 1 | |
| 55 | #elif defined(__wasm__) | |
| 56 | # define _LIBCPP_OBJECT_FORMAT_WASM 1 | |
| 57 | #else | |
| 58 | // ... add new file formats here ... | |
| 59 | #endif | |
| 63 | // ... add new file formats here ... | |
| 64 | # endif | |
| 60 | 65 | |
| 61 | #if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 | |
| 66 | # if _LIBCPP_ABI_VERSION >= 2 | |
| 62 | 67 | // Change short string representation so that string data starts at offset 0, |
| 63 | 68 | // improving its alignment in some cases. |
| 64 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 69 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 65 | 70 | // Fix deque iterator type in order to support incomplete types. |
| 66 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | |
| 71 | # define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE | |
| 67 | 72 | // Fix undefined behavior in how std::list stores its linked nodes. |
| 68 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | |
| 73 | # define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB | |
| 69 | 74 | // Fix undefined behavior in how __tree stores its end and parent nodes. |
| 70 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | |
| 75 | # define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB | |
| 71 | 76 | // Fix undefined behavior in how __hash_table stores its pointer types. |
| 72 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | |
| 73 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | |
| 74 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | |
| 77 | # define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB | |
| 78 | # define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB | |
| 79 | # define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE | |
| 75 | 80 | // Define a key function for `bad_function_call` in the library, to centralize |
| 76 | 81 | // its vtable and typeinfo to libc++ rather than having all other libraries |
| 77 | 82 | // using that class define their own copies. |
| 78 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 83 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 79 | 84 | // Override the default return value of exception::what() for |
| 80 | 85 | // bad_function_call::what() with a string that is specific to |
| 81 | 86 | // bad_function_call (see http://wg21.link/LWG2233). This is an ABI break |
| 82 | 87 | // because it changes the vtable layout of bad_function_call. |
| 83 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | |
| 88 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE | |
| 84 | 89 | // Enable optimized version of __do_get_(un)signed which avoids redundant copies. |
| 85 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 86 | // In C++20 and later, don't derive std::plus from std::binary_function, | |
| 87 | // nor std::negate from std::unary_function. | |
| 88 | # define _LIBCPP_ABI_NO_BINDER_BASES | |
| 90 | # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET | |
| 89 | 91 | // Give reverse_iterator<T> one data member of type T, not two. |
| 90 | 92 | // Also, in C++17 and later, don't derive iterator types from std::iterator. |
| 91 | # define _LIBCPP_ABI_NO_ITERATOR_BASES | |
| 93 | # define _LIBCPP_ABI_NO_ITERATOR_BASES | |
| 92 | 94 | // Use the smallest possible integer type to represent the index of the variant. |
| 93 | 95 | // Previously libc++ used "unsigned int" exclusively. |
| 94 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | |
| 96 | # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION | |
| 95 | 97 | // Unstable attempt to provide a more optimized std::function |
| 96 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | |
| 98 | # define _LIBCPP_ABI_OPTIMIZED_FUNCTION | |
| 97 | 99 | // All the regex constants must be distinct and nonzero. |
| 98 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | |
| 99 | // Use raw pointers, not wrapped ones, for std::span's iterator type. | |
| 100 | # define _LIBCPP_ABI_SPAN_POINTER_ITERATORS | |
| 100 | # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO | |
| 101 | 101 | // Re-worked external template instantiations for std::string with a focus on |
| 102 | 102 | // performance and fast-path inlining. |
| 103 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | |
| 103 | # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION | |
| 104 | 104 | // Enable clang::trivial_abi on std::unique_ptr. |
| 105 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | |
| 105 | # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI | |
| 106 | 106 | // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr |
| 107 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | |
| 107 | # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI | |
| 108 | 108 | // std::random_device holds some state when it uses an implementation that gets |
| 109 | 109 | // entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this |
| 110 | 110 | // implementation to another one on a platform that has already shipped |
| 111 | 111 | // std::random_device, one needs to retain the same object layout to remain ABI |
| 112 | 112 | // compatible. This switch removes these workarounds for platforms that don't care |
| 113 | 113 | // about ABI compatibility. |
| 114 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | |
| 115 | // Remove basic_string common base | |
| 116 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | |
| 117 | // Remove vector base class | |
| 118 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | |
| 119 | #elif _LIBCPP_ABI_VERSION == 1 | |
| 120 | # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 114 | # define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT | |
| 115 | // Don't export the legacy __basic_string_common class and its methods from the built library. | |
| 116 | # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON | |
| 117 | // Don't export the legacy __vector_base_common class and its methods from the built library. | |
| 118 | # define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON | |
| 119 | // According to the Standard, `bitset::operator[] const` returns bool | |
| 120 | # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 121 | // Remove the base 10 implementation of std::to_chars from the dylib. | |
| 122 | // The implementation moved to the header, but we still export the symbols from | |
| 123 | // the dylib for backwards compatibility. | |
| 124 | # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | |
| 125 | # elif _LIBCPP_ABI_VERSION == 1 | |
| 126 | # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) | |
| 121 | 127 | // Enable compiling copies of now inline methods into the dylib to support |
| 122 | 128 | // applications compiled against older libraries. This is unnecessary with |
| 123 | 129 | // COFF dllexport semantics, since dllexport forces a non-inline definition |
| 124 | 130 | // of inline functions to be emitted anyway. Our own non-inline copy would |
| 125 | // conflict with the dllexport-emitted copy, so we disable it. | |
| 126 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | |
| 127 | # endif | |
| 131 | // conflict with the dllexport-emitted copy, so we disable it. For XCOFF, | |
| 132 | // the linker will take issue with the symbols in the shared object if the | |
| 133 | // weak inline methods get visibility (such as from -fvisibility-inlines-hidden), | |
| 134 | // so disable it. | |
| 135 | # define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | |
| 136 | # endif | |
| 128 | 137 | // Feature macros for disabling pre ABI v1 features. All of these options |
| 129 | 138 | // are deprecated. |
| 130 | # if defined(__FreeBSD__) | |
| 131 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR | |
| 139 | # if defined(__FreeBSD__) | |
| 140 | # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR | |
| 141 | # endif | |
| 132 | 142 | # endif |
| 133 | #endif | |
| 134 | ||
| 135 | // By default, don't use a nullptr_t emulation type in C++03. | |
| 136 | // | |
| 137 | // This is technically an ABI break from previous releases, however it is | |
| 138 | // very unlikely to impact anyone. If a user is impacted by this break, | |
| 139 | // they can return to using the C++03 nullptr emulation by defining | |
| 140 | // _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION. | |
| 141 | // | |
| 142 | // This switch will be removed entirely in favour of never providing a | |
| 143 | // C++03 emulation after one release. | |
| 144 | // | |
| 145 | // IMPORTANT: IF YOU ARE READING THIS AND YOU TURN THIS MACRO ON, PLEASE LEAVE | |
| 146 | // A COMMENT ON https://reviews.llvm.org/D109459 OR YOU WILL BE BROKEN | |
| 147 | // IN THE FUTURE WHEN WE REMOVE THE ABILITY TO USE THE C++03 EMULATION. | |
| 148 | #ifndef _LIBCPP_ABI_USE_CXX03_NULLPTR_EMULATION | |
| 149 | # define _LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR | |
| 150 | #endif | |
| 151 | 143 | |
| 152 | #if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 | |
| 144 | # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 | |
| 153 | 145 | // Enable additional explicit instantiations of iostreams components. This |
| 154 | 146 | // reduces the number of weak definitions generated in programs that use |
| 155 | 147 | // iostreams by providing a single strong definition in the shared library. |
| 156 | # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 | |
| 148 | # define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 | |
| 157 | 149 | |
| 158 | 150 | // Define a key function for `bad_function_call` in the library, to centralize |
| 159 | 151 | // its vtable and typeinfo to libc++ rather than having all other libraries |
| 160 | 152 | // using that class define their own copies. |
| 161 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 162 | #endif | |
| 153 | # define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION | |
| 154 | # endif | |
| 163 | 155 | |
| 164 | #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y | |
| 165 | #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) | |
| 156 | # define _LIBCPP_TOSTRING2(x) # x | |
| 157 | # define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) | |
| 166 | 158 | |
| 167 | #ifndef _LIBCPP_ABI_NAMESPACE | |
| 168 | # define _LIBCPP_ABI_NAMESPACE _LIBCPP_CONCAT(__,_LIBCPP_ABI_VERSION) | |
| 169 | #endif | |
| 170 | ||
| 171 | #if __cplusplus < 201103L | |
| 172 | #define _LIBCPP_CXX03_LANG | |
| 173 | #endif | |
| 159 | # if __cplusplus < 201103L | |
| 160 | # define _LIBCPP_CXX03_LANG | |
| 161 | # endif | |
| 174 | 162 | |
| 175 | #ifndef __has_attribute | |
| 176 | #define __has_attribute(__x) 0 | |
| 177 | #endif | |
| 163 | # ifndef __has_attribute | |
| 164 | # define __has_attribute(__x) 0 | |
| 165 | # endif | |
| 178 | 166 | |
| 179 | #ifndef __has_builtin | |
| 180 | #define __has_builtin(__x) 0 | |
| 181 | #endif | |
| 167 | # ifndef __has_builtin | |
| 168 | # define __has_builtin(__x) 0 | |
| 169 | # endif | |
| 182 | 170 | |
| 183 | #ifndef __has_extension | |
| 184 | #define __has_extension(__x) 0 | |
| 185 | #endif | |
| 171 | # ifndef __has_extension | |
| 172 | # define __has_extension(__x) 0 | |
| 173 | # endif | |
| 186 | 174 | |
| 187 | #ifndef __has_feature | |
| 188 | #define __has_feature(__x) 0 | |
| 189 | #endif | |
| 175 | # ifndef __has_feature | |
| 176 | # define __has_feature(__x) 0 | |
| 177 | # endif | |
| 190 | 178 | |
| 191 | #ifndef __has_cpp_attribute | |
| 192 | #define __has_cpp_attribute(__x) 0 | |
| 193 | #endif | |
| 179 | # ifndef __has_cpp_attribute | |
| 180 | # define __has_cpp_attribute(__x) 0 | |
| 181 | # endif | |
| 194 | 182 | |
| 195 | 183 | // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by |
| 196 | 184 | // the compiler and '1' otherwise. |
| 197 | #ifndef __is_identifier | |
| 198 | #define __is_identifier(__x) 1 | |
| 199 | #endif | |
| 185 | # ifndef __is_identifier | |
| 186 | # define __is_identifier(__x) 1 | |
| 187 | # endif | |
| 200 | 188 | |
| 201 | #ifndef __has_declspec_attribute | |
| 202 | #define __has_declspec_attribute(__x) 0 | |
| 203 | #endif | |
| 189 | # ifndef __has_declspec_attribute | |
| 190 | # define __has_declspec_attribute(__x) 0 | |
| 191 | # endif | |
| 204 | 192 | |
| 205 | #define __has_keyword(__x) !(__is_identifier(__x)) | |
| 193 | # define __has_keyword(__x) !(__is_identifier(__x)) | |
| 206 | 194 | |
| 207 | #ifndef __has_include | |
| 208 | #define __has_include(...) 0 | |
| 209 | #endif | |
| 195 | # ifndef __has_include | |
| 196 | # define __has_include(...) 0 | |
| 197 | # endif | |
| 210 | 198 | |
| 211 | #if defined(__apple_build_version__) | |
| 212 | # define _LIBCPP_COMPILER_CLANG_BASED | |
| 213 | # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) | |
| 214 | #elif defined(__clang__) | |
| 215 | # define _LIBCPP_COMPILER_CLANG_BASED | |
| 216 | # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) | |
| 217 | #elif defined(__GNUC__) | |
| 218 | # define _LIBCPP_COMPILER_GCC | |
| 219 | #elif defined(_MSC_VER) | |
| 220 | # define _LIBCPP_COMPILER_MSVC | |
| 221 | #elif defined(__IBMCPP__) | |
| 222 | # define _LIBCPP_COMPILER_IBM | |
| 223 | #endif | |
| 199 | # if defined(__apple_build_version__) | |
| 200 | # define _LIBCPP_COMPILER_CLANG_BASED | |
| 201 | # define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000) | |
| 202 | # elif defined(__clang__) | |
| 203 | # define _LIBCPP_COMPILER_CLANG_BASED | |
| 204 | # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) | |
| 205 | # elif defined(__GNUC__) | |
| 206 | # define _LIBCPP_COMPILER_GCC | |
| 207 | # elif defined(_MSC_VER) | |
| 208 | # define _LIBCPP_COMPILER_MSVC | |
| 209 | # endif | |
| 224 | 210 | |
| 225 | #if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L | |
| 226 | #error "libc++ does not support using GCC with C++03. Please enable C++11" | |
| 227 | #endif | |
| 211 | # if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L | |
| 212 | # error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11" | |
| 213 | # endif | |
| 214 | ||
| 215 | # ifdef _LIBCPP_COMPILER_MSVC | |
| 216 | # error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \ | |
| 217 | changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \ | |
| 218 | If there are users of this configuration we are happy to provide support. | |
| 219 | # endif | |
| 228 | 220 | |
| 229 | 221 | // FIXME: ABI detection should be done via compiler builtin macros. This |
| 230 | 222 | // is just a placeholder until Clang implements such macros. For now assume |
| 231 | 223 | // that Windows compilers pretending to be MSVC++ target the Microsoft ABI, |
| 232 | 224 | // and allow the user to explicitly specify the ABI to handle cases where this |
| 233 | 225 | // heuristic falls short. |
| 234 | #if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) | |
| 235 | # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" | |
| 236 | #elif defined(_LIBCPP_ABI_FORCE_ITANIUM) | |
| 237 | # define _LIBCPP_ABI_ITANIUM | |
| 238 | #elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) | |
| 239 | # define _LIBCPP_ABI_MICROSOFT | |
| 240 | #else | |
| 241 | # if defined(_WIN32) && defined(_MSC_VER) | |
| 226 | # if defined(_LIBCPP_ABI_FORCE_ITANIUM) && defined(_LIBCPP_ABI_FORCE_MICROSOFT) | |
| 227 | # error "Only one of _LIBCPP_ABI_FORCE_ITANIUM and _LIBCPP_ABI_FORCE_MICROSOFT can be defined" | |
| 228 | # elif defined(_LIBCPP_ABI_FORCE_ITANIUM) | |
| 229 | # define _LIBCPP_ABI_ITANIUM | |
| 230 | # elif defined(_LIBCPP_ABI_FORCE_MICROSOFT) | |
| 242 | 231 | # define _LIBCPP_ABI_MICROSOFT |
| 243 | 232 | # else |
| 244 | # define _LIBCPP_ABI_ITANIUM | |
| 233 | # if defined(_WIN32) && defined(_MSC_VER) | |
| 234 | # define _LIBCPP_ABI_MICROSOFT | |
| 235 | # else | |
| 236 | # define _LIBCPP_ABI_ITANIUM | |
| 237 | # endif | |
| 245 | 238 | # endif |
| 246 | #endif | |
| 247 | 239 | |
| 248 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) | |
| 249 | # define _LIBCPP_ABI_VCRUNTIME | |
| 250 | #endif | |
| 240 | # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) | |
| 241 | # define _LIBCPP_ABI_VCRUNTIME | |
| 242 | # endif | |
| 251 | 243 | |
| 252 | // Need to detect which libc we're using if we're on Linux. | |
| 253 | #if defined(__linux__) | |
| 254 | # include <features.h> | |
| 255 | # if defined(__GLIBC_PREREQ) | |
| 256 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) | |
| 257 | # else | |
| 258 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 | |
| 259 | # endif // defined(__GLIBC_PREREQ) | |
| 260 | #endif // defined(__linux__) | |
| 244 | # if __has_feature(experimental_library) | |
| 245 | # ifndef _LIBCPP_ENABLE_EXPERIMENTAL | |
| 246 | # define _LIBCPP_ENABLE_EXPERIMENTAL | |
| 247 | # endif | |
| 248 | # endif | |
| 261 | 249 | |
| 262 | #if defined(__MVS__) | |
| 263 | # include <features.h> // for __NATIVE_ASCII_F | |
| 264 | #endif | |
| 250 | // Incomplete features get their own specific disabling flags. This makes it | |
| 251 | // easier to grep for target specific flags once the feature is complete. | |
| 252 | # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 253 | # define _LIBCPP_HAS_NO_INCOMPLETE_FORMAT | |
| 254 | # define _LIBCPP_HAS_NO_INCOMPLETE_RANGES | |
| 255 | # endif | |
| 265 | 256 | |
| 266 | #ifdef __LITTLE_ENDIAN__ | |
| 267 | # if __LITTLE_ENDIAN__ | |
| 268 | # define _LIBCPP_LITTLE_ENDIAN | |
| 269 | # endif // __LITTLE_ENDIAN__ | |
| 270 | #endif // __LITTLE_ENDIAN__ | |
| 257 | // Need to detect which libc we're using if we're on Linux. | |
| 258 | # if defined(__linux__) | |
| 259 | # include <features.h> | |
| 260 | # if defined(__GLIBC_PREREQ) | |
| 261 | # define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b) | |
| 262 | # else | |
| 263 | # define _LIBCPP_GLIBC_PREREQ(a, b) 0 | |
| 264 | # endif // defined(__GLIBC_PREREQ) | |
| 265 | # endif // defined(__linux__) | |
| 271 | 266 | |
| 272 | #ifdef __BIG_ENDIAN__ | |
| 273 | # if __BIG_ENDIAN__ | |
| 274 | # define _LIBCPP_BIG_ENDIAN | |
| 275 | # endif // __BIG_ENDIAN__ | |
| 276 | #endif // __BIG_ENDIAN__ | |
| 267 | # if defined(__MVS__) | |
| 268 | # include <features.h> // for __NATIVE_ASCII_F | |
| 269 | # endif | |
| 277 | 270 | |
| 278 | #ifdef __BYTE_ORDER__ | |
| 279 | # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | |
| 271 | # ifdef __LITTLE_ENDIAN__ | |
| 272 | # if __LITTLE_ENDIAN__ | |
| 273 | # define _LIBCPP_LITTLE_ENDIAN | |
| 274 | # endif // __LITTLE_ENDIAN__ | |
| 275 | # endif // __LITTLE_ENDIAN__ | |
| 276 | ||
| 277 | # ifdef __BIG_ENDIAN__ | |
| 278 | # if __BIG_ENDIAN__ | |
| 279 | # define _LIBCPP_BIG_ENDIAN | |
| 280 | # endif // __BIG_ENDIAN__ | |
| 281 | # endif // __BIG_ENDIAN__ | |
| 282 | ||
| 283 | # ifdef __BYTE_ORDER__ | |
| 284 | # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | |
| 285 | # define _LIBCPP_LITTLE_ENDIAN | |
| 286 | # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
| 287 | # define _LIBCPP_BIG_ENDIAN | |
| 288 | # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
| 289 | # endif // __BYTE_ORDER__ | |
| 290 | ||
| 291 | # ifdef __FreeBSD__ | |
| 292 | # include <sys/endian.h> | |
| 293 | # include <osreldate.h> | |
| 294 | # if _BYTE_ORDER == _LITTLE_ENDIAN | |
| 295 | # define _LIBCPP_LITTLE_ENDIAN | |
| 296 | # else // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 297 | # define _LIBCPP_BIG_ENDIAN | |
| 298 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 299 | # endif // __FreeBSD__ | |
| 300 | ||
| 301 | # if defined(__NetBSD__) || defined(__OpenBSD__) | |
| 302 | # include <sys/endian.h> | |
| 303 | # if _BYTE_ORDER == _LITTLE_ENDIAN | |
| 304 | # define _LIBCPP_LITTLE_ENDIAN | |
| 305 | # else // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 306 | # define _LIBCPP_BIG_ENDIAN | |
| 307 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 308 | # endif // defined(__NetBSD__) || defined(__OpenBSD__) | |
| 309 | ||
| 310 | # if defined(_WIN32) | |
| 311 | # define _LIBCPP_WIN32API | |
| 280 | 312 | # define _LIBCPP_LITTLE_ENDIAN |
| 281 | # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
| 282 | # define _LIBCPP_BIG_ENDIAN | |
| 283 | # endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ | |
| 284 | #endif // __BYTE_ORDER__ | |
| 285 | ||
| 286 | #ifdef __FreeBSD__ | |
| 287 | # include <sys/endian.h> | |
| 288 | # include <osreldate.h> | |
| 289 | # if _BYTE_ORDER == _LITTLE_ENDIAN | |
| 290 | # define _LIBCPP_LITTLE_ENDIAN | |
| 291 | # else // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 292 | # define _LIBCPP_BIG_ENDIAN | |
| 293 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 294 | #endif // __FreeBSD__ | |
| 295 | ||
| 296 | #if defined(__NetBSD__) || defined(__OpenBSD__) | |
| 297 | # include <sys/endian.h> | |
| 298 | # if _BYTE_ORDER == _LITTLE_ENDIAN | |
| 299 | # define _LIBCPP_LITTLE_ENDIAN | |
| 300 | # else // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 301 | # define _LIBCPP_BIG_ENDIAN | |
| 302 | # endif // _BYTE_ORDER == _LITTLE_ENDIAN | |
| 303 | #endif // defined(__NetBSD__) || defined(__OpenBSD__) | |
| 304 | ||
| 305 | #if defined(_WIN32) | |
| 306 | # define _LIBCPP_WIN32API | |
| 307 | # define _LIBCPP_LITTLE_ENDIAN | |
| 308 | # define _LIBCPP_SHORT_WCHAR 1 | |
| 313 | # define _LIBCPP_SHORT_WCHAR 1 | |
| 309 | 314 | // Both MinGW and native MSVC provide a "MSVC"-like environment |
| 310 | # define _LIBCPP_MSVCRT_LIKE | |
| 315 | # define _LIBCPP_MSVCRT_LIKE | |
| 311 | 316 | // If mingw not explicitly detected, assume using MS C runtime only if |
| 312 | 317 | // a MS compatibility version is specified. |
| 313 | # if defined(_MSC_VER) && !defined(__MINGW32__) | |
| 314 | # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library | |
| 315 | # endif | |
| 316 | # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) | |
| 317 | # define _LIBCPP_HAS_BITSCAN64 | |
| 318 | # endif | |
| 319 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 320 | # if defined(_LIBCPP_MSVCRT) | |
| 321 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 322 | # endif | |
| 318 | # if defined(_MSC_VER) && !defined(__MINGW32__) | |
| 319 | # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library | |
| 320 | # endif | |
| 321 | # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) | |
| 322 | # define _LIBCPP_HAS_BITSCAN64 | |
| 323 | # endif | |
| 324 | # define _LIBCPP_HAS_OPEN_WITH_WCHAR | |
| 325 | # endif // defined(_WIN32) | |
| 323 | 326 | |
| 324 | // Some CRT APIs are unavailable to store apps | |
| 325 | # if defined(WINAPI_FAMILY) | |
| 326 | # include <winapifamily.h> | |
| 327 | # if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && \ | |
| 328 | (!defined(WINAPI_PARTITION_SYSTEM) || \ | |
| 329 | !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)) | |
| 330 | # define _LIBCPP_WINDOWS_STORE_APP | |
| 327 | # ifdef __sun__ | |
| 328 | # include <sys/isa_defs.h> | |
| 329 | # ifdef _LITTLE_ENDIAN | |
| 330 | # define _LIBCPP_LITTLE_ENDIAN | |
| 331 | # else | |
| 332 | # define _LIBCPP_BIG_ENDIAN | |
| 331 | 333 | # endif |
| 332 | # endif | |
| 333 | #endif // defined(_WIN32) | |
| 334 | # endif // __sun__ | |
| 334 | 335 | |
| 335 | #ifdef __sun__ | |
| 336 | # include <sys/isa_defs.h> | |
| 337 | # ifdef _LITTLE_ENDIAN | |
| 338 | # define _LIBCPP_LITTLE_ENDIAN | |
| 339 | # else | |
| 340 | # define _LIBCPP_BIG_ENDIAN | |
| 336 | # if defined(_AIX) && !defined(__64BIT__) | |
| 337 | // The size of wchar is 2 byte on 32-bit mode on AIX. | |
| 338 | # define _LIBCPP_SHORT_WCHAR 1 | |
| 341 | 339 | # endif |
| 342 | #endif // __sun__ | |
| 343 | ||
| 344 | #if defined(_AIX) && !defined(__64BIT__) | |
| 345 | // The size of wchar is 2 byte on 32-bit mode on AIX. | |
| 346 | # define _LIBCPP_SHORT_WCHAR 1 | |
| 347 | #endif | |
| 348 | 340 | |
| 349 | 341 | // Libc++ supports various implementations of std::random_device. |
| 350 | 342 | // |
| ... | ... | @@ -384,806 +376,581 @@ |
| 384 | 376 | // Use rand_s(), for use on Windows. |
| 385 | 377 | // When this option is used, the token passed to `std::random_device`'s |
| 386 | 378 | // constructor *must* be "/dev/urandom" -- anything else is an error. |
| 387 | #if defined(__OpenBSD__) || defined(__APPLE__) | |
| 388 | # define _LIBCPP_USING_ARC4_RANDOM | |
| 389 | #elif defined(__wasi__) | |
| 390 | # define _LIBCPP_USING_GETENTROPY | |
| 391 | #elif defined(__Fuchsia__) | |
| 392 | # define _LIBCPP_USING_FUCHSIA_CPRNG | |
| 393 | #elif defined(__native_client__) | |
| 394 | # define _LIBCPP_USING_NACL_RANDOM | |
| 395 | #elif defined(_LIBCPP_WIN32API) | |
| 396 | # define _LIBCPP_USING_WIN32_RANDOM | |
| 397 | #else | |
| 398 | # define _LIBCPP_USING_DEV_RANDOM | |
| 399 | #endif | |
| 400 | ||
| 401 | #if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) | |
| 402 | # include <endian.h> | |
| 403 | # if __BYTE_ORDER == __LITTLE_ENDIAN | |
| 404 | # define _LIBCPP_LITTLE_ENDIAN | |
| 405 | # elif __BYTE_ORDER == __BIG_ENDIAN | |
| 406 | # define _LIBCPP_BIG_ENDIAN | |
| 407 | # else // __BYTE_ORDER == __BIG_ENDIAN | |
| 408 | # error unable to determine endian | |
| 379 | # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \ | |
| 380 | defined(__DragonFly__) || defined(__sun__) | |
| 381 | # define _LIBCPP_USING_ARC4_RANDOM | |
| 382 | # elif defined(__wasi__) || defined(__EMSCRIPTEN__) | |
| 383 | # define _LIBCPP_USING_GETENTROPY | |
| 384 | # elif defined(__Fuchsia__) | |
| 385 | # define _LIBCPP_USING_FUCHSIA_CPRNG | |
| 386 | # elif defined(__native_client__) | |
| 387 | # define _LIBCPP_USING_NACL_RANDOM | |
| 388 | # elif defined(_LIBCPP_WIN32API) | |
| 389 | # define _LIBCPP_USING_WIN32_RANDOM | |
| 390 | # else | |
| 391 | # define _LIBCPP_USING_DEV_RANDOM | |
| 409 | 392 | # endif |
| 410 | #endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) | |
| 411 | 393 | |
| 412 | #if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) | |
| 413 | # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) | |
| 414 | #else | |
| 415 | # define _LIBCPP_NO_CFI | |
| 416 | #endif | |
| 417 | ||
| 418 | // If the compiler supports using_if_exists, pretend we have those functions and they'll | |
| 419 | // be picked up if the C library provides them. | |
| 420 | // | |
| 421 | // TODO: Once we drop support for Clang 12, we can assume the compiler supports using_if_exists | |
| 422 | // for platforms that don't have a conforming C11 library, so we can drop this whole thing. | |
| 423 | #if __has_attribute(using_if_exists) | |
| 424 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 425 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 426 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 427 | #else | |
| 428 | #if (defined(__ISO_C_VISIBLE) && (__ISO_C_VISIBLE >= 2011)) || __cplusplus >= 201103L | |
| 429 | # if defined(__FreeBSD__) | |
| 430 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 431 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 432 | # if __FreeBSD_version >= 1300064 || \ | |
| 433 | (__FreeBSD_version >= 1201504 && __FreeBSD_version < 1300000) | |
| 434 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 435 | # endif | |
| 436 | # elif defined(__BIONIC__) | |
| 437 | # if __ANDROID_API__ >= 21 | |
| 438 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 439 | # endif | |
| 440 | # if __ANDROID_API__ >= 28 | |
| 441 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 442 | # endif | |
| 443 | # if __ANDROID_API__ >= 29 | |
| 444 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 445 | # endif | |
| 446 | # elif defined(__Fuchsia__) || defined(__wasi__) || defined(__NetBSD__) | |
| 447 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 448 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 449 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 450 | # elif defined(__OpenBSD__) | |
| 451 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 452 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 453 | # elif defined(__linux__) | |
| 454 | # if !defined(_LIBCPP_HAS_MUSL_LIBC) | |
| 455 | # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) | |
| 456 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 457 | # endif | |
| 458 | # if _LIBCPP_GLIBC_PREREQ(2, 17) | |
| 459 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 460 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 461 | # endif | |
| 462 | # else // defined(_LIBCPP_HAS_MUSL_LIBC) | |
| 463 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 464 | # define _LIBCPP_HAS_QUICK_EXIT | |
| 465 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 466 | # endif | |
| 467 | # elif defined(_LIBCPP_MSVCRT) | |
| 468 | // Using Microsoft's C Runtime library, not MinGW | |
| 469 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 470 | # elif defined(__APPLE__) | |
| 471 | // timespec_get and aligned_alloc were introduced in macOS 10.15 and | |
| 472 | // aligned releases | |
| 473 | # if ((defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500) || \ | |
| 474 | (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ | |
| 475 | (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000) || \ | |
| 476 | (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000)) | |
| 477 | # define _LIBCPP_HAS_ALIGNED_ALLOC | |
| 478 | # define _LIBCPP_HAS_TIMESPEC_GET | |
| 394 | # if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) | |
| 395 | # include <endian.h> | |
| 396 | # if __BYTE_ORDER == __LITTLE_ENDIAN | |
| 397 | # define _LIBCPP_LITTLE_ENDIAN | |
| 398 | # elif __BYTE_ORDER == __BIG_ENDIAN | |
| 399 | # define _LIBCPP_BIG_ENDIAN | |
| 400 | # else // __BYTE_ORDER == __BIG_ENDIAN | |
| 401 | # error unable to determine endian | |
| 479 | 402 | # endif |
| 480 | # endif // __APPLE__ | |
| 481 | #endif | |
| 482 | #endif // __has_attribute(using_if_exists) | |
| 483 | ||
| 484 | #ifndef _LIBCPP_CXX03_LANG | |
| 485 | # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) | |
| 486 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) | |
| 487 | # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) | |
| 488 | #else | |
| 489 | # error "We don't know a correct way to implement alignof(T) in C++03 outside of Clang" | |
| 490 | #endif | |
| 403 | # endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) | |
| 491 | 404 | |
| 492 | #define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) | |
| 405 | # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) | |
| 406 | # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) | |
| 407 | # else | |
| 408 | # define _LIBCPP_NO_CFI | |
| 409 | # endif | |
| 493 | 410 | |
| 494 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) | |
| 411 | # ifndef _LIBCPP_CXX03_LANG | |
| 495 | 412 | |
| 496 | #if defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) | |
| 497 | # error _LIBCPP_ALTERNATE_STRING_LAYOUT is deprecated, please use _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT instead | |
| 498 | #endif | |
| 499 | #if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ | |
| 500 | (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) | |
| 501 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 502 | #endif | |
| 413 | # define _LIBCPP_ALIGNOF(_Tp) alignof(_Tp) | |
| 414 | # define _ALIGNAS_TYPE(x) alignas(x) | |
| 415 | # define _ALIGNAS(x) alignas(x) | |
| 416 | # define _LIBCPP_NORETURN [[noreturn]] | |
| 417 | # define _NOEXCEPT noexcept | |
| 418 | # define _NOEXCEPT_(x) noexcept(x) | |
| 503 | 419 | |
| 504 | #if __has_feature(cxx_alignas) | |
| 505 | # define _ALIGNAS_TYPE(x) alignas(x) | |
| 506 | # define _ALIGNAS(x) alignas(x) | |
| 507 | #else | |
| 508 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) | |
| 509 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) | |
| 510 | #endif | |
| 420 | # else | |
| 421 | ||
| 422 | # define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp) | |
| 423 | # define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) | |
| 424 | # define _ALIGNAS(x) __attribute__((__aligned__(x))) | |
| 425 | # define _LIBCPP_NORETURN __attribute__((noreturn)) | |
| 426 | # define _LIBCPP_HAS_NO_NOEXCEPT | |
| 427 | # define nullptr __nullptr | |
| 428 | # define _NOEXCEPT throw() | |
| 429 | # define _NOEXCEPT_(x) | |
| 511 | 430 | |
| 512 | #if __cplusplus < 201103L | |
| 513 | 431 | typedef __char16_t char16_t; |
| 514 | 432 | typedef __char32_t char32_t; |
| 515 | #endif | |
| 516 | ||
| 517 | #if !__has_feature(cxx_exceptions) | |
| 518 | # define _LIBCPP_NO_EXCEPTIONS | |
| 519 | #endif | |
| 520 | 433 | |
| 521 | #if !(__has_feature(cxx_strong_enums)) | |
| 522 | #define _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 523 | #endif | |
| 524 | ||
| 525 | #if __has_feature(cxx_attributes) | |
| 526 | # define _LIBCPP_NORETURN [[noreturn]] | |
| 527 | #else | |
| 528 | # define _LIBCPP_NORETURN __attribute__ ((noreturn)) | |
| 529 | #endif | |
| 530 | ||
| 531 | #if !(__has_feature(cxx_nullptr)) | |
| 532 | # if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR) | |
| 533 | # define nullptr __nullptr | |
| 534 | # else | |
| 535 | # define _LIBCPP_HAS_NO_NULLPTR | |
| 536 | 434 | # endif |
| 537 | #endif | |
| 538 | ||
| 539 | // Objective-C++ features (opt-in) | |
| 540 | #if __has_feature(objc_arc) | |
| 541 | #define _LIBCPP_HAS_OBJC_ARC | |
| 542 | #endif | |
| 543 | ||
| 544 | #if __has_feature(objc_arc_weak) | |
| 545 | #define _LIBCPP_HAS_OBJC_ARC_WEAK | |
| 546 | #endif | |
| 547 | ||
| 548 | #if __has_extension(blocks) | |
| 549 | # define _LIBCPP_HAS_EXTENSION_BLOCKS | |
| 550 | #endif | |
| 551 | 435 | |
| 552 | #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) | |
| 553 | # define _LIBCPP_HAS_BLOCKS_RUNTIME | |
| 554 | #endif | |
| 436 | # if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L | |
| 437 | # define _LIBCPP_NO_EXCEPTIONS | |
| 438 | # endif | |
| 555 | 439 | |
| 556 | #if !(__has_feature(cxx_noexcept)) | |
| 557 | #define _LIBCPP_HAS_NO_NOEXCEPT | |
| 558 | #endif | |
| 440 | # define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp) | |
| 559 | 441 | |
| 560 | #if !__has_feature(address_sanitizer) | |
| 561 | #define _LIBCPP_HAS_NO_ASAN | |
| 562 | #endif | |
| 442 | # if defined(_LIBCPP_COMPILER_CLANG_BASED) | |
| 563 | 443 | |
| 564 | // Allow for build-time disabling of unsigned integer sanitization | |
| 565 | #if __has_attribute(no_sanitize) | |
| 566 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) | |
| 567 | #endif | |
| 568 | ||
| 569 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) | |
| 444 | # if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && (!defined(__arm__) || __ARM_ARCH_7K__ >= 2) | |
| 445 | # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 446 | # endif | |
| 570 | 447 | |
| 571 | #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | |
| 448 | // Objective-C++ features (opt-in) | |
| 449 | # if __has_feature(objc_arc) | |
| 450 | # define _LIBCPP_HAS_OBJC_ARC | |
| 451 | # endif | |
| 572 | 452 | |
| 573 | #elif defined(_LIBCPP_COMPILER_GCC) | |
| 453 | # if __has_feature(objc_arc_weak) | |
| 454 | # define _LIBCPP_HAS_OBJC_ARC_WEAK | |
| 455 | # endif | |
| 574 | 456 | |
| 575 | #define _ALIGNAS(x) __attribute__((__aligned__(x))) | |
| 576 | #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) | |
| 457 | # if __has_extension(blocks) | |
| 458 | # define _LIBCPP_HAS_EXTENSION_BLOCKS | |
| 459 | # endif | |
| 577 | 460 | |
| 578 | #define _LIBCPP_NORETURN __attribute__((noreturn)) | |
| 461 | # if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) | |
| 462 | # define _LIBCPP_HAS_BLOCKS_RUNTIME | |
| 463 | # endif | |
| 579 | 464 | |
| 580 | #if !defined(__EXCEPTIONS) | |
| 581 | # define _LIBCPP_NO_EXCEPTIONS | |
| 582 | #endif | |
| 465 | # if !__has_feature(address_sanitizer) | |
| 466 | # define _LIBCPP_HAS_NO_ASAN | |
| 467 | # endif | |
| 583 | 468 | |
| 584 | #if !defined(__SANITIZE_ADDRESS__) | |
| 585 | #define _LIBCPP_HAS_NO_ASAN | |
| 586 | #endif | |
| 469 | // Allow for build-time disabling of unsigned integer sanitization | |
| 470 | # if __has_attribute(no_sanitize) | |
| 471 | # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow"))) | |
| 472 | # endif | |
| 587 | 473 | |
| 588 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) | |
| 474 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) | |
| 589 | 475 | |
| 590 | #define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | |
| 476 | # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | |
| 591 | 477 | |
| 592 | #elif defined(_LIBCPP_COMPILER_MSVC) | |
| 478 | # elif defined(_LIBCPP_COMPILER_GCC) | |
| 593 | 479 | |
| 594 | #define _LIBCPP_TOSTRING2(x) #x | |
| 595 | #define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) | |
| 596 | #define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) | |
| 480 | # if !defined(__SANITIZE_ADDRESS__) | |
| 481 | # define _LIBCPP_HAS_NO_ASAN | |
| 482 | # endif | |
| 597 | 483 | |
| 598 | #if _MSC_VER < 1900 | |
| 599 | #error "MSVC versions prior to Visual Studio 2015 are not supported" | |
| 600 | #endif | |
| 484 | # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) | |
| 601 | 485 | |
| 602 | #define __alignof__ __alignof | |
| 603 | #define _LIBCPP_NORETURN __declspec(noreturn) | |
| 604 | #define _ALIGNAS(x) __declspec(align(x)) | |
| 605 | #define _ALIGNAS_TYPE(x) alignas(x) | |
| 486 | # define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__ | |
| 606 | 487 | |
| 607 | #define _LIBCPP_WEAK | |
| 488 | # elif defined(_LIBCPP_COMPILER_MSVC) | |
| 608 | 489 | |
| 609 | #define _LIBCPP_HAS_NO_ASAN | |
| 490 | # define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) | |
| 610 | 491 | |
| 611 | #define _LIBCPP_ALWAYS_INLINE __forceinline | |
| 492 | # if _MSC_VER < 1900 | |
| 493 | # error "MSVC versions prior to Visual Studio 2015 are not supported" | |
| 494 | # endif | |
| 612 | 495 | |
| 613 | #define _LIBCPP_HAS_NO_VECTOR_EXTENSION | |
| 496 | # define _LIBCPP_NORETURN __declspec(noreturn) | |
| 614 | 497 | |
| 615 | #define _LIBCPP_DISABLE_EXTENSION_WARNING | |
| 498 | # define _LIBCPP_WEAK | |
| 616 | 499 | |
| 617 | #elif defined(_LIBCPP_COMPILER_IBM) | |
| 500 | # define _LIBCPP_HAS_NO_ASAN | |
| 618 | 501 | |
| 619 | #define _ALIGNAS(x) __attribute__((__aligned__(x))) | |
| 620 | #define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x)))) | |
| 621 | #define _ATTRIBUTE(x) __attribute__((x)) | |
| 622 | #define _LIBCPP_NORETURN __attribute__((noreturn)) | |
| 502 | # define _LIBCPP_ALWAYS_INLINE __forceinline | |
| 623 | 503 | |
| 624 | #define _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 504 | # define _LIBCPP_HAS_NO_VECTOR_EXTENSION | |
| 625 | 505 | |
| 626 | #if defined(_AIX) | |
| 627 | #define __MULTILOCALE_API | |
| 628 | #endif | |
| 506 | # define _LIBCPP_DISABLE_EXTENSION_WARNING | |
| 629 | 507 | |
| 630 | #define _LIBCPP_HAS_NO_ASAN | |
| 508 | # endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC] | |
| 631 | 509 | |
| 632 | #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__always_inline__)) | |
| 510 | # if defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 633 | 511 | |
| 634 | #define _LIBCPP_HAS_NO_VECTOR_EXTENSION | |
| 512 | # ifdef _DLL | |
| 513 | # define _LIBCPP_CRT_FUNC __declspec(dllimport) | |
| 514 | # else | |
| 515 | # define _LIBCPP_CRT_FUNC | |
| 516 | # endif | |
| 635 | 517 | |
| 636 | #define _LIBCPP_DISABLE_EXTENSION_WARNING | |
| 518 | # if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY)) | |
| 519 | # define _LIBCPP_DLL_VIS | |
| 520 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | |
| 521 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 522 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 523 | # define _LIBCPP_EXPORTED_FROM_ABI | |
| 524 | # elif defined(_LIBCPP_BUILDING_LIBRARY) | |
| 525 | # define _LIBCPP_DLL_VIS __declspec(dllexport) | |
| 526 | # if defined(__MINGW32__) | |
| 527 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS | |
| 528 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 529 | # else | |
| 530 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | |
| 531 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS | |
| 532 | # endif | |
| 533 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS | |
| 534 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) | |
| 535 | # else | |
| 536 | # define _LIBCPP_DLL_VIS __declspec(dllimport) | |
| 537 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS | |
| 538 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 539 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 540 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) | |
| 541 | # endif | |
| 637 | 542 | |
| 638 | #endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] | |
| 543 | # define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS | |
| 544 | # define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS | |
| 545 | # define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS | |
| 546 | # define _LIBCPP_HIDDEN | |
| 547 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 548 | # define _LIBCPP_TEMPLATE_VIS | |
| 549 | # define _LIBCPP_TEMPLATE_DATA_VIS | |
| 550 | # define _LIBCPP_ENUM_VIS | |
| 639 | 551 | |
| 640 | #if defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 552 | # else | |
| 641 | 553 | |
| 642 | #ifdef _DLL | |
| 643 | # define _LIBCPP_CRT_FUNC __declspec(dllimport) | |
| 644 | #else | |
| 645 | # define _LIBCPP_CRT_FUNC | |
| 646 | #endif | |
| 554 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 555 | # define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis))) | |
| 556 | # else | |
| 557 | # define _LIBCPP_VISIBILITY(vis) | |
| 558 | # endif | |
| 647 | 559 | |
| 648 | #if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 649 | # define _LIBCPP_DLL_VIS | |
| 650 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | |
| 651 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 652 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 653 | # define _LIBCPP_EXPORTED_FROM_ABI | |
| 654 | #elif defined(_LIBCPP_BUILDING_LIBRARY) | |
| 655 | # define _LIBCPP_DLL_VIS __declspec(dllexport) | |
| 656 | # if defined(__MINGW32__) | |
| 657 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS | |
| 560 | # define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden") | |
| 561 | # define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default") | |
| 562 | # define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default") | |
| 563 | # define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default") | |
| 564 | # define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default") | |
| 565 | # define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default") | |
| 566 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default") | |
| 658 | 567 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS |
| 659 | # else | |
| 660 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | |
| 661 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS | |
| 662 | # endif | |
| 663 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS | |
| 664 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport) | |
| 665 | #else | |
| 666 | # define _LIBCPP_DLL_VIS __declspec(dllimport) | |
| 667 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS | |
| 668 | # define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 669 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 670 | # define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport) | |
| 671 | #endif | |
| 672 | 568 | |
| 673 | #define _LIBCPP_TYPE_VIS _LIBCPP_DLL_VIS | |
| 674 | #define _LIBCPP_FUNC_VIS _LIBCPP_DLL_VIS | |
| 675 | #define _LIBCPP_EXCEPTION_ABI _LIBCPP_DLL_VIS | |
| 676 | #define _LIBCPP_HIDDEN | |
| 677 | #define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 678 | #define _LIBCPP_TEMPLATE_VIS | |
| 679 | #define _LIBCPP_TEMPLATE_DATA_VIS | |
| 680 | #define _LIBCPP_ENUM_VIS | |
| 569 | // TODO: Make this a proper customization point or remove the option to override it. | |
| 570 | # ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 571 | # define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") | |
| 572 | # endif | |
| 681 | 573 | |
| 682 | #endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 574 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 575 | // The inline should be removed once PR32114 is resolved | |
| 576 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN | |
| 577 | # else | |
| 578 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 579 | # endif | |
| 683 | 580 | |
| 684 | #ifndef _LIBCPP_HIDDEN | |
| 685 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 686 | # define _LIBCPP_HIDDEN __attribute__ ((__visibility__("hidden"))) | |
| 687 | # else | |
| 688 | # define _LIBCPP_HIDDEN | |
| 689 | # endif | |
| 690 | #endif | |
| 581 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 582 | # if __has_attribute(__type_visibility__) | |
| 583 | # define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) | |
| 584 | # else | |
| 585 | # define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) | |
| 586 | # endif | |
| 587 | # else | |
| 588 | # define _LIBCPP_TEMPLATE_VIS | |
| 589 | # endif | |
| 691 | 590 | |
| 692 | #ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 693 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 694 | // The inline should be removed once PR32114 is resolved | |
| 695 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN | |
| 696 | # else | |
| 697 | # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 698 | # endif | |
| 699 | #endif | |
| 591 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) | |
| 592 | # define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) | |
| 593 | # else | |
| 594 | # define _LIBCPP_ENUM_VIS | |
| 595 | # endif | |
| 596 | ||
| 597 | # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 700 | 598 | |
| 701 | #ifndef _LIBCPP_FUNC_VIS | |
| 702 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 703 | # define _LIBCPP_FUNC_VIS __attribute__ ((__visibility__("default"))) | |
| 599 | # if __has_attribute(exclude_from_explicit_instantiation) | |
| 600 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__)) | |
| 704 | 601 | # else |
| 705 | # define _LIBCPP_FUNC_VIS | |
| 602 | // Try to approximate the effect of exclude_from_explicit_instantiation | |
| 603 | // (which is that entities are not assumed to be provided by explicit | |
| 604 | // template instantiations in the dylib) by always inlining those entities. | |
| 605 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE | |
| 706 | 606 | # endif |
| 707 | #endif | |
| 708 | 607 | |
| 709 | #ifndef _LIBCPP_TYPE_VIS | |
| 710 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 711 | # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) | |
| 608 | // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved | |
| 609 | // on two levels: | |
| 610 | // 1. The symbol is given hidden visibility, which ensures that users won't start exporting | |
| 611 | // symbols from their dynamic library by means of using the libc++ headers. This ensures | |
| 612 | // that those symbols stay private to the dynamic library in which it is defined. | |
| 613 | // | |
| 614 | // 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures | |
| 615 | // that no ODR violation can arise from mixing two TUs compiled with different versions | |
| 616 | // of libc++ where we would have changed the definition of a symbol. If the symbols shared | |
| 617 | // the same name, the ODR would require that their definitions be token-by-token equivalent, | |
| 618 | // which basically prevents us from being able to make any change to any function in our | |
| 619 | // headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at | |
| 620 | // each release, which lets us change the definition of these symbols at our leisure. | |
| 621 | // Note that historically, this has been achieved in various ways, including force-inlining | |
| 622 | // all functions or giving internal linkage to all functions. Both these (previous) solutions | |
| 623 | // suffer from drawbacks that lead notably to code bloat. | |
| 624 | // | |
| 625 | // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend | |
| 626 | // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library. | |
| 627 | // | |
| 628 | // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing | |
| 629 | // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and | |
| 630 | // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. | |
| 631 | # ifndef _LIBCPP_NO_ABI_TAG | |
| 632 | # define _LIBCPP_HIDE_FROM_ABI \ | |
| 633 | _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ | |
| 634 | __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER)))) | |
| 712 | 635 | # else |
| 713 | # define _LIBCPP_TYPE_VIS | |
| 636 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION | |
| 714 | 637 | # endif |
| 715 | #endif | |
| 716 | 638 | |
| 717 | #ifndef _LIBCPP_TEMPLATE_VIS | |
| 718 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 719 | # if __has_attribute(__type_visibility__) | |
| 720 | # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__type_visibility__("default"))) | |
| 639 | # ifdef _LIBCPP_BUILDING_LIBRARY | |
| 640 | # if _LIBCPP_ABI_VERSION > 1 | |
| 641 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | |
| 721 | 642 | # else |
| 722 | # define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default"))) | |
| 643 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 | |
| 723 | 644 | # endif |
| 724 | 645 | # else |
| 725 | # define _LIBCPP_TEMPLATE_VIS | |
| 646 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | |
| 726 | 647 | # endif |
| 727 | #endif | |
| 728 | 648 | |
| 729 | #ifndef _LIBCPP_TEMPLATE_DATA_VIS | |
| 730 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 731 | # define _LIBCPP_TEMPLATE_DATA_VIS __attribute__ ((__visibility__("default"))) | |
| 732 | # else | |
| 733 | # define _LIBCPP_TEMPLATE_DATA_VIS | |
| 734 | # endif | |
| 735 | #endif | |
| 649 | // Just so we can migrate to the new macros gradually. | |
| 650 | # define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI | |
| 736 | 651 | |
| 737 | #ifndef _LIBCPP_EXPORTED_FROM_ABI | |
| 738 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 739 | # define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) | |
| 740 | # else | |
| 741 | # define _LIBCPP_EXPORTED_FROM_ABI | |
| 742 | # endif | |
| 743 | #endif | |
| 652 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. | |
| 653 | // clang-format off | |
| 654 | # define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { | |
| 655 | # define _LIBCPP_END_NAMESPACE_STD }} | |
| 656 | # define _VSTD std | |
| 744 | 657 | |
| 745 | #ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS | |
| 746 | #define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS | |
| 747 | #endif | |
| 658 | _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD | |
| 748 | 659 | |
| 749 | #ifndef _LIBCPP_EXCEPTION_ABI | |
| 750 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 751 | # define _LIBCPP_EXCEPTION_ABI __attribute__ ((__visibility__("default"))) | |
| 660 | # if _LIBCPP_STD_VER > 14 | |
| 661 | # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ | |
| 662 | _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { | |
| 752 | 663 | # else |
| 753 | # define _LIBCPP_EXCEPTION_ABI | |
| 664 | # define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ | |
| 665 | _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { | |
| 754 | 666 | # endif |
| 755 | #endif | |
| 756 | 667 | |
| 757 | #ifndef _LIBCPP_ENUM_VIS | |
| 758 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) | |
| 759 | # define _LIBCPP_ENUM_VIS __attribute__ ((__type_visibility__("default"))) | |
| 760 | # else | |
| 761 | # define _LIBCPP_ENUM_VIS | |
| 762 | # endif | |
| 763 | #endif | |
| 668 | # define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }} | |
| 669 | // clang-format on | |
| 764 | 670 | |
| 765 | #ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | |
| 766 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 767 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__ ((__visibility__("default"))) | |
| 768 | # else | |
| 769 | # define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS | |
| 770 | # endif | |
| 771 | #endif | |
| 671 | # define _VSTD_FS std::__fs::filesystem | |
| 772 | 672 | |
| 773 | #ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 774 | #define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS | |
| 775 | #endif | |
| 673 | # if __has_attribute(__enable_if__) | |
| 674 | # define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, ""))) | |
| 675 | # endif | |
| 776 | 676 | |
| 777 | #if __has_attribute(internal_linkage) | |
| 778 | # define _LIBCPP_INTERNAL_LINKAGE __attribute__ ((internal_linkage)) | |
| 779 | #else | |
| 780 | # define _LIBCPP_INTERNAL_LINKAGE _LIBCPP_ALWAYS_INLINE | |
| 781 | #endif | |
| 677 | # ifndef __SIZEOF_INT128__ | |
| 678 | # define _LIBCPP_HAS_NO_INT128 | |
| 679 | # endif | |
| 782 | 680 | |
| 783 | #if __has_attribute(exclude_from_explicit_instantiation) | |
| 784 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__ ((__exclude_from_explicit_instantiation__)) | |
| 785 | #else | |
| 786 | // Try to approximate the effect of exclude_from_explicit_instantiation | |
| 787 | // (which is that entities are not assumed to be provided by explicit | |
| 788 | // template instantiations in the dylib) by always inlining those entities. | |
| 789 | # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE | |
| 790 | #endif | |
| 681 | # ifdef _LIBCPP_CXX03_LANG | |
| 682 | # define static_assert(...) _Static_assert(__VA_ARGS__) | |
| 683 | # define decltype(...) __decltype(__VA_ARGS__) | |
| 684 | # endif // _LIBCPP_CXX03_LANG | |
| 791 | 685 | |
| 792 | #ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU | |
| 793 | # ifndef _LIBCPP_HIDE_FROM_ABI_PER_TU_BY_DEFAULT | |
| 794 | # define _LIBCPP_HIDE_FROM_ABI_PER_TU 0 | |
| 686 | # ifdef _LIBCPP_CXX03_LANG | |
| 687 | # define _LIBCPP_CONSTEXPR | |
| 795 | 688 | # else |
| 796 | # define _LIBCPP_HIDE_FROM_ABI_PER_TU 1 | |
| 689 | # define _LIBCPP_CONSTEXPR constexpr | |
| 797 | 690 | # endif |
| 798 | #endif | |
| 799 | 691 | |
| 800 | #ifndef _LIBCPP_HIDE_FROM_ABI | |
| 801 | # if _LIBCPP_HIDE_FROM_ABI_PER_TU | |
| 802 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE | |
| 692 | # ifndef __cpp_consteval | |
| 693 | # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR | |
| 803 | 694 | # else |
| 804 | # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION | |
| 695 | # define _LIBCPP_CONSTEVAL consteval | |
| 805 | 696 | # endif |
| 806 | #endif | |
| 807 | 697 | |
| 808 | #ifdef _LIBCPP_BUILDING_LIBRARY | |
| 809 | # if _LIBCPP_ABI_VERSION > 1 | |
| 810 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | |
| 698 | # ifdef __GNUC__ | |
| 699 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) | |
| 811 | 700 | # else |
| 812 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 | |
| 701 | # define _LIBCPP_NOALIAS | |
| 813 | 702 | # endif |
| 814 | #else | |
| 815 | # define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI | |
| 816 | #endif | |
| 817 | ||
| 818 | // Just so we can migrate to the new macros gradually. | |
| 819 | #define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI | |
| 820 | ||
| 821 | // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. | |
| 822 | #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { | |
| 823 | #define _LIBCPP_END_NAMESPACE_STD } } | |
| 824 | #define _VSTD std | |
| 825 | _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD | |
| 826 | ||
| 827 | #if _LIBCPP_STD_VER > 14 | |
| 828 | #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ | |
| 829 | _LIBCPP_BEGIN_NAMESPACE_STD inline namespace __fs { namespace filesystem { | |
| 830 | #else | |
| 831 | #define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM \ | |
| 832 | _LIBCPP_BEGIN_NAMESPACE_STD namespace __fs { namespace filesystem { | |
| 833 | #endif | |
| 834 | ||
| 835 | #define _LIBCPP_END_NAMESPACE_FILESYSTEM \ | |
| 836 | _LIBCPP_END_NAMESPACE_STD } } | |
| 837 | ||
| 838 | #define _VSTD_FS _VSTD::__fs::filesystem | |
| 839 | ||
| 840 | #if __has_attribute(__enable_if__) | |
| 841 | # define _LIBCPP_PREFERRED_OVERLOAD __attribute__ ((__enable_if__(true, ""))) | |
| 842 | #endif | |
| 843 | ||
| 844 | #ifndef _LIBCPP_HAS_NO_NOEXCEPT | |
| 845 | # define _NOEXCEPT noexcept | |
| 846 | # define _NOEXCEPT_(x) noexcept(x) | |
| 847 | #else | |
| 848 | # define _NOEXCEPT throw() | |
| 849 | # define _NOEXCEPT_(x) | |
| 850 | #endif | |
| 851 | ||
| 852 | #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 853 | typedef unsigned short char16_t; | |
| 854 | typedef unsigned int char32_t; | |
| 855 | #endif | |
| 856 | ||
| 857 | #ifndef __SIZEOF_INT128__ | |
| 858 | #define _LIBCPP_HAS_NO_INT128 | |
| 859 | #endif | |
| 860 | 703 | |
| 861 | #ifdef _LIBCPP_CXX03_LANG | |
| 862 | # define static_assert(...) _Static_assert(__VA_ARGS__) | |
| 863 | # define decltype(...) __decltype(__VA_ARGS__) | |
| 864 | #endif // _LIBCPP_CXX03_LANG | |
| 865 | ||
| 866 | #ifdef _LIBCPP_CXX03_LANG | |
| 867 | # define _LIBCPP_CONSTEXPR | |
| 868 | #else | |
| 869 | # define _LIBCPP_CONSTEXPR constexpr | |
| 870 | #endif | |
| 871 | ||
| 872 | #ifndef __cpp_consteval | |
| 873 | # define _LIBCPP_CONSTEVAL _LIBCPP_CONSTEXPR | |
| 874 | #else | |
| 875 | # define _LIBCPP_CONSTEVAL consteval | |
| 876 | #endif | |
| 877 | ||
| 878 | #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_concepts) || __cpp_concepts < 201907L | |
| 879 | #define _LIBCPP_HAS_NO_CONCEPTS | |
| 880 | #endif | |
| 881 | ||
| 882 | #ifdef __GNUC__ | |
| 883 | # define _LIBCPP_NOALIAS __attribute__((__malloc__)) | |
| 884 | #else | |
| 885 | # define _LIBCPP_NOALIAS | |
| 886 | #endif | |
| 887 | ||
| 888 | #if __has_attribute(using_if_exists) | |
| 889 | # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) | |
| 890 | #else | |
| 891 | # define _LIBCPP_USING_IF_EXISTS | |
| 892 | #endif | |
| 893 | ||
| 894 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 895 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) struct _LIBCPP_TYPE_VIS x { enum __lx | |
| 896 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ | |
| 897 | __lx __v_; \ | |
| 898 | _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ | |
| 899 | _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ | |
| 900 | _LIBCPP_INLINE_VISIBILITY operator int() const {return __v_;} \ | |
| 901 | }; | |
| 902 | #else // _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 903 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x | |
| 904 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) | |
| 905 | #endif // _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 906 | ||
| 907 | // _LIBCPP_DEBUG potential values: | |
| 908 | // - undefined: No assertions. This is the default. | |
| 909 | // - 0: Basic assertions | |
| 910 | // - 1: Basic assertions + iterator validity checks + unspecified behavior randomization. | |
| 911 | # if !defined(_LIBCPP_DEBUG) | |
| 912 | # define _LIBCPP_DEBUG_LEVEL 0 | |
| 913 | # elif _LIBCPP_DEBUG == 0 | |
| 914 | # define _LIBCPP_DEBUG_LEVEL 1 | |
| 915 | # elif _LIBCPP_DEBUG == 1 | |
| 916 | # define _LIBCPP_DEBUG_LEVEL 2 | |
| 704 | # if __has_attribute(using_if_exists) | |
| 705 | # define _LIBCPP_USING_IF_EXISTS __attribute__((using_if_exists)) | |
| 917 | 706 | # else |
| 918 | # error Supported values for _LIBCPP_DEBUG are 0 and 1 | |
| 707 | # define _LIBCPP_USING_IF_EXISTS | |
| 919 | 708 | # endif |
| 920 | 709 | |
| 921 | # if _LIBCPP_DEBUG_LEVEL >= 2 && !defined(_LIBCPP_CXX03_LANG) | |
| 922 | # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY | |
| 710 | # ifdef _LIBCPP_CXX03_LANG | |
| 711 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) \ | |
| 712 | struct _LIBCPP_TYPE_VIS x { \ | |
| 713 | enum __lx | |
| 714 | // clang-format off | |
| 715 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) \ | |
| 716 | __lx __v_; \ | |
| 717 | _LIBCPP_INLINE_VISIBILITY x(__lx __v) : __v_(__v) {} \ | |
| 718 | _LIBCPP_INLINE_VISIBILITY explicit x(int __v) : __v_(static_cast<__lx>(__v)) {} \ | |
| 719 | _LIBCPP_INLINE_VISIBILITY operator int() const { return __v_; } \ | |
| 720 | }; | |
| 721 | // clang-format on | |
| 722 | ||
| 723 | # else // _LIBCPP_CXX03_LANG | |
| 724 | # define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x | |
| 725 | # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) | |
| 726 | # endif // _LIBCPP_CXX03_LANG | |
| 727 | ||
| 728 | # if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || defined(__sun__) || \ | |
| 729 | defined(__NetBSD__) | |
| 730 | # define _LIBCPP_LOCALE__L_EXTENSIONS 1 | |
| 923 | 731 | # endif |
| 924 | 732 | |
| 925 | # if defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 926 | # if defined(_LIBCPP_CXX03_LANG) | |
| 927 | # error Support for unspecified stability is only for C++11 and higher | |
| 928 | # endif | |
| 929 | # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ | |
| 930 | do { \ | |
| 931 | if (!__builtin_is_constant_evaluated()) \ | |
| 932 | _VSTD::shuffle(__first, __last, __libcpp_debug_randomizer()); \ | |
| 933 | } while (false) | |
| 934 | # else | |
| 935 | # define _LIBCPP_DEBUG_RANDOMIZE_RANGE(__first, __last) \ | |
| 936 | do { \ | |
| 937 | } while (false) | |
| 733 | # ifdef __FreeBSD__ | |
| 734 | # define _DECLARE_C99_LDBL_MATH 1 | |
| 938 | 735 | # endif |
| 939 | 736 | |
| 940 | // Libc++ allows disabling extern template instantiation declarations by | |
| 941 | // means of users defining _LIBCPP_DISABLE_EXTERN_TEMPLATE. | |
| 942 | // | |
| 943 | // Furthermore, when the Debug mode is enabled, we disable extern declarations | |
| 944 | // when building user code because we don't want to use the functions compiled | |
| 945 | // in the library, which might not have had the debug mode enabled when built. | |
| 946 | // However, some extern declarations need to be used, because code correctness | |
| 947 | // depends on it (several instances in <locale>). Those special declarations | |
| 948 | // are declared with _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE, which is enabled | |
| 949 | // even when the debug mode is enabled. | |
| 950 | #if defined(_LIBCPP_DISABLE_EXTERN_TEMPLATE) | |
| 951 | # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ | |
| 952 | # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) /* nothing */ | |
| 953 | #elif _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 954 | # define _LIBCPP_EXTERN_TEMPLATE(...) /* nothing */ | |
| 955 | # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; | |
| 956 | #else | |
| 957 | # define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; | |
| 958 | # define _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(...) extern template __VA_ARGS__; | |
| 959 | #endif | |
| 960 | ||
| 961 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \ | |
| 962 | defined(__sun__) || defined(__NetBSD__) | |
| 963 | #define _LIBCPP_LOCALE__L_EXTENSIONS 1 | |
| 964 | #endif | |
| 965 | ||
| 966 | #ifdef __FreeBSD__ | |
| 967 | #define _DECLARE_C99_LDBL_MATH 1 | |
| 968 | #endif | |
| 969 | ||
| 970 | 737 | // If we are getting operator new from the MSVC CRT, then allocation overloads |
| 971 | 738 | // for align_val_t were added in 19.12, aka VS 2017 version 15.3. |
| 972 | #if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 | |
| 973 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 974 | #elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) | |
| 975 | // We're deferring to Microsoft's STL to provide aligned new et al. We don't | |
| 976 | // have it unless the language feature test macro is defined. | |
| 977 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 978 | #elif defined(__MVS__) | |
| 979 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 980 | #endif | |
| 739 | # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 | |
| 740 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 741 | # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) | |
| 742 | // We're deferring to Microsoft's STL to provide aligned new et al. We don't | |
| 743 | // have it unless the language feature test macro is defined. | |
| 744 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 745 | # elif defined(__MVS__) | |
| 746 | # define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION | |
| 747 | # endif | |
| 981 | 748 | |
| 982 | #if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || \ | |
| 983 | (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) | |
| 984 | # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION | |
| 985 | #endif | |
| 749 | # if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) | |
| 750 | # define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION | |
| 751 | # endif | |
| 986 | 752 | |
| 987 | #if defined(__APPLE__) || defined(__FreeBSD__) | |
| 988 | #define _LIBCPP_HAS_DEFAULTRUNELOCALE | |
| 989 | #endif | |
| 753 | # if defined(__APPLE__) || defined(__FreeBSD__) | |
| 754 | # define _LIBCPP_HAS_DEFAULTRUNELOCALE | |
| 755 | # endif | |
| 990 | 756 | |
| 991 | #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) | |
| 992 | #define _LIBCPP_WCTYPE_IS_MASK | |
| 993 | #endif | |
| 757 | # if defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__) | |
| 758 | # define _LIBCPP_WCTYPE_IS_MASK | |
| 759 | # endif | |
| 994 | 760 | |
| 995 | #if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) | |
| 996 | #define _LIBCPP_HAS_NO_CHAR8_T | |
| 997 | #endif | |
| 761 | # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) | |
| 762 | # define _LIBCPP_HAS_NO_CHAR8_T | |
| 763 | # endif | |
| 998 | 764 | |
| 999 | 765 | // Deprecation macros. |
| 1000 | 766 | // |
| 1001 | 767 | // Deprecations warnings are always enabled, except when users explicitly opt-out |
| 1002 | 768 | // by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS. |
| 1003 | #if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | |
| 1004 | # if __has_attribute(deprecated) | |
| 1005 | # define _LIBCPP_DEPRECATED __attribute__ ((deprecated)) | |
| 1006 | # elif _LIBCPP_STD_VER > 11 | |
| 1007 | # define _LIBCPP_DEPRECATED [[deprecated]] | |
| 769 | # if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) | |
| 770 | # if __has_attribute(deprecated) | |
| 771 | # define _LIBCPP_DEPRECATED __attribute__((deprecated)) | |
| 772 | # define _LIBCPP_DEPRECATED_(m) __attribute__((deprected(m))) | |
| 773 | # elif _LIBCPP_STD_VER > 11 | |
| 774 | # define _LIBCPP_DEPRECATED [[deprecated]] | |
| 775 | # define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]] | |
| 776 | # else | |
| 777 | # define _LIBCPP_DEPRECATED | |
| 778 | # define _LIBCPP_DEPRECATED_(m) | |
| 779 | # endif | |
| 1008 | 780 | # else |
| 1009 | 781 | # define _LIBCPP_DEPRECATED |
| 782 | # define _LIBCPP_DEPRECATED_(m) | |
| 1010 | 783 | # endif |
| 1011 | #else | |
| 1012 | # define _LIBCPP_DEPRECATED | |
| 1013 | #endif | |
| 1014 | 784 | |
| 1015 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 1016 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED | |
| 1017 | #else | |
| 1018 | # define _LIBCPP_DEPRECATED_IN_CXX11 | |
| 1019 | #endif | |
| 785 | # if !defined(_LIBCPP_CXX03_LANG) | |
| 786 | # define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED | |
| 787 | # else | |
| 788 | # define _LIBCPP_DEPRECATED_IN_CXX11 | |
| 789 | # endif | |
| 1020 | 790 | |
| 1021 | #if _LIBCPP_STD_VER >= 14 | |
| 1022 | # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED | |
| 1023 | #else | |
| 1024 | # define _LIBCPP_DEPRECATED_IN_CXX14 | |
| 1025 | #endif | |
| 791 | # if _LIBCPP_STD_VER > 11 | |
| 792 | # define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED | |
| 793 | # else | |
| 794 | # define _LIBCPP_DEPRECATED_IN_CXX14 | |
| 795 | # endif | |
| 1026 | 796 | |
| 1027 | #if _LIBCPP_STD_VER >= 17 | |
| 1028 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED | |
| 1029 | #else | |
| 1030 | # define _LIBCPP_DEPRECATED_IN_CXX17 | |
| 1031 | #endif | |
| 797 | # if _LIBCPP_STD_VER > 14 | |
| 798 | # define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED | |
| 799 | # else | |
| 800 | # define _LIBCPP_DEPRECATED_IN_CXX17 | |
| 801 | # endif | |
| 1032 | 802 | |
| 1033 | #if _LIBCPP_STD_VER > 17 | |
| 1034 | # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED | |
| 1035 | #else | |
| 1036 | # define _LIBCPP_DEPRECATED_IN_CXX20 | |
| 1037 | #endif | |
| 803 | # if _LIBCPP_STD_VER > 17 | |
| 804 | # define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED | |
| 805 | # else | |
| 806 | # define _LIBCPP_DEPRECATED_IN_CXX20 | |
| 807 | # endif | |
| 1038 | 808 | |
| 1039 | #if !defined(_LIBCPP_HAS_NO_CHAR8_T) | |
| 1040 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED | |
| 1041 | #else | |
| 1042 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 1043 | #endif | |
| 809 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) | |
| 810 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED | |
| 811 | # else | |
| 812 | # define _LIBCPP_DEPRECATED_WITH_CHAR8_T | |
| 813 | # endif | |
| 1044 | 814 | |
| 1045 | 815 | // Macros to enter and leave a state where deprecation warnings are suppressed. |
| 1046 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) | |
| 1047 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ | |
| 1048 | _Pragma("GCC diagnostic push") \ | |
| 1049 | _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ | |
| 1050 | _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") | |
| 1051 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP \ | |
| 1052 | _Pragma("GCC diagnostic pop") | |
| 1053 | #else | |
| 1054 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 1055 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 1056 | #endif | |
| 816 | # if defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_COMPILER_GCC) | |
| 817 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ | |
| 818 | _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") \ | |
| 819 | _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") | |
| 820 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop") | |
| 821 | # else | |
| 822 | # define _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 823 | # define _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 824 | # endif | |
| 1057 | 825 | |
| 1058 | #if _LIBCPP_STD_VER <= 11 | |
| 1059 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 | |
| 1060 | #else | |
| 1061 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit | |
| 1062 | #endif | |
| 826 | # if _LIBCPP_STD_VER <= 11 | |
| 827 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 | |
| 828 | # else | |
| 829 | # define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit | |
| 830 | # endif | |
| 1063 | 831 | |
| 1064 | #if _LIBCPP_STD_VER > 11 | |
| 1065 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr | |
| 1066 | #else | |
| 1067 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1068 | #endif | |
| 832 | # if _LIBCPP_STD_VER > 11 | |
| 833 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr | |
| 834 | # else | |
| 835 | # define _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 836 | # endif | |
| 1069 | 837 | |
| 1070 | #if _LIBCPP_STD_VER > 14 | |
| 1071 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr | |
| 1072 | #else | |
| 1073 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 1074 | #endif | |
| 838 | # if _LIBCPP_STD_VER > 14 | |
| 839 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 constexpr | |
| 840 | # else | |
| 841 | # define _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 842 | # endif | |
| 1075 | 843 | |
| 1076 | #if _LIBCPP_STD_VER > 17 | |
| 1077 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr | |
| 1078 | #else | |
| 1079 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1080 | #endif | |
| 844 | # if _LIBCPP_STD_VER > 17 | |
| 845 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 constexpr | |
| 846 | # else | |
| 847 | # define _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 848 | # endif | |
| 1081 | 849 | |
| 1082 | #if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) | |
| 1083 | # define _LIBCPP_NODISCARD [[nodiscard]] | |
| 1084 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) | |
| 1085 | # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] | |
| 1086 | #else | |
| 850 | # if __has_cpp_attribute(nodiscard) || defined(_LIBCPP_COMPILER_MSVC) | |
| 851 | # define _LIBCPP_NODISCARD [[nodiscard]] | |
| 852 | # elif defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_CXX03_LANG) | |
| 853 | # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] | |
| 854 | # else | |
| 1087 | 855 | // We can't use GCC's [[gnu::warn_unused_result]] and |
| 1088 | 856 | // __attribute__((warn_unused_result)), because GCC does not silence them via |
| 1089 | 857 | // (void) cast. |
| 1090 | # define _LIBCPP_NODISCARD | |
| 1091 | #endif | |
| 858 | # define _LIBCPP_NODISCARD | |
| 859 | # endif | |
| 1092 | 860 | |
| 1093 | 861 | // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not |
| 1094 | 862 | // specified as such as an extension. |
| 1095 | #if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) | |
| 1096 | # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD | |
| 1097 | #else | |
| 1098 | # define _LIBCPP_NODISCARD_EXT | |
| 1099 | #endif | |
| 863 | # if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) | |
| 864 | # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD | |
| 865 | # else | |
| 866 | # define _LIBCPP_NODISCARD_EXT | |
| 867 | # endif | |
| 1100 | 868 | |
| 1101 | #if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && \ | |
| 1102 | (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) | |
| 1103 | # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD | |
| 1104 | #else | |
| 1105 | # define _LIBCPP_NODISCARD_AFTER_CXX17 | |
| 1106 | #endif | |
| 869 | # if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) | |
| 870 | # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD | |
| 871 | # else | |
| 872 | # define _LIBCPP_NODISCARD_AFTER_CXX17 | |
| 873 | # endif | |
| 1107 | 874 | |
| 1108 | #if __has_attribute(no_destroy) | |
| 1109 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) | |
| 1110 | #else | |
| 1111 | # define _LIBCPP_NO_DESTROY | |
| 1112 | #endif | |
| 875 | # if __has_attribute(no_destroy) | |
| 876 | # define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__)) | |
| 877 | # else | |
| 878 | # define _LIBCPP_NO_DESTROY | |
| 879 | # endif | |
| 1113 | 880 | |
| 1114 | #ifndef _LIBCPP_HAS_NO_ASAN | |
| 1115 | extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( | |
| 1116 | const void *, const void *, const void *, const void *); | |
| 1117 | #endif | |
| 881 | # ifndef _LIBCPP_HAS_NO_ASAN | |
| 882 | extern "C" _LIBCPP_FUNC_VIS void | |
| 883 | __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); | |
| 884 | # endif | |
| 1118 | 885 | |
| 1119 | 886 | // Try to find out if RTTI is disabled. |
| 1120 | #if defined(_LIBCPP_COMPILER_CLANG_BASED) && !__has_feature(cxx_rtti) | |
| 1121 | # define _LIBCPP_NO_RTTI | |
| 1122 | #elif defined(__GNUC__) && !defined(__GXX_RTTI) | |
| 1123 | # define _LIBCPP_NO_RTTI | |
| 1124 | #elif defined(_LIBCPP_COMPILER_MSVC) && !defined(_CPPRTTI) | |
| 1125 | # define _LIBCPP_NO_RTTI | |
| 1126 | #endif | |
| 887 | # if !defined(__cpp_rtti) || __cpp_rtti < 199711L | |
| 888 | # define _LIBCPP_NO_RTTI | |
| 889 | # endif | |
| 1127 | 890 | |
| 1128 | #ifndef _LIBCPP_WEAK | |
| 1129 | #define _LIBCPP_WEAK __attribute__((__weak__)) | |
| 1130 | #endif | |
| 891 | # ifndef _LIBCPP_WEAK | |
| 892 | # define _LIBCPP_WEAK __attribute__((__weak__)) | |
| 893 | # endif | |
| 1131 | 894 | |
| 1132 | 895 | // Thread API |
| 1133 | #if !defined(_LIBCPP_HAS_NO_THREADS) && \ | |
| 1134 | !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ | |
| 1135 | !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ | |
| 1136 | !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 1137 | # if defined(__FreeBSD__) || \ | |
| 1138 | defined(__wasi__) || \ | |
| 1139 | defined(__NetBSD__) || \ | |
| 1140 | defined(__OpenBSD__) || \ | |
| 1141 | defined(__NuttX__) || \ | |
| 1142 | defined(__linux__) || \ | |
| 1143 | defined(__GNU__) || \ | |
| 1144 | defined(__APPLE__) || \ | |
| 1145 | defined(__sun__) || \ | |
| 1146 | defined(__MVS__) || \ | |
| 1147 | defined(_AIX) | |
| 1148 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 1149 | # elif defined(__Fuchsia__) | |
| 1150 | // TODO(44575): Switch to C11 thread API when possible. | |
| 1151 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 1152 | # elif defined(_LIBCPP_WIN32API) | |
| 1153 | # define _LIBCPP_HAS_THREAD_API_WIN32 | |
| 1154 | # else | |
| 1155 | # error "No thread API" | |
| 1156 | # endif // _LIBCPP_HAS_THREAD_API | |
| 1157 | #endif // _LIBCPP_HAS_NO_THREADS | |
| 1158 | ||
| 1159 | #if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 1160 | #if defined(__ANDROID__) && __ANDROID_API__ >= 30 | |
| 1161 | #define _LIBCPP_HAS_COND_CLOCKWAIT | |
| 1162 | #elif defined(_LIBCPP_GLIBC_PREREQ) | |
| 1163 | #if _LIBCPP_GLIBC_PREREQ(2, 30) | |
| 1164 | #define _LIBCPP_HAS_COND_CLOCKWAIT | |
| 1165 | #endif | |
| 1166 | #endif | |
| 1167 | #endif | |
| 896 | // clang-format off | |
| 897 | # if !defined(_LIBCPP_HAS_NO_THREADS) && \ | |
| 898 | !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && \ | |
| 899 | !defined(_LIBCPP_HAS_THREAD_API_WIN32) && \ | |
| 900 | !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 901 | ||
| 902 | # if defined(__FreeBSD__) || \ | |
| 903 | defined(__wasi__) || \ | |
| 904 | defined(__NetBSD__) || \ | |
| 905 | defined(__OpenBSD__) || \ | |
| 906 | defined(__NuttX__) || \ | |
| 907 | defined(__linux__) || \ | |
| 908 | defined(__GNU__) || \ | |
| 909 | defined(__APPLE__) || \ | |
| 910 | defined(__sun__) || \ | |
| 911 | defined(__MVS__) || \ | |
| 912 | defined(_AIX) || \ | |
| 913 | defined(__EMSCRIPTEN__) | |
| 914 | // clang-format on | |
| 915 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 916 | # elif defined(__Fuchsia__) | |
| 917 | // TODO(44575): Switch to C11 thread API when possible. | |
| 918 | # define _LIBCPP_HAS_THREAD_API_PTHREAD | |
| 919 | # elif defined(_LIBCPP_WIN32API) | |
| 920 | # define _LIBCPP_HAS_THREAD_API_WIN32 | |
| 921 | # else | |
| 922 | # error "No thread API" | |
| 923 | # endif // _LIBCPP_HAS_THREAD_API | |
| 924 | # endif // _LIBCPP_HAS_NO_THREADS | |
| 925 | ||
| 926 | # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 927 | # if defined(__ANDROID__) && __ANDROID_API__ >= 30 | |
| 928 | # define _LIBCPP_HAS_COND_CLOCKWAIT | |
| 929 | # elif defined(_LIBCPP_GLIBC_PREREQ) | |
| 930 | # if _LIBCPP_GLIBC_PREREQ(2, 30) | |
| 931 | # define _LIBCPP_HAS_COND_CLOCKWAIT | |
| 932 | # endif | |
| 933 | # endif | |
| 934 | # endif | |
| 1168 | 935 | |
| 1169 | #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 1170 | #error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ | |
| 936 | # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | |
| 937 | # error _LIBCPP_HAS_THREAD_API_PTHREAD may only be defined when \ | |
| 1171 | 938 | _LIBCPP_HAS_NO_THREADS is not defined. |
| 1172 | #endif | |
| 939 | # endif | |
| 1173 | 940 | |
| 1174 | #if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 1175 | #error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ | |
| 941 | # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) | |
| 942 | # error _LIBCPP_HAS_THREAD_API_EXTERNAL may not be defined when \ | |
| 1176 | 943 | _LIBCPP_HAS_NO_THREADS is defined. |
| 1177 | #endif | |
| 944 | # endif | |
| 1178 | 945 | |
| 1179 | #if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 1180 | #error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ | |
| 946 | # if defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK) && !defined(_LIBCPP_HAS_NO_THREADS) | |
| 947 | # error _LIBCPP_HAS_NO_MONOTONIC_CLOCK may only be defined when \ | |
| 1181 | 948 | _LIBCPP_HAS_NO_THREADS is defined. |
| 1182 | #endif | |
| 949 | # endif | |
| 1183 | 950 | |
| 1184 | #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) | |
| 1185 | #define __STDCPP_THREADS__ 1 | |
| 1186 | #endif | |
| 951 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(__STDCPP_THREADS__) | |
| 952 | # define __STDCPP_THREADS__ 1 | |
| 953 | # endif | |
| 1187 | 954 | |
| 1188 | 955 | // The glibc and Bionic implementation of pthreads implements |
| 1189 | 956 | // pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32 |
| ... | ... | @@ -1195,11 +962,13 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1195 | 962 | // |
| 1196 | 963 | // TODO(EricWF): Enable this optimization on Bionic after speaking to their |
| 1197 | 964 | // respective stakeholders. |
| 1198 | #if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \ | |
| 1199 | || (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) \ | |
| 1200 | || defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 1201 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION | |
| 1202 | #endif | |
| 965 | // clang-format off | |
| 966 | # if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) || \ | |
| 967 | (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ | |
| 968 | defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 969 | // clang-format on | |
| 970 | # define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION | |
| 971 | # endif | |
| 1203 | 972 | |
| 1204 | 973 | // Destroying a condvar is a nop on Windows. |
| 1205 | 974 | // |
| ... | ... | @@ -1209,225 +978,245 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( |
| 1209 | 978 | // |
| 1210 | 979 | // TODO(EricWF): This is potentially true for some pthread implementations |
| 1211 | 980 | // as well. |
| 1212 | #if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ | |
| 1213 | defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 1214 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | |
| 1215 | #endif | |
| 981 | # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) | |
| 982 | # define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION | |
| 983 | # endif | |
| 1216 | 984 | |
| 1217 | 985 | // Some systems do not provide gets() in their C library, for security reasons. |
| 1218 | #if defined(_LIBCPP_MSVCRT) || \ | |
| 1219 | (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ | |
| 1220 | defined(__OpenBSD__) | |
| 1221 | # define _LIBCPP_C_HAS_NO_GETS | |
| 1222 | #endif | |
| 1223 | ||
| 1224 | #if defined(__BIONIC__) || defined(__NuttX__) || \ | |
| 1225 | defined(__Fuchsia__) || defined(__wasi__) || \ | |
| 1226 | defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) | |
| 1227 | #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE | |
| 1228 | #endif | |
| 986 | # if defined(_LIBCPP_MSVCRT) || (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || defined(__OpenBSD__) | |
| 987 | # define _LIBCPP_C_HAS_NO_GETS | |
| 988 | # endif | |
| 1229 | 989 | |
| 1230 | #if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) | |
| 1231 | # define _LIBCPP_HAS_C_ATOMIC_IMP | |
| 1232 | #elif defined(_LIBCPP_COMPILER_GCC) | |
| 1233 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP | |
| 1234 | #endif | |
| 990 | # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ | |
| 991 | defined(_LIBCPP_HAS_MUSL_LIBC) || defined(__OpenBSD__) | |
| 992 | # define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE | |
| 993 | # endif | |
| 1235 | 994 | |
| 1236 | #if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \ | |
| 1237 | !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ | |
| 1238 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) | |
| 1239 | # define _LIBCPP_HAS_NO_ATOMIC_HEADER | |
| 1240 | #else | |
| 1241 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE | |
| 1242 | # define _LIBCPP_ATOMIC_FLAG_TYPE bool | |
| 995 | # if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic) | |
| 996 | # define _LIBCPP_HAS_C_ATOMIC_IMP | |
| 997 | # elif defined(_LIBCPP_COMPILER_GCC) | |
| 998 | # define _LIBCPP_HAS_GCC_ATOMIC_IMP | |
| 1243 | 999 | # endif |
| 1244 | # ifdef _LIBCPP_FREESTANDING | |
| 1245 | # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS | |
| 1000 | ||
| 1001 | # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ | |
| 1002 | !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) | |
| 1003 | # define _LIBCPP_HAS_NO_ATOMIC_HEADER | |
| 1004 | # else | |
| 1005 | # ifndef _LIBCPP_ATOMIC_FLAG_TYPE | |
| 1006 | # define _LIBCPP_ATOMIC_FLAG_TYPE bool | |
| 1007 | # endif | |
| 1008 | # ifdef _LIBCPP_FREESTANDING | |
| 1009 | # define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS | |
| 1010 | # endif | |
| 1246 | 1011 | # endif |
| 1247 | #endif | |
| 1248 | 1012 | |
| 1249 | #ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 1250 | #define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 1251 | #endif | |
| 1013 | # ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 1014 | # define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK | |
| 1015 | # endif | |
| 1252 | 1016 | |
| 1253 | #if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) | |
| 1254 | # if defined(__clang__) && __has_attribute(acquire_capability) | |
| 1017 | # if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) | |
| 1018 | # if defined(__clang__) && __has_attribute(acquire_capability) | |
| 1255 | 1019 | // Work around the attribute handling in clang. When both __declspec and |
| 1256 | 1020 | // __attribute__ are present, the processing goes awry preventing the definition |
| 1257 | 1021 | // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus |
| 1258 | 1022 | // combining the two does work. |
| 1259 | # if !defined(_MSC_VER) | |
| 1260 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 1023 | # if !defined(_MSC_VER) | |
| 1024 | # define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 1025 | # endif | |
| 1261 | 1026 | # endif |
| 1262 | 1027 | # endif |
| 1263 | #endif | |
| 1264 | 1028 | |
| 1265 | #ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 1266 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) | |
| 1267 | #else | |
| 1268 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) | |
| 1269 | #endif | |
| 1029 | # ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS | |
| 1030 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) | |
| 1031 | # else | |
| 1032 | # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) | |
| 1033 | # endif | |
| 1270 | 1034 | |
| 1271 | #if __has_attribute(require_constant_initialization) | |
| 1272 | # define _LIBCPP_SAFE_STATIC __attribute__((__require_constant_initialization__)) | |
| 1273 | #else | |
| 1274 | # define _LIBCPP_SAFE_STATIC | |
| 1275 | #endif | |
| 1035 | # if _LIBCPP_STD_VER > 17 | |
| 1036 | # define _LIBCPP_CONSTINIT constinit | |
| 1037 | # elif __has_attribute(require_constant_initialization) | |
| 1038 | # define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__)) | |
| 1039 | # else | |
| 1040 | # define _LIBCPP_CONSTINIT | |
| 1041 | # endif | |
| 1276 | 1042 | |
| 1277 | #if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) | |
| 1278 | # define _LIBCPP_DIAGNOSE_WARNING(...) \ | |
| 1279 | __attribute__((diagnose_if(__VA_ARGS__, "warning"))) | |
| 1280 | # define _LIBCPP_DIAGNOSE_ERROR(...) \ | |
| 1281 | __attribute__((diagnose_if(__VA_ARGS__, "error"))) | |
| 1282 | #else | |
| 1283 | # define _LIBCPP_DIAGNOSE_WARNING(...) | |
| 1284 | # define _LIBCPP_DIAGNOSE_ERROR(...) | |
| 1285 | #endif | |
| 1043 | # if __has_attribute(diagnose_if) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) | |
| 1044 | # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((diagnose_if(__VA_ARGS__, "warning"))) | |
| 1045 | # define _LIBCPP_DIAGNOSE_ERROR(...) __attribute__((diagnose_if(__VA_ARGS__, "error"))) | |
| 1046 | # else | |
| 1047 | # define _LIBCPP_DIAGNOSE_WARNING(...) | |
| 1048 | # define _LIBCPP_DIAGNOSE_ERROR(...) | |
| 1049 | # endif | |
| 1286 | 1050 | |
| 1287 | 1051 | // Use a function like macro to imply that it must be followed by a semicolon |
| 1288 | #if __cplusplus > 201402L && __has_cpp_attribute(fallthrough) | |
| 1289 | # define _LIBCPP_FALLTHROUGH() [[fallthrough]] | |
| 1290 | #elif __has_cpp_attribute(clang::fallthrough) | |
| 1291 | # define _LIBCPP_FALLTHROUGH() [[clang::fallthrough]] | |
| 1292 | #elif __has_attribute(__fallthrough__) | |
| 1293 | # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) | |
| 1294 | #else | |
| 1295 | # define _LIBCPP_FALLTHROUGH() ((void)0) | |
| 1296 | #endif | |
| 1052 | # if __has_cpp_attribute(fallthrough) | |
| 1053 | # define _LIBCPP_FALLTHROUGH() [[fallthrough]] | |
| 1054 | # elif __has_attribute(__fallthrough__) | |
| 1055 | # define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__)) | |
| 1056 | # else | |
| 1057 | # define _LIBCPP_FALLTHROUGH() ((void)0) | |
| 1058 | # endif | |
| 1297 | 1059 | |
| 1298 | #if __has_attribute(__nodebug__) | |
| 1299 | #define _LIBCPP_NODEBUG __attribute__((__nodebug__)) | |
| 1300 | #else | |
| 1301 | #define _LIBCPP_NODEBUG | |
| 1302 | #endif | |
| 1060 | # if __has_attribute(__nodebug__) | |
| 1061 | # define _LIBCPP_NODEBUG __attribute__((__nodebug__)) | |
| 1062 | # else | |
| 1063 | # define _LIBCPP_NODEBUG | |
| 1064 | # endif | |
| 1303 | 1065 | |
| 1304 | #if __has_attribute(__standalone_debug__) | |
| 1305 | #define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) | |
| 1306 | #else | |
| 1307 | #define _LIBCPP_STANDALONE_DEBUG | |
| 1308 | #endif | |
| 1066 | # if __has_attribute(__standalone_debug__) | |
| 1067 | # define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__)) | |
| 1068 | # else | |
| 1069 | # define _LIBCPP_STANDALONE_DEBUG | |
| 1070 | # endif | |
| 1309 | 1071 | |
| 1310 | #if __has_attribute(__preferred_name__) | |
| 1311 | #define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) | |
| 1312 | #else | |
| 1313 | #define _LIBCPP_PREFERRED_NAME(x) | |
| 1314 | #endif | |
| 1072 | # if __has_attribute(__preferred_name__) | |
| 1073 | # define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x))) | |
| 1074 | # else | |
| 1075 | # define _LIBCPP_PREFERRED_NAME(x) | |
| 1076 | # endif | |
| 1315 | 1077 | |
| 1316 | 1078 | // We often repeat things just for handling wide characters in the library. |
| 1317 | 1079 | // When wide characters are disabled, it can be useful to have a quick way of |
| 1318 | 1080 | // disabling it without having to resort to #if-#endif, which has a larger |
| 1319 | 1081 | // impact on readability. |
| 1320 | #if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 1321 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) | |
| 1322 | #else | |
| 1323 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ | |
| 1324 | #endif | |
| 1325 | ||
| 1326 | #if defined(_LIBCPP_ABI_MICROSOFT) && \ | |
| 1327 | (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) | |
| 1328 | # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) | |
| 1329 | #else | |
| 1330 | # define _LIBCPP_DECLSPEC_EMPTY_BASES | |
| 1331 | #endif | |
| 1332 | ||
| 1333 | #if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) | |
| 1334 | #define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR | |
| 1335 | #define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS | |
| 1336 | #define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE | |
| 1337 | #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS | |
| 1338 | #endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES | |
| 1339 | ||
| 1340 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) | |
| 1341 | #define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS | |
| 1342 | #define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS | |
| 1343 | #define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS | |
| 1344 | #define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR | |
| 1345 | #define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS | |
| 1346 | #endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES | |
| 1347 | ||
| 1348 | #if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L | |
| 1349 | #define _LIBCPP_HAS_NO_CXX20_COROUTINES | |
| 1350 | #endif | |
| 1351 | ||
| 1352 | #if defined(_LIBCPP_COMPILER_IBM) | |
| 1353 | #define _LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO | |
| 1354 | #endif | |
| 1082 | # if defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS) | |
| 1083 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) | |
| 1084 | # else | |
| 1085 | # define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__ | |
| 1086 | # endif | |
| 1355 | 1087 | |
| 1356 | #if defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) | |
| 1357 | # define _LIBCPP_PUSH_MACROS | |
| 1358 | # define _LIBCPP_POP_MACROS | |
| 1359 | #else | |
| 1360 | // Don't warn about macro conflicts when we can restore them at the | |
| 1361 | // end of the header. | |
| 1362 | # ifndef _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS | |
| 1363 | # define _LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS | |
| 1364 | # endif | |
| 1365 | # if defined(_LIBCPP_COMPILER_MSVC) | |
| 1366 | # define _LIBCPP_PUSH_MACROS \ | |
| 1367 | __pragma(push_macro("min")) \ | |
| 1368 | __pragma(push_macro("max")) | |
| 1369 | # define _LIBCPP_POP_MACROS \ | |
| 1370 | __pragma(pop_macro("min")) \ | |
| 1371 | __pragma(pop_macro("max")) | |
| 1088 | # if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases)) | |
| 1089 | # define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases) | |
| 1372 | 1090 | # else |
| 1373 | # define _LIBCPP_PUSH_MACROS \ | |
| 1374 | _Pragma("push_macro(\"min\")") \ | |
| 1375 | _Pragma("push_macro(\"max\")") | |
| 1376 | # define _LIBCPP_POP_MACROS \ | |
| 1377 | _Pragma("pop_macro(\"min\")") \ | |
| 1378 | _Pragma("pop_macro(\"max\")") | |
| 1091 | # define _LIBCPP_DECLSPEC_EMPTY_BASES | |
| 1379 | 1092 | # endif |
| 1380 | #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO) | |
| 1381 | 1093 | |
| 1382 | #ifndef _LIBCPP_NO_AUTO_LINK | |
| 1383 | # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1384 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 1385 | # pragma comment(lib, "c++.lib") | |
| 1386 | # else | |
| 1387 | # pragma comment(lib, "libc++.lib") | |
| 1388 | # endif | |
| 1389 | # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1390 | #endif // _LIBCPP_NO_AUTO_LINK | |
| 1094 | # if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) | |
| 1095 | # define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR | |
| 1096 | # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS | |
| 1097 | # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE | |
| 1098 | # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS | |
| 1099 | # define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION | |
| 1100 | # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES | |
| 1101 | ||
| 1102 | # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) | |
| 1103 | # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS | |
| 1104 | # define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION | |
| 1105 | # define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS | |
| 1106 | # define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS | |
| 1107 | # define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR | |
| 1108 | # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS | |
| 1109 | # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES | |
| 1110 | ||
| 1111 | # if !defined(__cpp_impl_coroutine) || __cpp_impl_coroutine < 201902L | |
| 1112 | # define _LIBCPP_HAS_NO_CXX20_COROUTINES | |
| 1113 | # endif | |
| 1114 | ||
| 1115 | # define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") | |
| 1116 | # define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") | |
| 1117 | ||
| 1118 | # ifndef _LIBCPP_NO_AUTO_LINK | |
| 1119 | # if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1120 | # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) | |
| 1121 | # pragma comment(lib, "c++.lib") | |
| 1122 | # else | |
| 1123 | # pragma comment(lib, "libc++.lib") | |
| 1124 | # endif | |
| 1125 | # endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY) | |
| 1126 | # endif // _LIBCPP_NO_AUTO_LINK | |
| 1391 | 1127 | |
| 1392 | 1128 | // Configures the fopen close-on-exec mode character, if any. This string will |
| 1393 | 1129 | // be appended to any mode string used by fstream for fopen/fdopen. |
| 1394 | 1130 | // |
| 1395 | 1131 | // Not all platforms support this, but it helps avoid fd-leaks on platforms that |
| 1396 | 1132 | // do. |
| 1397 | #if defined(__BIONIC__) | |
| 1398 | # define _LIBCPP_FOPEN_CLOEXEC_MODE "e" | |
| 1399 | #else | |
| 1400 | # define _LIBCPP_FOPEN_CLOEXEC_MODE | |
| 1401 | #endif | |
| 1133 | # if defined(__BIONIC__) | |
| 1134 | # define _LIBCPP_FOPEN_CLOEXEC_MODE "e" | |
| 1135 | # else | |
| 1136 | # define _LIBCPP_FOPEN_CLOEXEC_MODE | |
| 1137 | # endif | |
| 1402 | 1138 | |
| 1403 | 1139 | // Support for _FILE_OFFSET_BITS=64 landed gradually in Android, so the full set |
| 1404 | 1140 | // of functions used in cstdio may not be available for low API levels when |
| 1405 | 1141 | // using 64-bit file offsets on LP32. |
| 1406 | #if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 | |
| 1407 | #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS | |
| 1408 | #endif | |
| 1142 | # if defined(__BIONIC__) && defined(__USE_FILE_OFFSET64) && __ANDROID_API__ < 24 | |
| 1143 | # define _LIBCPP_HAS_NO_FGETPOS_FSETPOS | |
| 1144 | # endif | |
| 1409 | 1145 | |
| 1410 | #if __has_attribute(init_priority) | |
| 1411 | // TODO: Remove this once we drop support for building libc++ with old Clangs | |
| 1412 | # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ | |
| 1413 | (defined(__apple_build_version__) && __apple_build_version__ < 13000000) | |
| 1414 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) | |
| 1415 | # else | |
| 1416 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) | |
| 1417 | # endif | |
| 1418 | #else | |
| 1419 | # define _LIBCPP_INIT_PRIORITY_MAX | |
| 1420 | #endif | |
| 1146 | # if __has_attribute(init_priority) | |
| 1147 | // TODO: Remove this once we drop support for building libc++ with old Clangs | |
| 1148 | # if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1200) || \ | |
| 1149 | (defined(__apple_build_version__) && __apple_build_version__ < 13000000) | |
| 1150 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101))) | |
| 1151 | # else | |
| 1152 | # define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(100))) | |
| 1153 | # endif | |
| 1154 | # else | |
| 1155 | # define _LIBCPP_INIT_PRIORITY_MAX | |
| 1156 | # endif | |
| 1421 | 1157 | |
| 1422 | #if defined(__GNUC__) || defined(__clang__) | |
| 1423 | // The attribute uses 1-based indices for ordinary and static member functions. | |
| 1424 | // The attribute uses 2-based indices for non-static member functions. | |
| 1425 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ | |
| 1426 | __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) | |
| 1427 | #else | |
| 1428 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ | |
| 1429 | #endif | |
| 1158 | # if defined(__GNUC__) || defined(__clang__) | |
| 1159 | // The attribute uses 1-based indices for ordinary and static member functions. | |
| 1160 | // The attribute uses 2-based indices for non-static member functions. | |
| 1161 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \ | |
| 1162 | __attribute__((__format__(archetype, format_string_index, first_format_arg_index))) | |
| 1163 | # else | |
| 1164 | # define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */ | |
| 1165 | # endif | |
| 1166 | ||
| 1167 | # if __has_cpp_attribute(msvc::no_unique_address) | |
| 1168 | // MSVC implements [[no_unique_address]] as a silent no-op currently. | |
| 1169 | // (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.) | |
| 1170 | // However, MSVC implements [[msvc::no_unique_address]] which does what | |
| 1171 | // [[no_unique_address]] is supposed to do, in general. | |
| 1172 | ||
| 1173 | // Clang-cl does not yet (14.0) implement either [[no_unique_address]] or | |
| 1174 | // [[msvc::no_unique_address]] though. If/when it does implement | |
| 1175 | // [[msvc::no_unique_address]], this should be preferred though. | |
| 1176 | # define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] | |
| 1177 | # elif __has_cpp_attribute(no_unique_address) | |
| 1178 | # define _LIBCPP_NO_UNIQUE_ADDRESS [[no_unique_address]] | |
| 1179 | # else | |
| 1180 | # define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */ | |
| 1181 | // Note that this can be replaced by #error as soon as clang-cl | |
| 1182 | // implements msvc::no_unique_address, since there should be no C++20 | |
| 1183 | // compiler that doesn't support one of the two attributes at that point. | |
| 1184 | // We generally don't want to use this macro outside of C++20-only code, | |
| 1185 | // because using it conditionally in one language version only would make | |
| 1186 | // the ABI inconsistent. | |
| 1187 | # endif | |
| 1188 | ||
| 1189 | # ifdef _LIBCPP_COMPILER_CLANG_BASED | |
| 1190 | # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") | |
| 1191 | # define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") | |
| 1192 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str)) | |
| 1193 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | |
| 1194 | # elif defined(_LIBCPP_COMPILER_GCC) | |
| 1195 | # define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") | |
| 1196 | # define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") | |
| 1197 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) | |
| 1198 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str)) | |
| 1199 | # else | |
| 1200 | # define _LIBCPP_DIAGNOSTIC_PUSH | |
| 1201 | # define _LIBCPP_DIAGNOSTIC_POP | |
| 1202 | # define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) | |
| 1203 | # define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) | |
| 1204 | # endif | |
| 1205 | ||
| 1206 | # if defined(_AIX) && !defined(_LIBCPP_COMPILER_GCC) | |
| 1207 | # define _LIBCPP_PACKED_BYTE_FOR_AIX _Pragma("pack(1)") | |
| 1208 | # define _LIBCPP_PACKED_BYTE_FOR_AIX_END _Pragma("pack(pop)") | |
| 1209 | # else | |
| 1210 | # define _LIBCPP_PACKED_BYTE_FOR_AIX /* empty */ | |
| 1211 | # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ | |
| 1212 | # endif | |
| 1213 | ||
| 1214 | # if __has_attribute(__packed__) | |
| 1215 | # define _LIBCPP_PACKED __attribute__((__packed__)) | |
| 1216 | # else | |
| 1217 | # define _LIBCPP_PACKED | |
| 1218 | # endif | |
| 1430 | 1219 | |
| 1431 | 1220 | #endif // __cplusplus |
| 1432 | 1221 | |
| 1433 | #endif // _LIBCPP_CONFIG | |
| 1222 | #endif // _LIBCPP___CONFIG |
lib/libcxx/include/__coroutine/coroutine_handle.h+2-2| ... | ... | @@ -9,15 +9,15 @@ |
| 9 | 9 | #ifndef _LIBCPP___COROUTINE_COROUTINE_HANDLE_H |
| 10 | 10 | #define _LIBCPP___COROUTINE_COROUTINE_HANDLE_H |
| 11 | 11 | |
| 12 | #include <__assert> | |
| 12 | 13 | #include <__config> |
| 13 | #include <__debug> | |
| 14 | 14 | #include <__functional/hash.h> |
| 15 | 15 | #include <__memory/addressof.h> |
| 16 | 16 | #include <compare> |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) |
lib/libcxx/include/__coroutine/coroutine_traits.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) |
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+2-2| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__coroutine/coroutine_handle.h> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) |
| ... | ... | @@ -66,7 +66,7 @@ private: |
| 66 | 66 | friend coroutine_handle<noop_coroutine_promise> noop_coroutine() noexcept; |
| 67 | 67 | |
| 68 | 68 | #if __has_builtin(__builtin_coro_noop) |
| 69 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { | |
| 69 | _LIBCPP_HIDE_FROM_ABI coroutine_handle() noexcept { | |
| 70 | 70 | this->__handle_ = __builtin_coro_noop(); |
| 71 | 71 | } |
| 72 | 72 |
lib/libcxx/include/__coroutine/trivial_awaitables.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__coroutine/coroutine_handle.h> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_CXX20_COROUTINES) |
lib/libcxx/include/__debug+58-85| ... | ... | @@ -7,80 +7,37 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP_DEBUG_H | |
| 11 | #define _LIBCPP_DEBUG_H | |
| 10 | #ifndef _LIBCPP___DEBUG | |
| 11 | #define _LIBCPP___DEBUG | |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <iosfwd> | |
| 15 | #include <cstddef> | |
| 15 | 16 | #include <type_traits> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | #if defined(_LIBCPP_HAS_NO_NULLPTR) | |
| 22 | # include <cstddef> | |
| 22 | // Catch invalid uses of the legacy _LIBCPP_DEBUG toggle. | |
| 23 | #if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE) | |
| 24 | # error "Enabling the debug mode now requires having configured the library with support for the debug mode" | |
| 23 | 25 | #endif |
| 24 | 26 | |
| 25 | #if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 26 | # include <cstddef> | |
| 27 | # include <cstdio> | |
| 28 | # include <cstdlib> | |
| 27 | #if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY) | |
| 28 | # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY | |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | #if _LIBCPP_DEBUG_LEVEL == 0 | |
| 32 | # define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) | |
| 33 | # define _LIBCPP_ASSERT_IMPL(x, m) ((void)0) | |
| 34 | #elif _LIBCPP_DEBUG_LEVEL == 1 | |
| 35 | # define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) | |
| 36 | # define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) | |
| 37 | #elif _LIBCPP_DEBUG_LEVEL == 2 | |
| 38 | # define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(__libcpp_is_constant_evaluated() || (x), m) | |
| 39 | # define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) | |
| 31 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 32 | # define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(::std::__libcpp_is_constant_evaluated() || (x), m) | |
| 40 | 33 | #else |
| 41 | # error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2 | |
| 34 | # define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) | |
| 42 | 35 | #endif |
| 43 | 36 | |
| 44 | #if !defined(_LIBCPP_ASSERT) | |
| 45 | # define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m) | |
| 46 | #endif | |
| 37 | #if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 47 | 38 | |
| 48 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 49 | 40 | |
| 50 | struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { | |
| 51 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 52 | __libcpp_debug_info() | |
| 53 | : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {} | |
| 54 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 55 | __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m) | |
| 56 | : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {} | |
| 57 | ||
| 58 | _LIBCPP_FUNC_VIS string what() const; | |
| 59 | ||
| 60 | const char* __file_; | |
| 61 | int __line_; | |
| 62 | const char* __pred_; | |
| 63 | const char* __msg_; | |
| 64 | }; | |
| 65 | ||
| 66 | /// __libcpp_debug_function_type - The type of the assertion failure handler. | |
| 67 | typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&); | |
| 68 | ||
| 69 | /// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT | |
| 70 | /// fails. | |
| 71 | extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_function; | |
| 72 | ||
| 73 | /// __libcpp_abort_debug_function - A debug handler that aborts when called. | |
| 74 | _LIBCPP_NORETURN _LIBCPP_FUNC_VIS | |
| 75 | void __libcpp_abort_debug_function(__libcpp_debug_info const&); | |
| 76 | ||
| 77 | /// __libcpp_set_debug_function - Set the debug handler to the specified | |
| 78 | /// function. | |
| 79 | _LIBCPP_FUNC_VIS | |
| 80 | bool __libcpp_set_debug_function(__libcpp_debug_function_type __func); | |
| 81 | ||
| 82 | #if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 83 | ||
| 84 | 41 | struct _LIBCPP_TYPE_VIS __c_node; |
| 85 | 42 | |
| 86 | 43 | struct _LIBCPP_TYPE_VIS __i_node |
| ... | ... | @@ -89,15 +46,9 @@ struct _LIBCPP_TYPE_VIS __i_node |
| 89 | 46 | __i_node* __next_; |
| 90 | 47 | __c_node* __c_; |
| 91 | 48 | |
| 92 | #ifndef _LIBCPP_CXX03_LANG | |
| 93 | 49 | __i_node(const __i_node&) = delete; |
| 94 | 50 | __i_node& operator=(const __i_node&) = delete; |
| 95 | #else | |
| 96 | private: | |
| 97 | __i_node(const __i_node&); | |
| 98 | __i_node& operator=(const __i_node&); | |
| 99 | public: | |
| 100 | #endif | |
| 51 | ||
| 101 | 52 | _LIBCPP_INLINE_VISIBILITY |
| 102 | 53 | __i_node(void* __i, __i_node* __next, __c_node* __c) |
| 103 | 54 | : __i_(__i), __next_(__next), __c_(__c) {} |
| ... | ... | @@ -112,17 +63,11 @@ struct _LIBCPP_TYPE_VIS __c_node |
| 112 | 63 | __i_node** end_; |
| 113 | 64 | __i_node** cap_; |
| 114 | 65 | |
| 115 | #ifndef _LIBCPP_CXX03_LANG | |
| 116 | 66 | __c_node(const __c_node&) = delete; |
| 117 | 67 | __c_node& operator=(const __c_node&) = delete; |
| 118 | #else | |
| 119 | private: | |
| 120 | __c_node(const __c_node&); | |
| 121 | __c_node& operator=(const __c_node&); | |
| 122 | public: | |
| 123 | #endif | |
| 68 | ||
| 124 | 69 | _LIBCPP_INLINE_VISIBILITY |
| 125 | __c_node(void* __c, __c_node* __next) | |
| 70 | explicit __c_node(void* __c, __c_node* __next) | |
| 126 | 71 | : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {} |
| 127 | 72 | virtual ~__c_node(); |
| 128 | 73 | |
| ... | ... | @@ -139,7 +84,7 @@ template <class _Cont> |
| 139 | 84 | struct _C_node |
| 140 | 85 | : public __c_node |
| 141 | 86 | { |
| 142 | _C_node(void* __c, __c_node* __n) | |
| 87 | explicit _C_node(void* __c, __c_node* __n) | |
| 143 | 88 | : __c_node(__c, __n) {} |
| 144 | 89 | |
| 145 | 90 | virtual bool __dereferenceable(const void*) const; |
| ... | ... | @@ -197,17 +142,11 @@ class _LIBCPP_TYPE_VIS __libcpp_db |
| 197 | 142 | __i_node** __iend_; |
| 198 | 143 | size_t __isz_; |
| 199 | 144 | |
| 200 | __libcpp_db(); | |
| 145 | explicit __libcpp_db(); | |
| 201 | 146 | public: |
| 202 | #ifndef _LIBCPP_CXX03_LANG | |
| 203 | 147 | __libcpp_db(const __libcpp_db&) = delete; |
| 204 | 148 | __libcpp_db& operator=(const __libcpp_db&) = delete; |
| 205 | #else | |
| 206 | private: | |
| 207 | __libcpp_db(const __libcpp_db&); | |
| 208 | __libcpp_db& operator=(const __libcpp_db&); | |
| 209 | public: | |
| 210 | #endif | |
| 149 | ||
| 211 | 150 | ~__libcpp_db(); |
| 212 | 151 | |
| 213 | 152 | class __db_c_iterator; |
| ... | ... | @@ -266,12 +205,15 @@ private: |
| 266 | 205 | _LIBCPP_FUNC_VIS __libcpp_db* __get_db(); |
| 267 | 206 | _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); |
| 268 | 207 | |
| 208 | _LIBCPP_END_NAMESPACE_STD | |
| 269 | 209 | |
| 270 | #endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 210 | #endif // defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY) | |
| 211 | ||
| 212 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 271 | 213 | |
| 272 | 214 | template <class _Tp> |
| 273 | 215 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_c(_Tp* __c) { |
| 274 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 216 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 275 | 217 | if (!__libcpp_is_constant_evaluated()) |
| 276 | 218 | __get_db()->__insert_c(__c); |
| 277 | 219 | #else |
| ... | ... | @@ -281,7 +223,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser |
| 281 | 223 | |
| 282 | 224 | template <class _Tp> |
| 283 | 225 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_insert_i(_Tp* __i) { |
| 284 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 226 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 285 | 227 | if (!__libcpp_is_constant_evaluated()) |
| 286 | 228 | __get_db()->__insert_i(__i); |
| 287 | 229 | #else |
| ... | ... | @@ -289,6 +231,37 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser |
| 289 | 231 | #endif |
| 290 | 232 | } |
| 291 | 233 | |
| 234 | template <class _Tp> | |
| 235 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) { | |
| 236 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 237 | if (!__libcpp_is_constant_evaluated()) | |
| 238 | __get_db()->__erase_c(__c); | |
| 239 | #else | |
| 240 | (void)(__c); | |
| 241 | #endif | |
| 242 | } | |
| 243 | ||
| 244 | template <class _Tp> | |
| 245 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) { | |
| 246 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 247 | if (!__libcpp_is_constant_evaluated()) | |
| 248 | __get_db()->swap(__lhs, __rhs); | |
| 249 | #else | |
| 250 | (void)(__lhs); | |
| 251 | (void)(__rhs); | |
| 252 | #endif | |
| 253 | } | |
| 254 | ||
| 255 | template <class _Tp> | |
| 256 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) { | |
| 257 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 258 | if (!__libcpp_is_constant_evaluated()) | |
| 259 | __get_db()->__invalidate_all(__c); | |
| 260 | #else | |
| 261 | (void)(__c); | |
| 262 | #endif | |
| 263 | } | |
| 264 | ||
| 292 | 265 | _LIBCPP_END_NAMESPACE_STD |
| 293 | 266 | |
| 294 | #endif // _LIBCPP_DEBUG_H | |
| 267 | #endif // _LIBCPP___DEBUG |
lib/libcxx/include/__debug_utils/randomize_range.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H | |
| 10 | #define _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY | |
| 15 | # include <__algorithm/shuffle.h> | |
| 16 | # include <__type_traits/is_constant_evaluated.h> | |
| 17 | #endif | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | template <class _AlgPolicy, class _Iterator, class _Sentinel> | |
| 26 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 27 | void __debug_randomize_range(_Iterator __first, _Sentinel __last) { | |
| 28 | #ifdef _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY | |
| 29 | # ifdef _LIBCPP_CXX03_LANG | |
| 30 | # error Support for unspecified stability is only for C++11 and higher | |
| 31 | # endif | |
| 32 | ||
| 33 | if (!__libcpp_is_constant_evaluated()) | |
| 34 | std::__shuffle<_AlgPolicy>(__first, __last, __libcpp_debug_randomizer()); | |
| 35 | #else | |
| 36 | (void)__first; | |
| 37 | (void)__last; | |
| 38 | #endif | |
| 39 | } | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | #endif // _LIBCPP___LIBCXX_DEBUG_RANDOMIZE_RANGE_H |
lib/libcxx/include/__errc+1-1| ... | ... | @@ -104,7 +104,7 @@ enum class errc |
| 104 | 104 | #include <cerrno> |
| 105 | 105 | |
| 106 | 106 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 107 | #pragma GCC system_header | |
| 107 | # pragma GCC system_header | |
| 108 | 108 | #endif |
| 109 | 109 | |
| 110 | 110 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__filesystem/copy_options.h+21-17| ... | ... | @@ -13,6 +13,10 @@ |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 16 | 20 | #ifndef _LIBCPP_CXX03_LANG |
| 17 | 21 | |
| 18 | 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -34,41 +38,41 @@ enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { |
| 34 | 38 | }; |
| 35 | 39 | |
| 36 | 40 | _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)); | |
| 41 | inline constexpr copy_options operator&(copy_options __lhs, copy_options __rhs) { | |
| 42 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) & | |
| 43 | static_cast<unsigned short>(__rhs)); | |
| 40 | 44 | } |
| 41 | 45 | |
| 42 | 46 | _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)); | |
| 47 | inline constexpr copy_options operator|(copy_options __lhs, copy_options __rhs) { | |
| 48 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) | | |
| 49 | static_cast<unsigned short>(__rhs)); | |
| 46 | 50 | } |
| 47 | 51 | |
| 48 | 52 | _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)); | |
| 53 | inline constexpr copy_options operator^(copy_options __lhs, copy_options __rhs) { | |
| 54 | return static_cast<copy_options>(static_cast<unsigned short>(__lhs) ^ | |
| 55 | static_cast<unsigned short>(__rhs)); | |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | 58 | _LIBCPP_INLINE_VISIBILITY |
| 55 | inline constexpr copy_options operator~(copy_options _LHS) { | |
| 56 | return static_cast<copy_options>(~static_cast<unsigned short>(_LHS)); | |
| 59 | inline constexpr copy_options operator~(copy_options __lhs) { | |
| 60 | return static_cast<copy_options>(~static_cast<unsigned short>(__lhs)); | |
| 57 | 61 | } |
| 58 | 62 | |
| 59 | 63 | _LIBCPP_INLINE_VISIBILITY |
| 60 | inline copy_options& operator&=(copy_options& _LHS, copy_options _RHS) { | |
| 61 | return _LHS = _LHS & _RHS; | |
| 64 | inline copy_options& operator&=(copy_options& __lhs, copy_options __rhs) { | |
| 65 | return __lhs = __lhs & __rhs; | |
| 62 | 66 | } |
| 63 | 67 | |
| 64 | 68 | _LIBCPP_INLINE_VISIBILITY |
| 65 | inline copy_options& operator|=(copy_options& _LHS, copy_options _RHS) { | |
| 66 | return _LHS = _LHS | _RHS; | |
| 69 | inline copy_options& operator|=(copy_options& __lhs, copy_options __rhs) { | |
| 70 | return __lhs = __lhs | __rhs; | |
| 67 | 71 | } |
| 68 | 72 | |
| 69 | 73 | _LIBCPP_INLINE_VISIBILITY |
| 70 | inline copy_options& operator^=(copy_options& _LHS, copy_options _RHS) { | |
| 71 | return _LHS = _LHS ^ _RHS; | |
| 74 | inline copy_options& operator^=(copy_options& __lhs, copy_options __rhs) { | |
| 75 | return __lhs = __lhs ^ __rhs; | |
| 72 | 76 | } |
| 73 | 77 | |
| 74 | 78 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
lib/libcxx/include/__filesystem/directory_entry.h+13-8| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | #include <__chrono/time_point.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__errc> |
| 16 | 17 | #include <__filesystem/file_status.h> |
| ... | ... | @@ -20,12 +21,16 @@ |
| 20 | 21 | #include <__filesystem/operations.h> |
| 21 | 22 | #include <__filesystem/path.h> |
| 22 | 23 | #include <__filesystem/perms.h> |
| 23 | #include <chrono> | |
| 24 | #include <__utility/unreachable.h> | |
| 24 | 25 | #include <cstdint> |
| 25 | 26 | #include <cstdlib> |
| 26 | 27 | #include <iosfwd> |
| 27 | 28 | #include <system_error> |
| 28 | 29 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 29 | 34 | _LIBCPP_PUSH_MACROS |
| 30 | 35 | #include <__undef_macros> |
| 31 | 36 | |
| ... | ... | @@ -358,7 +363,7 @@ private: |
| 358 | 363 | __ec->clear(); |
| 359 | 364 | return __data_.__type_; |
| 360 | 365 | } |
| 361 | _LIBCPP_UNREACHABLE(); | |
| 366 | __libcpp_unreachable(); | |
| 362 | 367 | } |
| 363 | 368 | |
| 364 | 369 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -379,7 +384,7 @@ private: |
| 379 | 384 | return __data_.__type_; |
| 380 | 385 | } |
| 381 | 386 | } |
| 382 | _LIBCPP_UNREACHABLE(); | |
| 387 | __libcpp_unreachable(); | |
| 383 | 388 | } |
| 384 | 389 | |
| 385 | 390 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -394,7 +399,7 @@ private: |
| 394 | 399 | case _RefreshSymlink: |
| 395 | 400 | return file_status(__get_ft(__ec), __data_.__non_sym_perms_); |
| 396 | 401 | } |
| 397 | _LIBCPP_UNREACHABLE(); | |
| 402 | __libcpp_unreachable(); | |
| 398 | 403 | } |
| 399 | 404 | |
| 400 | 405 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -410,7 +415,7 @@ private: |
| 410 | 415 | case _RefreshSymlinkUnresolved: |
| 411 | 416 | return file_status(__get_sym_ft(__ec), __data_.__sym_perms_); |
| 412 | 417 | } |
| 413 | _LIBCPP_UNREACHABLE(); | |
| 418 | __libcpp_unreachable(); | |
| 414 | 419 | } |
| 415 | 420 | |
| 416 | 421 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -435,7 +440,7 @@ private: |
| 435 | 440 | return __data_.__size_; |
| 436 | 441 | } |
| 437 | 442 | } |
| 438 | _LIBCPP_UNREACHABLE(); | |
| 443 | __libcpp_unreachable(); | |
| 439 | 444 | } |
| 440 | 445 | |
| 441 | 446 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -454,7 +459,7 @@ private: |
| 454 | 459 | return __data_.__nlink_; |
| 455 | 460 | } |
| 456 | 461 | } |
| 457 | _LIBCPP_UNREACHABLE(); | |
| 462 | __libcpp_unreachable(); | |
| 458 | 463 | } |
| 459 | 464 | |
| 460 | 465 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -477,7 +482,7 @@ private: |
| 477 | 482 | return __data_.__write_time_; |
| 478 | 483 | } |
| 479 | 484 | } |
| 480 | _LIBCPP_UNREACHABLE(); | |
| 485 | __libcpp_unreachable(); | |
| 481 | 486 | } |
| 482 | 487 | |
| 483 | 488 | private: |
lib/libcxx/include/__filesystem/directory_iterator.h+27-12| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__availability> |
| 14 | 15 | #include <__config> |
| 15 | #include <__debug> | |
| 16 | 16 | #include <__filesystem/directory_entry.h> |
| 17 | 17 | #include <__filesystem/directory_options.h> |
| 18 | 18 | #include <__filesystem/path.h> |
| ... | ... | @@ -23,6 +23,10 @@ |
| 23 | 23 | #include <cstddef> |
| 24 | 24 | #include <system_error> |
| 25 | 25 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 26 | 30 | #ifndef _LIBCPP_CXX03_LANG |
| 27 | 31 | |
| 28 | 32 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -40,25 +44,31 @@ public: |
| 40 | 44 | |
| 41 | 45 | public: |
| 42 | 46 | //ctor & dtor |
| 47 | _LIBCPP_HIDE_FROM_ABI | |
| 43 | 48 | directory_iterator() noexcept {} |
| 44 | 49 | |
| 50 | _LIBCPP_HIDE_FROM_ABI | |
| 45 | 51 | explicit directory_iterator(const path& __p) |
| 46 | 52 | : directory_iterator(__p, nullptr) {} |
| 47 | 53 | |
| 54 | _LIBCPP_HIDE_FROM_ABI | |
| 48 | 55 | directory_iterator(const path& __p, directory_options __opts) |
| 49 | 56 | : directory_iterator(__p, nullptr, __opts) {} |
| 50 | 57 | |
| 58 | _LIBCPP_HIDE_FROM_ABI | |
| 51 | 59 | directory_iterator(const path& __p, error_code& __ec) |
| 52 | 60 | : directory_iterator(__p, &__ec) {} |
| 53 | 61 | |
| 62 | _LIBCPP_HIDE_FROM_ABI | |
| 54 | 63 | directory_iterator(const path& __p, directory_options __opts, |
| 55 | 64 | error_code& __ec) |
| 56 | 65 | : directory_iterator(__p, &__ec, __opts) {} |
| 57 | 66 | |
| 58 | directory_iterator(const directory_iterator&) = default; | |
| 59 | directory_iterator(directory_iterator&&) = default; | |
| 60 | directory_iterator& operator=(const directory_iterator&) = default; | |
| 67 | _LIBCPP_HIDE_FROM_ABI directory_iterator(const directory_iterator&) = default; | |
| 68 | _LIBCPP_HIDE_FROM_ABI directory_iterator(directory_iterator&&) = default; | |
| 69 | _LIBCPP_HIDE_FROM_ABI directory_iterator& operator=(const directory_iterator&) = default; | |
| 61 | 70 | |
| 71 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | 72 | directory_iterator& operator=(directory_iterator&& __o) noexcept { |
| 63 | 73 | // non-default implementation provided to support self-move assign. |
| 64 | 74 | if (this != &__o) { |
| ... | ... | @@ -67,27 +77,32 @@ public: |
| 67 | 77 | return *this; |
| 68 | 78 | } |
| 69 | 79 | |
| 70 | ~directory_iterator() = default; | |
| 80 | _LIBCPP_HIDE_FROM_ABI ~directory_iterator() = default; | |
| 71 | 81 | |
| 82 | _LIBCPP_HIDE_FROM_ABI | |
| 72 | 83 | const directory_entry& operator*() const { |
| 73 | 84 | _LIBCPP_ASSERT(__imp_, "The end iterator cannot be dereferenced"); |
| 74 | 85 | return __dereference(); |
| 75 | 86 | } |
| 76 | 87 | |
| 88 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | 89 | const directory_entry* operator->() const { return &**this; } |
| 78 | 90 | |
| 91 | _LIBCPP_HIDE_FROM_ABI | |
| 79 | 92 | directory_iterator& operator++() { return __increment(); } |
| 80 | 93 | |
| 94 | _LIBCPP_HIDE_FROM_ABI | |
| 81 | 95 | __dir_element_proxy operator++(int) { |
| 82 | 96 | __dir_element_proxy __p(**this); |
| 83 | 97 | __increment(); |
| 84 | 98 | return __p; |
| 85 | 99 | } |
| 86 | 100 | |
| 101 | _LIBCPP_HIDE_FROM_ABI | |
| 87 | 102 | directory_iterator& increment(error_code& __ec) { return __increment(&__ec); } |
| 88 | 103 | |
| 89 | 104 | private: |
| 90 | inline _LIBCPP_INLINE_VISIBILITY friend bool | |
| 105 | inline _LIBCPP_HIDE_FROM_ABI friend bool | |
| 91 | 106 | operator==(const directory_iterator& __lhs, |
| 92 | 107 | const directory_iterator& __rhs) noexcept; |
| 93 | 108 | |
| ... | ... | @@ -106,25 +121,25 @@ private: |
| 106 | 121 | shared_ptr<__dir_stream> __imp_; |
| 107 | 122 | }; |
| 108 | 123 | |
| 109 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 124 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 110 | 125 | operator==(const directory_iterator& __lhs, |
| 111 | 126 | const directory_iterator& __rhs) noexcept { |
| 112 | 127 | return __lhs.__imp_ == __rhs.__imp_; |
| 113 | 128 | } |
| 114 | 129 | |
| 115 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 130 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 116 | 131 | operator!=(const directory_iterator& __lhs, |
| 117 | 132 | const directory_iterator& __rhs) noexcept { |
| 118 | 133 | return !(__lhs == __rhs); |
| 119 | 134 | } |
| 120 | 135 | |
| 121 | 136 | // enable directory_iterator range-based for statements |
| 122 | inline _LIBCPP_INLINE_VISIBILITY directory_iterator | |
| 137 | inline _LIBCPP_HIDE_FROM_ABI directory_iterator | |
| 123 | 138 | begin(directory_iterator __iter) noexcept { |
| 124 | 139 | return __iter; |
| 125 | 140 | } |
| 126 | 141 | |
| 127 | inline _LIBCPP_INLINE_VISIBILITY directory_iterator | |
| 142 | inline _LIBCPP_HIDE_FROM_ABI directory_iterator | |
| 128 | 143 | end(directory_iterator) noexcept { |
| 129 | 144 | return directory_iterator(); |
| 130 | 145 | } |
| ... | ... | @@ -133,7 +148,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
| 133 | 148 | |
| 134 | 149 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 135 | 150 | |
| 136 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 151 | #if _LIBCPP_STD_VER > 17 | |
| 137 | 152 | |
| 138 | 153 | template <> |
| 139 | 154 | _LIBCPP_AVAILABILITY_FILESYSTEM |
| ... | ... | @@ -143,7 +158,7 @@ template <> |
| 143 | 158 | _LIBCPP_AVAILABILITY_FILESYSTEM |
| 144 | 159 | inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::directory_iterator> = true; |
| 145 | 160 | |
| 146 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 161 | #endif // _LIBCPP_STD_VER > 17 | |
| 147 | 162 | |
| 148 | 163 | #endif // _LIBCPP_CXX03_LANG |
| 149 | 164 |
lib/libcxx/include/__filesystem/directory_options.h+27-23| ... | ... | @@ -13,6 +13,10 @@ |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 16 | 20 | #ifndef _LIBCPP_CXX03_LANG |
| 17 | 21 | |
| 18 | 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -26,47 +30,47 @@ enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { |
| 26 | 30 | }; |
| 27 | 31 | |
| 28 | 32 | _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 | inline constexpr directory_options operator&(directory_options __lhs, | |
| 34 | directory_options __rhs) { | |
| 35 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) & | |
| 36 | static_cast<unsigned char>(__rhs)); | |
| 33 | 37 | } |
| 34 | 38 | |
| 35 | 39 | _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 | inline constexpr directory_options operator|(directory_options __lhs, | |
| 41 | directory_options __rhs) { | |
| 42 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) | | |
| 43 | static_cast<unsigned char>(__rhs)); | |
| 40 | 44 | } |
| 41 | 45 | |
| 42 | 46 | _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 | inline constexpr directory_options operator^(directory_options __lhs, | |
| 48 | directory_options __rhs) { | |
| 49 | return static_cast<directory_options>(static_cast<unsigned char>(__lhs) ^ | |
| 50 | static_cast<unsigned char>(__rhs)); | |
| 47 | 51 | } |
| 48 | 52 | |
| 49 | 53 | _LIBCPP_INLINE_VISIBILITY |
| 50 | inline constexpr directory_options operator~(directory_options _LHS) { | |
| 51 | return static_cast<directory_options>(~static_cast<unsigned char>(_LHS)); | |
| 54 | inline constexpr directory_options operator~(directory_options __lhs) { | |
| 55 | return static_cast<directory_options>(~static_cast<unsigned char>(__lhs)); | |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | 58 | _LIBCPP_INLINE_VISIBILITY |
| 55 | inline directory_options& operator&=(directory_options& _LHS, | |
| 56 | directory_options _RHS) { | |
| 57 | return _LHS = _LHS & _RHS; | |
| 59 | inline directory_options& operator&=(directory_options& __lhs, | |
| 60 | directory_options __rhs) { | |
| 61 | return __lhs = __lhs & __rhs; | |
| 58 | 62 | } |
| 59 | 63 | |
| 60 | 64 | _LIBCPP_INLINE_VISIBILITY |
| 61 | inline directory_options& operator|=(directory_options& _LHS, | |
| 62 | directory_options _RHS) { | |
| 63 | return _LHS = _LHS | _RHS; | |
| 65 | inline directory_options& operator|=(directory_options& __lhs, | |
| 66 | directory_options __rhs) { | |
| 67 | return __lhs = __lhs | __rhs; | |
| 64 | 68 | } |
| 65 | 69 | |
| 66 | 70 | _LIBCPP_INLINE_VISIBILITY |
| 67 | inline directory_options& operator^=(directory_options& _LHS, | |
| 68 | directory_options _RHS) { | |
| 69 | return _LHS = _LHS ^ _RHS; | |
| 71 | inline directory_options& operator^=(directory_options& __lhs, | |
| 72 | directory_options __rhs) { | |
| 73 | return __lhs = __lhs ^ __rhs; | |
| 70 | 74 | } |
| 71 | 75 | |
| 72 | 76 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
lib/libcxx/include/__filesystem/file_status.h+4| ... | ... | @@ -15,6 +15,10 @@ |
| 15 | 15 | #include <__filesystem/file_type.h> |
| 16 | 16 | #include <__filesystem/perms.h> |
| 17 | 17 | |
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 18 | 22 | #ifndef _LIBCPP_CXX03_LANG |
| 19 | 23 | |
| 20 | 24 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
lib/libcxx/include/__filesystem/file_time_type.h+6-1| ... | ... | @@ -11,8 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | #include <__chrono/file_clock.h> | |
| 15 | #include <__chrono/time_point.h> | |
| 14 | 16 | #include <__config> |
| 15 | #include <chrono> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 16 | 21 | |
| 17 | 22 | #ifndef _LIBCPP_CXX03_LANG |
| 18 | 23 |
lib/libcxx/include/__filesystem/file_type.h+4| ... | ... | @@ -13,6 +13,10 @@ |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 16 | 20 | #ifndef _LIBCPP_CXX03_LANG |
| 17 | 21 | |
| 18 | 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
lib/libcxx/include/__filesystem/filesystem_error.h+4| ... | ... | @@ -19,6 +19,10 @@ |
| 19 | 19 | #include <system_error> |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 22 | 26 | #ifndef _LIBCPP_CXX03_LANG |
| 23 | 27 | |
| 24 | 28 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
lib/libcxx/include/__filesystem/operations.h+112-108| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_OPERATIONS_H |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | #include <__chrono/time_point.h> | |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__filesystem/copy_options.h> |
| 16 | 17 | #include <__filesystem/file_status.h> |
| ... | ... | @@ -20,10 +21,13 @@ |
| 20 | 21 | #include <__filesystem/perm_options.h> |
| 21 | 22 | #include <__filesystem/perms.h> |
| 22 | 23 | #include <__filesystem/space_info.h> |
| 23 | #include <chrono> | |
| 24 | 24 | #include <cstdint> |
| 25 | 25 | #include <system_error> |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | #endif | |
| 30 | ||
| 27 | 31 | #ifndef _LIBCPP_CXX03_LANG |
| 28 | 32 | |
| 29 | 33 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -35,10 +39,10 @@ _LIBCPP_FUNC_VIS path __canonical(const path&, error_code* __ec = nullptr); |
| 35 | 39 | _LIBCPP_FUNC_VIS bool __copy_file(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr); |
| 36 | 40 | _LIBCPP_FUNC_VIS void __copy_symlink(const path& __existing_symlink, const path& __new_symlink, error_code* __ec = nullptr); |
| 37 | 41 | _LIBCPP_FUNC_VIS void __copy(const path& __from, const path& __to, copy_options __opt, error_code* __ec = nullptr); |
| 38 | _LIBCPP_FUNC_VIS bool __create_directories(const path& p, error_code* ec = nullptr); | |
| 42 | _LIBCPP_FUNC_VIS bool __create_directories(const path&, error_code* = nullptr); | |
| 39 | 43 | _LIBCPP_FUNC_VIS void __create_directory_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr); |
| 40 | _LIBCPP_FUNC_VIS bool __create_directory(const path& p, error_code* ec = nullptr); | |
| 41 | _LIBCPP_FUNC_VIS bool __create_directory(const path& p, const path& attributes, error_code* ec = nullptr); | |
| 44 | _LIBCPP_FUNC_VIS bool __create_directory(const path&, error_code* = nullptr); | |
| 45 | _LIBCPP_FUNC_VIS bool __create_directory(const path&, const path& __attributes, error_code* = nullptr); | |
| 42 | 46 | _LIBCPP_FUNC_VIS void __create_hard_link(const path& __to, const path& __new_hard_link, error_code* __ec = nullptr); |
| 43 | 47 | _LIBCPP_FUNC_VIS void __create_symlink(const path& __to, const path& __new_symlink, error_code* __ec = nullptr); |
| 44 | 48 | _LIBCPP_FUNC_VIS path __current_path(error_code* __ec = nullptr); |
| ... | ... | @@ -48,51 +52,51 @@ _LIBCPP_FUNC_VIS file_status __status(const path&, error_code* __ec = nullptr); |
| 48 | 52 | _LIBCPP_FUNC_VIS uintmax_t __file_size(const path&, error_code* __ec = nullptr); |
| 49 | 53 | _LIBCPP_FUNC_VIS uintmax_t __hard_link_count(const path&, error_code* __ec = nullptr); |
| 50 | 54 | _LIBCPP_FUNC_VIS file_status __symlink_status(const path&, error_code* __ec = nullptr); |
| 51 | _LIBCPP_FUNC_VIS file_time_type __last_write_time(const path& p, error_code* ec = nullptr); | |
| 52 | _LIBCPP_FUNC_VIS void __last_write_time(const path& p, file_time_type new_time, error_code* ec = nullptr); | |
| 55 | _LIBCPP_FUNC_VIS file_time_type __last_write_time(const path&, error_code* __ec = nullptr); | |
| 56 | _LIBCPP_FUNC_VIS void __last_write_time(const path&, file_time_type __new_time, error_code* __ec = nullptr); | |
| 53 | 57 | _LIBCPP_FUNC_VIS path __weakly_canonical(path const& __p, error_code* __ec = nullptr); |
| 54 | _LIBCPP_FUNC_VIS path __read_symlink(const path& p, error_code* ec = nullptr); | |
| 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); | |
| 58 | _LIBCPP_FUNC_VIS path __read_symlink(const path&, error_code* __ec = nullptr); | |
| 59 | _LIBCPP_FUNC_VIS uintmax_t __remove_all(const path&, error_code* __ec = nullptr); | |
| 60 | _LIBCPP_FUNC_VIS bool __remove(const path&, error_code* __ec = nullptr); | |
| 61 | _LIBCPP_FUNC_VIS void __rename(const path& __from, const path& __to, error_code* __ec = nullptr); | |
| 62 | _LIBCPP_FUNC_VIS void __resize_file(const path&, uintmax_t __size, error_code* = nullptr); | |
| 59 | 63 | _LIBCPP_FUNC_VIS path __temp_directory_path(error_code* __ec = nullptr); |
| 60 | 64 | |
| 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)); } | |
| 65 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); } | |
| 66 | inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); } | |
| 67 | inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p) { return __canonical(__p); } | |
| 68 | inline _LIBCPP_HIDE_FROM_ABI path canonical(const path& __p, error_code& __ec) { return __canonical(__p, &__ec); } | |
| 69 | inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to) { return __copy_file(__from, __to, copy_options::none); } | |
| 70 | inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, error_code& __ec) { return __copy_file(__from, __to, copy_options::none, &__ec); } | |
| 71 | inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt) { return __copy_file(__from, __to, __opt); } | |
| 72 | inline _LIBCPP_HIDE_FROM_ABI bool copy_file(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { return __copy_file(__from, __to, __opt, &__ec); } | |
| 73 | inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to) { __copy_symlink(__from, __to); } | |
| 74 | inline _LIBCPP_HIDE_FROM_ABI void copy_symlink(const path& __from, const path& __to, error_code& __ec) noexcept { __copy_symlink(__from, __to, &__ec); } | |
| 75 | inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to) { __copy(__from, __to, copy_options::none); } | |
| 76 | inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, error_code& __ec) { __copy(__from, __to, copy_options::none, &__ec); } | |
| 77 | inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt) { __copy(__from, __to, __opt); } | |
| 78 | inline _LIBCPP_HIDE_FROM_ABI void copy(const path& __from, const path& __to, copy_options __opt, error_code& __ec) { __copy(__from, __to, __opt, &__ec); } | |
| 79 | inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p) { return __create_directories(__p); } | |
| 80 | inline _LIBCPP_HIDE_FROM_ABI bool create_directories(const path& __p, error_code& __ec) { return __create_directories(__p, &__ec); } | |
| 81 | inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link) { __create_directory_symlink(__target, __link); } | |
| 82 | inline _LIBCPP_HIDE_FROM_ABI void create_directory_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { __create_directory_symlink(__target, __link, &__ec); } | |
| 83 | inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p) { return __create_directory(__p); } | |
| 84 | inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, error_code& __ec) noexcept { return __create_directory(__p, &__ec); } | |
| 85 | inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs) { return __create_directory(__p, __attrs); } | |
| 86 | inline _LIBCPP_HIDE_FROM_ABI bool create_directory(const path& __p, const path& __attrs, error_code& __ec) noexcept { return __create_directory(__p, __attrs, &__ec); } | |
| 87 | inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link) { __create_hard_link(__target, __link); } | |
| 88 | inline _LIBCPP_HIDE_FROM_ABI void create_hard_link(const path& __target, const path& __link, error_code& __ec) noexcept { __create_hard_link(__target, __link, &__ec); } | |
| 89 | inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link) { __create_symlink(__target, __link); } | |
| 90 | inline _LIBCPP_HIDE_FROM_ABI void create_symlink(const path& __target, const path& __link, error_code& __ec) noexcept { return __create_symlink(__target, __link, &__ec); } | |
| 91 | inline _LIBCPP_HIDE_FROM_ABI path current_path() { return __current_path(); } | |
| 92 | inline _LIBCPP_HIDE_FROM_ABI path current_path(error_code& __ec) { return __current_path(&__ec); } | |
| 93 | inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p) { __current_path(__p); } | |
| 94 | inline _LIBCPP_HIDE_FROM_ABI void current_path(const path& __p, error_code& __ec) noexcept { __current_path(__p, &__ec); } | |
| 95 | inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2) { return __equivalent(__p1, __p2); } | |
| 96 | inline _LIBCPP_HIDE_FROM_ABI bool equivalent(const path& __p1, const path& __p2, error_code& __ec) noexcept { return __equivalent(__p1, __p2, &__ec); } | |
| 97 | inline _LIBCPP_HIDE_FROM_ABI bool status_known(file_status __s) noexcept { return __s.type() != file_type::none; } | |
| 98 | inline _LIBCPP_HIDE_FROM_ABI bool exists(file_status __s) noexcept { return status_known(__s) && __s.type() != file_type::not_found; } | |
| 99 | inline _LIBCPP_HIDE_FROM_ABI bool exists(const path& __p) { return exists(__status(__p)); } | |
| 96 | 100 | |
| 97 | 101 | inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) noexcept { |
| 98 | 102 | auto __s = __status(__p, &__ec); |
| ... | ... | @@ -101,45 +105,45 @@ inline _LIBCPP_INLINE_VISIBILITY bool exists(const path& __p, error_code& __ec) |
| 101 | 105 | return exists(__s); |
| 102 | 106 | } |
| 103 | 107 | |
| 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); } | |
| 108 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p) { return __file_size(__p); } | |
| 109 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t file_size(const path& __p, error_code& __ec) noexcept { return __file_size(__p, &__ec); } | |
| 110 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p) { return __hard_link_count(__p); } | |
| 111 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t hard_link_count(const path& __p, error_code& __ec) noexcept { return __hard_link_count(__p, &__ec); } | |
| 112 | inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(file_status __s) noexcept { return __s.type() == file_type::block; } | |
| 113 | inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p) { return is_block_file(__status(__p)); } | |
| 114 | inline _LIBCPP_HIDE_FROM_ABI bool is_block_file(const path& __p, error_code& __ec) noexcept { return is_block_file(__status(__p, &__ec)); } | |
| 115 | inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(file_status __s) noexcept { return __s.type() == file_type::character; } | |
| 116 | inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p) { return is_character_file(__status(__p)); } | |
| 117 | inline _LIBCPP_HIDE_FROM_ABI bool is_character_file(const path& __p, error_code& __ec) noexcept { return is_character_file(__status(__p, &__ec)); } | |
| 118 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(file_status __s) noexcept { return __s.type() == file_type::directory; } | |
| 119 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_directory(__status(__p)); } | |
| 120 | inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept { return is_directory(__status(__p, &__ec)); } | |
| 121 | _LIBCPP_FUNC_VIS bool __fs_is_empty(const path& __p, error_code* __ec = nullptr); | |
| 122 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); } | |
| 123 | inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); } | |
| 124 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; } | |
| 125 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p) { return is_fifo(__status(__p)); } | |
| 126 | inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(const path& __p, error_code& __ec) noexcept { return is_fifo(__status(__p, &__ec)); } | |
| 127 | inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(file_status __s) noexcept { return __s.type() == file_type::regular; } | |
| 128 | inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p) { return is_regular_file(__status(__p)); } | |
| 129 | inline _LIBCPP_HIDE_FROM_ABI bool is_regular_file(const path& __p, error_code& __ec) noexcept { return is_regular_file(__status(__p, &__ec)); } | |
| 130 | inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(file_status __s) noexcept { return __s.type() == file_type::symlink; } | |
| 131 | inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p) { return is_symlink(__symlink_status(__p)); } | |
| 132 | inline _LIBCPP_HIDE_FROM_ABI bool is_symlink(const path& __p, error_code& __ec) noexcept { return is_symlink(__symlink_status(__p, &__ec)); } | |
| 133 | inline _LIBCPP_HIDE_FROM_ABI bool is_other(file_status __s) noexcept { return exists(__s) && !is_regular_file(__s) && !is_directory(__s) && !is_symlink(__s); } | |
| 134 | inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p) { return is_other(__status(__p)); } | |
| 135 | inline _LIBCPP_HIDE_FROM_ABI bool is_other(const path& __p, error_code& __ec) noexcept { return is_other(__status(__p, &__ec)); } | |
| 136 | inline _LIBCPP_HIDE_FROM_ABI bool is_socket(file_status __s) noexcept { return __s.type() == file_type::socket; } | |
| 137 | inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p) { return is_socket(__status(__p)); } | |
| 138 | inline _LIBCPP_HIDE_FROM_ABI bool is_socket(const path& __p, error_code& __ec) noexcept { return is_socket(__status(__p, &__ec)); } | |
| 139 | inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p) { return __last_write_time(__p); } | |
| 140 | inline _LIBCPP_HIDE_FROM_ABI file_time_type last_write_time(const path& __p, error_code& __ec) noexcept { return __last_write_time(__p, &__ec); } | |
| 141 | inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t) { __last_write_time(__p, __t); } | |
| 142 | inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept { __last_write_time(__p, __t, &__ec); } | |
| 139 | 143 | _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); } | |
| 144 | inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) { __permissions(__p, __prms, __opts); } | |
| 145 | inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, error_code& __ec) noexcept { __permissions(__p, __prms, perm_options::replace, &__ec); } | |
| 146 | inline _LIBCPP_HIDE_FROM_ABI void permissions(const path& __p, perms __prms, perm_options __opts, error_code& __ec) { __permissions(__p, __prms, __opts, &__ec); } | |
| 143 | 147 | |
| 144 | 148 | inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __base, error_code& __ec) { |
| 145 | 149 | path __tmp = __weakly_canonical(__p, &__ec); |
| ... | ... | @@ -151,10 +155,10 @@ inline _LIBCPP_INLINE_VISIBILITY path proximate(const path& __p, const path& __b |
| 151 | 155 | return __tmp.lexically_proximate(__tmp_base); |
| 152 | 156 | } |
| 153 | 157 | |
| 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 | inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, error_code& __ec) { return proximate(__p, current_path(), __ec); } | |
| 159 | inline _LIBCPP_HIDE_FROM_ABI path proximate(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_proximate(__weakly_canonical(__base)); } | |
| 160 | inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p) { return __read_symlink(__p); } | |
| 161 | inline _LIBCPP_HIDE_FROM_ABI path read_symlink(const path& __p, error_code& __ec) { return __read_symlink(__p, &__ec); } | |
| 158 | 162 | |
| 159 | 163 | inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __base, error_code& __ec) { |
| 160 | 164 | path __tmp = __weakly_canonical(__p, &__ec); |
| ... | ... | @@ -166,27 +170,27 @@ inline _LIBCPP_INLINE_VISIBILITY path relative(const path& __p, const path& __ba |
| 166 | 170 | return __tmp.lexically_relative(__tmpbase); |
| 167 | 171 | } |
| 168 | 172 | |
| 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); } | |
| 173 | inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, error_code& __ec) { return relative(__p, current_path(), __ec); } | |
| 174 | inline _LIBCPP_HIDE_FROM_ABI path relative(const path& __p, const path& __base = current_path()) { return __weakly_canonical(__p).lexically_relative(__weakly_canonical(__base)); } | |
| 175 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p) { return __remove_all(__p); } | |
| 176 | inline _LIBCPP_HIDE_FROM_ABI uintmax_t remove_all(const path& __p, error_code& __ec) { return __remove_all(__p, &__ec); } | |
| 177 | inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p) { return __remove(__p); } | |
| 178 | inline _LIBCPP_HIDE_FROM_ABI bool remove(const path& __p, error_code& __ec) noexcept { return __remove(__p, &__ec); } | |
| 179 | inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to) { return __rename(__from, __to); } | |
| 180 | inline _LIBCPP_HIDE_FROM_ABI void rename(const path& __from, const path& __to, error_code& __ec) noexcept { return __rename(__from, __to, &__ec); } | |
| 181 | inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) { return __resize_file(__p, __ns); } | |
| 182 | inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept { return __resize_file(__p, __ns, &__ec); } | |
| 179 | 183 | _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); } | |
| 184 | inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); } | |
| 185 | inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept { return __space(__p, &__ec); } | |
| 186 | inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p) { return __status(__p); } | |
| 187 | inline _LIBCPP_HIDE_FROM_ABI file_status status(const path& __p, error_code& __ec) noexcept { return __status(__p, &__ec); } | |
| 188 | inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p) { return __symlink_status(__p); } | |
| 189 | inline _LIBCPP_HIDE_FROM_ABI file_status symlink_status(const path& __p, error_code& __ec) noexcept { return __symlink_status(__p, &__ec); } | |
| 190 | inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path() { return __temp_directory_path(); } | |
| 191 | inline _LIBCPP_HIDE_FROM_ABI path temp_directory_path(error_code& __ec) { return __temp_directory_path(&__ec); } | |
| 192 | inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p) { return __weakly_canonical(__p); } | |
| 193 | inline _LIBCPP_HIDE_FROM_ABI path weakly_canonical(path const& __p, error_code& __ec) { return __weakly_canonical(__p, &__ec); } | |
| 190 | 194 | |
| 191 | 195 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
| 192 | 196 |
lib/libcxx/include/__filesystem/path.h+147-81| ... | ... | @@ -10,6 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___FILESYSTEM_PATH_H |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_PATH_H |
| 12 | 12 | |
| 13 | #include <__algorithm/replace.h> | |
| 14 | #include <__algorithm/replace_copy.h> | |
| 13 | 15 | #include <__availability> |
| 14 | 16 | #include <__config> |
| 15 | 17 | #include <__iterator/back_insert_iterator.h> |
| ... | ... | @@ -24,6 +26,10 @@ |
| 24 | 26 | # include <locale> |
| 25 | 27 | #endif |
| 26 | 28 | |
| 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 30 | # pragma GCC system_header | |
| 31 | #endif | |
| 32 | ||
| 27 | 33 | #ifndef _LIBCPP_CXX03_LANG |
| 28 | 34 | |
| 29 | 35 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -65,6 +71,7 @@ struct __can_convert_char<char32_t> { |
| 65 | 71 | }; |
| 66 | 72 | |
| 67 | 73 | template <class _ECharT> |
| 74 | _LIBCPP_HIDE_FROM_ABI | |
| 68 | 75 | typename enable_if<__can_convert_char<_ECharT>::value, bool>::type |
| 69 | 76 | __is_separator(_ECharT __e) { |
| 70 | 77 | #if defined(_LIBCPP_WIN32API) |
| ... | ... | @@ -95,10 +102,16 @@ struct __is_pathable_string< |
| 95 | 102 | : public __can_convert_char<_ECharT> { |
| 96 | 103 | using _Str = basic_string<_ECharT, _Traits, _Alloc>; |
| 97 | 104 | using _Base = __can_convert_char<_ECharT>; |
| 105 | ||
| 106 | _LIBCPP_HIDE_FROM_ABI | |
| 98 | 107 | static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } |
| 108 | ||
| 109 | _LIBCPP_HIDE_FROM_ABI | |
| 99 | 110 | static _ECharT const* __range_end(_Str const& __s) { |
| 100 | 111 | return __s.data() + __s.length(); |
| 101 | 112 | } |
| 113 | ||
| 114 | _LIBCPP_HIDE_FROM_ABI | |
| 102 | 115 | static _ECharT __first_or_null(_Str const& __s) { |
| 103 | 116 | return __s.empty() ? _ECharT{} : __s[0]; |
| 104 | 117 | } |
| ... | ... | @@ -111,10 +124,16 @@ struct __is_pathable_string< |
| 111 | 124 | : public __can_convert_char<_ECharT> { |
| 112 | 125 | using _Str = basic_string_view<_ECharT, _Traits>; |
| 113 | 126 | using _Base = __can_convert_char<_ECharT>; |
| 127 | ||
| 128 | _LIBCPP_HIDE_FROM_ABI | |
| 114 | 129 | static _ECharT const* __range_begin(_Str const& __s) { return __s.data(); } |
| 130 | ||
| 131 | _LIBCPP_HIDE_FROM_ABI | |
| 115 | 132 | static _ECharT const* __range_end(_Str const& __s) { |
| 116 | 133 | return __s.data() + __s.length(); |
| 117 | 134 | } |
| 135 | ||
| 136 | _LIBCPP_HIDE_FROM_ABI | |
| 118 | 137 | static _ECharT __first_or_null(_Str const& __s) { |
| 119 | 138 | return __s.empty() ? _ECharT{} : __s[0]; |
| 120 | 139 | } |
| ... | ... | @@ -132,7 +151,10 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> |
| 132 | 151 | : __can_convert_char<typename remove_const<_ECharT>::type> { |
| 133 | 152 | using _Base = __can_convert_char<typename remove_const<_ECharT>::type>; |
| 134 | 153 | |
| 154 | _LIBCPP_HIDE_FROM_ABI | |
| 135 | 155 | static _ECharT const* __range_begin(const _ECharT* __b) { return __b; } |
| 156 | ||
| 157 | _LIBCPP_HIDE_FROM_ABI | |
| 136 | 158 | static _ECharT const* __range_end(const _ECharT* __b) { |
| 137 | 159 | using _Iter = const _ECharT*; |
| 138 | 160 | const _ECharT __sentinel = _ECharT{}; |
| ... | ... | @@ -142,6 +164,7 @@ struct __is_pathable_char_array<_Source, _ECharT*, _UPtr, true> |
| 142 | 164 | return __e; |
| 143 | 165 | } |
| 144 | 166 | |
| 167 | _LIBCPP_HIDE_FROM_ABI | |
| 145 | 168 | static _ECharT __first_or_null(const _ECharT* __b) { return *__b; } |
| 146 | 169 | }; |
| 147 | 170 | |
| ... | ... | @@ -158,9 +181,13 @@ struct __is_pathable_iter< |
| 158 | 181 | using _ECharT = typename iterator_traits<_Iter>::value_type; |
| 159 | 182 | using _Base = __can_convert_char<_ECharT>; |
| 160 | 183 | |
| 184 | _LIBCPP_HIDE_FROM_ABI | |
| 161 | 185 | static _Iter __range_begin(_Iter __b) { return __b; } |
| 186 | ||
| 187 | _LIBCPP_HIDE_FROM_ABI | |
| 162 | 188 | static _NullSentinel __range_end(_Iter) { return _NullSentinel{}; } |
| 163 | 189 | |
| 190 | _LIBCPP_HIDE_FROM_ABI | |
| 164 | 191 | static _ECharT __first_or_null(_Iter __b) { return *__b; } |
| 165 | 192 | }; |
| 166 | 193 | |
| ... | ... | @@ -210,6 +237,7 @@ struct _PathCVT { |
| 210 | 237 | typedef __widen_from_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Widener; |
| 211 | 238 | #endif |
| 212 | 239 | |
| 240 | _LIBCPP_HIDE_FROM_ABI | |
| 213 | 241 | static void __append_range(__path_string& __dest, _ECharT const* __b, |
| 214 | 242 | _ECharT const* __e) { |
| 215 | 243 | #if defined(_LIBCPP_WIN32API) |
| ... | ... | @@ -222,6 +250,7 @@ struct _PathCVT { |
| 222 | 250 | } |
| 223 | 251 | |
| 224 | 252 | template <class _Iter> |
| 253 | _LIBCPP_HIDE_FROM_ABI | |
| 225 | 254 | static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { |
| 226 | 255 | static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); |
| 227 | 256 | if (__b == __e) |
| ... | ... | @@ -239,6 +268,7 @@ struct _PathCVT { |
| 239 | 268 | } |
| 240 | 269 | |
| 241 | 270 | template <class _Iter> |
| 271 | _LIBCPP_HIDE_FROM_ABI | |
| 242 | 272 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { |
| 243 | 273 | static_assert(!is_same<_Iter, _ECharT*>::value, "Call const overload"); |
| 244 | 274 | const _ECharT __sentinel = _ECharT{}; |
| ... | ... | @@ -259,6 +289,7 @@ struct _PathCVT { |
| 259 | 289 | } |
| 260 | 290 | |
| 261 | 291 | template <class _Source> |
| 292 | _LIBCPP_HIDE_FROM_ABI | |
| 262 | 293 | static void __append_source(__path_string& __dest, _Source const& __s) { |
| 263 | 294 | using _Traits = __is_pathable<_Source>; |
| 264 | 295 | __append_range(__dest, _Traits::__range_begin(__s), |
| ... | ... | @@ -271,6 +302,7 @@ template <> |
| 271 | 302 | struct _PathCVT<__path_value> { |
| 272 | 303 | |
| 273 | 304 | template <class _Iter> |
| 305 | _LIBCPP_HIDE_FROM_ABI | |
| 274 | 306 | static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type |
| 275 | 307 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { |
| 276 | 308 | for (; __b != __e; ++__b) |
| ... | ... | @@ -278,12 +310,14 @@ struct _PathCVT<__path_value> { |
| 278 | 310 | } |
| 279 | 311 | |
| 280 | 312 | template <class _Iter> |
| 313 | _LIBCPP_HIDE_FROM_ABI | |
| 281 | 314 | static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type |
| 282 | 315 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { |
| 283 | 316 | __dest.append(__b, __e); |
| 284 | 317 | } |
| 285 | 318 | |
| 286 | 319 | template <class _Iter> |
| 320 | _LIBCPP_HIDE_FROM_ABI | |
| 287 | 321 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { |
| 288 | 322 | const char __sentinel = char{}; |
| 289 | 323 | for (; *__b != __sentinel; ++__b) |
| ... | ... | @@ -291,6 +325,7 @@ struct _PathCVT<__path_value> { |
| 291 | 325 | } |
| 292 | 326 | |
| 293 | 327 | template <class _Source> |
| 328 | _LIBCPP_HIDE_FROM_ABI | |
| 294 | 329 | static void __append_source(__path_string& __dest, _Source const& __s) { |
| 295 | 330 | using _Traits = __is_pathable<_Source>; |
| 296 | 331 | __append_range(__dest, _Traits::__range_begin(__s), |
| ... | ... | @@ -302,6 +337,7 @@ struct _PathCVT<__path_value> { |
| 302 | 337 | template <> |
| 303 | 338 | struct _PathCVT<char> { |
| 304 | 339 | |
| 340 | _LIBCPP_HIDE_FROM_ABI | |
| 305 | 341 | static void |
| 306 | 342 | __append_string(__path_string& __dest, const basic_string<char> &__str) { |
| 307 | 343 | size_t __size = __char_to_wide(__str, nullptr, 0); |
| ... | ... | @@ -311,6 +347,7 @@ struct _PathCVT<char> { |
| 311 | 347 | } |
| 312 | 348 | |
| 313 | 349 | template <class _Iter> |
| 350 | _LIBCPP_HIDE_FROM_ABI | |
| 314 | 351 | static typename enable_if<__is_exactly_cpp17_input_iterator<_Iter>::value>::type |
| 315 | 352 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { |
| 316 | 353 | basic_string<char> __tmp(__b, __e); |
| ... | ... | @@ -318,6 +355,7 @@ struct _PathCVT<char> { |
| 318 | 355 | } |
| 319 | 356 | |
| 320 | 357 | template <class _Iter> |
| 358 | _LIBCPP_HIDE_FROM_ABI | |
| 321 | 359 | static typename enable_if<__is_cpp17_forward_iterator<_Iter>::value>::type |
| 322 | 360 | __append_range(__path_string& __dest, _Iter __b, _Iter __e) { |
| 323 | 361 | basic_string<char> __tmp(__b, __e); |
| ... | ... | @@ -325,6 +363,7 @@ struct _PathCVT<char> { |
| 325 | 363 | } |
| 326 | 364 | |
| 327 | 365 | template <class _Iter> |
| 366 | _LIBCPP_HIDE_FROM_ABI | |
| 328 | 367 | static void __append_range(__path_string& __dest, _Iter __b, _NullSentinel) { |
| 329 | 368 | const char __sentinel = char{}; |
| 330 | 369 | basic_string<char> __tmp; |
| ... | ... | @@ -334,6 +373,7 @@ struct _PathCVT<char> { |
| 334 | 373 | } |
| 335 | 374 | |
| 336 | 375 | template <class _Source> |
| 376 | _LIBCPP_HIDE_FROM_ABI | |
| 337 | 377 | static void __append_source(__path_string& __dest, _Source const& __s) { |
| 338 | 378 | using _Traits = __is_pathable<_Source>; |
| 339 | 379 | __append_range(__dest, _Traits::__range_begin(__s), |
| ... | ... | @@ -347,6 +387,7 @@ struct _PathExport { |
| 347 | 387 | typedef __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__> _Widener; |
| 348 | 388 | |
| 349 | 389 | template <class _Str> |
| 390 | _LIBCPP_HIDE_FROM_ABI | |
| 350 | 391 | static void __append(_Str& __dest, const __path_string& __src) { |
| 351 | 392 | string __utf8; |
| 352 | 393 | _Narrower()(back_inserter(__utf8), __src.data(), __src.data() + __src.size()); |
| ... | ... | @@ -357,6 +398,7 @@ struct _PathExport { |
| 357 | 398 | template <> |
| 358 | 399 | struct _PathExport<char> { |
| 359 | 400 | template <class _Str> |
| 401 | _LIBCPP_HIDE_FROM_ABI | |
| 360 | 402 | static void __append(_Str& __dest, const __path_string& __src) { |
| 361 | 403 | size_t __size = __wide_to_char(__src, nullptr, 0); |
| 362 | 404 | size_t __pos = __dest.size(); |
| ... | ... | @@ -368,6 +410,7 @@ struct _PathExport<char> { |
| 368 | 410 | template <> |
| 369 | 411 | struct _PathExport<wchar_t> { |
| 370 | 412 | template <class _Str> |
| 413 | _LIBCPP_HIDE_FROM_ABI | |
| 371 | 414 | static void __append(_Str& __dest, const __path_string& __src) { |
| 372 | 415 | __dest.append(__src.begin(), __src.end()); |
| 373 | 416 | } |
| ... | ... | @@ -376,6 +419,7 @@ struct _PathExport<wchar_t> { |
| 376 | 419 | template <> |
| 377 | 420 | struct _PathExport<char16_t> { |
| 378 | 421 | template <class _Str> |
| 422 | _LIBCPP_HIDE_FROM_ABI | |
| 379 | 423 | static void __append(_Str& __dest, const __path_string& __src) { |
| 380 | 424 | __dest.append(__src.begin(), __src.end()); |
| 381 | 425 | } |
| ... | ... | @@ -387,6 +431,7 @@ struct _PathExport<char8_t> { |
| 387 | 431 | typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower; |
| 388 | 432 | |
| 389 | 433 | template <class _Str> |
| 434 | _LIBCPP_HIDE_FROM_ABI | |
| 390 | 435 | static void __append(_Str& __dest, const __path_string& __src) { |
| 391 | 436 | _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); |
| 392 | 437 | } |
| ... | ... | @@ -423,21 +468,23 @@ public: |
| 423 | 468 | }; |
| 424 | 469 | |
| 425 | 470 | // 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 | |
| 471 | _LIBCPP_HIDE_FROM_ABI path() noexcept {} | |
| 472 | _LIBCPP_HIDE_FROM_ABI path(const path& __p) : __pn_(__p.__pn_) {} | |
| 473 | _LIBCPP_HIDE_FROM_ABI path(path&& __p) noexcept | |
| 429 | 474 | : __pn_(_VSTD::move(__p.__pn_)) {} |
| 430 | 475 | |
| 431 | _LIBCPP_INLINE_VISIBILITY | |
| 476 | _LIBCPP_HIDE_FROM_ABI | |
| 432 | 477 | path(string_type&& __s, format = format::auto_format) noexcept |
| 433 | 478 | : __pn_(_VSTD::move(__s)) {} |
| 434 | 479 | |
| 435 | 480 | template <class _Source, class = _EnableIfPathable<_Source, void> > |
| 481 | _LIBCPP_HIDE_FROM_ABI | |
| 436 | 482 | path(const _Source& __src, format = format::auto_format) { |
| 437 | 483 | _SourceCVT<_Source>::__append_source(__pn_, __src); |
| 438 | 484 | } |
| 439 | 485 | |
| 440 | 486 | template <class _InputIt> |
| 487 | _LIBCPP_HIDE_FROM_ABI | |
| 441 | 488 | path(_InputIt __first, _InputIt __last, format = format::auto_format) { |
| 442 | 489 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; |
| 443 | 490 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); |
| ... | ... | @@ -454,41 +501,42 @@ public: |
| 454 | 501 | #endif |
| 455 | 502 | */ |
| 456 | 503 | |
| 457 | _LIBCPP_INLINE_VISIBILITY | |
| 504 | _LIBCPP_HIDE_FROM_ABI | |
| 458 | 505 | ~path() = default; |
| 459 | 506 | |
| 460 | 507 | // assignments |
| 461 | _LIBCPP_INLINE_VISIBILITY | |
| 508 | _LIBCPP_HIDE_FROM_ABI | |
| 462 | 509 | path& operator=(const path& __p) { |
| 463 | 510 | __pn_ = __p.__pn_; |
| 464 | 511 | return *this; |
| 465 | 512 | } |
| 466 | 513 | |
| 467 | _LIBCPP_INLINE_VISIBILITY | |
| 514 | _LIBCPP_HIDE_FROM_ABI | |
| 468 | 515 | path& operator=(path&& __p) noexcept { |
| 469 | 516 | __pn_ = _VSTD::move(__p.__pn_); |
| 470 | 517 | return *this; |
| 471 | 518 | } |
| 472 | 519 | |
| 473 | _LIBCPP_INLINE_VISIBILITY | |
| 520 | _LIBCPP_HIDE_FROM_ABI | |
| 474 | 521 | path& operator=(string_type&& __s) noexcept { |
| 475 | 522 | __pn_ = _VSTD::move(__s); |
| 476 | 523 | return *this; |
| 477 | 524 | } |
| 478 | 525 | |
| 479 | _LIBCPP_INLINE_VISIBILITY | |
| 526 | _LIBCPP_HIDE_FROM_ABI | |
| 480 | 527 | path& assign(string_type&& __s) noexcept { |
| 481 | 528 | __pn_ = _VSTD::move(__s); |
| 482 | 529 | return *this; |
| 483 | 530 | } |
| 484 | 531 | |
| 485 | 532 | template <class _Source> |
| 486 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 533 | _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> | |
| 487 | 534 | operator=(const _Source& __src) { |
| 488 | 535 | return this->assign(__src); |
| 489 | 536 | } |
| 490 | 537 | |
| 491 | 538 | template <class _Source> |
| 539 | _LIBCPP_HIDE_FROM_ABI | |
| 492 | 540 | _EnableIfPathable<_Source> assign(const _Source& __src) { |
| 493 | 541 | __pn_.clear(); |
| 494 | 542 | _SourceCVT<_Source>::__append_source(__pn_, __src); |
| ... | ... | @@ -496,6 +544,7 @@ public: |
| 496 | 544 | } |
| 497 | 545 | |
| 498 | 546 | template <class _InputIt> |
| 547 | _LIBCPP_HIDE_FROM_ABI | |
| 499 | 548 | path& assign(_InputIt __first, _InputIt __last) { |
| 500 | 549 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; |
| 501 | 550 | __pn_.clear(); |
| ... | ... | @@ -506,6 +555,7 @@ public: |
| 506 | 555 | public: |
| 507 | 556 | // appends |
| 508 | 557 | #if defined(_LIBCPP_WIN32API) |
| 558 | _LIBCPP_HIDE_FROM_ABI | |
| 509 | 559 | path& operator/=(const path& __p) { |
| 510 | 560 | auto __p_root_name = __p.__root_name(); |
| 511 | 561 | auto __p_root_name_size = __p_root_name.size(); |
| ... | ... | @@ -532,15 +582,18 @@ public: |
| 532 | 582 | } |
| 533 | 583 | |
| 534 | 584 | template <class _Source> |
| 585 | _LIBCPP_HIDE_FROM_ABI | |
| 535 | 586 | _EnableIfPathable<_Source> append(const _Source& __src) { |
| 536 | 587 | return operator/=(path(__src)); |
| 537 | 588 | } |
| 538 | 589 | |
| 539 | 590 | template <class _InputIt> |
| 591 | _LIBCPP_HIDE_FROM_ABI | |
| 540 | 592 | path& append(_InputIt __first, _InputIt __last) { |
| 541 | 593 | return operator/=(path(__first, __last)); |
| 542 | 594 | } |
| 543 | 595 | #else |
| 596 | _LIBCPP_HIDE_FROM_ABI | |
| 544 | 597 | path& operator/=(const path& __p) { |
| 545 | 598 | if (__p.is_absolute()) { |
| 546 | 599 | __pn_ = __p.__pn_; |
| ... | ... | @@ -556,12 +609,13 @@ public: |
| 556 | 609 | // is known at compile time to be "/' since the user almost certainly intended |
| 557 | 610 | // to append a separator instead of overwriting the path with "/" |
| 558 | 611 | template <class _Source> |
| 559 | _LIBCPP_INLINE_VISIBILITY _EnableIfPathable<_Source> | |
| 612 | _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> | |
| 560 | 613 | operator/=(const _Source& __src) { |
| 561 | 614 | return this->append(__src); |
| 562 | 615 | } |
| 563 | 616 | |
| 564 | 617 | template <class _Source> |
| 618 | _LIBCPP_HIDE_FROM_ABI | |
| 565 | 619 | _EnableIfPathable<_Source> append(const _Source& __src) { |
| 566 | 620 | using _Traits = __is_pathable<_Source>; |
| 567 | 621 | using _CVT = _PathCVT<_SourceChar<_Source> >; |
| ... | ... | @@ -575,6 +629,7 @@ public: |
| 575 | 629 | } |
| 576 | 630 | |
| 577 | 631 | template <class _InputIt> |
| 632 | _LIBCPP_HIDE_FROM_ABI | |
| 578 | 633 | path& append(_InputIt __first, _InputIt __last) { |
| 579 | 634 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; |
| 580 | 635 | static_assert(__can_convert_char<_ItVal>::value, "Must convertible"); |
| ... | ... | @@ -589,37 +644,38 @@ public: |
| 589 | 644 | #endif |
| 590 | 645 | |
| 591 | 646 | // concatenation |
| 592 | _LIBCPP_INLINE_VISIBILITY | |
| 647 | _LIBCPP_HIDE_FROM_ABI | |
| 593 | 648 | path& operator+=(const path& __x) { |
| 594 | 649 | __pn_ += __x.__pn_; |
| 595 | 650 | return *this; |
| 596 | 651 | } |
| 597 | 652 | |
| 598 | _LIBCPP_INLINE_VISIBILITY | |
| 653 | _LIBCPP_HIDE_FROM_ABI | |
| 599 | 654 | path& operator+=(const string_type& __x) { |
| 600 | 655 | __pn_ += __x; |
| 601 | 656 | return *this; |
| 602 | 657 | } |
| 603 | 658 | |
| 604 | _LIBCPP_INLINE_VISIBILITY | |
| 659 | _LIBCPP_HIDE_FROM_ABI | |
| 605 | 660 | path& operator+=(__string_view __x) { |
| 606 | 661 | __pn_ += __x; |
| 607 | 662 | return *this; |
| 608 | 663 | } |
| 609 | 664 | |
| 610 | _LIBCPP_INLINE_VISIBILITY | |
| 665 | _LIBCPP_HIDE_FROM_ABI | |
| 611 | 666 | path& operator+=(const value_type* __x) { |
| 612 | 667 | __pn_ += __x; |
| 613 | 668 | return *this; |
| 614 | 669 | } |
| 615 | 670 | |
| 616 | _LIBCPP_INLINE_VISIBILITY | |
| 671 | _LIBCPP_HIDE_FROM_ABI | |
| 617 | 672 | path& operator+=(value_type __x) { |
| 618 | 673 | __pn_ += __x; |
| 619 | 674 | return *this; |
| 620 | 675 | } |
| 621 | 676 | |
| 622 | 677 | template <class _ECharT> |
| 678 | _LIBCPP_HIDE_FROM_ABI | |
| 623 | 679 | typename enable_if<__can_convert_char<_ECharT>::value, path&>::type |
| 624 | 680 | operator+=(_ECharT __x) { |
| 625 | 681 | _PathCVT<_ECharT>::__append_source(__pn_, |
| ... | ... | @@ -628,17 +684,20 @@ public: |
| 628 | 684 | } |
| 629 | 685 | |
| 630 | 686 | template <class _Source> |
| 687 | _LIBCPP_HIDE_FROM_ABI | |
| 631 | 688 | _EnableIfPathable<_Source> operator+=(const _Source& __x) { |
| 632 | 689 | return this->concat(__x); |
| 633 | 690 | } |
| 634 | 691 | |
| 635 | 692 | template <class _Source> |
| 693 | _LIBCPP_HIDE_FROM_ABI | |
| 636 | 694 | _EnableIfPathable<_Source> concat(const _Source& __x) { |
| 637 | 695 | _SourceCVT<_Source>::__append_source(__pn_, __x); |
| 638 | 696 | return *this; |
| 639 | 697 | } |
| 640 | 698 | |
| 641 | 699 | template <class _InputIt> |
| 700 | _LIBCPP_HIDE_FROM_ABI | |
| 642 | 701 | path& concat(_InputIt __first, _InputIt __last) { |
| 643 | 702 | typedef typename iterator_traits<_InputIt>::value_type _ItVal; |
| 644 | 703 | _PathCVT<_ItVal>::__append_range(__pn_, __first, __last); |
| ... | ... | @@ -646,9 +705,10 @@ public: |
| 646 | 705 | } |
| 647 | 706 | |
| 648 | 707 | // modifiers |
| 649 | _LIBCPP_INLINE_VISIBILITY | |
| 708 | _LIBCPP_HIDE_FROM_ABI | |
| 650 | 709 | void clear() noexcept { __pn_.clear(); } |
| 651 | 710 | |
| 711 | _LIBCPP_HIDE_FROM_ABI | |
| 652 | 712 | path& make_preferred() { |
| 653 | 713 | #if defined(_LIBCPP_WIN32API) |
| 654 | 714 | _VSTD::replace(__pn_.begin(), __pn_.end(), L'/', L'\\'); |
| ... | ... | @@ -656,7 +716,7 @@ public: |
| 656 | 716 | return *this; |
| 657 | 717 | } |
| 658 | 718 | |
| 659 | _LIBCPP_INLINE_VISIBILITY | |
| 719 | _LIBCPP_HIDE_FROM_ABI | |
| 660 | 720 | path& remove_filename() { |
| 661 | 721 | auto __fname = __filename(); |
| 662 | 722 | if (!__fname.empty()) |
| ... | ... | @@ -664,6 +724,7 @@ public: |
| 664 | 724 | return *this; |
| 665 | 725 | } |
| 666 | 726 | |
| 727 | _LIBCPP_HIDE_FROM_ABI | |
| 667 | 728 | path& replace_filename(const path& __replacement) { |
| 668 | 729 | remove_filename(); |
| 669 | 730 | return (*this /= __replacement); |
| ... | ... | @@ -671,25 +732,26 @@ public: |
| 671 | 732 | |
| 672 | 733 | path& replace_extension(const path& __replacement = path()); |
| 673 | 734 | |
| 674 | _LIBCPP_INLINE_VISIBILITY | |
| 735 | _LIBCPP_HIDE_FROM_ABI | |
| 675 | 736 | void swap(path& __rhs) noexcept { __pn_.swap(__rhs.__pn_); } |
| 676 | 737 | |
| 677 | 738 | // private helper to allow reserving memory in the path |
| 678 | _LIBCPP_INLINE_VISIBILITY | |
| 739 | _LIBCPP_HIDE_FROM_ABI | |
| 679 | 740 | void __reserve(size_t __s) { __pn_.reserve(__s); } |
| 680 | 741 | |
| 681 | 742 | // native format observers |
| 682 | _LIBCPP_INLINE_VISIBILITY | |
| 743 | _LIBCPP_HIDE_FROM_ABI | |
| 683 | 744 | const string_type& native() const noexcept { return __pn_; } |
| 684 | 745 | |
| 685 | _LIBCPP_INLINE_VISIBILITY | |
| 746 | _LIBCPP_HIDE_FROM_ABI | |
| 686 | 747 | const value_type* c_str() const noexcept { return __pn_.c_str(); } |
| 687 | 748 | |
| 688 | _LIBCPP_INLINE_VISIBILITY operator string_type() const { return __pn_; } | |
| 749 | _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; } | |
| 689 | 750 | |
| 690 | 751 | #if defined(_LIBCPP_WIN32API) |
| 691 | _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { return __pn_; } | |
| 752 | _LIBCPP_HIDE_FROM_ABI _VSTD::wstring wstring() const { return __pn_; } | |
| 692 | 753 | |
| 754 | _LIBCPP_HIDE_FROM_ABI | |
| 693 | 755 | _VSTD::wstring generic_wstring() const { |
| 694 | 756 | _VSTD::wstring __s; |
| 695 | 757 | __s.resize(__pn_.size()); |
| ... | ... | @@ -700,6 +762,7 @@ public: |
| 700 | 762 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 701 | 763 | template <class _ECharT, class _Traits = char_traits<_ECharT>, |
| 702 | 764 | class _Allocator = allocator<_ECharT> > |
| 765 | _LIBCPP_HIDE_FROM_ABI | |
| 703 | 766 | basic_string<_ECharT, _Traits, _Allocator> |
| 704 | 767 | string(const _Allocator& __a = _Allocator()) const { |
| 705 | 768 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; |
| ... | ... | @@ -709,10 +772,10 @@ public: |
| 709 | 772 | return __s; |
| 710 | 773 | } |
| 711 | 774 | |
| 712 | _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { | |
| 775 | _LIBCPP_HIDE_FROM_ABI _VSTD::string string() const { | |
| 713 | 776 | return string<char>(); |
| 714 | 777 | } |
| 715 | _LIBCPP_INLINE_VISIBILITY __u8_string u8string() const { | |
| 778 | _LIBCPP_HIDE_FROM_ABI __u8_string u8string() const { | |
| 716 | 779 | using _CVT = __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__>; |
| 717 | 780 | __u8_string __s; |
| 718 | 781 | __s.reserve(__pn_.size()); |
| ... | ... | @@ -720,16 +783,17 @@ public: |
| 720 | 783 | return __s; |
| 721 | 784 | } |
| 722 | 785 | |
| 723 | _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { | |
| 786 | _LIBCPP_HIDE_FROM_ABI _VSTD::u16string u16string() const { | |
| 724 | 787 | return string<char16_t>(); |
| 725 | 788 | } |
| 726 | _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { | |
| 789 | _LIBCPP_HIDE_FROM_ABI _VSTD::u32string u32string() const { | |
| 727 | 790 | return string<char32_t>(); |
| 728 | 791 | } |
| 729 | 792 | |
| 730 | 793 | // generic format observers |
| 731 | 794 | template <class _ECharT, class _Traits = char_traits<_ECharT>, |
| 732 | 795 | class _Allocator = allocator<_ECharT> > |
| 796 | _LIBCPP_HIDE_FROM_ABI | |
| 733 | 797 | basic_string<_ECharT, _Traits, _Allocator> |
| 734 | 798 | generic_string(const _Allocator& __a = _Allocator()) const { |
| 735 | 799 | using _Str = basic_string<_ECharT, _Traits, _Allocator>; |
| ... | ... | @@ -742,9 +806,10 @@ public: |
| 742 | 806 | return __s; |
| 743 | 807 | } |
| 744 | 808 | |
| 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>(); } | |
| 809 | _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_string() const { return generic_string<char>(); } | |
| 810 | _LIBCPP_HIDE_FROM_ABI _VSTD::u16string generic_u16string() const { return generic_string<char16_t>(); } | |
| 811 | _LIBCPP_HIDE_FROM_ABI _VSTD::u32string generic_u32string() const { return generic_string<char32_t>(); } | |
| 812 | _LIBCPP_HIDE_FROM_ABI | |
| 748 | 813 | __u8_string generic_u8string() const { |
| 749 | 814 | __u8_string __s = u8string(); |
| 750 | 815 | _VSTD::replace(__s.begin(), __s.end(), '\\', '/'); |
| ... | ... | @@ -753,16 +818,17 @@ public: |
| 753 | 818 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ |
| 754 | 819 | #else /* _LIBCPP_WIN32API */ |
| 755 | 820 | |
| 756 | _LIBCPP_INLINE_VISIBILITY _VSTD::string string() const { return __pn_; } | |
| 821 | _LIBCPP_HIDE_FROM_ABI _VSTD::string string() const { return __pn_; } | |
| 757 | 822 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 758 | _LIBCPP_INLINE_VISIBILITY _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 823 | _LIBCPP_HIDE_FROM_ABI _VSTD::u8string u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 759 | 824 | #else |
| 760 | _LIBCPP_INLINE_VISIBILITY _VSTD::string u8string() const { return __pn_; } | |
| 825 | _LIBCPP_HIDE_FROM_ABI _VSTD::string u8string() const { return __pn_; } | |
| 761 | 826 | #endif |
| 762 | 827 | |
| 763 | 828 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 764 | 829 | template <class _ECharT, class _Traits = char_traits<_ECharT>, |
| 765 | 830 | class _Allocator = allocator<_ECharT> > |
| 831 | _LIBCPP_HIDE_FROM_ABI | |
| 766 | 832 | basic_string<_ECharT, _Traits, _Allocator> |
| 767 | 833 | string(const _Allocator& __a = _Allocator()) const { |
| 768 | 834 | using _CVT = __widen_from_utf8<sizeof(_ECharT) * __CHAR_BIT__>; |
| ... | ... | @@ -774,39 +840,40 @@ public: |
| 774 | 840 | } |
| 775 | 841 | |
| 776 | 842 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 777 | _LIBCPP_INLINE_VISIBILITY _VSTD::wstring wstring() const { | |
| 843 | _LIBCPP_HIDE_FROM_ABI _VSTD::wstring wstring() const { | |
| 778 | 844 | return string<wchar_t>(); |
| 779 | 845 | } |
| 780 | 846 | #endif |
| 781 | _LIBCPP_INLINE_VISIBILITY _VSTD::u16string u16string() const { | |
| 847 | _LIBCPP_HIDE_FROM_ABI _VSTD::u16string u16string() const { | |
| 782 | 848 | return string<char16_t>(); |
| 783 | 849 | } |
| 784 | _LIBCPP_INLINE_VISIBILITY _VSTD::u32string u32string() const { | |
| 850 | _LIBCPP_HIDE_FROM_ABI _VSTD::u32string u32string() const { | |
| 785 | 851 | return string<char32_t>(); |
| 786 | 852 | } |
| 787 | 853 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ |
| 788 | 854 | |
| 789 | 855 | // generic format observers |
| 790 | _VSTD::string generic_string() const { return __pn_; } | |
| 856 | _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_string() const { return __pn_; } | |
| 791 | 857 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 792 | _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 858 | _LIBCPP_HIDE_FROM_ABI _VSTD::u8string generic_u8string() const { return _VSTD::u8string(__pn_.begin(), __pn_.end()); } | |
| 793 | 859 | #else |
| 794 | _VSTD::string generic_u8string() const { return __pn_; } | |
| 860 | _LIBCPP_HIDE_FROM_ABI _VSTD::string generic_u8string() const { return __pn_; } | |
| 795 | 861 | #endif |
| 796 | 862 | |
| 797 | 863 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 798 | 864 | template <class _ECharT, class _Traits = char_traits<_ECharT>, |
| 799 | 865 | class _Allocator = allocator<_ECharT> > |
| 866 | _LIBCPP_HIDE_FROM_ABI | |
| 800 | 867 | basic_string<_ECharT, _Traits, _Allocator> |
| 801 | 868 | generic_string(const _Allocator& __a = _Allocator()) const { |
| 802 | 869 | return string<_ECharT, _Traits, _Allocator>(__a); |
| 803 | 870 | } |
| 804 | 871 | |
| 805 | 872 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 806 | _VSTD::wstring generic_wstring() const { return string<wchar_t>(); } | |
| 873 | _LIBCPP_HIDE_FROM_ABI _VSTD::wstring generic_wstring() const { return string<wchar_t>(); } | |
| 807 | 874 | #endif |
| 808 | _VSTD::u16string generic_u16string() const { return string<char16_t>(); } | |
| 809 | _VSTD::u32string generic_u32string() const { return string<char32_t>(); } | |
| 875 | _LIBCPP_HIDE_FROM_ABI _VSTD::u16string generic_u16string() const { return string<char16_t>(); } | |
| 876 | _LIBCPP_HIDE_FROM_ABI _VSTD::u32string generic_u32string() const { return string<char32_t>(); } | |
| 810 | 877 | #endif /* !_LIBCPP_HAS_NO_LOCALIZATION */ |
| 811 | 878 | #endif /* !_LIBCPP_WIN32API */ |
| 812 | 879 | |
| ... | ... | @@ -823,77 +890,77 @@ private: |
| 823 | 890 | |
| 824 | 891 | public: |
| 825 | 892 | // compare |
| 826 | _LIBCPP_INLINE_VISIBILITY int compare(const path& __p) const noexcept { | |
| 893 | _LIBCPP_HIDE_FROM_ABI int compare(const path& __p) const noexcept { | |
| 827 | 894 | return __compare(__p.__pn_); |
| 828 | 895 | } |
| 829 | _LIBCPP_INLINE_VISIBILITY int compare(const string_type& __s) const { | |
| 896 | _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { | |
| 830 | 897 | return __compare(__s); |
| 831 | 898 | } |
| 832 | _LIBCPP_INLINE_VISIBILITY int compare(__string_view __s) const { | |
| 899 | _LIBCPP_HIDE_FROM_ABI int compare(__string_view __s) const { | |
| 833 | 900 | return __compare(__s); |
| 834 | 901 | } |
| 835 | _LIBCPP_INLINE_VISIBILITY int compare(const value_type* __s) const { | |
| 902 | _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { | |
| 836 | 903 | return __compare(__s); |
| 837 | 904 | } |
| 838 | 905 | |
| 839 | 906 | // decomposition |
| 840 | _LIBCPP_INLINE_VISIBILITY path root_name() const { | |
| 907 | _LIBCPP_HIDE_FROM_ABI path root_name() const { | |
| 841 | 908 | return string_type(__root_name()); |
| 842 | 909 | } |
| 843 | _LIBCPP_INLINE_VISIBILITY path root_directory() const { | |
| 910 | _LIBCPP_HIDE_FROM_ABI path root_directory() const { | |
| 844 | 911 | return string_type(__root_directory()); |
| 845 | 912 | } |
| 846 | _LIBCPP_INLINE_VISIBILITY path root_path() const { | |
| 913 | _LIBCPP_HIDE_FROM_ABI path root_path() const { | |
| 847 | 914 | #if defined(_LIBCPP_WIN32API) |
| 848 | 915 | return string_type(__root_path_raw()); |
| 849 | 916 | #else |
| 850 | 917 | return root_name().append(string_type(__root_directory())); |
| 851 | 918 | #endif |
| 852 | 919 | } |
| 853 | _LIBCPP_INLINE_VISIBILITY path relative_path() const { | |
| 920 | _LIBCPP_HIDE_FROM_ABI path relative_path() const { | |
| 854 | 921 | return string_type(__relative_path()); |
| 855 | 922 | } |
| 856 | _LIBCPP_INLINE_VISIBILITY path parent_path() const { | |
| 923 | _LIBCPP_HIDE_FROM_ABI path parent_path() const { | |
| 857 | 924 | return string_type(__parent_path()); |
| 858 | 925 | } |
| 859 | _LIBCPP_INLINE_VISIBILITY path filename() const { | |
| 926 | _LIBCPP_HIDE_FROM_ABI path filename() const { | |
| 860 | 927 | return string_type(__filename()); |
| 861 | 928 | } |
| 862 | _LIBCPP_INLINE_VISIBILITY path stem() const { return string_type(__stem()); } | |
| 863 | _LIBCPP_INLINE_VISIBILITY path extension() const { | |
| 929 | _LIBCPP_HIDE_FROM_ABI path stem() const { return string_type(__stem()); } | |
| 930 | _LIBCPP_HIDE_FROM_ABI path extension() const { | |
| 864 | 931 | return string_type(__extension()); |
| 865 | 932 | } |
| 866 | 933 | |
| 867 | 934 | // query |
| 868 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool | |
| 935 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool | |
| 869 | 936 | empty() const noexcept { |
| 870 | 937 | return __pn_.empty(); |
| 871 | 938 | } |
| 872 | 939 | |
| 873 | _LIBCPP_INLINE_VISIBILITY bool has_root_name() const { | |
| 940 | _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { | |
| 874 | 941 | return !__root_name().empty(); |
| 875 | 942 | } |
| 876 | _LIBCPP_INLINE_VISIBILITY bool has_root_directory() const { | |
| 943 | _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { | |
| 877 | 944 | return !__root_directory().empty(); |
| 878 | 945 | } |
| 879 | _LIBCPP_INLINE_VISIBILITY bool has_root_path() const { | |
| 946 | _LIBCPP_HIDE_FROM_ABI bool has_root_path() const { | |
| 880 | 947 | return !__root_path_raw().empty(); |
| 881 | 948 | } |
| 882 | _LIBCPP_INLINE_VISIBILITY bool has_relative_path() const { | |
| 949 | _LIBCPP_HIDE_FROM_ABI bool has_relative_path() const { | |
| 883 | 950 | return !__relative_path().empty(); |
| 884 | 951 | } |
| 885 | _LIBCPP_INLINE_VISIBILITY bool has_parent_path() const { | |
| 952 | _LIBCPP_HIDE_FROM_ABI bool has_parent_path() const { | |
| 886 | 953 | return !__parent_path().empty(); |
| 887 | 954 | } |
| 888 | _LIBCPP_INLINE_VISIBILITY bool has_filename() const { | |
| 955 | _LIBCPP_HIDE_FROM_ABI bool has_filename() const { | |
| 889 | 956 | return !__filename().empty(); |
| 890 | 957 | } |
| 891 | _LIBCPP_INLINE_VISIBILITY bool has_stem() const { return !__stem().empty(); } | |
| 892 | _LIBCPP_INLINE_VISIBILITY bool has_extension() const { | |
| 958 | _LIBCPP_HIDE_FROM_ABI bool has_stem() const { return !__stem().empty(); } | |
| 959 | _LIBCPP_HIDE_FROM_ABI bool has_extension() const { | |
| 893 | 960 | return !__extension().empty(); |
| 894 | 961 | } |
| 895 | 962 | |
| 896 | _LIBCPP_INLINE_VISIBILITY bool is_absolute() const { | |
| 963 | _LIBCPP_HIDE_FROM_ABI bool is_absolute() const { | |
| 897 | 964 | #if defined(_LIBCPP_WIN32API) |
| 898 | 965 | __string_view __root_name_str = __root_name(); |
| 899 | 966 | __string_view __root_dir = __root_directory(); |
| ... | ... | @@ -917,13 +984,13 @@ public: |
| 917 | 984 | return has_root_directory(); |
| 918 | 985 | #endif |
| 919 | 986 | } |
| 920 | _LIBCPP_INLINE_VISIBILITY bool is_relative() const { return !is_absolute(); } | |
| 987 | _LIBCPP_HIDE_FROM_ABI bool is_relative() const { return !is_absolute(); } | |
| 921 | 988 | |
| 922 | 989 | // relative paths |
| 923 | 990 | path lexically_normal() const; |
| 924 | 991 | path lexically_relative(const path& __base) const; |
| 925 | 992 | |
| 926 | _LIBCPP_INLINE_VISIBILITY path lexically_proximate(const path& __base) const { | |
| 993 | _LIBCPP_HIDE_FROM_ABI path lexically_proximate(const path& __base) const { | |
| 927 | 994 | path __result = this->lexically_relative(__base); |
| 928 | 995 | if (__result.native().empty()) |
| 929 | 996 | return *this; |
| ... | ... | @@ -939,7 +1006,7 @@ public: |
| 939 | 1006 | |
| 940 | 1007 | #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 941 | 1008 | template <class _CharT, class _Traits> |
| 942 | _LIBCPP_INLINE_VISIBILITY friend | |
| 1009 | _LIBCPP_HIDE_FROM_ABI friend | |
| 943 | 1010 | typename enable_if<is_same<_CharT, value_type>::value && |
| 944 | 1011 | is_same<_Traits, char_traits<value_type> >::value, |
| 945 | 1012 | basic_ostream<_CharT, _Traits>&>::type |
| ... | ... | @@ -949,7 +1016,7 @@ public: |
| 949 | 1016 | } |
| 950 | 1017 | |
| 951 | 1018 | template <class _CharT, class _Traits> |
| 952 | _LIBCPP_INLINE_VISIBILITY friend | |
| 1019 | _LIBCPP_HIDE_FROM_ABI friend | |
| 953 | 1020 | typename enable_if<!is_same<_CharT, value_type>::value || |
| 954 | 1021 | !is_same<_Traits, char_traits<value_type> >::value, |
| 955 | 1022 | basic_ostream<_CharT, _Traits>&>::type |
| ... | ... | @@ -959,42 +1026,41 @@ public: |
| 959 | 1026 | } |
| 960 | 1027 | |
| 961 | 1028 | template <class _CharT, class _Traits> |
| 962 | _LIBCPP_INLINE_VISIBILITY friend basic_istream<_CharT, _Traits>& | |
| 1029 | _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT, _Traits>& | |
| 963 | 1030 | operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) { |
| 964 | 1031 | basic_string<_CharT, _Traits> __tmp; |
| 965 | __is >> __quoted(__tmp); | |
| 1032 | __is >> _VSTD::__quoted(__tmp); | |
| 966 | 1033 | __p = __tmp; |
| 967 | 1034 | return __is; |
| 968 | 1035 | } |
| 969 | 1036 | #endif // !_LIBCPP_HAS_NO_LOCALIZATION |
| 970 | 1037 | |
| 971 | friend _LIBCPP_INLINE_VISIBILITY bool operator==(const path& __lhs, const path& __rhs) noexcept { | |
| 1038 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept { | |
| 972 | 1039 | return __lhs.__compare(__rhs.__pn_) == 0; |
| 973 | 1040 | } |
| 974 | friend _LIBCPP_INLINE_VISIBILITY bool operator!=(const path& __lhs, const path& __rhs) noexcept { | |
| 1041 | friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const path& __lhs, const path& __rhs) noexcept { | |
| 975 | 1042 | return __lhs.__compare(__rhs.__pn_) != 0; |
| 976 | 1043 | } |
| 977 | friend _LIBCPP_INLINE_VISIBILITY bool operator<(const path& __lhs, const path& __rhs) noexcept { | |
| 1044 | friend _LIBCPP_HIDE_FROM_ABI bool operator<(const path& __lhs, const path& __rhs) noexcept { | |
| 978 | 1045 | return __lhs.__compare(__rhs.__pn_) < 0; |
| 979 | 1046 | } |
| 980 | friend _LIBCPP_INLINE_VISIBILITY bool operator<=(const path& __lhs, const path& __rhs) noexcept { | |
| 1047 | friend _LIBCPP_HIDE_FROM_ABI bool operator<=(const path& __lhs, const path& __rhs) noexcept { | |
| 981 | 1048 | return __lhs.__compare(__rhs.__pn_) <= 0; |
| 982 | 1049 | } |
| 983 | friend _LIBCPP_INLINE_VISIBILITY bool operator>(const path& __lhs, const path& __rhs) noexcept { | |
| 1050 | friend _LIBCPP_HIDE_FROM_ABI bool operator>(const path& __lhs, const path& __rhs) noexcept { | |
| 984 | 1051 | return __lhs.__compare(__rhs.__pn_) > 0; |
| 985 | 1052 | } |
| 986 | friend _LIBCPP_INLINE_VISIBILITY bool operator>=(const path& __lhs, const path& __rhs) noexcept { | |
| 1053 | friend _LIBCPP_HIDE_FROM_ABI bool operator>=(const path& __lhs, const path& __rhs) noexcept { | |
| 987 | 1054 | return __lhs.__compare(__rhs.__pn_) >= 0; |
| 988 | 1055 | } |
| 989 | 1056 | |
| 990 | friend _LIBCPP_INLINE_VISIBILITY path operator/(const path& __lhs, | |
| 991 | const path& __rhs) { | |
| 1057 | friend _LIBCPP_HIDE_FROM_ABI path operator/(const path& __lhs, const path& __rhs) { | |
| 992 | 1058 | path __result(__lhs); |
| 993 | 1059 | __result /= __rhs; |
| 994 | 1060 | return __result; |
| 995 | 1061 | } |
| 996 | 1062 | private: |
| 997 | inline _LIBCPP_INLINE_VISIBILITY path& | |
| 1063 | inline _LIBCPP_HIDE_FROM_ABI path& | |
| 998 | 1064 | __assign_view(__string_view const& __s) noexcept { |
| 999 | 1065 | __pn_ = string_type(__s); |
| 1000 | 1066 | return *this; |
| ... | ... | @@ -1002,7 +1068,7 @@ private: |
| 1002 | 1068 | string_type __pn_; |
| 1003 | 1069 | }; |
| 1004 | 1070 | |
| 1005 | inline _LIBCPP_INLINE_VISIBILITY void swap(path& __lhs, path& __rhs) noexcept { | |
| 1071 | inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept { | |
| 1006 | 1072 | __lhs.swap(__rhs); |
| 1007 | 1073 | } |
| 1008 | 1074 |
lib/libcxx/include/__filesystem/path_iterator.h+5-1| ... | ... | @@ -10,15 +10,19 @@ |
| 10 | 10 | #ifndef _LIBCPP___FILESYSTEM_PATH_ITERATOR_H |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__availability> |
| 14 | 15 | #include <__config> |
| 15 | #include <__debug> | |
| 16 | 16 | #include <__filesystem/path.h> |
| 17 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | 18 | #include <cstddef> |
| 19 | 19 | #include <string> |
| 20 | 20 | #include <string_view> |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 22 | 26 | #ifndef _LIBCPP_CXX03_LANG |
| 23 | 27 | |
| 24 | 28 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
lib/libcxx/include/__filesystem/perm_options.h+21-17| ... | ... | @@ -13,6 +13,10 @@ |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 16 | 20 | #ifndef _LIBCPP_CXX03_LANG |
| 17 | 21 | |
| 18 | 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -27,41 +31,41 @@ enum class _LIBCPP_ENUM_VIS perm_options : unsigned char { |
| 27 | 31 | }; |
| 28 | 32 | |
| 29 | 33 | _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)); | |
| 34 | inline constexpr perm_options operator&(perm_options __lhs, perm_options __rhs) { | |
| 35 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) & | |
| 36 | static_cast<unsigned>(__rhs)); | |
| 33 | 37 | } |
| 34 | 38 | |
| 35 | 39 | _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)); | |
| 40 | inline constexpr perm_options operator|(perm_options __lhs, perm_options __rhs) { | |
| 41 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) | | |
| 42 | static_cast<unsigned>(__rhs)); | |
| 39 | 43 | } |
| 40 | 44 | |
| 41 | 45 | _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)); | |
| 46 | inline constexpr perm_options operator^(perm_options __lhs, perm_options __rhs) { | |
| 47 | return static_cast<perm_options>(static_cast<unsigned>(__lhs) ^ | |
| 48 | static_cast<unsigned>(__rhs)); | |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | _LIBCPP_INLINE_VISIBILITY |
| 48 | inline constexpr perm_options operator~(perm_options _LHS) { | |
| 49 | return static_cast<perm_options>(~static_cast<unsigned>(_LHS)); | |
| 52 | inline constexpr perm_options operator~(perm_options __lhs) { | |
| 53 | return static_cast<perm_options>(~static_cast<unsigned>(__lhs)); | |
| 50 | 54 | } |
| 51 | 55 | |
| 52 | 56 | _LIBCPP_INLINE_VISIBILITY |
| 53 | inline perm_options& operator&=(perm_options& _LHS, perm_options _RHS) { | |
| 54 | return _LHS = _LHS & _RHS; | |
| 57 | inline perm_options& operator&=(perm_options& __lhs, perm_options __rhs) { | |
| 58 | return __lhs = __lhs & __rhs; | |
| 55 | 59 | } |
| 56 | 60 | |
| 57 | 61 | _LIBCPP_INLINE_VISIBILITY |
| 58 | inline perm_options& operator|=(perm_options& _LHS, perm_options _RHS) { | |
| 59 | return _LHS = _LHS | _RHS; | |
| 62 | inline perm_options& operator|=(perm_options& __lhs, perm_options __rhs) { | |
| 63 | return __lhs = __lhs | __rhs; | |
| 60 | 64 | } |
| 61 | 65 | |
| 62 | 66 | _LIBCPP_INLINE_VISIBILITY |
| 63 | inline perm_options& operator^=(perm_options& _LHS, perm_options _RHS) { | |
| 64 | return _LHS = _LHS ^ _RHS; | |
| 67 | inline perm_options& operator^=(perm_options& __lhs, perm_options __rhs) { | |
| 68 | return __lhs = __lhs ^ __rhs; | |
| 65 | 69 | } |
| 66 | 70 | |
| 67 | 71 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
lib/libcxx/include/__filesystem/perms.h+18-14| ... | ... | @@ -13,6 +13,10 @@ |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | 15 | |
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 16 | 20 | #ifndef _LIBCPP_CXX03_LANG |
| 17 | 21 | |
| 18 | 22 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -51,36 +55,36 @@ enum class _LIBCPP_ENUM_VIS perms : unsigned { |
| 51 | 55 | }; |
| 52 | 56 | |
| 53 | 57 | _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)); | |
| 58 | inline constexpr perms operator&(perms __lhs, perms __rhs) { | |
| 59 | return static_cast<perms>(static_cast<unsigned>(__lhs) & | |
| 60 | static_cast<unsigned>(__rhs)); | |
| 57 | 61 | } |
| 58 | 62 | |
| 59 | 63 | _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)); | |
| 64 | inline constexpr perms operator|(perms __lhs, perms __rhs) { | |
| 65 | return static_cast<perms>(static_cast<unsigned>(__lhs) | | |
| 66 | static_cast<unsigned>(__rhs)); | |
| 63 | 67 | } |
| 64 | 68 | |
| 65 | 69 | _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)); | |
| 70 | inline constexpr perms operator^(perms __lhs, perms __rhs) { | |
| 71 | return static_cast<perms>(static_cast<unsigned>(__lhs) ^ | |
| 72 | static_cast<unsigned>(__rhs)); | |
| 69 | 73 | } |
| 70 | 74 | |
| 71 | 75 | _LIBCPP_INLINE_VISIBILITY |
| 72 | inline constexpr perms operator~(perms _LHS) { | |
| 73 | return static_cast<perms>(~static_cast<unsigned>(_LHS)); | |
| 76 | inline constexpr perms operator~(perms __lhs) { | |
| 77 | return static_cast<perms>(~static_cast<unsigned>(__lhs)); | |
| 74 | 78 | } |
| 75 | 79 | |
| 76 | 80 | _LIBCPP_INLINE_VISIBILITY |
| 77 | inline perms& operator&=(perms& _LHS, perms _RHS) { return _LHS = _LHS & _RHS; } | |
| 81 | inline perms& operator&=(perms& __lhs, perms __rhs) { return __lhs = __lhs & __rhs; } | |
| 78 | 82 | |
| 79 | 83 | _LIBCPP_INLINE_VISIBILITY |
| 80 | inline perms& operator|=(perms& _LHS, perms _RHS) { return _LHS = _LHS | _RHS; } | |
| 84 | inline perms& operator|=(perms& __lhs, perms __rhs) { return __lhs = __lhs | __rhs; } | |
| 81 | 85 | |
| 82 | 86 | _LIBCPP_INLINE_VISIBILITY |
| 83 | inline perms& operator^=(perms& _LHS, perms _RHS) { return _LHS = _LHS ^ _RHS; } | |
| 87 | inline perms& operator^=(perms& __lhs, perms __rhs) { return __lhs = __lhs ^ __rhs; } | |
| 84 | 88 | |
| 85 | 89 | _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
| 86 | 90 |
lib/libcxx/include/__filesystem/recursive_directory_iterator.h+6-2| ... | ... | @@ -22,6 +22,10 @@ |
| 22 | 22 | #include <cstddef> |
| 23 | 23 | #include <system_error> |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 26 | # pragma GCC system_header | |
| 27 | #endif | |
| 28 | ||
| 25 | 29 | #ifndef _LIBCPP_CXX03_LANG |
| 26 | 30 | |
| 27 | 31 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -164,7 +168,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_POP |
| 164 | 168 | |
| 165 | 169 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 166 | 170 | |
| 167 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 171 | #if _LIBCPP_STD_VER > 17 | |
| 168 | 172 | |
| 169 | 173 | template <> |
| 170 | 174 | _LIBCPP_AVAILABILITY_FILESYSTEM |
| ... | ... | @@ -174,7 +178,7 @@ template <> |
| 174 | 178 | _LIBCPP_AVAILABILITY_FILESYSTEM |
| 175 | 179 | inline constexpr bool _VSTD::ranges::enable_view<_VSTD_FS::recursive_directory_iterator> = true; |
| 176 | 180 | |
| 177 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 181 | #endif // _LIBCPP_STD_VER > 17 | |
| 178 | 182 | |
| 179 | 183 | #endif // _LIBCPP_CXX03_LANG |
| 180 | 184 |
lib/libcxx/include/__filesystem/space_info.h+4| ... | ... | @@ -14,6 +14,10 @@ |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <cstdint> |
| 16 | 16 | |
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 17 | 21 | #ifndef _LIBCPP_CXX03_LANG |
| 18 | 22 | |
| 19 | 23 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
lib/libcxx/include/__filesystem/u8path.h+12| ... | ... | @@ -10,11 +10,23 @@ |
| 10 | 10 | #ifndef _LIBCPP___FILESYSTEM_U8PATH_H |
| 11 | 11 | #define _LIBCPP___FILESYSTEM_U8PATH_H |
| 12 | 12 | |
| 13 | #include <__algorithm/unwrap_iter.h> | |
| 13 | 14 | #include <__availability> |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__filesystem/path.h> |
| 17 | #include <string> | |
| 16 | 18 | #include <type_traits> |
| 17 | 19 | |
| 20 | // Only required on Windows for __widen_from_utf8, and included conservatively | |
| 21 | // because it requires support for localization. | |
| 22 | #if defined(_LIBCPP_WIN32API) | |
| 23 | # include <locale> | |
| 24 | #endif | |
| 25 | ||
| 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 27 | # pragma GCC system_header | |
| 28 | #endif | |
| 29 | ||
| 18 | 30 | #ifndef _LIBCPP_CXX03_LANG |
| 19 | 31 | |
| 20 | 32 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
lib/libcxx/include/__format/buffer.h created+369| ... | ... | @@ -0,0 +1,369 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FORMAT_BUFFER_H | |
| 11 | #define _LIBCPP___FORMAT_BUFFER_H | |
| 12 | ||
| 13 | #include <__algorithm/copy_n.h> | |
| 14 | #include <__algorithm/max.h> | |
| 15 | #include <__algorithm/min.h> | |
| 16 | #include <__algorithm/unwrap_iter.h> | |
| 17 | #include <__config> | |
| 18 | #include <__format/enable_insertable.h> | |
| 19 | #include <__format/format_to_n_result.h> | |
| 20 | #include <__format/formatter.h> // for __char_type TODO FMT Move the concept? | |
| 21 | #include <__iterator/back_insert_iterator.h> | |
| 22 | #include <__iterator/concepts.h> | |
| 23 | #include <__iterator/incrementable_traits.h> | |
| 24 | #include <__iterator/iterator_traits.h> | |
| 25 | #include <__iterator/wrap_iter.h> | |
| 26 | #include <__utility/move.h> | |
| 27 | #include <concepts> | |
| 28 | #include <cstddef> | |
| 29 | #include <type_traits> | |
| 30 | ||
| 31 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 32 | # pragma GCC system_header | |
| 33 | #endif | |
| 34 | ||
| 35 | _LIBCPP_PUSH_MACROS | |
| 36 | #include <__undef_macros> | |
| 37 | ||
| 38 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 39 | ||
| 40 | #if _LIBCPP_STD_VER > 17 | |
| 41 | ||
| 42 | namespace __format { | |
| 43 | ||
| 44 | /// A "buffer" that handles writing to the proper iterator. | |
| 45 | /// | |
| 46 | /// This helper is used together with the @ref back_insert_iterator to offer | |
| 47 | /// type-erasure for the formatting functions. This reduces the number to | |
| 48 | /// template instantiations. | |
| 49 | template <__formatter::__char_type _CharT> | |
| 50 | class _LIBCPP_TEMPLATE_VIS __output_buffer { | |
| 51 | public: | |
| 52 | using value_type = _CharT; | |
| 53 | ||
| 54 | template <class _Tp> | |
| 55 | _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, | |
| 56 | size_t __capacity, _Tp* __obj) | |
| 57 | : __ptr_(__ptr), __capacity_(__capacity), | |
| 58 | __flush_([](_CharT* __p, size_t __size, void* __o) { | |
| 59 | static_cast<_Tp*>(__o)->flush(__p, __size); | |
| 60 | }), | |
| 61 | __obj_(__obj) {} | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI void reset(_CharT* __ptr, size_t __capacity) { | |
| 64 | __ptr_ = __ptr; | |
| 65 | __capacity_ = __capacity; | |
| 66 | } | |
| 67 | ||
| 68 | _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { | |
| 69 | return back_insert_iterator{*this}; | |
| 70 | } | |
| 71 | ||
| 72 | // TODO FMT It would be nice to have an overload taking a | |
| 73 | // basic_string_view<_CharT> and append it directly. | |
| 74 | _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) { | |
| 75 | __ptr_[__size_++] = __c; | |
| 76 | ||
| 77 | // Profiling showed flushing after adding is more efficient than flushing | |
| 78 | // when entering the function. | |
| 79 | if (__size_ == __capacity_) | |
| 80 | flush(); | |
| 81 | } | |
| 82 | ||
| 83 | _LIBCPP_HIDE_FROM_ABI void flush() { | |
| 84 | __flush_(__ptr_, __size_, __obj_); | |
| 85 | __size_ = 0; | |
| 86 | } | |
| 87 | ||
| 88 | private: | |
| 89 | _CharT* __ptr_; | |
| 90 | size_t __capacity_; | |
| 91 | size_t __size_{0}; | |
| 92 | void (*__flush_)(_CharT*, size_t, void*); | |
| 93 | void* __obj_; | |
| 94 | }; | |
| 95 | ||
| 96 | /// A storage using an internal buffer. | |
| 97 | /// | |
| 98 | /// This storage is used when writing a single element to the output iterator | |
| 99 | /// is expensive. | |
| 100 | template <__formatter::__char_type _CharT> | |
| 101 | class _LIBCPP_TEMPLATE_VIS __internal_storage { | |
| 102 | public: | |
| 103 | _LIBCPP_HIDE_FROM_ABI _CharT* begin() { return __buffer_; } | |
| 104 | ||
| 105 | static constexpr size_t __buffer_size = 256 / sizeof(_CharT); | |
| 106 | ||
| 107 | private: | |
| 108 | _CharT __buffer_[__buffer_size]; | |
| 109 | }; | |
| 110 | ||
| 111 | /// A storage writing directly to the storage. | |
| 112 | /// | |
| 113 | /// This requires the storage to be a contiguous buffer of \a _CharT. | |
| 114 | /// Since the output is directly written to the underlying storage this class | |
| 115 | /// is just an empty class. | |
| 116 | template <__formatter::__char_type _CharT> | |
| 117 | class _LIBCPP_TEMPLATE_VIS __direct_storage {}; | |
| 118 | ||
| 119 | template <class _OutIt, class _CharT> | |
| 120 | concept __enable_direct_output = __formatter::__char_type<_CharT> && | |
| 121 | (same_as<_OutIt, _CharT*> | |
| 122 | #ifndef _LIBCPP_ENABLE_DEBUG_MODE | |
| 123 | || same_as<_OutIt, __wrap_iter<_CharT*>> | |
| 124 | #endif | |
| 125 | ); | |
| 126 | ||
| 127 | /// Write policy for directly writing to the underlying output. | |
| 128 | template <class _OutIt, __formatter::__char_type _CharT> | |
| 129 | class _LIBCPP_TEMPLATE_VIS __writer_direct { | |
| 130 | public: | |
| 131 | _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it) | |
| 132 | : __out_it_(__out_it) {} | |
| 133 | ||
| 134 | _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; } | |
| 135 | ||
| 136 | _LIBCPP_HIDE_FROM_ABI void flush(_CharT*, size_t __size) { | |
| 137 | // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator | |
| 138 | // is adjusted. | |
| 139 | __out_it_ += __size; | |
| 140 | } | |
| 141 | ||
| 142 | private: | |
| 143 | _OutIt __out_it_; | |
| 144 | }; | |
| 145 | ||
| 146 | /// Write policy for copying the buffer to the output. | |
| 147 | template <class _OutIt, __formatter::__char_type _CharT> | |
| 148 | class _LIBCPP_TEMPLATE_VIS __writer_iterator { | |
| 149 | public: | |
| 150 | _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it) | |
| 151 | : __out_it_{_VSTD::move(__out_it)} {} | |
| 152 | ||
| 153 | _LIBCPP_HIDE_FROM_ABI auto out() { return __out_it_; } | |
| 154 | ||
| 155 | _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { | |
| 156 | __out_it_ = _VSTD::copy_n(__ptr, __size, _VSTD::move(__out_it_)); | |
| 157 | } | |
| 158 | ||
| 159 | private: | |
| 160 | _OutIt __out_it_; | |
| 161 | }; | |
| 162 | ||
| 163 | /// Concept to see whether a \a _Container is insertable. | |
| 164 | /// | |
| 165 | /// The concept is used to validate whether multiple calls to a | |
| 166 | /// \ref back_insert_iterator can be replace by a call to \c _Container::insert. | |
| 167 | /// | |
| 168 | /// \note a \a _Container needs to opt-in to the concept by specializing | |
| 169 | /// \ref __enable_insertable. | |
| 170 | template <class _Container> | |
| 171 | concept __insertable = | |
| 172 | __enable_insertable<_Container> && __formatter::__char_type<typename _Container::value_type> && | |
| 173 | requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first, | |
| 174 | add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); }; | |
| 175 | ||
| 176 | /// Extract the container type of a \ref back_insert_iterator. | |
| 177 | template <class _It> | |
| 178 | struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container { | |
| 179 | using type = void; | |
| 180 | }; | |
| 181 | ||
| 182 | template <__insertable _Container> | |
| 183 | struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> { | |
| 184 | using type = _Container; | |
| 185 | }; | |
| 186 | ||
| 187 | /// Write policy for inserting the buffer in a container. | |
| 188 | template <class _Container> | |
| 189 | class _LIBCPP_TEMPLATE_VIS __writer_container { | |
| 190 | public: | |
| 191 | using _CharT = typename _Container::value_type; | |
| 192 | ||
| 193 | _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it) | |
| 194 | : __container_{__out_it.__get_container()} {} | |
| 195 | ||
| 196 | _LIBCPP_HIDE_FROM_ABI auto out() { return back_inserter(*__container_); } | |
| 197 | ||
| 198 | _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { | |
| 199 | __container_->insert(__container_->end(), __ptr, __ptr + __size); | |
| 200 | } | |
| 201 | ||
| 202 | private: | |
| 203 | _Container* __container_; | |
| 204 | }; | |
| 205 | ||
| 206 | /// Selects the type of the writer used for the output iterator. | |
| 207 | template <class _OutIt, class _CharT> | |
| 208 | class _LIBCPP_TEMPLATE_VIS __writer_selector { | |
| 209 | using _Container = typename __back_insert_iterator_container<_OutIt>::type; | |
| 210 | ||
| 211 | public: | |
| 212 | using type = conditional_t<!same_as<_Container, void>, __writer_container<_Container>, | |
| 213 | conditional_t<__enable_direct_output<_OutIt, _CharT>, __writer_direct<_OutIt, _CharT>, | |
| 214 | __writer_iterator<_OutIt, _CharT>>>; | |
| 215 | }; | |
| 216 | ||
| 217 | /// The generic formatting buffer. | |
| 218 | template <class _OutIt, __formatter::__char_type _CharT> | |
| 219 | requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS | |
| 220 | __format_buffer { | |
| 221 | using _Storage = | |
| 222 | conditional_t<__enable_direct_output<_OutIt, _CharT>, | |
| 223 | __direct_storage<_CharT>, __internal_storage<_CharT>>; | |
| 224 | ||
| 225 | public: | |
| 226 | _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) | |
| 227 | requires(same_as<_Storage, __internal_storage<_CharT>>) | |
| 228 | : __output_(__storage_.begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {} | |
| 229 | ||
| 230 | _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires( | |
| 231 | same_as<_Storage, __direct_storage<_CharT>>) | |
| 232 | : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this), | |
| 233 | __writer_(_VSTD::move(__out_it)) {} | |
| 234 | ||
| 235 | _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { | |
| 236 | return __output_.make_output_iterator(); | |
| 237 | } | |
| 238 | ||
| 239 | _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { | |
| 240 | __writer_.flush(__ptr, __size); | |
| 241 | } | |
| 242 | ||
| 243 | _LIBCPP_HIDE_FROM_ABI _OutIt out() && { | |
| 244 | __output_.flush(); | |
| 245 | return _VSTD::move(__writer_).out(); | |
| 246 | } | |
| 247 | ||
| 248 | private: | |
| 249 | _LIBCPP_NO_UNIQUE_ADDRESS _Storage __storage_; | |
| 250 | __output_buffer<_CharT> __output_; | |
| 251 | typename __writer_selector<_OutIt, _CharT>::type __writer_; | |
| 252 | }; | |
| 253 | ||
| 254 | /// A buffer that counts the number of insertions. | |
| 255 | /// | |
| 256 | /// Since \ref formatted_size only needs to know the size, the output itself is | |
| 257 | /// discarded. | |
| 258 | template <__formatter::__char_type _CharT> | |
| 259 | class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer { | |
| 260 | public: | |
| 261 | _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return __output_.make_output_iterator(); } | |
| 262 | ||
| 263 | _LIBCPP_HIDE_FROM_ABI void flush(const _CharT*, size_t __size) { __size_ += __size; } | |
| 264 | ||
| 265 | _LIBCPP_HIDE_FROM_ABI size_t result() && { | |
| 266 | __output_.flush(); | |
| 267 | return __size_; | |
| 268 | } | |
| 269 | ||
| 270 | private: | |
| 271 | __internal_storage<_CharT> __storage_; | |
| 272 | __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this}; | |
| 273 | size_t __size_{0}; | |
| 274 | }; | |
| 275 | ||
| 276 | /// The base of a buffer that counts and limits the number of insertions. | |
| 277 | template <class _OutIt, __formatter::__char_type _CharT, bool> | |
| 278 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 279 | struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base { | |
| 280 | using _Size = iter_difference_t<_OutIt>; | |
| 281 | ||
| 282 | public: | |
| 283 | _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n) | |
| 284 | : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {} | |
| 285 | ||
| 286 | _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { | |
| 287 | if (_Size(__size_) <= __n_) | |
| 288 | __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_)); | |
| 289 | __size_ += __size; | |
| 290 | } | |
| 291 | ||
| 292 | protected: | |
| 293 | __internal_storage<_CharT> __storage_; | |
| 294 | __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.__buffer_size, this}; | |
| 295 | typename __writer_selector<_OutIt, _CharT>::type __writer_; | |
| 296 | ||
| 297 | _Size __n_; | |
| 298 | _Size __size_{0}; | |
| 299 | }; | |
| 300 | ||
| 301 | /// The base of a buffer that counts and limits the number of insertions. | |
| 302 | /// | |
| 303 | /// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true. | |
| 304 | /// | |
| 305 | /// This class limits the size available the the direct writer so it will not | |
| 306 | /// exceed the maximum number of code units. | |
| 307 | template <class _OutIt, __formatter::__char_type _CharT> | |
| 308 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 309 | class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> { | |
| 310 | using _Size = iter_difference_t<_OutIt>; | |
| 311 | ||
| 312 | public: | |
| 313 | _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n) | |
| 314 | : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) { | |
| 315 | if (__n <= 0) [[unlikely]] | |
| 316 | __output_.reset(__storage_.begin(), __storage_.__buffer_size); | |
| 317 | } | |
| 318 | ||
| 319 | _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { | |
| 320 | // A flush to the direct writer happens in two occasions: | |
| 321 | // - The format function has written the maximum number of allowed code | |
| 322 | // units. At this point it's no longer valid to write to this writer. So | |
| 323 | // switch to the internal storage. This internal storage doesn't need to | |
| 324 | // be written anywhere so the flush for that storage writes no output. | |
| 325 | // - The format_to_n function is finished. In this case there's no need to | |
| 326 | // switch the buffer, but for simplicity the buffers are still switched. | |
| 327 | // When the __n <= 0 the constructor already switched the buffers. | |
| 328 | if (__size_ == 0 && __ptr != __storage_.begin()) { | |
| 329 | __writer_.flush(__ptr, __size); | |
| 330 | __output_.reset(__storage_.begin(), __storage_.__buffer_size); | |
| 331 | } | |
| 332 | ||
| 333 | __size_ += __size; | |
| 334 | } | |
| 335 | ||
| 336 | protected: | |
| 337 | __internal_storage<_CharT> __storage_; | |
| 338 | __output_buffer<_CharT> __output_; | |
| 339 | __writer_direct<_OutIt, _CharT> __writer_; | |
| 340 | ||
| 341 | _Size __size_{0}; | |
| 342 | }; | |
| 343 | ||
| 344 | /// The buffer that counts and limits the number of insertions. | |
| 345 | template <class _OutIt, __formatter::__char_type _CharT> | |
| 346 | requires(output_iterator<_OutIt, const _CharT&>) | |
| 347 | struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final | |
| 348 | : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> { | |
| 349 | using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>; | |
| 350 | using _Size = iter_difference_t<_OutIt>; | |
| 351 | ||
| 352 | public: | |
| 353 | _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {} | |
| 354 | _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); } | |
| 355 | ||
| 356 | _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> result() && { | |
| 357 | this->__output_.flush(); | |
| 358 | return {_VSTD::move(this->__writer_).out(), this->__size_}; | |
| 359 | } | |
| 360 | }; | |
| 361 | } // namespace __format | |
| 362 | ||
| 363 | #endif //_LIBCPP_STD_VER > 17 | |
| 364 | ||
| 365 | _LIBCPP_END_NAMESPACE_STD | |
| 366 | ||
| 367 | _LIBCPP_POP_MACROS | |
| 368 | ||
| 369 | #endif // _LIBCPP___FORMAT_BUFFER_H |
lib/libcxx/include/__format/concepts.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FORMAT_CONCEPTS_H | |
| 11 | #define _LIBCPP___FORMAT_CONCEPTS_H | |
| 12 | ||
| 13 | #include <__concepts/same_as.h> | |
| 14 | #include <__concepts/semiregular.h> | |
| 15 | #include <__config> | |
| 16 | #include <__format/format_fwd.h> | |
| 17 | #include <__format/format_parse_context.h> | |
| 18 | #include <type_traits> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | ||
| 28 | // The output iterator isn't specified. A formatter should accept any | |
| 29 | // output_iterator. This iterator is a minimal iterator to test the concept. | |
| 30 | // (Note testing for (w)format_context would be a valid choice, but requires | |
| 31 | // selecting the proper one depending on the type of _CharT.) | |
| 32 | template <class _CharT> | |
| 33 | using __fmt_iter_for = _CharT*; | |
| 34 | ||
| 35 | // The concept is based on P2286R6 | |
| 36 | // It lacks the const of __cf as required by, the not yet accepted, LWG-3636. | |
| 37 | // The current formatters can't be easily adapted, but that is WIP. | |
| 38 | // TODO FMT properly implement this concepts once accepted. | |
| 39 | template <class _Tp, class _CharT> | |
| 40 | concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) && | |
| 41 | requires(formatter<remove_cvref_t<_Tp>, _CharT> __f, | |
| 42 | formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t, | |
| 43 | basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc, | |
| 44 | basic_format_parse_context<_CharT> __pc) { | |
| 45 | { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>; | |
| 46 | { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>; | |
| 47 | }; | |
| 48 | ||
| 49 | #endif //_LIBCPP_STD_VER > 17 | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___FORMAT_CONCEPTS_H |
lib/libcxx/include/__format/enable_insertable.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FORMAT_ENABLE_INSERTABLE_H | |
| 11 | #define _LIBCPP___FORMAT_ENABLE_INSERTABLE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | ||
| 23 | namespace __format { | |
| 24 | ||
| 25 | /// Opt-in to enable \ref __insertable for a \a _Container. | |
| 26 | template <class _Container> | |
| 27 | inline constexpr bool __enable_insertable = false; | |
| 28 | ||
| 29 | } // namespace __format | |
| 30 | ||
| 31 | #endif //_LIBCPP_STD_VER > 17 | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___FORMAT_ENABLE_INSERTABLE_H |
lib/libcxx/include/__format/extended_grapheme_cluster_table.h created+332| ... | ... | @@ -0,0 +1,332 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | // WARNING, this entire header is generated by | |
| 11 | // utiles/generate_extended_grapheme_cluster_table.py | |
| 12 | // DO NOT MODIFY! | |
| 13 | ||
| 14 | // UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE | |
| 15 | // | |
| 16 | // See Terms of Use <https://www.unicode.org/copyright.html> | |
| 17 | // for definitions of Unicode Inc.'s Data Files and Software. | |
| 18 | // | |
| 19 | // NOTICE TO USER: Carefully read the following legal agreement. | |
| 20 | // BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S | |
| 21 | // DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"), | |
| 22 | // YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE | |
| 23 | // TERMS AND CONDITIONS OF THIS AGREEMENT. | |
| 24 | // IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE | |
| 25 | // THE DATA FILES OR SOFTWARE. | |
| 26 | // | |
| 27 | // COPYRIGHT AND PERMISSION NOTICE | |
| 28 | // | |
| 29 | // Copyright (c) 1991-2022 Unicode, Inc. All rights reserved. | |
| 30 | // Distributed under the Terms of Use in https://www.unicode.org/copyright.html. | |
| 31 | // | |
| 32 | // Permission is hereby granted, free of charge, to any person obtaining | |
| 33 | // a copy of the Unicode data files and any associated documentation | |
| 34 | // (the "Data Files") or Unicode software and any associated documentation | |
| 35 | // (the "Software") to deal in the Data Files or Software | |
| 36 | // without restriction, including without limitation the rights to use, | |
| 37 | // copy, modify, merge, publish, distribute, and/or sell copies of | |
| 38 | // the Data Files or Software, and to permit persons to whom the Data Files | |
| 39 | // or Software are furnished to do so, provided that either | |
| 40 | // (a) this copyright and permission notice appear with all copies | |
| 41 | // of the Data Files or Software, or | |
| 42 | // (b) this copyright and permission notice appear in associated | |
| 43 | // Documentation. | |
| 44 | // | |
| 45 | // THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF | |
| 46 | // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | |
| 47 | // WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
| 48 | // NONINFRINGEMENT OF THIRD PARTY RIGHTS. | |
| 49 | // IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS | |
| 50 | // NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL | |
| 51 | // DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
| 52 | // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
| 53 | // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
| 54 | // PERFORMANCE OF THE DATA FILES OR SOFTWARE. | |
| 55 | // | |
| 56 | // Except as contained in this notice, the name of a copyright holder | |
| 57 | // shall not be used in advertising or otherwise to promote the sale, | |
| 58 | // use or other dealings in these Data Files or Software without prior | |
| 59 | // written authorization of the copyright holder. | |
| 60 | ||
| 61 | #ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H | |
| 62 | #define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H | |
| 63 | ||
| 64 | #include <__algorithm/upper_bound.h> | |
| 65 | #include <__config> | |
| 66 | #include <__iterator/access.h> | |
| 67 | #include <cstddef> | |
| 68 | #include <cstdint> | |
| 69 | ||
| 70 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 71 | # pragma GCC system_header | |
| 72 | #endif | |
| 73 | ||
| 74 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 75 | ||
| 76 | #if _LIBCPP_STD_VER > 17 | |
| 77 | ||
| 78 | namespace __extended_grapheme_custer_property_boundary { | |
| 79 | ||
| 80 | enum class __property : uint8_t { | |
| 81 | // Values generated from the data files. | |
| 82 | __CR, | |
| 83 | __Control, | |
| 84 | __Extend, | |
| 85 | __Extended_Pictographic, | |
| 86 | __L, | |
| 87 | __LF, | |
| 88 | __LV, | |
| 89 | __LVT, | |
| 90 | __Prepend, | |
| 91 | __Regional_Indicator, | |
| 92 | __SpacingMark, | |
| 93 | __T, | |
| 94 | __V, | |
| 95 | __ZWJ, | |
| 96 | ||
| 97 | // The properies below aren't stored in the "database". | |
| 98 | ||
| 99 | // Text position properties. | |
| 100 | __sot, | |
| 101 | __eot, | |
| 102 | ||
| 103 | // The code unit has none of above properties. | |
| 104 | __none | |
| 105 | }; | |
| 106 | ||
| 107 | /// The entries of the extended grapheme cluster bondary property table. | |
| 108 | /// | |
| 109 | /// The data is generated from | |
| 110 | /// - https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt | |
| 111 | /// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt | |
| 112 | /// | |
| 113 | /// The data has 3 values | |
| 114 | /// - bits [0, 3] The property. One of the values generated form the datafiles | |
| 115 | /// of \ref __property | |
| 116 | /// - bits [4, 10] The size of the range. | |
| 117 | /// - bits [11, 31] The lower bound code point of the range. The upper bound of | |
| 118 | /// the range is lower bound + size. | |
| 119 | /// | |
| 120 | /// The 7 bits for the size allow a maximum range of 128 elements. Some ranges | |
| 121 | /// in the Unicode tables are larger. They are stored in multiple consecutive | |
| 122 | /// ranges in the data table. An alternative would be to store the sizes in a | |
| 123 | /// separate 16-bit value. The original MSVC STL code had such an approach, but | |
| 124 | /// this approach uses less space for the data and is about 4% faster in the | |
| 125 | /// following benchmark. | |
| 126 | /// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp | |
| 127 | inline constexpr uint32_t __entries[1480] = { | |
| 128 | 0x00000091, 0x00005005, 0x00005811, 0x00006800, 0x00007111, 0x0003fa01, 0x00054803, 0x00056801, 0x00057003, | |
| 129 | 0x001806f2, 0x00241862, 0x002c8ac2, 0x002df802, 0x002e0812, 0x002e2012, 0x002e3802, 0x00300058, 0x003080a2, | |
| 130 | 0x0030e001, 0x00325942, 0x00338002, 0x0036b062, 0x0036e808, 0x0036f852, 0x00373812, 0x00375032, 0x00387808, | |
| 131 | 0x00388802, 0x003981a2, 0x003d30a2, 0x003f5882, 0x003fe802, 0x0040b032, 0x0040d882, 0x00412822, 0x00414842, | |
| 132 | 0x0042c822, 0x00448018, 0x0044c072, 0x00465172, 0x00471008, 0x004719f2, 0x0048180a, 0x0049d002, 0x0049d80a, | |
| 133 | 0x0049e002, 0x0049f02a, 0x004a0872, 0x004a483a, 0x004a6802, 0x004a701a, 0x004a8862, 0x004b1012, 0x004c0802, | |
| 134 | 0x004c101a, 0x004de002, 0x004df002, 0x004df81a, 0x004e0832, 0x004e381a, 0x004e581a, 0x004e6802, 0x004eb802, | |
| 135 | 0x004f1012, 0x004ff002, 0x00500812, 0x0050180a, 0x0051e002, 0x0051f02a, 0x00520812, 0x00523812, 0x00525822, | |
| 136 | 0x00528802, 0x00538012, 0x0053a802, 0x00540812, 0x0054180a, 0x0055e002, 0x0055f02a, 0x00560842, 0x00563812, | |
| 137 | 0x0056480a, 0x0056581a, 0x00566802, 0x00571012, 0x0057d052, 0x00580802, 0x0058101a, 0x0059e002, 0x0059f012, | |
| 138 | 0x005a000a, 0x005a0832, 0x005a381a, 0x005a581a, 0x005a6802, 0x005aa822, 0x005b1012, 0x005c1002, 0x005df002, | |
| 139 | 0x005df80a, 0x005e0002, 0x005e081a, 0x005e302a, 0x005e502a, 0x005e6802, 0x005eb802, 0x00600002, 0x0060082a, | |
| 140 | 0x00602002, 0x0061e002, 0x0061f022, 0x0062083a, 0x00623022, 0x00625032, 0x0062a812, 0x00631012, 0x00640802, | |
| 141 | 0x0064101a, 0x0065e002, 0x0065f00a, 0x0065f802, 0x0066001a, 0x00661002, 0x0066181a, 0x00663002, 0x0066381a, | |
| 142 | 0x0066501a, 0x00666012, 0x0066a812, 0x00671012, 0x00680012, 0x0068101a, 0x0069d812, 0x0069f002, 0x0069f81a, | |
| 143 | 0x006a0832, 0x006a302a, 0x006a502a, 0x006a6802, 0x006a7008, 0x006ab802, 0x006b1012, 0x006c0802, 0x006c101a, | |
| 144 | 0x006e5002, 0x006e7802, 0x006e801a, 0x006e9022, 0x006eb002, 0x006ec06a, 0x006ef802, 0x006f901a, 0x00718802, | |
| 145 | 0x0071980a, 0x0071a062, 0x00723872, 0x00758802, 0x0075980a, 0x0075a082, 0x00764052, 0x0078c012, 0x0079a802, | |
| 146 | 0x0079b802, 0x0079c802, 0x0079f01a, 0x007b88d2, 0x007bf80a, 0x007c0042, 0x007c3012, 0x007c68a2, 0x007cca32, | |
| 147 | 0x007e3002, 0x00816832, 0x0081880a, 0x00819052, 0x0081c812, 0x0081d81a, 0x0081e812, 0x0082b01a, 0x0082c012, | |
| 148 | 0x0082f022, 0x00838832, 0x00841002, 0x0084200a, 0x00842812, 0x00846802, 0x0084e802, 0x008805f4, 0x008b047c, | |
| 149 | 0x008d457b, 0x009ae822, 0x00b89022, 0x00b8a80a, 0x00b99012, 0x00b9a00a, 0x00ba9012, 0x00bb9012, 0x00bda012, | |
| 150 | 0x00bdb00a, 0x00bdb862, 0x00bdf07a, 0x00be3002, 0x00be381a, 0x00be48a2, 0x00bee802, 0x00c05822, 0x00c07001, | |
| 151 | 0x00c07802, 0x00c42812, 0x00c54802, 0x00c90022, 0x00c9183a, 0x00c93812, 0x00c9482a, 0x00c9801a, 0x00c99002, | |
| 152 | 0x00c9985a, 0x00c9c822, 0x00d0b812, 0x00d0c81a, 0x00d0d802, 0x00d2a80a, 0x00d2b002, 0x00d2b80a, 0x00d2c062, | |
| 153 | 0x00d30002, 0x00d31002, 0x00d32872, 0x00d3685a, 0x00d39892, 0x00d3f802, 0x00d581e2, 0x00d80032, 0x00d8200a, | |
| 154 | 0x00d9a062, 0x00d9d80a, 0x00d9e002, 0x00d9e84a, 0x00da1002, 0x00da181a, 0x00db5882, 0x00dc0012, 0x00dc100a, | |
| 155 | 0x00dd080a, 0x00dd1032, 0x00dd301a, 0x00dd4012, 0x00dd500a, 0x00dd5822, 0x00df3002, 0x00df380a, 0x00df4012, | |
| 156 | 0x00df502a, 0x00df6802, 0x00df700a, 0x00df7822, 0x00df901a, 0x00e1207a, 0x00e16072, 0x00e1a01a, 0x00e1b012, | |
| 157 | 0x00e68022, 0x00e6a0c2, 0x00e7080a, 0x00e71062, 0x00e76802, 0x00e7a002, 0x00e7b80a, 0x00e7c012, 0x00ee03f2, | |
| 158 | 0x01005801, 0x01006002, 0x0100680d, 0x01007011, 0x01014061, 0x0101e003, 0x01024803, 0x010300f1, 0x01068202, | |
| 159 | 0x01091003, 0x0109c803, 0x010ca053, 0x010d4813, 0x0118d013, 0x01194003, 0x011c4003, 0x011e7803, 0x011f48a3, | |
| 160 | 0x011fc023, 0x01261003, 0x012d5013, 0x012db003, 0x012e0003, 0x012fd833, 0x01300053, 0x013038b3, 0x0130a713, | |
| 161 | 0x01348753, 0x013840a3, 0x0138a003, 0x0138b003, 0x0138e803, 0x01390803, 0x01394003, 0x01399813, 0x013a2003, | |
| 162 | 0x013a3803, 0x013a6003, 0x013a7003, 0x013a9823, 0x013ab803, 0x013b1843, 0x013ca823, 0x013d0803, 0x013d8003, | |
| 163 | 0x013df803, 0x0149a013, 0x01582823, 0x0158d813, 0x015a8003, 0x015aa803, 0x01677822, 0x016bf802, 0x016f01f2, | |
| 164 | 0x01815052, 0x01818003, 0x0181e803, 0x0184c812, 0x0194b803, 0x0194c803, 0x05337832, 0x0533a092, 0x0534f012, | |
| 165 | 0x05378012, 0x05401002, 0x05403002, 0x05405802, 0x0541181a, 0x05412812, 0x0541380a, 0x05416002, 0x0544001a, | |
| 166 | 0x0545a0fa, 0x05462012, 0x05470112, 0x0547f802, 0x05493072, 0x054a38a2, 0x054a901a, 0x054b01c4, 0x054c0022, | |
| 167 | 0x054c180a, 0x054d9802, 0x054da01a, 0x054db032, 0x054dd01a, 0x054de012, 0x054df02a, 0x054f2802, 0x05514852, | |
| 168 | 0x0551781a, 0x05518812, 0x0551981a, 0x0551a812, 0x05521802, 0x05526002, 0x0552680a, 0x0553e002, 0x05558002, | |
| 169 | 0x05559022, 0x0555b812, 0x0555f012, 0x05560802, 0x0557580a, 0x05576012, 0x0557701a, 0x0557a80a, 0x0557b002, | |
| 170 | 0x055f181a, 0x055f2802, 0x055f301a, 0x055f4002, 0x055f481a, 0x055f600a, 0x055f6802, 0x05600006, 0x056009a7, | |
| 171 | 0x0560e006, 0x0560e9a7, 0x0561c006, 0x0561c9a7, 0x0562a006, 0x0562a9a7, 0x05638006, 0x056389a7, 0x05646006, | |
| 172 | 0x056469a7, 0x05654006, 0x056549a7, 0x05662006, 0x056629a7, 0x05670006, 0x056709a7, 0x0567e006, 0x0567e9a7, | |
| 173 | 0x0568c006, 0x0568c9a7, 0x0569a006, 0x0569a9a7, 0x056a8006, 0x056a89a7, 0x056b6006, 0x056b69a7, 0x056c4006, | |
| 174 | 0x056c49a7, 0x056d2006, 0x056d29a7, 0x056e0006, 0x056e09a7, 0x056ee006, 0x056ee9a7, 0x056fc006, 0x056fc9a7, | |
| 175 | 0x0570a006, 0x0570a9a7, 0x05718006, 0x057189a7, 0x05726006, 0x057269a7, 0x05734006, 0x057349a7, 0x05742006, | |
| 176 | 0x057429a7, 0x05750006, 0x057509a7, 0x0575e006, 0x0575e9a7, 0x0576c006, 0x0576c9a7, 0x0577a006, 0x0577a9a7, | |
| 177 | 0x05788006, 0x057889a7, 0x05796006, 0x057969a7, 0x057a4006, 0x057a49a7, 0x057b2006, 0x057b29a7, 0x057c0006, | |
| 178 | 0x057c09a7, 0x057ce006, 0x057ce9a7, 0x057dc006, 0x057dc9a7, 0x057ea006, 0x057ea9a7, 0x057f8006, 0x057f89a7, | |
| 179 | 0x05806006, 0x058069a7, 0x05814006, 0x058149a7, 0x05822006, 0x058229a7, 0x05830006, 0x058309a7, 0x0583e006, | |
| 180 | 0x0583e9a7, 0x0584c006, 0x0584c9a7, 0x0585a006, 0x0585a9a7, 0x05868006, 0x058689a7, 0x05876006, 0x058769a7, | |
| 181 | 0x05884006, 0x058849a7, 0x05892006, 0x058929a7, 0x058a0006, 0x058a09a7, 0x058ae006, 0x058ae9a7, 0x058bc006, | |
| 182 | 0x058bc9a7, 0x058ca006, 0x058ca9a7, 0x058d8006, 0x058d89a7, 0x058e6006, 0x058e69a7, 0x058f4006, 0x058f49a7, | |
| 183 | 0x05902006, 0x059029a7, 0x05910006, 0x059109a7, 0x0591e006, 0x0591e9a7, 0x0592c006, 0x0592c9a7, 0x0593a006, | |
| 184 | 0x0593a9a7, 0x05948006, 0x059489a7, 0x05956006, 0x059569a7, 0x05964006, 0x059649a7, 0x05972006, 0x059729a7, | |
| 185 | 0x05980006, 0x059809a7, 0x0598e006, 0x0598e9a7, 0x0599c006, 0x0599c9a7, 0x059aa006, 0x059aa9a7, 0x059b8006, | |
| 186 | 0x059b89a7, 0x059c6006, 0x059c69a7, 0x059d4006, 0x059d49a7, 0x059e2006, 0x059e29a7, 0x059f0006, 0x059f09a7, | |
| 187 | 0x059fe006, 0x059fe9a7, 0x05a0c006, 0x05a0c9a7, 0x05a1a006, 0x05a1a9a7, 0x05a28006, 0x05a289a7, 0x05a36006, | |
| 188 | 0x05a369a7, 0x05a44006, 0x05a449a7, 0x05a52006, 0x05a529a7, 0x05a60006, 0x05a609a7, 0x05a6e006, 0x05a6e9a7, | |
| 189 | 0x05a7c006, 0x05a7c9a7, 0x05a8a006, 0x05a8a9a7, 0x05a98006, 0x05a989a7, 0x05aa6006, 0x05aa69a7, 0x05ab4006, | |
| 190 | 0x05ab49a7, 0x05ac2006, 0x05ac29a7, 0x05ad0006, 0x05ad09a7, 0x05ade006, 0x05ade9a7, 0x05aec006, 0x05aec9a7, | |
| 191 | 0x05afa006, 0x05afa9a7, 0x05b08006, 0x05b089a7, 0x05b16006, 0x05b169a7, 0x05b24006, 0x05b249a7, 0x05b32006, | |
| 192 | 0x05b329a7, 0x05b40006, 0x05b409a7, 0x05b4e006, 0x05b4e9a7, 0x05b5c006, 0x05b5c9a7, 0x05b6a006, 0x05b6a9a7, | |
| 193 | 0x05b78006, 0x05b789a7, 0x05b86006, 0x05b869a7, 0x05b94006, 0x05b949a7, 0x05ba2006, 0x05ba29a7, 0x05bb0006, | |
| 194 | 0x05bb09a7, 0x05bbe006, 0x05bbe9a7, 0x05bcc006, 0x05bcc9a7, 0x05bda006, 0x05bda9a7, 0x05be8006, 0x05be89a7, | |
| 195 | 0x05bf6006, 0x05bf69a7, 0x05c04006, 0x05c049a7, 0x05c12006, 0x05c129a7, 0x05c20006, 0x05c209a7, 0x05c2e006, | |
| 196 | 0x05c2e9a7, 0x05c3c006, 0x05c3c9a7, 0x05c4a006, 0x05c4a9a7, 0x05c58006, 0x05c589a7, 0x05c66006, 0x05c669a7, | |
| 197 | 0x05c74006, 0x05c749a7, 0x05c82006, 0x05c829a7, 0x05c90006, 0x05c909a7, 0x05c9e006, 0x05c9e9a7, 0x05cac006, | |
| 198 | 0x05cac9a7, 0x05cba006, 0x05cba9a7, 0x05cc8006, 0x05cc89a7, 0x05cd6006, 0x05cd69a7, 0x05ce4006, 0x05ce49a7, | |
| 199 | 0x05cf2006, 0x05cf29a7, 0x05d00006, 0x05d009a7, 0x05d0e006, 0x05d0e9a7, 0x05d1c006, 0x05d1c9a7, 0x05d2a006, | |
| 200 | 0x05d2a9a7, 0x05d38006, 0x05d389a7, 0x05d46006, 0x05d469a7, 0x05d54006, 0x05d549a7, 0x05d62006, 0x05d629a7, | |
| 201 | 0x05d70006, 0x05d709a7, 0x05d7e006, 0x05d7e9a7, 0x05d8c006, 0x05d8c9a7, 0x05d9a006, 0x05d9a9a7, 0x05da8006, | |
| 202 | 0x05da89a7, 0x05db6006, 0x05db69a7, 0x05dc4006, 0x05dc49a7, 0x05dd2006, 0x05dd29a7, 0x05de0006, 0x05de09a7, | |
| 203 | 0x05dee006, 0x05dee9a7, 0x05dfc006, 0x05dfc9a7, 0x05e0a006, 0x05e0a9a7, 0x05e18006, 0x05e189a7, 0x05e26006, | |
| 204 | 0x05e269a7, 0x05e34006, 0x05e349a7, 0x05e42006, 0x05e429a7, 0x05e50006, 0x05e509a7, 0x05e5e006, 0x05e5e9a7, | |
| 205 | 0x05e6c006, 0x05e6c9a7, 0x05e7a006, 0x05e7a9a7, 0x05e88006, 0x05e889a7, 0x05e96006, 0x05e969a7, 0x05ea4006, | |
| 206 | 0x05ea49a7, 0x05eb2006, 0x05eb29a7, 0x05ec0006, 0x05ec09a7, 0x05ece006, 0x05ece9a7, 0x05edc006, 0x05edc9a7, | |
| 207 | 0x05eea006, 0x05eea9a7, 0x05ef8006, 0x05ef89a7, 0x05f06006, 0x05f069a7, 0x05f14006, 0x05f149a7, 0x05f22006, | |
| 208 | 0x05f229a7, 0x05f30006, 0x05f309a7, 0x05f3e006, 0x05f3e9a7, 0x05f4c006, 0x05f4c9a7, 0x05f5a006, 0x05f5a9a7, | |
| 209 | 0x05f68006, 0x05f689a7, 0x05f76006, 0x05f769a7, 0x05f84006, 0x05f849a7, 0x05f92006, 0x05f929a7, 0x05fa0006, | |
| 210 | 0x05fa09a7, 0x05fae006, 0x05fae9a7, 0x05fbc006, 0x05fbc9a7, 0x05fca006, 0x05fca9a7, 0x05fd8006, 0x05fd89a7, | |
| 211 | 0x05fe6006, 0x05fe69a7, 0x05ff4006, 0x05ff49a7, 0x06002006, 0x060029a7, 0x06010006, 0x060109a7, 0x0601e006, | |
| 212 | 0x0601e9a7, 0x0602c006, 0x0602c9a7, 0x0603a006, 0x0603a9a7, 0x06048006, 0x060489a7, 0x06056006, 0x060569a7, | |
| 213 | 0x06064006, 0x060649a7, 0x06072006, 0x060729a7, 0x06080006, 0x060809a7, 0x0608e006, 0x0608e9a7, 0x0609c006, | |
| 214 | 0x0609c9a7, 0x060aa006, 0x060aa9a7, 0x060b8006, 0x060b89a7, 0x060c6006, 0x060c69a7, 0x060d4006, 0x060d49a7, | |
| 215 | 0x060e2006, 0x060e29a7, 0x060f0006, 0x060f09a7, 0x060fe006, 0x060fe9a7, 0x0610c006, 0x0610c9a7, 0x0611a006, | |
| 216 | 0x0611a9a7, 0x06128006, 0x061289a7, 0x06136006, 0x061369a7, 0x06144006, 0x061449a7, 0x06152006, 0x061529a7, | |
| 217 | 0x06160006, 0x061609a7, 0x0616e006, 0x0616e9a7, 0x0617c006, 0x0617c9a7, 0x0618a006, 0x0618a9a7, 0x06198006, | |
| 218 | 0x061989a7, 0x061a6006, 0x061a69a7, 0x061b4006, 0x061b49a7, 0x061c2006, 0x061c29a7, 0x061d0006, 0x061d09a7, | |
| 219 | 0x061de006, 0x061de9a7, 0x061ec006, 0x061ec9a7, 0x061fa006, 0x061fa9a7, 0x06208006, 0x062089a7, 0x06216006, | |
| 220 | 0x062169a7, 0x06224006, 0x062249a7, 0x06232006, 0x062329a7, 0x06240006, 0x062409a7, 0x0624e006, 0x0624e9a7, | |
| 221 | 0x0625c006, 0x0625c9a7, 0x0626a006, 0x0626a9a7, 0x06278006, 0x062789a7, 0x06286006, 0x062869a7, 0x06294006, | |
| 222 | 0x062949a7, 0x062a2006, 0x062a29a7, 0x062b0006, 0x062b09a7, 0x062be006, 0x062be9a7, 0x062cc006, 0x062cc9a7, | |
| 223 | 0x062da006, 0x062da9a7, 0x062e8006, 0x062e89a7, 0x062f6006, 0x062f69a7, 0x06304006, 0x063049a7, 0x06312006, | |
| 224 | 0x063129a7, 0x06320006, 0x063209a7, 0x0632e006, 0x0632e9a7, 0x0633c006, 0x0633c9a7, 0x0634a006, 0x0634a9a7, | |
| 225 | 0x06358006, 0x063589a7, 0x06366006, 0x063669a7, 0x06374006, 0x063749a7, 0x06382006, 0x063829a7, 0x06390006, | |
| 226 | 0x063909a7, 0x0639e006, 0x0639e9a7, 0x063ac006, 0x063ac9a7, 0x063ba006, 0x063ba9a7, 0x063c8006, 0x063c89a7, | |
| 227 | 0x063d6006, 0x063d69a7, 0x063e4006, 0x063e49a7, 0x063f2006, 0x063f29a7, 0x06400006, 0x064009a7, 0x0640e006, | |
| 228 | 0x0640e9a7, 0x0641c006, 0x0641c9a7, 0x0642a006, 0x0642a9a7, 0x06438006, 0x064389a7, 0x06446006, 0x064469a7, | |
| 229 | 0x06454006, 0x064549a7, 0x06462006, 0x064629a7, 0x06470006, 0x064709a7, 0x0647e006, 0x0647e9a7, 0x0648c006, | |
| 230 | 0x0648c9a7, 0x0649a006, 0x0649a9a7, 0x064a8006, 0x064a89a7, 0x064b6006, 0x064b69a7, 0x064c4006, 0x064c49a7, | |
| 231 | 0x064d2006, 0x064d29a7, 0x064e0006, 0x064e09a7, 0x064ee006, 0x064ee9a7, 0x064fc006, 0x064fc9a7, 0x0650a006, | |
| 232 | 0x0650a9a7, 0x06518006, 0x065189a7, 0x06526006, 0x065269a7, 0x06534006, 0x065349a7, 0x06542006, 0x065429a7, | |
| 233 | 0x06550006, 0x065509a7, 0x0655e006, 0x0655e9a7, 0x0656c006, 0x0656c9a7, 0x0657a006, 0x0657a9a7, 0x06588006, | |
| 234 | 0x065889a7, 0x06596006, 0x065969a7, 0x065a4006, 0x065a49a7, 0x065b2006, 0x065b29a7, 0x065c0006, 0x065c09a7, | |
| 235 | 0x065ce006, 0x065ce9a7, 0x065dc006, 0x065dc9a7, 0x065ea006, 0x065ea9a7, 0x065f8006, 0x065f89a7, 0x06606006, | |
| 236 | 0x066069a7, 0x06614006, 0x066149a7, 0x06622006, 0x066229a7, 0x06630006, 0x066309a7, 0x0663e006, 0x0663e9a7, | |
| 237 | 0x0664c006, 0x0664c9a7, 0x0665a006, 0x0665a9a7, 0x06668006, 0x066689a7, 0x06676006, 0x066769a7, 0x06684006, | |
| 238 | 0x066849a7, 0x06692006, 0x066929a7, 0x066a0006, 0x066a09a7, 0x066ae006, 0x066ae9a7, 0x066bc006, 0x066bc9a7, | |
| 239 | 0x066ca006, 0x066ca9a7, 0x066d8006, 0x066d89a7, 0x066e6006, 0x066e69a7, 0x066f4006, 0x066f49a7, 0x06702006, | |
| 240 | 0x067029a7, 0x06710006, 0x067109a7, 0x0671e006, 0x0671e9a7, 0x0672c006, 0x0672c9a7, 0x0673a006, 0x0673a9a7, | |
| 241 | 0x06748006, 0x067489a7, 0x06756006, 0x067569a7, 0x06764006, 0x067649a7, 0x06772006, 0x067729a7, 0x06780006, | |
| 242 | 0x067809a7, 0x0678e006, 0x0678e9a7, 0x0679c006, 0x0679c9a7, 0x067aa006, 0x067aa9a7, 0x067b8006, 0x067b89a7, | |
| 243 | 0x067c6006, 0x067c69a7, 0x067d4006, 0x067d49a7, 0x067e2006, 0x067e29a7, 0x067f0006, 0x067f09a7, 0x067fe006, | |
| 244 | 0x067fe9a7, 0x0680c006, 0x0680c9a7, 0x0681a006, 0x0681a9a7, 0x06828006, 0x068289a7, 0x06836006, 0x068369a7, | |
| 245 | 0x06844006, 0x068449a7, 0x06852006, 0x068529a7, 0x06860006, 0x068609a7, 0x0686e006, 0x0686e9a7, 0x0687c006, | |
| 246 | 0x0687c9a7, 0x0688a006, 0x0688a9a7, 0x06898006, 0x068989a7, 0x068a6006, 0x068a69a7, 0x068b4006, 0x068b49a7, | |
| 247 | 0x068c2006, 0x068c29a7, 0x068d0006, 0x068d09a7, 0x068de006, 0x068de9a7, 0x068ec006, 0x068ec9a7, 0x068fa006, | |
| 248 | 0x068fa9a7, 0x06908006, 0x069089a7, 0x06916006, 0x069169a7, 0x06924006, 0x069249a7, 0x06932006, 0x069329a7, | |
| 249 | 0x06940006, 0x069409a7, 0x0694e006, 0x0694e9a7, 0x0695c006, 0x0695c9a7, 0x0696a006, 0x0696a9a7, 0x06978006, | |
| 250 | 0x069789a7, 0x06986006, 0x069869a7, 0x06994006, 0x069949a7, 0x069a2006, 0x069a29a7, 0x069b0006, 0x069b09a7, | |
| 251 | 0x069be006, 0x069be9a7, 0x069cc006, 0x069cc9a7, 0x069da006, 0x069da9a7, 0x069e8006, 0x069e89a7, 0x069f6006, | |
| 252 | 0x069f69a7, 0x06a04006, 0x06a049a7, 0x06a12006, 0x06a129a7, 0x06a20006, 0x06a209a7, 0x06a2e006, 0x06a2e9a7, | |
| 253 | 0x06a3c006, 0x06a3c9a7, 0x06a4a006, 0x06a4a9a7, 0x06a58006, 0x06a589a7, 0x06a66006, 0x06a669a7, 0x06a74006, | |
| 254 | 0x06a749a7, 0x06a82006, 0x06a829a7, 0x06a90006, 0x06a909a7, 0x06a9e006, 0x06a9e9a7, 0x06aac006, 0x06aac9a7, | |
| 255 | 0x06aba006, 0x06aba9a7, 0x06ac8006, 0x06ac89a7, 0x06ad6006, 0x06ad69a7, 0x06ae4006, 0x06ae49a7, 0x06af2006, | |
| 256 | 0x06af29a7, 0x06b00006, 0x06b009a7, 0x06b0e006, 0x06b0e9a7, 0x06b1c006, 0x06b1c9a7, 0x06b2a006, 0x06b2a9a7, | |
| 257 | 0x06b38006, 0x06b389a7, 0x06b46006, 0x06b469a7, 0x06b54006, 0x06b549a7, 0x06b62006, 0x06b629a7, 0x06b70006, | |
| 258 | 0x06b709a7, 0x06b7e006, 0x06b7e9a7, 0x06b8c006, 0x06b8c9a7, 0x06b9a006, 0x06b9a9a7, 0x06ba8006, 0x06ba89a7, | |
| 259 | 0x06bb6006, 0x06bb69a7, 0x06bc4006, 0x06bc49a7, 0x06bd816c, 0x06be5b0b, 0x07d8f002, 0x07f000f2, 0x07f100f2, | |
| 260 | 0x07f7f801, 0x07fcf012, 0x07ff80b1, 0x080fe802, 0x08170002, 0x081bb042, 0x08500822, 0x08502812, 0x08506032, | |
| 261 | 0x0851c022, 0x0851f802, 0x08572812, 0x08692032, 0x08755812, 0x087a30a2, 0x087c1032, 0x0880000a, 0x08800802, | |
| 262 | 0x0880100a, 0x0881c0e2, 0x08838002, 0x08839812, 0x0883f822, 0x0884100a, 0x0885802a, 0x08859832, 0x0885b81a, | |
| 263 | 0x0885c812, 0x0885e808, 0x08861002, 0x08866808, 0x08880022, 0x08893842, 0x0889600a, 0x08896872, 0x088a281a, | |
| 264 | 0x088b9802, 0x088c0012, 0x088c100a, 0x088d982a, 0x088db082, 0x088df81a, 0x088e1018, 0x088e4832, 0x088e700a, | |
| 265 | 0x088e7802, 0x0891602a, 0x08917822, 0x0891901a, 0x0891a002, 0x0891a80a, 0x0891b012, 0x0891f002, 0x0896f802, | |
| 266 | 0x0897002a, 0x08971872, 0x08980012, 0x0898101a, 0x0899d812, 0x0899f002, 0x0899f80a, 0x089a0002, 0x089a083a, | |
| 267 | 0x089a381a, 0x089a582a, 0x089ab802, 0x089b101a, 0x089b3062, 0x089b8042, 0x08a1a82a, 0x08a1c072, 0x08a2001a, | |
| 268 | 0x08a21022, 0x08a2280a, 0x08a23002, 0x08a2f002, 0x08a58002, 0x08a5881a, 0x08a59852, 0x08a5c80a, 0x08a5d002, | |
| 269 | 0x08a5d81a, 0x08a5e802, 0x08a5f00a, 0x08a5f812, 0x08a6080a, 0x08a61012, 0x08ad7802, 0x08ad801a, 0x08ad9032, | |
| 270 | 0x08adc03a, 0x08ade012, 0x08adf00a, 0x08adf812, 0x08aee012, 0x08b1802a, 0x08b19872, 0x08b1d81a, 0x08b1e802, | |
| 271 | 0x08b1f00a, 0x08b1f812, 0x08b55802, 0x08b5600a, 0x08b56802, 0x08b5701a, 0x08b58052, 0x08b5b00a, 0x08b5b802, | |
| 272 | 0x08b8e822, 0x08b91032, 0x08b9300a, 0x08b93842, 0x08c1602a, 0x08c17882, 0x08c1c00a, 0x08c1c812, 0x08c98002, | |
| 273 | 0x08c9884a, 0x08c9b81a, 0x08c9d812, 0x08c9e80a, 0x08c9f002, 0x08c9f808, 0x08ca000a, 0x08ca0808, 0x08ca100a, | |
| 274 | 0x08ca1802, 0x08ce882a, 0x08cea032, 0x08ced012, 0x08cee03a, 0x08cf0002, 0x08cf200a, 0x08d00892, 0x08d19852, | |
| 275 | 0x08d1c80a, 0x08d1d008, 0x08d1d832, 0x08d23802, 0x08d28852, 0x08d2b81a, 0x08d2c822, 0x08d42058, 0x08d450c2, | |
| 276 | 0x08d4b80a, 0x08d4c012, 0x08e1780a, 0x08e18062, 0x08e1c052, 0x08e1f00a, 0x08e1f802, 0x08e49152, 0x08e5480a, | |
| 277 | 0x08e55062, 0x08e5880a, 0x08e59012, 0x08e5a00a, 0x08e5a812, 0x08e98852, 0x08e9d002, 0x08e9e012, 0x08e9f862, | |
| 278 | 0x08ea3008, 0x08ea3802, 0x08ec504a, 0x08ec8012, 0x08ec981a, 0x08eca802, 0x08ecb00a, 0x08ecb802, 0x08f79812, | |
| 279 | 0x08f7a81a, 0x09a18081, 0x0b578042, 0x0b598062, 0x0b7a7802, 0x0b7a8b6a, 0x0b7c7832, 0x0b7f2002, 0x0b7f801a, | |
| 280 | 0x0de4e812, 0x0de50031, 0x0e7802d2, 0x0e798162, 0x0e8b2802, 0x0e8b300a, 0x0e8b3822, 0x0e8b680a, 0x0e8b7042, | |
| 281 | 0x0e8b9871, 0x0e8bd872, 0x0e8c2862, 0x0e8d5032, 0x0e921022, 0x0ed00362, 0x0ed1db12, 0x0ed3a802, 0x0ed42002, | |
| 282 | 0x0ed4d842, 0x0ed508e2, 0x0f000062, 0x0f004102, 0x0f00d862, 0x0f011812, 0x0f013042, 0x0f098062, 0x0f157002, | |
| 283 | 0x0f176032, 0x0f468062, 0x0f4a2062, 0x0f8007f3, 0x0f8407f3, 0x0f886823, 0x0f897803, 0x0f8b6053, 0x0f8bf013, | |
| 284 | 0x0f8c7003, 0x0f8c8893, 0x0f8d6b83, 0x0f8f3199, 0x0f9008e3, 0x0f90d003, 0x0f917803, 0x0f919083, 0x0f91e033, | |
| 285 | 0x0f924ff3, 0x0f964ff3, 0x0f9a4ff3, 0x0f9e4b13, 0x0f9fd842, 0x0fa007f3, 0x0fa407f3, 0x0fa803d3, 0x0faa37f3, | |
| 286 | 0x0fae37f3, 0x0fb23093, 0x0fb407f3, 0x0fbba0b3, 0x0fbeaaa3, 0x0fc06033, 0x0fc24073, 0x0fc2d053, 0x0fc44073, | |
| 287 | 0x0fc57513, 0x0fc862e3, 0x0fc9e093, 0x0fca3ff3, 0x0fce3ff3, 0x0fd23ff3, 0x0fd63b83, 0x0fe007f3, 0x0fe407f3, | |
| 288 | 0x0fe807f3, 0x0fec07f3, 0x0ff007f3, 0x0ff407f3, 0x0ff807f3, 0x0ffc07d3, 0x700001f1, 0x700105f2, 0x700407f1, | |
| 289 | 0x700807f2, 0x700c06f2, 0x700f87f1, 0x701387f1, 0x701787f1, 0x701b87f1, 0x701f87f1, 0x702387f1, 0x702787f1, | |
| 290 | 0x702b87f1, 0x702f87f1, 0x703387f1, 0x703787f1, 0x703b87f1, 0x703f87f1, 0x704387f1, 0x704787f1, 0x704b87f1, | |
| 291 | 0x704f87f1, 0x705387f1, 0x705787f1, 0x705b87f1, 0x705f87f1, 0x706387f1, 0x706787f1, 0x706b87f1, 0x706f87f1, | |
| 292 | 0x707387f1, 0x707787f1, 0x707b87f1, 0x707f80f1}; | |
| 293 | ||
| 294 | /// Returns the extended grapheme cluster bondary property of a code point. | |
| 295 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept { | |
| 296 | // TODO FMT use std::ranges::upper_bound. | |
| 297 | ||
| 298 | // The algorithm searches for the upper bound of the range and, when found, | |
| 299 | // steps back one entry. This algorithm is used since the code point can be | |
| 300 | // anywhere in the range. After a lower bound is found the next step is to | |
| 301 | // compare whether the code unit is indeed in the range. | |
| 302 | // | |
| 303 | // Since the entry contains a code unit, size, and property the code point | |
| 304 | // being sought needs to be adjusted. Just shifting the code point to the | |
| 305 | // proper position doesn't work; suppose an entry has property 0, size 1, | |
| 306 | // and lower bound 3. This results in the entry 0x1810. | |
| 307 | // When searching for code point 3 it will search for 0x1800, find 0x1810 | |
| 308 | // and moves to the previous entry. Thus the lower bound value will never | |
| 309 | // be found. | |
| 310 | // The simple solution is to set the bits belonging to the property and | |
| 311 | // size. Then the upper bound for code point 3 will return the entry after | |
| 312 | // 0x1810. After moving to the previous entry the algorithm arrives at the | |
| 313 | // correct entry. | |
| 314 | ptrdiff_t __i = std::upper_bound(__entries, std::end(__entries), (__code_point << 11) | 0x7ffu) - __entries; | |
| 315 | if (__i == 0) | |
| 316 | return __property::__none; | |
| 317 | ||
| 318 | --__i; | |
| 319 | uint32_t __upper_bound = (__entries[__i] >> 11) + ((__entries[__i] >> 4) & 0x7f); | |
| 320 | if (__code_point <= __upper_bound) | |
| 321 | return static_cast<__property>(__entries[__i] & 0xf); | |
| 322 | ||
| 323 | return __property::__none; | |
| 324 | } | |
| 325 | ||
| 326 | } // namespace __extended_grapheme_custer_property_boundary | |
| 327 | ||
| 328 | #endif //_LIBCPP_STD_VER > 17 | |
| 329 | ||
| 330 | _LIBCPP_END_NAMESPACE_STD | |
| 331 | ||
| 332 | #endif // _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H |
lib/libcxx/include/__format/format_arg.h+152-172| ... | ... | @@ -10,39 +10,41 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMAT_ARG_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMAT_ARG_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__concepts/arithmetic.h> |
| 14 | 15 | #include <__config> |
| 15 | 16 | #include <__format/format_error.h> |
| 16 | 17 | #include <__format/format_fwd.h> |
| 17 | 18 | #include <__format/format_parse_context.h> |
| 18 | #include <__functional_base> | |
| 19 | #include <__functional/invoke.h> | |
| 19 | 20 | #include <__memory/addressof.h> |
| 21 | #include <__utility/forward.h> | |
| 22 | #include <__utility/unreachable.h> | |
| 20 | 23 | #include <__variant/monostate.h> |
| 21 | 24 | #include <string> |
| 22 | 25 | #include <string_view> |
| 23 | 26 | |
| 24 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 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 | 33 | #if _LIBCPP_STD_VER > 17 |
| 34 | 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 | 35 | namespace __format { |
| 42 | 36 | /// The type stored in @ref basic_format_arg. |
| 43 | 37 | /// |
| 44 | 38 | /// @note The 128-bit types are unconditionally in the list to avoid the values |
| 45 | 39 | /// of the enums to depend on the availability of 128-bit integers. |
| 40 | /// | |
| 41 | /// @note The value is stored as a 5-bit value in the __packed_arg_t_bits. This | |
| 42 | /// limits the maximum number of elements to 32. | |
| 43 | /// When modifying update the test | |
| 44 | /// test/libcxx/utilities/format/format.arguments/format.arg/arg_t.compile.pass.cpp | |
| 45 | /// It could be packed in 4-bits but that means a new type directly becomes an | |
| 46 | /// ABI break. The packed type is 64-bit so this reduces the maximum number of | |
| 47 | /// packed elements from 16 to 12. | |
| 46 | 48 | enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { |
| 47 | 49 | __none, |
| 48 | 50 | __boolean, |
| ... | ... | @@ -61,58 +63,158 @@ enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { |
| 61 | 63 | __ptr, |
| 62 | 64 | __handle |
| 63 | 65 | }; |
| 66 | ||
| 67 | inline constexpr unsigned __packed_arg_t_bits = 5; | |
| 68 | inline constexpr uint8_t __packed_arg_t_mask = 0x1f; | |
| 69 | ||
| 70 | inline constexpr unsigned __packed_types_storage_bits = 64; | |
| 71 | inline constexpr unsigned __packed_types_max = __packed_types_storage_bits / __packed_arg_t_bits; | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI | |
| 74 | constexpr bool __use_packed_format_arg_store(size_t __size) { return __size <= __packed_types_max; } | |
| 75 | ||
| 76 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) { | |
| 78 | _LIBCPP_ASSERT(__id <= __packed_types_max, ""); | |
| 79 | ||
| 80 | if (__id > 0) | |
| 81 | __types >>= __id * __packed_arg_t_bits; | |
| 82 | ||
| 83 | return static_cast<__format::__arg_t>(__types & __packed_arg_t_mask); | |
| 84 | } | |
| 85 | ||
| 64 | 86 | } // namespace __format |
| 65 | 87 | |
| 66 | 88 | 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) { | |
| 89 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis, | |
| 90 | basic_format_arg<_Context> __arg) { | |
| 69 | 91 | switch (__arg.__type_) { |
| 70 | 92 | case __format::__arg_t::__none: |
| 71 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{}); | |
| 93 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_); | |
| 72 | 94 | case __format::__arg_t::__boolean: |
| 73 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean); | |
| 95 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__boolean_); | |
| 74 | 96 | case __format::__arg_t::__char_type: |
| 75 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type); | |
| 97 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__char_type_); | |
| 76 | 98 | case __format::__arg_t::__int: |
| 77 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int); | |
| 99 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__int_); | |
| 78 | 100 | case __format::__arg_t::__long_long: |
| 79 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long); | |
| 101 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_long_); | |
| 80 | 102 | 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 | |
| 103 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 104 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__i128_); | |
| 105 | # else | |
| 106 | __libcpp_unreachable(); | |
| 107 | # endif | |
| 86 | 108 | case __format::__arg_t::__unsigned: |
| 87 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned); | |
| 109 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_); | |
| 88 | 110 | case __format::__arg_t::__unsigned_long_long: |
| 89 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), | |
| 90 | __arg.__unsigned_long_long); | |
| 111 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); | |
| 91 | 112 | 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 | |
| 113 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 114 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__u128_); | |
| 115 | # else | |
| 116 | __libcpp_unreachable(); | |
| 117 | # endif | |
| 97 | 118 | case __format::__arg_t::__float: |
| 98 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float); | |
| 119 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__float_); | |
| 99 | 120 | case __format::__arg_t::__double: |
| 100 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double); | |
| 121 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__double_); | |
| 101 | 122 | case __format::__arg_t::__long_double: |
| 102 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double); | |
| 123 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_double_); | |
| 103 | 124 | case __format::__arg_t::__const_char_type_ptr: |
| 104 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), | |
| 105 | __arg.__const_char_type_ptr); | |
| 125 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_); | |
| 106 | 126 | case __format::__arg_t::__string_view: |
| 107 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view); | |
| 127 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__string_view_); | |
| 108 | 128 | case __format::__arg_t::__ptr: |
| 109 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr); | |
| 129 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__ptr_); | |
| 110 | 130 | case __format::__arg_t::__handle: |
| 111 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle); | |
| 131 | return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), | |
| 132 | typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_}); | |
| 112 | 133 | } |
| 113 | _LIBCPP_UNREACHABLE(); | |
| 134 | ||
| 135 | __libcpp_unreachable(); | |
| 114 | 136 | } |
| 115 | 137 | |
| 138 | /// Contains the values used in basic_format_arg. | |
| 139 | /// | |
| 140 | /// This is a separate type so it's possible to store the values and types in | |
| 141 | /// separate arrays. | |
| 142 | template <class _Context> | |
| 143 | class __basic_format_arg_value { | |
| 144 | using _CharT = typename _Context::char_type; | |
| 145 | ||
| 146 | public: | |
| 147 | /// Contains the implementation for basic_format_arg::handle. | |
| 148 | struct __handle { | |
| 149 | template <class _Tp> | |
| 150 | _LIBCPP_HIDE_FROM_ABI explicit __handle(_Tp&& __v) noexcept | |
| 151 | : __ptr_(_VSTD::addressof(__v)), | |
| 152 | __format_([](basic_format_parse_context<_CharT>& __parse_ctx, _Context& __ctx, const void* __ptr) { | |
| 153 | using _Dp = remove_cvref_t<_Tp>; | |
| 154 | using _Formatter = typename _Context::template formatter_type<_Dp>; | |
| 155 | constexpr bool __const_formattable = | |
| 156 | requires { _Formatter().format(declval<const _Dp&>(), declval<_Context&>()); }; | |
| 157 | using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>; | |
| 158 | ||
| 159 | static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18"); | |
| 160 | ||
| 161 | _Formatter __f; | |
| 162 | __parse_ctx.advance_to(__f.parse(__parse_ctx)); | |
| 163 | __ctx.advance_to(__f.format(*const_cast<_Qp*>(static_cast<const _Dp*>(__ptr)), __ctx)); | |
| 164 | }) {} | |
| 165 | ||
| 166 | const void* __ptr_; | |
| 167 | void (*__format_)(basic_format_parse_context<_CharT>&, _Context&, const void*); | |
| 168 | }; | |
| 169 | ||
| 170 | union { | |
| 171 | monostate __monostate_; | |
| 172 | bool __boolean_; | |
| 173 | _CharT __char_type_; | |
| 174 | int __int_; | |
| 175 | unsigned __unsigned_; | |
| 176 | long long __long_long_; | |
| 177 | unsigned long long __unsigned_long_long_; | |
| 178 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 179 | __int128_t __i128_; | |
| 180 | __uint128_t __u128_; | |
| 181 | # endif | |
| 182 | float __float_; | |
| 183 | double __double_; | |
| 184 | long double __long_double_; | |
| 185 | const _CharT* __const_char_type_ptr_; | |
| 186 | basic_string_view<_CharT> __string_view_; | |
| 187 | const void* __ptr_; | |
| 188 | __handle __handle_; | |
| 189 | }; | |
| 190 | ||
| 191 | // These constructors contain the exact storage type used. If adjustments are | |
| 192 | // required, these will be done in __create_format_arg. | |
| 193 | ||
| 194 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value() noexcept : __monostate_() {} | |
| 195 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(bool __value) noexcept : __boolean_(__value) {} | |
| 196 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(_CharT __value) noexcept : __char_type_(__value) {} | |
| 197 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(int __value) noexcept : __int_(__value) {} | |
| 198 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned __value) noexcept : __unsigned_(__value) {} | |
| 199 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {} | |
| 200 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept | |
| 201 | : __unsigned_long_long_(__value) {} | |
| 202 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 203 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {} | |
| 204 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {} | |
| 205 | # endif | |
| 206 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(float __value) noexcept : __float_(__value) {} | |
| 207 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(double __value) noexcept : __double_(__value) {} | |
| 208 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long double __value) noexcept : __long_double_(__value) {} | |
| 209 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const _CharT* __value) noexcept : __const_char_type_ptr_(__value) {} | |
| 210 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(basic_string_view<_CharT> __value) noexcept | |
| 211 | : __string_view_(__value) {} | |
| 212 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const void* __value) noexcept : __ptr_(__value) {} | |
| 213 | _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle __value) noexcept | |
| 214 | // TODO FMT Investigate why it doesn't work without the forward. | |
| 215 | : __handle_(std::forward<__handle>(__value)) {} | |
| 216 | }; | |
| 217 | ||
| 116 | 218 | template <class _Context> |
| 117 | 219 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg { |
| 118 | 220 | public: |
| ... | ... | @@ -139,154 +241,32 @@ private: |
| 139 | 241 | // .format(declval<const T&>(), declval<Context&>()) |
| 140 | 242 | // shall be well-formed when treated as an unevaluated operand. |
| 141 | 243 | |
| 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 | }; | |
| 244 | public: | |
| 245 | __basic_format_arg_value<_Context> __value_; | |
| 169 | 246 | __format::__arg_t __type_; |
| 170 | 247 | |
| 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) {} | |
| 248 | _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type, | |
| 249 | __basic_format_arg_value<_Context> __value) noexcept | |
| 250 | : __value_(__value), __type_(__type) {} | |
| 258 | 251 | }; |
| 259 | 252 | |
| 260 | 253 | template <class _Context> |
| 261 | 254 | class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle { |
| 262 | friend class basic_format_arg<_Context>; | |
| 263 | ||
| 264 | 255 | public: |
| 265 | 256 | _LIBCPP_HIDE_FROM_ABI |
| 266 | 257 | void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const { |
| 267 | __format_(__parse_ctx, __ctx, __ptr_); | |
| 258 | __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_); | |
| 268 | 259 | } |
| 269 | 260 | |
| 261 | _LIBCPP_HIDE_FROM_ABI explicit handle(typename __basic_format_arg_value<_Context>::__handle& __handle) noexcept | |
| 262 | : __handle_(__handle) {} | |
| 263 | ||
| 270 | 264 | 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 | }) {} | |
| 265 | typename __basic_format_arg_value<_Context>::__handle& __handle_; | |
| 282 | 266 | }; |
| 283 | 267 | |
| 284 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 285 | ||
| 286 | 268 | #endif //_LIBCPP_STD_VER > 17 |
| 287 | 269 | |
| 288 | 270 | _LIBCPP_END_NAMESPACE_STD |
| 289 | 271 | |
| 290 | _LIBCPP_POP_MACROS | |
| 291 | ||
| 292 | 272 | #endif // _LIBCPP___FORMAT_FORMAT_ARG_H |
lib/libcxx/include/__format/format_arg_store.h created+253| ... | ... | @@ -0,0 +1,253 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FORMAT_FORMAT_ARG_STORE_H | |
| 11 | #define _LIBCPP___FORMAT_FORMAT_ARG_STORE_H | |
| 12 | ||
| 13 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 14 | # pragma GCC system_header | |
| 15 | #endif | |
| 16 | ||
| 17 | #include <__concepts/arithmetic.h> | |
| 18 | #include <__concepts/same_as.h> | |
| 19 | #include <__config> | |
| 20 | #include <__format/concepts.h> | |
| 21 | #include <__format/format_arg.h> | |
| 22 | #include <cstring> | |
| 23 | #include <string> | |
| 24 | #include <string_view> | |
| 25 | #include <type_traits> | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 | |
| 30 | ||
| 31 | namespace __format { | |
| 32 | ||
| 33 | /// \returns The @c __arg_t based on the type of the formatting argument. | |
| 34 | /// | |
| 35 | /// \pre \c __formattable<_Tp, typename _Context::char_type> | |
| 36 | template <class _Context, class _Tp> | |
| 37 | consteval __arg_t __determine_arg_t(); | |
| 38 | ||
| 39 | // Boolean | |
| 40 | template <class, same_as<bool> _Tp> | |
| 41 | consteval __arg_t __determine_arg_t() { | |
| 42 | return __arg_t::__boolean; | |
| 43 | } | |
| 44 | ||
| 45 | // Char | |
| 46 | template <class _Context, same_as<typename _Context::char_type> _Tp> | |
| 47 | consteval __arg_t __determine_arg_t() { | |
| 48 | return __arg_t::__char_type; | |
| 49 | } | |
| 50 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 51 | template <class _Context, class _CharT> | |
| 52 | requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>) | |
| 53 | consteval __arg_t __determine_arg_t() { | |
| 54 | return __arg_t::__char_type; | |
| 55 | } | |
| 56 | # endif | |
| 57 | ||
| 58 | // Signed integers | |
| 59 | template <class, __libcpp_signed_integer _Tp> | |
| 60 | consteval __arg_t __determine_arg_t() { | |
| 61 | if constexpr (sizeof(_Tp) <= sizeof(int)) | |
| 62 | return __arg_t::__int; | |
| 63 | else if constexpr (sizeof(_Tp) <= sizeof(long long)) | |
| 64 | return __arg_t::__long_long; | |
| 65 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 66 | else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) | |
| 67 | return __arg_t::__i128; | |
| 68 | # endif | |
| 69 | else | |
| 70 | static_assert(sizeof(_Tp) == 0, "an unsupported signed integer was used"); | |
| 71 | } | |
| 72 | ||
| 73 | // Unsigned integers | |
| 74 | template <class, __libcpp_unsigned_integer _Tp> | |
| 75 | consteval __arg_t __determine_arg_t() { | |
| 76 | if constexpr (sizeof(_Tp) <= sizeof(unsigned)) | |
| 77 | return __arg_t::__unsigned; | |
| 78 | else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) | |
| 79 | return __arg_t::__unsigned_long_long; | |
| 80 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 81 | else if constexpr (sizeof(_Tp) == sizeof(__uint128_t)) | |
| 82 | return __arg_t::__u128; | |
| 83 | # endif | |
| 84 | else | |
| 85 | static_assert(sizeof(_Tp) == 0, "an unsupported unsigned integer was used"); | |
| 86 | } | |
| 87 | ||
| 88 | // Floating-point | |
| 89 | template <class, same_as<float> _Tp> | |
| 90 | consteval __arg_t __determine_arg_t() { | |
| 91 | return __arg_t::__float; | |
| 92 | } | |
| 93 | template <class, same_as<double> _Tp> | |
| 94 | consteval __arg_t __determine_arg_t() { | |
| 95 | return __arg_t::__double; | |
| 96 | } | |
| 97 | template <class, same_as<long double> _Tp> | |
| 98 | consteval __arg_t __determine_arg_t() { | |
| 99 | return __arg_t::__long_double; | |
| 100 | } | |
| 101 | ||
| 102 | // Char pointer | |
| 103 | template <class _Context, class _Tp> | |
| 104 | requires(same_as<typename _Context::char_type*, _Tp> || same_as<const typename _Context::char_type*, _Tp>) | |
| 105 | consteval __arg_t __determine_arg_t() { | |
| 106 | return __arg_t::__const_char_type_ptr; | |
| 107 | } | |
| 108 | ||
| 109 | // Char array | |
| 110 | template <class _Context, class _Tp> | |
| 111 | requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>) | |
| 112 | consteval __arg_t __determine_arg_t() { | |
| 113 | return __arg_t::__string_view; | |
| 114 | } | |
| 115 | ||
| 116 | // String view | |
| 117 | template <class _Context, class _Tp> | |
| 118 | requires(same_as<typename _Context::char_type, typename _Tp::value_type> && | |
| 119 | same_as<_Tp, basic_string_view<typename _Tp::value_type, typename _Tp::traits_type>>) | |
| 120 | consteval __arg_t __determine_arg_t() { | |
| 121 | return __arg_t::__string_view; | |
| 122 | } | |
| 123 | ||
| 124 | // String | |
| 125 | template <class _Context, class _Tp> | |
| 126 | requires( | |
| 127 | same_as<typename _Context::char_type, typename _Tp::value_type> && | |
| 128 | same_as<_Tp, basic_string<typename _Tp::value_type, typename _Tp::traits_type, typename _Tp::allocator_type>>) | |
| 129 | consteval __arg_t __determine_arg_t() { | |
| 130 | return __arg_t::__string_view; | |
| 131 | } | |
| 132 | ||
| 133 | // Pointers | |
| 134 | template <class, class _Ptr> | |
| 135 | requires(same_as<_Ptr, void*> || same_as<_Ptr, const void*> || same_as<_Ptr, nullptr_t>) | |
| 136 | consteval __arg_t __determine_arg_t() { | |
| 137 | return __arg_t::__ptr; | |
| 138 | } | |
| 139 | ||
| 140 | // Handle | |
| 141 | // | |
| 142 | // Note this version can't be constrained avoiding ambiguous overloads. | |
| 143 | // That means it can be instantiated by disabled formatters. To solve this, a | |
| 144 | // constrained version for not formattable formatters is added. That overload | |
| 145 | // is marked as deleted to fail creating a storage type for disabled formatters. | |
| 146 | template <class _Context, class _Tp> | |
| 147 | consteval __arg_t __determine_arg_t() { | |
| 148 | return __arg_t::__handle; | |
| 149 | } | |
| 150 | ||
| 151 | template <class _Context, class _Tp> | |
| 152 | requires(!__formattable<_Tp, typename _Context::char_type>) | |
| 153 | consteval __arg_t __determine_arg_t() = delete; | |
| 154 | ||
| 155 | template <class _Context, class _Tp> | |
| 156 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp&& __value) noexcept { | |
| 157 | constexpr __arg_t __arg = __determine_arg_t<_Context, remove_cvref_t<_Tp>>(); | |
| 158 | static_assert(__arg != __arg_t::__none); | |
| 159 | ||
| 160 | // Not all types can be used to directly initialize the | |
| 161 | // __basic_format_arg_value. First handle all types needing adjustment, the | |
| 162 | // final else requires no adjustment. | |
| 163 | if constexpr (__arg == __arg_t::__char_type) | |
| 164 | // On some platforms initializing a wchar_t from a char is a narrowing | |
| 165 | // conversion. | |
| 166 | return basic_format_arg<_Context>{__arg, static_cast<typename _Context::char_type>(__value)}; | |
| 167 | else if constexpr (__arg == __arg_t::__int) | |
| 168 | return basic_format_arg<_Context>{__arg, static_cast<int>(__value)}; | |
| 169 | else if constexpr (__arg == __arg_t::__long_long) | |
| 170 | return basic_format_arg<_Context>{__arg, static_cast<long long>(__value)}; | |
| 171 | else if constexpr (__arg == __arg_t::__unsigned) | |
| 172 | return basic_format_arg<_Context>{__arg, static_cast<unsigned>(__value)}; | |
| 173 | else if constexpr (__arg == __arg_t::__unsigned_long_long) | |
| 174 | return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)}; | |
| 175 | else if constexpr (__arg == __arg_t::__string_view) | |
| 176 | // Using std::size on a character array will add the NUL-terminator to the size. | |
| 177 | if constexpr (is_array_v<remove_cvref_t<_Tp>>) | |
| 178 | return basic_format_arg<_Context>{ | |
| 179 | __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<remove_cvref_t<_Tp>> - 1}}; | |
| 180 | else | |
| 181 | // When the _Traits or _Allocator are different an implicit conversion will | |
| 182 | // fail. | |
| 183 | return basic_format_arg<_Context>{ | |
| 184 | __arg, basic_string_view<typename _Context::char_type>{__value.data(), __value.size()}}; | |
| 185 | else if constexpr (__arg == __arg_t::__ptr) | |
| 186 | return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)}; | |
| 187 | else if constexpr (__arg == __arg_t::__handle) | |
| 188 | return basic_format_arg<_Context>{ | |
| 189 | __arg, typename __basic_format_arg_value<_Context>::__handle{_VSTD::forward<_Tp>(__value)}}; | |
| 190 | else | |
| 191 | return basic_format_arg<_Context>{__arg, __value}; | |
| 192 | } | |
| 193 | ||
| 194 | template <class _Context, class... _Args> | |
| 195 | _LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_format_arg_value<_Context>* __values, | |
| 196 | _Args&&... __args) noexcept { | |
| 197 | int __shift = 0; | |
| 198 | ( | |
| 199 | [&] { | |
| 200 | basic_format_arg<_Context> __arg = __create_format_arg<_Context>(__args); | |
| 201 | if (__shift != 0) | |
| 202 | __types |= static_cast<uint64_t>(__arg.__type_) << __shift; | |
| 203 | else | |
| 204 | // Assigns the initial value. | |
| 205 | __types = static_cast<uint64_t>(__arg.__type_); | |
| 206 | __shift += __packed_arg_t_bits; | |
| 207 | *__values++ = __arg.__value_; | |
| 208 | }(), | |
| 209 | ...); | |
| 210 | } | |
| 211 | ||
| 212 | template <class _Context, class... _Args> | |
| 213 | _LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept { | |
| 214 | ([&] { *__data++ = __create_format_arg<_Context>(__args); }(), ...); | |
| 215 | } | |
| 216 | ||
| 217 | template <class _Context, size_t N> | |
| 218 | struct __packed_format_arg_store { | |
| 219 | __basic_format_arg_value<_Context> __values_[N]; | |
| 220 | uint64_t __types_; | |
| 221 | }; | |
| 222 | ||
| 223 | template <class _Context, size_t N> | |
| 224 | struct __unpacked_format_arg_store { | |
| 225 | basic_format_arg<_Context> __args_[N]; | |
| 226 | }; | |
| 227 | ||
| 228 | } // namespace __format | |
| 229 | ||
| 230 | template <class _Context, class... _Args> | |
| 231 | struct _LIBCPP_TEMPLATE_VIS __format_arg_store { | |
| 232 | _LIBCPP_HIDE_FROM_ABI | |
| 233 | __format_arg_store(_Args&... __args) noexcept { | |
| 234 | if constexpr (sizeof...(_Args) != 0) { | |
| 235 | if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) | |
| 236 | __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...); | |
| 237 | else | |
| 238 | __format::__store_basic_format_arg<_Context>(__storage.__args_, __args...); | |
| 239 | } | |
| 240 | } | |
| 241 | ||
| 242 | using _Storage = conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)), | |
| 243 | __format::__packed_format_arg_store<_Context, sizeof...(_Args)>, | |
| 244 | __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>; | |
| 245 | ||
| 246 | _Storage __storage; | |
| 247 | }; | |
| 248 | ||
| 249 | #endif //_LIBCPP_STD_VER > 17 | |
| 250 | ||
| 251 | _LIBCPP_END_NAMESPACE_STD | |
| 252 | ||
| 253 | #endif // _LIBCPP___FORMAT_FORMAT_ARG_STORE_H |
lib/libcxx/include/__format/format_args.h+33-25| ... | ... | @@ -12,60 +12,68 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | #include <__format/format_arg.h> | |
| 16 | #include <__format/format_arg_store.h> | |
| 15 | 17 | #include <__format/format_fwd.h> |
| 16 | 18 | #include <cstddef> |
| 19 | #include <cstdint> | |
| 17 | 20 | |
| 18 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 20 | 23 | #endif |
| 21 | 24 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | 27 | #if _LIBCPP_STD_VER > 17 |
| 28 | 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 | 29 | template <class _Context> |
| 36 | 30 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args { |
| 37 | 31 | 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 | 32 | _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default; |
| 45 | 33 | |
| 46 | 34 | 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()) {} | |
| 35 | _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept | |
| 36 | : __size_(sizeof...(_Args)) { | |
| 37 | if constexpr (sizeof...(_Args) != 0) { | |
| 38 | if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) { | |
| 39 | __values_ = __store.__storage.__values_; | |
| 40 | __types_ = __store.__storage.__types_; | |
| 41 | } else | |
| 42 | __args_ = __store.__storage.__args_; | |
| 43 | } | |
| 44 | } | |
| 50 | 45 | |
| 51 | 46 | _LIBCPP_HIDE_FROM_ABI |
| 52 | 47 | basic_format_arg<_Context> get(size_t __id) const noexcept { |
| 53 | return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{}; | |
| 48 | if (__id >= __size_) | |
| 49 | return basic_format_arg<_Context>{}; | |
| 50 | ||
| 51 | if (__format::__use_packed_format_arg_store(__size_)) | |
| 52 | return basic_format_arg<_Context>{__format::__get_packed_type(__types_, __id), __values_[__id]}; | |
| 53 | ||
| 54 | return __args_[__id]; | |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | 57 | _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; } |
| 57 | 58 | |
| 58 | 59 | private: |
| 59 | 60 | size_t __size_{0}; |
| 60 | const basic_format_arg<_Context>* __data_{nullptr}; | |
| 61 | // [format.args]/5 | |
| 62 | // [Note 1: Implementations are encouraged to optimize the representation of | |
| 63 | // basic_format_args for small number of formatting arguments by storing | |
| 64 | // indices of type alternatives separately from values and packing the | |
| 65 | // former. - end note] | |
| 66 | union { | |
| 67 | struct { | |
| 68 | const __basic_format_arg_value<_Context>* __values_; | |
| 69 | uint64_t __types_; | |
| 70 | }; | |
| 71 | const basic_format_arg<_Context>* __args_; | |
| 72 | }; | |
| 61 | 73 | }; |
| 62 | 74 | |
| 63 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 64 | ||
| 65 | 75 | #endif //_LIBCPP_STD_VER > 17 |
| 66 | 76 | |
| 67 | 77 | _LIBCPP_END_NAMESPACE_STD |
| 68 | 78 | |
| 69 | _LIBCPP_POP_MACROS | |
| 70 | ||
| 71 | 79 | #endif // _LIBCPP___FORMAT_FORMAT_ARGS_H |
lib/libcxx/include/__format/format_context.h+10-24| ... | ... | @@ -12,11 +12,14 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | #include <__format/buffer.h> | |
| 15 | 16 | #include <__format/format_args.h> |
| 16 | 17 | #include <__format/format_fwd.h> |
| 17 | 18 | #include <__iterator/back_insert_iterator.h> |
| 18 | 19 | #include <__iterator/concepts.h> |
| 20 | #include <__utility/move.h> | |
| 19 | 21 | #include <concepts> |
| 22 | #include <cstddef> | |
| 20 | 23 | |
| 21 | 24 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 22 | 25 | #include <locale> |
| ... | ... | @@ -24,22 +27,13 @@ |
| 24 | 27 | #endif |
| 25 | 28 | |
| 26 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | #pragma GCC system_header | |
| 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 | 35 | #if _LIBCPP_STD_VER > 17 |
| 36 | 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 | 37 | template <class _OutIt, class _CharT> |
| 44 | 38 | requires output_iterator<_OutIt, const _CharT&> |
| 45 | 39 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context; |
| ... | ... | @@ -69,16 +63,12 @@ __format_context_create( |
| 69 | 63 | } |
| 70 | 64 | #endif |
| 71 | 65 | |
| 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>; | |
| 66 | using format_context = | |
| 67 | basic_format_context<back_insert_iterator<__format::__output_buffer<char>>, | |
| 68 | char>; | |
| 80 | 69 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 81 | using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>; | |
| 70 | using wformat_context = basic_format_context< | |
| 71 | back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>; | |
| 82 | 72 | #endif |
| 83 | 73 | |
| 84 | 74 | template <class _OutIt, class _CharT> |
| ... | ... | @@ -101,7 +91,7 @@ public: |
| 101 | 91 | basic_format_context& operator=(const basic_format_context&) = delete; |
| 102 | 92 | |
| 103 | 93 | _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> |
| 104 | arg(size_t __id) const { | |
| 94 | arg(size_t __id) const noexcept { | |
| 105 | 95 | return __args_.get(__id); |
| 106 | 96 | } |
| 107 | 97 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| ... | ... | @@ -154,12 +144,8 @@ private: |
| 154 | 144 | #endif |
| 155 | 145 | }; |
| 156 | 146 | |
| 157 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 158 | ||
| 159 | 147 | #endif //_LIBCPP_STD_VER > 17 |
| 160 | 148 | |
| 161 | 149 | _LIBCPP_END_NAMESPACE_STD |
| 162 | 150 | |
| 163 | _LIBCPP_POP_MACROS | |
| 164 | ||
| 165 | 151 | #endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H |
lib/libcxx/include/__format/format_error.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__format/format_fwd.h+4-21| ... | ... | @@ -13,44 +13,27 @@ |
| 13 | 13 | #include <__availability> |
| 14 | 14 | #include <__config> |
| 15 | 15 | #include <__iterator/concepts.h> |
| 16 | #include <__utility/forward.h> | |
| 17 | 16 | |
| 18 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 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 | #if _LIBCPP_STD_VER > 17 |
| 28 | 24 | |
| 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 | 25 | template <class _Context> |
| 36 | 26 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg; |
| 37 | 27 | |
| 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&...); | |
| 28 | template <class _OutIt, class _CharT> | |
| 29 | requires output_iterator<_OutIt, const _CharT&> | |
| 30 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context; | |
| 44 | 31 | |
| 45 | 32 | template <class _Tp, class _CharT = char> |
| 46 | 33 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter; |
| 47 | 34 | |
| 48 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 49 | ||
| 50 | 35 | #endif //_LIBCPP_STD_VER > 17 |
| 51 | 36 | |
| 52 | 37 | _LIBCPP_END_NAMESPACE_STD |
| 53 | 38 | |
| 54 | _LIBCPP_POP_MACROS | |
| 55 | ||
| 56 | 39 | #endif // _LIBCPP___FORMAT_FORMAT_FWD_H |
lib/libcxx/include/__format/format_parse_context.h+1-9| ... | ... | @@ -15,19 +15,13 @@ |
| 15 | 15 | #include <string_view> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | 23 | #if _LIBCPP_STD_VER > 17 |
| 24 | 24 | |
| 25 | // TODO FMT Remove this once we require compilers with proper C++20 support. | |
| 26 | // If the compiler has no concepts support, the format header will be disabled. | |
| 27 | // Without concepts support enable_if needs to be used and that too much effort | |
| 28 | // to support compilers with partial C++20 support. | |
| 29 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | ||
| 31 | 25 | template <class _CharT> |
| 32 | 26 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context { |
| 33 | 27 | public: |
| ... | ... | @@ -100,8 +94,6 @@ using format_parse_context = basic_format_parse_context<char>; |
| 100 | 94 | using wformat_parse_context = basic_format_parse_context<wchar_t>; |
| 101 | 95 | #endif |
| 102 | 96 | |
| 103 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 104 | ||
| 105 | 97 | #endif //_LIBCPP_STD_VER > 17 |
| 106 | 98 | |
| 107 | 99 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__format/format_string.h+2-10| ... | ... | @@ -10,26 +10,20 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMAT_STRING_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMAT_STRING_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__format/format_error.h> |
| 16 | 16 | #include <cstddef> |
| 17 | 17 | #include <cstdint> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | #if _LIBCPP_STD_VER > 17 |
| 26 | 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 | 27 | namespace __format { |
| 34 | 28 | |
| 35 | 29 | template <class _CharT> |
| ... | ... | @@ -160,8 +154,6 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { |
| 160 | 154 | |
| 161 | 155 | } // namespace __format |
| 162 | 156 | |
| 163 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 164 | ||
| 165 | 157 | #endif //_LIBCPP_STD_VER > 17 |
| 166 | 158 | |
| 167 | 159 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__format/format_to_n_result.h-7| ... | ... | @@ -21,19 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | 22 | #if _LIBCPP_STD_VER > 17 |
| 23 | 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 | 24 | template <class _OutIt> |
| 31 | 25 | struct _LIBCPP_TEMPLATE_VIS format_to_n_result { |
| 32 | 26 | _OutIt out; |
| 33 | 27 | iter_difference_t<_OutIt> size; |
| 34 | 28 | }; |
| 35 | 29 | |
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 37 | 30 | #endif //_LIBCPP_STD_VER > 17 |
| 38 | 31 | |
| 39 | 32 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__format/formatter.h+2-238| ... | ... | @@ -10,34 +10,19 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_H |
| 12 | 12 | |
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/fill_n.h> | |
| 15 | 13 | #include <__availability> |
| 14 | #include <__concepts/same_as.h> | |
| 16 | 15 | #include <__config> |
| 17 | #include <__format/format_error.h> | |
| 18 | 16 | #include <__format/format_fwd.h> |
| 19 | #include <__format/format_string.h> | |
| 20 | #include <__format/parser_std_format_spec.h> | |
| 21 | #include <concepts> | |
| 22 | #include <string_view> | |
| 23 | 17 | |
| 24 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 26 | 20 | #endif |
| 27 | 21 | |
| 28 | _LIBCPP_PUSH_MACROS | |
| 29 | #include <__undef_macros> | |
| 30 | ||
| 31 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 23 | |
| 33 | 24 | #if _LIBCPP_STD_VER > 17 |
| 34 | 25 | |
| 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 | 26 | /// The default formatter template. |
| 42 | 27 | /// |
| 43 | 28 | /// [format.formatter.spec]/5 |
| ... | ... | @@ -54,237 +39,16 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter { |
| 54 | 39 | formatter& operator=(const formatter&) = delete; |
| 55 | 40 | }; |
| 56 | 41 | |
| 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 | 42 | namespace __formatter { |
| 101 | 43 | |
| 102 | 44 | /** The character types that formatters are specialized for. */ |
| 103 | 45 | template <class _CharT> |
| 104 | 46 | concept __char_type = same_as<_CharT, char> || same_as<_CharT, wchar_t>; |
| 105 | 47 | |
| 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 | 48 | } // namespace __formatter |
| 281 | 49 | |
| 282 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 283 | ||
| 284 | 50 | #endif //_LIBCPP_STD_VER > 17 |
| 285 | 51 | |
| 286 | 52 | _LIBCPP_END_NAMESPACE_STD |
| 287 | 53 | |
| 288 | _LIBCPP_POP_MACROS | |
| 289 | ||
| 290 | 54 | #endif // _LIBCPP___FORMAT_FORMATTER_H |
lib/libcxx/include/__format/formatter_bool.h+33-102| ... | ... | @@ -10,136 +10,67 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_BOOL_H |
| 12 | 12 | |
| 13 | #include <__algorithm/copy.h> | |
| 13 | 14 | #include <__availability> |
| 14 | 15 | #include <__config> |
| 16 | #include <__debug> | |
| 15 | 17 | #include <__format/format_error.h> |
| 16 | 18 | #include <__format/format_fwd.h> |
| 19 | #include <__format/format_parse_context.h> | |
| 17 | 20 | #include <__format/formatter.h> |
| 18 | 21 | #include <__format/formatter_integral.h> |
| 19 | 22 | #include <__format/parser_std_format_spec.h> |
| 23 | #include <__utility/unreachable.h> | |
| 20 | 24 | #include <string_view> |
| 21 | 25 | |
| 22 | 26 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 23 | #include <locale> | |
| 27 | # include <locale> | |
| 24 | 28 | #endif |
| 25 | 29 | |
| 26 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | #pragma GCC system_header | |
| 31 | # pragma GCC system_header | |
| 28 | 32 | #endif |
| 29 | 33 | |
| 30 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 35 | |
| 32 | 36 | #if _LIBCPP_STD_VER > 17 |
| 33 | 37 | |
| 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> { | |
| 38 | template <__formatter::__char_type _CharT> | |
| 39 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> { | |
| 44 | 40 | 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; | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 42 | parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { | |
| 43 | auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); | |
| 44 | __format_spec::__process_parsed_bool(__parser_); | |
| 45 | return __result; | |
| 46 | } | |
| 60 | 47 | |
| 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; | |
| 48 | _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 49 | switch (__parser_.__type_) { | |
| 50 | case __format_spec::__type::__default: | |
| 51 | case __format_spec::__type::__string: | |
| 52 | return __formatter::__format_bool(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); | |
| 53 | ||
| 54 | case __format_spec::__type::__binary_lower_case: | |
| 55 | case __format_spec::__type::__binary_upper_case: | |
| 56 | case __format_spec::__type::__octal: | |
| 57 | case __format_spec::__type::__decimal: | |
| 58 | case __format_spec::__type::__hexadecimal_lower_case: | |
| 59 | case __format_spec::__type::__hexadecimal_upper_case: | |
| 60 | // Promotes bool to an integral type. This reduces the number of | |
| 61 | // instantiations of __format_integer reducing code size. | |
| 62 | return __formatter::__format_integer( | |
| 63 | static_cast<unsigned>(__value), __ctx, __parser_.__get_parsed_std_specifications(__ctx)); | |
| 69 | 64 | |
| 70 | 65 | default: |
| 71 | __throw_format_error( | |
| 72 | "The format-spec type has a type not supported for a bool argument"); | |
| 66 | _LIBCPP_ASSERT(false, "The parse function should have validated the type"); | |
| 67 | __libcpp_unreachable(); | |
| 73 | 68 | } |
| 74 | ||
| 75 | return __it; | |
| 76 | 69 | } |
| 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 | 70 | |
| 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 | } | |
| 71 | __format_spec::__parser<_CharT> __parser_; | |
| 139 | 72 | }; |
| 140 | 73 | |
| 141 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 142 | ||
| 143 | 74 | #endif //_LIBCPP_STD_VER > 17 |
| 144 | 75 | |
| 145 | 76 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__format/formatter_char.h+40-60| ... | ... | @@ -11,91 +11,71 @@ |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_CHAR_H |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | #include <__concepts/same_as.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <__format/format_error.h> | |
| 16 | 16 | #include <__format/format_fwd.h> |
| 17 | #include <__format/format_parse_context.h> | |
| 17 | 18 | #include <__format/formatter.h> |
| 18 | 19 | #include <__format/formatter_integral.h> |
| 20 | #include <__format/formatter_output.h> | |
| 19 | 21 | #include <__format/parser_std_format_spec.h> |
| 22 | #include <__type_traits/conditional.h> | |
| 23 | #include <__type_traits/is_signed.h> | |
| 20 | 24 | |
| 21 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 23 | 27 | #endif |
| 24 | 28 | |
| 25 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 30 | |
| 27 | 31 | #if _LIBCPP_STD_VER > 17 |
| 28 | 32 | |
| 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> { | |
| 33 | template <__formatter::__char_type _CharT> | |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char { | |
| 39 | 35 | 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; | |
| 36 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 37 | parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { | |
| 38 | auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); | |
| 39 | __format_spec::__process_parsed_char(__parser_); | |
| 40 | return __result; | |
| 67 | 41 | } |
| 68 | }; | |
| 69 | 42 | |
| 70 | template <class _CharT> | |
| 71 | using __formatter_char = __formatter_integral<__parser_char<_CharT>>; | |
| 43 | _LIBCPP_HIDE_FROM_ABI auto format(_CharT __value, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 44 | if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char) | |
| 45 | return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx)); | |
| 46 | ||
| 47 | if constexpr (sizeof(_CharT) <= sizeof(int)) | |
| 48 | // Promotes _CharT to an integral type. This reduces the number of | |
| 49 | // instantiations of __format_integer reducing code size. | |
| 50 | return __formatter::__format_integer( | |
| 51 | static_cast<conditional_t<is_signed_v<_CharT>, int, unsigned>>(__value), | |
| 52 | __ctx, | |
| 53 | __parser_.__get_parsed_std_specifications(__ctx)); | |
| 54 | else | |
| 55 | return __formatter::__format_integer(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); | |
| 56 | } | |
| 72 | 57 | |
| 73 | } // namespace __format_spec | |
| 58 | _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) const -> decltype(__ctx.out()) | |
| 59 | requires(same_as<_CharT, wchar_t>) | |
| 60 | { | |
| 61 | return format(static_cast<wchar_t>(__value), __ctx); | |
| 62 | } | |
| 74 | 63 | |
| 75 | // [format.formatter.spec]/2.1 The specializations | |
| 64 | __format_spec::__parser<_CharT> __parser_; | |
| 65 | }; | |
| 76 | 66 | |
| 77 | 67 | template <> |
| 78 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> | |
| 79 | : public __format_spec::__formatter_char<char> {}; | |
| 68 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> : public __formatter_char<char> {}; | |
| 80 | 69 | |
| 81 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 70 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 82 | 71 | 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>; | |
| 72 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> : public __formatter_char<wchar_t> {}; | |
| 86 | 73 | |
| 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 | } | |
| 74 | template <> | |
| 75 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> { | |
| 91 | 76 | }; |
| 92 | 77 | |
| 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) | |
| 78 | # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 99 | 79 | |
| 100 | 80 | #endif //_LIBCPP_STD_VER > 17 |
| 101 | 81 |
lib/libcxx/include/__format/formatter_floating_point.h+216-212| ... | ... | @@ -18,17 +18,18 @@ |
| 18 | 18 | #include <__algorithm/rotate.h> |
| 19 | 19 | #include <__algorithm/transform.h> |
| 20 | 20 | #include <__concepts/arithmetic.h> |
| 21 | #include <__concepts/same_as.h> | |
| 21 | 22 | #include <__config> |
| 22 | #include <__debug> | |
| 23 | #include <__format/format_error.h> | |
| 24 | 23 | #include <__format/format_fwd.h> |
| 25 | #include <__format/format_string.h> | |
| 24 | #include <__format/format_parse_context.h> | |
| 26 | 25 | #include <__format/formatter.h> |
| 27 | 26 | #include <__format/formatter_integral.h> |
| 27 | #include <__format/formatter_output.h> | |
| 28 | 28 | #include <__format/parser_std_format_spec.h> |
| 29 | #include <__memory/allocator.h> | |
| 29 | 30 | #include <__utility/move.h> |
| 31 | #include <__utility/unreachable.h> | |
| 30 | 32 | #include <charconv> |
| 31 | #include <cmath> | |
| 32 | 33 | |
| 33 | 34 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 34 | 35 | # include <locale> |
| ... | ... | @@ -45,13 +46,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 45 | 46 | |
| 46 | 47 | #if _LIBCPP_STD_VER > 17 |
| 47 | 48 | |
| 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 { | |
| 49 | namespace __formatter { | |
| 55 | 50 | |
| 56 | 51 | template <floating_point _Tp> |
| 57 | 52 | _LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) { |
| ... | ... | @@ -167,7 +162,7 @@ public: |
| 167 | 162 | __precision_ = _Traits::__max_fractional; |
| 168 | 163 | } |
| 169 | 164 | |
| 170 | __size_ = __format_spec::__float_buffer_size<_Fp>(__precision_); | |
| 165 | __size_ = __formatter::__float_buffer_size<_Fp>(__precision_); | |
| 171 | 166 | if (__size_ > _Traits::__stack_buffer_size) |
| 172 | 167 | // The allocated buffer's contents don't need initialization. |
| 173 | 168 | __begin_ = allocator<char>{}.allocate(__size_); |
| ... | ... | @@ -236,9 +231,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffe |
| 236 | 231 | char* __integral) { |
| 237 | 232 | __float_result __result; |
| 238 | 233 | __result.__integral = __integral; |
| 239 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value); | |
| 234 | __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value); | |
| 240 | 235 | |
| 241 | __result.__exponent = __format_spec::__find_exponent(__result.__integral, __result.__last); | |
| 236 | __result.__exponent = __formatter::__find_exponent(__result.__integral, __result.__last); | |
| 242 | 237 | |
| 243 | 238 | // Constrains: |
| 244 | 239 | // - There's at least one decimal digit before the radix point. |
| ... | ... | @@ -267,9 +262,9 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(cons |
| 267 | 262 | __float_result __result; |
| 268 | 263 | __result.__integral = __integral; |
| 269 | 264 | if (__precision == -1) |
| 270 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex); | |
| 265 | __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex); | |
| 271 | 266 | else |
| 272 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision); | |
| 267 | __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision); | |
| 273 | 268 | |
| 274 | 269 | // H = one or more hex-digits |
| 275 | 270 | // S = sign |
| ... | ... | @@ -318,7 +313,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(cons |
| 318 | 313 | _Tp __value, int __precision, |
| 319 | 314 | char* __integral) { |
| 320 | 315 | __float_result __result = |
| 321 | __format_spec::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral); | |
| 316 | __formatter::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral); | |
| 322 | 317 | _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper); |
| 323 | 318 | *__result.__exponent = 'P'; |
| 324 | 319 | return __result; |
| ... | ... | @@ -331,13 +326,13 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const |
| 331 | 326 | __float_result __result; |
| 332 | 327 | __result.__integral = __integral; |
| 333 | 328 | __result.__last = |
| 334 | __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision); | |
| 329 | __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision); | |
| 335 | 330 | |
| 336 | 331 | char* __first = __integral + 1; |
| 337 | 332 | _LIBCPP_ASSERT(__first != __result.__last, "No exponent present"); |
| 338 | 333 | if (*__first == '.') { |
| 339 | 334 | __result.__radix_point = __first; |
| 340 | __result.__exponent = __format_spec::__find_exponent(__first + 1, __result.__last); | |
| 335 | __result.__exponent = __formatter::__find_exponent(__first + 1, __result.__last); | |
| 341 | 336 | } else { |
| 342 | 337 | __result.__radix_point = __result.__last; |
| 343 | 338 | __result.__exponent = __first; |
| ... | ... | @@ -357,7 +352,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const |
| 357 | 352 | _Tp __value, int __precision, |
| 358 | 353 | char* __integral) { |
| 359 | 354 | __float_result __result = |
| 360 | __format_spec::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral); | |
| 355 | __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral); | |
| 361 | 356 | *__result.__exponent = 'E'; |
| 362 | 357 | return __result; |
| 363 | 358 | } |
| ... | ... | @@ -367,7 +362,7 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer< |
| 367 | 362 | int __precision, char* __integral) { |
| 368 | 363 | __float_result __result; |
| 369 | 364 | __result.__integral = __integral; |
| 370 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision); | |
| 365 | __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision); | |
| 371 | 366 | |
| 372 | 367 | // When there's no precision there's no radix point. |
| 373 | 368 | // Else the radix point is placed at __precision + 1 from the end. |
| ... | ... | @@ -393,14 +388,14 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_ |
| 393 | 388 | |
| 394 | 389 | __float_result __result; |
| 395 | 390 | __result.__integral = __integral; |
| 396 | __result.__last = __format_spec::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision); | |
| 391 | __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision); | |
| 397 | 392 | |
| 398 | 393 | char* __first = __integral + 1; |
| 399 | 394 | if (__first == __result.__last) { |
| 400 | 395 | __result.__radix_point = __result.__last; |
| 401 | 396 | __result.__exponent = __result.__last; |
| 402 | 397 | } else { |
| 403 | __result.__exponent = __format_spec::__find_exponent(__first, __result.__last); | |
| 398 | __result.__exponent = __formatter::__find_exponent(__first, __result.__last); | |
| 404 | 399 | if (__result.__exponent != __result.__last) |
| 405 | 400 | // In scientific mode if there's a radix point it will always be after |
| 406 | 401 | // the first digit. (This is the position __first points at). |
| ... | ... | @@ -426,19 +421,79 @@ _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_ |
| 426 | 421 | template <class _Fp, class _Tp> |
| 427 | 422 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value, |
| 428 | 423 | int __precision, char* __integral) { |
| 429 | __float_result __result = | |
| 430 | __format_spec::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral); | |
| 424 | __float_result __result = __formatter::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral); | |
| 431 | 425 | if (__result.__exponent != __result.__last) |
| 432 | 426 | *__result.__exponent = 'E'; |
| 433 | 427 | return __result; |
| 434 | 428 | } |
| 435 | 429 | |
| 436 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 430 | /// Fills the buffer with the data based on the requested formatting. | |
| 431 | /// | |
| 432 | /// This function, when needed, turns the characters to upper case and | |
| 433 | /// determines the "interesting" locations which are returned to the caller. | |
| 434 | /// | |
| 435 | /// This means the caller never has to convert the contents of the buffer to | |
| 436 | /// upper case or search for radix points and the location of the exponent. | |
| 437 | /// This gives a bit of overhead. The original code didn't do that, but due | |
| 438 | /// to the number of possible additional work needed to turn this number to | |
| 439 | /// the proper output the code was littered with tests for upper cases and | |
| 440 | /// searches for radix points and exponents. | |
| 441 | /// - When a precision larger than the type's precision is selected | |
| 442 | /// additional zero characters need to be written before the exponent. | |
| 443 | /// - alternate form needs to add a radix point when not present. | |
| 444 | /// - localization needs to do grouping in the integral part. | |
| 445 | template <class _Fp, class _Tp> | |
| 446 | // TODO FMT _Fp should just be _Tp when to_chars has proper long double support. | |
| 447 | _LIBCPP_HIDE_FROM_ABI __float_result __format_buffer( | |
| 448 | __float_buffer<_Fp>& __buffer, | |
| 449 | _Tp __value, | |
| 450 | bool __negative, | |
| 451 | bool __has_precision, | |
| 452 | __format_spec::__sign __sign, | |
| 453 | __format_spec::__type __type) { | |
| 454 | char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign); | |
| 455 | switch (__type) { | |
| 456 | case __format_spec::__type::__default: | |
| 457 | return __formatter::__format_buffer_default(__buffer, __value, __first); | |
| 458 | ||
| 459 | case __format_spec::__type::__hexfloat_lower_case: | |
| 460 | return __formatter::__format_buffer_hexadecimal_lower_case( | |
| 461 | __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first); | |
| 462 | ||
| 463 | case __format_spec::__type::__hexfloat_upper_case: | |
| 464 | return __formatter::__format_buffer_hexadecimal_upper_case( | |
| 465 | __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first); | |
| 466 | ||
| 467 | case __format_spec::__type::__scientific_lower_case: | |
| 468 | return __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first); | |
| 469 | ||
| 470 | case __format_spec::__type::__scientific_upper_case: | |
| 471 | return __formatter::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first); | |
| 472 | ||
| 473 | case __format_spec::__type::__fixed_lower_case: | |
| 474 | case __format_spec::__type::__fixed_upper_case: | |
| 475 | return __formatter::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first); | |
| 476 | ||
| 477 | case __format_spec::__type::__general_lower_case: | |
| 478 | return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first); | |
| 479 | ||
| 480 | case __format_spec::__type::__general_upper_case: | |
| 481 | return __formatter::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first); | |
| 482 | ||
| 483 | default: | |
| 484 | _LIBCPP_ASSERT(false, "The parser should have validated the type"); | |
| 485 | __libcpp_unreachable(); | |
| 486 | } | |
| 487 | } | |
| 488 | ||
| 489 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 437 | 490 | 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) { | |
| 491 | _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form( | |
| 492 | _OutIt __out_it, | |
| 493 | const __float_buffer<_Fp>& __buffer, | |
| 494 | const __float_result& __result, | |
| 495 | _VSTD::locale __loc, | |
| 496 | __format_spec::__parsed_specifications<_CharT> __specs) { | |
| 442 | 497 | const auto& __np = use_facet<numpunct<_CharT>>(__loc); |
| 443 | 498 | string __grouping = __np.grouping(); |
| 444 | 499 | char* __first = __result.__integral; |
| ... | ... | @@ -450,29 +505,30 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons |
| 450 | 505 | if (__digits <= __grouping[0]) |
| 451 | 506 | __grouping.clear(); |
| 452 | 507 | else |
| 453 | __grouping = __determine_grouping(__digits, __grouping); | |
| 508 | __grouping = __formatter::__determine_grouping(__digits, __grouping); | |
| 454 | 509 | } |
| 455 | 510 | |
| 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 | |
| 511 | ptrdiff_t __size = | |
| 512 | __result.__last - __buffer.begin() + // Formatted string | |
| 513 | __buffer.__num_trailing_zeros() + // Not yet rendered zeros | |
| 514 | __grouping.size() - // Grouping contains one | |
| 515 | !__grouping.empty(); // additional character | |
| 460 | 516 | |
| 461 | __formatter::__padding_size_result __padding = {0, 0}; | |
| 462 | bool __zero_padding = __alignment == _Flags::_Alignment::__default; | |
| 463 | if (__size < __width) { | |
| 517 | __formatter::__padding_size_result __padding = {0, 0}; | |
| 518 | bool __zero_padding = __specs.__alignment_ == __format_spec::__alignment::__zero_padding; | |
| 519 | if (__size < __specs.__width_) { | |
| 464 | 520 | if (__zero_padding) { |
| 465 | __alignment = _Flags::_Alignment::__right; | |
| 466 | __fill = _CharT('0'); | |
| 521 | __specs.__alignment_ = __format_spec::__alignment::__right; | |
| 522 | __specs.__fill_ = _CharT('0'); | |
| 467 | 523 | } |
| 468 | 524 | |
| 469 | __padding = __formatter::__padding_size(__size, __width, __alignment); | |
| 525 | __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_); | |
| 470 | 526 | } |
| 471 | 527 | |
| 472 | 528 | // sign and (zero padding or alignment) |
| 473 | 529 | if (__zero_padding && __first != __buffer.begin()) |
| 474 | 530 | *__out_it++ = *__buffer.begin(); |
| 475 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, __fill); | |
| 531 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); | |
| 476 | 532 | if (!__zero_padding && __first != __buffer.begin()) |
| 477 | 533 | *__out_it++ = *__buffer.begin(); |
| 478 | 534 | |
| ... | ... | @@ -513,200 +569,148 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons |
| 513 | 569 | __out_it = _VSTD::copy(__result.__exponent, __result.__last, _VSTD::move(__out_it)); |
| 514 | 570 | |
| 515 | 571 | // alignment |
| 516 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, __fill); | |
| 572 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); | |
| 573 | } | |
| 574 | # endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 575 | ||
| 576 | template <class _OutIt, class _CharT> | |
| 577 | _LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite( | |
| 578 | _OutIt __out_it, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative, bool __isnan) { | |
| 579 | char __buffer[4]; | |
| 580 | char* __last = __formatter::__insert_sign(__buffer, __negative, __specs.__std_.__sign_); | |
| 581 | ||
| 582 | // to_chars can return inf, infinity, nan, and nan(n-char-sequence). | |
| 583 | // The format library requires inf and nan. | |
| 584 | // All in one expression to avoid dangling references. | |
| 585 | bool __upper_case = | |
| 586 | __specs.__std_.__type_ == __format_spec::__type::__hexfloat_upper_case || | |
| 587 | __specs.__std_.__type_ == __format_spec::__type::__scientific_upper_case || | |
| 588 | __specs.__std_.__type_ == __format_spec::__type::__fixed_upper_case || | |
| 589 | __specs.__std_.__type_ == __format_spec::__type::__general_upper_case; | |
| 590 | __last = _VSTD::copy_n(&("infnanINFNAN"[6 * __upper_case + 3 * __isnan]), 3, __last); | |
| 591 | ||
| 592 | // [format.string.std]/13 | |
| 593 | // A zero (0) character preceding the width field pads the field with | |
| 594 | // leading zeros (following any indication of sign or base) to the field | |
| 595 | // width, except when applied to an infinity or NaN. | |
| 596 | if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) | |
| 597 | __specs.__alignment_ = __format_spec::__alignment::__right; | |
| 598 | ||
| 599 | return __formatter::__write(__buffer, __last, _VSTD::move(__out_it), __specs); | |
| 517 | 600 | } |
| 518 | 601 | |
| 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 | } | |
| 602 | template <floating_point _Tp, class _CharT> | |
| 603 | _LIBCPP_HIDE_FROM_ABI auto | |
| 604 | __format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) | |
| 605 | -> decltype(__ctx.out()) { | |
| 606 | bool __negative = _VSTD::signbit(__value); | |
| 569 | 607 | |
| 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 | } | |
| 608 | if (!_VSTD::isfinite(__value)) [[unlikely]] | |
| 609 | return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, _VSTD::isnan(__value)); | |
| 588 | 610 | |
| 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 | } | |
| 611 | // Depending on the std-format-spec string the sign and the value | |
| 612 | // might not be outputted together: | |
| 613 | // - zero-padding may insert additional '0' characters. | |
| 614 | // Therefore the value is processed as a non negative value. | |
| 615 | // The function @ref __insert_sign will insert a '-' when the value was | |
| 616 | // negative. | |
| 602 | 617 | |
| 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); | |
| 618 | if (__negative) | |
| 619 | __value = -__value; | |
| 606 | 620 | |
| 607 | return __formatter::__write(_VSTD::move(__out_it), __first, __result.__last, __size, this->__width, this->__fill, | |
| 608 | this->__alignment); | |
| 621 | // TODO FMT _Fp should just be _Tp when to_chars has proper long double support. | |
| 622 | using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>; | |
| 623 | // Force the type of the precision to avoid -1 to become an unsigned value. | |
| 624 | __float_buffer<_Fp> __buffer(__specs.__precision_); | |
| 625 | __float_result __result = __formatter::__format_buffer( | |
| 626 | __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_); | |
| 627 | ||
| 628 | if (__specs.__std_.__alternate_form_ && __result.__radix_point == __result.__last) { | |
| 629 | *__result.__last++ = '.'; | |
| 630 | ||
| 631 | // When there is an exponent the point needs to be moved before the | |
| 632 | // exponent. When there's no exponent the rotate does nothing. Since | |
| 633 | // rotate tests whether the operation is a nop, call it unconditionally. | |
| 634 | _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last); | |
| 635 | __result.__radix_point = __result.__exponent; | |
| 636 | ||
| 637 | // The radix point is always placed before the exponent. | |
| 638 | // - No exponent needs to point to the new last. | |
| 639 | // - An exponent needs to move one position to the right. | |
| 640 | // So it's safe to increment the value unconditionally. | |
| 641 | ++__result.__exponent; | |
| 609 | 642 | } |
| 610 | 643 | |
| 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); | |
| 644 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 645 | if (__specs.__std_.__locale_specific_form_) | |
| 646 | return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs); | |
| 647 | # endif | |
| 648 | ||
| 649 | ptrdiff_t __size = __result.__last - __buffer.begin(); | |
| 650 | int __num_trailing_zeros = __buffer.__num_trailing_zeros(); | |
| 651 | if (__size + __num_trailing_zeros >= __specs.__width_) { | |
| 652 | if (__num_trailing_zeros && __result.__exponent != __result.__last) | |
| 653 | // Insert trailing zeros before exponent character. | |
| 654 | return _VSTD::copy( | |
| 655 | __result.__exponent, | |
| 656 | __result.__last, | |
| 657 | _VSTD::fill_n( | |
| 658 | _VSTD::copy(__buffer.begin(), __result.__exponent, __ctx.out()), __num_trailing_zeros, _CharT('0'))); | |
| 659 | ||
| 660 | return _VSTD::fill_n( | |
| 661 | _VSTD::copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0')); | |
| 640 | 662 | } |
| 641 | 663 | |
| 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); | |
| 664 | auto __out_it = __ctx.out(); | |
| 665 | char* __first = __buffer.begin(); | |
| 666 | if (__specs.__alignment_ == __format_spec::__alignment ::__zero_padding) { | |
| 667 | // When there is a sign output it before the padding. Note the __size | |
| 668 | // doesn't need any adjustment, regardless whether the sign is written | |
| 669 | // here or in __formatter::__write. | |
| 670 | if (__first != __result.__integral) | |
| 671 | *__out_it++ = *__first++; | |
| 672 | // After the sign is written, zero padding is the same a right alignment | |
| 673 | // with '0'. | |
| 674 | __specs.__alignment_ = __format_spec::__alignment::__right; | |
| 675 | __specs.__fill_ = _CharT('0'); | |
| 676 | } | |
| 676 | 677 | |
| 677 | case _Flags::_Type::__scientific_upper_case: | |
| 678 | return __format_spec::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first); | |
| 678 | if (__num_trailing_zeros) | |
| 679 | return __formatter::__write_using_trailing_zeros( | |
| 680 | __first, __result.__last, _VSTD::move(__out_it), __specs, __size, __result.__exponent, __num_trailing_zeros); | |
| 679 | 681 | |
| 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); | |
| 682 | return __formatter::__write(__first, __result.__last, _VSTD::move(__out_it), __specs, __size); | |
| 683 | } | |
| 683 | 684 | |
| 684 | case _Flags::_Type::__general_lower_case: | |
| 685 | return __format_spec::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first); | |
| 685 | } // namespace __formatter | |
| 686 | 686 | |
| 687 | case _Flags::_Type::__general_upper_case: | |
| 688 | return __format_spec::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first); | |
| 687 | template <__formatter::__char_type _CharT> | |
| 688 | struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point { | |
| 689 | public: | |
| 690 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 691 | parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { | |
| 692 | auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_floating_point); | |
| 693 | __format_spec::__process_parsed_floating_point(__parser_); | |
| 694 | return __result; | |
| 695 | } | |
| 689 | 696 | |
| 690 | default: | |
| 691 | _LIBCPP_ASSERT(false, "The parser should have validated the type"); | |
| 692 | _LIBCPP_UNREACHABLE(); | |
| 693 | } | |
| 697 | template <floating_point _Tp> | |
| 698 | _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 699 | return __formatter::__format_floating_point(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); | |
| 694 | 700 | } |
| 695 | }; | |
| 696 | 701 | |
| 697 | } //namespace __format_spec | |
| 702 | __format_spec::__parser<_CharT> __parser_; | |
| 703 | }; | |
| 698 | 704 | |
| 699 | 705 | template <__formatter::__char_type _CharT> |
| 700 | 706 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT> |
| 701 | : public __format_spec::__formatter_floating_point<_CharT> {}; | |
| 707 | : public __formatter_floating_point<_CharT> {}; | |
| 702 | 708 | template <__formatter::__char_type _CharT> |
| 703 | 709 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT> |
| 704 | : public __format_spec::__formatter_floating_point<_CharT> {}; | |
| 710 | : public __formatter_floating_point<_CharT> {}; | |
| 705 | 711 | template <__formatter::__char_type _CharT> |
| 706 | 712 | 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) | |
| 713 | : public __formatter_floating_point<_CharT> {}; | |
| 710 | 714 | |
| 711 | 715 | #endif //_LIBCPP_STD_VER > 17 |
| 712 | 716 |
lib/libcxx/include/__format/formatter_integer.h+54-117| ... | ... | @@ -11,160 +11,97 @@ |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_INTEGER_H |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | #include <__concepts/arithmetic.h> | |
| 14 | 15 | #include <__config> |
| 15 | #include <__format/format_error.h> | |
| 16 | 16 | #include <__format/format_fwd.h> |
| 17 | #include <__format/format_parse_context.h> | |
| 17 | 18 | #include <__format/formatter.h> |
| 18 | 19 | #include <__format/formatter_integral.h> |
| 20 | #include <__format/formatter_output.h> | |
| 19 | 21 | #include <__format/parser_std_format_spec.h> |
| 20 | #include <limits> | |
| 22 | #include <__type_traits/make_32_64_or_128_bit.h> | |
| 23 | #include <type_traits> | |
| 21 | 24 | |
| 22 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 24 | 27 | #endif |
| 25 | 28 | |
| 26 | _LIBCPP_PUSH_MACROS | |
| 27 | #include <__undef_macros> | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | 30 | |
| 31 | 31 | #if _LIBCPP_STD_VER > 17 |
| 32 | 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 { | |
| 33 | template <__formatter::__char_type _CharT> | |
| 34 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer { | |
| 40 | 35 | |
| 41 | template <class _CharT> | |
| 42 | class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> { | |
| 43 | 36 | 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; | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 38 | parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { | |
| 39 | auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); | |
| 40 | __format_spec::__process_parsed_integer(__parser_); | |
| 41 | return __result; | |
| 71 | 42 | } |
| 72 | }; | |
| 73 | 43 | |
| 74 | template <class _CharT> | |
| 75 | using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>; | |
| 44 | template <integral _Tp> | |
| 45 | _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 46 | __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx); | |
| 47 | ||
| 48 | if (__specs.__std_.__type_ == __format_spec::__type::__char) | |
| 49 | return __formatter::__format_char(__value, __ctx.out(), __specs); | |
| 76 | 50 | |
| 77 | } // namespace __format_spec | |
| 51 | using _Type = __make_32_64_or_128_bit_t<_Tp>; | |
| 52 | static_assert(!is_same<_Type, void>::value, "unsupported integral type used in __formatter_integer::__format"); | |
| 78 | 53 | |
| 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 | |
| 54 | // Reduce the number of instantiation of the integer formatter | |
| 55 | return __formatter::__format_integer(static_cast<_Type>(__value), __ctx, __specs); | |
| 56 | } | |
| 57 | ||
| 58 | __format_spec::__parser<_CharT> __parser_; | |
| 59 | }; | |
| 82 | 60 | |
| 83 | 61 | // Signed integral types. |
| 84 | 62 | 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> {}; | |
| 63 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT> | |
| 64 | : public __formatter_integer<_CharT> {}; | |
| 88 | 65 | template <__formatter::__char_type _CharT> |
| 89 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> | |
| 90 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 66 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> { | |
| 67 | }; | |
| 91 | 68 | template <__formatter::__char_type _CharT> |
| 92 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> | |
| 93 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 69 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {}; | |
| 94 | 70 | template <__formatter::__char_type _CharT> |
| 95 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> | |
| 96 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 71 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {}; | |
| 97 | 72 | 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 | |
| 73 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT> | |
| 74 | : public __formatter_integer<_CharT> {}; | |
| 75 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 102 | 76 | 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 | |
| 77 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT> | |
| 78 | : public __formatter_integer<_CharT> {}; | |
| 79 | # endif | |
| 120 | 80 | |
| 121 | 81 | // Unsigned integral types. |
| 122 | 82 | 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> {}; | |
| 83 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT> | |
| 84 | : public __formatter_integer<_CharT> {}; | |
| 126 | 85 | 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> {}; | |
| 86 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT> | |
| 87 | : public __formatter_integer<_CharT> {}; | |
| 130 | 88 | template <__formatter::__char_type _CharT> |
| 131 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 132 | formatter<unsigned, _CharT> | |
| 133 | : public __format_spec::__formatter_integer<_CharT> {}; | |
| 89 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT> | |
| 90 | : public __formatter_integer<_CharT> {}; | |
| 134 | 91 | 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> {}; | |
| 92 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT> | |
| 93 | : public __formatter_integer<_CharT> {}; | |
| 138 | 94 | 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 | |
| 95 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT> | |
| 96 | : public __formatter_integer<_CharT> {}; | |
| 97 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 143 | 98 | 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) | |
| 99 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT> | |
| 100 | : public __formatter_integer<_CharT> {}; | |
| 101 | # endif | |
| 163 | 102 | |
| 164 | 103 | #endif //_LIBCPP_STD_VER > 17 |
| 165 | 104 | |
| 166 | 105 | _LIBCPP_END_NAMESPACE_STD |
| 167 | 106 | |
| 168 | _LIBCPP_POP_MACROS | |
| 169 | ||
| 170 | 107 | #endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H |
lib/libcxx/include/__format/formatter_integral.h+254-355| ... | ... | @@ -10,27 +10,24 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H |
| 12 | 12 | |
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/copy_n.h> | |
| 15 | #include <__algorithm/fill_n.h> | |
| 16 | #include <__algorithm/transform.h> | |
| 13 | #include <__concepts/arithmetic.h> | |
| 14 | #include <__concepts/same_as.h> | |
| 17 | 15 | #include <__config> |
| 18 | 16 | #include <__format/format_error.h> |
| 19 | #include <__format/format_fwd.h> | |
| 20 | #include <__format/formatter.h> | |
| 17 | #include <__format/formatter.h> // for __char_type TODO FMT Move the concept? | |
| 18 | #include <__format/formatter_output.h> | |
| 21 | 19 | #include <__format/parser_std_format_spec.h> |
| 22 | #include <array> | |
| 20 | #include <__utility/unreachable.h> | |
| 23 | 21 | #include <charconv> |
| 24 | #include <concepts> | |
| 25 | 22 | #include <limits> |
| 26 | 23 | #include <string> |
| 27 | 24 | |
| 28 | 25 | #ifndef _LIBCPP_HAS_NO_LOCALIZATION |
| 29 | #include <locale> | |
| 26 | # include <locale> | |
| 30 | 27 | #endif |
| 31 | 28 | |
| 32 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 33 | #pragma GCC system_header | |
| 30 | # pragma GCC system_header | |
| 34 | 31 | #endif |
| 35 | 32 | |
| 36 | 33 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -40,97 +37,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 40 | 37 | |
| 41 | 38 | #if _LIBCPP_STD_VER > 17 |
| 42 | 39 | |
| 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) | |
| 40 | namespace __formatter { | |
| 48 | 41 | |
| 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 | } | |
| 42 | // | |
| 43 | // Generic | |
| 44 | // | |
| 118 | 45 | |
| 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 | } | |
| 46 | _LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative, __format_spec::__sign __sign) { | |
| 47 | if (__negative) | |
| 48 | *__buf++ = '-'; | |
| 49 | else | |
| 50 | switch (__sign) { | |
| 51 | case __format_spec::__sign::__default: | |
| 52 | case __format_spec::__sign::__minus: | |
| 53 | // No sign added. | |
| 54 | break; | |
| 55 | case __format_spec::__sign::__plus: | |
| 56 | *__buf++ = '+'; | |
| 57 | break; | |
| 58 | case __format_spec::__sign::__space: | |
| 59 | *__buf++ = ' '; | |
| 60 | break; | |
| 61 | } | |
| 126 | 62 | |
| 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. | |
| 63 | return __buf; | |
| 134 | 64 | } |
| 135 | 65 | |
| 136 | 66 | /** |
| ... | ... | @@ -148,8 +78,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept |
| 148 | 78 | * @note The grouping field of the locale is always a @c std::string, |
| 149 | 79 | * regardless whether the @c std::numpunct's type is @c char or @c wchar_t. |
| 150 | 80 | */ |
| 151 | _LIBCPP_HIDE_FROM_ABI inline string | |
| 152 | __determine_grouping(ptrdiff_t __size, const string& __grouping) { | |
| 81 | _LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const string& __grouping) { | |
| 153 | 82 | _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0], |
| 154 | 83 | "The slow grouping formatting is used while there will be no " |
| 155 | 84 | "separators written"); |
| ... | ... | @@ -176,283 +105,253 @@ __determine_grouping(ptrdiff_t __size, const string& __grouping) { |
| 176 | 105 | } |
| 177 | 106 | } |
| 178 | 107 | |
| 179 | _LIBCPP_UNREACHABLE(); | |
| 108 | __libcpp_unreachable(); | |
| 180 | 109 | } |
| 181 | 110 | |
| 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); | |
| 111 | // | |
| 112 | // Char | |
| 113 | // | |
| 196 | 114 | |
| 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); | |
| 115 | template <__formatter::__char_type _CharT> | |
| 116 | _LIBCPP_HIDE_FROM_ABI auto __format_char( | |
| 117 | integral auto __value, | |
| 118 | output_iterator<const _CharT&> auto __out_it, | |
| 119 | __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) { | |
| 120 | using _Tp = decltype(__value); | |
| 121 | if constexpr (!same_as<_CharT, _Tp>) { | |
| 122 | // cmp_less and cmp_greater can't be used for character types. | |
| 123 | if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) { | |
| 124 | if (__value < numeric_limits<_CharT>::min() || __value > numeric_limits<_CharT>::max()) | |
| 125 | std::__throw_format_error("Integral value outside the range of the char type"); | |
| 126 | } else if constexpr (signed_integral<_CharT>) { | |
| 127 | // _CharT is signed _Tp is unsigned | |
| 128 | if (__value > static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max())) | |
| 129 | std::__throw_format_error("Integral value outside the range of the char type"); | |
| 130 | } else { | |
| 131 | // _CharT is unsigned _Tp is signed | |
| 132 | if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) > numeric_limits<_CharT>::max()) | |
| 133 | std::__throw_format_error("Integral value outside the range of the char type"); | |
| 212 | 134 | } |
| 213 | 135 | } |
| 214 | 136 | |
| 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 | } | |
| 137 | const auto __c = static_cast<_CharT>(__value); | |
| 138 | return __formatter::__write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, _VSTD::move(__out_it), __specs); | |
| 139 | } | |
| 245 | 140 | |
| 246 | const auto __c = static_cast<_CharT>(__value); | |
| 247 | return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, | |
| 248 | __ctx.out()); | |
| 249 | } | |
| 141 | // | |
| 142 | // Integer | |
| 143 | // | |
| 250 | 144 | |
| 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 | } | |
| 145 | /** Wrapper around @ref to_chars, returning the output pointer. */ | |
| 146 | template <integral _Tp> | |
| 147 | _LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, int __base) { | |
| 148 | // TODO FMT Evaluate code overhead due to not calling the internal function | |
| 149 | // directly. (Should be zero overhead.) | |
| 150 | to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base); | |
| 151 | _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); | |
| 152 | return __r.ptr; | |
| 153 | } | |
| 298 | 154 | |
| 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) { | |
| 155 | /** | |
| 156 | * Helper to determine the buffer size to output a integer in Base @em x. | |
| 157 | * | |
| 158 | * There are several overloads for the supported bases. The function uses the | |
| 159 | * base as template argument so it can be used in a constant expression. | |
| 160 | */ | |
| 161 | template <unsigned_integral _Tp, size_t _Base> | |
| 162 | consteval size_t __buffer_size() noexcept | |
| 163 | requires(_Base == 2) | |
| 164 | { | |
| 165 | return numeric_limits<_Tp>::digits // The number of binary digits. | |
| 166 | + 2 // Reserve space for the '0[Bb]' prefix. | |
| 167 | + 1; // Reserve space for the sign. | |
| 168 | } | |
| 303 | 169 | |
| 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)); | |
| 170 | template <unsigned_integral _Tp, size_t _Base> | |
| 171 | consteval size_t __buffer_size() noexcept | |
| 172 | requires(_Base == 8) | |
| 173 | { | |
| 174 | return numeric_limits<_Tp>::digits // The number of binary digits. | |
| 175 | / 3 // Adjust to octal. | |
| 176 | + 1 // Turn floor to ceil. | |
| 177 | + 1 // Reserve space for the '0' prefix. | |
| 178 | + 1; // Reserve space for the sign. | |
| 179 | } | |
| 308 | 180 | |
| 309 | return __formatter::__write(_VSTD::move(__out_it), __first, __last, | |
| 310 | __size, this->__width, this->__fill, | |
| 311 | this->__alignment); | |
| 312 | } | |
| 181 | template <unsigned_integral _Tp, size_t _Base> | |
| 182 | consteval size_t __buffer_size() noexcept | |
| 183 | requires(_Base == 10) | |
| 184 | { | |
| 185 | return numeric_limits<_Tp>::digits10 // The floored value. | |
| 186 | + 1 // Turn floor to ceil. | |
| 187 | + 1; // Reserve space for the sign. | |
| 188 | } | |
| 189 | ||
| 190 | template <unsigned_integral _Tp, size_t _Base> | |
| 191 | consteval size_t __buffer_size() noexcept | |
| 192 | requires(_Base == 16) | |
| 193 | { | |
| 194 | return numeric_limits<_Tp>::digits // The number of binary digits. | |
| 195 | / 4 // Adjust to hexadecimal. | |
| 196 | + 2 // Reserve space for the '0[Xx]' prefix. | |
| 197 | + 1; // Reserve space for the sign. | |
| 198 | } | |
| 313 | 199 | |
| 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); | |
| 200 | template <unsigned_integral _Tp, class _CharT> | |
| 201 | _LIBCPP_HIDE_FROM_ABI auto __format_integer( | |
| 202 | _Tp __value, | |
| 203 | auto& __ctx, | |
| 204 | __format_spec::__parsed_specifications<_CharT> __specs, | |
| 205 | bool __negative, | |
| 206 | char* __begin, | |
| 207 | char* __end, | |
| 208 | const char* __prefix, | |
| 209 | int __base) -> decltype(__ctx.out()) { | |
| 210 | char* __first = __formatter::__insert_sign(__begin, __negative, __specs.__std_.__sign_); | |
| 211 | if (__specs.__std_.__alternate_form_ && __prefix) | |
| 212 | while (*__prefix) | |
| 213 | *__first++ = *__prefix++; | |
| 214 | ||
| 215 | char* __last = __formatter::__to_buffer(__first, __end, __value, __base); | |
| 216 | ||
| 217 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 218 | if (__specs.__std_.__locale_specific_form_) { | |
| 219 | const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale()); | |
| 220 | string __grouping = __np.grouping(); | |
| 221 | ptrdiff_t __size = __last - __first; | |
| 222 | // Writing the grouped form has more overhead than the normal output | |
| 223 | // routines. If there will be no separators written the locale-specific | |
| 224 | // form is identical to the normal routine. Test whether to grouped form | |
| 225 | // is required. | |
| 226 | if (!__grouping.empty() && __size > __grouping[0]) | |
| 227 | return __formatter::__write_using_decimal_separators( | |
| 228 | __ctx.out(), | |
| 229 | __begin, | |
| 230 | __first, | |
| 231 | __last, | |
| 232 | __formatter::__determine_grouping(__size, __grouping), | |
| 233 | __np.thousands_sep(), | |
| 234 | __specs); | |
| 235 | } | |
| 236 | # endif | |
| 237 | auto __out_it = __ctx.out(); | |
| 238 | if (__specs.__alignment_ != __format_spec::__alignment::__zero_padding) | |
| 239 | __first = __begin; | |
| 240 | else { | |
| 241 | // __buf contains [sign][prefix]data | |
| 242 | // ^ location of __first | |
| 243 | // The zero padding is done like: | |
| 244 | // - Write [sign][prefix] | |
| 245 | // - Write data right aligned with '0' as fill character. | |
| 246 | __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); | |
| 247 | __specs.__alignment_ = __format_spec::__alignment::__right; | |
| 248 | __specs.__fill_ = _CharT('0'); | |
| 249 | int32_t __size = __first - __begin; | |
| 250 | ||
| 251 | __specs.__width_ -= _VSTD::min(__size, __specs.__width_); | |
| 328 | 252 | } |
| 329 | 253 | |
| 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 | } | |
| 254 | if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]] | |
| 255 | return __formatter::__write(__first, __last, __ctx.out(), __specs); | |
| 256 | ||
| 257 | return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper); | |
| 258 | } | |
| 371 | 259 | |
| 372 | return __write(__first, __last, _VSTD::move(__out_it)); | |
| 260 | template <unsigned_integral _Tp, class _CharT> | |
| 261 | _LIBCPP_HIDE_FROM_ABI auto __format_integer( | |
| 262 | _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false) | |
| 263 | -> decltype(__ctx.out()) { | |
| 264 | switch (__specs.__std_.__type_) { | |
| 265 | case __format_spec::__type::__binary_lower_case: { | |
| 266 | array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array; | |
| 267 | return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0b", 2); | |
| 268 | } | |
| 269 | case __format_spec::__type::__binary_upper_case: { | |
| 270 | array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array; | |
| 271 | return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0B", 2); | |
| 272 | } | |
| 273 | case __format_spec::__type::__octal: { | |
| 274 | // Octal is special; if __value == 0 there's no prefix. | |
| 275 | array<char, __formatter::__buffer_size<decltype(__value), 8>()> __array; | |
| 276 | return __formatter::__format_integer( | |
| 277 | __value, __ctx, __specs, __negative, __array.begin(), __array.end(), __value != 0 ? "0" : nullptr, 8); | |
| 278 | } | |
| 279 | case __format_spec::__type::__default: | |
| 280 | case __format_spec::__type::__decimal: { | |
| 281 | array<char, __formatter::__buffer_size<decltype(__value), 10>()> __array; | |
| 282 | return __formatter::__format_integer( | |
| 283 | __value, __ctx, __specs, __negative, __array.begin(), __array.end(), nullptr, 10); | |
| 284 | } | |
| 285 | case __format_spec::__type::__hexadecimal_lower_case: { | |
| 286 | array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array; | |
| 287 | return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0x", 16); | |
| 288 | } | |
| 289 | case __format_spec::__type::__hexadecimal_upper_case: { | |
| 290 | array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array; | |
| 291 | return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0X", 16); | |
| 292 | } | |
| 293 | default: | |
| 294 | _LIBCPP_ASSERT(false, "The parse function should have validated the type"); | |
| 295 | __libcpp_unreachable(); | |
| 373 | 296 | } |
| 297 | } | |
| 374 | 298 | |
| 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 | } | |
| 299 | template <signed_integral _Tp, class _CharT> | |
| 300 | _LIBCPP_HIDE_FROM_ABI auto | |
| 301 | __format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) | |
| 302 | -> decltype(__ctx.out()) { | |
| 303 | // Depending on the std-format-spec string the sign and the value | |
| 304 | // might not be outputted together: | |
| 305 | // - alternate form may insert a prefix string. | |
| 306 | // - zero-padding may insert additional '0' characters. | |
| 307 | // Therefore the value is processed as a positive unsigned value. | |
| 308 | // The function @ref __insert_sign will a '-' when the value was negative. | |
| 309 | auto __r = std::__to_unsigned_like(__value); | |
| 310 | bool __negative = __value < 0; | |
| 311 | if (__negative) | |
| 312 | __r = __complement(__r); | |
| 313 | ||
| 314 | return __formatter::__format_integer(__r, __ctx, __specs, __negative); | |
| 315 | } | |
| 413 | 316 | |
| 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 | } | |
| 317 | // | |
| 318 | // Formatter arithmetic (bool) | |
| 319 | // | |
| 446 | 320 | |
| 447 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, | |
| 448 | this->__fill); | |
| 449 | } | |
| 450 | #endif // _LIBCPP_HAS_NO_LOCALIZATION | |
| 321 | template <class _CharT> | |
| 322 | struct _LIBCPP_TEMPLATE_VIS __bool_strings; | |
| 323 | ||
| 324 | template <> | |
| 325 | struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> { | |
| 326 | static constexpr string_view __true{"true"}; | |
| 327 | static constexpr string_view __false{"false"}; | |
| 451 | 328 | }; |
| 452 | 329 | |
| 453 | } // namespace __format_spec | |
| 330 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 331 | template <> | |
| 332 | struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> { | |
| 333 | static constexpr wstring_view __true{L"true"}; | |
| 334 | static constexpr wstring_view __false{L"false"}; | |
| 335 | }; | |
| 336 | # endif | |
| 337 | ||
| 338 | template <class _CharT> | |
| 339 | _LIBCPP_HIDE_FROM_ABI auto | |
| 340 | __format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) | |
| 341 | -> decltype(__ctx.out()) { | |
| 342 | # ifndef _LIBCPP_HAS_NO_LOCALIZATION | |
| 343 | if (__specs.__std_.__locale_specific_form_) { | |
| 344 | const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale()); | |
| 345 | basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename(); | |
| 346 | return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs); | |
| 347 | } | |
| 348 | # endif | |
| 349 | basic_string_view<_CharT> __str = | |
| 350 | __value ? __formatter::__bool_strings<_CharT>::__true : __formatter::__bool_strings<_CharT>::__false; | |
| 351 | return __formatter::__write(__str.begin(), __str.end(), __ctx.out(), __specs); | |
| 352 | } | |
| 454 | 353 | |
| 455 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 354 | } // namespace __formatter | |
| 456 | 355 | |
| 457 | 356 | #endif //_LIBCPP_STD_VER > 17 |
| 458 | 357 |
lib/libcxx/include/__format/formatter_output.h created+308| ... | ... | @@ -0,0 +1,308 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H | |
| 11 | #define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H | |
| 12 | ||
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/copy_n.h> | |
| 15 | #include <__algorithm/fill_n.h> | |
| 16 | #include <__algorithm/transform.h> | |
| 17 | #include <__config> | |
| 18 | #include <__format/formatter.h> | |
| 19 | #include <__format/parser_std_format_spec.h> | |
| 20 | #include <__format/unicode.h> | |
| 21 | #include <__utility/move.h> | |
| 22 | #include <__utility/unreachable.h> | |
| 23 | #include <cstddef> | |
| 24 | #include <string> | |
| 25 | #include <string_view> | |
| 26 | ||
| 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 28 | # pragma GCC system_header | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 17 | |
| 34 | ||
| 35 | namespace __formatter { | |
| 36 | ||
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) { | |
| 38 | switch (__c) { | |
| 39 | case 'a': | |
| 40 | return 'A'; | |
| 41 | case 'b': | |
| 42 | return 'B'; | |
| 43 | case 'c': | |
| 44 | return 'C'; | |
| 45 | case 'd': | |
| 46 | return 'D'; | |
| 47 | case 'e': | |
| 48 | return 'E'; | |
| 49 | case 'f': | |
| 50 | return 'F'; | |
| 51 | } | |
| 52 | return __c; | |
| 53 | } | |
| 54 | ||
| 55 | struct _LIBCPP_TYPE_VIS __padding_size_result { | |
| 56 | size_t __before_; | |
| 57 | size_t __after_; | |
| 58 | }; | |
| 59 | ||
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result | |
| 61 | __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align) { | |
| 62 | _LIBCPP_ASSERT(__width > __size, "don't call this function when no padding is required"); | |
| 63 | _LIBCPP_ASSERT( | |
| 64 | __align != __format_spec::__alignment::__zero_padding, "the caller should have handled the zero-padding"); | |
| 65 | ||
| 66 | size_t __fill = __width - __size; | |
| 67 | switch (__align) { | |
| 68 | case __format_spec::__alignment::__zero_padding: | |
| 69 | __libcpp_unreachable(); | |
| 70 | ||
| 71 | case __format_spec::__alignment::__left: | |
| 72 | return {0, __fill}; | |
| 73 | ||
| 74 | case __format_spec::__alignment::__center: { | |
| 75 | // The extra padding is divided per [format.string.std]/3 | |
| 76 | // __before = floor(__fill, 2); | |
| 77 | // __after = ceil(__fill, 2); | |
| 78 | size_t __before = __fill / 2; | |
| 79 | size_t __after = __fill - __before; | |
| 80 | return {__before, __after}; | |
| 81 | } | |
| 82 | case __format_spec::__alignment::__default: | |
| 83 | case __format_spec::__alignment::__right: | |
| 84 | return {__fill, 0}; | |
| 85 | } | |
| 86 | __libcpp_unreachable(); | |
| 87 | } | |
| 88 | ||
| 89 | template <class _OutIt, class _CharT> | |
| 90 | _LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first, | |
| 91 | const char* __last, string&& __grouping, _CharT __sep, | |
| 92 | __format_spec::__parsed_specifications<_CharT> __specs) { | |
| 93 | int __size = (__first - __begin) + // [sign][prefix] | |
| 94 | (__last - __first) + // data | |
| 95 | (__grouping.size() - 1); // number of separator characters | |
| 96 | ||
| 97 | __padding_size_result __padding = {0, 0}; | |
| 98 | if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) { | |
| 99 | // Write [sign][prefix]. | |
| 100 | __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); | |
| 101 | ||
| 102 | if (__specs.__width_ > __size) { | |
| 103 | // Write zero padding. | |
| 104 | __padding.__before_ = __specs.__width_ - __size; | |
| 105 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0')); | |
| 106 | } | |
| 107 | } else { | |
| 108 | if (__specs.__width_ > __size) { | |
| 109 | // Determine padding and write padding. | |
| 110 | __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_); | |
| 111 | ||
| 112 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); | |
| 113 | } | |
| 114 | // Write [sign][prefix]. | |
| 115 | __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); | |
| 116 | } | |
| 117 | ||
| 118 | auto __r = __grouping.rbegin(); | |
| 119 | auto __e = __grouping.rend() - 1; | |
| 120 | _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while " | |
| 121 | "there will be no separators written."); | |
| 122 | // The output is divided in small groups of numbers to write: | |
| 123 | // - A group before the first separator. | |
| 124 | // - A separator and a group, repeated for the number of separators. | |
| 125 | // - A group after the last separator. | |
| 126 | // This loop achieves that process by testing the termination condition | |
| 127 | // midway in the loop. | |
| 128 | // | |
| 129 | // TODO FMT This loop evaluates the loop invariant `__parser.__type != | |
| 130 | // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test | |
| 131 | // happens in the __write call.) Benchmark whether making two loops and | |
| 132 | // hoisting the invariant is worth the effort. | |
| 133 | while (true) { | |
| 134 | if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) { | |
| 135 | __last = __first + *__r; | |
| 136 | __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper); | |
| 137 | __first = __last; | |
| 138 | } else { | |
| 139 | __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it)); | |
| 140 | __first += *__r; | |
| 141 | } | |
| 142 | ||
| 143 | if (__r == __e) | |
| 144 | break; | |
| 145 | ||
| 146 | ++__r; | |
| 147 | *__out_it++ = __sep; | |
| 148 | } | |
| 149 | ||
| 150 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); | |
| 151 | } | |
| 152 | ||
| 153 | /// Writes the input to the output with the required padding. | |
| 154 | /// | |
| 155 | /// Since the output column width is specified the function can be used for | |
| 156 | /// ASCII and Unicode output. | |
| 157 | /// | |
| 158 | /// \pre [\a __first, \a __last) is a valid range. | |
| 159 | /// \pre \a __size <= \a __width. Using this function when this pre-condition | |
| 160 | /// doesn't hold incurs an unwanted overhead. | |
| 161 | /// | |
| 162 | /// \param __first Pointer to the first element to write. | |
| 163 | /// \param __last Pointer beyond the last element to write. | |
| 164 | /// \param __out_it The output iterator to write to. | |
| 165 | /// \param __specs The parsed formatting specifications. | |
| 166 | /// \param __size The (estimated) output column width. When the elements | |
| 167 | /// to be written are ASCII the following condition holds | |
| 168 | /// \a __size == \a __last - \a __first. | |
| 169 | /// | |
| 170 | /// \returns An iterator pointing beyond the last element written. | |
| 171 | /// | |
| 172 | /// \note The type of the elements in range [\a __first, \a __last) can differ | |
| 173 | /// from the type of \a __specs. Integer output uses \c std::to_chars for its | |
| 174 | /// conversion, which means the [\a __first, \a __last) always contains elements | |
| 175 | /// of the type \c char. | |
| 176 | template <class _CharT, class _ParserCharT> | |
| 177 | _LIBCPP_HIDE_FROM_ABI auto __write( | |
| 178 | const _CharT* __first, | |
| 179 | const _CharT* __last, | |
| 180 | output_iterator<const _CharT&> auto __out_it, | |
| 181 | __format_spec::__parsed_specifications<_ParserCharT> __specs, | |
| 182 | ptrdiff_t __size) -> decltype(__out_it) { | |
| 183 | _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); | |
| 184 | ||
| 185 | if (__size >= __specs.__width_) | |
| 186 | return _VSTD::copy(__first, __last, _VSTD::move(__out_it)); | |
| 187 | ||
| 188 | __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_); | |
| 189 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); | |
| 190 | __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it)); | |
| 191 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); | |
| 192 | } | |
| 193 | ||
| 194 | /// \overload | |
| 195 | /// | |
| 196 | /// Calls the function above where \a __size = \a __last - \a __first. | |
| 197 | template <class _CharT, class _ParserCharT> | |
| 198 | _LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last, | |
| 199 | output_iterator<const _CharT&> auto __out_it, | |
| 200 | __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) { | |
| 201 | return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first); | |
| 202 | } | |
| 203 | ||
| 204 | template <class _CharT, class _ParserCharT, class _UnaryOperation> | |
| 205 | _LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _CharT* __last, | |
| 206 | output_iterator<const _CharT&> auto __out_it, | |
| 207 | __format_spec::__parsed_specifications<_ParserCharT> __specs, | |
| 208 | _UnaryOperation __op) -> decltype(__out_it) { | |
| 209 | _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); | |
| 210 | ||
| 211 | ptrdiff_t __size = __last - __first; | |
| 212 | if (__size >= __specs.__width_) | |
| 213 | return _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op); | |
| 214 | ||
| 215 | __padding_size_result __padding = __padding_size(__size, __specs.__width_, __specs.__alignment_); | |
| 216 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); | |
| 217 | __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op); | |
| 218 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); | |
| 219 | } | |
| 220 | ||
| 221 | /// Writes additional zero's for the precision before the exponent. | |
| 222 | /// This is used when the precision requested in the format string is larger | |
| 223 | /// than the maximum precision of the floating-point type. These precision | |
| 224 | /// digits are always 0. | |
| 225 | /// | |
| 226 | /// \param __exponent The location of the exponent character. | |
| 227 | /// \param __num_trailing_zeros The number of 0's to write before the exponent | |
| 228 | /// character. | |
| 229 | template <class _CharT, class _ParserCharT> | |
| 230 | _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros( | |
| 231 | const _CharT* __first, | |
| 232 | const _CharT* __last, | |
| 233 | output_iterator<const _CharT&> auto __out_it, | |
| 234 | __format_spec::__parsed_specifications<_ParserCharT> __specs, | |
| 235 | size_t __size, | |
| 236 | const _CharT* __exponent, | |
| 237 | size_t __num_trailing_zeros) -> decltype(__out_it) { | |
| 238 | _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); | |
| 239 | _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used"); | |
| 240 | ||
| 241 | __padding_size_result __padding = | |
| 242 | __padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_); | |
| 243 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); | |
| 244 | __out_it = _VSTD::copy(__first, __exponent, _VSTD::move(__out_it)); | |
| 245 | __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0')); | |
| 246 | __out_it = _VSTD::copy(__exponent, __last, _VSTD::move(__out_it)); | |
| 247 | return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); | |
| 248 | } | |
| 249 | ||
| 250 | /// Writes a string using format's width estimation algorithm. | |
| 251 | /// | |
| 252 | /// \pre !__specs.__has_precision() | |
| 253 | /// | |
| 254 | /// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the | |
| 255 | /// input is ASCII. | |
| 256 | template <class _CharT> | |
| 257 | _LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision( | |
| 258 | basic_string_view<_CharT> __str, | |
| 259 | output_iterator<const _CharT&> auto __out_it, | |
| 260 | __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) { | |
| 261 | _LIBCPP_ASSERT(!__specs.__has_precision(), "use __write_string"); | |
| 262 | ||
| 263 | // No padding -> copy the string | |
| 264 | if (!__specs.__has_width()) | |
| 265 | return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it)); | |
| 266 | ||
| 267 | // Note when the estimated width is larger than size there's no padding. So | |
| 268 | // there's no reason to get the real size when the estimate is larger than or | |
| 269 | // equal to the minimum field width. | |
| 270 | size_t __size = | |
| 271 | __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up) | |
| 272 | .__width_; | |
| 273 | ||
| 274 | return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size); | |
| 275 | } | |
| 276 | ||
| 277 | template <class _CharT> | |
| 278 | _LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __precision) { | |
| 279 | __format_spec::__column_width_result<_CharT> __result = | |
| 280 | __format_spec::__estimate_column_width(__str, __precision, __format_spec::__column_width_rounding::__down); | |
| 281 | __str = basic_string_view<_CharT>{__str.begin(), __result.__last_}; | |
| 282 | return __result.__width_; | |
| 283 | } | |
| 284 | ||
| 285 | /// Writes a string using format's width estimation algorithm. | |
| 286 | /// | |
| 287 | /// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the | |
| 288 | /// input is ASCII. | |
| 289 | template <class _CharT> | |
| 290 | _LIBCPP_HIDE_FROM_ABI auto __write_string( | |
| 291 | basic_string_view<_CharT> __str, | |
| 292 | output_iterator<const _CharT&> auto __out_it, | |
| 293 | __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) { | |
| 294 | if (!__specs.__has_precision()) | |
| 295 | return __formatter::__write_string_no_precision(__str, _VSTD::move(__out_it), __specs); | |
| 296 | ||
| 297 | int __size = __formatter::__truncate(__str, __specs.__precision_); | |
| 298 | ||
| 299 | return __write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size); | |
| 300 | } | |
| 301 | ||
| 302 | } // namespace __formatter | |
| 303 | ||
| 304 | #endif //_LIBCPP_STD_VER > 17 | |
| 305 | ||
| 306 | _LIBCPP_END_NAMESPACE_STD | |
| 307 | ||
| 308 | #endif // _LIBCPP___FORMAT_FORMATTER_OUTPUT_H |
lib/libcxx/include/__format/formatter_pointer.h+22-40| ... | ... | @@ -10,17 +10,15 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_POINTER_H |
| 12 | 12 | |
| 13 | #include <__algorithm/copy.h> | |
| 14 | 13 | #include <__availability> |
| 15 | 14 | #include <__config> |
| 16 | #include <__debug> | |
| 17 | #include <__format/format_error.h> | |
| 18 | 15 | #include <__format/format_fwd.h> |
| 16 | #include <__format/format_parse_context.h> | |
| 19 | 17 | #include <__format/formatter.h> |
| 20 | 18 | #include <__format/formatter_integral.h> |
| 19 | #include <__format/formatter_output.h> | |
| 21 | 20 | #include <__format/parser_std_format_spec.h> |
| 22 | #include <__iterator/access.h> | |
| 23 | #include <__nullptr> | |
| 21 | #include <cstddef> | |
| 24 | 22 | #include <cstdint> |
| 25 | 23 | |
| 26 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| ... | ... | @@ -31,41 +29,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 29 | |
| 32 | 30 | #if _LIBCPP_STD_VER > 17 |
| 33 | 31 | |
| 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 | 32 | template <__formatter::__char_type _CharT> |
| 43 | class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> { | |
| 33 | struct _LIBCPP_TEMPLATE_VIS __formatter_pointer { | |
| 44 | 34 | 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)); | |
| 35 | constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; } | |
| 50 | 36 | |
| 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()); | |
| 37 | _LIBCPP_HIDE_FROM_ABI constexpr auto | |
| 38 | parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { | |
| 39 | auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer); | |
| 40 | __format_spec::__process_display_type_pointer(__parser_.__type_); | |
| 41 | return __result; | |
| 42 | } | |
| 63 | 43 | |
| 64 | return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment); | |
| 44 | _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 45 | __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx); | |
| 46 | __specs.__std_.__alternate_form_ = true; | |
| 47 | __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case; | |
| 48 | return __formatter::__format_integer(reinterpret_cast<uintptr_t>(__ptr), __ctx, __specs); | |
| 65 | 49 | } |
| 66 | }; | |
| 67 | 50 | |
| 68 | } // namespace __format_spec | |
| 51 | __format_spec::__parser<_CharT> __parser_; | |
| 52 | }; | |
| 69 | 53 | |
| 70 | 54 | // [format.formatter.spec]/2.4 |
| 71 | 55 | // For each charT, the pointer type specializations template<> |
| ... | ... | @@ -74,15 +58,13 @@ public: |
| 74 | 58 | // - template<> struct formatter<const void*, charT>; |
| 75 | 59 | template <__formatter::__char_type _CharT> |
| 76 | 60 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT> |
| 77 | : public __format_spec::__formatter_pointer<_CharT> {}; | |
| 61 | : public __formatter_pointer<_CharT> {}; | |
| 78 | 62 | template <__formatter::__char_type _CharT> |
| 79 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> | |
| 80 | : public __format_spec::__formatter_pointer<_CharT> {}; | |
| 63 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> { | |
| 64 | }; | |
| 81 | 65 | template <__formatter::__char_type _CharT> |
| 82 | 66 | 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) | |
| 67 | : public __formatter_pointer<_CharT> {}; | |
| 86 | 68 | |
| 87 | 69 | #endif //_LIBCPP_STD_VER > 17 |
| 88 | 70 |
lib/libcxx/include/__format/formatter_string.h+51-68| ... | ... | @@ -10,68 +10,49 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H |
| 11 | 11 | #define _LIBCPP___FORMAT_FORMATTER_STRING_H |
| 12 | 12 | |
| 13 | #include <__availability> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__format/format_error.h> | |
| 15 | 15 | #include <__format/format_fwd.h> |
| 16 | #include <__format/format_string.h> | |
| 16 | #include <__format/format_parse_context.h> | |
| 17 | 17 | #include <__format/formatter.h> |
| 18 | #include <__format/formatter_output.h> | |
| 18 | 19 | #include <__format/parser_std_format_spec.h> |
| 20 | #include <__utility/move.h> | |
| 21 | #include <string> | |
| 19 | 22 | #include <string_view> |
| 20 | 23 | |
| 21 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 23 | 26 | #endif |
| 24 | 27 | |
| 25 | _LIBCPP_PUSH_MACROS | |
| 26 | #include <__undef_macros> | |
| 27 | ||
| 28 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | |
| 30 | 30 | #if _LIBCPP_STD_VER > 17 |
| 31 | 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 | 32 | template <__formatter::__char_type _CharT> |
| 41 | class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> { | |
| 33 | struct _LIBCPP_TEMPLATE_VIS __formatter_string { | |
| 42 | 34 | 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); | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) | |
| 36 | -> decltype(__parse_ctx.begin()) { | |
| 37 | auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_string); | |
| 38 | __format_spec::__process_display_type_string(__parser_.__type_); | |
| 39 | return __result; | |
| 59 | 40 | } |
| 60 | }; | |
| 61 | 41 | |
| 62 | } //namespace __format_spec | |
| 42 | _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 43 | return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx)); | |
| 44 | } | |
| 63 | 45 | |
| 64 | // [format.formatter.spec]/2.2 For each charT, the string type specializations | |
| 46 | __format_spec::__parser<_CharT> __parser_; | |
| 47 | }; | |
| 65 | 48 | |
| 66 | 49 | // Formatter const char*. |
| 67 | 50 | 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>; | |
| 51 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT> | |
| 52 | : public __formatter_string<_CharT> { | |
| 53 | using _Base = __formatter_string<_CharT>; | |
| 72 | 54 | |
| 73 | _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) | |
| 74 | -> decltype(__ctx.out()) { | |
| 55 | _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 75 | 56 | _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have " |
| 76 | 57 | "prevented an invalid pointer."); |
| 77 | 58 | |
| ... | ... | @@ -86,8 +67,9 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT |
| 86 | 67 | // now these optimizations aren't implemented. Instead the base class |
| 87 | 68 | // handles these options. |
| 88 | 69 | // TODO FMT Implement these improvements. |
| 89 | if (this->__has_width_field() || this->__has_precision_field()) | |
| 90 | return _Base::format(__str, __ctx); | |
| 70 | __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx); | |
| 71 | if (__specs.__has_width() || __specs.__has_precision()) | |
| 72 | return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs); | |
| 91 | 73 | |
| 92 | 74 | // No formatting required, copy the string to the output. |
| 93 | 75 | auto __out_it = __ctx.out(); |
| ... | ... | @@ -99,40 +81,46 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT |
| 99 | 81 | |
| 100 | 82 | // Formatter char*. |
| 101 | 83 | template <__formatter::__char_type _CharT> |
| 102 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT | |
| 103 | formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> { | |
| 84 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT> | |
| 85 | : public formatter<const _CharT*, _CharT> { | |
| 104 | 86 | using _Base = formatter<const _CharT*, _CharT>; |
| 105 | 87 | |
| 106 | _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) | |
| 107 | -> decltype(__ctx.out()) { | |
| 88 | _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) { | |
| 108 | 89 | return _Base::format(__str, __ctx); |
| 109 | 90 | } |
| 110 | 91 | }; |
| 111 | 92 | |
| 93 | // Formatter char[]. | |
| 94 | template <__formatter::__char_type _CharT, size_t _Size> | |
| 95 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT> | |
| 96 | : public __formatter_string<_CharT> { | |
| 97 | using _Base = __formatter_string<_CharT>; | |
| 98 | ||
| 99 | _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) { | |
| 100 | return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); | |
| 101 | } | |
| 102 | }; | |
| 103 | ||
| 112 | 104 | // Formatter const char[]. |
| 113 | 105 | 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>; | |
| 106 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT> | |
| 107 | : public __formatter_string<_CharT> { | |
| 108 | using _Base = __formatter_string<_CharT>; | |
| 118 | 109 | |
| 119 | _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) | |
| 120 | -> decltype(__ctx.out()) { | |
| 110 | _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) { | |
| 121 | 111 | return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); |
| 122 | 112 | } |
| 123 | 113 | }; |
| 124 | 114 | |
| 125 | 115 | // Formatter std::string. |
| 126 | 116 | 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>; | |
| 117 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> | |
| 118 | : public __formatter_string<_CharT> { | |
| 119 | using _Base = __formatter_string<_CharT>; | |
| 131 | 120 | |
| 132 | _LIBCPP_HIDE_FROM_ABI auto | |
| 133 | format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) | |
| 121 | _LIBCPP_HIDE_FROM_ABI auto format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) const | |
| 134 | 122 | -> decltype(__ctx.out()) { |
| 135 | // drop _Traits and _Allocator | |
| 123 | // Drop _Traits and _Allocator to have one std::basic_string formatter. | |
| 136 | 124 | return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); |
| 137 | 125 | } |
| 138 | 126 | }; |
| ... | ... | @@ -140,23 +128,18 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT |
| 140 | 128 | // Formatter std::string_view. |
| 141 | 129 | template <__formatter::__char_type _CharT, class _Traits> |
| 142 | 130 | 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>; | |
| 131 | : public __formatter_string<_CharT> { | |
| 132 | using _Base = __formatter_string<_CharT>; | |
| 145 | 133 | |
| 146 | _LIBCPP_HIDE_FROM_ABI auto | |
| 147 | format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) | |
| 134 | _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) const | |
| 148 | 135 | -> decltype(__ctx.out()) { |
| 149 | // drop _Traits | |
| 136 | // Drop _Traits to have one std::basic_string_view formatter. | |
| 150 | 137 | return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); |
| 151 | 138 | } |
| 152 | 139 | }; |
| 153 | 140 | |
| 154 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 155 | ||
| 156 | 141 | #endif //_LIBCPP_STD_VER > 17 |
| 157 | 142 | |
| 158 | 143 | _LIBCPP_END_NAMESPACE_STD |
| 159 | 144 | |
| 160 | _LIBCPP_POP_MACROS | |
| 161 | ||
| 162 | 145 | #endif // _LIBCPP___FORMAT_FORMATTER_STRING_H |
lib/libcxx/include/__format/parser_std_format_spec.h+677-1169| ... | ... | @@ -10,21 +10,31 @@ |
| 10 | 10 | #ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H |
| 11 | 11 | #define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H |
| 12 | 12 | |
| 13 | /// \file Contains the std-format-spec parser. | |
| 14 | /// | |
| 15 | /// Most of the code can be reused in the chrono-format-spec. | |
| 16 | /// This header has some support for the chrono-format-spec since it doesn't | |
| 17 | /// affect the std-format-spec. | |
| 18 | ||
| 13 | 19 | #include <__algorithm/find_if.h> |
| 14 | 20 | #include <__algorithm/min.h> |
| 21 | #include <__assert> | |
| 15 | 22 | #include <__config> |
| 16 | 23 | #include <__debug> |
| 17 | 24 | #include <__format/format_arg.h> |
| 18 | 25 | #include <__format/format_error.h> |
| 26 | #include <__format/format_parse_context.h> | |
| 19 | 27 | #include <__format/format_string.h> |
| 28 | #include <__format/unicode.h> | |
| 20 | 29 | #include <__variant/monostate.h> |
| 21 | 30 | #include <bit> |
| 22 | 31 | #include <concepts> |
| 23 | 32 | #include <cstdint> |
| 33 | #include <string_view> | |
| 24 | 34 | #include <type_traits> |
| 25 | 35 | |
| 26 | 36 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | # pragma GCC system_header | |
| 37 | # pragma GCC system_header | |
| 28 | 38 | #endif |
| 29 | 39 | |
| 30 | 40 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -34,174 +44,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 44 | |
| 35 | 45 | #if _LIBCPP_STD_VER > 17 |
| 36 | 46 | |
| 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 | 47 | namespace __format_spec { |
| 44 | 48 | |
| 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 | 49 | template <class _CharT> |
| 206 | 50 | _LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT> |
| 207 | 51 | __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { |
| ... | ... | @@ -222,7 +66,7 @@ __parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) { |
| 222 | 66 | |
| 223 | 67 | template <class _Context> |
| 224 | 68 | _LIBCPP_HIDE_FROM_ABI constexpr uint32_t |
| 225 | __substitute_arg_id(basic_format_arg<_Context> __arg) { | |
| 69 | __substitute_arg_id(basic_format_arg<_Context> __format_arg) { | |
| 226 | 70 | return visit_format_arg( |
| 227 | 71 | [](auto __arg) -> uint32_t { |
| 228 | 72 | using _Type = decltype(__arg); |
| ... | ... | @@ -246,803 +90,638 @@ __substitute_arg_id(basic_format_arg<_Context> __arg) { |
| 246 | 90 | __throw_format_error("A format-spec arg-id replacement argument " |
| 247 | 91 | "isn't an integral type"); |
| 248 | 92 | }, |
| 249 | __arg); | |
| 93 | __format_arg); | |
| 250 | 94 | } |
| 251 | 95 | |
| 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 | } | |
| 96 | /// These fields are a filter for which elements to parse. | |
| 97 | /// | |
| 98 | /// They default to false so when a new field is added it needs to be opted in | |
| 99 | /// explicitly. | |
| 100 | struct __fields { | |
| 101 | uint8_t __sign_ : 1 {false}; | |
| 102 | uint8_t __alternate_form_ : 1 {false}; | |
| 103 | uint8_t __zero_padding_ : 1 {false}; | |
| 104 | uint8_t __precision_ : 1 {false}; | |
| 105 | uint8_t __locale_specific_form_ : 1 {false}; | |
| 106 | uint8_t __type_ : 1 {false}; | |
| 107 | }; | |
| 293 | 108 | |
| 294 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 295 | return __begin; | |
| 109 | // By not placing this constant in the formatter class it's not duplicated for | |
| 110 | // char and wchar_t. | |
| 111 | inline constexpr __fields __fields_integral{ | |
| 112 | .__sign_ = true, | |
| 113 | .__alternate_form_ = true, | |
| 114 | .__zero_padding_ = true, | |
| 115 | .__locale_specific_form_ = true, | |
| 116 | .__type_ = true}; | |
| 117 | inline constexpr __fields __fields_floating_point{ | |
| 118 | .__sign_ = true, | |
| 119 | .__alternate_form_ = true, | |
| 120 | .__zero_padding_ = true, | |
| 121 | .__precision_ = true, | |
| 122 | .__locale_specific_form_ = true, | |
| 123 | .__type_ = true}; | |
| 124 | inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true}; | |
| 125 | inline constexpr __fields __fields_pointer{.__type_ = true}; | |
| 126 | ||
| 127 | enum class _LIBCPP_ENUM_VIS __alignment : uint8_t { | |
| 128 | /// No alignment is set in the format string. | |
| 129 | __default, | |
| 130 | __left, | |
| 131 | __center, | |
| 132 | __right, | |
| 133 | __zero_padding | |
| 134 | }; | |
| 296 | 135 | |
| 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 | } | |
| 136 | enum class _LIBCPP_ENUM_VIS __sign : uint8_t { | |
| 137 | /// No sign is set in the format string. | |
| 138 | /// | |
| 139 | /// The sign isn't allowed for certain format-types. By using this value | |
| 140 | /// it's possible to detect whether or not the user explicitly set the sign | |
| 141 | /// flag. For formatting purposes it behaves the same as \ref __minus. | |
| 142 | __default, | |
| 143 | __minus, | |
| 144 | __plus, | |
| 145 | __space | |
| 146 | }; | |
| 305 | 147 | |
| 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 | } | |
| 148 | enum class _LIBCPP_ENUM_VIS __type : uint8_t { | |
| 149 | __default, | |
| 150 | __string, | |
| 151 | __binary_lower_case, | |
| 152 | __binary_upper_case, | |
| 153 | __octal, | |
| 154 | __decimal, | |
| 155 | __hexadecimal_lower_case, | |
| 156 | __hexadecimal_upper_case, | |
| 157 | __pointer, | |
| 158 | __char, | |
| 159 | __hexfloat_lower_case, | |
| 160 | __hexfloat_upper_case, | |
| 161 | __scientific_lower_case, | |
| 162 | __scientific_upper_case, | |
| 163 | __fixed_lower_case, | |
| 164 | __fixed_upper_case, | |
| 165 | __general_lower_case, | |
| 166 | __general_upper_case | |
| 318 | 167 | }; |
| 319 | 168 | |
| 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 | } | |
| 169 | struct __std { | |
| 170 | __alignment __alignment_ : 3; | |
| 171 | __sign __sign_ : 2; | |
| 172 | bool __alternate_form_ : 1; | |
| 173 | bool __locale_specific_form_ : 1; | |
| 174 | __type __type_; | |
| 175 | }; | |
| 346 | 176 | |
| 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 | } | |
| 177 | struct __chrono { | |
| 178 | __alignment __alignment_ : 3; | |
| 179 | bool __weekday_name_ : 1; | |
| 180 | bool __month_name_ : 1; | |
| 181 | }; | |
| 355 | 182 | |
| 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; | |
| 183 | /// Contains the parsed formatting specifications. | |
| 184 | /// | |
| 185 | /// This contains information for both the std-format-spec and the | |
| 186 | /// chrono-format-spec. This results in some unused members for both | |
| 187 | /// specifications. However these unused members don't increase the size | |
| 188 | /// of the structure. | |
| 189 | /// | |
| 190 | /// This struct doesn't cross ABI boundaries so its layout doesn't need to be | |
| 191 | /// kept stable. | |
| 192 | template <class _CharT> | |
| 193 | struct __parsed_specifications { | |
| 194 | union { | |
| 195 | // The field __alignment_ is the first element in __std_ and __chrono_. | |
| 196 | // This allows the code to always inspect this value regards which member | |
| 197 | // of the union is the active member [class.union.general]/2. | |
| 198 | // | |
| 199 | // This is needed since the generic output routines handle the alignment of | |
| 200 | // the output. | |
| 201 | __alignment __alignment_ : 3; | |
| 202 | __std __std_; | |
| 203 | __chrono __chrono_; | |
| 204 | }; | |
| 361 | 205 | |
| 362 | ++__begin; | |
| 363 | if (__begin == __end) | |
| 364 | __throw_format_error("End of input while parsing format-spec precision"); | |
| 206 | /// The requested width. | |
| 207 | /// | |
| 208 | /// When the format-spec used an arg-id for this field it has already been | |
| 209 | /// replaced with the value of that arg-id. | |
| 210 | int32_t __width_; | |
| 365 | 211 | |
| 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 | } | |
| 212 | /// The requested precision. | |
| 213 | /// | |
| 214 | /// When the format-spec used an arg-id for this field it has already been | |
| 215 | /// replaced with the value of that arg-id. | |
| 216 | int32_t __precision_; | |
| 375 | 217 | |
| 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 | } | |
| 218 | _CharT __fill_; | |
| 386 | 219 | |
| 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"); | |
| 220 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_width() const { return __width_ > 0; } | |
| 392 | 221 | |
| 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 | } | |
| 222 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_precision() const { return __precision_ >= 0; } | |
| 398 | 223 | }; |
| 399 | 224 | |
| 225 | // Validate the struct is small and cheap to copy since the struct is passed by | |
| 226 | // value in formatting functions. | |
| 227 | static_assert(sizeof(__parsed_specifications<char>) == 16); | |
| 228 | static_assert(is_trivially_copyable_v<__parsed_specifications<char>>); | |
| 229 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 230 | static_assert(sizeof(__parsed_specifications<wchar_t>) == 16); | |
| 231 | static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>); | |
| 232 | # endif | |
| 233 | ||
| 234 | /// The parser for the std-format-spec. | |
| 235 | /// | |
| 236 | /// Note this class is a member of std::formatter specializations. It's | |
| 237 | /// expected developers will create their own formatter specializations that | |
| 238 | /// inherit from the std::formatter specializations. This means this class | |
| 239 | /// must be ABI stable. To aid the stability the unused bits in the class are | |
| 240 | /// set to zero. That way they can be repurposed if a future revision of the | |
| 241 | /// Standards adds new fields to std-format-spec. | |
| 400 | 242 | 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 | { | |
| 243 | class _LIBCPP_TEMPLATE_VIS __parser { | |
| 519 | 244 | public: |
| 520 | using char_type = _CharT; | |
| 245 | _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields) | |
| 246 | -> decltype(__parse_ctx.begin()) { | |
| 521 | 247 | |
| 522 | _LIBCPP_HIDE_FROM_ABI constexpr __parser_string() { | |
| 523 | this->__alignment = _Flags::_Alignment::__left; | |
| 524 | } | |
| 248 | const _CharT* __begin = __parse_ctx.begin(); | |
| 249 | const _CharT* __end = __parse_ctx.end(); | |
| 250 | if (__begin == __end) | |
| 251 | return __begin; | |
| 525 | 252 | |
| 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 | } | |
| 253 | if (__parse_fill_align(__begin, __end) && __begin == __end) | |
| 254 | return __begin; | |
| 542 | 255 | |
| 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()) { | |
| 256 | if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end) | |
| 257 | return __begin; | |
| 554 | 258 | |
| 555 | auto __begin = __parse_ctx.begin(); | |
| 556 | auto __end = __parse_ctx.end(); | |
| 557 | if (__begin == __end) | |
| 259 | if (__fields.__alternate_form_ && __parse_alternate_form(__begin) && __begin == __end) | |
| 558 | 260 | return __begin; |
| 559 | 261 | |
| 560 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, | |
| 561 | static_cast<_Flags&>(*this)); | |
| 562 | if (__begin == __end) | |
| 262 | if (__fields.__zero_padding_ && __parse_zero_padding(__begin) && __begin == __end) | |
| 563 | 263 | return __begin; |
| 564 | 264 | |
| 565 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 566 | if (__begin == __end) | |
| 265 | if (__parse_width(__begin, __end, __parse_ctx) && __begin == __end) | |
| 567 | 266 | return __begin; |
| 568 | 267 | |
| 569 | __begin = __parser_precision::__parse(__begin, __end, __parse_ctx); | |
| 570 | if (__begin == __end) | |
| 268 | if (__fields.__precision_ && __parse_precision(__begin, __end, __parse_ctx) && __begin == __end) | |
| 269 | return __begin; | |
| 270 | ||
| 271 | if (__fields.__locale_specific_form_ && __parse_locale_specific_form(__begin) && __begin == __end) | |
| 571 | 272 | return __begin; |
| 572 | 273 | |
| 573 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 274 | if (__fields.__type_) { | |
| 275 | __parse_type(__begin); | |
| 574 | 276 | |
| 575 | if (__begin != __end && *__begin != _CharT('}')) | |
| 576 | __throw_format_error( | |
| 577 | "The format-spec should consume the input or end with a '}'"); | |
| 277 | // When __type_ is false the calling parser is expected to do additional | |
| 278 | // parsing. In that case that parser should do the end of format string | |
| 279 | // validation. | |
| 280 | if (__begin != __end && *__begin != _CharT('}')) | |
| 281 | __throw_format_error("The format-spec should consume the input or end with a '}'"); | |
| 282 | } | |
| 578 | 283 | |
| 579 | 284 | return __begin; |
| 580 | 285 | } |
| 581 | 286 | |
| 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; | |
| 287 | /// \returns the `__parsed_specifications` with the resolved dynamic sizes.. | |
| 288 | _LIBCPP_HIDE_FROM_ABI | |
| 289 | __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const { | |
| 290 | return __parsed_specifications<_CharT>{ | |
| 291 | .__std_ = | |
| 292 | __std{.__alignment_ = __alignment_, | |
| 293 | .__sign_ = __sign_, | |
| 294 | .__alternate_form_ = __alternate_form_, | |
| 295 | .__locale_specific_form_ = __locale_specific_form_, | |
| 296 | .__type_ = __type_}, | |
| 297 | .__width_{__get_width(__ctx)}, | |
| 298 | .__precision_{__get_precision(__ctx)}, | |
| 299 | .__fill_{__fill_}}; | |
| 300 | } | |
| 301 | ||
| 302 | __alignment __alignment_ : 3 {__alignment::__default}; | |
| 303 | __sign __sign_ : 2 {__sign::__default}; | |
| 304 | bool __alternate_form_ : 1 {false}; | |
| 305 | bool __locale_specific_form_ : 1 {false}; | |
| 306 | bool __reserved_0_ : 1 {false}; | |
| 307 | __type __type_{__type::__default}; | |
| 308 | ||
| 309 | // These two flags are used for formatting chrono. Since the struct has | |
| 310 | // padding space left it's added to this structure. | |
| 311 | bool __weekday_name_ : 1 {false}; | |
| 312 | bool __month_name_ : 1 {false}; | |
| 313 | ||
| 314 | uint8_t __reserved_1_ : 6 {0}; | |
| 315 | uint8_t __reserved_2_ : 6 {0}; | |
| 316 | // These two flags are only used internally and not part of the | |
| 317 | // __parsed_specifications. Therefore put them at the end. | |
| 318 | bool __width_as_arg_ : 1 {false}; | |
| 319 | bool __precision_as_arg_ : 1 {false}; | |
| 320 | ||
| 321 | /// The requested width, either the value or the arg-id. | |
| 322 | int32_t __width_{0}; | |
| 323 | ||
| 324 | /// The requested precision, either the value or the arg-id. | |
| 325 | int32_t __precision_{-1}; | |
| 326 | ||
| 327 | // LWG 3576 will probably change this to always accept a Unicode code point | |
| 328 | // To avoid changing the size with that change align the field so when it | |
| 329 | // becomes 32-bit its alignment will remain the same. That also means the | |
| 330 | // size will remain the same. (D2572 addresses the solution for LWG 3576.) | |
| 331 | _CharT __fill_{_CharT(' ')}; | |
| 588 | 332 | |
| 589 | default: | |
| 590 | __throw_format_error("The format-spec type has a type not supported for " | |
| 591 | "a string argument"); | |
| 333 | private: | |
| 334 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alignment(_CharT __c) { | |
| 335 | switch (__c) { | |
| 336 | case _CharT('<'): | |
| 337 | __alignment_ = __alignment::__left; | |
| 338 | return true; | |
| 339 | ||
| 340 | case _CharT('^'): | |
| 341 | __alignment_ = __alignment::__center; | |
| 342 | return true; | |
| 343 | ||
| 344 | case _CharT('>'): | |
| 345 | __alignment_ = __alignment::__right; | |
| 346 | return true; | |
| 592 | 347 | } |
| 348 | return false; | |
| 593 | 349 | } |
| 594 | }; | |
| 595 | ||
| 596 | /** | |
| 597 | * The parser for the std-format-spec. | |
| 598 | * | |
| 599 | * This implements the parser for the integral types. This includes the | |
| 600 | * character type and boolean type. | |
| 601 | * | |
| 602 | * See @ref __parser_string. | |
| 603 | */ | |
| 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 | 350 | |
| 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; | |
| 351 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) { | |
| 352 | _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause " | |
| 353 | "undefined behavior by evaluating data not in the input"); | |
| 354 | if (__begin + 1 != __end) { | |
| 355 | if (__parse_alignment(*(__begin + 1))) { | |
| 356 | if (*__begin == _CharT('{') || *__begin == _CharT('}')) | |
| 357 | __throw_format_error("The format-spec fill field contains an invalid character"); | |
| 643 | 358 | |
| 644 | __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this)); | |
| 645 | if (__begin == __end) | |
| 646 | return __begin; | |
| 359 | __fill_ = *__begin; | |
| 360 | __begin += 2; | |
| 361 | return true; | |
| 362 | } | |
| 363 | } | |
| 647 | 364 | |
| 648 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 649 | if (__begin == __end) | |
| 650 | return __begin; | |
| 365 | if (!__parse_alignment(*__begin)) | |
| 366 | return false; | |
| 651 | 367 | |
| 652 | __begin = | |
| 653 | __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this)); | |
| 654 | if (__begin == __end) | |
| 655 | return __begin; | |
| 368 | ++__begin; | |
| 369 | return true; | |
| 370 | } | |
| 656 | 371 | |
| 657 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 372 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(const _CharT*& __begin) { | |
| 373 | switch (*__begin) { | |
| 374 | case _CharT('-'): | |
| 375 | __sign_ = __sign::__minus; | |
| 376 | break; | |
| 377 | case _CharT('+'): | |
| 378 | __sign_ = __sign::__plus; | |
| 379 | break; | |
| 380 | case _CharT(' '): | |
| 381 | __sign_ = __sign::__space; | |
| 382 | break; | |
| 383 | default: | |
| 384 | return false; | |
| 385 | } | |
| 386 | ++__begin; | |
| 387 | return true; | |
| 388 | } | |
| 658 | 389 | |
| 659 | if (__begin != __end && *__begin != _CharT('}')) | |
| 660 | __throw_format_error( | |
| 661 | "The format-spec should consume the input or end with a '}'"); | |
| 390 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alternate_form(const _CharT*& __begin) { | |
| 391 | if (*__begin != _CharT('#')) | |
| 392 | return false; | |
| 662 | 393 | |
| 663 | return __begin; | |
| 394 | __alternate_form_ = true; | |
| 395 | ++__begin; | |
| 396 | return true; | |
| 664 | 397 | } |
| 665 | 398 | |
| 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 | } | |
| 399 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_zero_padding(const _CharT*& __begin) { | |
| 400 | if (*__begin != _CharT('0')) | |
| 401 | return false; | |
| 670 | 402 | |
| 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; | |
| 403 | if (__alignment_ == __alignment::__default) | |
| 404 | __alignment_ = __alignment::__zero_padding; | |
| 405 | ++__begin; | |
| 406 | return true; | |
| 702 | 407 | } |
| 703 | }; | |
| 704 | 408 | |
| 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; | |
| 409 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) { | |
| 410 | if (*__begin == _CharT('0')) | |
| 411 | __throw_format_error("A format-spec width field shouldn't have a leading zero"); | |
| 756 | 412 | |
| 757 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, | |
| 758 | static_cast<_Flags&>(*this)); | |
| 759 | if (__begin == __end) | |
| 760 | return __begin; | |
| 413 | if (*__begin == _CharT('{')) { | |
| 414 | __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); | |
| 415 | __width_as_arg_ = true; | |
| 416 | __width_ = __r.__value; | |
| 417 | __begin = __r.__ptr; | |
| 418 | return true; | |
| 419 | } | |
| 761 | 420 | |
| 762 | __begin = __parse_sign(__begin, static_cast<_Flags&>(*this)); | |
| 763 | if (__begin == __end) | |
| 764 | return __begin; | |
| 421 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 422 | return false; | |
| 765 | 423 | |
| 766 | __begin = __parse_alternate_form(__begin, static_cast<_Flags&>(*this)); | |
| 767 | if (__begin == __end) | |
| 768 | return __begin; | |
| 424 | __format::__parse_number_result __r = __format::__parse_number(__begin, __end); | |
| 425 | __width_ = __r.__value; | |
| 426 | _LIBCPP_ASSERT(__width_ != 0, "A zero value isn't allowed and should be impossible, " | |
| 427 | "due to validations in this function"); | |
| 428 | __begin = __r.__ptr; | |
| 429 | return true; | |
| 430 | } | |
| 769 | 431 | |
| 770 | __begin = __parse_zero_padding(__begin, static_cast<_Flags&>(*this)); | |
| 771 | if (__begin == __end) | |
| 772 | return __begin; | |
| 432 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(const _CharT*& __begin, const _CharT* __end, | |
| 433 | auto& __parse_ctx) { | |
| 434 | if (*__begin != _CharT('.')) | |
| 435 | return false; | |
| 773 | 436 | |
| 774 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 437 | ++__begin; | |
| 775 | 438 | if (__begin == __end) |
| 776 | return __begin; | |
| 439 | __throw_format_error("End of input while parsing format-spec precision"); | |
| 777 | 440 | |
| 778 | __begin = __parser_precision::__parse(__begin, __end, __parse_ctx); | |
| 779 | if (__begin == __end) | |
| 780 | return __begin; | |
| 441 | if (*__begin == _CharT('{')) { | |
| 442 | __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); | |
| 443 | __precision_as_arg_ = true; | |
| 444 | __precision_ = __arg_id.__value; | |
| 445 | __begin = __arg_id.__ptr; | |
| 446 | return true; | |
| 447 | } | |
| 781 | 448 | |
| 782 | __begin = | |
| 783 | __parse_locale_specific_form(__begin, static_cast<_Flags&>(*this)); | |
| 784 | if (__begin == __end) | |
| 785 | return __begin; | |
| 449 | if (*__begin < _CharT('0') || *__begin > _CharT('9')) | |
| 450 | __throw_format_error("The format-spec precision field doesn't contain a value or arg-id"); | |
| 786 | 451 | |
| 787 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 452 | __format::__parse_number_result __r = __format::__parse_number(__begin, __end); | |
| 453 | __precision_ = __r.__value; | |
| 454 | __precision_as_arg_ = false; | |
| 455 | __begin = __r.__ptr; | |
| 456 | return true; | |
| 457 | } | |
| 788 | 458 | |
| 789 | if (__begin != __end && *__begin != _CharT('}')) | |
| 790 | __throw_format_error( | |
| 791 | "The format-spec should consume the input or end with a '}'"); | |
| 459 | _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_locale_specific_form(const _CharT*& __begin) { | |
| 460 | if (*__begin != _CharT('L')) | |
| 461 | return false; | |
| 792 | 462 | |
| 793 | return __begin; | |
| 463 | __locale_specific_form_ = true; | |
| 464 | ++__begin; | |
| 465 | return true; | |
| 794 | 466 | } |
| 795 | 467 | |
| 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; | |
| 468 | _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin) { | |
| 469 | // Determines the type. It does not validate whether the selected type is | |
| 470 | // valid. Most formatters have optional fields that are only allowed for | |
| 471 | // certain types. These parsers need to do validation after the type has | |
| 472 | // been parsed. So its easier to implement the validation for all types in | |
| 473 | // the specific parse function. | |
| 474 | switch (*__begin) { | |
| 475 | case 'A': | |
| 476 | __type_ = __type::__hexfloat_upper_case; | |
| 804 | 477 | 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. | |
| 478 | case 'B': | |
| 479 | __type_ = __type::__binary_upper_case; | |
| 808 | 480 | 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 | } | |
| 481 | case 'E': | |
| 482 | __type_ = __type::__scientific_upper_case; | |
| 483 | break; | |
| 484 | case 'F': | |
| 485 | __type_ = __type::__fixed_upper_case; | |
| 486 | break; | |
| 487 | case 'G': | |
| 488 | __type_ = __type::__general_upper_case; | |
| 489 | break; | |
| 490 | case 'X': | |
| 491 | __type_ = __type::__hexadecimal_upper_case; | |
| 492 | break; | |
| 493 | case 'a': | |
| 494 | __type_ = __type::__hexfloat_lower_case; | |
| 495 | break; | |
| 496 | case 'b': | |
| 497 | __type_ = __type::__binary_lower_case; | |
| 498 | break; | |
| 499 | case 'c': | |
| 500 | __type_ = __type::__char; | |
| 501 | break; | |
| 502 | case 'd': | |
| 503 | __type_ = __type::__decimal; | |
| 504 | break; | |
| 505 | case 'e': | |
| 506 | __type_ = __type::__scientific_lower_case; | |
| 507 | break; | |
| 508 | case 'f': | |
| 509 | __type_ = __type::__fixed_lower_case; | |
| 510 | break; | |
| 511 | case 'g': | |
| 512 | __type_ = __type::__general_lower_case; | |
| 513 | break; | |
| 514 | case 'o': | |
| 515 | __type_ = __type::__octal; | |
| 516 | break; | |
| 517 | case 'p': | |
| 518 | __type_ = __type::__pointer; | |
| 519 | break; | |
| 520 | case 's': | |
| 521 | __type_ = __type::__string; | |
| 522 | break; | |
| 523 | case 'x': | |
| 524 | __type_ = __type::__hexadecimal_lower_case; | |
| 820 | 525 | break; |
| 821 | ||
| 822 | 526 | default: |
| 823 | __throw_format_error("The format-spec type has a type not supported for " | |
| 824 | "a floating-point argument"); | |
| 527 | return; | |
| 825 | 528 | } |
| 529 | ++__begin; | |
| 826 | 530 | } |
| 827 | }; | |
| 828 | 531 | |
| 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; | |
| 532 | _LIBCPP_HIDE_FROM_ABI | |
| 533 | int32_t __get_width(auto& __ctx) const { | |
| 534 | if (!__width_as_arg_) | |
| 535 | return __width_; | |
| 843 | 536 | |
| 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; | |
| 537 | int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_)); | |
| 538 | if (__result == 0) | |
| 539 | __throw_format_error("A format-spec width field replacement should have a positive value"); | |
| 540 | return __result; | |
| 851 | 541 | } |
| 852 | 542 | |
| 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; | |
| 543 | _LIBCPP_HIDE_FROM_ABI | |
| 544 | int32_t __get_precision(auto& __ctx) const { | |
| 545 | if (!__precision_as_arg_) | |
| 546 | return __precision_; | |
| 547 | ||
| 548 | return __format_spec::__substitute_arg_id(__ctx.arg(__precision_)); | |
| 867 | 549 | } |
| 550 | }; | |
| 868 | 551 | |
| 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; | |
| 552 | // Validates whether the reserved bitfields don't change the size. | |
| 553 | static_assert(sizeof(__parser<char>) == 16); | |
| 554 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 555 | static_assert(sizeof(__parser<wchar_t>) == 16); | |
| 556 | # endif | |
| 885 | 557 | |
| 886 | __begin = __parser_fill_align<_CharT>::__parse(__begin, __end, static_cast<_Flags&>(*this)); | |
| 887 | if (__begin == __end) | |
| 888 | return __begin; | |
| 558 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec::__type __type) { | |
| 559 | switch (__type) { | |
| 560 | case __format_spec::__type::__default: | |
| 561 | case __format_spec::__type::__string: | |
| 562 | break; | |
| 889 | 563 | |
| 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. | |
| 564 | default: | |
| 565 | std::__throw_format_error("The format-spec type has a type not supported for a string argument"); | |
| 566 | } | |
| 567 | } | |
| 905 | 568 | |
| 906 | __begin = __parser_width::__parse(__begin, __end, __parse_ctx); | |
| 907 | if (__begin == __end) | |
| 908 | return __begin; | |
| 569 | template <class _CharT> | |
| 570 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_bool_string(__parser<_CharT>& __parser) { | |
| 571 | if (__parser.__sign_ != __sign::__default) | |
| 572 | std::__throw_format_error("A sign field isn't allowed in this format-spec"); | |
| 909 | 573 | |
| 910 | __begin = __parse_type(__begin, static_cast<_Flags&>(*this)); | |
| 574 | if (__parser.__alternate_form_) | |
| 575 | std::__throw_format_error("An alternate form field isn't allowed in this format-spec"); | |
| 911 | 576 | |
| 912 | if (__begin != __end && *__begin != _CharT('}')) | |
| 913 | __throw_format_error("The format-spec should consume the input or end with a '}'"); | |
| 577 | if (__parser.__alignment_ == __alignment::__zero_padding) | |
| 578 | std::__throw_format_error("A zero-padding field isn't allowed in this format-spec"); | |
| 914 | 579 | |
| 915 | return __begin; | |
| 916 | } | |
| 580 | if (__parser.__alignment_ == __alignment::__default) | |
| 581 | __parser.__alignment_ = __alignment::__left; | |
| 582 | } | |
| 917 | 583 | |
| 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 | }; | |
| 584 | template <class _CharT> | |
| 585 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_char(__parser<_CharT>& __parser) { | |
| 586 | __format_spec::__process_display_type_bool_string(__parser); | |
| 587 | } | |
| 931 | 588 | |
| 932 | /** Helper struct returned from @ref __get_string_alignment. */ | |
| 933 | 589 | 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 | }; | |
| 590 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_bool(__parser<_CharT>& __parser) { | |
| 591 | switch (__parser.__type_) { | |
| 592 | case __format_spec::__type::__default: | |
| 593 | case __format_spec::__type::__string: | |
| 594 | __format_spec::__process_display_type_bool_string(__parser); | |
| 595 | break; | |
| 966 | 596 | |
| 967 | #ifndef _LIBCPP_HAS_NO_UNICODE | |
| 968 | namespace __detail { | |
| 597 | case __format_spec::__type::__binary_lower_case: | |
| 598 | case __format_spec::__type::__binary_upper_case: | |
| 599 | case __format_spec::__type::__octal: | |
| 600 | case __format_spec::__type::__decimal: | |
| 601 | case __format_spec::__type::__hexadecimal_lower_case: | |
| 602 | case __format_spec::__type::__hexadecimal_upper_case: | |
| 603 | break; | |
| 604 | ||
| 605 | default: | |
| 606 | std::__throw_format_error("The format-spec type has a type not supported for a bool argument"); | |
| 607 | } | |
| 608 | } | |
| 969 | 609 | |
| 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 | 610 | template <class _CharT> |
| 1021 | concept __utf8_character = same_as<_CharT, char> || same_as<_CharT, char8_t>; | |
| 611 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __parser) { | |
| 612 | switch (__parser.__type_) { | |
| 613 | case __format_spec::__type::__default: | |
| 614 | case __format_spec::__type::__char: | |
| 615 | __format_spec::__process_display_type_char(__parser); | |
| 616 | break; | |
| 617 | ||
| 618 | case __format_spec::__type::__binary_lower_case: | |
| 619 | case __format_spec::__type::__binary_upper_case: | |
| 620 | case __format_spec::__type::__octal: | |
| 621 | case __format_spec::__type::__decimal: | |
| 622 | case __format_spec::__type::__hexadecimal_lower_case: | |
| 623 | case __format_spec::__type::__hexadecimal_upper_case: | |
| 624 | break; | |
| 625 | ||
| 626 | default: | |
| 627 | std::__throw_format_error("The format-spec type has a type not supported for a char argument"); | |
| 628 | } | |
| 629 | } | |
| 1022 | 630 | |
| 1023 | /** Helper concept for an UTF-16 character type. */ | |
| 1024 | 631 | template <class _CharT> |
| 1025 | concept __utf16_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2) || same_as<_CharT, char16_t>; | |
| 632 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_integer(__parser<_CharT>& __parser) { | |
| 633 | switch (__parser.__type_) { | |
| 634 | case __format_spec::__type::__default: | |
| 635 | case __format_spec::__type::__binary_lower_case: | |
| 636 | case __format_spec::__type::__binary_upper_case: | |
| 637 | case __format_spec::__type::__octal: | |
| 638 | case __format_spec::__type::__decimal: | |
| 639 | case __format_spec::__type::__hexadecimal_lower_case: | |
| 640 | case __format_spec::__type::__hexadecimal_upper_case: | |
| 641 | break; | |
| 642 | ||
| 643 | case __format_spec::__type::__char: | |
| 644 | __format_spec::__process_display_type_char(__parser); | |
| 645 | break; | |
| 646 | ||
| 647 | default: | |
| 648 | std::__throw_format_error("The format-spec type has a type not supported for an integer argument"); | |
| 649 | } | |
| 650 | } | |
| 1026 | 651 | |
| 1027 | /** Helper concept for an UTF-32 character type. */ | |
| 1028 | 652 | template <class _CharT> |
| 1029 | concept __utf32_character = (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4) || same_as<_CharT, char32_t>; | |
| 653 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) { | |
| 654 | switch (__parser.__type_) { | |
| 655 | case __format_spec::__type::__default: | |
| 656 | // When no precision specified then it keeps default since that | |
| 657 | // formatting differs from the other types. | |
| 658 | if (__parser.__precision_as_arg_ || __parser.__precision_ != -1) | |
| 659 | __parser.__type_ = __format_spec::__type::__general_lower_case; | |
| 660 | break; | |
| 661 | case __format_spec::__type::__hexfloat_lower_case: | |
| 662 | case __format_spec::__type::__hexfloat_upper_case: | |
| 663 | // Precision specific behavior will be handled later. | |
| 664 | break; | |
| 665 | case __format_spec::__type::__scientific_lower_case: | |
| 666 | case __format_spec::__type::__scientific_upper_case: | |
| 667 | case __format_spec::__type::__fixed_lower_case: | |
| 668 | case __format_spec::__type::__fixed_upper_case: | |
| 669 | case __format_spec::__type::__general_lower_case: | |
| 670 | case __format_spec::__type::__general_upper_case: | |
| 671 | if (!__parser.__precision_as_arg_ && __parser.__precision_ == -1) | |
| 672 | // Set the default precision for the call to to_chars. | |
| 673 | __parser.__precision_ = 6; | |
| 674 | break; | |
| 675 | ||
| 676 | default: | |
| 677 | std::__throw_format_error("The format-spec type has a type not supported for a floating-point argument"); | |
| 678 | } | |
| 679 | } | |
| 680 | ||
| 681 | _LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_pointer(__format_spec::__type __type) { | |
| 682 | switch (__type) { | |
| 683 | case __format_spec::__type::__default: | |
| 684 | case __format_spec::__type::__pointer: | |
| 685 | break; | |
| 686 | ||
| 687 | default: | |
| 688 | std::__throw_format_error("The format-spec type has a type not supported for a pointer argument"); | |
| 689 | } | |
| 690 | } | |
| 1030 | 691 | |
| 1031 | /** Helper concept for an UTF-16 or UTF-32 character type. */ | |
| 1032 | 692 | 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"); | |
| 693 | struct __column_width_result { | |
| 694 | /// The number of output columns. | |
| 695 | size_t __width_; | |
| 696 | /// One beyond the last code unit used in the estimation. | |
| 697 | /// | |
| 698 | /// This limits the original output to fit in the wanted number of columns. | |
| 699 | const _CharT* __last_; | |
| 700 | }; | |
| 701 | ||
| 702 | /// Since a column width can be two it's possible that the requested column | |
| 703 | /// width can't be achieved. Depending on the intended usage the policy can be | |
| 704 | /// selected. | |
| 705 | /// - When used as precision the maximum width may not be exceeded and the | |
| 706 | /// result should be "rounded down" to the previous boundary. | |
| 707 | /// - When used as a width we're done once the minimum is reached, but | |
| 708 | /// exceeding is not an issue. Rounding down is an issue since that will | |
| 709 | /// result in writing fill characters. Therefore the result needs to be | |
| 710 | /// "rounded up". | |
| 711 | enum class __column_width_rounding { __down, __up }; | |
| 712 | ||
| 713 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 714 | ||
| 715 | namespace __detail { | |
| 716 | ||
| 717 | /// Converts a code point to the column width. | |
| 718 | /// | |
| 719 | /// The estimations are conforming to [format.string.general]/11 | |
| 720 | /// | |
| 721 | /// This version expects a value less than 0x1'0000, which is a 3-byte UTF-8 | |
| 722 | /// character. | |
| 723 | _LIBCPP_HIDE_FROM_ABI constexpr int __column_width_3(uint32_t __c) noexcept { | |
| 724 | _LIBCPP_ASSERT(__c < 0x10000, "Use __column_width_4 or __column_width for larger values"); | |
| 1046 | 725 | |
| 1047 | 726 | // clang-format off |
| 1048 | 727 | return 1 + (__c >= 0x1100 && (__c <= 0x115f || |
| ... | ... | @@ -1059,15 +738,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_3(uint32_t __c) noexce |
| 1059 | 738 | // clang-format on |
| 1060 | 739 | } |
| 1061 | 740 | |
| 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"); | |
| 741 | /// @overload | |
| 742 | /// | |
| 743 | /// This version expects a value greater than or equal to 0x1'0000, which is a | |
| 744 | /// 4-byte UTF-8 character. | |
| 745 | _LIBCPP_HIDE_FROM_ABI constexpr int __column_width_4(uint32_t __c) noexcept { | |
| 746 | _LIBCPP_ASSERT(__c >= 0x10000, "Use __column_width_3 or __column_width for smaller values"); | |
| 1071 | 747 | |
| 1072 | 748 | // clang-format off |
| 1073 | 749 | return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f || |
| ... | ... | @@ -1078,316 +754,148 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr int __column_width_4(uint32_t __c) noexce |
| 1078 | 754 | // clang-format on |
| 1079 | 755 | } |
| 1080 | 756 | |
| 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); | |
| 757 | /// @overload | |
| 758 | /// | |
| 759 | /// The general case, accepting all values. | |
| 760 | _LIBCPP_HIDE_FROM_ABI constexpr int __column_width(uint32_t __c) noexcept { | |
| 761 | if (__c < 0x10000) | |
| 762 | return __detail::__column_width_3(__c); | |
| 1089 | 763 | |
| 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; }); | |
| 764 | return __detail::__column_width_4(__c); | |
| 1115 | 765 | } |
| 1116 | 766 | |
| 1117 | 767 | 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 | } | |
| 768 | _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width_grapheme_clustering( | |
| 769 | const _CharT* __first, const _CharT* __last, size_t __maximum, __column_width_rounding __rounding) noexcept { | |
| 770 | __unicode::__extended_grapheme_cluster_view<_CharT> __view{__first, __last}; | |
| 1144 | 771 | |
| 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; | |
| 772 | __column_width_result<_CharT> __result{0, __first}; | |
| 773 | while (__result.__last_ != __last && __result.__width_ <= __maximum) { | |
| 774 | typename __unicode::__extended_grapheme_cluster_view<_CharT>::__cluster __cluster = __view.__consume(); | |
| 775 | int __width = __detail::__column_width(__cluster.__code_point_); | |
| 1173 | 776 | |
| 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; | |
| 777 | // When the next entry would exceed the maximum width the previous width | |
| 778 | // might be returned. For example when a width of 100 is requested the | |
| 779 | // returned width might be 99, since the next code point has an estimated | |
| 780 | // column width of 2. This depends on the rounding flag. | |
| 781 | // When the maximum is exceeded the loop will abort the next iteration. | |
| 782 | if (__rounding == __column_width_rounding::__down && __result.__width_ + __width > __maximum) | |
| 783 | return __result; | |
| 1182 | 784 | |
| 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}; | |
| 785 | __result.__width_ += __width; | |
| 786 | __result.__last_ = __cluster.__last_; | |
| 1225 | 787 | } |
| 1226 | return {__result, __first}; | |
| 1227 | } | |
| 1228 | 788 | |
| 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}; | |
| 789 | return __result; | |
| 1286 | 790 | } |
| 1287 | 791 | |
| 1288 | 792 | } // namespace __detail |
| 1289 | 793 | |
| 794 | // Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32. | |
| 795 | // Depending on format the relation between the number of code units stored and | |
| 796 | // the number of output columns differs. The first relation is the number of | |
| 797 | // code units forming a code point. (The text assumes the code units are | |
| 798 | // unsigned.) | |
| 799 | // - UTF-8 The number of code units is between one and four. The first 127 | |
| 800 | // Unicode code points match the ASCII character set. When the highest bit is | |
| 801 | // set it means the code point has more than one code unit. | |
| 802 | // - UTF-16: The number of code units is between 1 and 2. When the first | |
| 803 | // code unit is in the range [0xd800,0xdfff) it means the code point uses two | |
| 804 | // code units. | |
| 805 | // - UTF-32: The number of code units is always one. | |
| 806 | // | |
| 807 | // The code point to the number of columns is specified in | |
| 808 | // [format.string.std]/11. This list might change in the future. | |
| 809 | // | |
| 810 | // Another thing to be taken into account is Grapheme clustering. This means | |
| 811 | // that in some cases multiple code points are combined one element in the | |
| 812 | // output. For example: | |
| 813 | // - an ASCII character with a combined diacritical mark | |
| 814 | // - an emoji with a skin tone modifier | |
| 815 | // - a group of combined people emoji to create a family | |
| 816 | // - a combination of flag emoji | |
| 817 | // | |
| 818 | // See also: | |
| 819 | // - [format.string.general]/11 | |
| 820 | // - https://en.wikipedia.org/wiki/UTF-8#Encoding | |
| 821 | // - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF | |
| 822 | ||
| 823 | _LIBCPP_HIDE_FROM_ABI constexpr bool __is_ascii(char32_t __c) { return __c < 0x80; } | |
| 824 | ||
| 825 | /// Determines the number of output columns needed to render the input. | |
| 826 | /// | |
| 827 | /// \note When the scanner encounters malformed Unicode it acts as-if every | |
| 828 | /// code unit is a one column code point. Typically a terminal uses the same | |
| 829 | /// strategy and replaces every malformed code unit with a one column | |
| 830 | /// replacement character. | |
| 831 | /// | |
| 832 | /// \param __first Points to the first element of the input range. | |
| 833 | /// \param __last Points beyond the last element of the input range. | |
| 834 | /// \param __maximum The maximum number of output columns. The returned number | |
| 835 | /// of estimated output columns will not exceed this value. | |
| 836 | /// \param __rounding Selects the rounding method. | |
| 837 | /// \c __down result.__width_ <= __maximum | |
| 838 | /// \c __up result.__width_ <= __maximum + 1 | |
| 1290 | 839 | 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}; | |
| 840 | _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width( | |
| 841 | basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding __rounding) noexcept { | |
| 842 | // The width estimation is done in two steps: | |
| 843 | // - Quickly process for the ASCII part. ASCII has the following properties | |
| 844 | // - One code unit is one code point | |
| 845 | // - Every code point has an estimated width of one | |
| 846 | // - When needed it will a Unicode Grapheme clustering algorithm to find | |
| 847 | // the proper place for truncation. | |
| 848 | ||
| 849 | if (__str.empty() || __maximum == 0) | |
| 850 | return {0, __str.begin()}; | |
| 851 | ||
| 852 | // ASCII has one caveat; when an ASCII character is followed by a non-ASCII | |
| 853 | // character they might be part of an extended grapheme cluster. For example: | |
| 854 | // an ASCII letter and a COMBINING ACUTE ACCENT | |
| 855 | // The truncate should happen after the COMBINING ACUTE ACCENT. Therefore we | |
| 856 | // need to scan one code unit beyond the requested precision. When this code | |
| 857 | // unit is non-ASCII we omit the current code unit and let the Grapheme | |
| 858 | // clustering algorithm do its work. | |
| 859 | const _CharT* __it = __str.begin(); | |
| 860 | if (__is_ascii(*__it)) { | |
| 861 | do { | |
| 862 | --__maximum; | |
| 863 | ++__it; | |
| 864 | if (__it == __str.end()) | |
| 865 | return {__str.size(), __str.end()}; | |
| 866 | ||
| 867 | if (__maximum == 0) { | |
| 868 | if (__is_ascii(*__it)) | |
| 869 | return {static_cast<size_t>(__it - __str.begin()), __it}; | |
| 870 | ||
| 871 | break; | |
| 872 | } | |
| 873 | } while (__is_ascii(*__it)); | |
| 874 | --__it; | |
| 875 | ++__maximum; | |
| 1344 | 876 | } |
| 1345 | 877 | |
| 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 | } | |
| 878 | ptrdiff_t __ascii_size = __it - __str.begin(); | |
| 879 | __column_width_result __result = | |
| 880 | __detail::__estimate_column_width_grapheme_clustering(__it, __str.end(), __maximum, __rounding); | |
| 1370 | 881 | |
| 1371 | __size = __lengh_info.__width + __prefix; | |
| 1372 | return {__last, __size, __size < __width}; | |
| 882 | __result.__width_ += __ascii_size; | |
| 883 | return __result; | |
| 1373 | 884 | } |
| 1374 | #else // _LIBCPP_HAS_NO_UNICODE | |
| 885 | # else // !defined(_LIBCPP_HAS_NO_UNICODE) | |
| 1375 | 886 | 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}; | |
| 887 | _LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> | |
| 888 | __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept { | |
| 889 | // When Unicode isn't supported assume ASCII and every code unit is one code | |
| 890 | // point. In ASCII the estimated column width is always one. Thus there's no | |
| 891 | // need for rounding. | |
| 892 | size_t __width_ = _VSTD::min(__str.size(), __maximum); | |
| 893 | return {__width_, __str.begin() + __width_}; | |
| 1385 | 894 | } |
| 1386 | #endif // _LIBCPP_HAS_NO_UNICODE | |
| 1387 | 895 | |
| 1388 | } // namespace __format_spec | |
| 896 | # endif // !defined(_LIBCPP_HAS_NO_UNICODE) | |
| 1389 | 897 | |
| 1390 | # endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 898 | } // namespace __format_spec | |
| 1391 | 899 | |
| 1392 | 900 | #endif //_LIBCPP_STD_VER > 17 |
| 1393 | 901 |
lib/libcxx/include/__format/unicode.h created+339| ... | ... | @@ -0,0 +1,339 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___FORMAT_UNICODE_H | |
| 11 | #define _LIBCPP___FORMAT_UNICODE_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__config> | |
| 15 | #include <__format/extended_grapheme_cluster_table.h> | |
| 16 | #include <__utility/unreachable.h> | |
| 17 | #include <bit> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | ||
| 27 | # ifndef _LIBCPP_HAS_NO_UNICODE | |
| 28 | ||
| 29 | /// Implements the grapheme cluster boundary rules | |
| 30 | /// | |
| 31 | /// These rules are used to implement format's width estimation as stated in | |
| 32 | /// [format.string.std]/11 | |
| 33 | /// | |
| 34 | /// The Standard refers to UAX \#29 for Unicode 12.0.0 | |
| 35 | /// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules | |
| 36 | /// | |
| 37 | /// The data tables used are | |
| 38 | /// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt | |
| 39 | /// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt | |
| 40 | /// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only) | |
| 41 | ||
| 42 | namespace __unicode { | |
| 43 | ||
| 44 | inline constexpr char32_t __replacement_character = U'\ufffd'; | |
| 45 | ||
| 46 | _LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) { | |
| 47 | do { | |
| 48 | if ((*__char & 0b1000'0000) != 0b1000'0000) | |
| 49 | return false; | |
| 50 | --__count; | |
| 51 | ++__char; | |
| 52 | } while (__count); | |
| 53 | return true; | |
| 54 | } | |
| 55 | ||
| 56 | /// Helper class to extract a code unit from a Unicode character range. | |
| 57 | /// | |
| 58 | /// The stored range is a view. There are multiple specialization for different | |
| 59 | /// character types. | |
| 60 | template <class _CharT> | |
| 61 | class __code_point_view; | |
| 62 | ||
| 63 | /// UTF-8 specialization. | |
| 64 | template <> | |
| 65 | class __code_point_view<char> { | |
| 66 | public: | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const char* __first, const char* __last) | |
| 68 | : __first_(__first), __last_(__last) {} | |
| 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; } | |
| 71 | _LIBCPP_HIDE_FROM_ABI constexpr const char* __position() const noexcept { return __first_; } | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept { | |
| 74 | _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input"); | |
| 75 | ||
| 76 | // Based on the number of leading 1 bits the number of code units in the | |
| 77 | // code point can be determined. See | |
| 78 | // https://en.wikipedia.org/wiki/UTF-8#Encoding | |
| 79 | switch (_VSTD::countl_one(static_cast<unsigned char>(*__first_))) { | |
| 80 | case 0: | |
| 81 | return *__first_++; | |
| 82 | ||
| 83 | case 2: | |
| 84 | if (__last_ - __first_ < 2 || !__unicode::__is_continuation(__first_ + 1, 1)) [[unlikely]] | |
| 85 | break; | |
| 86 | else { | |
| 87 | char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f; | |
| 88 | __value <<= 6; | |
| 89 | __value |= static_cast<unsigned char>(*__first_++) & 0x3f; | |
| 90 | return __value; | |
| 91 | } | |
| 92 | ||
| 93 | case 3: | |
| 94 | if (__last_ - __first_ < 3 || !__unicode::__is_continuation(__first_ + 1, 2)) [[unlikely]] | |
| 95 | break; | |
| 96 | else { | |
| 97 | char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f; | |
| 98 | __value <<= 6; | |
| 99 | __value |= static_cast<unsigned char>(*__first_++) & 0x3f; | |
| 100 | __value <<= 6; | |
| 101 | __value |= static_cast<unsigned char>(*__first_++) & 0x3f; | |
| 102 | return __value; | |
| 103 | } | |
| 104 | ||
| 105 | case 4: | |
| 106 | if (__last_ - __first_ < 4 || !__unicode::__is_continuation(__first_ + 1, 3)) [[unlikely]] | |
| 107 | break; | |
| 108 | else { | |
| 109 | char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07; | |
| 110 | __value <<= 6; | |
| 111 | __value |= static_cast<unsigned char>(*__first_++) & 0x3f; | |
| 112 | __value <<= 6; | |
| 113 | __value |= static_cast<unsigned char>(*__first_++) & 0x3f; | |
| 114 | __value <<= 6; | |
| 115 | __value |= static_cast<unsigned char>(*__first_++) & 0x3f; | |
| 116 | return __value; | |
| 117 | } | |
| 118 | } | |
| 119 | // An invalid number of leading ones can be garbage or a code unit in the | |
| 120 | // middle of a code point. By consuming one code unit the parser may get | |
| 121 | // "in sync" after a few code units. | |
| 122 | ++__first_; | |
| 123 | return __replacement_character; | |
| 124 | } | |
| 125 | ||
| 126 | private: | |
| 127 | const char* __first_; | |
| 128 | const char* __last_; | |
| 129 | }; | |
| 130 | ||
| 131 | # ifndef TEST_HAS_NO_WIDE_CHARACTERS | |
| 132 | /// This specialization depends on the size of wchar_t | |
| 133 | /// - 2 UTF-16 (for example Windows and AIX) | |
| 134 | /// - 4 UTF-32 (for example Linux) | |
| 135 | template <> | |
| 136 | class __code_point_view<wchar_t> { | |
| 137 | public: | |
| 138 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last) | |
| 139 | : __first_(__first), __last_(__last) {} | |
| 140 | ||
| 141 | _LIBCPP_HIDE_FROM_ABI constexpr const wchar_t* __position() const noexcept { return __first_; } | |
| 142 | _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; } | |
| 143 | ||
| 144 | _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept { | |
| 145 | _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input"); | |
| 146 | ||
| 147 | if constexpr (sizeof(wchar_t) == 2) { | |
| 148 | char32_t __result = *__first_++; | |
| 149 | // Is the code unit part of a surrogate pair? See | |
| 150 | // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF | |
| 151 | if (__result >= 0xd800 && __result <= 0xDfff) { | |
| 152 | // Malformed Unicode. | |
| 153 | if (__first_ == __last_) [[unlikely]] | |
| 154 | return __replacement_character; | |
| 155 | ||
| 156 | __result -= 0xd800; | |
| 157 | __result <<= 10; | |
| 158 | __result += *__first_++ - 0xdc00; | |
| 159 | __result += 0x10000; | |
| 160 | } | |
| 161 | return __result; | |
| 162 | ||
| 163 | } else if constexpr (sizeof(wchar_t) == 4) { | |
| 164 | char32_t __result = *__first_++; | |
| 165 | if (__result > 0x10FFFF) [[unlikely]] | |
| 166 | return __replacement_character; | |
| 167 | return __result; | |
| 168 | } else { | |
| 169 | // TODO FMT P2593R0 Use static_assert(false, "sizeof(wchar_t) has a not implemented value"); | |
| 170 | _LIBCPP_ASSERT(sizeof(wchar_t) == 0, "sizeof(wchar_t) has a not implemented value"); | |
| 171 | __libcpp_unreachable(); | |
| 172 | } | |
| 173 | } | |
| 174 | ||
| 175 | private: | |
| 176 | const wchar_t* __first_; | |
| 177 | const wchar_t* __last_; | |
| 178 | }; | |
| 179 | # endif | |
| 180 | ||
| 181 | _LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break( | |
| 182 | bool& __ri_break_allowed, | |
| 183 | bool __has_extened_pictographic, | |
| 184 | __extended_grapheme_custer_property_boundary::__property __prev, | |
| 185 | __extended_grapheme_custer_property_boundary::__property __next) { | |
| 186 | using __extended_grapheme_custer_property_boundary::__property; | |
| 187 | ||
| 188 | __has_extened_pictographic |= __prev == __property::__Extended_Pictographic; | |
| 189 | ||
| 190 | // https://www.unicode.org/reports/tr29/tr29-39.html#Grapheme_Cluster_Boundary_Rules | |
| 191 | ||
| 192 | // *** Break at the start and end of text, unless the text is empty. *** | |
| 193 | ||
| 194 | _LIBCPP_ASSERT(__prev != __property::__sot, "should be handled in the constructor"); // GB1 | |
| 195 | _LIBCPP_ASSERT(__prev != __property::__eot, "should be handled by our caller"); // GB2 | |
| 196 | ||
| 197 | // *** Do not break between a CR and LF. Otherwise, break before and after controls. *** | |
| 198 | if (__prev == __property::__CR && __next == __property::__LF) // GB3 | |
| 199 | return false; | |
| 200 | ||
| 201 | if (__prev == __property::__Control || __prev == __property::__CR || __prev == __property::__LF) // GB4 | |
| 202 | return true; | |
| 203 | ||
| 204 | if (__next == __property::__Control || __next == __property::__CR || __next == __property::__LF) // GB5 | |
| 205 | return true; | |
| 206 | ||
| 207 | // *** Do not break Hangul syllable sequences. *** | |
| 208 | if (__prev == __property::__L && | |
| 209 | (__next == __property::__L || __next == __property::__V || __next == __property::__LV || | |
| 210 | __next == __property::__LVT)) // GB6 | |
| 211 | return false; | |
| 212 | ||
| 213 | if ((__prev == __property::__LV || __prev == __property::__V) && | |
| 214 | (__next == __property::__V || __next == __property::__T)) // GB7 | |
| 215 | return false; | |
| 216 | ||
| 217 | if ((__prev == __property::__LVT || __prev == __property::__T) && __next == __property::__T) // GB8 | |
| 218 | return false; | |
| 219 | ||
| 220 | // *** Do not break before extending characters or ZWJ. *** | |
| 221 | if (__next == __property::__Extend || __next == __property::__ZWJ) | |
| 222 | return false; // GB9 | |
| 223 | ||
| 224 | // *** Do not break before SpacingMarks, or after Prepend characters. *** | |
| 225 | if (__next == __property::__SpacingMark) // GB9a | |
| 226 | return false; | |
| 227 | ||
| 228 | if (__prev == __property::__Prepend) // GB9b | |
| 229 | return false; | |
| 230 | ||
| 231 | // *** Do not break within emoji modifier sequences or emoji zwj sequences. *** | |
| 232 | ||
| 233 | // GB11 \p{Extended_Pictographic} Extend* ZWJ x \p{Extended_Pictographic} | |
| 234 | // | |
| 235 | // Note that several parts of this rule are matched by GB9: Any x (Extend | ZWJ) | |
| 236 | // - \p{Extended_Pictographic} x Extend | |
| 237 | // - Extend x Extend | |
| 238 | // - \p{Extended_Pictographic} x ZWJ | |
| 239 | // - Extend x ZWJ | |
| 240 | // | |
| 241 | // So the only case left to test is | |
| 242 | // - \p{Extended_Pictographic}' x ZWJ x \p{Extended_Pictographic} | |
| 243 | // where \p{Extended_Pictographic}' is stored in __has_extened_pictographic | |
| 244 | if (__has_extened_pictographic && __prev == __property::__ZWJ && __next == __property::__Extended_Pictographic) | |
| 245 | return false; | |
| 246 | ||
| 247 | // *** Do not break within emoji flag sequences *** | |
| 248 | ||
| 249 | // That is, do not break between regional indicator (RI) symbols if there | |
| 250 | // is an odd number of RI characters before the break point. | |
| 251 | ||
| 252 | if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13 | |
| 253 | __ri_break_allowed = !__ri_break_allowed; | |
| 254 | if (__ri_break_allowed) | |
| 255 | return true; | |
| 256 | ||
| 257 | return false; | |
| 258 | } | |
| 259 | ||
| 260 | // *** Otherwise, break everywhere. *** | |
| 261 | return true; // GB999 | |
| 262 | } | |
| 263 | ||
| 264 | /// Helper class to extract an extended grapheme cluster from a Unicode character range. | |
| 265 | /// | |
| 266 | /// This function is used to determine the column width of an extended grapheme | |
| 267 | /// cluster. In order to do that only the first code point is evaluated. | |
| 268 | /// Therefore only this code point is extracted. | |
| 269 | template <class _CharT> | |
| 270 | class __extended_grapheme_cluster_view { | |
| 271 | public: | |
| 272 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(const _CharT* __first, const _CharT* __last) | |
| 273 | : __code_point_view_(__first, __last), | |
| 274 | __next_code_point_(__code_point_view_.__consume()), | |
| 275 | __next_prop_(__extended_grapheme_custer_property_boundary::__get_property(__next_code_point_)) {} | |
| 276 | ||
| 277 | struct __cluster { | |
| 278 | /// The first code point of the extended grapheme cluster. | |
| 279 | /// | |
| 280 | /// The first code point is used to estimate the width of the extended | |
| 281 | /// grapheme cluster. | |
| 282 | char32_t __code_point_; | |
| 283 | ||
| 284 | /// Points one beyond the last code unit in the extended grapheme cluster. | |
| 285 | /// | |
| 286 | /// It's expected the caller has the start position and thus can determine | |
| 287 | /// the code unit range of the extended grapheme cluster. | |
| 288 | const _CharT* __last_; | |
| 289 | }; | |
| 290 | ||
| 291 | _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() { | |
| 292 | _LIBCPP_ASSERT( | |
| 293 | __next_prop_ != __extended_grapheme_custer_property_boundary::__property::__eot, | |
| 294 | "can't move beyond the end of input"); | |
| 295 | char32_t __code_point = __next_code_point_; | |
| 296 | if (!__code_point_view_.__at_end()) | |
| 297 | return {__code_point, __get_break()}; | |
| 298 | ||
| 299 | __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot; | |
| 300 | return {__code_point, __code_point_view_.__position()}; | |
| 301 | } | |
| 302 | ||
| 303 | private: | |
| 304 | __code_point_view<_CharT> __code_point_view_; | |
| 305 | ||
| 306 | char32_t __next_code_point_; | |
| 307 | __extended_grapheme_custer_property_boundary::__property __next_prop_; | |
| 308 | ||
| 309 | _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __get_break() { | |
| 310 | bool __ri_break_allowed = true; | |
| 311 | bool __has_extened_pictographic = false; | |
| 312 | while (true) { | |
| 313 | const _CharT* __result = __code_point_view_.__position(); | |
| 314 | __extended_grapheme_custer_property_boundary::__property __prev = __next_prop_; | |
| 315 | if (__code_point_view_.__at_end()) { | |
| 316 | __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot; | |
| 317 | return __result; | |
| 318 | } | |
| 319 | __next_code_point_ = __code_point_view_.__consume(); | |
| 320 | __next_prop_ = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point_); | |
| 321 | ||
| 322 | __has_extened_pictographic |= | |
| 323 | __prev == __extended_grapheme_custer_property_boundary::__property::__Extended_Pictographic; | |
| 324 | ||
| 325 | if (__at_extended_grapheme_cluster_break(__ri_break_allowed, __has_extened_pictographic, __prev, __next_prop_)) | |
| 326 | return __result; | |
| 327 | } | |
| 328 | } | |
| 329 | }; | |
| 330 | ||
| 331 | } // namespace __unicode | |
| 332 | ||
| 333 | # endif // _LIBCPP_HAS_NO_UNICODE | |
| 334 | ||
| 335 | #endif //_LIBCPP_STD_VER > 17 | |
| 336 | ||
| 337 | _LIBCPP_END_NAMESPACE_STD | |
| 338 | ||
| 339 | #endif // _LIBCPP___FORMAT_UNICODE_H |
lib/libcxx/include/__functional/binary_function.h+25-2| ... | ... | @@ -13,19 +13,42 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | |
| 22 | ||
| 21 | 23 | template <class _Arg1, class _Arg2, class _Result> |
| 22 | struct _LIBCPP_TEMPLATE_VIS binary_function | |
| 24 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function | |
| 23 | 25 | { |
| 24 | 26 | typedef _Arg1 first_argument_type; |
| 25 | 27 | typedef _Arg2 second_argument_type; |
| 26 | 28 | typedef _Result result_type; |
| 27 | 29 | }; |
| 28 | 30 | |
| 31 | #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | |
| 32 | ||
| 33 | template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base { | |
| 34 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 35 | using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1; | |
| 36 | using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2; | |
| 37 | using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result; | |
| 38 | #endif | |
| 39 | }; | |
| 40 | ||
| 41 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | |
| 42 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 43 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") | |
| 44 | template <class _Arg1, class _Arg2, class _Result> | |
| 45 | using __binary_function = binary_function<_Arg1, _Arg2, _Result>; | |
| 46 | _LIBCPP_DIAGNOSTIC_POP | |
| 47 | #else | |
| 48 | template <class _Arg1, class _Arg2, class _Result> | |
| 49 | using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; | |
| 50 | #endif | |
| 51 | ||
| 29 | 52 | _LIBCPP_END_NAMESPACE_STD |
| 30 | 53 | |
| 31 | 54 | #endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H |
lib/libcxx/include/__functional/binary_negate.h+4-4| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__functional/binary_function.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class _Predicate> |
| 25 | 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate |
| 26 | : public binary_function<typename _Predicate::first_argument_type, | |
| 27 | typename _Predicate::second_argument_type, | |
| 28 | bool> | |
| 26 | : public __binary_function<typename _Predicate::first_argument_type, | |
| 27 | typename _Predicate::second_argument_type, | |
| 28 | bool> | |
| 29 | 29 | { |
| 30 | 30 | _Predicate __pred_; |
| 31 | 31 | public: |
lib/libcxx/include/__functional/bind.h+6-9| ... | ... | @@ -18,16 +18,16 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | 26 | template<class _Tp> |
| 27 | 27 | struct is_bind_expression : _If< |
| 28 | _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, | |
| 28 | _IsSame<_Tp, __uncvref_t<_Tp> >::value, | |
| 29 | 29 | false_type, |
| 30 | is_bind_expression<typename __uncvref<_Tp>::type> | |
| 30 | is_bind_expression<__uncvref_t<_Tp> > | |
| 31 | 31 | > {}; |
| 32 | 32 | |
| 33 | 33 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -37,9 +37,9 @@ inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; |
| 37 | 37 | |
| 38 | 38 | template<class _Tp> |
| 39 | 39 | struct is_placeholder : _If< |
| 40 | _IsSame<_Tp, typename __uncvref<_Tp>::type>::value, | |
| 40 | _IsSame<_Tp, __uncvref_t<_Tp> >::value, | |
| 41 | 41 | integral_constant<int, 0>, |
| 42 | is_placeholder<typename __uncvref<_Tp>::type> | |
| 42 | is_placeholder<__uncvref_t<_Tp> > | |
| 43 | 43 | > {}; |
| 44 | 44 | |
| 45 | 45 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | template<class _Fp, class ..._BoundArgs> |
| 267 | class __bind | |
| 268 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 269 | : public __weak_result_type<typename decay<_Fp>::type> | |
| 270 | #endif | |
| 267 | class __bind : public __weak_result_type<typename decay<_Fp>::type> | |
| 271 | 268 | { |
| 272 | 269 | protected: |
| 273 | 270 | typedef typename decay<_Fp>::type _Fd; |
lib/libcxx/include/__functional/bind_back.h+6-7| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -31,12 +31,11 @@ struct __bind_back_op; |
| 31 | 31 | |
| 32 | 32 | template <size_t _NBound, size_t ..._Ip> |
| 33 | 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))...); } | |
| 34 | template <class _Fn, class _BoundArgs, class... _Args> | |
| 35 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const | |
| 36 | noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...))) | |
| 37 | -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)) | |
| 38 | { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...); } | |
| 40 | 39 | }; |
| 41 | 40 | |
| 42 | 41 | template <class _Fn, class _BoundArgs> |
lib/libcxx/include/__functional/bind_front.h+2-2| ... | ... | @@ -13,11 +13,11 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__functional/invoke.h> |
| 15 | 15 | #include <__functional/perfect_forward.h> |
| 16 | #include <__utility/forward.h> | |
| 16 | 17 | #include <type_traits> |
| 17 | #include <utility> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__functional/binder1st.h+2-3| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__functional/unary_function.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class __Operation> |
| 25 | 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st |
| 26 | : public unary_function<typename __Operation::second_argument_type, | |
| 27 | typename __Operation::result_type> | |
| 26 | : public __unary_function<typename __Operation::second_argument_type, typename __Operation::result_type> | |
| 28 | 27 | { |
| 29 | 28 | protected: |
| 30 | 29 | __Operation op; |
lib/libcxx/include/__functional/binder2nd.h+2-3| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__functional/unary_function.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class __Operation> |
| 25 | 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd |
| 26 | : public unary_function<typename __Operation::first_argument_type, | |
| 27 | typename __Operation::result_type> | |
| 26 | : public __unary_function<typename __Operation::first_argument_type, typename __Operation::result_type> | |
| 28 | 27 | { |
| 29 | 28 | protected: |
| 30 | 29 | __Operation op; |
lib/libcxx/include/__functional/boyer_moore_searcher.h created+313| ... | ... | @@ -0,0 +1,313 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H | |
| 10 | #define _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H | |
| 11 | ||
| 12 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 13 | # pragma GCC system_header | |
| 14 | #endif | |
| 15 | ||
| 16 | #include <__algorithm/fill_n.h> | |
| 17 | #include <__config> | |
| 18 | #include <__functional/hash.h> | |
| 19 | #include <__functional/operations.h> | |
| 20 | #include <__iterator/distance.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__memory/shared_ptr.h> | |
| 23 | #include <__utility/pair.h> | |
| 24 | #include <array> | |
| 25 | #include <unordered_map> | |
| 26 | #include <vector> | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | ||
| 30 | _LIBCPP_PUSH_MACROS | |
| 31 | #include <__undef_macros> | |
| 32 | ||
| 33 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 34 | ||
| 35 | template <class _Key, | |
| 36 | class _Value, | |
| 37 | class _Hash, | |
| 38 | class _BinaryPredicate, | |
| 39 | bool /*useArray*/> | |
| 40 | class _BMSkipTable; | |
| 41 | ||
| 42 | // General case for BM data searching; use a map | |
| 43 | template <class _Key, | |
| 44 | class _Value, | |
| 45 | class _Hash, | |
| 46 | class _BinaryPredicate> | |
| 47 | class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> { | |
| 48 | private: | |
| 49 | using value_type = _Value; | |
| 50 | using key_type = _Key; | |
| 51 | ||
| 52 | const value_type __default_value_; | |
| 53 | unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_; | |
| 54 | ||
| 55 | public: | |
| 56 | _LIBCPP_HIDE_FROM_ABI | |
| 57 | explicit _BMSkipTable(size_t __sz, value_type __default_value, _Hash __hash, _BinaryPredicate __pred) | |
| 58 | : __default_value_(__default_value), | |
| 59 | __table_(__sz, __hash, __pred) {} | |
| 60 | ||
| 61 | _LIBCPP_HIDE_FROM_ABI void insert(const key_type& __key, value_type __val) { | |
| 62 | __table_[__key] = __val; | |
| 63 | } | |
| 64 | ||
| 65 | _LIBCPP_HIDE_FROM_ABI value_type operator[](const key_type& __key) const { | |
| 66 | auto __it = __table_.find(__key); | |
| 67 | return __it == __table_.end() ? __default_value_ : __it->second; | |
| 68 | } | |
| 69 | }; | |
| 70 | ||
| 71 | // Special case small numeric values; use an array | |
| 72 | template <class _Key, | |
| 73 | class _Value, | |
| 74 | class _Hash, | |
| 75 | class _BinaryPredicate> | |
| 76 | class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> { | |
| 77 | private: | |
| 78 | using value_type = _Value; | |
| 79 | using key_type = _Key; | |
| 80 | ||
| 81 | using unsigned_key_type = make_unsigned_t<key_type>; | |
| 82 | std::array<value_type, 256> __table_; | |
| 83 | static_assert(numeric_limits<unsigned_key_type>::max() < 256); | |
| 84 | ||
| 85 | public: | |
| 86 | _LIBCPP_HIDE_FROM_ABI explicit _BMSkipTable(size_t, value_type __default_value, _Hash, _BinaryPredicate) { | |
| 87 | std::fill_n(__table_.data(), __table_.size(), __default_value); | |
| 88 | } | |
| 89 | ||
| 90 | _LIBCPP_HIDE_FROM_ABI void insert(key_type __key, value_type __val) { | |
| 91 | __table_[static_cast<unsigned_key_type>(__key)] = __val; | |
| 92 | } | |
| 93 | ||
| 94 | _LIBCPP_HIDE_FROM_ABI value_type operator[](key_type __key) const { | |
| 95 | return __table_[static_cast<unsigned_key_type>(__key)]; | |
| 96 | } | |
| 97 | }; | |
| 98 | ||
| 99 | template <class _RandomAccessIterator1, | |
| 100 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, | |
| 101 | class _BinaryPredicate = equal_to<>> | |
| 102 | class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher { | |
| 103 | private: | |
| 104 | using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type; | |
| 105 | using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type; | |
| 106 | using __skip_table_type = _BMSkipTable<value_type, | |
| 107 | difference_type, | |
| 108 | _Hash, | |
| 109 | _BinaryPredicate, | |
| 110 | is_integral_v<value_type> | |
| 111 | && sizeof(value_type) == 1 | |
| 112 | && is_same_v<_Hash, hash<value_type>> | |
| 113 | && is_same_v<_BinaryPredicate, equal_to<>>>; | |
| 114 | ||
| 115 | public: | |
| 116 | boyer_moore_searcher(_RandomAccessIterator1 __first, | |
| 117 | _RandomAccessIterator1 __last, | |
| 118 | _Hash __hash = _Hash(), | |
| 119 | _BinaryPredicate __pred = _BinaryPredicate()) | |
| 120 | : __first_(__first), | |
| 121 | __last_(__last), | |
| 122 | __pred_(__pred), | |
| 123 | __pattern_length_(__last - __first), | |
| 124 | __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, -1, __hash, __pred_)), | |
| 125 | __suffix_(std::__allocate_shared_unbounded_array<difference_type[]>( | |
| 126 | allocator<difference_type>(), __pattern_length_ + 1)) { | |
| 127 | difference_type __i = 0; | |
| 128 | while (__first != __last) { | |
| 129 | __skip_table_->insert(*__first, __i); | |
| 130 | ++__first; | |
| 131 | ++__i; | |
| 132 | } | |
| 133 | __build_suffix_table(__first_, __last_, __pred_); | |
| 134 | } | |
| 135 | ||
| 136 | template <class _RandomAccessIterator2> | |
| 137 | pair<_RandomAccessIterator2, _RandomAccessIterator2> | |
| 138 | operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { | |
| 139 | static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type, | |
| 140 | typename iterator_traits<_RandomAccessIterator2>::value_type>::value, | |
| 141 | "Corpus and Pattern iterators must point to the same type"); | |
| 142 | if (__first == __last) | |
| 143 | return std::make_pair(__last, __last); | |
| 144 | if (__first_ == __last_) | |
| 145 | return std::make_pair(__first, __first); | |
| 146 | ||
| 147 | if (__pattern_length_ > (__last - __first)) | |
| 148 | return std::make_pair(__last, __last); | |
| 149 | return __search(__first, __last); | |
| 150 | } | |
| 151 | ||
| 152 | private: | |
| 153 | _RandomAccessIterator1 __first_; | |
| 154 | _RandomAccessIterator1 __last_; | |
| 155 | _BinaryPredicate __pred_; | |
| 156 | difference_type __pattern_length_; | |
| 157 | shared_ptr<__skip_table_type> __skip_table_; | |
| 158 | shared_ptr<difference_type[]> __suffix_; | |
| 159 | ||
| 160 | template <class _RandomAccessIterator2> | |
| 161 | pair<_RandomAccessIterator2, _RandomAccessIterator2> | |
| 162 | __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const { | |
| 163 | _RandomAccessIterator2 __current = __f; | |
| 164 | const _RandomAccessIterator2 __last = __l - __pattern_length_; | |
| 165 | const __skip_table_type& __skip_table = *__skip_table_; | |
| 166 | ||
| 167 | while (__current <= __last) { | |
| 168 | difference_type __j = __pattern_length_; | |
| 169 | while (__pred_(__first_[__j - 1], __current[__j - 1])) { | |
| 170 | --__j; | |
| 171 | if (__j == 0) | |
| 172 | return std::make_pair(__current, __current + __pattern_length_); | |
| 173 | } | |
| 174 | ||
| 175 | difference_type __k = __skip_table[__current[__j - 1]]; | |
| 176 | difference_type __m = __j - __k - 1; | |
| 177 | if (__k < __j && __m > __suffix_[__j]) | |
| 178 | __current += __m; | |
| 179 | else | |
| 180 | __current += __suffix_[__j]; | |
| 181 | } | |
| 182 | return std::make_pair(__l, __l); | |
| 183 | } | |
| 184 | ||
| 185 | template <class _Iterator, class _Container> | |
| 186 | void __compute_bm_prefix(_Iterator __first, _Iterator __last, _BinaryPredicate __pred, _Container& __prefix) { | |
| 187 | const size_t __count = __last - __first; | |
| 188 | ||
| 189 | __prefix[0] = 0; | |
| 190 | size_t __k = 0; | |
| 191 | ||
| 192 | for (size_t __i = 1; __i != __count; ++__i) { | |
| 193 | while (__k > 0 && !__pred(__first[__k], __first[__i])) | |
| 194 | __k = __prefix[__k - 1]; | |
| 195 | ||
| 196 | if (__pred(__first[__k], __first[__i])) | |
| 197 | ++__k; | |
| 198 | __prefix[__i] = __k; | |
| 199 | } | |
| 200 | } | |
| 201 | ||
| 202 | void __build_suffix_table(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _BinaryPredicate __pred) { | |
| 203 | const size_t __count = __last - __first; | |
| 204 | ||
| 205 | if (__count == 0) | |
| 206 | return; | |
| 207 | ||
| 208 | vector<difference_type> __scratch(__count); | |
| 209 | ||
| 210 | __compute_bm_prefix(__first, __last, __pred, __scratch); | |
| 211 | for (size_t __i = 0; __i <= __count; ++__i) | |
| 212 | __suffix_[__i] = __count - __scratch[__count - 1]; | |
| 213 | ||
| 214 | using _ReverseIter = reverse_iterator<_RandomAccessIterator1>; | |
| 215 | __compute_bm_prefix(_ReverseIter(__last), _ReverseIter(__first), __pred, __scratch); | |
| 216 | ||
| 217 | for (size_t __i = 0; __i != __count; ++__i) { | |
| 218 | const size_t __j = __count - __scratch[__i]; | |
| 219 | const difference_type __k = __i - __scratch[__i] + 1; | |
| 220 | ||
| 221 | if (__suffix_[__j] > __k) | |
| 222 | __suffix_[__j] = __k; | |
| 223 | } | |
| 224 | } | |
| 225 | }; | |
| 226 | ||
| 227 | template <class _RandomAccessIterator1, | |
| 228 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, | |
| 229 | class _BinaryPredicate = equal_to<>> | |
| 230 | class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher { | |
| 231 | private: | |
| 232 | using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type; | |
| 233 | using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type; | |
| 234 | using __skip_table_type = _BMSkipTable<value_type, | |
| 235 | difference_type, | |
| 236 | _Hash, | |
| 237 | _BinaryPredicate, | |
| 238 | is_integral_v<value_type> | |
| 239 | && sizeof(value_type) == 1 | |
| 240 | && is_same_v<_Hash, hash<value_type>> | |
| 241 | && is_same_v<_BinaryPredicate, equal_to<>>>; | |
| 242 | public: | |
| 243 | boyer_moore_horspool_searcher(_RandomAccessIterator1 __first, | |
| 244 | _RandomAccessIterator1 __last, | |
| 245 | _Hash __hash = _Hash(), | |
| 246 | _BinaryPredicate __pred = _BinaryPredicate()) | |
| 247 | : __first_(__first), | |
| 248 | __last_(__last), | |
| 249 | __pred_(__pred), | |
| 250 | __pattern_length_(__last - __first), | |
| 251 | __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, __pattern_length_, __hash, __pred_)) { | |
| 252 | if (__first == __last) | |
| 253 | return; | |
| 254 | --__last; | |
| 255 | difference_type __i = 0; | |
| 256 | while (__first != __last) { | |
| 257 | __skip_table_->insert(*__first, __pattern_length_ - 1 - __i); | |
| 258 | ++__first; | |
| 259 | ++__i; | |
| 260 | } | |
| 261 | } | |
| 262 | ||
| 263 | template <class _RandomAccessIterator2> | |
| 264 | pair<_RandomAccessIterator2, _RandomAccessIterator2> | |
| 265 | operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const { | |
| 266 | static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type, | |
| 267 | typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value, | |
| 268 | "Corpus and Pattern iterators must point to the same type"); | |
| 269 | if (__first == __last) | |
| 270 | return std::make_pair(__last, __last); | |
| 271 | if (__first_ == __last_) | |
| 272 | return std::make_pair(__first, __first); | |
| 273 | ||
| 274 | if (__pattern_length_ > __last - __first) | |
| 275 | return std::make_pair(__last, __last); | |
| 276 | ||
| 277 | return __search(__first, __last); | |
| 278 | } | |
| 279 | ||
| 280 | private: | |
| 281 | _RandomAccessIterator1 __first_; | |
| 282 | _RandomAccessIterator1 __last_; | |
| 283 | _BinaryPredicate __pred_; | |
| 284 | difference_type __pattern_length_; | |
| 285 | shared_ptr<__skip_table_type> __skip_table_; | |
| 286 | ||
| 287 | template <class _RandomAccessIterator2> | |
| 288 | pair<_RandomAccessIterator2, _RandomAccessIterator2> | |
| 289 | __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const { | |
| 290 | _RandomAccessIterator2 __current = __f; | |
| 291 | const _RandomAccessIterator2 __last = __l - __pattern_length_; | |
| 292 | const __skip_table_type& __skip_table = *__skip_table_; | |
| 293 | ||
| 294 | while (__current <= __last) { | |
| 295 | difference_type __j = __pattern_length_; | |
| 296 | while (__pred_(__first_[__j - 1], __current[__j - 1])) { | |
| 297 | --__j; | |
| 298 | if (__j == 0) | |
| 299 | return std::make_pair(__current, __current + __pattern_length_); | |
| 300 | } | |
| 301 | __current += __skip_table[__current[__pattern_length_ - 1]]; | |
| 302 | } | |
| 303 | return std::make_pair(__l, __l); | |
| 304 | } | |
| 305 | }; | |
| 306 | ||
| 307 | _LIBCPP_END_NAMESPACE_STD | |
| 308 | ||
| 309 | _LIBCPP_POP_MACROS | |
| 310 | ||
| 311 | #endif // _LIBCPP_STD_VER > 14 | |
| 312 | ||
| 313 | #endif // _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H |
lib/libcxx/include/__functional/compose.h+1-1| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__functional/default_searcher.h+6-6| ... | ... | @@ -12,12 +12,13 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__algorithm/search.h> |
| 14 | 14 | #include <__config> |
| 15 | #include <__functional/identity.h> | |
| 15 | 16 | #include <__functional/operations.h> |
| 16 | 17 | #include <__iterator/iterator_traits.h> |
| 17 | #include <utility> | |
| 18 | #include <__utility/pair.h> | |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -38,16 +39,15 @@ public: |
| 38 | 39 | pair<_ForwardIterator2, _ForwardIterator2> |
| 39 | 40 | operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const |
| 40 | 41 | { |
| 41 | return _VSTD::__search(__f, __l, __first_, __last_, __pred_, | |
| 42 | typename iterator_traits<_ForwardIterator>::iterator_category(), | |
| 43 | typename iterator_traits<_ForwardIterator2>::iterator_category()); | |
| 42 | auto __proj = __identity(); | |
| 43 | return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj); | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | private: |
| 47 | 47 | _ForwardIterator __first_; |
| 48 | 48 | _ForwardIterator __last_; |
| 49 | 49 | _BinaryPredicate __pred_; |
| 50 | }; | |
| 50 | }; | |
| 51 | 51 | |
| 52 | 52 | #endif // _LIBCPP_STD_VER > 14 |
| 53 | 53 |
lib/libcxx/include/__functional/function.h+14-11| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___FUNCTIONAL_FUNCTION_H |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_FUNCTION_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__functional/binary_function.h> |
| 16 | 16 | #include <__functional/invoke.h> |
| 17 | 17 | #include <__functional/unary_function.h> |
| ... | ... | @@ -20,19 +20,23 @@ |
| 20 | 20 | #include <__memory/allocator_traits.h> |
| 21 | 21 | #include <__memory/compressed_pair.h> |
| 22 | 22 | #include <__memory/shared_ptr.h> |
| 23 | #include <__utility/forward.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | #include <__utility/swap.h> | |
| 23 | 26 | #include <exception> |
| 24 | 27 | #include <memory> // TODO: replace with <__memory/__builtin_new_allocator.h> |
| 25 | 28 | #include <type_traits> |
| 26 | #include <utility> | |
| 27 | 29 | |
| 28 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | #pragma GCC system_header | |
| 31 | # pragma GCC system_header | |
| 30 | 32 | #endif |
| 31 | 33 | |
| 32 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 35 | |
| 34 | 36 | // bad_function_call |
| 35 | 37 | |
| 38 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 39 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables") | |
| 36 | 40 | class _LIBCPP_EXCEPTION_ABI bad_function_call |
| 37 | 41 | : public exception |
| 38 | 42 | { |
| ... | ... | @@ -50,6 +54,7 @@ public: |
| 50 | 54 | virtual const char* what() const _NOEXCEPT; |
| 51 | 55 | #endif |
| 52 | 56 | }; |
| 57 | _LIBCPP_DIAGNOSTIC_POP | |
| 53 | 58 | |
| 54 | 59 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
| 55 | 60 | void __throw_bad_function_call() |
| ... | ... | @@ -80,7 +85,7 @@ struct __maybe_derive_from_unary_function |
| 80 | 85 | |
| 81 | 86 | template<class _Rp, class _A1> |
| 82 | 87 | struct __maybe_derive_from_unary_function<_Rp(_A1)> |
| 83 | : public unary_function<_A1, _Rp> | |
| 88 | : public __unary_function<_A1, _Rp> | |
| 84 | 89 | { |
| 85 | 90 | }; |
| 86 | 91 | |
| ... | ... | @@ -91,7 +96,7 @@ struct __maybe_derive_from_binary_function |
| 91 | 96 | |
| 92 | 97 | template<class _Rp, class _A1, class _A2> |
| 93 | 98 | struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> |
| 94 | : public binary_function<_A1, _A2, _Rp> | |
| 99 | : public __binary_function<_A1, _A2, _Rp> | |
| 95 | 100 | { |
| 96 | 101 | }; |
| 97 | 102 | |
| ... | ... | @@ -385,9 +390,9 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)> |
| 385 | 390 | typedef __base<_Rp(_ArgTypes...)> __func; |
| 386 | 391 | __func* __f_; |
| 387 | 392 | |
| 388 | _LIBCPP_NO_CFI static __func* __as_base(void* p) | |
| 393 | _LIBCPP_NO_CFI static __func* __as_base(void* __p) | |
| 389 | 394 | { |
| 390 | return reinterpret_cast<__func*>(p); | |
| 395 | return reinterpret_cast<__func*>(__p); | |
| 391 | 396 | } |
| 392 | 397 | |
| 393 | 398 | public: |
| ... | ... | @@ -951,10 +956,8 @@ public: |
| 951 | 956 | |
| 952 | 957 | template<class _Rp, class ..._ArgTypes> |
| 953 | 958 | class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> |
| 954 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 955 | 959 | : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, |
| 956 | 960 | public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> |
| 957 | #endif | |
| 958 | 961 | { |
| 959 | 962 | #ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION |
| 960 | 963 | typedef __function::__value_func<_Rp(_ArgTypes...)> __func; |
| ... | ... | @@ -1237,7 +1240,7 @@ void |
| 1237 | 1240 | swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT |
| 1238 | 1241 | {return __x.swap(__y);} |
| 1239 | 1242 | |
| 1240 | #else // _LIBCPP_CXX03_LANG | |
| 1243 | #elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION) | |
| 1241 | 1244 | |
| 1242 | 1245 | namespace __function { |
| 1243 | 1246 | |
| ... | ... | @@ -2803,7 +2806,7 @@ void |
| 2803 | 2806 | swap(function<_Fp>& __x, function<_Fp>& __y) |
| 2804 | 2807 | {return __x.swap(__y);} |
| 2805 | 2808 | |
| 2806 | #endif | |
| 2809 | #endif // _LIBCPP_CXX03_LANG | |
| 2807 | 2810 | |
| 2808 | 2811 | _LIBCPP_END_NAMESPACE_STD |
| 2809 | 2812 |
lib/libcxx/include/__functional/hash.h+24-207| ... | ... | @@ -23,7 +23,7 @@ |
| 23 | 23 | #include <type_traits> |
| 24 | 24 | |
| 25 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -265,18 +265,10 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) |
| 265 | 265 | template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> |
| 266 | 266 | struct __scalar_hash; |
| 267 | 267 | |
| 268 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 269 | 268 | template <class _Tp> |
| 270 | 269 | struct __scalar_hash<_Tp, 0> |
| 271 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 272 | : public unary_function<_Tp, size_t> | |
| 273 | #endif | |
| 270 | : public __unary_function<_Tp, size_t> | |
| 274 | 271 | { |
| 275 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 276 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 277 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 278 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 279 | #endif | |
| 280 | 272 | _LIBCPP_INLINE_VISIBILITY |
| 281 | 273 | size_t operator()(_Tp __v) const _NOEXCEPT |
| 282 | 274 | { |
| ... | ... | @@ -291,18 +283,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 291 | 283 | } |
| 292 | 284 | }; |
| 293 | 285 | |
| 294 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 295 | 286 | template <class _Tp> |
| 296 | 287 | struct __scalar_hash<_Tp, 1> |
| 297 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 298 | : public unary_function<_Tp, size_t> | |
| 299 | #endif | |
| 288 | : public __unary_function<_Tp, size_t> | |
| 300 | 289 | { |
| 301 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 302 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 303 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 304 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 305 | #endif | |
| 306 | 290 | _LIBCPP_INLINE_VISIBILITY |
| 307 | 291 | size_t operator()(_Tp __v) const _NOEXCEPT |
| 308 | 292 | { |
| ... | ... | @@ -316,18 +300,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 316 | 300 | } |
| 317 | 301 | }; |
| 318 | 302 | |
| 319 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 320 | 303 | template <class _Tp> |
| 321 | 304 | struct __scalar_hash<_Tp, 2> |
| 322 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 323 | : public unary_function<_Tp, size_t> | |
| 324 | #endif | |
| 305 | : public __unary_function<_Tp, size_t> | |
| 325 | 306 | { |
| 326 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 327 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 328 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 329 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 330 | #endif | |
| 331 | 307 | _LIBCPP_INLINE_VISIBILITY |
| 332 | 308 | size_t operator()(_Tp __v) const _NOEXCEPT |
| 333 | 309 | { |
| ... | ... | @@ -345,18 +321,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 345 | 321 | } |
| 346 | 322 | }; |
| 347 | 323 | |
| 348 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 349 | 324 | template <class _Tp> |
| 350 | 325 | struct __scalar_hash<_Tp, 3> |
| 351 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 352 | : public unary_function<_Tp, size_t> | |
| 353 | #endif | |
| 326 | : public __unary_function<_Tp, size_t> | |
| 354 | 327 | { |
| 355 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 356 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 357 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 358 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 359 | #endif | |
| 360 | 328 | _LIBCPP_INLINE_VISIBILITY |
| 361 | 329 | size_t operator()(_Tp __v) const _NOEXCEPT |
| 362 | 330 | { |
| ... | ... | @@ -375,18 +343,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 375 | 343 | } |
| 376 | 344 | }; |
| 377 | 345 | |
| 378 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 379 | 346 | template <class _Tp> |
| 380 | 347 | struct __scalar_hash<_Tp, 4> |
| 381 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 382 | : public unary_function<_Tp, size_t> | |
| 383 | #endif | |
| 348 | : public __unary_function<_Tp, size_t> | |
| 384 | 349 | { |
| 385 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 386 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 387 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 388 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 389 | #endif | |
| 390 | 350 | _LIBCPP_INLINE_VISIBILITY |
| 391 | 351 | size_t operator()(_Tp __v) const _NOEXCEPT |
| 392 | 352 | { |
| ... | ... | @@ -418,18 +378,10 @@ inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { |
| 418 | 378 | return _HashT()(__p); |
| 419 | 379 | } |
| 420 | 380 | |
| 421 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 422 | 381 | template<class _Tp> |
| 423 | 382 | struct _LIBCPP_TEMPLATE_VIS hash<_Tp*> |
| 424 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 425 | : public unary_function<_Tp*, size_t> | |
| 426 | #endif | |
| 383 | : public __unary_function<_Tp*, size_t> | |
| 427 | 384 | { |
| 428 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 429 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 430 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 431 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type; | |
| 432 | #endif | |
| 433 | 385 | _LIBCPP_INLINE_VISIBILITY |
| 434 | 386 | size_t operator()(_Tp* __v) const _NOEXCEPT |
| 435 | 387 | { |
| ... | ... | @@ -443,234 +395,118 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 443 | 395 | } |
| 444 | 396 | }; |
| 445 | 397 | |
| 446 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 447 | 398 | template <> |
| 448 | 399 | struct _LIBCPP_TEMPLATE_VIS hash<bool> |
| 449 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 450 | : public unary_function<bool, size_t> | |
| 451 | #endif | |
| 400 | : public __unary_function<bool, size_t> | |
| 452 | 401 | { |
| 453 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 454 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 455 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 456 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type; | |
| 457 | #endif | |
| 458 | 402 | _LIBCPP_INLINE_VISIBILITY |
| 459 | 403 | size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 460 | 404 | }; |
| 461 | 405 | |
| 462 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 463 | 406 | template <> |
| 464 | 407 | struct _LIBCPP_TEMPLATE_VIS hash<char> |
| 465 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 466 | : public unary_function<char, size_t> | |
| 467 | #endif | |
| 408 | : public __unary_function<char, size_t> | |
| 468 | 409 | { |
| 469 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 470 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 471 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 472 | _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type; | |
| 473 | #endif | |
| 474 | 410 | _LIBCPP_INLINE_VISIBILITY |
| 475 | 411 | size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 476 | 412 | }; |
| 477 | 413 | |
| 478 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 479 | 414 | template <> |
| 480 | 415 | struct _LIBCPP_TEMPLATE_VIS hash<signed char> |
| 481 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 482 | : public unary_function<signed char, size_t> | |
| 483 | #endif | |
| 416 | : public __unary_function<signed char, size_t> | |
| 484 | 417 | { |
| 485 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 486 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 487 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 488 | _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type; | |
| 489 | #endif | |
| 490 | 418 | _LIBCPP_INLINE_VISIBILITY |
| 491 | 419 | size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 492 | 420 | }; |
| 493 | 421 | |
| 494 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 495 | 422 | template <> |
| 496 | 423 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> |
| 497 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 498 | : public unary_function<unsigned char, size_t> | |
| 499 | #endif | |
| 424 | : public __unary_function<unsigned char, size_t> | |
| 500 | 425 | { |
| 501 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 502 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 503 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 504 | _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type; | |
| 505 | #endif | |
| 506 | 426 | _LIBCPP_INLINE_VISIBILITY |
| 507 | 427 | size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 508 | 428 | }; |
| 509 | 429 | |
| 510 | 430 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 511 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 512 | 431 | template <> |
| 513 | 432 | struct _LIBCPP_TEMPLATE_VIS hash<char8_t> |
| 514 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 515 | : public unary_function<char8_t, size_t> | |
| 516 | #endif | |
| 433 | : public __unary_function<char8_t, size_t> | |
| 517 | 434 | { |
| 518 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 519 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 520 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 521 | _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type; | |
| 522 | #endif | |
| 523 | 435 | _LIBCPP_INLINE_VISIBILITY |
| 524 | 436 | size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 525 | 437 | }; |
| 526 | 438 | #endif // !_LIBCPP_HAS_NO_CHAR8_T |
| 527 | 439 | |
| 528 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 529 | ||
| 530 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 531 | 440 | template <> |
| 532 | 441 | struct _LIBCPP_TEMPLATE_VIS hash<char16_t> |
| 533 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 534 | : public unary_function<char16_t, size_t> | |
| 535 | #endif | |
| 442 | : public __unary_function<char16_t, size_t> | |
| 536 | 443 | { |
| 537 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 538 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 539 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 540 | _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type; | |
| 541 | #endif | |
| 542 | 444 | _LIBCPP_INLINE_VISIBILITY |
| 543 | 445 | size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 544 | 446 | }; |
| 545 | 447 | |
| 546 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 547 | 448 | template <> |
| 548 | 449 | struct _LIBCPP_TEMPLATE_VIS hash<char32_t> |
| 549 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 550 | : public unary_function<char32_t, size_t> | |
| 551 | #endif | |
| 450 | : public __unary_function<char32_t, size_t> | |
| 552 | 451 | { |
| 553 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 554 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 555 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 556 | _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type; | |
| 557 | #endif | |
| 558 | 452 | _LIBCPP_INLINE_VISIBILITY |
| 559 | 453 | size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 560 | 454 | }; |
| 561 | 455 | |
| 562 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 563 | ||
| 564 | 456 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 565 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 566 | 457 | template <> |
| 567 | 458 | struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> |
| 568 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 569 | : public unary_function<wchar_t, size_t> | |
| 570 | #endif | |
| 459 | : public __unary_function<wchar_t, size_t> | |
| 571 | 460 | { |
| 572 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 573 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 574 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 575 | _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type; | |
| 576 | #endif | |
| 577 | 461 | _LIBCPP_INLINE_VISIBILITY |
| 578 | 462 | size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 579 | 463 | }; |
| 580 | 464 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 581 | 465 | |
| 582 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 583 | 466 | template <> |
| 584 | 467 | struct _LIBCPP_TEMPLATE_VIS hash<short> |
| 585 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 586 | : public unary_function<short, size_t> | |
| 587 | #endif | |
| 468 | : public __unary_function<short, size_t> | |
| 588 | 469 | { |
| 589 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 590 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 591 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 592 | _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type; | |
| 593 | #endif | |
| 594 | 470 | _LIBCPP_INLINE_VISIBILITY |
| 595 | 471 | size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 596 | 472 | }; |
| 597 | 473 | |
| 598 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 599 | 474 | template <> |
| 600 | 475 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> |
| 601 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 602 | : public unary_function<unsigned short, size_t> | |
| 603 | #endif | |
| 476 | : public __unary_function<unsigned short, size_t> | |
| 604 | 477 | { |
| 605 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 606 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 607 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 608 | _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type; | |
| 609 | #endif | |
| 610 | 478 | _LIBCPP_INLINE_VISIBILITY |
| 611 | 479 | size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 612 | 480 | }; |
| 613 | 481 | |
| 614 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 615 | 482 | template <> |
| 616 | 483 | struct _LIBCPP_TEMPLATE_VIS hash<int> |
| 617 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 618 | : public unary_function<int, size_t> | |
| 619 | #endif | |
| 484 | : public __unary_function<int, size_t> | |
| 620 | 485 | { |
| 621 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 622 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 623 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 624 | _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type; | |
| 625 | #endif | |
| 626 | 486 | _LIBCPP_INLINE_VISIBILITY |
| 627 | 487 | size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 628 | 488 | }; |
| 629 | 489 | |
| 630 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 631 | 490 | template <> |
| 632 | 491 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> |
| 633 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 634 | : public unary_function<unsigned int, size_t> | |
| 635 | #endif | |
| 492 | : public __unary_function<unsigned int, size_t> | |
| 636 | 493 | { |
| 637 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 638 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 639 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 640 | _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type; | |
| 641 | #endif | |
| 642 | 494 | _LIBCPP_INLINE_VISIBILITY |
| 643 | 495 | size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 644 | 496 | }; |
| 645 | 497 | |
| 646 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 647 | 498 | template <> |
| 648 | 499 | struct _LIBCPP_TEMPLATE_VIS hash<long> |
| 649 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 650 | : public unary_function<long, size_t> | |
| 651 | #endif | |
| 500 | : public __unary_function<long, size_t> | |
| 652 | 501 | { |
| 653 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 654 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 655 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 656 | _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type; | |
| 657 | #endif | |
| 658 | 502 | _LIBCPP_INLINE_VISIBILITY |
| 659 | 503 | size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 660 | 504 | }; |
| 661 | 505 | |
| 662 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 663 | 506 | template <> |
| 664 | 507 | struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> |
| 665 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 666 | : public unary_function<unsigned long, size_t> | |
| 667 | #endif | |
| 508 | : public __unary_function<unsigned long, size_t> | |
| 668 | 509 | { |
| 669 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 670 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 671 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 672 | _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type; | |
| 673 | #endif | |
| 674 | 510 | _LIBCPP_INLINE_VISIBILITY |
| 675 | 511 | size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} |
| 676 | 512 | }; |
| ... | ... | @@ -781,25 +617,15 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double> |
| 781 | 617 | } |
| 782 | 618 | }; |
| 783 | 619 | |
| 784 | #if _LIBCPP_STD_VER > 11 | |
| 785 | ||
| 786 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 787 | 620 | template <class _Tp, bool = is_enum<_Tp>::value> |
| 788 | 621 | struct _LIBCPP_TEMPLATE_VIS __enum_hash |
| 789 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 790 | : public unary_function<_Tp, size_t> | |
| 791 | #endif | |
| 622 | : public __unary_function<_Tp, size_t> | |
| 792 | 623 | { |
| 793 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 794 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 795 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 796 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 797 | #endif | |
| 798 | 624 | _LIBCPP_INLINE_VISIBILITY |
| 799 | 625 | size_t operator()(_Tp __v) const _NOEXCEPT |
| 800 | 626 | { |
| 801 | 627 | typedef typename underlying_type<_Tp>::type type; |
| 802 | return hash<type>{}(static_cast<type>(__v)); | |
| 628 | return hash<type>()(static_cast<type>(__v)); | |
| 803 | 629 | } |
| 804 | 630 | }; |
| 805 | 631 | template <class _Tp> |
| ... | ... | @@ -813,22 +639,13 @@ template <class _Tp> |
| 813 | 639 | struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> |
| 814 | 640 | { |
| 815 | 641 | }; |
| 816 | #endif | |
| 817 | 642 | |
| 818 | 643 | #if _LIBCPP_STD_VER > 14 |
| 819 | 644 | |
| 820 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 821 | 645 | template <> |
| 822 | 646 | struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> |
| 823 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 824 | : public unary_function<nullptr_t, size_t> | |
| 825 | #endif | |
| 647 | : public __unary_function<nullptr_t, size_t> | |
| 826 | 648 | { |
| 827 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 828 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 829 | _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; | |
| 830 | _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type; | |
| 831 | #endif | |
| 832 | 649 | _LIBCPP_INLINE_VISIBILITY |
| 833 | 650 | size_t operator()(nullptr_t) const _NOEXCEPT { |
| 834 | 651 | return 662607004ull; |
lib/libcxx/include/__functional/identity.h+11-2| ... | ... | @@ -11,14 +11,23 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_IDENTITY_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <utility> | |
| 14 | #include <__utility/forward.h> | |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | struct __identity { | |
| 23 | template <class _Tp> | |
| 24 | _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT { | |
| 25 | return std::forward<_Tp>(__t); | |
| 26 | } | |
| 27 | ||
| 28 | using is_transparent = void; | |
| 29 | }; | |
| 30 | ||
| 22 | 31 | #if _LIBCPP_STD_VER > 17 |
| 23 | 32 | |
| 24 | 33 | struct identity { |
lib/libcxx/include/__functional/invoke.h+485-47| ... | ... | @@ -11,79 +11,517 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_INVOKE_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__functional/weak_result_type.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/apply_cv.h> | |
| 16 | #include <__type_traits/conditional.h> | |
| 17 | #include <__type_traits/decay.h> | |
| 18 | #include <__type_traits/enable_if.h> | |
| 19 | #include <__type_traits/integral_constant.h> | |
| 20 | #include <__type_traits/is_base_of.h> | |
| 21 | #include <__type_traits/is_core_convertible.h> | |
| 22 | #include <__type_traits/is_member_function_pointer.h> | |
| 23 | #include <__type_traits/is_member_object_pointer.h> | |
| 24 | #include <__type_traits/is_reference_wrapper.h> | |
| 25 | #include <__type_traits/is_same.h> | |
| 26 | #include <__type_traits/is_void.h> | |
| 27 | #include <__type_traits/nat.h> | |
| 28 | #include <__type_traits/remove_cv.h> | |
| 29 | #include <__utility/declval.h> | |
| 15 | 30 | #include <__utility/forward.h> |
| 16 | #include <type_traits> | |
| 17 | 31 | |
| 18 | 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 33 | # pragma GCC system_header | |
| 20 | 34 | #endif |
| 21 | 35 | |
| 36 | // TODO: Disentangle the type traits and std::invoke properly | |
| 37 | ||
| 22 | 38 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 39 | |
| 40 | struct __any | |
| 41 | { | |
| 42 | __any(...); | |
| 43 | }; | |
| 44 | ||
| 45 | template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> | |
| 46 | struct __member_pointer_traits_imp | |
| 47 | { | |
| 48 | }; | |
| 49 | ||
| 50 | template <class _Rp, class _Class, class ..._Param> | |
| 51 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> | |
| 52 | { | |
| 53 | typedef _Class _ClassType; | |
| 54 | typedef _Rp _ReturnType; | |
| 55 | typedef _Rp (_FnType) (_Param...); | |
| 56 | }; | |
| 57 | ||
| 58 | template <class _Rp, class _Class, class ..._Param> | |
| 59 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> | |
| 60 | { | |
| 61 | typedef _Class _ClassType; | |
| 62 | typedef _Rp _ReturnType; | |
| 63 | typedef _Rp (_FnType) (_Param..., ...); | |
| 64 | }; | |
| 65 | ||
| 66 | template <class _Rp, class _Class, class ..._Param> | |
| 67 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> | |
| 68 | { | |
| 69 | typedef _Class const _ClassType; | |
| 70 | typedef _Rp _ReturnType; | |
| 71 | typedef _Rp (_FnType) (_Param...); | |
| 72 | }; | |
| 73 | ||
| 74 | template <class _Rp, class _Class, class ..._Param> | |
| 75 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> | |
| 76 | { | |
| 77 | typedef _Class const _ClassType; | |
| 78 | typedef _Rp _ReturnType; | |
| 79 | typedef _Rp (_FnType) (_Param..., ...); | |
| 80 | }; | |
| 81 | ||
| 82 | template <class _Rp, class _Class, class ..._Param> | |
| 83 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> | |
| 84 | { | |
| 85 | typedef _Class volatile _ClassType; | |
| 86 | typedef _Rp _ReturnType; | |
| 87 | typedef _Rp (_FnType) (_Param...); | |
| 88 | }; | |
| 89 | ||
| 90 | template <class _Rp, class _Class, class ..._Param> | |
| 91 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> | |
| 92 | { | |
| 93 | typedef _Class volatile _ClassType; | |
| 94 | typedef _Rp _ReturnType; | |
| 95 | typedef _Rp (_FnType) (_Param..., ...); | |
| 96 | }; | |
| 97 | ||
| 98 | template <class _Rp, class _Class, class ..._Param> | |
| 99 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> | |
| 100 | { | |
| 101 | typedef _Class const volatile _ClassType; | |
| 102 | typedef _Rp _ReturnType; | |
| 103 | typedef _Rp (_FnType) (_Param...); | |
| 104 | }; | |
| 105 | ||
| 106 | template <class _Rp, class _Class, class ..._Param> | |
| 107 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> | |
| 108 | { | |
| 109 | typedef _Class const volatile _ClassType; | |
| 110 | typedef _Rp _ReturnType; | |
| 111 | typedef _Rp (_FnType) (_Param..., ...); | |
| 112 | }; | |
| 113 | ||
| 114 | template <class _Rp, class _Class, class ..._Param> | |
| 115 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> | |
| 116 | { | |
| 117 | typedef _Class& _ClassType; | |
| 118 | typedef _Rp _ReturnType; | |
| 119 | typedef _Rp (_FnType) (_Param...); | |
| 120 | }; | |
| 121 | ||
| 122 | template <class _Rp, class _Class, class ..._Param> | |
| 123 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> | |
| 124 | { | |
| 125 | typedef _Class& _ClassType; | |
| 126 | typedef _Rp _ReturnType; | |
| 127 | typedef _Rp (_FnType) (_Param..., ...); | |
| 128 | }; | |
| 129 | ||
| 130 | template <class _Rp, class _Class, class ..._Param> | |
| 131 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> | |
| 132 | { | |
| 133 | typedef _Class const& _ClassType; | |
| 134 | typedef _Rp _ReturnType; | |
| 135 | typedef _Rp (_FnType) (_Param...); | |
| 136 | }; | |
| 137 | ||
| 138 | template <class _Rp, class _Class, class ..._Param> | |
| 139 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> | |
| 140 | { | |
| 141 | typedef _Class const& _ClassType; | |
| 142 | typedef _Rp _ReturnType; | |
| 143 | typedef _Rp (_FnType) (_Param..., ...); | |
| 144 | }; | |
| 145 | ||
| 146 | template <class _Rp, class _Class, class ..._Param> | |
| 147 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> | |
| 148 | { | |
| 149 | typedef _Class volatile& _ClassType; | |
| 150 | typedef _Rp _ReturnType; | |
| 151 | typedef _Rp (_FnType) (_Param...); | |
| 152 | }; | |
| 153 | ||
| 154 | template <class _Rp, class _Class, class ..._Param> | |
| 155 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> | |
| 156 | { | |
| 157 | typedef _Class volatile& _ClassType; | |
| 158 | typedef _Rp _ReturnType; | |
| 159 | typedef _Rp (_FnType) (_Param..., ...); | |
| 160 | }; | |
| 161 | ||
| 162 | template <class _Rp, class _Class, class ..._Param> | |
| 163 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> | |
| 164 | { | |
| 165 | typedef _Class const volatile& _ClassType; | |
| 166 | typedef _Rp _ReturnType; | |
| 167 | typedef _Rp (_FnType) (_Param...); | |
| 168 | }; | |
| 169 | ||
| 170 | template <class _Rp, class _Class, class ..._Param> | |
| 171 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> | |
| 172 | { | |
| 173 | typedef _Class const volatile& _ClassType; | |
| 174 | typedef _Rp _ReturnType; | |
| 175 | typedef _Rp (_FnType) (_Param..., ...); | |
| 176 | }; | |
| 177 | ||
| 178 | template <class _Rp, class _Class, class ..._Param> | |
| 179 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> | |
| 180 | { | |
| 181 | typedef _Class&& _ClassType; | |
| 182 | typedef _Rp _ReturnType; | |
| 183 | typedef _Rp (_FnType) (_Param...); | |
| 184 | }; | |
| 185 | ||
| 186 | template <class _Rp, class _Class, class ..._Param> | |
| 187 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> | |
| 188 | { | |
| 189 | typedef _Class&& _ClassType; | |
| 190 | typedef _Rp _ReturnType; | |
| 191 | typedef _Rp (_FnType) (_Param..., ...); | |
| 192 | }; | |
| 193 | ||
| 194 | template <class _Rp, class _Class, class ..._Param> | |
| 195 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> | |
| 196 | { | |
| 197 | typedef _Class const&& _ClassType; | |
| 198 | typedef _Rp _ReturnType; | |
| 199 | typedef _Rp (_FnType) (_Param...); | |
| 200 | }; | |
| 201 | ||
| 202 | template <class _Rp, class _Class, class ..._Param> | |
| 203 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> | |
| 204 | { | |
| 205 | typedef _Class const&& _ClassType; | |
| 206 | typedef _Rp _ReturnType; | |
| 207 | typedef _Rp (_FnType) (_Param..., ...); | |
| 208 | }; | |
| 209 | ||
| 210 | template <class _Rp, class _Class, class ..._Param> | |
| 211 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> | |
| 212 | { | |
| 213 | typedef _Class volatile&& _ClassType; | |
| 214 | typedef _Rp _ReturnType; | |
| 215 | typedef _Rp (_FnType) (_Param...); | |
| 216 | }; | |
| 217 | ||
| 218 | template <class _Rp, class _Class, class ..._Param> | |
| 219 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> | |
| 220 | { | |
| 221 | typedef _Class volatile&& _ClassType; | |
| 222 | typedef _Rp _ReturnType; | |
| 223 | typedef _Rp (_FnType) (_Param..., ...); | |
| 224 | }; | |
| 225 | ||
| 226 | template <class _Rp, class _Class, class ..._Param> | |
| 227 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> | |
| 228 | { | |
| 229 | typedef _Class const volatile&& _ClassType; | |
| 230 | typedef _Rp _ReturnType; | |
| 231 | typedef _Rp (_FnType) (_Param...); | |
| 232 | }; | |
| 233 | ||
| 234 | template <class _Rp, class _Class, class ..._Param> | |
| 235 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> | |
| 236 | { | |
| 237 | typedef _Class const volatile&& _ClassType; | |
| 238 | typedef _Rp _ReturnType; | |
| 239 | typedef _Rp (_FnType) (_Param..., ...); | |
| 240 | }; | |
| 241 | ||
| 242 | template <class _Rp, class _Class> | |
| 243 | struct __member_pointer_traits_imp<_Rp _Class::*, false, true> | |
| 244 | { | |
| 245 | typedef _Class _ClassType; | |
| 246 | typedef _Rp _ReturnType; | |
| 247 | }; | |
| 248 | ||
| 249 | template <class _MP> | |
| 250 | struct __member_pointer_traits | |
| 251 | : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, | |
| 252 | is_member_function_pointer<_MP>::value, | |
| 253 | is_member_object_pointer<_MP>::value> | |
| 254 | { | |
| 255 | // typedef ... _ClassType; | |
| 256 | // typedef ... _ReturnType; | |
| 257 | // typedef ... _FnType; | |
| 258 | }; | |
| 259 | ||
| 260 | template <class _DecayedFp> | |
| 261 | struct __member_pointer_class_type {}; | |
| 262 | ||
| 263 | template <class _Ret, class _ClassType> | |
| 264 | struct __member_pointer_class_type<_Ret _ClassType::*> { | |
| 265 | typedef _ClassType type; | |
| 266 | }; | |
| 267 | ||
| 268 | template <class _Fp, class _A0, | |
| 269 | class _DecayFp = typename decay<_Fp>::type, | |
| 270 | class _DecayA0 = typename decay<_A0>::type, | |
| 271 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 272 | using __enable_if_bullet1 = typename enable_if | |
| 273 | < | |
| 274 | is_member_function_pointer<_DecayFp>::value | |
| 275 | && is_base_of<_ClassT, _DecayA0>::value | |
| 276 | >::type; | |
| 277 | ||
| 278 | template <class _Fp, class _A0, | |
| 279 | class _DecayFp = typename decay<_Fp>::type, | |
| 280 | class _DecayA0 = typename decay<_A0>::type> | |
| 281 | using __enable_if_bullet2 = typename enable_if | |
| 282 | < | |
| 283 | is_member_function_pointer<_DecayFp>::value | |
| 284 | && __is_reference_wrapper<_DecayA0>::value | |
| 285 | >::type; | |
| 286 | ||
| 287 | template <class _Fp, class _A0, | |
| 288 | class _DecayFp = typename decay<_Fp>::type, | |
| 289 | class _DecayA0 = typename decay<_A0>::type, | |
| 290 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 291 | using __enable_if_bullet3 = typename enable_if | |
| 292 | < | |
| 293 | is_member_function_pointer<_DecayFp>::value | |
| 294 | && !is_base_of<_ClassT, _DecayA0>::value | |
| 295 | && !__is_reference_wrapper<_DecayA0>::value | |
| 296 | >::type; | |
| 297 | ||
| 298 | template <class _Fp, class _A0, | |
| 299 | class _DecayFp = typename decay<_Fp>::type, | |
| 300 | class _DecayA0 = typename decay<_A0>::type, | |
| 301 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 302 | using __enable_if_bullet4 = typename enable_if | |
| 303 | < | |
| 304 | is_member_object_pointer<_DecayFp>::value | |
| 305 | && is_base_of<_ClassT, _DecayA0>::value | |
| 306 | >::type; | |
| 307 | ||
| 308 | template <class _Fp, class _A0, | |
| 309 | class _DecayFp = typename decay<_Fp>::type, | |
| 310 | class _DecayA0 = typename decay<_A0>::type> | |
| 311 | using __enable_if_bullet5 = typename enable_if | |
| 312 | < | |
| 313 | is_member_object_pointer<_DecayFp>::value | |
| 314 | && __is_reference_wrapper<_DecayA0>::value | |
| 315 | >::type; | |
| 316 | ||
| 317 | template <class _Fp, class _A0, | |
| 318 | class _DecayFp = typename decay<_Fp>::type, | |
| 319 | class _DecayA0 = typename decay<_A0>::type, | |
| 320 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 321 | using __enable_if_bullet6 = typename enable_if | |
| 322 | < | |
| 323 | is_member_object_pointer<_DecayFp>::value | |
| 324 | && !is_base_of<_ClassT, _DecayA0>::value | |
| 325 | && !__is_reference_wrapper<_DecayA0>::value | |
| 326 | >::type; | |
| 327 | ||
| 328 | // __invoke forward declarations | |
| 329 | ||
| 330 | // fall back - none of the bullets | |
| 331 | ||
| 332 | template <class ..._Args> | |
| 333 | __nat __invoke(__any, _Args&& ...__args); | |
| 334 | ||
| 335 | // bullets 1, 2 and 3 | |
| 336 | ||
| 337 | template <class _Fp, class _A0, class ..._Args, | |
| 338 | class = __enable_if_bullet1<_Fp, _A0> > | |
| 339 | inline _LIBCPP_INLINE_VISIBILITY | |
| 340 | _LIBCPP_CONSTEXPR decltype((std::declval<_A0>().*std::declval<_Fp>())(std::declval<_Args>()...)) | |
| 341 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 342 | _NOEXCEPT_(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))) | |
| 343 | { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); } | |
| 344 | ||
| 345 | template <class _Fp, class _A0, class ..._Args, | |
| 346 | class = __enable_if_bullet2<_Fp, _A0> > | |
| 347 | inline _LIBCPP_INLINE_VISIBILITY | |
| 348 | _LIBCPP_CONSTEXPR decltype((std::declval<_A0>().get().*std::declval<_Fp>())(std::declval<_Args>()...)) | |
| 349 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 350 | _NOEXCEPT_(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...))) | |
| 351 | { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); } | |
| 352 | ||
| 353 | template <class _Fp, class _A0, class ..._Args, | |
| 354 | class = __enable_if_bullet3<_Fp, _A0> > | |
| 355 | inline _LIBCPP_INLINE_VISIBILITY | |
| 356 | _LIBCPP_CONSTEXPR decltype(((*std::declval<_A0>()).*std::declval<_Fp>())(std::declval<_Args>()...)) | |
| 357 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 358 | _NOEXCEPT_(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))) | |
| 359 | { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); } | |
| 360 | ||
| 361 | // bullets 4, 5 and 6 | |
| 362 | ||
| 363 | template <class _Fp, class _A0, | |
| 364 | class = __enable_if_bullet4<_Fp, _A0> > | |
| 365 | inline _LIBCPP_INLINE_VISIBILITY | |
| 366 | _LIBCPP_CONSTEXPR decltype(std::declval<_A0>().*std::declval<_Fp>()) | |
| 367 | __invoke(_Fp&& __f, _A0&& __a0) | |
| 368 | _NOEXCEPT_(noexcept(static_cast<_A0&&>(__a0).*__f)) | |
| 369 | { return static_cast<_A0&&>(__a0).*__f; } | |
| 370 | ||
| 371 | template <class _Fp, class _A0, | |
| 372 | class = __enable_if_bullet5<_Fp, _A0> > | |
| 373 | inline _LIBCPP_INLINE_VISIBILITY | |
| 374 | _LIBCPP_CONSTEXPR decltype(std::declval<_A0>().get().*std::declval<_Fp>()) | |
| 375 | __invoke(_Fp&& __f, _A0&& __a0) | |
| 376 | _NOEXCEPT_(noexcept(__a0.get().*__f)) | |
| 377 | { return __a0.get().*__f; } | |
| 378 | ||
| 379 | template <class _Fp, class _A0, | |
| 380 | class = __enable_if_bullet6<_Fp, _A0> > | |
| 381 | inline _LIBCPP_INLINE_VISIBILITY | |
| 382 | _LIBCPP_CONSTEXPR decltype((*std::declval<_A0>()).*std::declval<_Fp>()) | |
| 383 | __invoke(_Fp&& __f, _A0&& __a0) | |
| 384 | _NOEXCEPT_(noexcept((*static_cast<_A0&&>(__a0)).*__f)) | |
| 385 | { return (*static_cast<_A0&&>(__a0)).*__f; } | |
| 386 | ||
| 387 | // bullet 7 | |
| 388 | ||
| 389 | template <class _Fp, class ..._Args> | |
| 390 | inline _LIBCPP_INLINE_VISIBILITY | |
| 391 | _LIBCPP_CONSTEXPR decltype(std::declval<_Fp>()(std::declval<_Args>()...)) | |
| 392 | __invoke(_Fp&& __f, _Args&& ...__args) | |
| 393 | _NOEXCEPT_(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))) | |
| 394 | { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); } | |
| 395 | ||
| 396 | // __invokable | |
| 397 | template <class _Ret, class _Fp, class ..._Args> | |
| 398 | struct __invokable_r | |
| 399 | { | |
| 400 | template <class _XFp, class ..._XArgs> | |
| 401 | static decltype(std::__invoke(declval<_XFp>(), declval<_XArgs>()...)) __try_call(int); | |
| 402 | template <class _XFp, class ..._XArgs> | |
| 403 | static __nat __try_call(...); | |
| 404 | ||
| 405 | // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, | |
| 406 | // or incomplete array types as required by the standard. | |
| 407 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); | |
| 408 | ||
| 409 | using type = typename conditional< | |
| 410 | _IsNotSame<_Result, __nat>::value, | |
| 411 | typename conditional< is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >::type, | |
| 412 | false_type >::type; | |
| 413 | static const bool value = type::value; | |
| 414 | }; | |
| 415 | template <class _Fp, class ..._Args> | |
| 416 | using __invokable = __invokable_r<void, _Fp, _Args...>; | |
| 417 | ||
| 418 | template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args> | |
| 419 | struct __nothrow_invokable_r_imp { | |
| 420 | static const bool value = false; | |
| 421 | }; | |
| 422 | ||
| 423 | template <class _Ret, class _Fp, class ..._Args> | |
| 424 | struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> | |
| 425 | { | |
| 426 | typedef __nothrow_invokable_r_imp _ThisT; | |
| 427 | ||
| 428 | template <class _Tp> | |
| 429 | static void __test_noexcept(_Tp) _NOEXCEPT; | |
| 430 | ||
| 431 | static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( | |
| 432 | _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...))); | |
| 433 | }; | |
| 434 | ||
| 435 | template <class _Ret, class _Fp, class ..._Args> | |
| 436 | struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> | |
| 437 | { | |
| 438 | static const bool value = noexcept( | |
| 439 | _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)); | |
| 440 | }; | |
| 441 | ||
| 442 | template <class _Ret, class _Fp, class ..._Args> | |
| 443 | using __nothrow_invokable_r = | |
| 444 | __nothrow_invokable_r_imp< | |
| 445 | __invokable_r<_Ret, _Fp, _Args...>::value, | |
| 446 | is_void<_Ret>::value, | |
| 447 | _Ret, _Fp, _Args... | |
| 448 | >; | |
| 449 | ||
| 450 | template <class _Fp, class ..._Args> | |
| 451 | using __nothrow_invokable = | |
| 452 | __nothrow_invokable_r_imp< | |
| 453 | __invokable<_Fp, _Args...>::value, | |
| 454 | true, void, _Fp, _Args... | |
| 455 | >; | |
| 456 | ||
| 457 | template <class _Fp, class ..._Args> | |
| 458 | struct __invoke_of | |
| 459 | : public enable_if< | |
| 460 | __invokable<_Fp, _Args...>::value, | |
| 461 | typename __invokable_r<void, _Fp, _Args...>::_Result> | |
| 462 | { | |
| 463 | }; | |
| 464 | ||
| 24 | 465 | template <class _Ret, bool = is_void<_Ret>::value> |
| 25 | 466 | struct __invoke_void_return_wrapper |
| 26 | 467 | { |
| 27 | #ifndef _LIBCPP_CXX03_LANG | |
| 28 | 468 | template <class ..._Args> |
| 29 | 469 | static _Ret __call(_Args&&... __args) { |
| 30 | return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...); | |
| 31 | } | |
| 32 | #else | |
| 33 | template <class _Fn> | |
| 34 | static _Ret __call(_Fn __f) { | |
| 35 | return _VSTD::__invoke(__f); | |
| 470 | return std::__invoke(std::forward<_Args>(__args)...); | |
| 36 | 471 | } |
| 37 | ||
| 38 | template <class _Fn, class _A0> | |
| 39 | static _Ret __call(_Fn __f, _A0& __a0) { | |
| 40 | return _VSTD::__invoke(__f, __a0); | |
| 41 | } | |
| 42 | ||
| 43 | template <class _Fn, class _A0, class _A1> | |
| 44 | static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) { | |
| 45 | return _VSTD::__invoke(__f, __a0, __a1); | |
| 46 | } | |
| 47 | ||
| 48 | template <class _Fn, class _A0, class _A1, class _A2> | |
| 49 | static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){ | |
| 50 | return _VSTD::__invoke(__f, __a0, __a1, __a2); | |
| 51 | } | |
| 52 | #endif | |
| 53 | 472 | }; |
| 54 | 473 | |
| 55 | 474 | template <class _Ret> |
| 56 | 475 | struct __invoke_void_return_wrapper<_Ret, true> |
| 57 | 476 | { |
| 58 | #ifndef _LIBCPP_CXX03_LANG | |
| 59 | 477 | template <class ..._Args> |
| 60 | 478 | static void __call(_Args&&... __args) { |
| 61 | _VSTD::__invoke(_VSTD::forward<_Args>(__args)...); | |
| 62 | } | |
| 63 | #else | |
| 64 | template <class _Fn> | |
| 65 | static void __call(_Fn __f) { | |
| 66 | _VSTD::__invoke(__f); | |
| 479 | std::__invoke(std::forward<_Args>(__args)...); | |
| 67 | 480 | } |
| 481 | }; | |
| 68 | 482 | |
| 69 | template <class _Fn, class _A0> | |
| 70 | static void __call(_Fn __f, _A0& __a0) { | |
| 71 | _VSTD::__invoke(__f, __a0); | |
| 72 | } | |
| 483 | #if _LIBCPP_STD_VER > 14 | |
| 73 | 484 | |
| 74 | template <class _Fn, class _A0, class _A1> | |
| 75 | static void __call(_Fn __f, _A0& __a0, _A1& __a1) { | |
| 76 | _VSTD::__invoke(__f, __a0, __a1); | |
| 77 | } | |
| 485 | // is_invocable | |
| 78 | 486 | |
| 79 | template <class _Fn, class _A0, class _A1, class _A2> | |
| 80 | static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) { | |
| 81 | _VSTD::__invoke(__f, __a0, __a1, __a2); | |
| 82 | } | |
| 83 | #endif | |
| 487 | template <class _Fn, class ..._Args> | |
| 488 | struct _LIBCPP_TEMPLATE_VIS is_invocable | |
| 489 | : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; | |
| 490 | ||
| 491 | template <class _Ret, class _Fn, class ..._Args> | |
| 492 | struct _LIBCPP_TEMPLATE_VIS is_invocable_r | |
| 493 | : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 494 | ||
| 495 | template <class _Fn, class ..._Args> | |
| 496 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
| 497 | ||
| 498 | template <class _Ret, class _Fn, class ..._Args> | |
| 499 | inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 500 | ||
| 501 | // is_nothrow_invocable | |
| 502 | ||
| 503 | template <class _Fn, class ..._Args> | |
| 504 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable | |
| 505 | : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {}; | |
| 506 | ||
| 507 | template <class _Ret, class _Fn, class ..._Args> | |
| 508 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r | |
| 509 | : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 510 | ||
| 511 | template <class _Fn, class ..._Args> | |
| 512 | inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; | |
| 513 | ||
| 514 | template <class _Ret, class _Fn, class ..._Args> | |
| 515 | inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 516 | ||
| 517 | template <class _Fn, class... _Args> | |
| 518 | struct _LIBCPP_TEMPLATE_VIS invoke_result | |
| 519 | : __invoke_of<_Fn, _Args...> | |
| 520 | { | |
| 84 | 521 | }; |
| 85 | 522 | |
| 86 | #if _LIBCPP_STD_VER > 14 | |
| 523 | template <class _Fn, class... _Args> | |
| 524 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; | |
| 87 | 525 | |
| 88 | 526 | template <class _Fn, class ..._Args> |
| 89 | 527 | _LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...> |
lib/libcxx/include/__functional/is_transparent.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__functional/mem_fn.h+6-108| ... | ... | @@ -14,19 +14,17 @@ |
| 14 | 14 | #include <__functional/binary_function.h> |
| 15 | 15 | #include <__functional/invoke.h> |
| 16 | 16 | #include <__functional/weak_result_type.h> |
| 17 | #include <utility> | |
| 17 | #include <__utility/forward.h> | |
| 18 | #include <type_traits> | |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 25 | |
| 25 | 26 | template <class _Tp> |
| 26 | class __mem_fn | |
| 27 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 28 | : public __weak_result_type<_Tp> | |
| 29 | #endif | |
| 27 | class __mem_fn : public __weak_result_type<_Tp> | |
| 30 | 28 | { |
| 31 | 29 | public: |
| 32 | 30 | // types |
| ... | ... | @@ -38,114 +36,14 @@ public: |
| 38 | 36 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 39 | 37 | __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} |
| 40 | 38 | |
| 41 | #ifndef _LIBCPP_CXX03_LANG | |
| 42 | 39 | // invoke |
| 43 | 40 | template <class... _ArgTypes> |
| 44 | 41 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 42 | ||
| 45 | 43 | typename __invoke_return<type, _ArgTypes...>::type |
| 46 | 44 | operator() (_ArgTypes&&... __args) const { |
| 47 | return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); | |
| 48 | } | |
| 49 | #else | |
| 50 | ||
| 51 | template <class _A0> | |
| 52 | _LIBCPP_INLINE_VISIBILITY | |
| 53 | typename __invoke_return0<type, _A0>::type | |
| 54 | operator() (_A0& __a0) const { | |
| 55 | return _VSTD::__invoke(__f_, __a0); | |
| 56 | } | |
| 57 | ||
| 58 | template <class _A0> | |
| 59 | _LIBCPP_INLINE_VISIBILITY | |
| 60 | typename __invoke_return0<type, _A0 const>::type | |
| 61 | operator() (_A0 const& __a0) const { | |
| 62 | return _VSTD::__invoke(__f_, __a0); | |
| 63 | } | |
| 64 | ||
| 65 | template <class _A0, class _A1> | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | typename __invoke_return1<type, _A0, _A1>::type | |
| 68 | operator() (_A0& __a0, _A1& __a1) const { | |
| 69 | return _VSTD::__invoke(__f_, __a0, __a1); | |
| 70 | } | |
| 71 | ||
| 72 | template <class _A0, class _A1> | |
| 73 | _LIBCPP_INLINE_VISIBILITY | |
| 74 | typename __invoke_return1<type, _A0 const, _A1>::type | |
| 75 | operator() (_A0 const& __a0, _A1& __a1) const { | |
| 76 | return _VSTD::__invoke(__f_, __a0, __a1); | |
| 77 | } | |
| 78 | ||
| 79 | template <class _A0, class _A1> | |
| 80 | _LIBCPP_INLINE_VISIBILITY | |
| 81 | typename __invoke_return1<type, _A0, _A1 const>::type | |
| 82 | operator() (_A0& __a0, _A1 const& __a1) const { | |
| 83 | return _VSTD::__invoke(__f_, __a0, __a1); | |
| 84 | } | |
| 85 | ||
| 86 | template <class _A0, class _A1> | |
| 87 | _LIBCPP_INLINE_VISIBILITY | |
| 88 | typename __invoke_return1<type, _A0 const, _A1 const>::type | |
| 89 | operator() (_A0 const& __a0, _A1 const& __a1) const { | |
| 90 | return _VSTD::__invoke(__f_, __a0, __a1); | |
| 91 | } | |
| 92 | ||
| 93 | template <class _A0, class _A1, class _A2> | |
| 94 | _LIBCPP_INLINE_VISIBILITY | |
| 95 | typename __invoke_return2<type, _A0, _A1, _A2>::type | |
| 96 | operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { | |
| 97 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 45 | return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...); | |
| 98 | 46 | } |
| 99 | ||
| 100 | template <class _A0, class _A1, class _A2> | |
| 101 | _LIBCPP_INLINE_VISIBILITY | |
| 102 | typename __invoke_return2<type, _A0 const, _A1, _A2>::type | |
| 103 | operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { | |
| 104 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 105 | } | |
| 106 | ||
| 107 | template <class _A0, class _A1, class _A2> | |
| 108 | _LIBCPP_INLINE_VISIBILITY | |
| 109 | typename __invoke_return2<type, _A0, _A1 const, _A2>::type | |
| 110 | operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { | |
| 111 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 112 | } | |
| 113 | ||
| 114 | template <class _A0, class _A1, class _A2> | |
| 115 | _LIBCPP_INLINE_VISIBILITY | |
| 116 | typename __invoke_return2<type, _A0, _A1, _A2 const>::type | |
| 117 | operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { | |
| 118 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 119 | } | |
| 120 | ||
| 121 | template <class _A0, class _A1, class _A2> | |
| 122 | _LIBCPP_INLINE_VISIBILITY | |
| 123 | typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type | |
| 124 | operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { | |
| 125 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 126 | } | |
| 127 | ||
| 128 | template <class _A0, class _A1, class _A2> | |
| 129 | _LIBCPP_INLINE_VISIBILITY | |
| 130 | typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type | |
| 131 | operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { | |
| 132 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 133 | } | |
| 134 | ||
| 135 | template <class _A0, class _A1, class _A2> | |
| 136 | _LIBCPP_INLINE_VISIBILITY | |
| 137 | typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type | |
| 138 | operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { | |
| 139 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 140 | } | |
| 141 | ||
| 142 | template <class _A0, class _A1, class _A2> | |
| 143 | _LIBCPP_INLINE_VISIBILITY | |
| 144 | typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type | |
| 145 | operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { | |
| 146 | return _VSTD::__invoke(__f_, __a0, __a1, __a2); | |
| 147 | } | |
| 148 | #endif | |
| 149 | 47 | }; |
| 150 | 48 | |
| 151 | 49 | template<class _Rp, class _Tp> |
lib/libcxx/include/__functional/mem_fun_ref.h+9-9| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <__functional/unary_function.h> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | template<class _Sp, class _Tp> |
| 26 | 26 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t |
| 27 | : public unary_function<_Tp*, _Sp> | |
| 27 | : public __unary_function<_Tp*, _Sp> | |
| 28 | 28 | { |
| 29 | 29 | _Sp (_Tp::*__p_)(); |
| 30 | 30 | public: |
| ... | ... | @@ -36,7 +36,7 @@ public: |
| 36 | 36 | |
| 37 | 37 | template<class _Sp, class _Tp, class _Ap> |
| 38 | 38 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t |
| 39 | : public binary_function<_Tp*, _Ap, _Sp> | |
| 39 | : public __binary_function<_Tp*, _Ap, _Sp> | |
| 40 | 40 | { |
| 41 | 41 | _Sp (_Tp::*__p_)(_Ap); |
| 42 | 42 | public: |
| ... | ... | @@ -60,7 +60,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap)) |
| 60 | 60 | |
| 61 | 61 | template<class _Sp, class _Tp> |
| 62 | 62 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t |
| 63 | : public unary_function<_Tp, _Sp> | |
| 63 | : public __unary_function<_Tp, _Sp> | |
| 64 | 64 | { |
| 65 | 65 | _Sp (_Tp::*__p_)(); |
| 66 | 66 | public: |
| ... | ... | @@ -72,7 +72,7 @@ public: |
| 72 | 72 | |
| 73 | 73 | template<class _Sp, class _Tp, class _Ap> |
| 74 | 74 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t |
| 75 | : public binary_function<_Tp, _Ap, _Sp> | |
| 75 | : public __binary_function<_Tp, _Ap, _Sp> | |
| 76 | 76 | { |
| 77 | 77 | _Sp (_Tp::*__p_)(_Ap); |
| 78 | 78 | public: |
| ... | ... | @@ -96,7 +96,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) |
| 96 | 96 | |
| 97 | 97 | template <class _Sp, class _Tp> |
| 98 | 98 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t |
| 99 | : public unary_function<const _Tp*, _Sp> | |
| 99 | : public __unary_function<const _Tp*, _Sp> | |
| 100 | 100 | { |
| 101 | 101 | _Sp (_Tp::*__p_)() const; |
| 102 | 102 | public: |
| ... | ... | @@ -108,7 +108,7 @@ public: |
| 108 | 108 | |
| 109 | 109 | template <class _Sp, class _Tp, class _Ap> |
| 110 | 110 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t |
| 111 | : public binary_function<const _Tp*, _Ap, _Sp> | |
| 111 | : public __binary_function<const _Tp*, _Ap, _Sp> | |
| 112 | 112 | { |
| 113 | 113 | _Sp (_Tp::*__p_)(_Ap) const; |
| 114 | 114 | public: |
| ... | ... | @@ -132,7 +132,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) |
| 132 | 132 | |
| 133 | 133 | template <class _Sp, class _Tp> |
| 134 | 134 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t |
| 135 | : public unary_function<_Tp, _Sp> | |
| 135 | : public __unary_function<_Tp, _Sp> | |
| 136 | 136 | { |
| 137 | 137 | _Sp (_Tp::*__p_)() const; |
| 138 | 138 | public: |
| ... | ... | @@ -144,7 +144,7 @@ public: |
| 144 | 144 | |
| 145 | 145 | template <class _Sp, class _Tp, class _Ap> |
| 146 | 146 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t |
| 147 | : public binary_function<_Tp, _Ap, _Sp> | |
| 147 | : public __binary_function<_Tp, _Ap, _Sp> | |
| 148 | 148 | { |
| 149 | 149 | _Sp (_Tp::*__p_)(_Ap) const; |
| 150 | 150 | public: |
lib/libcxx/include/__functional/not_fn.h+3-2| ... | ... | @@ -13,10 +13,11 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__functional/invoke.h> |
| 15 | 15 | #include <__functional/perfect_forward.h> |
| 16 | #include <utility> | |
| 16 | #include <__utility/forward.h> | |
| 17 | #include <type_traits> | |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__functional/operations.h+20-188| ... | ... | @@ -16,31 +16,22 @@ |
| 16 | 16 | #include <__utility/forward.h> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | // Arithmetic operations |
| 25 | 25 | |
| 26 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 27 | 26 | #if _LIBCPP_STD_VER > 11 |
| 28 | 27 | template <class _Tp = void> |
| 29 | 28 | #else |
| 30 | 29 | template <class _Tp> |
| 31 | 30 | #endif |
| 32 | 31 | struct _LIBCPP_TEMPLATE_VIS plus |
| 33 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 34 | : binary_function<_Tp, _Tp, _Tp> | |
| 35 | #endif | |
| 32 | : __binary_function<_Tp, _Tp, _Tp> | |
| 36 | 33 | { |
| 37 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 38 | 34 | typedef _Tp __result_type; // used by valarray |
| 39 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 40 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 41 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 42 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 43 | #endif | |
| 44 | 35 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 45 | 36 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 46 | 37 | {return __x + __y;} |
| ... | ... | @@ -60,24 +51,15 @@ struct _LIBCPP_TEMPLATE_VIS plus<void> |
| 60 | 51 | }; |
| 61 | 52 | #endif |
| 62 | 53 | |
| 63 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 64 | 54 | #if _LIBCPP_STD_VER > 11 |
| 65 | 55 | template <class _Tp = void> |
| 66 | 56 | #else |
| 67 | 57 | template <class _Tp> |
| 68 | 58 | #endif |
| 69 | 59 | struct _LIBCPP_TEMPLATE_VIS minus |
| 70 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 71 | : binary_function<_Tp, _Tp, _Tp> | |
| 72 | #endif | |
| 60 | : __binary_function<_Tp, _Tp, _Tp> | |
| 73 | 61 | { |
| 74 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 75 | 62 | typedef _Tp __result_type; // used by valarray |
| 76 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 77 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 78 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 79 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 80 | #endif | |
| 81 | 63 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 82 | 64 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 83 | 65 | {return __x - __y;} |
| ... | ... | @@ -97,24 +79,15 @@ struct _LIBCPP_TEMPLATE_VIS minus<void> |
| 97 | 79 | }; |
| 98 | 80 | #endif |
| 99 | 81 | |
| 100 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 101 | 82 | #if _LIBCPP_STD_VER > 11 |
| 102 | 83 | template <class _Tp = void> |
| 103 | 84 | #else |
| 104 | 85 | template <class _Tp> |
| 105 | 86 | #endif |
| 106 | 87 | struct _LIBCPP_TEMPLATE_VIS multiplies |
| 107 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 108 | : binary_function<_Tp, _Tp, _Tp> | |
| 109 | #endif | |
| 88 | : __binary_function<_Tp, _Tp, _Tp> | |
| 110 | 89 | { |
| 111 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 112 | 90 | typedef _Tp __result_type; // used by valarray |
| 113 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 114 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 115 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 116 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 117 | #endif | |
| 118 | 91 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 119 | 92 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 120 | 93 | {return __x * __y;} |
| ... | ... | @@ -134,24 +107,15 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void> |
| 134 | 107 | }; |
| 135 | 108 | #endif |
| 136 | 109 | |
| 137 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 138 | 110 | #if _LIBCPP_STD_VER > 11 |
| 139 | 111 | template <class _Tp = void> |
| 140 | 112 | #else |
| 141 | 113 | template <class _Tp> |
| 142 | 114 | #endif |
| 143 | 115 | struct _LIBCPP_TEMPLATE_VIS divides |
| 144 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 145 | : binary_function<_Tp, _Tp, _Tp> | |
| 146 | #endif | |
| 116 | : __binary_function<_Tp, _Tp, _Tp> | |
| 147 | 117 | { |
| 148 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 149 | 118 | typedef _Tp __result_type; // used by valarray |
| 150 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 151 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 152 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 153 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 154 | #endif | |
| 155 | 119 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 156 | 120 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 157 | 121 | {return __x / __y;} |
| ... | ... | @@ -171,24 +135,15 @@ struct _LIBCPP_TEMPLATE_VIS divides<void> |
| 171 | 135 | }; |
| 172 | 136 | #endif |
| 173 | 137 | |
| 174 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 175 | 138 | #if _LIBCPP_STD_VER > 11 |
| 176 | 139 | template <class _Tp = void> |
| 177 | 140 | #else |
| 178 | 141 | template <class _Tp> |
| 179 | 142 | #endif |
| 180 | 143 | struct _LIBCPP_TEMPLATE_VIS modulus |
| 181 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 182 | : binary_function<_Tp, _Tp, _Tp> | |
| 183 | #endif | |
| 144 | : __binary_function<_Tp, _Tp, _Tp> | |
| 184 | 145 | { |
| 185 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 186 | 146 | typedef _Tp __result_type; // used by valarray |
| 187 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 188 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 189 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 190 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 191 | #endif | |
| 192 | 147 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 193 | 148 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 194 | 149 | {return __x % __y;} |
| ... | ... | @@ -208,23 +163,15 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void> |
| 208 | 163 | }; |
| 209 | 164 | #endif |
| 210 | 165 | |
| 211 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 212 | 166 | #if _LIBCPP_STD_VER > 11 |
| 213 | 167 | template <class _Tp = void> |
| 214 | 168 | #else |
| 215 | 169 | template <class _Tp> |
| 216 | 170 | #endif |
| 217 | 171 | struct _LIBCPP_TEMPLATE_VIS negate |
| 218 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 219 | : unary_function<_Tp, _Tp> | |
| 220 | #endif | |
| 172 | : __unary_function<_Tp, _Tp> | |
| 221 | 173 | { |
| 222 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 223 | 174 | typedef _Tp __result_type; // used by valarray |
| 224 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 225 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 226 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 227 | #endif | |
| 228 | 175 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 229 | 176 | _Tp operator()(const _Tp& __x) const |
| 230 | 177 | {return -__x;} |
| ... | ... | @@ -246,24 +193,15 @@ struct _LIBCPP_TEMPLATE_VIS negate<void> |
| 246 | 193 | |
| 247 | 194 | // Bitwise operations |
| 248 | 195 | |
| 249 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 250 | 196 | #if _LIBCPP_STD_VER > 11 |
| 251 | 197 | template <class _Tp = void> |
| 252 | 198 | #else |
| 253 | 199 | template <class _Tp> |
| 254 | 200 | #endif |
| 255 | 201 | struct _LIBCPP_TEMPLATE_VIS bit_and |
| 256 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 257 | : binary_function<_Tp, _Tp, _Tp> | |
| 258 | #endif | |
| 202 | : __binary_function<_Tp, _Tp, _Tp> | |
| 259 | 203 | { |
| 260 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 261 | 204 | typedef _Tp __result_type; // used by valarray |
| 262 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 263 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 264 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 265 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 266 | #endif | |
| 267 | 205 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 268 | 206 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 269 | 207 | {return __x & __y;} |
| ... | ... | @@ -284,18 +222,10 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> |
| 284 | 222 | #endif |
| 285 | 223 | |
| 286 | 224 | #if _LIBCPP_STD_VER > 11 |
| 287 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 288 | 225 | template <class _Tp = void> |
| 289 | 226 | struct _LIBCPP_TEMPLATE_VIS bit_not |
| 290 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 291 | : unary_function<_Tp, _Tp> | |
| 292 | #endif | |
| 227 | : __unary_function<_Tp, _Tp> | |
| 293 | 228 | { |
| 294 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 295 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 296 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 297 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 298 | #endif | |
| 299 | 229 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 300 | 230 | _Tp operator()(const _Tp& __x) const |
| 301 | 231 | {return ~__x;} |
| ... | ... | @@ -314,24 +244,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void> |
| 314 | 244 | }; |
| 315 | 245 | #endif |
| 316 | 246 | |
| 317 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 318 | 247 | #if _LIBCPP_STD_VER > 11 |
| 319 | 248 | template <class _Tp = void> |
| 320 | 249 | #else |
| 321 | 250 | template <class _Tp> |
| 322 | 251 | #endif |
| 323 | 252 | struct _LIBCPP_TEMPLATE_VIS bit_or |
| 324 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 325 | : binary_function<_Tp, _Tp, _Tp> | |
| 326 | #endif | |
| 253 | : __binary_function<_Tp, _Tp, _Tp> | |
| 327 | 254 | { |
| 328 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 329 | 255 | typedef _Tp __result_type; // used by valarray |
| 330 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 331 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 332 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 333 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 334 | #endif | |
| 335 | 256 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 336 | 257 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 337 | 258 | {return __x | __y;} |
| ... | ... | @@ -351,24 +272,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void> |
| 351 | 272 | }; |
| 352 | 273 | #endif |
| 353 | 274 | |
| 354 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 355 | 275 | #if _LIBCPP_STD_VER > 11 |
| 356 | 276 | template <class _Tp = void> |
| 357 | 277 | #else |
| 358 | 278 | template <class _Tp> |
| 359 | 279 | #endif |
| 360 | 280 | struct _LIBCPP_TEMPLATE_VIS bit_xor |
| 361 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 362 | : binary_function<_Tp, _Tp, _Tp> | |
| 363 | #endif | |
| 281 | : __binary_function<_Tp, _Tp, _Tp> | |
| 364 | 282 | { |
| 365 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 366 | 283 | typedef _Tp __result_type; // used by valarray |
| 367 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 368 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; | |
| 369 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 370 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 371 | #endif | |
| 372 | 284 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 373 | 285 | _Tp operator()(const _Tp& __x, const _Tp& __y) const |
| 374 | 286 | {return __x ^ __y;} |
| ... | ... | @@ -390,24 +302,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void> |
| 390 | 302 | |
| 391 | 303 | // Comparison operations |
| 392 | 304 | |
| 393 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 394 | 305 | #if _LIBCPP_STD_VER > 11 |
| 395 | 306 | template <class _Tp = void> |
| 396 | 307 | #else |
| 397 | 308 | template <class _Tp> |
| 398 | 309 | #endif |
| 399 | 310 | struct _LIBCPP_TEMPLATE_VIS equal_to |
| 400 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 401 | : binary_function<_Tp, _Tp, bool> | |
| 402 | #endif | |
| 311 | : __binary_function<_Tp, _Tp, bool> | |
| 403 | 312 | { |
| 404 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 405 | 313 | typedef bool __result_type; // used by valarray |
| 406 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 407 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 408 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 409 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 410 | #endif | |
| 411 | 314 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 412 | 315 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 413 | 316 | {return __x == __y;} |
| ... | ... | @@ -427,24 +330,15 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void> |
| 427 | 330 | }; |
| 428 | 331 | #endif |
| 429 | 332 | |
| 430 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 431 | 333 | #if _LIBCPP_STD_VER > 11 |
| 432 | 334 | template <class _Tp = void> |
| 433 | 335 | #else |
| 434 | 336 | template <class _Tp> |
| 435 | 337 | #endif |
| 436 | 338 | struct _LIBCPP_TEMPLATE_VIS not_equal_to |
| 437 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 438 | : binary_function<_Tp, _Tp, bool> | |
| 439 | #endif | |
| 339 | : __binary_function<_Tp, _Tp, bool> | |
| 440 | 340 | { |
| 441 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 442 | 341 | typedef bool __result_type; // used by valarray |
| 443 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 444 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 445 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 446 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 447 | #endif | |
| 448 | 342 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 449 | 343 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 450 | 344 | {return __x != __y;} |
| ... | ... | @@ -464,24 +358,15 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> |
| 464 | 358 | }; |
| 465 | 359 | #endif |
| 466 | 360 | |
| 467 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 468 | 361 | #if _LIBCPP_STD_VER > 11 |
| 469 | 362 | template <class _Tp = void> |
| 470 | 363 | #else |
| 471 | 364 | template <class _Tp> |
| 472 | 365 | #endif |
| 473 | 366 | struct _LIBCPP_TEMPLATE_VIS less |
| 474 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 475 | : binary_function<_Tp, _Tp, bool> | |
| 476 | #endif | |
| 367 | : __binary_function<_Tp, _Tp, bool> | |
| 477 | 368 | { |
| 478 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 479 | 369 | typedef bool __result_type; // used by valarray |
| 480 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 481 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 482 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 483 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 484 | #endif | |
| 485 | 370 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 486 | 371 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 487 | 372 | {return __x < __y;} |
| ... | ... | @@ -501,24 +386,15 @@ struct _LIBCPP_TEMPLATE_VIS less<void> |
| 501 | 386 | }; |
| 502 | 387 | #endif |
| 503 | 388 | |
| 504 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 505 | 389 | #if _LIBCPP_STD_VER > 11 |
| 506 | 390 | template <class _Tp = void> |
| 507 | 391 | #else |
| 508 | 392 | template <class _Tp> |
| 509 | 393 | #endif |
| 510 | 394 | struct _LIBCPP_TEMPLATE_VIS less_equal |
| 511 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 512 | : binary_function<_Tp, _Tp, bool> | |
| 513 | #endif | |
| 395 | : __binary_function<_Tp, _Tp, bool> | |
| 514 | 396 | { |
| 515 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 516 | 397 | typedef bool __result_type; // used by valarray |
| 517 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 518 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 519 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 520 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 521 | #endif | |
| 522 | 398 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 523 | 399 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 524 | 400 | {return __x <= __y;} |
| ... | ... | @@ -538,24 +414,15 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void> |
| 538 | 414 | }; |
| 539 | 415 | #endif |
| 540 | 416 | |
| 541 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 542 | 417 | #if _LIBCPP_STD_VER > 11 |
| 543 | 418 | template <class _Tp = void> |
| 544 | 419 | #else |
| 545 | 420 | template <class _Tp> |
| 546 | 421 | #endif |
| 547 | 422 | struct _LIBCPP_TEMPLATE_VIS greater_equal |
| 548 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 549 | : binary_function<_Tp, _Tp, bool> | |
| 550 | #endif | |
| 423 | : __binary_function<_Tp, _Tp, bool> | |
| 551 | 424 | { |
| 552 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 553 | 425 | typedef bool __result_type; // used by valarray |
| 554 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 555 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 556 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 557 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 558 | #endif | |
| 559 | 426 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 560 | 427 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 561 | 428 | {return __x >= __y;} |
| ... | ... | @@ -575,24 +442,15 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void> |
| 575 | 442 | }; |
| 576 | 443 | #endif |
| 577 | 444 | |
| 578 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 579 | 445 | #if _LIBCPP_STD_VER > 11 |
| 580 | 446 | template <class _Tp = void> |
| 581 | 447 | #else |
| 582 | 448 | template <class _Tp> |
| 583 | 449 | #endif |
| 584 | 450 | struct _LIBCPP_TEMPLATE_VIS greater |
| 585 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 586 | : binary_function<_Tp, _Tp, bool> | |
| 587 | #endif | |
| 451 | : __binary_function<_Tp, _Tp, bool> | |
| 588 | 452 | { |
| 589 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 590 | 453 | typedef bool __result_type; // used by valarray |
| 591 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 592 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 593 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 594 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 595 | #endif | |
| 596 | 454 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 597 | 455 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 598 | 456 | {return __x > __y;} |
| ... | ... | @@ -614,24 +472,15 @@ struct _LIBCPP_TEMPLATE_VIS greater<void> |
| 614 | 472 | |
| 615 | 473 | // Logical operations |
| 616 | 474 | |
| 617 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 618 | 475 | #if _LIBCPP_STD_VER > 11 |
| 619 | 476 | template <class _Tp = void> |
| 620 | 477 | #else |
| 621 | 478 | template <class _Tp> |
| 622 | 479 | #endif |
| 623 | 480 | struct _LIBCPP_TEMPLATE_VIS logical_and |
| 624 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 625 | : binary_function<_Tp, _Tp, bool> | |
| 626 | #endif | |
| 481 | : __binary_function<_Tp, _Tp, bool> | |
| 627 | 482 | { |
| 628 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 629 | 483 | typedef bool __result_type; // used by valarray |
| 630 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 631 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 632 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 633 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 634 | #endif | |
| 635 | 484 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 636 | 485 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 637 | 486 | {return __x && __y;} |
| ... | ... | @@ -651,23 +500,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void> |
| 651 | 500 | }; |
| 652 | 501 | #endif |
| 653 | 502 | |
| 654 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 655 | 503 | #if _LIBCPP_STD_VER > 11 |
| 656 | 504 | template <class _Tp = void> |
| 657 | 505 | #else |
| 658 | 506 | template <class _Tp> |
| 659 | 507 | #endif |
| 660 | 508 | struct _LIBCPP_TEMPLATE_VIS logical_not |
| 661 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 662 | : unary_function<_Tp, bool> | |
| 663 | #endif | |
| 509 | : __unary_function<_Tp, bool> | |
| 664 | 510 | { |
| 665 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 666 | 511 | typedef bool __result_type; // used by valarray |
| 667 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 668 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 669 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; | |
| 670 | #endif | |
| 671 | 512 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 672 | 513 | bool operator()(const _Tp& __x) const |
| 673 | 514 | {return !__x;} |
| ... | ... | @@ -687,24 +528,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void> |
| 687 | 528 | }; |
| 688 | 529 | #endif |
| 689 | 530 | |
| 690 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 691 | 531 | #if _LIBCPP_STD_VER > 11 |
| 692 | 532 | template <class _Tp = void> |
| 693 | 533 | #else |
| 694 | 534 | template <class _Tp> |
| 695 | 535 | #endif |
| 696 | 536 | struct _LIBCPP_TEMPLATE_VIS logical_or |
| 697 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 698 | : binary_function<_Tp, _Tp, bool> | |
| 699 | #endif | |
| 537 | : __binary_function<_Tp, _Tp, bool> | |
| 700 | 538 | { |
| 701 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 702 | 539 | typedef bool __result_type; // used by valarray |
| 703 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 704 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 705 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; | |
| 706 | _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; | |
| 707 | #endif | |
| 708 | 540 | _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY |
| 709 | 541 | bool operator()(const _Tp& __x, const _Tp& __y) const |
| 710 | 542 | {return __x || __y;} |
lib/libcxx/include/__functional/perfect_forward.h+52-53| ... | ... | @@ -18,70 +18,69 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | 26 | #if _LIBCPP_STD_VER > 14 |
| 27 | 27 | |
| 28 | template <class _Op, class _Indices, class ..._Bound> | |
| 28 | template <class _Op, class _Indices, class... _BoundArgs> | |
| 29 | 29 | struct __perfect_forward_impl; |
| 30 | 30 | |
| 31 | template <class _Op, size_t ..._Idx, class ..._Bound> | |
| 32 | struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _Bound...> { | |
| 31 | template <class _Op, size_t... _Idx, class... _BoundArgs> | |
| 32 | struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> { | |
| 33 | 33 | private: |
| 34 | tuple<_Bound...> __bound_; | |
| 34 | tuple<_BoundArgs...> __bound_args_; | |
| 35 | 35 | |
| 36 | 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; | |
| 37 | template <class... _Args, class = enable_if_t< | |
| 38 | is_constructible_v<tuple<_BoundArgs...>, _Args&&...> | |
| 39 | >> | |
| 40 | explicit constexpr __perfect_forward_impl(_Args&&... __bound_args) | |
| 41 | : __bound_args_(_VSTD::forward<_Args>(__bound_args)...) {} | |
| 42 | ||
| 43 | __perfect_forward_impl(__perfect_forward_impl const&) = default; | |
| 44 | __perfect_forward_impl(__perfect_forward_impl&&) = default; | |
| 45 | ||
| 46 | __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default; | |
| 47 | __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default; | |
| 48 | ||
| 49 | template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>> | |
| 50 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) & | |
| 51 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))) | |
| 52 | -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)) | |
| 53 | { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); } | |
| 54 | ||
| 55 | template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>> | |
| 56 | auto operator()(_Args&&...) & = delete; | |
| 57 | ||
| 58 | template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>> | |
| 59 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const& | |
| 60 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))) | |
| 61 | -> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)) | |
| 62 | { return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...); } | |
| 63 | ||
| 64 | template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>> | |
| 65 | auto operator()(_Args&&...) const& = delete; | |
| 66 | ||
| 67 | template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>> | |
| 68 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) && | |
| 69 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))) | |
| 70 | -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)) | |
| 71 | { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); } | |
| 72 | ||
| 73 | template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>> | |
| 74 | auto operator()(_Args&&...) && = delete; | |
| 75 | ||
| 76 | template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>> | |
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&& | |
| 78 | noexcept(noexcept(_Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))) | |
| 79 | -> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)) | |
| 80 | { return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...); } | |
| 81 | ||
| 82 | template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>> | |
| 83 | auto operator()(_Args&&...) const&& = delete; | |
| 85 | 84 | }; |
| 86 | 85 | |
| 87 | 86 | // __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require]. |
lib/libcxx/include/__functional/pointer_to_binary_function.h+2-2| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__functional/binary_function.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class _Arg1, class _Arg2, class _Result> |
| 25 | 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function |
| 26 | : public binary_function<_Arg1, _Arg2, _Result> | |
| 26 | : public __binary_function<_Arg1, _Arg2, _Result> | |
| 27 | 27 | { |
| 28 | 28 | _Result (*__f_)(_Arg1, _Arg2); |
| 29 | 29 | public: |
lib/libcxx/include/__functional/pointer_to_unary_function.h+2-2| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__functional/unary_function.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class _Arg, class _Result> |
| 25 | 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function |
| 26 | : public unary_function<_Arg, _Result> | |
| 26 | : public __unary_function<_Arg, _Result> | |
| 27 | 27 | { |
| 28 | 28 | _Result (*__f_)(_Arg); |
| 29 | 29 | public: |
lib/libcxx/include/__functional/ranges_operations.h+5-4| ... | ... | @@ -11,16 +11,16 @@ |
| 11 | 11 | #define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__utility/forward.h> | |
| 14 | 15 | #include <concepts> |
| 15 | #include <utility> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | namespace ranges { |
| 26 | 26 | |
| ... | ... | @@ -91,7 +91,8 @@ struct greater_equal { |
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | 93 | } // namespace ranges |
| 94 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 94 | ||
| 95 | #endif // _LIBCPP_STD_VER > 17 | |
| 95 | 96 | |
| 96 | 97 | _LIBCPP_END_NAMESPACE_STD |
| 97 | 98 |
lib/libcxx/include/__functional/reference_wrapper.h+3-113| ... | ... | @@ -17,16 +17,13 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | 25 | template <class _Tp> |
| 26 | class _LIBCPP_TEMPLATE_VIS reference_wrapper | |
| 27 | #if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 28 | : public __weak_result_type<_Tp> | |
| 29 | #endif | |
| 26 | class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> | |
| 30 | 27 | { |
| 31 | 28 | public: |
| 32 | 29 | // types |
| ... | ... | @@ -51,120 +48,13 @@ public: |
| 51 | 48 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 52 | 49 | type& get() const _NOEXCEPT {return *__f_;} |
| 53 | 50 | |
| 54 | #ifndef _LIBCPP_CXX03_LANG | |
| 55 | 51 | // invoke |
| 56 | 52 | template <class... _ArgTypes> |
| 57 | 53 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 58 | 54 | typename __invoke_of<type&, _ArgTypes...>::type |
| 59 | 55 | operator() (_ArgTypes&&... __args) const { |
| 60 | return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); | |
| 61 | } | |
| 62 | #else | |
| 63 | ||
| 64 | _LIBCPP_INLINE_VISIBILITY | |
| 65 | typename __invoke_return<type>::type | |
| 66 | operator() () const { | |
| 67 | return _VSTD::__invoke(get()); | |
| 68 | } | |
| 69 | ||
| 70 | template <class _A0> | |
| 71 | _LIBCPP_INLINE_VISIBILITY | |
| 72 | typename __invoke_return0<type, _A0>::type | |
| 73 | operator() (_A0& __a0) const { | |
| 74 | return _VSTD::__invoke(get(), __a0); | |
| 75 | } | |
| 76 | ||
| 77 | template <class _A0> | |
| 78 | _LIBCPP_INLINE_VISIBILITY | |
| 79 | typename __invoke_return0<type, _A0 const>::type | |
| 80 | operator() (_A0 const& __a0) const { | |
| 81 | return _VSTD::__invoke(get(), __a0); | |
| 82 | } | |
| 83 | ||
| 84 | template <class _A0, class _A1> | |
| 85 | _LIBCPP_INLINE_VISIBILITY | |
| 86 | typename __invoke_return1<type, _A0, _A1>::type | |
| 87 | operator() (_A0& __a0, _A1& __a1) const { | |
| 88 | return _VSTD::__invoke(get(), __a0, __a1); | |
| 89 | } | |
| 90 | ||
| 91 | template <class _A0, class _A1> | |
| 92 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | typename __invoke_return1<type, _A0 const, _A1>::type | |
| 94 | operator() (_A0 const& __a0, _A1& __a1) const { | |
| 95 | return _VSTD::__invoke(get(), __a0, __a1); | |
| 96 | } | |
| 97 | ||
| 98 | template <class _A0, class _A1> | |
| 99 | _LIBCPP_INLINE_VISIBILITY | |
| 100 | typename __invoke_return1<type, _A0, _A1 const>::type | |
| 101 | operator() (_A0& __a0, _A1 const& __a1) const { | |
| 102 | return _VSTD::__invoke(get(), __a0, __a1); | |
| 103 | } | |
| 104 | ||
| 105 | template <class _A0, class _A1> | |
| 106 | _LIBCPP_INLINE_VISIBILITY | |
| 107 | typename __invoke_return1<type, _A0 const, _A1 const>::type | |
| 108 | operator() (_A0 const& __a0, _A1 const& __a1) const { | |
| 109 | return _VSTD::__invoke(get(), __a0, __a1); | |
| 110 | } | |
| 111 | ||
| 112 | template <class _A0, class _A1, class _A2> | |
| 113 | _LIBCPP_INLINE_VISIBILITY | |
| 114 | typename __invoke_return2<type, _A0, _A1, _A2>::type | |
| 115 | operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { | |
| 116 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 117 | } | |
| 118 | ||
| 119 | template <class _A0, class _A1, class _A2> | |
| 120 | _LIBCPP_INLINE_VISIBILITY | |
| 121 | typename __invoke_return2<type, _A0 const, _A1, _A2>::type | |
| 122 | operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { | |
| 123 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 124 | } | |
| 125 | ||
| 126 | template <class _A0, class _A1, class _A2> | |
| 127 | _LIBCPP_INLINE_VISIBILITY | |
| 128 | typename __invoke_return2<type, _A0, _A1 const, _A2>::type | |
| 129 | operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { | |
| 130 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 131 | } | |
| 132 | ||
| 133 | template <class _A0, class _A1, class _A2> | |
| 134 | _LIBCPP_INLINE_VISIBILITY | |
| 135 | typename __invoke_return2<type, _A0, _A1, _A2 const>::type | |
| 136 | operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { | |
| 137 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 138 | } | |
| 139 | ||
| 140 | template <class _A0, class _A1, class _A2> | |
| 141 | _LIBCPP_INLINE_VISIBILITY | |
| 142 | typename __invoke_return2<type, _A0 const, _A1 const, _A2>::type | |
| 143 | operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { | |
| 144 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 145 | } | |
| 146 | ||
| 147 | template <class _A0, class _A1, class _A2> | |
| 148 | _LIBCPP_INLINE_VISIBILITY | |
| 149 | typename __invoke_return2<type, _A0 const, _A1, _A2 const>::type | |
| 150 | operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { | |
| 151 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 152 | } | |
| 153 | ||
| 154 | template <class _A0, class _A1, class _A2> | |
| 155 | _LIBCPP_INLINE_VISIBILITY | |
| 156 | typename __invoke_return2<type, _A0, _A1 const, _A2 const>::type | |
| 157 | operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { | |
| 158 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 159 | } | |
| 160 | ||
| 161 | template <class _A0, class _A1, class _A2> | |
| 162 | _LIBCPP_INLINE_VISIBILITY | |
| 163 | typename __invoke_return2<type, _A0 const, _A1 const, _A2 const>::type | |
| 164 | operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { | |
| 165 | return _VSTD::__invoke(get(), __a0, __a1, __a2); | |
| 56 | return std::__invoke(get(), std::forward<_ArgTypes>(__args)...); | |
| 166 | 57 | } |
| 167 | #endif // _LIBCPP_CXX03_LANG | |
| 168 | 58 | }; |
| 169 | 59 | |
| 170 | 60 | #if _LIBCPP_STD_VER > 14 |
lib/libcxx/include/__functional/unary_function.h+24-2| ... | ... | @@ -12,18 +12,40 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 19 | |
| 20 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | |
| 21 | ||
| 20 | 22 | template <class _Arg, class _Result> |
| 21 | struct _LIBCPP_TEMPLATE_VIS unary_function | |
| 23 | struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function | |
| 22 | 24 | { |
| 23 | 25 | typedef _Arg argument_type; |
| 24 | 26 | typedef _Result result_type; |
| 25 | 27 | }; |
| 26 | 28 | |
| 29 | #endif // _LIBCPP_STD_VER <= 14 | |
| 30 | ||
| 31 | template <class _Arg, class _Result> struct __unary_function_keep_layout_base { | |
| 32 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 33 | using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg; | |
| 34 | using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result; | |
| 35 | #endif | |
| 36 | }; | |
| 37 | ||
| 38 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) | |
| 39 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 40 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") | |
| 41 | template <class _Arg, class _Result> | |
| 42 | using __unary_function = unary_function<_Arg, _Result>; | |
| 43 | _LIBCPP_DIAGNOSTIC_POP | |
| 44 | #else | |
| 45 | template <class _Arg, class _Result> | |
| 46 | using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>; | |
| 47 | #endif | |
| 48 | ||
| 27 | 49 | _LIBCPP_END_NAMESPACE_STD |
| 28 | 50 | |
| 29 | 51 | #endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H |
lib/libcxx/include/__functional/unary_negate.h+2-2| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__functional/unary_function.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | 24 | template <class _Predicate> |
| 25 | 25 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate |
| 26 | : public unary_function<typename _Predicate::argument_type, bool> | |
| 26 | : public __unary_function<typename _Predicate::argument_type, bool> | |
| 27 | 27 | { |
| 28 | 28 | _Predicate __pred_; |
| 29 | 29 | public: |
lib/libcxx/include/__functional/unwrap_ref.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__functional/weak_result_type.h+57-247| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -25,11 +25,10 @@ template <class _Tp> |
| 25 | 25 | struct __has_result_type |
| 26 | 26 | { |
| 27 | 27 | private: |
| 28 | struct __two {char __lx; char __lxx;}; | |
| 29 | template <class _Up> static __two __test(...); | |
| 30 | template <class _Up> static char __test(typename _Up::result_type* = 0); | |
| 28 | template <class _Up> static false_type __test(...); | |
| 29 | template <class _Up> static true_type __test(typename _Up::result_type* = 0); | |
| 31 | 30 | public: |
| 32 | static const bool value = sizeof(__test<_Tp>(0)) == 1; | |
| 31 | static const bool value = decltype(__test<_Tp>(0))::value; | |
| 33 | 32 | }; |
| 34 | 33 | |
| 35 | 34 | // __weak_result_type |
| ... | ... | @@ -41,8 +40,9 @@ private: |
| 41 | 40 | struct __two {char __lx; char __lxx;}; |
| 42 | 41 | static __two __test(...); |
| 43 | 42 | template <class _Ap, class _Rp> |
| 44 | static unary_function<_Ap, _Rp> | |
| 45 | __test(const volatile unary_function<_Ap, _Rp>*); | |
| 43 | static __unary_function<_Ap, _Rp> | |
| 44 | __test(const volatile __unary_function<_Ap, _Rp>*); | |
| 45 | ||
| 46 | 46 | public: |
| 47 | 47 | static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value; |
| 48 | 48 | typedef decltype(__test((_Tp*)0)) type; |
| ... | ... | @@ -55,8 +55,9 @@ private: |
| 55 | 55 | struct __two {char __lx; char __lxx;}; |
| 56 | 56 | static __two __test(...); |
| 57 | 57 | template <class _A1, class _A2, class _Rp> |
| 58 | static binary_function<_A1, _A2, _Rp> | |
| 59 | __test(const volatile binary_function<_A1, _A2, _Rp>*); | |
| 58 | static __binary_function<_A1, _A2, _Rp> | |
| 59 | __test(const volatile __binary_function<_A1, _A2, _Rp>*); | |
| 60 | ||
| 60 | 61 | public: |
| 61 | 62 | static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value; |
| 62 | 63 | typedef decltype(__test((_Tp*)0)) type; |
| ... | ... | @@ -89,7 +90,9 @@ struct __weak_result_type_imp // bool is true |
| 89 | 90 | : public __maybe_derive_from_unary_function<_Tp>, |
| 90 | 91 | public __maybe_derive_from_binary_function<_Tp> |
| 91 | 92 | { |
| 92 | typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type; | |
| 93 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 94 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = typename _Tp::result_type; | |
| 95 | #endif | |
| 93 | 96 | }; |
| 94 | 97 | |
| 95 | 98 | template <class _Tp> |
| ... | ... | @@ -110,62 +113,68 @@ struct __weak_result_type |
| 110 | 113 | template <class _Rp> |
| 111 | 114 | struct __weak_result_type<_Rp ()> |
| 112 | 115 | { |
| 113 | typedef _LIBCPP_NODEBUG _Rp result_type; | |
| 116 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 117 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 118 | #endif | |
| 114 | 119 | }; |
| 115 | 120 | |
| 116 | 121 | template <class _Rp> |
| 117 | 122 | struct __weak_result_type<_Rp (&)()> |
| 118 | 123 | { |
| 119 | typedef _LIBCPP_NODEBUG _Rp result_type; | |
| 124 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 125 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 126 | #endif | |
| 120 | 127 | }; |
| 121 | 128 | |
| 122 | 129 | template <class _Rp> |
| 123 | 130 | struct __weak_result_type<_Rp (*)()> |
| 124 | 131 | { |
| 125 | typedef _LIBCPP_NODEBUG _Rp result_type; | |
| 132 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 133 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 134 | #endif | |
| 126 | 135 | }; |
| 127 | 136 | |
| 128 | 137 | // 1 argument case |
| 129 | 138 | |
| 130 | 139 | template <class _Rp, class _A1> |
| 131 | 140 | struct __weak_result_type<_Rp (_A1)> |
| 132 | : public unary_function<_A1, _Rp> | |
| 141 | : public __unary_function<_A1, _Rp> | |
| 133 | 142 | { |
| 134 | 143 | }; |
| 135 | 144 | |
| 136 | 145 | template <class _Rp, class _A1> |
| 137 | 146 | struct __weak_result_type<_Rp (&)(_A1)> |
| 138 | : public unary_function<_A1, _Rp> | |
| 147 | : public __unary_function<_A1, _Rp> | |
| 139 | 148 | { |
| 140 | 149 | }; |
| 141 | 150 | |
| 142 | 151 | template <class _Rp, class _A1> |
| 143 | 152 | struct __weak_result_type<_Rp (*)(_A1)> |
| 144 | : public unary_function<_A1, _Rp> | |
| 153 | : public __unary_function<_A1, _Rp> | |
| 145 | 154 | { |
| 146 | 155 | }; |
| 147 | 156 | |
| 148 | 157 | template <class _Rp, class _Cp> |
| 149 | 158 | struct __weak_result_type<_Rp (_Cp::*)()> |
| 150 | : public unary_function<_Cp*, _Rp> | |
| 159 | : public __unary_function<_Cp*, _Rp> | |
| 151 | 160 | { |
| 152 | 161 | }; |
| 153 | 162 | |
| 154 | 163 | template <class _Rp, class _Cp> |
| 155 | 164 | struct __weak_result_type<_Rp (_Cp::*)() const> |
| 156 | : public unary_function<const _Cp*, _Rp> | |
| 165 | : public __unary_function<const _Cp*, _Rp> | |
| 157 | 166 | { |
| 158 | 167 | }; |
| 159 | 168 | |
| 160 | 169 | template <class _Rp, class _Cp> |
| 161 | 170 | struct __weak_result_type<_Rp (_Cp::*)() volatile> |
| 162 | : public unary_function<volatile _Cp*, _Rp> | |
| 171 | : public __unary_function<volatile _Cp*, _Rp> | |
| 163 | 172 | { |
| 164 | 173 | }; |
| 165 | 174 | |
| 166 | 175 | template <class _Rp, class _Cp> |
| 167 | 176 | struct __weak_result_type<_Rp (_Cp::*)() const volatile> |
| 168 | : public unary_function<const volatile _Cp*, _Rp> | |
| 177 | : public __unary_function<const volatile _Cp*, _Rp> | |
| 169 | 178 | { |
| 170 | 179 | }; |
| 171 | 180 | |
| ... | ... | @@ -173,90 +182,102 @@ struct __weak_result_type<_Rp (_Cp::*)() const volatile> |
| 173 | 182 | |
| 174 | 183 | template <class _Rp, class _A1, class _A2> |
| 175 | 184 | struct __weak_result_type<_Rp (_A1, _A2)> |
| 176 | : public binary_function<_A1, _A2, _Rp> | |
| 185 | : public __binary_function<_A1, _A2, _Rp> | |
| 177 | 186 | { |
| 178 | 187 | }; |
| 179 | 188 | |
| 180 | 189 | template <class _Rp, class _A1, class _A2> |
| 181 | 190 | struct __weak_result_type<_Rp (*)(_A1, _A2)> |
| 182 | : public binary_function<_A1, _A2, _Rp> | |
| 191 | : public __binary_function<_A1, _A2, _Rp> | |
| 183 | 192 | { |
| 184 | 193 | }; |
| 185 | 194 | |
| 186 | 195 | template <class _Rp, class _A1, class _A2> |
| 187 | 196 | struct __weak_result_type<_Rp (&)(_A1, _A2)> |
| 188 | : public binary_function<_A1, _A2, _Rp> | |
| 197 | : public __binary_function<_A1, _A2, _Rp> | |
| 189 | 198 | { |
| 190 | 199 | }; |
| 191 | 200 | |
| 192 | 201 | template <class _Rp, class _Cp, class _A1> |
| 193 | 202 | struct __weak_result_type<_Rp (_Cp::*)(_A1)> |
| 194 | : public binary_function<_Cp*, _A1, _Rp> | |
| 203 | : public __binary_function<_Cp*, _A1, _Rp> | |
| 195 | 204 | { |
| 196 | 205 | }; |
| 197 | 206 | |
| 198 | 207 | template <class _Rp, class _Cp, class _A1> |
| 199 | 208 | struct __weak_result_type<_Rp (_Cp::*)(_A1) const> |
| 200 | : public binary_function<const _Cp*, _A1, _Rp> | |
| 209 | : public __binary_function<const _Cp*, _A1, _Rp> | |
| 201 | 210 | { |
| 202 | 211 | }; |
| 203 | 212 | |
| 204 | 213 | template <class _Rp, class _Cp, class _A1> |
| 205 | 214 | struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> |
| 206 | : public binary_function<volatile _Cp*, _A1, _Rp> | |
| 215 | : public __binary_function<volatile _Cp*, _A1, _Rp> | |
| 207 | 216 | { |
| 208 | 217 | }; |
| 209 | 218 | |
| 210 | 219 | template <class _Rp, class _Cp, class _A1> |
| 211 | 220 | struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> |
| 212 | : public binary_function<const volatile _Cp*, _A1, _Rp> | |
| 221 | : public __binary_function<const volatile _Cp*, _A1, _Rp> | |
| 213 | 222 | { |
| 214 | 223 | }; |
| 215 | 224 | |
| 216 | ||
| 217 | #ifndef _LIBCPP_CXX03_LANG | |
| 218 | 225 | // 3 or more arguments |
| 219 | 226 | |
| 220 | 227 | template <class _Rp, class _A1, class _A2, class _A3, class ..._A4> |
| 221 | 228 | struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)> |
| 222 | 229 | { |
| 223 | typedef _Rp result_type; | |
| 230 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 231 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 232 | #endif | |
| 224 | 233 | }; |
| 225 | 234 | |
| 226 | 235 | template <class _Rp, class _A1, class _A2, class _A3, class ..._A4> |
| 227 | 236 | struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> |
| 228 | 237 | { |
| 229 | typedef _Rp result_type; | |
| 238 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 239 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 240 | #endif | |
| 230 | 241 | }; |
| 231 | 242 | |
| 232 | 243 | template <class _Rp, class _A1, class _A2, class _A3, class ..._A4> |
| 233 | 244 | struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> |
| 234 | 245 | { |
| 235 | typedef _Rp result_type; | |
| 246 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 247 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 248 | #endif | |
| 236 | 249 | }; |
| 237 | 250 | |
| 238 | 251 | template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> |
| 239 | 252 | struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> |
| 240 | 253 | { |
| 241 | typedef _Rp result_type; | |
| 254 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 255 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 256 | #endif | |
| 242 | 257 | }; |
| 243 | 258 | |
| 244 | 259 | template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> |
| 245 | 260 | struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> |
| 246 | 261 | { |
| 247 | typedef _Rp result_type; | |
| 262 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 263 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 264 | #endif | |
| 248 | 265 | }; |
| 249 | 266 | |
| 250 | 267 | template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> |
| 251 | 268 | struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> |
| 252 | 269 | { |
| 253 | typedef _Rp result_type; | |
| 270 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 271 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 272 | #endif | |
| 254 | 273 | }; |
| 255 | 274 | |
| 256 | 275 | template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> |
| 257 | 276 | struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> |
| 258 | 277 | { |
| 259 | typedef _Rp result_type; | |
| 278 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 279 | using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; | |
| 280 | #endif | |
| 260 | 281 | }; |
| 261 | 282 | |
| 262 | 283 | template <class _Tp, class ..._Args> |
| ... | ... | @@ -265,217 +286,6 @@ struct __invoke_return |
| 265 | 286 | typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type; |
| 266 | 287 | }; |
| 267 | 288 | |
| 268 | #else // defined(_LIBCPP_CXX03_LANG) | |
| 269 | ||
| 270 | template <class _Ret, class _T1, bool _IsFunc, bool _IsBase> | |
| 271 | struct __enable_invoke_imp; | |
| 272 | ||
| 273 | template <class _Ret, class _T1> | |
| 274 | struct __enable_invoke_imp<_Ret, _T1, true, true> { | |
| 275 | typedef _Ret _Bullet1; | |
| 276 | typedef _Bullet1 type; | |
| 277 | }; | |
| 278 | ||
| 279 | template <class _Ret, class _T1> | |
| 280 | struct __enable_invoke_imp<_Ret, _T1, true, false> { | |
| 281 | typedef _Ret _Bullet2; | |
| 282 | typedef _Bullet2 type; | |
| 283 | }; | |
| 284 | ||
| 285 | template <class _Ret, class _T1> | |
| 286 | struct __enable_invoke_imp<_Ret, _T1, false, true> { | |
| 287 | typedef typename add_lvalue_reference< | |
| 288 | typename __apply_cv<_T1, _Ret>::type | |
| 289 | >::type _Bullet3; | |
| 290 | typedef _Bullet3 type; | |
| 291 | }; | |
| 292 | ||
| 293 | template <class _Ret, class _T1> | |
| 294 | struct __enable_invoke_imp<_Ret, _T1, false, false> { | |
| 295 | typedef typename add_lvalue_reference< | |
| 296 | typename __apply_cv<decltype(*declval<_T1>()), _Ret>::type | |
| 297 | >::type _Bullet4; | |
| 298 | typedef _Bullet4 type; | |
| 299 | }; | |
| 300 | ||
| 301 | template <class _Ret, class _T1> | |
| 302 | struct __enable_invoke_imp<_Ret, _T1*, false, false> { | |
| 303 | typedef typename add_lvalue_reference< | |
| 304 | typename __apply_cv<_T1, _Ret>::type | |
| 305 | >::type _Bullet4; | |
| 306 | typedef _Bullet4 type; | |
| 307 | }; | |
| 308 | ||
| 309 | template <class _Fn, class _T1, | |
| 310 | class _Traits = __member_pointer_traits<_Fn>, | |
| 311 | class _Ret = typename _Traits::_ReturnType, | |
| 312 | class _Class = typename _Traits::_ClassType> | |
| 313 | struct __enable_invoke : __enable_invoke_imp< | |
| 314 | _Ret, _T1, | |
| 315 | is_member_function_pointer<_Fn>::value, | |
| 316 | is_base_of<_Class, typename remove_reference<_T1>::type>::value> | |
| 317 | { | |
| 318 | }; | |
| 319 | ||
| 320 | __nat __invoke(__any, ...); | |
| 321 | ||
| 322 | // first bullet | |
| 323 | ||
| 324 | template <class _Fn, class _T1> | |
| 325 | inline _LIBCPP_INLINE_VISIBILITY | |
| 326 | typename __enable_invoke<_Fn, _T1>::_Bullet1 | |
| 327 | __invoke(_Fn __f, _T1& __t1) { | |
| 328 | return (__t1.*__f)(); | |
| 329 | } | |
| 330 | ||
| 331 | template <class _Fn, class _T1, class _A0> | |
| 332 | inline _LIBCPP_INLINE_VISIBILITY | |
| 333 | typename __enable_invoke<_Fn, _T1>::_Bullet1 | |
| 334 | __invoke(_Fn __f, _T1& __t1, _A0& __a0) { | |
| 335 | return (__t1.*__f)(__a0); | |
| 336 | } | |
| 337 | ||
| 338 | template <class _Fn, class _T1, class _A0, class _A1> | |
| 339 | inline _LIBCPP_INLINE_VISIBILITY | |
| 340 | typename __enable_invoke<_Fn, _T1>::_Bullet1 | |
| 341 | __invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { | |
| 342 | return (__t1.*__f)(__a0, __a1); | |
| 343 | } | |
| 344 | ||
| 345 | template <class _Fn, class _T1, class _A0, class _A1, class _A2> | |
| 346 | inline _LIBCPP_INLINE_VISIBILITY | |
| 347 | typename __enable_invoke<_Fn, _T1>::_Bullet1 | |
| 348 | __invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { | |
| 349 | return (__t1.*__f)(__a0, __a1, __a2); | |
| 350 | } | |
| 351 | ||
| 352 | template <class _Fn, class _T1> | |
| 353 | inline _LIBCPP_INLINE_VISIBILITY | |
| 354 | typename __enable_invoke<_Fn, _T1>::_Bullet2 | |
| 355 | __invoke(_Fn __f, _T1& __t1) { | |
| 356 | return ((*__t1).*__f)(); | |
| 357 | } | |
| 358 | ||
| 359 | template <class _Fn, class _T1, class _A0> | |
| 360 | inline _LIBCPP_INLINE_VISIBILITY | |
| 361 | typename __enable_invoke<_Fn, _T1>::_Bullet2 | |
| 362 | __invoke(_Fn __f, _T1& __t1, _A0& __a0) { | |
| 363 | return ((*__t1).*__f)(__a0); | |
| 364 | } | |
| 365 | ||
| 366 | template <class _Fn, class _T1, class _A0, class _A1> | |
| 367 | inline _LIBCPP_INLINE_VISIBILITY | |
| 368 | typename __enable_invoke<_Fn, _T1>::_Bullet2 | |
| 369 | __invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { | |
| 370 | return ((*__t1).*__f)(__a0, __a1); | |
| 371 | } | |
| 372 | ||
| 373 | template <class _Fn, class _T1, class _A0, class _A1, class _A2> | |
| 374 | inline _LIBCPP_INLINE_VISIBILITY | |
| 375 | typename __enable_invoke<_Fn, _T1>::_Bullet2 | |
| 376 | __invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { | |
| 377 | return ((*__t1).*__f)(__a0, __a1, __a2); | |
| 378 | } | |
| 379 | ||
| 380 | template <class _Fn, class _T1> | |
| 381 | inline _LIBCPP_INLINE_VISIBILITY | |
| 382 | typename __enable_invoke<_Fn, _T1>::_Bullet3 | |
| 383 | __invoke(_Fn __f, _T1& __t1) { | |
| 384 | return __t1.*__f; | |
| 385 | } | |
| 386 | ||
| 387 | template <class _Fn, class _T1> | |
| 388 | inline _LIBCPP_INLINE_VISIBILITY | |
| 389 | typename __enable_invoke<_Fn, _T1>::_Bullet4 | |
| 390 | __invoke(_Fn __f, _T1& __t1) { | |
| 391 | return (*__t1).*__f; | |
| 392 | } | |
| 393 | ||
| 394 | // fifth bullet | |
| 395 | ||
| 396 | template <class _Fp> | |
| 397 | inline _LIBCPP_INLINE_VISIBILITY | |
| 398 | decltype(declval<_Fp&>()()) | |
| 399 | __invoke(_Fp& __f) | |
| 400 | { | |
| 401 | return __f(); | |
| 402 | } | |
| 403 | ||
| 404 | template <class _Fp, class _A0> | |
| 405 | inline _LIBCPP_INLINE_VISIBILITY | |
| 406 | decltype(declval<_Fp&>()(declval<_A0&>())) | |
| 407 | __invoke(_Fp& __f, _A0& __a0) | |
| 408 | { | |
| 409 | return __f(__a0); | |
| 410 | } | |
| 411 | ||
| 412 | template <class _Fp, class _A0, class _A1> | |
| 413 | inline _LIBCPP_INLINE_VISIBILITY | |
| 414 | decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>())) | |
| 415 | __invoke(_Fp& __f, _A0& __a0, _A1& __a1) | |
| 416 | { | |
| 417 | return __f(__a0, __a1); | |
| 418 | } | |
| 419 | ||
| 420 | template <class _Fp, class _A0, class _A1, class _A2> | |
| 421 | inline _LIBCPP_INLINE_VISIBILITY | |
| 422 | decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>())) | |
| 423 | __invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) | |
| 424 | { | |
| 425 | return __f(__a0, __a1, __a2); | |
| 426 | } | |
| 427 | ||
| 428 | template <class _Fp, bool = __has_result_type<__weak_result_type<_Fp> >::value> | |
| 429 | struct __invoke_return | |
| 430 | { | |
| 431 | typedef typename __weak_result_type<_Fp>::result_type type; | |
| 432 | }; | |
| 433 | ||
| 434 | template <class _Fp> | |
| 435 | struct __invoke_return<_Fp, false> | |
| 436 | { | |
| 437 | typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type; | |
| 438 | }; | |
| 439 | ||
| 440 | template <class _Tp, class _A0> | |
| 441 | struct __invoke_return0 | |
| 442 | { | |
| 443 | typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type; | |
| 444 | }; | |
| 445 | ||
| 446 | template <class _Rp, class _Tp, class _A0> | |
| 447 | struct __invoke_return0<_Rp _Tp::*, _A0> | |
| 448 | { | |
| 449 | typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; | |
| 450 | }; | |
| 451 | ||
| 452 | template <class _Tp, class _A0, class _A1> | |
| 453 | struct __invoke_return1 | |
| 454 | { | |
| 455 | typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(), | |
| 456 | declval<_A1&>())) type; | |
| 457 | }; | |
| 458 | ||
| 459 | template <class _Rp, class _Class, class _A0, class _A1> | |
| 460 | struct __invoke_return1<_Rp _Class::*, _A0, _A1> { | |
| 461 | typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type; | |
| 462 | }; | |
| 463 | ||
| 464 | template <class _Tp, class _A0, class _A1, class _A2> | |
| 465 | struct __invoke_return2 | |
| 466 | { | |
| 467 | typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(), | |
| 468 | declval<_A1&>(), | |
| 469 | declval<_A2&>())) type; | |
| 470 | }; | |
| 471 | ||
| 472 | template <class _Ret, class _Class, class _A0, class _A1, class _A2> | |
| 473 | struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { | |
| 474 | typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; | |
| 475 | }; | |
| 476 | ||
| 477 | #endif // !defined(_LIBCPP_CXX03_LANG) | |
| 478 | ||
| 479 | 289 | _LIBCPP_END_NAMESPACE_STD |
| 480 | 290 | |
| 481 | 291 | #endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H |
lib/libcxx/include/__functional_base deleted-32| ... | ... | @@ -1,32 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_FUNCTIONAL_BASE | |
| 11 | #define _LIBCPP_FUNCTIONAL_BASE | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/binary_function.h> | |
| 15 | #include <__functional/invoke.h> | |
| 16 | #include <__functional/operations.h> | |
| 17 | #include <__functional/reference_wrapper.h> | |
| 18 | #include <__functional/unary_function.h> | |
| 19 | #include <__functional/weak_result_type.h> | |
| 20 | #include <__memory/allocator_arg_t.h> | |
| 21 | #include <__memory/uses_allocator.h> | |
| 22 | #include <exception> | |
| 23 | #include <new> | |
| 24 | #include <type_traits> | |
| 25 | #include <typeinfo> | |
| 26 | #include <utility> | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 29 | #pragma GCC system_header | |
| 30 | #endif | |
| 31 | ||
| 32 | #endif // _LIBCPP_FUNCTIONAL_BASE |
lib/libcxx/include/__fwd/span.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===---------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===---------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_FWD_SPAN_H | |
| 11 | #define _LIBCPP_FWD_SPAN_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <cstddef> | |
| 15 | #include <limits> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | ||
| 28 | inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); | |
| 29 | template <typename _Tp, size_t _Extent = dynamic_extent> class span; | |
| 30 | ||
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | _LIBCPP_POP_MACROS | |
| 36 | ||
| 37 | #endif // _LIBCPP_FWD_SPAN_H |
lib/libcxx/include/__fwd/string_view.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===---------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===---------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_FWD_STRING_VIEW_H | |
| 11 | #define _LIBCPP_FWD_STRING_VIEW_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <iosfwd> // char_traits | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template<class _CharT, class _Traits = char_traits<_CharT> > | |
| 23 | class _LIBCPP_TEMPLATE_VIS basic_string_view; | |
| 24 | ||
| 25 | typedef basic_string_view<char> string_view; | |
| 26 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 27 | typedef basic_string_view<char8_t> u8string_view; | |
| 28 | #endif | |
| 29 | typedef basic_string_view<char16_t> u16string_view; | |
| 30 | typedef basic_string_view<char32_t> u32string_view; | |
| 31 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 32 | typedef basic_string_view<wchar_t> wstring_view; | |
| 33 | #endif | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP_FWD_STRING_VIEW_H |
lib/libcxx/include/__hash_table+87-176| ... | ... | @@ -7,22 +7,26 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP__HASH_TABLE | |
| 11 | #define _LIBCPP__HASH_TABLE | |
| 10 | #ifndef _LIBCPP___HASH_TABLE | |
| 11 | #define _LIBCPP___HASH_TABLE | |
| 12 | 12 | |
| 13 | #include <__algorithm/max.h> | |
| 14 | #include <__algorithm/min.h> | |
| 15 | #include <__assert> | |
| 13 | 16 | #include <__bits> // __libcpp_clz |
| 14 | 17 | #include <__config> |
| 15 | 18 | #include <__debug> |
| 16 | #include <algorithm> | |
| 19 | #include <__functional/hash.h> | |
| 20 | #include <__iterator/iterator_traits.h> | |
| 21 | #include <__memory/swap_allocator.h> | |
| 22 | #include <__utility/swap.h> | |
| 17 | 23 | #include <cmath> |
| 18 | 24 | #include <initializer_list> |
| 19 | #include <iterator> | |
| 20 | 25 | #include <memory> |
| 21 | 26 | #include <type_traits> |
| 22 | #include <utility> | |
| 23 | 27 | |
| 24 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 29 | # pragma GCC system_header | |
| 26 | 30 | #endif |
| 27 | 31 | |
| 28 | 32 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -44,7 +48,7 @@ template <class ..._Args> |
| 44 | 48 | struct __is_hash_value_type : false_type {}; |
| 45 | 49 | |
| 46 | 50 | template <class _One> |
| 47 | struct __is_hash_value_type<_One> : __is_hash_value_type_imp<typename __uncvref<_One>::type> {}; | |
| 51 | struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__uncvref_t<_One> > {}; | |
| 48 | 52 | |
| 49 | 53 | _LIBCPP_FUNC_VIS |
| 50 | 54 | size_t __next_prime(size_t __n); |
| ... | ... | @@ -175,16 +179,14 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { |
| 175 | 179 | |
| 176 | 180 | template <class _Up> |
| 177 | 181 | _LIBCPP_INLINE_VISIBILITY |
| 178 | static typename enable_if<__is_same_uncvref<_Up, __node_value_type>::value, | |
| 179 | __container_value_type const&>::type | |
| 182 | static __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, __container_value_type const&> | |
| 180 | 183 | __get_value(_Up& __t) { |
| 181 | 184 | return __t.__get_value(); |
| 182 | 185 | } |
| 183 | 186 | |
| 184 | 187 | template <class _Up> |
| 185 | 188 | _LIBCPP_INLINE_VISIBILITY |
| 186 | static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, | |
| 187 | __container_value_type const&>::type | |
| 189 | static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&> | |
| 188 | 190 | __get_value(_Up& __t) { |
| 189 | 191 | return __t; |
| 190 | 192 | } |
| ... | ... | @@ -291,7 +293,7 @@ public: |
| 291 | 293 | _VSTD::__debug_db_insert_i(this); |
| 292 | 294 | } |
| 293 | 295 | |
| 294 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 296 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 295 | 297 | _LIBCPP_INLINE_VISIBILITY |
| 296 | 298 | __hash_iterator(const __hash_iterator& __i) |
| 297 | 299 | : __node_(__i.__node_) |
| ... | ... | @@ -315,7 +317,7 @@ public: |
| 315 | 317 | } |
| 316 | 318 | return *this; |
| 317 | 319 | } |
| 318 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 320 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 319 | 321 | |
| 320 | 322 | _LIBCPP_INLINE_VISIBILITY |
| 321 | 323 | reference operator*() const { |
| ... | ... | @@ -357,19 +359,15 @@ public: |
| 357 | 359 | {return !(__x == __y);} |
| 358 | 360 | |
| 359 | 361 | private: |
| 360 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 361 | 362 | _LIBCPP_INLINE_VISIBILITY |
| 362 | __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT | |
| 363 | explicit __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT | |
| 363 | 364 | : __node_(__node) |
| 364 | 365 | { |
| 366 | (void)__c; | |
| 367 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 365 | 368 | __get_db()->__insert_ic(this, __c); |
| 366 | } | |
| 367 | #else | |
| 368 | _LIBCPP_INLINE_VISIBILITY | |
| 369 | __hash_iterator(__next_pointer __node) _NOEXCEPT | |
| 370 | : __node_(__node) | |
| 371 | {} | |
| 372 | 369 | #endif |
| 370 | } | |
| 373 | 371 | template <class, class, class, class> friend class __hash_table; |
| 374 | 372 | template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; |
| 375 | 373 | template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; |
| ... | ... | @@ -405,12 +403,12 @@ public: |
| 405 | 403 | __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT |
| 406 | 404 | : __node_(__x.__node_) |
| 407 | 405 | { |
| 408 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 406 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 409 | 407 | __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); |
| 410 | 408 | #endif |
| 411 | 409 | } |
| 412 | 410 | |
| 413 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 411 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 414 | 412 | _LIBCPP_INLINE_VISIBILITY |
| 415 | 413 | __hash_const_iterator(const __hash_const_iterator& __i) |
| 416 | 414 | : __node_(__i.__node_) |
| ... | ... | @@ -434,7 +432,7 @@ public: |
| 434 | 432 | } |
| 435 | 433 | return *this; |
| 436 | 434 | } |
| 437 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 435 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 438 | 436 | |
| 439 | 437 | _LIBCPP_INLINE_VISIBILITY |
| 440 | 438 | reference operator*() const { |
| ... | ... | @@ -475,19 +473,15 @@ public: |
| 475 | 473 | {return !(__x == __y);} |
| 476 | 474 | |
| 477 | 475 | private: |
| 478 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 479 | 476 | _LIBCPP_INLINE_VISIBILITY |
| 480 | __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT | |
| 477 | explicit __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT | |
| 481 | 478 | : __node_(__node) |
| 482 | 479 | { |
| 480 | (void)__c; | |
| 481 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 483 | 482 | __get_db()->__insert_ic(this, __c); |
| 484 | } | |
| 485 | #else | |
| 486 | _LIBCPP_INLINE_VISIBILITY | |
| 487 | __hash_const_iterator(__next_pointer __node) _NOEXCEPT | |
| 488 | : __node_(__node) | |
| 489 | {} | |
| 490 | 483 | #endif |
| 484 | } | |
| 491 | 485 | template <class, class, class, class> friend class __hash_table; |
| 492 | 486 | template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; |
| 493 | 487 | template <class, class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS unordered_map; |
| ... | ... | @@ -516,7 +510,7 @@ public: |
| 516 | 510 | _VSTD::__debug_db_insert_i(this); |
| 517 | 511 | } |
| 518 | 512 | |
| 519 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 513 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 520 | 514 | _LIBCPP_INLINE_VISIBILITY |
| 521 | 515 | __hash_local_iterator(const __hash_local_iterator& __i) |
| 522 | 516 | : __node_(__i.__node_), |
| ... | ... | @@ -544,7 +538,7 @@ public: |
| 544 | 538 | } |
| 545 | 539 | return *this; |
| 546 | 540 | } |
| 547 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 541 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 548 | 542 | |
| 549 | 543 | _LIBCPP_INLINE_VISIBILITY |
| 550 | 544 | reference operator*() const { |
| ... | ... | @@ -588,30 +582,20 @@ public: |
| 588 | 582 | {return !(__x == __y);} |
| 589 | 583 | |
| 590 | 584 | private: |
| 591 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 592 | 585 | _LIBCPP_INLINE_VISIBILITY |
| 593 | __hash_local_iterator(__next_pointer __node, size_t __bucket, | |
| 594 | size_t __bucket_count, const void* __c) _NOEXCEPT | |
| 586 | explicit __hash_local_iterator(__next_pointer __node, size_t __bucket, | |
| 587 | size_t __bucket_count, const void* __c) _NOEXCEPT | |
| 595 | 588 | : __node_(__node), |
| 596 | 589 | __bucket_(__bucket), |
| 597 | 590 | __bucket_count_(__bucket_count) |
| 598 | 591 | { |
| 592 | (void)__c; | |
| 593 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 599 | 594 | __get_db()->__insert_ic(this, __c); |
| 595 | #endif | |
| 600 | 596 | if (__node_ != nullptr) |
| 601 | 597 | __node_ = __node_->__next_; |
| 602 | 598 | } |
| 603 | #else | |
| 604 | _LIBCPP_INLINE_VISIBILITY | |
| 605 | __hash_local_iterator(__next_pointer __node, size_t __bucket, | |
| 606 | size_t __bucket_count) _NOEXCEPT | |
| 607 | : __node_(__node), | |
| 608 | __bucket_(__bucket), | |
| 609 | __bucket_count_(__bucket_count) | |
| 610 | { | |
| 611 | if (__node_ != nullptr) | |
| 612 | __node_ = __node_->__next_; | |
| 613 | } | |
| 614 | #endif | |
| 615 | 599 | template <class, class, class, class> friend class __hash_table; |
| 616 | 600 | template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator; |
| 617 | 601 | template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator; |
| ... | ... | @@ -654,12 +638,12 @@ public: |
| 654 | 638 | __bucket_(__x.__bucket_), |
| 655 | 639 | __bucket_count_(__x.__bucket_count_) |
| 656 | 640 | { |
| 657 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 641 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 658 | 642 | __get_db()->__iterator_copy(this, _VSTD::addressof(__x)); |
| 659 | 643 | #endif |
| 660 | 644 | } |
| 661 | 645 | |
| 662 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 646 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 663 | 647 | _LIBCPP_INLINE_VISIBILITY |
| 664 | 648 | __hash_const_local_iterator(const __hash_const_local_iterator& __i) |
| 665 | 649 | : __node_(__i.__node_), |
| ... | ... | @@ -687,7 +671,7 @@ public: |
| 687 | 671 | } |
| 688 | 672 | return *this; |
| 689 | 673 | } |
| 690 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 674 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 691 | 675 | |
| 692 | 676 | _LIBCPP_INLINE_VISIBILITY |
| 693 | 677 | reference operator*() const { |
| ... | ... | @@ -731,30 +715,20 @@ public: |
| 731 | 715 | {return !(__x == __y);} |
| 732 | 716 | |
| 733 | 717 | private: |
| 734 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 735 | 718 | _LIBCPP_INLINE_VISIBILITY |
| 736 | __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, | |
| 737 | size_t __bucket_count, const void* __c) _NOEXCEPT | |
| 719 | explicit __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, | |
| 720 | size_t __bucket_count, const void* __c) _NOEXCEPT | |
| 738 | 721 | : __node_(__node_ptr), |
| 739 | 722 | __bucket_(__bucket), |
| 740 | 723 | __bucket_count_(__bucket_count) |
| 741 | 724 | { |
| 725 | (void)__c; | |
| 726 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 742 | 727 | __get_db()->__insert_ic(this, __c); |
| 728 | #endif | |
| 743 | 729 | if (__node_ != nullptr) |
| 744 | 730 | __node_ = __node_->__next_; |
| 745 | 731 | } |
| 746 | #else | |
| 747 | _LIBCPP_INLINE_VISIBILITY | |
| 748 | __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, | |
| 749 | size_t __bucket_count) _NOEXCEPT | |
| 750 | : __node_(__node_ptr), | |
| 751 | __bucket_(__bucket), | |
| 752 | __bucket_count_(__bucket_count) | |
| 753 | { | |
| 754 | if (__node_ != nullptr) | |
| 755 | __node_ = __node_->__next_; | |
| 756 | } | |
| 757 | #endif | |
| 758 | 732 | template <class, class, class, class> friend class __hash_table; |
| 759 | 733 | template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator; |
| 760 | 734 | }; |
| ... | ... | @@ -1074,10 +1048,8 @@ public: |
| 1074 | 1048 | |
| 1075 | 1049 | template <class _First, class _Second> |
| 1076 | 1050 | _LIBCPP_INLINE_VISIBILITY |
| 1077 | typename enable_if< | |
| 1078 | __can_extract_map_key<_First, key_type, __container_value_type>::value, | |
| 1079 | pair<iterator, bool> | |
| 1080 | >::type __emplace_unique(_First&& __f, _Second&& __s) { | |
| 1051 | __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> > | |
| 1052 | __emplace_unique(_First&& __f, _Second&& __s) { | |
| 1081 | 1053 | return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), |
| 1082 | 1054 | _VSTD::forward<_Second>(__s)); |
| 1083 | 1055 | } |
| ... | ... | @@ -1121,9 +1093,7 @@ public: |
| 1121 | 1093 | return __emplace_unique_key_args(_NodeTypes::__get_key(__x), _VSTD::move(__x)); |
| 1122 | 1094 | } |
| 1123 | 1095 | |
| 1124 | template <class _Pp, class = typename enable_if< | |
| 1125 | !__is_same_uncvref<_Pp, __container_value_type>::value | |
| 1126 | >::type> | |
| 1096 | template <class _Pp, class = __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value> > | |
| 1127 | 1097 | _LIBCPP_INLINE_VISIBILITY |
| 1128 | 1098 | pair<iterator, bool> __insert_unique(_Pp&& __x) { |
| 1129 | 1099 | return __emplace_unique(_VSTD::forward<_Pp>(__x)); |
| ... | ... | @@ -1177,9 +1147,16 @@ public: |
| 1177 | 1147 | #endif |
| 1178 | 1148 | |
| 1179 | 1149 | void clear() _NOEXCEPT; |
| 1180 | void rehash(size_type __n); | |
| 1181 | _LIBCPP_INLINE_VISIBILITY void reserve(size_type __n) | |
| 1182 | {rehash(static_cast<size_type>(ceil(__n / max_load_factor())));} | |
| 1150 | _LIBCPP_INLINE_VISIBILITY void __rehash_unique(size_type __n) { __rehash<true>(__n); } | |
| 1151 | _LIBCPP_INLINE_VISIBILITY void __rehash_multi(size_type __n) { __rehash<false>(__n); } | |
| 1152 | _LIBCPP_INLINE_VISIBILITY void __reserve_unique(size_type __n) | |
| 1153 | { | |
| 1154 | __rehash_unique(static_cast<size_type>(ceil(__n / max_load_factor()))); | |
| 1155 | } | |
| 1156 | _LIBCPP_INLINE_VISIBILITY void __reserve_multi(size_type __n) | |
| 1157 | { | |
| 1158 | __rehash_multi(static_cast<size_type>(ceil(__n / max_load_factor()))); | |
| 1159 | } | |
| 1183 | 1160 | |
| 1184 | 1161 | _LIBCPP_INLINE_VISIBILITY |
| 1185 | 1162 | size_type bucket_count() const _NOEXCEPT |
| ... | ... | @@ -1276,11 +1253,7 @@ public: |
| 1276 | 1253 | { |
| 1277 | 1254 | _LIBCPP_ASSERT(__n < bucket_count(), |
| 1278 | 1255 | "unordered container::begin(n) called with n >= bucket_count()"); |
| 1279 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1280 | 1256 | return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); |
| 1281 | #else | |
| 1282 | return local_iterator(__bucket_list_[__n], __n, bucket_count()); | |
| 1283 | #endif | |
| 1284 | 1257 | } |
| 1285 | 1258 | |
| 1286 | 1259 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1289,11 +1262,7 @@ public: |
| 1289 | 1262 | { |
| 1290 | 1263 | _LIBCPP_ASSERT(__n < bucket_count(), |
| 1291 | 1264 | "unordered container::end(n) called with n >= bucket_count()"); |
| 1292 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1293 | 1265 | return local_iterator(nullptr, __n, bucket_count(), this); |
| 1294 | #else | |
| 1295 | return local_iterator(nullptr, __n, bucket_count()); | |
| 1296 | #endif | |
| 1297 | 1266 | } |
| 1298 | 1267 | |
| 1299 | 1268 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1302,11 +1271,7 @@ public: |
| 1302 | 1271 | { |
| 1303 | 1272 | _LIBCPP_ASSERT(__n < bucket_count(), |
| 1304 | 1273 | "unordered container::cbegin(n) called with n >= bucket_count()"); |
| 1305 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1306 | 1274 | return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); |
| 1307 | #else | |
| 1308 | return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); | |
| 1309 | #endif | |
| 1310 | 1275 | } |
| 1311 | 1276 | |
| 1312 | 1277 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1315,24 +1280,21 @@ public: |
| 1315 | 1280 | { |
| 1316 | 1281 | _LIBCPP_ASSERT(__n < bucket_count(), |
| 1317 | 1282 | "unordered container::cend(n) called with n >= bucket_count()"); |
| 1318 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1319 | 1283 | return const_local_iterator(nullptr, __n, bucket_count(), this); |
| 1320 | #else | |
| 1321 | return const_local_iterator(nullptr, __n, bucket_count()); | |
| 1322 | #endif | |
| 1323 | 1284 | } |
| 1324 | 1285 | |
| 1325 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1286 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1326 | 1287 | |
| 1327 | 1288 | bool __dereferenceable(const const_iterator* __i) const; |
| 1328 | 1289 | bool __decrementable(const const_iterator* __i) const; |
| 1329 | 1290 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const; |
| 1330 | 1291 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; |
| 1331 | 1292 | |
| 1332 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1293 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1333 | 1294 | |
| 1334 | 1295 | private: |
| 1335 | void __rehash(size_type __n); | |
| 1296 | template <bool _UniqueKeys> void __rehash(size_type __n); | |
| 1297 | template <bool _UniqueKeys> void __do_rehash(size_type __n); | |
| 1336 | 1298 | |
| 1337 | 1299 | template <class ..._Args> |
| 1338 | 1300 | __node_holder __construct_node(_Args&& ...__args); |
| ... | ... | @@ -1509,9 +1471,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() |
| 1509 | 1471 | #endif |
| 1510 | 1472 | |
| 1511 | 1473 | __deallocate_node(__p1_.first().__next_); |
| 1512 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1513 | __get_db()->__erase_c(this); | |
| 1514 | #endif | |
| 1474 | std::__debug_db_erase_c(this); | |
| 1515 | 1475 | } |
| 1516 | 1476 | |
| 1517 | 1477 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1553,7 +1513,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) |
| 1553 | 1513 | while (__np != nullptr) |
| 1554 | 1514 | { |
| 1555 | 1515 | __next_pointer __next = __np->__next_; |
| 1556 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1516 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1557 | 1517 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 1558 | 1518 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) |
| 1559 | 1519 | { |
| ... | ... | @@ -1614,9 +1574,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( |
| 1614 | 1574 | __u.__p1_.first().__next_ = nullptr; |
| 1615 | 1575 | __u.size() = 0; |
| 1616 | 1576 | } |
| 1617 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1618 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1619 | #endif | |
| 1577 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1620 | 1578 | } |
| 1621 | 1579 | |
| 1622 | 1580 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1766,11 +1724,7 @@ inline |
| 1766 | 1724 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 1767 | 1725 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT |
| 1768 | 1726 | { |
| 1769 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1770 | 1727 | return iterator(__p1_.first().__next_, this); |
| 1771 | #else | |
| 1772 | return iterator(__p1_.first().__next_); | |
| 1773 | #endif | |
| 1774 | 1728 | } |
| 1775 | 1729 | |
| 1776 | 1730 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1778,11 +1732,7 @@ inline |
| 1778 | 1732 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator |
| 1779 | 1733 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT |
| 1780 | 1734 | { |
| 1781 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1782 | 1735 | return iterator(nullptr, this); |
| 1783 | #else | |
| 1784 | return iterator(nullptr); | |
| 1785 | #endif | |
| 1786 | 1736 | } |
| 1787 | 1737 | |
| 1788 | 1738 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1790,11 +1740,7 @@ inline |
| 1790 | 1740 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator |
| 1791 | 1741 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT |
| 1792 | 1742 | { |
| 1793 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1794 | 1743 | return const_iterator(__p1_.first().__next_, this); |
| 1795 | #else | |
| 1796 | return const_iterator(__p1_.first().__next_); | |
| 1797 | #endif | |
| 1798 | 1744 | } |
| 1799 | 1745 | |
| 1800 | 1746 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1802,11 +1748,7 @@ inline |
| 1802 | 1748 | typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator |
| 1803 | 1749 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT |
| 1804 | 1750 | { |
| 1805 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1806 | 1751 | return const_iterator(nullptr, this); |
| 1807 | #else | |
| 1808 | return const_iterator(nullptr); | |
| 1809 | #endif | |
| 1810 | 1752 | } |
| 1811 | 1753 | |
| 1812 | 1754 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -1857,7 +1799,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare( |
| 1857 | 1799 | } |
| 1858 | 1800 | if (size()+1 > __bc * max_load_factor() || __bc == 0) |
| 1859 | 1801 | { |
| 1860 | rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 1802 | __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 1861 | 1803 | size_type(ceil(float(size() + 1) / max_load_factor())))); |
| 1862 | 1804 | } |
| 1863 | 1805 | return nullptr; |
| ... | ... | @@ -1911,11 +1853,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ |
| 1911 | 1853 | __existing_node = __nd->__ptr(); |
| 1912 | 1854 | __inserted = true; |
| 1913 | 1855 | } |
| 1914 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1915 | 1856 | return pair<iterator, bool>(iterator(__existing_node, this), __inserted); |
| 1916 | #else | |
| 1917 | return pair<iterator, bool>(iterator(__existing_node), __inserted); | |
| 1918 | #endif | |
| 1919 | 1857 | } |
| 1920 | 1858 | |
| 1921 | 1859 | // Prepare the container for an insertion of the value __cp_val with the hash |
| ... | ... | @@ -1933,7 +1871,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare( |
| 1933 | 1871 | size_type __bc = bucket_count(); |
| 1934 | 1872 | if (size()+1 > __bc * max_load_factor() || __bc == 0) |
| 1935 | 1873 | { |
| 1936 | rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 1874 | __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 1937 | 1875 | size_type(ceil(float(size() + 1) / max_load_factor())))); |
| 1938 | 1876 | __bc = bucket_count(); |
| 1939 | 1877 | } |
| ... | ... | @@ -2009,11 +1947,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c |
| 2009 | 1947 | __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_); |
| 2010 | 1948 | __node_insert_multi_perform(__cp, __pn); |
| 2011 | 1949 | |
| 2012 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2013 | 1950 | return iterator(__cp->__ptr(), this); |
| 2014 | #else | |
| 2015 | return iterator(__cp->__ptr()); | |
| 2016 | #endif | |
| 2017 | 1951 | } |
| 2018 | 1952 | |
| 2019 | 1953 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -2031,7 +1965,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( |
| 2031 | 1965 | size_type __bc = bucket_count(); |
| 2032 | 1966 | if (size()+1 > __bc * max_load_factor() || __bc == 0) |
| 2033 | 1967 | { |
| 2034 | rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 1968 | __rehash_multi(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 2035 | 1969 | size_type(ceil(float(size() + 1) / max_load_factor())))); |
| 2036 | 1970 | __bc = bucket_count(); |
| 2037 | 1971 | } |
| ... | ... | @@ -2042,11 +1976,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( |
| 2042 | 1976 | __cp->__next_ = __np; |
| 2043 | 1977 | __pp->__next_ = static_cast<__next_pointer>(__cp); |
| 2044 | 1978 | ++size(); |
| 2045 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2046 | 1979 | return iterator(static_cast<__next_pointer>(__cp), this); |
| 2047 | #else | |
| 2048 | return iterator(static_cast<__next_pointer>(__cp)); | |
| 2049 | #endif | |
| 2050 | 1980 | } |
| 2051 | 1981 | return __node_insert_multi(__cp); |
| 2052 | 1982 | } |
| ... | ... | @@ -2083,7 +2013,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& |
| 2083 | 2013 | __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...); |
| 2084 | 2014 | if (size()+1 > __bc * max_load_factor() || __bc == 0) |
| 2085 | 2015 | { |
| 2086 | rehash(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 2016 | __rehash_unique(_VSTD::max<size_type>(2 * __bc + !__is_hash_power2(__bc), | |
| 2087 | 2017 | size_type(ceil(float(size() + 1) / max_load_factor())))); |
| 2088 | 2018 | __bc = bucket_count(); |
| 2089 | 2019 | __chash = __constrain_hash(__hash, __bc); |
| ... | ... | @@ -2112,11 +2042,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& |
| 2112 | 2042 | __inserted = true; |
| 2113 | 2043 | } |
| 2114 | 2044 | __done: |
| 2115 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2116 | 2045 | return pair<iterator, bool>(iterator(__nd, this), __inserted); |
| 2117 | #else | |
| 2118 | return pair<iterator, bool>(iterator(__nd), __inserted); | |
| 2119 | #endif | |
| 2120 | 2046 | } |
| 2121 | 2047 | |
| 2122 | 2048 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -2290,8 +2216,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi( |
| 2290 | 2216 | #endif // _LIBCPP_STD_VER > 14 |
| 2291 | 2217 | |
| 2292 | 2218 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 2219 | template <bool _UniqueKeys> | |
| 2293 | 2220 | void |
| 2294 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n) | |
| 2221 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) | |
| 2295 | 2222 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 2296 | 2223 | { |
| 2297 | 2224 | if (__n == 1) |
| ... | ... | @@ -2300,7 +2227,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 2300 | 2227 | __n = __next_prime(__n); |
| 2301 | 2228 | size_type __bc = bucket_count(); |
| 2302 | 2229 | if (__n > __bc) |
| 2303 | __rehash(__n); | |
| 2230 | __do_rehash<_UniqueKeys>(__n); | |
| 2304 | 2231 | else if (__n < __bc) |
| 2305 | 2232 | { |
| 2306 | 2233 | __n = _VSTD::max<size_type> |
| ... | ... | @@ -2310,17 +2237,16 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 2310 | 2237 | __next_prime(size_t(ceil(float(size()) / max_load_factor()))) |
| 2311 | 2238 | ); |
| 2312 | 2239 | if (__n < __bc) |
| 2313 | __rehash(__n); | |
| 2240 | __do_rehash<_UniqueKeys>(__n); | |
| 2314 | 2241 | } |
| 2315 | 2242 | } |
| 2316 | 2243 | |
| 2317 | 2244 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 2245 | template <bool _UniqueKeys> | |
| 2318 | 2246 | void |
| 2319 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) | |
| 2247 | __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) | |
| 2320 | 2248 | { |
| 2321 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2322 | __get_db()->__invalidate_all(this); | |
| 2323 | #endif | |
| 2249 | std::__debug_db_invalidate_all(this); | |
| 2324 | 2250 | __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); |
| 2325 | 2251 | __bucket_list_.reset(__nbc > 0 ? |
| 2326 | 2252 | __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); |
| ... | ... | @@ -2353,11 +2279,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) |
| 2353 | 2279 | else |
| 2354 | 2280 | { |
| 2355 | 2281 | __next_pointer __np = __cp; |
| 2356 | for (; __np->__next_ != nullptr && | |
| 2357 | key_eq()(__cp->__upcast()->__value_, | |
| 2358 | __np->__next_->__upcast()->__value_); | |
| 2359 | __np = __np->__next_) | |
| 2360 | ; | |
| 2282 | if _LIBCPP_CONSTEXPR_AFTER_CXX14 (!_UniqueKeys) | |
| 2283 | { | |
| 2284 | for (; __np->__next_ != nullptr && | |
| 2285 | key_eq()(__cp->__upcast()->__value_, | |
| 2286 | __np->__next_->__upcast()->__value_); | |
| 2287 | __np = __np->__next_) | |
| 2288 | ; | |
| 2289 | } | |
| 2361 | 2290 | __pp->__next_ = __np->__next_; |
| 2362 | 2291 | __np->__next_ = __bucket_list_[__chash]->__next_; |
| 2363 | 2292 | __bucket_list_[__chash]->__next_ = __cp; |
| ... | ... | @@ -2389,11 +2318,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) |
| 2389 | 2318 | { |
| 2390 | 2319 | if ((__nd->__hash() == __hash) |
| 2391 | 2320 | && key_eq()(__nd->__upcast()->__value_, __k)) |
| 2392 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2393 | 2321 | return iterator(__nd, this); |
| 2394 | #else | |
| 2395 | return iterator(__nd); | |
| 2396 | #endif | |
| 2397 | 2322 | } |
| 2398 | 2323 | } |
| 2399 | 2324 | } |
| ... | ... | @@ -2420,11 +2345,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const |
| 2420 | 2345 | { |
| 2421 | 2346 | if ((__nd->__hash() == __hash) |
| 2422 | 2347 | && key_eq()(__nd->__upcast()->__value_, __k)) |
| 2423 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2424 | 2348 | return const_iterator(__nd, this); |
| 2425 | #else | |
| 2426 | return const_iterator(__nd); | |
| 2427 | #endif | |
| 2428 | 2349 | } |
| 2429 | 2350 | } |
| 2430 | 2351 | |
| ... | ... | @@ -2475,13 +2396,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) |
| 2475 | 2396 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, |
| 2476 | 2397 | "unordered container erase(iterator) called with an iterator not" |
| 2477 | 2398 | " referring to this container"); |
| 2478 | _LIBCPP_DEBUG_ASSERT(__p != end(), | |
| 2479 | "unordered container erase(iterator) called with a non-dereferenceable iterator"); | |
| 2480 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2399 | _LIBCPP_ASSERT(__p != end(), | |
| 2400 | "unordered container erase(iterator) called with a non-dereferenceable iterator"); | |
| 2481 | 2401 | iterator __r(__np, this); |
| 2482 | #else | |
| 2483 | iterator __r(__np); | |
| 2484 | #endif | |
| 2485 | 2402 | ++__r; |
| 2486 | 2403 | remove(__p); |
| 2487 | 2404 | return __r; |
| ... | ... | @@ -2504,11 +2421,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, |
| 2504 | 2421 | erase(__p); |
| 2505 | 2422 | } |
| 2506 | 2423 | __next_pointer __np = __last.__node_; |
| 2507 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2508 | 2424 | return iterator (__np, this); |
| 2509 | #else | |
| 2510 | return iterator (__np); | |
| 2511 | #endif | |
| 2512 | 2425 | } |
| 2513 | 2426 | |
| 2514 | 2427 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -2575,7 +2488,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT |
| 2575 | 2488 | __pn->__next_ = __cn->__next_; |
| 2576 | 2489 | __cn->__next_ = nullptr; |
| 2577 | 2490 | --size(); |
| 2578 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2491 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2579 | 2492 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 2580 | 2493 | for (__i_node** __dp = __c->end_; __dp != __c->beg_; ) |
| 2581 | 2494 | { |
| ... | ... | @@ -2726,9 +2639,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) |
| 2726 | 2639 | if (__u.size() > 0) |
| 2727 | 2640 | __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = |
| 2728 | 2641 | __u.__p1_.first().__ptr(); |
| 2729 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2730 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 2731 | #endif | |
| 2642 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 2732 | 2643 | } |
| 2733 | 2644 | |
| 2734 | 2645 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| ... | ... | @@ -2760,7 +2671,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, |
| 2760 | 2671 | __x.swap(__y); |
| 2761 | 2672 | } |
| 2762 | 2673 | |
| 2763 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2674 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2764 | 2675 | |
| 2765 | 2676 | template <class _Tp, class _Hash, class _Equal, class _Alloc> |
| 2766 | 2677 | bool |
| ... | ... | @@ -2790,10 +2701,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, |
| 2790 | 2701 | return false; |
| 2791 | 2702 | } |
| 2792 | 2703 | |
| 2793 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 2704 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 2794 | 2705 | |
| 2795 | 2706 | _LIBCPP_END_NAMESPACE_STD |
| 2796 | 2707 | |
| 2797 | 2708 | _LIBCPP_POP_MACROS |
| 2798 | 2709 | |
| 2799 | #endif // _LIBCPP__HASH_TABLE | |
| 2710 | #endif // _LIBCPP___HASH_TABLE |
lib/libcxx/include/__ios/fpos.h created+79| ... | ... | @@ -0,0 +1,79 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___IOS_FPOS_H | |
| 11 | #define _LIBCPP___IOS_FPOS_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <iosfwd> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _StateT> | |
| 23 | class _LIBCPP_TEMPLATE_VIS fpos { | |
| 24 | private: | |
| 25 | _StateT __st_; | |
| 26 | streamoff __off_; | |
| 27 | ||
| 28 | public: | |
| 29 | _LIBCPP_HIDE_FROM_ABI fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} | |
| 30 | ||
| 31 | _LIBCPP_HIDE_FROM_ABI operator streamoff() const { return __off_; } | |
| 32 | ||
| 33 | _LIBCPP_HIDE_FROM_ABI _StateT state() const { return __st_; } | |
| 34 | _LIBCPP_HIDE_FROM_ABI void state(_StateT __st) { __st_ = __st; } | |
| 35 | ||
| 36 | _LIBCPP_HIDE_FROM_ABI fpos& operator+=(streamoff __off) { | |
| 37 | __off_ += __off; | |
| 38 | return *this; | |
| 39 | } | |
| 40 | ||
| 41 | _LIBCPP_HIDE_FROM_ABI fpos operator+(streamoff __off) const { | |
| 42 | fpos __t(*this); | |
| 43 | __t += __off; | |
| 44 | return __t; | |
| 45 | } | |
| 46 | ||
| 47 | _LIBCPP_HIDE_FROM_ABI fpos& operator-=(streamoff __off) { | |
| 48 | __off_ -= __off; | |
| 49 | return *this; | |
| 50 | } | |
| 51 | ||
| 52 | _LIBCPP_HIDE_FROM_ABI fpos operator-(streamoff __off) const { | |
| 53 | fpos __t(*this); | |
| 54 | __t -= __off; | |
| 55 | return __t; | |
| 56 | } | |
| 57 | }; | |
| 58 | ||
| 59 | template <class _StateT> | |
| 60 | inline _LIBCPP_HIDE_FROM_ABI | |
| 61 | streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) { | |
| 62 | return streamoff(__x) - streamoff(__y); | |
| 63 | } | |
| 64 | ||
| 65 | template <class _StateT> | |
| 66 | inline _LIBCPP_HIDE_FROM_ABI | |
| 67 | bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) { | |
| 68 | return streamoff(__x) == streamoff(__y); | |
| 69 | } | |
| 70 | ||
| 71 | template <class _StateT> | |
| 72 | inline _LIBCPP_HIDE_FROM_ABI | |
| 73 | bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) { | |
| 74 | return streamoff(__x) != streamoff(__y); | |
| 75 | } | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD | |
| 78 | ||
| 79 | #endif // _LIBCPP___IOS_FPOS_H |
lib/libcxx/include/__iterator/access.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <cstddef> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__iterator/advance.h+27-27| ... | ... | @@ -10,19 +10,20 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_ADVANCE_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_ADVANCE_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__iterator/concepts.h> |
| 16 | 16 | #include <__iterator/incrementable_traits.h> |
| 17 | 17 | #include <__iterator/iterator_traits.h> |
| 18 | 18 | #include <__utility/move.h> |
| 19 | #include <__utility/unreachable.h> | |
| 19 | 20 | #include <concepts> |
| 20 | 21 | #include <cstdlib> |
| 21 | 22 | #include <limits> |
| 22 | 23 | #include <type_traits> |
| 23 | 24 | |
| 24 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 26 | 27 | #endif |
| 27 | 28 | |
| 28 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -64,7 +65,7 @@ void advance(_InputIter& __i, _Distance __orig_n) { |
| 64 | 65 | _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); |
| 65 | 66 | } |
| 66 | 67 | |
| 67 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 68 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 68 | 69 | |
| 69 | 70 | // [range.iter.op.advance] |
| 70 | 71 | |
| ... | ... | @@ -116,47 +117,46 @@ public: |
| 116 | 117 | } |
| 117 | 118 | } |
| 118 | 119 | |
| 119 | // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range. | |
| 120 | // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound_sentinel) denotes a range. | |
| 120 | 121 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 121 | _LIBCPP_HIDE_FROM_ABI | |
| 122 | constexpr void operator()(_Ip& __i, _Sp __bound) const { | |
| 123 | // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`. | |
| 122 | _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, _Sp __bound_sentinel) const { | |
| 123 | // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound_sentinel)`. | |
| 124 | 124 | if constexpr (assignable_from<_Ip&, _Sp>) { |
| 125 | __i = _VSTD::move(__bound); | |
| 125 | __i = _VSTD::move(__bound_sentinel); | |
| 126 | 126 | } |
| 127 | // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`. | |
| 127 | // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound_sentinel - i)`. | |
| 128 | 128 | else if constexpr (sized_sentinel_for<_Sp, _Ip>) { |
| 129 | (*this)(__i, __bound - __i); | |
| 129 | (*this)(__i, __bound_sentinel - __i); | |
| 130 | 130 | } |
| 131 | // Otherwise, while `bool(i != bound)` is true, increments `i`. | |
| 131 | // Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`. | |
| 132 | 132 | else { |
| 133 | while (__i != __bound) { | |
| 133 | while (__i != __bound_sentinel) { | |
| 134 | 134 | ++__i; |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Preconditions: |
| 140 | // * If `n > 0`, [i, bound) denotes a range. | |
| 141 | // * If `n == 0`, [i, bound) or [bound, i) denotes a range. | |
| 142 | // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`. | |
| 143 | // Returns: `n - M`, where `M` is the difference between the the ending and starting position. | |
| 140 | // * If `n > 0`, [i, bound_sentinel) denotes a range. | |
| 141 | // * If `n == 0`, [i, bound_sentinel) or [bound_sentinel, i) denotes a range. | |
| 142 | // * If `n < 0`, [bound_sentinel, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`. | |
| 143 | // Returns: `n - M`, where `M` is the difference between the ending and starting position. | |
| 144 | 144 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 145 | _LIBCPP_HIDE_FROM_ABI | |
| 146 | constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const { | |
| 145 | _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, | |
| 146 | _Sp __bound_sentinel) const { | |
| 147 | 147 | _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), |
| 148 | 148 | "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true."); |
| 149 | 149 | // If `S` and `I` model `sized_sentinel_for<S, I>`: |
| 150 | 150 | if constexpr (sized_sentinel_for<_Sp, _Ip>) { |
| 151 | // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. | |
| 151 | // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`. | |
| 152 | 152 | // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign. |
| 153 | 153 | auto __magnitude_geq = [](auto __a, auto __b) { |
| 154 | 154 | return __a == 0 ? __b == 0 : |
| 155 | 155 | __a > 0 ? __a >= __b : |
| 156 | 156 | __a <= __b; |
| 157 | 157 | }; |
| 158 | if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) { | |
| 159 | (*this)(__i, __bound); | |
| 158 | if (const auto __M = __bound_sentinel - __i; __magnitude_geq(__n, __M)) { | |
| 159 | (*this)(__i, __bound_sentinel); | |
| 160 | 160 | return __n - __M; |
| 161 | 161 | } |
| 162 | 162 | |
| ... | ... | @@ -164,16 +164,16 @@ public: |
| 164 | 164 | (*this)(__i, __n); |
| 165 | 165 | return 0; |
| 166 | 166 | } else { |
| 167 | // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at | |
| 167 | // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at | |
| 168 | 168 | // most `n` times. |
| 169 | while (__i != __bound && __n > 0) { | |
| 169 | while (__i != __bound_sentinel && __n > 0) { | |
| 170 | 170 | ++__i; |
| 171 | 171 | --__n; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times. | |
| 174 | // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times. | |
| 175 | 175 | if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { |
| 176 | while (__i != __bound && __n < 0) { | |
| 176 | while (__i != __bound_sentinel && __n < 0) { | |
| 177 | 177 | --__i; |
| 178 | 178 | ++__n; |
| 179 | 179 | } |
| ... | ... | @@ -181,7 +181,7 @@ public: |
| 181 | 181 | return __n; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | _LIBCPP_UNREACHABLE(); | |
| 184 | __libcpp_unreachable(); | |
| 185 | 185 | } |
| 186 | 186 | }; |
| 187 | 187 | |
| ... | ... | @@ -192,7 +192,7 @@ inline namespace __cpo { |
| 192 | 192 | } // namespace __cpo |
| 193 | 193 | } // namespace ranges |
| 194 | 194 | |
| 195 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 195 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 196 | 196 | |
| 197 | 197 | _LIBCPP_END_NAMESPACE_STD |
| 198 | 198 |
lib/libcxx/include/__iterator/back_insert_iterator.h+7-5| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <cstddef> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -46,15 +46,17 @@ public: |
| 46 | 46 | typedef _Container container_type; |
| 47 | 47 | |
| 48 | 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_) | |
| 50 | {container->push_back(__value_); return *this;} | |
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value) | |
| 50 | {container->push_back(__value); return *this;} | |
| 51 | 51 | #ifndef _LIBCPP_CXX03_LANG |
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) | |
| 53 | {container->push_back(_VSTD::move(__value_)); return *this;} | |
| 52 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value) | |
| 53 | {container->push_back(_VSTD::move(__value)); return *this;} | |
| 54 | 54 | #endif // _LIBCPP_CXX03_LANG |
| 55 | 55 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} |
| 56 | 56 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} |
| 57 | 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} |
| 58 | ||
| 59 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Container* __get_container() const { return container; } | |
| 58 | 60 | }; |
| 59 | 61 | |
| 60 | 62 | template <class _Container> |
lib/libcxx/include/__iterator/bounded_iter.h created+229| ... | ... | @@ -0,0 +1,229 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ITERATOR_BOUNDED_ITER_H | |
| 11 | #define _LIBCPP___ITERATOR_BOUNDED_ITER_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/iterator_traits.h> | |
| 16 | #include <__memory/pointer_traits.h> | |
| 17 | #include <__utility/move.h> | |
| 18 | #include <type_traits> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | // Iterator wrapper that carries the valid range it is allowed to access. | |
| 27 | // | |
| 28 | // This is a simple iterator wrapper for contiguous iterators that points | |
| 29 | // within a [begin, end) range and carries these bounds with it. The iterator | |
| 30 | // ensures that it is pointing within that [begin, end) range when it is | |
| 31 | // dereferenced. | |
| 32 | // | |
| 33 | // Arithmetic operations are allowed and the bounds of the resulting iterator | |
| 34 | // are not checked. Hence, it is possible to create an iterator pointing outside | |
| 35 | // its range, but it is not possible to dereference it. | |
| 36 | template <class _Iterator, class = __enable_if_t< __is_cpp17_contiguous_iterator<_Iterator>::value > > | |
| 37 | struct __bounded_iter { | |
| 38 | using value_type = typename iterator_traits<_Iterator>::value_type; | |
| 39 | using difference_type = typename iterator_traits<_Iterator>::difference_type; | |
| 40 | using pointer = typename iterator_traits<_Iterator>::pointer; | |
| 41 | using reference = typename iterator_traits<_Iterator>::reference; | |
| 42 | using iterator_category = typename iterator_traits<_Iterator>::iterator_category; | |
| 43 | #if _LIBCPP_STD_VER > 17 | |
| 44 | using iterator_concept = contiguous_iterator_tag; | |
| 45 | #endif | |
| 46 | ||
| 47 | // Create a singular iterator. | |
| 48 | // | |
| 49 | // Such an iterator does not point to any object and is conceptually out of bounds, so it is | |
| 50 | // not dereferenceable. Observing operations like comparison and assignment are valid. | |
| 51 | _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default; | |
| 52 | ||
| 53 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default; | |
| 54 | _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default; | |
| 55 | ||
| 56 | template <class _OtherIterator, class = __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value > > | |
| 57 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT | |
| 58 | : __current_(__other.__current_), | |
| 59 | __begin_(__other.__begin_), | |
| 60 | __end_(__other.__end_) {} | |
| 61 | ||
| 62 | // Assign a bounded iterator to another one, rebinding the bounds of the iterator as well. | |
| 63 | _LIBCPP_HIDE_FROM_ABI __bounded_iter& operator=(__bounded_iter const&) = default; | |
| 64 | _LIBCPP_HIDE_FROM_ABI __bounded_iter& operator=(__bounded_iter&&) = default; | |
| 65 | ||
| 66 | private: | |
| 67 | // Create an iterator wrapping the given iterator, and whose bounds are described | |
| 68 | // by the provided [begin, end) range. | |
| 69 | // | |
| 70 | // This constructor does not check whether the resulting iterator is within its bounds. | |
| 71 | // However, it does check that the provided [begin, end) range is a valid range (that | |
| 72 | // is, begin <= end). | |
| 73 | // | |
| 74 | // Since it is non-standard for iterators to have this constructor, __bounded_iter must | |
| 75 | // be created via `std::__make_bounded_iter`. | |
| 76 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit __bounded_iter( | |
| 77 | _Iterator __current, _Iterator __begin, _Iterator __end) | |
| 78 | : __current_(__current), __begin_(__begin), __end_(__end) { | |
| 79 | _LIBCPP_ASSERT(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range"); | |
| 80 | } | |
| 81 | ||
| 82 | template <class _It> | |
| 83 | friend _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(_It, _It, _It); | |
| 84 | ||
| 85 | public: | |
| 86 | // Dereference and indexing operations. | |
| 87 | // | |
| 88 | // These operations check that the iterator is dereferenceable, that is within [begin, end). | |
| 89 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT { | |
| 90 | _LIBCPP_ASSERT( | |
| 91 | __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator"); | |
| 92 | return *__current_; | |
| 93 | } | |
| 94 | ||
| 95 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT { | |
| 96 | _LIBCPP_ASSERT( | |
| 97 | __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator"); | |
| 98 | return std::__to_address(__current_); | |
| 99 | } | |
| 100 | ||
| 101 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT { | |
| 102 | _LIBCPP_ASSERT( | |
| 103 | __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range"); | |
| 104 | return __current_[__n]; | |
| 105 | } | |
| 106 | ||
| 107 | // Arithmetic operations. | |
| 108 | // | |
| 109 | // These operations do not check that the resulting iterator is within the bounds, since that | |
| 110 | // would make it impossible to create a past-the-end iterator. | |
| 111 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator++() _NOEXCEPT { | |
| 112 | ++__current_; | |
| 113 | return *this; | |
| 114 | } | |
| 115 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator++(int) _NOEXCEPT { | |
| 116 | __bounded_iter __tmp(*this); | |
| 117 | ++*this; | |
| 118 | return __tmp; | |
| 119 | } | |
| 120 | ||
| 121 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator--() _NOEXCEPT { | |
| 122 | --__current_; | |
| 123 | return *this; | |
| 124 | } | |
| 125 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter operator--(int) _NOEXCEPT { | |
| 126 | __bounded_iter __tmp(*this); | |
| 127 | --*this; | |
| 128 | return __tmp; | |
| 129 | } | |
| 130 | ||
| 131 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT { | |
| 132 | __current_ += __n; | |
| 133 | return *this; | |
| 134 | } | |
| 135 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter | |
| 136 | operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT { | |
| 137 | __bounded_iter __tmp(__self); | |
| 138 | __tmp += __n; | |
| 139 | return __tmp; | |
| 140 | } | |
| 141 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter | |
| 142 | operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT { | |
| 143 | __bounded_iter __tmp(__self); | |
| 144 | __tmp += __n; | |
| 145 | return __tmp; | |
| 146 | } | |
| 147 | ||
| 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT { | |
| 149 | __current_ -= __n; | |
| 150 | return *this; | |
| 151 | } | |
| 152 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend __bounded_iter | |
| 153 | operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT { | |
| 154 | __bounded_iter __tmp(__self); | |
| 155 | __tmp -= __n; | |
| 156 | return __tmp; | |
| 157 | } | |
| 158 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type | |
| 159 | operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 160 | return __x.__current_ - __y.__current_; | |
| 161 | } | |
| 162 | ||
| 163 | // Comparison operations. | |
| 164 | // | |
| 165 | // These operations do not check whether the iterators are within their bounds. | |
| 166 | // The valid range for each iterator is also not considered as part of the comparison, | |
| 167 | // i.e. two iterators pointing to the same location will be considered equal even | |
| 168 | // if they have different validity ranges. | |
| 169 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 170 | operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 171 | return __x.__current_ == __y.__current_; | |
| 172 | } | |
| 173 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 174 | operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 175 | return __x.__current_ != __y.__current_; | |
| 176 | } | |
| 177 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 178 | operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 179 | return __x.__current_ < __y.__current_; | |
| 180 | } | |
| 181 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 182 | operator>(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 183 | return __x.__current_ > __y.__current_; | |
| 184 | } | |
| 185 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 186 | operator<=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 187 | return __x.__current_ <= __y.__current_; | |
| 188 | } | |
| 189 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool | |
| 190 | operator>=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT { | |
| 191 | return __x.__current_ >= __y.__current_; | |
| 192 | } | |
| 193 | ||
| 194 | private: | |
| 195 | // Return whether the given iterator is in the bounds of this __bounded_iter. | |
| 196 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Iterator const& __iter) const { | |
| 197 | return __iter >= __begin_ && __iter < __end_; | |
| 198 | } | |
| 199 | ||
| 200 | template <class> | |
| 201 | friend struct pointer_traits; | |
| 202 | _Iterator __current_; // current iterator | |
| 203 | _Iterator __begin_, __end_; // valid range represented as [begin, end) | |
| 204 | }; | |
| 205 | ||
| 206 | template <class _It> | |
| 207 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter<_It> __make_bounded_iter(_It __it, _It __begin, _It __end) { | |
| 208 | return __bounded_iter<_It>(std::move(__it), std::move(__begin), std::move(__end)); | |
| 209 | } | |
| 210 | ||
| 211 | #if _LIBCPP_STD_VER <= 17 | |
| 212 | template <class _Iterator> | |
| 213 | struct __is_cpp17_contiguous_iterator<__bounded_iter<_Iterator> > : true_type {}; | |
| 214 | #endif | |
| 215 | ||
| 216 | template <class _Iterator> | |
| 217 | struct pointer_traits<__bounded_iter<_Iterator> > { | |
| 218 | using pointer = __bounded_iter<_Iterator>; | |
| 219 | using element_type = typename pointer_traits<_Iterator>::element_type; | |
| 220 | using difference_type = typename pointer_traits<_Iterator>::difference_type; | |
| 221 | ||
| 222 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __it) _NOEXCEPT { | |
| 223 | return std::__to_address(__it.__current_); | |
| 224 | } | |
| 225 | }; | |
| 226 | ||
| 227 | _LIBCPP_END_NAMESPACE_STD | |
| 228 | ||
| 229 | #endif // _LIBCPP___ITERATOR_BOUNDED_ITER_H |
lib/libcxx/include/__iterator/common_iterator.h+13-26| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_COMMON_ITERATOR_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_COMMON_ITERATOR_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__iterator/concepts.h> |
| 16 | 16 | #include <__iterator/incrementable_traits.h> |
| 17 | 17 | #include <__iterator/iter_move.h> |
| ... | ... | @@ -22,12 +22,12 @@ |
| 22 | 22 | #include <variant> |
| 23 | 23 | |
| 24 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | #if _LIBCPP_STD_VER > 17 | |
| 31 | 31 | |
| 32 | 32 | template<class _Iter> |
| 33 | 33 | concept __can_use_postfix_proxy = |
| ... | ... | @@ -37,31 +37,18 @@ concept __can_use_postfix_proxy = |
| 37 | 37 | template<input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent> |
| 38 | 38 | requires (!same_as<_Iter, _Sent> && copyable<_Iter>) |
| 39 | 39 | class common_iterator { |
| 40 | class __proxy { | |
| 41 | friend common_iterator; | |
| 42 | ||
| 43 | iter_value_t<_Iter> __value; | |
| 44 | // We can move __x because the only caller verifies that __x is not a reference. | |
| 45 | constexpr __proxy(iter_reference_t<_Iter>&& __x) | |
| 46 | : __value(_VSTD::move(__x)) {} | |
| 47 | ||
| 48 | public: | |
| 40 | struct __proxy { | |
| 49 | 41 | constexpr const iter_value_t<_Iter>* operator->() const noexcept { |
| 50 | return _VSTD::addressof(__value); | |
| 42 | return _VSTD::addressof(__value_); | |
| 51 | 43 | } |
| 44 | iter_value_t<_Iter> __value_; | |
| 52 | 45 | }; |
| 53 | 46 | |
| 54 | class __postfix_proxy { | |
| 55 | friend common_iterator; | |
| 56 | ||
| 57 | iter_value_t<_Iter> __value; | |
| 58 | constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x) | |
| 59 | : __value(_VSTD::forward<iter_reference_t<_Iter>>(__x)) {} | |
| 60 | ||
| 61 | public: | |
| 47 | struct __postfix_proxy { | |
| 62 | 48 | constexpr const iter_value_t<_Iter>& operator*() const noexcept { |
| 63 | return __value; | |
| 49 | return __value_; | |
| 64 | 50 | } |
| 51 | iter_value_t<_Iter> __value_; | |
| 65 | 52 | }; |
| 66 | 53 | |
| 67 | 54 | public: |
| ... | ... | @@ -133,7 +120,7 @@ public: |
| 133 | 120 | auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_); |
| 134 | 121 | return _VSTD::addressof(__tmp); |
| 135 | 122 | } else { |
| 136 | return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_)); | |
| 123 | return __proxy{*_VSTD::__unchecked_get<_Iter>(__hold_)}; | |
| 137 | 124 | } |
| 138 | 125 | } |
| 139 | 126 | |
| ... | ... | @@ -148,11 +135,11 @@ public: |
| 148 | 135 | auto __tmp = *this; |
| 149 | 136 | ++*this; |
| 150 | 137 | return __tmp; |
| 151 | } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } || | |
| 138 | } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __can_reference; } || | |
| 152 | 139 | !__can_use_postfix_proxy<_Iter>) { |
| 153 | 140 | return _VSTD::__unchecked_get<_Iter>(__hold_)++; |
| 154 | 141 | } else { |
| 155 | __postfix_proxy __p(**this); | |
| 142 | auto __p = __postfix_proxy{**this}; | |
| 156 | 143 | ++*this; |
| 157 | 144 | return __p; |
| 158 | 145 | } |
| ... | ... | @@ -276,7 +263,7 @@ struct iterator_traits<common_iterator<_Iter, _Sent>> { |
| 276 | 263 | using reference = iter_reference_t<_Iter>; |
| 277 | 264 | }; |
| 278 | 265 | |
| 279 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 266 | #endif // _LIBCPP_STD_VER > 17 | |
| 280 | 267 | |
| 281 | 268 | _LIBCPP_END_NAMESPACE_STD |
| 282 | 269 |
lib/libcxx/include/__iterator/concepts.h+20-4| ... | ... | @@ -21,12 +21,12 @@ |
| 21 | 21 | #include <type_traits> |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 25 | 25 | #endif |
| 26 | 26 | |
| 27 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 28 | |
| 29 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 29 | #if _LIBCPP_STD_VER > 17 | |
| 30 | 30 | |
| 31 | 31 | // [iterator.concept.readable] |
| 32 | 32 | template<class _In> |
| ... | ... | @@ -90,7 +90,7 @@ concept incrementable = |
| 90 | 90 | template<class _Ip> |
| 91 | 91 | concept input_or_output_iterator = |
| 92 | 92 | requires(_Ip __i) { |
| 93 | { *__i } -> __referenceable; | |
| 93 | { *__i } -> __can_reference; | |
| 94 | 94 | } && |
| 95 | 95 | weakly_incrementable<_Ip>; |
| 96 | 96 | |
| ... | ... | @@ -254,10 +254,26 @@ concept indirectly_movable_storable = |
| 254 | 254 | constructible_from<iter_value_t<_In>, iter_rvalue_reference_t<_In>> && |
| 255 | 255 | assignable_from<iter_value_t<_In>&, iter_rvalue_reference_t<_In>>; |
| 256 | 256 | |
| 257 | template<class _In, class _Out> | |
| 258 | concept indirectly_copyable = | |
| 259 | indirectly_readable<_In> && | |
| 260 | indirectly_writable<_Out, iter_reference_t<_In>>; | |
| 261 | ||
| 262 | template<class _In, class _Out> | |
| 263 | concept indirectly_copyable_storable = | |
| 264 | indirectly_copyable<_In, _Out> && | |
| 265 | indirectly_writable<_Out, iter_value_t<_In>&> && | |
| 266 | indirectly_writable<_Out, const iter_value_t<_In>&> && | |
| 267 | indirectly_writable<_Out, iter_value_t<_In>&&> && | |
| 268 | indirectly_writable<_Out, const iter_value_t<_In>&&> && | |
| 269 | copyable<iter_value_t<_In>> && | |
| 270 | constructible_from<iter_value_t<_In>, iter_reference_t<_In>> && | |
| 271 | assignable_from<iter_value_t<_In>&, iter_reference_t<_In>>; | |
| 272 | ||
| 257 | 273 | // Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle |
| 258 | 274 | // (both iter_swap and indirectly_swappable require indirectly_readable). |
| 259 | 275 | |
| 260 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 276 | #endif // _LIBCPP_STD_VER > 17 | |
| 261 | 277 | |
| 262 | 278 | _LIBCPP_END_NAMESPACE_STD |
| 263 | 279 |
lib/libcxx/include/__iterator/counted_iterator.h+5-5| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef _LIBCPP___ITERATOR_COUNTED_ITERATOR_H |
| 10 | 10 | #define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H |
| 11 | 11 | |
| 12 | #include <__assert> | |
| 12 | 13 | #include <__config> |
| 13 | #include <__debug> | |
| 14 | 14 | #include <__iterator/concepts.h> |
| 15 | 15 | #include <__iterator/default_sentinel.h> |
| 16 | 16 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -25,12 +25,12 @@ |
| 25 | 25 | #include <type_traits> |
| 26 | 26 | |
| 27 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | #pragma GCC system_header | |
| 28 | # pragma GCC system_header | |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 33 | #if _LIBCPP_STD_VER > 17 | |
| 34 | 34 | |
| 35 | 35 | template<class> |
| 36 | 36 | struct __counted_iterator_concept {}; |
| ... | ... | @@ -65,7 +65,7 @@ class counted_iterator |
| 65 | 65 | , public __counted_iterator_value_type<_Iter> |
| 66 | 66 | { |
| 67 | 67 | public: |
| 68 | [[no_unique_address]] _Iter __current_ = _Iter(); | |
| 68 | _LIBCPP_NO_UNIQUE_ADDRESS _Iter __current_ = _Iter(); | |
| 69 | 69 | iter_difference_t<_Iter> __count_ = 0; |
| 70 | 70 | |
| 71 | 71 | using iterator_type = _Iter; |
| ... | ... | @@ -296,7 +296,7 @@ struct iterator_traits<counted_iterator<_Iter>> : iterator_traits<_Iter> { |
| 296 | 296 | add_pointer_t<iter_reference_t<_Iter>>, void>; |
| 297 | 297 | }; |
| 298 | 298 | |
| 299 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 299 | #endif // _LIBCPP_STD_VER > 17 | |
| 300 | 300 | |
| 301 | 301 | _LIBCPP_END_NAMESPACE_STD |
| 302 | 302 |
lib/libcxx/include/__iterator/data.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <initializer_list> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__iterator/default_sentinel.h+3-3| ... | ... | @@ -13,17 +13,17 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | 20 | |
| 21 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 21 | #if _LIBCPP_STD_VER > 17 | |
| 22 | 22 | |
| 23 | 23 | struct default_sentinel_t { }; |
| 24 | 24 | inline constexpr default_sentinel_t default_sentinel{}; |
| 25 | 25 | |
| 26 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | #endif // _LIBCPP_STD_VER > 17 | |
| 27 | 27 | |
| 28 | 28 | _LIBCPP_END_NAMESPACE_STD |
| 29 | 29 |
lib/libcxx/include/__iterator/distance.h+3-3| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -52,7 +52,7 @@ distance(_InputIter __first, _InputIter __last) |
| 52 | 52 | return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 55 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 56 | 56 | |
| 57 | 57 | // [range.iter.op.distance] |
| 58 | 58 | |
| ... | ... | @@ -100,7 +100,7 @@ inline namespace __cpo { |
| 100 | 100 | } // namespace __cpo |
| 101 | 101 | } // namespace ranges |
| 102 | 102 | |
| 103 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 103 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 104 | 104 | |
| 105 | 105 | _LIBCPP_END_NAMESPACE_STD |
| 106 | 106 |
lib/libcxx/include/__iterator/empty.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <initializer_list> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__iterator/erase_if_container.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__iterator/front_insert_iterator.h+5-5| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <cstddef> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -46,11 +46,11 @@ public: |
| 46 | 46 | typedef _Container container_type; |
| 47 | 47 | |
| 48 | 48 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} |
| 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_) | |
| 50 | {container->push_front(__value_); return *this;} | |
| 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value) | |
| 50 | {container->push_front(__value); return *this;} | |
| 51 | 51 | #ifndef _LIBCPP_CXX03_LANG |
| 52 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_) | |
| 53 | {container->push_front(_VSTD::move(__value_)); return *this;} | |
| 52 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value) | |
| 53 | {container->push_front(_VSTD::move(__value)); return *this;} | |
| 54 | 54 | #endif // _LIBCPP_CXX03_LANG |
| 55 | 55 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;} |
| 56 | 56 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;} |
lib/libcxx/include/__iterator/incrementable_traits.h+4-3| ... | ... | @@ -11,16 +11,17 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__type_traits/is_primary_template.h> | |
| 14 | 15 | #include <concepts> |
| 15 | 16 | #include <type_traits> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 23 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 25 | |
| 25 | 26 | // [incrementable.traits] |
| 26 | 27 | template<class> struct incrementable_traits {}; |
| ... | ... | @@ -65,7 +66,7 @@ using iter_difference_t = typename conditional_t<__is_primary_template<iterator_ |
| 65 | 66 | incrementable_traits<remove_cvref_t<_Ip> >, |
| 66 | 67 | iterator_traits<remove_cvref_t<_Ip> > >::difference_type; |
| 67 | 68 | |
| 68 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 69 | #endif // _LIBCPP_STD_VER > 17 | |
| 69 | 70 | |
| 70 | 71 | _LIBCPP_END_NAMESPACE_STD |
| 71 | 72 |
lib/libcxx/include/__iterator/indirectly_comparable.h+6-2| ... | ... | @@ -15,15 +15,19 @@ |
| 15 | 15 | #include <__iterator/concepts.h> |
| 16 | 16 | #include <__iterator/projected.h> |
| 17 | 17 | |
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 18 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 23 | |
| 20 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 21 | 25 | |
| 22 | 26 | template <class _I1, class _I2, class _Rp, class _P1 = identity, class _P2 = identity> |
| 23 | 27 | concept indirectly_comparable = |
| 24 | 28 | indirect_binary_predicate<_Rp, projected<_I1, _P1>, projected<_I2, _P2>>; |
| 25 | 29 | |
| 26 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 30 | #endif // _LIBCPP_STD_VER > 17 | |
| 27 | 31 | |
| 28 | 32 | _LIBCPP_END_NAMESPACE_STD |
| 29 | 33 |
lib/libcxx/include/__iterator/insert_iterator.h+6-6| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <cstddef> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | 28 | template <class _Container> |
| 29 | 29 | using __insert_iterator_iter_t = ranges::iterator_t<_Container>; |
| 30 | 30 | #else |
| ... | ... | @@ -57,11 +57,11 @@ public: |
| 57 | 57 | |
| 58 | 58 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, __insert_iterator_iter_t<_Container> __i) |
| 59 | 59 | : container(_VSTD::addressof(__x)), iter(__i) {} |
| 60 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) | |
| 61 | {iter = container->insert(iter, __value_); ++iter; return *this;} | |
| 60 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value) | |
| 61 | {iter = container->insert(iter, __value); ++iter; return *this;} | |
| 62 | 62 | #ifndef _LIBCPP_CXX03_LANG |
| 63 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) | |
| 64 | {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} | |
| 63 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value) | |
| 64 | {iter = container->insert(iter, _VSTD::move(__value)); ++iter; return *this;} | |
| 65 | 65 | #endif // _LIBCPP_CXX03_LANG |
| 66 | 66 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} |
| 67 | 67 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} |
lib/libcxx/include/__iterator/istream_iterator.h+14-1| ... | ... | @@ -11,13 +11,15 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__iterator/default_sentinel.h> | |
| 14 | 15 | #include <__iterator/iterator.h> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <__memory/addressof.h> |
| 18 | #include <cstddef> | |
| 17 | 19 | #include <iosfwd> // for forward declarations of char_traits and basic_istream |
| 18 | 20 | |
| 19 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 21 | 23 | #endif |
| 22 | 24 | |
| 23 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -45,6 +47,9 @@ private: |
| 45 | 47 | _Tp __value_; |
| 46 | 48 | public: |
| 47 | 49 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {} |
| 50 | #if _LIBCPP_STD_VER > 17 | |
| 51 | _LIBCPP_HIDE_FROM_ABI constexpr istream_iterator(default_sentinel_t) : istream_iterator() {} | |
| 52 | #endif // _LIBCPP_STD_VER > 17 | |
| 48 | 53 | _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s)) |
| 49 | 54 | { |
| 50 | 55 | if (!(*__in_stream_ >> __value_)) |
| ... | ... | @@ -67,6 +72,12 @@ public: |
| 67 | 72 | bool |
| 68 | 73 | operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, |
| 69 | 74 | const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); |
| 75 | ||
| 76 | #if _LIBCPP_STD_VER > 17 | |
| 77 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istream_iterator& __i, default_sentinel_t) { | |
| 78 | return __i.__in_stream_ == nullptr; | |
| 79 | } | |
| 80 | #endif // _LIBCPP_STD_VER > 17 | |
| 70 | 81 | }; |
| 71 | 82 | |
| 72 | 83 | template <class _Tp, class _CharT, class _Traits, class _Distance> |
| ... | ... | @@ -78,6 +89,7 @@ operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, |
| 78 | 89 | return __x.__in_stream_ == __y.__in_stream_; |
| 79 | 90 | } |
| 80 | 91 | |
| 92 | #if _LIBCPP_STD_VER <= 17 | |
| 81 | 93 | template <class _Tp, class _CharT, class _Traits, class _Distance> |
| 82 | 94 | inline _LIBCPP_INLINE_VISIBILITY |
| 83 | 95 | bool |
| ... | ... | @@ -86,6 +98,7 @@ operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, |
| 86 | 98 | { |
| 87 | 99 | return !(__x == __y); |
| 88 | 100 | } |
| 101 | #endif // _LIBCPP_STD_VER <= 17 | |
| 89 | 102 | |
| 90 | 103 | _LIBCPP_END_NAMESPACE_STD |
| 91 | 104 |
lib/libcxx/include/__iterator/istreambuf_iterator.h+16-2| ... | ... | @@ -11,12 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__iterator/default_sentinel.h> | |
| 14 | 15 | #include <__iterator/iterator.h> |
| 15 | 16 | #include <__iterator/iterator_traits.h> |
| 16 | 17 | #include <iosfwd> // for forward declaration of basic_streambuf |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -49,7 +50,8 @@ private: |
| 49 | 50 | { |
| 50 | 51 | char_type __keep_; |
| 51 | 52 | streambuf_type* __sbuf_; |
| 52 | _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s) | |
| 53 | _LIBCPP_INLINE_VISIBILITY | |
| 54 | explicit __proxy(char_type __c, streambuf_type* __s) | |
| 53 | 55 | : __keep_(__c), __sbuf_(__s) {} |
| 54 | 56 | friend class istreambuf_iterator; |
| 55 | 57 | public: |
| ... | ... | @@ -65,6 +67,10 @@ private: |
| 65 | 67 | } |
| 66 | 68 | public: |
| 67 | 69 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {} |
| 70 | #if _LIBCPP_STD_VER > 17 | |
| 71 | _LIBCPP_INLINE_VISIBILITY constexpr istreambuf_iterator(default_sentinel_t) noexcept | |
| 72 | : istreambuf_iterator() {} | |
| 73 | #endif // _LIBCPP_STD_VER > 17 | |
| 68 | 74 | _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT |
| 69 | 75 | : __sbuf_(__s.rdbuf()) {} |
| 70 | 76 | _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT |
| ... | ... | @@ -86,6 +92,12 @@ public: |
| 86 | 92 | |
| 87 | 93 | _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const |
| 88 | 94 | {return __test_for_eof() == __b.__test_for_eof();} |
| 95 | ||
| 96 | #if _LIBCPP_STD_VER > 17 | |
| 97 | friend _LIBCPP_HIDE_FROM_ABI bool operator==(const istreambuf_iterator& __i, default_sentinel_t) { | |
| 98 | return __i.__test_for_eof(); | |
| 99 | } | |
| 100 | #endif // _LIBCPP_STD_VER > 17 | |
| 89 | 101 | }; |
| 90 | 102 | |
| 91 | 103 | template <class _CharT, class _Traits> |
| ... | ... | @@ -94,11 +106,13 @@ bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a, |
| 94 | 106 | const istreambuf_iterator<_CharT,_Traits>& __b) |
| 95 | 107 | {return __a.equal(__b);} |
| 96 | 108 | |
| 109 | #if _LIBCPP_STD_VER <= 17 | |
| 97 | 110 | template <class _CharT, class _Traits> |
| 98 | 111 | inline _LIBCPP_INLINE_VISIBILITY |
| 99 | 112 | bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, |
| 100 | 113 | const istreambuf_iterator<_CharT,_Traits>& __b) |
| 101 | 114 | {return !__a.equal(__b);} |
| 115 | #endif // _LIBCPP_STD_VER <= 17 | |
| 102 | 116 | |
| 103 | 117 | _LIBCPP_END_NAMESPACE_STD |
| 104 | 118 |
lib/libcxx/include/__iterator/iter_move.h+40-34| ... | ... | @@ -10,20 +10,20 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_ITER_MOVE_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_ITER_MOVE_H |
| 12 | 12 | |
| 13 | #include <__concepts/class_or_enum.h> | |
| 13 | 14 | #include <__config> |
| 14 | 15 | #include <__iterator/iterator_traits.h> |
| 15 | 16 | #include <__utility/forward.h> |
| 16 | #include <concepts> // __class_or_enum | |
| 17 | #include <__utility/move.h> | |
| 17 | 18 | #include <type_traits> |
| 18 | #include <utility> | |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| 26 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | 27 | |
| 28 | 28 | // [iterator.cust.move] |
| 29 | 29 | |
| ... | ... | @@ -36,44 +36,50 @@ template <class _Tp> |
| 36 | 36 | concept __unqualified_iter_move = |
| 37 | 37 | __class_or_enum<remove_cvref_t<_Tp>> && |
| 38 | 38 | requires (_Tp&& __t) { |
| 39 | iter_move(_VSTD::forward<_Tp>(__t)); | |
| 39 | iter_move(std::forward<_Tp>(__t)); | |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | // [iterator.cust.move]/1 | |
| 43 | // The name ranges::iter_move denotes a customization point object. | |
| 44 | // The expression ranges::iter_move(E) for a subexpression E is | |
| 45 | // expression-equivalent to: | |
| 42 | template<class _Tp> | |
| 43 | concept __move_deref = | |
| 44 | !__unqualified_iter_move<_Tp> && | |
| 45 | requires (_Tp&& __t) { | |
| 46 | *__t; | |
| 47 | requires is_lvalue_reference_v<decltype(*__t)>; | |
| 48 | }; | |
| 49 | ||
| 50 | template<class _Tp> | |
| 51 | concept __just_deref = | |
| 52 | !__unqualified_iter_move<_Tp> && | |
| 53 | !__move_deref<_Tp> && | |
| 54 | requires (_Tp&& __t) { | |
| 55 | *__t; | |
| 56 | requires (!is_lvalue_reference_v<decltype(*__t)>); | |
| 57 | }; | |
| 58 | ||
| 59 | // [iterator.cust.move] | |
| 60 | ||
| 46 | 61 | struct __fn { |
| 47 | // [iterator.cust.move]/1.1 | |
| 48 | // iter_move(E), if E has class or enumeration type and iter_move(E) is a | |
| 49 | // well-formed expression when treated as an unevaluated operand, [...] | |
| 50 | 62 | template<class _Ip> |
| 51 | requires __class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip> | |
| 63 | requires __unqualified_iter_move<_Ip> | |
| 52 | 64 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const |
| 53 | noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i)))) | |
| 65 | noexcept(noexcept(iter_move(std::forward<_Ip>(__i)))) | |
| 54 | 66 | { |
| 55 | return iter_move(_VSTD::forward<_Ip>(__i)); | |
| 67 | return iter_move(std::forward<_Ip>(__i)); | |
| 56 | 68 | } |
| 57 | 69 | |
| 58 | // [iterator.cust.move]/1.2 | |
| 59 | // Otherwise, if the expression *E is well-formed: | |
| 60 | // 1.2.1 if *E is an lvalue, std::move(*E); | |
| 61 | // 1.2.2 otherwise, *E. | |
| 62 | 70 | template<class _Ip> |
| 63 | requires (!(__class_or_enum<remove_cvref_t<_Ip>> && __unqualified_iter_move<_Ip>)) && | |
| 64 | requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); } | |
| 65 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const | |
| 66 | noexcept(noexcept(*_VSTD::forward<_Ip>(__i))) | |
| 67 | { | |
| 68 | if constexpr (is_lvalue_reference_v<decltype(*_VSTD::forward<_Ip>(__i))>) { | |
| 69 | return _VSTD::move(*_VSTD::forward<_Ip>(__i)); | |
| 70 | } else { | |
| 71 | return *_VSTD::forward<_Ip>(__i); | |
| 72 | } | |
| 73 | } | |
| 71 | requires __move_deref<_Ip> | |
| 72 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const | |
| 73 | noexcept(noexcept(std::move(*std::forward<_Ip>(__i)))) | |
| 74 | -> decltype( std::move(*std::forward<_Ip>(__i))) | |
| 75 | { return std::move(*std::forward<_Ip>(__i)); } | |
| 74 | 76 | |
| 75 | // [iterator.cust.move]/1.3 | |
| 76 | // Otherwise, ranges::iter_move(E) is ill-formed. | |
| 77 | template<class _Ip> | |
| 78 | requires __just_deref<_Ip> | |
| 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ip&& __i) const | |
| 80 | noexcept(noexcept(*std::forward<_Ip>(__i))) | |
| 81 | -> decltype( *std::forward<_Ip>(__i)) | |
| 82 | { return *std::forward<_Ip>(__i); } | |
| 77 | 83 | }; |
| 78 | 84 | } // namespace __iter_move |
| 79 | 85 | |
| ... | ... | @@ -83,10 +89,10 @@ inline namespace __cpo { |
| 83 | 89 | } // namespace ranges |
| 84 | 90 | |
| 85 | 91 | template<__dereferenceable _Tp> |
| 86 | requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } | |
| 92 | requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __can_reference; } | |
| 87 | 93 | using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); |
| 88 | 94 | |
| 89 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 95 | #endif // _LIBCPP_STD_VER > 17 | |
| 90 | 96 | |
| 91 | 97 | _LIBCPP_END_NAMESPACE_STD |
| 92 | 98 |
lib/libcxx/include/__iterator/iter_swap.h+3-3| ... | ... | @@ -20,12 +20,12 @@ |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 28 | #if _LIBCPP_STD_VER > 17 | |
| 29 | 29 | |
| 30 | 30 | // [iter.cust.swap] |
| 31 | 31 | |
| ... | ... | @@ -99,7 +99,7 @@ concept indirectly_swappable = |
| 99 | 99 | ranges::iter_swap(__i2, __i1); |
| 100 | 100 | }; |
| 101 | 101 | |
| 102 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 102 | #endif // _LIBCPP_STD_VER > 17 | |
| 103 | 103 | |
| 104 | 104 | _LIBCPP_END_NAMESPACE_STD |
| 105 | 105 |
lib/libcxx/include/__iterator/iterator.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <cstddef> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__iterator/iterator_traits.h+51-34| ... | ... | @@ -17,31 +17,31 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | 26 | |
| 27 | 27 | template <class _Tp> |
| 28 | 28 | using __with_reference = _Tp&; |
| 29 | 29 | |
| 30 | 30 | template <class _Tp> |
| 31 | concept __referenceable = requires { | |
| 31 | concept __can_reference = requires { | |
| 32 | 32 | typename __with_reference<_Tp>; |
| 33 | 33 | }; |
| 34 | 34 | |
| 35 | 35 | template <class _Tp> |
| 36 | 36 | concept __dereferenceable = requires(_Tp& __t) { |
| 37 | { *__t } -> __referenceable; // not required to be equality-preserving | |
| 37 | { *__t } -> __can_reference; // not required to be equality-preserving | |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | 40 | // [iterator.traits] |
| 41 | 41 | template<__dereferenceable _Tp> |
| 42 | 42 | using iter_reference_t = decltype(*declval<_Tp&>()); |
| 43 | 43 | |
| 44 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 44 | #endif // _LIBCPP_STD_VER > 17 | |
| 45 | 45 | |
| 46 | 46 | template <class _Iter> |
| 47 | 47 | struct _LIBCPP_TEMPLATE_VIS iterator_traits; |
| ... | ... | @@ -105,15 +105,14 @@ template <class _Tp> |
| 105 | 105 | struct __has_iterator_typedefs |
| 106 | 106 | { |
| 107 | 107 | private: |
| 108 | struct __two {char __lx; char __lxx;}; | |
| 109 | template <class _Up> static __two __test(...); | |
| 110 | template <class _Up> static char __test(typename __void_t<typename _Up::iterator_category>::type* = 0, | |
| 111 | typename __void_t<typename _Up::difference_type>::type* = 0, | |
| 112 | typename __void_t<typename _Up::value_type>::type* = 0, | |
| 113 | typename __void_t<typename _Up::reference>::type* = 0, | |
| 114 | typename __void_t<typename _Up::pointer>::type* = 0); | |
| 108 | template <class _Up> static false_type __test(...); | |
| 109 | template <class _Up> static true_type __test(typename __void_t<typename _Up::iterator_category>::type* = 0, | |
| 110 | typename __void_t<typename _Up::difference_type>::type* = 0, | |
| 111 | typename __void_t<typename _Up::value_type>::type* = 0, | |
| 112 | typename __void_t<typename _Up::reference>::type* = 0, | |
| 113 | typename __void_t<typename _Up::pointer>::type* = 0); | |
| 115 | 114 | public: |
| 116 | static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1; | |
| 115 | static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value; | |
| 117 | 116 | }; |
| 118 | 117 | |
| 119 | 118 | |
| ... | ... | @@ -121,35 +120,34 @@ template <class _Tp> |
| 121 | 120 | struct __has_iterator_category |
| 122 | 121 | { |
| 123 | 122 | private: |
| 124 | struct __two {char __lx; char __lxx;}; | |
| 125 | template <class _Up> static __two __test(...); | |
| 126 | template <class _Up> static char __test(typename _Up::iterator_category* = nullptr); | |
| 123 | template <class _Up> static false_type __test(...); | |
| 124 | template <class _Up> static true_type __test(typename _Up::iterator_category* = nullptr); | |
| 127 | 125 | public: |
| 128 | static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; | |
| 126 | static const bool value = decltype(__test<_Tp>(nullptr))::value; | |
| 129 | 127 | }; |
| 130 | 128 | |
| 131 | 129 | template <class _Tp> |
| 132 | 130 | struct __has_iterator_concept |
| 133 | 131 | { |
| 134 | 132 | private: |
| 135 | struct __two {char __lx; char __lxx;}; | |
| 136 | template <class _Up> static __two __test(...); | |
| 137 | template <class _Up> static char __test(typename _Up::iterator_concept* = nullptr); | |
| 133 | template <class _Up> static false_type __test(...); | |
| 134 | template <class _Up> static true_type __test(typename _Up::iterator_concept* = nullptr); | |
| 138 | 135 | public: |
| 139 | static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; | |
| 136 | static const bool value = decltype(__test<_Tp>(nullptr))::value; | |
| 140 | 137 | }; |
| 141 | 138 | |
| 142 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 139 | #if _LIBCPP_STD_VER > 17 | |
| 143 | 140 | |
| 144 | // The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, | |
| 145 | // so they've been banished to a namespace that makes it obvious they have a niche use-case. | |
| 141 | // The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements | |
| 142 | // from `[iterator.cpp17]`. To avoid confusion between the two, the exposition-only concepts have been banished to | |
| 143 | // a "detail" namespace indicating they have a niche use-case. | |
| 146 | 144 | namespace __iterator_traits_detail { |
| 147 | 145 | template<class _Ip> |
| 148 | 146 | concept __cpp17_iterator = |
| 149 | 147 | requires(_Ip __i) { |
| 150 | { *__i } -> __referenceable; | |
| 148 | { *__i } -> __can_reference; | |
| 151 | 149 | { ++__i } -> same_as<_Ip&>; |
| 152 | { *__i++ } -> __referenceable; | |
| 150 | { *__i++ } -> __can_reference; | |
| 153 | 151 | } && |
| 154 | 152 | copyable<_Ip>; |
| 155 | 153 | |
| ... | ... | @@ -198,7 +196,7 @@ concept __cpp17_random_access_iterator = |
| 198 | 196 | { __i + __n } -> same_as<_Ip>; |
| 199 | 197 | { __n + __i } -> same_as<_Ip>; |
| 200 | 198 | { __i - __n } -> same_as<_Ip>; |
| 201 | { __i - __i } -> same_as<decltype(__n)>; | |
| 199 | { __i - __i } -> same_as<decltype(__n)>; // NOLINT(misc-redundant-expression) ; This is llvm.org/PR54114 | |
| 202 | 200 | { __i[__n] } -> convertible_to<iter_reference_t<_Ip>>; |
| 203 | 201 | }; |
| 204 | 202 | } // namespace __iterator_traits_detail |
| ... | ... | @@ -362,7 +360,7 @@ struct iterator_traits : __iterator_traits<_Ip> { |
| 362 | 360 | using __primary_template = iterator_traits; |
| 363 | 361 | }; |
| 364 | 362 | |
| 365 | #else // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 363 | #else // _LIBCPP_STD_VER > 17 | |
| 366 | 364 | |
| 367 | 365 | template <class _Iter, bool> struct __iterator_traits {}; |
| 368 | 366 | |
| ... | ... | @@ -399,10 +397,10 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits |
| 399 | 397 | |
| 400 | 398 | using __primary_template = iterator_traits; |
| 401 | 399 | }; |
| 402 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 400 | #endif // _LIBCPP_STD_VER > 17 | |
| 403 | 401 | |
| 404 | 402 | template<class _Tp> |
| 405 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 403 | #if _LIBCPP_STD_VER > 17 | |
| 406 | 404 | requires is_object_v<_Tp> |
| 407 | 405 | #endif |
| 408 | 406 | struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> |
| ... | ... | @@ -468,27 +466,46 @@ template <class _Up> |
| 468 | 466 | struct __is_cpp17_contiguous_iterator<_Up*> : true_type {}; |
| 469 | 467 | |
| 470 | 468 | |
| 469 | template <class _Iter> | |
| 470 | class __wrap_iter; | |
| 471 | ||
| 471 | 472 | template <class _Tp> |
| 472 | 473 | struct __is_exactly_cpp17_input_iterator |
| 473 | 474 | : public integral_constant<bool, |
| 474 | 475 | __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value && |
| 475 | 476 | !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; |
| 476 | 477 | |
| 477 | #if _LIBCPP_STD_VER >= 17 | |
| 478 | template <class _Tp> | |
| 479 | struct __is_exactly_cpp17_forward_iterator | |
| 480 | : public integral_constant<bool, | |
| 481 | __has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value && | |
| 482 | !__has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value> {}; | |
| 483 | ||
| 484 | template <class _Tp> | |
| 485 | struct __is_exactly_cpp17_bidirectional_iterator | |
| 486 | : public integral_constant<bool, | |
| 487 | __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag>::value && | |
| 488 | !__has_iterator_category_convertible_to<_Tp, random_access_iterator_tag>::value> {}; | |
| 489 | ||
| 478 | 490 | template<class _InputIterator> |
| 479 | 491 | using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; |
| 480 | 492 | |
| 481 | 493 | template<class _InputIterator> |
| 482 | using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>; | |
| 494 | using __iter_key_type = typename remove_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type; | |
| 483 | 495 | |
| 484 | 496 | template<class _InputIterator> |
| 485 | 497 | using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type; |
| 486 | 498 | |
| 487 | 499 | template<class _InputIterator> |
| 488 | 500 | using __iter_to_alloc_type = pair< |
| 489 | add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>, | |
| 501 | typename add_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type, | |
| 490 | 502 | typename iterator_traits<_InputIterator>::value_type::second_type>; |
| 491 | #endif // _LIBCPP_STD_VER >= 17 | |
| 503 | ||
| 504 | template <class _Iter> | |
| 505 | using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category; | |
| 506 | ||
| 507 | template <class _Iter> | |
| 508 | using __iterator_pointer_type = typename iterator_traits<_Iter>::pointer; | |
| 492 | 509 | |
| 493 | 510 | _LIBCPP_END_NAMESPACE_STD |
| 494 | 511 |
lib/libcxx/include/__iterator/mergeable.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ITERATOR_MERGEABLE_H | |
| 11 | #define _LIBCPP___ITERATOR_MERGEABLE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/projected.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | ||
| 27 | template <class _Input1, class _Input2, class _Output, | |
| 28 | class _Comp = ranges::less, class _Proj1 = identity, class _Proj2 = identity> | |
| 29 | concept mergeable = | |
| 30 | input_iterator<_Input1> && | |
| 31 | input_iterator<_Input2> && | |
| 32 | weakly_incrementable<_Output> && | |
| 33 | indirectly_copyable<_Input1, _Output> && | |
| 34 | indirectly_copyable<_Input2, _Output> && | |
| 35 | indirect_strict_weak_order<_Comp, projected<_Input1, _Proj1>, projected<_Input2, _Proj2>>; | |
| 36 | ||
| 37 | #endif // _LIBCPP_STD_VER > 17 | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___ITERATOR_MERGEABLE_H |
lib/libcxx/include/__iterator/move_iterator.h+158-17| ... | ... | @@ -10,51 +10,131 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_MOVE_ITERATOR_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_MOVE_ITERATOR_H |
| 12 | 12 | |
| 13 | #include <__compare/compare_three_way_result.h> | |
| 14 | #include <__compare/three_way_comparable.h> | |
| 15 | #include <__concepts/assignable.h> | |
| 16 | #include <__concepts/convertible_to.h> | |
| 17 | #include <__concepts/derived_from.h> | |
| 18 | #include <__concepts/same_as.h> | |
| 13 | 19 | #include <__config> |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/incrementable_traits.h> | |
| 22 | #include <__iterator/iter_move.h> | |
| 23 | #include <__iterator/iter_swap.h> | |
| 14 | 24 | #include <__iterator/iterator_traits.h> |
| 25 | #include <__iterator/move_sentinel.h> | |
| 26 | #include <__iterator/readable_traits.h> | |
| 15 | 27 | #include <__utility/move.h> |
| 16 | 28 | #include <type_traits> |
| 17 | 29 | |
| 18 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 31 | # pragma GCC system_header | |
| 20 | 32 | #endif |
| 21 | 33 | |
| 22 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 35 | |
| 36 | #if _LIBCPP_STD_VER > 17 | |
| 37 | template<class _Iter, class = void> | |
| 38 | struct __move_iter_category_base {}; | |
| 39 | ||
| 40 | template<class _Iter> | |
| 41 | requires requires { typename iterator_traits<_Iter>::iterator_category; } | |
| 42 | struct __move_iter_category_base<_Iter> { | |
| 43 | using iterator_category = _If< | |
| 44 | derived_from<typename iterator_traits<_Iter>::iterator_category, random_access_iterator_tag>, | |
| 45 | random_access_iterator_tag, | |
| 46 | typename iterator_traits<_Iter>::iterator_category | |
| 47 | >; | |
| 48 | }; | |
| 49 | ||
| 50 | template<class _Iter, class _Sent> | |
| 51 | concept __move_iter_comparable = requires { | |
| 52 | { declval<const _Iter&>() == declval<_Sent>() } -> convertible_to<bool>; | |
| 53 | }; | |
| 54 | #endif // _LIBCPP_STD_VER > 17 | |
| 55 | ||
| 24 | 56 | template <class _Iter> |
| 25 | 57 | class _LIBCPP_TEMPLATE_VIS move_iterator |
| 58 | #if _LIBCPP_STD_VER > 17 | |
| 59 | : public __move_iter_category_base<_Iter> | |
| 60 | #endif | |
| 26 | 61 | { |
| 27 | 62 | public: |
| 28 | 63 | #if _LIBCPP_STD_VER > 17 |
| 29 | typedef input_iterator_tag iterator_concept; | |
| 30 | #endif | |
| 31 | ||
| 64 | using iterator_type = _Iter; | |
| 65 | using iterator_concept = input_iterator_tag; | |
| 66 | // iterator_category is inherited and not always present | |
| 67 | using value_type = iter_value_t<_Iter>; | |
| 68 | using difference_type = iter_difference_t<_Iter>; | |
| 69 | using pointer = _Iter; | |
| 70 | using reference = iter_rvalue_reference_t<_Iter>; | |
| 71 | #else | |
| 32 | 72 | typedef _Iter iterator_type; |
| 33 | 73 | typedef _If< |
| 34 | 74 | __is_cpp17_random_access_iterator<_Iter>::value, |
| 35 | 75 | random_access_iterator_tag, |
| 36 | 76 | typename iterator_traits<_Iter>::iterator_category |
| 37 | > iterator_category; | |
| 77 | > iterator_category; | |
| 38 | 78 | typedef typename iterator_traits<iterator_type>::value_type value_type; |
| 39 | 79 | typedef typename iterator_traits<iterator_type>::difference_type difference_type; |
| 40 | 80 | typedef iterator_type pointer; |
| 41 | 81 | |
| 42 | #ifndef _LIBCPP_CXX03_LANG | |
| 43 | 82 | typedef typename iterator_traits<iterator_type>::reference __reference; |
| 44 | 83 | typedef typename conditional< |
| 45 | 84 | is_reference<__reference>::value, |
| 46 | 85 | typename remove_reference<__reference>::type&&, |
| 47 | 86 | __reference |
| 48 | 87 | >::type reference; |
| 49 | #else | |
| 50 | typedef typename iterator_traits<iterator_type>::reference reference; | |
| 51 | #endif | |
| 88 | #endif // _LIBCPP_STD_VER > 17 | |
| 52 | 89 | |
| 53 | 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 54 | move_iterator() : __current_() {} | |
| 91 | explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {} | |
| 92 | ||
| 93 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 94 | move_iterator& operator++() { ++__current_; return *this; } | |
| 95 | ||
| 96 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 97 | pointer operator->() const { return __current_; } | |
| 98 | ||
| 99 | #if _LIBCPP_STD_VER > 17 | |
| 100 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 101 | move_iterator() requires is_constructible_v<_Iter> : __current_() {} | |
| 102 | ||
| 103 | template <class _Up> | |
| 104 | requires (!_IsSame<_Up, _Iter>::value) && convertible_to<const _Up&, _Iter> | |
| 105 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 106 | move_iterator(const move_iterator<_Up>& __u) : __current_(__u.base()) {} | |
| 107 | ||
| 108 | template <class _Up> | |
| 109 | requires (!_IsSame<_Up, _Iter>::value) && | |
| 110 | convertible_to<const _Up&, _Iter> && | |
| 111 | assignable_from<_Iter&, const _Up&> | |
| 112 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 113 | move_iterator& operator=(const move_iterator<_Up>& __u) { | |
| 114 | __current_ = __u.base(); | |
| 115 | return *this; | |
| 116 | } | |
| 117 | ||
| 118 | _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const & noexcept { return __current_; } | |
| 119 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); } | |
| 55 | 120 | |
| 121 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 122 | reference operator*() const { return ranges::iter_move(__current_); } | |
| 123 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 124 | reference operator[](difference_type __n) const { return ranges::iter_move(__current_ + __n); } | |
| 125 | ||
| 126 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 127 | auto operator++(int) | |
| 128 | requires forward_iterator<_Iter> | |
| 129 | { | |
| 130 | move_iterator __tmp(*this); ++__current_; return __tmp; | |
| 131 | } | |
| 132 | ||
| 133 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 134 | void operator++(int) { ++__current_; } | |
| 135 | #else | |
| 56 | 136 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 57 | explicit move_iterator(_Iter __i) : __current_(_VSTD::move(__i)) {} | |
| 137 | move_iterator() : __current_() {} | |
| 58 | 138 | |
| 59 | 139 | template <class _Up, class = __enable_if_t< |
| 60 | 140 | !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value |
| ... | ... | @@ -79,14 +159,12 @@ public: |
| 79 | 159 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 80 | 160 | reference operator*() const { return static_cast<reference>(*__current_); } |
| 81 | 161 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 82 | pointer operator->() const { return __current_; } | |
| 83 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 84 | 162 | reference operator[](difference_type __n) const { return static_cast<reference>(__current_[__n]); } |
| 85 | 163 | |
| 86 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 87 | move_iterator& operator++() { ++__current_; return *this; } | |
| 88 | 164 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 89 | 165 | move_iterator operator++(int) { move_iterator __tmp(*this); ++__current_; return __tmp; } |
| 166 | #endif // _LIBCPP_STD_VER > 17 | |
| 167 | ||
| 90 | 168 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 91 | 169 | move_iterator& operator--() { --__current_; return *this; } |
| 92 | 170 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -100,7 +178,48 @@ public: |
| 100 | 178 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 101 | 179 | move_iterator& operator-=(difference_type __n) { __current_ -= __n; return *this; } |
| 102 | 180 | |
| 181 | #if _LIBCPP_STD_VER > 17 | |
| 182 | template<sentinel_for<_Iter> _Sent> | |
| 183 | friend _LIBCPP_HIDE_FROM_ABI constexpr | |
| 184 | bool operator==(const move_iterator& __x, const move_sentinel<_Sent>& __y) | |
| 185 | requires __move_iter_comparable<_Iter, _Sent> | |
| 186 | { | |
| 187 | return __x.base() == __y.base(); | |
| 188 | } | |
| 189 | ||
| 190 | template<sized_sentinel_for<_Iter> _Sent> | |
| 191 | friend _LIBCPP_HIDE_FROM_ABI constexpr | |
| 192 | iter_difference_t<_Iter> operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y) | |
| 193 | { | |
| 194 | return __x.base() - __y.base(); | |
| 195 | } | |
| 196 | ||
| 197 | template<sized_sentinel_for<_Iter> _Sent> | |
| 198 | friend _LIBCPP_HIDE_FROM_ABI constexpr | |
| 199 | iter_difference_t<_Iter> operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y) | |
| 200 | { | |
| 201 | return __x.base() - __y.base(); | |
| 202 | } | |
| 203 | ||
| 204 | friend _LIBCPP_HIDE_FROM_ABI constexpr | |
| 205 | iter_rvalue_reference_t<_Iter> iter_move(const move_iterator& __i) | |
| 206 | noexcept(noexcept(ranges::iter_move(__i.__current_))) | |
| 207 | { | |
| 208 | return ranges::iter_move(__i.__current_); | |
| 209 | } | |
| 210 | ||
| 211 | template<indirectly_swappable<_Iter> _It2> | |
| 212 | friend _LIBCPP_HIDE_FROM_ABI constexpr | |
| 213 | void iter_swap(const move_iterator& __x, const move_iterator<_It2>& __y) | |
| 214 | noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) | |
| 215 | { | |
| 216 | return ranges::iter_swap(__x.__current_, __y.__current_); | |
| 217 | } | |
| 218 | #endif // _LIBCPP_STD_VER > 17 | |
| 219 | ||
| 103 | 220 | private: |
| 221 | template<class _It2> friend class move_iterator; | |
| 222 | ||
| 104 | 223 | _Iter __current_; |
| 105 | 224 | }; |
| 106 | 225 | |
| ... | ... | @@ -111,12 +230,14 @@ bool operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _ |
| 111 | 230 | return __x.base() == __y.base(); |
| 112 | 231 | } |
| 113 | 232 | |
| 233 | #if _LIBCPP_STD_VER <= 17 | |
| 114 | 234 | template <class _Iter1, class _Iter2> |
| 115 | 235 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 116 | 236 | bool operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) |
| 117 | 237 | { |
| 118 | 238 | return __x.base() != __y.base(); |
| 119 | 239 | } |
| 240 | #endif // _LIBCPP_STD_VER <= 17 | |
| 120 | 241 | |
| 121 | 242 | template <class _Iter1, class _Iter2> |
| 122 | 243 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -146,6 +267,16 @@ bool operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& _ |
| 146 | 267 | return __x.base() >= __y.base(); |
| 147 | 268 | } |
| 148 | 269 | |
| 270 | #if _LIBCPP_STD_VER > 17 | |
| 271 | template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2> | |
| 272 | inline _LIBCPP_HIDE_FROM_ABI constexpr | |
| 273 | auto operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) | |
| 274 | -> compare_three_way_result_t<_Iter1, _Iter2> | |
| 275 | { | |
| 276 | return __x.base() <=> __y.base(); | |
| 277 | } | |
| 278 | #endif // _LIBCPP_STD_VER > 17 | |
| 279 | ||
| 149 | 280 | #ifndef _LIBCPP_CXX03_LANG |
| 150 | 281 | template <class _Iter1, class _Iter2> |
| 151 | 282 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -162,8 +293,17 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) |
| 162 | 293 | { |
| 163 | 294 | return __x.base() - __y.base(); |
| 164 | 295 | } |
| 165 | #endif | |
| 296 | #endif // !_LIBCPP_CXX03_LANG | |
| 166 | 297 | |
| 298 | #if _LIBCPP_STD_VER > 17 | |
| 299 | template <class _Iter> | |
| 300 | inline _LIBCPP_HIDE_FROM_ABI constexpr | |
| 301 | move_iterator<_Iter> operator+(iter_difference_t<_Iter> __n, const move_iterator<_Iter>& __x) | |
| 302 | requires requires { { __x.base() + __n } -> same_as<_Iter>; } | |
| 303 | { | |
| 304 | return __x + __n; | |
| 305 | } | |
| 306 | #else | |
| 167 | 307 | template <class _Iter> |
| 168 | 308 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 169 | 309 | move_iterator<_Iter> |
| ... | ... | @@ -171,13 +311,14 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato |
| 171 | 311 | { |
| 172 | 312 | return move_iterator<_Iter>(__x.base() + __n); |
| 173 | 313 | } |
| 314 | #endif // _LIBCPP_STD_VER > 17 | |
| 174 | 315 | |
| 175 | 316 | template <class _Iter> |
| 176 | 317 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 177 | 318 | move_iterator<_Iter> |
| 178 | 319 | make_move_iterator(_Iter __i) |
| 179 | 320 | { |
| 180 | return move_iterator<_Iter>(_VSTD::move(__i)); | |
| 321 | return move_iterator<_Iter>(std::move(__i)); | |
| 181 | 322 | } |
| 182 | 323 | |
| 183 | 324 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__iterator/move_sentinel.h created+57| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___ITERATOR_MOVE_SENTINEL_H | |
| 10 | #define _LIBCPP___ITERATOR_MOVE_SENTINEL_H | |
| 11 | ||
| 12 | #include <__concepts/assignable.h> | |
| 13 | #include <__concepts/convertible_to.h> | |
| 14 | #include <__concepts/semiregular.h> | |
| 15 | #include <__config> | |
| 16 | #include <__utility/move.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | ||
| 26 | template <semiregular _Sent> | |
| 27 | class _LIBCPP_TEMPLATE_VIS move_sentinel | |
| 28 | { | |
| 29 | public: | |
| 30 | _LIBCPP_HIDE_FROM_ABI | |
| 31 | move_sentinel() = default; | |
| 32 | ||
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 34 | explicit move_sentinel(_Sent __s) : __last_(std::move(__s)) {} | |
| 35 | ||
| 36 | template <class _S2> | |
| 37 | requires convertible_to<const _S2&, _Sent> | |
| 38 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 39 | move_sentinel(const move_sentinel<_S2>& __s) : __last_(__s.base()) {} | |
| 40 | ||
| 41 | template <class _S2> | |
| 42 | requires assignable_from<_Sent&, const _S2&> | |
| 43 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 44 | move_sentinel& operator=(const move_sentinel<_S2>& __s) | |
| 45 | { __last_ = __s.base(); return *this; } | |
| 46 | ||
| 47 | constexpr _Sent base() const { return __last_; } | |
| 48 | ||
| 49 | private: | |
| 50 | _Sent __last_ = _Sent(); | |
| 51 | }; | |
| 52 | ||
| 53 | #endif // _LIBCPP_STD_VER > 17 | |
| 54 | ||
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 56 | ||
| 57 | #endif // _LIBCPP___ITERATOR_MOVE_SENTINEL_H |
lib/libcxx/include/__iterator/next.h+8-10| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_NEXT_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_NEXT_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__iterator/advance.h> |
| 16 | 16 | #include <__iterator/concepts.h> |
| 17 | 17 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -35,7 +35,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 35 | 35 | return __x; |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 39 | 39 | |
| 40 | 40 | // [range.iter.op.next] |
| 41 | 41 | |
| ... | ... | @@ -58,16 +58,14 @@ struct __fn { |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 61 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | constexpr _Ip operator()(_Ip __x, _Sp __bound) const { | |
| 63 | ranges::advance(__x, __bound); | |
| 61 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp __bound_sentinel) const { | |
| 62 | ranges::advance(__x, __bound_sentinel); | |
| 64 | 63 | return __x; |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> |
| 68 | _LIBCPP_HIDE_FROM_ABI | |
| 69 | constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound) const { | |
| 70 | ranges::advance(__x, __n, __bound); | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const { | |
| 68 | ranges::advance(__x, __n, __bound_sentinel); | |
| 71 | 69 | return __x; |
| 72 | 70 | } |
| 73 | 71 | }; |
| ... | ... | @@ -79,7 +77,7 @@ inline namespace __cpo { |
| 79 | 77 | } // namespace __cpo |
| 80 | 78 | } // namespace ranges |
| 81 | 79 | |
| 82 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 80 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 83 | 81 | |
| 84 | 82 | _LIBCPP_END_NAMESPACE_STD |
| 85 | 83 |
lib/libcxx/include/__iterator/ostream_iterator.h+4-3| ... | ... | @@ -14,10 +14,11 @@ |
| 14 | 14 | #include <__iterator/iterator.h> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | 16 | #include <__memory/addressof.h> |
| 17 | #include <cstddef> | |
| 17 | 18 | #include <iosfwd> // for forward declarations of char_traits and basic_ostream |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -52,9 +53,9 @@ public: |
| 52 | 53 | : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {} |
| 53 | 54 | _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT |
| 54 | 55 | : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {} |
| 55 | _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) | |
| 56 | _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value) | |
| 56 | 57 | { |
| 57 | *__out_stream_ << __value_; | |
| 58 | *__out_stream_ << __value; | |
| 58 | 59 | if (__delim_) |
| 59 | 60 | *__out_stream_ << __delim_; |
| 60 | 61 | return *this; |
lib/libcxx/include/__iterator/ostreambuf_iterator.h+2-1| ... | ... | @@ -13,10 +13,11 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__iterator/iterator.h> |
| 15 | 15 | #include <__iterator/iterator_traits.h> |
| 16 | #include <cstddef> | |
| 16 | 17 | #include <iosfwd> // for forward declaration of basic_streambuf |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__iterator/permutable.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ITERATOR_PERMUTABLE_H | |
| 11 | #define _LIBCPP___ITERATOR_PERMUTABLE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__iterator/concepts.h> | |
| 15 | #include <__iterator/iter_swap.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | ||
| 25 | template <class _Iterator> | |
| 26 | concept permutable = | |
| 27 | forward_iterator<_Iterator> && | |
| 28 | indirectly_movable_storable<_Iterator, _Iterator> && | |
| 29 | indirectly_swappable<_Iterator, _Iterator>; | |
| 30 | ||
| 31 | #endif // _LIBCPP_STD_VER > 17 | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___ITERATOR_PERMUTABLE_H |
lib/libcxx/include/__iterator/prev.h+6-7| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_PREV_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_PREV_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__iterator/advance.h> |
| 16 | 16 | #include <__iterator/concepts.h> |
| 17 | 17 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -19,7 +19,7 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -34,7 +34,7 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 34 | 34 | return __x; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 37 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | 38 | |
| 39 | 39 | // [range.iter.op.prev] |
| 40 | 40 | |
| ... | ... | @@ -57,9 +57,8 @@ struct __fn { |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | template <bidirectional_iterator _Ip> |
| 60 | _LIBCPP_HIDE_FROM_ABI | |
| 61 | constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound) const { | |
| 62 | ranges::advance(__x, -__n, __bound); | |
| 60 | _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound_iter) const { | |
| 61 | ranges::advance(__x, -__n, __bound_iter); | |
| 63 | 62 | return __x; |
| 64 | 63 | } |
| 65 | 64 | }; |
| ... | ... | @@ -71,7 +70,7 @@ inline namespace __cpo { |
| 71 | 70 | } // namespace __cpo |
| 72 | 71 | } // namespace ranges |
| 73 | 72 | |
| 74 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 73 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 75 | 74 | |
| 76 | 75 | _LIBCPP_END_NAMESPACE_STD |
| 77 | 76 |
lib/libcxx/include/__iterator/projected.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> |
| 26 | 26 | struct projected { |
| ... | ... | @@ -33,7 +33,7 @@ struct incrementable_traits<projected<_It, _Proj>> { |
| 33 | 33 | using difference_type = iter_difference_t<_It>; |
| 34 | 34 | }; |
| 35 | 35 | |
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 36 | #endif // _LIBCPP_STD_VER > 17 | |
| 37 | 37 | |
| 38 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 39 | 39 |
lib/libcxx/include/__iterator/readable_traits.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | // [readable.traits] |
| 26 | 26 | template<class> struct __cond_value_type {}; |
| ... | ... | @@ -79,7 +79,7 @@ using iter_value_t = typename conditional_t<__is_primary_template<iterator_trait |
| 79 | 79 | indirectly_readable_traits<remove_cvref_t<_Ip> >, |
| 80 | 80 | iterator_traits<remove_cvref_t<_Ip> > >::value_type; |
| 81 | 81 | |
| 82 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 82 | #endif // _LIBCPP_STD_VER > 17 | |
| 83 | 83 | |
| 84 | 84 | _LIBCPP_END_NAMESPACE_STD |
| 85 | 85 |
lib/libcxx/include/__iterator/reverse_access.h+2-6| ... | ... | @@ -16,13 +16,11 @@ |
| 16 | 16 | #include <initializer_list> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 25 | ||
| 26 | 24 | #if _LIBCPP_STD_VER > 11 |
| 27 | 25 | |
| 28 | 26 | template <class _Tp, size_t _Np> |
| ... | ... | @@ -95,9 +93,7 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) |
| 95 | 93 | return _VSTD::rend(__c); |
| 96 | 94 | } |
| 97 | 95 | |
| 98 | #endif | |
| 99 | ||
| 100 | #endif // !defined(_LIBCPP_CXX03_LANG) | |
| 96 | #endif // _LIBCPP_STD_VER > 11 | |
| 101 | 97 | |
| 102 | 98 | _LIBCPP_END_NAMESPACE_STD |
| 103 | 99 |
lib/libcxx/include/__iterator/reverse_iterator.h+311-20| ... | ... | @@ -10,16 +10,30 @@ |
| 10 | 10 | #ifndef _LIBCPP___ITERATOR_REVERSE_ITERATOR_H |
| 11 | 11 | #define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H |
| 12 | 12 | |
| 13 | #include <__algorithm/unwrap_iter.h> | |
| 13 | 14 | #include <__compare/compare_three_way_result.h> |
| 14 | 15 | #include <__compare/three_way_comparable.h> |
| 16 | #include <__concepts/convertible_to.h> | |
| 15 | 17 | #include <__config> |
| 18 | #include <__iterator/advance.h> | |
| 19 | #include <__iterator/concepts.h> | |
| 20 | #include <__iterator/incrementable_traits.h> | |
| 21 | #include <__iterator/iter_move.h> | |
| 22 | #include <__iterator/iter_swap.h> | |
| 16 | 23 | #include <__iterator/iterator.h> |
| 17 | 24 | #include <__iterator/iterator_traits.h> |
| 25 | #include <__iterator/next.h> | |
| 26 | #include <__iterator/prev.h> | |
| 27 | #include <__iterator/readable_traits.h> | |
| 18 | 28 | #include <__memory/addressof.h> |
| 29 | #include <__ranges/access.h> | |
| 30 | #include <__ranges/concepts.h> | |
| 31 | #include <__ranges/subrange.h> | |
| 32 | #include <__utility/move.h> | |
| 19 | 33 | #include <type_traits> |
| 20 | 34 | |
| 21 | 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 36 | # pragma GCC system_header | |
| 23 | 37 | #endif |
| 24 | 38 | |
| 25 | 39 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -41,22 +55,29 @@ private: |
| 41 | 55 | _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break |
| 42 | 56 | #endif |
| 43 | 57 | |
| 58 | #if _LIBCPP_STD_VER > 17 | |
| 59 | static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value || bidirectional_iterator<_Iter>, | |
| 60 | "reverse_iterator<It> requires It to be a bidirectional iterator."); | |
| 61 | #endif // _LIBCPP_STD_VER > 17 | |
| 62 | ||
| 44 | 63 | protected: |
| 45 | 64 | _Iter current; |
| 46 | 65 | public: |
| 47 | typedef _Iter iterator_type; | |
| 48 | typedef typename iterator_traits<_Iter>::difference_type difference_type; | |
| 49 | typedef typename iterator_traits<_Iter>::reference reference; | |
| 50 | typedef typename iterator_traits<_Iter>::pointer pointer; | |
| 51 | typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, | |
| 52 | random_access_iterator_tag, | |
| 53 | typename iterator_traits<_Iter>::iterator_category> iterator_category; | |
| 54 | typedef typename iterator_traits<_Iter>::value_type value_type; | |
| 66 | using iterator_type = _Iter; | |
| 55 | 67 | |
| 68 | using iterator_category = _If<__is_cpp17_random_access_iterator<_Iter>::value, | |
| 69 | random_access_iterator_tag, | |
| 70 | typename iterator_traits<_Iter>::iterator_category>; | |
| 71 | using pointer = typename iterator_traits<_Iter>::pointer; | |
| 56 | 72 | #if _LIBCPP_STD_VER > 17 |
| 57 | typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, | |
| 58 | random_access_iterator_tag, | |
| 59 | bidirectional_iterator_tag> iterator_concept; | |
| 73 | using iterator_concept = _If<random_access_iterator<_Iter>, random_access_iterator_tag, bidirectional_iterator_tag>; | |
| 74 | using value_type = iter_value_t<_Iter>; | |
| 75 | using difference_type = iter_difference_t<_Iter>; | |
| 76 | using reference = iter_reference_t<_Iter>; | |
| 77 | #else | |
| 78 | using value_type = typename iterator_traits<_Iter>::value_type; | |
| 79 | using difference_type = typename iterator_traits<_Iter>::difference_type; | |
| 80 | using reference = typename iterator_traits<_Iter>::reference; | |
| 60 | 81 | #endif |
| 61 | 82 | |
| 62 | 83 | #ifndef _LIBCPP_ABI_NO_ITERATOR_BASES |
| ... | ... | @@ -114,32 +135,81 @@ public: |
| 114 | 135 | _Iter base() const {return current;} |
| 115 | 136 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 116 | 137 | reference operator*() const {_Iter __tmp = current; return *--__tmp;} |
| 138 | ||
| 139 | #if _LIBCPP_STD_VER > 17 | |
| 140 | _LIBCPP_INLINE_VISIBILITY | |
| 141 | constexpr pointer operator->() const | |
| 142 | requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); } | |
| 143 | { | |
| 144 | if constexpr (is_pointer_v<_Iter>) { | |
| 145 | return std::prev(current); | |
| 146 | } else { | |
| 147 | return std::prev(current).operator->(); | |
| 148 | } | |
| 149 | } | |
| 150 | #else | |
| 117 | 151 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 118 | pointer operator->() const {return _VSTD::addressof(operator*());} | |
| 152 | pointer operator->() const { | |
| 153 | return std::addressof(operator*()); | |
| 154 | } | |
| 155 | #endif // _LIBCPP_STD_VER > 17 | |
| 156 | ||
| 119 | 157 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 120 | 158 | reverse_iterator& operator++() {--current; return *this;} |
| 121 | 159 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 122 | reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} | |
| 160 | reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} | |
| 123 | 161 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 124 | 162 | reverse_iterator& operator--() {++current; return *this;} |
| 125 | 163 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 126 | reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} | |
| 164 | reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} | |
| 127 | 165 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 128 | reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} | |
| 166 | reverse_iterator operator+(difference_type __n) const {return reverse_iterator(current - __n);} | |
| 129 | 167 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 130 | 168 | reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} |
| 131 | 169 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 132 | reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} | |
| 170 | reverse_iterator operator-(difference_type __n) const {return reverse_iterator(current + __n);} | |
| 133 | 171 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 134 | 172 | reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} |
| 135 | 173 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 136 | reference operator[](difference_type __n) const {return *(*this + __n);} | |
| 174 | reference operator[](difference_type __n) const {return *(*this + __n);} | |
| 175 | ||
| 176 | #if _LIBCPP_STD_VER > 17 | |
| 177 | _LIBCPP_HIDE_FROM_ABI friend constexpr | |
| 178 | iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i) | |
| 179 | noexcept(is_nothrow_copy_constructible_v<_Iter> && | |
| 180 | noexcept(ranges::iter_move(--declval<_Iter&>()))) { | |
| 181 | auto __tmp = __i.base(); | |
| 182 | return ranges::iter_move(--__tmp); | |
| 183 | } | |
| 184 | ||
| 185 | template <indirectly_swappable<_Iter> _Iter2> | |
| 186 | _LIBCPP_HIDE_FROM_ABI friend constexpr | |
| 187 | void iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y) | |
| 188 | noexcept(is_nothrow_copy_constructible_v<_Iter> && | |
| 189 | is_nothrow_copy_constructible_v<_Iter2> && | |
| 190 | noexcept(ranges::iter_swap(--declval<_Iter&>(), --declval<_Iter2&>()))) { | |
| 191 | auto __xtmp = __x.base(); | |
| 192 | auto __ytmp = __y.base(); | |
| 193 | ranges::iter_swap(--__xtmp, --__ytmp); | |
| 194 | } | |
| 195 | #endif // _LIBCPP_STD_VER > 17 | |
| 137 | 196 | }; |
| 138 | 197 | |
| 198 | template <class _Iter> | |
| 199 | struct __is_reverse_iterator : false_type {}; | |
| 200 | ||
| 201 | template <class _Iter> | |
| 202 | struct __is_reverse_iterator<reverse_iterator<_Iter> > : true_type {}; | |
| 203 | ||
| 139 | 204 | template <class _Iter1, class _Iter2> |
| 140 | 205 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 141 | 206 | bool |
| 142 | 207 | operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) |
| 208 | #if _LIBCPP_STD_VER > 17 | |
| 209 | requires requires { | |
| 210 | { __x.base() == __y.base() } -> convertible_to<bool>; | |
| 211 | } | |
| 212 | #endif // _LIBCPP_STD_VER > 17 | |
| 143 | 213 | { |
| 144 | 214 | return __x.base() == __y.base(); |
| 145 | 215 | } |
| ... | ... | @@ -148,6 +218,11 @@ template <class _Iter1, class _Iter2> |
| 148 | 218 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 149 | 219 | bool |
| 150 | 220 | operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) |
| 221 | #if _LIBCPP_STD_VER > 17 | |
| 222 | requires requires { | |
| 223 | { __x.base() > __y.base() } -> convertible_to<bool>; | |
| 224 | } | |
| 225 | #endif // _LIBCPP_STD_VER > 17 | |
| 151 | 226 | { |
| 152 | 227 | return __x.base() > __y.base(); |
| 153 | 228 | } |
| ... | ... | @@ -156,6 +231,11 @@ template <class _Iter1, class _Iter2> |
| 156 | 231 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 157 | 232 | bool |
| 158 | 233 | operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) |
| 234 | #if _LIBCPP_STD_VER > 17 | |
| 235 | requires requires { | |
| 236 | { __x.base() != __y.base() } -> convertible_to<bool>; | |
| 237 | } | |
| 238 | #endif // _LIBCPP_STD_VER > 17 | |
| 159 | 239 | { |
| 160 | 240 | return __x.base() != __y.base(); |
| 161 | 241 | } |
| ... | ... | @@ -164,6 +244,11 @@ template <class _Iter1, class _Iter2> |
| 164 | 244 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 165 | 245 | bool |
| 166 | 246 | operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) |
| 247 | #if _LIBCPP_STD_VER > 17 | |
| 248 | requires requires { | |
| 249 | { __x.base() < __y.base() } -> convertible_to<bool>; | |
| 250 | } | |
| 251 | #endif // _LIBCPP_STD_VER > 17 | |
| 167 | 252 | { |
| 168 | 253 | return __x.base() < __y.base(); |
| 169 | 254 | } |
| ... | ... | @@ -172,6 +257,11 @@ template <class _Iter1, class _Iter2> |
| 172 | 257 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 173 | 258 | bool |
| 174 | 259 | operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) |
| 260 | #if _LIBCPP_STD_VER > 17 | |
| 261 | requires requires { | |
| 262 | { __x.base() <= __y.base() } -> convertible_to<bool>; | |
| 263 | } | |
| 264 | #endif // _LIBCPP_STD_VER > 17 | |
| 175 | 265 | { |
| 176 | 266 | return __x.base() <= __y.base(); |
| 177 | 267 | } |
| ... | ... | @@ -180,11 +270,16 @@ template <class _Iter1, class _Iter2> |
| 180 | 270 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 181 | 271 | bool |
| 182 | 272 | operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) |
| 273 | #if _LIBCPP_STD_VER > 17 | |
| 274 | requires requires { | |
| 275 | { __x.base() >= __y.base() } -> convertible_to<bool>; | |
| 276 | } | |
| 277 | #endif // _LIBCPP_STD_VER > 17 | |
| 183 | 278 | { |
| 184 | 279 | return __x.base() >= __y.base(); |
| 185 | 280 | } |
| 186 | 281 | |
| 187 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 282 | #if _LIBCPP_STD_VER > 17 | |
| 188 | 283 | template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2> |
| 189 | 284 | _LIBCPP_HIDE_FROM_ABI constexpr |
| 190 | 285 | compare_three_way_result_t<_Iter1, _Iter2> |
| ... | ... | @@ -192,7 +287,7 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& |
| 192 | 287 | { |
| 193 | 288 | return __y.base() <=> __x.base(); |
| 194 | 289 | } |
| 195 | #endif | |
| 290 | #endif // _LIBCPP_STD_VER > 17 | |
| 196 | 291 | |
| 197 | 292 | #ifndef _LIBCPP_CXX03_LANG |
| 198 | 293 | template <class _Iter1, class _Iter2> |
| ... | ... | @@ -221,6 +316,12 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i |
| 221 | 316 | return reverse_iterator<_Iter>(__x.base() - __n); |
| 222 | 317 | } |
| 223 | 318 | |
| 319 | #if _LIBCPP_STD_VER > 17 | |
| 320 | template <class _Iter1, class _Iter2> | |
| 321 | requires (!sized_sentinel_for<_Iter1, _Iter2>) | |
| 322 | inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, reverse_iterator<_Iter2>> = true; | |
| 323 | #endif // _LIBCPP_STD_VER > 17 | |
| 324 | ||
| 224 | 325 | #if _LIBCPP_STD_VER > 11 |
| 225 | 326 | template <class _Iter> |
| 226 | 327 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| ... | ... | @@ -230,6 +331,196 @@ reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) |
| 230 | 331 | } |
| 231 | 332 | #endif |
| 232 | 333 | |
| 334 | #if _LIBCPP_STD_VER <= 17 | |
| 335 | template <class _Iter> | |
| 336 | using __unconstrained_reverse_iterator = reverse_iterator<_Iter>; | |
| 337 | #else | |
| 338 | ||
| 339 | // __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working | |
| 340 | // around a language issue in C++20. | |
| 341 | // In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will | |
| 342 | // result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not | |
| 343 | // an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a | |
| 344 | // C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with | |
| 345 | // tweaks to make it support hostile iterators. | |
| 346 | // | |
| 347 | // A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match | |
| 348 | // and the other requires an implicit conversion, for example: | |
| 349 | // friend bool operator==(const BaseIter&, const DerivedIter&); | |
| 350 | // | |
| 351 | // C++20 rules for rewriting equality operators create another overload of this function with parameters reversed: | |
| 352 | // friend bool operator==(const DerivedIter&, const BaseIter&); | |
| 353 | // | |
| 354 | // This creates an ambiguity in overload resolution. | |
| 355 | // | |
| 356 | // Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function | |
| 357 | // body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however, | |
| 358 | // it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its | |
| 359 | // base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload | |
| 360 | // resolution. This class simply removes the problematic constraints from comparison functions. | |
| 361 | template <class _Iter> | |
| 362 | class __unconstrained_reverse_iterator { | |
| 363 | _Iter __iter_; | |
| 364 | ||
| 365 | public: | |
| 366 | static_assert(__is_cpp17_bidirectional_iterator<_Iter>::value); | |
| 367 | ||
| 368 | using iterator_type = _Iter; | |
| 369 | using iterator_category = | |
| 370 | _If<__is_cpp17_random_access_iterator<_Iter>::value, random_access_iterator_tag, __iterator_category_type<_Iter>>; | |
| 371 | using pointer = __iterator_pointer_type<_Iter>; | |
| 372 | using value_type = iter_value_t<_Iter>; | |
| 373 | using difference_type = iter_difference_t<_Iter>; | |
| 374 | using reference = iter_reference_t<_Iter>; | |
| 375 | ||
| 376 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator() = default; | |
| 377 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator&) = default; | |
| 378 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __unconstrained_reverse_iterator(_Iter __iter) : __iter_(__iter) {} | |
| 379 | ||
| 380 | _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() const { return __iter_; } | |
| 381 | _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const { | |
| 382 | auto __tmp = __iter_; | |
| 383 | return *--__tmp; | |
| 384 | } | |
| 385 | ||
| 386 | _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const { | |
| 387 | if constexpr (is_pointer_v<_Iter>) { | |
| 388 | return std::prev(__iter_); | |
| 389 | } else { | |
| 390 | return std::prev(__iter_).operator->(); | |
| 391 | } | |
| 392 | } | |
| 393 | ||
| 394 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() { | |
| 395 | --__iter_; | |
| 396 | return *this; | |
| 397 | } | |
| 398 | ||
| 399 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator++(int) { | |
| 400 | auto __tmp = *this; | |
| 401 | --__iter_; | |
| 402 | return __tmp; | |
| 403 | } | |
| 404 | ||
| 405 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator--() { | |
| 406 | ++__iter_; | |
| 407 | return *this; | |
| 408 | } | |
| 409 | ||
| 410 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator--(int) { | |
| 411 | auto __tmp = *this; | |
| 412 | ++__iter_; | |
| 413 | return __tmp; | |
| 414 | } | |
| 415 | ||
| 416 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator+=(difference_type __n) { | |
| 417 | __iter_ -= __n; | |
| 418 | return *this; | |
| 419 | } | |
| 420 | ||
| 421 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator-=(difference_type __n) { | |
| 422 | __iter_ += __n; | |
| 423 | return *this; | |
| 424 | } | |
| 425 | ||
| 426 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator+(difference_type __n) const { | |
| 427 | return __unconstrained_reverse_iterator(__iter_ - __n); | |
| 428 | } | |
| 429 | ||
| 430 | _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator-(difference_type __n) const { | |
| 431 | return __unconstrained_reverse_iterator(__iter_ + __n); | |
| 432 | } | |
| 433 | ||
| 434 | _LIBCPP_HIDE_FROM_ABI constexpr difference_type operator-(const __unconstrained_reverse_iterator& __other) const { | |
| 435 | return __other.__iter_ - __iter_; | |
| 436 | } | |
| 437 | ||
| 438 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const { return *(*this + __n); } | |
| 439 | ||
| 440 | // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the | |
| 441 | // rationale. | |
| 442 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 443 | operator==(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | |
| 444 | return __lhs.base() == __rhs.base(); | |
| 445 | } | |
| 446 | ||
| 447 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 448 | operator!=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | |
| 449 | return __lhs.base() != __rhs.base(); | |
| 450 | } | |
| 451 | ||
| 452 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 453 | operator<(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | |
| 454 | return __lhs.base() > __rhs.base(); | |
| 455 | } | |
| 456 | ||
| 457 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 458 | operator>(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | |
| 459 | return __lhs.base() < __rhs.base(); | |
| 460 | } | |
| 461 | ||
| 462 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 463 | operator<=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | |
| 464 | return __lhs.base() >= __rhs.base(); | |
| 465 | } | |
| 466 | ||
| 467 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool | |
| 468 | operator>=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) { | |
| 469 | return __lhs.base() <= __rhs.base(); | |
| 470 | } | |
| 471 | }; | |
| 472 | ||
| 473 | template <class _Iter> | |
| 474 | struct __is_reverse_iterator<__unconstrained_reverse_iterator<_Iter>> : true_type {}; | |
| 475 | ||
| 476 | #endif // _LIBCPP_STD_VER <= 17 | |
| 477 | ||
| 478 | template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter> | |
| 479 | struct __unwrap_reverse_iter_impl { | |
| 480 | using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>())); | |
| 481 | using _ReverseWrapper = _RevIter1<_RevIter2<_Iter> >; | |
| 482 | ||
| 483 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper | |
| 484 | __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) { | |
| 485 | return _ReverseWrapper( | |
| 486 | _RevIter2<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter))); | |
| 487 | } | |
| 488 | ||
| 489 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT { | |
| 490 | return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base()); | |
| 491 | } | |
| 492 | }; | |
| 493 | ||
| 494 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 495 | template <ranges::bidirectional_range _Range> | |
| 496 | _LIBCPP_HIDE_FROM_ABI constexpr ranges:: | |
| 497 | subrange<reverse_iterator<ranges::iterator_t<_Range>>, reverse_iterator<ranges::iterator_t<_Range>>> | |
| 498 | __reverse_range(_Range&& __range) { | |
| 499 | auto __first = ranges::begin(__range); | |
| 500 | return {std::make_reverse_iterator(ranges::next(__first, ranges::end(__range))), std::make_reverse_iterator(__first)}; | |
| 501 | } | |
| 502 | #endif | |
| 503 | ||
| 504 | template <class _Iter, bool __b> | |
| 505 | struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> | |
| 506 | : __unwrap_reverse_iter_impl<reverse_iterator, reverse_iterator, _Iter> {}; | |
| 507 | ||
| 508 | #if _LIBCPP_STD_VER > 17 | |
| 509 | ||
| 510 | template <class _Iter, bool __b> | |
| 511 | struct __unwrap_iter_impl<reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b> | |
| 512 | : __unwrap_reverse_iter_impl<reverse_iterator, __unconstrained_reverse_iterator, _Iter> {}; | |
| 513 | ||
| 514 | template <class _Iter, bool __b> | |
| 515 | struct __unwrap_iter_impl<__unconstrained_reverse_iterator<reverse_iterator<_Iter>>, __b> | |
| 516 | : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, reverse_iterator, _Iter> {}; | |
| 517 | ||
| 518 | template <class _Iter, bool __b> | |
| 519 | struct __unwrap_iter_impl<__unconstrained_reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b> | |
| 520 | : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, __unconstrained_reverse_iterator, _Iter> {}; | |
| 521 | ||
| 522 | #endif // _LIBCPP_STD_VER > 17 | |
| 523 | ||
| 233 | 524 | _LIBCPP_END_NAMESPACE_STD |
| 234 | 525 | |
| 235 | 526 | #endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H |
lib/libcxx/include/__iterator/size.h+6-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -41,9 +41,14 @@ _NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype( |
| 41 | 41 | -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> |
| 42 | 42 | { return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); } |
| 43 | 43 | |
| 44 | // GCC complains about the implicit conversion from ptrdiff_t to size_t in | |
| 45 | // the array bound. | |
| 46 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 47 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wsign-conversion") | |
| 44 | 48 | template <class _Tp, ptrdiff_t _Sz> |
| 45 | 49 | _LIBCPP_INLINE_VISIBILITY |
| 46 | 50 | constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } |
| 51 | _LIBCPP_DIAGNOSTIC_POP | |
| 47 | 52 | #endif |
| 48 | 53 | |
| 49 | 54 | #endif // _LIBCPP_STD_VER > 14 |
lib/libcxx/include/__iterator/sortable.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___ITERATOR_SORTABLE_H | |
| 11 | #define _LIBCPP___ITERATOR_SORTABLE_H | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | #include <__functional/identity.h> | |
| 15 | #include <__functional/ranges_operations.h> | |
| 16 | #include <__iterator/concepts.h> | |
| 17 | #include <__iterator/permutable.h> | |
| 18 | #include <__iterator/projected.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | ||
| 28 | template <class _Iter, class _Comp = ranges::less, class _Proj = identity> | |
| 29 | concept sortable = | |
| 30 | permutable<_Iter> && | |
| 31 | indirect_strict_weak_order<_Comp, projected<_Iter, _Proj>>; | |
| 32 | ||
| 33 | #endif // _LIBCPP_STD_VER > 17 | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___ITERATOR_SORTABLE_H |
lib/libcxx/include/__iterator/unreachable_sentinel.h+3-3| ... | ... | @@ -14,12 +14,12 @@ |
| 14 | 14 | #include <__iterator/concepts.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | |
| 22 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 22 | #if _LIBCPP_STD_VER > 17 | |
| 23 | 23 | |
| 24 | 24 | struct unreachable_sentinel_t { |
| 25 | 25 | template<weakly_incrementable _Iter> |
| ... | ... | @@ -31,7 +31,7 @@ struct unreachable_sentinel_t { |
| 31 | 31 | |
| 32 | 32 | inline constexpr unreachable_sentinel_t unreachable_sentinel{}; |
| 33 | 33 | |
| 34 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 34 | #endif // _LIBCPP_STD_VER > 17 | |
| 35 | 35 | |
| 36 | 36 | _LIBCPP_END_NAMESPACE_STD |
| 37 | 37 |
lib/libcxx/include/__iterator/wrap_iter.h+8-8| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -50,12 +50,12 @@ public: |
| 50 | 50 | typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT |
| 51 | 51 | : __i(__u.base()) |
| 52 | 52 | { |
| 53 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 53 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 54 | 54 | if (!__libcpp_is_constant_evaluated()) |
| 55 | 55 | __get_db()->__iterator_copy(this, _VSTD::addressof(__u)); |
| 56 | 56 | #endif |
| 57 | 57 | } |
| 58 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 58 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 59 | 59 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 60 | 60 | __wrap_iter(const __wrap_iter& __x) |
| 61 | 61 | : __i(__x.base()) |
| ... | ... | @@ -135,15 +135,15 @@ public: |
| 135 | 135 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 iterator_type base() const _NOEXCEPT {return __i;} |
| 136 | 136 | |
| 137 | 137 | private: |
| 138 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(const void* __p, iterator_type __x) : __i(__x) | |
| 138 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 139 | explicit __wrap_iter(const void* __p, iterator_type __x) _NOEXCEPT : __i(__x) | |
| 140 | 140 | { |
| 141 | (void)__p; | |
| 142 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 141 | 143 | if (!__libcpp_is_constant_evaluated()) |
| 142 | 144 | __get_db()->__insert_ic(this, __p); |
| 143 | } | |
| 144 | #else | |
| 145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} | |
| 146 | 145 | #endif |
| 146 | } | |
| 147 | 147 | |
| 148 | 148 | template <class _Up> friend class __wrap_iter; |
| 149 | 149 | template <class _CharT, class _Traits, class _Alloc> friend class basic_string; |
lib/libcxx/include/__libcpp_version deleted-1| ... | ... | @@ -1 +0,0 @@ |
| 1 | 14000 |
lib/libcxx/include/__locale+17-17| ... | ... | @@ -18,24 +18,22 @@ |
| 18 | 18 | #include <memory> |
| 19 | 19 | #include <mutex> |
| 20 | 20 | #include <string> |
| 21 | #include <utility> | |
| 22 | 21 | |
| 23 | 22 | #if defined(_LIBCPP_MSVCRT_LIKE) |
| 24 | # include <cstring> | |
| 25 | 23 | # include <__support/win32/locale_win32.h> |
| 24 | # include <cstring> | |
| 26 | 25 | #elif defined(_AIX) || defined(__MVS__) |
| 27 | 26 | # include <__support/ibm/xlocale.h> |
| 28 | 27 | #elif defined(__ANDROID__) |
| 29 | 28 | # include <__support/android/locale_bionic.h> |
| 30 | 29 | #elif defined(__sun__) |
| 31 | # include <xlocale.h> | |
| 32 | 30 | # include <__support/solaris/xlocale.h> |
| 31 | # include <xlocale.h> | |
| 33 | 32 | #elif defined(_NEWLIB_VERSION) |
| 34 | 33 | # include <__support/newlib/xlocale.h> |
| 35 | 34 | #elif defined(__OpenBSD__) |
| 36 | 35 | # include <__support/openbsd/xlocale.h> |
| 37 | #elif (defined(__APPLE__) || defined(__FreeBSD__) \ | |
| 38 | || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) | |
| 36 | #elif (defined(__APPLE__) || defined(__FreeBSD__)) | |
| 39 | 37 | # include <xlocale.h> |
| 40 | 38 | #elif defined(__Fuchsia__) |
| 41 | 39 | # include <__support/fuchsia/xlocale.h> |
| ... | ... | @@ -47,7 +45,7 @@ |
| 47 | 45 | #endif |
| 48 | 46 | |
| 49 | 47 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 50 | #pragma GCC system_header | |
| 48 | # pragma GCC system_header | |
| 51 | 49 | #endif |
| 52 | 50 | |
| 53 | 51 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -339,9 +337,9 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const |
| 339 | 337 | return static_cast<long>(__h); |
| 340 | 338 | } |
| 341 | 339 | |
| 342 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>) | |
| 340 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>; | |
| 343 | 341 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 344 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>) | |
| 342 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>; | |
| 345 | 343 | #endif |
| 346 | 344 | |
| 347 | 345 | // template <class CharT> class collate_byname; |
| ... | ... | @@ -454,6 +452,7 @@ public: |
| 454 | 452 | static const mask blank = _BLANK; |
| 455 | 453 | static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used |
| 456 | 454 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT |
| 455 | # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA | |
| 457 | 456 | #elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) |
| 458 | 457 | # ifdef __APPLE__ |
| 459 | 458 | typedef __uint32_t mask; |
| ... | ... | @@ -493,7 +492,11 @@ public: |
| 493 | 492 | static const mask punct = _ISPUNCT; |
| 494 | 493 | static const mask xdigit = _ISXDIGIT; |
| 495 | 494 | static const mask blank = _ISBLANK; |
| 495 | # if defined(_AIX) | |
| 496 | static const mask __regex_word = 0x8000; | |
| 497 | # else | |
| 496 | 498 | static const mask __regex_word = 0x80; |
| 499 | # endif | |
| 497 | 500 | #elif defined(_NEWLIB_VERSION) |
| 498 | 501 | // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h. |
| 499 | 502 | typedef char mask; |
| ... | ... | @@ -546,11 +549,8 @@ public: |
| 546 | 549 | |
| 547 | 550 | _LIBCPP_INLINE_VISIBILITY ctype_base() {} |
| 548 | 551 | |
| 549 | // TODO: Remove the ifndef when the assert no longer fails on AIX. | |
| 550 | #ifndef _AIX | |
| 551 | 552 | static_assert((__regex_word & ~(space | print | cntrl | upper | lower | alpha | digit | punct | xdigit | blank)) == __regex_word, |
| 552 | 553 | "__regex_word can't overlap other bits"); |
| 553 | #endif | |
| 554 | 554 | }; |
| 555 | 555 | |
| 556 | 556 | template <class _CharT> class _LIBCPP_TEMPLATE_VIS ctype; |
| ... | ... | @@ -1498,15 +1498,15 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() |
| 1498 | 1498 | } |
| 1499 | 1499 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 1500 | 1500 | |
| 1501 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>) | |
| 1501 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>; | |
| 1502 | 1502 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1503 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) | |
| 1503 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>; | |
| 1504 | 1504 | #endif |
| 1505 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) // deprecated in C++20 | |
| 1506 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) // deprecated in C++20 | |
| 1505 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20 | |
| 1506 | extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20 | |
| 1507 | 1507 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 1508 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>) // C++20 | |
| 1509 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>) // C++20 | |
| 1508 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20 | |
| 1509 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20 | |
| 1510 | 1510 | #endif |
| 1511 | 1511 | |
| 1512 | 1512 | template <size_t _Np> |
lib/libcxx/include/__mbstate_t.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | // TODO(ldionne): |
lib/libcxx/include/__memory/addressof.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__memory/allocate_at_least.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H | |
| 10 | #define _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__memory/allocator_traits.h> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if _LIBCPP_STD_VER > 20 | |
| 23 | template <class _Pointer> | |
| 24 | struct allocation_result { | |
| 25 | _Pointer ptr; | |
| 26 | size_t count; | |
| 27 | }; | |
| 28 | ||
| 29 | template <class _Alloc> | |
| 30 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr | |
| 31 | allocation_result<typename allocator_traits<_Alloc>::pointer> allocate_at_least(_Alloc& __alloc, size_t __n) { | |
| 32 | if constexpr (requires { __alloc.allocate_at_least(__n); }) { | |
| 33 | return __alloc.allocate_at_least(__n); | |
| 34 | } else { | |
| 35 | return {__alloc.allocate(__n), __n}; | |
| 36 | } | |
| 37 | } | |
| 38 | ||
| 39 | template <class _Alloc> | |
| 40 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr | |
| 41 | auto __allocate_at_least(_Alloc& __alloc, size_t __n) { | |
| 42 | return std::allocate_at_least(__alloc, __n); | |
| 43 | } | |
| 44 | #else | |
| 45 | template <class _Pointer> | |
| 46 | struct __allocation_result { | |
| 47 | _Pointer ptr; | |
| 48 | size_t count; | |
| 49 | }; | |
| 50 | ||
| 51 | template <class _Alloc> | |
| 52 | _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 53 | __allocation_result<typename allocator_traits<_Alloc>::pointer> __allocate_at_least(_Alloc& __alloc, size_t __n) { | |
| 54 | return {__alloc.allocate(__n), __n}; | |
| 55 | } | |
| 56 | ||
| 57 | #endif // _LIBCPP_STD_VER > 20 | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP___MEMORY_ALLOCATE_AT_LEAST_H |
lib/libcxx/include/__memory/allocation_guard.h+2-2| ... | ... | @@ -12,11 +12,11 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__memory/allocator_traits.h> |
| 15 | #include <__utility/move.h> | |
| 15 | 16 | #include <cstddef> |
| 16 | #include <utility> | |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__memory/allocator.h+23-2| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_ALLOCATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__memory/allocate_at_least.h> | |
| 14 | 15 | #include <__memory/allocator_traits.h> |
| 15 | 16 | #include <__utility/forward.h> |
| 16 | 17 | #include <cstddef> |
| ... | ... | @@ -19,34 +20,40 @@ |
| 19 | 20 | #include <type_traits> |
| 20 | 21 | |
| 21 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 23 | 24 | #endif |
| 24 | 25 | |
| 25 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | |
| 27 | 28 | template <class _Tp> class allocator; |
| 28 | 29 | |
| 29 | #if _LIBCPP_STD_VER <= 17 | |
| 30 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION) | |
| 31 | // These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. | |
| 32 | // Specializing allocator<void> is deprecated, but not using it. | |
| 30 | 33 | template <> |
| 31 | 34 | class _LIBCPP_TEMPLATE_VIS allocator<void> |
| 32 | 35 | { |
| 36 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | |
| 33 | 37 | public: |
| 34 | 38 | _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; |
| 35 | 39 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; |
| 36 | 40 | _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type; |
| 37 | 41 | |
| 38 | 42 | template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; |
| 43 | #endif | |
| 39 | 44 | }; |
| 40 | 45 | |
| 41 | 46 | template <> |
| 42 | 47 | class _LIBCPP_TEMPLATE_VIS allocator<const void> |
| 43 | 48 | { |
| 49 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) | |
| 44 | 50 | public: |
| 45 | 51 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; |
| 46 | 52 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; |
| 47 | 53 | _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type; |
| 48 | 54 | |
| 49 | 55 | template <class _Up> struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; |
| 56 | #endif | |
| 50 | 57 | }; |
| 51 | 58 | #endif |
| 52 | 59 | |
| ... | ... | @@ -106,6 +113,13 @@ public: |
| 106 | 113 | } |
| 107 | 114 | } |
| 108 | 115 | |
| 116 | #if _LIBCPP_STD_VER > 20 | |
| 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr | |
| 118 | allocation_result<_Tp*> allocate_at_least(size_t __n) { | |
| 119 | return {allocate(__n), __n}; | |
| 120 | } | |
| 121 | #endif | |
| 122 | ||
| 109 | 123 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 110 | 124 | void deallocate(_Tp* __p, size_t __n) _NOEXCEPT { |
| 111 | 125 | if (__libcpp_is_constant_evaluated()) { |
| ... | ... | @@ -188,6 +202,13 @@ public: |
| 188 | 202 | } |
| 189 | 203 | } |
| 190 | 204 | |
| 205 | #if _LIBCPP_STD_VER > 20 | |
| 206 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr | |
| 207 | allocation_result<const _Tp*> allocate_at_least(size_t __n) { | |
| 208 | return {allocate(__n), __n}; | |
| 209 | } | |
| 210 | #endif | |
| 211 | ||
| 191 | 212 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 192 | 213 | void deallocate(const _Tp* __p, size_t __n) { |
| 193 | 214 | if (__libcpp_is_constant_evaluated()) { |
lib/libcxx/include/__memory/allocator_arg_t.h+2-2| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -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 typename __uncvref<_Alloc>::type _RawAlloc; | |
| 39 | typedef _LIBCPP_NODEBUG __uncvref_t<_Alloc> _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; |
lib/libcxx/include/__memory/allocator_traits.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__memory/assume_aligned.h created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___MEMORY_ASSUME_ALIGNED_H | |
| 11 | #define _LIBCPP___MEMORY_ASSUME_ALIGNED_H | |
| 12 | ||
| 13 | #include <__assert> | |
| 14 | #include <__config> | |
| 15 | #include <cstddef> | |
| 16 | #include <cstdint> | |
| 17 | #include <type_traits> // for is_constant_evaluated() | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | ||
| 27 | template <size_t _Np, class _Tp> | |
| 28 | [[nodiscard]] | |
| 29 | _LIBCPP_HIDE_FROM_ABI | |
| 30 | constexpr _Tp* assume_aligned(_Tp* __ptr) { | |
| 31 | static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0, | |
| 32 | "std::assume_aligned<N>(p) requires N to be a power of two"); | |
| 33 | ||
| 34 | if (is_constant_evaluated()) { | |
| 35 | return __ptr; | |
| 36 | } else { | |
| 37 | _LIBCPP_ASSERT(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated"); | |
| 38 | return static_cast<_Tp*>(__builtin_assume_aligned(__ptr, _Np)); | |
| 39 | } | |
| 40 | } | |
| 41 | ||
| 42 | #endif // _LIBCPP_STD_VER > 17 | |
| 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | |
| 45 | ||
| 46 | #endif // _LIBCPP___MEMORY_ASSUME_ALIGNED_H |
lib/libcxx/include/__memory/auto_ptr.h+5-2| ... | ... | @@ -11,12 +11,13 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_AUTO_PTR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__nullptr> | |
| 15 | 14 | |
| 16 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 18 | 17 | #endif |
| 19 | 18 | |
| 19 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 20 | ||
| 20 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 22 | |
| 22 | 23 | template <class _Tp> |
| ... | ... | @@ -78,4 +79,6 @@ public: |
| 78 | 79 | |
| 79 | 80 | _LIBCPP_END_NAMESPACE_STD |
| 80 | 81 | |
| 82 | #endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 83 | ||
| 81 | 84 | #endif // _LIBCPP___MEMORY_AUTO_PTR_H |
lib/libcxx/include/__memory/compressed_pair.h+69-88| ... | ... | @@ -12,12 +12,12 @@ |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__utility/forward.h> |
| 15 | #include <__utility/move.h> | |
| 15 | 16 | #include <tuple> // needed in c++03 for some constructors |
| 16 | 17 | #include <type_traits> |
| 17 | #include <utility> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -26,40 +26,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | struct __default_init_tag {}; |
| 27 | 27 | struct __value_init_tag {}; |
| 28 | 28 | |
| 29 | template <class _Tp, int _Idx, | |
| 30 | bool _CanBeEmptyBase = | |
| 31 | is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value> | |
| 29 | template <class _Tp, int _Idx, bool _CanBeEmptyBase = is_empty<_Tp>::value && !__libcpp_is_final<_Tp>::value> | |
| 32 | 30 | struct __compressed_pair_elem { |
| 33 | typedef _Tp _ParamT; | |
| 34 | typedef _Tp& reference; | |
| 35 | typedef const _Tp& const_reference; | |
| 36 | ||
| 37 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 38 | __compressed_pair_elem(__default_init_tag) {} | |
| 39 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 40 | __compressed_pair_elem(__value_init_tag) : __value_() {} | |
| 41 | ||
| 42 | template <class _Up, class = typename enable_if< | |
| 43 | !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value | |
| 44 | >::type> | |
| 45 | _LIBCPP_INLINE_VISIBILITY | |
| 46 | _LIBCPP_CONSTEXPR explicit | |
| 47 | __compressed_pair_elem(_Up&& __u) | |
| 48 | : __value_(_VSTD::forward<_Up>(__u)) | |
| 49 | { | |
| 50 | } | |
| 31 | using _ParamT = _Tp; | |
| 32 | using reference = _Tp&; | |
| 33 | using const_reference = const _Tp&; | |
| 51 | 34 | |
| 35 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} | |
| 36 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {} | |
| 37 | ||
| 38 | template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> > | |
| 39 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 40 | explicit __compressed_pair_elem(_Up&& __u) : __value_(std::forward<_Up>(__u)) {} | |
| 52 | 41 | |
| 53 | 42 | #ifndef _LIBCPP_CXX03_LANG |
| 54 | template <class... _Args, size_t... _Indexes> | |
| 55 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 56 | __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, | |
| 57 | __tuple_indices<_Indexes...>) | |
| 58 | : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} | |
| 43 | template <class... _Args, size_t... _Indices> | |
| 44 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 45 | explicit __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>) | |
| 46 | : __value_(std::forward<_Args>(std::get<_Indices>(__args))...) {} | |
| 59 | 47 | #endif |
| 60 | 48 | |
| 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_; } | |
| 49 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return __value_; } | |
| 50 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return __value_; } | |
| 63 | 51 | |
| 64 | 52 | private: |
| 65 | 53 | _Tp __value_; |
| ... | ... | @@ -67,36 +55,28 @@ private: |
| 67 | 55 | |
| 68 | 56 | template <class _Tp, int _Idx> |
| 69 | 57 | struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { |
| 70 | typedef _Tp _ParamT; | |
| 71 | typedef _Tp& reference; | |
| 72 | typedef const _Tp& const_reference; | |
| 73 | typedef _Tp __value_type; | |
| 74 | ||
| 75 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default; | |
| 76 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 77 | __compressed_pair_elem(__default_init_tag) {} | |
| 78 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 79 | __compressed_pair_elem(__value_init_tag) : __value_type() {} | |
| 80 | ||
| 81 | template <class _Up, class = typename enable_if< | |
| 82 | !is_same<__compressed_pair_elem, typename decay<_Up>::type>::value | |
| 83 | >::type> | |
| 84 | _LIBCPP_INLINE_VISIBILITY | |
| 85 | _LIBCPP_CONSTEXPR explicit | |
| 86 | __compressed_pair_elem(_Up&& __u) | |
| 87 | : __value_type(_VSTD::forward<_Up>(__u)) | |
| 88 | {} | |
| 58 | using _ParamT = _Tp; | |
| 59 | using reference = _Tp&; | |
| 60 | using const_reference = const _Tp&; | |
| 61 | using __value_type = _Tp; | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem() = default; | |
| 64 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {} | |
| 65 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {} | |
| 66 | ||
| 67 | template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, typename decay<_Up>::type>::value> > | |
| 68 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 69 | explicit __compressed_pair_elem(_Up&& __u) : __value_type(std::forward<_Up>(__u)) {} | |
| 89 | 70 | |
| 90 | 71 | #ifndef _LIBCPP_CXX03_LANG |
| 91 | template <class... _Args, size_t... _Indexes> | |
| 92 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 93 | __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, | |
| 94 | __tuple_indices<_Indexes...>) | |
| 95 | : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} | |
| 72 | template <class... _Args, size_t... _Indices> | |
| 73 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 74 | __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indices...>) | |
| 75 | : __value_type(std::forward<_Args>(std::get<_Indices>(__args))...) {} | |
| 96 | 76 | #endif |
| 97 | 77 | |
| 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; } | |
| 78 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference __get() _NOEXCEPT { return *this; } | |
| 79 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference __get() const _NOEXCEPT { return *this; } | |
| 100 | 80 | }; |
| 101 | 81 | |
| 102 | 82 | template <class _T1, class _T2> |
| ... | ... | @@ -109,72 +89,73 @@ public: |
| 109 | 89 | // object and the allocator have the same type). |
| 110 | 90 | static_assert((!is_same<_T1, _T2>::value), |
| 111 | 91 | "__compressed_pair cannot be instantiated when T1 and T2 are the same type; " |
| 112 | "The current implementation is NOT ABI-compatible with the previous " | |
| 113 | "implementation for this configuration"); | |
| 92 | "The current implementation is NOT ABI-compatible with the previous implementation for this configuration"); | |
| 114 | 93 | |
| 115 | typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T1, 0> _Base1; | |
| 116 | typedef _LIBCPP_NODEBUG __compressed_pair_elem<_T2, 1> _Base2; | |
| 94 | using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>; | |
| 95 | using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>; | |
| 117 | 96 | |
| 118 | template <bool _Dummy = true, | |
| 119 | class = typename enable_if< | |
| 120 | __dependent_type<is_default_constructible<_T1>, _Dummy>::value && | |
| 121 | __dependent_type<is_default_constructible<_T2>, _Dummy>::value | |
| 122 | >::type | |
| 97 | template <bool _Dummy = true, | |
| 98 | class = __enable_if_t< | |
| 99 | __dependent_type<is_default_constructible<_T1>, _Dummy>::value && | |
| 100 | __dependent_type<is_default_constructible<_T2>, _Dummy>::value | |
| 101 | > | |
| 123 | 102 | > |
| 124 | _LIBCPP_INLINE_VISIBILITY | |
| 125 | _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} | |
| 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 104 | explicit __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} | |
| 126 | 105 | |
| 127 | 106 | template <class _U1, class _U2> |
| 128 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 129 | __compressed_pair(_U1&& __t1, _U2&& __t2) | |
| 130 | : _Base1(_VSTD::forward<_U1>(__t1)), _Base2(_VSTD::forward<_U2>(__t2)) {} | |
| 107 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 108 | explicit __compressed_pair(_U1&& __t1, _U2&& __t2) : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} | |
| 131 | 109 | |
| 132 | 110 | #ifndef _LIBCPP_CXX03_LANG |
| 133 | 111 | template <class... _Args1, class... _Args2> |
| 134 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 135 | __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, | |
| 136 | tuple<_Args2...> __second_args) | |
| 137 | : _Base1(__pc, _VSTD::move(__first_args), | |
| 138 | typename __make_tuple_indices<sizeof...(_Args1)>::type()), | |
| 139 | _Base2(__pc, _VSTD::move(__second_args), | |
| 140 | typename __make_tuple_indices<sizeof...(_Args2)>::type()) {} | |
| 112 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 113 | explicit __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, | |
| 114 | tuple<_Args2...> __second_args) | |
| 115 | : _Base1(__pc, std::move(__first_args), typename __make_tuple_indices<sizeof...(_Args1)>::type()), | |
| 116 | _Base2(__pc, std::move(__second_args), typename __make_tuple_indices<sizeof...(_Args2)>::type()) {} | |
| 141 | 117 | #endif |
| 142 | 118 | |
| 143 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base1::reference first() _NOEXCEPT { | |
| 119 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 120 | typename _Base1::reference first() _NOEXCEPT { | |
| 144 | 121 | return static_cast<_Base1&>(*this).__get(); |
| 145 | 122 | } |
| 146 | 123 | |
| 147 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base1::const_reference first() const _NOEXCEPT { | |
| 124 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 125 | typename _Base1::const_reference first() const _NOEXCEPT { | |
| 148 | 126 | return static_cast<_Base1 const&>(*this).__get(); |
| 149 | 127 | } |
| 150 | 128 | |
| 151 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename _Base2::reference second() _NOEXCEPT { | |
| 129 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 130 | typename _Base2::reference second() _NOEXCEPT { | |
| 152 | 131 | return static_cast<_Base2&>(*this).__get(); |
| 153 | 132 | } |
| 154 | 133 | |
| 155 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR typename _Base2::const_reference second() const _NOEXCEPT { | |
| 134 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 135 | typename _Base2::const_reference second() const _NOEXCEPT { | |
| 156 | 136 | return static_cast<_Base2 const&>(*this).__get(); |
| 157 | 137 | } |
| 158 | 138 | |
| 159 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 160 | static _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT { | |
| 139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static | |
| 140 | _Base1* __get_first_base(__compressed_pair* __pair) _NOEXCEPT { | |
| 161 | 141 | return static_cast<_Base1*>(__pair); |
| 162 | 142 | } |
| 163 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 164 | static _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT { | |
| 143 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static | |
| 144 | _Base2* __get_second_base(__compressed_pair* __pair) _NOEXCEPT { | |
| 165 | 145 | return static_cast<_Base2*>(__pair); |
| 166 | 146 | } |
| 167 | 147 | |
| 168 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 void swap(__compressed_pair& __x) | |
| 148 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 149 | void swap(__compressed_pair& __x) | |
| 169 | 150 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) { |
| 170 | using _VSTD::swap; | |
| 151 | using std::swap; | |
| 171 | 152 | swap(first(), __x.first()); |
| 172 | 153 | swap(second(), __x.second()); |
| 173 | 154 | } |
| 174 | 155 | }; |
| 175 | 156 | |
| 176 | 157 | template <class _T1, class _T2> |
| 177 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 158 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 178 | 159 | void swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y) |
| 179 | 160 | _NOEXCEPT_(__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value) { |
| 180 | 161 | __x.swap(__y); |
lib/libcxx/include/__memory/concepts.h+3-3| ... | ... | @@ -20,12 +20,12 @@ |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | 29 | |
| 30 | 30 | namespace ranges { |
| 31 | 31 | |
| ... | ... | @@ -61,7 +61,7 @@ concept __nothrow_forward_range = |
| 61 | 61 | |
| 62 | 62 | } // namespace ranges |
| 63 | 63 | |
| 64 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 64 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 65 | 65 | |
| 66 | 66 | _LIBCPP_END_NAMESPACE_STD |
| 67 | 67 |
lib/libcxx/include/__memory/construct_at.h+19-12| ... | ... | @@ -10,17 +10,17 @@ |
| 10 | 10 | #ifndef _LIBCPP___MEMORY_CONSTRUCT_AT_H |
| 11 | 11 | #define _LIBCPP___MEMORY_CONSTRUCT_AT_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <__iterator/access.h> |
| 16 | 16 | #include <__memory/addressof.h> |
| 17 | 17 | #include <__memory/voidify.h> |
| 18 | 18 | #include <__utility/forward.h> |
| 19 | #include <__utility/move.h> | |
| 19 | 20 | #include <type_traits> |
| 20 | #include <utility> | |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -29,17 +29,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 29 | |
| 30 | 30 | #if _LIBCPP_STD_VER > 17 |
| 31 | 31 | |
| 32 | template<class _Tp, class ..._Args, class = decltype( | |
| 33 | ::new (declval<void*>()) _Tp(declval<_Args>()...) | |
| 34 | )> | |
| 35 | _LIBCPP_HIDE_FROM_ABI | |
| 36 | constexpr _Tp* construct_at(_Tp* __location, _Args&& ...__args) { | |
| 37 | _LIBCPP_ASSERT(__location, "null pointer given to construct_at"); | |
| 38 | return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...); | |
| 32 | template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))> | |
| 33 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __args) { | |
| 34 | _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"); | |
| 35 | return ::new (_VSTD::__voidify(*__location)) _Tp(_VSTD::forward<_Args>(__args)...); | |
| 39 | 36 | } |
| 40 | 37 | |
| 41 | 38 | #endif |
| 42 | 39 | |
| 40 | template <class _Tp, class... _Args, class = decltype(::new(declval<void*>()) _Tp(declval<_Args>()...))> | |
| 41 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) { | |
| 42 | #if _LIBCPP_STD_VER > 17 | |
| 43 | return std::construct_at(__location, std::forward<_Args>(__args)...); | |
| 44 | #else | |
| 45 | return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"), | |
| 46 | ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...); | |
| 47 | #endif | |
| 48 | } | |
| 49 | ||
| 43 | 50 | // destroy_at |
| 44 | 51 | |
| 45 | 52 | // The internal functions are available regardless of the language version (with the exception of the `__destroy_at` |
| ... | ... | @@ -52,7 +59,7 @@ _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); |
| 52 | 59 | template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0> |
| 53 | 60 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 54 | 61 | void __destroy_at(_Tp* __loc) { |
| 55 | _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at"); | |
| 62 | _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at"); | |
| 56 | 63 | __loc->~_Tp(); |
| 57 | 64 | } |
| 58 | 65 | |
| ... | ... | @@ -60,7 +67,7 @@ void __destroy_at(_Tp* __loc) { |
| 60 | 67 | template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0> |
| 61 | 68 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 62 | 69 | void __destroy_at(_Tp* __loc) { |
| 63 | _LIBCPP_ASSERT(__loc, "null pointer given to destroy_at"); | |
| 70 | _LIBCPP_ASSERT(__loc != nullptr, "null pointer given to destroy_at"); | |
| 64 | 71 | _VSTD::__destroy(_VSTD::begin(*__loc), _VSTD::end(*__loc)); |
| 65 | 72 | } |
| 66 | 73 | #endif |
lib/libcxx/include/__memory/pointer_traits.h+5-6| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -71,13 +71,12 @@ template <class _Tp, class _Up> |
| 71 | 71 | struct __has_rebind |
| 72 | 72 | { |
| 73 | 73 | private: |
| 74 | struct __two {char __lx; char __lxx;}; | |
| 75 | template <class _Xp> static __two __test(...); | |
| 74 | template <class _Xp> static false_type __test(...); | |
| 76 | 75 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH |
| 77 | template <class _Xp> static char __test(typename _Xp::template rebind<_Up>* = 0); | |
| 76 | template <class _Xp> static true_type __test(typename _Xp::template rebind<_Up>* = 0); | |
| 78 | 77 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 79 | 78 | public: |
| 80 | static const bool value = sizeof(__test<_Tp>(0)) == 1; | |
| 79 | static const bool value = decltype(__test<_Tp>(0))::value; | |
| 81 | 80 | }; |
| 82 | 81 | |
| 83 | 82 | template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value> |
| ... | ... | @@ -123,7 +122,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits |
| 123 | 122 | private: |
| 124 | 123 | struct __nat {}; |
| 125 | 124 | public: |
| 126 | _LIBCPP_INLINE_VISIBILITY | |
| 125 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 127 | 126 | static pointer pointer_to(typename conditional<is_void<element_type>::value, |
| 128 | 127 | __nat, element_type>::type& __r) |
| 129 | 128 | {return pointer::pointer_to(__r);} |
lib/libcxx/include/__memory/ranges_construct_at.h+3-3| ... | ... | @@ -24,12 +24,12 @@ |
| 24 | 24 | #include <__utility/move.h> |
| 25 | 25 | |
| 26 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | #pragma GCC system_header | |
| 27 | # pragma GCC system_header | |
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | 33 | namespace ranges { |
| 34 | 34 | |
| 35 | 35 | // construct_at |
| ... | ... | @@ -117,7 +117,7 @@ inline namespace __cpo { |
| 117 | 117 | |
| 118 | 118 | } // namespace ranges |
| 119 | 119 | |
| 120 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 120 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 121 | 121 | |
| 122 | 122 | _LIBCPP_END_NAMESPACE_STD |
| 123 | 123 |
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+3-3| ... | ... | @@ -27,12 +27,12 @@ |
| 27 | 27 | #include <type_traits> |
| 28 | 28 | |
| 29 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 30 | #pragma GCC system_header | |
| 30 | # pragma GCC system_header | |
| 31 | 31 | #endif |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | 38 | |
| ... | ... | @@ -311,7 +311,7 @@ inline namespace __cpo { |
| 311 | 311 | |
| 312 | 312 | } // namespace ranges |
| 313 | 313 | |
| 314 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 314 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 315 | 315 | |
| 316 | 316 | _LIBCPP_END_NAMESPACE_STD |
| 317 | 317 |
lib/libcxx/include/__memory/raw_storage_iterator.h+4-3| ... | ... | @@ -11,13 +11,14 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__iterator/iterator.h> | |
| 15 | #include <__iterator/iterator_traits.h> | |
| 14 | 16 | #include <__memory/addressof.h> |
| 17 | #include <__utility/move.h> | |
| 15 | 18 | #include <cstddef> |
| 16 | #include <iterator> | |
| 17 | #include <utility> | |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__memory/shared_ptr.h+236-41| ... | ... | @@ -15,32 +15,33 @@ |
| 15 | 15 | #include <__functional/binary_function.h> |
| 16 | 16 | #include <__functional/operations.h> |
| 17 | 17 | #include <__functional/reference_wrapper.h> |
| 18 | #include <__functional_base> | |
| 18 | #include <__iterator/access.h> | |
| 19 | 19 | #include <__memory/addressof.h> |
| 20 | 20 | #include <__memory/allocation_guard.h> |
| 21 | 21 | #include <__memory/allocator.h> |
| 22 | 22 | #include <__memory/allocator_traits.h> |
| 23 | #include <__memory/auto_ptr.h> | |
| 23 | 24 | #include <__memory/compressed_pair.h> |
| 25 | #include <__memory/construct_at.h> | |
| 24 | 26 | #include <__memory/pointer_traits.h> |
| 27 | #include <__memory/uninitialized_algorithms.h> | |
| 25 | 28 | #include <__memory/unique_ptr.h> |
| 26 | 29 | #include <__utility/forward.h> |
| 30 | #include <__utility/move.h> | |
| 31 | #include <__utility/swap.h> | |
| 27 | 32 | #include <cstddef> |
| 28 | 33 | #include <cstdlib> // abort |
| 29 | 34 | #include <iosfwd> |
| 30 | 35 | #include <stdexcept> |
| 31 | 36 | #include <type_traits> |
| 32 | 37 | #include <typeinfo> |
| 33 | #include <utility> | |
| 34 | 38 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
| 35 | 39 | # include <atomic> |
| 36 | 40 | #endif |
| 37 | 41 | |
| 38 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 39 | # include <__memory/auto_ptr.h> | |
| 40 | #endif | |
| 41 | 42 | |
| 42 | 43 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 43 | #pragma GCC system_header | |
| 44 | # pragma GCC system_header | |
| 44 | 45 | #endif |
| 45 | 46 | |
| 46 | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -159,10 +160,9 @@ public: |
| 159 | 160 | explicit __shared_count(long __refs = 0) _NOEXCEPT |
| 160 | 161 | : __shared_owners_(__refs) {} |
| 161 | 162 | |
| 162 | #if defined(_LIBCPP_BUILDING_LIBRARY) && \ | |
| 163 | defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) | |
| 164 | void __add_shared() _NOEXCEPT; | |
| 165 | bool __release_shared() _NOEXCEPT; | |
| 163 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 164 | void __add_shared() noexcept; | |
| 165 | bool __release_shared() noexcept; | |
| 166 | 166 | #else |
| 167 | 167 | _LIBCPP_INLINE_VISIBILITY |
| 168 | 168 | void __add_shared() _NOEXCEPT { |
| ... | ... | @@ -197,11 +197,10 @@ protected: |
| 197 | 197 | virtual ~__shared_weak_count(); |
| 198 | 198 | |
| 199 | 199 | public: |
| 200 | #if defined(_LIBCPP_BUILDING_LIBRARY) && \ | |
| 201 | defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) | |
| 202 | void __add_shared() _NOEXCEPT; | |
| 203 | void __add_weak() _NOEXCEPT; | |
| 204 | void __release_shared() _NOEXCEPT; | |
| 200 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 201 | void __add_shared() noexcept; | |
| 202 | void __add_weak() noexcept; | |
| 203 | void __release_shared() noexcept; | |
| 205 | 204 | #else |
| 206 | 205 | _LIBCPP_INLINE_VISIBILITY |
| 207 | 206 | void __add_shared() _NOEXCEPT { |
| ... | ... | @@ -457,7 +456,7 @@ public: |
| 457 | 456 | explicit shared_ptr(_Yp* __p) : __ptr_(__p) { |
| 458 | 457 | unique_ptr<_Yp> __hold(__p); |
| 459 | 458 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| 460 | typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT > _CntrlBlk; | |
| 459 | typedef __shared_ptr_pointer<_Yp*, __shared_ptr_default_delete<_Tp, _Yp>, _AllocT> _CntrlBlk; | |
| 461 | 460 | __cntrl_ = new _CntrlBlk(__p, __shared_ptr_default_delete<_Tp, _Yp>(), _AllocT()); |
| 462 | 461 | __hold.release(); |
| 463 | 462 | __enable_weak_this(__p, __p); |
| ... | ... | @@ -473,7 +472,7 @@ public: |
| 473 | 472 | { |
| 474 | 473 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 475 | 474 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| 476 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk; | |
| 475 | typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk; | |
| 477 | 476 | #ifndef _LIBCPP_CXX03_LANG |
| 478 | 477 | __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); |
| 479 | 478 | #else |
| ... | ... | @@ -532,7 +531,7 @@ public: |
| 532 | 531 | { |
| 533 | 532 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 534 | 533 | typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; |
| 535 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT > _CntrlBlk; | |
| 534 | typedef __shared_ptr_pointer<nullptr_t, _Dp, _AllocT> _CntrlBlk; | |
| 536 | 535 | #ifndef _LIBCPP_CXX03_LANG |
| 537 | 536 | __cntrl_ = new _CntrlBlk(__p, _VSTD::move(__d), _AllocT()); |
| 538 | 537 | #else |
| ... | ... | @@ -665,8 +664,8 @@ public: |
| 665 | 664 | #endif |
| 666 | 665 | { |
| 667 | 666 | 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()); | |
| 667 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, _Dp, _AllocT> _CntrlBlk; | |
| 668 | __cntrl_ = new _CntrlBlk(__r.get(), std::move(__r.get_deleter()), _AllocT()); | |
| 670 | 669 | __enable_weak_this(__r.get(), __r.get()); |
| 671 | 670 | } |
| 672 | 671 | __r.release(); |
| ... | ... | @@ -689,7 +688,7 @@ public: |
| 689 | 688 | typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; |
| 690 | 689 | typedef __shared_ptr_pointer<typename unique_ptr<_Yp, _Dp>::pointer, |
| 691 | 690 | reference_wrapper<typename remove_reference<_Dp>::type>, |
| 692 | _AllocT > _CntrlBlk; | |
| 691 | _AllocT> _CntrlBlk; | |
| 693 | 692 | __cntrl_ = new _CntrlBlk(__r.get(), _VSTD::ref(__r.get_deleter()), _AllocT()); |
| 694 | 693 | __enable_weak_this(__r.get(), __r.get()); |
| 695 | 694 | } |
| ... | ... | @@ -963,6 +962,220 @@ shared_ptr<_Tp> make_shared(_Args&& ...__args) |
| 963 | 962 | return _VSTD::allocate_shared<_Tp>(allocator<_Tp>(), _VSTD::forward<_Args>(__args)...); |
| 964 | 963 | } |
| 965 | 964 | |
| 965 | #if _LIBCPP_STD_VER > 14 | |
| 966 | ||
| 967 | template <size_t _Alignment> | |
| 968 | struct __sp_aligned_storage { | |
| 969 | alignas(_Alignment) char __storage[_Alignment]; | |
| 970 | }; | |
| 971 | ||
| 972 | template <class _Tp, class _Alloc> | |
| 973 | struct __unbounded_array_control_block; | |
| 974 | ||
| 975 | template <class _Tp, class _Alloc> | |
| 976 | struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count | |
| 977 | { | |
| 978 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 979 | _Tp* __get_data() noexcept { return __data_; } | |
| 980 | ||
| 981 | _LIBCPP_HIDE_FROM_ABI | |
| 982 | explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count, _Tp const& __arg) | |
| 983 | : __alloc_(__alloc), __count_(__count) | |
| 984 | { | |
| 985 | std::__uninitialized_allocator_fill_n(__alloc_, std::begin(__data_), __count_, __arg); | |
| 986 | } | |
| 987 | ||
| 988 | _LIBCPP_HIDE_FROM_ABI | |
| 989 | explicit __unbounded_array_control_block(_Alloc const& __alloc, size_t __count) | |
| 990 | : __alloc_(__alloc), __count_(__count) | |
| 991 | { | |
| 992 | std::__uninitialized_allocator_value_construct_n(__alloc_, std::begin(__data_), __count_); | |
| 993 | } | |
| 994 | ||
| 995 | // Returns the number of bytes required to store a control block followed by the given number | |
| 996 | // of elements of _Tp, with the whole storage being aligned to a multiple of _Tp's alignment. | |
| 997 | _LIBCPP_HIDE_FROM_ABI | |
| 998 | static constexpr size_t __bytes_for(size_t __elements) { | |
| 999 | // When there's 0 elements, the control block alone is enough since it holds one element. | |
| 1000 | // Otherwise, we allocate one fewer element than requested because the control block already | |
| 1001 | // holds one. Also, we use the bitwise formula below to ensure that we allocate enough bytes | |
| 1002 | // for the whole allocation to be a multiple of _Tp's alignment. That formula is taken from [1]. | |
| 1003 | // | |
| 1004 | // [1]: https://en.wikipedia.org/wiki/Data_structure_alignment#Computing_padding | |
| 1005 | size_t __bytes = __elements == 0 ? sizeof(__unbounded_array_control_block) | |
| 1006 | : (__elements - 1) * sizeof(_Tp) + sizeof(__unbounded_array_control_block); | |
| 1007 | constexpr size_t __align = alignof(_Tp); | |
| 1008 | return (__bytes + __align - 1) & ~(__align - 1); | |
| 1009 | } | |
| 1010 | ||
| 1011 | _LIBCPP_HIDE_FROM_ABI | |
| 1012 | ~__unbounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_ | |
| 1013 | ||
| 1014 | private: | |
| 1015 | void __on_zero_shared() _NOEXCEPT override { | |
| 1016 | __allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_); | |
| 1017 | std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + __count_); | |
| 1018 | } | |
| 1019 | ||
| 1020 | void __on_zero_shared_weak() _NOEXCEPT override { | |
| 1021 | using _AlignedStorage = __sp_aligned_storage<alignof(__unbounded_array_control_block)>; | |
| 1022 | using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>; | |
| 1023 | using _PointerTraits = pointer_traits<typename allocator_traits<_StorageAlloc>::pointer>; | |
| 1024 | ||
| 1025 | _StorageAlloc __tmp(__alloc_); | |
| 1026 | __alloc_.~_Alloc(); | |
| 1027 | size_t __size = __unbounded_array_control_block::__bytes_for(__count_); | |
| 1028 | _AlignedStorage* __storage = reinterpret_cast<_AlignedStorage*>(this); | |
| 1029 | allocator_traits<_StorageAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*__storage), __size); | |
| 1030 | } | |
| 1031 | ||
| 1032 | _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_; | |
| 1033 | size_t __count_; | |
| 1034 | union { | |
| 1035 | _Tp __data_[1]; | |
| 1036 | }; | |
| 1037 | }; | |
| 1038 | ||
| 1039 | template<class _Array, class _Alloc, class... _Arg> | |
| 1040 | _LIBCPP_HIDE_FROM_ABI | |
| 1041 | shared_ptr<_Array> __allocate_shared_unbounded_array(const _Alloc& __a, size_t __n, _Arg&& ...__arg) | |
| 1042 | { | |
| 1043 | static_assert(__libcpp_is_unbounded_array<_Array>::value); | |
| 1044 | // We compute the number of bytes necessary to hold the control block and the | |
| 1045 | // array elements. Then, we allocate an array of properly-aligned dummy structs | |
| 1046 | // large enough to hold the control block and array. This allows shifting the | |
| 1047 | // burden of aligning memory properly from us to the allocator. | |
| 1048 | using _ControlBlock = __unbounded_array_control_block<_Array, _Alloc>; | |
| 1049 | using _AlignedStorage = __sp_aligned_storage<alignof(_ControlBlock)>; | |
| 1050 | using _StorageAlloc = __allocator_traits_rebind_t<_Alloc, _AlignedStorage>; | |
| 1051 | __allocation_guard<_StorageAlloc> __guard(__a, _ControlBlock::__bytes_for(__n) / sizeof(_AlignedStorage)); | |
| 1052 | _ControlBlock* __control_block = reinterpret_cast<_ControlBlock*>(std::addressof(*__guard.__get())); | |
| 1053 | std::__construct_at(__control_block, __a, __n, std::forward<_Arg>(__arg)...); | |
| 1054 | __guard.__release_ptr(); | |
| 1055 | return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block); | |
| 1056 | } | |
| 1057 | ||
| 1058 | template <class _Tp, class _Alloc> | |
| 1059 | struct __bounded_array_control_block; | |
| 1060 | ||
| 1061 | template <class _Tp, size_t _Count, class _Alloc> | |
| 1062 | struct __bounded_array_control_block<_Tp[_Count], _Alloc> | |
| 1063 | : __shared_weak_count | |
| 1064 | { | |
| 1065 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1066 | _Tp* __get_data() noexcept { return __data_; } | |
| 1067 | ||
| 1068 | _LIBCPP_HIDE_FROM_ABI | |
| 1069 | explicit __bounded_array_control_block(_Alloc const& __alloc, _Tp const& __arg) : __alloc_(__alloc) { | |
| 1070 | std::__uninitialized_allocator_fill_n(__alloc_, std::addressof(__data_[0]), _Count, __arg); | |
| 1071 | } | |
| 1072 | ||
| 1073 | _LIBCPP_HIDE_FROM_ABI | |
| 1074 | explicit __bounded_array_control_block(_Alloc const& __alloc) : __alloc_(__alloc) { | |
| 1075 | std::__uninitialized_allocator_value_construct_n(__alloc_, std::addressof(__data_[0]), _Count); | |
| 1076 | } | |
| 1077 | ||
| 1078 | _LIBCPP_HIDE_FROM_ABI | |
| 1079 | ~__bounded_array_control_block() override { } // can't be `= default` because of the sometimes-non-trivial union member __data_ | |
| 1080 | ||
| 1081 | private: | |
| 1082 | void __on_zero_shared() _NOEXCEPT override { | |
| 1083 | __allocator_traits_rebind_t<_Alloc, _Tp> __value_alloc(__alloc_); | |
| 1084 | std::__allocator_destroy_multidimensional(__value_alloc, __data_, __data_ + _Count); | |
| 1085 | } | |
| 1086 | ||
| 1087 | void __on_zero_shared_weak() _NOEXCEPT override { | |
| 1088 | using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, __bounded_array_control_block>; | |
| 1089 | using _PointerTraits = pointer_traits<typename allocator_traits<_ControlBlockAlloc>::pointer>; | |
| 1090 | ||
| 1091 | _ControlBlockAlloc __tmp(__alloc_); | |
| 1092 | __alloc_.~_Alloc(); | |
| 1093 | allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, _PointerTraits::pointer_to(*this), sizeof(*this)); | |
| 1094 | } | |
| 1095 | ||
| 1096 | _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_; | |
| 1097 | union { | |
| 1098 | _Tp __data_[_Count]; | |
| 1099 | }; | |
| 1100 | }; | |
| 1101 | ||
| 1102 | template<class _Array, class _Alloc, class... _Arg> | |
| 1103 | _LIBCPP_HIDE_FROM_ABI | |
| 1104 | shared_ptr<_Array> __allocate_shared_bounded_array(const _Alloc& __a, _Arg&& ...__arg) | |
| 1105 | { | |
| 1106 | static_assert(__libcpp_is_bounded_array<_Array>::value); | |
| 1107 | using _ControlBlock = __bounded_array_control_block<_Array, _Alloc>; | |
| 1108 | using _ControlBlockAlloc = __allocator_traits_rebind_t<_Alloc, _ControlBlock>; | |
| 1109 | ||
| 1110 | __allocation_guard<_ControlBlockAlloc> __guard(__a, 1); | |
| 1111 | _ControlBlock* __control_block = reinterpret_cast<_ControlBlock*>(std::addressof(*__guard.__get())); | |
| 1112 | std::__construct_at(__control_block, __a, std::forward<_Arg>(__arg)...); | |
| 1113 | __guard.__release_ptr(); | |
| 1114 | return shared_ptr<_Array>::__create_with_control_block(__control_block->__get_data(), __control_block); | |
| 1115 | } | |
| 1116 | ||
| 1117 | #endif // _LIBCPP_STD_VER > 14 | |
| 1118 | ||
| 1119 | #if _LIBCPP_STD_VER > 17 | |
| 1120 | ||
| 1121 | template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>> | |
| 1122 | _LIBCPP_HIDE_FROM_ABI | |
| 1123 | shared_ptr<_Tp> allocate_shared(const _Alloc& __a) | |
| 1124 | { | |
| 1125 | return std::__allocate_shared_bounded_array<_Tp>(__a); | |
| 1126 | } | |
| 1127 | ||
| 1128 | template<class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>> | |
| 1129 | _LIBCPP_HIDE_FROM_ABI | |
| 1130 | shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) | |
| 1131 | { | |
| 1132 | return std::__allocate_shared_bounded_array<_Tp>(__a, __u); | |
| 1133 | } | |
| 1134 | ||
| 1135 | template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | |
| 1136 | _LIBCPP_HIDE_FROM_ABI | |
| 1137 | shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) | |
| 1138 | { | |
| 1139 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n); | |
| 1140 | } | |
| 1141 | ||
| 1142 | template<class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | |
| 1143 | _LIBCPP_HIDE_FROM_ABI | |
| 1144 | shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) | |
| 1145 | { | |
| 1146 | return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u); | |
| 1147 | } | |
| 1148 | ||
| 1149 | template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>> | |
| 1150 | _LIBCPP_HIDE_FROM_ABI | |
| 1151 | shared_ptr<_Tp> make_shared() | |
| 1152 | { | |
| 1153 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>()); | |
| 1154 | } | |
| 1155 | ||
| 1156 | template<class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>> | |
| 1157 | _LIBCPP_HIDE_FROM_ABI | |
| 1158 | shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) | |
| 1159 | { | |
| 1160 | return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u); | |
| 1161 | } | |
| 1162 | ||
| 1163 | template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | |
| 1164 | _LIBCPP_HIDE_FROM_ABI | |
| 1165 | shared_ptr<_Tp> make_shared(size_t __n) | |
| 1166 | { | |
| 1167 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n); | |
| 1168 | } | |
| 1169 | ||
| 1170 | template<class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>> | |
| 1171 | _LIBCPP_HIDE_FROM_ABI | |
| 1172 | shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) | |
| 1173 | { | |
| 1174 | return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u); | |
| 1175 | } | |
| 1176 | ||
| 1177 | #endif // _LIBCPP_STD_VER > 17 | |
| 1178 | ||
| 966 | 1179 | template<class _Tp, class _Up> |
| 967 | 1180 | inline _LIBCPP_INLINE_VISIBILITY |
| 968 | 1181 | bool |
| ... | ... | @@ -1442,19 +1655,10 @@ template <class _Tp> struct owner_less; |
| 1442 | 1655 | #endif |
| 1443 | 1656 | |
| 1444 | 1657 | |
| 1445 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 1446 | 1658 | template <class _Tp> |
| 1447 | 1659 | struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > |
| 1448 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 1449 | : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> | |
| 1450 | #endif | |
| 1660 | : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> | |
| 1451 | 1661 | { |
| 1452 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 1453 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 1454 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 1455 | _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> first_argument_type; | |
| 1456 | _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> second_argument_type; | |
| 1457 | #endif | |
| 1458 | 1662 | _LIBCPP_INLINE_VISIBILITY |
| 1459 | 1663 | bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT |
| 1460 | 1664 | {return __x.owner_before(__y);} |
| ... | ... | @@ -1466,19 +1670,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 1466 | 1670 | {return __x.owner_before(__y);} |
| 1467 | 1671 | }; |
| 1468 | 1672 | |
| 1469 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 1470 | 1673 | template <class _Tp> |
| 1471 | 1674 | struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > |
| 1472 | #if !defined(_LIBCPP_ABI_NO_BINDER_BASES) | |
| 1473 | : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> | |
| 1474 | #endif | |
| 1675 | : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> | |
| 1475 | 1676 | { |
| 1476 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 1477 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 1478 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 1479 | _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> first_argument_type; | |
| 1480 | _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> second_argument_type; | |
| 1481 | #endif | |
| 1482 | 1677 | _LIBCPP_INLINE_VISIBILITY |
| 1483 | 1678 | bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT |
| 1484 | 1679 | {return __x.owner_before(__y);} |
lib/libcxx/include/__memory/swap_allocator.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___MEMORY_SWAP_ALLOCATOR_H | |
| 10 | #define _LIBCPP___MEMORY_SWAP_ALLOCATOR_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__memory/allocator_traits.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__utility/swap.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <typename _Alloc> | |
| 24 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2, true_type) | |
| 25 | #if _LIBCPP_STD_VER > 11 | |
| 26 | _NOEXCEPT | |
| 27 | #else | |
| 28 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) | |
| 29 | #endif | |
| 30 | { | |
| 31 | using _VSTD::swap; | |
| 32 | swap(__a1, __a2); | |
| 33 | } | |
| 34 | ||
| 35 | template <typename _Alloc> | |
| 36 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void | |
| 37 | __swap_allocator(_Alloc&, _Alloc&, false_type) _NOEXCEPT {} | |
| 38 | ||
| 39 | template <typename _Alloc> | |
| 40 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void __swap_allocator(_Alloc& __a1, _Alloc& __a2) | |
| 41 | #if _LIBCPP_STD_VER > 11 | |
| 42 | _NOEXCEPT | |
| 43 | #else | |
| 44 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) | |
| 45 | #endif | |
| 46 | { | |
| 47 | _VSTD::__swap_allocator( | |
| 48 | __a1, __a2, integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>()); | |
| 49 | } | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___MEMORY_SWAP_ALLOCATOR_H |
lib/libcxx/include/__memory/temporary_buffer.h+7-4| ... | ... | @@ -11,18 +11,19 @@ |
| 11 | 11 | #define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__type_traits/alignment_of.h> | |
| 15 | #include <__utility/pair.h> | |
| 14 | 16 | #include <cstddef> |
| 15 | 17 | #include <new> |
| 16 | #include <utility> // pair | |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 24 | |
| 24 | 25 | template <class _Tp> |
| 25 | _LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI | |
| 26 | _LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 | |
| 26 | 27 | pair<_Tp*, ptrdiff_t> |
| 27 | 28 | get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT |
| 28 | 29 | { |
| ... | ... | @@ -67,7 +68,7 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | 70 | template <class _Tp> |
| 70 | inline _LIBCPP_INLINE_VISIBILITY | |
| 71 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17 | |
| 71 | 72 | void return_temporary_buffer(_Tp* __p) _NOEXCEPT |
| 72 | 73 | { |
| 73 | 74 | _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp)); |
| ... | ... | @@ -75,8 +76,10 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT |
| 75 | 76 | |
| 76 | 77 | struct __return_temporary_buffer |
| 77 | 78 | { |
| 79 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 78 | 80 | template <class _Tp> |
| 79 | 81 | _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);} |
| 82 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 80 | 83 | }; |
| 81 | 84 | |
| 82 | 85 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__memory/uninitialized_algorithms.h+295-3| ... | ... | @@ -10,15 +10,24 @@ |
| 10 | 10 | #ifndef _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H |
| 11 | 11 | #define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H |
| 12 | 12 | |
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/move.h> | |
| 13 | 15 | #include <__config> |
| 16 | #include <__iterator/iterator_traits.h> | |
| 17 | #include <__iterator/reverse_iterator.h> | |
| 14 | 18 | #include <__memory/addressof.h> |
| 19 | #include <__memory/allocator_traits.h> | |
| 15 | 20 | #include <__memory/construct_at.h> |
| 21 | #include <__memory/pointer_traits.h> | |
| 16 | 22 | #include <__memory/voidify.h> |
| 17 | #include <iterator> | |
| 18 | #include <utility> | |
| 23 | #include <__type_traits/is_constant_evaluated.h> | |
| 24 | #include <__utility/move.h> | |
| 25 | #include <__utility/pair.h> | |
| 26 | #include <__utility/transaction.h> | |
| 27 | #include <type_traits> | |
| 19 | 28 | |
| 20 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 30 | # pragma GCC system_header | |
| 22 | 31 | #endif |
| 23 | 32 | |
| 24 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -343,8 +352,291 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir |
| 343 | 352 | __unreachable_sentinel(), __iter_move); |
| 344 | 353 | } |
| 345 | 354 | |
| 355 | // TODO: Rewrite this to iterate left to right and use reverse_iterators when calling | |
| 356 | // Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator | |
| 357 | // destruction. If elements are themselves C-style arrays, they are recursively destroyed | |
| 358 | // in the same manner. | |
| 359 | // | |
| 360 | // This function assumes that destructors do not throw, and that the allocator is bound to | |
| 361 | // the correct type. | |
| 362 | template<class _Alloc, class _BidirIter, class = __enable_if_t< | |
| 363 | __is_cpp17_bidirectional_iterator<_BidirIter>::value | |
| 364 | >> | |
| 365 | _LIBCPP_HIDE_FROM_ABI | |
| 366 | constexpr void __allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept { | |
| 367 | using _ValueType = typename iterator_traits<_BidirIter>::value_type; | |
| 368 | static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _ValueType>, | |
| 369 | "The allocator should already be rebound to the correct type"); | |
| 370 | ||
| 371 | if (__first == __last) | |
| 372 | return; | |
| 373 | ||
| 374 | if constexpr (is_array_v<_ValueType>) { | |
| 375 | static_assert(!__libcpp_is_unbounded_array<_ValueType>::value, | |
| 376 | "arrays of unbounded arrays don't exist, but if they did we would mess up here"); | |
| 377 | ||
| 378 | using _Element = remove_extent_t<_ValueType>; | |
| 379 | __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc); | |
| 380 | do { | |
| 381 | --__last; | |
| 382 | decltype(auto) __array = *__last; | |
| 383 | std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + extent_v<_ValueType>); | |
| 384 | } while (__last != __first); | |
| 385 | } else { | |
| 386 | do { | |
| 387 | --__last; | |
| 388 | allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__last)); | |
| 389 | } while (__last != __first); | |
| 390 | } | |
| 391 | } | |
| 392 | ||
| 393 | // Constructs the object at the given location using the allocator's construct method. | |
| 394 | // | |
| 395 | // If the object being constructed is an array, each element of the array is allocator-constructed, | |
| 396 | // recursively. If an exception is thrown during the construction of an array, the initialized | |
| 397 | // elements are destroyed in reverse order of initialization using allocator destruction. | |
| 398 | // | |
| 399 | // This function assumes that the allocator is bound to the correct type. | |
| 400 | template<class _Alloc, class _Tp> | |
| 401 | _LIBCPP_HIDE_FROM_ABI | |
| 402 | constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc) { | |
| 403 | static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>, | |
| 404 | "The allocator should already be rebound to the correct type"); | |
| 405 | ||
| 406 | if constexpr (is_array_v<_Tp>) { | |
| 407 | using _Element = remove_extent_t<_Tp>; | |
| 408 | __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc); | |
| 409 | size_t __i = 0; | |
| 410 | _Tp& __array = *__loc; | |
| 411 | ||
| 412 | // If an exception is thrown, destroy what we have constructed so far in reverse order. | |
| 413 | __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); }); | |
| 414 | for (; __i != extent_v<_Tp>; ++__i) { | |
| 415 | std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i])); | |
| 416 | } | |
| 417 | __guard.__complete(); | |
| 418 | } else { | |
| 419 | allocator_traits<_Alloc>::construct(__alloc, __loc); | |
| 420 | } | |
| 421 | } | |
| 422 | ||
| 423 | // Constructs the object at the given location using the allocator's construct method, passing along | |
| 424 | // the provided argument. | |
| 425 | // | |
| 426 | // If the object being constructed is an array, the argument is also assumed to be an array. Each | |
| 427 | // each element of the array being constructed is allocator-constructed from the corresponding | |
| 428 | // element of the argument array. If an exception is thrown during the construction of an array, | |
| 429 | // the initialized elements are destroyed in reverse order of initialization using allocator | |
| 430 | // destruction. | |
| 431 | // | |
| 432 | // This function assumes that the allocator is bound to the correct type. | |
| 433 | template<class _Alloc, class _Tp, class _Arg> | |
| 434 | _LIBCPP_HIDE_FROM_ABI | |
| 435 | constexpr void __allocator_construct_at(_Alloc& __alloc, _Tp* __loc, _Arg const& __arg) { | |
| 436 | static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>, | |
| 437 | "The allocator should already be rebound to the correct type"); | |
| 438 | ||
| 439 | if constexpr (is_array_v<_Tp>) { | |
| 440 | static_assert(is_array_v<_Arg>, | |
| 441 | "Provided non-array initialization argument to __allocator_construct_at when " | |
| 442 | "trying to construct an array."); | |
| 443 | ||
| 444 | using _Element = remove_extent_t<_Tp>; | |
| 445 | __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc); | |
| 446 | size_t __i = 0; | |
| 447 | _Tp& __array = *__loc; | |
| 448 | ||
| 449 | // If an exception is thrown, destroy what we have constructed so far in reverse order. | |
| 450 | __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i); }); | |
| 451 | for (; __i != extent_v<_Tp>; ++__i) { | |
| 452 | std::__allocator_construct_at(__elem_alloc, std::addressof(__array[__i]), __arg[__i]); | |
| 453 | } | |
| 454 | __guard.__complete(); | |
| 455 | } else { | |
| 456 | allocator_traits<_Alloc>::construct(__alloc, __loc, __arg); | |
| 457 | } | |
| 458 | } | |
| 459 | ||
| 460 | // Given a range starting at it and containing n elements, initializes each element in the | |
| 461 | // range from left to right using the construct method of the allocator (rebound to the | |
| 462 | // correct type). | |
| 463 | // | |
| 464 | // If an exception is thrown, the initialized elements are destroyed in reverse order of | |
| 465 | // initialization using allocator_traits destruction. If the elements in the range are C-style | |
| 466 | // arrays, they are initialized element-wise using allocator construction, and recursively so. | |
| 467 | template<class _Alloc, class _BidirIter, class _Tp, class _Size = typename iterator_traits<_BidirIter>::difference_type> | |
| 468 | _LIBCPP_HIDE_FROM_ABI | |
| 469 | constexpr void __uninitialized_allocator_fill_n(_Alloc& __alloc, _BidirIter __it, _Size __n, _Tp const& __value) { | |
| 470 | using _ValueType = typename iterator_traits<_BidirIter>::value_type; | |
| 471 | __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc); | |
| 472 | _BidirIter __begin = __it; | |
| 473 | ||
| 474 | // If an exception is thrown, destroy what we have constructed so far in reverse order. | |
| 475 | __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); }); | |
| 476 | for (; __n != 0; --__n, ++__it) { | |
| 477 | std::__allocator_construct_at(__value_alloc, std::addressof(*__it), __value); | |
| 478 | } | |
| 479 | __guard.__complete(); | |
| 480 | } | |
| 481 | ||
| 482 | // Same as __uninitialized_allocator_fill_n, but doesn't pass any initialization argument | |
| 483 | // to the allocator's construct method, which results in value initialization. | |
| 484 | template<class _Alloc, class _BidirIter, class _Size = typename iterator_traits<_BidirIter>::difference_type> | |
| 485 | _LIBCPP_HIDE_FROM_ABI | |
| 486 | constexpr void __uninitialized_allocator_value_construct_n(_Alloc& __alloc, _BidirIter __it, _Size __n) { | |
| 487 | using _ValueType = typename iterator_traits<_BidirIter>::value_type; | |
| 488 | __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc); | |
| 489 | _BidirIter __begin = __it; | |
| 490 | ||
| 491 | // If an exception is thrown, destroy what we have constructed so far in reverse order. | |
| 492 | __transaction __guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); }); | |
| 493 | for (; __n != 0; --__n, ++__it) { | |
| 494 | std::__allocator_construct_at(__value_alloc, std::addressof(*__it)); | |
| 495 | } | |
| 496 | __guard.__complete(); | |
| 497 | } | |
| 498 | ||
| 346 | 499 | #endif // _LIBCPP_STD_VER > 14 |
| 347 | 500 | |
| 501 | // Destroy all elements in [__first, __last) from left to right using allocator destruction. | |
| 502 | template <class _Alloc, class _Iter, class _Sent> | |
| 503 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 504 | __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) { | |
| 505 | for (; __first != __last; ++__first) | |
| 506 | allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first)); | |
| 507 | } | |
| 508 | ||
| 509 | template <class _Alloc, class _Iter> | |
| 510 | class _AllocatorDestroyRangeReverse { | |
| 511 | public: | |
| 512 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 513 | _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last) | |
| 514 | : __alloc_(__alloc), __first_(__first), __last_(__last) {} | |
| 515 | ||
| 516 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const { | |
| 517 | std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_)); | |
| 518 | } | |
| 519 | ||
| 520 | private: | |
| 521 | _Alloc& __alloc_; | |
| 522 | _Iter& __first_; | |
| 523 | _Iter& __last_; | |
| 524 | }; | |
| 525 | ||
| 526 | // Copy-construct [__first1, __last1) in [__first2, __first2 + N), where N is distance(__first1, __last1). | |
| 527 | // | |
| 528 | // The caller has to ensure that __first2 can hold at least N uninitialized elements. If an exception is thrown the | |
| 529 | // already copied elements are destroyed in reverse order of their construction. | |
| 530 | template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> | |
| 531 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 | |
| 532 | __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { | |
| 533 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 534 | auto __destruct_first = __first2; | |
| 535 | try { | |
| 536 | #endif | |
| 537 | while (__first1 != __last1) { | |
| 538 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), *__first1); | |
| 539 | ++__first1; | |
| 540 | ++__first2; | |
| 541 | } | |
| 542 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 543 | } catch (...) { | |
| 544 | _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)(); | |
| 545 | throw; | |
| 546 | } | |
| 547 | #endif | |
| 548 | return __first2; | |
| 549 | } | |
| 550 | ||
| 551 | template <class _Alloc, class _Type> | |
| 552 | struct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {}; | |
| 553 | ||
| 554 | template <class _Type> | |
| 555 | struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {}; | |
| 556 | ||
| 557 | template <class _Alloc, | |
| 558 | class _Type, | |
| 559 | class _RawType = typename remove_const<_Type>::type, | |
| 560 | __enable_if_t< | |
| 561 | // using _RawType because of the allocator<T const> extension | |
| 562 | is_trivially_copy_constructible<_RawType>::value && is_trivially_copy_assignable<_RawType>::value && | |
| 563 | __allocator_has_trivial_copy_construct<_Alloc, _RawType>::value>* = nullptr> | |
| 564 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Type* | |
| 565 | __uninitialized_allocator_copy(_Alloc&, const _Type* __first1, const _Type* __last1, _Type* __first2) { | |
| 566 | // TODO: Remove the const_cast once we drop support for std::allocator<T const> | |
| 567 | if (__libcpp_is_constant_evaluated()) { | |
| 568 | while (__first1 != __last1) { | |
| 569 | std::__construct_at(std::__to_address(__first2), *__first1); | |
| 570 | ++__first1; | |
| 571 | ++__first2; | |
| 572 | } | |
| 573 | return __first2; | |
| 574 | } else { | |
| 575 | return std::copy(__first1, __last1, const_cast<_RawType*>(__first2)); | |
| 576 | } | |
| 577 | } | |
| 578 | ||
| 579 | // Move-construct the elements [__first1, __last1) into [__first2, __first2 + N) | |
| 580 | // if the move constructor is noexcept, where N is distance(__first1, __last1). | |
| 581 | // | |
| 582 | // Otherwise try to copy all elements. If an exception is thrown the already copied | |
| 583 | // elements are destroyed in reverse order of their construction. | |
| 584 | template <class _Alloc, class _Iter1, class _Sent1, class _Iter2> | |
| 585 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 __uninitialized_allocator_move_if_noexcept( | |
| 586 | _Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) { | |
| 587 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, | |
| 588 | "The specified type does not meet the requirements of Cpp17MoveInsertable"); | |
| 589 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 590 | auto __destruct_first = __first2; | |
| 591 | try { | |
| 592 | #endif | |
| 593 | while (__first1 != __last1) { | |
| 594 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 595 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1)); | |
| 596 | #else | |
| 597 | allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1)); | |
| 598 | #endif | |
| 599 | ++__first1; | |
| 600 | ++__first2; | |
| 601 | } | |
| 602 | #ifndef _LIBCPP_NO_EXCEPTIONS | |
| 603 | } catch (...) { | |
| 604 | _AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2)(); | |
| 605 | throw; | |
| 606 | } | |
| 607 | #endif | |
| 608 | return __first2; | |
| 609 | } | |
| 610 | ||
| 611 | template <class _Alloc, class _Type> | |
| 612 | struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {}; | |
| 613 | ||
| 614 | template <class _Type> | |
| 615 | struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {}; | |
| 616 | ||
| 617 | #ifndef _LIBCPP_COMPILER_GCC | |
| 618 | template < | |
| 619 | class _Alloc, | |
| 620 | class _Iter1, | |
| 621 | class _Iter2, | |
| 622 | class _Type = typename iterator_traits<_Iter1>::value_type, | |
| 623 | class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value && | |
| 624 | __allocator_has_trivial_move_construct<_Alloc, _Type>::value> > | |
| 625 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2 | |
| 626 | __uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) { | |
| 627 | if (__libcpp_is_constant_evaluated()) { | |
| 628 | while (__first1 != __last1) { | |
| 629 | std::__construct_at(std::__to_address(__first2), std::move(*__first1)); | |
| 630 | ++__first1; | |
| 631 | ++__first2; | |
| 632 | } | |
| 633 | return __first2; | |
| 634 | } else { | |
| 635 | return std::move(__first1, __last1, __first2); | |
| 636 | } | |
| 637 | } | |
| 638 | #endif // _LIBCPP_COMPILER_GCC | |
| 639 | ||
| 348 | 640 | _LIBCPP_END_NAMESPACE_STD |
| 349 | 641 | |
| 350 | 642 | #endif // _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H |
lib/libcxx/include/__memory/unique_ptr.h+8-19| ... | ... | @@ -13,20 +13,16 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | #include <__functional/hash.h> |
| 15 | 15 | #include <__functional/operations.h> |
| 16 | #include <__functional_base> | |
| 17 | 16 | #include <__memory/allocator_traits.h> // __pointer |
| 17 | #include <__memory/auto_ptr.h> | |
| 18 | 18 | #include <__memory/compressed_pair.h> |
| 19 | 19 | #include <__utility/forward.h> |
| 20 | #include <__utility/move.h> | |
| 20 | 21 | #include <cstddef> |
| 21 | 22 | #include <type_traits> |
| 22 | #include <utility> | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 25 | # include <__memory/auto_ptr.h> | |
| 26 | #endif | |
| 27 | 23 | |
| 28 | 24 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | #pragma GCC system_header | |
| 25 | # pragma GCC system_header | |
| 30 | 26 | #endif |
| 31 | 27 | |
| 32 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -47,10 +43,8 @@ struct _LIBCPP_TEMPLATE_VIS default_delete { |
| 47 | 43 | 0) _NOEXCEPT {} |
| 48 | 44 | |
| 49 | 45 | _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT { |
| 50 | static_assert(sizeof(_Tp) > 0, | |
| 51 | "default_delete can not delete incomplete type"); | |
| 52 | static_assert(!is_void<_Tp>::value, | |
| 53 | "default_delete can not delete incomplete type"); | |
| 46 | static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type"); | |
| 47 | static_assert(!is_void<_Tp>::value, "cannot delete an incomplete type"); | |
| 54 | 48 | delete __ptr; |
| 55 | 49 | } |
| 56 | 50 | }; |
| ... | ... | @@ -78,10 +72,7 @@ public: |
| 78 | 72 | _LIBCPP_INLINE_VISIBILITY |
| 79 | 73 | typename _EnableIfConvertible<_Up>::type |
| 80 | 74 | operator()(_Up* __ptr) const _NOEXCEPT { |
| 81 | static_assert(sizeof(_Tp) > 0, | |
| 82 | "default_delete can not delete incomplete type"); | |
| 83 | static_assert(!is_void<_Tp>::value, | |
| 84 | "default_delete can not delete void type"); | |
| 75 | static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type"); | |
| 85 | 76 | delete[] __ptr; |
| 86 | 77 | } |
| 87 | 78 | }; |
| ... | ... | @@ -144,7 +135,7 @@ private: |
| 144 | 135 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type; |
| 145 | 136 | |
| 146 | 137 | template <bool _Dummy, class _Deleter = typename __dependent_type< |
| 147 | __identity<deleter_type>, _Dummy>::type> | |
| 138 | __type_identity<deleter_type>, _Dummy>::type> | |
| 148 | 139 | using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG = |
| 149 | 140 | typename enable_if<is_default_constructible<_Deleter>::value && |
| 150 | 141 | !is_pointer<_Deleter>::value>::type; |
| ... | ... | @@ -264,7 +255,6 @@ public: |
| 264 | 255 | unique_ptr& operator=(unique_ptr const&) = delete; |
| 265 | 256 | #endif |
| 266 | 257 | |
| 267 | ||
| 268 | 258 | _LIBCPP_INLINE_VISIBILITY |
| 269 | 259 | ~unique_ptr() { reset(); } |
| 270 | 260 | |
| ... | ... | @@ -359,7 +349,7 @@ private: |
| 359 | 349 | typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type; |
| 360 | 350 | |
| 361 | 351 | template <bool _Dummy, class _Deleter = typename __dependent_type< |
| 362 | __identity<deleter_type>, _Dummy>::type> | |
| 352 | __type_identity<deleter_type>, _Dummy>::type> | |
| 363 | 353 | using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG = |
| 364 | 354 | typename enable_if<is_default_constructible<_Deleter>::value && |
| 365 | 355 | !is_pointer<_Deleter>::value>::type; |
| ... | ... | @@ -486,7 +476,6 @@ public: |
| 486 | 476 | unique_ptr(unique_ptr const&) = delete; |
| 487 | 477 | unique_ptr& operator=(unique_ptr const&) = delete; |
| 488 | 478 | #endif |
| 489 | ||
| 490 | 479 | public: |
| 491 | 480 | _LIBCPP_INLINE_VISIBILITY |
| 492 | 481 | ~unique_ptr() { reset(); } |
lib/libcxx/include/__memory/uses_allocator.h+4-5| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -24,11 +24,10 @@ template <class _Tp> |
| 24 | 24 | struct __has_allocator_type |
| 25 | 25 | { |
| 26 | 26 | private: |
| 27 | struct __two {char __lx; char __lxx;}; | |
| 28 | template <class _Up> static __two __test(...); | |
| 29 | template <class _Up> static char __test(typename _Up::allocator_type* = 0); | |
| 27 | template <class _Up> static false_type __test(...); | |
| 28 | template <class _Up> static true_type __test(typename _Up::allocator_type* = 0); | |
| 30 | 29 | public: |
| 31 | static const bool value = sizeof(__test<_Tp>(0)) == 1; | |
| 30 | static const bool value = decltype(__test<_Tp>(0))::value; | |
| 32 | 31 | }; |
| 33 | 32 | |
| 34 | 33 | template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> |
lib/libcxx/include/__mutex_base+7-12| ... | ... | @@ -10,15 +10,18 @@ |
| 10 | 10 | #ifndef _LIBCPP___MUTEX_BASE |
| 11 | 11 | #define _LIBCPP___MUTEX_BASE |
| 12 | 12 | |
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/steady_clock.h> | |
| 15 | #include <__chrono/system_clock.h> | |
| 16 | #include <__chrono/time_point.h> | |
| 13 | 17 | #include <__config> |
| 14 | 18 | #include <__threading_support> |
| 15 | #include <chrono> | |
| 16 | 19 | #include <ratio> |
| 17 | 20 | #include <system_error> |
| 18 | 21 | #include <time.h> |
| 19 | 22 | |
| 20 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 22 | 25 | #endif |
| 23 | 26 | |
| 24 | 27 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -335,11 +338,7 @@ private: |
| 335 | 338 | |
| 336 | 339 | template <class _Rep, class _Period> |
| 337 | 340 | inline _LIBCPP_INLINE_VISIBILITY |
| 338 | typename enable_if | |
| 339 | < | |
| 340 | is_floating_point<_Rep>::value, | |
| 341 | chrono::nanoseconds | |
| 342 | >::type | |
| 341 | __enable_if_t<is_floating_point<_Rep>::value, chrono::nanoseconds> | |
| 343 | 342 | __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) |
| 344 | 343 | { |
| 345 | 344 | using namespace chrono; |
| ... | ... | @@ -362,11 +361,7 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) |
| 362 | 361 | |
| 363 | 362 | template <class _Rep, class _Period> |
| 364 | 363 | inline _LIBCPP_INLINE_VISIBILITY |
| 365 | typename enable_if | |
| 366 | < | |
| 367 | !is_floating_point<_Rep>::value, | |
| 368 | chrono::nanoseconds | |
| 369 | >::type | |
| 364 | __enable_if_t<!is_floating_point<_Rep>::value, chrono::nanoseconds> | |
| 370 | 365 | __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) |
| 371 | 366 | { |
| 372 | 367 | using namespace chrono; |
lib/libcxx/include/__node_handle+2-2| ... | ... | @@ -58,13 +58,13 @@ public: |
| 58 | 58 | |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | #include <__assert> | |
| 61 | 62 | #include <__config> |
| 62 | #include <__debug> | |
| 63 | 63 | #include <memory> |
| 64 | 64 | #include <optional> |
| 65 | 65 | |
| 66 | 66 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 67 | #pragma GCC system_header | |
| 67 | # pragma GCC system_header | |
| 68 | 68 | #endif |
| 69 | 69 | |
| 70 | 70 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__nullptr deleted-61| ... | ... | @@ -1,61 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_NULLPTR | |
| 11 | #define _LIBCPP_NULLPTR | |
| 12 | ||
| 13 | #include <__config> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | #pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | #ifdef _LIBCPP_HAS_NO_NULLPTR | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | struct _LIBCPP_TEMPLATE_VIS nullptr_t | |
| 24 | { | |
| 25 | void* __lx; | |
| 26 | ||
| 27 | struct __nat {int __for_bool_;}; | |
| 28 | ||
| 29 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} | |
| 30 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} | |
| 31 | ||
| 32 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} | |
| 33 | ||
| 34 | template <class _Tp> | |
| 35 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 36 | operator _Tp* () const {return 0;} | |
| 37 | ||
| 38 | template <class _Tp, class _Up> | |
| 39 | _LIBCPP_INLINE_VISIBILITY | |
| 40 | operator _Tp _Up::* () const {return 0;} | |
| 41 | ||
| 42 | friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} | |
| 43 | friend _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} | |
| 44 | }; | |
| 45 | ||
| 46 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} | |
| 47 | ||
| 48 | #define nullptr _VSTD::__get_nullptr_t() | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #else // _LIBCPP_HAS_NO_NULLPTR | |
| 53 | ||
| 54 | namespace std | |
| 55 | { | |
| 56 | typedef decltype(nullptr) nullptr_t; | |
| 57 | } // namespace std | |
| 58 | ||
| 59 | #endif // _LIBCPP_HAS_NO_NULLPTR | |
| 60 | ||
| 61 | #endif // _LIBCPP_NULLPTR |
lib/libcxx/include/__numeric/accumulate.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__utility/move.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__numeric/gcd_lcm.h+1-1| ... | ... | @@ -10,8 +10,8 @@ |
| 10 | 10 | #ifndef _LIBCPP___NUMERIC_GCD_LCM_H |
| 11 | 11 | #define _LIBCPP___NUMERIC_GCD_LCM_H |
| 12 | 12 | |
| 13 | #include <__assert> | |
| 13 | 14 | #include <__config> |
| 14 | #include <__debug> | |
| 15 | 15 | #include <limits> |
| 16 | 16 | #include <type_traits> |
| 17 | 17 |
lib/libcxx/include/__numeric/inner_product.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__utility/move.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__numeric/iota.h+3-3| ... | ... | @@ -21,10 +21,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 21 | 21 | template <class _ForwardIterator, class _Tp> |
| 22 | 22 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 23 | 23 | void |
| 24 | iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_) | |
| 24 | iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value) | |
| 25 | 25 | { |
| 26 | for (; __first != __last; ++__first, (void) ++__value_) | |
| 27 | *__first = __value_; | |
| 26 | for (; __first != __last; ++__first, (void) ++__value) | |
| 27 | *__first = __value; | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/__random/bernoulli_distribution.h+3-1| ... | ... | @@ -10,11 +10,12 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_BERNOULLI_DISTRIBUTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__random/is_valid.h> | |
| 13 | 14 | #include <__random/uniform_real_distribution.h> |
| 14 | 15 | #include <iosfwd> |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | 21 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -103,6 +104,7 @@ inline |
| 103 | 104 | bernoulli_distribution::result_type |
| 104 | 105 | bernoulli_distribution::operator()(_URNG& __g, const param_type& __p) |
| 105 | 106 | { |
| 107 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 106 | 108 | uniform_real_distribution<double> __gen; |
| 107 | 109 | return __gen(__g) < __p.p(); |
| 108 | 110 | } |
lib/libcxx/include/__random/binomial_distribution.h+4-1| ... | ... | @@ -10,12 +10,13 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__random/is_valid.h> | |
| 13 | 14 | #include <__random/uniform_real_distribution.h> |
| 14 | 15 | #include <cmath> |
| 15 | 16 | #include <iosfwd> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | template<class _IntType = int> |
| 27 | 28 | class _LIBCPP_TEMPLATE_VIS binomial_distribution |
| 28 | 29 | { |
| 30 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | |
| 29 | 31 | public: |
| 30 | 32 | // types |
| 31 | 33 | typedef _IntType result_type; |
| ... | ... | @@ -146,6 +148,7 @@ template<class _URNG> |
| 146 | 148 | _IntType |
| 147 | 149 | binomial_distribution<_IntType>::operator()(_URNG& __g, const param_type& __pr) |
| 148 | 150 | { |
| 151 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 149 | 152 | if (__pr.__t_ == 0 || __pr.__p_ == 0) |
| 150 | 153 | return 0; |
| 151 | 154 | if (__pr.__p_ == 1) |
lib/libcxx/include/__random/cauchy_distribution.h+3-1| ... | ... | @@ -10,13 +10,14 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_CAUCHY_DISTRIBUTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__random/is_valid.h> | |
| 13 | 14 | #include <__random/uniform_real_distribution.h> |
| 14 | 15 | #include <cmath> |
| 15 | 16 | #include <iosfwd> |
| 16 | 17 | #include <limits> |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -116,6 +117,7 @@ inline |
| 116 | 117 | _RealType |
| 117 | 118 | cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 118 | 119 | { |
| 120 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 119 | 121 | uniform_real_distribution<result_type> __gen; |
| 120 | 122 | // purposefully let tan arg get as close to pi/2 as it wants, tan will return a finite |
| 121 | 123 | return __p.a() + __p.b() * _VSTD::tan(3.1415926535897932384626433832795 * __gen(__g)); |
lib/libcxx/include/__random/chi_squared_distribution.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <limits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/clamp_to_integral.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/default_random_engine.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__random/linear_congruential_engine.h> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__random/discard_block_engine.h+1-1| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/discrete_distribution.h+4-1| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/upper_bound.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/uniform_real_distribution.h> |
| 15 | 16 | #include <cstddef> |
| 16 | 17 | #include <iosfwd> |
| ... | ... | @@ -18,7 +19,7 @@ |
| 18 | 19 | #include <vector> |
| 19 | 20 | |
| 20 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 22 | 23 | #endif |
| 23 | 24 | |
| 24 | 25 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -29,6 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 30 | template<class _IntType = int> |
| 30 | 31 | class _LIBCPP_TEMPLATE_VIS discrete_distribution |
| 31 | 32 | { |
| 33 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | |
| 32 | 34 | public: |
| 33 | 35 | // types |
| 34 | 36 | typedef _IntType result_type; |
| ... | ... | @@ -211,6 +213,7 @@ template<class _URNG> |
| 211 | 213 | _IntType |
| 212 | 214 | discrete_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) |
| 213 | 215 | { |
| 216 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 214 | 217 | uniform_real_distribution<double> __gen; |
| 215 | 218 | return static_cast<_IntType>( |
| 216 | 219 | _VSTD::upper_bound(__p.__p_.begin(), __p.__p_.end(), __gen(__g)) - |
lib/libcxx/include/__random/exponential_distribution.h+3-1| ... | ... | @@ -11,13 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/generate_canonical.h> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/uniform_real_distribution.h> |
| 15 | 16 | #include <cmath> |
| 16 | 17 | #include <iosfwd> |
| 17 | 18 | #include <limits> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -109,6 +110,7 @@ template<class _URNG> |
| 109 | 110 | _RealType |
| 110 | 111 | exponential_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 111 | 112 | { |
| 113 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 112 | 114 | return -_VSTD::log |
| 113 | 115 | ( |
| 114 | 116 | result_type(1) - |
lib/libcxx/include/__random/extreme_value_distribution.h+3-1| ... | ... | @@ -10,13 +10,14 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_EXTREME_VALUE_DISTRIBUTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__random/is_valid.h> | |
| 13 | 14 | #include <__random/uniform_real_distribution.h> |
| 14 | 15 | #include <cmath> |
| 15 | 16 | #include <iosfwd> |
| 16 | 17 | #include <limits> |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -116,6 +117,7 @@ template<class _URNG> |
| 116 | 117 | _RealType |
| 117 | 118 | extreme_value_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 118 | 119 | { |
| 120 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 119 | 121 | return __p.a() - __p.b() * |
| 120 | 122 | _VSTD::log(-_VSTD::log(1-uniform_real_distribution<result_type>()(__g))); |
| 121 | 123 | } |
lib/libcxx/include/__random/fisher_f_distribution.h+3-1| ... | ... | @@ -11,11 +11,12 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/gamma_distribution.h> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <iosfwd> |
| 15 | 16 | #include <limits> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -114,6 +115,7 @@ template<class _URNG> |
| 114 | 115 | _RealType |
| 115 | 116 | fisher_f_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 116 | 117 | { |
| 118 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 117 | 119 | gamma_distribution<result_type> __gdm(__p.m() * result_type(.5)); |
| 118 | 120 | gamma_distribution<result_type> __gdn(__p.n() * result_type(.5)); |
| 119 | 121 | return __p.n() * __gdm(__g) / (__p.m() * __gdn(__g)); |
lib/libcxx/include/__random/gamma_distribution.h+3-1| ... | ... | @@ -11,13 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/exponential_distribution.h> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/uniform_real_distribution.h> |
| 15 | 16 | #include <cmath> |
| 16 | 17 | #include <iosfwd> |
| 17 | 18 | #include <limits> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -117,6 +118,7 @@ template<class _URNG> |
| 117 | 118 | _RealType |
| 118 | 119 | gamma_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 119 | 120 | { |
| 121 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 120 | 122 | result_type __a = __p.alpha(); |
| 121 | 123 | uniform_real_distribution<result_type> __gen(0, 1); |
| 122 | 124 | exponential_distribution<result_type> __egen; |
lib/libcxx/include/__random/generate_canonical.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <limits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/geometric_distribution.h+3-1| ... | ... | @@ -10,12 +10,13 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_GEOMETRIC_DISTRIBUTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__random/is_valid.h> | |
| 13 | 14 | #include <__random/negative_binomial_distribution.h> |
| 14 | 15 | #include <iosfwd> |
| 15 | 16 | #include <limits> |
| 16 | 17 | |
| 17 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 21 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -26,6 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | template<class _IntType = int> |
| 27 | 28 | class _LIBCPP_TEMPLATE_VIS geometric_distribution |
| 28 | 29 | { |
| 30 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | |
| 29 | 31 | public: |
| 30 | 32 | // types |
| 31 | 33 | typedef _IntType result_type; |
lib/libcxx/include/__random/independent_bits_engine.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/is_seed_sequence.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__random/is_valid.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___RANDOM_IS_VALID_H | |
| 10 | #define _LIBCPP___RANDOM_IS_VALID_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstdint> | |
| 14 | #include <type_traits> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | // [rand.req.genl]/1.5: | |
| 23 | // The effect of instantiating a template that has a template type parameter | |
| 24 | // named IntType is undefined unless the corresponding template argument is | |
| 25 | // cv-unqualified and is one of short, int, long, long long, unsigned short, | |
| 26 | // unsigned int, unsigned long, or unsigned long long. | |
| 27 | ||
| 28 | template<class> struct __libcpp_random_is_valid_inttype : false_type {}; | |
| 29 | template<> struct __libcpp_random_is_valid_inttype<int8_t> : true_type {}; // extension | |
| 30 | template<> struct __libcpp_random_is_valid_inttype<short> : true_type {}; | |
| 31 | template<> struct __libcpp_random_is_valid_inttype<int> : true_type {}; | |
| 32 | template<> struct __libcpp_random_is_valid_inttype<long> : true_type {}; | |
| 33 | template<> struct __libcpp_random_is_valid_inttype<long long> : true_type {}; | |
| 34 | template<> struct __libcpp_random_is_valid_inttype<uint8_t> : true_type {}; // extension | |
| 35 | template<> struct __libcpp_random_is_valid_inttype<unsigned short> : true_type {}; | |
| 36 | template<> struct __libcpp_random_is_valid_inttype<unsigned int> : true_type {}; | |
| 37 | template<> struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {}; | |
| 38 | template<> struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {}; | |
| 39 | ||
| 40 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 41 | template<> struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension | |
| 42 | template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension | |
| 43 | #endif // _LIBCPP_HAS_NO_INT128 | |
| 44 | ||
| 45 | // [rand.req.urng]/3: | |
| 46 | // A class G meets the uniform random bit generator requirements if G models | |
| 47 | // uniform_random_bit_generator, invoke_result_t<G&> is an unsigned integer type, | |
| 48 | // and G provides a nested typedef-name result_type that denotes the same type | |
| 49 | // as invoke_result_t<G&>. | |
| 50 | // (In particular, reject URNGs with signed result_types; our distributions cannot | |
| 51 | // handle such generator types.) | |
| 52 | ||
| 53 | template<class, class = void> struct __libcpp_random_is_valid_urng : false_type {}; | |
| 54 | template<class _Gp> struct __libcpp_random_is_valid_urng<_Gp, __enable_if_t< | |
| 55 | is_unsigned<typename _Gp::result_type>::value && | |
| 56 | _IsSame<decltype(declval<_Gp&>()()), typename _Gp::result_type>::value | |
| 57 | > > : true_type {}; | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP___RANDOM_IS_VALID_H |
lib/libcxx/include/__random/knuth_b.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <__random/shuffle_order_engine.h> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__random/linear_congruential_engine.h+3-3| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -218,8 +218,8 @@ private: |
| 218 | 218 | static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters"); |
| 219 | 219 | static_assert(is_unsigned<_UIntType>::value, "_UIntType must be unsigned type"); |
| 220 | 220 | public: |
| 221 | static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u: 0u; | |
| 222 | static _LIBCPP_CONSTEXPR const result_type _Max = __m - 1u; | |
| 221 | static _LIBCPP_CONSTEXPR const result_type _Min = __c == 0u ? 1u : 0u; | |
| 222 | static _LIBCPP_CONSTEXPR const result_type _Max = __m - _UIntType(1u); | |
| 223 | 223 | static_assert(_Min < _Max, "linear_congruential_engine invalid parameters"); |
| 224 | 224 | |
| 225 | 225 | // engine characteristics |
lib/libcxx/include/__random/log2.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__random/lognormal_distribution.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <limits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/mersenne_twister_engine.h+1-1| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/negative_binomial_distribution.h+9-2| ... | ... | @@ -12,12 +12,13 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/bernoulli_distribution.h> |
| 14 | 14 | #include <__random/gamma_distribution.h> |
| 15 | #include <__random/is_valid.h> | |
| 15 | 16 | #include <__random/poisson_distribution.h> |
| 16 | 17 | #include <iosfwd> |
| 17 | 18 | #include <limits> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -28,6 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 28 | 29 | template<class _IntType = int> |
| 29 | 30 | class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution |
| 30 | 31 | { |
| 32 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | |
| 31 | 33 | public: |
| 32 | 34 | // types |
| 33 | 35 | typedef _IntType result_type; |
| ... | ... | @@ -116,9 +118,12 @@ template<class _URNG> |
| 116 | 118 | _IntType |
| 117 | 119 | negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) |
| 118 | 120 | { |
| 121 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 119 | 122 | result_type __k = __pr.k(); |
| 120 | 123 | double __p = __pr.p(); |
| 121 | if (__k <= 21 * __p) | |
| 124 | // When the number of bits in _IntType is small, we are too likely to | |
| 125 | // overflow __f below to use this technique. | |
| 126 | if (__k <= 21 * __p && sizeof(_IntType) > 1) | |
| 122 | 127 | { |
| 123 | 128 | bernoulli_distribution __gen(__p); |
| 124 | 129 | result_type __f = 0; |
| ... | ... | @@ -130,6 +135,8 @@ negative_binomial_distribution<_IntType>::operator()(_URNG& __urng, const param_ |
| 130 | 135 | else |
| 131 | 136 | ++__f; |
| 132 | 137 | } |
| 138 | _LIBCPP_ASSERT(__f >= 0, "std::negative_binomial_distribution should never produce negative values. " | |
| 139 | "This is almost certainly a signed integer overflow issue on __f."); | |
| 133 | 140 | return __f; |
| 134 | 141 | } |
| 135 | 142 | return poisson_distribution<result_type>(gamma_distribution<double> |
lib/libcxx/include/__random/normal_distribution.h+3-1| ... | ... | @@ -10,13 +10,14 @@ |
| 10 | 10 | #define _LIBCPP___RANDOM_NORMAL_DISTRIBUTION_H |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | #include <__random/is_valid.h> | |
| 13 | 14 | #include <__random/uniform_real_distribution.h> |
| 14 | 15 | #include <cmath> |
| 15 | 16 | #include <iosfwd> |
| 16 | 17 | #include <limits> |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -131,6 +132,7 @@ template<class _URNG> |
| 131 | 132 | _RealType |
| 132 | 133 | normal_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 133 | 134 | { |
| 135 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 134 | 136 | result_type _Up; |
| 135 | 137 | if (_V_hot_) |
| 136 | 138 | { |
lib/libcxx/include/__random/piecewise_constant_distribution.h+13-11| ... | ... | @@ -11,13 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/upper_bound.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/uniform_real_distribution.h> |
| 15 | 16 | #include <iosfwd> |
| 16 | 17 | #include <numeric> |
| 17 | 18 | #include <vector> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -42,8 +43,8 @@ public: |
| 42 | 43 | |
| 43 | 44 | param_type(); |
| 44 | 45 | template<class _InputIteratorB, class _InputIteratorW> |
| 45 | param_type(_InputIteratorB __fB, _InputIteratorB __lB, | |
| 46 | _InputIteratorW __fW); | |
| 46 | param_type(_InputIteratorB __f_b, _InputIteratorB __l_b, | |
| 47 | _InputIteratorW __f_w); | |
| 47 | 48 | #ifndef _LIBCPP_CXX03_LANG |
| 48 | 49 | template<class _UnaryOperation> |
| 49 | 50 | param_type(initializer_list<result_type> __bl, _UnaryOperation __fw); |
| ... | ... | @@ -93,10 +94,10 @@ public: |
| 93 | 94 | piecewise_constant_distribution() {} |
| 94 | 95 | template<class _InputIteratorB, class _InputIteratorW> |
| 95 | 96 | _LIBCPP_INLINE_VISIBILITY |
| 96 | piecewise_constant_distribution(_InputIteratorB __fB, | |
| 97 | _InputIteratorB __lB, | |
| 98 | _InputIteratorW __fW) | |
| 99 | : __p_(__fB, __lB, __fW) {} | |
| 97 | piecewise_constant_distribution(_InputIteratorB __f_b, | |
| 98 | _InputIteratorB __l_b, | |
| 99 | _InputIteratorW __f_w) | |
| 100 | : __p_(__f_b, __l_b, __f_w) {} | |
| 100 | 101 | |
| 101 | 102 | #ifndef _LIBCPP_CXX03_LANG |
| 102 | 103 | template<class _UnaryOperation> |
| ... | ... | @@ -214,8 +215,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type() |
| 214 | 215 | template<class _RealType> |
| 215 | 216 | template<class _InputIteratorB, class _InputIteratorW> |
| 216 | 217 | piecewise_constant_distribution<_RealType>::param_type::param_type( |
| 217 | _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) | |
| 218 | : __b_(__fB, __lB) | |
| 218 | _InputIteratorB __f_b, _InputIteratorB __l_b, _InputIteratorW __f_w) | |
| 219 | : __b_(__f_b, __l_b) | |
| 219 | 220 | { |
| 220 | 221 | if (__b_.size() < 2) |
| 221 | 222 | { |
| ... | ... | @@ -228,8 +229,8 @@ piecewise_constant_distribution<_RealType>::param_type::param_type( |
| 228 | 229 | else |
| 229 | 230 | { |
| 230 | 231 | __densities_.reserve(__b_.size() - 1); |
| 231 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__fW) | |
| 232 | __densities_.push_back(*__fW); | |
| 232 | for (size_t __i = 0; __i < __b_.size() - 1; ++__i, ++__f_w) | |
| 233 | __densities_.push_back(*__f_w); | |
| 233 | 234 | __init(); |
| 234 | 235 | } |
| 235 | 236 | } |
| ... | ... | @@ -284,6 +285,7 @@ template<class _URNG> |
| 284 | 285 | _RealType |
| 285 | 286 | piecewise_constant_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 286 | 287 | { |
| 288 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 287 | 289 | typedef uniform_real_distribution<result_type> _Gen; |
| 288 | 290 | result_type __u = _Gen()(__g); |
| 289 | 291 | ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), |
lib/libcxx/include/__random/piecewise_linear_distribution.h+13-11| ... | ... | @@ -11,13 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/upper_bound.h> |
| 13 | 13 | #include <__config> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/uniform_real_distribution.h> |
| 15 | 16 | #include <iosfwd> |
| 16 | 17 | #include <numeric> |
| 17 | 18 | #include <vector> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -42,8 +43,8 @@ public: |
| 42 | 43 | |
| 43 | 44 | param_type(); |
| 44 | 45 | template<class _InputIteratorB, class _InputIteratorW> |
| 45 | param_type(_InputIteratorB __fB, _InputIteratorB __lB, | |
| 46 | _InputIteratorW __fW); | |
| 46 | param_type(_InputIteratorB __f_b, _InputIteratorB __l_b, | |
| 47 | _InputIteratorW __f_w); | |
| 47 | 48 | #ifndef _LIBCPP_CXX03_LANG |
| 48 | 49 | template<class _UnaryOperation> |
| 49 | 50 | param_type(initializer_list<result_type> __bl, _UnaryOperation __fw); |
| ... | ... | @@ -93,10 +94,10 @@ public: |
| 93 | 94 | piecewise_linear_distribution() {} |
| 94 | 95 | template<class _InputIteratorB, class _InputIteratorW> |
| 95 | 96 | _LIBCPP_INLINE_VISIBILITY |
| 96 | piecewise_linear_distribution(_InputIteratorB __fB, | |
| 97 | _InputIteratorB __lB, | |
| 98 | _InputIteratorW __fW) | |
| 99 | : __p_(__fB, __lB, __fW) {} | |
| 97 | piecewise_linear_distribution(_InputIteratorB __f_b, | |
| 98 | _InputIteratorB __l_b, | |
| 99 | _InputIteratorW __f_w) | |
| 100 | : __p_(__f_b, __l_b, __f_w) {} | |
| 100 | 101 | |
| 101 | 102 | #ifndef _LIBCPP_CXX03_LANG |
| 102 | 103 | template<class _UnaryOperation> |
| ... | ... | @@ -218,8 +219,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type() |
| 218 | 219 | template<class _RealType> |
| 219 | 220 | template<class _InputIteratorB, class _InputIteratorW> |
| 220 | 221 | piecewise_linear_distribution<_RealType>::param_type::param_type( |
| 221 | _InputIteratorB __fB, _InputIteratorB __lB, _InputIteratorW __fW) | |
| 222 | : __b_(__fB, __lB) | |
| 222 | _InputIteratorB __f_b, _InputIteratorB __l_b, _InputIteratorW __f_w) | |
| 223 | : __b_(__f_b, __l_b) | |
| 223 | 224 | { |
| 224 | 225 | if (__b_.size() < 2) |
| 225 | 226 | { |
| ... | ... | @@ -232,8 +233,8 @@ piecewise_linear_distribution<_RealType>::param_type::param_type( |
| 232 | 233 | else |
| 233 | 234 | { |
| 234 | 235 | __densities_.reserve(__b_.size()); |
| 235 | for (size_t __i = 0; __i < __b_.size(); ++__i, ++__fW) | |
| 236 | __densities_.push_back(*__fW); | |
| 236 | for (size_t __i = 0; __i < __b_.size(); ++__i, ++__f_w) | |
| 237 | __densities_.push_back(*__f_w); | |
| 237 | 238 | __init(); |
| 238 | 239 | } |
| 239 | 240 | } |
| ... | ... | @@ -289,6 +290,7 @@ template<class _URNG> |
| 289 | 290 | _RealType |
| 290 | 291 | piecewise_linear_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 291 | 292 | { |
| 293 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 292 | 294 | typedef uniform_real_distribution<result_type> _Gen; |
| 293 | 295 | result_type __u = _Gen()(__g); |
| 294 | 296 | ptrdiff_t __k = _VSTD::upper_bound(__p.__areas_.begin(), __p.__areas_.end(), |
lib/libcxx/include/__random/poisson_distribution.h+4-1| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/clamp_to_integral.h> |
| 14 | 14 | #include <__random/exponential_distribution.h> |
| 15 | #include <__random/is_valid.h> | |
| 15 | 16 | #include <__random/normal_distribution.h> |
| 16 | 17 | #include <__random/uniform_real_distribution.h> |
| 17 | 18 | #include <cmath> |
| ... | ... | @@ -19,7 +20,7 @@ |
| 19 | 20 | #include <limits> |
| 20 | 21 | |
| 21 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 23 | 24 | #endif |
| 24 | 25 | |
| 25 | 26 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -30,6 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 31 | template<class _IntType = int> |
| 31 | 32 | class _LIBCPP_TEMPLATE_VIS poisson_distribution |
| 32 | 33 | { |
| 34 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | |
| 33 | 35 | public: |
| 34 | 36 | // types |
| 35 | 37 | typedef _IntType result_type; |
| ... | ... | @@ -157,6 +159,7 @@ template<class _URNG> |
| 157 | 159 | _IntType |
| 158 | 160 | poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) |
| 159 | 161 | { |
| 162 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 160 | 163 | double __tx; |
| 161 | 164 | uniform_real_distribution<double> __urd; |
| 162 | 165 | if (__pr.__mean_ < 10) |
lib/libcxx/include/__random/random_device.h+4-8| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <string> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -28,10 +28,8 @@ class _LIBCPP_TYPE_VIS random_device |
| 28 | 28 | #ifdef _LIBCPP_USING_DEV_RANDOM |
| 29 | 29 | int __f_; |
| 30 | 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 | |
| 31 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 32 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field") | |
| 35 | 33 | |
| 36 | 34 | // Apple platforms used to use the `_LIBCPP_USING_DEV_RANDOM` code path, and now |
| 37 | 35 | // use `arc4random()` as of this comment. In order to avoid breaking the ABI, we |
| ... | ... | @@ -42,9 +40,7 @@ class _LIBCPP_TYPE_VIS random_device |
| 42 | 40 | |
| 43 | 41 | // ... vendors can add workarounds here if they switch to a different representation ... |
| 44 | 42 | |
| 45 | # if defined(__clang__) | |
| 46 | # pragma clang diagnostic pop | |
| 47 | # endif | |
| 43 | _LIBCPP_DIAGNOSTIC_POP | |
| 48 | 44 | #endif |
| 49 | 45 | |
| 50 | 46 | public: |
lib/libcxx/include/__random/ranlux.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <cstdint> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__random/seed_seq.h+50-26| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <vector> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -109,39 +109,63 @@ seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) |
| 109 | 109 | __first[__q] += __r; |
| 110 | 110 | __first[0] = __r; |
| 111 | 111 | } |
| 112 | // Initialize indexing terms used with if statements as an optimization to | |
| 113 | // avoid calculating modulo n on every loop iteration for each term. | |
| 114 | size_t __kmodn = 0; // __k % __n | |
| 115 | size_t __k1modn = __n - 1; // (__k - 1) % __n | |
| 116 | size_t __kpmodn = __p % __n; // (__k + __p) % __n | |
| 117 | size_t __kqmodn = __q % __n; // (__k + __q) % __n | |
| 118 | ||
| 112 | 119 | for (size_t __k = 1; __k <= __s; ++__k) |
| 113 | 120 | { |
| 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; | |
| 121 | if (++__kmodn == __n) | |
| 122 | __kmodn = 0; | |
| 123 | if (++__k1modn == __n) | |
| 124 | __k1modn = 0; | |
| 125 | if (++__kpmodn == __n) | |
| 126 | __kpmodn = 0; | |
| 127 | if (++__kqmodn == __n) | |
| 128 | __kqmodn = 0; | |
| 129 | ||
| 130 | result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]); | |
| 131 | __first[__kpmodn] += __r; | |
| 132 | __r += __kmodn + __v_[__k - 1]; | |
| 133 | __first[__kqmodn] += __r; | |
| 134 | __first[__kmodn] = __r; | |
| 122 | 135 | } |
| 123 | 136 | for (size_t __k = __s + 1; __k < __m; ++__k) |
| 124 | 137 | { |
| 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; | |
| 138 | if (++__kmodn == __n) | |
| 139 | __kmodn = 0; | |
| 140 | if (++__k1modn == __n) | |
| 141 | __k1modn = 0; | |
| 142 | if (++__kpmodn == __n) | |
| 143 | __kpmodn = 0; | |
| 144 | if (++__kqmodn == __n) | |
| 145 | __kqmodn = 0; | |
| 146 | ||
| 147 | result_type __r = 1664525 * _Tp(__first[__kmodn] ^ __first[__kpmodn] ^ __first[__k1modn]); | |
| 148 | __first[__kpmodn] += __r; | |
| 149 | __r += __kmodn; | |
| 150 | __first[__kqmodn] += __r; | |
| 151 | __first[__kmodn] = __r; | |
| 133 | 152 | } |
| 134 | 153 | for (size_t __k = __m; __k < __m + __n; ++__k) |
| 135 | 154 | { |
| 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; | |
| 155 | if (++__kmodn == __n) | |
| 156 | __kmodn = 0; | |
| 157 | if (++__k1modn == __n) | |
| 158 | __k1modn = 0; | |
| 159 | if (++__kpmodn == __n) | |
| 160 | __kpmodn = 0; | |
| 161 | if (++__kqmodn == __n) | |
| 162 | __kqmodn = 0; | |
| 163 | ||
| 164 | result_type __r = 1566083941 * _Tp(__first[__kmodn] + __first[__kpmodn] + __first[__k1modn]); | |
| 165 | __first[__kpmodn] ^= __r; | |
| 166 | __r -= __kmodn; | |
| 167 | __first[__kqmodn] ^= __r; | |
| 168 | __first[__kmodn] = __r; | |
| 145 | 169 | } |
| 146 | 170 | } |
| 147 | 171 | } |
lib/libcxx/include/__random/shuffle_order_engine.h+1-1| ... | ... | @@ -18,7 +18,7 @@ |
| 18 | 18 | #include <type_traits> |
| 19 | 19 | |
| 20 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 22 | 22 | #endif |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/student_t_distribution.h+3-1| ... | ... | @@ -11,13 +11,14 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/gamma_distribution.h> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/normal_distribution.h> |
| 15 | 16 | #include <cmath> |
| 16 | 17 | #include <iosfwd> |
| 17 | 18 | #include <limits> |
| 18 | 19 | |
| 19 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 21 | 22 | #endif |
| 22 | 23 | |
| 23 | 24 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -111,6 +112,7 @@ template<class _URNG> |
| 111 | 112 | _RealType |
| 112 | 113 | student_t_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 113 | 114 | { |
| 115 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 114 | 116 | gamma_distribution<result_type> __gd(__p.n() * .5, 2); |
| 115 | 117 | return __nd_(__g) * _VSTD::sqrt(__p.n()/__gd(__g)); |
| 116 | 118 | } |
lib/libcxx/include/__random/subtract_with_carry_engine.h+1-1| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | #include <type_traits> |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 25 | 25 | #endif |
| 26 | 26 | |
| 27 | 27 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__random/uniform_int_distribution.h+5-2| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__bits> |
| 13 | 13 | #include <__config> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <__random/log2.h> |
| 15 | 16 | #include <bit> |
| 16 | 17 | #include <cstddef> |
| ... | ... | @@ -20,7 +21,7 @@ |
| 20 | 21 | #include <type_traits> |
| 21 | 22 | |
| 22 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 24 | 25 | #endif |
| 25 | 26 | |
| 26 | 27 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -155,9 +156,10 @@ __independent_bits_engine<_Engine, _UIntType>::__eval(true_type) |
| 155 | 156 | return _Sp; |
| 156 | 157 | } |
| 157 | 158 | |
| 158 | template<class _IntType = int> // __int128_t is also supported as an extension here | |
| 159 | template<class _IntType = int> | |
| 159 | 160 | class uniform_int_distribution |
| 160 | 161 | { |
| 162 | static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type"); | |
| 161 | 163 | public: |
| 162 | 164 | // types |
| 163 | 165 | typedef _IntType result_type; |
| ... | ... | @@ -230,6 +232,7 @@ typename uniform_int_distribution<_IntType>::result_type |
| 230 | 232 | uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p) |
| 231 | 233 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| 232 | 234 | { |
| 235 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 233 | 236 | typedef typename conditional<sizeof(result_type) <= sizeof(uint32_t), uint32_t, |
| 234 | 237 | typename make_unsigned<result_type>::type>::type _UIntType; |
| 235 | 238 | const _UIntType _Rp = _UIntType(__p.b()) - _UIntType(__p.a()) + _UIntType(1); |
lib/libcxx/include/__random/uniform_random_bit_generator.h+3-3| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | 28 | |
| 29 | 29 | // [rand.req.urng] |
| 30 | 30 | template<class _Gen> |
| ... | ... | @@ -36,7 +36,7 @@ concept uniform_random_bit_generator = |
| 36 | 36 | requires bool_constant<(_Gen::min() < _Gen::max())>::value; |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 39 | #endif // _LIBCPP_STD_VER > 17 | |
| 40 | 40 | |
| 41 | 41 | _LIBCPP_END_NAMESPACE_STD |
| 42 | 42 |
lib/libcxx/include/__random/uniform_real_distribution.h+3-1| ... | ... | @@ -11,12 +11,13 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__random/generate_canonical.h> |
| 14 | #include <__random/is_valid.h> | |
| 14 | 15 | #include <iosfwd> |
| 15 | 16 | #include <limits> |
| 16 | 17 | #include <type_traits> |
| 17 | 18 | |
| 18 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 20 | 21 | #endif |
| 21 | 22 | |
| 22 | 23 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -115,6 +116,7 @@ inline |
| 115 | 116 | typename uniform_real_distribution<_RealType>::result_type |
| 116 | 117 | uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) |
| 117 | 118 | { |
| 119 | static_assert(__libcpp_random_is_valid_urng<_URNG>::value, ""); | |
| 118 | 120 | return (__p.b() - __p.a()) |
| 119 | 121 | * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g) |
| 120 | 122 | + __p.a(); |
lib/libcxx/include/__random/weibull_distribution.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <limits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__ranges/access.h+7-10| ... | ... | @@ -14,18 +14,16 @@ |
| 14 | 14 | #include <__iterator/concepts.h> |
| 15 | 15 | #include <__iterator/readable_traits.h> |
| 16 | 16 | #include <__ranges/enable_borrowed_range.h> |
| 17 | #include <__utility/as_const.h> | |
| 18 | 17 | #include <__utility/auto_cast.h> |
| 19 | #include <concepts> | |
| 20 | 18 | #include <type_traits> |
| 21 | 19 | |
| 22 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 24 | 22 | #endif |
| 25 | 23 | |
| 26 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 25 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 29 | 27 | |
| 30 | 28 | namespace ranges { |
| 31 | 29 | template <class _Tp> |
| ... | ... | @@ -60,14 +58,14 @@ namespace __begin { |
| 60 | 58 | struct __fn { |
| 61 | 59 | template <class _Tp> |
| 62 | 60 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[]) const noexcept |
| 63 | requires (sizeof(_Tp) != 0) // Disallow incomplete element types. | |
| 61 | requires (sizeof(_Tp) >= 0) // Disallow incomplete element types. | |
| 64 | 62 | { |
| 65 | 63 | return __t + 0; |
| 66 | 64 | } |
| 67 | 65 | |
| 68 | 66 | template <class _Tp, size_t _Np> |
| 69 | 67 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept |
| 70 | requires (sizeof(_Tp) != 0) // Disallow incomplete element types. | |
| 68 | requires (sizeof(_Tp) >= 0) // Disallow incomplete element types. | |
| 71 | 69 | { |
| 72 | 70 | return __t + 0; |
| 73 | 71 | } |
| ... | ... | @@ -130,11 +128,10 @@ namespace __end { |
| 130 | 128 | { _LIBCPP_AUTO_CAST(end(__t)) } -> sentinel_for<iterator_t<_Tp>>; |
| 131 | 129 | }; |
| 132 | 130 | |
| 133 | class __fn { | |
| 134 | public: | |
| 131 | struct __fn { | |
| 135 | 132 | template <class _Tp, size_t _Np> |
| 136 | 133 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp (&__t)[_Np]) const noexcept |
| 137 | requires (sizeof(_Tp) != 0) // Disallow incomplete element types. | |
| 134 | requires (sizeof(_Tp) >= 0) // Disallow incomplete element types. | |
| 138 | 135 | { |
| 139 | 136 | return __t + _Np; |
| 140 | 137 | } |
| ... | ... | @@ -220,7 +217,7 @@ inline namespace __cpo { |
| 220 | 217 | } // namespace __cpo |
| 221 | 218 | } // namespace ranges |
| 222 | 219 | |
| 223 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 220 | #endif // _LIBCPP_STD_VER > 17 | |
| 224 | 221 | |
| 225 | 222 | _LIBCPP_END_NAMESPACE_STD |
| 226 | 223 |
lib/libcxx/include/__ranges/all.h+13-12| ... | ... | @@ -23,12 +23,12 @@ |
| 23 | 23 | #include <type_traits> |
| 24 | 24 | |
| 25 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | |
| 31 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | 32 | |
| 33 | 33 | namespace ranges::views { |
| 34 | 34 | |
| ... | ... | @@ -38,30 +38,31 @@ namespace __all { |
| 38 | 38 | requires ranges::view<decay_t<_Tp>> |
| 39 | 39 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 40 | 40 | constexpr auto operator()(_Tp&& __t) const |
| 41 | noexcept(noexcept(_LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t)))) | |
| 41 | noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))) | |
| 42 | -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) | |
| 42 | 43 | { |
| 43 | return _LIBCPP_AUTO_CAST(_VSTD::forward<_Tp>(__t)); | |
| 44 | return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)); | |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | 47 | template<class _Tp> |
| 47 | 48 | requires (!ranges::view<decay_t<_Tp>>) && |
| 48 | requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } | |
| 49 | requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; } | |
| 49 | 50 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 50 | 51 | constexpr auto operator()(_Tp&& __t) const |
| 51 | noexcept(noexcept(ranges::ref_view{_VSTD::forward<_Tp>(__t)})) | |
| 52 | noexcept(noexcept(ranges::ref_view{std::forward<_Tp>(__t)})) | |
| 52 | 53 | { |
| 53 | return ranges::ref_view{_VSTD::forward<_Tp>(__t)}; | |
| 54 | return ranges::ref_view{std::forward<_Tp>(__t)}; | |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | 57 | template<class _Tp> |
| 57 | 58 | requires (!ranges::view<decay_t<_Tp>> && |
| 58 | !requires (_Tp&& __t) { ranges::ref_view{_VSTD::forward<_Tp>(__t)}; } && | |
| 59 | requires (_Tp&& __t) { ranges::owning_view{_VSTD::forward<_Tp>(__t)}; }) | |
| 59 | !requires (_Tp&& __t) { ranges::ref_view{std::forward<_Tp>(__t)}; } && | |
| 60 | requires (_Tp&& __t) { ranges::owning_view{std::forward<_Tp>(__t)}; }) | |
| 60 | 61 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 61 | 62 | constexpr auto operator()(_Tp&& __t) const |
| 62 | noexcept(noexcept(ranges::owning_view{_VSTD::forward<_Tp>(__t)})) | |
| 63 | noexcept(noexcept(ranges::owning_view{std::forward<_Tp>(__t)})) | |
| 63 | 64 | { |
| 64 | return ranges::owning_view{_VSTD::forward<_Tp>(__t)}; | |
| 65 | return ranges::owning_view{std::forward<_Tp>(__t)}; | |
| 65 | 66 | } |
| 66 | 67 | }; |
| 67 | 68 | } // namespace __all |
| ... | ... | @@ -75,7 +76,7 @@ using all_t = decltype(views::all(declval<_Range>())); |
| 75 | 76 | |
| 76 | 77 | } // namespace ranges::views |
| 77 | 78 | |
| 78 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | 80 | |
| 80 | 81 | _LIBCPP_END_NAMESPACE_STD |
| 81 | 82 |
lib/libcxx/include/__ranges/common_view.h+11-11| ... | ... | @@ -25,12 +25,12 @@ |
| 25 | 25 | #include <type_traits> |
| 26 | 26 | |
| 27 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | #pragma GCC system_header | |
| 28 | # pragma GCC system_header | |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | 31 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 32 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | 34 | |
| 35 | 35 | namespace ranges { |
| 36 | 36 | |
| ... | ... | @@ -44,13 +44,13 @@ public: |
| 44 | 44 | common_view() requires default_initializable<_View> = default; |
| 45 | 45 | |
| 46 | 46 | _LIBCPP_HIDE_FROM_ABI |
| 47 | constexpr explicit common_view(_View __v) : __base_(_VSTD::move(__v)) { } | |
| 47 | constexpr explicit common_view(_View __v) : __base_(std::move(__v)) { } | |
| 48 | 48 | |
| 49 | 49 | _LIBCPP_HIDE_FROM_ABI |
| 50 | 50 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } |
| 51 | 51 | |
| 52 | 52 | _LIBCPP_HIDE_FROM_ABI |
| 53 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 53 | constexpr _View base() && { return std::move(__base_); } | |
| 54 | 54 | |
| 55 | 55 | _LIBCPP_HIDE_FROM_ABI |
| 56 | 56 | constexpr auto begin() { |
| ... | ... | @@ -109,16 +109,16 @@ namespace __common { |
| 109 | 109 | requires common_range<_Range> |
| 110 | 110 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 111 | 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)); } | |
| 112 | noexcept(noexcept(views::all(std::forward<_Range>(__range)))) | |
| 113 | -> decltype( views::all(std::forward<_Range>(__range))) | |
| 114 | { return views::all(std::forward<_Range>(__range)); } | |
| 115 | 115 | |
| 116 | 116 | template<class _Range> |
| 117 | 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 118 | 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)}; } | |
| 119 | noexcept(noexcept(common_view{std::forward<_Range>(__range)})) | |
| 120 | -> decltype( common_view{std::forward<_Range>(__range)}) | |
| 121 | { return common_view{std::forward<_Range>(__range)}; } | |
| 122 | 122 | }; |
| 123 | 123 | } // namespace __common |
| 124 | 124 | |
| ... | ... | @@ -128,7 +128,7 @@ inline namespace __cpo { |
| 128 | 128 | } // namespace views |
| 129 | 129 | } // namespace ranges |
| 130 | 130 | |
| 131 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 131 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 132 | 132 | |
| 133 | 133 | _LIBCPP_END_NAMESPACE_STD |
| 134 | 134 |
lib/libcxx/include/__ranges/concepts.h+3-3| ... | ... | @@ -27,12 +27,12 @@ |
| 27 | 27 | #include <type_traits> |
| 28 | 28 | |
| 29 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 30 | #pragma GCC system_header | |
| 30 | # pragma GCC system_header | |
| 31 | 31 | #endif |
| 32 | 32 | |
| 33 | 33 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 34 | 34 | |
| 35 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 35 | #if _LIBCPP_STD_VER > 17 | |
| 36 | 36 | |
| 37 | 37 | namespace ranges { |
| 38 | 38 | |
| ... | ... | @@ -135,7 +135,7 @@ namespace ranges { |
| 135 | 135 | |
| 136 | 136 | } // namespace ranges |
| 137 | 137 | |
| 138 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 138 | #endif // _LIBCPP_STD_VER > 17 | |
| 139 | 139 | |
| 140 | 140 | _LIBCPP_END_NAMESPACE_STD |
| 141 | 141 |
lib/libcxx/include/__ranges/copyable_box.h+18-18| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | 28 | |
| 29 | 29 | // __copyable_box allows turning a type that is copy-constructible (but maybe not copy-assignable) into |
| 30 | 30 | // a type that is both copy-constructible and copy-assignable. It does that by introducing an empty state |
| ... | ... | @@ -41,7 +41,7 @@ namespace ranges { |
| 41 | 41 | // Primary template - uses std::optional and introduces an empty state in case assignment fails. |
| 42 | 42 | template<__copy_constructible_object _Tp> |
| 43 | 43 | class __copyable_box { |
| 44 | [[no_unique_address]] optional<_Tp> __val_; | |
| 44 | _LIBCPP_NO_UNIQUE_ADDRESS optional<_Tp> __val_; | |
| 45 | 45 | |
| 46 | 46 | public: |
| 47 | 47 | template<class ..._Args> |
| ... | ... | @@ -49,7 +49,7 @@ namespace ranges { |
| 49 | 49 | _LIBCPP_HIDE_FROM_ABI |
| 50 | 50 | constexpr explicit __copyable_box(in_place_t, _Args&& ...__args) |
| 51 | 51 | noexcept(is_nothrow_constructible_v<_Tp, _Args...>) |
| 52 | : __val_(in_place, _VSTD::forward<_Args>(__args)...) | |
| 52 | : __val_(in_place, std::forward<_Args>(__args)...) | |
| 53 | 53 | { } |
| 54 | 54 | |
| 55 | 55 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -65,7 +65,7 @@ namespace ranges { |
| 65 | 65 | constexpr __copyable_box& operator=(__copyable_box const& __other) |
| 66 | 66 | noexcept(is_nothrow_copy_constructible_v<_Tp>) |
| 67 | 67 | { |
| 68 | if (this != _VSTD::addressof(__other)) { | |
| 68 | if (this != std::addressof(__other)) { | |
| 69 | 69 | if (__other.__has_value()) __val_.emplace(*__other); |
| 70 | 70 | else __val_.reset(); |
| 71 | 71 | } |
| ... | ... | @@ -79,8 +79,8 @@ namespace ranges { |
| 79 | 79 | constexpr __copyable_box& operator=(__copyable_box&& __other) |
| 80 | 80 | noexcept(is_nothrow_move_constructible_v<_Tp>) |
| 81 | 81 | { |
| 82 | if (this != _VSTD::addressof(__other)) { | |
| 83 | if (__other.__has_value()) __val_.emplace(_VSTD::move(*__other)); | |
| 82 | if (this != std::addressof(__other)) { | |
| 83 | if (__other.__has_value()) __val_.emplace(std::move(*__other)); | |
| 84 | 84 | else __val_.reset(); |
| 85 | 85 | } |
| 86 | 86 | return *this; |
| ... | ... | @@ -116,7 +116,7 @@ namespace ranges { |
| 116 | 116 | template<__copy_constructible_object _Tp> |
| 117 | 117 | requires __doesnt_need_empty_state_for_copy<_Tp> && __doesnt_need_empty_state_for_move<_Tp> |
| 118 | 118 | class __copyable_box<_Tp> { |
| 119 | [[no_unique_address]] _Tp __val_; | |
| 119 | _LIBCPP_NO_UNIQUE_ADDRESS _Tp __val_; | |
| 120 | 120 | |
| 121 | 121 | public: |
| 122 | 122 | template<class ..._Args> |
| ... | ... | @@ -124,7 +124,7 @@ namespace ranges { |
| 124 | 124 | _LIBCPP_HIDE_FROM_ABI |
| 125 | 125 | constexpr explicit __copyable_box(in_place_t, _Args&& ...__args) |
| 126 | 126 | noexcept(is_nothrow_constructible_v<_Tp, _Args...>) |
| 127 | : __val_(_VSTD::forward<_Args>(__args)...) | |
| 127 | : __val_(std::forward<_Args>(__args)...) | |
| 128 | 128 | { } |
| 129 | 129 | |
| 130 | 130 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -144,9 +144,9 @@ namespace ranges { |
| 144 | 144 | _LIBCPP_HIDE_FROM_ABI |
| 145 | 145 | constexpr __copyable_box& operator=(__copyable_box const& __other) noexcept { |
| 146 | 146 | static_assert(is_nothrow_copy_constructible_v<_Tp>); |
| 147 | if (this != _VSTD::addressof(__other)) { | |
| 148 | _VSTD::destroy_at(_VSTD::addressof(__val_)); | |
| 149 | _VSTD::construct_at(_VSTD::addressof(__val_), __other.__val_); | |
| 147 | if (this != std::addressof(__other)) { | |
| 148 | std::destroy_at(std::addressof(__val_)); | |
| 149 | std::construct_at(std::addressof(__val_), __other.__val_); | |
| 150 | 150 | } |
| 151 | 151 | return *this; |
| 152 | 152 | } |
| ... | ... | @@ -154,9 +154,9 @@ namespace ranges { |
| 154 | 154 | _LIBCPP_HIDE_FROM_ABI |
| 155 | 155 | constexpr __copyable_box& operator=(__copyable_box&& __other) noexcept { |
| 156 | 156 | static_assert(is_nothrow_move_constructible_v<_Tp>); |
| 157 | if (this != _VSTD::addressof(__other)) { | |
| 158 | _VSTD::destroy_at(_VSTD::addressof(__val_)); | |
| 159 | _VSTD::construct_at(_VSTD::addressof(__val_), _VSTD::move(__other.__val_)); | |
| 157 | if (this != std::addressof(__other)) { | |
| 158 | std::destroy_at(std::addressof(__val_)); | |
| 159 | std::construct_at(std::addressof(__val_), std::move(__other.__val_)); | |
| 160 | 160 | } |
| 161 | 161 | return *this; |
| 162 | 162 | } |
| ... | ... | @@ -164,14 +164,14 @@ namespace ranges { |
| 164 | 164 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& operator*() const noexcept { return __val_; } |
| 165 | 165 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() noexcept { return __val_; } |
| 166 | 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_); } | |
| 167 | _LIBCPP_HIDE_FROM_ABI constexpr const _Tp *operator->() const noexcept { return std::addressof(__val_); } | |
| 168 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp *operator->() noexcept { return std::addressof(__val_); } | |
| 169 | 169 | |
| 170 | 170 | _LIBCPP_HIDE_FROM_ABI constexpr bool __has_value() const noexcept { return true; } |
| 171 | 171 | }; |
| 172 | 172 | } // namespace ranges |
| 173 | 173 | |
| 174 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 174 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 175 | 175 | |
| 176 | 176 | _LIBCPP_END_NAMESPACE_STD |
| 177 | 177 |
lib/libcxx/include/__ranges/counted.h+11-11| ... | ... | @@ -24,12 +24,12 @@ |
| 24 | 24 | #include <type_traits> |
| 25 | 25 | |
| 26 | 26 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 27 | #pragma GCC system_header | |
| 27 | # pragma GCC system_header | |
| 28 | 28 | #endif |
| 29 | 29 | |
| 30 | 30 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 31 | 31 | |
| 32 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 33 | 33 | |
| 34 | 34 | namespace ranges::views { |
| 35 | 35 | |
| ... | ... | @@ -39,9 +39,9 @@ namespace __counted { |
| 39 | 39 | template<contiguous_iterator _It> |
| 40 | 40 | _LIBCPP_HIDE_FROM_ABI |
| 41 | 41 | static constexpr auto __go(_It __it, iter_difference_t<_It> __count) |
| 42 | noexcept(noexcept(span(_VSTD::to_address(__it), static_cast<size_t>(__count)))) | |
| 42 | noexcept(noexcept(span(std::to_address(__it), static_cast<size_t>(__count)))) | |
| 43 | 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)); } | |
| 44 | { return span(std::to_address(__it), static_cast<size_t>(__count)); } | |
| 45 | 45 | |
| 46 | 46 | template<random_access_iterator _It> |
| 47 | 47 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -53,17 +53,17 @@ namespace __counted { |
| 53 | 53 | template<class _It> |
| 54 | 54 | _LIBCPP_HIDE_FROM_ABI |
| 55 | 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); } | |
| 56 | noexcept(noexcept(subrange(counted_iterator(std::move(__it), __count), default_sentinel))) | |
| 57 | -> decltype( subrange(counted_iterator(std::move(__it), __count), default_sentinel)) | |
| 58 | { return subrange(counted_iterator(std::move(__it), __count), default_sentinel); } | |
| 59 | 59 | |
| 60 | 60 | template<class _It, convertible_to<iter_difference_t<_It>> _Diff> |
| 61 | 61 | requires input_or_output_iterator<decay_t<_It>> |
| 62 | 62 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 63 | 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)); } | |
| 64 | noexcept(noexcept(__go(std::forward<_It>(__it), std::forward<_Diff>(__count)))) | |
| 65 | -> decltype( __go(std::forward<_It>(__it), std::forward<_Diff>(__count))) | |
| 66 | { return __go(std::forward<_It>(__it), std::forward<_Diff>(__count)); } | |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | 69 | } // namespace __counted |
| ... | ... | @@ -74,7 +74,7 @@ inline namespace __cpo { |
| 74 | 74 | |
| 75 | 75 | } // namespace ranges::views |
| 76 | 76 | |
| 77 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 77 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | 78 | |
| 79 | 79 | _LIBCPP_END_NAMESPACE_STD |
| 80 | 80 |
lib/libcxx/include/__ranges/dangling.h+3-3| ... | ... | @@ -16,12 +16,12 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 23 | |
| 24 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | 25 | |
| 26 | 26 | namespace ranges { |
| 27 | 27 | struct dangling { |
| ... | ... | @@ -35,7 +35,7 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>; |
| 35 | 35 | // borrowed_subrange_t defined in <__ranges/subrange.h> |
| 36 | 36 | } // namespace ranges |
| 37 | 37 | |
| 38 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 38 | #endif // _LIBCPP_STD_VER > 17 | |
| 39 | 39 | |
| 40 | 40 | _LIBCPP_END_NAMESPACE_STD |
| 41 | 41 |
lib/libcxx/include/__ranges/data.h+5-5| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | 28 | |
| 29 | 29 | // [range.prim.data] |
| 30 | 30 | |
| ... | ... | @@ -60,8 +60,8 @@ namespace __data { |
| 60 | 60 | template<__ranges_begin_invocable _Tp> |
| 61 | 61 | _LIBCPP_HIDE_FROM_ABI |
| 62 | 62 | constexpr auto operator()(_Tp&& __t) const |
| 63 | noexcept(noexcept(_VSTD::to_address(ranges::begin(__t)))) { | |
| 64 | return _VSTD::to_address(ranges::begin(__t)); | |
| 63 | noexcept(noexcept(std::to_address(ranges::begin(__t)))) { | |
| 64 | return std::to_address(ranges::begin(__t)); | |
| 65 | 65 | } |
| 66 | 66 | }; |
| 67 | 67 | } // namespace __data |
| ... | ... | @@ -99,7 +99,7 @@ inline namespace __cpo { |
| 99 | 99 | } // namespace __cpo |
| 100 | 100 | } // namespace ranges |
| 101 | 101 | |
| 102 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 102 | #endif // _LIBCPP_STD_VER > 17 | |
| 103 | 103 | |
| 104 | 104 | _LIBCPP_END_NAMESPACE_STD |
| 105 | 105 |
lib/libcxx/include/__ranges/drop_view.h+190-11| ... | ... | @@ -9,29 +9,43 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_DROP_VIEW_H |
| 10 | 10 | #define _LIBCPP___RANGES_DROP_VIEW_H |
| 11 | 11 | |
| 12 | #include <__algorithm/min.h> | |
| 13 | #include <__assert> | |
| 12 | 14 | #include <__config> |
| 13 | #include <__debug> | |
| 15 | #include <__functional/bind_back.h> | |
| 16 | #include <__fwd/span.h> | |
| 17 | #include <__fwd/string_view.h> | |
| 14 | 18 | #include <__iterator/concepts.h> |
| 19 | #include <__iterator/distance.h> | |
| 15 | 20 | #include <__iterator/iterator_traits.h> |
| 16 | 21 | #include <__iterator/next.h> |
| 17 | 22 | #include <__ranges/access.h> |
| 18 | 23 | #include <__ranges/all.h> |
| 19 | 24 | #include <__ranges/concepts.h> |
| 25 | #include <__ranges/empty_view.h> | |
| 20 | 26 | #include <__ranges/enable_borrowed_range.h> |
| 27 | #include <__ranges/iota_view.h> | |
| 21 | 28 | #include <__ranges/non_propagating_cache.h> |
| 29 | #include <__ranges/range_adaptor.h> | |
| 22 | 30 | #include <__ranges/size.h> |
| 31 | #include <__ranges/subrange.h> | |
| 23 | 32 | #include <__ranges/view_interface.h> |
| 33 | #include <__utility/auto_cast.h> | |
| 34 | #include <__utility/forward.h> | |
| 24 | 35 | #include <__utility/move.h> |
| 25 | 36 | #include <concepts> |
| 26 | 37 | #include <type_traits> |
| 27 | 38 | |
| 28 | 39 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | #pragma GCC system_header | |
| 40 | # pragma GCC system_header | |
| 30 | 41 | #endif |
| 31 | 42 | |
| 43 | _LIBCPP_PUSH_MACROS | |
| 44 | #include <__undef_macros> | |
| 45 | ||
| 32 | 46 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 47 | |
| 34 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 48 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | 49 | |
| 36 | 50 | namespace ranges { |
| 37 | 51 | template<view _View> |
| ... | ... | @@ -45,7 +59,7 @@ namespace ranges { |
| 45 | 59 | // one can't call begin() on it more than once. |
| 46 | 60 | static constexpr bool _UseCache = forward_range<_View> && !(random_access_range<_View> && sized_range<_View>); |
| 47 | 61 | using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; |
| 48 | [[no_unique_address]] _Cache __cached_begin_ = _Cache(); | |
| 62 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); | |
| 49 | 63 | range_difference_t<_View> __count_ = 0; |
| 50 | 64 | _View __base_ = _View(); |
| 51 | 65 | |
| ... | ... | @@ -55,13 +69,13 @@ public: |
| 55 | 69 | _LIBCPP_HIDE_FROM_ABI |
| 56 | 70 | constexpr drop_view(_View __base, range_difference_t<_View> __count) |
| 57 | 71 | : __count_(__count) |
| 58 | , __base_(_VSTD::move(__base)) | |
| 72 | , __base_(std::move(__base)) | |
| 59 | 73 | { |
| 60 | 74 | _LIBCPP_ASSERT(__count_ >= 0, "count must be greater than or equal to zero."); |
| 61 | 75 | } |
| 62 | 76 | |
| 63 | 77 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; } |
| 64 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return _VSTD::move(__base_); } | |
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } | |
| 65 | 79 | |
| 66 | 80 | _LIBCPP_HIDE_FROM_ABI |
| 67 | 81 | constexpr auto begin() |
| ... | ... | @@ -113,15 +127,180 @@ public: |
| 113 | 127 | { return __size(*this); } |
| 114 | 128 | }; |
| 115 | 129 | |
| 116 | template<class _Range> | |
| 117 | drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>; | |
| 130 | template<class _Range> | |
| 131 | drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>; | |
| 132 | ||
| 133 | template<class _Tp> | |
| 134 | inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 135 | ||
| 136 | namespace views { | |
| 137 | namespace __drop { | |
| 138 | ||
| 139 | template <class _Tp> | |
| 140 | inline constexpr bool __is_empty_view = false; | |
| 141 | ||
| 142 | template <class _Tp> | |
| 143 | inline constexpr bool __is_empty_view<empty_view<_Tp>> = true; | |
| 144 | ||
| 145 | template <class _Tp> | |
| 146 | inline constexpr bool __is_passthrough_specialization = false; | |
| 147 | ||
| 148 | template <class _Tp, size_t _Extent> | |
| 149 | inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true; | |
| 150 | ||
| 151 | template <class _CharT, class _Traits> | |
| 152 | inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true; | |
| 153 | ||
| 154 | template <class _Np, class _Bound> | |
| 155 | inline constexpr bool __is_passthrough_specialization<iota_view<_Np, _Bound>> = true; | |
| 156 | ||
| 157 | template <class _Iter, class _Sent, subrange_kind _Kind> | |
| 158 | inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = | |
| 159 | !subrange<_Iter, _Sent, _Kind>::_StoreSize; | |
| 160 | ||
| 161 | template <class _Tp> | |
| 162 | inline constexpr bool __is_subrange_specialization_with_store_size = false; | |
| 163 | ||
| 164 | template <class _Iter, class _Sent, subrange_kind _Kind> | |
| 165 | inline constexpr bool __is_subrange_specialization_with_store_size<subrange<_Iter, _Sent, _Kind>> = | |
| 166 | subrange<_Iter, _Sent, _Kind>::_StoreSize; | |
| 167 | ||
| 168 | template <class _Tp> | |
| 169 | struct __passthrough_type; | |
| 170 | ||
| 171 | template <class _Tp, size_t _Extent> | |
| 172 | struct __passthrough_type<span<_Tp, _Extent>> { | |
| 173 | using type = span<_Tp>; | |
| 174 | }; | |
| 175 | ||
| 176 | template <class _CharT, class _Traits> | |
| 177 | struct __passthrough_type<basic_string_view<_CharT, _Traits>> { | |
| 178 | using type = basic_string_view<_CharT, _Traits>; | |
| 179 | }; | |
| 180 | ||
| 181 | template <class _Np, class _Bound> | |
| 182 | struct __passthrough_type<iota_view<_Np, _Bound>> { | |
| 183 | using type = iota_view<_Np, _Bound>; | |
| 184 | }; | |
| 185 | ||
| 186 | template <class _Iter, class _Sent, subrange_kind _Kind> | |
| 187 | struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { | |
| 188 | using type = subrange<_Iter, _Sent, _Kind>; | |
| 189 | }; | |
| 190 | ||
| 191 | template <class _Tp> | |
| 192 | using __passthrough_type_t = typename __passthrough_type<_Tp>::type; | |
| 193 | ||
| 194 | struct __fn { | |
| 195 | // [range.drop.overview]: the `empty_view` case. | |
| 196 | template <class _Range, convertible_to<range_difference_t<_Range>> _Np> | |
| 197 | requires __is_empty_view<remove_cvref_t<_Range>> | |
| 198 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 199 | constexpr auto operator()(_Range&& __range, _Np&&) const | |
| 200 | noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))) | |
| 201 | -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) | |
| 202 | { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); } | |
| 203 | ||
| 204 | // [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case. | |
| 205 | template <class _Range, | |
| 206 | convertible_to<range_difference_t<_Range>> _Np, | |
| 207 | class _RawRange = remove_cvref_t<_Range>, | |
| 208 | class _Dist = range_difference_t<_Range>> | |
| 209 | requires (!__is_empty_view<_RawRange> && | |
| 210 | random_access_range<_RawRange> && | |
| 211 | sized_range<_RawRange> && | |
| 212 | __is_passthrough_specialization<_RawRange>) | |
| 213 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 214 | constexpr auto operator()(_Range&& __rng, _Np&& __n) const | |
| 215 | noexcept(noexcept(__passthrough_type_t<_RawRange>( | |
| 216 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), | |
| 217 | ranges::end(__rng) | |
| 218 | ))) | |
| 219 | -> decltype( __passthrough_type_t<_RawRange>( | |
| 220 | // Note: deliberately not forwarding `__rng` to guard against double moves. | |
| 221 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), | |
| 222 | ranges::end(__rng) | |
| 223 | )) | |
| 224 | { return __passthrough_type_t<_RawRange>( | |
| 225 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), | |
| 226 | ranges::end(__rng) | |
| 227 | ); } | |
| 228 | ||
| 229 | // [range.drop.overview]: the `subrange (StoreSize == true)` case. | |
| 230 | template <class _Range, | |
| 231 | convertible_to<range_difference_t<_Range>> _Np, | |
| 232 | class _RawRange = remove_cvref_t<_Range>, | |
| 233 | class _Dist = range_difference_t<_Range>> | |
| 234 | requires (!__is_empty_view<_RawRange> && | |
| 235 | random_access_range<_RawRange> && | |
| 236 | sized_range<_RawRange> && | |
| 237 | __is_subrange_specialization_with_store_size<_RawRange>) | |
| 238 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 239 | constexpr auto operator()(_Range&& __rng, _Np&& __n) const | |
| 240 | noexcept(noexcept(_RawRange( | |
| 241 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), | |
| 242 | ranges::end(__rng), | |
| 243 | std::__to_unsigned_like(ranges::distance(__rng) - | |
| 244 | std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))) | |
| 245 | ))) | |
| 246 | -> decltype( _RawRange( | |
| 247 | // Note: deliberately not forwarding `__rng` to guard against double moves. | |
| 248 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), | |
| 249 | ranges::end(__rng), | |
| 250 | std::__to_unsigned_like(ranges::distance(__rng) - | |
| 251 | std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))) | |
| 252 | )) | |
| 253 | { | |
| 254 | // Introducing local variables avoids calculating `min` and `distance` twice (at the cost of diverging from the | |
| 255 | // expression used in the `noexcept` clause and the return statement). | |
| 256 | auto dist = ranges::distance(__rng); | |
| 257 | auto clamped = std::min<_Dist>(dist, std::forward<_Np>(__n)); | |
| 258 | return _RawRange( | |
| 259 | ranges::begin(__rng) + clamped, | |
| 260 | ranges::end(__rng), | |
| 261 | std::__to_unsigned_like(dist - clamped) | |
| 262 | );} | |
| 263 | ||
| 264 | // [range.drop.overview]: the "otherwise" case. | |
| 265 | template <class _Range, convertible_to<range_difference_t<_Range>> _Np, | |
| 266 | class _RawRange = remove_cvref_t<_Range>> | |
| 267 | // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other | |
| 268 | // overloads. | |
| 269 | requires (!(__is_empty_view<_RawRange> || | |
| 270 | (__is_subrange_specialization_with_store_size<_RawRange> && | |
| 271 | sized_range<_RawRange> && | |
| 272 | random_access_range<_RawRange>) || | |
| 273 | (__is_passthrough_specialization<_RawRange> && | |
| 274 | sized_range<_RawRange> && | |
| 275 | random_access_range<_RawRange>) | |
| 276 | )) | |
| 277 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 278 | constexpr auto operator()(_Range&& __range, _Np&& __n) const | |
| 279 | noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))) | |
| 280 | -> decltype( drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) | |
| 281 | { return drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); } | |
| 282 | ||
| 283 | template <class _Np> | |
| 284 | requires constructible_from<decay_t<_Np>, _Np> | |
| 285 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 286 | constexpr auto operator()(_Np&& __n) const | |
| 287 | noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) | |
| 288 | { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); } | |
| 289 | }; | |
| 290 | ||
| 291 | } // namespace __drop | |
| 292 | ||
| 293 | inline namespace __cpo { | |
| 294 | inline constexpr auto drop = __drop::__fn{}; | |
| 295 | } // namespace __cpo | |
| 296 | } // namespace views | |
| 118 | 297 | |
| 119 | template<class _Tp> | |
| 120 | inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 121 | 298 | } // namespace ranges |
| 122 | 299 | |
| 123 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 300 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 124 | 301 | |
| 125 | 302 | _LIBCPP_END_NAMESPACE_STD |
| 126 | 303 | |
| 304 | _LIBCPP_POP_MACROS | |
| 305 | ||
| 127 | 306 | #endif // _LIBCPP___RANGES_DROP_VIEW_H |
lib/libcxx/include/__ranges/empty.h+3-3| ... | ... | @@ -17,12 +17,12 @@ |
| 17 | 17 | #include <type_traits> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 25 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 26 | 26 | |
| 27 | 27 | // [range.prim.empty] |
| 28 | 28 | |
| ... | ... | @@ -75,7 +75,7 @@ inline namespace __cpo { |
| 75 | 75 | } // namespace __cpo |
| 76 | 76 | } // namespace ranges |
| 77 | 77 | |
| 78 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 79 | 79 | |
| 80 | 80 | _LIBCPP_END_NAMESPACE_STD |
| 81 | 81 |
lib/libcxx/include/__ranges/empty_view.h+10-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 23 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 24 | 24 | |
| 25 | 25 | namespace ranges { |
| 26 | 26 | template<class _Tp> |
| ... | ... | @@ -36,9 +36,16 @@ namespace ranges { |
| 36 | 36 | |
| 37 | 37 | template<class _Tp> |
| 38 | 38 | inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true; |
| 39 | ||
| 40 | namespace views { | |
| 41 | ||
| 42 | template <class _Tp> | |
| 43 | inline constexpr empty_view<_Tp> empty{}; | |
| 44 | ||
| 45 | } // namespace views | |
| 39 | 46 | } // namespace ranges |
| 40 | 47 | |
| 41 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 48 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 42 | 49 | |
| 43 | 50 | _LIBCPP_END_NAMESPACE_STD |
| 44 | 51 |
lib/libcxx/include/__ranges/enable_borrowed_range.h+3-3| ... | ... | @@ -17,12 +17,12 @@ |
| 17 | 17 | #include <__config> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 24 | |
| 25 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | 26 | |
| 27 | 27 | namespace ranges { |
| 28 | 28 | |
| ... | ... | @@ -33,7 +33,7 @@ inline constexpr bool enable_borrowed_range = false; |
| 33 | 33 | |
| 34 | 34 | } // namespace ranges |
| 35 | 35 | |
| 36 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 36 | #endif // _LIBCPP_STD_VER > 17 | |
| 37 | 37 | |
| 38 | 38 | _LIBCPP_END_NAMESPACE_STD |
| 39 | 39 |
lib/libcxx/include/__ranges/enable_view.h+3-3| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 22 | 22 | |
| 23 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 23 | #if _LIBCPP_STD_VER > 17 | |
| 24 | 24 | |
| 25 | 25 | namespace ranges { |
| 26 | 26 | |
| ... | ... | @@ -40,7 +40,7 @@ inline constexpr bool enable_view = derived_from<_Tp, view_base> || |
| 40 | 40 | |
| 41 | 41 | } // namespace ranges |
| 42 | 42 | |
| 43 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 43 | #endif // _LIBCPP_STD_VER > 17 | |
| 44 | 44 | |
| 45 | 45 | _LIBCPP_END_NAMESPACE_STD |
| 46 | 46 |
lib/libcxx/include/__ranges/filter_view.h created+259| ... | ... | @@ -0,0 +1,259 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP___RANGES_FILTER_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_FILTER_VIEW_H | |
| 11 | ||
| 12 | #include <__algorithm/ranges_find_if.h> | |
| 13 | #include <__config> | |
| 14 | #include <__debug> | |
| 15 | #include <__functional/bind_back.h> | |
| 16 | #include <__functional/invoke.h> | |
| 17 | #include <__functional/reference_wrapper.h> | |
| 18 | #include <__iterator/concepts.h> | |
| 19 | #include <__iterator/iter_move.h> | |
| 20 | #include <__iterator/iter_swap.h> | |
| 21 | #include <__iterator/iterator_traits.h> | |
| 22 | #include <__memory/addressof.h> | |
| 23 | #include <__ranges/access.h> | |
| 24 | #include <__ranges/all.h> | |
| 25 | #include <__ranges/concepts.h> | |
| 26 | #include <__ranges/copyable_box.h> | |
| 27 | #include <__ranges/non_propagating_cache.h> | |
| 28 | #include <__ranges/range_adaptor.h> | |
| 29 | #include <__ranges/view_interface.h> | |
| 30 | #include <__utility/forward.h> | |
| 31 | #include <__utility/in_place.h> | |
| 32 | #include <__utility/move.h> | |
| 33 | #include <concepts> | |
| 34 | #include <type_traits> | |
| 35 | ||
| 36 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 37 | # pragma GCC system_header | |
| 38 | #endif | |
| 39 | ||
| 40 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 41 | ||
| 42 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 43 | ||
| 44 | namespace ranges { | |
| 45 | template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred> | |
| 46 | requires view<_View> && is_object_v<_Pred> | |
| 47 | class filter_view : public view_interface<filter_view<_View, _Pred>> { | |
| 48 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | |
| 49 | _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Pred> __pred_; | |
| 50 | ||
| 51 | // We cache the result of begin() to allow providing an amortized O(1) begin() whenever | |
| 52 | // the underlying range is at least a forward_range. | |
| 53 | static constexpr bool _UseCache = forward_range<_View>; | |
| 54 | using _Cache = _If<_UseCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 55 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); | |
| 56 | ||
| 57 | class __iterator; | |
| 58 | class __sentinel; | |
| 59 | ||
| 60 | public: | |
| 61 | _LIBCPP_HIDE_FROM_ABI | |
| 62 | filter_view() requires default_initializable<_View> && default_initializable<_Pred> = default; | |
| 63 | ||
| 64 | _LIBCPP_HIDE_FROM_ABI | |
| 65 | constexpr filter_view(_View __base, _Pred __pred) | |
| 66 | : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) | |
| 67 | { } | |
| 68 | ||
| 69 | template<class _Vp = _View> | |
| 70 | _LIBCPP_HIDE_FROM_ABI | |
| 71 | constexpr _View base() const& requires copy_constructible<_Vp> { return __base_; } | |
| 72 | _LIBCPP_HIDE_FROM_ABI | |
| 73 | constexpr _View base() && { return std::move(__base_); } | |
| 74 | ||
| 75 | _LIBCPP_HIDE_FROM_ABI | |
| 76 | constexpr _Pred const& pred() const { return *__pred_; } | |
| 77 | ||
| 78 | _LIBCPP_HIDE_FROM_ABI | |
| 79 | constexpr __iterator begin() { | |
| 80 | _LIBCPP_ASSERT(__pred_.__has_value(), "Trying to call begin() on a filter_view that does not have a valid predicate."); | |
| 81 | if constexpr (_UseCache) { | |
| 82 | if (!__cached_begin_.__has_value()) { | |
| 83 | __cached_begin_.__emplace(ranges::find_if(__base_, std::ref(*__pred_))); | |
| 84 | } | |
| 85 | return {*this, *__cached_begin_}; | |
| 86 | } else { | |
| 87 | return {*this, ranges::find_if(__base_, std::ref(*__pred_))}; | |
| 88 | } | |
| 89 | } | |
| 90 | ||
| 91 | _LIBCPP_HIDE_FROM_ABI | |
| 92 | constexpr auto end() { | |
| 93 | if constexpr (common_range<_View>) | |
| 94 | return __iterator{*this, ranges::end(__base_)}; | |
| 95 | else | |
| 96 | return __sentinel{*this}; | |
| 97 | } | |
| 98 | }; | |
| 99 | ||
| 100 | template<class _Range, class _Pred> | |
| 101 | filter_view(_Range&&, _Pred) -> filter_view<views::all_t<_Range>, _Pred>; | |
| 102 | ||
| 103 | template<class _View> | |
| 104 | struct __filter_iterator_category { }; | |
| 105 | ||
| 106 | template<forward_range _View> | |
| 107 | struct __filter_iterator_category<_View> { | |
| 108 | using _Cat = typename iterator_traits<iterator_t<_View>>::iterator_category; | |
| 109 | using iterator_category = | |
| 110 | _If<derived_from<_Cat, bidirectional_iterator_tag>, bidirectional_iterator_tag, | |
| 111 | _If<derived_from<_Cat, forward_iterator_tag>, forward_iterator_tag, | |
| 112 | /* else */ _Cat | |
| 113 | >>; | |
| 114 | }; | |
| 115 | ||
| 116 | template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred> | |
| 117 | requires view<_View> && is_object_v<_Pred> | |
| 118 | class filter_view<_View, _Pred>::__iterator : public __filter_iterator_category<_View> { | |
| 119 | public: | |
| 120 | _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>(); | |
| 121 | _LIBCPP_NO_UNIQUE_ADDRESS filter_view* __parent_ = nullptr; | |
| 122 | ||
| 123 | using iterator_concept = | |
| 124 | _If<bidirectional_range<_View>, bidirectional_iterator_tag, | |
| 125 | _If<forward_range<_View>, forward_iterator_tag, | |
| 126 | /* else */ input_iterator_tag | |
| 127 | >>; | |
| 128 | // using iterator_category = inherited; | |
| 129 | using value_type = range_value_t<_View>; | |
| 130 | using difference_type = range_difference_t<_View>; | |
| 131 | ||
| 132 | _LIBCPP_HIDE_FROM_ABI | |
| 133 | __iterator() requires default_initializable<iterator_t<_View>> = default; | |
| 134 | ||
| 135 | _LIBCPP_HIDE_FROM_ABI | |
| 136 | constexpr __iterator(filter_view& __parent, iterator_t<_View> __current) | |
| 137 | : __current_(std::move(__current)), __parent_(std::addressof(__parent)) | |
| 138 | { } | |
| 139 | ||
| 140 | _LIBCPP_HIDE_FROM_ABI | |
| 141 | constexpr iterator_t<_View> const& base() const& noexcept { return __current_; } | |
| 142 | _LIBCPP_HIDE_FROM_ABI | |
| 143 | constexpr iterator_t<_View> base() && { return std::move(__current_); } | |
| 144 | ||
| 145 | _LIBCPP_HIDE_FROM_ABI | |
| 146 | constexpr range_reference_t<_View> operator*() const { return *__current_; } | |
| 147 | _LIBCPP_HIDE_FROM_ABI | |
| 148 | constexpr iterator_t<_View> operator->() const | |
| 149 | requires __has_arrow<iterator_t<_View>> && copyable<iterator_t<_View>> | |
| 150 | { | |
| 151 | return __current_; | |
| 152 | } | |
| 153 | ||
| 154 | _LIBCPP_HIDE_FROM_ABI | |
| 155 | constexpr __iterator& operator++() { | |
| 156 | __current_ = ranges::find_if(std::move(++__current_), ranges::end(__parent_->__base_), | |
| 157 | std::ref(*__parent_->__pred_)); | |
| 158 | return *this; | |
| 159 | } | |
| 160 | _LIBCPP_HIDE_FROM_ABI | |
| 161 | constexpr void operator++(int) { ++*this; } | |
| 162 | _LIBCPP_HIDE_FROM_ABI | |
| 163 | constexpr __iterator operator++(int) requires forward_range<_View> { | |
| 164 | auto __tmp = *this; | |
| 165 | ++*this; | |
| 166 | return __tmp; | |
| 167 | } | |
| 168 | ||
| 169 | _LIBCPP_HIDE_FROM_ABI | |
| 170 | constexpr __iterator& operator--() requires bidirectional_range<_View> { | |
| 171 | do { | |
| 172 | --__current_; | |
| 173 | } while (!std::invoke(*__parent_->__pred_, *__current_)); | |
| 174 | return *this; | |
| 175 | } | |
| 176 | _LIBCPP_HIDE_FROM_ABI | |
| 177 | constexpr __iterator operator--(int) requires bidirectional_range<_View> { | |
| 178 | auto tmp = *this; | |
| 179 | --*this; | |
| 180 | return tmp; | |
| 181 | } | |
| 182 | ||
| 183 | _LIBCPP_HIDE_FROM_ABI | |
| 184 | friend constexpr bool operator==(__iterator const& __x, __iterator const& __y) | |
| 185 | requires equality_comparable<iterator_t<_View>> | |
| 186 | { | |
| 187 | return __x.__current_ == __y.__current_; | |
| 188 | } | |
| 189 | ||
| 190 | _LIBCPP_HIDE_FROM_ABI | |
| 191 | friend constexpr range_rvalue_reference_t<_View> iter_move(__iterator const& __it) | |
| 192 | noexcept(noexcept(ranges::iter_move(__it.__current_))) | |
| 193 | { | |
| 194 | return ranges::iter_move(__it.__current_); | |
| 195 | } | |
| 196 | ||
| 197 | _LIBCPP_HIDE_FROM_ABI | |
| 198 | friend constexpr void iter_swap(__iterator const& __x, __iterator const& __y) | |
| 199 | noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) | |
| 200 | requires indirectly_swappable<iterator_t<_View>> | |
| 201 | { | |
| 202 | return ranges::iter_swap(__x.__current_, __y.__current_); | |
| 203 | } | |
| 204 | }; | |
| 205 | ||
| 206 | template<input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred> | |
| 207 | requires view<_View> && is_object_v<_Pred> | |
| 208 | class filter_view<_View, _Pred>::__sentinel { | |
| 209 | public: | |
| 210 | sentinel_t<_View> __end_ = sentinel_t<_View>(); | |
| 211 | ||
| 212 | _LIBCPP_HIDE_FROM_ABI | |
| 213 | __sentinel() = default; | |
| 214 | ||
| 215 | _LIBCPP_HIDE_FROM_ABI | |
| 216 | constexpr explicit __sentinel(filter_view& __parent) | |
| 217 | : __end_(ranges::end(__parent.__base_)) | |
| 218 | { } | |
| 219 | ||
| 220 | _LIBCPP_HIDE_FROM_ABI | |
| 221 | constexpr sentinel_t<_View> base() const { return __end_; } | |
| 222 | ||
| 223 | _LIBCPP_HIDE_FROM_ABI | |
| 224 | friend constexpr bool operator==(__iterator const& __x, __sentinel const& __y) { | |
| 225 | return __x.__current_ == __y.__end_; | |
| 226 | } | |
| 227 | }; | |
| 228 | ||
| 229 | namespace views { | |
| 230 | namespace __filter { | |
| 231 | struct __fn { | |
| 232 | template<class _Range, class _Pred> | |
| 233 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 234 | constexpr auto operator()(_Range&& __range, _Pred&& __pred) const | |
| 235 | noexcept(noexcept(filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))) | |
| 236 | -> decltype( filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) | |
| 237 | { return filter_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); } | |
| 238 | ||
| 239 | template<class _Pred> | |
| 240 | requires constructible_from<decay_t<_Pred>, _Pred> | |
| 241 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 242 | constexpr auto operator()(_Pred&& __pred) const | |
| 243 | noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) | |
| 244 | { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); } | |
| 245 | }; | |
| 246 | } // namespace __filter | |
| 247 | ||
| 248 | inline namespace __cpo { | |
| 249 | inline constexpr auto filter = __filter::__fn{}; | |
| 250 | } // namespace __cpo | |
| 251 | } // namespace views | |
| 252 | ||
| 253 | } // namespace ranges | |
| 254 | ||
| 255 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 256 | ||
| 257 | _LIBCPP_END_NAMESPACE_STD | |
| 258 | ||
| 259 | #endif // _LIBCPP___RANGES_FILTER_VIEW_H |
lib/libcxx/include/__ranges/iota_view.h+58-58| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_IOTA_VIEW_H |
| 10 | 10 | #define _LIBCPP___RANGES_IOTA_VIEW_H |
| 11 | 11 | |
| 12 | #include <__assert> | |
| 12 | 13 | #include <__compare/three_way_comparable.h> |
| 13 | 14 | #include <__concepts/arithmetic.h> |
| 14 | 15 | #include <__concepts/constructible.h> |
| ... | ... | @@ -20,7 +21,6 @@ |
| 20 | 21 | #include <__concepts/semiregular.h> |
| 21 | 22 | #include <__concepts/totally_ordered.h> |
| 22 | 23 | #include <__config> |
| 23 | #include <__debug> | |
| 24 | 24 | #include <__functional/ranges_operations.h> |
| 25 | 25 | #include <__iterator/concepts.h> |
| 26 | 26 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -34,12 +34,12 @@ |
| 34 | 34 | #include <type_traits> |
| 35 | 35 | |
| 36 | 36 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 37 | #pragma GCC system_header | |
| 37 | # pragma GCC system_header | |
| 38 | 38 | #endif |
| 39 | 39 | |
| 40 | 40 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 41 | 41 | |
| 42 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 42 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 43 | 43 | |
| 44 | 44 | namespace ranges { |
| 45 | 45 | template<class _Int> |
| ... | ... | @@ -90,9 +90,9 @@ namespace ranges { |
| 90 | 90 | using iterator_category = input_iterator_tag; |
| 91 | 91 | }; |
| 92 | 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>> { | |
| 93 | template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t> | |
| 94 | requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start> | |
| 95 | class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { | |
| 96 | 96 | struct __iterator : public __iota_iterator_category<_Start> { |
| 97 | 97 | friend class iota_view; |
| 98 | 98 | |
| ... | ... | @@ -111,7 +111,7 @@ namespace ranges { |
| 111 | 111 | __iterator() requires default_initializable<_Start> = default; |
| 112 | 112 | |
| 113 | 113 | _LIBCPP_HIDE_FROM_ABI |
| 114 | constexpr explicit __iterator(_Start __value) : __value_(_VSTD::move(__value)) {} | |
| 114 | constexpr explicit __iterator(_Start __value) : __value_(std::move(__value)) {} | |
| 115 | 115 | |
| 116 | 116 | _LIBCPP_HIDE_FROM_ABI |
| 117 | 117 | constexpr _Start operator*() const noexcept(is_nothrow_copy_constructible_v<_Start>) { |
| ... | ... | @@ -271,127 +271,127 @@ namespace ranges { |
| 271 | 271 | friend class iota_view; |
| 272 | 272 | |
| 273 | 273 | private: |
| 274 | _Bound __bound_ = _Bound(); | |
| 274 | _BoundSentinel __bound_sentinel_ = _BoundSentinel(); | |
| 275 | 275 | |
| 276 | 276 | public: |
| 277 | 277 | _LIBCPP_HIDE_FROM_ABI |
| 278 | 278 | __sentinel() = default; |
| 279 | constexpr explicit __sentinel(_Bound __bound) : __bound_(_VSTD::move(__bound)) {} | |
| 279 | constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {} | |
| 280 | 280 | |
| 281 | 281 | _LIBCPP_HIDE_FROM_ABI |
| 282 | 282 | friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) { |
| 283 | return __x.__value_ == __y.__bound_; | |
| 283 | return __x.__value_ == __y.__bound_sentinel_; | |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | _LIBCPP_HIDE_FROM_ABI |
| 287 | 287 | friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y) |
| 288 | requires sized_sentinel_for<_Bound, _Start> | |
| 288 | requires sized_sentinel_for<_BoundSentinel, _Start> | |
| 289 | 289 | { |
| 290 | return __x.__value_ - __y.__bound_; | |
| 290 | return __x.__value_ - __y.__bound_sentinel_; | |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | _LIBCPP_HIDE_FROM_ABI |
| 294 | 294 | friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y) |
| 295 | requires sized_sentinel_for<_Bound, _Start> | |
| 295 | requires sized_sentinel_for<_BoundSentinel, _Start> | |
| 296 | 296 | { |
| 297 | 297 | return -(__y - __x); |
| 298 | 298 | } |
| 299 | 299 | }; |
| 300 | 300 | |
| 301 | 301 | _Start __value_ = _Start(); |
| 302 | _Bound __bound_ = _Bound(); | |
| 302 | _BoundSentinel __bound_sentinel_ = _BoundSentinel(); | |
| 303 | 303 | |
| 304 | 304 | public: |
| 305 | 305 | _LIBCPP_HIDE_FROM_ABI |
| 306 | 306 | iota_view() requires default_initializable<_Start> = default; |
| 307 | 307 | |
| 308 | 308 | _LIBCPP_HIDE_FROM_ABI |
| 309 | constexpr explicit iota_view(_Start __value) : __value_(_VSTD::move(__value)) { } | |
| 309 | constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { } | |
| 310 | 310 | |
| 311 | 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)) { | |
| 312 | constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel) | |
| 313 | : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) { | |
| 314 | 314 | // Validate the precondition if possible. |
| 315 | if constexpr (totally_ordered_with<_Start, _Bound>) { | |
| 316 | _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_), | |
| 315 | if constexpr (totally_ordered_with<_Start, _BoundSentinel>) { | |
| 316 | _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_sentinel_), | |
| 317 | 317 | "Precondition violated: value is greater than bound."); |
| 318 | 318 | } |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | _LIBCPP_HIDE_FROM_ABI |
| 322 | 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_)) {} | |
| 323 | requires same_as<_Start, _BoundSentinel> | |
| 324 | : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {} | |
| 325 | 325 | |
| 326 | 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)) {} | |
| 327 | constexpr iota_view(__iterator __first, _BoundSentinel __last) | |
| 328 | requires same_as<_BoundSentinel, unreachable_sentinel_t> | |
| 329 | : iota_view(std::move(__first.__value_), std::move(__last)) {} | |
| 330 | 330 | |
| 331 | 331 | _LIBCPP_HIDE_FROM_ABI |
| 332 | 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_)) {} | |
| 333 | requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>) | |
| 334 | : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {} | |
| 335 | 335 | |
| 336 | 336 | _LIBCPP_HIDE_FROM_ABI |
| 337 | 337 | constexpr __iterator begin() const { return __iterator{__value_}; } |
| 338 | 338 | |
| 339 | 339 | _LIBCPP_HIDE_FROM_ABI |
| 340 | 340 | constexpr auto end() const { |
| 341 | if constexpr (same_as<_Bound, unreachable_sentinel_t>) | |
| 341 | if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>) | |
| 342 | 342 | return unreachable_sentinel; |
| 343 | 343 | else |
| 344 | return __sentinel{__bound_}; | |
| 344 | return __sentinel{__bound_sentinel_}; | |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | _LIBCPP_HIDE_FROM_ABI |
| 348 | constexpr __iterator end() const requires same_as<_Start, _Bound> { | |
| 349 | return __iterator{__bound_}; | |
| 348 | constexpr __iterator end() const | |
| 349 | requires same_as<_Start, _BoundSentinel> | |
| 350 | { | |
| 351 | return __iterator{__bound_sentinel_}; | |
| 350 | 352 | } |
| 351 | 353 | |
| 352 | 354 | _LIBCPP_HIDE_FROM_ABI |
| 353 | 355 | constexpr auto size() const |
| 354 | requires (same_as<_Start, _Bound> && __advanceable<_Start>) || | |
| 355 | (integral<_Start> && integral<_Bound>) || | |
| 356 | sized_sentinel_for<_Bound, _Start> | |
| 356 | requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || | |
| 357 | (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> | |
| 357 | 358 | { |
| 358 | if constexpr (__integer_like<_Start> && __integer_like<_Bound>) { | |
| 359 | if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) { | |
| 359 | 360 | if (__value_ < 0) { |
| 360 | if (__bound_ < 0) { | |
| 361 | return _VSTD::__to_unsigned_like(-__value_) - _VSTD::__to_unsigned_like(-__bound_); | |
| 361 | if (__bound_sentinel_ < 0) { | |
| 362 | return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_); | |
| 362 | 363 | } |
| 363 | return _VSTD::__to_unsigned_like(__bound_) + _VSTD::__to_unsigned_like(-__value_); | |
| 364 | return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_); | |
| 364 | 365 | } |
| 365 | return _VSTD::__to_unsigned_like(__bound_) - _VSTD::__to_unsigned_like(__value_); | |
| 366 | return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_); | |
| 366 | 367 | } |
| 367 | return _VSTD::__to_unsigned_like(__bound_ - __value_); | |
| 368 | return std::__to_unsigned_like(__bound_sentinel_ - __value_); | |
| 368 | 369 | } |
| 369 | 370 | }; |
| 370 | 371 | |
| 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>; | |
| 372 | template <class _Start, class _BoundSentinel> | |
| 373 | requires(!__integer_like<_Start> || !__integer_like<_BoundSentinel> || | |
| 374 | (__signed_integer_like<_Start> == __signed_integer_like<_BoundSentinel>)) | |
| 375 | iota_view(_Start, _BoundSentinel) -> iota_view<_Start, _BoundSentinel>; | |
| 375 | 376 | |
| 376 | template<class _Start, class _Bound> | |
| 377 | inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true; | |
| 377 | template <class _Start, class _BoundSentinel> | |
| 378 | inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true; | |
| 378 | 379 | |
| 379 | namespace views { | |
| 380 | namespace __iota { | |
| 380 | namespace views { | |
| 381 | namespace __iota { | |
| 381 | 382 | struct __fn { |
| 382 | 383 | template<class _Start> |
| 383 | 384 | _LIBCPP_HIDE_FROM_ABI |
| 384 | 385 | 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)); } | |
| 386 | noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start)))) | |
| 387 | -> decltype( ranges::iota_view(std::forward<_Start>(__start))) | |
| 388 | { return ranges::iota_view(std::forward<_Start>(__start)); } | |
| 389 | ||
| 390 | template <class _Start, class _BoundSentinel> | |
| 391 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const | |
| 392 | noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))) | |
| 393 | -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))) | |
| 394 | { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); } | |
| 395 | 395 | }; |
| 396 | 396 | } // namespace __iota |
| 397 | 397 | |
| ... | ... | @@ -401,7 +401,7 @@ inline namespace __cpo { |
| 401 | 401 | } // namespace views |
| 402 | 402 | } // namespace ranges |
| 403 | 403 | |
| 404 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 404 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 405 | 405 | |
| 406 | 406 | _LIBCPP_END_NAMESPACE_STD |
| 407 | 407 |
lib/libcxx/include/__ranges/join_view.h+40-20| ... | ... | @@ -9,28 +9,33 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_JOIN_VIEW_H |
| 10 | 10 | #define _LIBCPP___RANGES_JOIN_VIEW_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/equality_comparable.h> | |
| 12 | 17 | #include <__config> |
| 13 | 18 | #include <__iterator/concepts.h> |
| 19 | #include <__iterator/iter_move.h> | |
| 20 | #include <__iterator/iter_swap.h> | |
| 14 | 21 | #include <__iterator/iterator_traits.h> |
| 15 | 22 | #include <__ranges/access.h> |
| 16 | 23 | #include <__ranges/all.h> |
| 17 | 24 | #include <__ranges/concepts.h> |
| 18 | 25 | #include <__ranges/non_propagating_cache.h> |
| 19 | #include <__ranges/ref_view.h> | |
| 20 | #include <__ranges/subrange.h> | |
| 26 | #include <__ranges/range_adaptor.h> | |
| 21 | 27 | #include <__ranges/view_interface.h> |
| 22 | #include <__utility/declval.h> | |
| 23 | 28 | #include <__utility/forward.h> |
| 24 | 29 | #include <optional> |
| 25 | 30 | #include <type_traits> |
| 26 | 31 | |
| 27 | 32 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | #pragma GCC system_header | |
| 33 | # pragma GCC system_header | |
| 29 | 34 | #endif |
| 30 | 35 | |
| 31 | 36 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 32 | 37 | |
| 33 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | 39 | |
| 35 | 40 | namespace ranges { |
| 36 | 41 | template<class> |
| ... | ... | @@ -45,7 +50,8 @@ namespace ranges { |
| 45 | 50 | using _InnerC = typename iterator_traits<iterator_t<range_reference_t<_View>>>::iterator_category; |
| 46 | 51 | |
| 47 | 52 | using iterator_category = _If< |
| 48 | derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag>, | |
| 53 | derived_from<_OuterC, bidirectional_iterator_tag> && derived_from<_InnerC, bidirectional_iterator_tag> && | |
| 54 | common_range<range_reference_t<_View>>, | |
| 49 | 55 | bidirectional_iterator_tag, |
| 50 | 56 | _If< |
| 51 | 57 | derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag>, |
| ... | ... | @@ -67,8 +73,8 @@ namespace ranges { |
| 67 | 73 | |
| 68 | 74 | static constexpr bool _UseCache = !is_reference_v<_InnerRange>; |
| 69 | 75 | 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 :) | |
| 76 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cache_; | |
| 77 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | |
| 72 | 78 | |
| 73 | 79 | public: |
| 74 | 80 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -76,13 +82,13 @@ namespace ranges { |
| 76 | 82 | |
| 77 | 83 | _LIBCPP_HIDE_FROM_ABI |
| 78 | 84 | constexpr explicit join_view(_View __base) |
| 79 | : __base_(_VSTD::move(__base)) {} | |
| 85 | : __base_(std::move(__base)) {} | |
| 80 | 86 | |
| 81 | 87 | _LIBCPP_HIDE_FROM_ABI |
| 82 | 88 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } |
| 83 | 89 | |
| 84 | 90 | _LIBCPP_HIDE_FROM_ABI |
| 85 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 91 | constexpr _View base() && { return std::move(__base_); } | |
| 86 | 92 | |
| 87 | 93 | _LIBCPP_HIDE_FROM_ABI |
| 88 | 94 | constexpr auto begin() { |
| ... | ... | @@ -152,7 +158,7 @@ namespace ranges { |
| 152 | 158 | _LIBCPP_HIDE_FROM_ABI |
| 153 | 159 | constexpr __sentinel(__sentinel<!_Const> __s) |
| 154 | 160 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> |
| 155 | : __end_(_VSTD::move(__s.__end_)) {} | |
| 161 | : __end_(std::move(__s.__end_)) {} | |
| 156 | 162 | |
| 157 | 163 | template<bool _OtherConst> |
| 158 | 164 | requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> |
| ... | ... | @@ -204,7 +210,8 @@ namespace ranges { |
| 204 | 210 | |
| 205 | 211 | public: |
| 206 | 212 | using iterator_concept = _If< |
| 207 | __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>>, | |
| 213 | __ref_is_glvalue && bidirectional_range<_Base> && bidirectional_range<range_reference_t<_Base>> && | |
| 214 | common_range<range_reference_t<_Base>>, | |
| 208 | 215 | bidirectional_iterator_tag, |
| 209 | 216 | _If< |
| 210 | 217 | __ref_is_glvalue && forward_range<_Base> && forward_range<range_reference_t<_Base>>, |
| ... | ... | @@ -223,8 +230,8 @@ namespace ranges { |
| 223 | 230 | |
| 224 | 231 | _LIBCPP_HIDE_FROM_ABI |
| 225 | 232 | constexpr __iterator(_Parent& __parent, _Outer __outer) |
| 226 | : __outer_(_VSTD::move(__outer)) | |
| 227 | , __parent_(_VSTD::addressof(__parent)) { | |
| 233 | : __outer_(std::move(__outer)) | |
| 234 | , __parent_(std::addressof(__parent)) { | |
| 228 | 235 | __satisfy(); |
| 229 | 236 | } |
| 230 | 237 | |
| ... | ... | @@ -233,8 +240,8 @@ namespace ranges { |
| 233 | 240 | requires _Const && |
| 234 | 241 | convertible_to<iterator_t<_View>, _Outer> && |
| 235 | 242 | convertible_to<iterator_t<_InnerRange>, _Inner> |
| 236 | : __outer_(_VSTD::move(__i.__outer_)) | |
| 237 | , __inner_(_VSTD::move(__i.__inner_)) | |
| 243 | : __outer_(std::move(__i.__outer_)) | |
| 244 | , __inner_(std::move(__i.__inner_)) | |
| 238 | 245 | , __parent_(__i.__parent_) {} |
| 239 | 246 | |
| 240 | 247 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -338,12 +345,25 @@ namespace ranges { |
| 338 | 345 | |
| 339 | 346 | template<class _Range> |
| 340 | 347 | explicit join_view(_Range&&) -> join_view<views::all_t<_Range>>; |
| 341 | ||
| 348 | ||
| 349 | namespace views { | |
| 350 | namespace __join_view { | |
| 351 | struct __fn : __range_adaptor_closure<__fn> { | |
| 352 | template<class _Range> | |
| 353 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 354 | constexpr auto operator()(_Range&& __range) const | |
| 355 | noexcept(noexcept(join_view<all_t<_Range&&>>(std::forward<_Range>(__range)))) | |
| 356 | -> decltype( join_view<all_t<_Range&&>>(std::forward<_Range>(__range))) | |
| 357 | { return join_view<all_t<_Range&&>>(std::forward<_Range>(__range)); } | |
| 358 | }; | |
| 359 | } // namespace __join_view | |
| 360 | inline namespace __cpo { | |
| 361 | inline constexpr auto join = __join_view::__fn{}; | |
| 362 | } // namespace __cpo | |
| 363 | } // namespace views | |
| 342 | 364 | } // namespace ranges |
| 343 | 365 | |
| 344 | #undef _CONSTEXPR_TERNARY | |
| 345 | ||
| 346 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 366 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 347 | 367 | |
| 348 | 368 | _LIBCPP_END_NAMESPACE_STD |
| 349 | 369 |
lib/libcxx/include/__ranges/lazy_split_view.h created+465| ... | ... | @@ -0,0 +1,465 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H | |
| 11 | #define _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H | |
| 12 | ||
| 13 | #include <__algorithm/in_in_result.h> | |
| 14 | #include <__algorithm/ranges_find.h> | |
| 15 | #include <__algorithm/ranges_mismatch.h> | |
| 16 | #include <__concepts/constructible.h> | |
| 17 | #include <__concepts/convertible_to.h> | |
| 18 | #include <__concepts/derived_from.h> | |
| 19 | #include <__config> | |
| 20 | #include <__functional/bind_back.h> | |
| 21 | #include <__functional/ranges_operations.h> | |
| 22 | #include <__iterator/concepts.h> | |
| 23 | #include <__iterator/default_sentinel.h> | |
| 24 | #include <__iterator/incrementable_traits.h> | |
| 25 | #include <__iterator/indirectly_comparable.h> | |
| 26 | #include <__iterator/iter_move.h> | |
| 27 | #include <__iterator/iter_swap.h> | |
| 28 | #include <__iterator/iterator_traits.h> | |
| 29 | #include <__memory/addressof.h> | |
| 30 | #include <__ranges/access.h> | |
| 31 | #include <__ranges/all.h> | |
| 32 | #include <__ranges/concepts.h> | |
| 33 | #include <__ranges/non_propagating_cache.h> | |
| 34 | #include <__ranges/range_adaptor.h> | |
| 35 | #include <__ranges/single_view.h> | |
| 36 | #include <__ranges/subrange.h> | |
| 37 | #include <__ranges/view_interface.h> | |
| 38 | #include <__utility/forward.h> | |
| 39 | #include <__utility/move.h> | |
| 40 | #include <type_traits> | |
| 41 | ||
| 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 43 | # pragma GCC system_header | |
| 44 | #endif | |
| 45 | ||
| 46 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 47 | ||
| 48 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 49 | ||
| 50 | namespace ranges { | |
| 51 | ||
| 52 | template <auto> struct __require_constant; | |
| 53 | ||
| 54 | template <class _Range> | |
| 55 | concept __tiny_range = | |
| 56 | sized_range<_Range> && | |
| 57 | requires { typename __require_constant<remove_reference_t<_Range>::size()>; } && | |
| 58 | (remove_reference_t<_Range>::size() <= 1); | |
| 59 | ||
| 60 | template <input_range _View, forward_range _Pattern> | |
| 61 | requires view<_View> && view<_Pattern> && | |
| 62 | indirectly_comparable<iterator_t<_View>, iterator_t<_Pattern>, ranges::equal_to> && | |
| 63 | (forward_range<_View> || __tiny_range<_Pattern>) | |
| 64 | class lazy_split_view : public view_interface<lazy_split_view<_View, _Pattern>> { | |
| 65 | ||
| 66 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | |
| 67 | _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern(); | |
| 68 | ||
| 69 | using _MaybeCurrent = _If<!forward_range<_View>, __non_propagating_cache<iterator_t<_View>>, __empty_cache>; | |
| 70 | _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent(); | |
| 71 | ||
| 72 | template <bool> struct __outer_iterator; | |
| 73 | template <bool> struct __inner_iterator; | |
| 74 | ||
| 75 | public: | |
| 76 | _LIBCPP_HIDE_FROM_ABI | |
| 77 | lazy_split_view() | |
| 78 | requires default_initializable<_View> && default_initializable<_Pattern> = default; | |
| 79 | ||
| 80 | _LIBCPP_HIDE_FROM_ABI | |
| 81 | constexpr lazy_split_view(_View __base, _Pattern __pattern) | |
| 82 | : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {} | |
| 83 | ||
| 84 | template <input_range _Range> | |
| 85 | requires constructible_from<_View, views::all_t<_Range>> && | |
| 86 | constructible_from<_Pattern, single_view<range_value_t<_Range>>> | |
| 87 | _LIBCPP_HIDE_FROM_ABI | |
| 88 | constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e) | |
| 89 | : __base_(views::all(std::forward<_Range>(__r))) | |
| 90 | , __pattern_(views::single(std::move(__e))) {} | |
| 91 | ||
| 92 | _LIBCPP_HIDE_FROM_ABI | |
| 93 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } | |
| 94 | _LIBCPP_HIDE_FROM_ABI | |
| 95 | constexpr _View base() && { return std::move(__base_); } | |
| 96 | ||
| 97 | _LIBCPP_HIDE_FROM_ABI | |
| 98 | constexpr auto begin() { | |
| 99 | if constexpr (forward_range<_View>) { | |
| 100 | return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::begin(__base_)}; | |
| 101 | } else { | |
| 102 | __current_.__emplace(ranges::begin(__base_)); | |
| 103 | return __outer_iterator<false>{*this}; | |
| 104 | } | |
| 105 | } | |
| 106 | ||
| 107 | _LIBCPP_HIDE_FROM_ABI | |
| 108 | constexpr auto begin() const requires forward_range<_View> && forward_range<const _View> { | |
| 109 | return __outer_iterator<true>{*this, ranges::begin(__base_)}; | |
| 110 | } | |
| 111 | ||
| 112 | _LIBCPP_HIDE_FROM_ABI | |
| 113 | constexpr auto end() requires forward_range<_View> && common_range<_View> { | |
| 114 | return __outer_iterator<__simple_view<_View> && __simple_view<_Pattern>>{*this, ranges::end(__base_)}; | |
| 115 | } | |
| 116 | ||
| 117 | _LIBCPP_HIDE_FROM_ABI | |
| 118 | constexpr auto end() const { | |
| 119 | if constexpr (forward_range<_View> && forward_range<const _View> && common_range<const _View>) { | |
| 120 | return __outer_iterator<true>{*this, ranges::end(__base_)}; | |
| 121 | } else { | |
| 122 | return default_sentinel; | |
| 123 | } | |
| 124 | } | |
| 125 | ||
| 126 | private: | |
| 127 | ||
| 128 | template <class> | |
| 129 | struct __outer_iterator_category {}; | |
| 130 | ||
| 131 | template <forward_range _Tp> | |
| 132 | struct __outer_iterator_category<_Tp> { | |
| 133 | using iterator_category = input_iterator_tag; | |
| 134 | }; | |
| 135 | ||
| 136 | template <bool _Const> | |
| 137 | struct __outer_iterator : __outer_iterator_category<__maybe_const<_Const, _View>> { | |
| 138 | private: | |
| 139 | template <bool> | |
| 140 | friend struct __inner_iterator; | |
| 141 | friend __outer_iterator<true>; | |
| 142 | ||
| 143 | using _Parent = __maybe_const<_Const, lazy_split_view>; | |
| 144 | using _Base = __maybe_const<_Const, _View>; | |
| 145 | ||
| 146 | _Parent* __parent_ = nullptr; | |
| 147 | using _MaybeCurrent = _If<forward_range<_View>, iterator_t<_Base>, __empty_cache>; | |
| 148 | _LIBCPP_NO_UNIQUE_ADDRESS _MaybeCurrent __current_ = _MaybeCurrent(); | |
| 149 | bool __trailing_empty_ = false; | |
| 150 | ||
| 151 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 152 | constexpr auto& __current() noexcept { | |
| 153 | if constexpr (forward_range<_View>) { | |
| 154 | return __current_; | |
| 155 | } else { | |
| 156 | return *__parent_->__current_; | |
| 157 | } | |
| 158 | } | |
| 159 | ||
| 160 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 161 | constexpr const auto& __current() const noexcept { | |
| 162 | if constexpr (forward_range<_View>) { | |
| 163 | return __current_; | |
| 164 | } else { | |
| 165 | return *__parent_->__current_; | |
| 166 | } | |
| 167 | } | |
| 168 | ||
| 169 | // Workaround for the GCC issue that doesn't allow calling `__parent_->__base_` from friend functions (because | |
| 170 | // `__base_` is private). | |
| 171 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 172 | constexpr auto& __parent_base() const noexcept { | |
| 173 | return __parent_->__base_; | |
| 174 | } | |
| 175 | ||
| 176 | public: | |
| 177 | // using iterator_category = inherited; | |
| 178 | using iterator_concept = conditional_t<forward_range<_Base>, forward_iterator_tag, input_iterator_tag>; | |
| 179 | using difference_type = range_difference_t<_Base>; | |
| 180 | ||
| 181 | struct value_type : view_interface<value_type> { | |
| 182 | private: | |
| 183 | __outer_iterator __i_ = __outer_iterator(); | |
| 184 | ||
| 185 | public: | |
| 186 | _LIBCPP_HIDE_FROM_ABI | |
| 187 | value_type() = default; | |
| 188 | _LIBCPP_HIDE_FROM_ABI | |
| 189 | constexpr explicit value_type(__outer_iterator __i) | |
| 190 | : __i_(std::move(__i)) {} | |
| 191 | ||
| 192 | _LIBCPP_HIDE_FROM_ABI | |
| 193 | constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; } | |
| 194 | _LIBCPP_HIDE_FROM_ABI | |
| 195 | constexpr default_sentinel_t end() const noexcept { return default_sentinel; } | |
| 196 | }; | |
| 197 | ||
| 198 | _LIBCPP_HIDE_FROM_ABI | |
| 199 | __outer_iterator() = default; | |
| 200 | ||
| 201 | _LIBCPP_HIDE_FROM_ABI | |
| 202 | constexpr explicit __outer_iterator(_Parent& __parent) | |
| 203 | requires (!forward_range<_Base>) | |
| 204 | : __parent_(std::addressof(__parent)) {} | |
| 205 | ||
| 206 | _LIBCPP_HIDE_FROM_ABI | |
| 207 | constexpr __outer_iterator(_Parent& __parent, iterator_t<_Base> __current) | |
| 208 | requires forward_range<_Base> | |
| 209 | : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {} | |
| 210 | ||
| 211 | _LIBCPP_HIDE_FROM_ABI | |
| 212 | constexpr __outer_iterator(__outer_iterator<!_Const> __i) | |
| 213 | requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>> | |
| 214 | : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {} | |
| 215 | ||
| 216 | _LIBCPP_HIDE_FROM_ABI | |
| 217 | constexpr value_type operator*() const { return value_type{*this}; } | |
| 218 | ||
| 219 | _LIBCPP_HIDE_FROM_ABI | |
| 220 | constexpr __outer_iterator& operator++() { | |
| 221 | const auto __end = ranges::end(__parent_->__base_); | |
| 222 | if (__current() == __end) { | |
| 223 | __trailing_empty_ = false; | |
| 224 | return *this; | |
| 225 | } | |
| 226 | ||
| 227 | const auto [__pbegin, __pend] = ranges::subrange{__parent_->__pattern_}; | |
| 228 | if (__pbegin == __pend) { | |
| 229 | // Empty pattern: split on every element in the input range | |
| 230 | ++__current(); | |
| 231 | ||
| 232 | } else if constexpr (__tiny_range<_Pattern>) { | |
| 233 | // One-element pattern: we can use `ranges::find`. | |
| 234 | __current() = ranges::find(std::move(__current()), __end, *__pbegin); | |
| 235 | if (__current() != __end) { | |
| 236 | // Make sure we point to after the separator we just found. | |
| 237 | ++__current(); | |
| 238 | if (__current() == __end) | |
| 239 | __trailing_empty_ = true; | |
| 240 | } | |
| 241 | ||
| 242 | } else { | |
| 243 | // General case for n-element pattern. | |
| 244 | do { | |
| 245 | const auto [__b, __p] = ranges::mismatch(__current(), __end, __pbegin, __pend); | |
| 246 | if (__p == __pend) { | |
| 247 | __current() = __b; | |
| 248 | if (__current() == __end) { | |
| 249 | __trailing_empty_ = true; | |
| 250 | } | |
| 251 | break; // The pattern matched; skip it. | |
| 252 | } | |
| 253 | } while (++__current() != __end); | |
| 254 | } | |
| 255 | ||
| 256 | return *this; | |
| 257 | } | |
| 258 | ||
| 259 | _LIBCPP_HIDE_FROM_ABI | |
| 260 | constexpr decltype(auto) operator++(int) { | |
| 261 | if constexpr (forward_range<_Base>) { | |
| 262 | auto __tmp = *this; | |
| 263 | ++*this; | |
| 264 | return __tmp; | |
| 265 | ||
| 266 | } else { | |
| 267 | ++*this; | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | _LIBCPP_HIDE_FROM_ABI | |
| 272 | friend constexpr bool operator==(const __outer_iterator& __x, const __outer_iterator& __y) | |
| 273 | requires forward_range<_Base> { | |
| 274 | return __x.__current_ == __y.__current_ && __x.__trailing_empty_ == __y.__trailing_empty_; | |
| 275 | } | |
| 276 | ||
| 277 | _LIBCPP_HIDE_FROM_ABI | |
| 278 | friend constexpr bool operator==(const __outer_iterator& __x, default_sentinel_t) { | |
| 279 | _LIBCPP_ASSERT(__x.__parent_, "Cannot call comparison on a default-constructed iterator."); | |
| 280 | return __x.__current() == ranges::end(__x.__parent_base()) && !__x.__trailing_empty_; | |
| 281 | } | |
| 282 | }; | |
| 283 | ||
| 284 | template <class> | |
| 285 | struct __inner_iterator_category {}; | |
| 286 | ||
| 287 | template <forward_range _Tp> | |
| 288 | struct __inner_iterator_category<_Tp> { | |
| 289 | using iterator_category = _If< | |
| 290 | derived_from<typename iterator_traits<iterator_t<_Tp>>::iterator_category, forward_iterator_tag>, | |
| 291 | forward_iterator_tag, | |
| 292 | typename iterator_traits<iterator_t<_Tp>>::iterator_category | |
| 293 | >; | |
| 294 | }; | |
| 295 | ||
| 296 | template <bool _Const> | |
| 297 | struct __inner_iterator : __inner_iterator_category<__maybe_const<_Const, _View>> { | |
| 298 | private: | |
| 299 | using _Base = __maybe_const<_Const, _View>; | |
| 300 | // Workaround for a GCC issue. | |
| 301 | static constexpr bool _OuterConst = _Const; | |
| 302 | __outer_iterator<_Const> __i_ = __outer_iterator<_OuterConst>(); | |
| 303 | bool __incremented_ = false; | |
| 304 | ||
| 305 | // Note: these private functions are necessary because GCC doesn't allow calls to private members of `__i_` from | |
| 306 | // free functions that are friends of `inner-iterator`. | |
| 307 | ||
| 308 | _LIBCPP_HIDE_FROM_ABI | |
| 309 | constexpr bool __is_done() const { | |
| 310 | _LIBCPP_ASSERT(__i_.__parent_, "Cannot call comparison on a default-constructed iterator."); | |
| 311 | ||
| 312 | auto [__pcur, __pend] = ranges::subrange{__i_.__parent_->__pattern_}; | |
| 313 | auto __end = ranges::end(__i_.__parent_->__base_); | |
| 314 | ||
| 315 | if constexpr (__tiny_range<_Pattern>) { | |
| 316 | const auto& __cur = __i_.__current(); | |
| 317 | if (__cur == __end) | |
| 318 | return true; | |
| 319 | if (__pcur == __pend) | |
| 320 | return __incremented_; | |
| 321 | ||
| 322 | return *__cur == *__pcur; | |
| 323 | ||
| 324 | } else { | |
| 325 | auto __cur = __i_.__current(); | |
| 326 | if (__cur == __end) | |
| 327 | return true; | |
| 328 | if (__pcur == __pend) | |
| 329 | return __incremented_; | |
| 330 | ||
| 331 | do { | |
| 332 | if (*__cur != *__pcur) | |
| 333 | return false; | |
| 334 | if (++__pcur == __pend) | |
| 335 | return true; | |
| 336 | } while (++__cur != __end); | |
| 337 | ||
| 338 | return false; | |
| 339 | } | |
| 340 | } | |
| 341 | ||
| 342 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 343 | constexpr auto& __outer_current() noexcept { | |
| 344 | return __i_.__current(); | |
| 345 | } | |
| 346 | ||
| 347 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 348 | constexpr const auto& __outer_current() const noexcept { | |
| 349 | return __i_.__current(); | |
| 350 | } | |
| 351 | ||
| 352 | public: | |
| 353 | // using iterator_category = inherited; | |
| 354 | using iterator_concept = typename __outer_iterator<_Const>::iterator_concept; | |
| 355 | using value_type = range_value_t<_Base>; | |
| 356 | using difference_type = range_difference_t<_Base>; | |
| 357 | ||
| 358 | _LIBCPP_HIDE_FROM_ABI | |
| 359 | __inner_iterator() = default; | |
| 360 | ||
| 361 | _LIBCPP_HIDE_FROM_ABI | |
| 362 | constexpr explicit __inner_iterator(__outer_iterator<_Const> __i) | |
| 363 | : __i_(std::move(__i)) {} | |
| 364 | ||
| 365 | _LIBCPP_HIDE_FROM_ABI | |
| 366 | constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); } | |
| 367 | _LIBCPP_HIDE_FROM_ABI | |
| 368 | constexpr iterator_t<_Base> base() && | |
| 369 | requires forward_range<_View> { return std::move(__i_.__current()); } | |
| 370 | ||
| 371 | _LIBCPP_HIDE_FROM_ABI | |
| 372 | constexpr decltype(auto) operator*() const { return *__i_.__current(); } | |
| 373 | ||
| 374 | _LIBCPP_HIDE_FROM_ABI | |
| 375 | constexpr __inner_iterator& operator++() { | |
| 376 | __incremented_ = true; | |
| 377 | ||
| 378 | if constexpr (!forward_range<_Base>) { | |
| 379 | if constexpr (_Pattern::size() == 0) { | |
| 380 | return *this; | |
| 381 | } | |
| 382 | } | |
| 383 | ||
| 384 | ++__i_.__current(); | |
| 385 | return *this; | |
| 386 | } | |
| 387 | ||
| 388 | _LIBCPP_HIDE_FROM_ABI | |
| 389 | constexpr decltype(auto) operator++(int) { | |
| 390 | if constexpr (forward_range<_Base>) { | |
| 391 | auto __tmp = *this; | |
| 392 | ++*this; | |
| 393 | return __tmp; | |
| 394 | ||
| 395 | } else { | |
| 396 | ++*this; | |
| 397 | } | |
| 398 | } | |
| 399 | ||
| 400 | _LIBCPP_HIDE_FROM_ABI | |
| 401 | friend constexpr bool operator==(const __inner_iterator& __x, const __inner_iterator& __y) | |
| 402 | requires forward_range<_Base> { | |
| 403 | return __x.__outer_current() == __y.__outer_current(); | |
| 404 | } | |
| 405 | ||
| 406 | _LIBCPP_HIDE_FROM_ABI | |
| 407 | friend constexpr bool operator==(const __inner_iterator& __x, default_sentinel_t) { | |
| 408 | return __x.__is_done(); | |
| 409 | } | |
| 410 | ||
| 411 | _LIBCPP_HIDE_FROM_ABI | |
| 412 | friend constexpr decltype(auto) iter_move(const __inner_iterator& __i) | |
| 413 | noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) { | |
| 414 | return ranges::iter_move(__i.__outer_current()); | |
| 415 | } | |
| 416 | ||
| 417 | _LIBCPP_HIDE_FROM_ABI | |
| 418 | friend constexpr void iter_swap(const __inner_iterator& __x, const __inner_iterator& __y) | |
| 419 | noexcept(noexcept(ranges::iter_swap(__x.__outer_current(), __y.__outer_current()))) | |
| 420 | requires indirectly_swappable<iterator_t<_Base>> { | |
| 421 | ranges::iter_swap(__x.__outer_current(), __y.__outer_current()); | |
| 422 | } | |
| 423 | }; | |
| 424 | ||
| 425 | }; | |
| 426 | ||
| 427 | template <class _Range, class _Pattern> | |
| 428 | lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>; | |
| 429 | ||
| 430 | template <input_range _Range> | |
| 431 | lazy_split_view(_Range&&, range_value_t<_Range>) | |
| 432 | -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>; | |
| 433 | ||
| 434 | namespace views { | |
| 435 | namespace __lazy_split_view { | |
| 436 | struct __fn : __range_adaptor_closure<__fn> { | |
| 437 | template <class _Range, class _Pattern> | |
| 438 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 439 | constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const | |
| 440 | noexcept(noexcept(lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))) | |
| 441 | -> decltype( lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) | |
| 442 | { return lazy_split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)); } | |
| 443 | ||
| 444 | template <class _Pattern> | |
| 445 | requires constructible_from<decay_t<_Pattern>, _Pattern> | |
| 446 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 447 | constexpr auto operator()(_Pattern&& __pattern) const | |
| 448 | noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) { | |
| 449 | return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern))); | |
| 450 | } | |
| 451 | }; | |
| 452 | } // namespace __lazy_split_view | |
| 453 | ||
| 454 | inline namespace __cpo { | |
| 455 | inline constexpr auto lazy_split = __lazy_split_view::__fn{}; | |
| 456 | } // namespace __cpo | |
| 457 | } // namespace views | |
| 458 | ||
| 459 | } // namespace ranges | |
| 460 | ||
| 461 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 462 | ||
| 463 | _LIBCPP_END_NAMESPACE_STD | |
| 464 | ||
| 465 | #endif // _LIBCPP___RANGES_LAZY_SPLIT_VIEW_H |
lib/libcxx/include/__ranges/non_propagating_cache.h+6-6| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 27 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | 28 | |
| 29 | 29 | namespace ranges { |
| 30 | 30 | // __non_propagating_cache is a helper type that allows storing an optional value in it, |
| ... | ... | @@ -45,7 +45,7 @@ namespace ranges { |
| 45 | 45 | // constructing the contained type from an iterator. |
| 46 | 46 | struct __wrapper { |
| 47 | 47 | template<class ..._Args> |
| 48 | constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(_VSTD::forward<_Args>(__args)...) { } | |
| 48 | constexpr explicit __wrapper(__forward_tag, _Args&& ...__args) : __t_(std::forward<_Args>(__args)...) { } | |
| 49 | 49 | template<class _Fn> |
| 50 | 50 | constexpr explicit __wrapper(__from_tag, _Fn const& __f) : __t_(__f()) { } |
| 51 | 51 | _Tp __t_; |
| ... | ... | @@ -70,7 +70,7 @@ namespace ranges { |
| 70 | 70 | |
| 71 | 71 | _LIBCPP_HIDE_FROM_ABI |
| 72 | 72 | constexpr __non_propagating_cache& operator=(__non_propagating_cache const& __other) noexcept { |
| 73 | if (this != _VSTD::addressof(__other)) { | |
| 73 | if (this != std::addressof(__other)) { | |
| 74 | 74 | __value_.reset(); |
| 75 | 75 | } |
| 76 | 76 | return *this; |
| ... | ... | @@ -100,14 +100,14 @@ namespace ranges { |
| 100 | 100 | template<class ..._Args> |
| 101 | 101 | _LIBCPP_HIDE_FROM_ABI |
| 102 | 102 | constexpr _Tp& __emplace(_Args&& ...__args) { |
| 103 | return __value_.emplace(__forward_tag{}, _VSTD::forward<_Args>(__args)...).__t_; | |
| 103 | return __value_.emplace(__forward_tag{}, std::forward<_Args>(__args)...).__t_; | |
| 104 | 104 | } |
| 105 | 105 | }; |
| 106 | 106 | |
| 107 | 107 | struct __empty_cache { }; |
| 108 | 108 | } // namespace ranges |
| 109 | 109 | |
| 110 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 110 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 111 | 111 | |
| 112 | 112 | _LIBCPP_END_NAMESPACE_STD |
| 113 | 113 |
lib/libcxx/include/__ranges/owning_view.h+6-6| ... | ... | @@ -23,12 +23,12 @@ |
| 23 | 23 | #include <type_traits> |
| 24 | 24 | |
| 25 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 26 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 27 | 27 | #endif |
| 28 | 28 | |
| 29 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 30 | |
| 31 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 32 | 32 | |
| 33 | 33 | namespace ranges { |
| 34 | 34 | template<range _Rp> |
| ... | ... | @@ -38,15 +38,15 @@ namespace ranges { |
| 38 | 38 | |
| 39 | 39 | public: |
| 40 | 40 | owning_view() requires default_initializable<_Rp> = default; |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(_VSTD::move(__r)) {} | |
| 41 | _LIBCPP_HIDE_FROM_ABI constexpr owning_view(_Rp&& __r) : __r_(std::move(__r)) {} | |
| 42 | 42 | |
| 43 | 43 | owning_view(owning_view&&) = default; |
| 44 | 44 | owning_view& operator=(owning_view&&) = default; |
| 45 | 45 | |
| 46 | 46 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp& base() & noexcept { return __r_; } |
| 47 | 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_); } | |
| 48 | _LIBCPP_HIDE_FROM_ABI constexpr _Rp&& base() && noexcept { return std::move(__r_); } | |
| 49 | _LIBCPP_HIDE_FROM_ABI constexpr const _Rp&& base() const&& noexcept { return std::move(__r_); } | |
| 50 | 50 | |
| 51 | 51 | _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Rp> begin() { return ranges::begin(__r_); } |
| 52 | 52 | _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Rp> end() { return ranges::end(__r_); } |
| ... | ... | @@ -74,7 +74,7 @@ public: |
| 74 | 74 | |
| 75 | 75 | } // namespace ranges |
| 76 | 76 | |
| 77 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 77 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | 78 | |
| 79 | 79 | _LIBCPP_END_NAMESPACE_STD |
| 80 | 80 |
lib/libcxx/include/__ranges/range_adaptor.h+6-6| ... | ... | @@ -20,12 +20,12 @@ |
| 20 | 20 | #include <type_traits> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 27 | |
| 28 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | 29 | |
| 30 | 30 | // CRTP base that one can derive from in order to be considered a range adaptor closure |
| 31 | 31 | // by the library. When deriving from this class, a pipe operator will be provided to |
| ... | ... | @@ -39,7 +39,7 @@ struct __range_adaptor_closure; |
| 39 | 39 | // i.e. something that can be called via the `x | f` notation. |
| 40 | 40 | template <class _Fn> |
| 41 | 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)) { } | |
| 42 | constexpr explicit __range_adaptor_closure_t(_Fn&& __f) : _Fn(std::move(__f)) { } | |
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | 45 | template <class _Tp> |
| ... | ... | @@ -53,7 +53,7 @@ struct __range_adaptor_closure { |
| 53 | 53 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 54 | 54 | friend constexpr decltype(auto) operator|(_View&& __view, _Closure&& __closure) |
| 55 | 55 | noexcept(is_nothrow_invocable_v<_Closure, _View>) |
| 56 | { return _VSTD::invoke(_VSTD::forward<_Closure>(__closure), _VSTD::forward<_View>(__view)); } | |
| 56 | { return std::invoke(std::forward<_Closure>(__closure), std::forward<_View>(__view)); } | |
| 57 | 57 | |
| 58 | 58 | template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure> |
| 59 | 59 | requires same_as<_Tp, remove_cvref_t<_Closure>> && |
| ... | ... | @@ -63,10 +63,10 @@ struct __range_adaptor_closure { |
| 63 | 63 | friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) |
| 64 | 64 | noexcept(is_nothrow_constructible_v<decay_t<_Closure>, _Closure> && |
| 65 | 65 | is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) |
| 66 | { return __range_adaptor_closure_t(_VSTD::__compose(_VSTD::forward<_OtherClosure>(__c2), _VSTD::forward<_Closure>(__c1))); } | |
| 66 | { return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1))); } | |
| 67 | 67 | }; |
| 68 | 68 | |
| 69 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 69 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 70 | 70 | |
| 71 | 71 | _LIBCPP_END_NAMESPACE_STD |
| 72 | 72 |
lib/libcxx/include/__ranges/rbegin.h created+130| ... | ... | @@ -0,0 +1,130 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP___RANGES_RBEGIN_H | |
| 10 | #define _LIBCPP___RANGES_RBEGIN_H | |
| 11 | ||
| 12 | #include <__concepts/class_or_enum.h> | |
| 13 | #include <__concepts/same_as.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/readable_traits.h> | |
| 17 | #include <__iterator/reverse_iterator.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__utility/auto_cast.h> | |
| 20 | #include <type_traits> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 29 | ||
| 30 | // [ranges.access.rbegin] | |
| 31 | ||
| 32 | namespace ranges { | |
| 33 | namespace __rbegin { | |
| 34 | template <class _Tp> | |
| 35 | concept __member_rbegin = | |
| 36 | __can_borrow<_Tp> && | |
| 37 | __workaround_52970<_Tp> && | |
| 38 | requires(_Tp&& __t) { | |
| 39 | { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator; | |
| 40 | }; | |
| 41 | ||
| 42 | void rbegin(auto&) = delete; | |
| 43 | void rbegin(const auto&) = delete; | |
| 44 | ||
| 45 | template <class _Tp> | |
| 46 | concept __unqualified_rbegin = | |
| 47 | !__member_rbegin<_Tp> && | |
| 48 | __can_borrow<_Tp> && | |
| 49 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 50 | requires(_Tp&& __t) { | |
| 51 | { _LIBCPP_AUTO_CAST(rbegin(__t)) } -> input_or_output_iterator; | |
| 52 | }; | |
| 53 | ||
| 54 | template <class _Tp> | |
| 55 | concept __can_reverse = | |
| 56 | __can_borrow<_Tp> && | |
| 57 | !__member_rbegin<_Tp> && | |
| 58 | !__unqualified_rbegin<_Tp> && | |
| 59 | requires(_Tp&& __t) { | |
| 60 | { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>; | |
| 61 | { ranges::begin(__t) } -> bidirectional_iterator; | |
| 62 | }; | |
| 63 | ||
| 64 | struct __fn { | |
| 65 | template <class _Tp> | |
| 66 | requires __member_rbegin<_Tp> | |
| 67 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 68 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rbegin()))) | |
| 69 | { | |
| 70 | return _LIBCPP_AUTO_CAST(__t.rbegin()); | |
| 71 | } | |
| 72 | ||
| 73 | template <class _Tp> | |
| 74 | requires __unqualified_rbegin<_Tp> | |
| 75 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 76 | noexcept(noexcept(_LIBCPP_AUTO_CAST(rbegin(__t)))) | |
| 77 | { | |
| 78 | return _LIBCPP_AUTO_CAST(rbegin(__t)); | |
| 79 | } | |
| 80 | ||
| 81 | template <class _Tp> | |
| 82 | requires __can_reverse<_Tp> | |
| 83 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 84 | noexcept(noexcept(ranges::end(__t))) | |
| 85 | { | |
| 86 | return std::make_reverse_iterator(ranges::end(__t)); | |
| 87 | } | |
| 88 | ||
| 89 | void operator()(auto&&) const = delete; | |
| 90 | }; | |
| 91 | } // namespace __rbegin | |
| 92 | ||
| 93 | inline namespace __cpo { | |
| 94 | inline constexpr auto rbegin = __rbegin::__fn{}; | |
| 95 | } // namespace __cpo | |
| 96 | } // namespace ranges | |
| 97 | ||
| 98 | // [range.access.crbegin] | |
| 99 | ||
| 100 | namespace ranges { | |
| 101 | namespace __crbegin { | |
| 102 | struct __fn { | |
| 103 | template <class _Tp> | |
| 104 | requires is_lvalue_reference_v<_Tp&&> | |
| 105 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 106 | constexpr auto operator()(_Tp&& __t) const | |
| 107 | noexcept(noexcept(ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)))) | |
| 108 | -> decltype( ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t))) | |
| 109 | { return ranges::rbegin(static_cast<const remove_reference_t<_Tp>&>(__t)); } | |
| 110 | ||
| 111 | template <class _Tp> | |
| 112 | requires is_rvalue_reference_v<_Tp&&> | |
| 113 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 114 | constexpr auto operator()(_Tp&& __t) const | |
| 115 | noexcept(noexcept(ranges::rbegin(static_cast<const _Tp&&>(__t)))) | |
| 116 | -> decltype( ranges::rbegin(static_cast<const _Tp&&>(__t))) | |
| 117 | { return ranges::rbegin(static_cast<const _Tp&&>(__t)); } | |
| 118 | }; | |
| 119 | } // namespace __crbegin | |
| 120 | ||
| 121 | inline namespace __cpo { | |
| 122 | inline constexpr auto crbegin = __crbegin::__fn{}; | |
| 123 | } // namespace __cpo | |
| 124 | } // namespace ranges | |
| 125 | ||
| 126 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 127 | ||
| 128 | _LIBCPP_END_NAMESPACE_STD | |
| 129 | ||
| 130 | #endif // _LIBCPP___RANGES_RBEGIN_H |
lib/libcxx/include/__ranges/ref_view.h+4-4| ... | ... | @@ -26,12 +26,12 @@ |
| 26 | 26 | #include <type_traits> |
| 27 | 27 | |
| 28 | 28 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | #pragma GCC system_header | |
| 29 | # pragma GCC system_header | |
| 30 | 30 | #endif |
| 31 | 31 | |
| 32 | 32 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 33 | 33 | |
| 34 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 34 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 35 | 35 | |
| 36 | 36 | namespace ranges { |
| 37 | 37 | template<range _Range> |
| ... | ... | @@ -48,7 +48,7 @@ public: |
| 48 | 48 | convertible_to<_Tp, _Range&> && requires { __fun(declval<_Tp>()); } |
| 49 | 49 | _LIBCPP_HIDE_FROM_ABI |
| 50 | 50 | constexpr ref_view(_Tp&& __t) |
| 51 | : __range_(_VSTD::addressof(static_cast<_Range&>(_VSTD::forward<_Tp>(__t)))) | |
| 51 | : __range_(std::addressof(static_cast<_Range&>(std::forward<_Tp>(__t)))) | |
| 52 | 52 | {} |
| 53 | 53 | |
| 54 | 54 | _LIBCPP_HIDE_FROM_ABI constexpr _Range& base() const { return *__range_; } |
| ... | ... | @@ -79,7 +79,7 @@ public: |
| 79 | 79 | inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true; |
| 80 | 80 | } // namespace ranges |
| 81 | 81 | |
| 82 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 82 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 83 | 83 | |
| 84 | 84 | _LIBCPP_END_NAMESPACE_STD |
| 85 | 85 |
lib/libcxx/include/__ranges/rend.h created+134| ... | ... | @@ -0,0 +1,134 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP___RANGES_REND_H | |
| 10 | #define _LIBCPP___RANGES_REND_H | |
| 11 | ||
| 12 | #include <__concepts/class_or_enum.h> | |
| 13 | #include <__concepts/same_as.h> | |
| 14 | #include <__config> | |
| 15 | #include <__iterator/concepts.h> | |
| 16 | #include <__iterator/readable_traits.h> | |
| 17 | #include <__iterator/reverse_iterator.h> | |
| 18 | #include <__ranges/access.h> | |
| 19 | #include <__ranges/rbegin.h> | |
| 20 | #include <__utility/auto_cast.h> | |
| 21 | #include <type_traits> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 30 | ||
| 31 | // [range.access.rend] | |
| 32 | ||
| 33 | namespace ranges { | |
| 34 | namespace __rend { | |
| 35 | template <class _Tp> | |
| 36 | concept __member_rend = | |
| 37 | __can_borrow<_Tp> && | |
| 38 | __workaround_52970<_Tp> && | |
| 39 | requires(_Tp&& __t) { | |
| 40 | ranges::rbegin(__t); | |
| 41 | { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>; | |
| 42 | }; | |
| 43 | ||
| 44 | void rend(auto&) = delete; | |
| 45 | void rend(const auto&) = delete; | |
| 46 | ||
| 47 | template <class _Tp> | |
| 48 | concept __unqualified_rend = | |
| 49 | !__member_rend<_Tp> && | |
| 50 | __can_borrow<_Tp> && | |
| 51 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 52 | requires(_Tp&& __t) { | |
| 53 | ranges::rbegin(__t); | |
| 54 | { _LIBCPP_AUTO_CAST(rend(__t)) } -> sentinel_for<decltype(ranges::rbegin(__t))>; | |
| 55 | }; | |
| 56 | ||
| 57 | template <class _Tp> | |
| 58 | concept __can_reverse = | |
| 59 | __can_borrow<_Tp> && | |
| 60 | !__member_rend<_Tp> && | |
| 61 | !__unqualified_rend<_Tp> && | |
| 62 | requires(_Tp&& __t) { | |
| 63 | { ranges::begin(__t) } -> same_as<decltype(ranges::end(__t))>; | |
| 64 | { ranges::begin(__t) } -> bidirectional_iterator; | |
| 65 | }; | |
| 66 | ||
| 67 | class __fn { | |
| 68 | public: | |
| 69 | template <class _Tp> | |
| 70 | requires __member_rend<_Tp> | |
| 71 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 72 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.rend()))) | |
| 73 | { | |
| 74 | return _LIBCPP_AUTO_CAST(__t.rend()); | |
| 75 | } | |
| 76 | ||
| 77 | template <class _Tp> | |
| 78 | requires __unqualified_rend<_Tp> | |
| 79 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 80 | noexcept(noexcept(_LIBCPP_AUTO_CAST(rend(__t)))) | |
| 81 | { | |
| 82 | return _LIBCPP_AUTO_CAST(rend(__t)); | |
| 83 | } | |
| 84 | ||
| 85 | template <class _Tp> | |
| 86 | requires __can_reverse<_Tp> | |
| 87 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 88 | noexcept(noexcept(ranges::begin(__t))) | |
| 89 | { | |
| 90 | return std::make_reverse_iterator(ranges::begin(__t)); | |
| 91 | } | |
| 92 | ||
| 93 | void operator()(auto&&) const = delete; | |
| 94 | }; | |
| 95 | } // namespace __rend | |
| 96 | ||
| 97 | inline namespace __cpo { | |
| 98 | inline constexpr auto rend = __rend::__fn{}; | |
| 99 | } // namespace __cpo | |
| 100 | } // namespace ranges | |
| 101 | ||
| 102 | // [range.access.crend] | |
| 103 | ||
| 104 | namespace ranges { | |
| 105 | namespace __crend { | |
| 106 | struct __fn { | |
| 107 | template <class _Tp> | |
| 108 | requires is_lvalue_reference_v<_Tp&&> | |
| 109 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 110 | constexpr auto operator()(_Tp&& __t) const | |
| 111 | noexcept(noexcept(ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)))) | |
| 112 | -> decltype( ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t))) | |
| 113 | { return ranges::rend(static_cast<const remove_reference_t<_Tp>&>(__t)); } | |
| 114 | ||
| 115 | template <class _Tp> | |
| 116 | requires is_rvalue_reference_v<_Tp&&> | |
| 117 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 118 | constexpr auto operator()(_Tp&& __t) const | |
| 119 | noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t)))) | |
| 120 | -> decltype( ranges::rend(static_cast<const _Tp&&>(__t))) | |
| 121 | { return ranges::rend(static_cast<const _Tp&&>(__t)); } | |
| 122 | }; | |
| 123 | } // namespace __crend | |
| 124 | ||
| 125 | inline namespace __cpo { | |
| 126 | inline constexpr auto crend = __crend::__fn{}; | |
| 127 | } // namespace __cpo | |
| 128 | } // namespace ranges | |
| 129 | ||
| 130 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 131 | ||
| 132 | _LIBCPP_END_NAMESPACE_STD | |
| 133 | ||
| 134 | #endif // _LIBCPP___RANGES_REND_H |
lib/libcxx/include/__ranges/reverse_view.h+24-24| ... | ... | @@ -28,12 +28,12 @@ |
| 28 | 28 | #include <type_traits> |
| 29 | 29 | |
| 30 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 31 | #pragma GCC system_header | |
| 31 | # pragma GCC system_header | |
| 32 | 32 | #endif |
| 33 | 33 | |
| 34 | 34 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 35 | 35 | |
| 36 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 36 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 37 | 37 | |
| 38 | 38 | namespace ranges { |
| 39 | 39 | template<view _View> |
| ... | ... | @@ -43,21 +43,21 @@ namespace ranges { |
| 43 | 43 | // amortized O(1) begin() method. |
| 44 | 44 | static constexpr bool _UseCache = !random_access_range<_View> && !common_range<_View>; |
| 45 | 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(); | |
| 46 | _LIBCPP_NO_UNIQUE_ADDRESS _Cache __cached_begin_ = _Cache(); | |
| 47 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | |
| 48 | 48 | |
| 49 | 49 | public: |
| 50 | 50 | _LIBCPP_HIDE_FROM_ABI |
| 51 | 51 | reverse_view() requires default_initializable<_View> = default; |
| 52 | 52 | |
| 53 | 53 | _LIBCPP_HIDE_FROM_ABI |
| 54 | constexpr explicit reverse_view(_View __view) : __base_(_VSTD::move(__view)) {} | |
| 54 | constexpr explicit reverse_view(_View __view) : __base_(std::move(__view)) {} | |
| 55 | 55 | |
| 56 | 56 | _LIBCPP_HIDE_FROM_ABI |
| 57 | 57 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } |
| 58 | 58 | |
| 59 | 59 | _LIBCPP_HIDE_FROM_ABI |
| 60 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 60 | constexpr _View base() && { return std::move(__base_); } | |
| 61 | 61 | |
| 62 | 62 | _LIBCPP_HIDE_FROM_ABI |
| 63 | 63 | constexpr reverse_iterator<iterator_t<_View>> begin() { |
| ... | ... | @@ -65,7 +65,7 @@ namespace ranges { |
| 65 | 65 | if (__cached_begin_.__has_value()) |
| 66 | 66 | return *__cached_begin_; |
| 67 | 67 | |
| 68 | auto __tmp = _VSTD::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_))); | |
| 68 | auto __tmp = std::make_reverse_iterator(ranges::next(ranges::begin(__base_), ranges::end(__base_))); | |
| 69 | 69 | if constexpr (_UseCache) |
| 70 | 70 | __cached_begin_.__emplace(__tmp); |
| 71 | 71 | return __tmp; |
| ... | ... | @@ -73,22 +73,22 @@ namespace ranges { |
| 73 | 73 | |
| 74 | 74 | _LIBCPP_HIDE_FROM_ABI |
| 75 | 75 | constexpr reverse_iterator<iterator_t<_View>> begin() requires common_range<_View> { |
| 76 | return _VSTD::make_reverse_iterator(ranges::end(__base_)); | |
| 76 | return std::make_reverse_iterator(ranges::end(__base_)); | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | _LIBCPP_HIDE_FROM_ABI |
| 80 | 80 | constexpr auto begin() const requires common_range<const _View> { |
| 81 | return _VSTD::make_reverse_iterator(ranges::end(__base_)); | |
| 81 | return std::make_reverse_iterator(ranges::end(__base_)); | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | _LIBCPP_HIDE_FROM_ABI |
| 85 | 85 | constexpr reverse_iterator<iterator_t<_View>> end() { |
| 86 | return _VSTD::make_reverse_iterator(ranges::begin(__base_)); | |
| 86 | return std::make_reverse_iterator(ranges::begin(__base_)); | |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | _LIBCPP_HIDE_FROM_ABI |
| 90 | 90 | constexpr auto end() const requires common_range<const _View> { |
| 91 | return _VSTD::make_reverse_iterator(ranges::begin(__base_)); | |
| 91 | return std::make_reverse_iterator(ranges::begin(__base_)); | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -111,22 +111,22 @@ namespace ranges { |
| 111 | 111 | namespace views { |
| 112 | 112 | namespace __reverse { |
| 113 | 113 | template<class _Tp> |
| 114 | constexpr bool __is_reverse_view = false; | |
| 114 | inline constexpr bool __is_reverse_view = false; | |
| 115 | 115 | |
| 116 | 116 | template<class _Tp> |
| 117 | constexpr bool __is_reverse_view<reverse_view<_Tp>> = true; | |
| 117 | inline constexpr bool __is_reverse_view<reverse_view<_Tp>> = true; | |
| 118 | 118 | |
| 119 | 119 | template<class _Tp> |
| 120 | constexpr bool __is_sized_reverse_subrange = false; | |
| 120 | inline constexpr bool __is_sized_reverse_subrange = false; | |
| 121 | 121 | |
| 122 | 122 | template<class _Iter> |
| 123 | constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true; | |
| 123 | inline constexpr bool __is_sized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, subrange_kind::sized>> = true; | |
| 124 | 124 | |
| 125 | 125 | template<class _Tp> |
| 126 | constexpr bool __is_unsized_reverse_subrange = false; | |
| 126 | inline constexpr bool __is_unsized_reverse_subrange = false; | |
| 127 | 127 | |
| 128 | 128 | template<class _Iter, subrange_kind _Kind> |
| 129 | constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized; | |
| 129 | inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> = _Kind == subrange_kind::unsized; | |
| 130 | 130 | |
| 131 | 131 | template<class _Tp> |
| 132 | 132 | struct __unwrapped_reverse_subrange { |
| ... | ... | @@ -143,9 +143,9 @@ namespace ranges { |
| 143 | 143 | requires __is_reverse_view<remove_cvref_t<_Range>> |
| 144 | 144 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 145 | 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(); } | |
| 146 | noexcept(noexcept(std::forward<_Range>(__range).base())) | |
| 147 | -> decltype( std::forward<_Range>(__range).base()) | |
| 148 | { return std::forward<_Range>(__range).base(); } | |
| 149 | 149 | |
| 150 | 150 | template<class _Range, |
| 151 | 151 | class _UnwrappedSubrange = typename __unwrapped_reverse_subrange<remove_cvref_t<_Range>>::type> |
| ... | ... | @@ -171,9 +171,9 @@ namespace ranges { |
| 171 | 171 | !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>) |
| 172 | 172 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 173 | 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)}; } | |
| 174 | noexcept(noexcept(reverse_view{std::forward<_Range>(__range)})) | |
| 175 | -> decltype( reverse_view{std::forward<_Range>(__range)}) | |
| 176 | { return reverse_view{std::forward<_Range>(__range)}; } | |
| 177 | 177 | }; |
| 178 | 178 | } // namespace __reverse |
| 179 | 179 | |
| ... | ... | @@ -183,7 +183,7 @@ namespace ranges { |
| 183 | 183 | } // namespace views |
| 184 | 184 | } // namespace ranges |
| 185 | 185 | |
| 186 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 186 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 187 | 187 | |
| 188 | 188 | _LIBCPP_END_NAMESPACE_STD |
| 189 | 189 |
lib/libcxx/include/__ranges/single_view.h+27-7| ... | ... | @@ -11,6 +11,7 @@ |
| 11 | 11 | |
| 12 | 12 | #include <__config> |
| 13 | 13 | #include <__ranges/copyable_box.h> |
| 14 | #include <__ranges/range_adaptor.h> | |
| 14 | 15 | #include <__ranges/view_interface.h> |
| 15 | 16 | #include <__utility/forward.h> |
| 16 | 17 | #include <__utility/in_place.h> |
| ... | ... | @@ -19,12 +20,12 @@ |
| 19 | 20 | #include <type_traits> |
| 20 | 21 | |
| 21 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 23 | 24 | #endif |
| 24 | 25 | |
| 25 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 27 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 28 | 29 | |
| 29 | 30 | namespace ranges { |
| 30 | 31 | template<copy_constructible _Tp> |
| ... | ... | @@ -40,13 +41,13 @@ namespace ranges { |
| 40 | 41 | constexpr explicit single_view(const _Tp& __t) : __value_(in_place, __t) {} |
| 41 | 42 | |
| 42 | 43 | _LIBCPP_HIDE_FROM_ABI |
| 43 | constexpr explicit single_view(_Tp&& __t) : __value_(in_place, _VSTD::move(__t)) {} | |
| 44 | constexpr explicit single_view(_Tp&& __t) : __value_(in_place, std::move(__t)) {} | |
| 44 | 45 | |
| 45 | 46 | template<class... _Args> |
| 46 | 47 | requires constructible_from<_Tp, _Args...> |
| 47 | 48 | _LIBCPP_HIDE_FROM_ABI |
| 48 | 49 | constexpr explicit single_view(in_place_t, _Args&&... __args) |
| 49 | : __value_{in_place, _VSTD::forward<_Args>(__args)...} {} | |
| 50 | : __value_{in_place, std::forward<_Args>(__args)...} {} | |
| 50 | 51 | |
| 51 | 52 | _LIBCPP_HIDE_FROM_ABI |
| 52 | 53 | constexpr _Tp* begin() noexcept { return data(); } |
| ... | ... | @@ -70,11 +71,30 @@ namespace ranges { |
| 70 | 71 | constexpr const _Tp* data() const noexcept { return __value_.operator->(); } |
| 71 | 72 | }; |
| 72 | 73 | |
| 73 | template<class _Tp> | |
| 74 | single_view(_Tp) -> single_view<_Tp>; | |
| 74 | template<class _Tp> | |
| 75 | single_view(_Tp) -> single_view<_Tp>; | |
| 76 | ||
| 77 | namespace views { | |
| 78 | namespace __single_view { | |
| 79 | ||
| 80 | struct __fn : __range_adaptor_closure<__fn> { | |
| 81 | template<class _Range> | |
| 82 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 83 | constexpr auto operator()(_Range&& __range) const | |
| 84 | noexcept(noexcept(single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)))) | |
| 85 | -> decltype( single_view<decay_t<_Range&&>>(std::forward<_Range>(__range))) | |
| 86 | { return single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)); } | |
| 87 | }; | |
| 88 | } // namespace __single_view | |
| 89 | ||
| 90 | inline namespace __cpo { | |
| 91 | inline constexpr auto single = __single_view::__fn{}; | |
| 92 | } // namespace __cpo | |
| 93 | ||
| 94 | } // namespace views | |
| 75 | 95 | } // namespace ranges |
| 76 | 96 | |
| 77 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 97 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 78 | 98 | |
| 79 | 99 | _LIBCPP_END_NAMESPACE_STD |
| 80 | 100 |
lib/libcxx/include/__ranges/size.h+84-77| ... | ... | @@ -19,12 +19,12 @@ |
| 19 | 19 | #include <type_traits> |
| 20 | 20 | |
| 21 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 23 | 23 | #endif |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | 28 | |
| 29 | 29 | namespace ranges { |
| 30 | 30 | template<class> |
| ... | ... | @@ -35,68 +35,76 @@ namespace ranges { |
| 35 | 35 | |
| 36 | 36 | namespace ranges { |
| 37 | 37 | namespace __size { |
| 38 | void size(auto&) = delete; | |
| 39 | void size(const auto&) = delete; | |
| 40 | ||
| 41 | template <class _Tp> | |
| 42 | concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; | |
| 43 | ||
| 44 | template <class _Tp> | |
| 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 | }; | |
| 51 | ||
| 52 | template <class _Tp> | |
| 53 | concept __unqualified_size = | |
| 54 | __size_enabled<_Tp> && | |
| 55 | !__member_size<_Tp> && | |
| 56 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 57 | requires(_Tp&& __t) { | |
| 58 | { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like; | |
| 59 | }; | |
| 60 | ||
| 61 | template <class _Tp> | |
| 62 | concept __difference = | |
| 63 | !__member_size<_Tp> && | |
| 64 | !__unqualified_size<_Tp> && | |
| 65 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 66 | requires(_Tp&& __t) { | |
| 67 | { ranges::begin(__t) } -> forward_iterator; | |
| 68 | { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>; | |
| 69 | }; | |
| 70 | ||
| 71 | struct __fn { | |
| 72 | template <class _Tp, size_t _Sz> | |
| 73 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept { | |
| 74 | return _Sz; | |
| 75 | } | |
| 76 | ||
| 77 | template <class _Tp, size_t _Sz> | |
| 78 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept { | |
| 79 | return _Sz; | |
| 80 | } | |
| 81 | ||
| 82 | template <__member_size _Tp> | |
| 83 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const | |
| 84 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) { | |
| 85 | return _LIBCPP_AUTO_CAST(__t.size()); | |
| 86 | } | |
| 87 | ||
| 88 | template <__unqualified_size _Tp> | |
| 89 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const | |
| 90 | noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) { | |
| 91 | return _LIBCPP_AUTO_CAST(size(__t)); | |
| 92 | } | |
| 93 | ||
| 94 | template<__difference _Tp> | |
| 95 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const | |
| 96 | noexcept(noexcept(ranges::end(__t) - ranges::begin(__t))) { | |
| 97 | return _VSTD::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)); | |
| 98 | } | |
| 38 | void size(auto&) = delete; | |
| 39 | void size(const auto&) = delete; | |
| 40 | ||
| 41 | template <class _Tp> | |
| 42 | concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; | |
| 43 | ||
| 44 | template <class _Tp> | |
| 45 | concept __member_size = | |
| 46 | __size_enabled<_Tp> && | |
| 47 | __workaround_52970<_Tp> && | |
| 48 | requires(_Tp&& __t) { | |
| 49 | { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like; | |
| 99 | 50 | }; |
| 51 | ||
| 52 | template <class _Tp> | |
| 53 | concept __unqualified_size = | |
| 54 | __size_enabled<_Tp> && | |
| 55 | !__member_size<_Tp> && | |
| 56 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 57 | requires(_Tp&& __t) { | |
| 58 | { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like; | |
| 59 | }; | |
| 60 | ||
| 61 | template <class _Tp> | |
| 62 | concept __difference = | |
| 63 | !__member_size<_Tp> && | |
| 64 | !__unqualified_size<_Tp> && | |
| 65 | __class_or_enum<remove_cvref_t<_Tp>> && | |
| 66 | requires(_Tp&& __t) { | |
| 67 | { ranges::begin(__t) } -> forward_iterator; | |
| 68 | { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>; | |
| 69 | }; | |
| 70 | ||
| 71 | struct __fn { | |
| 72 | ||
| 73 | // `[range.prim.size]`: the array case (for rvalues). | |
| 74 | template <class _Tp, size_t _Sz> | |
| 75 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept { | |
| 76 | return _Sz; | |
| 77 | } | |
| 78 | ||
| 79 | // `[range.prim.size]`: the array case (for lvalues). | |
| 80 | template <class _Tp, size_t _Sz> | |
| 81 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept { | |
| 82 | return _Sz; | |
| 83 | } | |
| 84 | ||
| 85 | // `[range.prim.size]`: `auto(t.size())` is a valid expression. | |
| 86 | template <__member_size _Tp> | |
| 87 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const | |
| 88 | noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) { | |
| 89 | return _LIBCPP_AUTO_CAST(__t.size()); | |
| 90 | } | |
| 91 | ||
| 92 | // `[range.prim.size]`: `auto(size(t))` is a valid expression. | |
| 93 | template <__unqualified_size _Tp> | |
| 94 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const | |
| 95 | noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) { | |
| 96 | return _LIBCPP_AUTO_CAST(size(__t)); | |
| 97 | } | |
| 98 | ||
| 99 | // [range.prim.size]: the `to-unsigned-like` case. | |
| 100 | template <__difference _Tp> | |
| 101 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const | |
| 102 | noexcept(noexcept(std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)))) | |
| 103 | -> decltype( std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t))) | |
| 104 | { return std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)); | |
| 105 | } | |
| 106 | }; | |
| 107 | ||
| 100 | 108 | } // namespace __size |
| 101 | 109 | |
| 102 | 110 | inline namespace __cpo { |
| ... | ... | @@ -108,19 +116,18 @@ inline namespace __cpo { |
| 108 | 116 | |
| 109 | 117 | namespace ranges { |
| 110 | 118 | namespace __ssize { |
| 111 | struct __fn { | |
| 112 | template<class _Tp> | |
| 113 | requires requires (_Tp&& __t) { ranges::size(__t); } | |
| 114 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const | |
| 115 | noexcept(noexcept(ranges::size(__t))) | |
| 116 | { | |
| 117 | using _Signed = make_signed_t<decltype(ranges::size(__t))>; | |
| 118 | if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed)) | |
| 119 | return static_cast<ptrdiff_t>(ranges::size(__t)); | |
| 120 | else | |
| 121 | return static_cast<_Signed>(ranges::size(__t)); | |
| 122 | } | |
| 123 | }; | |
| 119 | struct __fn { | |
| 120 | template<class _Tp> | |
| 121 | requires requires (_Tp&& __t) { ranges::size(__t); } | |
| 122 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const | |
| 123 | noexcept(noexcept(ranges::size(__t))) { | |
| 124 | using _Signed = make_signed_t<decltype(ranges::size(__t))>; | |
| 125 | if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed)) | |
| 126 | return static_cast<ptrdiff_t>(ranges::size(__t)); | |
| 127 | else | |
| 128 | return static_cast<_Signed>(ranges::size(__t)); | |
| 129 | } | |
| 130 | }; | |
| 124 | 131 | } // namespace __ssize |
| 125 | 132 | |
| 126 | 133 | inline namespace __cpo { |
| ... | ... | @@ -128,7 +135,7 @@ inline namespace __cpo { |
| 128 | 135 | } // namespace __cpo |
| 129 | 136 | } // namespace ranges |
| 130 | 137 | |
| 131 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 138 | #endif // _LIBCPP_STD_VER > 17 | |
| 132 | 139 | |
| 133 | 140 | _LIBCPP_END_NAMESPACE_STD |
| 134 | 141 |
lib/libcxx/include/__ranges/subrange.h+20-17| ... | ... | @@ -9,13 +9,13 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_SUBRANGE_H |
| 10 | 10 | #define _LIBCPP___RANGES_SUBRANGE_H |
| 11 | 11 | |
| 12 | #include <__assert> | |
| 12 | 13 | #include <__concepts/constructible.h> |
| 13 | 14 | #include <__concepts/convertible_to.h> |
| 14 | 15 | #include <__concepts/copyable.h> |
| 15 | 16 | #include <__concepts/derived_from.h> |
| 16 | 17 | #include <__concepts/different_from.h> |
| 17 | 18 | #include <__config> |
| 18 | #include <__debug> | |
| 19 | 19 | #include <__iterator/advance.h> |
| 20 | 20 | #include <__iterator/concepts.h> |
| 21 | 21 | #include <__iterator/incrementable_traits.h> |
| ... | ... | @@ -31,12 +31,12 @@ |
| 31 | 31 | #include <type_traits> |
| 32 | 32 | |
| 33 | 33 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 34 | #pragma GCC system_header | |
| 34 | # pragma GCC system_header | |
| 35 | 35 | #endif |
| 36 | 36 | |
| 37 | 37 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 38 | 38 | |
| 39 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 39 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 40 | 40 | |
| 41 | 41 | namespace ranges { |
| 42 | 42 | template<class _From, class _To> |
| ... | ... | @@ -56,8 +56,8 @@ namespace ranges { |
| 56 | 56 | requires derived_from<tuple_size<_Tp>, integral_constant<size_t, 2>>; |
| 57 | 57 | typename tuple_element_t<0, remove_const_t<_Tp>>; |
| 58 | 58 | typename tuple_element_t<1, remove_const_t<_Tp>>; |
| 59 | { _VSTD::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>; | |
| 60 | { _VSTD::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>; | |
| 59 | { std::get<0>(__t) } -> convertible_to<const tuple_element_t<0, _Tp>&>; | |
| 60 | { std::get<1>(__t) } -> convertible_to<const tuple_element_t<1, _Tp>&>; | |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | template<class _Pair, class _Iter, class _Sent> |
| ... | ... | @@ -77,14 +77,17 @@ namespace ranges { |
| 77 | 77 | class _LIBCPP_TEMPLATE_VIS subrange |
| 78 | 78 | : public view_interface<subrange<_Iter, _Sent, _Kind>> |
| 79 | 79 | { |
| 80 | private: | |
| 80 | public: | |
| 81 | // Note: this is an internal implementation detail that is public only for internal usage. | |
| 81 | 82 | static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>); |
| 83 | ||
| 84 | private: | |
| 82 | 85 | static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics |
| 83 | 86 | struct _Empty { constexpr _Empty(auto) noexcept { } }; |
| 84 | 87 | 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 | _LIBCPP_NO_UNIQUE_ADDRESS _Iter __begin_ = _Iter(); | |
| 89 | _LIBCPP_NO_UNIQUE_ADDRESS _Sent __end_ = _Sent(); | |
| 90 | _LIBCPP_NO_UNIQUE_ADDRESS _Size __size_ = 0; | |
| 88 | 91 | |
| 89 | 92 | public: |
| 90 | 93 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -93,14 +96,14 @@ namespace ranges { |
| 93 | 96 | _LIBCPP_HIDE_FROM_ABI |
| 94 | 97 | constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent) |
| 95 | 98 | requires _MustProvideSizeAtConstruction |
| 96 | : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent)) | |
| 99 | : __begin_(std::move(__iter)), __end_(std::move(__sent)) | |
| 97 | 100 | { } |
| 98 | 101 | |
| 99 | 102 | _LIBCPP_HIDE_FROM_ABI |
| 100 | 103 | constexpr subrange(__convertible_to_non_slicing<_Iter> auto __iter, _Sent __sent, |
| 101 | 104 | make_unsigned_t<iter_difference_t<_Iter>> __n) |
| 102 | 105 | requires (_Kind == subrange_kind::sized) |
| 103 | : __begin_(_VSTD::move(__iter)), __end_(_VSTD::move(__sent)), __size_(__n) | |
| 106 | : __begin_(std::move(__iter)), __end_(std::move(__sent)), __size_(__n) | |
| 104 | 107 | { |
| 105 | 108 | if constexpr (sized_sentinel_for<_Sent, _Iter>) |
| 106 | 109 | _LIBCPP_ASSERT((__end_ - __begin_) == static_cast<iter_difference_t<_Iter>>(__n), |
| ... | ... | @@ -149,7 +152,7 @@ namespace ranges { |
| 149 | 152 | } |
| 150 | 153 | |
| 151 | 154 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() requires (!copyable<_Iter>) { |
| 152 | return _VSTD::move(__begin_); | |
| 155 | return std::move(__begin_); | |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | 158 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -168,7 +171,7 @@ namespace ranges { |
| 168 | 171 | if constexpr (_StoreSize) |
| 169 | 172 | return __size_; |
| 170 | 173 | else |
| 171 | return _VSTD::__to_unsigned_like(__end_ - __begin_); | |
| 174 | return std::__to_unsigned_like(__end_ - __begin_); | |
| 172 | 175 | } |
| 173 | 176 | |
| 174 | 177 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) const& |
| ... | ... | @@ -181,7 +184,7 @@ namespace ranges { |
| 181 | 184 | |
| 182 | 185 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange next(iter_difference_t<_Iter> __n = 1) && { |
| 183 | 186 | advance(__n); |
| 184 | return _VSTD::move(*this); | |
| 187 | return std::move(*this); | |
| 185 | 188 | } |
| 186 | 189 | |
| 187 | 190 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange prev(iter_difference_t<_Iter> __n = 1) const |
| ... | ... | @@ -198,14 +201,14 @@ namespace ranges { |
| 198 | 201 | if (__n < 0) { |
| 199 | 202 | ranges::advance(__begin_, __n); |
| 200 | 203 | if constexpr (_StoreSize) |
| 201 | __size_ += _VSTD::__to_unsigned_like(-__n); | |
| 204 | __size_ += std::__to_unsigned_like(-__n); | |
| 202 | 205 | return *this; |
| 203 | 206 | } |
| 204 | 207 | } |
| 205 | 208 | |
| 206 | 209 | auto __d = __n - ranges::advance(__begin_, __n, __end_); |
| 207 | 210 | if constexpr (_StoreSize) |
| 208 | __size_ -= _VSTD::__to_unsigned_like(__d); | |
| 211 | __size_ -= std::__to_unsigned_like(__d); | |
| 209 | 212 | return *this; |
| 210 | 213 | } |
| 211 | 214 | }; |
| ... | ... | @@ -282,7 +285,7 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> { |
| 282 | 285 | using type = _Sp; |
| 283 | 286 | }; |
| 284 | 287 | |
| 285 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 288 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 286 | 289 | |
| 287 | 290 | _LIBCPP_END_NAMESPACE_STD |
| 288 | 291 |
lib/libcxx/include/__ranges/take_view.h+274-122| ... | ... | @@ -10,23 +10,34 @@ |
| 10 | 10 | #define _LIBCPP___RANGES_TAKE_VIEW_H |
| 11 | 11 | |
| 12 | 12 | #include <__algorithm/min.h> |
| 13 | #include <__algorithm/ranges_min.h> | |
| 13 | 14 | #include <__config> |
| 15 | #include <__functional/bind_back.h> | |
| 16 | #include <__fwd/span.h> | |
| 17 | #include <__fwd/string_view.h> | |
| 14 | 18 | #include <__iterator/concepts.h> |
| 15 | 19 | #include <__iterator/counted_iterator.h> |
| 16 | 20 | #include <__iterator/default_sentinel.h> |
| 21 | #include <__iterator/distance.h> | |
| 17 | 22 | #include <__iterator/iterator_traits.h> |
| 18 | 23 | #include <__ranges/access.h> |
| 19 | 24 | #include <__ranges/all.h> |
| 20 | 25 | #include <__ranges/concepts.h> |
| 26 | #include <__ranges/empty_view.h> | |
| 21 | 27 | #include <__ranges/enable_borrowed_range.h> |
| 28 | #include <__ranges/iota_view.h> | |
| 29 | #include <__ranges/range_adaptor.h> | |
| 22 | 30 | #include <__ranges/size.h> |
| 31 | #include <__ranges/subrange.h> | |
| 23 | 32 | #include <__ranges/view_interface.h> |
| 33 | #include <__utility/auto_cast.h> | |
| 34 | #include <__utility/forward.h> | |
| 24 | 35 | #include <__utility/move.h> |
| 25 | 36 | #include <concepts> |
| 26 | 37 | #include <type_traits> |
| 27 | 38 | |
| 28 | 39 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | #pragma GCC system_header | |
| 40 | # pragma GCC system_header | |
| 30 | 41 | #endif |
| 31 | 42 | |
| 32 | 43 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -34,149 +45,290 @@ _LIBCPP_PUSH_MACROS |
| 34 | 45 | |
| 35 | 46 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 36 | 47 | |
| 37 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 48 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 38 | 49 | |
| 39 | 50 | 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 | } | |
| 51 | ||
| 52 | template<view _View> | |
| 53 | class take_view : public view_interface<take_view<_View>> { | |
| 54 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | |
| 55 | range_difference_t<_View> __count_ = 0; | |
| 56 | ||
| 57 | template<bool> class __sentinel; | |
| 58 | ||
| 59 | public: | |
| 60 | _LIBCPP_HIDE_FROM_ABI | |
| 61 | take_view() requires default_initializable<_View> = default; | |
| 62 | ||
| 63 | _LIBCPP_HIDE_FROM_ABI | |
| 64 | constexpr take_view(_View __base, range_difference_t<_View> __count) | |
| 65 | : __base_(std::move(__base)), __count_(__count) {} | |
| 66 | ||
| 67 | _LIBCPP_HIDE_FROM_ABI | |
| 68 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } | |
| 69 | ||
| 70 | _LIBCPP_HIDE_FROM_ABI | |
| 71 | constexpr _View base() && { return std::move(__base_); } | |
| 72 | ||
| 73 | _LIBCPP_HIDE_FROM_ABI | |
| 74 | constexpr auto begin() requires (!__simple_view<_View>) { | |
| 75 | if constexpr (sized_range<_View>) { | |
| 76 | if constexpr (random_access_range<_View>) { | |
| 77 | return ranges::begin(__base_); | |
| 71 | 78 | } else { |
| 72 | return counted_iterator(ranges::begin(__base_), __count_); | |
| 79 | using _DifferenceT = range_difference_t<_View>; | |
| 80 | auto __size = size(); | |
| 81 | return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size)); | |
| 73 | 82 | } |
| 83 | } else { | |
| 84 | return counted_iterator(ranges::begin(__base_), __count_); | |
| 74 | 85 | } |
| 86 | } | |
| 75 | 87 | |
| 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 | } | |
| 88 | _LIBCPP_HIDE_FROM_ABI | |
| 89 | constexpr auto begin() const requires range<const _View> { | |
| 90 | if constexpr (sized_range<const _View>) { | |
| 91 | if constexpr (random_access_range<const _View>) { | |
| 92 | return ranges::begin(__base_); | |
| 86 | 93 | } else { |
| 87 | return counted_iterator(ranges::begin(__base_), __count_); | |
| 94 | using _DifferenceT = range_difference_t<const _View>; | |
| 95 | auto __size = size(); | |
| 96 | return counted_iterator(ranges::begin(__base_), static_cast<_DifferenceT>(__size)); | |
| 88 | 97 | } |
| 98 | } else { | |
| 99 | return counted_iterator(ranges::begin(__base_), __count_); | |
| 89 | 100 | } |
| 101 | } | |
| 90 | 102 | |
| 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 | } | |
| 103 | _LIBCPP_HIDE_FROM_ABI | |
| 104 | constexpr auto end() requires (!__simple_view<_View>) { | |
| 105 | if constexpr (sized_range<_View>) { | |
| 106 | if constexpr (random_access_range<_View>) { | |
| 107 | return ranges::begin(__base_) + size(); | |
| 99 | 108 | } else { |
| 100 | return __sentinel<false>{ranges::end(__base_)}; | |
| 109 | return default_sentinel; | |
| 101 | 110 | } |
| 111 | } else { | |
| 112 | return __sentinel<false>{ranges::end(__base_)}; | |
| 102 | 113 | } |
| 114 | } | |
| 103 | 115 | |
| 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 | } | |
| 116 | _LIBCPP_HIDE_FROM_ABI | |
| 117 | constexpr auto end() const requires range<const _View> { | |
| 118 | if constexpr (sized_range<const _View>) { | |
| 119 | if constexpr (random_access_range<const _View>) { | |
| 120 | return ranges::begin(__base_) + size(); | |
| 112 | 121 | } else { |
| 113 | return __sentinel<true>{ranges::end(__base_)}; | |
| 122 | return default_sentinel; | |
| 114 | 123 | } |
| 124 | } else { | |
| 125 | return __sentinel<true>{ranges::end(__base_)}; | |
| 115 | 126 | } |
| 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; | |
| 127 | } | |
| 128 | ||
| 129 | _LIBCPP_HIDE_FROM_ABI | |
| 130 | constexpr auto size() requires sized_range<_View> { | |
| 131 | auto __n = ranges::size(__base_); | |
| 132 | return ranges::min(__n, static_cast<decltype(__n)>(__count_)); | |
| 133 | } | |
| 134 | ||
| 135 | _LIBCPP_HIDE_FROM_ABI | |
| 136 | constexpr auto size() const requires sized_range<const _View> { | |
| 137 | auto __n = ranges::size(__base_); | |
| 138 | return ranges::min(__n, static_cast<decltype(__n)>(__count_)); | |
| 139 | } | |
| 140 | }; | |
| 141 | ||
| 142 | template<view _View> | |
| 143 | template<bool _Const> | |
| 144 | class take_view<_View>::__sentinel { | |
| 145 | using _Base = __maybe_const<_Const, _View>; | |
| 146 | template<bool _OtherConst> | |
| 147 | using _Iter = counted_iterator<iterator_t<__maybe_const<_OtherConst, _View>>>; | |
| 148 | _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>(); | |
| 149 | ||
| 150 | template<bool> | |
| 151 | friend class take_view<_View>::__sentinel; | |
| 143 | 152 | |
| 144 | 153 | 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>>; | |
| 154 | _LIBCPP_HIDE_FROM_ABI | |
| 155 | __sentinel() = default; | |
| 156 | ||
| 157 | _LIBCPP_HIDE_FROM_ABI | |
| 158 | constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {} | |
| 159 | ||
| 160 | _LIBCPP_HIDE_FROM_ABI | |
| 161 | constexpr __sentinel(__sentinel<!_Const> __s) | |
| 162 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> | |
| 163 | : __end_(std::move(__s.__end_)) {} | |
| 164 | ||
| 165 | _LIBCPP_HIDE_FROM_ABI | |
| 166 | constexpr sentinel_t<_Base> base() const { return __end_; } | |
| 167 | ||
| 168 | _LIBCPP_HIDE_FROM_ABI | |
| 169 | friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) { | |
| 170 | return __lhs.count() == 0 || __lhs.base() == __rhs.__end_; | |
| 171 | } | |
| 172 | ||
| 173 | template<bool _OtherConst = !_Const> | |
| 174 | requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>> | |
| 175 | _LIBCPP_HIDE_FROM_ABI | |
| 176 | friend constexpr bool operator==(const _Iter<_Const>& __lhs, const __sentinel& __rhs) { | |
| 177 | return __lhs.count() == 0 || __lhs.base() == __rhs.__end_; | |
| 178 | } | |
| 179 | }; | |
| 180 | ||
| 181 | template<class _Range> | |
| 182 | take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range>>; | |
| 183 | ||
| 184 | template<class _Tp> | |
| 185 | inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 186 | ||
| 187 | namespace views { | |
| 188 | namespace __take { | |
| 189 | ||
| 190 | template <class _Tp> | |
| 191 | inline constexpr bool __is_empty_view = false; | |
| 192 | ||
| 193 | template <class _Tp> | |
| 194 | inline constexpr bool __is_empty_view<empty_view<_Tp>> = true; | |
| 195 | ||
| 196 | template <class _Tp> | |
| 197 | inline constexpr bool __is_passthrough_specialization = false; | |
| 198 | ||
| 199 | template <class _Tp, size_t _Extent> | |
| 200 | inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true; | |
| 201 | ||
| 202 | template <class _CharT, class _Traits> | |
| 203 | inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true; | |
| 204 | ||
| 205 | template <class _Iter, class _Sent, subrange_kind _Kind> | |
| 206 | inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = true; | |
| 207 | ||
| 208 | template <class _Tp> | |
| 209 | inline constexpr bool __is_iota_specialization = false; | |
| 210 | ||
| 211 | template <class _Np, class _Bound> | |
| 212 | inline constexpr bool __is_iota_specialization<iota_view<_Np, _Bound>> = true; | |
| 213 | ||
| 214 | template <class _Tp> | |
| 215 | struct __passthrough_type; | |
| 216 | ||
| 217 | template <class _Tp, size_t _Extent> | |
| 218 | struct __passthrough_type<span<_Tp, _Extent>> { | |
| 219 | using type = span<_Tp>; | |
| 220 | }; | |
| 221 | ||
| 222 | template <class _CharT, class _Traits> | |
| 223 | struct __passthrough_type<basic_string_view<_CharT, _Traits>> { | |
| 224 | using type = basic_string_view<_CharT, _Traits>; | |
| 225 | }; | |
| 226 | ||
| 227 | template <class _Iter, class _Sent, subrange_kind _Kind> | |
| 228 | struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { | |
| 229 | using type = subrange<_Iter>; | |
| 230 | }; | |
| 231 | ||
| 232 | template <class _Tp> | |
| 233 | using __passthrough_type_t = typename __passthrough_type<_Tp>::type; | |
| 234 | ||
| 235 | struct __fn { | |
| 236 | // [range.take.overview]: the `empty_view` case. | |
| 237 | template <class _Range, convertible_to<range_difference_t<_Range>> _Np> | |
| 238 | requires __is_empty_view<remove_cvref_t<_Range>> | |
| 239 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 240 | constexpr auto operator()(_Range&& __range, _Np&&) const | |
| 241 | noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))) | |
| 242 | -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) | |
| 243 | { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); } | |
| 244 | ||
| 245 | // [range.take.overview]: the `span | basic_string_view | subrange` case. | |
| 246 | template <class _Range, | |
| 247 | convertible_to<range_difference_t<_Range>> _Np, | |
| 248 | class _RawRange = remove_cvref_t<_Range>, | |
| 249 | class _Dist = range_difference_t<_Range>> | |
| 250 | requires (!__is_empty_view<_RawRange> && | |
| 251 | random_access_range<_RawRange> && | |
| 252 | sized_range<_RawRange> && | |
| 253 | __is_passthrough_specialization<_RawRange>) | |
| 254 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 255 | constexpr auto operator()(_Range&& __rng, _Np&& __n) const | |
| 256 | noexcept(noexcept(__passthrough_type_t<_RawRange>( | |
| 257 | ranges::begin(__rng), | |
| 258 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) | |
| 259 | ))) | |
| 260 | -> decltype( __passthrough_type_t<_RawRange>( | |
| 261 | // Note: deliberately not forwarding `__rng` to guard against double moves. | |
| 262 | ranges::begin(__rng), | |
| 263 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) | |
| 264 | )) | |
| 265 | { return __passthrough_type_t<_RawRange>( | |
| 266 | ranges::begin(__rng), | |
| 267 | ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) | |
| 268 | ); } | |
| 269 | ||
| 270 | // [range.take.overview]: the `iota_view` case. | |
| 271 | template <class _Range, | |
| 272 | convertible_to<range_difference_t<_Range>> _Np, | |
| 273 | class _RawRange = remove_cvref_t<_Range>, | |
| 274 | class _Dist = range_difference_t<_Range>> | |
| 275 | requires (!__is_empty_view<_RawRange> && | |
| 276 | random_access_range<_RawRange> && | |
| 277 | sized_range<_RawRange> && | |
| 278 | __is_iota_specialization<_RawRange>) | |
| 279 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 280 | constexpr auto operator()(_Range&& __rng, _Np&& __n) const | |
| 281 | noexcept(noexcept(ranges::iota_view( | |
| 282 | *ranges::begin(__rng), | |
| 283 | *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) | |
| 284 | ))) | |
| 285 | -> decltype( ranges::iota_view( | |
| 286 | // Note: deliberately not forwarding `__rng` to guard against double moves. | |
| 287 | *ranges::begin(__rng), | |
| 288 | *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) | |
| 289 | )) | |
| 290 | { return ranges::iota_view( | |
| 291 | *ranges::begin(__rng), | |
| 292 | *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) | |
| 293 | ); } | |
| 294 | ||
| 295 | // [range.take.overview]: the "otherwise" case. | |
| 296 | template <class _Range, convertible_to<range_difference_t<_Range>> _Np, | |
| 297 | class _RawRange = remove_cvref_t<_Range>> | |
| 298 | // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other | |
| 299 | // overloads. | |
| 300 | requires (!(__is_empty_view<_RawRange> || | |
| 301 | (__is_iota_specialization<_RawRange> && | |
| 302 | sized_range<_RawRange> && | |
| 303 | random_access_range<_RawRange>) || | |
| 304 | (__is_passthrough_specialization<_RawRange> && | |
| 305 | sized_range<_RawRange> && | |
| 306 | random_access_range<_RawRange>) | |
| 307 | )) | |
| 308 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 309 | constexpr auto operator()(_Range&& __range, _Np&& __n) const | |
| 310 | noexcept(noexcept(take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))) | |
| 311 | -> decltype( take_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) | |
| 312 | { return take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); } | |
| 313 | ||
| 314 | template <class _Np> | |
| 315 | requires constructible_from<decay_t<_Np>, _Np> | |
| 316 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI | |
| 317 | constexpr auto operator()(_Np&& __n) const | |
| 318 | noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) | |
| 319 | { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); } | |
| 320 | }; | |
| 321 | ||
| 322 | } // namespace __take | |
| 323 | ||
| 324 | inline namespace __cpo { | |
| 325 | inline constexpr auto take = __take::__fn{}; | |
| 326 | } // namespace __cpo | |
| 327 | } // namespace views | |
| 174 | 328 | |
| 175 | template<class _Tp> | |
| 176 | inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>; | |
| 177 | 329 | } // namespace ranges |
| 178 | 330 | |
| 179 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 331 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 180 | 332 | |
| 181 | 333 | _LIBCPP_END_NAMESPACE_STD |
| 182 | 334 |
lib/libcxx/include/__ranges/transform_view.h+21-21| ... | ... | @@ -36,12 +36,12 @@ |
| 36 | 36 | #include <type_traits> |
| 37 | 37 | |
| 38 | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 39 | #pragma GCC system_header | |
| 39 | # pragma GCC system_header | |
| 40 | 40 | #endif |
| 41 | 41 | |
| 42 | 42 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 43 | 43 | |
| 44 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 44 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 45 | 45 | |
| 46 | 46 | namespace ranges { |
| 47 | 47 | |
| ... | ... | @@ -53,7 +53,7 @@ template<class _View, class _Fn> |
| 53 | 53 | concept __transform_view_constraints = |
| 54 | 54 | view<_View> && is_object_v<_Fn> && |
| 55 | 55 | regular_invocable<_Fn&, range_reference_t<_View>> && |
| 56 | __referenceable<invoke_result_t<_Fn&, range_reference_t<_View>>>; | |
| 56 | __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>; | |
| 57 | 57 | |
| 58 | 58 | template<input_range _View, copy_constructible _Fn> |
| 59 | 59 | requires __transform_view_constraints<_View, _Fn> |
| ... | ... | @@ -61,8 +61,8 @@ class transform_view : public view_interface<transform_view<_View, _Fn>> { |
| 61 | 61 | template<bool> class __iterator; |
| 62 | 62 | template<bool> class __sentinel; |
| 63 | 63 | |
| 64 | [[no_unique_address]] __copyable_box<_Fn> __func_; | |
| 65 | [[no_unique_address]] _View __base_ = _View(); | |
| 64 | _LIBCPP_NO_UNIQUE_ADDRESS __copyable_box<_Fn> __func_; | |
| 65 | _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); | |
| 66 | 66 | |
| 67 | 67 | public: |
| 68 | 68 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -71,12 +71,12 @@ public: |
| 71 | 71 | |
| 72 | 72 | _LIBCPP_HIDE_FROM_ABI |
| 73 | 73 | constexpr transform_view(_View __base, _Fn __func) |
| 74 | : __func_(_VSTD::in_place, _VSTD::move(__func)), __base_(_VSTD::move(__base)) {} | |
| 74 | : __func_(std::in_place, std::move(__func)), __base_(std::move(__base)) {} | |
| 75 | 75 | |
| 76 | 76 | _LIBCPP_HIDE_FROM_ABI |
| 77 | 77 | constexpr _View base() const& requires copy_constructible<_View> { return __base_; } |
| 78 | 78 | _LIBCPP_HIDE_FROM_ABI |
| 79 | constexpr _View base() && { return _VSTD::move(__base_); } | |
| 79 | constexpr _View base() && { return std::move(__base_); } | |
| 80 | 80 | |
| 81 | 81 | _LIBCPP_HIDE_FROM_ABI |
| 82 | 82 | constexpr __iterator<false> begin() { |
| ... | ... | @@ -183,7 +183,7 @@ public: |
| 183 | 183 | |
| 184 | 184 | _LIBCPP_HIDE_FROM_ABI |
| 185 | 185 | constexpr __iterator(_Parent& __parent, iterator_t<_Base> __current) |
| 186 | : __parent_(_VSTD::addressof(__parent)), __current_(_VSTD::move(__current)) {} | |
| 186 | : __parent_(std::addressof(__parent)), __current_(std::move(__current)) {} | |
| 187 | 187 | |
| 188 | 188 | // Note: `__i` should always be `__iterator<false>`, but directly using |
| 189 | 189 | // `__iterator<false>` is ill-formed when `_Const` is false |
| ... | ... | @@ -191,7 +191,7 @@ public: |
| 191 | 191 | _LIBCPP_HIDE_FROM_ABI |
| 192 | 192 | constexpr __iterator(__iterator<!_Const> __i) |
| 193 | 193 | requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>> |
| 194 | : __parent_(__i.__parent_), __current_(_VSTD::move(__i.__current_)) {} | |
| 194 | : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {} | |
| 195 | 195 | |
| 196 | 196 | _LIBCPP_HIDE_FROM_ABI |
| 197 | 197 | constexpr const iterator_t<_Base>& base() const& noexcept { |
| ... | ... | @@ -200,14 +200,14 @@ public: |
| 200 | 200 | |
| 201 | 201 | _LIBCPP_HIDE_FROM_ABI |
| 202 | 202 | constexpr iterator_t<_Base> base() && { |
| 203 | return _VSTD::move(__current_); | |
| 203 | return std::move(__current_); | |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | _LIBCPP_HIDE_FROM_ABI |
| 207 | 207 | constexpr decltype(auto) operator*() const |
| 208 | noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, *__current_))) | |
| 208 | noexcept(noexcept(std::invoke(*__parent_->__func_, *__current_))) | |
| 209 | 209 | { |
| 210 | return _VSTD::invoke(*__parent_->__func_, *__current_); | |
| 210 | return std::invoke(*__parent_->__func_, *__current_); | |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -263,10 +263,10 @@ public: |
| 263 | 263 | |
| 264 | 264 | _LIBCPP_HIDE_FROM_ABI |
| 265 | 265 | constexpr decltype(auto) operator[](difference_type __n) const |
| 266 | noexcept(noexcept(_VSTD::invoke(*__parent_->__func_, __current_[__n]))) | |
| 266 | noexcept(noexcept(std::invoke(*__parent_->__func_, __current_[__n]))) | |
| 267 | 267 | requires random_access_range<_Base> |
| 268 | 268 | { |
| 269 | return _VSTD::invoke(*__parent_->__func_, __current_[__n]); | |
| 269 | return std::invoke(*__parent_->__func_, __current_[__n]); | |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -344,7 +344,7 @@ public: |
| 344 | 344 | noexcept(noexcept(*__i)) |
| 345 | 345 | { |
| 346 | 346 | if constexpr (is_lvalue_reference_v<decltype(*__i)>) |
| 347 | return _VSTD::move(*__i); | |
| 347 | return std::move(*__i); | |
| 348 | 348 | else |
| 349 | 349 | return *__i; |
| 350 | 350 | } |
| ... | ... | @@ -378,7 +378,7 @@ public: |
| 378 | 378 | _LIBCPP_HIDE_FROM_ABI |
| 379 | 379 | constexpr __sentinel(__sentinel<!_Const> __i) |
| 380 | 380 | requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>> |
| 381 | : __end_(_VSTD::move(__i.__end_)) {} | |
| 381 | : __end_(std::move(__i.__end_)) {} | |
| 382 | 382 | |
| 383 | 383 | _LIBCPP_HIDE_FROM_ABI |
| 384 | 384 | constexpr sentinel_t<_Base> base() const { return __end_; } |
| ... | ... | @@ -413,16 +413,16 @@ namespace __transform { |
| 413 | 413 | template<class _Range, class _Fn> |
| 414 | 414 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 415 | 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)); } | |
| 416 | noexcept(noexcept(transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)))) | |
| 417 | -> decltype( transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f))) | |
| 418 | { return transform_view(std::forward<_Range>(__range), std::forward<_Fn>(__f)); } | |
| 419 | 419 | |
| 420 | 420 | template<class _Fn> |
| 421 | 421 | requires constructible_from<decay_t<_Fn>, _Fn> |
| 422 | 422 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI |
| 423 | 423 | constexpr auto operator()(_Fn&& __f) const |
| 424 | 424 | noexcept(is_nothrow_constructible_v<decay_t<_Fn>, _Fn>) |
| 425 | { return __range_adaptor_closure_t(_VSTD::__bind_back(*this, _VSTD::forward<_Fn>(__f))); } | |
| 425 | { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Fn>(__f))); } | |
| 426 | 426 | }; |
| 427 | 427 | } // namespace __transform |
| 428 | 428 | |
| ... | ... | @@ -433,7 +433,7 @@ inline namespace __cpo { |
| 433 | 433 | |
| 434 | 434 | } // namespace ranges |
| 435 | 435 | |
| 436 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 436 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 437 | 437 | |
| 438 | 438 | _LIBCPP_END_NAMESPACE_STD |
| 439 | 439 |
lib/libcxx/include/__ranges/view_interface.h+12-33| ... | ... | @@ -9,8 +9,10 @@ |
| 9 | 9 | #ifndef _LIBCPP___RANGES_VIEW_INTERFACE_H |
| 10 | 10 | #define _LIBCPP___RANGES_VIEW_INTERFACE_H |
| 11 | 11 | |
| 12 | #include <__assert> | |
| 13 | #include <__concepts/derived_from.h> | |
| 14 | #include <__concepts/same_as.h> | |
| 12 | 15 | #include <__config> |
| 13 | #include <__debug> | |
| 14 | 16 | #include <__iterator/concepts.h> |
| 15 | 17 | #include <__iterator/iterator_traits.h> |
| 16 | 18 | #include <__iterator/prev.h> |
| ... | ... | @@ -18,25 +20,18 @@ |
| 18 | 20 | #include <__ranges/access.h> |
| 19 | 21 | #include <__ranges/concepts.h> |
| 20 | 22 | #include <__ranges/empty.h> |
| 21 | #include <concepts> | |
| 22 | 23 | #include <type_traits> |
| 23 | 24 | |
| 24 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 26 | 27 | #endif |
| 27 | 28 | |
| 28 | 29 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 29 | 30 | |
| 30 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 31 | 32 | |
| 32 | 33 | namespace ranges { |
| 33 | 34 | |
| 34 | template<class _Tp> | |
| 35 | concept __can_empty = requires(_Tp __t) { ranges::empty(__t); }; | |
| 36 | ||
| 37 | template<class _Tp> | |
| 38 | void __implicitly_convert_to(type_identity_t<_Tp>) noexcept; | |
| 39 | ||
| 40 | 35 | template<class _Derived> |
| 41 | 36 | requires is_class_v<_Derived> && same_as<_Derived, remove_cv_t<_Derived>> |
| 42 | 37 | class view_interface { |
| ... | ... | @@ -55,7 +50,6 @@ class view_interface { |
| 55 | 50 | public: |
| 56 | 51 | template<class _D2 = _Derived> |
| 57 | 52 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() |
| 58 | noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived())))) | |
| 59 | 53 | requires forward_range<_D2> |
| 60 | 54 | { |
| 61 | 55 | return ranges::begin(__derived()) == ranges::end(__derived()); |
| ... | ... | @@ -63,7 +57,6 @@ public: |
| 63 | 57 | |
| 64 | 58 | template<class _D2 = _Derived> |
| 65 | 59 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const |
| 66 | noexcept(noexcept(__implicitly_convert_to<bool>(ranges::begin(__derived()) == ranges::end(__derived())))) | |
| 67 | 60 | requires forward_range<const _D2> |
| 68 | 61 | { |
| 69 | 62 | return ranges::begin(__derived()) == ranges::end(__derived()); |
| ... | ... | @@ -72,8 +65,7 @@ public: |
| 72 | 65 | template<class _D2 = _Derived> |
| 73 | 66 | _LIBCPP_HIDE_FROM_ABI |
| 74 | 67 | constexpr explicit operator bool() |
| 75 | noexcept(noexcept(ranges::empty(declval<_D2>()))) | |
| 76 | requires __can_empty<_D2> | |
| 68 | requires requires (_D2& __t) { ranges::empty(__t); } | |
| 77 | 69 | { |
| 78 | 70 | return !ranges::empty(__derived()); |
| 79 | 71 | } |
| ... | ... | @@ -81,8 +73,7 @@ public: |
| 81 | 73 | template<class _D2 = _Derived> |
| 82 | 74 | _LIBCPP_HIDE_FROM_ABI |
| 83 | 75 | constexpr explicit operator bool() const |
| 84 | noexcept(noexcept(ranges::empty(declval<const _D2>()))) | |
| 85 | requires __can_empty<const _D2> | |
| 76 | requires requires (const _D2& __t) { ranges::empty(__t); } | |
| 86 | 77 | { |
| 87 | 78 | return !ranges::empty(__derived()); |
| 88 | 79 | } |
| ... | ... | @@ -90,27 +81,23 @@ public: |
| 90 | 81 | template<class _D2 = _Derived> |
| 91 | 82 | _LIBCPP_HIDE_FROM_ABI |
| 92 | 83 | constexpr auto data() |
| 93 | noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived())))) | |
| 94 | 84 | requires contiguous_iterator<iterator_t<_D2>> |
| 95 | 85 | { |
| 96 | return _VSTD::to_address(ranges::begin(__derived())); | |
| 86 | return std::to_address(ranges::begin(__derived())); | |
| 97 | 87 | } |
| 98 | 88 | |
| 99 | 89 | template<class _D2 = _Derived> |
| 100 | 90 | _LIBCPP_HIDE_FROM_ABI |
| 101 | 91 | constexpr auto data() const |
| 102 | noexcept(noexcept(_VSTD::to_address(ranges::begin(__derived())))) | |
| 103 | 92 | requires range<const _D2> && contiguous_iterator<iterator_t<const _D2>> |
| 104 | 93 | { |
| 105 | return _VSTD::to_address(ranges::begin(__derived())); | |
| 94 | return std::to_address(ranges::begin(__derived())); | |
| 106 | 95 | } |
| 107 | 96 | |
| 108 | 97 | template<class _D2 = _Derived> |
| 109 | 98 | _LIBCPP_HIDE_FROM_ABI |
| 110 | 99 | constexpr auto size() |
| 111 | noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived()))) | |
| 112 | requires forward_range<_D2> | |
| 113 | && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>> | |
| 100 | requires forward_range<_D2> && sized_sentinel_for<sentinel_t<_D2>, iterator_t<_D2>> | |
| 114 | 101 | { |
| 115 | 102 | return ranges::end(__derived()) - ranges::begin(__derived()); |
| 116 | 103 | } |
| ... | ... | @@ -118,9 +105,7 @@ public: |
| 118 | 105 | template<class _D2 = _Derived> |
| 119 | 106 | _LIBCPP_HIDE_FROM_ABI |
| 120 | 107 | constexpr auto size() const |
| 121 | noexcept(noexcept(ranges::end(__derived()) - ranges::begin(__derived()))) | |
| 122 | requires forward_range<const _D2> | |
| 123 | && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>> | |
| 108 | requires forward_range<const _D2> && sized_sentinel_for<sentinel_t<const _D2>, iterator_t<const _D2>> | |
| 124 | 109 | { |
| 125 | 110 | return ranges::end(__derived()) - ranges::begin(__derived()); |
| 126 | 111 | } |
| ... | ... | @@ -128,7 +113,6 @@ public: |
| 128 | 113 | template<class _D2 = _Derived> |
| 129 | 114 | _LIBCPP_HIDE_FROM_ABI |
| 130 | 115 | constexpr decltype(auto) front() |
| 131 | noexcept(noexcept(*ranges::begin(__derived()))) | |
| 132 | 116 | requires forward_range<_D2> |
| 133 | 117 | { |
| 134 | 118 | _LIBCPP_ASSERT(!empty(), |
| ... | ... | @@ -139,7 +123,6 @@ public: |
| 139 | 123 | template<class _D2 = _Derived> |
| 140 | 124 | _LIBCPP_HIDE_FROM_ABI |
| 141 | 125 | constexpr decltype(auto) front() const |
| 142 | noexcept(noexcept(*ranges::begin(__derived()))) | |
| 143 | 126 | requires forward_range<const _D2> |
| 144 | 127 | { |
| 145 | 128 | _LIBCPP_ASSERT(!empty(), |
| ... | ... | @@ -150,7 +133,6 @@ public: |
| 150 | 133 | template<class _D2 = _Derived> |
| 151 | 134 | _LIBCPP_HIDE_FROM_ABI |
| 152 | 135 | constexpr decltype(auto) back() |
| 153 | noexcept(noexcept(*ranges::prev(ranges::end(__derived())))) | |
| 154 | 136 | requires bidirectional_range<_D2> && common_range<_D2> |
| 155 | 137 | { |
| 156 | 138 | _LIBCPP_ASSERT(!empty(), |
| ... | ... | @@ -161,7 +143,6 @@ public: |
| 161 | 143 | template<class _D2 = _Derived> |
| 162 | 144 | _LIBCPP_HIDE_FROM_ABI |
| 163 | 145 | constexpr decltype(auto) back() const |
| 164 | noexcept(noexcept(*ranges::prev(ranges::end(__derived())))) | |
| 165 | 146 | requires bidirectional_range<const _D2> && common_range<const _D2> |
| 166 | 147 | { |
| 167 | 148 | _LIBCPP_ASSERT(!empty(), |
| ... | ... | @@ -172,7 +153,6 @@ public: |
| 172 | 153 | template<random_access_range _RARange = _Derived> |
| 173 | 154 | _LIBCPP_HIDE_FROM_ABI |
| 174 | 155 | constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) |
| 175 | noexcept(noexcept(ranges::begin(__derived())[__index])) | |
| 176 | 156 | { |
| 177 | 157 | return ranges::begin(__derived())[__index]; |
| 178 | 158 | } |
| ... | ... | @@ -180,7 +160,6 @@ public: |
| 180 | 160 | template<random_access_range _RARange = const _Derived> |
| 181 | 161 | _LIBCPP_HIDE_FROM_ABI |
| 182 | 162 | constexpr decltype(auto) operator[](range_difference_t<_RARange> __index) const |
| 183 | noexcept(noexcept(ranges::begin(__derived())[__index])) | |
| 184 | 163 | { |
| 185 | 164 | return ranges::begin(__derived())[__index]; |
| 186 | 165 | } |
| ... | ... | @@ -188,7 +167,7 @@ public: |
| 188 | 167 | |
| 189 | 168 | } // namespace ranges |
| 190 | 169 | |
| 191 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 170 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 192 | 171 | |
| 193 | 172 | _LIBCPP_END_NAMESPACE_STD |
| 194 | 173 |
lib/libcxx/include/__ranges/zip_view.h created+511| ... | ... | @@ -0,0 +1,511 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP___RANGES_ZIP_VIEW_H | |
| 10 | #define _LIBCPP___RANGES_ZIP_VIEW_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #include <__algorithm/ranges_min.h> | |
| 15 | #include <__compare/three_way_comparable.h> | |
| 16 | #include <__concepts/convertible_to.h> | |
| 17 | #include <__concepts/equality_comparable.h> | |
| 18 | #include <__functional/invoke.h> | |
| 19 | #include <__functional/operations.h> | |
| 20 | #include <__iterator/concepts.h> | |
| 21 | #include <__iterator/incrementable_traits.h> | |
| 22 | #include <__iterator/iter_move.h> | |
| 23 | #include <__iterator/iter_swap.h> | |
| 24 | #include <__iterator/iterator_traits.h> | |
| 25 | #include <__ranges/access.h> | |
| 26 | #include <__ranges/all.h> | |
| 27 | #include <__ranges/concepts.h> | |
| 28 | #include <__ranges/empty_view.h> | |
| 29 | #include <__ranges/enable_borrowed_range.h> | |
| 30 | #include <__ranges/size.h> | |
| 31 | #include <__ranges/view_interface.h> | |
| 32 | #include <__utility/forward.h> | |
| 33 | #include <__utility/integer_sequence.h> | |
| 34 | #include <__utility/move.h> | |
| 35 | #include <tuple> | |
| 36 | #include <type_traits> | |
| 37 | ||
| 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 39 | # pragma GCC system_header | |
| 40 | #endif | |
| 41 | ||
| 42 | _LIBCPP_PUSH_MACROS | |
| 43 | #include <__undef_macros> | |
| 44 | ||
| 45 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 46 | ||
| 47 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 48 | ||
| 49 | namespace ranges { | |
| 50 | ||
| 51 | template <class... _Ranges> | |
| 52 | concept __zip_is_common = (sizeof...(_Ranges) == 1 && (common_range<_Ranges> && ...)) || | |
| 53 | (!(bidirectional_range<_Ranges> && ...) && (common_range<_Ranges> && ...)) || | |
| 54 | ((random_access_range<_Ranges> && ...) && (sized_range<_Ranges> && ...)); | |
| 55 | ||
| 56 | template <typename _Tp, typename _Up> | |
| 57 | auto __tuple_or_pair_test() -> pair<_Tp, _Up>; | |
| 58 | ||
| 59 | template <typename... _Types> | |
| 60 | requires(sizeof...(_Types) != 2) | |
| 61 | auto __tuple_or_pair_test() -> tuple<_Types...>; | |
| 62 | ||
| 63 | template <class... _Types> | |
| 64 | using __tuple_or_pair = decltype(__tuple_or_pair_test<_Types...>()); | |
| 65 | ||
| 66 | template <class _Fun, class _Tuple> | |
| 67 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_transform(_Fun&& __f, _Tuple&& __tuple) { | |
| 68 | return std::apply( | |
| 69 | [&]<class... _Types>(_Types&&... __elements) { | |
| 70 | return __tuple_or_pair<invoke_result_t<_Fun&, _Types>...>( | |
| 71 | std::invoke(__f, std::forward<_Types>(__elements))...); | |
| 72 | }, | |
| 73 | std::forward<_Tuple>(__tuple)); | |
| 74 | } | |
| 75 | ||
| 76 | template <class _Fun, class _Tuple> | |
| 77 | _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_for_each(_Fun&& __f, _Tuple&& __tuple) { | |
| 78 | std::apply( | |
| 79 | [&]<class... _Types>(_Types&&... __elements) { (std::invoke(__f, std::forward<_Types>(__elements)), ...); }, | |
| 80 | std::forward<_Tuple>(__tuple)); | |
| 81 | } | |
| 82 | ||
| 83 | template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices> | |
| 84 | _LIBCPP_HIDE_FROM_ABI constexpr __tuple_or_pair< | |
| 85 | invoke_result_t<_Fun&, typename tuple_element<_Indices, remove_cvref_t<_Tuple1>>::type, | |
| 86 | typename tuple_element<_Indices, remove_cvref_t<_Tuple2>>::type>...> | |
| 87 | __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, index_sequence<_Indices...>) { | |
| 88 | return {std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)), | |
| 89 | std::get<_Indices>(std::forward<_Tuple2>(__tuple2)))...}; | |
| 90 | } | |
| 91 | ||
| 92 | template <class _Fun, class _Tuple1, class _Tuple2> | |
| 93 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_transform(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) { | |
| 94 | return ranges::__tuple_zip_transform(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2), | |
| 95 | std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>()); | |
| 96 | } | |
| 97 | ||
| 98 | template <class _Fun, class _Tuple1, class _Tuple2, size_t... _Indices> | |
| 99 | _LIBCPP_HIDE_FROM_ABI constexpr void __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2, | |
| 100 | index_sequence<_Indices...>) { | |
| 101 | (std::invoke(__f, std::get<_Indices>(std::forward<_Tuple1>(__tuple1)), | |
| 102 | std::get<_Indices>(std::forward<_Tuple2>(__tuple2))), | |
| 103 | ...); | |
| 104 | } | |
| 105 | ||
| 106 | template <class _Fun, class _Tuple1, class _Tuple2> | |
| 107 | _LIBCPP_HIDE_FROM_ABI constexpr auto __tuple_zip_for_each(_Fun&& __f, _Tuple1&& __tuple1, _Tuple2&& __tuple2) { | |
| 108 | return ranges::__tuple_zip_for_each(__f, std::forward<_Tuple1>(__tuple1), std::forward<_Tuple2>(__tuple2), | |
| 109 | std::make_index_sequence<tuple_size<remove_cvref_t<_Tuple1>>::value>()); | |
| 110 | } | |
| 111 | ||
| 112 | template <class _Tuple1, class _Tuple2> | |
| 113 | _LIBCPP_HIDE_FROM_ABI constexpr bool __tuple_any_equals(const _Tuple1& __tuple1, const _Tuple2& __tuple2) { | |
| 114 | const auto __equals = ranges::__tuple_zip_transform(std::equal_to<>(), __tuple1, __tuple2); | |
| 115 | return std::apply([](auto... __bools) { return (__bools || ...); }, __equals); | |
| 116 | } | |
| 117 | ||
| 118 | // abs in cstdlib is not constexpr | |
| 119 | // TODO : remove __abs once P0533R9 is implemented. | |
| 120 | template <class _Tp> | |
| 121 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __abs(_Tp __t) { | |
| 122 | return __t < 0 ? -__t : __t; | |
| 123 | } | |
| 124 | ||
| 125 | template <input_range... _Views> | |
| 126 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) | |
| 127 | class zip_view : public view_interface<zip_view<_Views...>> { | |
| 128 | ||
| 129 | _LIBCPP_NO_UNIQUE_ADDRESS tuple<_Views...> __views_; | |
| 130 | ||
| 131 | template <bool> | |
| 132 | class __iterator; | |
| 133 | ||
| 134 | template <bool> | |
| 135 | class __sentinel; | |
| 136 | ||
| 137 | public: | |
| 138 | _LIBCPP_HIDE_FROM_ABI | |
| 139 | zip_view() = default; | |
| 140 | ||
| 141 | _LIBCPP_HIDE_FROM_ABI | |
| 142 | constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {} | |
| 143 | ||
| 144 | _LIBCPP_HIDE_FROM_ABI | |
| 145 | constexpr auto begin() | |
| 146 | requires(!(__simple_view<_Views> && ...)) { | |
| 147 | return __iterator<false>(ranges::__tuple_transform(ranges::begin, __views_)); | |
| 148 | } | |
| 149 | ||
| 150 | _LIBCPP_HIDE_FROM_ABI | |
| 151 | constexpr auto begin() const | |
| 152 | requires(range<const _Views> && ...) { | |
| 153 | return __iterator<true>(ranges::__tuple_transform(ranges::begin, __views_)); | |
| 154 | } | |
| 155 | ||
| 156 | _LIBCPP_HIDE_FROM_ABI | |
| 157 | constexpr auto end() | |
| 158 | requires(!(__simple_view<_Views> && ...)) { | |
| 159 | if constexpr (!__zip_is_common<_Views...>) { | |
| 160 | return __sentinel<false>(ranges::__tuple_transform(ranges::end, __views_)); | |
| 161 | } else if constexpr ((random_access_range<_Views> && ...)) { | |
| 162 | return begin() + iter_difference_t<__iterator<false>>(size()); | |
| 163 | } else { | |
| 164 | return __iterator<false>(ranges::__tuple_transform(ranges::end, __views_)); | |
| 165 | } | |
| 166 | } | |
| 167 | ||
| 168 | _LIBCPP_HIDE_FROM_ABI | |
| 169 | constexpr auto end() const | |
| 170 | requires(range<const _Views> && ...) { | |
| 171 | if constexpr (!__zip_is_common<const _Views...>) { | |
| 172 | return __sentinel<true>(ranges::__tuple_transform(ranges::end, __views_)); | |
| 173 | } else if constexpr ((random_access_range<const _Views> && ...)) { | |
| 174 | return begin() + iter_difference_t<__iterator<true>>(size()); | |
| 175 | } else { | |
| 176 | return __iterator<true>(ranges::__tuple_transform(ranges::end, __views_)); | |
| 177 | } | |
| 178 | } | |
| 179 | ||
| 180 | _LIBCPP_HIDE_FROM_ABI | |
| 181 | constexpr auto size() | |
| 182 | requires(sized_range<_Views> && ...) { | |
| 183 | return std::apply( | |
| 184 | [](auto... __sizes) { | |
| 185 | using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>; | |
| 186 | return ranges::min({_CT(__sizes)...}); | |
| 187 | }, | |
| 188 | ranges::__tuple_transform(ranges::size, __views_)); | |
| 189 | } | |
| 190 | ||
| 191 | _LIBCPP_HIDE_FROM_ABI | |
| 192 | constexpr auto size() const | |
| 193 | requires(sized_range<const _Views> && ...) { | |
| 194 | return std::apply( | |
| 195 | [](auto... __sizes) { | |
| 196 | using _CT = make_unsigned_t<common_type_t<decltype(__sizes)...>>; | |
| 197 | return ranges::min({_CT(__sizes)...}); | |
| 198 | }, | |
| 199 | ranges::__tuple_transform(ranges::size, __views_)); | |
| 200 | } | |
| 201 | }; | |
| 202 | ||
| 203 | template <class... _Ranges> | |
| 204 | zip_view(_Ranges&&...) -> zip_view<views::all_t<_Ranges>...>; | |
| 205 | ||
| 206 | template <bool _Const, class... _Views> | |
| 207 | concept __zip_all_random_access = (random_access_range<__maybe_const<_Const, _Views>> && ...); | |
| 208 | ||
| 209 | template <bool _Const, class... _Views> | |
| 210 | concept __zip_all_bidirectional = (bidirectional_range<__maybe_const<_Const, _Views>> && ...); | |
| 211 | ||
| 212 | template <bool _Const, class... _Views> | |
| 213 | concept __zip_all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...); | |
| 214 | ||
| 215 | template <bool _Const, class... _Views> | |
| 216 | consteval auto __get_zip_view_iterator_tag() { | |
| 217 | if constexpr (__zip_all_random_access<_Const, _Views...>) { | |
| 218 | return random_access_iterator_tag(); | |
| 219 | } else if constexpr (__zip_all_bidirectional<_Const, _Views...>) { | |
| 220 | return bidirectional_iterator_tag(); | |
| 221 | } else if constexpr (__zip_all_forward<_Const, _Views...>) { | |
| 222 | return forward_iterator_tag(); | |
| 223 | } else { | |
| 224 | return input_iterator_tag(); | |
| 225 | } | |
| 226 | } | |
| 227 | ||
| 228 | template <bool _Const, class... _Views> | |
| 229 | struct __zip_view_iterator_category_base {}; | |
| 230 | ||
| 231 | template <bool _Const, class... _Views> | |
| 232 | requires __zip_all_forward<_Const, _Views...> | |
| 233 | struct __zip_view_iterator_category_base<_Const, _Views...> { | |
| 234 | using iterator_category = input_iterator_tag; | |
| 235 | }; | |
| 236 | ||
| 237 | template <input_range... _Views> | |
| 238 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) | |
| 239 | template <bool _Const> | |
| 240 | class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base<_Const, _Views...> { | |
| 241 | ||
| 242 | __tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current_; | |
| 243 | ||
| 244 | _LIBCPP_HIDE_FROM_ABI | |
| 245 | constexpr explicit __iterator(__tuple_or_pair<iterator_t<__maybe_const<_Const, _Views>>...> __current) | |
| 246 | : __current_(std::move(__current)) {} | |
| 247 | ||
| 248 | template <bool> | |
| 249 | friend class zip_view<_Views...>::__iterator; | |
| 250 | ||
| 251 | template <bool> | |
| 252 | friend class zip_view<_Views...>::__sentinel; | |
| 253 | ||
| 254 | friend class zip_view<_Views...>; | |
| 255 | ||
| 256 | public: | |
| 257 | using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>()); | |
| 258 | using value_type = __tuple_or_pair<range_value_t<__maybe_const<_Const, _Views>>...>; | |
| 259 | using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>; | |
| 260 | ||
| 261 | _LIBCPP_HIDE_FROM_ABI | |
| 262 | __iterator() = default; | |
| 263 | ||
| 264 | _LIBCPP_HIDE_FROM_ABI | |
| 265 | constexpr __iterator(__iterator<!_Const> __i) | |
| 266 | requires _Const && (convertible_to<iterator_t<_Views>, iterator_t<__maybe_const<_Const, _Views>>> && ...) | |
| 267 | : __current_(std::move(__i.__current_)) {} | |
| 268 | ||
| 269 | _LIBCPP_HIDE_FROM_ABI | |
| 270 | constexpr auto operator*() const { | |
| 271 | return ranges::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_); | |
| 272 | } | |
| 273 | ||
| 274 | _LIBCPP_HIDE_FROM_ABI | |
| 275 | constexpr __iterator& operator++() { | |
| 276 | ranges::__tuple_for_each([](auto& __i) { ++__i; }, __current_); | |
| 277 | return *this; | |
| 278 | } | |
| 279 | ||
| 280 | _LIBCPP_HIDE_FROM_ABI | |
| 281 | constexpr void operator++(int) { ++*this; } | |
| 282 | ||
| 283 | _LIBCPP_HIDE_FROM_ABI | |
| 284 | constexpr __iterator operator++(int) | |
| 285 | requires __zip_all_forward<_Const, _Views...> { | |
| 286 | auto __tmp = *this; | |
| 287 | ++*this; | |
| 288 | return __tmp; | |
| 289 | } | |
| 290 | ||
| 291 | _LIBCPP_HIDE_FROM_ABI | |
| 292 | constexpr __iterator& operator--() | |
| 293 | requires __zip_all_bidirectional<_Const, _Views...> { | |
| 294 | ranges::__tuple_for_each([](auto& __i) { --__i; }, __current_); | |
| 295 | return *this; | |
| 296 | } | |
| 297 | ||
| 298 | _LIBCPP_HIDE_FROM_ABI | |
| 299 | constexpr __iterator operator--(int) | |
| 300 | requires __zip_all_bidirectional<_Const, _Views...> { | |
| 301 | auto __tmp = *this; | |
| 302 | --*this; | |
| 303 | return __tmp; | |
| 304 | } | |
| 305 | ||
| 306 | _LIBCPP_HIDE_FROM_ABI | |
| 307 | constexpr __iterator& operator+=(difference_type __x) | |
| 308 | requires __zip_all_random_access<_Const, _Views...> { | |
| 309 | ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i += iter_difference_t<_Iter>(__x); }, __current_); | |
| 310 | return *this; | |
| 311 | } | |
| 312 | ||
| 313 | _LIBCPP_HIDE_FROM_ABI | |
| 314 | constexpr __iterator& operator-=(difference_type __x) | |
| 315 | requires __zip_all_random_access<_Const, _Views...> { | |
| 316 | ranges::__tuple_for_each([&]<class _Iter>(_Iter& __i) { __i -= iter_difference_t<_Iter>(__x); }, __current_); | |
| 317 | return *this; | |
| 318 | } | |
| 319 | ||
| 320 | _LIBCPP_HIDE_FROM_ABI | |
| 321 | constexpr auto operator[](difference_type __n) const | |
| 322 | requires __zip_all_random_access<_Const, _Views...> { | |
| 323 | return ranges::__tuple_transform( | |
| 324 | [&]<class _Iter>(_Iter& __i) -> decltype(auto) { return __i[iter_difference_t<_Iter>(__n)]; }, __current_); | |
| 325 | } | |
| 326 | ||
| 327 | _LIBCPP_HIDE_FROM_ABI | |
| 328 | friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) | |
| 329 | requires(equality_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) { | |
| 330 | if constexpr (__zip_all_bidirectional<_Const, _Views...>) { | |
| 331 | return __x.__current_ == __y.__current_; | |
| 332 | } else { | |
| 333 | return ranges::__tuple_any_equals(__x.__current_, __y.__current_); | |
| 334 | } | |
| 335 | } | |
| 336 | ||
| 337 | _LIBCPP_HIDE_FROM_ABI | |
| 338 | friend constexpr bool operator<(const __iterator& __x, const __iterator& __y) | |
| 339 | requires __zip_all_random_access<_Const, _Views...> { | |
| 340 | return __x.__current_ < __y.__current_; | |
| 341 | } | |
| 342 | ||
| 343 | _LIBCPP_HIDE_FROM_ABI | |
| 344 | friend constexpr bool operator>(const __iterator& __x, const __iterator& __y) | |
| 345 | requires __zip_all_random_access<_Const, _Views...> { | |
| 346 | return __y < __x; | |
| 347 | } | |
| 348 | ||
| 349 | _LIBCPP_HIDE_FROM_ABI | |
| 350 | friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y) | |
| 351 | requires __zip_all_random_access<_Const, _Views...> { | |
| 352 | return !(__y < __x); | |
| 353 | } | |
| 354 | ||
| 355 | _LIBCPP_HIDE_FROM_ABI | |
| 356 | friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y) | |
| 357 | requires __zip_all_random_access<_Const, _Views...> { | |
| 358 | return !(__x < __y); | |
| 359 | } | |
| 360 | ||
| 361 | _LIBCPP_HIDE_FROM_ABI | |
| 362 | friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y) | |
| 363 | requires __zip_all_random_access<_Const, _Views...> && | |
| 364 | (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...) { | |
| 365 | return __x.__current_ <=> __y.__current_; | |
| 366 | } | |
| 367 | ||
| 368 | _LIBCPP_HIDE_FROM_ABI | |
| 369 | friend constexpr __iterator operator+(const __iterator& __i, difference_type __n) | |
| 370 | requires __zip_all_random_access<_Const, _Views...> { | |
| 371 | auto __r = __i; | |
| 372 | __r += __n; | |
| 373 | return __r; | |
| 374 | } | |
| 375 | ||
| 376 | _LIBCPP_HIDE_FROM_ABI | |
| 377 | friend constexpr __iterator operator+(difference_type __n, const __iterator& __i) | |
| 378 | requires __zip_all_random_access<_Const, _Views...> { | |
| 379 | return __i + __n; | |
| 380 | } | |
| 381 | ||
| 382 | _LIBCPP_HIDE_FROM_ABI | |
| 383 | friend constexpr __iterator operator-(const __iterator& __i, difference_type __n) | |
| 384 | requires __zip_all_random_access<_Const, _Views...> { | |
| 385 | auto __r = __i; | |
| 386 | __r -= __n; | |
| 387 | return __r; | |
| 388 | } | |
| 389 | ||
| 390 | _LIBCPP_HIDE_FROM_ABI | |
| 391 | friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y) | |
| 392 | requires(sized_sentinel_for<iterator_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> && | |
| 393 | ...) { | |
| 394 | const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __x.__current_, __y.__current_); | |
| 395 | return std::apply( | |
| 396 | [](auto... __ds) { | |
| 397 | return ranges::min({difference_type(__ds)...}, | |
| 398 | [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); }); | |
| 399 | }, | |
| 400 | __diffs); | |
| 401 | } | |
| 402 | ||
| 403 | _LIBCPP_HIDE_FROM_ABI | |
| 404 | friend constexpr auto iter_move(const __iterator& __i) noexcept( | |
| 405 | (noexcept(ranges::iter_move(declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) && | |
| 406 | (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) { | |
| 407 | return ranges::__tuple_transform(ranges::iter_move, __i.__current_); | |
| 408 | } | |
| 409 | ||
| 410 | _LIBCPP_HIDE_FROM_ABI | |
| 411 | friend constexpr void iter_swap(const __iterator& __l, const __iterator& __r) noexcept( | |
| 412 | (noexcept(ranges::iter_swap(declval<const iterator_t<__maybe_const<_Const, _Views>>&>(), | |
| 413 | declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && | |
| 414 | ...)) | |
| 415 | requires(indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>> && ...) { | |
| 416 | ranges::__tuple_zip_for_each(ranges::iter_swap, __l.__current_, __r.__current_); | |
| 417 | } | |
| 418 | }; | |
| 419 | ||
| 420 | template <input_range... _Views> | |
| 421 | requires(view<_Views> && ...) && (sizeof...(_Views) > 0) | |
| 422 | template <bool _Const> | |
| 423 | class zip_view<_Views...>::__sentinel { | |
| 424 | ||
| 425 | __tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end_; | |
| 426 | ||
| 427 | _LIBCPP_HIDE_FROM_ABI | |
| 428 | constexpr explicit __sentinel(__tuple_or_pair<sentinel_t<__maybe_const<_Const, _Views>>...> __end) : __end_(__end) {} | |
| 429 | ||
| 430 | friend class zip_view<_Views...>; | |
| 431 | ||
| 432 | // hidden friend cannot access private member of iterator because they are friends of friends | |
| 433 | template <bool _OtherConst> | |
| 434 | _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) | |
| 435 | __iter_current(zip_view<_Views...>::__iterator<_OtherConst> const& __it) { | |
| 436 | return (__it.__current_); | |
| 437 | } | |
| 438 | ||
| 439 | public: | |
| 440 | _LIBCPP_HIDE_FROM_ABI | |
| 441 | __sentinel() = default; | |
| 442 | ||
| 443 | _LIBCPP_HIDE_FROM_ABI | |
| 444 | constexpr __sentinel(__sentinel<!_Const> __i) | |
| 445 | requires _Const && (convertible_to<sentinel_t<_Views>, sentinel_t<__maybe_const<_Const, _Views>>> && ...) | |
| 446 | : __end_(std::move(__i.__end_)) {} | |
| 447 | ||
| 448 | template <bool _OtherConst> | |
| 449 | requires(sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> && | |
| 450 | ...) | |
| 451 | _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | |
| 452 | return ranges::__tuple_any_equals(__iter_current(__x), __y.__end_); | |
| 453 | } | |
| 454 | ||
| 455 | template <bool _OtherConst> | |
| 456 | requires( | |
| 457 | sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> && | |
| 458 | ...) | |
| 459 | _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...> | |
| 460 | operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) { | |
| 461 | const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __iter_current(__x), __y.__end_); | |
| 462 | return std::apply( | |
| 463 | [](auto... __ds) { | |
| 464 | using _Diff = common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>; | |
| 465 | return ranges::min({_Diff(__ds)...}, | |
| 466 | [](auto __a, auto __b) { return ranges::__abs(__a) < ranges::__abs(__b); }); | |
| 467 | }, | |
| 468 | __diffs); | |
| 469 | } | |
| 470 | ||
| 471 | template <bool _OtherConst> | |
| 472 | requires( | |
| 473 | sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> && | |
| 474 | ...) | |
| 475 | _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...> | |
| 476 | operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) { | |
| 477 | return -(__x - __y); | |
| 478 | } | |
| 479 | }; | |
| 480 | ||
| 481 | template <class... _Views> | |
| 482 | inline constexpr bool enable_borrowed_range<zip_view<_Views...>> = (enable_borrowed_range<_Views> && ...); | |
| 483 | ||
| 484 | namespace views { | |
| 485 | namespace __zip { | |
| 486 | ||
| 487 | struct __fn { | |
| 488 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; } | |
| 489 | ||
| 490 | template <class... _Ranges> | |
| 491 | _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const | |
| 492 | noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...))) | |
| 493 | -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) { | |
| 494 | return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...); | |
| 495 | } | |
| 496 | }; | |
| 497 | ||
| 498 | } // namespace __zip | |
| 499 | inline namespace __cpo { | |
| 500 | inline constexpr auto zip = __zip::__fn{}; | |
| 501 | } // namespace __cpo | |
| 502 | } // namespace views | |
| 503 | } // namespace ranges | |
| 504 | ||
| 505 | #endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 506 | ||
| 507 | _LIBCPP_END_NAMESPACE_STD | |
| 508 | ||
| 509 | _LIBCPP_POP_MACROS | |
| 510 | ||
| 511 | #endif // _LIBCPP___RANGES_ZIP_VIEW_H |
lib/libcxx/include/__split_buffer+112-83| ... | ... | @@ -1,14 +1,31 @@ |
| 1 | 1 | // -*- C++ -*- |
| 2 | #ifndef _LIBCPP_SPLIT_BUFFER | |
| 3 | #define _LIBCPP_SPLIT_BUFFER | |
| 4 | ||
| 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___SPLIT_BUFFER | |
| 11 | #define _LIBCPP___SPLIT_BUFFER | |
| 12 | ||
| 13 | #include <__algorithm/max.h> | |
| 14 | #include <__algorithm/move.h> | |
| 15 | #include <__algorithm/move_backward.h> | |
| 5 | 16 | #include <__config> |
| 17 | #include <__iterator/distance.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/move_iterator.h> | |
| 20 | #include <__memory/allocator.h> | |
| 21 | #include <__memory/compressed_pair.h> | |
| 22 | #include <__memory/swap_allocator.h> | |
| 6 | 23 | #include <__utility/forward.h> |
| 7 | #include <algorithm> | |
| 24 | #include <memory> | |
| 8 | 25 | #include <type_traits> |
| 9 | 26 | |
| 10 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 11 | #pragma GCC system_header | |
| 28 | # pragma GCC system_header | |
| 12 | 29 | #endif |
| 13 | 30 | |
| 14 | 31 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -45,116 +62,107 @@ public: |
| 45 | 62 | typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref; |
| 46 | 63 | typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref; |
| 47 | 64 | |
| 48 | _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} | |
| 49 | _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} | |
| 50 | _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} | |
| 51 | _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} | |
| 65 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr& __alloc() _NOEXCEPT {return __end_cap_.second();} | |
| 66 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr& __alloc() const _NOEXCEPT {return __end_cap_.second();} | |
| 67 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} | |
| 68 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} | |
| 52 | 69 | |
| 53 | _LIBCPP_INLINE_VISIBILITY | |
| 70 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 54 | 71 | __split_buffer() |
| 55 | 72 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); |
| 56 | _LIBCPP_INLINE_VISIBILITY | |
| 73 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 57 | 74 | explicit __split_buffer(__alloc_rr& __a); |
| 58 | _LIBCPP_INLINE_VISIBILITY | |
| 75 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 59 | 76 | explicit __split_buffer(const __alloc_rr& __a); |
| 60 | __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); | |
| 61 | ~__split_buffer(); | |
| 77 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); | |
| 78 | _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer(); | |
| 62 | 79 | |
| 63 | __split_buffer(__split_buffer&& __c) | |
| 80 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c) | |
| 64 | 81 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
| 65 | __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); | |
| 66 | __split_buffer& operator=(__split_buffer&& __c) | |
| 82 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a); | |
| 83 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c) | |
| 67 | 84 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && |
| 68 | 85 | is_nothrow_move_assignable<allocator_type>::value) || |
| 69 | 86 | !__alloc_traits::propagate_on_container_move_assignment::value); |
| 70 | 87 | |
| 71 | _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} | |
| 72 | _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} | |
| 73 | _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} | |
| 74 | _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} | |
| 88 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return __begin_;} | |
| 89 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;} | |
| 90 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT {return __end_;} | |
| 91 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return __end_;} | |
| 75 | 92 | |
| 76 | _LIBCPP_INLINE_VISIBILITY | |
| 93 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 77 | 94 | void clear() _NOEXCEPT |
| 78 | 95 | {__destruct_at_end(__begin_);} |
| 79 | _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);} | |
| 80 | _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} | |
| 81 | _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);} | |
| 82 | _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);} | |
| 83 | _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);} | |
| 84 | ||
| 85 | _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} | |
| 86 | _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} | |
| 87 | _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} | |
| 88 | _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} | |
| 89 | ||
| 90 | void reserve(size_type __n); | |
| 91 | void shrink_to_fit() _NOEXCEPT; | |
| 92 | void push_front(const_reference __x); | |
| 93 | _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); | |
| 94 | void push_front(value_type&& __x); | |
| 95 | void push_back(value_type&& __x); | |
| 96 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);} | |
| 97 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty() const {return __end_ == __begin_;} | |
| 98 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);} | |
| 99 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);} | |
| 100 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);} | |
| 101 | ||
| 102 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() {return *__begin_;} | |
| 103 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;} | |
| 104 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() {return *(__end_ - 1);} | |
| 105 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const {return *(__end_ - 1);} | |
| 106 | ||
| 107 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n); | |
| 108 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; | |
| 109 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x); | |
| 110 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); | |
| 111 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x); | |
| 112 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x); | |
| 96 | 113 | template <class... _Args> |
| 97 | void emplace_back(_Args&&... __args); | |
| 114 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args); | |
| 98 | 115 | |
| 99 | _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} | |
| 100 | _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} | |
| 116 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);} | |
| 117 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);} | |
| 101 | 118 | |
| 102 | void __construct_at_end(size_type __n); | |
| 103 | void __construct_at_end(size_type __n, const_reference __x); | |
| 119 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n); | |
| 120 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x); | |
| 104 | 121 | template <class _InputIter> |
| 105 | typename enable_if | |
| 106 | < | |
| 107 | __is_cpp17_input_iterator<_InputIter>::value && | |
| 108 | !__is_cpp17_forward_iterator<_InputIter>::value, | |
| 109 | void | |
| 110 | >::type | |
| 122 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> | |
| 111 | 123 | __construct_at_end(_InputIter __first, _InputIter __last); |
| 112 | 124 | template <class _ForwardIterator> |
| 113 | typename enable_if | |
| 114 | < | |
| 115 | __is_cpp17_forward_iterator<_ForwardIterator>::value, | |
| 116 | void | |
| 117 | >::type | |
| 125 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> | |
| 118 | 126 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); |
| 119 | 127 | |
| 120 | _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) | |
| 128 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) | |
| 121 | 129 | {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());} |
| 122 | _LIBCPP_INLINE_VISIBILITY | |
| 130 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 123 | 131 | void __destruct_at_begin(pointer __new_begin, false_type); |
| 124 | _LIBCPP_INLINE_VISIBILITY | |
| 132 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 125 | 133 | void __destruct_at_begin(pointer __new_begin, true_type); |
| 126 | 134 | |
| 127 | _LIBCPP_INLINE_VISIBILITY | |
| 135 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 128 | 136 | void __destruct_at_end(pointer __new_last) _NOEXCEPT |
| 129 | 137 | {__destruct_at_end(__new_last, false_type());} |
| 130 | _LIBCPP_INLINE_VISIBILITY | |
| 138 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 131 | 139 | void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT; |
| 132 | _LIBCPP_INLINE_VISIBILITY | |
| 140 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 133 | 141 | void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT; |
| 134 | 142 | |
| 135 | void swap(__split_buffer& __x) | |
| 143 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x) | |
| 136 | 144 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| |
| 137 | 145 | __is_nothrow_swappable<__alloc_rr>::value); |
| 138 | 146 | |
| 139 | bool __invariants() const; | |
| 147 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; | |
| 140 | 148 | |
| 141 | 149 | private: |
| 142 | _LIBCPP_INLINE_VISIBILITY | |
| 150 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 143 | 151 | void __move_assign_alloc(__split_buffer& __c, true_type) |
| 144 | 152 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| 145 | 153 | { |
| 146 | 154 | __alloc() = _VSTD::move(__c.__alloc()); |
| 147 | 155 | } |
| 148 | 156 | |
| 149 | _LIBCPP_INLINE_VISIBILITY | |
| 157 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 150 | 158 | void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT |
| 151 | 159 | {} |
| 152 | 160 | |
| 153 | 161 | struct _ConstructTransaction { |
| 154 | explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT | |
| 162 | _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT | |
| 155 | 163 | : __pos_(*__p), __end_(*__p + __n), __dest_(__p) { |
| 156 | 164 | } |
| 157 | ~_ConstructTransaction() { | |
| 165 | _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() { | |
| 158 | 166 | *__dest_ = __pos_; |
| 159 | 167 | } |
| 160 | 168 | pointer __pos_; |
| ... | ... | @@ -165,6 +173,7 @@ private: |
| 165 | 173 | }; |
| 166 | 174 | |
| 167 | 175 | template <class _Tp, class _Allocator> |
| 176 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 168 | 177 | bool |
| 169 | 178 | __split_buffer<_Tp, _Allocator>::__invariants() const |
| 170 | 179 | { |
| ... | ... | @@ -195,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const |
| 195 | 204 | // Precondition: size() + __n <= capacity() |
| 196 | 205 | // Postcondition: size() == size() + __n |
| 197 | 206 | template <class _Tp, class _Allocator> |
| 207 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 198 | 208 | void |
| 199 | 209 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 200 | 210 | { |
| ... | ... | @@ -211,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 211 | 221 | // Postcondition: size() == old size() + __n |
| 212 | 222 | // Postcondition: [i] == __x for all i in [size() - __n, __n) |
| 213 | 223 | template <class _Tp, class _Allocator> |
| 224 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 214 | 225 | void |
| 215 | 226 | __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
| 216 | 227 | { |
| ... | ... | @@ -223,12 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen |
| 223 | 234 | |
| 224 | 235 | template <class _Tp, class _Allocator> |
| 225 | 236 | template <class _InputIter> |
| 226 | typename enable_if | |
| 227 | < | |
| 228 | __is_cpp17_input_iterator<_InputIter>::value && | |
| 229 | !__is_cpp17_forward_iterator<_InputIter>::value, | |
| 230 | void | |
| 231 | >::type | |
| 237 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value> | |
| 232 | 238 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) |
| 233 | 239 | { |
| 234 | 240 | __alloc_rr& __a = this->__alloc(); |
| ... | ... | @@ -251,11 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt |
| 251 | 257 | |
| 252 | 258 | template <class _Tp, class _Allocator> |
| 253 | 259 | template <class _ForwardIterator> |
| 254 | typename enable_if | |
| 255 | < | |
| 256 | __is_cpp17_forward_iterator<_ForwardIterator>::value, | |
| 257 | void | |
| 258 | >::type | |
| 260 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value> | |
| 259 | 261 | __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) |
| 260 | 262 | { |
| 261 | 263 | _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last)); |
| ... | ... | @@ -266,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F |
| 266 | 268 | } |
| 267 | 269 | |
| 268 | 270 | template <class _Tp, class _Allocator> |
| 271 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 269 | 272 | inline |
| 270 | 273 | void |
| 271 | 274 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) |
| ... | ... | @@ -275,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_ |
| 275 | 278 | } |
| 276 | 279 | |
| 277 | 280 | template <class _Tp, class _Allocator> |
| 281 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 278 | 282 | inline |
| 279 | 283 | void |
| 280 | 284 | __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) |
| ... | ... | @@ -283,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t |
| 283 | 287 | } |
| 284 | 288 | |
| 285 | 289 | template <class _Tp, class _Allocator> |
| 290 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 286 | 291 | inline _LIBCPP_INLINE_VISIBILITY |
| 287 | 292 | void |
| 288 | 293 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT |
| ... | ... | @@ -292,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ |
| 292 | 297 | } |
| 293 | 298 | |
| 294 | 299 | template <class _Tp, class _Allocator> |
| 300 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 295 | 301 | inline _LIBCPP_INLINE_VISIBILITY |
| 296 | 302 | void |
| 297 | 303 | __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT |
| ... | ... | @@ -300,15 +306,23 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type |
| 300 | 306 | } |
| 301 | 307 | |
| 302 | 308 | template <class _Tp, class _Allocator> |
| 309 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 303 | 310 | __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a) |
| 304 | 311 | : __end_cap_(nullptr, __a) |
| 305 | 312 | { |
| 306 | __first_ = __cap != 0 ? __alloc_traits::allocate(__alloc(), __cap) : nullptr; | |
| 313 | if (__cap == 0) { | |
| 314 | __first_ = nullptr; | |
| 315 | } else { | |
| 316 | auto __allocation = std::__allocate_at_least(__alloc(), __cap); | |
| 317 | __first_ = __allocation.ptr; | |
| 318 | __cap = __allocation.count; | |
| 319 | } | |
| 307 | 320 | __begin_ = __end_ = __first_ + __start; |
| 308 | 321 | __end_cap() = __first_ + __cap; |
| 309 | 322 | } |
| 310 | 323 | |
| 311 | 324 | template <class _Tp, class _Allocator> |
| 325 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 312 | 326 | inline |
| 313 | 327 | __split_buffer<_Tp, _Allocator>::__split_buffer() |
| 314 | 328 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| ... | ... | @@ -317,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer() |
| 317 | 331 | } |
| 318 | 332 | |
| 319 | 333 | template <class _Tp, class _Allocator> |
| 334 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 320 | 335 | inline |
| 321 | 336 | __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) |
| 322 | 337 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) |
| ... | ... | @@ -324,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) |
| 324 | 339 | } |
| 325 | 340 | |
| 326 | 341 | template <class _Tp, class _Allocator> |
| 342 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 327 | 343 | inline |
| 328 | 344 | __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) |
| 329 | 345 | : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) |
| ... | ... | @@ -331,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) |
| 331 | 347 | } |
| 332 | 348 | |
| 333 | 349 | template <class _Tp, class _Allocator> |
| 350 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 334 | 351 | __split_buffer<_Tp, _Allocator>::~__split_buffer() |
| 335 | 352 | { |
| 336 | 353 | clear(); |
| ... | ... | @@ -339,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer() |
| 339 | 356 | } |
| 340 | 357 | |
| 341 | 358 | template <class _Tp, class _Allocator> |
| 359 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 342 | 360 | __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) |
| 343 | 361 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 344 | 362 | : __first_(_VSTD::move(__c.__first_)), |
| ... | ... | @@ -353,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) |
| 353 | 371 | } |
| 354 | 372 | |
| 355 | 373 | template <class _Tp, class _Allocator> |
| 374 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 356 | 375 | __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) |
| 357 | 376 | : __end_cap_(nullptr, __a) |
| 358 | 377 | { |
| ... | ... | @@ -369,16 +388,17 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al |
| 369 | 388 | } |
| 370 | 389 | else |
| 371 | 390 | { |
| 372 | size_type __cap = __c.size(); | |
| 373 | __first_ = __alloc_traits::allocate(__alloc(), __cap); | |
| 391 | auto __allocation = std::__allocate_at_least(__alloc(), __c.size()); | |
| 392 | __first_ = __allocation.ptr; | |
| 374 | 393 | __begin_ = __end_ = __first_; |
| 375 | __end_cap() = __first_ + __cap; | |
| 394 | __end_cap() = __first_ + __allocation.count; | |
| 376 | 395 | typedef move_iterator<iterator> _Ip; |
| 377 | 396 | __construct_at_end(_Ip(__c.begin()), _Ip(__c.end())); |
| 378 | 397 | } |
| 379 | 398 | } |
| 380 | 399 | |
| 381 | 400 | template <class _Tp, class _Allocator> |
| 401 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 382 | 402 | __split_buffer<_Tp, _Allocator>& |
| 383 | 403 | __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) |
| 384 | 404 | _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value && |
| ... | ... | @@ -399,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c) |
| 399 | 419 | } |
| 400 | 420 | |
| 401 | 421 | template <class _Tp, class _Allocator> |
| 422 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 402 | 423 | void |
| 403 | 424 | __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) |
| 404 | 425 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value|| |
| ... | ... | @@ -412,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x) |
| 412 | 433 | } |
| 413 | 434 | |
| 414 | 435 | template <class _Tp, class _Allocator> |
| 436 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 415 | 437 | void |
| 416 | 438 | __split_buffer<_Tp, _Allocator>::reserve(size_type __n) |
| 417 | 439 | { |
| ... | ... | @@ -428,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n) |
| 428 | 450 | } |
| 429 | 451 | |
| 430 | 452 | template <class _Tp, class _Allocator> |
| 453 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 431 | 454 | void |
| 432 | 455 | __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 433 | 456 | { |
| ... | ... | @@ -455,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 455 | 478 | } |
| 456 | 479 | |
| 457 | 480 | template <class _Tp, class _Allocator> |
| 481 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 458 | 482 | void |
| 459 | 483 | __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) |
| 460 | 484 | { |
| ... | ... | @@ -484,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x) |
| 484 | 508 | } |
| 485 | 509 | |
| 486 | 510 | template <class _Tp, class _Allocator> |
| 511 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 487 | 512 | void |
| 488 | 513 | __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) |
| 489 | 514 | { |
| ... | ... | @@ -514,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) |
| 514 | 539 | } |
| 515 | 540 | |
| 516 | 541 | template <class _Tp, class _Allocator> |
| 542 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 517 | 543 | inline _LIBCPP_INLINE_VISIBILITY |
| 518 | 544 | void |
| 519 | 545 | __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) |
| ... | ... | @@ -544,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) |
| 544 | 570 | } |
| 545 | 571 | |
| 546 | 572 | template <class _Tp, class _Allocator> |
| 573 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 547 | 574 | void |
| 548 | 575 | __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) |
| 549 | 576 | { |
| ... | ... | @@ -575,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x) |
| 575 | 602 | |
| 576 | 603 | template <class _Tp, class _Allocator> |
| 577 | 604 | template <class... _Args> |
| 605 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 578 | 606 | void |
| 579 | 607 | __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) |
| 580 | 608 | { |
| ... | ... | @@ -605,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) |
| 605 | 633 | } |
| 606 | 634 | |
| 607 | 635 | template <class _Tp, class _Allocator> |
| 636 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 608 | 637 | inline _LIBCPP_INLINE_VISIBILITY |
| 609 | 638 | void |
| 610 | 639 | swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) |
| ... | ... | @@ -617,4 +646,4 @@ _LIBCPP_END_NAMESPACE_STD |
| 617 | 646 | |
| 618 | 647 | _LIBCPP_POP_MACROS |
| 619 | 648 | |
| 620 | #endif // _LIBCPP_SPLIT_BUFFER | |
| 649 | #endif // _LIBCPP___SPLIT_BUFFER |
lib/libcxx/include/__std_stream+1-1| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | #include <ostream> |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/__string deleted-1175| ... | ... | @@ -1,1175 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___STRING | |
| 11 | #define _LIBCPP___STRING | |
| 12 | ||
| 13 | #include <__algorithm/copy.h> | |
| 14 | #include <__algorithm/copy_backward.h> | |
| 15 | #include <__algorithm/copy_n.h> | |
| 16 | #include <__algorithm/fill_n.h> | |
| 17 | #include <__algorithm/find_end.h> | |
| 18 | #include <__algorithm/find_first_of.h> | |
| 19 | #include <__algorithm/min.h> | |
| 20 | #include <__config> | |
| 21 | #include <__functional/hash.h> // for __murmur2_or_cityhash | |
| 22 | #include <__iterator/iterator_traits.h> | |
| 23 | #include <cstdint> // for uint_least16_t | |
| 24 | #include <cstdio> // for EOF | |
| 25 | #include <cstring> // for memcpy | |
| 26 | #include <iosfwd> // for streampos & friends | |
| 27 | #include <type_traits> // for __libcpp_is_constant_evaluated | |
| 28 | ||
| 29 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 30 | # include <cwchar> // for wmemcpy | |
| 31 | #endif | |
| 32 | ||
| 33 | #include <__debug> | |
| 34 | ||
| 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 36 | #pragma GCC system_header | |
| 37 | #endif | |
| 38 | ||
| 39 | _LIBCPP_PUSH_MACROS | |
| 40 | #include <__undef_macros> | |
| 41 | ||
| 42 | ||
| 43 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 44 | ||
| 45 | // The extern template ABI lists are kept outside of <string> to improve the | |
| 46 | // readability of that header. We maintain 2 ABI lists: | |
| 47 | // - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST | |
| 48 | // - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST | |
| 49 | // As the name implies, the ABI lists define the V1 (Stable) and unstable ABI. | |
| 50 | // | |
| 51 | // For unstable, we may explicitly remove function that are external in V1, | |
| 52 | // and add (new) external functions to better control inlining and compiler | |
| 53 | // optimization opportunities. | |
| 54 | // | |
| 55 | // For stable, the ABI list should rarely change, except for adding new | |
| 56 | // functions supporting new c++ version / API changes. Typically entries | |
| 57 | // must never be removed from the stable list. | |
| 58 | #define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | |
| 59 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | |
| 60 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | |
| 61 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | |
| 62 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \ | |
| 63 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | |
| 64 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \ | |
| 65 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | |
| 66 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ | |
| 67 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | |
| 68 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | |
| 69 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | |
| 70 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ | |
| 71 | _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ | |
| 72 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | |
| 73 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | |
| 74 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | |
| 75 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \ | |
| 76 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ | |
| 77 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | |
| 78 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | |
| 79 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | |
| 80 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ | |
| 81 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | |
| 82 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ | |
| 83 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | |
| 84 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | |
| 85 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | |
| 86 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | |
| 87 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ | |
| 88 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | |
| 89 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | |
| 90 | _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | |
| 91 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | |
| 92 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \ | |
| 93 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | |
| 94 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ | |
| 95 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | |
| 96 | _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ | |
| 97 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \ | |
| 98 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | |
| 99 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | |
| 100 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | |
| 101 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \ | |
| 102 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | |
| 103 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | |
| 104 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | |
| 105 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ | |
| 106 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | |
| 107 | ||
| 108 | #define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | |
| 109 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | |
| 110 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | |
| 111 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | |
| 112 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | |
| 113 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | |
| 114 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ | |
| 115 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | |
| 116 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | |
| 117 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | |
| 118 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ | |
| 119 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \ | |
| 120 | _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ | |
| 121 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | |
| 122 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | |
| 123 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | |
| 124 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \ | |
| 125 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \ | |
| 126 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ | |
| 127 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | |
| 128 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | |
| 129 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | |
| 130 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ | |
| 131 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | |
| 132 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ | |
| 133 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | |
| 134 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | |
| 135 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | |
| 136 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | |
| 137 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \ | |
| 138 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \ | |
| 139 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ | |
| 140 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | |
| 141 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | |
| 142 | _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | |
| 143 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | |
| 144 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \ | |
| 145 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | |
| 146 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ | |
| 147 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | |
| 148 | _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ | |
| 149 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | |
| 150 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | |
| 151 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | |
| 152 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | |
| 153 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | |
| 154 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | |
| 155 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ | |
| 156 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | |
| 157 | ||
| 158 | ||
| 159 | // char_traits | |
| 160 | ||
| 161 | template <class _CharT> | |
| 162 | struct _LIBCPP_TEMPLATE_VIS char_traits | |
| 163 | { | |
| 164 | typedef _CharT char_type; | |
| 165 | typedef int int_type; | |
| 166 | typedef streamoff off_type; | |
| 167 | typedef streampos pos_type; | |
| 168 | typedef mbstate_t state_type; | |
| 169 | ||
| 170 | static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 171 | assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 172 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 173 | {return __c1 == __c2;} | |
| 174 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 175 | {return __c1 < __c2;} | |
| 176 | ||
| 177 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 178 | int compare(const char_type* __s1, const char_type* __s2, size_t __n); | |
| 179 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 180 | size_t length(const char_type* __s); | |
| 181 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 182 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a); | |
| 183 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 184 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n); | |
| 185 | _LIBCPP_INLINE_VISIBILITY | |
| 186 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 187 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); | |
| 188 | _LIBCPP_INLINE_VISIBILITY | |
| 189 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 190 | char_type* assign(char_type* __s, size_t __n, char_type __a); | |
| 191 | ||
| 192 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 193 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 194 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 195 | {return char_type(__c);} | |
| 196 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 197 | {return int_type(__c);} | |
| 198 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 199 | {return __c1 == __c2;} | |
| 200 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 201 | {return int_type(EOF);} | |
| 202 | }; | |
| 203 | ||
| 204 | template <class _CharT> | |
| 205 | _LIBCPP_CONSTEXPR_AFTER_CXX14 int | |
| 206 | char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) | |
| 207 | { | |
| 208 | for (; __n; --__n, ++__s1, ++__s2) | |
| 209 | { | |
| 210 | if (lt(*__s1, *__s2)) | |
| 211 | return -1; | |
| 212 | if (lt(*__s2, *__s1)) | |
| 213 | return 1; | |
| 214 | } | |
| 215 | return 0; | |
| 216 | } | |
| 217 | ||
| 218 | template <class _CharT> | |
| 219 | inline | |
| 220 | _LIBCPP_CONSTEXPR_AFTER_CXX14 size_t | |
| 221 | char_traits<_CharT>::length(const char_type* __s) | |
| 222 | { | |
| 223 | size_t __len = 0; | |
| 224 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 225 | ++__len; | |
| 226 | return __len; | |
| 227 | } | |
| 228 | ||
| 229 | template <class _CharT> | |
| 230 | inline | |
| 231 | _LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT* | |
| 232 | char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) | |
| 233 | { | |
| 234 | for (; __n; --__n) | |
| 235 | { | |
| 236 | if (eq(*__s, __a)) | |
| 237 | return __s; | |
| 238 | ++__s; | |
| 239 | } | |
| 240 | return nullptr; | |
| 241 | } | |
| 242 | ||
| 243 | template <class _CharT> | |
| 244 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT* | |
| 245 | char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) | |
| 246 | { | |
| 247 | if (__n == 0) return __s1; | |
| 248 | char_type* __r = __s1; | |
| 249 | if (__s1 < __s2) | |
| 250 | { | |
| 251 | for (; __n; --__n, ++__s1, ++__s2) | |
| 252 | assign(*__s1, *__s2); | |
| 253 | } | |
| 254 | else if (__s2 < __s1) | |
| 255 | { | |
| 256 | __s1 += __n; | |
| 257 | __s2 += __n; | |
| 258 | for (; __n; --__n) | |
| 259 | assign(*--__s1, *--__s2); | |
| 260 | } | |
| 261 | return __r; | |
| 262 | } | |
| 263 | ||
| 264 | template <class _CharT> | |
| 265 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 266 | _CharT* | |
| 267 | char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) | |
| 268 | { | |
| 269 | if (!__libcpp_is_constant_evaluated()) { | |
| 270 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 271 | } | |
| 272 | char_type* __r = __s1; | |
| 273 | for (; __n; --__n, ++__s1, ++__s2) | |
| 274 | assign(*__s1, *__s2); | |
| 275 | return __r; | |
| 276 | } | |
| 277 | ||
| 278 | template <class _CharT> | |
| 279 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 280 | _CharT* | |
| 281 | char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) | |
| 282 | { | |
| 283 | char_type* __r = __s; | |
| 284 | for (; __n; --__n, ++__s) | |
| 285 | assign(*__s, __a); | |
| 286 | return __r; | |
| 287 | } | |
| 288 | ||
| 289 | // constexpr versions of move/copy/assign. | |
| 290 | ||
| 291 | template <class _CharT> | |
| 292 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 293 | _CharT* __copy_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT | |
| 294 | { | |
| 295 | _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__copy_constexpr() should always be constant evaluated"); | |
| 296 | _VSTD::copy_n(__source, __n, __dest); | |
| 297 | return __dest; | |
| 298 | } | |
| 299 | ||
| 300 | template <class _CharT> | |
| 301 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 302 | _CharT* __move_constexpr(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT | |
| 303 | { | |
| 304 | _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__move_constexpr() should always be constant evaluated"); | |
| 305 | if (__n == 0) | |
| 306 | return __dest; | |
| 307 | _CharT* __allocation = new _CharT[__n]; | |
| 308 | _VSTD::__copy_constexpr(__allocation, __source, __n); | |
| 309 | _VSTD::__copy_constexpr(__dest, static_cast<const _CharT*>(__allocation), __n); | |
| 310 | delete[] __allocation; | |
| 311 | return __dest; | |
| 312 | } | |
| 313 | ||
| 314 | template <class _CharT> | |
| 315 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 316 | _CharT* __assign_constexpr(_CharT* __s, size_t __n, _CharT __a) _NOEXCEPT | |
| 317 | { | |
| 318 | _LIBCPP_ASSERT(__libcpp_is_constant_evaluated(), "__assign_constexpr() should always be constant evaluated"); | |
| 319 | _VSTD::fill_n(__s, __n, __a); | |
| 320 | return __s; | |
| 321 | } | |
| 322 | ||
| 323 | // char_traits<char> | |
| 324 | ||
| 325 | template <> | |
| 326 | struct _LIBCPP_TEMPLATE_VIS char_traits<char> | |
| 327 | { | |
| 328 | typedef char char_type; | |
| 329 | typedef int int_type; | |
| 330 | typedef streamoff off_type; | |
| 331 | typedef streampos pos_type; | |
| 332 | typedef mbstate_t state_type; | |
| 333 | ||
| 334 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 335 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 336 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 337 | {return __c1 == __c2;} | |
| 338 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 339 | {return (unsigned char)__c1 < (unsigned char)__c2;} | |
| 340 | ||
| 341 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 342 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 343 | ||
| 344 | static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT { | |
| 345 | // GCC currently does not support __builtin_strlen during constant evaluation. | |
| 346 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816 | |
| 347 | #ifdef _LIBCPP_COMPILER_GCC | |
| 348 | if (__libcpp_is_constant_evaluated()) { | |
| 349 | size_t __i = 0; | |
| 350 | for (; __s[__i] != char_type('\0'); ++__i) | |
| 351 | ; | |
| 352 | return __i; | |
| 353 | } | |
| 354 | #endif | |
| 355 | return __builtin_strlen(__s); | |
| 356 | } | |
| 357 | ||
| 358 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 359 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 360 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 361 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 362 | { | |
| 363 | return __libcpp_is_constant_evaluated() | |
| 364 | ? _VSTD::__move_constexpr(__s1, __s2, __n) | |
| 365 | : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); | |
| 366 | } | |
| 367 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 368 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 369 | { | |
| 370 | if (!__libcpp_is_constant_evaluated()) { | |
| 371 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 372 | } | |
| 373 | return __libcpp_is_constant_evaluated() | |
| 374 | ? _VSTD::__copy_constexpr(__s1, __s2, __n) | |
| 375 | : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); | |
| 376 | } | |
| 377 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 378 | char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT | |
| 379 | { | |
| 380 | return __libcpp_is_constant_evaluated() | |
| 381 | ? _VSTD::__assign_constexpr(__s, __n, __a) | |
| 382 | : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); | |
| 383 | } | |
| 384 | ||
| 385 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 386 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 387 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 388 | {return char_type(__c);} | |
| 389 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 390 | {return int_type((unsigned char)__c);} | |
| 391 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 392 | {return __c1 == __c2;} | |
| 393 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 394 | {return int_type(EOF);} | |
| 395 | }; | |
| 396 | ||
| 397 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 398 | int | |
| 399 | char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 400 | { | |
| 401 | if (__n == 0) | |
| 402 | return 0; | |
| 403 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 404 | return __builtin_memcmp(__s1, __s2, __n); | |
| 405 | #elif _LIBCPP_STD_VER <= 14 | |
| 406 | return _VSTD::memcmp(__s1, __s2, __n); | |
| 407 | #else | |
| 408 | for (; __n; --__n, ++__s1, ++__s2) | |
| 409 | { | |
| 410 | if (lt(*__s1, *__s2)) | |
| 411 | return -1; | |
| 412 | if (lt(*__s2, *__s1)) | |
| 413 | return 1; | |
| 414 | } | |
| 415 | return 0; | |
| 416 | #endif | |
| 417 | } | |
| 418 | ||
| 419 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 420 | const char* | |
| 421 | char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 422 | { | |
| 423 | if (__n == 0) | |
| 424 | return nullptr; | |
| 425 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 426 | return __builtin_char_memchr(__s, to_int_type(__a), __n); | |
| 427 | #elif _LIBCPP_STD_VER <= 14 | |
| 428 | return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n); | |
| 429 | #else | |
| 430 | for (; __n; --__n) | |
| 431 | { | |
| 432 | if (eq(*__s, __a)) | |
| 433 | return __s; | |
| 434 | ++__s; | |
| 435 | } | |
| 436 | return nullptr; | |
| 437 | #endif | |
| 438 | } | |
| 439 | ||
| 440 | ||
| 441 | // char_traits<wchar_t> | |
| 442 | ||
| 443 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 444 | template <> | |
| 445 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> | |
| 446 | { | |
| 447 | typedef wchar_t char_type; | |
| 448 | typedef wint_t int_type; | |
| 449 | typedef streamoff off_type; | |
| 450 | typedef streampos pos_type; | |
| 451 | typedef mbstate_t state_type; | |
| 452 | ||
| 453 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 454 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 455 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 456 | {return __c1 == __c2;} | |
| 457 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 458 | {return __c1 < __c2;} | |
| 459 | ||
| 460 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 461 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 462 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 463 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 464 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 465 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 466 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 467 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 468 | { | |
| 469 | return __libcpp_is_constant_evaluated() | |
| 470 | ? _VSTD::__move_constexpr(__s1, __s2, __n) | |
| 471 | : __n == 0 ? __s1 : _VSTD::wmemmove(__s1, __s2, __n); | |
| 472 | } | |
| 473 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 474 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 475 | { | |
| 476 | if (!__libcpp_is_constant_evaluated()) { | |
| 477 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 478 | } | |
| 479 | return __libcpp_is_constant_evaluated() | |
| 480 | ? _VSTD::__copy_constexpr(__s1, __s2, __n) | |
| 481 | : __n == 0 ? __s1 : _VSTD::wmemcpy(__s1, __s2, __n); | |
| 482 | } | |
| 483 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 484 | char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT | |
| 485 | { | |
| 486 | return __libcpp_is_constant_evaluated() | |
| 487 | ? _VSTD::__assign_constexpr(__s, __n, __a) | |
| 488 | : __n == 0 ? __s : _VSTD::wmemset(__s, __a, __n); | |
| 489 | } | |
| 490 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 491 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 492 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 493 | {return char_type(__c);} | |
| 494 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 495 | {return int_type(__c);} | |
| 496 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 497 | {return __c1 == __c2;} | |
| 498 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 499 | {return int_type(WEOF);} | |
| 500 | }; | |
| 501 | ||
| 502 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 503 | int | |
| 504 | char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 505 | { | |
| 506 | if (__n == 0) | |
| 507 | return 0; | |
| 508 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 509 | return __builtin_wmemcmp(__s1, __s2, __n); | |
| 510 | #elif _LIBCPP_STD_VER <= 14 | |
| 511 | return _VSTD::wmemcmp(__s1, __s2, __n); | |
| 512 | #else | |
| 513 | for (; __n; --__n, ++__s1, ++__s2) | |
| 514 | { | |
| 515 | if (lt(*__s1, *__s2)) | |
| 516 | return -1; | |
| 517 | if (lt(*__s2, *__s1)) | |
| 518 | return 1; | |
| 519 | } | |
| 520 | return 0; | |
| 521 | #endif | |
| 522 | } | |
| 523 | ||
| 524 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 525 | size_t | |
| 526 | char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT | |
| 527 | { | |
| 528 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 529 | return __builtin_wcslen(__s); | |
| 530 | #elif _LIBCPP_STD_VER <= 14 | |
| 531 | return _VSTD::wcslen(__s); | |
| 532 | #else | |
| 533 | size_t __len = 0; | |
| 534 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 535 | ++__len; | |
| 536 | return __len; | |
| 537 | #endif | |
| 538 | } | |
| 539 | ||
| 540 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 541 | const wchar_t* | |
| 542 | char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 543 | { | |
| 544 | if (__n == 0) | |
| 545 | return nullptr; | |
| 546 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 547 | return __builtin_wmemchr(__s, __a, __n); | |
| 548 | #elif _LIBCPP_STD_VER <= 14 | |
| 549 | return _VSTD::wmemchr(__s, __a, __n); | |
| 550 | #else | |
| 551 | for (; __n; --__n) | |
| 552 | { | |
| 553 | if (eq(*__s, __a)) | |
| 554 | return __s; | |
| 555 | ++__s; | |
| 556 | } | |
| 557 | return nullptr; | |
| 558 | #endif | |
| 559 | } | |
| 560 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 561 | ||
| 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 | } | |
| 572 | ||
| 573 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 574 | ||
| 575 | template <> | |
| 576 | struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> | |
| 577 | { | |
| 578 | typedef char8_t char_type; | |
| 579 | typedef unsigned int int_type; | |
| 580 | typedef streamoff off_type; | |
| 581 | typedef u8streampos pos_type; | |
| 582 | typedef mbstate_t state_type; | |
| 583 | ||
| 584 | static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept | |
| 585 | {__c1 = __c2;} | |
| 586 | static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept | |
| 587 | {return __c1 == __c2;} | |
| 588 | static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept | |
| 589 | {return __c1 < __c2;} | |
| 590 | ||
| 591 | static constexpr | |
| 592 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 593 | ||
| 594 | static constexpr | |
| 595 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 596 | ||
| 597 | _LIBCPP_INLINE_VISIBILITY static constexpr | |
| 598 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 599 | ||
| 600 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 601 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 602 | { | |
| 603 | return __libcpp_is_constant_evaluated() | |
| 604 | ? _VSTD::__move_constexpr(__s1, __s2, __n) | |
| 605 | : __n == 0 ? __s1 : (char_type*)_VSTD::memmove(__s1, __s2, __n); | |
| 606 | } | |
| 607 | ||
| 608 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 609 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 610 | { | |
| 611 | if (!__libcpp_is_constant_evaluated()) { | |
| 612 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 613 | } | |
| 614 | return __libcpp_is_constant_evaluated() | |
| 615 | ? _VSTD::__copy_constexpr(__s1, __s2, __n) | |
| 616 | : __n == 0 ? __s1 : (char_type*)_VSTD::memcpy(__s1, __s2, __n); | |
| 617 | } | |
| 618 | ||
| 619 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 620 | char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT | |
| 621 | { | |
| 622 | return __libcpp_is_constant_evaluated() | |
| 623 | ? _VSTD::__assign_constexpr(__s, __n, __a) | |
| 624 | : __n == 0 ? __s : (char_type*)_VSTD::memset(__s, to_int_type(__a), __n); | |
| 625 | } | |
| 626 | ||
| 627 | static inline constexpr int_type not_eof(int_type __c) noexcept | |
| 628 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 629 | static inline constexpr char_type to_char_type(int_type __c) noexcept | |
| 630 | {return char_type(__c);} | |
| 631 | static inline constexpr int_type to_int_type(char_type __c) noexcept | |
| 632 | {return int_type(__c);} | |
| 633 | static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept | |
| 634 | {return __c1 == __c2;} | |
| 635 | static inline constexpr int_type eof() noexcept | |
| 636 | {return int_type(EOF);} | |
| 637 | }; | |
| 638 | ||
| 639 | // TODO use '__builtin_strlen' if it ever supports char8_t ?? | |
| 640 | inline constexpr | |
| 641 | size_t | |
| 642 | char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT | |
| 643 | { | |
| 644 | size_t __len = 0; | |
| 645 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 646 | ++__len; | |
| 647 | return __len; | |
| 648 | } | |
| 649 | ||
| 650 | inline constexpr | |
| 651 | int | |
| 652 | char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 653 | { | |
| 654 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 655 | return __builtin_memcmp(__s1, __s2, __n); | |
| 656 | #else | |
| 657 | for (; __n; --__n, ++__s1, ++__s2) | |
| 658 | { | |
| 659 | if (lt(*__s1, *__s2)) | |
| 660 | return -1; | |
| 661 | if (lt(*__s2, *__s1)) | |
| 662 | return 1; | |
| 663 | } | |
| 664 | return 0; | |
| 665 | #endif | |
| 666 | } | |
| 667 | ||
| 668 | // TODO use '__builtin_char_memchr' if it ever supports char8_t ?? | |
| 669 | inline constexpr | |
| 670 | const char8_t* | |
| 671 | char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 672 | { | |
| 673 | for (; __n; --__n) | |
| 674 | { | |
| 675 | if (eq(*__s, __a)) | |
| 676 | return __s; | |
| 677 | ++__s; | |
| 678 | } | |
| 679 | return nullptr; | |
| 680 | } | |
| 681 | ||
| 682 | #endif // #_LIBCPP_HAS_NO_CHAR8_T | |
| 683 | ||
| 684 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 685 | ||
| 686 | template <> | |
| 687 | struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> | |
| 688 | { | |
| 689 | typedef char16_t char_type; | |
| 690 | typedef uint_least16_t int_type; | |
| 691 | typedef streamoff off_type; | |
| 692 | typedef u16streampos pos_type; | |
| 693 | typedef mbstate_t state_type; | |
| 694 | ||
| 695 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 696 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 697 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 698 | {return __c1 == __c2;} | |
| 699 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 700 | {return __c1 < __c2;} | |
| 701 | ||
| 702 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 703 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 704 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 705 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 706 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 707 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 708 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 709 | static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 710 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 711 | static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 712 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 713 | static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT; | |
| 714 | ||
| 715 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 716 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 717 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 718 | {return char_type(__c);} | |
| 719 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 720 | {return int_type(__c);} | |
| 721 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 722 | {return __c1 == __c2;} | |
| 723 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 724 | {return int_type(0xFFFF);} | |
| 725 | }; | |
| 726 | ||
| 727 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 728 | int | |
| 729 | char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 730 | { | |
| 731 | for (; __n; --__n, ++__s1, ++__s2) | |
| 732 | { | |
| 733 | if (lt(*__s1, *__s2)) | |
| 734 | return -1; | |
| 735 | if (lt(*__s2, *__s1)) | |
| 736 | return 1; | |
| 737 | } | |
| 738 | return 0; | |
| 739 | } | |
| 740 | ||
| 741 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 742 | size_t | |
| 743 | char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT | |
| 744 | { | |
| 745 | size_t __len = 0; | |
| 746 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 747 | ++__len; | |
| 748 | return __len; | |
| 749 | } | |
| 750 | ||
| 751 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 752 | const char16_t* | |
| 753 | char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 754 | { | |
| 755 | for (; __n; --__n) | |
| 756 | { | |
| 757 | if (eq(*__s, __a)) | |
| 758 | return __s; | |
| 759 | ++__s; | |
| 760 | } | |
| 761 | return nullptr; | |
| 762 | } | |
| 763 | ||
| 764 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 765 | char16_t* | |
| 766 | char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 767 | { | |
| 768 | if (__n == 0) return __s1; | |
| 769 | char_type* __r = __s1; | |
| 770 | if (__s1 < __s2) | |
| 771 | { | |
| 772 | for (; __n; --__n, ++__s1, ++__s2) | |
| 773 | assign(*__s1, *__s2); | |
| 774 | } | |
| 775 | else if (__s2 < __s1) | |
| 776 | { | |
| 777 | __s1 += __n; | |
| 778 | __s2 += __n; | |
| 779 | for (; __n; --__n) | |
| 780 | assign(*--__s1, *--__s2); | |
| 781 | } | |
| 782 | return __r; | |
| 783 | } | |
| 784 | ||
| 785 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 786 | char16_t* | |
| 787 | char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 788 | { | |
| 789 | if (!__libcpp_is_constant_evaluated()) { | |
| 790 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 791 | } | |
| 792 | char_type* __r = __s1; | |
| 793 | for (; __n; --__n, ++__s1, ++__s2) | |
| 794 | assign(*__s1, *__s2); | |
| 795 | return __r; | |
| 796 | } | |
| 797 | ||
| 798 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 799 | char16_t* | |
| 800 | char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT | |
| 801 | { | |
| 802 | char_type* __r = __s; | |
| 803 | for (; __n; --__n, ++__s) | |
| 804 | assign(*__s, __a); | |
| 805 | return __r; | |
| 806 | } | |
| 807 | ||
| 808 | template <> | |
| 809 | struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> | |
| 810 | { | |
| 811 | typedef char32_t char_type; | |
| 812 | typedef uint_least32_t int_type; | |
| 813 | typedef streamoff off_type; | |
| 814 | typedef u32streampos pos_type; | |
| 815 | typedef mbstate_t state_type; | |
| 816 | ||
| 817 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 818 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 819 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 820 | {return __c1 == __c2;} | |
| 821 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 822 | {return __c1 < __c2;} | |
| 823 | ||
| 824 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 825 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 826 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 827 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 828 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 829 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 830 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 831 | static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 832 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 833 | static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 834 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 835 | static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT; | |
| 836 | ||
| 837 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 838 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 839 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 840 | {return char_type(__c);} | |
| 841 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 842 | {return int_type(__c);} | |
| 843 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 844 | {return __c1 == __c2;} | |
| 845 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 846 | {return int_type(0xFFFFFFFF);} | |
| 847 | }; | |
| 848 | ||
| 849 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 850 | int | |
| 851 | char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 852 | { | |
| 853 | for (; __n; --__n, ++__s1, ++__s2) | |
| 854 | { | |
| 855 | if (lt(*__s1, *__s2)) | |
| 856 | return -1; | |
| 857 | if (lt(*__s2, *__s1)) | |
| 858 | return 1; | |
| 859 | } | |
| 860 | return 0; | |
| 861 | } | |
| 862 | ||
| 863 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 864 | size_t | |
| 865 | char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT | |
| 866 | { | |
| 867 | size_t __len = 0; | |
| 868 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 869 | ++__len; | |
| 870 | return __len; | |
| 871 | } | |
| 872 | ||
| 873 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 874 | const char32_t* | |
| 875 | char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 876 | { | |
| 877 | for (; __n; --__n) | |
| 878 | { | |
| 879 | if (eq(*__s, __a)) | |
| 880 | return __s; | |
| 881 | ++__s; | |
| 882 | } | |
| 883 | return nullptr; | |
| 884 | } | |
| 885 | ||
| 886 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 887 | char32_t* | |
| 888 | char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 889 | { | |
| 890 | if (__n == 0) return __s1; | |
| 891 | char_type* __r = __s1; | |
| 892 | if (__s1 < __s2) | |
| 893 | { | |
| 894 | for (; __n; --__n, ++__s1, ++__s2) | |
| 895 | assign(*__s1, *__s2); | |
| 896 | } | |
| 897 | else if (__s2 < __s1) | |
| 898 | { | |
| 899 | __s1 += __n; | |
| 900 | __s2 += __n; | |
| 901 | for (; __n; --__n) | |
| 902 | assign(*--__s1, *--__s2); | |
| 903 | } | |
| 904 | return __r; | |
| 905 | } | |
| 906 | ||
| 907 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 908 | char32_t* | |
| 909 | char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 910 | { | |
| 911 | if (!__libcpp_is_constant_evaluated()) { | |
| 912 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 913 | } | |
| 914 | char_type* __r = __s1; | |
| 915 | for (; __n; --__n, ++__s1, ++__s2) | |
| 916 | assign(*__s1, *__s2); | |
| 917 | return __r; | |
| 918 | } | |
| 919 | ||
| 920 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 921 | char32_t* | |
| 922 | char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT | |
| 923 | { | |
| 924 | char_type* __r = __s; | |
| 925 | for (; __n; --__n, ++__s) | |
| 926 | assign(*__s, __a); | |
| 927 | return __r; | |
| 928 | } | |
| 929 | ||
| 930 | #endif // _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 931 | ||
| 932 | // helper fns for basic_string and string_view | |
| 933 | ||
| 934 | // __str_find | |
| 935 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 936 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 937 | __str_find(const _CharT *__p, _SizeT __sz, | |
| 938 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 939 | { | |
| 940 | if (__pos >= __sz) | |
| 941 | return __npos; | |
| 942 | const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); | |
| 943 | if (__r == nullptr) | |
| 944 | return __npos; | |
| 945 | return static_cast<_SizeT>(__r - __p); | |
| 946 | } | |
| 947 | ||
| 948 | template <class _CharT, class _Traits> | |
| 949 | inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT * | |
| 950 | __search_substring(const _CharT *__first1, const _CharT *__last1, | |
| 951 | const _CharT *__first2, const _CharT *__last2) _NOEXCEPT { | |
| 952 | // Take advantage of knowing source and pattern lengths. | |
| 953 | // Stop short when source is smaller than pattern. | |
| 954 | const ptrdiff_t __len2 = __last2 - __first2; | |
| 955 | if (__len2 == 0) | |
| 956 | return __first1; | |
| 957 | ||
| 958 | ptrdiff_t __len1 = __last1 - __first1; | |
| 959 | if (__len1 < __len2) | |
| 960 | return __last1; | |
| 961 | ||
| 962 | // First element of __first2 is loop invariant. | |
| 963 | _CharT __f2 = *__first2; | |
| 964 | while (true) { | |
| 965 | __len1 = __last1 - __first1; | |
| 966 | // Check whether __first1 still has at least __len2 bytes. | |
| 967 | if (__len1 < __len2) | |
| 968 | return __last1; | |
| 969 | ||
| 970 | // Find __f2 the first byte matching in __first1. | |
| 971 | __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); | |
| 972 | if (__first1 == nullptr) | |
| 973 | return __last1; | |
| 974 | ||
| 975 | // It is faster to compare from the first byte of __first1 even if we | |
| 976 | // already know that it matches the first byte of __first2: this is because | |
| 977 | // __first2 is most likely aligned, as it is user's "pattern" string, and | |
| 978 | // __first1 + 1 is most likely not aligned, as the match is in the middle of | |
| 979 | // the string. | |
| 980 | if (_Traits::compare(__first1, __first2, __len2) == 0) | |
| 981 | return __first1; | |
| 982 | ||
| 983 | ++__first1; | |
| 984 | } | |
| 985 | } | |
| 986 | ||
| 987 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 988 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 989 | __str_find(const _CharT *__p, _SizeT __sz, | |
| 990 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 991 | { | |
| 992 | if (__pos > __sz) | |
| 993 | return __npos; | |
| 994 | ||
| 995 | if (__n == 0) // There is nothing to search, just return __pos. | |
| 996 | return __pos; | |
| 997 | ||
| 998 | const _CharT *__r = __search_substring<_CharT, _Traits>( | |
| 999 | __p + __pos, __p + __sz, __s, __s + __n); | |
| 1000 | ||
| 1001 | if (__r == __p + __sz) | |
| 1002 | return __npos; | |
| 1003 | return static_cast<_SizeT>(__r - __p); | |
| 1004 | } | |
| 1005 | ||
| 1006 | ||
| 1007 | // __str_rfind | |
| 1008 | ||
| 1009 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1010 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1011 | __str_rfind(const _CharT *__p, _SizeT __sz, | |
| 1012 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 1013 | { | |
| 1014 | if (__sz < 1) | |
| 1015 | return __npos; | |
| 1016 | if (__pos < __sz) | |
| 1017 | ++__pos; | |
| 1018 | else | |
| 1019 | __pos = __sz; | |
| 1020 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 1021 | { | |
| 1022 | if (_Traits::eq(*--__ps, __c)) | |
| 1023 | return static_cast<_SizeT>(__ps - __p); | |
| 1024 | } | |
| 1025 | return __npos; | |
| 1026 | } | |
| 1027 | ||
| 1028 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1029 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1030 | __str_rfind(const _CharT *__p, _SizeT __sz, | |
| 1031 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 1032 | { | |
| 1033 | __pos = _VSTD::min(__pos, __sz); | |
| 1034 | if (__n < __sz - __pos) | |
| 1035 | __pos += __n; | |
| 1036 | else | |
| 1037 | __pos = __sz; | |
| 1038 | const _CharT* __r = _VSTD::__find_end( | |
| 1039 | __p, __p + __pos, __s, __s + __n, _Traits::eq, | |
| 1040 | random_access_iterator_tag(), random_access_iterator_tag()); | |
| 1041 | if (__n > 0 && __r == __p + __pos) | |
| 1042 | return __npos; | |
| 1043 | return static_cast<_SizeT>(__r - __p); | |
| 1044 | } | |
| 1045 | ||
| 1046 | // __str_find_first_of | |
| 1047 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1048 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1049 | __str_find_first_of(const _CharT *__p, _SizeT __sz, | |
| 1050 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 1051 | { | |
| 1052 | if (__pos >= __sz || __n == 0) | |
| 1053 | return __npos; | |
| 1054 | const _CharT* __r = _VSTD::__find_first_of_ce | |
| 1055 | (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); | |
| 1056 | if (__r == __p + __sz) | |
| 1057 | return __npos; | |
| 1058 | return static_cast<_SizeT>(__r - __p); | |
| 1059 | } | |
| 1060 | ||
| 1061 | ||
| 1062 | // __str_find_last_of | |
| 1063 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1064 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1065 | __str_find_last_of(const _CharT *__p, _SizeT __sz, | |
| 1066 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 1067 | { | |
| 1068 | if (__n != 0) | |
| 1069 | { | |
| 1070 | if (__pos < __sz) | |
| 1071 | ++__pos; | |
| 1072 | else | |
| 1073 | __pos = __sz; | |
| 1074 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 1075 | { | |
| 1076 | const _CharT* __r = _Traits::find(__s, __n, *--__ps); | |
| 1077 | if (__r) | |
| 1078 | return static_cast<_SizeT>(__ps - __p); | |
| 1079 | } | |
| 1080 | } | |
| 1081 | return __npos; | |
| 1082 | } | |
| 1083 | ||
| 1084 | ||
| 1085 | // __str_find_first_not_of | |
| 1086 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1087 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1088 | __str_find_first_not_of(const _CharT *__p, _SizeT __sz, | |
| 1089 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 1090 | { | |
| 1091 | if (__pos < __sz) | |
| 1092 | { | |
| 1093 | const _CharT* __pe = __p + __sz; | |
| 1094 | for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) | |
| 1095 | if (_Traits::find(__s, __n, *__ps) == nullptr) | |
| 1096 | return static_cast<_SizeT>(__ps - __p); | |
| 1097 | } | |
| 1098 | return __npos; | |
| 1099 | } | |
| 1100 | ||
| 1101 | ||
| 1102 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1103 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1104 | __str_find_first_not_of(const _CharT *__p, _SizeT __sz, | |
| 1105 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 1106 | { | |
| 1107 | if (__pos < __sz) | |
| 1108 | { | |
| 1109 | const _CharT* __pe = __p + __sz; | |
| 1110 | for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) | |
| 1111 | if (!_Traits::eq(*__ps, __c)) | |
| 1112 | return static_cast<_SizeT>(__ps - __p); | |
| 1113 | } | |
| 1114 | return __npos; | |
| 1115 | } | |
| 1116 | ||
| 1117 | ||
| 1118 | // __str_find_last_not_of | |
| 1119 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1120 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1121 | __str_find_last_not_of(const _CharT *__p, _SizeT __sz, | |
| 1122 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 1123 | { | |
| 1124 | if (__pos < __sz) | |
| 1125 | ++__pos; | |
| 1126 | else | |
| 1127 | __pos = __sz; | |
| 1128 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 1129 | if (_Traits::find(__s, __n, *--__ps) == nullptr) | |
| 1130 | return static_cast<_SizeT>(__ps - __p); | |
| 1131 | return __npos; | |
| 1132 | } | |
| 1133 | ||
| 1134 | ||
| 1135 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 1136 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 1137 | __str_find_last_not_of(const _CharT *__p, _SizeT __sz, | |
| 1138 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 1139 | { | |
| 1140 | if (__pos < __sz) | |
| 1141 | ++__pos; | |
| 1142 | else | |
| 1143 | __pos = __sz; | |
| 1144 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 1145 | if (!_Traits::eq(*--__ps, __c)) | |
| 1146 | return static_cast<_SizeT>(__ps - __p); | |
| 1147 | return __npos; | |
| 1148 | } | |
| 1149 | ||
| 1150 | template<class _Ptr> | |
| 1151 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1152 | size_t __do_string_hash(_Ptr __p, _Ptr __e) | |
| 1153 | { | |
| 1154 | typedef typename iterator_traits<_Ptr>::value_type value_type; | |
| 1155 | return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type)); | |
| 1156 | } | |
| 1157 | ||
| 1158 | template <class _CharT, class _Iter, class _Traits=char_traits<_CharT> > | |
| 1159 | struct __quoted_output_proxy | |
| 1160 | { | |
| 1161 | _Iter __first; | |
| 1162 | _Iter __last; | |
| 1163 | _CharT __delim; | |
| 1164 | _CharT __escape; | |
| 1165 | ||
| 1166 | __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) | |
| 1167 | : __first(__f), __last(__l), __delim(__d), __escape(__e) {} | |
| 1168 | // This would be a nice place for a string_ref | |
| 1169 | }; | |
| 1170 | ||
| 1171 | _LIBCPP_END_NAMESPACE_STD | |
| 1172 | ||
| 1173 | _LIBCPP_POP_MACROS | |
| 1174 | ||
| 1175 | #endif // _LIBCPP___STRING |
lib/libcxx/include/__string/char_traits.h created+927| ... | ... | @@ -0,0 +1,927 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___STRING_CHAR_TRAITS_H | |
| 10 | #define _LIBCPP___STRING_CHAR_TRAITS_H | |
| 11 | ||
| 12 | #include <__algorithm/copy_n.h> | |
| 13 | #include <__algorithm/fill_n.h> | |
| 14 | #include <__algorithm/find_end.h> | |
| 15 | #include <__algorithm/find_first_of.h> | |
| 16 | #include <__algorithm/min.h> | |
| 17 | #include <__config> | |
| 18 | #include <__functional/hash.h> | |
| 19 | #include <__iterator/iterator_traits.h> | |
| 20 | #include <cstdint> | |
| 21 | #include <cstdio> | |
| 22 | #include <cstring> | |
| 23 | #include <iosfwd> | |
| 24 | #include <type_traits> | |
| 25 | ||
| 26 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 27 | # include <cwchar> // for wmemcpy | |
| 28 | #endif | |
| 29 | ||
| 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 31 | # pragma GCC system_header | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_PUSH_MACROS | |
| 35 | #include <__undef_macros> | |
| 36 | ||
| 37 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 38 | ||
| 39 | template <class _CharT> | |
| 40 | struct _LIBCPP_TEMPLATE_VIS char_traits | |
| 41 | { | |
| 42 | typedef _CharT char_type; | |
| 43 | typedef int int_type; | |
| 44 | typedef streamoff off_type; | |
| 45 | typedef streampos pos_type; | |
| 46 | typedef mbstate_t state_type; | |
| 47 | ||
| 48 | static inline void _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 49 | assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 50 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 51 | {return __c1 == __c2;} | |
| 52 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 53 | {return __c1 < __c2;} | |
| 54 | ||
| 55 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 56 | int compare(const char_type* __s1, const char_type* __s2, size_t __n); | |
| 57 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 58 | size_t length(const char_type* __s); | |
| 59 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 60 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a); | |
| 61 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 62 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n); | |
| 63 | _LIBCPP_INLINE_VISIBILITY | |
| 64 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 65 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); | |
| 66 | _LIBCPP_INLINE_VISIBILITY | |
| 67 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 68 | char_type* assign(char_type* __s, size_t __n, char_type __a); | |
| 69 | ||
| 70 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 71 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 72 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 73 | {return char_type(__c);} | |
| 74 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 75 | {return int_type(__c);} | |
| 76 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 77 | {return __c1 == __c2;} | |
| 78 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 79 | {return int_type(EOF);} | |
| 80 | }; | |
| 81 | ||
| 82 | template <class _CharT> | |
| 83 | _LIBCPP_CONSTEXPR_AFTER_CXX14 int | |
| 84 | char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_t __n) | |
| 85 | { | |
| 86 | for (; __n; --__n, ++__s1, ++__s2) | |
| 87 | { | |
| 88 | if (lt(*__s1, *__s2)) | |
| 89 | return -1; | |
| 90 | if (lt(*__s2, *__s1)) | |
| 91 | return 1; | |
| 92 | } | |
| 93 | return 0; | |
| 94 | } | |
| 95 | ||
| 96 | template <class _CharT> | |
| 97 | inline | |
| 98 | _LIBCPP_CONSTEXPR_AFTER_CXX14 size_t | |
| 99 | char_traits<_CharT>::length(const char_type* __s) | |
| 100 | { | |
| 101 | size_t __len = 0; | |
| 102 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 103 | ++__len; | |
| 104 | return __len; | |
| 105 | } | |
| 106 | ||
| 107 | template <class _CharT> | |
| 108 | inline | |
| 109 | _LIBCPP_CONSTEXPR_AFTER_CXX14 const _CharT* | |
| 110 | char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) | |
| 111 | { | |
| 112 | for (; __n; --__n) | |
| 113 | { | |
| 114 | if (eq(*__s, __a)) | |
| 115 | return __s; | |
| 116 | ++__s; | |
| 117 | } | |
| 118 | return nullptr; | |
| 119 | } | |
| 120 | ||
| 121 | template <class _CharT> | |
| 122 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _CharT* | |
| 123 | char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) | |
| 124 | { | |
| 125 | if (__n == 0) return __s1; | |
| 126 | char_type* __r = __s1; | |
| 127 | if (__s1 < __s2) | |
| 128 | { | |
| 129 | for (; __n; --__n, ++__s1, ++__s2) | |
| 130 | assign(*__s1, *__s2); | |
| 131 | } | |
| 132 | else if (__s2 < __s1) | |
| 133 | { | |
| 134 | __s1 += __n; | |
| 135 | __s2 += __n; | |
| 136 | for (; __n; --__n) | |
| 137 | assign(*--__s1, *--__s2); | |
| 138 | } | |
| 139 | return __r; | |
| 140 | } | |
| 141 | ||
| 142 | template <class _CharT> | |
| 143 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 144 | _CharT* | |
| 145 | char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) | |
| 146 | { | |
| 147 | if (!__libcpp_is_constant_evaluated()) { | |
| 148 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 149 | } | |
| 150 | char_type* __r = __s1; | |
| 151 | for (; __n; --__n, ++__s1, ++__s2) | |
| 152 | assign(*__s1, *__s2); | |
| 153 | return __r; | |
| 154 | } | |
| 155 | ||
| 156 | template <class _CharT> | |
| 157 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 158 | _CharT* | |
| 159 | char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) | |
| 160 | { | |
| 161 | char_type* __r = __s; | |
| 162 | for (; __n; --__n, ++__s) | |
| 163 | assign(*__s, __a); | |
| 164 | return __r; | |
| 165 | } | |
| 166 | ||
| 167 | template <class _CharT> | |
| 168 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 169 | _CharT* __char_traits_move(_CharT* __dest, const _CharT* __source, size_t __n) _NOEXCEPT | |
| 170 | { | |
| 171 | #ifdef _LIBCPP_COMPILER_GCC | |
| 172 | if (__libcpp_is_constant_evaluated()) { | |
| 173 | if (__n == 0) | |
| 174 | return __dest; | |
| 175 | _CharT* __allocation = new _CharT[__n]; | |
| 176 | std::copy_n(__source, __n, __allocation); | |
| 177 | std::copy_n(static_cast<const _CharT*>(__allocation), __n, __dest); | |
| 178 | delete[] __allocation; | |
| 179 | return __dest; | |
| 180 | } | |
| 181 | #endif | |
| 182 | ::__builtin_memmove(__dest, __source, __n * sizeof(_CharT)); | |
| 183 | return __dest; | |
| 184 | } | |
| 185 | ||
| 186 | // char_traits<char> | |
| 187 | ||
| 188 | template <> | |
| 189 | struct _LIBCPP_TEMPLATE_VIS char_traits<char> | |
| 190 | { | |
| 191 | typedef char char_type; | |
| 192 | typedef int int_type; | |
| 193 | typedef streamoff off_type; | |
| 194 | typedef streampos pos_type; | |
| 195 | typedef mbstate_t state_type; | |
| 196 | ||
| 197 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 198 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 199 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 200 | {return __c1 == __c2;} | |
| 201 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 202 | {return (unsigned char)__c1 < (unsigned char)__c2;} | |
| 203 | ||
| 204 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 205 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 206 | ||
| 207 | static inline size_t _LIBCPP_CONSTEXPR_AFTER_CXX14 length(const char_type* __s) _NOEXCEPT { | |
| 208 | // GCC currently does not support __builtin_strlen during constant evaluation. | |
| 209 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816 | |
| 210 | #ifdef _LIBCPP_COMPILER_GCC | |
| 211 | if (__libcpp_is_constant_evaluated()) { | |
| 212 | size_t __i = 0; | |
| 213 | for (; __s[__i] != char_type('\0'); ++__i) | |
| 214 | ; | |
| 215 | return __i; | |
| 216 | } | |
| 217 | #endif | |
| 218 | return __builtin_strlen(__s); | |
| 219 | } | |
| 220 | ||
| 221 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 222 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 223 | ||
| 224 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 225 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 226 | return std::__char_traits_move(__s1, __s2, __n); | |
| 227 | } | |
| 228 | ||
| 229 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 230 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 231 | if (!__libcpp_is_constant_evaluated()) | |
| 232 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 233 | std::copy_n(__s2, __n, __s1); | |
| 234 | return __s1; | |
| 235 | } | |
| 236 | ||
| 237 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 238 | char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | |
| 239 | std::fill_n(__s, __n, __a); | |
| 240 | return __s; | |
| 241 | } | |
| 242 | ||
| 243 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 244 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 245 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 246 | {return char_type(__c);} | |
| 247 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 248 | {return int_type((unsigned char)__c);} | |
| 249 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 250 | {return __c1 == __c2;} | |
| 251 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 252 | {return int_type(EOF);} | |
| 253 | }; | |
| 254 | ||
| 255 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 256 | int | |
| 257 | char_traits<char>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 258 | { | |
| 259 | if (__n == 0) | |
| 260 | return 0; | |
| 261 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 262 | return __builtin_memcmp(__s1, __s2, __n); | |
| 263 | #elif _LIBCPP_STD_VER <= 14 | |
| 264 | return _VSTD::memcmp(__s1, __s2, __n); | |
| 265 | #else | |
| 266 | for (; __n; --__n, ++__s1, ++__s2) | |
| 267 | { | |
| 268 | if (lt(*__s1, *__s2)) | |
| 269 | return -1; | |
| 270 | if (lt(*__s2, *__s1)) | |
| 271 | return 1; | |
| 272 | } | |
| 273 | return 0; | |
| 274 | #endif | |
| 275 | } | |
| 276 | ||
| 277 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 278 | const char* | |
| 279 | char_traits<char>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 280 | { | |
| 281 | if (__n == 0) | |
| 282 | return nullptr; | |
| 283 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 284 | return __builtin_char_memchr(__s, to_int_type(__a), __n); | |
| 285 | #elif _LIBCPP_STD_VER <= 14 | |
| 286 | return (const char_type*) _VSTD::memchr(__s, to_int_type(__a), __n); | |
| 287 | #else | |
| 288 | for (; __n; --__n) | |
| 289 | { | |
| 290 | if (eq(*__s, __a)) | |
| 291 | return __s; | |
| 292 | ++__s; | |
| 293 | } | |
| 294 | return nullptr; | |
| 295 | #endif | |
| 296 | } | |
| 297 | ||
| 298 | ||
| 299 | // char_traits<wchar_t> | |
| 300 | ||
| 301 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 302 | template <> | |
| 303 | struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> | |
| 304 | { | |
| 305 | typedef wchar_t char_type; | |
| 306 | typedef wint_t int_type; | |
| 307 | typedef streamoff off_type; | |
| 308 | typedef streampos pos_type; | |
| 309 | typedef mbstate_t state_type; | |
| 310 | ||
| 311 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 312 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 313 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 314 | {return __c1 == __c2;} | |
| 315 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 316 | {return __c1 < __c2;} | |
| 317 | ||
| 318 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 319 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 320 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 321 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 322 | static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 323 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 324 | ||
| 325 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 326 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 327 | return std::__char_traits_move(__s1, __s2, __n); | |
| 328 | } | |
| 329 | ||
| 330 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 331 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 332 | if (!__libcpp_is_constant_evaluated()) | |
| 333 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 334 | std::copy_n(__s2, __n, __s1); | |
| 335 | return __s1; | |
| 336 | } | |
| 337 | ||
| 338 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 339 | char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | |
| 340 | std::fill_n(__s, __n, __a); | |
| 341 | return __s; | |
| 342 | } | |
| 343 | ||
| 344 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 345 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 346 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 347 | {return char_type(__c);} | |
| 348 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 349 | {return int_type(__c);} | |
| 350 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 351 | {return __c1 == __c2;} | |
| 352 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 353 | {return int_type(WEOF);} | |
| 354 | }; | |
| 355 | ||
| 356 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 357 | int | |
| 358 | char_traits<wchar_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 359 | { | |
| 360 | if (__n == 0) | |
| 361 | return 0; | |
| 362 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 363 | return __builtin_wmemcmp(__s1, __s2, __n); | |
| 364 | #elif _LIBCPP_STD_VER <= 14 | |
| 365 | return _VSTD::wmemcmp(__s1, __s2, __n); | |
| 366 | #else | |
| 367 | for (; __n; --__n, ++__s1, ++__s2) | |
| 368 | { | |
| 369 | if (lt(*__s1, *__s2)) | |
| 370 | return -1; | |
| 371 | if (lt(*__s2, *__s1)) | |
| 372 | return 1; | |
| 373 | } | |
| 374 | return 0; | |
| 375 | #endif | |
| 376 | } | |
| 377 | ||
| 378 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 379 | size_t | |
| 380 | char_traits<wchar_t>::length(const char_type* __s) _NOEXCEPT | |
| 381 | { | |
| 382 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 383 | return __builtin_wcslen(__s); | |
| 384 | #elif _LIBCPP_STD_VER <= 14 | |
| 385 | return _VSTD::wcslen(__s); | |
| 386 | #else | |
| 387 | size_t __len = 0; | |
| 388 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 389 | ++__len; | |
| 390 | return __len; | |
| 391 | #endif | |
| 392 | } | |
| 393 | ||
| 394 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 395 | const wchar_t* | |
| 396 | char_traits<wchar_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 397 | { | |
| 398 | if (__n == 0) | |
| 399 | return nullptr; | |
| 400 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 401 | return __builtin_wmemchr(__s, __a, __n); | |
| 402 | #elif _LIBCPP_STD_VER <= 14 | |
| 403 | return _VSTD::wmemchr(__s, __a, __n); | |
| 404 | #else | |
| 405 | for (; __n; --__n) | |
| 406 | { | |
| 407 | if (eq(*__s, __a)) | |
| 408 | return __s; | |
| 409 | ++__s; | |
| 410 | } | |
| 411 | return nullptr; | |
| 412 | #endif | |
| 413 | } | |
| 414 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 415 | ||
| 416 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 417 | ||
| 418 | template <> | |
| 419 | struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> | |
| 420 | { | |
| 421 | typedef char8_t char_type; | |
| 422 | typedef unsigned int int_type; | |
| 423 | typedef streamoff off_type; | |
| 424 | typedef u8streampos pos_type; | |
| 425 | typedef mbstate_t state_type; | |
| 426 | ||
| 427 | static inline constexpr void assign(char_type& __c1, const char_type& __c2) noexcept | |
| 428 | {__c1 = __c2;} | |
| 429 | static inline constexpr bool eq(char_type __c1, char_type __c2) noexcept | |
| 430 | {return __c1 == __c2;} | |
| 431 | static inline constexpr bool lt(char_type __c1, char_type __c2) noexcept | |
| 432 | {return __c1 < __c2;} | |
| 433 | ||
| 434 | static constexpr | |
| 435 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 436 | ||
| 437 | static constexpr | |
| 438 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 439 | ||
| 440 | _LIBCPP_INLINE_VISIBILITY static constexpr | |
| 441 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 442 | ||
| 443 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 444 | char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 445 | return std::__char_traits_move(__s1, __s2, __n); | |
| 446 | } | |
| 447 | ||
| 448 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 449 | char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 450 | if (!__libcpp_is_constant_evaluated()) | |
| 451 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 452 | std::copy_n(__s2, __n, __s1); | |
| 453 | return __s1; | |
| 454 | } | |
| 455 | ||
| 456 | static _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 457 | char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | |
| 458 | std::fill_n(__s, __n, __a); | |
| 459 | return __s; | |
| 460 | } | |
| 461 | ||
| 462 | static inline constexpr int_type not_eof(int_type __c) noexcept | |
| 463 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 464 | static inline constexpr char_type to_char_type(int_type __c) noexcept | |
| 465 | {return char_type(__c);} | |
| 466 | static inline constexpr int_type to_int_type(char_type __c) noexcept | |
| 467 | {return int_type(__c);} | |
| 468 | static inline constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept | |
| 469 | {return __c1 == __c2;} | |
| 470 | static inline constexpr int_type eof() noexcept | |
| 471 | {return int_type(EOF);} | |
| 472 | }; | |
| 473 | ||
| 474 | // TODO use '__builtin_strlen' if it ever supports char8_t ?? | |
| 475 | inline constexpr | |
| 476 | size_t | |
| 477 | char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT | |
| 478 | { | |
| 479 | size_t __len = 0; | |
| 480 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 481 | ++__len; | |
| 482 | return __len; | |
| 483 | } | |
| 484 | ||
| 485 | inline constexpr | |
| 486 | int | |
| 487 | char_traits<char8_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 488 | { | |
| 489 | #if __has_feature(cxx_constexpr_string_builtins) | |
| 490 | return __builtin_memcmp(__s1, __s2, __n); | |
| 491 | #else | |
| 492 | for (; __n; --__n, ++__s1, ++__s2) | |
| 493 | { | |
| 494 | if (lt(*__s1, *__s2)) | |
| 495 | return -1; | |
| 496 | if (lt(*__s2, *__s1)) | |
| 497 | return 1; | |
| 498 | } | |
| 499 | return 0; | |
| 500 | #endif | |
| 501 | } | |
| 502 | ||
| 503 | // TODO use '__builtin_char_memchr' if it ever supports char8_t ?? | |
| 504 | inline constexpr | |
| 505 | const char8_t* | |
| 506 | char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 507 | { | |
| 508 | for (; __n; --__n) | |
| 509 | { | |
| 510 | if (eq(*__s, __a)) | |
| 511 | return __s; | |
| 512 | ++__s; | |
| 513 | } | |
| 514 | return nullptr; | |
| 515 | } | |
| 516 | ||
| 517 | #endif // _LIBCPP_HAS_NO_CHAR8_T | |
| 518 | ||
| 519 | template <> | |
| 520 | struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> | |
| 521 | { | |
| 522 | typedef char16_t char_type; | |
| 523 | typedef uint_least16_t int_type; | |
| 524 | typedef streamoff off_type; | |
| 525 | typedef u16streampos pos_type; | |
| 526 | typedef mbstate_t state_type; | |
| 527 | ||
| 528 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 529 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 530 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 531 | {return __c1 == __c2;} | |
| 532 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 533 | {return __c1 < __c2;} | |
| 534 | ||
| 535 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 536 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 537 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 538 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 539 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 540 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 541 | ||
| 542 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 543 | static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 544 | return std::__char_traits_move(__s1, __s2, __n); | |
| 545 | } | |
| 546 | ||
| 547 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 548 | static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 549 | if (!__libcpp_is_constant_evaluated()) | |
| 550 | _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); | |
| 551 | std::copy_n(__s2, __n, __s1); | |
| 552 | return __s1; | |
| 553 | } | |
| 554 | ||
| 555 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 556 | static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | |
| 557 | std::fill_n(__s, __n, __a); | |
| 558 | return __s; | |
| 559 | } | |
| 560 | ||
| 561 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 562 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 563 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 564 | {return char_type(__c);} | |
| 565 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 566 | {return int_type(__c);} | |
| 567 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 568 | {return __c1 == __c2;} | |
| 569 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 570 | {return int_type(0xFFFF);} | |
| 571 | }; | |
| 572 | ||
| 573 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 574 | int | |
| 575 | char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 576 | { | |
| 577 | for (; __n; --__n, ++__s1, ++__s2) | |
| 578 | { | |
| 579 | if (lt(*__s1, *__s2)) | |
| 580 | return -1; | |
| 581 | if (lt(*__s2, *__s1)) | |
| 582 | return 1; | |
| 583 | } | |
| 584 | return 0; | |
| 585 | } | |
| 586 | ||
| 587 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 588 | size_t | |
| 589 | char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT | |
| 590 | { | |
| 591 | size_t __len = 0; | |
| 592 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 593 | ++__len; | |
| 594 | return __len; | |
| 595 | } | |
| 596 | ||
| 597 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 598 | const char16_t* | |
| 599 | char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 600 | { | |
| 601 | for (; __n; --__n) | |
| 602 | { | |
| 603 | if (eq(*__s, __a)) | |
| 604 | return __s; | |
| 605 | ++__s; | |
| 606 | } | |
| 607 | return nullptr; | |
| 608 | } | |
| 609 | ||
| 610 | template <> | |
| 611 | struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> | |
| 612 | { | |
| 613 | typedef char32_t char_type; | |
| 614 | typedef uint_least32_t int_type; | |
| 615 | typedef streamoff off_type; | |
| 616 | typedef u32streampos pos_type; | |
| 617 | typedef mbstate_t state_type; | |
| 618 | ||
| 619 | static inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 620 | void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} | |
| 621 | static inline _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT | |
| 622 | {return __c1 == __c2;} | |
| 623 | static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT | |
| 624 | {return __c1 < __c2;} | |
| 625 | ||
| 626 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 627 | int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT; | |
| 628 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 629 | size_t length(const char_type* __s) _NOEXCEPT; | |
| 630 | _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 631 | const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT; | |
| 632 | ||
| 633 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 634 | static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 635 | return std::__char_traits_move(__s1, __s2, __n); | |
| 636 | } | |
| 637 | ||
| 638 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 639 | static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT { | |
| 640 | std::copy_n(__s2, __n, __s1); | |
| 641 | return __s1; | |
| 642 | } | |
| 643 | ||
| 644 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 645 | static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT { | |
| 646 | std::fill_n(__s, __n, __a); | |
| 647 | return __s; | |
| 648 | } | |
| 649 | ||
| 650 | static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT | |
| 651 | {return eq_int_type(__c, eof()) ? ~eof() : __c;} | |
| 652 | static inline _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT | |
| 653 | {return char_type(__c);} | |
| 654 | static inline _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT | |
| 655 | {return int_type(__c);} | |
| 656 | static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT | |
| 657 | {return __c1 == __c2;} | |
| 658 | static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT | |
| 659 | {return int_type(0xFFFFFFFF);} | |
| 660 | }; | |
| 661 | ||
| 662 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 663 | int | |
| 664 | char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT | |
| 665 | { | |
| 666 | for (; __n; --__n, ++__s1, ++__s2) | |
| 667 | { | |
| 668 | if (lt(*__s1, *__s2)) | |
| 669 | return -1; | |
| 670 | if (lt(*__s2, *__s1)) | |
| 671 | return 1; | |
| 672 | } | |
| 673 | return 0; | |
| 674 | } | |
| 675 | ||
| 676 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 677 | size_t | |
| 678 | char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT | |
| 679 | { | |
| 680 | size_t __len = 0; | |
| 681 | for (; !eq(*__s, char_type(0)); ++__s) | |
| 682 | ++__len; | |
| 683 | return __len; | |
| 684 | } | |
| 685 | ||
| 686 | inline _LIBCPP_CONSTEXPR_AFTER_CXX14 | |
| 687 | const char32_t* | |
| 688 | char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT | |
| 689 | { | |
| 690 | for (; __n; --__n) | |
| 691 | { | |
| 692 | if (eq(*__s, __a)) | |
| 693 | return __s; | |
| 694 | ++__s; | |
| 695 | } | |
| 696 | return nullptr; | |
| 697 | } | |
| 698 | ||
| 699 | // helper fns for basic_string and string_view | |
| 700 | ||
| 701 | // __str_find | |
| 702 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 703 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 704 | __str_find(const _CharT *__p, _SizeT __sz, | |
| 705 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 706 | { | |
| 707 | if (__pos >= __sz) | |
| 708 | return __npos; | |
| 709 | const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c); | |
| 710 | if (__r == nullptr) | |
| 711 | return __npos; | |
| 712 | return static_cast<_SizeT>(__r - __p); | |
| 713 | } | |
| 714 | ||
| 715 | template <class _CharT, class _Traits> | |
| 716 | inline _LIBCPP_CONSTEXPR_AFTER_CXX11 const _CharT * | |
| 717 | __search_substring(const _CharT *__first1, const _CharT *__last1, | |
| 718 | const _CharT *__first2, const _CharT *__last2) _NOEXCEPT { | |
| 719 | // Take advantage of knowing source and pattern lengths. | |
| 720 | // Stop short when source is smaller than pattern. | |
| 721 | const ptrdiff_t __len2 = __last2 - __first2; | |
| 722 | if (__len2 == 0) | |
| 723 | return __first1; | |
| 724 | ||
| 725 | ptrdiff_t __len1 = __last1 - __first1; | |
| 726 | if (__len1 < __len2) | |
| 727 | return __last1; | |
| 728 | ||
| 729 | // First element of __first2 is loop invariant. | |
| 730 | _CharT __f2 = *__first2; | |
| 731 | while (true) { | |
| 732 | __len1 = __last1 - __first1; | |
| 733 | // Check whether __first1 still has at least __len2 bytes. | |
| 734 | if (__len1 < __len2) | |
| 735 | return __last1; | |
| 736 | ||
| 737 | // Find __f2 the first byte matching in __first1. | |
| 738 | __first1 = _Traits::find(__first1, __len1 - __len2 + 1, __f2); | |
| 739 | if (__first1 == nullptr) | |
| 740 | return __last1; | |
| 741 | ||
| 742 | // It is faster to compare from the first byte of __first1 even if we | |
| 743 | // already know that it matches the first byte of __first2: this is because | |
| 744 | // __first2 is most likely aligned, as it is user's "pattern" string, and | |
| 745 | // __first1 + 1 is most likely not aligned, as the match is in the middle of | |
| 746 | // the string. | |
| 747 | if (_Traits::compare(__first1, __first2, __len2) == 0) | |
| 748 | return __first1; | |
| 749 | ||
| 750 | ++__first1; | |
| 751 | } | |
| 752 | } | |
| 753 | ||
| 754 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 755 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 756 | __str_find(const _CharT *__p, _SizeT __sz, | |
| 757 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 758 | { | |
| 759 | if (__pos > __sz) | |
| 760 | return __npos; | |
| 761 | ||
| 762 | if (__n == 0) // There is nothing to search, just return __pos. | |
| 763 | return __pos; | |
| 764 | ||
| 765 | const _CharT *__r = __search_substring<_CharT, _Traits>( | |
| 766 | __p + __pos, __p + __sz, __s, __s + __n); | |
| 767 | ||
| 768 | if (__r == __p + __sz) | |
| 769 | return __npos; | |
| 770 | return static_cast<_SizeT>(__r - __p); | |
| 771 | } | |
| 772 | ||
| 773 | ||
| 774 | // __str_rfind | |
| 775 | ||
| 776 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 777 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 778 | __str_rfind(const _CharT *__p, _SizeT __sz, | |
| 779 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 780 | { | |
| 781 | if (__sz < 1) | |
| 782 | return __npos; | |
| 783 | if (__pos < __sz) | |
| 784 | ++__pos; | |
| 785 | else | |
| 786 | __pos = __sz; | |
| 787 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 788 | { | |
| 789 | if (_Traits::eq(*--__ps, __c)) | |
| 790 | return static_cast<_SizeT>(__ps - __p); | |
| 791 | } | |
| 792 | return __npos; | |
| 793 | } | |
| 794 | ||
| 795 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 796 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 797 | __str_rfind(const _CharT *__p, _SizeT __sz, | |
| 798 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 799 | { | |
| 800 | __pos = _VSTD::min(__pos, __sz); | |
| 801 | if (__n < __sz - __pos) | |
| 802 | __pos += __n; | |
| 803 | else | |
| 804 | __pos = __sz; | |
| 805 | const _CharT* __r = std::__find_end_classic(__p, __p + __pos, __s, __s + __n, _Traits::eq); | |
| 806 | if (__n > 0 && __r == __p + __pos) | |
| 807 | return __npos; | |
| 808 | return static_cast<_SizeT>(__r - __p); | |
| 809 | } | |
| 810 | ||
| 811 | // __str_find_first_of | |
| 812 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 813 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 814 | __str_find_first_of(const _CharT *__p, _SizeT __sz, | |
| 815 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 816 | { | |
| 817 | if (__pos >= __sz || __n == 0) | |
| 818 | return __npos; | |
| 819 | const _CharT* __r = _VSTD::__find_first_of_ce | |
| 820 | (__p + __pos, __p + __sz, __s, __s + __n, _Traits::eq ); | |
| 821 | if (__r == __p + __sz) | |
| 822 | return __npos; | |
| 823 | return static_cast<_SizeT>(__r - __p); | |
| 824 | } | |
| 825 | ||
| 826 | ||
| 827 | // __str_find_last_of | |
| 828 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 829 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 830 | __str_find_last_of(const _CharT *__p, _SizeT __sz, | |
| 831 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 832 | { | |
| 833 | if (__n != 0) | |
| 834 | { | |
| 835 | if (__pos < __sz) | |
| 836 | ++__pos; | |
| 837 | else | |
| 838 | __pos = __sz; | |
| 839 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 840 | { | |
| 841 | const _CharT* __r = _Traits::find(__s, __n, *--__ps); | |
| 842 | if (__r) | |
| 843 | return static_cast<_SizeT>(__ps - __p); | |
| 844 | } | |
| 845 | } | |
| 846 | return __npos; | |
| 847 | } | |
| 848 | ||
| 849 | ||
| 850 | // __str_find_first_not_of | |
| 851 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 852 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 853 | __str_find_first_not_of(const _CharT *__p, _SizeT __sz, | |
| 854 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 855 | { | |
| 856 | if (__pos < __sz) | |
| 857 | { | |
| 858 | const _CharT* __pe = __p + __sz; | |
| 859 | for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) | |
| 860 | if (_Traits::find(__s, __n, *__ps) == nullptr) | |
| 861 | return static_cast<_SizeT>(__ps - __p); | |
| 862 | } | |
| 863 | return __npos; | |
| 864 | } | |
| 865 | ||
| 866 | ||
| 867 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 868 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 869 | __str_find_first_not_of(const _CharT *__p, _SizeT __sz, | |
| 870 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 871 | { | |
| 872 | if (__pos < __sz) | |
| 873 | { | |
| 874 | const _CharT* __pe = __p + __sz; | |
| 875 | for (const _CharT* __ps = __p + __pos; __ps != __pe; ++__ps) | |
| 876 | if (!_Traits::eq(*__ps, __c)) | |
| 877 | return static_cast<_SizeT>(__ps - __p); | |
| 878 | } | |
| 879 | return __npos; | |
| 880 | } | |
| 881 | ||
| 882 | ||
| 883 | // __str_find_last_not_of | |
| 884 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 885 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 886 | __str_find_last_not_of(const _CharT *__p, _SizeT __sz, | |
| 887 | const _CharT* __s, _SizeT __pos, _SizeT __n) _NOEXCEPT | |
| 888 | { | |
| 889 | if (__pos < __sz) | |
| 890 | ++__pos; | |
| 891 | else | |
| 892 | __pos = __sz; | |
| 893 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 894 | if (_Traits::find(__s, __n, *--__ps) == nullptr) | |
| 895 | return static_cast<_SizeT>(__ps - __p); | |
| 896 | return __npos; | |
| 897 | } | |
| 898 | ||
| 899 | ||
| 900 | template<class _CharT, class _SizeT, class _Traits, _SizeT __npos> | |
| 901 | inline _SizeT _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY | |
| 902 | __str_find_last_not_of(const _CharT *__p, _SizeT __sz, | |
| 903 | _CharT __c, _SizeT __pos) _NOEXCEPT | |
| 904 | { | |
| 905 | if (__pos < __sz) | |
| 906 | ++__pos; | |
| 907 | else | |
| 908 | __pos = __sz; | |
| 909 | for (const _CharT* __ps = __p + __pos; __ps != __p;) | |
| 910 | if (!_Traits::eq(*--__ps, __c)) | |
| 911 | return static_cast<_SizeT>(__ps - __p); | |
| 912 | return __npos; | |
| 913 | } | |
| 914 | ||
| 915 | template<class _Ptr> | |
| 916 | inline _LIBCPP_INLINE_VISIBILITY | |
| 917 | size_t __do_string_hash(_Ptr __p, _Ptr __e) | |
| 918 | { | |
| 919 | typedef typename iterator_traits<_Ptr>::value_type value_type; | |
| 920 | return __murmur2_or_cityhash<size_t>()(__p, (__e-__p)*sizeof(value_type)); | |
| 921 | } | |
| 922 | ||
| 923 | _LIBCPP_END_NAMESPACE_STD | |
| 924 | ||
| 925 | _LIBCPP_POP_MACROS | |
| 926 | ||
| 927 | #endif // _LIBCPP___STRING_CHAR_TRAITS_H |
lib/libcxx/include/__string/extern_template_lists.h created+131| ... | ... | @@ -0,0 +1,131 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H | |
| 10 | #define _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | // We maintain 2 ABI lists: | |
| 19 | // - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST | |
| 20 | // - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST | |
| 21 | // As the name implies, the ABI lists define the V1 (Stable) and unstable ABI. | |
| 22 | // | |
| 23 | // For unstable, we may explicitly remove function that are external in V1, | |
| 24 | // and add (new) external functions to better control inlining and compiler | |
| 25 | // optimization opportunities. | |
| 26 | // | |
| 27 | // For stable, the ABI list should rarely change, except for adding new | |
| 28 | // functions supporting new c++ version / API changes. Typically entries | |
| 29 | // must never be removed from the stable list. | |
| 30 | #define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | |
| 31 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | |
| 32 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | |
| 33 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | |
| 34 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&)) \ | |
| 35 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | |
| 36 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \ | |
| 37 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | |
| 38 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ | |
| 39 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | |
| 40 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | |
| 41 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | |
| 42 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ | |
| 43 | _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ | |
| 44 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | |
| 45 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | |
| 46 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | |
| 47 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \ | |
| 48 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ | |
| 49 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | |
| 50 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | |
| 51 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | |
| 52 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ | |
| 53 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | |
| 54 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ | |
| 55 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | |
| 56 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | |
| 57 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | |
| 58 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | |
| 59 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ | |
| 60 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | |
| 61 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | |
| 62 | _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | |
| 63 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | |
| 64 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \ | |
| 65 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | |
| 66 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ | |
| 67 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | |
| 68 | _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ | |
| 69 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \ | |
| 70 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | |
| 71 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | |
| 72 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | |
| 73 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \ | |
| 74 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | |
| 75 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | |
| 76 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | |
| 77 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ | |
| 78 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | |
| 79 | ||
| 80 | #define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \ | |
| 81 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \ | |
| 82 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \ | |
| 83 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \ | |
| 84 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \ | |
| 85 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \ | |
| 86 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::~basic_string()) \ | |
| 87 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \ | |
| 88 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \ | |
| 89 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \ | |
| 90 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(value_type const*, size_type)) \ | |
| 91 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \ | |
| 92 | _Func(_LIBCPP_FUNC_VIS const _CharType& basic_string<_CharType>::at(size_type) const) \ | |
| 93 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \ | |
| 94 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \ | |
| 95 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \ | |
| 96 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \ | |
| 97 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \ | |
| 98 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::reserve(size_type)) \ | |
| 99 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \ | |
| 100 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \ | |
| 101 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \ | |
| 102 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \ | |
| 103 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \ | |
| 104 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__init(size_type, value_type)) \ | |
| 105 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \ | |
| 106 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \ | |
| 107 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \ | |
| 108 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \ | |
| 109 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \ | |
| 110 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \ | |
| 111 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::push_back(value_type)) \ | |
| 112 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \ | |
| 113 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \ | |
| 114 | _Func(_LIBCPP_FUNC_VIS const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \ | |
| 115 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \ | |
| 116 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \ | |
| 117 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \ | |
| 118 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(value_type const*) const) \ | |
| 119 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \ | |
| 120 | _Func(_LIBCPP_FUNC_VIS _CharType& basic_string<_CharType>::at(size_type)) \ | |
| 121 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \ | |
| 122 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \ | |
| 123 | _Func(_LIBCPP_FUNC_VIS int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \ | |
| 124 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \ | |
| 125 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \ | |
| 126 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \ | |
| 127 | _Func(_LIBCPP_FUNC_VIS void basic_string<_CharType>::resize(size_type, value_type)) \ | |
| 128 | _Func(_LIBCPP_FUNC_VIS basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type)) | |
| 129 | ||
| 130 | ||
| 131 | #endif // _LIBCPP___STRING_EXTERN_TEMPLATE_LISTS_H |
lib/libcxx/include/__support/android/locale_bionic.h+13-7| ... | ... | @@ -26,10 +26,15 @@ extern "C" { |
| 26 | 26 | #if defined(__ANDROID__) |
| 27 | 27 | |
| 28 | 28 | #include <android/api-level.h> |
| 29 | #include <android/ndk-version.h> | |
| 30 | 29 | #if __ANDROID_API__ < 21 |
| 31 | 30 | #include <__support/xlocale/__posix_l_fallback.h> |
| 32 | 31 | #endif |
| 32 | ||
| 33 | // If we do not have this header, we are in a platform build rather than an NDK | |
| 34 | // build, which will always be at least as new as the ToT NDK, in which case we | |
| 35 | // don't need any of the inlines below since libc provides them. | |
| 36 | #if __has_include(<android/ndk-version.h>) | |
| 37 | #include <android/ndk-version.h> | |
| 33 | 38 | // In NDK versions later than 16, locale-aware functions are provided by |
| 34 | 39 | // legacy_stdlib_inlines.h |
| 35 | 40 | #if __NDK_MAJOR__ <= 16 |
| ... | ... | @@ -41,18 +46,18 @@ extern "C" { |
| 41 | 46 | extern "C" { |
| 42 | 47 | #endif |
| 43 | 48 | |
| 44 | inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char* __nptr, char** __endptr, | |
| 45 | locale_t) { | |
| 49 | inline _LIBCPP_HIDE_FROM_ABI float | |
| 50 | strtof_l(const char* __nptr, char** __endptr, locale_t) { | |
| 46 | 51 | return ::strtof(__nptr, __endptr); |
| 47 | 52 | } |
| 48 | 53 | |
| 49 | inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char* __nptr, | |
| 50 | char** __endptr, locale_t) { | |
| 54 | inline _LIBCPP_HIDE_FROM_ABI double | |
| 55 | strtod_l(const char* __nptr, char** __endptr, locale_t) { | |
| 51 | 56 | return ::strtod(__nptr, __endptr); |
| 52 | 57 | } |
| 53 | 58 | |
| 54 | inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endptr, | |
| 55 | int __base, locale_t) { | |
| 59 | inline _LIBCPP_HIDE_FROM_ABI long | |
| 60 | strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) { | |
| 56 | 61 | return ::strtol(__nptr, __endptr, __base); |
| 57 | 62 | } |
| 58 | 63 | |
| ... | ... | @@ -63,6 +68,7 @@ inline _LIBCPP_INLINE_VISIBILITY long strtol_l(const char* __nptr, char** __endp |
| 63 | 68 | #endif // __ANDROID_API__ < 26 |
| 64 | 69 | |
| 65 | 70 | #endif // __NDK_MAJOR__ <= 16 |
| 71 | #endif // __has_include(<android/ndk-version.h>) | |
| 66 | 72 | #endif // defined(__ANDROID__) |
| 67 | 73 | |
| 68 | 74 | #endif // defined(__BIONIC__) |
lib/libcxx/include/__support/ibm/gettod_zos.h+2-1| ... | ... | @@ -12,7 +12,8 @@ |
| 12 | 12 | |
| 13 | 13 | #include <time.h> |
| 14 | 14 | |
| 15 | static inline int gettimeofdayMonotonic(struct timespec64* Output) { | |
| 15 | inline _LIBCPP_HIDE_FROM_ABI int | |
| 16 | gettimeofdayMonotonic(struct timespec64* Output) { | |
| 16 | 17 | |
| 17 | 18 | // The POSIX gettimeofday() function is not available on z/OS. Therefore, |
| 18 | 19 | // we will call stcke and other hardware instructions in implement equivalent. |
lib/libcxx/include/__support/ibm/limits.h deleted-98| ... | ... | @@ -1,98 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===-----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H | |
| 11 | #define _LIBCPP_SUPPORT_IBM_LIMITS_H | |
| 12 | ||
| 13 | #if !defined(_AIX) // Linux | |
| 14 | #include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN | |
| 15 | ||
| 16 | static const unsigned int _QNAN_F = 0x7fc00000; | |
| 17 | #define NANF (*((float *)(&_QNAN_F))) | |
| 18 | static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0}; | |
| 19 | #define NANL (*((long double *)(&_QNAN_LDBL128))) | |
| 20 | static const unsigned int _SNAN_F= 0x7f855555; | |
| 21 | #define NANSF (*((float *)(&_SNAN_F))) | |
| 22 | static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555}; | |
| 23 | #define NANS (*((double *)(&_SNAN_D))) | |
| 24 | static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0}; | |
| 25 | #define NANSL (*((long double *)(&_SNAN_LDBL128))) | |
| 26 | ||
| 27 | #define __builtin_huge_val() HUGE_VAL | |
| 28 | #define __builtin_huge_valf() HUGE_VALF | |
| 29 | #define __builtin_huge_vall() HUGE_VALL | |
| 30 | #define __builtin_nan(__dummy) NAN | |
| 31 | #define __builtin_nanf(__dummy) NANF | |
| 32 | #define __builtin_nanl(__dummy) NANL | |
| 33 | #define __builtin_nans(__dummy) NANS | |
| 34 | #define __builtin_nansf(__dummy) NANSF | |
| 35 | #define __builtin_nansl(__dummy) NANSL | |
| 36 | ||
| 37 | #else | |
| 38 | ||
| 39 | #include <math.h> | |
| 40 | #include <float.h> // limit constants | |
| 41 | ||
| 42 | #define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000 | |
| 43 | #define __builtin_huge_valf() HUGE_VALF //0x7f800000 | |
| 44 | #define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000 | |
| 45 | #define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000 | |
| 46 | #define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000 | |
| 47 | #define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000 | |
| 48 | #define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555 | |
| 49 | #define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555 | |
| 50 | #define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555 | |
| 51 | ||
| 52 | #define __FLT_MANT_DIG__ FLT_MANT_DIG | |
| 53 | #define __FLT_DIG__ FLT_DIG | |
| 54 | #define __FLT_RADIX__ FLT_RADIX | |
| 55 | #define __FLT_MIN_EXP__ FLT_MIN_EXP | |
| 56 | #define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP | |
| 57 | #define __FLT_MAX_EXP__ FLT_MAX_EXP | |
| 58 | #define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP | |
| 59 | #define __FLT_MIN__ FLT_MIN | |
| 60 | #define __FLT_MAX__ FLT_MAX | |
| 61 | #define __FLT_EPSILON__ FLT_EPSILON | |
| 62 | // predefined by XLC on LoP | |
| 63 | #define __FLT_DENORM_MIN__ 1.40129846e-45F | |
| 64 | ||
| 65 | #define __DBL_MANT_DIG__ DBL_MANT_DIG | |
| 66 | #define __DBL_DIG__ DBL_DIG | |
| 67 | #define __DBL_MIN_EXP__ DBL_MIN_EXP | |
| 68 | #define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP | |
| 69 | #define __DBL_MAX_EXP__ DBL_MAX_EXP | |
| 70 | #define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP | |
| 71 | #define __DBL_MIN__ DBL_MIN | |
| 72 | #define __DBL_MAX__ DBL_MAX | |
| 73 | #define __DBL_EPSILON__ DBL_EPSILON | |
| 74 | // predefined by XLC on LoP | |
| 75 | #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 | |
| 76 | ||
| 77 | #define __LDBL_MANT_DIG__ LDBL_MANT_DIG | |
| 78 | #define __LDBL_DIG__ LDBL_DIG | |
| 79 | #define __LDBL_MIN_EXP__ LDBL_MIN_EXP | |
| 80 | #define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP | |
| 81 | #define __LDBL_MAX_EXP__ LDBL_MAX_EXP | |
| 82 | #define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP | |
| 83 | #define __LDBL_MIN__ LDBL_MIN | |
| 84 | #define __LDBL_MAX__ LDBL_MAX | |
| 85 | #define __LDBL_EPSILON__ LDBL_EPSILON | |
| 86 | // predefined by XLC on LoP | |
| 87 | #if __LONGDOUBLE128 | |
| 88 | #define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L | |
| 89 | #else | |
| 90 | #define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L | |
| 91 | #endif | |
| 92 | ||
| 93 | // predefined by XLC on LoP | |
| 94 | #define __CHAR_BIT__ 8 | |
| 95 | ||
| 96 | #endif // _AIX | |
| 97 | ||
| 98 | #endif // _LIBCPP_SUPPORT_IBM_LIMITS_H |
lib/libcxx/include/__support/ibm/support.h deleted-53| ... | ... | @@ -1,53 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===-----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H | |
| 11 | #define _LIBCPP_SUPPORT_IBM_SUPPORT_H | |
| 12 | ||
| 13 | extern "builtin" int __popcnt4(unsigned int); | |
| 14 | extern "builtin" int __popcnt8(unsigned long long); | |
| 15 | extern "builtin" unsigned int __cnttz4(unsigned int); | |
| 16 | extern "builtin" unsigned int __cnttz8(unsigned long long); | |
| 17 | extern "builtin" unsigned int __cntlz4(unsigned int); | |
| 18 | extern "builtin" unsigned int __cntlz8(unsigned long long); | |
| 19 | ||
| 20 | // Builtin functions for counting population | |
| 21 | #define __builtin_popcount(x) __popcnt4(x) | |
| 22 | #define __builtin_popcountll(x) __popcnt8(x) | |
| 23 | #if defined(__64BIT__) | |
| 24 | #define __builtin_popcountl(x) __builtin_popcountll(x) | |
| 25 | #else | |
| 26 | #define __builtin_popcountl(x) __builtin_popcount(x) | |
| 27 | #endif | |
| 28 | ||
| 29 | // Builtin functions for counting trailing zeros | |
| 30 | #define __builtin_ctz(x) __cnttz4(x) | |
| 31 | #define __builtin_ctzll(x) __cnttz8(x) | |
| 32 | #if defined(__64BIT__) | |
| 33 | #define __builtin_ctzl(x) __builtin_ctzll(x) | |
| 34 | #else | |
| 35 | #define __builtin_ctzl(x) __builtin_ctz(x) | |
| 36 | #endif | |
| 37 | ||
| 38 | // Builtin functions for counting leading zeros | |
| 39 | #define __builtin_clz(x) __cntlz4(x) | |
| 40 | #define __builtin_clzll(x) __cntlz8(x) | |
| 41 | #if defined(__64BIT__) | |
| 42 | #define __builtin_clzl(x) __builtin_clzll(x) | |
| 43 | #else | |
| 44 | #define __builtin_clzl(x) __builtin_clz(x) | |
| 45 | #endif | |
| 46 | ||
| 47 | #if defined(__64BIT__) | |
| 48 | #define __SIZE_WIDTH__ 64 | |
| 49 | #else | |
| 50 | #define __SIZE_WIDTH__ 32 | |
| 51 | #endif | |
| 52 | ||
| 53 | #endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H |
lib/libcxx/include/__support/ibm/xlocale.h+26-30| ... | ... | @@ -10,7 +10,10 @@ |
| 10 | 10 | #ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H |
| 11 | 11 | #define _LIBCPP_SUPPORT_IBM_XLOCALE_H |
| 12 | 12 | |
| 13 | #if defined(__MVS__) | |
| 13 | 14 | #include <__support/ibm/locale_mgmt_zos.h> |
| 15 | #endif // defined(__MVS__) | |
| 16 | ||
| 14 | 17 | #include <stdarg.h> |
| 15 | 18 | |
| 16 | 19 | #include "cstdlib" |
| ... | ... | @@ -52,57 +55,50 @@ private: |
| 52 | 55 | |
| 53 | 56 | // The following are not POSIX routines. These are quick-and-dirty hacks |
| 54 | 57 | // to make things pretend to work |
| 55 | static inline | |
| 56 | long long strtoll_l(const char *__nptr, char **__endptr, | |
| 57 | int __base, locale_t locale) { | |
| 58 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 59 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { | |
| 58 | 60 | __setAndRestore __newloc(locale); |
| 59 | return strtoll(__nptr, __endptr, __base); | |
| 61 | return ::strtoll(__nptr, __endptr, __base); | |
| 60 | 62 | } |
| 61 | 63 | |
| 62 | static inline | |
| 63 | long strtol_l(const char *__nptr, char **__endptr, | |
| 64 | int __base, locale_t locale) { | |
| 64 | inline _LIBCPP_HIDE_FROM_ABI long | |
| 65 | strtol_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { | |
| 65 | 66 | __setAndRestore __newloc(locale); |
| 66 | return strtol(__nptr, __endptr, __base); | |
| 67 | return ::strtol(__nptr, __endptr, __base); | |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | static inline | |
| 70 | double strtod_l(const char *__nptr, char **__endptr, | |
| 71 | locale_t locale) { | |
| 70 | inline _LIBCPP_HIDE_FROM_ABI double | |
| 71 | strtod_l(const char *__nptr, char **__endptr, locale_t locale) { | |
| 72 | 72 | __setAndRestore __newloc(locale); |
| 73 | return strtod(__nptr, __endptr); | |
| 73 | return ::strtod(__nptr, __endptr); | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | static inline | |
| 77 | float strtof_l(const char *__nptr, char **__endptr, | |
| 78 | locale_t locale) { | |
| 76 | inline _LIBCPP_HIDE_FROM_ABI float | |
| 77 | strtof_l(const char *__nptr, char **__endptr, locale_t locale) { | |
| 79 | 78 | __setAndRestore __newloc(locale); |
| 80 | return strtof(__nptr, __endptr); | |
| 79 | return ::strtof(__nptr, __endptr); | |
| 81 | 80 | } |
| 82 | 81 | |
| 83 | static inline | |
| 84 | long double strtold_l(const char *__nptr, char **__endptr, | |
| 85 | locale_t locale) { | |
| 82 | inline _LIBCPP_HIDE_FROM_ABI long double | |
| 83 | strtold_l(const char *__nptr, char **__endptr, locale_t locale) { | |
| 86 | 84 | __setAndRestore __newloc(locale); |
| 87 | return strtold(__nptr, __endptr); | |
| 85 | return ::strtold(__nptr, __endptr); | |
| 88 | 86 | } |
| 89 | 87 | |
| 90 | static inline | |
| 91 | unsigned long long strtoull_l(const char *__nptr, char **__endptr, | |
| 92 | int __base, locale_t locale) { | |
| 88 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 89 | strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { | |
| 93 | 90 | __setAndRestore __newloc(locale); |
| 94 | return strtoull(__nptr, __endptr, __base); | |
| 91 | return ::strtoull(__nptr, __endptr, __base); | |
| 95 | 92 | } |
| 96 | 93 | |
| 97 | static inline | |
| 98 | unsigned long strtoul_l(const char *__nptr, char **__endptr, | |
| 99 | int __base, locale_t locale) { | |
| 94 | inline _LIBCPP_HIDE_FROM_ABI unsigned long | |
| 95 | strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { | |
| 100 | 96 | __setAndRestore __newloc(locale); |
| 101 | return strtoul(__nptr, __endptr, __base); | |
| 97 | return ::strtoul(__nptr, __endptr, __base); | |
| 102 | 98 | } |
| 103 | 99 | |
| 104 | static inline | |
| 105 | int vasprintf(char **strp, const char *fmt, va_list ap) { | |
| 100 | inline _LIBCPP_HIDE_FROM_ABI int | |
| 101 | vasprintf(char **strp, const char *fmt, va_list ap) { | |
| 106 | 102 | const size_t buff_size = 256; |
| 107 | 103 | if ((*strp = (char *)malloc(buff_size)) == NULL) { |
| 108 | 104 | return -1; |
lib/libcxx/include/__support/musl/xlocale.h+15-16| ... | ... | @@ -24,30 +24,29 @@ |
| 24 | 24 | extern "C" { |
| 25 | 25 | #endif |
| 26 | 26 | |
| 27 | static inline long long strtoll_l(const char *nptr, char **endptr, int base, | |
| 28 | locale_t) { | |
| 29 | return strtoll(nptr, endptr, base); | |
| 27 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 28 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) { | |
| 29 | return ::strtoll(__nptr, __endptr, __base); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | static inline unsigned long long strtoull_l(const char *nptr, char **endptr, | |
| 33 | int base, locale_t) { | |
| 34 | return strtoull(nptr, endptr, base); | |
| 32 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 33 | strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) { | |
| 34 | return ::strtoull(__nptr, __endptr, __base); | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, | |
| 38 | int base, locale_t) { | |
| 39 | return wcstoll(nptr, endptr, base); | |
| 37 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 38 | wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) { | |
| 39 | return ::wcstoll(__nptr, __endptr, __base); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | static inline unsigned long long wcstoull_l(const wchar_t *nptr, | |
| 43 | wchar_t **endptr, int base, | |
| 44 | locale_t) { | |
| 45 | return wcstoull(nptr, endptr, base); | |
| 42 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 43 | wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) { | |
| 44 | return ::wcstoull(__nptr, __endptr, __base); | |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr, | |
| 49 | locale_t) { | |
| 50 | return wcstold(nptr, endptr); | |
| 47 | inline _LIBCPP_HIDE_FROM_ABI long double | |
| 48 | wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) { | |
| 49 | return ::wcstold(__nptr, __endptr); | |
| 51 | 50 | } |
| 52 | 51 | |
| 53 | 52 | #ifdef __cplusplus |
lib/libcxx/include/__support/openbsd/xlocale.h+4-4| ... | ... | @@ -22,13 +22,13 @@ extern "C" { |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 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); | |
| 25 | strtol_l(const char *__nptr, char **__endptr, int __base, locale_t) { | |
| 26 | return ::strtol(__nptr, __endptr, __base); | |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 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); | |
| 30 | strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t) { | |
| 31 | return ::strtoul(__nptr, __endptr, __base); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 |
lib/libcxx/include/__support/solaris/xlocale.h+27-28| ... | ... | @@ -32,40 +32,39 @@ struct lconv *localeconv(void); |
| 32 | 32 | struct lconv *localeconv_l(locale_t __l); |
| 33 | 33 | |
| 34 | 34 | // FIXME: These are quick-and-dirty hacks to make things pretend to work |
| 35 | static inline | |
| 36 | long long strtoll_l(const char *__nptr, char **__endptr, | |
| 37 | int __base, locale_t __loc) { | |
| 38 | return strtoll(__nptr, __endptr, __base); | |
| 35 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 36 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { | |
| 37 | return ::strtoll(__nptr, __endptr, __base); | |
| 39 | 38 | } |
| 40 | static inline | |
| 41 | long strtol_l(const char *__nptr, char **__endptr, | |
| 42 | int __base, locale_t __loc) { | |
| 43 | return strtol(__nptr, __endptr, __base); | |
| 39 | ||
| 40 | inline _LIBCPP_HIDE_FROM_ABI long | |
| 41 | strtol_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { | |
| 42 | return ::strtol(__nptr, __endptr, __base); | |
| 44 | 43 | } |
| 45 | static inline | |
| 46 | unsigned long long strtoull_l(const char *__nptr, char **__endptr, | |
| 47 | int __base, locale_t __loc) { | |
| 48 | return strtoull(__nptr, __endptr, __base); | |
| 44 | ||
| 45 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 46 | strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) | |
| 47 | return ::strtoull(__nptr, __endptr, __base); | |
| 49 | 48 | } |
| 50 | static inline | |
| 51 | unsigned long strtoul_l(const char *__nptr, char **__endptr, | |
| 52 | int __base, locale_t __loc) { | |
| 53 | return strtoul(__nptr, __endptr, __base); | |
| 49 | ||
| 50 | inline _LIBCPP_HIDE_FROM_ABI unsigned long | |
| 51 | strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { | |
| 52 | return ::strtoul(__nptr, __endptr, __base); | |
| 54 | 53 | } |
| 55 | static inline | |
| 56 | float strtof_l(const char *__nptr, char **__endptr, | |
| 57 | locale_t __loc) { | |
| 58 | return strtof(__nptr, __endptr); | |
| 54 | ||
| 55 | inline _LIBCPP_HIDE_FROM_ABI float | |
| 56 | strtof_l(const char *__nptr, char **__endptr, locale_t __loc) { | |
| 57 | return ::strtof(__nptr, __endptr); | |
| 59 | 58 | } |
| 60 | static inline | |
| 61 | double strtod_l(const char *__nptr, char **__endptr, | |
| 62 | locale_t __loc) { | |
| 63 | return strtod(__nptr, __endptr); | |
| 59 | ||
| 60 | inline _LIBCPP_HIDE_FROM_ABI double | |
| 61 | strtod_l(const char *__nptr, char **__endptr, locale_t __loc) { | |
| 62 | return ::strtod(__nptr, __endptr); | |
| 64 | 63 | } |
| 65 | static inline | |
| 66 | long double strtold_l(const char *__nptr, char **__endptr, | |
| 67 | locale_t __loc) { | |
| 68 | return strtold(__nptr, __endptr); | |
| 64 | ||
| 65 | inline _LIBCPP_HIDE_FROM_ABI long double | |
| 66 | strtold_l(const char *__nptr, char **__endptr, locale_t __loc) { | |
| 67 | return ::strtold(__nptr, __endptr); | |
| 69 | 68 | } |
| 70 | 69 | |
| 71 | 70 |
lib/libcxx/include/__support/win32/locale_win32.h+30-32| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | #define _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <__nullptr> | |
| 14 | #include <cstddef> | |
| 15 | 15 | #include <locale.h> // _locale_t |
| 16 | 16 | #include <stdio.h> |
| 17 | 17 | |
| ... | ... | @@ -186,28 +186,28 @@ private: |
| 186 | 186 | // Locale management functions |
| 187 | 187 | #define freelocale _free_locale |
| 188 | 188 | // FIXME: base currently unused. Needs manual work to construct the new locale |
| 189 | locale_t newlocale( int mask, const char * locale, locale_t base ); | |
| 189 | locale_t newlocale( int __mask, const char * __locale, locale_t __base ); | |
| 190 | 190 | // uselocale can't be implemented on Windows because Windows allows partial modification |
| 191 | 191 | // of thread-local locale and so _get_current_locale() returns a copy while uselocale does |
| 192 | 192 | // not create any copies. |
| 193 | 193 | // We can still implement raii even without uselocale though. |
| 194 | 194 | |
| 195 | 195 | |
| 196 | lconv *localeconv_l( locale_t &loc ); | |
| 197 | size_t mbrlen_l( const char *__restrict s, size_t n, | |
| 198 | mbstate_t *__restrict ps, locale_t loc); | |
| 199 | size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, | |
| 200 | size_t len, mbstate_t *__restrict ps, locale_t loc ); | |
| 201 | size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps, | |
| 202 | locale_t loc); | |
| 203 | size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s, | |
| 204 | size_t n, mbstate_t *__restrict ps, locale_t loc); | |
| 205 | size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, | |
| 206 | size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc); | |
| 207 | size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src, | |
| 208 | size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc); | |
| 209 | wint_t btowc_l( int c, locale_t loc ); | |
| 210 | int wctob_l( wint_t c, locale_t loc ); | |
| 196 | lconv *localeconv_l( locale_t & __loc ); | |
| 197 | size_t mbrlen_l( const char *__restrict __s, size_t __n, | |
| 198 | mbstate_t *__restrict __ps, locale_t __loc); | |
| 199 | size_t mbsrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src, | |
| 200 | size_t __len, mbstate_t *__restrict __ps, locale_t __loc ); | |
| 201 | size_t wcrtomb_l( char *__restrict __s, wchar_t __wc, mbstate_t *__restrict __ps, | |
| 202 | locale_t __loc); | |
| 203 | size_t mbrtowc_l( wchar_t *__restrict __pwc, const char *__restrict __s, | |
| 204 | size_t __n, mbstate_t *__restrict __ps, locale_t __loc); | |
| 205 | size_t mbsnrtowcs_l( wchar_t *__restrict __dst, const char **__restrict __src, | |
| 206 | size_t __nms, size_t __len, mbstate_t *__restrict __ps, locale_t __loc); | |
| 207 | size_t wcsnrtombs_l( char *__restrict __dst, const wchar_t **__restrict __src, | |
| 208 | size_t __nwc, size_t __len, mbstate_t *__restrict __ps, locale_t __loc); | |
| 209 | wint_t btowc_l( int __c, locale_t __loc ); | |
| 210 | int wctob_l( wint_t __c, locale_t __loc ); | |
| 211 | 211 | |
| 212 | 212 | decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ); |
| 213 | 213 | |
| ... | ... | @@ -223,18 +223,16 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ); |
| 223 | 223 | _LIBCPP_FUNC_VIS float strtof_l(const char*, char**, locale_t); |
| 224 | 224 | _LIBCPP_FUNC_VIS long double strtold_l(const char*, char**, locale_t); |
| 225 | 225 | #endif |
| 226 | inline _LIBCPP_INLINE_VISIBILITY | |
| 227 | int | |
| 228 | islower_l(int c, _locale_t loc) | |
| 226 | inline _LIBCPP_HIDE_FROM_ABI int | |
| 227 | islower_l(int __c, _locale_t __loc) | |
| 229 | 228 | { |
| 230 | return _islower_l((int)c, loc); | |
| 229 | return _islower_l((int)__c, __loc); | |
| 231 | 230 | } |
| 232 | 231 | |
| 233 | inline _LIBCPP_INLINE_VISIBILITY | |
| 234 | int | |
| 235 | isupper_l(int c, _locale_t loc) | |
| 232 | inline _LIBCPP_HIDE_FROM_ABI int | |
| 233 | isupper_l(int __c, _locale_t __loc) | |
| 236 | 234 | { |
| 237 | return _isupper_l((int)c, loc); | |
| 235 | return _isupper_l((int)__c, __loc); | |
| 238 | 236 | } |
| 239 | 237 | |
| 240 | 238 | #define isdigit_l _isdigit_l |
| ... | ... | @@ -266,18 +264,18 @@ _LIBCPP_FUNC_VIS size_t strftime_l(char *ret, size_t n, const char *format, |
| 266 | 264 | #define sprintf_l( __s, __l, __f, ... ) _sprintf_l( __s, __f, __l, __VA_ARGS__ ) |
| 267 | 265 | #define vsprintf_l( __s, __l, __f, ... ) _vsprintf_l( __s, __f, __l, __VA_ARGS__ ) |
| 268 | 266 | #define vsnprintf_l( __s, __n, __l, __f, ... ) _vsnprintf_l( __s, __n, __f, __l, __VA_ARGS__ ) |
| 269 | _LIBCPP_FUNC_VIS int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...); | |
| 270 | _LIBCPP_FUNC_VIS int asprintf_l( char **ret, locale_t loc, const char *format, ... ); | |
| 271 | _LIBCPP_FUNC_VIS int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap ); | |
| 267 | _LIBCPP_FUNC_VIS int snprintf_l(char *__ret, size_t __n, locale_t __loc, const char *__format, ...); | |
| 268 | _LIBCPP_FUNC_VIS int asprintf_l( char **__ret, locale_t __loc, const char *__format, ... ); | |
| 269 | _LIBCPP_FUNC_VIS int vasprintf_l( char **__ret, locale_t __loc, const char *__format, va_list __ap ); | |
| 272 | 270 | |
| 273 | 271 | // not-so-pressing FIXME: use locale to determine blank characters |
| 274 | inline int isblank_l( int c, locale_t /*loc*/ ) | |
| 272 | inline int isblank_l( int __c, locale_t /*loc*/ ) | |
| 275 | 273 | { |
| 276 | return ( c == ' ' || c == '\t' ); | |
| 274 | return ( __c == ' ' || __c == '\t' ); | |
| 277 | 275 | } |
| 278 | inline int iswblank_l( wint_t c, locale_t /*loc*/ ) | |
| 276 | inline int iswblank_l( wint_t __c, locale_t /*loc*/ ) | |
| 279 | 277 | { |
| 280 | return ( c == L' ' || c == L'\t' ); | |
| 278 | return ( __c == L' ' || __c == L'\t' ); | |
| 281 | 279 | } |
| 282 | 280 | |
| 283 | 281 | #endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H |
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+9-4| ... | ... | @@ -16,18 +16,23 @@ extern "C" { |
| 16 | 16 | |
| 17 | 17 | // Patch over lack of extended locale support |
| 18 | 18 | typedef void *locale_t; |
| 19 | static inline locale_t duplocale(locale_t) { | |
| 19 | ||
| 20 | inline _LIBCPP_HIDE_FROM_ABI locale_t | |
| 21 | duplocale(locale_t) { | |
| 20 | 22 | return NULL; |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | static inline void freelocale(locale_t) { | |
| 25 | inline _LIBCPP_HIDE_FROM_ABI void | |
| 26 | freelocale(locale_t) { | |
| 24 | 27 | } |
| 25 | 28 | |
| 26 | static inline locale_t newlocale(int, const char *, locale_t) { | |
| 29 | inline _LIBCPP_HIDE_FROM_ABI locale_t | |
| 30 | newlocale(int, const char *, locale_t) { | |
| 27 | 31 | return NULL; |
| 28 | 32 | } |
| 29 | 33 | |
| 30 | static inline locale_t uselocale(locale_t) { | |
| 34 | inline _LIBCPP_HIDE_FROM_ABI locale_t | |
| 35 | uselocale(locale_t) { | |
| 31 | 36 | return NULL; |
| 32 | 37 | } |
| 33 | 38 |
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+72-72| ... | ... | @@ -19,142 +19,142 @@ |
| 19 | 19 | extern "C" { |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | inline _LIBCPP_INLINE_VISIBILITY int isalnum_l(int c, locale_t) { | |
| 23 | return ::isalnum(c); | |
| 22 | inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { | |
| 23 | return ::isalnum(__c); | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | inline _LIBCPP_INLINE_VISIBILITY int isalpha_l(int c, locale_t) { | |
| 27 | return ::isalpha(c); | |
| 26 | inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) { | |
| 27 | return ::isalpha(__c); | |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | inline _LIBCPP_INLINE_VISIBILITY int isblank_l(int c, locale_t) { | |
| 31 | return ::isblank(c); | |
| 30 | inline _LIBCPP_HIDE_FROM_ABI int isblank_l(int __c, locale_t) { | |
| 31 | return ::isblank(__c); | |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | inline _LIBCPP_INLINE_VISIBILITY int iscntrl_l(int c, locale_t) { | |
| 35 | return ::iscntrl(c); | |
| 34 | inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { | |
| 35 | return ::iscntrl(__c); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | inline _LIBCPP_INLINE_VISIBILITY int isdigit_l(int c, locale_t) { | |
| 39 | return ::isdigit(c); | |
| 38 | inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { | |
| 39 | return ::isdigit(__c); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | inline _LIBCPP_INLINE_VISIBILITY int isgraph_l(int c, locale_t) { | |
| 43 | return ::isgraph(c); | |
| 42 | inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) { | |
| 43 | return ::isgraph(__c); | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, locale_t) { | |
| 47 | return ::islower(c); | |
| 46 | inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) { | |
| 47 | return ::islower(__c); | |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | inline _LIBCPP_INLINE_VISIBILITY int isprint_l(int c, locale_t) { | |
| 51 | return ::isprint(c); | |
| 50 | inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) { | |
| 51 | return ::isprint(__c); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | inline _LIBCPP_INLINE_VISIBILITY int ispunct_l(int c, locale_t) { | |
| 55 | return ::ispunct(c); | |
| 54 | inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) { | |
| 55 | return ::ispunct(__c); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | inline _LIBCPP_INLINE_VISIBILITY int isspace_l(int c, locale_t) { | |
| 59 | return ::isspace(c); | |
| 58 | inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) { | |
| 59 | return ::isspace(__c); | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | inline _LIBCPP_INLINE_VISIBILITY int isupper_l(int c, locale_t) { | |
| 63 | return ::isupper(c); | |
| 62 | inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) { | |
| 63 | return ::isupper(__c); | |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | inline _LIBCPP_INLINE_VISIBILITY int isxdigit_l(int c, locale_t) { | |
| 67 | return ::isxdigit(c); | |
| 66 | inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) { | |
| 67 | return ::isxdigit(__c); | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | inline _LIBCPP_INLINE_VISIBILITY int iswalnum_l(wint_t c, locale_t) { | |
| 71 | return ::iswalnum(c); | |
| 70 | inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) { | |
| 71 | return ::iswalnum(__c); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | inline _LIBCPP_INLINE_VISIBILITY int iswalpha_l(wint_t c, locale_t) { | |
| 75 | return ::iswalpha(c); | |
| 74 | inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) { | |
| 75 | return ::iswalpha(__c); | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | inline _LIBCPP_INLINE_VISIBILITY int iswblank_l(wint_t c, locale_t) { | |
| 79 | return ::iswblank(c); | |
| 78 | inline _LIBCPP_HIDE_FROM_ABI int iswblank_l(wint_t __c, locale_t) { | |
| 79 | return ::iswblank(__c); | |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) { | |
| 83 | return ::iswcntrl(c); | |
| 82 | inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) { | |
| 83 | return ::iswcntrl(__c); | |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | inline _LIBCPP_INLINE_VISIBILITY int iswdigit_l(wint_t c, locale_t) { | |
| 87 | return ::iswdigit(c); | |
| 86 | inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) { | |
| 87 | return ::iswdigit(__c); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | inline _LIBCPP_INLINE_VISIBILITY int iswgraph_l(wint_t c, locale_t) { | |
| 91 | return ::iswgraph(c); | |
| 90 | inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) { | |
| 91 | return ::iswgraph(__c); | |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | inline _LIBCPP_INLINE_VISIBILITY int iswlower_l(wint_t c, locale_t) { | |
| 95 | return ::iswlower(c); | |
| 94 | inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) { | |
| 95 | return ::iswlower(__c); | |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | inline _LIBCPP_INLINE_VISIBILITY int iswprint_l(wint_t c, locale_t) { | |
| 99 | return ::iswprint(c); | |
| 98 | inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) { | |
| 99 | return ::iswprint(__c); | |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | inline _LIBCPP_INLINE_VISIBILITY int iswpunct_l(wint_t c, locale_t) { | |
| 103 | return ::iswpunct(c); | |
| 102 | inline _LIBCPP_HIDE_FROM_ABI int iswpunct_l(wint_t __c, locale_t) { | |
| 103 | return ::iswpunct(__c); | |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | inline _LIBCPP_INLINE_VISIBILITY int iswspace_l(wint_t c, locale_t) { | |
| 107 | return ::iswspace(c); | |
| 106 | inline _LIBCPP_HIDE_FROM_ABI int iswspace_l(wint_t __c, locale_t) { | |
| 107 | return ::iswspace(__c); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | inline _LIBCPP_INLINE_VISIBILITY int iswupper_l(wint_t c, locale_t) { | |
| 111 | return ::iswupper(c); | |
| 110 | inline _LIBCPP_HIDE_FROM_ABI int iswupper_l(wint_t __c, locale_t) { | |
| 111 | return ::iswupper(__c); | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | inline _LIBCPP_INLINE_VISIBILITY int iswxdigit_l(wint_t c, locale_t) { | |
| 115 | return ::iswxdigit(c); | |
| 114 | inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) { | |
| 115 | return ::iswxdigit(__c); | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | inline _LIBCPP_INLINE_VISIBILITY int toupper_l(int c, locale_t) { | |
| 119 | return ::toupper(c); | |
| 118 | inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) { | |
| 119 | return ::toupper(__c); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | inline _LIBCPP_INLINE_VISIBILITY int tolower_l(int c, locale_t) { | |
| 123 | return ::tolower(c); | |
| 122 | inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) { | |
| 123 | return ::tolower(__c); | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | inline _LIBCPP_INLINE_VISIBILITY wint_t towupper_l(wint_t c, locale_t) { | |
| 127 | return ::towupper(c); | |
| 126 | inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) { | |
| 127 | return ::towupper(__c); | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | inline _LIBCPP_INLINE_VISIBILITY wint_t towlower_l(wint_t c, locale_t) { | |
| 131 | return ::towlower(c); | |
| 130 | inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) { | |
| 131 | return ::towlower(__c); | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | inline _LIBCPP_INLINE_VISIBILITY int strcoll_l(const char *s1, const char *s2, | |
| 135 | locale_t) { | |
| 136 | return ::strcoll(s1, s2); | |
| 134 | inline _LIBCPP_HIDE_FROM_ABI int | |
| 135 | strcoll_l(const char *__s1, const char *__s2, locale_t) { | |
| 136 | return ::strcoll(__s1, __s2); | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | inline _LIBCPP_INLINE_VISIBILITY size_t strxfrm_l(char *dest, const char *src, | |
| 140 | size_t n, locale_t) { | |
| 141 | return ::strxfrm(dest, src, n); | |
| 139 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 140 | strxfrm_l(char *__dest, const char *__src, size_t __n, locale_t) { | |
| 141 | return ::strxfrm(__dest, __src, __n); | |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | inline _LIBCPP_INLINE_VISIBILITY size_t strftime_l(char *s, size_t max, | |
| 145 | const char *format, | |
| 146 | const struct tm *tm, locale_t) { | |
| 147 | return ::strftime(s, max, format, tm); | |
| 144 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 145 | strftime_l(char *__s, size_t __max, const char *__format, const struct tm *__tm, | |
| 146 | locale_t) { | |
| 147 | return ::strftime(__s, __max, __format, __tm); | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | inline _LIBCPP_INLINE_VISIBILITY int wcscoll_l(const wchar_t *ws1, | |
| 151 | const wchar_t *ws2, locale_t) { | |
| 152 | return ::wcscoll(ws1, ws2); | |
| 150 | inline _LIBCPP_HIDE_FROM_ABI int | |
| 151 | wcscoll_l(const wchar_t *__ws1, const wchar_t *__ws2, locale_t) { | |
| 152 | return ::wcscoll(__ws1, __ws2); | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | inline _LIBCPP_INLINE_VISIBILITY size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, | |
| 156 | size_t n, locale_t) { | |
| 157 | return ::wcsxfrm(dest, src, n); | |
| 155 | inline _LIBCPP_HIDE_FROM_ABI size_t | |
| 156 | wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, size_t __n, locale_t) { | |
| 157 | return ::wcsxfrm(__dest, __src, __n); | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | #ifdef __cplusplus |
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+24-24| ... | ... | @@ -19,44 +19,44 @@ |
| 19 | 19 | extern "C" { |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char *nptr, | |
| 23 | char **endptr, locale_t) { | |
| 24 | return ::strtof(nptr, endptr); | |
| 22 | inline _LIBCPP_HIDE_FROM_ABI float | |
| 23 | strtof_l(const char *__nptr, char **__endptr, locale_t) { | |
| 24 | return ::strtof(__nptr, __endptr); | |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char *nptr, | |
| 28 | char **endptr, locale_t) { | |
| 29 | return ::strtod(nptr, endptr); | |
| 27 | inline _LIBCPP_HIDE_FROM_ABI double | |
| 28 | strtod_l(const char *__nptr, char **__endptr, locale_t) { | |
| 29 | return ::strtod(__nptr, __endptr); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | inline _LIBCPP_INLINE_VISIBILITY long double strtold_l(const char *nptr, | |
| 33 | char **endptr, locale_t) { | |
| 34 | return ::strtold(nptr, endptr); | |
| 32 | inline _LIBCPP_HIDE_FROM_ABI long double | |
| 33 | strtold_l(const char *__nptr, char **__endptr, locale_t) { | |
| 34 | return ::strtold(__nptr, __endptr); | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | inline _LIBCPP_INLINE_VISIBILITY long long | |
| 38 | strtoll_l(const char *nptr, char **endptr, int base, locale_t) { | |
| 39 | return ::strtoll(nptr, endptr, base); | |
| 37 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 38 | strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) { | |
| 39 | return ::strtoll(__nptr, __endptr, __base); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | inline _LIBCPP_INLINE_VISIBILITY unsigned long long | |
| 43 | strtoull_l(const char *nptr, char **endptr, int base, locale_t) { | |
| 44 | return ::strtoull(nptr, endptr, base); | |
| 42 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 43 | strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) { | |
| 44 | return ::strtoull(__nptr, __endptr, __base); | |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | inline _LIBCPP_INLINE_VISIBILITY long long | |
| 48 | wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { | |
| 49 | return ::wcstoll(nptr, endptr, base); | |
| 47 | inline _LIBCPP_HIDE_FROM_ABI long long | |
| 48 | wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) { | |
| 49 | return ::wcstoll(__nptr, __endptr, __base); | |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | inline _LIBCPP_INLINE_VISIBILITY unsigned long long | |
| 53 | wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { | |
| 54 | return ::wcstoull(nptr, endptr, base); | |
| 52 | inline _LIBCPP_HIDE_FROM_ABI unsigned long long | |
| 53 | wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) { | |
| 54 | return ::wcstoull(__nptr, __endptr, __base); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | inline _LIBCPP_INLINE_VISIBILITY long double wcstold_l(const wchar_t *nptr, | |
| 58 | wchar_t **endptr, locale_t) { | |
| 59 | return ::wcstold(nptr, endptr); | |
| 57 | inline _LIBCPP_HIDE_FROM_ABI long double | |
| 58 | wcstold_l(const wchar_t *__nptr, wchar_t **__endptr, locale_t) { | |
| 59 | return ::wcstold(__nptr, __endptr); | |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | #ifdef __cplusplus |
lib/libcxx/include/__thread/poll_with_backoff.h+6-2| ... | ... | @@ -10,11 +10,15 @@ |
| 10 | 10 | #define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H |
| 11 | 11 | |
| 12 | 12 | #include <__availability> |
| 13 | #include <__chrono/duration.h> | |
| 14 | #include <__chrono/high_resolution_clock.h> | |
| 15 | #include <__chrono/steady_clock.h> | |
| 16 | #include <__chrono/time_point.h> | |
| 13 | 17 | #include <__config> |
| 14 | #include <chrono> | |
| 18 | #include <__filesystem/file_time_type.h> | |
| 15 | 19 | |
| 16 | 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 21 | # pragma GCC system_header | |
| 18 | 22 | #endif |
| 19 | 23 | |
| 20 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__thread/timed_backoff_policy.h+3-3| ... | ... | @@ -13,11 +13,11 @@ |
| 13 | 13 | |
| 14 | 14 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 15 | 15 | |
| 16 | #include <__threading_support> | |
| 17 | #include <chrono> | |
| 16 | # include <__chrono/duration.h> | |
| 17 | # include <__threading_support> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 20 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 21 | 21 | #endif |
| 22 | 22 | |
| 23 | 23 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__threading_support+17-16| ... | ... | @@ -7,13 +7,14 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | #ifndef _LIBCPP_THREADING_SUPPORT | |
| 11 | #define _LIBCPP_THREADING_SUPPORT | |
| 10 | #ifndef _LIBCPP___THREADING_SUPPORT | |
| 11 | #define _LIBCPP___THREADING_SUPPORT | |
| 12 | 12 | |
| 13 | 13 | #include <__availability> |
| 14 | #include <__chrono/convert_to_timespec.h> | |
| 15 | #include <__chrono/duration.h> | |
| 14 | 16 | #include <__config> |
| 15 | 17 | #include <__thread/poll_with_backoff.h> |
| 16 | #include <chrono> | |
| 17 | 18 | #include <errno.h> |
| 18 | 19 | #include <iosfwd> |
| 19 | 20 | #include <limits> |
| ... | ... | @@ -23,7 +24,7 @@ |
| 23 | 24 | #endif |
| 24 | 25 | |
| 25 | 26 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 26 | #pragma GCC system_header | |
| 27 | # pragma GCC system_header | |
| 27 | 28 | #endif |
| 28 | 29 | |
| 29 | 30 | #if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL) |
| ... | ... | @@ -200,15 +201,15 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv); |
| 200 | 201 | |
| 201 | 202 | // Execute once |
| 202 | 203 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 203 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, | |
| 204 | void (*init_routine)()); | |
| 204 | int __libcpp_execute_once(__libcpp_exec_once_flag *__flag, | |
| 205 | void (*__init_routine)()); | |
| 205 | 206 | |
| 206 | 207 | // Thread id |
| 207 | 208 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 208 | bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2); | |
| 209 | bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2); | |
| 209 | 210 | |
| 210 | 211 | _LIBCPP_THREAD_ABI_VISIBILITY |
| 211 | bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2); | |
| 212 | bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2); | |
| 212 | 213 | |
| 213 | 214 | // Thread |
| 214 | 215 | _LIBCPP_THREAD_ABI_VISIBILITY |
| ... | ... | @@ -346,22 +347,22 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv) |
| 346 | 347 | } |
| 347 | 348 | |
| 348 | 349 | // Execute once |
| 349 | int __libcpp_execute_once(__libcpp_exec_once_flag *flag, | |
| 350 | void (*init_routine)()) { | |
| 351 | return pthread_once(flag, init_routine); | |
| 350 | int __libcpp_execute_once(__libcpp_exec_once_flag *__flag, | |
| 351 | void (*__init_routine)()) { | |
| 352 | return pthread_once(__flag, __init_routine); | |
| 352 | 353 | } |
| 353 | 354 | |
| 354 | 355 | // Thread id |
| 355 | 356 | // Returns non-zero if the thread ids are equal, otherwise 0 |
| 356 | bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) | |
| 357 | bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2) | |
| 357 | 358 | { |
| 358 | return t1 == t2; | |
| 359 | return __t1 == __t2; | |
| 359 | 360 | } |
| 360 | 361 | |
| 361 | 362 | // Returns non-zero if t1 < t2, otherwise 0 |
| 362 | bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) | |
| 363 | bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2) | |
| 363 | 364 | { |
| 364 | return t1 < t2; | |
| 365 | return __t1 < __t2; | |
| 365 | 366 | } |
| 366 | 367 | |
| 367 | 368 | // Thread |
| ... | ... | @@ -673,4 +674,4 @@ get_id() _NOEXCEPT |
| 673 | 674 | |
| 674 | 675 | _LIBCPP_END_NAMESPACE_STD |
| 675 | 676 | |
| 676 | #endif // _LIBCPP_THREADING_SUPPORT | |
| 677 | #endif // _LIBCPP___THREADING_SUPPORT |
lib/libcxx/include/__tree+37-40| ... | ... | @@ -10,16 +10,22 @@ |
| 10 | 10 | #ifndef _LIBCPP___TREE |
| 11 | 11 | #define _LIBCPP___TREE |
| 12 | 12 | |
| 13 | #include <__algorithm/min.h> | |
| 14 | #include <__assert> | |
| 13 | 15 | #include <__config> |
| 16 | #include <__debug> | |
| 17 | #include <__iterator/distance.h> | |
| 18 | #include <__iterator/iterator_traits.h> | |
| 19 | #include <__iterator/next.h> | |
| 20 | #include <__memory/swap_allocator.h> | |
| 14 | 21 | #include <__utility/forward.h> |
| 15 | #include <algorithm> | |
| 16 | #include <iterator> | |
| 22 | #include <__utility/swap.h> | |
| 17 | 23 | #include <limits> |
| 18 | 24 | #include <memory> |
| 19 | 25 | #include <stdexcept> |
| 20 | 26 | |
| 21 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 22 | #pragma GCC system_header | |
| 28 | # pragma GCC system_header | |
| 23 | 29 | #endif |
| 24 | 30 | |
| 25 | 31 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -28,12 +34,10 @@ _LIBCPP_PUSH_MACROS |
| 28 | 34 | |
| 29 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 30 | 36 | |
| 31 | #if defined(__GNUC__) && !defined(__clang__) // gcc.gnu.org/PR37804 | |
| 32 | 37 | template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS map; |
| 33 | 38 | template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS multimap; |
| 34 | 39 | template <class, class, class> class _LIBCPP_TEMPLATE_VIS set; |
| 35 | 40 | template <class, class, class> class _LIBCPP_TEMPLATE_VIS multiset; |
| 36 | #endif | |
| 37 | 41 | |
| 38 | 42 | template <class _Tp, class _Compare, class _Allocator> class __tree; |
| 39 | 43 | template <class _Tp, class _NodePtr, class _DiffType> |
| ... | ... | @@ -140,35 +144,35 @@ __tree_invariant(_NodePtr __root) |
| 140 | 144 | } |
| 141 | 145 | |
| 142 | 146 | // Returns: pointer to the left-most node under __x. |
| 143 | // Precondition: __x != nullptr. | |
| 144 | 147 | template <class _NodePtr> |
| 145 | 148 | inline _LIBCPP_INLINE_VISIBILITY |
| 146 | 149 | _NodePtr |
| 147 | 150 | __tree_min(_NodePtr __x) _NOEXCEPT |
| 148 | 151 | { |
| 152 | _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null"); | |
| 149 | 153 | while (__x->__left_ != nullptr) |
| 150 | 154 | __x = __x->__left_; |
| 151 | 155 | return __x; |
| 152 | 156 | } |
| 153 | 157 | |
| 154 | 158 | // Returns: pointer to the right-most node under __x. |
| 155 | // Precondition: __x != nullptr. | |
| 156 | 159 | template <class _NodePtr> |
| 157 | 160 | inline _LIBCPP_INLINE_VISIBILITY |
| 158 | 161 | _NodePtr |
| 159 | 162 | __tree_max(_NodePtr __x) _NOEXCEPT |
| 160 | 163 | { |
| 164 | _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null"); | |
| 161 | 165 | while (__x->__right_ != nullptr) |
| 162 | 166 | __x = __x->__right_; |
| 163 | 167 | return __x; |
| 164 | 168 | } |
| 165 | 169 | |
| 166 | 170 | // Returns: pointer to the next in-order node after __x. |
| 167 | // Precondition: __x != nullptr. | |
| 168 | 171 | template <class _NodePtr> |
| 169 | 172 | _NodePtr |
| 170 | 173 | __tree_next(_NodePtr __x) _NOEXCEPT |
| 171 | 174 | { |
| 175 | _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); | |
| 172 | 176 | if (__x->__right_ != nullptr) |
| 173 | 177 | return _VSTD::__tree_min(__x->__right_); |
| 174 | 178 | while (!_VSTD::__tree_is_left_child(__x)) |
| ... | ... | @@ -181,6 +185,7 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 181 | 185 | _EndNodePtr |
| 182 | 186 | __tree_next_iter(_NodePtr __x) _NOEXCEPT |
| 183 | 187 | { |
| 188 | _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); | |
| 184 | 189 | if (__x->__right_ != nullptr) |
| 185 | 190 | return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_)); |
| 186 | 191 | while (!_VSTD::__tree_is_left_child(__x)) |
| ... | ... | @@ -189,13 +194,13 @@ __tree_next_iter(_NodePtr __x) _NOEXCEPT |
| 189 | 194 | } |
| 190 | 195 | |
| 191 | 196 | // Returns: pointer to the previous in-order node before __x. |
| 192 | // Precondition: __x != nullptr. | |
| 193 | 197 | // Note: __x may be the end node. |
| 194 | 198 | template <class _NodePtr, class _EndNodePtr> |
| 195 | 199 | inline _LIBCPP_INLINE_VISIBILITY |
| 196 | 200 | _NodePtr |
| 197 | 201 | __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT |
| 198 | 202 | { |
| 203 | _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); | |
| 199 | 204 | if (__x->__left_ != nullptr) |
| 200 | 205 | return _VSTD::__tree_max(__x->__left_); |
| 201 | 206 | _NodePtr __xx = static_cast<_NodePtr>(__x); |
| ... | ... | @@ -205,11 +210,11 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT |
| 205 | 210 | } |
| 206 | 211 | |
| 207 | 212 | // Returns: pointer to a node which has no children |
| 208 | // Precondition: __x != nullptr. | |
| 209 | 213 | template <class _NodePtr> |
| 210 | 214 | _NodePtr |
| 211 | 215 | __tree_leaf(_NodePtr __x) _NOEXCEPT |
| 212 | 216 | { |
| 217 | _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); | |
| 213 | 218 | while (true) |
| 214 | 219 | { |
| 215 | 220 | if (__x->__left_ != nullptr) |
| ... | ... | @@ -229,11 +234,12 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT |
| 229 | 234 | |
| 230 | 235 | // Effects: Makes __x->__right_ the subtree root with __x as its left child |
| 231 | 236 | // while preserving in-order order. |
| 232 | // Precondition: __x->__right_ != nullptr | |
| 233 | 237 | template <class _NodePtr> |
| 234 | 238 | void |
| 235 | 239 | __tree_left_rotate(_NodePtr __x) _NOEXCEPT |
| 236 | 240 | { |
| 241 | _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); | |
| 242 | _LIBCPP_ASSERT(__x->__right_ != nullptr, "node should have a right child"); | |
| 237 | 243 | _NodePtr __y = __x->__right_; |
| 238 | 244 | __x->__right_ = __y->__left_; |
| 239 | 245 | if (__x->__right_ != nullptr) |
| ... | ... | @@ -249,11 +255,12 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT |
| 249 | 255 | |
| 250 | 256 | // Effects: Makes __x->__left_ the subtree root with __x as its right child |
| 251 | 257 | // while preserving in-order order. |
| 252 | // Precondition: __x->__left_ != nullptr | |
| 253 | 258 | template <class _NodePtr> |
| 254 | 259 | void |
| 255 | 260 | __tree_right_rotate(_NodePtr __x) _NOEXCEPT |
| 256 | 261 | { |
| 262 | _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); | |
| 263 | _LIBCPP_ASSERT(__x->__left_ != nullptr, "node should have a left child"); | |
| 257 | 264 | _NodePtr __y = __x->__left_; |
| 258 | 265 | __x->__left_ = __y->__right_; |
| 259 | 266 | if (__x->__left_ != nullptr) |
| ... | ... | @@ -268,8 +275,7 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT |
| 268 | 275 | } |
| 269 | 276 | |
| 270 | 277 | // Effects: Rebalances __root after attaching __x to a leaf. |
| 271 | // Precondition: __root != nulptr && __x != nullptr. | |
| 272 | // __x has no children. | |
| 278 | // Precondition: __x has no children. | |
| 273 | 279 | // __x == __root or == a direct or indirect child of __root. |
| 274 | 280 | // If __x were to be unlinked from __root (setting __root to |
| 275 | 281 | // nullptr if __root == __x), __tree_invariant(__root) == true. |
| ... | ... | @@ -279,6 +285,8 @@ template <class _NodePtr> |
| 279 | 285 | void |
| 280 | 286 | __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT |
| 281 | 287 | { |
| 288 | _LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null"); | |
| 289 | _LIBCPP_ASSERT(__x != nullptr, "Can't attach null node to a leaf"); | |
| 282 | 290 | __x->__is_black_ = __x == __root; |
| 283 | 291 | while (__x != __root && !__x->__parent_unsafe()->__is_black_) |
| 284 | 292 | { |
| ... | ... | @@ -338,9 +346,7 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT |
| 338 | 346 | } |
| 339 | 347 | } |
| 340 | 348 | |
| 341 | // Precondition: __root != nullptr && __z != nullptr. | |
| 342 | // __tree_invariant(__root) == true. | |
| 343 | // __z == __root or == a direct or indirect child of __root. | |
| 349 | // Precondition: __z == __root or == a direct or indirect child of __root. | |
| 344 | 350 | // Effects: unlinks __z from the tree rooted at __root, rebalancing as needed. |
| 345 | 351 | // Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_ |
| 346 | 352 | // nor any of its children refer to __z. end_node->__left_ |
| ... | ... | @@ -349,6 +355,9 @@ template <class _NodePtr> |
| 349 | 355 | void |
| 350 | 356 | __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT |
| 351 | 357 | { |
| 358 | _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null"); | |
| 359 | _LIBCPP_ASSERT(__z != nullptr, "The node to remove should not be null"); | |
| 360 | _LIBCPP_DEBUG_ASSERT(__tree_invariant(__root), "The tree invariants should hold"); | |
| 352 | 361 | // __z will be removed from the tree. Client still needs to destruct/deallocate it |
| 353 | 362 | // __y is either __z, or if __z has two children, __tree_next(__z). |
| 354 | 363 | // __y will have at most one child. |
| ... | ... | @@ -545,7 +554,7 @@ template <class ..._Args> |
| 545 | 554 | struct __is_tree_value_type : false_type {}; |
| 546 | 555 | |
| 547 | 556 | template <class _One> |
| 548 | struct __is_tree_value_type<_One> : __is_tree_value_type_imp<typename __uncvref<_One>::type> {}; | |
| 557 | struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__uncvref_t<_One> > {}; | |
| 549 | 558 | |
| 550 | 559 | template <class _Tp> |
| 551 | 560 | struct __tree_key_value_types { |
| ... | ... | @@ -589,8 +598,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { |
| 589 | 598 | |
| 590 | 599 | template <class _Up> |
| 591 | 600 | _LIBCPP_INLINE_VISIBILITY |
| 592 | static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, | |
| 593 | key_type const&>::type | |
| 601 | static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, key_type const&> | |
| 594 | 602 | __get_key(_Up& __t) { |
| 595 | 603 | return __t.first; |
| 596 | 604 | } |
| ... | ... | @@ -603,8 +611,7 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { |
| 603 | 611 | |
| 604 | 612 | template <class _Up> |
| 605 | 613 | _LIBCPP_INLINE_VISIBILITY |
| 606 | static typename enable_if<__is_same_uncvref<_Up, __container_value_type>::value, | |
| 607 | __container_value_type const&>::type | |
| 614 | static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&> | |
| 608 | 615 | __get_value(_Up& __t) { |
| 609 | 616 | return __t; |
| 610 | 617 | } |
| ... | ... | @@ -1167,10 +1174,8 @@ public: |
| 1167 | 1174 | |
| 1168 | 1175 | template <class _First, class _Second> |
| 1169 | 1176 | _LIBCPP_INLINE_VISIBILITY |
| 1170 | typename enable_if< | |
| 1171 | __can_extract_map_key<_First, key_type, __container_value_type>::value, | |
| 1172 | pair<iterator, bool> | |
| 1173 | >::type __emplace_unique(_First&& __f, _Second&& __s) { | |
| 1177 | __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> > | |
| 1178 | __emplace_unique(_First&& __f, _Second&& __s) { | |
| 1174 | 1179 | return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), |
| 1175 | 1180 | _VSTD::forward<_Second>(__s)); |
| 1176 | 1181 | } |
| ... | ... | @@ -1211,10 +1216,8 @@ public: |
| 1211 | 1216 | |
| 1212 | 1217 | template <class _First, class _Second> |
| 1213 | 1218 | _LIBCPP_INLINE_VISIBILITY |
| 1214 | typename enable_if< | |
| 1215 | __can_extract_map_key<_First, key_type, __container_value_type>::value, | |
| 1216 | iterator | |
| 1217 | >::type __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { | |
| 1219 | __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, iterator> | |
| 1220 | __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { | |
| 1218 | 1221 | return __emplace_hint_unique_key_args(__p, __f, |
| 1219 | 1222 | _VSTD::forward<_First>(__f), |
| 1220 | 1223 | _VSTD::forward<_Second>(__s)).first; |
| ... | ... | @@ -1267,21 +1270,15 @@ public: |
| 1267 | 1270 | return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), _VSTD::move(__v)).first; |
| 1268 | 1271 | } |
| 1269 | 1272 | |
| 1270 | template <class _Vp, class = typename enable_if< | |
| 1271 | !is_same<typename __unconstref<_Vp>::type, | |
| 1272 | __container_value_type | |
| 1273 | >::value | |
| 1274 | >::type> | |
| 1273 | template <class _Vp, | |
| 1274 | class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> > | |
| 1275 | 1275 | _LIBCPP_INLINE_VISIBILITY |
| 1276 | 1276 | pair<iterator, bool> __insert_unique(_Vp&& __v) { |
| 1277 | 1277 | return __emplace_unique(_VSTD::forward<_Vp>(__v)); |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | template <class _Vp, class = typename enable_if< | |
| 1281 | !is_same<typename __unconstref<_Vp>::type, | |
| 1282 | __container_value_type | |
| 1283 | >::value | |
| 1284 | >::type> | |
| 1280 | template <class _Vp, | |
| 1281 | class = __enable_if_t<!is_same<typename __unconstref<_Vp>::type, __container_value_type>::value> > | |
| 1285 | 1282 | _LIBCPP_INLINE_VISIBILITY |
| 1286 | 1283 | iterator __insert_unique(const_iterator __p, _Vp&& __v) { |
| 1287 | 1284 | return __emplace_hint_unique(__p, _VSTD::forward<_Vp>(__v)); |
lib/libcxx/include/__tuple+6-7| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | |
| ... | ... | @@ -30,14 +30,14 @@ using __enable_if_tuple_size_imp = _Tp; |
| 30 | 30 | template <class _Tp> |
| 31 | 31 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< |
| 32 | 32 | const _Tp, |
| 33 | typename enable_if<!is_volatile<_Tp>::value>::type, | |
| 33 | __enable_if_t<!is_volatile<_Tp>::value>, | |
| 34 | 34 | integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> |
| 35 | 35 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; |
| 36 | 36 | |
| 37 | 37 | template <class _Tp> |
| 38 | 38 | struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< |
| 39 | 39 | volatile _Tp, |
| 40 | typename enable_if<!is_const<_Tp>::value>::type, | |
| 40 | __enable_if_t<!is_const<_Tp>::value>, | |
| 41 | 41 | integral_constant<size_t, sizeof(tuple_size<_Tp>)>>> |
| 42 | 42 | : public integral_constant<size_t, tuple_size<_Tp>::value> {}; |
| 43 | 43 | |
| ... | ... | @@ -278,7 +278,7 @@ using __type_pack_element _LIBCPP_NODEBUG = typename decltype( |
| 278 | 278 | #endif |
| 279 | 279 | |
| 280 | 280 | template <size_t _Ip, class ..._Types> |
| 281 | struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>> | |
| 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 | 284 | typedef _LIBCPP_NODEBUG __type_pack_element<_Ip, _Types...> type; |
| ... | ... | @@ -393,7 +393,7 @@ struct __tuple_sfinae_base { |
| 393 | 393 | template <template <class, class...> class _Trait, |
| 394 | 394 | class ..._LArgs, class ..._RArgs> |
| 395 | 395 | static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>) |
| 396 | -> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>; | |
| 396 | -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>; | |
| 397 | 397 | template <template <class...> class> |
| 398 | 398 | static auto __do_test(...) -> false_type; |
| 399 | 399 | |
| ... | ... | @@ -469,8 +469,7 @@ template <class _SizeTrait, size_t _Expected> |
| 469 | 469 | struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected> |
| 470 | 470 | : integral_constant<bool, _SizeTrait::value == _Expected> {}; |
| 471 | 471 | |
| 472 | template <class _Tuple, size_t _ExpectedSize, | |
| 473 | class _RawTuple = typename __uncvref<_Tuple>::type> | |
| 472 | template <class _Tuple, size_t _ExpectedSize, class _RawTuple = __uncvref_t<_Tuple> > | |
| 474 | 473 | using __tuple_like_with_size _LIBCPP_NODEBUG = __tuple_like_with_size_imp< |
| 475 | 474 | __tuple_like<_RawTuple>::value, |
| 476 | 475 | tuple_size<_RawTuple>, _ExpectedSize |
lib/libcxx/include/__type_traits/add_const.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_CONST_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_CONST_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const { | |
| 21 | typedef _LIBCPP_NODEBUG const _Tp type; | |
| 22 | }; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 11 | |
| 25 | template <class _Tp> using add_const_t = typename add_const<_Tp>::type; | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H |
lib/libcxx/include/__type_traits/add_cv.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_CV_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_CV_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv { | |
| 21 | typedef _LIBCPP_NODEBUG const volatile _Tp type; | |
| 22 | }; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 11 | |
| 25 | template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H |
lib/libcxx/include/__type_traits/add_lvalue_reference.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_referenceable.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 22 | template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; }; | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference | |
| 25 | {typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 11 | |
| 28 | template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H |
lib/libcxx/include/__type_traits/add_pointer.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_referenceable.h> | |
| 14 | #include <__type_traits/is_same.h> | |
| 15 | #include <__type_traits/remove_cv.h> | |
| 16 | #include <__type_traits/remove_reference.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp, | |
| 25 | bool = __is_referenceable<_Tp>::value || | |
| 26 | _IsSame<typename remove_cv<_Tp>::type, void>::value> | |
| 27 | struct __add_pointer_impl | |
| 28 | {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;}; | |
| 29 | template <class _Tp> struct __add_pointer_impl<_Tp, false> | |
| 30 | {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 31 | ||
| 32 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer | |
| 33 | {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;}; | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 11 | |
| 36 | template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; | |
| 37 | #endif | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___TYPE_TRAITS_ADD_POINTER_H |
lib/libcxx/include/__type_traits/add_rvalue_reference.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_referenceable.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 22 | template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; }; | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference | |
| 25 | {typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 11 | |
| 28 | template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H |
lib/libcxx/include/__type_traits/add_volatile.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile { | |
| 21 | typedef _LIBCPP_NODEBUG volatile _Tp type; | |
| 22 | }; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 11 | |
| 25 | template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H |
lib/libcxx/include/__type_traits/aligned_storage.h created+142| ... | ... | @@ -0,0 +1,142 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/conditional.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/nat.h> | |
| 16 | #include <__type_traits/type_list.h> | |
| 17 | #include <cstddef> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | template <class _Tp> | |
| 26 | struct __align_type | |
| 27 | { | |
| 28 | static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); | |
| 29 | typedef _Tp type; | |
| 30 | }; | |
| 31 | ||
| 32 | struct __struct_double {long double __lx;}; | |
| 33 | struct __struct_double4 {double __lx[4];}; | |
| 34 | ||
| 35 | typedef | |
| 36 | __type_list<__align_type<unsigned char>, | |
| 37 | __type_list<__align_type<unsigned short>, | |
| 38 | __type_list<__align_type<unsigned int>, | |
| 39 | __type_list<__align_type<unsigned long>, | |
| 40 | __type_list<__align_type<unsigned long long>, | |
| 41 | __type_list<__align_type<double>, | |
| 42 | __type_list<__align_type<long double>, | |
| 43 | __type_list<__align_type<__struct_double>, | |
| 44 | __type_list<__align_type<__struct_double4>, | |
| 45 | __type_list<__align_type<int*>, | |
| 46 | __nat | |
| 47 | > > > > > > > > > > __all_types; | |
| 48 | ||
| 49 | template <size_t _Align> | |
| 50 | struct _ALIGNAS(_Align) __fallback_overaligned {}; | |
| 51 | ||
| 52 | template <class _TL, size_t _Align> struct __find_pod; | |
| 53 | ||
| 54 | template <class _Hp, size_t _Align> | |
| 55 | struct __find_pod<__type_list<_Hp, __nat>, _Align> | |
| 56 | { | |
| 57 | typedef typename conditional< | |
| 58 | _Align == _Hp::value, | |
| 59 | typename _Hp::type, | |
| 60 | __fallback_overaligned<_Align> | |
| 61 | >::type type; | |
| 62 | }; | |
| 63 | ||
| 64 | template <class _Hp, class _Tp, size_t _Align> | |
| 65 | struct __find_pod<__type_list<_Hp, _Tp>, _Align> | |
| 66 | { | |
| 67 | typedef typename conditional< | |
| 68 | _Align == _Hp::value, | |
| 69 | typename _Hp::type, | |
| 70 | typename __find_pod<_Tp, _Align>::type | |
| 71 | >::type type; | |
| 72 | }; | |
| 73 | ||
| 74 | template <class _TL, size_t _Len> struct __find_max_align; | |
| 75 | ||
| 76 | template <class _Hp, size_t _Len> | |
| 77 | struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; | |
| 78 | ||
| 79 | template <size_t _Len, size_t _A1, size_t _A2> | |
| 80 | struct __select_align | |
| 81 | { | |
| 82 | private: | |
| 83 | static const size_t __min = _A2 < _A1 ? _A2 : _A1; | |
| 84 | static const size_t __max = _A1 < _A2 ? _A2 : _A1; | |
| 85 | public: | |
| 86 | static const size_t value = _Len < __max ? __min : __max; | |
| 87 | }; | |
| 88 | ||
| 89 | template <class _Hp, class _Tp, size_t _Len> | |
| 90 | struct __find_max_align<__type_list<_Hp, _Tp>, _Len> | |
| 91 | : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; | |
| 92 | ||
| 93 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | |
| 94 | struct _LIBCPP_TEMPLATE_VIS aligned_storage | |
| 95 | { | |
| 96 | typedef typename __find_pod<__all_types, _Align>::type _Aligner; | |
| 97 | union type | |
| 98 | { | |
| 99 | _Aligner __align; | |
| 100 | unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; | |
| 101 | }; | |
| 102 | }; | |
| 103 | ||
| 104 | #if _LIBCPP_STD_VER > 11 | |
| 105 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | |
| 106 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; | |
| 107 | #endif | |
| 108 | ||
| 109 | #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ | |
| 110 | template <size_t _Len>\ | |
| 111 | struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ | |
| 112 | {\ | |
| 113 | struct _ALIGNAS(n) type\ | |
| 114 | {\ | |
| 115 | unsigned char __lx[(_Len + n - 1)/n * n];\ | |
| 116 | };\ | |
| 117 | } | |
| 118 | ||
| 119 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); | |
| 120 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); | |
| 121 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); | |
| 122 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); | |
| 123 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); | |
| 124 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); | |
| 125 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); | |
| 126 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); | |
| 127 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); | |
| 128 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); | |
| 129 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); | |
| 130 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); | |
| 131 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); | |
| 132 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); | |
| 133 | // PE/COFF does not support alignment beyond 8192 (=0x2000) | |
| 134 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 135 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); | |
| 136 | #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 137 | ||
| 138 | #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION | |
| 139 | ||
| 140 | _LIBCPP_END_NAMESPACE_STD | |
| 141 | ||
| 142 | #endif // _LIBCPP___TYPE_TRAITS_ALIGNED_STORAGE_H |
lib/libcxx/include/__type_traits/aligned_union.h created+55| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/aligned_storage.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <cstddef> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <size_t _I0, size_t ..._In> | |
| 24 | struct __static_max; | |
| 25 | ||
| 26 | template <size_t _I0> | |
| 27 | struct __static_max<_I0> | |
| 28 | { | |
| 29 | static const size_t value = _I0; | |
| 30 | }; | |
| 31 | ||
| 32 | template <size_t _I0, size_t _I1, size_t ..._In> | |
| 33 | struct __static_max<_I0, _I1, _In...> | |
| 34 | { | |
| 35 | static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : | |
| 36 | __static_max<_I1, _In...>::value; | |
| 37 | }; | |
| 38 | ||
| 39 | template <size_t _Len, class _Type0, class ..._Types> | |
| 40 | struct aligned_union | |
| 41 | { | |
| 42 | static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), | |
| 43 | _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; | |
| 44 | static const size_t __len = __static_max<_Len, sizeof(_Type0), | |
| 45 | sizeof(_Types)...>::value; | |
| 46 | typedef typename aligned_storage<__len, alignment_value>::type type; | |
| 47 | }; | |
| 48 | ||
| 49 | #if _LIBCPP_STD_VER > 11 | |
| 50 | template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; | |
| 51 | #endif | |
| 52 | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | |
| 54 | ||
| 55 | #endif // _LIBCPP___TYPE_TRAITS_ALIGNED_UNION_H |
lib/libcxx/include/__type_traits/alignment_of.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of | |
| 23 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Tp> | |
| 27 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_ALIGNMENT_OF_H |
lib/libcxx/include/__type_traits/apply_cv.h created+76| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_APPLY_CV_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_APPLY_CV_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_const.h> | |
| 15 | #include <__type_traits/is_volatile.h> | |
| 16 | #include <__type_traits/remove_reference.h> | |
| 17 | #include <cstddef> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, | |
| 26 | bool = is_volatile<typename remove_reference<_Tp>::type>::value> | |
| 27 | struct __apply_cv | |
| 28 | { | |
| 29 | typedef _LIBCPP_NODEBUG _Up type; | |
| 30 | }; | |
| 31 | ||
| 32 | template <class _Tp, class _Up> | |
| 33 | struct __apply_cv<_Tp, _Up, true, false> | |
| 34 | { | |
| 35 | typedef _LIBCPP_NODEBUG const _Up type; | |
| 36 | }; | |
| 37 | ||
| 38 | template <class _Tp, class _Up> | |
| 39 | struct __apply_cv<_Tp, _Up, false, true> | |
| 40 | { | |
| 41 | typedef volatile _Up type; | |
| 42 | }; | |
| 43 | ||
| 44 | template <class _Tp, class _Up> | |
| 45 | struct __apply_cv<_Tp, _Up, true, true> | |
| 46 | { | |
| 47 | typedef const volatile _Up type; | |
| 48 | }; | |
| 49 | ||
| 50 | template <class _Tp, class _Up> | |
| 51 | struct __apply_cv<_Tp&, _Up, false, false> | |
| 52 | { | |
| 53 | typedef _Up& type; | |
| 54 | }; | |
| 55 | ||
| 56 | template <class _Tp, class _Up> | |
| 57 | struct __apply_cv<_Tp&, _Up, true, false> | |
| 58 | { | |
| 59 | typedef const _Up& type; | |
| 60 | }; | |
| 61 | ||
| 62 | template <class _Tp, class _Up> | |
| 63 | struct __apply_cv<_Tp&, _Up, false, true> | |
| 64 | { | |
| 65 | typedef volatile _Up& type; | |
| 66 | }; | |
| 67 | ||
| 68 | template <class _Tp, class _Up> | |
| 69 | struct __apply_cv<_Tp&, _Up, true, true> | |
| 70 | { | |
| 71 | typedef const volatile _Up& type; | |
| 72 | }; | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_STD | |
| 75 | ||
| 76 | #endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H |
lib/libcxx/include/__type_traits/common_reference.h created+188| ... | ... | @@ -0,0 +1,188 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/common_type.h> | |
| 14 | #include <__type_traits/copy_cv.h> | |
| 15 | #include <__type_traits/copy_cvref.h> | |
| 16 | #include <__type_traits/is_convertible.h> | |
| 17 | #include <__type_traits/is_reference.h> | |
| 18 | #include <__type_traits/remove_cv.h> | |
| 19 | #include <__type_traits/remove_cvref.h> | |
| 20 | #include <__type_traits/remove_reference.h> | |
| 21 | #include <__utility/declval.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | // common_reference | |
| 30 | #if _LIBCPP_STD_VER > 17 | |
| 31 | // Let COND_RES(X, Y) be: | |
| 32 | template <class _Xp, class _Yp> | |
| 33 | using __cond_res = | |
| 34 | decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); | |
| 35 | ||
| 36 | // Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U` | |
| 37 | // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type | |
| 38 | // `U`. | |
| 39 | // [Note: `XREF(A)` is `__xref<A>::template __apply`] | |
| 40 | template <class _Tp> | |
| 41 | struct __xref { | |
| 42 | template<class _Up> | |
| 43 | using __apply = __copy_cvref_t<_Tp, _Up>; | |
| 44 | }; | |
| 45 | ||
| 46 | // Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>, | |
| 47 | // and let COMMON-REF(A, B) be: | |
| 48 | template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>> | |
| 49 | struct __common_ref; | |
| 50 | ||
| 51 | template<class _Xp, class _Yp> | |
| 52 | using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type; | |
| 53 | ||
| 54 | template<class _Xp, class _Yp> | |
| 55 | using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; | |
| 56 | ||
| 57 | ||
| 58 | // If A and B are both lvalue reference types, COMMON-REF(A, B) is | |
| 59 | // COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type. | |
| 60 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 61 | requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>> | |
| 62 | struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> | |
| 63 | { | |
| 64 | using __type = __cv_cond_res<_Xp, _Yp>; | |
| 65 | }; | |
| 66 | ||
| 67 | // Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ... | |
| 68 | template <class _Xp, class _Yp> | |
| 69 | using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; | |
| 70 | ||
| 71 | ||
| 72 | // .... If A and B are both rvalue reference types, C is well-formed, and | |
| 73 | // is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C. | |
| 74 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 75 | requires | |
| 76 | requires { typename __common_ref_C<_Xp, _Yp>; } && | |
| 77 | is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> && | |
| 78 | is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>> | |
| 79 | struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> | |
| 80 | { | |
| 81 | using __type = __common_ref_C<_Xp, _Yp>; | |
| 82 | }; | |
| 83 | ||
| 84 | // Otherwise, let D be COMMON-REF(const X&, Y&). ... | |
| 85 | template <class _Tp, class _Up> | |
| 86 | using __common_ref_D = __common_ref_t<const _Tp&, _Up&>; | |
| 87 | ||
| 88 | // ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and | |
| 89 | // is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D. | |
| 90 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 91 | requires requires { typename __common_ref_D<_Xp, _Yp>; } && | |
| 92 | is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>> | |
| 93 | struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> | |
| 94 | { | |
| 95 | using __type = __common_ref_D<_Xp, _Yp>; | |
| 96 | }; | |
| 97 | ||
| 98 | // Otherwise, if A is an lvalue reference and B is an rvalue reference, then | |
| 99 | // COMMON-REF(A, B) is COMMON-REF(B, A). | |
| 100 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 101 | struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {}; | |
| 102 | ||
| 103 | // Otherwise, COMMON-REF(A, B) is ill-formed. | |
| 104 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 105 | struct __common_ref {}; | |
| 106 | ||
| 107 | // Note C: For the common_reference trait applied to a parameter pack [...] | |
| 108 | ||
| 109 | template <class...> | |
| 110 | struct common_reference; | |
| 111 | ||
| 112 | template <class... _Types> | |
| 113 | using common_reference_t = typename common_reference<_Types...>::type; | |
| 114 | ||
| 115 | // bullet 1 - sizeof...(T) == 0 | |
| 116 | template<> | |
| 117 | struct common_reference<> {}; | |
| 118 | ||
| 119 | // bullet 2 - sizeof...(T) == 1 | |
| 120 | template <class _Tp> | |
| 121 | struct common_reference<_Tp> | |
| 122 | { | |
| 123 | using type = _Tp; | |
| 124 | }; | |
| 125 | ||
| 126 | // bullet 3 - sizeof...(T) == 2 | |
| 127 | template <class _Tp, class _Up> struct __common_reference_sub_bullet3; | |
| 128 | template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {}; | |
| 129 | template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; | |
| 130 | ||
| 131 | // sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then | |
| 132 | // the member typedef `type` denotes that type. | |
| 133 | template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; | |
| 134 | ||
| 135 | template <class _Tp, class _Up> | |
| 136 | requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } | |
| 137 | struct __common_reference_sub_bullet1<_Tp, _Up> | |
| 138 | { | |
| 139 | using type = __common_ref_t<_Tp, _Up>; | |
| 140 | }; | |
| 141 | ||
| 142 | // sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type | |
| 143 | // is well-formed, then the member typedef `type` denotes that type. | |
| 144 | template <class, class, template <class> class, template <class> class> struct basic_common_reference {}; | |
| 145 | ||
| 146 | template <class _Tp, class _Up> | |
| 147 | using __basic_common_reference_t = typename basic_common_reference< | |
| 148 | remove_cvref_t<_Tp>, remove_cvref_t<_Up>, | |
| 149 | __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type; | |
| 150 | ||
| 151 | template <class _Tp, class _Up> | |
| 152 | requires requires { typename __basic_common_reference_t<_Tp, _Up>; } | |
| 153 | struct __common_reference_sub_bullet2<_Tp, _Up> | |
| 154 | { | |
| 155 | using type = __basic_common_reference_t<_Tp, _Up>; | |
| 156 | }; | |
| 157 | ||
| 158 | // sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, | |
| 159 | // then the member typedef `type` denotes that type. | |
| 160 | template <class _Tp, class _Up> | |
| 161 | requires requires { typename __cond_res<_Tp, _Up>; } | |
| 162 | struct __common_reference_sub_bullet3<_Tp, _Up> | |
| 163 | { | |
| 164 | using type = __cond_res<_Tp, _Up>; | |
| 165 | }; | |
| 166 | ||
| 167 | ||
| 168 | // sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, | |
| 169 | // then the member typedef `type` denotes that type. | |
| 170 | // - Otherwise, there shall be no member `type`. | |
| 171 | template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; | |
| 172 | ||
| 173 | // bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if | |
| 174 | // any, as `common_reference_t<C, Rest...>`. | |
| 175 | template <class _Tp, class _Up, class _Vp, class... _Rest> | |
| 176 | requires requires { typename common_reference_t<_Tp, _Up>; } | |
| 177 | struct common_reference<_Tp, _Up, _Vp, _Rest...> | |
| 178 | : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> | |
| 179 | {}; | |
| 180 | ||
| 181 | // bullet 5 - Otherwise, there shall be no member `type`. | |
| 182 | template <class...> struct common_reference {}; | |
| 183 | ||
| 184 | #endif // _LIBCPP_STD_VER > 17 | |
| 185 | ||
| 186 | _LIBCPP_END_NAMESPACE_STD | |
| 187 | ||
| 188 | #endif // _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H |
lib/libcxx/include/__type_traits/common_type.h created+138| ... | ... | @@ -0,0 +1,138 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/conditional.h> | |
| 14 | #include <__type_traits/decay.h> | |
| 15 | #include <__type_traits/is_same.h> | |
| 16 | #include <__type_traits/remove_cvref.h> | |
| 17 | #include <__type_traits/void_t.h> | |
| 18 | #include <__utility/declval.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | // Let COND_RES(X, Y) be: | |
| 28 | template <class _Tp, class _Up> | |
| 29 | using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>()); | |
| 30 | ||
| 31 | template <class _Tp, class _Up, class = void> | |
| 32 | struct __common_type3 {}; | |
| 33 | ||
| 34 | // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." | |
| 35 | template <class _Tp, class _Up> | |
| 36 | struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> | |
| 37 | { | |
| 38 | using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; | |
| 39 | }; | |
| 40 | ||
| 41 | template <class _Tp, class _Up, class = void> | |
| 42 | struct __common_type2_imp : __common_type3<_Tp, _Up> {}; | |
| 43 | #else | |
| 44 | template <class _Tp, class _Up, class = void> | |
| 45 | struct __common_type2_imp {}; | |
| 46 | #endif | |
| 47 | ||
| 48 | // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." | |
| 49 | template <class _Tp, class _Up> | |
| 50 | struct __common_type2_imp<_Tp, _Up, | |
| 51 | typename __void_t<decltype( | |
| 52 | true ? declval<_Tp>() : declval<_Up>() | |
| 53 | )>::type> | |
| 54 | { | |
| 55 | typedef _LIBCPP_NODEBUG typename decay<decltype( | |
| 56 | true ? declval<_Tp>() : declval<_Up>() | |
| 57 | )>::type type; | |
| 58 | }; | |
| 59 | ||
| 60 | template <class, class = void> | |
| 61 | struct __common_type_impl {}; | |
| 62 | ||
| 63 | // Clang provides variadic templates in C++03 as an extension. | |
| 64 | #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) | |
| 65 | # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ | |
| 66 | template <class... _Tp> | |
| 67 | struct __common_types; | |
| 68 | template <class... _Tp> | |
| 69 | struct _LIBCPP_TEMPLATE_VIS common_type; | |
| 70 | #else | |
| 71 | # define _LIBCPP_OPTIONAL_PACK(...) | |
| 72 | struct __no_arg; | |
| 73 | template <class _Tp, class _Up, class = __no_arg> | |
| 74 | struct __common_types; | |
| 75 | template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, | |
| 76 | class _Unused = __no_arg> | |
| 77 | struct common_type { | |
| 78 | static_assert(sizeof(_Unused) == 0, | |
| 79 | "common_type accepts at most 3 arguments in C++03"); | |
| 80 | }; | |
| 81 | #endif // _LIBCPP_CXX03_LANG | |
| 82 | ||
| 83 | template <class _Tp, class _Up> | |
| 84 | struct __common_type_impl< | |
| 85 | __common_types<_Tp, _Up>, | |
| 86 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> | |
| 87 | { | |
| 88 | typedef typename common_type<_Tp, _Up>::type type; | |
| 89 | }; | |
| 90 | ||
| 91 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> | |
| 92 | struct __common_type_impl< | |
| 93 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, | |
| 94 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> | |
| 95 | : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, | |
| 96 | _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { | |
| 97 | }; | |
| 98 | ||
| 99 | // bullet 1 - sizeof...(Tp) == 0 | |
| 100 | ||
| 101 | template <> | |
| 102 | struct _LIBCPP_TEMPLATE_VIS common_type<> {}; | |
| 103 | ||
| 104 | // bullet 2 - sizeof...(Tp) == 1 | |
| 105 | ||
| 106 | template <class _Tp> | |
| 107 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> | |
| 108 | : public common_type<_Tp, _Tp> {}; | |
| 109 | ||
| 110 | // bullet 3 - sizeof...(Tp) == 2 | |
| 111 | ||
| 112 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." | |
| 113 | template <class _Tp, class _Up> | |
| 114 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> | |
| 115 | : conditional< | |
| 116 | _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, | |
| 117 | __common_type2_imp<_Tp, _Up>, | |
| 118 | common_type<typename decay<_Tp>::type, typename decay<_Up>::type> | |
| 119 | >::type | |
| 120 | {}; | |
| 121 | ||
| 122 | // bullet 4 - sizeof...(Tp) > 2 | |
| 123 | ||
| 124 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> | |
| 125 | struct _LIBCPP_TEMPLATE_VIS | |
| 126 | common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> | |
| 127 | : __common_type_impl< | |
| 128 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; | |
| 129 | ||
| 130 | #undef _LIBCPP_OPTIONAL_PACK | |
| 131 | ||
| 132 | #if _LIBCPP_STD_VER > 11 | |
| 133 | template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; | |
| 134 | #endif | |
| 135 | ||
| 136 | _LIBCPP_END_NAMESPACE_STD | |
| 137 | ||
| 138 | #endif // _LIBCPP___TYPE_TRAITS_COMMON_TYPE_H |
lib/libcxx/include/__type_traits/conditional.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_CONDITIONAL_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_CONDITIONAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <bool> | |
| 21 | struct _IfImpl; | |
| 22 | ||
| 23 | template <> | |
| 24 | struct _IfImpl<true> { | |
| 25 | template <class _IfRes, class _ElseRes> | |
| 26 | using _Select _LIBCPP_NODEBUG = _IfRes; | |
| 27 | }; | |
| 28 | ||
| 29 | template <> | |
| 30 | struct _IfImpl<false> { | |
| 31 | template <class _IfRes, class _ElseRes> | |
| 32 | using _Select _LIBCPP_NODEBUG = _ElseRes; | |
| 33 | }; | |
| 34 | ||
| 35 | template <bool _Cond, class _IfRes, class _ElseRes> | |
| 36 | using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>; | |
| 37 | ||
| 38 | template <bool _Bp, class _If, class _Then> | |
| 39 | struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; | |
| 40 | template <class _If, class _Then> | |
| 41 | struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;}; | |
| 42 | ||
| 43 | #if _LIBCPP_STD_VER > 11 | |
| 44 | template <bool _Bp, class _IfRes, class _ElseRes> | |
| 45 | using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type; | |
| 46 | #endif | |
| 47 | ||
| 48 | // Helper so we can use "conditional_t" in all language versions. | |
| 49 | template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type; | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H |
lib/libcxx/include/__type_traits/conjunction.h created+57| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_CONJUNCTION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_CONJUNCTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/conditional.h> | |
| 14 | #include <__type_traits/enable_if.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 14 | |
| 24 | ||
| 25 | template <class _Arg, class... _Args> | |
| 26 | struct __conjunction_impl { | |
| 27 | using type = conditional_t<!bool(_Arg::value), _Arg, typename __conjunction_impl<_Args...>::type>; | |
| 28 | }; | |
| 29 | ||
| 30 | template <class _Arg> | |
| 31 | struct __conjunction_impl<_Arg> { | |
| 32 | using type = _Arg; | |
| 33 | }; | |
| 34 | ||
| 35 | template <class... _Args> | |
| 36 | struct conjunction : __conjunction_impl<true_type, _Args...>::type {}; | |
| 37 | ||
| 38 | template<class... _Args> | |
| 39 | inline constexpr bool conjunction_v = conjunction<_Args...>::value; | |
| 40 | ||
| 41 | #endif // _LIBCPP_STD_VER > 14 | |
| 42 | ||
| 43 | template <class...> | |
| 44 | using __expand_to_true = true_type; | |
| 45 | ||
| 46 | template <class... _Pred> | |
| 47 | __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); | |
| 48 | ||
| 49 | template <class...> | |
| 50 | false_type __and_helper(...); | |
| 51 | ||
| 52 | template <class... _Pred> | |
| 53 | using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0)); | |
| 54 | ||
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 56 | ||
| 57 | #endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_H |
lib/libcxx/include/__type_traits/copy_cv.h created+54| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_COPY_CV_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_COPY_CV_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_cv.h> | |
| 15 | #include <__type_traits/add_volatile.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's | |
| 24 | // top-level cv-qualifiers. | |
| 25 | template <class _From, class _To> | |
| 26 | struct __copy_cv | |
| 27 | { | |
| 28 | using type = _To; | |
| 29 | }; | |
| 30 | ||
| 31 | template <class _From, class _To> | |
| 32 | struct __copy_cv<const _From, _To> | |
| 33 | { | |
| 34 | using type = typename add_const<_To>::type; | |
| 35 | }; | |
| 36 | ||
| 37 | template <class _From, class _To> | |
| 38 | struct __copy_cv<volatile _From, _To> | |
| 39 | { | |
| 40 | using type = typename add_volatile<_To>::type; | |
| 41 | }; | |
| 42 | ||
| 43 | template <class _From, class _To> | |
| 44 | struct __copy_cv<const volatile _From, _To> | |
| 45 | { | |
| 46 | using type = typename add_cv<_To>::type; | |
| 47 | }; | |
| 48 | ||
| 49 | template <class _From, class _To> | |
| 50 | using __copy_cv_t = typename __copy_cv<_From, _To>::type; | |
| 51 | ||
| 52 | _LIBCPP_END_NAMESPACE_STD | |
| 53 | ||
| 54 | #endif // _LIBCPP___TYPE_TRAITS_COPY_CV_H |
lib/libcxx/include/__type_traits/copy_cvref.h created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_COPY_CVREF_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_lvalue_reference.h> | |
| 14 | #include <__type_traits/add_rvalue_reference.h> | |
| 15 | #include <__type_traits/copy_cv.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _From, class _To> | |
| 24 | struct __copy_cvref | |
| 25 | { | |
| 26 | using type = __copy_cv_t<_From, _To>; | |
| 27 | }; | |
| 28 | ||
| 29 | template <class _From, class _To> | |
| 30 | struct __copy_cvref<_From&, _To> | |
| 31 | { | |
| 32 | using type = typename add_lvalue_reference<__copy_cv_t<_From, _To> >::type; | |
| 33 | }; | |
| 34 | ||
| 35 | template <class _From, class _To> | |
| 36 | struct __copy_cvref<_From&&, _To> | |
| 37 | { | |
| 38 | using type = typename add_rvalue_reference<__copy_cv_t<_From, _To> >::type; | |
| 39 | }; | |
| 40 | ||
| 41 | template <class _From, class _To> | |
| 42 | using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; | |
| 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | |
| 45 | ||
| 46 | #endif // _LIBCPP___TYPE_TRAITS_COPY_CVREF_H |
lib/libcxx/include/__type_traits/decay.h created+65| ... | ... | @@ -0,0 +1,65 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_DECAY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_DECAY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_pointer.h> | |
| 14 | #include <__type_traits/conditional.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_array.h> | |
| 17 | #include <__type_traits/is_function.h> | |
| 18 | #include <__type_traits/is_referenceable.h> | |
| 19 | #include <__type_traits/remove_cv.h> | |
| 20 | #include <__type_traits/remove_extent.h> | |
| 21 | #include <__type_traits/remove_reference.h> | |
| 22 | ||
| 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 24 | # pragma GCC system_header | |
| 25 | #endif | |
| 26 | ||
| 27 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 28 | ||
| 29 | template <class _Up, bool> | |
| 30 | struct __decay { | |
| 31 | typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type; | |
| 32 | }; | |
| 33 | ||
| 34 | template <class _Up> | |
| 35 | struct __decay<_Up, true> { | |
| 36 | public: | |
| 37 | typedef _LIBCPP_NODEBUG typename conditional | |
| 38 | < | |
| 39 | is_array<_Up>::value, | |
| 40 | typename remove_extent<_Up>::type*, | |
| 41 | typename conditional | |
| 42 | < | |
| 43 | is_function<_Up>::value, | |
| 44 | typename add_pointer<_Up>::type, | |
| 45 | typename remove_cv<_Up>::type | |
| 46 | >::type | |
| 47 | >::type type; | |
| 48 | }; | |
| 49 | ||
| 50 | template <class _Tp> | |
| 51 | struct _LIBCPP_TEMPLATE_VIS decay | |
| 52 | { | |
| 53 | private: | |
| 54 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up; | |
| 55 | public: | |
| 56 | typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type; | |
| 57 | }; | |
| 58 | ||
| 59 | #if _LIBCPP_STD_VER > 11 | |
| 60 | template <class _Tp> using decay_t = typename decay<_Tp>::type; | |
| 61 | #endif | |
| 62 | ||
| 63 | _LIBCPP_END_NAMESPACE_STD | |
| 64 | ||
| 65 | #endif // _LIBCPP___TYPE_TRAITS_DECAY_H |
lib/libcxx/include/__type_traits/disjunction.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_DISJUNCTION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/conditional.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <bool> | |
| 23 | struct _OrImpl; | |
| 24 | ||
| 25 | template <> | |
| 26 | struct _OrImpl<true> { | |
| 27 | template <class _Res, class _First, class... _Rest> | |
| 28 | using _Result _LIBCPP_NODEBUG = | |
| 29 | typename _OrImpl<!bool(_First::value) && sizeof...(_Rest) != 0>::template _Result<_First, _Rest...>; | |
| 30 | }; | |
| 31 | ||
| 32 | template <> | |
| 33 | struct _OrImpl<false> { | |
| 34 | template <class _Res, class...> | |
| 35 | using _Result = _Res; | |
| 36 | }; | |
| 37 | ||
| 38 | template <class... _Args> | |
| 39 | using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>; | |
| 40 | ||
| 41 | #if _LIBCPP_STD_VER > 14 | |
| 42 | ||
| 43 | template <class... _Args> | |
| 44 | struct disjunction : _Or<_Args...> {}; | |
| 45 | ||
| 46 | template <class... _Args> | |
| 47 | inline constexpr bool disjunction_v = _Or<_Args...>::value; | |
| 48 | ||
| 49 | #endif // _LIBCPP_STD_VER > 14 | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___TYPE_TRAITS_DISJUNCTION_H |
lib/libcxx/include/__type_traits/enable_if.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_ENABLE_IF_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_ENABLE_IF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <bool, class _Tp = void> struct _LIBCPP_TEMPLATE_VIS enable_if {}; | |
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;}; | |
| 22 | ||
| 23 | template <bool _Bp, class _Tp = void> using __enable_if_t _LIBCPP_NODEBUG = typename enable_if<_Bp, _Tp>::type; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 11 | |
| 26 | template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; | |
| 27 | #endif | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H |
lib/libcxx/include/__type_traits/extent.h created+55| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_EXTENT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_EXTENT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if __has_builtin(__array_extent) | |
| 23 | ||
| 24 | template<class _Tp, size_t _Dim = 0> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS extent | |
| 26 | : integral_constant<size_t, __array_extent(_Tp, _Dim)> { }; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp, unsigned _Ip = 0> | |
| 30 | inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); | |
| 31 | #endif | |
| 32 | ||
| 33 | #else // __has_builtin(__array_extent) | |
| 34 | ||
| 35 | template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent | |
| 36 | : public integral_constant<size_t, 0> {}; | |
| 37 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> | |
| 38 | : public integral_constant<size_t, 0> {}; | |
| 39 | template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> | |
| 40 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; | |
| 41 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> | |
| 42 | : public integral_constant<size_t, _Np> {}; | |
| 43 | template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> | |
| 44 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; | |
| 45 | ||
| 46 | #if _LIBCPP_STD_VER > 14 | |
| 47 | template <class _Tp, unsigned _Ip = 0> | |
| 48 | inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; | |
| 49 | #endif | |
| 50 | ||
| 51 | #endif // __has_builtin(__array_extent) | |
| 52 | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | |
| 54 | ||
| 55 | #endif // _LIBCPP___TYPE_TRAITS_EXTENT_H |
lib/libcxx/include/__type_traits/has_unique_object_representation.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_all_extents.h> | |
| 15 | #include <__type_traits/remove_cv.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if _LIBCPP_STD_VER > 14 | |
| 24 | ||
| 25 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations | |
| 26 | : public integral_constant<bool, | |
| 27 | __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; | |
| 28 | ||
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value; | |
| 31 | ||
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H |
lib/libcxx/include/__type_traits/has_virtual_destructor.h created+40| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__has_virtual_destructor) | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor | |
| 24 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; | |
| 25 | ||
| 26 | #else | |
| 27 | ||
| 28 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor | |
| 29 | : public false_type {}; | |
| 30 | ||
| 31 | #endif | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 14 | |
| 34 | template <class _Tp> | |
| 35 | inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; | |
| 36 | #endif | |
| 37 | ||
| 38 | _LIBCPP_END_NAMESPACE_STD | |
| 39 | ||
| 40 | #endif // _LIBCPP___TYPE_TRAITS_HAS_VIRTUAL_DESTRUCTOR_H |
lib/libcxx/include/__type_traits/integral_constant.h created+50| ... | ... | @@ -0,0 +1,50 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp, _Tp __v> | |
| 21 | struct _LIBCPP_TEMPLATE_VIS integral_constant | |
| 22 | { | |
| 23 | static _LIBCPP_CONSTEXPR const _Tp value = __v; | |
| 24 | typedef _Tp value_type; | |
| 25 | typedef integral_constant type; | |
| 26 | _LIBCPP_INLINE_VISIBILITY | |
| 27 | _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} | |
| 28 | #if _LIBCPP_STD_VER > 11 | |
| 29 | _LIBCPP_INLINE_VISIBILITY | |
| 30 | constexpr value_type operator ()() const _NOEXCEPT {return value;} | |
| 31 | #endif | |
| 32 | }; | |
| 33 | ||
| 34 | template <class _Tp, _Tp __v> | |
| 35 | _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; | |
| 36 | ||
| 37 | typedef integral_constant<bool, true> true_type; | |
| 38 | typedef integral_constant<bool, false> false_type; | |
| 39 | ||
| 40 | template <bool _Val> | |
| 41 | using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>; | |
| 42 | ||
| 43 | #if _LIBCPP_STD_VER > 14 | |
| 44 | template <bool __b> | |
| 45 | using bool_constant = integral_constant<bool, __b>; | |
| 46 | #endif | |
| 47 | ||
| 48 | _LIBCPP_END_NAMESPACE_STD | |
| 49 | ||
| 50 | #endif // _LIBCPP___TYPE_TRAITS_INTEGRAL_CONSTANT_H |
lib/libcxx/include/__type_traits/is_abstract.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract | |
| 22 | : public integral_constant<bool, __is_abstract(_Tp)> {}; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 14 | |
| 25 | template <class _Tp> | |
| 26 | inline constexpr bool is_abstract_v = __is_abstract(_Tp); | |
| 27 | #endif | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H |
lib/libcxx/include/__type_traits/is_aggregate.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER > 14 | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | |
| 24 | is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; | |
| 25 | ||
| 26 | template <class _Tp> | |
| 27 | inline constexpr bool is_aggregate_v = __is_aggregate(_Tp); | |
| 28 | ||
| 29 | #endif // _LIBCPP_STD_VER > 14 | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H |
lib/libcxx/include/__type_traits/is_arithmetic.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_floating_point.h> | |
| 15 | #include <__type_traits/is_integral.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic | |
| 24 | : public integral_constant<bool, is_integral<_Tp>::value || | |
| 25 | is_floating_point<_Tp>::value> {}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H |
lib/libcxx/include/__type_traits/is_array.h created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_ARRAY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | // TODO: Clang incorrectly reports that __is_array is true for T[0]. | |
| 23 | // Re-enable the branch once https://llvm.org/PR54705 is fixed. | |
| 24 | #if __has_builtin(__is_array) && 0 | |
| 25 | ||
| 26 | template <class _Tp> | |
| 27 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_array_v = __is_array(_Tp); | |
| 32 | #endif | |
| 33 | ||
| 34 | #else | |
| 35 | ||
| 36 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array | |
| 37 | : public false_type {}; | |
| 38 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> | |
| 39 | : public true_type {}; | |
| 40 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> | |
| 41 | : public true_type {}; | |
| 42 | ||
| 43 | #if _LIBCPP_STD_VER > 14 | |
| 44 | template <class _Tp> | |
| 45 | inline constexpr bool is_array_v = is_array<_Tp>::value; | |
| 46 | #endif | |
| 47 | ||
| 48 | #endif // __has_builtin(__is_array) | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___TYPE_TRAITS_IS_ARRAY_H |
lib/libcxx/include/__type_traits/is_assignable.h created+66| ... | ... | @@ -0,0 +1,66 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 22 | ||
| 23 | #if __has_builtin(__is_assignable) | |
| 24 | ||
| 25 | template<class _Tp, class _Up> | |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { }; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp, class _Arg> | |
| 30 | inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); | |
| 31 | #endif | |
| 32 | ||
| 33 | #else // __has_builtin(__is_assignable) | |
| 34 | ||
| 35 | template <class _Tp, class _Arg> | |
| 36 | typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type | |
| 37 | __is_assignable_test(int); | |
| 38 | ||
| 39 | template <class, class> | |
| 40 | false_type __is_assignable_test(...); | |
| 41 | ||
| 42 | ||
| 43 | template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> | |
| 44 | struct __is_assignable_imp | |
| 45 | : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; | |
| 46 | ||
| 47 | template <class _Tp, class _Arg> | |
| 48 | struct __is_assignable_imp<_Tp, _Arg, true> | |
| 49 | : public false_type | |
| 50 | { | |
| 51 | }; | |
| 52 | ||
| 53 | template <class _Tp, class _Arg> | |
| 54 | struct is_assignable | |
| 55 | : public __is_assignable_imp<_Tp, _Arg> {}; | |
| 56 | ||
| 57 | #if _LIBCPP_STD_VER > 14 | |
| 58 | template <class _Tp, class _Arg> | |
| 59 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value; | |
| 60 | #endif | |
| 61 | ||
| 62 | #endif // __has_builtin(__is_assignable) | |
| 63 | ||
| 64 | _LIBCPP_END_NAMESPACE_STD | |
| 65 | ||
| 66 | #endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_base_of.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Bp, class _Dp> | |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_base_of | |
| 23 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Bp, class _Dp> | |
| 27 | inline constexpr bool is_base_of_v = __is_base_of(_Bp, _Dp); | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_BASE_OF_H |
lib/libcxx/include/__type_traits/is_bounded_array.h created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array : false_type {}; | |
| 23 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_bounded_array<_Tp[_Np]> : true_type {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 17 | |
| 26 | ||
| 27 | template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; | |
| 28 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; | |
| 29 | ||
| 30 | template <class _Tp> | |
| 31 | inline constexpr | |
| 32 | bool is_bounded_array_v = is_bounded_array<_Tp>::value; | |
| 33 | ||
| 34 | #endif | |
| 35 | ||
| 36 | _LIBCPP_END_NAMESPACE_STD | |
| 37 | ||
| 38 | #endif // _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H |
lib/libcxx/include/__type_traits/is_callable.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__utility/declval.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template<class _Func, class... _Args, class = decltype(std::declval<_Func>()(std::declval<_Args>()...))> | |
| 23 | true_type __is_callable_helper(int); | |
| 24 | template<class...> | |
| 25 | false_type __is_callable_helper(...); | |
| 26 | ||
| 27 | template<class _Func, class... _Args> | |
| 28 | struct __is_callable : decltype(__is_callable_helper<_Func, _Args...>(0)) {}; | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_CALLABLE_H |
lib/libcxx/include/__type_traits/is_class.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_CLASS_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_CLASS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_union.h> | |
| 15 | #include <__type_traits/remove_cv.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class | |
| 24 | : public integral_constant<bool, __is_class(_Tp)> {}; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_class_v = __is_class(_Tp); | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_CLASS_H |
lib/libcxx/include/__type_traits/is_compound.h created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_fundamental.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if __has_builtin(__is_compound) | |
| 23 | ||
| 24 | template<class _Tp> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { }; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_compound_v = __is_compound(_Tp); | |
| 30 | #endif | |
| 31 | ||
| 32 | #else // __has_builtin(__is_compound) | |
| 33 | ||
| 34 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound | |
| 35 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; | |
| 36 | ||
| 37 | #if _LIBCPP_STD_VER > 14 | |
| 38 | template <class _Tp> | |
| 39 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; | |
| 40 | #endif | |
| 41 | ||
| 42 | #endif // __has_builtin(__is_compound) | |
| 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | |
| 45 | ||
| 46 | #endif // _LIBCPP___TYPE_TRAITS_IS_COMPOUND_H |
lib/libcxx/include/__type_traits/is_const.h created+45| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_CONST_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_CONST_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_const) | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_const_v = __is_const(_Tp); | |
| 29 | #endif | |
| 30 | ||
| 31 | #else | |
| 32 | ||
| 33 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; | |
| 34 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; | |
| 35 | ||
| 36 | #if _LIBCPP_STD_VER > 14 | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_const_v = is_const<_Tp>::value; | |
| 39 | #endif | |
| 40 | ||
| 41 | #endif // __has_builtin(__is_const) | |
| 42 | ||
| 43 | _LIBCPP_END_NAMESPACE_STD | |
| 44 | ||
| 45 | #endif // _LIBCPP___TYPE_TRAITS_IS_CONST_H |
lib/libcxx/include/__type_traits/is_constant_evaluated.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | #if _LIBCPP_STD_VER > 17 | |
| 21 | _LIBCPP_INLINE_VISIBILITY | |
| 22 | inline constexpr bool is_constant_evaluated() noexcept { | |
| 23 | return __builtin_is_constant_evaluated(); | |
| 24 | } | |
| 25 | #endif | |
| 26 | ||
| 27 | inline _LIBCPP_CONSTEXPR | |
| 28 | bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); } | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_CONSTANT_EVALUATED_H |
lib/libcxx/include/__type_traits/is_constructible.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, class ..._Args> | |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_constructible | |
| 23 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> | |
| 24 | { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp, class ..._Args> | |
| 28 | inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_convertible.h created+108| ... | ... | @@ -0,0 +1,108 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_array.h> | |
| 15 | #include <__type_traits/is_function.h> | |
| 16 | #include <__type_traits/is_void.h> | |
| 17 | #include <__type_traits/remove_reference.h> | |
| 18 | #include <__utility/declval.h> | |
| 19 | #include <cstddef> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) | |
| 28 | ||
| 29 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible | |
| 30 | : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {}; | |
| 31 | ||
| 32 | #else // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) | |
| 33 | ||
| 34 | namespace __is_convertible_imp | |
| 35 | { | |
| 36 | template <class _Tp> void __test_convert(_Tp); | |
| 37 | ||
| 38 | template <class _From, class _To, class = void> | |
| 39 | struct __is_convertible_test : public false_type {}; | |
| 40 | ||
| 41 | template <class _From, class _To> | |
| 42 | struct __is_convertible_test<_From, _To, | |
| 43 | decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type | |
| 44 | {}; | |
| 45 | ||
| 46 | template <class _Tp, bool _IsArray = is_array<_Tp>::value, | |
| 47 | bool _IsFunction = is_function<_Tp>::value, | |
| 48 | bool _IsVoid = is_void<_Tp>::value> | |
| 49 | struct __is_array_function_or_void {enum {value = 0};}; | |
| 50 | template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; | |
| 51 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; | |
| 52 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; | |
| 53 | } | |
| 54 | ||
| 55 | template <class _Tp, | |
| 56 | unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> | |
| 57 | struct __is_convertible_check | |
| 58 | { | |
| 59 | static const size_t __v = 0; | |
| 60 | }; | |
| 61 | ||
| 62 | template <class _Tp> | |
| 63 | struct __is_convertible_check<_Tp, 0> | |
| 64 | { | |
| 65 | static const size_t __v = sizeof(_Tp); | |
| 66 | }; | |
| 67 | ||
| 68 | template <class _T1, class _T2, | |
| 69 | unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, | |
| 70 | unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> | |
| 71 | struct __is_convertible | |
| 72 | : public integral_constant<bool, | |
| 73 | __is_convertible_imp::__is_convertible_test<_T1, _T2>::value | |
| 74 | > | |
| 75 | {}; | |
| 76 | ||
| 77 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; | |
| 78 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; | |
| 79 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; | |
| 80 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; | |
| 81 | ||
| 82 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; | |
| 83 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; | |
| 84 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; | |
| 85 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; | |
| 86 | ||
| 87 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; | |
| 88 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; | |
| 89 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; | |
| 90 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; | |
| 91 | ||
| 92 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible | |
| 93 | : public __is_convertible<_T1, _T2> | |
| 94 | { | |
| 95 | static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; | |
| 96 | static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; | |
| 97 | }; | |
| 98 | ||
| 99 | #endif // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) | |
| 100 | ||
| 101 | #if _LIBCPP_STD_VER > 14 | |
| 102 | template <class _From, class _To> | |
| 103 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; | |
| 104 | #endif | |
| 105 | ||
| 106 | _LIBCPP_END_NAMESPACE_STD | |
| 107 | ||
| 108 | #endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H |
lib/libcxx/include/__type_traits/is_copy_assignable.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_assignable.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable | |
| 25 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 26 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_copy_constructible.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_constructible.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible | |
| 26 | : public is_constructible<_Tp, | |
| 27 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_core_convertible.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | // [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed. | |
| 22 | // We can't test for that, but we can test implicit convertibility by passing it | |
| 23 | // to a function. Notice that __is_core_convertible<void,void> is false, | |
| 24 | // and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later. | |
| 25 | ||
| 26 | template <class _Tp, class _Up, class = void> | |
| 27 | struct __is_core_convertible : public false_type {}; | |
| 28 | ||
| 29 | template <class _Tp, class _Up> | |
| 30 | struct __is_core_convertible<_Tp, _Up, decltype( | |
| 31 | static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() ) | |
| 32 | )> : public true_type {}; | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_CORE_CONVERTIBLE_H |
lib/libcxx/include/__type_traits/is_default_constructible.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_constructible.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> | |
| 23 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible | |
| 24 | : public is_constructible<_Tp> | |
| 25 | {}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_destructible.h created+102| ... | ... | @@ -0,0 +1,102 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_function.h> | |
| 15 | #include <__type_traits/is_reference.h> | |
| 16 | #include <__type_traits/remove_all_extents.h> | |
| 17 | #include <__utility/declval.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if __has_builtin(__is_destructible) | |
| 26 | ||
| 27 | template<class _Tp> | |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { }; | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 14 | |
| 31 | template <class _Tp> | |
| 32 | inline constexpr bool is_destructible_v = __is_destructible(_Tp); | |
| 33 | #endif | |
| 34 | ||
| 35 | #else // __has_builtin(__is_destructible) | |
| 36 | ||
| 37 | // if it's a reference, return true | |
| 38 | // if it's a function, return false | |
| 39 | // if it's void, return false | |
| 40 | // if it's an array of unknown bound, return false | |
| 41 | // Otherwise, return "declval<_Up&>().~_Up()" is well-formed | |
| 42 | // where _Up is remove_all_extents<_Tp>::type | |
| 43 | ||
| 44 | template <class> | |
| 45 | struct __is_destructible_apply { typedef int type; }; | |
| 46 | ||
| 47 | template <typename _Tp> | |
| 48 | struct __is_destructor_wellformed { | |
| 49 | template <typename _Tp1> | |
| 50 | static true_type __test ( | |
| 51 | typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type | |
| 52 | ); | |
| 53 | ||
| 54 | template <typename _Tp1> | |
| 55 | static false_type __test (...); | |
| 56 | ||
| 57 | static const bool value = decltype(__test<_Tp>(12))::value; | |
| 58 | }; | |
| 59 | ||
| 60 | template <class _Tp, bool> | |
| 61 | struct __destructible_imp; | |
| 62 | ||
| 63 | template <class _Tp> | |
| 64 | struct __destructible_imp<_Tp, false> | |
| 65 | : public integral_constant<bool, | |
| 66 | __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {}; | |
| 67 | ||
| 68 | template <class _Tp> | |
| 69 | struct __destructible_imp<_Tp, true> | |
| 70 | : public true_type {}; | |
| 71 | ||
| 72 | template <class _Tp, bool> | |
| 73 | struct __destructible_false; | |
| 74 | ||
| 75 | template <class _Tp> | |
| 76 | struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {}; | |
| 77 | ||
| 78 | template <class _Tp> | |
| 79 | struct __destructible_false<_Tp, true> : public false_type {}; | |
| 80 | ||
| 81 | template <class _Tp> | |
| 82 | struct is_destructible | |
| 83 | : public __destructible_false<_Tp, is_function<_Tp>::value> {}; | |
| 84 | ||
| 85 | template <class _Tp> | |
| 86 | struct is_destructible<_Tp[]> | |
| 87 | : public false_type {}; | |
| 88 | ||
| 89 | template <> | |
| 90 | struct is_destructible<void> | |
| 91 | : public false_type {}; | |
| 92 | ||
| 93 | #if _LIBCPP_STD_VER > 14 | |
| 94 | template <class _Tp> | |
| 95 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; | |
| 96 | #endif | |
| 97 | ||
| 98 | #endif // __has_builtin(__is_destructible) | |
| 99 | ||
| 100 | _LIBCPP_END_NAMESPACE_STD | |
| 101 | ||
| 102 | #endif // _LIBCPP___TYPE_TRAITS_IS_DESTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_empty.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_EMPTY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_EMPTY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> | |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_empty | |
| 23 | : public integral_constant<bool, __is_empty(_Tp)> {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Tp> | |
| 27 | inline constexpr bool is_empty_v = __is_empty(_Tp); | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_EMPTY_H |
lib/libcxx/include/__type_traits/is_enum.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_ENUM_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_ENUM_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum | |
| 23 | : public integral_constant<bool, __is_enum(_Tp)> {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Tp> | |
| 27 | inline constexpr bool is_enum_v = __is_enum(_Tp); | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H |
lib/libcxx/include/__type_traits/is_final.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_FINAL_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_FINAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | |
| 22 | __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 11 | |
| 25 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | |
| 26 | is_final : public integral_constant<bool, __is_final(_Tp)> {}; | |
| 27 | #endif | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_final_v = __is_final(_Tp); | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_FINAL_H |
lib/libcxx/include/__type_traits/is_floating_point.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; | |
| 23 | template <> struct __libcpp_is_floating_point<float> : public true_type {}; | |
| 24 | template <> struct __libcpp_is_floating_point<double> : public true_type {}; | |
| 25 | template <> struct __libcpp_is_floating_point<long double> : public true_type {}; | |
| 26 | ||
| 27 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point | |
| 28 | : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 14 | |
| 31 | template <class _Tp> | |
| 32 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; | |
| 33 | #endif | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___TYPE_TRAITS_IS_FLOATING_POINT_H |
lib/libcxx/include/__type_traits/is_function.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_const.h> | |
| 15 | #include <__type_traits/is_reference.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if __has_builtin(__is_function) | |
| 24 | ||
| 25 | template <class _Tp> | |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {}; | |
| 27 | ||
| 28 | #else | |
| 29 | ||
| 30 | template <class _Tp> | |
| 31 | struct _LIBCPP_TEMPLATE_VIS is_function | |
| 32 | : public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {}; | |
| 33 | ||
| 34 | #endif // __has_builtin(__is_function) | |
| 35 | ||
| 36 | #if _LIBCPP_STD_VER > 14 | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_function_v = is_function<_Tp>::value; | |
| 39 | #endif | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | #endif // _LIBCPP___TYPE_TRAITS_IS_FUNCTIONAL_H |
lib/libcxx/include/__type_traits/is_fundamental.h created+49| ... | ... | @@ -0,0 +1,49 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_null_pointer.h> | |
| 15 | #include <__type_traits/is_void.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | #if __has_builtin(__is_fundamental) | |
| 24 | ||
| 25 | template<class _Tp> | |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { }; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); | |
| 31 | #endif | |
| 32 | ||
| 33 | #else // __has_builtin(__is_fundamental) | |
| 34 | ||
| 35 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental | |
| 36 | : public integral_constant<bool, is_void<_Tp>::value || | |
| 37 | __is_nullptr_t<_Tp>::value || | |
| 38 | is_arithmetic<_Tp>::value> {}; | |
| 39 | ||
| 40 | #if _LIBCPP_STD_VER > 14 | |
| 41 | template <class _Tp> | |
| 42 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; | |
| 43 | #endif | |
| 44 | ||
| 45 | #endif // __has_builtin(__is_fundamental) | |
| 46 | ||
| 47 | _LIBCPP_END_NAMESPACE_STD | |
| 48 | ||
| 49 | #endif // _LIBCPP___TYPE_TRAITS_IS_FUNDAMENTAL_H |
lib/libcxx/include/__type_traits/is_integral.h created+72| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; }; | |
| 23 | template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; }; | |
| 24 | template <> struct __libcpp_is_integral<char> { enum { value = 1 }; }; | |
| 25 | template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; }; | |
| 26 | template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; }; | |
| 27 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 28 | template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; }; | |
| 29 | #endif | |
| 30 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 31 | template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; }; | |
| 32 | #endif | |
| 33 | template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; }; | |
| 34 | template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; }; | |
| 35 | template <> struct __libcpp_is_integral<short> { enum { value = 1 }; }; | |
| 36 | template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; }; | |
| 37 | template <> struct __libcpp_is_integral<int> { enum { value = 1 }; }; | |
| 38 | template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; }; | |
| 39 | template <> struct __libcpp_is_integral<long> { enum { value = 1 }; }; | |
| 40 | template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; }; | |
| 41 | template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; }; | |
| 42 | template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; }; | |
| 43 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 44 | template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; | |
| 45 | template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; | |
| 46 | #endif | |
| 47 | ||
| 48 | #if __has_builtin(__is_integral) | |
| 49 | ||
| 50 | template <class _Tp> | |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { }; | |
| 52 | ||
| 53 | #if _LIBCPP_STD_VER > 14 | |
| 54 | template <class _Tp> | |
| 55 | inline constexpr bool is_integral_v = __is_integral(_Tp); | |
| 56 | #endif | |
| 57 | ||
| 58 | #else | |
| 59 | ||
| 60 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral | |
| 61 | : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {}; | |
| 62 | ||
| 63 | #if _LIBCPP_STD_VER > 14 | |
| 64 | template <class _Tp> | |
| 65 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; | |
| 66 | #endif | |
| 67 | ||
| 68 | #endif // __has_builtin(__is_integral) | |
| 69 | ||
| 70 | _LIBCPP_END_NAMESPACE_STD | |
| 71 | ||
| 72 | #endif // _LIBCPP___TYPE_TRAITS_IS_INTEGRAL_H |
lib/libcxx/include/__type_traits/is_literal_type.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) | |
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type | |
| 23 | : public integral_constant<bool, __is_literal_type(_Tp)> | |
| 24 | {}; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | _LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; | |
| 29 | #endif // _LIBCPP_STD_VER > 14 | |
| 30 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE |
lib/libcxx/include/__type_traits/is_member_function_pointer.h created+64| ... | ... | @@ -0,0 +1,64 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_function.h> | |
| 15 | #include <__type_traits/remove_cv.h> | |
| 16 | #include <cstddef> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct __libcpp_is_member_pointer { | |
| 25 | enum { | |
| 26 | __is_member = false, | |
| 27 | __is_func = false, | |
| 28 | __is_obj = false | |
| 29 | }; | |
| 30 | }; | |
| 31 | template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> { | |
| 32 | enum { | |
| 33 | __is_member = true, | |
| 34 | __is_func = is_function<_Tp>::value, | |
| 35 | __is_obj = !__is_func, | |
| 36 | }; | |
| 37 | }; | |
| 38 | ||
| 39 | #if __has_builtin(__is_member_function_pointer) | |
| 40 | ||
| 41 | template<class _Tp> | |
| 42 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | |
| 43 | : _BoolConstant<__is_member_function_pointer(_Tp)> { }; | |
| 44 | ||
| 45 | #if _LIBCPP_STD_VER > 14 | |
| 46 | template <class _Tp> | |
| 47 | inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); | |
| 48 | #endif | |
| 49 | ||
| 50 | #else // __has_builtin(__is_member_function_pointer) | |
| 51 | ||
| 52 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | |
| 53 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {}; | |
| 54 | ||
| 55 | #if _LIBCPP_STD_VER > 14 | |
| 56 | template <class _Tp> | |
| 57 | inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; | |
| 58 | #endif | |
| 59 | ||
| 60 | #endif // __has_builtin(__is_member_function_pointer) | |
| 61 | ||
| 62 | _LIBCPP_END_NAMESPACE_STD | |
| 63 | ||
| 64 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H |
lib/libcxx/include/__type_traits/is_member_object_pointer.h created+46| ... | ... | @@ -0,0 +1,46 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_member_object_pointer) | |
| 22 | ||
| 23 | template<class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | |
| 25 | : _BoolConstant<__is_member_object_pointer(_Tp)> { }; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); | |
| 30 | #endif | |
| 31 | ||
| 32 | #else // __has_builtin(__is_member_object_pointer) | |
| 33 | ||
| 34 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | |
| 35 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {}; | |
| 36 | ||
| 37 | #if _LIBCPP_STD_VER > 14 | |
| 38 | template <class _Tp> | |
| 39 | inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; | |
| 40 | #endif | |
| 41 | ||
| 42 | #endif // __has_builtin(__is_member_object_pointer) | |
| 43 | ||
| 44 | _LIBCPP_END_NAMESPACE_STD | |
| 45 | ||
| 46 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H |
lib/libcxx/include/__type_traits/is_member_pointer.h created+45| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_member_pointer) | |
| 22 | ||
| 23 | template<class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); | |
| 29 | #endif | |
| 30 | ||
| 31 | #else // __has_builtin(__is_member_pointer) | |
| 32 | ||
| 33 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer | |
| 34 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {}; | |
| 35 | ||
| 36 | #if _LIBCPP_STD_VER > 14 | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; | |
| 39 | #endif | |
| 40 | ||
| 41 | #endif // __has_builtin(__is_member_pointer) | |
| 42 | ||
| 43 | _LIBCPP_END_NAMESPACE_STD | |
| 44 | ||
| 45 | #endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H |
lib/libcxx/include/__type_traits/is_move_assignable.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/add_rvalue_reference.h> | |
| 16 | #include <__type_traits/integral_constant.h> | |
| 17 | #include <__type_traits/is_assignable.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable | |
| 26 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 27 | typename add_rvalue_reference<_Tp>::type> {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_move_constructible.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_rvalue_reference.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_constructible.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible | |
| 25 | : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> | |
| 26 | {}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_nothrow_assignable.h created+59| ... | ... | @@ -0,0 +1,59 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if __has_builtin(__is_nothrow_assignable) | |
| 23 | ||
| 24 | template <class _Tp, class _Arg> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable | |
| 26 | : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; | |
| 27 | ||
| 28 | #else | |
| 29 | ||
| 30 | template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; | |
| 31 | ||
| 32 | template <class _Tp, class _Arg> | |
| 33 | struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> | |
| 34 | : public false_type | |
| 35 | { | |
| 36 | }; | |
| 37 | ||
| 38 | template <class _Tp, class _Arg> | |
| 39 | struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> | |
| 40 | : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) > | |
| 41 | { | |
| 42 | }; | |
| 43 | ||
| 44 | template <class _Tp, class _Arg> | |
| 45 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable | |
| 46 | : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> | |
| 47 | { | |
| 48 | }; | |
| 49 | ||
| 50 | #endif // __has_builtin(__is_nothrow_assignable) | |
| 51 | ||
| 52 | #if _LIBCPP_STD_VER > 14 | |
| 53 | template <class _Tp, class _Arg> | |
| 54 | inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value; | |
| 55 | #endif | |
| 56 | ||
| 57 | _LIBCPP_END_NAMESPACE_STD | |
| 58 | ||
| 59 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_nothrow_constructible.h created+75| ... | ... | @@ -0,0 +1,75 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__utility/declval.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if __has_builtin(__is_nothrow_constructible) | |
| 23 | ||
| 24 | template <class _Tp, class... _Args> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | |
| 26 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; | |
| 27 | ||
| 28 | #else | |
| 29 | ||
| 30 | template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; | |
| 31 | ||
| 32 | template <class _Tp, class... _Args> | |
| 33 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...> | |
| 34 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> | |
| 35 | { | |
| 36 | }; | |
| 37 | ||
| 38 | template <class _Tp> | |
| 39 | void __implicit_conversion_to(_Tp) noexcept { } | |
| 40 | ||
| 41 | template <class _Tp, class _Arg> | |
| 42 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg> | |
| 43 | : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))> | |
| 44 | { | |
| 45 | }; | |
| 46 | ||
| 47 | template <class _Tp, bool _IsReference, class... _Args> | |
| 48 | struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...> | |
| 49 | : public false_type | |
| 50 | { | |
| 51 | }; | |
| 52 | ||
| 53 | template <class _Tp, class... _Args> | |
| 54 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | |
| 55 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...> | |
| 56 | { | |
| 57 | }; | |
| 58 | ||
| 59 | template <class _Tp, size_t _Ns> | |
| 60 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> | |
| 61 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> | |
| 62 | { | |
| 63 | }; | |
| 64 | ||
| 65 | #endif // __has_builtin(__is_nothrow_constructible) | |
| 66 | ||
| 67 | ||
| 68 | #if _LIBCPP_STD_VER > 14 | |
| 69 | template <class _Tp, class ..._Args> | |
| 70 | inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; | |
| 71 | #endif | |
| 72 | ||
| 73 | _LIBCPP_END_NAMESPACE_STD | |
| 74 | ||
| 75 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_nothrow_convertible.h created+53| ... | ... | @@ -0,0 +1,53 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/conjunction.h> | |
| 14 | #include <__type_traits/disjunction.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_convertible.h> | |
| 17 | #include <__type_traits/is_void.h> | |
| 18 | #include <__type_traits/lazy.h> | |
| 19 | #include <__utility/declval.h> | |
| 20 | ||
| 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 22 | # pragma GCC system_header | |
| 23 | #endif | |
| 24 | ||
| 25 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 28 | ||
| 29 | template <typename _Tp> | |
| 30 | static void __test_noexcept(_Tp) noexcept; | |
| 31 | ||
| 32 | template<typename _Fm, typename _To> | |
| 33 | static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))> | |
| 34 | __is_nothrow_convertible_test(); | |
| 35 | ||
| 36 | template <typename _Fm, typename _To> | |
| 37 | struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) | |
| 38 | { }; | |
| 39 | ||
| 40 | template <typename _Fm, typename _To> | |
| 41 | struct is_nothrow_convertible : _Or< | |
| 42 | _And<is_void<_To>, is_void<_Fm>>, | |
| 43 | _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> | |
| 44 | >::type { }; | |
| 45 | ||
| 46 | template <typename _Fm, typename _To> | |
| 47 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; | |
| 48 | ||
| 49 | #endif // _LIBCPP_STD_VER > 17 | |
| 50 | ||
| 51 | _LIBCPP_END_NAMESPACE_STD | |
| 52 | ||
| 53 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H |
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_nothrow_assignable.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | |
| 25 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 26 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_nothrow_constructible.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible | |
| 25 | : public is_nothrow_constructible<_Tp, | |
| 26 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_nothrow_constructible.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | |
| 23 | : public is_nothrow_constructible<_Tp> | |
| 24 | {}; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_nothrow_destructible.h created+90| ... | ... | @@ -0,0 +1,90 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_destructible.h> | |
| 16 | #include <__type_traits/is_reference.h> | |
| 17 | #include <__type_traits/is_scalar.h> | |
| 18 | #include <__type_traits/remove_all_extents.h> | |
| 19 | #include <__utility/declval.h> | |
| 20 | #include <cstddef> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 29 | ||
| 30 | template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; | |
| 31 | ||
| 32 | template <class _Tp> | |
| 33 | struct __libcpp_is_nothrow_destructible<false, _Tp> | |
| 34 | : public false_type | |
| 35 | { | |
| 36 | }; | |
| 37 | ||
| 38 | template <class _Tp> | |
| 39 | struct __libcpp_is_nothrow_destructible<true, _Tp> | |
| 40 | : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) > | |
| 41 | { | |
| 42 | }; | |
| 43 | ||
| 44 | template <class _Tp> | |
| 45 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible | |
| 46 | : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> | |
| 47 | { | |
| 48 | }; | |
| 49 | ||
| 50 | template <class _Tp, size_t _Ns> | |
| 51 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> | |
| 52 | : public is_nothrow_destructible<_Tp> | |
| 53 | { | |
| 54 | }; | |
| 55 | ||
| 56 | template <class _Tp> | |
| 57 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> | |
| 58 | : public true_type | |
| 59 | { | |
| 60 | }; | |
| 61 | ||
| 62 | template <class _Tp> | |
| 63 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> | |
| 64 | : public true_type | |
| 65 | { | |
| 66 | }; | |
| 67 | ||
| 68 | #else | |
| 69 | ||
| 70 | template <class _Tp> struct __libcpp_nothrow_destructor | |
| 71 | : public integral_constant<bool, is_scalar<_Tp>::value || | |
| 72 | is_reference<_Tp>::value> {}; | |
| 73 | ||
| 74 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible | |
| 75 | : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; | |
| 76 | ||
| 77 | template <class _Tp> | |
| 78 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> | |
| 79 | : public false_type {}; | |
| 80 | ||
| 81 | #endif | |
| 82 | ||
| 83 | #if _LIBCPP_STD_VER > 14 | |
| 84 | template <class _Tp> | |
| 85 | inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; | |
| 86 | #endif | |
| 87 | ||
| 88 | _LIBCPP_END_NAMESPACE_STD | |
| 89 | ||
| 90 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_lvalue_reference.h> | |
| 14 | #include <__type_traits/add_rvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_nothrow_assignable.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | |
| 25 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 26 | typename add_rvalue_reference<_Tp>::type> | |
| 27 | {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_rvalue_reference.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_nothrow_constructible.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible | |
| 24 | : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> | |
| 25 | {}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_null_pointer.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | #include <cstddef> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; | |
| 24 | template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; | |
| 25 | ||
| 26 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t | |
| 27 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 11 | |
| 30 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer | |
| 31 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; | |
| 32 | ||
| 33 | #if _LIBCPP_STD_VER > 14 | |
| 34 | template <class _Tp> | |
| 35 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; | |
| 36 | #endif | |
| 37 | #endif // _LIBCPP_STD_VER > 11 | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___TYPE_TRAITS_IS_NULL_POINTER_H |
lib/libcxx/include/__type_traits/is_object.h created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_OBJECT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_OBJECT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_array.h> | |
| 15 | #include <__type_traits/is_class.h> | |
| 16 | #include <__type_traits/is_scalar.h> | |
| 17 | #include <__type_traits/is_union.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if __has_builtin(__is_object) | |
| 26 | ||
| 27 | template<class _Tp> | |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { }; | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 14 | |
| 31 | template <class _Tp> | |
| 32 | inline constexpr bool is_object_v = __is_object(_Tp); | |
| 33 | #endif | |
| 34 | ||
| 35 | #else // __has_builtin(__is_object) | |
| 36 | ||
| 37 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object | |
| 38 | : public integral_constant<bool, is_scalar<_Tp>::value || | |
| 39 | is_array<_Tp>::value || | |
| 40 | is_union<_Tp>::value || | |
| 41 | is_class<_Tp>::value > {}; | |
| 42 | ||
| 43 | #if _LIBCPP_STD_VER > 14 | |
| 44 | template <class _Tp> | |
| 45 | inline constexpr bool is_object_v = is_object<_Tp>::value; | |
| 46 | #endif | |
| 47 | ||
| 48 | #endif // __has_builtin(__is_object) | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___TYPE_TRAITS_IS_OBJECT_H |
lib/libcxx/include/__type_traits/is_pod.h created+43| ... | ... | @@ -0,0 +1,43 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_POD_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_POD_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_pod) | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod | |
| 24 | : public integral_constant<bool, __is_pod(_Tp)> {}; | |
| 25 | ||
| 26 | #else | |
| 27 | ||
| 28 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod | |
| 29 | : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && | |
| 30 | is_trivially_copy_constructible<_Tp>::value && | |
| 31 | is_trivially_copy_assignable<_Tp>::value && | |
| 32 | is_trivially_destructible<_Tp>::value> {}; | |
| 33 | ||
| 34 | #endif // __has_builtin(__is_pod) | |
| 35 | ||
| 36 | #if _LIBCPP_STD_VER > 14 | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; | |
| 39 | #endif | |
| 40 | ||
| 41 | _LIBCPP_END_NAMESPACE_STD | |
| 42 | ||
| 43 | #endif // _LIBCPP___TYPE_TRAITS_IS_POD_H |
lib/libcxx/include/__type_traits/is_pointer.h created+57| ... | ... | @@ -0,0 +1,57 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | #if __has_builtin(__is_pointer) | |
| 23 | ||
| 24 | template<class _Tp> | |
| 25 | struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { }; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_pointer_v = __is_pointer(_Tp); | |
| 30 | #endif | |
| 31 | ||
| 32 | #else // __has_builtin(__is_pointer) | |
| 33 | ||
| 34 | template <class _Tp> struct __libcpp_is_pointer : public false_type {}; | |
| 35 | template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; | |
| 36 | ||
| 37 | template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; | |
| 38 | #if defined(_LIBCPP_HAS_OBJC_ARC) | |
| 39 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; | |
| 40 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; | |
| 41 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; | |
| 42 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; | |
| 43 | #endif | |
| 44 | ||
| 45 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer | |
| 46 | : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {}; | |
| 47 | ||
| 48 | #if _LIBCPP_STD_VER > 14 | |
| 49 | template <class _Tp> | |
| 50 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; | |
| 51 | #endif | |
| 52 | ||
| 53 | #endif // __has_builtin(__is_pointer) | |
| 54 | ||
| 55 | _LIBCPP_END_NAMESPACE_STD | |
| 56 | ||
| 57 | #endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H |
lib/libcxx/include/__type_traits/is_polymorphic.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> | |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_polymorphic | |
| 23 | : public integral_constant<bool, __is_polymorphic(_Tp)> {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Tp> | |
| 27 | inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp); | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_POLYMORPHIC_H |
lib/libcxx/include/__type_traits/is_primary_template.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/enable_if.h> | |
| 14 | #include <__type_traits/is_same.h> | |
| 15 | #include <__type_traits/is_valid_expansion.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | using __test_for_primary_template = __enable_if_t< | |
| 25 | _IsSame<_Tp, typename _Tp::__primary_template>::value | |
| 26 | >; | |
| 27 | template <class _Tp> | |
| 28 | using __is_primary_template = _IsValidExpansion< | |
| 29 | __test_for_primary_template, _Tp | |
| 30 | >; | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H |
lib/libcxx/include/__type_traits/is_reference.h created+70| ... | ... | @@ -0,0 +1,70 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_lvalue_reference) && \ | |
| 22 | __has_builtin(__is_rvalue_reference) && \ | |
| 23 | __has_builtin(__is_reference) | |
| 24 | ||
| 25 | template<class _Tp> | |
| 26 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; | |
| 27 | ||
| 28 | template<class _Tp> | |
| 29 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { }; | |
| 30 | ||
| 31 | template<class _Tp> | |
| 32 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; | |
| 33 | ||
| 34 | #if _LIBCPP_STD_VER > 14 | |
| 35 | template <class _Tp> | |
| 36 | inline constexpr bool is_reference_v = __is_reference(_Tp); | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | |
| 39 | template <class _Tp> | |
| 40 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | |
| 41 | #endif | |
| 42 | ||
| 43 | #else // __has_builtin(__is_lvalue_reference) && etc... | |
| 44 | ||
| 45 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; | |
| 46 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; | |
| 47 | ||
| 48 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; | |
| 49 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; | |
| 50 | ||
| 51 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; | |
| 52 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; | |
| 53 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; | |
| 54 | ||
| 55 | #if _LIBCPP_STD_VER > 14 | |
| 56 | template <class _Tp> | |
| 57 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; | |
| 58 | ||
| 59 | template <class _Tp> | |
| 60 | inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; | |
| 61 | ||
| 62 | template <class _Tp> | |
| 63 | inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; | |
| 64 | #endif | |
| 65 | ||
| 66 | #endif // __has_builtin(__is_lvalue_reference) && etc... | |
| 67 | ||
| 68 | _LIBCPP_END_NAMESPACE_STD | |
| 69 | ||
| 70 | #endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCE_H |
lib/libcxx/include/__type_traits/is_reference_wrapper.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper; | |
| 23 | ||
| 24 | template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; | |
| 25 | template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; | |
| 26 | template <class _Tp> struct __is_reference_wrapper | |
| 27 | : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {}; | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_ENABLE_IF_H |
lib/libcxx/include/__type_traits/is_referenceable.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_same.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | struct __is_referenceable_impl { | |
| 23 | template <class _Tp> static _Tp& __test(int); | |
| 24 | template <class _Tp> static false_type __test(...); | |
| 25 | }; | |
| 26 | ||
| 27 | template <class _Tp> | |
| 28 | struct __is_referenceable : integral_constant<bool, | |
| 29 | _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {}; | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H |
lib/libcxx/include/__type_traits/is_same.h created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SAME_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SAME_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, class _Up> | |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 14 | |
| 25 | template <class _Tp, class _Up> | |
| 26 | inline constexpr bool is_same_v = __is_same(_Tp, _Up); | |
| 27 | #endif | |
| 28 | ||
| 29 | // _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types: | |
| 30 | // is_same<A,B> and is_same<C,D> are guaranteed to be different types, but | |
| 31 | // _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type). | |
| 32 | // Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame | |
| 33 | // mustn't be directly used anywhere that contributes to name-mangling | |
| 34 | // (such as in a dependent return type). | |
| 35 | ||
| 36 | template <class _Tp, class _Up> | |
| 37 | using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; | |
| 38 | ||
| 39 | template <class _Tp, class _Up> | |
| 40 | using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>; | |
| 41 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | |
| 43 | ||
| 44 | #endif // _LIBCPP___TYPE_TRAITS_IS_SAME_H |
lib/libcxx/include/__type_traits/is_scalar.h created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SCALAR_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SCALAR_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_arithmetic.h> | |
| 15 | #include <__type_traits/is_enum.h> | |
| 16 | #include <__type_traits/is_member_pointer.h> | |
| 17 | #include <__type_traits/is_pointer.h> | |
| 18 | ||
| 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 20 | # pragma GCC system_header | |
| 21 | #endif | |
| 22 | ||
| 23 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 24 | ||
| 25 | #if __has_builtin(__is_scalar) | |
| 26 | ||
| 27 | template<class _Tp> | |
| 28 | struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { }; | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 14 | |
| 31 | template <class _Tp> | |
| 32 | inline constexpr bool is_scalar_v = __is_scalar(_Tp); | |
| 33 | #endif | |
| 34 | ||
| 35 | #else // __has_builtin(__is_scalar) | |
| 36 | ||
| 37 | template <class _Tp> struct __is_block : false_type {}; | |
| 38 | #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) | |
| 39 | template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {}; | |
| 40 | #endif | |
| 41 | ||
| 42 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar | |
| 43 | : public integral_constant<bool, is_arithmetic<_Tp>::value || | |
| 44 | is_member_pointer<_Tp>::value || | |
| 45 | is_pointer<_Tp>::value || | |
| 46 | __is_nullptr_t<_Tp>::value || | |
| 47 | __is_block<_Tp>::value || | |
| 48 | is_enum<_Tp>::value > {}; | |
| 49 | ||
| 50 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; | |
| 51 | ||
| 52 | #if _LIBCPP_STD_VER > 14 | |
| 53 | template <class _Tp> | |
| 54 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; | |
| 55 | #endif | |
| 56 | ||
| 57 | #endif // __has_builtin(__is_scalar) | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP___TYPE_TRAITS_IS_SCALAR_H |
lib/libcxx/include/__type_traits/is_scoped_enum.h created+42| ... | ... | @@ -0,0 +1,42 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_convertible.h> | |
| 15 | #include <__type_traits/is_enum.h> | |
| 16 | #include <__type_traits/underlying_type.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 20 | |
| 25 | template <class _Tp, bool = is_enum_v<_Tp> > | |
| 26 | struct __is_scoped_enum_helper : false_type {}; | |
| 27 | ||
| 28 | template <class _Tp> | |
| 29 | struct __is_scoped_enum_helper<_Tp, true> | |
| 30 | : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {}; | |
| 31 | ||
| 32 | template <class _Tp> | |
| 33 | struct _LIBCPP_TEMPLATE_VIS is_scoped_enum | |
| 34 | : public __is_scoped_enum_helper<_Tp> {}; | |
| 35 | ||
| 36 | template <class _Tp> | |
| 37 | inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; | |
| 38 | #endif | |
| 39 | ||
| 40 | _LIBCPP_END_NAMESPACE_STD | |
| 41 | ||
| 42 | #endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H |
lib/libcxx/include/__type_traits/is_signed.h created+55| ... | ... | @@ -0,0 +1,55 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SIGNED_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SIGNED_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_signed) | |
| 22 | ||
| 23 | template<class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_signed_v = __is_signed(_Tp); | |
| 29 | #endif | |
| 30 | ||
| 31 | #else // __has_builtin(__is_signed) | |
| 32 | ||
| 33 | template <class _Tp, bool = is_integral<_Tp>::value> | |
| 34 | struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {}; | |
| 35 | ||
| 36 | template <class _Tp> | |
| 37 | struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point | |
| 38 | ||
| 39 | template <class _Tp, bool = is_arithmetic<_Tp>::value> | |
| 40 | struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; | |
| 41 | ||
| 42 | template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; | |
| 43 | ||
| 44 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; | |
| 45 | ||
| 46 | #if _LIBCPP_STD_VER > 14 | |
| 47 | template <class _Tp> | |
| 48 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; | |
| 49 | #endif | |
| 50 | ||
| 51 | #endif // __has_builtin(__is_signed) | |
| 52 | ||
| 53 | _LIBCPP_END_NAMESPACE_STD | |
| 54 | ||
| 55 | #endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_H |
lib/libcxx/include/__type_traits/is_signed_integer.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct __libcpp_is_signed_integer : public false_type {}; | |
| 22 | template <> struct __libcpp_is_signed_integer<signed char> : public true_type {}; | |
| 23 | template <> struct __libcpp_is_signed_integer<signed short> : public true_type {}; | |
| 24 | template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; | |
| 25 | template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; | |
| 26 | template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; | |
| 27 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 28 | template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H |
lib/libcxx/include/__type_traits/is_standard_layout.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout | |
| 22 | #if __has_builtin(__is_standard_layout) | |
| 23 | : public integral_constant<bool, __is_standard_layout(_Tp)> | |
| 24 | #else | |
| 25 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> | |
| 26 | #endif | |
| 27 | {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_STANDARD_LAYOUT_H |
lib/libcxx/include/__type_traits/is_trivial.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial | |
| 22 | #if __has_builtin(__is_trivial) | |
| 23 | : public integral_constant<bool, __is_trivial(_Tp)> | |
| 24 | #else | |
| 25 | : integral_constant<bool, is_trivially_copyable<_Tp>::value && | |
| 26 | is_trivially_default_constructible<_Tp>::value> | |
| 27 | #endif | |
| 28 | {}; | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 14 | |
| 31 | template <class _Tp> | |
| 32 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; | |
| 33 | #endif | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIAL_H |
lib/libcxx/include/__type_traits/is_trivially_assignable.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, class _Arg> | |
| 22 | struct is_trivially_assignable | |
| 23 | : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> | |
| 24 | { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp, class _Arg> | |
| 28 | inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_trivially_constructible.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, class... _Args> | |
| 22 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible | |
| 23 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> | |
| 24 | { | |
| 25 | }; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp, class... _Args> | |
| 29 | inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.h created+35| ... | ... | @@ -0,0 +1,35 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_const.h> | |
| 14 | #include <__type_traits/add_lvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_trivially_assignable.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable | |
| 25 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 26 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 14 | |
| 29 | template <class _Tp> | |
| 30 | inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; | |
| 31 | #endif | |
| 32 | ||
| 33 | _LIBCPP_END_NAMESPACE_STD | |
| 34 | ||
| 35 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_lvalue_reference.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_trivially_constructible.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible | |
| 24 | : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> | |
| 25 | {}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_trivially_copyable.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable | |
| 22 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> | |
| 23 | {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Tp> | |
| 27 | inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPYABLE_H |
lib/libcxx/include/__type_traits/is_trivially_default_constructible.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_trivially_constructible.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible | |
| 23 | : public is_trivially_constructible<_Tp> | |
| 24 | {}; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_trivially_destructible.h created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_trivially_destructible) | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 24 | : public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; | |
| 25 | ||
| 26 | #elif __has_builtin(__has_trivial_destructor) | |
| 27 | ||
| 28 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 29 | : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; | |
| 30 | ||
| 31 | #else | |
| 32 | ||
| 33 | template <class _Tp> struct __libcpp_trivial_destructor | |
| 34 | : public integral_constant<bool, is_scalar<_Tp>::value || | |
| 35 | is_reference<_Tp>::value> {}; | |
| 36 | ||
| 37 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 38 | : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; | |
| 39 | ||
| 40 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> | |
| 41 | : public false_type {}; | |
| 42 | ||
| 43 | #endif // __has_builtin(__is_trivially_destructible) | |
| 44 | ||
| 45 | #if _LIBCPP_STD_VER > 14 | |
| 46 | template <class _Tp> | |
| 47 | inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; | |
| 48 | #endif | |
| 49 | ||
| 50 | _LIBCPP_END_NAMESPACE_STD | |
| 51 | ||
| 52 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DESTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_trivially_move_assignable.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_lvalue_reference.h> | |
| 14 | #include <__type_traits/add_rvalue_reference.h> | |
| 15 | #include <__type_traits/integral_constant.h> | |
| 16 | #include <__type_traits/is_trivially_assignable.h> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable | |
| 25 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 26 | typename add_rvalue_reference<_Tp>::type> | |
| 27 | {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H |
lib/libcxx/include/__type_traits/is_trivially_move_constructible.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/add_rvalue_reference.h> | |
| 14 | #include <__type_traits/integral_constant.h> | |
| 15 | #include <__type_traits/is_trivially_constructible.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible | |
| 24 | : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> | |
| 25 | {}; | |
| 26 | ||
| 27 | #if _LIBCPP_STD_VER > 14 | |
| 28 | template <class _Tp> | |
| 29 | inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H |
lib/libcxx/include/__type_traits/is_unbounded_array.h created+37| ... | ... | @@ -0,0 +1,37 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array : false_type {}; | |
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __libcpp_is_unbounded_array<_Tp[]> : true_type {}; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 17 | |
| 25 | ||
| 26 | template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; | |
| 27 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; | |
| 28 | ||
| 29 | template <class _Tp> | |
| 30 | inline constexpr | |
| 31 | bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; | |
| 32 | ||
| 33 | #endif | |
| 34 | ||
| 35 | _LIBCPP_END_NAMESPACE_STD | |
| 36 | ||
| 37 | #endif // _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H |
lib/libcxx/include/__type_traits/is_union.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_UNION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_UNION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union | |
| 23 | : public integral_constant<bool, __is_union(_Tp)> {}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 14 | |
| 26 | template <class _Tp> | |
| 27 | inline constexpr bool is_union_v = __is_union(_Tp); | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_IS_UNION_H |
lib/libcxx/include/__type_traits/is_unsigned.h created+58| ... | ... | @@ -0,0 +1,58 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_arithmetic.h> | |
| 15 | #include <__type_traits/is_integral.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | // Before AppleClang 14, __is_unsigned returned true for enums with signed underlying type. | |
| 24 | #if __has_builtin(__is_unsigned) && !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1400) | |
| 25 | ||
| 26 | template<class _Tp> | |
| 27 | struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { }; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); | |
| 32 | #endif | |
| 33 | ||
| 34 | #else // __has_builtin(__is_unsigned) | |
| 35 | ||
| 36 | template <class _Tp, bool = is_integral<_Tp>::value> | |
| 37 | struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {}; | |
| 38 | ||
| 39 | template <class _Tp> | |
| 40 | struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point | |
| 41 | ||
| 42 | template <class _Tp, bool = is_arithmetic<_Tp>::value> | |
| 43 | struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; | |
| 44 | ||
| 45 | template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; | |
| 46 | ||
| 47 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; | |
| 48 | ||
| 49 | #if _LIBCPP_STD_VER > 14 | |
| 50 | template <class _Tp> | |
| 51 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; | |
| 52 | #endif | |
| 53 | ||
| 54 | #endif // __has_builtin(__is_unsigned) | |
| 55 | ||
| 56 | _LIBCPP_END_NAMESPACE_STD | |
| 57 | ||
| 58 | #endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_H |
lib/libcxx/include/__type_traits/is_unsigned_integer.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {}; | |
| 22 | template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {}; | |
| 23 | template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {}; | |
| 24 | template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; | |
| 25 | template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; | |
| 26 | template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; | |
| 27 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 28 | template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H |
lib/libcxx/include/__type_traits/is_valid_expansion.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> > | |
| 22 | true_type __sfinae_test_impl(int); | |
| 23 | template <template <class...> class, class ...> | |
| 24 | false_type __sfinae_test_impl(...); | |
| 25 | ||
| 26 | template <template <class ...> class _Templ, class ..._Args> | |
| 27 | using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H |
lib/libcxx/include/__type_traits/is_void.h created+45| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_VOID_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_VOID_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_void) | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_void_v = __is_void(_Tp); | |
| 29 | #endif | |
| 30 | ||
| 31 | #else | |
| 32 | ||
| 33 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void | |
| 34 | : public is_same<typename remove_cv<_Tp>::type, void> {}; | |
| 35 | ||
| 36 | #if _LIBCPP_STD_VER > 14 | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_void_v = is_void<_Tp>::value; | |
| 39 | #endif | |
| 40 | ||
| 41 | #endif // __has_builtin(__is_void) | |
| 42 | ||
| 43 | _LIBCPP_END_NAMESPACE_STD | |
| 44 | ||
| 45 | #endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H |
lib/libcxx/include/__type_traits/is_volatile.h created+45| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | #if __has_builtin(__is_volatile) | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { }; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 14 | |
| 27 | template <class _Tp> | |
| 28 | inline constexpr bool is_volatile_v = __is_volatile(_Tp); | |
| 29 | #endif | |
| 30 | ||
| 31 | #else | |
| 32 | ||
| 33 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; | |
| 34 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; | |
| 35 | ||
| 36 | #if _LIBCPP_STD_VER > 14 | |
| 37 | template <class _Tp> | |
| 38 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; | |
| 39 | #endif | |
| 40 | ||
| 41 | #endif // __has_builtin(__is_volatile) | |
| 42 | ||
| 43 | _LIBCPP_END_NAMESPACE_STD | |
| 44 | ||
| 45 | #endif // _LIBCPP___TYPE_TRAITS_IS_VOLATILE_H |
lib/libcxx/include/__type_traits/lazy.h created+25| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_LAZY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_LAZY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <template <class...> class _Func, class ..._Args> | |
| 21 | struct _Lazy : _Func<_Args...> {}; | |
| 22 | ||
| 23 | _LIBCPP_END_NAMESPACE_STD | |
| 24 | ||
| 25 | #endif // _LIBCPP___TYPE_TRAITS_LAZY_H |
lib/libcxx/include/__type_traits/make_32_64_or_128_bit.h created+48| ... | ... | @@ -0,0 +1,48 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/conditional.h> | |
| 14 | #include <__type_traits/is_same.h> | |
| 15 | #include <__type_traits/is_signed.h> | |
| 16 | #include <__type_traits/is_unsigned.h> | |
| 17 | #include <__type_traits/make_unsigned.h> | |
| 18 | #include <cstdint> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | /// Helper to promote an integral to smallest 32, 64, or 128 bit representation. | |
| 27 | /// | |
| 28 | /// The restriction is the same as the integral version of to_char. | |
| 29 | template <class _Tp> | |
| 30 | #if _LIBCPP_STD_VER > 17 | |
| 31 | requires (is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>) | |
| 32 | #endif | |
| 33 | using __make_32_64_or_128_bit_t = | |
| 34 | __copy_unsigned_t<_Tp, | |
| 35 | __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t, | |
| 36 | __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t, | |
| 37 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 38 | __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t, | |
| 39 | /* else */ void> | |
| 40 | #else | |
| 41 | /* else */ void | |
| 42 | #endif | |
| 43 | > > | |
| 44 | >; | |
| 45 | ||
| 46 | _LIBCPP_END_NAMESPACE_STD | |
| 47 | ||
| 48 | #endif // _LIBCPP___TYPE_TRAITS_MAKE_32_64_OR_128_BIT_H |
lib/libcxx/include/__type_traits/make_signed.h created+76| ... | ... | @@ -0,0 +1,76 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/apply_cv.h> | |
| 14 | #include <__type_traits/is_enum.h> | |
| 15 | #include <__type_traits/is_integral.h> | |
| 16 | #include <__type_traits/nat.h> | |
| 17 | #include <__type_traits/remove_cv.h> | |
| 18 | #include <__type_traits/type_list.h> | |
| 19 | ||
| 20 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 21 | # pragma GCC system_header | |
| 22 | #endif | |
| 23 | ||
| 24 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 25 | ||
| 26 | typedef | |
| 27 | __type_list<signed char, | |
| 28 | __type_list<signed short, | |
| 29 | __type_list<signed int, | |
| 30 | __type_list<signed long, | |
| 31 | __type_list<signed long long, | |
| 32 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 33 | __type_list<__int128_t, | |
| 34 | #endif | |
| 35 | __nat | |
| 36 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 37 | > | |
| 38 | #endif | |
| 39 | > > > > > __signed_types; | |
| 40 | ||
| 41 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> | |
| 42 | struct __make_signed {}; | |
| 43 | ||
| 44 | template <class _Tp> | |
| 45 | struct __make_signed<_Tp, true> | |
| 46 | { | |
| 47 | typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; | |
| 48 | }; | |
| 49 | ||
| 50 | template <> struct __make_signed<bool, true> {}; | |
| 51 | template <> struct __make_signed< signed short, true> {typedef short type;}; | |
| 52 | template <> struct __make_signed<unsigned short, true> {typedef short type;}; | |
| 53 | template <> struct __make_signed< signed int, true> {typedef int type;}; | |
| 54 | template <> struct __make_signed<unsigned int, true> {typedef int type;}; | |
| 55 | template <> struct __make_signed< signed long, true> {typedef long type;}; | |
| 56 | template <> struct __make_signed<unsigned long, true> {typedef long type;}; | |
| 57 | template <> struct __make_signed< signed long long, true> {typedef long long type;}; | |
| 58 | template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; | |
| 59 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 60 | template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; | |
| 61 | template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; | |
| 62 | #endif | |
| 63 | ||
| 64 | template <class _Tp> | |
| 65 | struct _LIBCPP_TEMPLATE_VIS make_signed | |
| 66 | { | |
| 67 | typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; | |
| 68 | }; | |
| 69 | ||
| 70 | #if _LIBCPP_STD_VER > 11 | |
| 71 | template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; | |
| 72 | #endif | |
| 73 | ||
| 74 | _LIBCPP_END_NAMESPACE_STD | |
| 75 | ||
| 76 | #endif // _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H |
lib/libcxx/include/__type_traits/make_unsigned.h created+89| ... | ... | @@ -0,0 +1,89 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/apply_cv.h> | |
| 14 | #include <__type_traits/conditional.h> | |
| 15 | #include <__type_traits/is_enum.h> | |
| 16 | #include <__type_traits/is_integral.h> | |
| 17 | #include <__type_traits/is_unsigned.h> | |
| 18 | #include <__type_traits/nat.h> | |
| 19 | #include <__type_traits/remove_cv.h> | |
| 20 | #include <__type_traits/type_list.h> | |
| 21 | ||
| 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 23 | # pragma GCC system_header | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 27 | ||
| 28 | typedef | |
| 29 | __type_list<unsigned char, | |
| 30 | __type_list<unsigned short, | |
| 31 | __type_list<unsigned int, | |
| 32 | __type_list<unsigned long, | |
| 33 | __type_list<unsigned long long, | |
| 34 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 35 | __type_list<__uint128_t, | |
| 36 | #endif | |
| 37 | __nat | |
| 38 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 39 | > | |
| 40 | #endif | |
| 41 | > > > > > __unsigned_types; | |
| 42 | ||
| 43 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> | |
| 44 | struct __make_unsigned {}; | |
| 45 | ||
| 46 | template <class _Tp> | |
| 47 | struct __make_unsigned<_Tp, true> | |
| 48 | { | |
| 49 | typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; | |
| 50 | }; | |
| 51 | ||
| 52 | template <> struct __make_unsigned<bool, true> {}; | |
| 53 | template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; | |
| 54 | template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; | |
| 55 | template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; | |
| 56 | template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; | |
| 57 | template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; | |
| 58 | template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; | |
| 59 | template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; | |
| 60 | template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; | |
| 61 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 62 | template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; | |
| 63 | template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; | |
| 64 | #endif | |
| 65 | ||
| 66 | template <class _Tp> | |
| 67 | struct _LIBCPP_TEMPLATE_VIS make_unsigned | |
| 68 | { | |
| 69 | typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; | |
| 70 | }; | |
| 71 | ||
| 72 | #if _LIBCPP_STD_VER > 11 | |
| 73 | template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; | |
| 74 | #endif | |
| 75 | ||
| 76 | #ifndef _LIBCPP_CXX03_LANG | |
| 77 | template <class _Tp> | |
| 78 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 79 | typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { | |
| 80 | return static_cast<typename make_unsigned<_Tp>::type>(__x); | |
| 81 | } | |
| 82 | #endif | |
| 83 | ||
| 84 | template <class _Tp, class _Up> | |
| 85 | using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>; | |
| 86 | ||
| 87 | _LIBCPP_END_NAMESPACE_STD | |
| 88 | ||
| 89 | #endif // _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H |
lib/libcxx/include/__type_traits/nat.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_NAT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_NAT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | struct __nat | |
| 21 | { | |
| 22 | #ifndef _LIBCPP_CXX03_LANG | |
| 23 | __nat() = delete; | |
| 24 | __nat(const __nat&) = delete; | |
| 25 | __nat& operator=(const __nat&) = delete; | |
| 26 | ~__nat() = delete; | |
| 27 | #endif | |
| 28 | }; | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_NAT_H |
lib/libcxx/include/__type_traits/negation.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_NEGATION_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_NEGATION_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Pred> | |
| 22 | struct _Not : _BoolConstant<!_Pred::value> {}; | |
| 23 | ||
| 24 | #if _LIBCPP_STD_VER > 14 | |
| 25 | template <class _Tp> | |
| 26 | struct negation : _Not<_Tp> {}; | |
| 27 | template<class _Tp> | |
| 28 | inline constexpr bool negation_v = negation<_Tp>::value; | |
| 29 | #endif // _LIBCPP_STD_VER > 14 | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_NEGATION_H |
lib/libcxx/include/__type_traits/promote.h created+95| ... | ... | @@ -0,0 +1,95 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_PROMOTE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_PROMOTE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <__type_traits/is_same.h> | |
| 15 | #include <__utility/declval.h> | |
| 16 | #include <cstddef> | |
| 17 | ||
| 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 19 | # pragma GCC system_header | |
| 20 | #endif | |
| 21 | ||
| 22 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 23 | ||
| 24 | template <class _Tp> | |
| 25 | struct __numeric_type | |
| 26 | { | |
| 27 | static void __test(...); | |
| 28 | static float __test(float); | |
| 29 | static double __test(char); | |
| 30 | static double __test(int); | |
| 31 | static double __test(unsigned); | |
| 32 | static double __test(long); | |
| 33 | static double __test(unsigned long); | |
| 34 | static double __test(long long); | |
| 35 | static double __test(unsigned long long); | |
| 36 | static double __test(double); | |
| 37 | static long double __test(long double); | |
| 38 | ||
| 39 | typedef decltype(__test(declval<_Tp>())) type; | |
| 40 | static const bool value = _IsNotSame<type, void>::value; | |
| 41 | }; | |
| 42 | ||
| 43 | template <> | |
| 44 | struct __numeric_type<void> | |
| 45 | { | |
| 46 | static const bool value = true; | |
| 47 | }; | |
| 48 | ||
| 49 | template <class _A1, class _A2 = void, class _A3 = void, | |
| 50 | bool = __numeric_type<_A1>::value && | |
| 51 | __numeric_type<_A2>::value && | |
| 52 | __numeric_type<_A3>::value> | |
| 53 | class __promote_imp | |
| 54 | { | |
| 55 | public: | |
| 56 | static const bool value = false; | |
| 57 | }; | |
| 58 | ||
| 59 | template <class _A1, class _A2, class _A3> | |
| 60 | class __promote_imp<_A1, _A2, _A3, true> | |
| 61 | { | |
| 62 | private: | |
| 63 | typedef typename __promote_imp<_A1>::type __type1; | |
| 64 | typedef typename __promote_imp<_A2>::type __type2; | |
| 65 | typedef typename __promote_imp<_A3>::type __type3; | |
| 66 | public: | |
| 67 | typedef decltype(__type1() + __type2() + __type3()) type; | |
| 68 | static const bool value = true; | |
| 69 | }; | |
| 70 | ||
| 71 | template <class _A1, class _A2> | |
| 72 | class __promote_imp<_A1, _A2, void, true> | |
| 73 | { | |
| 74 | private: | |
| 75 | typedef typename __promote_imp<_A1>::type __type1; | |
| 76 | typedef typename __promote_imp<_A2>::type __type2; | |
| 77 | public: | |
| 78 | typedef decltype(__type1() + __type2()) type; | |
| 79 | static const bool value = true; | |
| 80 | }; | |
| 81 | ||
| 82 | template <class _A1> | |
| 83 | class __promote_imp<_A1, void, void, true> | |
| 84 | { | |
| 85 | public: | |
| 86 | typedef typename __numeric_type<_A1>::type type; | |
| 87 | static const bool value = true; | |
| 88 | }; | |
| 89 | ||
| 90 | template <class _A1, class _A2 = void, class _A3 = void> | |
| 91 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; | |
| 92 | ||
| 93 | _LIBCPP_END_NAMESPACE_STD | |
| 94 | ||
| 95 | #endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H |
lib/libcxx/include/__type_traits/rank.h created+36| ... | ... | @@ -0,0 +1,36 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_RANK_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_RANK_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/integral_constant.h> | |
| 14 | #include <cstddef> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank | |
| 23 | : public integral_constant<size_t, 0> {}; | |
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> | |
| 25 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; | |
| 26 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> | |
| 27 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 14 | |
| 30 | template <class _Tp> | |
| 31 | inline constexpr size_t rank_v = rank<_Tp>::value; | |
| 32 | #endif | |
| 33 | ||
| 34 | _LIBCPP_END_NAMESPACE_STD | |
| 35 | ||
| 36 | #endif // _LIBCPP___TYPE_TRAITS_RANK_H |
lib/libcxx/include/__type_traits/remove_all_extents.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstddef> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents | |
| 22 | {typedef _Tp type;}; | |
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> | |
| 24 | {typedef typename remove_all_extents<_Tp>::type type;}; | |
| 25 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> | |
| 26 | {typedef typename remove_all_extents<_Tp>::type type;}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 11 | |
| 29 | template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H |
lib/libcxx/include/__type_traits/remove_const.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; | |
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; | |
| 22 | #if _LIBCPP_STD_VER > 11 | |
| 23 | template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_END_NAMESPACE_STD | |
| 27 | ||
| 28 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_CONST_H |
lib/libcxx/include/__type_traits/remove_cv.h created+30| ... | ... | @@ -0,0 +1,30 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CV_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_CV_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/remove_const.h> | |
| 14 | #include <__type_traits/remove_volatile.h> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv | |
| 23 | {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; | |
| 24 | #if _LIBCPP_STD_VER > 11 | |
| 25 | template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; | |
| 26 | #endif | |
| 27 | ||
| 28 | _LIBCPP_END_NAMESPACE_STD | |
| 29 | ||
| 30 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_CV_H |
lib/libcxx/include/__type_traits/remove_cvref.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_same.h> | |
| 14 | #include <__type_traits/remove_cv.h> | |
| 15 | #include <__type_traits/remove_reference.h> | |
| 16 | ||
| 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 18 | # pragma GCC system_header | |
| 19 | #endif | |
| 20 | ||
| 21 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | using __uncvref_t _LIBCPP_NODEBUG = typename remove_cv<typename remove_reference<_Tp>::type>::type; | |
| 25 | ||
| 26 | template <class _Tp, class _Up> | |
| 27 | struct __is_same_uncvref : _IsSame<__uncvref_t<_Tp>, __uncvref_t<_Up> > {}; | |
| 28 | ||
| 29 | #if _LIBCPP_STD_VER > 17 | |
| 30 | // remove_cvref - same as __uncvref | |
| 31 | template <class _Tp> | |
| 32 | struct remove_cvref { | |
| 33 | using type _LIBCPP_NODEBUG = __uncvref_t<_Tp>; | |
| 34 | }; | |
| 35 | ||
| 36 | template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; | |
| 37 | #endif | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H |
lib/libcxx/include/__type_traits/remove_extent.h created+34| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstddef> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent | |
| 22 | {typedef _Tp type;}; | |
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> | |
| 24 | {typedef _Tp type;}; | |
| 25 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> | |
| 26 | {typedef _Tp type;}; | |
| 27 | ||
| 28 | #if _LIBCPP_STD_VER > 11 | |
| 29 | template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; | |
| 30 | #endif | |
| 31 | ||
| 32 | _LIBCPP_END_NAMESPACE_STD | |
| 33 | ||
| 34 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H |
lib/libcxx/include/__type_traits/remove_pointer.h created+32| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 24 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 11 | |
| 27 | template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; | |
| 28 | #endif | |
| 29 | ||
| 30 | _LIBCPP_END_NAMESPACE_STD | |
| 31 | ||
| 32 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_POINTER_H |
lib/libcxx/include/__type_traits/remove_reference.h created+31| ... | ... | @@ -0,0 +1,31 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstddef> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 22 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 23 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 24 | ||
| 25 | #if _LIBCPP_STD_VER > 11 | |
| 26 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; | |
| 27 | #endif | |
| 28 | ||
| 29 | _LIBCPP_END_NAMESPACE_STD | |
| 30 | ||
| 31 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H |
lib/libcxx/include/__type_traits/remove_volatile.h created+28| ... | ... | @@ -0,0 +1,28 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; | |
| 21 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; | |
| 22 | #if _LIBCPP_STD_VER > 11 | |
| 23 | template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; | |
| 24 | #endif | |
| 25 | ||
| 26 | _LIBCPP_END_NAMESPACE_STD | |
| 27 | ||
| 28 | #endif // _LIBCPP___TYPE_TRAITS_REMOVE_VOLATILE_H |
lib/libcxx/include/__type_traits/type_identity.h created+33| ... | ... | @@ -0,0 +1,33 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | template <class _Tp> | |
| 21 | struct __type_identity { typedef _Tp type; }; | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | using __type_identity_t _LIBCPP_NODEBUG = typename __type_identity<_Tp>::type; | |
| 25 | ||
| 26 | #if _LIBCPP_STD_VER > 17 | |
| 27 | template<class _Tp> struct type_identity { typedef _Tp type; }; | |
| 28 | template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; | |
| 29 | #endif | |
| 30 | ||
| 31 | _LIBCPP_END_NAMESPACE_STD | |
| 32 | ||
| 33 | #endif // _LIBCPP___TYPE_TRAITS_TYPE_IDENTITY_H |
lib/libcxx/include/__type_traits/type_list.h created+44| ... | ... | @@ -0,0 +1,44 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_TYPE_LIST_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_TYPE_LIST_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstddef> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Hp, class _Tp> | |
| 22 | struct __type_list | |
| 23 | { | |
| 24 | typedef _Hp _Head; | |
| 25 | typedef _Tp _Tail; | |
| 26 | }; | |
| 27 | ||
| 28 | template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; | |
| 29 | ||
| 30 | template <class _Hp, class _Tp, size_t _Size> | |
| 31 | struct __find_first<__type_list<_Hp, _Tp>, _Size, true> | |
| 32 | { | |
| 33 | typedef _LIBCPP_NODEBUG _Hp type; | |
| 34 | }; | |
| 35 | ||
| 36 | template <class _Hp, class _Tp, size_t _Size> | |
| 37 | struct __find_first<__type_list<_Hp, _Tp>, _Size, false> | |
| 38 | { | |
| 39 | typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; | |
| 40 | }; | |
| 41 | ||
| 42 | _LIBCPP_END_NAMESPACE_STD | |
| 43 | ||
| 44 | #endif // _LIBCPP___TYPE_TRAITS_TYPE_LIST_H |
lib/libcxx/include/__type_traits/underlying_type.h created+41| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <__type_traits/is_enum.h> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl; | |
| 22 | ||
| 23 | template <class _Tp> | |
| 24 | struct __underlying_type_impl<_Tp, false> {}; | |
| 25 | ||
| 26 | template <class _Tp> | |
| 27 | struct __underlying_type_impl<_Tp, true> | |
| 28 | { | |
| 29 | typedef __underlying_type(_Tp) type; | |
| 30 | }; | |
| 31 | ||
| 32 | template <class _Tp> | |
| 33 | struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; | |
| 34 | ||
| 35 | #if _LIBCPP_STD_VER > 11 | |
| 36 | template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; | |
| 37 | #endif | |
| 38 | ||
| 39 | _LIBCPP_END_NAMESPACE_STD | |
| 40 | ||
| 41 | #endif // _LIBCPP___TYPE_TRAITS_UNDERLYING_TYPE_H |
lib/libcxx/include/__type_traits/void_t.h created+29| ... | ... | @@ -0,0 +1,29 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___TYPE_TRAITS_VOID_T_H | |
| 10 | #define _LIBCPP___TYPE_TRAITS_VOID_T_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | ||
| 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 15 | # pragma GCC system_header | |
| 16 | #endif | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | #if _LIBCPP_STD_VER > 14 | |
| 21 | template <class...> using void_t = void; | |
| 22 | #endif | |
| 23 | ||
| 24 | template <class> | |
| 25 | struct __void_t { typedef void type; }; | |
| 26 | ||
| 27 | _LIBCPP_END_NAMESPACE_STD | |
| 28 | ||
| 29 | #endif // _LIBCPP___TYPE_TRAITS_VOID_T_H |
lib/libcxx/include/__undef_macros+2-19| ... | ... | @@ -7,27 +7,10 @@ |
| 7 | 7 | // |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | |
| 10 | ||
| 11 | 10 | #ifdef min |
| 12 | #if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) | |
| 13 | #if defined(_LIBCPP_WARNING) | |
| 14 | _LIBCPP_WARNING("macro min is incompatible with C++. Try #define NOMINMAX " | |
| 15 | "before any Windows header. #undefing min") | |
| 16 | #else | |
| 17 | #warning: macro min is incompatible with C++. #undefing min | |
| 18 | #endif | |
| 19 | #endif | |
| 20 | #undef min | |
| 11 | # undef min | |
| 21 | 12 | #endif |
| 22 | 13 | |
| 23 | 14 | #ifdef max |
| 24 | #if !defined(_LIBCPP_DISABLE_MACRO_CONFLICT_WARNINGS) | |
| 25 | #if defined(_LIBCPP_WARNING) | |
| 26 | _LIBCPP_WARNING("macro max is incompatible with C++. Try #define NOMINMAX " | |
| 27 | "before any Windows header. #undefing max") | |
| 28 | #else | |
| 29 | #warning: macro max is incompatible with C++. #undefing max | |
| 30 | #endif | |
| 31 | #endif | |
| 32 | #undef max | |
| 15 | # undef max | |
| 33 | 16 | #endif |
lib/libcxx/include/__utility/as_const.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/auto_cast.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | #define _LIBCPP_AUTO_CAST(expr) static_cast<typename decay<decltype((expr))>::type>(expr) |
lib/libcxx/include/__utility/cmp.h+4-7| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -24,19 +24,16 @@ _LIBCPP_PUSH_MACROS |
| 24 | 24 | |
| 25 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | 26 | |
| 27 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 27 | #if _LIBCPP_STD_VER > 17 | |
| 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, char16_t, char32_t | |
| 34 | 34 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 35 | 35 | , char8_t |
| 36 | 36 | #endif |
| 37 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 38 | , char16_t, char32_t | |
| 39 | #endif | |
| 40 | 37 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 41 | 38 | , wchar_t |
| 42 | 39 | #endif |
| ... | ... | @@ -101,7 +98,7 @@ bool in_range(_Up __u) noexcept |
| 101 | 98 | return _VSTD::cmp_less_equal(__u, numeric_limits<_Tp>::max()) && |
| 102 | 99 | _VSTD::cmp_greater_equal(__u, numeric_limits<_Tp>::min()); |
| 103 | 100 | } |
| 104 | #endif | |
| 101 | #endif // _LIBCPP_STD_VER > 17 | |
| 105 | 102 | |
| 106 | 103 | _LIBCPP_END_NAMESPACE_STD |
| 107 | 104 |
lib/libcxx/include/__utility/declval.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/exchange.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/forward.h+3-2| ... | ... | @@ -11,10 +11,11 @@ |
| 11 | 11 | #define _LIBCPP___UTILITY_FORWARD_H |
| 12 | 12 | |
| 13 | 13 | #include <__config> |
| 14 | #include <type_traits> | |
| 14 | #include <__type_traits/is_reference.h> | |
| 15 | #include <__type_traits/remove_reference.h> | |
| 15 | 16 | |
| 16 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/in_place.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/integer_sequence.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <type_traits> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/move.h+1-6| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -26,15 +26,10 @@ move(_Tp&& __t) _NOEXCEPT { |
| 26 | 26 | return static_cast<_Up&&>(__t); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | #ifndef _LIBCPP_CXX03_LANG | |
| 30 | 29 | template <class _Tp> |
| 31 | 30 | using __move_if_noexcept_result_t = |
| 32 | 31 | typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, |
| 33 | 32 | _Tp&&>::type; |
| 34 | #else // _LIBCPP_CXX03_LANG | |
| 35 | template <class _Tp> | |
| 36 | using __move_if_noexcept_result_t = const _Tp&; | |
| 37 | #endif | |
| 38 | 33 | |
| 39 | 34 | template <class _Tp> |
| 40 | 35 | _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp> |
lib/libcxx/include/__utility/pair.h+21-5| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | #include <type_traits> |
| 22 | 22 | |
| 23 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 24 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 25 | 25 | #endif |
| 26 | 26 | |
| 27 | 27 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -315,7 +315,7 @@ private: |
| 315 | 315 | #endif |
| 316 | 316 | }; |
| 317 | 317 | |
| 318 | #if _LIBCPP_STD_VER >= 17 | |
| 318 | #if _LIBCPP_STD_VER > 14 | |
| 319 | 319 | template<class _T1, class _T2> |
| 320 | 320 | pair(_T1, _T2) -> pair<_T1, _T2>; |
| 321 | 321 | #endif |
| ... | ... | @@ -330,7 +330,7 @@ operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) |
| 330 | 330 | return __x.first == __y.first && __x.second == __y.second; |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 333 | #if _LIBCPP_STD_VER > 17 | |
| 334 | 334 | |
| 335 | 335 | template <class _T1, class _T2> |
| 336 | 336 | _LIBCPP_HIDE_FROM_ABI constexpr |
| ... | ... | @@ -345,7 +345,7 @@ operator<=>(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) |
| 345 | 345 | return _VSTD::__synth_three_way(__x.second, __y.second); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | #else // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 348 | #else // _LIBCPP_STD_VER > 17 | |
| 349 | 349 | |
| 350 | 350 | template <class _T1, class _T2> |
| 351 | 351 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| ... | ... | @@ -387,7 +387,23 @@ operator<=(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y) |
| 387 | 387 | return !(__y < __x); |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 390 | #endif // _LIBCPP_STD_VER > 17 | |
| 391 | ||
| 392 | #if _LIBCPP_STD_VER > 20 | |
| 393 | template <class _T1, class _T2, class _U1, class _U2, template<class> class _TQual, template<class> class _UQual> | |
| 394 | requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, | |
| 395 | common_reference_t<_TQual<_T2>, _UQual<_U2>>>; } | |
| 396 | struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> { | |
| 397 | using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, | |
| 398 | common_reference_t<_TQual<_T2>, _UQual<_U2>>>; | |
| 399 | }; | |
| 400 | ||
| 401 | template <class _T1, class _T2, class _U1, class _U2> | |
| 402 | requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; } | |
| 403 | struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { | |
| 404 | using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; | |
| 405 | }; | |
| 406 | #endif // _LIBCPP_STD_VER > 20 | |
| 391 | 407 | |
| 392 | 408 | template <class _T1, class _T2> |
| 393 | 409 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
lib/libcxx/include/__utility/piecewise_construct.h+1-1| ... | ... | @@ -12,7 +12,7 @@ |
| 12 | 12 | #include <__config> |
| 13 | 13 | |
| 14 | 14 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 15 | #pragma GCC system_header | |
| 15 | # pragma GCC system_header | |
| 16 | 16 | #endif |
| 17 | 17 | |
| 18 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/priority_tag.h+1-1| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <cstddef> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/rel_ops.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/swap.h+1-1| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | #include <type_traits> |
| 17 | 17 | |
| 18 | 18 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 19 | #pragma GCC system_header | |
| 19 | # pragma GCC system_header | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/to_underlying.h+1-1| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | #include <type_traits> |
| 15 | 15 | |
| 16 | 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 17 | #pragma GCC system_header | |
| 17 | # pragma GCC system_header | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__utility/transaction.h+6-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <type_traits> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -86,6 +86,11 @@ private: |
| 86 | 86 | bool __completed_; |
| 87 | 87 | }; |
| 88 | 88 | |
| 89 | template <class _Rollback> | |
| 90 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __transaction<_Rollback> __make_transaction(_Rollback __rollback) { | |
| 91 | return __transaction<_Rollback>(std::move(__rollback)); | |
| 92 | } | |
| 93 | ||
| 89 | 94 | _LIBCPP_END_NAMESPACE_STD |
| 90 | 95 | |
| 91 | 96 | #endif // _LIBCPP___UTILITY_TRANSACTION_H |
lib/libcxx/include/__utility/unreachable.h created+38| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #ifndef _LIBCPP___UTILITY_UNREACHABLE_H | |
| 10 | #define _LIBCPP___UTILITY_UNREACHABLE_H | |
| 11 | ||
| 12 | #include <__config> | |
| 13 | #include <cstdlib> | |
| 14 | ||
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 16 | # pragma GCC system_header | |
| 17 | #endif | |
| 18 | ||
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 20 | ||
| 21 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __libcpp_unreachable() | |
| 22 | { | |
| 23 | #if __has_builtin(__builtin_unreachable) | |
| 24 | __builtin_unreachable(); | |
| 25 | #else | |
| 26 | std::abort(); | |
| 27 | #endif | |
| 28 | } | |
| 29 | ||
| 30 | #if _LIBCPP_STD_VER > 20 | |
| 31 | ||
| 32 | [[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void unreachable() { __libcpp_unreachable(); } | |
| 33 | ||
| 34 | #endif // _LIBCPP_STD_VER > 20 | |
| 35 | ||
| 36 | _LIBCPP_END_NAMESPACE_STD | |
| 37 | ||
| 38 | #endif |
lib/libcxx/include/__variant/monostate.h+1-1| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | #include <cstddef> |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 18 | #pragma GCC system_header | |
| 18 | # pragma GCC system_header | |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | 21 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/__verbose_abort created+27| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP___VERBOSE_ABORT | |
| 11 | #define _LIBCPP___VERBOSE_ABORT | |
| 12 | ||
| 13 | #include <__availability> | |
| 14 | #include <__config> | |
| 15 | ||
| 16 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 17 | # pragma GCC system_header | |
| 18 | #endif | |
| 19 | ||
| 20 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 21 | ||
| 22 | _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) | |
| 23 | void __libcpp_verbose_abort(const char *__format, ...); | |
| 24 | ||
| 25 | _LIBCPP_END_NAMESPACE_STD | |
| 26 | ||
| 27 | #endif // _LIBCPP___VERBOSE_ABORT |
lib/libcxx/include/algorithm+1006-16| ... | ... | @@ -19,14 +19,901 @@ namespace std |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | 21 | namespace ranges { |
| 22 | ||
| 23 | // [algorithms.results], algorithm result types | |
| 24 | template <class I, class F> | |
| 25 | struct in_fun_result; // since C++20 | |
| 26 | ||
| 22 | 27 | template <class I1, class I2> |
| 23 | struct in_in_result; // since C++20 | |
| 28 | struct in_in_result; // since C++20 | |
| 29 | ||
| 30 | template <class I, class O> | |
| 31 | struct in_out_result; // since C++20 | |
| 24 | 32 | |
| 25 | 33 | template <class I1, class I2, class O> |
| 26 | struct in_in_out_result; // since C++20 | |
| 34 | struct in_in_out_result; // since C++20 | |
| 35 | ||
| 36 | template <class I, class O1, class O2> | |
| 37 | struct in_out_out_result; // since C++20 | |
| 38 | ||
| 39 | template <class I1, class I2> | |
| 40 | struct min_max_result; // since C++20 | |
| 41 | ||
| 42 | template <class I> | |
| 43 | struct in_found_result; // since C++20 | |
| 44 | ||
| 45 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 46 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20 | |
| 47 | constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {}); | |
| 48 | ||
| 49 | template<forward_range R, class Proj = identity, | |
| 50 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> // since C++20 | |
| 51 | constexpr borrowed_iterator_t<R> min_element(R&& r, Comp comp = {}, Proj proj = {}); | |
| 52 | ||
| 53 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 54 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> | |
| 55 | constexpr I ranges::max_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 56 | ||
| 57 | template<forward_range R, class Proj = identity, | |
| 58 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 59 | constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 60 | ||
| 61 | template<class I1, class I2> | |
| 62 | using mismatch_result = in_in_result<I1, I2>; | |
| 63 | ||
| 64 | template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2, | |
| 65 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 66 | requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> | |
| 67 | constexpr mismatch_result<_I1, _I2> | |
| 68 | mismatch()(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 | |
| 69 | ||
| 70 | template <input_range R1, input_range R2, | |
| 71 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 72 | requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> | |
| 73 | constexpr mismatch_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>> | |
| 74 | mismatch(R1&& r1, R2&& r2, Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}) // since C++20 | |
| 75 | ||
| 76 | requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> | |
| 77 | constexpr I find(I first, S last, const T& value, Proj proj = {}); // since C++20 | |
| 78 | ||
| 79 | template<input_range R, class T, class Proj = identity> | |
| 80 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> | |
| 81 | constexpr borrowed_iterator_t<R> | |
| 82 | find(R&& r, const T& value, Proj proj = {}); // since C++20 | |
| 83 | ||
| 84 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 85 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 86 | constexpr I find_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 87 | ||
| 88 | template<input_range R, class Proj = identity, | |
| 89 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 90 | constexpr borrowed_iterator_t<R> | |
| 91 | find_if(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 92 | ||
| 93 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 94 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 95 | constexpr I find_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 96 | ||
| 97 | template<input_range R, class Proj = identity, | |
| 98 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 99 | constexpr borrowed_iterator_t<R> | |
| 100 | find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 101 | ||
| 102 | template<class T, class Proj = identity, | |
| 103 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | |
| 104 | constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 105 | ||
| 106 | template<copyable T, class Proj = identity, | |
| 107 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | |
| 108 | constexpr T min(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 109 | ||
| 110 | template<input_range R, class Proj = identity, | |
| 111 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 112 | requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*> | |
| 113 | constexpr range_value_t<R> | |
| 114 | min(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 115 | ||
| 116 | template<class T, class Proj = identity, | |
| 117 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | |
| 118 | constexpr const T& max(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 119 | ||
| 120 | template<copyable T, class Proj = identity, | |
| 121 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | |
| 122 | constexpr T max(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 123 | ||
| 124 | template<input_range R, class Proj = identity, | |
| 125 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 126 | requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*> | |
| 127 | constexpr range_value_t<R> | |
| 128 | max(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 129 | ||
| 130 | template<class I, class O> | |
| 131 | using unary_transform_result = in_out_result<I, O>; // since C++20 | |
| 132 | ||
| 133 | template<class I1, class I2, class O> | |
| 134 | using binary_transform_result = in_in_out_result<I1, I2, O>; // since C++20 | |
| 135 | ||
| 136 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, | |
| 137 | copy_constructible F, class Proj = identity> | |
| 138 | requires indirectly_writable<O, indirect_result_t<F&, projected<I, Proj>>> | |
| 139 | constexpr ranges::unary_transform_result<I, O> | |
| 140 | transform(I first1, S last1, O result, F op, Proj proj = {}); // since C++20 | |
| 141 | ||
| 142 | template<input_range R, weakly_incrementable O, copy_constructible F, | |
| 143 | class Proj = identity> | |
| 144 | requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R>, Proj>>> | |
| 145 | constexpr ranges::unary_transform_result<borrowed_iterator_t<R>, O> | |
| 146 | transform(R&& r, O result, F op, Proj proj = {}); // since C++20 | |
| 147 | ||
| 148 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 149 | weakly_incrementable O, copy_constructible F, class Proj1 = identity, | |
| 150 | class Proj2 = identity> | |
| 151 | requires indirectly_writable<O, indirect_result_t<F&, projected<I1, Proj1>, | |
| 152 | projected<I2, Proj2>>> | |
| 153 | constexpr ranges::binary_transform_result<I1, I2, O> | |
| 154 | transform(I1 first1, S1 last1, I2 first2, S2 last2, O result, | |
| 155 | F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 156 | ||
| 157 | template<input_range R1, input_range R2, weakly_incrementable O, | |
| 158 | copy_constructible F, class Proj1 = identity, class Proj2 = identity> | |
| 159 | requires indirectly_writable<O, indirect_result_t<F&, projected<iterator_t<R1>, Proj1>, | |
| 160 | projected<iterator_t<R2>, Proj2>>> | |
| 161 | constexpr ranges::binary_transform_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O> | |
| 162 | transform(R1&& r1, R2&& r2, O result, | |
| 163 | F binary_op, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 164 | ||
| 165 | template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity> | |
| 166 | requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> | |
| 167 | constexpr iter_difference_t<I> | |
| 168 | count(I first, S last, const T& value, Proj proj = {}); // since C++20 | |
| 169 | ||
| 170 | template<input_range R, class T, class Proj = identity> | |
| 171 | requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> | |
| 172 | constexpr range_difference_t<R> | |
| 173 | count(R&& r, const T& value, Proj proj = {}); // since C++20 | |
| 174 | ||
| 175 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 176 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 177 | constexpr iter_difference_t<I> | |
| 178 | count_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 179 | ||
| 180 | template<input_range R, class Proj = identity, | |
| 181 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 182 | constexpr range_difference_t<R> | |
| 183 | count_if(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 184 | ||
| 185 | template<class T> | |
| 186 | using minmax_result = min_max_result<T>; | |
| 187 | ||
| 188 | template<class T, class Proj = identity, | |
| 189 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | |
| 190 | constexpr ranges::minmax_result<const T&> | |
| 191 | minmax(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 192 | ||
| 193 | template<copyable T, class Proj = identity, | |
| 194 | indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> | |
| 195 | constexpr ranges::minmax_result<T> | |
| 196 | minmax(initializer_list<T> r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 197 | ||
| 198 | template<input_range R, class Proj = identity, | |
| 199 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 200 | requires indirectly_copyable_storable<iterator_t<R>, range_value_t<R>*> | |
| 201 | constexpr ranges::minmax_result<range_value_t<R>> | |
| 202 | minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 203 | ||
| 204 | template<class I> | |
| 205 | using minmax_element_result = min_max_result<I>; | |
| 206 | ||
| 207 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 208 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> | |
| 209 | constexpr ranges::minmax_element_result<I> | |
| 210 | minmax_element(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 211 | ||
| 212 | template<forward_range R, class Proj = identity, | |
| 213 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 214 | constexpr ranges::minmax_element_result<borrowed_iterator_t<R>> | |
| 215 | minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 216 | ||
| 217 | template<class I, class O> | |
| 218 | using copy_result = in_out_result<I, O>; // since C++20 | |
| 219 | ||
| 220 | template<class I, class O> | |
| 221 | using copy_n_result = in_out_result<I, O>; // since C++20 | |
| 222 | ||
| 223 | template<class I, class O> | |
| 224 | using copy_if_result = in_out_result<I, O>; // since C++20 | |
| 225 | ||
| 226 | template<class I1, class I2> | |
| 227 | using copy_backward_result = in_out_result<I1, I2>; // since C++20 | |
| 228 | ||
| 229 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O> | |
| 230 | requires indirectly_copyable<I, O> | |
| 231 | constexpr ranges::copy_result<I, O> ranges::copy(I first, S last, O result); // since C++20 | |
| 232 | ||
| 233 | template<input_range R, weakly_incrementable O> | |
| 234 | requires indirectly_copyable<iterator_t<R>, O> | |
| 235 | constexpr ranges::copy_result<borrowed_iterator_t<R>, O> ranges::copy(R&& r, O result); // since C++20 | |
| 236 | ||
| 237 | template<input_iterator I, weakly_incrementable O> | |
| 238 | requires indirectly_copyable<I, O> | |
| 239 | constexpr ranges::copy_n_result<I, O> | |
| 240 | ranges::copy_n(I first, iter_difference_t<I> n, O result); // since C++20 | |
| 241 | ||
| 242 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity, | |
| 243 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 244 | requires indirectly_copyable<I, O> | |
| 245 | constexpr ranges::copy_if_result<I, O> | |
| 246 | ranges::copy_if(I first, S last, O result, Pred pred, Proj proj = {}); // since C++20 | |
| 247 | ||
| 248 | template<input_range R, weakly_incrementable O, class Proj = identity, | |
| 249 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 250 | requires indirectly_copyable<iterator_t<R>, O> | |
| 251 | constexpr ranges::copy_if_result<borrowed_iterator_t<R>, O> | |
| 252 | ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}); // since C++20 | |
| 253 | ||
| 254 | template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> | |
| 255 | requires indirectly_copyable<I1, I2> | |
| 256 | constexpr ranges::copy_backward_result<I1, I2> | |
| 257 | ranges::copy_backward(I1 first, S1 last, I2 result); // since C++20 | |
| 258 | ||
| 259 | template<bidirectional_range R, bidirectional_iterator I> | |
| 260 | requires indirectly_copyable<iterator_t<R>, I> | |
| 261 | constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I> | |
| 262 | ranges::copy_backward(R&& r, I result); // since C++20 | |
| 263 | ||
| 264 | template<class I, class F> | |
| 265 | using for_each_result = in_fun_result<I, F>; // since C++20 | |
| 266 | ||
| 267 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 268 | indirectly_unary_invocable<projected<I, Proj>> Fun> | |
| 269 | constexpr ranges::for_each_result<I, Fun> | |
| 270 | ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20 | |
| 271 | ||
| 272 | template<input_range R, class Proj = identity, | |
| 273 | indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun> | |
| 274 | constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun> | |
| 275 | ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20 | |
| 276 | ||
| 277 | template<input_iterator I, class Proj = identity, | |
| 278 | indirectly_unary_invocable<projected<I, Proj>> Fun> | |
| 279 | constexpr ranges::for_each_n_result<I, Fun> | |
| 280 | ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20 | |
| 281 | ||
| 282 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 283 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 284 | constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 285 | ||
| 286 | template<input_range R, class Proj = identity, | |
| 287 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 288 | constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 289 | ||
| 290 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 291 | class Proj = identity> | |
| 292 | requires sortable<I, Comp, Proj> | |
| 293 | constexpr I | |
| 294 | ranges::push_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 295 | ||
| 296 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 297 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 298 | constexpr borrowed_iterator_t<R> | |
| 299 | ranges::push_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 300 | ||
| 301 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 302 | class Proj = identity> | |
| 303 | requires sortable<I, Comp, Proj> | |
| 304 | constexpr I | |
| 305 | ranges::pop_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 306 | ||
| 307 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 308 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 309 | constexpr borrowed_iterator_t<R> | |
| 310 | ranges::pop_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 311 | ||
| 312 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 313 | class Proj = identity> | |
| 314 | requires sortable<I, Comp, Proj> | |
| 315 | constexpr I | |
| 316 | ranges::make_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 317 | ||
| 318 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 319 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 320 | constexpr borrowed_iterator_t<R> | |
| 321 | ranges::make_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 322 | ||
| 323 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 324 | class Proj = identity> | |
| 325 | requires sortable<I, Comp, Proj> | |
| 326 | constexpr I | |
| 327 | ranges::sort_heap(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 328 | ||
| 329 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 330 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 331 | constexpr borrowed_iterator_t<R> | |
| 332 | ranges::sort_heap(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 333 | ||
| 334 | template<random_access_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 335 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> | |
| 336 | constexpr bool is_heap(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 | |
| 337 | ||
| 338 | template<random_access_range R, class Proj = identity, | |
| 339 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 340 | constexpr bool is_heap(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 | |
| 341 | ||
| 342 | template<random_access_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 343 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> | |
| 344 | constexpr I is_heap_until(I first, S last, Comp comp = {}, Proj proj = {}); // Since C++20 | |
| 345 | ||
| 346 | template<random_access_range R, class Proj = identity, | |
| 347 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 348 | constexpr borrowed_iterator_t<R> | |
| 349 | is_heap_until(R&& r, Comp comp = {}, Proj proj = {}); // Since C++20 | |
| 350 | ||
| 351 | template<bidirectional_iterator I, sentinel_for<I> S> | |
| 352 | requires permutable<I> | |
| 353 | constexpr I ranges::reverse(I first, S last); // since C++20 | |
| 354 | ||
| 355 | template<bidirectional_range R> | |
| 356 | requires permutable<iterator_t<R>> | |
| 357 | constexpr borrowed_iterator_t<R> ranges::reverse(R&& r); // since C++20 | |
| 358 | ||
| 359 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 360 | class Proj = identity> | |
| 361 | requires sortable<I, Comp, Proj> | |
| 362 | constexpr I | |
| 363 | ranges::sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 364 | ||
| 365 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 366 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 367 | constexpr borrowed_iterator_t<R> | |
| 368 | ranges::sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 369 | ||
| 370 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 371 | class Proj = identity> | |
| 372 | requires sortable<I, Comp, Proj> | |
| 373 | I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 374 | ||
| 375 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 376 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 377 | borrowed_iterator_t<R> | |
| 378 | ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 379 | ||
| 380 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 381 | class Proj = identity> | |
| 382 | requires sortable<I, Comp, Proj> | |
| 383 | constexpr I | |
| 384 | ranges::partial_sort(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 385 | ||
| 386 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 387 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 388 | constexpr borrowed_iterator_t<R> | |
| 389 | ranges::partial_sort(R&& r, iterator_t<R> middle, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 390 | ||
| 391 | template<class T, output_iterator<const T&> O, sentinel_for<O> S> | |
| 392 | constexpr O ranges::fill(O first, S last, const T& value); // since C++20 | |
| 393 | ||
| 394 | template<class T, output_range<const T&> R> | |
| 395 | constexpr borrowed_iterator_t<R> ranges::fill(R&& r, const T& value); // since C++20 | |
| 396 | ||
| 397 | template<class T, output_iterator<const T&> O> | |
| 398 | constexpr O ranges::fill_n(O first, iter_difference_t<O> n, const T& value); // since C++20 | |
| 399 | ||
| 400 | template<input_or_output_iterator O, sentinel_for<O> S, copy_constructible F> | |
| 401 | requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>> | |
| 402 | constexpr O generate(O first, S last, F gen); // Since C++20 | |
| 403 | ||
| 404 | template<class R, copy_constructible F> | |
| 405 | requires invocable<F&> && output_range<R, invoke_result_t<F&>> | |
| 406 | constexpr borrowed_iterator_t<R> generate(R&& r, F gen); // Since C++20 | |
| 407 | ||
| 408 | template<input_or_output_iterator O, copy_constructible F> | |
| 409 | requires invocable<F&> && indirectly_writable<O, invoke_result_t<F&>> | |
| 410 | constexpr O generate_n(O first, iter_difference_t<O> n, F gen); // Since C++20 | |
| 411 | ||
| 412 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 413 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 414 | requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> | |
| 415 | constexpr bool ranges::equal(I1 first1, S1 last1, I2 first2, S2 last2, | |
| 416 | Pred pred = {}, | |
| 417 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 418 | ||
| 419 | template<input_range R1, input_range R2, class Pred = ranges::equal_to, | |
| 420 | class Proj1 = identity, class Proj2 = identity> | |
| 421 | requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> | |
| 422 | constexpr bool ranges::equal(R1&& r1, R2&& r2, Pred pred = {}, | |
| 423 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 424 | ||
| 425 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 426 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 427 | constexpr bool ranges::all_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 428 | ||
| 429 | template<input_range R, class Proj = identity, | |
| 430 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 431 | constexpr bool ranges::all_of(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 432 | ||
| 433 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 434 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 435 | constexpr bool ranges::any_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 436 | ||
| 437 | template<input_range R, class Proj = identity, | |
| 438 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 439 | constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 440 | ||
| 441 | template<input_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 442 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 443 | constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 444 | ||
| 445 | template<input_range R, class Proj = identity, | |
| 446 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 447 | constexpr bool ranges::none_of(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 448 | ||
| 449 | template<input_iterator I1, sentinel_for<I1> S1, | |
| 450 | random_access_iterator I2, sentinel_for<I2> S2, | |
| 451 | class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> | |
| 452 | requires indirectly_copyable<I1, I2> && sortable<I2, Comp, Proj2> && | |
| 453 | indirect_strict_weak_order<Comp, projected<I1, Proj1>, projected<I2, Proj2>> | |
| 454 | constexpr partial_sort_copy_result<I1, I2> | |
| 455 | partial_sort_copy(I1 first, S1 last, I2 result_first, S2 result_last, | |
| 456 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 | |
| 457 | ||
| 458 | template<input_range R1, random_access_range R2, class Comp = ranges::less, | |
| 459 | class Proj1 = identity, class Proj2 = identity> | |
| 460 | requires indirectly_copyable<iterator_t<R1>, iterator_t<R2>> && | |
| 461 | sortable<iterator_t<R2>, Comp, Proj2> && | |
| 462 | indirect_strict_weak_order<Comp, projected<iterator_t<R1>, Proj1>, | |
| 463 | projected<iterator_t<R2>, Proj2>> | |
| 464 | constexpr partial_sort_copy_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>> | |
| 465 | partial_sort_copy(R1&& r, R2&& result_r, Comp comp = {}, | |
| 466 | Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 | |
| 467 | ||
| 468 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 469 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> | |
| 470 | constexpr bool ranges::is_sorted(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 471 | ||
| 472 | template<forward_range R, class Proj = identity, | |
| 473 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 474 | constexpr bool ranges::is_sorted(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 475 | ||
| 476 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 477 | indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> | |
| 478 | constexpr I ranges::is_sorted_until(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 479 | ||
| 480 | template<forward_range R, class Proj = identity, | |
| 481 | indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> | |
| 482 | constexpr borrowed_iterator_t<R> | |
| 483 | ranges::is_sorted_until(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 484 | ||
| 485 | template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 486 | class Proj = identity> | |
| 487 | requires sortable<I, Comp, Proj> | |
| 488 | constexpr I | |
| 489 | ranges::nth_element(I first, I nth, S last, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 490 | ||
| 491 | template<random_access_range R, class Comp = ranges::less, class Proj = identity> | |
| 492 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 493 | constexpr borrowed_iterator_t<R> | |
| 494 | ranges::nth_element(R&& r, iterator_t<R> nth, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 495 | ||
| 496 | template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, | |
| 497 | indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> | |
| 498 | constexpr I upper_bound(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 499 | ||
| 500 | template<forward_range R, class T, class Proj = identity, | |
| 501 | indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = | |
| 502 | ranges::less> | |
| 503 | constexpr borrowed_iterator_t<R> | |
| 504 | upper_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 505 | ||
| 506 | template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, | |
| 507 | indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> | |
| 508 | constexpr I lower_bound(I first, S last, const T& value, Comp comp = {}, | |
| 509 | Proj proj = {}); // since C++20 | |
| 510 | template<forward_range R, class T, class Proj = identity, | |
| 511 | indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = | |
| 512 | ranges::less> | |
| 513 | constexpr borrowed_iterator_t<R> | |
| 514 | lower_bound(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 515 | ||
| 516 | template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, | |
| 517 | indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> | |
| 518 | constexpr bool binary_search(I first, S last, const T& value, Comp comp = {}, | |
| 519 | Proj proj = {}); // since C++20 | |
| 520 | ||
| 521 | template<forward_range R, class T, class Proj = identity, | |
| 522 | indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = | |
| 523 | ranges::less> | |
| 524 | constexpr bool binary_search(R&& r, const T& value, Comp comp = {}, | |
| 525 | Proj proj = {}); // since C++20 | |
| 526 | ||
| 527 | template<permutable I, sentinel_for<I> S, class Proj = identity, | |
| 528 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 529 | constexpr subrange<I> | |
| 530 | partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20 | |
| 531 | ||
| 532 | template<forward_range R, class Proj = identity, | |
| 533 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 534 | requires permutable<iterator_t<R>> | |
| 535 | constexpr borrowed_subrange_t<R> | |
| 536 | partition(R&& r, Pred pred, Proj proj = {}); // Since C++20 | |
| 537 | ||
| 538 | template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 539 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 540 | requires permutable<I> | |
| 541 | subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // Since C++20 | |
| 542 | ||
| 543 | template<bidirectional_range R, class Proj = identity, | |
| 544 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 545 | requires permutable<iterator_t<R>> | |
| 546 | borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // Since C++20 | |
| 547 | ||
| 548 | template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2, | |
| 549 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 550 | requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> | |
| 551 | constexpr I1 ranges::find_first_of(I1 first1, S1 last1, I2 first2, S2 last2, | |
| 552 | Pred pred = {}, | |
| 553 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 554 | ||
| 555 | template<input_range R1, forward_range R2, | |
| 556 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 557 | requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> | |
| 558 | constexpr borrowed_iterator_t<R1> | |
| 559 | ranges::find_first_of(R1&& r1, R2&& r2, | |
| 560 | Pred pred = {}, | |
| 561 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 562 | ||
| 563 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 564 | indirect_binary_predicate<projected<I, Proj>, | |
| 565 | projected<I, Proj>> Pred = ranges::equal_to> | |
| 566 | constexpr I ranges::adjacent_find(I first, S last, Pred pred = {}, Proj proj = {}); // since C+20 | |
| 567 | ||
| 568 | template<forward_range R, class Proj = identity, | |
| 569 | indirect_binary_predicate<projected<iterator_t<R>, Proj>, | |
| 570 | projected<iterator_t<R>, Proj>> Pred = ranges::equal_to> | |
| 571 | constexpr borrowed_iterator_t<R> ranges::adjacent_find(R&& r, Pred pred = {}, Proj proj = {}); // since C++20 | |
| 572 | ||
| 573 | template<input_iterator I, sentinel_for<I> S, class T1, class T2, class Proj = identity> | |
| 574 | requires indirectly_writable<I, const T2&> && | |
| 575 | indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T1*> | |
| 576 | constexpr I | |
| 577 | ranges::replace(I first, S last, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20 | |
| 578 | ||
| 579 | template<input_range R, class T1, class T2, class Proj = identity> | |
| 580 | requires indirectly_writable<iterator_t<R>, const T2&> && | |
| 581 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T1*> | |
| 582 | constexpr borrowed_iterator_t<R> | |
| 583 | ranges::replace(R&& r, const T1& old_value, const T2& new_value, Proj proj = {}); // since C++20 | |
| 584 | ||
| 585 | template<input_iterator I, sentinel_for<I> S, class T, class Proj = identity, | |
| 586 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 587 | requires indirectly_writable<I, const T&> | |
| 588 | constexpr I ranges::replace_if(I first, S last, Pred pred, const T& new_value, Proj proj = {}); // since C++20 | |
| 589 | ||
| 590 | template<input_range R, class T, class Proj = identity, | |
| 591 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 592 | requires indirectly_writable<iterator_t<R>, const T&> | |
| 593 | constexpr borrowed_iterator_t<R> | |
| 594 | ranges::replace_if(R&& r, Pred pred, const T& new_value, Proj proj = {}); // since C++20 | |
| 595 | ||
| 596 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 597 | class Proj1 = identity, class Proj2 = identity, | |
| 598 | indirect_strict_weak_order<projected<I1, Proj1>, | |
| 599 | projected<I2, Proj2>> Comp = ranges::less> | |
| 600 | constexpr bool | |
| 601 | ranges::lexicographical_compare(I1 first1, S1 last1, I2 first2, S2 last2, | |
| 602 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 603 | ||
| 604 | template<input_range R1, input_range R2, class Proj1 = identity, | |
| 605 | class Proj2 = identity, | |
| 606 | indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>, | |
| 607 | projected<iterator_t<R2>, Proj2>> Comp = ranges::less> | |
| 608 | constexpr bool | |
| 609 | ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, | |
| 610 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 611 | ||
| 612 | template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> | |
| 613 | requires indirectly_movable<I1, I2> | |
| 614 | constexpr ranges::move_backward_result<I1, I2> | |
| 615 | ranges::move_backward(I1 first, S1 last, I2 result); // since C++20 | |
| 616 | ||
| 617 | template<bidirectional_range R, bidirectional_iterator I> | |
| 618 | requires indirectly_movable<iterator_t<R>, I> | |
| 619 | constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I> | |
| 620 | ranges::move_backward(R&& r, I result); // since C++20 | |
| 621 | ||
| 622 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O> | |
| 623 | requires indirectly_movable<I, O> | |
| 624 | constexpr ranges::move_result<I, O> | |
| 625 | ranges::move(I first, S last, O result); // since C++20 | |
| 626 | ||
| 627 | template<input_range R, weakly_incrementable O> | |
| 628 | requires indirectly_movable<iterator_t<R>, O> | |
| 629 | constexpr ranges::move_result<borrowed_iterator_t<R>, O> | |
| 630 | ranges::move(R&& r, O result); // since C++20 | |
| 631 | ||
| 632 | template<class I, class O1, class O2> | |
| 633 | using partition_copy_result = in_out_out_result<I, O1, O2>; // since C++20 | |
| 634 | ||
| 635 | template<input_iterator I, sentinel_for<I> S, | |
| 636 | weakly_incrementable O1, weakly_incrementable O2, | |
| 637 | class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 638 | requires indirectly_copyable<I, O1> && indirectly_copyable<I, O2> | |
| 639 | constexpr partition_copy_result<I, O1, O2> | |
| 640 | partition_copy(I first, S last, O1 out_true, O2 out_false, Pred pred, | |
| 641 | Proj proj = {}); // Since C++20 | |
| 642 | ||
| 643 | template<input_range R, weakly_incrementable O1, weakly_incrementable O2, | |
| 644 | class Proj = identity, | |
| 645 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 646 | requires indirectly_copyable<iterator_t<R>, O1> && | |
| 647 | indirectly_copyable<iterator_t<R>, O2> | |
| 648 | constexpr partition_copy_result<borrowed_iterator_t<R>, O1, O2> | |
| 649 | partition_copy(R&& r, O1 out_true, O2 out_false, Pred pred, Proj proj = {}); // Since C++20 | |
| 650 | ||
| 651 | template<forward_iterator I, sentinel_for<I> S, class Proj = identity, | |
| 652 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 653 | constexpr I partition_point(I first, S last, Pred pred, Proj proj = {}); // Since C++20 | |
| 654 | ||
| 655 | template<forward_range R, class Proj = identity, | |
| 656 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 657 | constexpr borrowed_iterator_t<R> | |
| 658 | partition_point(R&& r, Pred pred, Proj proj = {}); // Since C++20 | |
| 659 | ||
| 660 | template<class I1, class I2, class O> | |
| 661 | using merge_result = in_in_out_result<I1, I2, O>; // since C++20 | |
| 662 | ||
| 663 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 664 | weakly_incrementable O, class Comp = ranges::less, class Proj1 = identity, | |
| 665 | class Proj2 = identity> | |
| 666 | requires mergeable<I1, I2, O, Comp, Proj1, Proj2> | |
| 667 | constexpr merge_result<I1, I2, O> | |
| 668 | merge(I1 first1, S1 last1, I2 first2, S2 last2, O result, | |
| 669 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 670 | ||
| 671 | template<input_range R1, input_range R2, weakly_incrementable O, class Comp = ranges::less, | |
| 672 | class Proj1 = identity, class Proj2 = identity> | |
| 673 | requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2> | |
| 674 | constexpr merge_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O> | |
| 675 | merge(R1&& r1, R2&& r2, O result, | |
| 676 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 677 | ||
| 678 | template<permutable I, sentinel_for<I> S, class T, class Proj = identity> | |
| 679 | requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*> | |
| 680 | constexpr subrange<I> ranges::remove(I first, S last, const T& value, Proj proj = {}); // since C++20 | |
| 681 | ||
| 682 | template<forward_range R, class T, class Proj = identity> | |
| 683 | requires permutable<iterator_t<R>> && | |
| 684 | indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*> | |
| 685 | constexpr borrowed_subrange_t<R> | |
| 686 | ranges::remove(R&& r, const T& value, Proj proj = {}); // since C++20 | |
| 687 | ||
| 688 | template<permutable I, sentinel_for<I> S, class Proj = identity, | |
| 689 | indirect_unary_predicate<projected<I, Proj>> Pred> | |
| 690 | constexpr subrange<I> ranges::remove_if(I first, S last, Pred pred, Proj proj = {}); // since C++20 | |
| 691 | ||
| 692 | template<forward_range R, class Proj = identity, | |
| 693 | indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> | |
| 694 | requires permutable<iterator_t<R>> | |
| 695 | constexpr borrowed_subrange_t<R> | |
| 696 | ranges::remove_if(R&& r, Pred pred, Proj proj = {}); // since C++20 | |
| 697 | ||
| 698 | template<class I, class O> | |
| 699 | using set_difference_result = in_out_result<I, O>; // since C++20 | |
| 700 | ||
| 701 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 702 | weakly_incrementable O, class Comp = ranges::less, | |
| 703 | class Proj1 = identity, class Proj2 = identity> | |
| 704 | requires mergeable<I1, I2, O, Comp, Proj1, Proj2> | |
| 705 | constexpr set_difference_result<I1, O> | |
| 706 | set_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result, | |
| 707 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 708 | ||
| 709 | template<input_range R1, input_range R2, weakly_incrementable O, | |
| 710 | class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> | |
| 711 | requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2> | |
| 712 | constexpr set_difference_result<borrowed_iterator_t<R1>, O> | |
| 713 | set_difference(R1&& r1, R2&& r2, O result, | |
| 714 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 715 | ||
| 716 | template<class I1, class I2, class O> | |
| 717 | using set_intersection_result = in_in_out_result<I1, I2, O>; // since C++20 | |
| 718 | ||
| 719 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 720 | weakly_incrementable O, class Comp = ranges::less, | |
| 721 | class Proj1 = identity, class Proj2 = identity> | |
| 722 | requires mergeable<I1, I2, O, Comp, Proj1, Proj2> | |
| 723 | constexpr set_intersection_result<I1, I2, O> | |
| 724 | set_intersection(I1 first1, S1 last1, I2 first2, S2 last2, O result, | |
| 725 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 726 | ||
| 727 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 728 | weakly_incrementable O, class Comp = ranges::less, | |
| 729 | class Proj1 = identity, class Proj2 = identity> | |
| 730 | requires mergeable<I1, I2, O, Comp, Proj1, Proj2> | |
| 731 | constexpr set_intersection_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O> | |
| 732 | set_intersection(R1&& r1, R2&& r2, O result, | |
| 733 | Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 734 | ||
| 735 | template <class _InIter, class _OutIter> | |
| 736 | using reverse_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 | |
| 737 | ||
| 738 | template<bidirectional_iterator I, sentinel_for<I> S, weakly_incrementable O> | |
| 739 | requires indirectly_copyable<I, O> | |
| 740 | constexpr ranges::reverse_copy_result<I, O> | |
| 741 | ranges::reverse_copy(I first, S last, O result); // since C++20 | |
| 742 | ||
| 743 | template<bidirectional_range R, weakly_incrementable O> | |
| 744 | requires indirectly_copyable<iterator_t<R>, O> | |
| 745 | constexpr ranges::reverse_copy_result<borrowed_iterator_t<R>, O> | |
| 746 | ranges::reverse_copy(R&& r, O result); // since C++20 | |
| 747 | ||
| 748 | template <class _InIter, class _OutIter> | |
| 749 | using rotate_copy_result = in_out_result<_InIter, _OutIter>; // since C++20 | |
| 750 | ||
| 751 | template<forward_iterator I, sentinel_for<I> S, weakly_incrementable O> | |
| 752 | requires indirectly_copyable<I, O> | |
| 753 | constexpr ranges::rotate_copy_result<I, O> | |
| 754 | ranges::rotate_copy(I first, I middle, S last, O result); // since C++20 | |
| 755 | ||
| 756 | template<forward_range R, weakly_incrementable O> | |
| 757 | requires indirectly_copyable<iterator_t<R>, O> | |
| 758 | constexpr ranges::rotate_copy_result<borrowed_iterator_t<R>, O> | |
| 759 | ranges::rotate_copy(R&& r, iterator_t<R> middle, O result); // since C++20 | |
| 760 | ||
| 761 | template<random_access_iterator I, sentinel_for<I> S, class Gen> | |
| 762 | requires permutable<I> && | |
| 763 | uniform_random_bit_generator<remove_reference_t<Gen>> | |
| 764 | I shuffle(I first, S last, Gen&& g); // Since C++20 | |
| 765 | ||
| 766 | template<random_access_range R, class Gen> | |
| 767 | requires permutable<iterator_t<R>> && | |
| 768 | uniform_random_bit_generator<remove_reference_t<Gen>> | |
| 769 | borrowed_iterator_t<R> shuffle(R&& r, Gen&& g); // Since C++20 | |
| 770 | ||
| 771 | template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, | |
| 772 | sentinel_for<I2> S2, class Pred = ranges::equal_to, | |
| 773 | class Proj1 = identity, class Proj2 = identity> | |
| 774 | requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> | |
| 775 | constexpr subrange<I1> | |
| 776 | ranges::search(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, | |
| 777 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 778 | ||
| 779 | template<forward_range R1, forward_range R2, class Pred = ranges::equal_to, | |
| 780 | class Proj1 = identity, class Proj2 = identity> | |
| 781 | requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> | |
| 782 | constexpr borrowed_subrange_t<R1> | |
| 783 | ranges::search(R1&& r1, R2&& r2, Pred pred = {}, | |
| 784 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 785 | ||
| 786 | template<forward_iterator I, sentinel_for<I> S, class T, | |
| 787 | class Pred = ranges::equal_to, class Proj = identity> | |
| 788 | requires indirectly_comparable<I, const T*, Pred, Proj> | |
| 789 | constexpr subrange<I> | |
| 790 | ranges::search_n(I first, S last, iter_difference_t<I> count, | |
| 791 | const T& value, Pred pred = {}, Proj proj = {}); // since C++20 | |
| 792 | ||
| 793 | template<forward_range R, class T, class Pred = ranges::equal_to, | |
| 794 | class Proj = identity> | |
| 795 | requires indirectly_comparable<iterator_t<R>, const T*, Pred, Proj> | |
| 796 | constexpr borrowed_subrange_t<R> | |
| 797 | ranges::search_n(R&& r, range_difference_t<R> count, | |
| 798 | const T& value, Pred pred = {}, Proj proj = {}); // since C++20 | |
| 799 | ||
| 800 | template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2, | |
| 801 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 802 | requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> | |
| 803 | constexpr subrange<I1> | |
| 804 | ranges::find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, | |
| 805 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 806 | ||
| 807 | template<forward_range R1, forward_range R2, | |
| 808 | class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> | |
| 809 | requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> | |
| 810 | constexpr borrowed_subrange_t<R1> | |
| 811 | ranges::find_end(R1&& r1, R2&& r2, Pred pred = {}, | |
| 812 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 813 | ||
| 814 | template<class I1, class I2, class O> | |
| 815 | using set_symmetric_difference_result = in_in_out_result<I1, I2, O>; // since C++20 | |
| 816 | ||
| 817 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 818 | weakly_incrementable O, class Comp = ranges::less, | |
| 819 | class Proj1 = identity, class Proj2 = identity> | |
| 820 | requires mergeable<I1, I2, O, Comp, Proj1, Proj2> | |
| 821 | constexpr set_symmetric_difference_result<I1, I2, O> | |
| 822 | set_symmetric_difference(I1 first1, S1 last1, I2 first2, S2 last2, O result, | |
| 823 | Comp comp = {}, Proj1 proj1 = {}, | |
| 824 | Proj2 proj2 = {}); // since C++20 | |
| 825 | ||
| 826 | template<input_range R1, input_range R2, weakly_incrementable O, | |
| 827 | class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> | |
| 828 | requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2> | |
| 829 | constexpr set_symmetric_difference_result<borrowed_iterator_t<R1>, | |
| 830 | borrowed_iterator_t<R2>, O> | |
| 831 | set_symmetric_difference(R1&& r1, R2&& r2, O result, Comp comp = {}, | |
| 832 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 833 | ||
| 834 | template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity, | |
| 835 | indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less> | |
| 836 | constexpr subrange<I> | |
| 837 | equal_range(I first, S last, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 838 | ||
| 839 | template<forward_range R, class T, class Proj = identity, | |
| 840 | indirect_strict_weak_order<const T*, projected<iterator_t<R>, Proj>> Comp = | |
| 841 | ranges::less> | |
| 842 | constexpr borrowed_subrange_t<R> | |
| 843 | equal_range(R&& r, const T& value, Comp comp = {}, Proj proj = {}); // since C++20 | |
| 844 | ||
| 845 | template<class I1, class I2, class O> | |
| 846 | using set_union_result = in_in_out_result<I1, I2, O>; // since C++20 | |
| 847 | ||
| 848 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 849 | weakly_incrementable O, class Comp = ranges::less, | |
| 850 | class Proj1 = identity, class Proj2 = identity> | |
| 851 | requires mergeable<I1, I2, O, Comp, Proj1, Proj2> | |
| 852 | constexpr set_union_result<I1, I2, O> | |
| 853 | set_union(I1 first1, S1 last1, I2 first2, S2 last2, O result, Comp comp = {}, | |
| 854 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 855 | ||
| 856 | template<input_range R1, input_range R2, weakly_incrementable O, | |
| 857 | class Comp = ranges::less, class Proj1 = identity, class Proj2 = identity> | |
| 858 | requires mergeable<iterator_t<R1>, iterator_t<R2>, O, Comp, Proj1, Proj2> | |
| 859 | constexpr set_union_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>, O> | |
| 860 | set_union(R1&& r1, R2&& r2, O result, Comp comp = {}, | |
| 861 | Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 | |
| 862 | ||
| 863 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, | |
| 864 | class Proj1 = identity, class Proj2 = identity, | |
| 865 | indirect_strict_weak_order<projected<I1, Proj1>, projected<I2, Proj2>> Comp = | |
| 866 | ranges::less> | |
| 867 | constexpr bool includes(I1 first1, S1 last1, I2 first2, S2 last2, Comp comp = {}, | |
| 868 | Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 | |
| 869 | ||
| 870 | template<input_range R1, input_range R2, class Proj1 = identity, | |
| 871 | class Proj2 = identity, | |
| 872 | indirect_strict_weak_order<projected<iterator_t<R1>, Proj1>, | |
| 873 | projected<iterator_t<R2>, Proj2>> Comp = ranges::less> | |
| 874 | constexpr bool includes(R1&& r1, R2&& r2, Comp comp = {}, | |
| 875 | Proj1 proj1 = {}, Proj2 proj2 = {}); // Since C++20 | |
| 876 | ||
| 877 | template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less, | |
| 878 | class Proj = identity> | |
| 879 | requires sortable<I, Comp, Proj> | |
| 880 | I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // Since C++20 | |
| 881 | ||
| 882 | template<bidirectional_range R, class Comp = ranges::less, class Proj = identity> | |
| 883 | requires sortable<iterator_t<R>, Comp, Proj> | |
| 884 | borrowed_iterator_t<R> | |
| 885 | inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {}, | |
| 886 | Proj proj = {}); // Since C++20 | |
| 887 | ||
| 888 | template<permutable I, sentinel_for<I> S, class Proj = identity, | |
| 889 | indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to> | |
| 890 | constexpr subrange<I> unique(I first, S last, C comp = {}, Proj proj = {}); // Since C++20 | |
| 891 | ||
| 892 | template<forward_range R, class Proj = identity, | |
| 893 | indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to> | |
| 894 | requires permutable<iterator_t<R>> | |
| 895 | constexpr borrowed_subrange_t<R> | |
| 896 | unique(R&& r, C comp = {}, Proj proj = {}); // Since C++20 | |
| 897 | ||
| 898 | template<input_iterator I, sentinel_for<I> S, weakly_incrementable O, class Proj = identity, | |
| 899 | indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to> | |
| 900 | requires indirectly_copyable<I, O> && | |
| 901 | (forward_iterator<I> || | |
| 902 | (input_iterator<O> && same_as<iter_value_t<I>, iter_value_t<O>>) || | |
| 903 | indirectly_copyable_storable<I, O>) | |
| 904 | constexpr unique_copy_result<I, O> | |
| 905 | unique_copy(I first, S last, O result, C comp = {}, Proj proj = {}); // Since C++20 | |
| 906 | ||
| 907 | template<input_range R, weakly_incrementable O, class Proj = identity, | |
| 908 | indirect_equivalence_relation<projected<iterator_t<R>, Proj>> C = ranges::equal_to> | |
| 909 | requires indirectly_copyable<iterator_t<R>, O> && | |
| 910 | (forward_iterator<iterator_t<R>> || | |
| 911 | (input_iterator<O> && same_as<range_value_t<R>, iter_value_t<O>>) || | |
| 912 | indirectly_copyable_storable<iterator_t<R>, O>) | |
| 913 | constexpr unique_copy_result<borrowed_iterator_t<R>, O> | |
| 914 | unique_copy(R&& r, O result, C comp = {}, Proj proj = {}); // Since C++20 | |
| 27 | 915 | } |
| 28 | 916 | |
| 29 | template <class InputIterator, class Predicate> | |
| 30 | 917 | constexpr bool // constexpr in C++20 |
| 31 | 918 | all_of(InputIterator first, InputIterator last, Predicate pred); |
| 32 | 919 | |
| ... | ... | @@ -192,10 +1079,35 @@ template <class BidirectionalIterator1, class BidirectionalIterator2> |
| 192 | 1079 | copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, |
| 193 | 1080 | BidirectionalIterator2 result); |
| 194 | 1081 | |
| 1082 | // [alg.move], move | |
| 1083 | template<class InputIterator, class OutputIterator> | |
| 1084 | constexpr OutputIterator move(InputIterator first, InputIterator last, | |
| 1085 | OutputIterator result); | |
| 1086 | ||
| 1087 | template<class BidirectionalIterator1, class BidirectionalIterator2> | |
| 1088 | constexpr BidirectionalIterator2 | |
| 1089 | move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, | |
| 1090 | BidirectionalIterator2 result); | |
| 1091 | ||
| 195 | 1092 | template <class ForwardIterator1, class ForwardIterator2> |
| 196 | 1093 | constexpr ForwardIterator2 // constexpr in C++20 |
| 197 | 1094 | swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); |
| 198 | 1095 | |
| 1096 | namespace ranges { | |
| 1097 | template<class I1, class I2> | |
| 1098 | using swap_ranges_result = in_in_result<I1, I2>; | |
| 1099 | ||
| 1100 | template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2> | |
| 1101 | requires indirectly_swappable<I1, I2> | |
| 1102 | constexpr ranges::swap_ranges_result<I1, I2> | |
| 1103 | swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2); | |
| 1104 | ||
| 1105 | template<input_range R1, input_range R2> | |
| 1106 | requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>> | |
| 1107 | constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>> | |
| 1108 | swap_ranges(R1&& r1, R2&& r2); | |
| 1109 | } | |
| 1110 | ||
| 199 | 1111 | template <class ForwardIterator1, class ForwardIterator2> |
| 200 | 1112 | constexpr void // constexpr in C++20 |
| 201 | 1113 | iter_swap(ForwardIterator1 a, ForwardIterator2 b); |
| ... | ... | @@ -648,28 +1560,18 @@ template <class BidirectionalIterator> |
| 648 | 1560 | template <class BidirectionalIterator, class Compare> |
| 649 | 1561 | constexpr bool // constexpr in C++20 |
| 650 | 1562 | prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp); |
| 651 | ||
| 652 | namespace ranges { | |
| 653 | // [algorithms.results], algorithm result types | |
| 654 | template<class InputIterator, class OutputIterator> | |
| 655 | struct in_out_result; | |
| 656 | } | |
| 657 | ||
| 658 | 1563 | } // std |
| 659 | 1564 | |
| 660 | 1565 | */ |
| 661 | 1566 | |
| 662 | #include <__bits> // __libcpp_clz | |
| 1567 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 1568 | #include <__bits> | |
| 663 | 1569 | #include <__config> |
| 664 | 1570 | #include <__debug> |
| 665 | 1571 | #include <cstddef> |
| 666 | 1572 | #include <cstring> |
| 667 | #include <functional> | |
| 668 | #include <initializer_list> | |
| 669 | #include <iterator> | |
| 670 | 1573 | #include <memory> |
| 671 | 1574 | #include <type_traits> |
| 672 | #include <utility> // swap_ranges | |
| 673 | 1575 | #include <version> |
| 674 | 1576 | |
| 675 | 1577 | #include <__algorithm/adjacent_find.h> |
| ... | ... | @@ -699,8 +1601,11 @@ template<class InputIterator, class OutputIterator> |
| 699 | 1601 | #include <__algorithm/generate.h> |
| 700 | 1602 | #include <__algorithm/generate_n.h> |
| 701 | 1603 | #include <__algorithm/half_positive.h> |
| 1604 | #include <__algorithm/in_found_result.h> | |
| 1605 | #include <__algorithm/in_fun_result.h> | |
| 702 | 1606 | #include <__algorithm/in_in_out_result.h> |
| 703 | 1607 | #include <__algorithm/in_in_result.h> |
| 1608 | #include <__algorithm/in_out_out_result.h> | |
| 704 | 1609 | #include <__algorithm/in_out_result.h> |
| 705 | 1610 | #include <__algorithm/includes.h> |
| 706 | 1611 | #include <__algorithm/inplace_merge.h> |
| ... | ... | @@ -719,6 +1624,7 @@ template<class InputIterator, class OutputIterator> |
| 719 | 1624 | #include <__algorithm/merge.h> |
| 720 | 1625 | #include <__algorithm/min.h> |
| 721 | 1626 | #include <__algorithm/min_element.h> |
| 1627 | #include <__algorithm/min_max_result.h> | |
| 722 | 1628 | #include <__algorithm/minmax.h> |
| 723 | 1629 | #include <__algorithm/minmax_element.h> |
| 724 | 1630 | #include <__algorithm/mismatch.h> |
| ... | ... | @@ -735,6 +1641,81 @@ template<class InputIterator, class OutputIterator> |
| 735 | 1641 | #include <__algorithm/pop_heap.h> |
| 736 | 1642 | #include <__algorithm/prev_permutation.h> |
| 737 | 1643 | #include <__algorithm/push_heap.h> |
| 1644 | #include <__algorithm/ranges_adjacent_find.h> | |
| 1645 | #include <__algorithm/ranges_all_of.h> | |
| 1646 | #include <__algorithm/ranges_any_of.h> | |
| 1647 | #include <__algorithm/ranges_binary_search.h> | |
| 1648 | #include <__algorithm/ranges_copy.h> | |
| 1649 | #include <__algorithm/ranges_copy_backward.h> | |
| 1650 | #include <__algorithm/ranges_copy_if.h> | |
| 1651 | #include <__algorithm/ranges_copy_n.h> | |
| 1652 | #include <__algorithm/ranges_count.h> | |
| 1653 | #include <__algorithm/ranges_count_if.h> | |
| 1654 | #include <__algorithm/ranges_equal.h> | |
| 1655 | #include <__algorithm/ranges_equal_range.h> | |
| 1656 | #include <__algorithm/ranges_fill.h> | |
| 1657 | #include <__algorithm/ranges_fill_n.h> | |
| 1658 | #include <__algorithm/ranges_find.h> | |
| 1659 | #include <__algorithm/ranges_find_end.h> | |
| 1660 | #include <__algorithm/ranges_find_first_of.h> | |
| 1661 | #include <__algorithm/ranges_find_if.h> | |
| 1662 | #include <__algorithm/ranges_find_if_not.h> | |
| 1663 | #include <__algorithm/ranges_for_each.h> | |
| 1664 | #include <__algorithm/ranges_for_each_n.h> | |
| 1665 | #include <__algorithm/ranges_generate.h> | |
| 1666 | #include <__algorithm/ranges_generate_n.h> | |
| 1667 | #include <__algorithm/ranges_includes.h> | |
| 1668 | #include <__algorithm/ranges_inplace_merge.h> | |
| 1669 | #include <__algorithm/ranges_is_heap.h> | |
| 1670 | #include <__algorithm/ranges_is_heap_until.h> | |
| 1671 | #include <__algorithm/ranges_is_partitioned.h> | |
| 1672 | #include <__algorithm/ranges_is_sorted.h> | |
| 1673 | #include <__algorithm/ranges_is_sorted_until.h> | |
| 1674 | #include <__algorithm/ranges_lexicographical_compare.h> | |
| 1675 | #include <__algorithm/ranges_lower_bound.h> | |
| 1676 | #include <__algorithm/ranges_make_heap.h> | |
| 1677 | #include <__algorithm/ranges_max.h> | |
| 1678 | #include <__algorithm/ranges_max_element.h> | |
| 1679 | #include <__algorithm/ranges_merge.h> | |
| 1680 | #include <__algorithm/ranges_min.h> | |
| 1681 | #include <__algorithm/ranges_min_element.h> | |
| 1682 | #include <__algorithm/ranges_minmax.h> | |
| 1683 | #include <__algorithm/ranges_minmax_element.h> | |
| 1684 | #include <__algorithm/ranges_mismatch.h> | |
| 1685 | #include <__algorithm/ranges_move.h> | |
| 1686 | #include <__algorithm/ranges_move_backward.h> | |
| 1687 | #include <__algorithm/ranges_none_of.h> | |
| 1688 | #include <__algorithm/ranges_nth_element.h> | |
| 1689 | #include <__algorithm/ranges_partial_sort.h> | |
| 1690 | #include <__algorithm/ranges_partial_sort_copy.h> | |
| 1691 | #include <__algorithm/ranges_partition.h> | |
| 1692 | #include <__algorithm/ranges_partition_copy.h> | |
| 1693 | #include <__algorithm/ranges_partition_point.h> | |
| 1694 | #include <__algorithm/ranges_pop_heap.h> | |
| 1695 | #include <__algorithm/ranges_push_heap.h> | |
| 1696 | #include <__algorithm/ranges_remove.h> | |
| 1697 | #include <__algorithm/ranges_remove_if.h> | |
| 1698 | #include <__algorithm/ranges_replace.h> | |
| 1699 | #include <__algorithm/ranges_replace_if.h> | |
| 1700 | #include <__algorithm/ranges_reverse.h> | |
| 1701 | #include <__algorithm/ranges_reverse_copy.h> | |
| 1702 | #include <__algorithm/ranges_rotate_copy.h> | |
| 1703 | #include <__algorithm/ranges_search.h> | |
| 1704 | #include <__algorithm/ranges_search_n.h> | |
| 1705 | #include <__algorithm/ranges_set_difference.h> | |
| 1706 | #include <__algorithm/ranges_set_intersection.h> | |
| 1707 | #include <__algorithm/ranges_set_symmetric_difference.h> | |
| 1708 | #include <__algorithm/ranges_set_union.h> | |
| 1709 | #include <__algorithm/ranges_shuffle.h> | |
| 1710 | #include <__algorithm/ranges_sort.h> | |
| 1711 | #include <__algorithm/ranges_sort_heap.h> | |
| 1712 | #include <__algorithm/ranges_stable_partition.h> | |
| 1713 | #include <__algorithm/ranges_stable_sort.h> | |
| 1714 | #include <__algorithm/ranges_swap_ranges.h> | |
| 1715 | #include <__algorithm/ranges_transform.h> | |
| 1716 | #include <__algorithm/ranges_unique.h> | |
| 1717 | #include <__algorithm/ranges_unique_copy.h> | |
| 1718 | #include <__algorithm/ranges_upper_bound.h> | |
| 738 | 1719 | #include <__algorithm/remove.h> |
| 739 | 1720 | #include <__algorithm/remove_copy.h> |
| 740 | 1721 | #include <__algorithm/remove_copy_if.h> |
| ... | ... | @@ -769,8 +1750,17 @@ template<class InputIterator, class OutputIterator> |
| 769 | 1750 | #include <__algorithm/unwrap_iter.h> |
| 770 | 1751 | #include <__algorithm/upper_bound.h> |
| 771 | 1752 | |
| 1753 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 1754 | # include <chrono> | |
| 1755 | # include <iterator> | |
| 1756 | # include <utility> | |
| 1757 | #endif | |
| 1758 | ||
| 1759 | // standard-mandated includes | |
| 1760 | #include <initializer_list> | |
| 1761 | ||
| 772 | 1762 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 773 | #pragma GCC system_header | |
| 1763 | # pragma GCC system_header | |
| 774 | 1764 | #endif |
| 775 | 1765 | |
| 776 | 1766 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/any+14-2| ... | ... | @@ -80,17 +80,26 @@ namespace std { |
| 80 | 80 | |
| 81 | 81 | */ |
| 82 | 82 | |
| 83 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 83 | 84 | #include <__availability> |
| 84 | 85 | #include <__config> |
| 85 | 86 | #include <__utility/forward.h> |
| 87 | #include <__utility/in_place.h> | |
| 88 | #include <__utility/move.h> | |
| 89 | #include <__utility/unreachable.h> | |
| 86 | 90 | #include <cstdlib> |
| 91 | #include <initializer_list> | |
| 87 | 92 | #include <memory> |
| 88 | 93 | #include <type_traits> |
| 89 | 94 | #include <typeinfo> |
| 90 | 95 | #include <version> |
| 91 | 96 | |
| 97 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 98 | # include <chrono> | |
| 99 | #endif | |
| 100 | ||
| 92 | 101 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 93 | #pragma GCC system_header | |
| 102 | # pragma GCC system_header | |
| 94 | 103 | #endif |
| 95 | 104 | |
| 96 | 105 | namespace std { |
| ... | ... | @@ -262,7 +271,7 @@ public: |
| 262 | 271 | is_copy_constructible<_Tp>::value> |
| 263 | 272 | > |
| 264 | 273 | _LIBCPP_INLINE_VISIBILITY |
| 265 | _Tp& emplace(_Args&&... args); | |
| 274 | _Tp& emplace(_Args&&...); | |
| 266 | 275 | |
| 267 | 276 | template <class _ValueType, class _Up, class ..._Args, |
| 268 | 277 | class _Tp = decay_t<_ValueType>, |
| ... | ... | @@ -364,6 +373,7 @@ namespace __any_imp |
| 364 | 373 | case _Action::_TypeInfo: |
| 365 | 374 | return __type_info(); |
| 366 | 375 | } |
| 376 | __libcpp_unreachable(); | |
| 367 | 377 | } |
| 368 | 378 | |
| 369 | 379 | template <class ..._Args> |
| ... | ... | @@ -447,6 +457,7 @@ namespace __any_imp |
| 447 | 457 | case _Action::_TypeInfo: |
| 448 | 458 | return __type_info(); |
| 449 | 459 | } |
| 460 | __libcpp_unreachable(); | |
| 450 | 461 | } |
| 451 | 462 | |
| 452 | 463 | template <class ..._Args> |
| ... | ... | @@ -658,6 +669,7 @@ _RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept { |
| 658 | 669 | } |
| 659 | 670 | |
| 660 | 671 | template <class _ValueType> |
| 672 | _LIBCPP_HIDE_FROM_ABI | |
| 661 | 673 | add_pointer_t<_ValueType> |
| 662 | 674 | any_cast(any * __any) _NOEXCEPT |
| 663 | 675 | { |
lib/libcxx/include/array+39-21| ... | ... | @@ -108,19 +108,42 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce |
| 108 | 108 | |
| 109 | 109 | */ |
| 110 | 110 | |
| 111 | #include <__algorithm/equal.h> | |
| 112 | #include <__algorithm/fill_n.h> | |
| 113 | #include <__algorithm/lexicographical_compare.h> | |
| 114 | #include <__algorithm/swap_ranges.h> | |
| 115 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 111 | 116 | #include <__config> |
| 112 | #include <__debug> | |
| 117 | #include <__iterator/reverse_iterator.h> | |
| 113 | 118 | #include <__tuple> |
| 114 | #include <algorithm> | |
| 115 | #include <cstdlib> // for _LIBCPP_UNREACHABLE | |
| 116 | #include <iterator> | |
| 119 | #include <__utility/integer_sequence.h> | |
| 120 | #include <__utility/move.h> | |
| 121 | #include <__utility/unreachable.h> | |
| 117 | 122 | #include <stdexcept> |
| 118 | 123 | #include <type_traits> |
| 119 | #include <utility> | |
| 120 | 124 | #include <version> |
| 121 | 125 | |
| 126 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 127 | # include <algorithm> | |
| 128 | # include <iterator> | |
| 129 | # include <utility> | |
| 130 | #endif | |
| 131 | ||
| 132 | // standard-mandated includes | |
| 133 | ||
| 134 | // [iterator.range] | |
| 135 | #include <__iterator/access.h> | |
| 136 | #include <__iterator/data.h> | |
| 137 | #include <__iterator/empty.h> | |
| 138 | #include <__iterator/reverse_access.h> | |
| 139 | #include <__iterator/size.h> | |
| 140 | ||
| 141 | // [array.syn] | |
| 142 | #include <compare> | |
| 143 | #include <initializer_list> | |
| 144 | ||
| 122 | 145 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 123 | #pragma GCC system_header | |
| 146 | # pragma GCC system_header | |
| 124 | 147 | #endif |
| 125 | 148 | |
| 126 | 149 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -309,54 +332,54 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> |
| 309 | 332 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 310 | 333 | reference operator[](size_type) _NOEXCEPT { |
| 311 | 334 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); |
| 312 | _LIBCPP_UNREACHABLE(); | |
| 335 | __libcpp_unreachable(); | |
| 313 | 336 | } |
| 314 | 337 | |
| 315 | 338 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 316 | 339 | const_reference operator[](size_type) const _NOEXCEPT { |
| 317 | 340 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); |
| 318 | _LIBCPP_UNREACHABLE(); | |
| 341 | __libcpp_unreachable(); | |
| 319 | 342 | } |
| 320 | 343 | |
| 321 | 344 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 322 | 345 | reference at(size_type) { |
| 323 | 346 | __throw_out_of_range("array<T, 0>::at"); |
| 324 | _LIBCPP_UNREACHABLE(); | |
| 347 | __libcpp_unreachable(); | |
| 325 | 348 | } |
| 326 | 349 | |
| 327 | 350 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 328 | 351 | const_reference at(size_type) const { |
| 329 | 352 | __throw_out_of_range("array<T, 0>::at"); |
| 330 | _LIBCPP_UNREACHABLE(); | |
| 353 | __libcpp_unreachable(); | |
| 331 | 354 | } |
| 332 | 355 | |
| 333 | 356 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 334 | 357 | reference front() _NOEXCEPT { |
| 335 | 358 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); |
| 336 | _LIBCPP_UNREACHABLE(); | |
| 359 | __libcpp_unreachable(); | |
| 337 | 360 | } |
| 338 | 361 | |
| 339 | 362 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 340 | 363 | const_reference front() const _NOEXCEPT { |
| 341 | 364 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); |
| 342 | _LIBCPP_UNREACHABLE(); | |
| 365 | __libcpp_unreachable(); | |
| 343 | 366 | } |
| 344 | 367 | |
| 345 | 368 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 |
| 346 | 369 | reference back() _NOEXCEPT { |
| 347 | 370 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); |
| 348 | _LIBCPP_UNREACHABLE(); | |
| 371 | __libcpp_unreachable(); | |
| 349 | 372 | } |
| 350 | 373 | |
| 351 | 374 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 352 | 375 | const_reference back() const _NOEXCEPT { |
| 353 | 376 | _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); |
| 354 | _LIBCPP_UNREACHABLE(); | |
| 377 | __libcpp_unreachable(); | |
| 355 | 378 | } |
| 356 | 379 | }; |
| 357 | 380 | |
| 358 | 381 | |
| 359 | #if _LIBCPP_STD_VER >= 17 | |
| 382 | #if _LIBCPP_STD_VER > 14 | |
| 360 | 383 | template<class _Tp, class... _Args, |
| 361 | 384 | class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value> |
| 362 | 385 | > |
| ... | ... | @@ -415,12 +438,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) |
| 415 | 438 | |
| 416 | 439 | template <class _Tp, size_t _Size> |
| 417 | 440 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 418 | typename enable_if | |
| 419 | < | |
| 420 | _Size == 0 || | |
| 421 | __is_swappable<_Tp>::value, | |
| 422 | void | |
| 423 | >::type | |
| 441 | __enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void> | |
| 424 | 442 | swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) |
| 425 | 443 | _NOEXCEPT_(noexcept(__x.swap(__y))) |
| 426 | 444 | { |
lib/libcxx/include/atomic+15-25| ... | ... | @@ -518,7 +518,9 @@ template <class T> |
| 518 | 518 | |
| 519 | 519 | */ |
| 520 | 520 | |
| 521 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 521 | 522 | #include <__availability> |
| 523 | #include <__chrono/duration.h> | |
| 522 | 524 | #include <__config> |
| 523 | 525 | #include <__thread/poll_with_backoff.h> |
| 524 | 526 | #include <__thread/timed_backoff_policy.h> |
| ... | ... | @@ -532,15 +534,19 @@ template <class T> |
| 532 | 534 | # include <__threading_support> |
| 533 | 535 | #endif |
| 534 | 536 | |
| 537 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 538 | # include <chrono> | |
| 539 | #endif | |
| 540 | ||
| 535 | 541 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 536 | #pragma GCC system_header | |
| 542 | # pragma GCC system_header | |
| 537 | 543 | #endif |
| 538 | 544 | |
| 539 | 545 | #ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 540 | 546 | # error <atomic> is not implemented |
| 541 | 547 | #endif |
| 542 | 548 | #ifdef kill_dependency |
| 543 | # error C++ standard library is incompatible with <stdatomic.h> | |
| 549 | # error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23. | |
| 544 | 550 | #endif |
| 545 | 551 | |
| 546 | 552 | #define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \ |
| ... | ... | @@ -900,8 +906,8 @@ struct __cxx_atomic_base_impl { |
| 900 | 906 | #else |
| 901 | 907 | __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {} |
| 902 | 908 | #endif // _LIBCPP_CXX03_LANG |
| 903 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT | |
| 904 | : __a_value(value) {} | |
| 909 | _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT | |
| 910 | : __a_value(__value) {} | |
| 905 | 911 | _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value; |
| 906 | 912 | }; |
| 907 | 913 | |
| ... | ... | @@ -1445,15 +1451,15 @@ struct __cxx_atomic_impl : public _Base { |
| 1445 | 1451 | "std::atomic<T> requires that 'T' be a trivially copyable type"); |
| 1446 | 1452 | |
| 1447 | 1453 | _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT = default; |
| 1448 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT | |
| 1449 | : _Base(value) {} | |
| 1454 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT | |
| 1455 | : _Base(__value) {} | |
| 1450 | 1456 | }; |
| 1451 | 1457 | |
| 1452 | #ifdef __linux__ | |
| 1458 | #if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__)) | |
| 1453 | 1459 | using __cxx_contention_t = int32_t; |
| 1454 | 1460 | #else |
| 1455 | 1461 | using __cxx_contention_t = int64_t; |
| 1456 | #endif //__linux__ | |
| 1462 | #endif // __linux__ || (_AIX && !__64BIT__) | |
| 1457 | 1463 | |
| 1458 | 1464 | using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>; |
| 1459 | 1465 | |
| ... | ... | @@ -1651,13 +1657,7 @@ struct __atomic_base // false |
| 1651 | 1657 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 1652 | 1658 | __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {} |
| 1653 | 1659 | |
| 1654 | #ifndef _LIBCPP_CXX03_LANG | |
| 1655 | 1660 | __atomic_base(const __atomic_base&) = delete; |
| 1656 | #else | |
| 1657 | private: | |
| 1658 | _LIBCPP_INLINE_VISIBILITY | |
| 1659 | __atomic_base(const __atomic_base&); | |
| 1660 | #endif | |
| 1661 | 1661 | }; |
| 1662 | 1662 | |
| 1663 | 1663 | #if defined(__cpp_lib_atomic_is_always_lock_free) |
| ... | ... | @@ -2439,19 +2439,10 @@ typedef struct atomic_flag |
| 2439 | 2439 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 2440 | 2440 | atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION |
| 2441 | 2441 | |
| 2442 | #ifndef _LIBCPP_CXX03_LANG | |
| 2443 | 2442 | atomic_flag(const atomic_flag&) = delete; |
| 2444 | 2443 | atomic_flag& operator=(const atomic_flag&) = delete; |
| 2445 | 2444 | atomic_flag& operator=(const atomic_flag&) volatile = delete; |
| 2446 | #else | |
| 2447 | private: | |
| 2448 | _LIBCPP_INLINE_VISIBILITY | |
| 2449 | atomic_flag(const atomic_flag&); | |
| 2450 | _LIBCPP_INLINE_VISIBILITY | |
| 2451 | atomic_flag& operator=(const atomic_flag&); | |
| 2452 | _LIBCPP_INLINE_VISIBILITY | |
| 2453 | atomic_flag& operator=(const atomic_flag&) volatile; | |
| 2454 | #endif | |
| 2445 | ||
| 2455 | 2446 | } atomic_flag; |
| 2456 | 2447 | |
| 2457 | 2448 | |
| ... | ... | @@ -2705,7 +2696,6 @@ typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free; |
| 2705 | 2696 | |
| 2706 | 2697 | #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) |
| 2707 | 2698 | # if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400 |
| 2708 | # pragma clang deprecated(ATOMIC_FLAG_INIT) | |
| 2709 | 2699 | # pragma clang deprecated(ATOMIC_VAR_INIT) |
| 2710 | 2700 | # endif |
| 2711 | 2701 | #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) |
lib/libcxx/include/barrier+28-28| ... | ... | @@ -45,20 +45,20 @@ namespace std |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 48 | 49 | #include <__availability> |
| 49 | 50 | #include <__config> |
| 50 | 51 | #include <__thread/timed_backoff_policy.h> |
| 51 | 52 | #include <atomic> |
| 52 | #ifndef _LIBCPP_HAS_NO_TREE_BARRIER | |
| 53 | # include <memory> | |
| 54 | #endif | |
| 53 | #include <limits> | |
| 54 | #include <memory> | |
| 55 | 55 | |
| 56 | 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 57 | #pragma GCC system_header | |
| 57 | # pragma GCC system_header | |
| 58 | 58 | #endif |
| 59 | 59 | |
| 60 | 60 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 61 | # error <barrier> is not supported on this single threaded system | |
| 61 | # error "<barrier> is not supported since libc++ has been configured without support for threads." | |
| 62 | 62 | #endif |
| 63 | 63 | |
| 64 | 64 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -108,12 +108,12 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier); |
| 108 | 108 | |
| 109 | 109 | template<class _CompletionF> |
| 110 | 110 | class __barrier_base { |
| 111 | ptrdiff_t __expected; | |
| 111 | ptrdiff_t __expected_; | |
| 112 | 112 | unique_ptr<__barrier_algorithm_base, |
| 113 | void (*)(__barrier_algorithm_base*)> __base; | |
| 114 | __atomic_base<ptrdiff_t> __expected_adjustment; | |
| 115 | _CompletionF __completion; | |
| 116 | __atomic_base<__barrier_phase_t> __phase; | |
| 113 | void (*)(__barrier_algorithm_base*)> __base_; | |
| 114 | __atomic_base<ptrdiff_t> __expected_adjustment_; | |
| 115 | _CompletionF __completion_; | |
| 116 | __atomic_base<__barrier_phase_t> __phase_; | |
| 117 | 117 | |
| 118 | 118 | public: |
| 119 | 119 | using arrival_token = __barrier_phase_t; |
| ... | ... | @@ -124,22 +124,22 @@ public: |
| 124 | 124 | |
| 125 | 125 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 126 | 126 | __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) |
| 127 | : __expected(__expected), __base(__construct_barrier_algorithm_base(this->__expected), | |
| 128 | &__destroy_barrier_algorithm_base), | |
| 129 | __expected_adjustment(0), __completion(move(__completion)), __phase(0) | |
| 127 | : __expected_(__expected), __base_(__construct_barrier_algorithm_base(this->__expected_), | |
| 128 | &__destroy_barrier_algorithm_base), | |
| 129 | __expected_adjustment_(0), __completion_(std::move(__completion)), __phase_(0) | |
| 130 | 130 | { |
| 131 | 131 | } |
| 132 | 132 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 133 | arrival_token arrive(ptrdiff_t update) | |
| 133 | arrival_token arrive(ptrdiff_t __update) | |
| 134 | 134 | { |
| 135 | auto const __old_phase = __phase.load(memory_order_relaxed); | |
| 136 | for(; update; --update) | |
| 137 | if(__arrive_barrier_algorithm_base(__base.get(), __old_phase)) { | |
| 138 | __completion(); | |
| 139 | __expected += __expected_adjustment.load(memory_order_relaxed); | |
| 140 | __expected_adjustment.store(0, memory_order_relaxed); | |
| 141 | __phase.store(__old_phase + 2, memory_order_release); | |
| 142 | __phase.notify_all(); | |
| 135 | auto const __old_phase = __phase_.load(memory_order_relaxed); | |
| 136 | for(; __update; --__update) | |
| 137 | if(__arrive_barrier_algorithm_base(__base_.get(), __old_phase)) { | |
| 138 | __completion_(); | |
| 139 | __expected_ += __expected_adjustment_.load(memory_order_relaxed); | |
| 140 | __expected_adjustment_.store(0, memory_order_relaxed); | |
| 141 | __phase_.store(__old_phase + 2, memory_order_release); | |
| 142 | __phase_.notify_all(); | |
| 143 | 143 | } |
| 144 | 144 | return __old_phase; |
| 145 | 145 | } |
| ... | ... | @@ -147,14 +147,14 @@ public: |
| 147 | 147 | void wait(arrival_token&& __old_phase) const |
| 148 | 148 | { |
| 149 | 149 | auto const __test_fn = [this, __old_phase]() -> bool { |
| 150 | return __phase.load(memory_order_acquire) != __old_phase; | |
| 150 | return __phase_.load(memory_order_acquire) != __old_phase; | |
| 151 | 151 | }; |
| 152 | 152 | __libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy()); |
| 153 | 153 | } |
| 154 | 154 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 155 | 155 | void arrive_and_drop() |
| 156 | 156 | { |
| 157 | __expected_adjustment.fetch_sub(1, memory_order_relaxed); | |
| 157 | __expected_adjustment_.fetch_sub(1, memory_order_relaxed); | |
| 158 | 158 | (void)arrive(1); |
| 159 | 159 | } |
| 160 | 160 | }; |
| ... | ... | @@ -190,7 +190,7 @@ public: |
| 190 | 190 | |
| 191 | 191 | _LIBCPP_INLINE_VISIBILITY |
| 192 | 192 | __barrier_base(ptrdiff_t __expected, _CompletionF __completion = _CompletionF()) |
| 193 | : __expected(__expected), __arrived(__expected), __completion(move(__completion)), __phase(false) | |
| 193 | : __expected(__expected), __arrived(__expected), __completion(std::move(__completion)), __phase(false) | |
| 194 | 194 | { |
| 195 | 195 | } |
| 196 | 196 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -278,7 +278,7 @@ public: |
| 278 | 278 | } |
| 279 | 279 | }; |
| 280 | 280 | |
| 281 | #endif //_LIBCPP_HAS_NO_TREE_BARRIER | |
| 281 | #endif // !_LIBCPP_HAS_NO_TREE_BARRIER | |
| 282 | 282 | |
| 283 | 283 | template<class _CompletionF = __empty_completion> |
| 284 | 284 | class barrier { |
| ... | ... | @@ -300,9 +300,9 @@ public: |
| 300 | 300 | barrier& operator=(barrier const&) = delete; |
| 301 | 301 | |
| 302 | 302 | [[nodiscard]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 303 | arrival_token arrive(ptrdiff_t update = 1) | |
| 303 | arrival_token arrive(ptrdiff_t __update = 1) | |
| 304 | 304 | { |
| 305 | return __b.arrive(update); | |
| 305 | return __b.arrive(__update); | |
| 306 | 306 | } |
| 307 | 307 | _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 308 | 308 | void wait(arrival_token&& __phase) const |
lib/libcxx/include/bit+107-198| ... | ... | @@ -30,7 +30,7 @@ namespace std { |
| 30 | 30 | template <class T> |
| 31 | 31 | constexpr T bit_floor(T x) noexcept; // C++20 |
| 32 | 32 | template <class T> |
| 33 | constexpr T bit_width(T x) noexcept; // C++20 | |
| 33 | constexpr int bit_width(T x) noexcept; // C++20 | |
| 34 | 34 | |
| 35 | 35 | // [bit.rotate], rotating |
| 36 | 36 | template<class T> |
| ... | ... | @@ -61,24 +61,26 @@ namespace std { |
| 61 | 61 | |
| 62 | 62 | */ |
| 63 | 63 | |
| 64 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 64 | 65 | #include <__bit/bit_cast.h> |
| 65 | 66 | #include <__bit/byteswap.h> |
| 66 | 67 | #include <__bits> // __libcpp_clz |
| 68 | #include <__concepts/arithmetic.h> | |
| 67 | 69 | #include <__config> |
| 68 | #include <__debug> | |
| 69 | 70 | #include <limits> |
| 70 | 71 | #include <type_traits> |
| 71 | 72 | #include <version> |
| 72 | 73 | |
| 73 | #if defined(__IBMCPP__) | |
| 74 | #include "__support/ibm/support.h" | |
| 74 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 75 | # include <iosfwd> | |
| 75 | 76 | #endif |
| 77 | ||
| 76 | 78 | #if defined(_LIBCPP_COMPILER_MSVC) |
| 77 | #include <intrin.h> | |
| 79 | # include <intrin.h> | |
| 78 | 80 | #endif |
| 79 | 81 | |
| 80 | 82 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 81 | #pragma GCC system_header | |
| 83 | # pragma GCC system_header | |
| 82 | 84 | #endif |
| 83 | 85 | |
| 84 | 86 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -87,18 +89,7 @@ _LIBCPP_PUSH_MACROS |
| 87 | 89 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 88 | 90 | |
| 89 | 91 | template<class _Tp> |
| 90 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 91 | _Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT | |
| 92 | { | |
| 93 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type"); | |
| 94 | const unsigned int __dig = numeric_limits<_Tp>::digits; | |
| 95 | if ((__cnt % __dig) == 0) | |
| 96 | return __t; | |
| 97 | return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); | |
| 98 | } | |
| 99 | ||
| 100 | template<class _Tp> | |
| 101 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 92 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 102 | 93 | _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT |
| 103 | 94 | { |
| 104 | 95 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); |
| ... | ... | @@ -109,34 +100,7 @@ _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT |
| 109 | 100 | } |
| 110 | 101 | |
| 111 | 102 | template<class _Tp> |
| 112 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 113 | int __countr_zero(_Tp __t) _NOEXCEPT | |
| 114 | { | |
| 115 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type"); | |
| 116 | if (__t == 0) | |
| 117 | return numeric_limits<_Tp>::digits; | |
| 118 | ||
| 119 | if (sizeof(_Tp) <= sizeof(unsigned int)) | |
| 120 | return __libcpp_ctz(static_cast<unsigned int>(__t)); | |
| 121 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | |
| 122 | return __libcpp_ctz(static_cast<unsigned long>(__t)); | |
| 123 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | |
| 124 | return __libcpp_ctz(static_cast<unsigned long long>(__t)); | |
| 125 | else | |
| 126 | { | |
| 127 | int __ret = 0; | |
| 128 | const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; | |
| 129 | while (static_cast<unsigned long long>(__t) == 0uLL) | |
| 130 | { | |
| 131 | __ret += __ulldigits; | |
| 132 | __t >>= __ulldigits; | |
| 133 | } | |
| 134 | return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t)); | |
| 135 | } | |
| 136 | } | |
| 137 | ||
| 138 | template<class _Tp> | |
| 139 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 103 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 140 | 104 | int __countl_zero(_Tp __t) _NOEXCEPT |
| 141 | 105 | { |
| 142 | 106 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type"); |
| ... | ... | @@ -144,13 +108,13 @@ int __countl_zero(_Tp __t) _NOEXCEPT |
| 144 | 108 | return numeric_limits<_Tp>::digits; |
| 145 | 109 | |
| 146 | 110 | if (sizeof(_Tp) <= sizeof(unsigned int)) |
| 147 | return __libcpp_clz(static_cast<unsigned int>(__t)) | |
| 111 | return std::__libcpp_clz(static_cast<unsigned int>(__t)) | |
| 148 | 112 | - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits); |
| 149 | 113 | else if (sizeof(_Tp) <= sizeof(unsigned long)) |
| 150 | return __libcpp_clz(static_cast<unsigned long>(__t)) | |
| 114 | return std::__libcpp_clz(static_cast<unsigned long>(__t)) | |
| 151 | 115 | - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits); |
| 152 | 116 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) |
| 153 | return __libcpp_clz(static_cast<unsigned long long>(__t)) | |
| 117 | return std::__libcpp_clz(static_cast<unsigned long long>(__t)) | |
| 154 | 118 | - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits); |
| 155 | 119 | else |
| 156 | 120 | { |
| ... | ... | @@ -158,8 +122,8 @@ int __countl_zero(_Tp __t) _NOEXCEPT |
| 158 | 122 | int __iter = 0; |
| 159 | 123 | const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; |
| 160 | 124 | while (true) { |
| 161 | __t = __rotr(__t, __ulldigits); | |
| 162 | if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits) | |
| 125 | __t = std::__rotr(__t, __ulldigits); | |
| 126 | if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits) | |
| 163 | 127 | break; |
| 164 | 128 | __ret += __iter; |
| 165 | 129 | } |
| ... | ... | @@ -167,178 +131,123 @@ int __countl_zero(_Tp __t) _NOEXCEPT |
| 167 | 131 | } |
| 168 | 132 | } |
| 169 | 133 | |
| 170 | template<class _Tp> | |
| 171 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 172 | int __countl_one(_Tp __t) _NOEXCEPT | |
| 173 | { | |
| 174 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_one requires an unsigned integer type"); | |
| 175 | return __t != numeric_limits<_Tp>::max() | |
| 176 | ? __countl_zero(static_cast<_Tp>(~__t)) | |
| 177 | : numeric_limits<_Tp>::digits; | |
| 178 | } | |
| 179 | ||
| 180 | template<class _Tp> | |
| 181 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 182 | int __countr_one(_Tp __t) _NOEXCEPT | |
| 183 | { | |
| 184 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_one requires an unsigned integer type"); | |
| 185 | return __t != numeric_limits<_Tp>::max() | |
| 186 | ? __countr_zero(static_cast<_Tp>(~__t)) | |
| 187 | : numeric_limits<_Tp>::digits; | |
| 188 | } | |
| 189 | ||
| 190 | template<class _Tp> | |
| 191 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 192 | int __popcount(_Tp __t) _NOEXCEPT | |
| 193 | { | |
| 194 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount requires an unsigned integer type"); | |
| 195 | if (sizeof(_Tp) <= sizeof(unsigned int)) | |
| 196 | return __libcpp_popcount(static_cast<unsigned int>(__t)); | |
| 197 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | |
| 198 | return __libcpp_popcount(static_cast<unsigned long>(__t)); | |
| 199 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | |
| 200 | return __libcpp_popcount(static_cast<unsigned long long>(__t)); | |
| 201 | else | |
| 202 | { | |
| 203 | int __ret = 0; | |
| 204 | while (__t != 0) | |
| 205 | { | |
| 206 | __ret += __libcpp_popcount(static_cast<unsigned long long>(__t)); | |
| 207 | __t >>= numeric_limits<unsigned long long>::digits; | |
| 208 | } | |
| 209 | return __ret; | |
| 210 | } | |
| 211 | } | |
| 212 | ||
| 213 | // integral log base 2 | |
| 214 | template<class _Tp> | |
| 215 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 216 | unsigned __bit_log2(_Tp __t) _NOEXCEPT | |
| 217 | { | |
| 218 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type"); | |
| 219 | return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t); | |
| 220 | } | |
| 221 | ||
| 222 | template <class _Tp> | |
| 223 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 224 | bool __has_single_bit(_Tp __t) _NOEXCEPT | |
| 225 | { | |
| 226 | static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type"); | |
| 227 | return __t != 0 && (((__t & (__t - 1)) == 0)); | |
| 228 | } | |
| 229 | ||
| 230 | 134 | #if _LIBCPP_STD_VER > 17 |
| 231 | 135 | |
| 232 | template<class _Tp> | |
| 233 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 234 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 235 | rotl(_Tp __t, unsigned int __cnt) noexcept | |
| 236 | { | |
| 237 | return __rotl(__t, __cnt); | |
| 136 | template <__libcpp_unsigned_integer _Tp> | |
| 137 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept { | |
| 138 | const unsigned int __dig = numeric_limits<_Tp>::digits; | |
| 139 | if ((__cnt % __dig) == 0) | |
| 140 | return __t; | |
| 141 | return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); | |
| 238 | 142 | } |
| 239 | 143 | |
| 240 | template<class _Tp> | |
| 241 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 242 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 243 | rotr(_Tp __t, unsigned int __cnt) noexcept | |
| 244 | { | |
| 245 | return __rotr(__t, __cnt); | |
| 144 | template <__libcpp_unsigned_integer _Tp> | |
| 145 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept { | |
| 146 | return std::__rotr(__t, __cnt); | |
| 246 | 147 | } |
| 247 | 148 | |
| 248 | template<class _Tp> | |
| 249 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 250 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 251 | countl_zero(_Tp __t) noexcept | |
| 252 | { | |
| 253 | return __countl_zero(__t); | |
| 149 | template <__libcpp_unsigned_integer _Tp> | |
| 150 | _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept { | |
| 151 | return std::__countl_zero(__t); | |
| 254 | 152 | } |
| 255 | 153 | |
| 256 | template<class _Tp> | |
| 257 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 258 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 259 | countl_one(_Tp __t) noexcept | |
| 260 | { | |
| 261 | return __countl_one(__t); | |
| 154 | template <__libcpp_unsigned_integer _Tp> | |
| 155 | _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { | |
| 156 | return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | |
| 262 | 157 | } |
| 263 | 158 | |
| 264 | template<class _Tp> | |
| 265 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 266 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 267 | countr_zero(_Tp __t) noexcept | |
| 268 | { | |
| 269 | return __countr_zero(__t); | |
| 159 | template <__libcpp_unsigned_integer _Tp> | |
| 160 | _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept { | |
| 161 | if (__t == 0) | |
| 162 | return numeric_limits<_Tp>::digits; | |
| 163 | ||
| 164 | if (sizeof(_Tp) <= sizeof(unsigned int)) | |
| 165 | return std::__libcpp_ctz(static_cast<unsigned int>(__t)); | |
| 166 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | |
| 167 | return std::__libcpp_ctz(static_cast<unsigned long>(__t)); | |
| 168 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | |
| 169 | return std::__libcpp_ctz(static_cast<unsigned long long>(__t)); | |
| 170 | else { | |
| 171 | int __ret = 0; | |
| 172 | const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; | |
| 173 | while (static_cast<unsigned long long>(__t) == 0uLL) { | |
| 174 | __ret += __ulldigits; | |
| 175 | __t >>= __ulldigits; | |
| 176 | } | |
| 177 | return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t)); | |
| 178 | } | |
| 270 | 179 | } |
| 271 | 180 | |
| 272 | template<class _Tp> | |
| 273 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 274 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 275 | countr_one(_Tp __t) noexcept | |
| 276 | { | |
| 277 | return __countr_one(__t); | |
| 181 | template <__libcpp_unsigned_integer _Tp> | |
| 182 | _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { | |
| 183 | return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; | |
| 278 | 184 | } |
| 279 | 185 | |
| 280 | template<class _Tp> | |
| 281 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 282 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, int> | |
| 283 | popcount(_Tp __t) noexcept | |
| 284 | { | |
| 285 | return __popcount(__t); | |
| 186 | template <__libcpp_unsigned_integer _Tp> | |
| 187 | _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept { | |
| 188 | if (sizeof(_Tp) <= sizeof(unsigned int)) | |
| 189 | return std::__libcpp_popcount(static_cast<unsigned int>(__t)); | |
| 190 | else if (sizeof(_Tp) <= sizeof(unsigned long)) | |
| 191 | return std::__libcpp_popcount(static_cast<unsigned long>(__t)); | |
| 192 | else if (sizeof(_Tp) <= sizeof(unsigned long long)) | |
| 193 | return std::__libcpp_popcount(static_cast<unsigned long long>(__t)); | |
| 194 | else { | |
| 195 | int __ret = 0; | |
| 196 | while (__t != 0) { | |
| 197 | __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t)); | |
| 198 | __t >>= numeric_limits<unsigned long long>::digits; | |
| 199 | } | |
| 200 | return __ret; | |
| 201 | } | |
| 286 | 202 | } |
| 287 | 203 | |
| 288 | template <class _Tp> | |
| 289 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 290 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, bool> | |
| 291 | has_single_bit(_Tp __t) noexcept | |
| 292 | { | |
| 293 | return __has_single_bit(__t); | |
| 204 | template <__libcpp_unsigned_integer _Tp> | |
| 205 | _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept { | |
| 206 | return __t != 0 && (((__t & (__t - 1)) == 0)); | |
| 294 | 207 | } |
| 295 | 208 | |
| 296 | template <class _Tp> | |
| 297 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 298 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 299 | bit_floor(_Tp __t) noexcept | |
| 300 | { | |
| 301 | return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t); | |
| 209 | // integral log base 2 | |
| 210 | template <__libcpp_unsigned_integer _Tp> | |
| 211 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept { | |
| 212 | return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t); | |
| 302 | 213 | } |
| 303 | 214 | |
| 304 | template <class _Tp> | |
| 305 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 306 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 307 | bit_ceil(_Tp __t) noexcept | |
| 308 | { | |
| 309 | if (__t < 2) return 1; | |
| 310 | const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u)); | |
| 311 | _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); | |
| 215 | template <__libcpp_unsigned_integer _Tp> | |
| 216 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept { | |
| 217 | return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t); | |
| 218 | } | |
| 312 | 219 | |
| 313 | if constexpr (sizeof(_Tp) >= sizeof(unsigned)) | |
| 314 | return _Tp{1} << __n; | |
| 315 | else | |
| 316 | { | |
| 317 | const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits; | |
| 318 | const unsigned __retVal = 1u << (__n + __extra); | |
| 319 | return (_Tp) (__retVal >> __extra); | |
| 320 | } | |
| 220 | template <__libcpp_unsigned_integer _Tp> | |
| 221 | _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { | |
| 222 | if (__t < 2) | |
| 223 | return 1; | |
| 224 | const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u)); | |
| 225 | _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); | |
| 226 | ||
| 227 | if constexpr (sizeof(_Tp) >= sizeof(unsigned)) | |
| 228 | return _Tp{1} << __n; | |
| 229 | else { | |
| 230 | const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits; | |
| 231 | const unsigned __retVal = 1u << (__n + __extra); | |
| 232 | return (_Tp)(__retVal >> __extra); | |
| 233 | } | |
| 321 | 234 | } |
| 322 | 235 | |
| 323 | template <class _Tp> | |
| 324 | _LIBCPP_INLINE_VISIBILITY constexpr | |
| 325 | enable_if_t<__libcpp_is_unsigned_integer<_Tp>::value, _Tp> | |
| 326 | bit_width(_Tp __t) noexcept | |
| 327 | { | |
| 328 | return __t == 0 ? 0 : __bit_log2(__t) + 1; | |
| 236 | template <__libcpp_unsigned_integer _Tp> | |
| 237 | _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept { | |
| 238 | return __t == 0 ? 0 : std::__bit_log2(__t) + 1; | |
| 329 | 239 | } |
| 330 | 240 | |
| 331 | enum class endian | |
| 332 | { | |
| 333 | little = 0xDEAD, | |
| 334 | big = 0xFACE, | |
| 335 | #if defined(_LIBCPP_LITTLE_ENDIAN) | |
| 336 | native = little | |
| 337 | #elif defined(_LIBCPP_BIG_ENDIAN) | |
| 338 | native = big | |
| 339 | #else | |
| 340 | native = 0xCAFE | |
| 341 | #endif | |
| 241 | enum class endian { | |
| 242 | little = 0xDEAD, | |
| 243 | big = 0xFACE, | |
| 244 | # if defined(_LIBCPP_LITTLE_ENDIAN) | |
| 245 | native = little | |
| 246 | # elif defined(_LIBCPP_BIG_ENDIAN) | |
| 247 | native = big | |
| 248 | # else | |
| 249 | native = 0xCAFE | |
| 250 | # endif | |
| 342 | 251 | }; |
| 343 | 252 | |
| 344 | 253 | #endif // _LIBCPP_STD_VER > 17 |
lib/libcxx/include/bitset+17-9| ... | ... | @@ -112,18 +112,23 @@ template <size_t N> struct hash<std::bitset<N>>; |
| 112 | 112 | |
| 113 | 113 | */ |
| 114 | 114 | |
| 115 | #include <__algorithm/fill.h> | |
| 116 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 115 | 117 | #include <__bit_reference> |
| 116 | 118 | #include <__config> |
| 117 | #include <__functional_base> | |
| 119 | #include <__functional/hash.h> | |
| 120 | #include <__functional/unary_function.h> | |
| 118 | 121 | #include <climits> |
| 119 | 122 | #include <cstddef> |
| 120 | #include <iosfwd> | |
| 121 | 123 | #include <stdexcept> |
| 122 | #include <string> | |
| 123 | 124 | #include <version> |
| 124 | 125 | |
| 126 | // standard-mandated includes | |
| 127 | #include <iosfwd> | |
| 128 | #include <string> | |
| 129 | ||
| 125 | 130 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 126 | #pragma GCC system_header | |
| 131 | # pragma GCC system_header | |
| 127 | 132 | #endif |
| 128 | 133 | |
| 129 | 134 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -713,9 +718,12 @@ public: |
| 713 | 718 | bitset& flip(size_t __pos); |
| 714 | 719 | |
| 715 | 720 | // element access: |
| 716 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | |
| 717 | const_reference operator[](size_t __p) const {return base::__make_ref(__p);} | |
| 718 | _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);} | |
| 721 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 722 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator[](size_t __p) const {return base::__make_ref(__p);} | |
| 723 | #else | |
| 724 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);} | |
| 725 | #endif | |
| 726 | _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __p) {return base::__make_ref(__p);} | |
| 719 | 727 | _LIBCPP_INLINE_VISIBILITY |
| 720 | 728 | unsigned long to_ulong() const; |
| 721 | 729 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -946,7 +954,7 @@ basic_string<_CharT, _Traits, _Allocator> |
| 946 | 954 | bitset<_Size>::to_string(_CharT __zero, _CharT __one) const |
| 947 | 955 | { |
| 948 | 956 | basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero); |
| 949 | for (size_t __i = 0; __i < _Size; ++__i) | |
| 957 | for (size_t __i = 0; __i != _Size; ++__i) | |
| 950 | 958 | { |
| 951 | 959 | if ((*this)[__i]) |
| 952 | 960 | __r[_Size - 1 - __i] = __one; |
| ... | ... | @@ -1082,7 +1090,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT |
| 1082 | 1090 | |
| 1083 | 1091 | template <size_t _Size> |
| 1084 | 1092 | struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > |
| 1085 | : public unary_function<bitset<_Size>, size_t> | |
| 1093 | : public __unary_function<bitset<_Size>, size_t> | |
| 1086 | 1094 | { |
| 1087 | 1095 | _LIBCPP_INLINE_VISIBILITY |
| 1088 | 1096 | size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT |
lib/libcxx/include/cassert+2-1| ... | ... | @@ -16,9 +16,10 @@ Macros: |
| 16 | 16 | |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 19 | 20 | #include <__config> |
| 20 | 21 | #include <assert.h> |
| 21 | 22 | |
| 22 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 24 | 25 | #endif |
lib/libcxx/include/ccomplex+2-3| ... | ... | @@ -17,12 +17,11 @@ |
| 17 | 17 | |
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 20 | 21 | #include <complex> |
| 21 | 22 | |
| 22 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 24 | 25 | #endif |
| 25 | 26 | |
| 26 | // hh 080623 Created | |
| 27 | ||
| 28 | 27 | #endif // _LIBCPP_CCOMPLEX |
lib/libcxx/include/cctype+2-1| ... | ... | @@ -34,11 +34,12 @@ int toupper(int c); |
| 34 | 34 | } // std |
| 35 | 35 | */ |
| 36 | 36 | |
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 37 | 38 | #include <__config> |
| 38 | 39 | #include <ctype.h> |
| 39 | 40 | |
| 40 | 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | #pragma GCC system_header | |
| 42 | # pragma GCC system_header | |
| 42 | 43 | #endif |
| 43 | 44 | |
| 44 | 45 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cerrno+2-1| ... | ... | @@ -22,11 +22,12 @@ Macros: |
| 22 | 22 | |
| 23 | 23 | */ |
| 24 | 24 | |
| 25 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 25 | 26 | #include <__config> |
| 26 | 27 | #include <errno.h> |
| 27 | 28 | |
| 28 | 29 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 29 | #pragma GCC system_header | |
| 30 | # pragma GCC system_header | |
| 30 | 31 | #endif |
| 31 | 32 | |
| 32 | 33 | #endif // _LIBCPP_CERRNO |
lib/libcxx/include/cfenv+2-1| ... | ... | @@ -52,11 +52,12 @@ int feupdateenv(const fenv_t* envp); |
| 52 | 52 | } // std |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 55 | 56 | #include <__config> |
| 56 | 57 | #include <fenv.h> |
| 57 | 58 | |
| 58 | 59 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 59 | #pragma GCC system_header | |
| 60 | # pragma GCC system_header | |
| 60 | 61 | #endif |
| 61 | 62 | |
| 62 | 63 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cfloat+2-1| ... | ... | @@ -69,11 +69,12 @@ Macros: |
| 69 | 69 | LDBL_TRUE_MIN // C11 |
| 70 | 70 | */ |
| 71 | 71 | |
| 72 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 72 | 73 | #include <__config> |
| 73 | 74 | #include <float.h> |
| 74 | 75 | |
| 75 | 76 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 76 | #pragma GCC system_header | |
| 77 | # pragma GCC system_header | |
| 77 | 78 | #endif |
| 78 | 79 | |
| 79 | 80 | #endif // _LIBCPP_CFLOAT |
lib/libcxx/include/charconv+311-123| ... | ... | @@ -77,24 +77,32 @@ namespace std { |
| 77 | 77 | |
| 78 | 78 | */ |
| 79 | 79 | |
| 80 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 80 | 81 | #include <__availability> |
| 81 | 82 | #include <__bits> |
| 82 | 83 | #include <__charconv/chars_format.h> |
| 83 | 84 | #include <__charconv/from_chars_result.h> |
| 85 | #include <__charconv/tables.h> | |
| 86 | #include <__charconv/to_chars_base_10.h> | |
| 84 | 87 | #include <__charconv/to_chars_result.h> |
| 85 | 88 | #include <__config> |
| 89 | #include <__debug> | |
| 86 | 90 | #include <__errc> |
| 91 | #include <__type_traits/make_32_64_or_128_bit.h> | |
| 92 | #include <__utility/unreachable.h> | |
| 87 | 93 | #include <cmath> // for log2f |
| 88 | 94 | #include <cstdint> |
| 89 | #include <cstdlib> // for _LIBCPP_UNREACHABLE | |
| 95 | #include <cstdlib> | |
| 90 | 96 | #include <cstring> |
| 91 | 97 | #include <limits> |
| 92 | 98 | #include <type_traits> |
| 93 | 99 | |
| 94 | #include <__debug> | |
| 100 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 101 | # include <iosfwd> | |
| 102 | #endif | |
| 95 | 103 | |
| 96 | 104 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 97 | #pragma GCC system_header | |
| 105 | # pragma GCC system_header | |
| 98 | 106 | #endif |
| 99 | 107 | |
| 100 | 108 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -102,11 +110,6 @@ _LIBCPP_PUSH_MACROS |
| 102 | 110 | |
| 103 | 111 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 104 | 112 | |
| 105 | namespace __itoa { | |
| 106 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer) _NOEXCEPT; | |
| 107 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer) _NOEXCEPT; | |
| 108 | } // namespace __itoa | |
| 109 | ||
| 110 | 113 | #ifndef _LIBCPP_CXX03_LANG |
| 111 | 114 | |
| 112 | 115 | to_chars_result to_chars(char*, char*, bool, int = 10) = delete; |
| ... | ... | @@ -115,79 +118,93 @@ from_chars_result from_chars(const char*, const char*, bool, int = 10) = delete; |
| 115 | 118 | namespace __itoa |
| 116 | 119 | { |
| 117 | 120 | |
| 118 | static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = { | |
| 119 | UINT64_C(0), | |
| 120 | UINT64_C(10), | |
| 121 | UINT64_C(100), | |
| 122 | UINT64_C(1000), | |
| 123 | UINT64_C(10000), | |
| 124 | UINT64_C(100000), | |
| 125 | UINT64_C(1000000), | |
| 126 | UINT64_C(10000000), | |
| 127 | UINT64_C(100000000), | |
| 128 | UINT64_C(1000000000), | |
| 129 | UINT64_C(10000000000), | |
| 130 | UINT64_C(100000000000), | |
| 131 | UINT64_C(1000000000000), | |
| 132 | UINT64_C(10000000000000), | |
| 133 | UINT64_C(100000000000000), | |
| 134 | UINT64_C(1000000000000000), | |
| 135 | UINT64_C(10000000000000000), | |
| 136 | UINT64_C(100000000000000000), | |
| 137 | UINT64_C(1000000000000000000), | |
| 138 | UINT64_C(10000000000000000000), | |
| 139 | }; | |
| 140 | ||
| 141 | static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = { | |
| 142 | UINT32_C(0), UINT32_C(10), UINT32_C(100), | |
| 143 | UINT32_C(1000), UINT32_C(10000), UINT32_C(100000), | |
| 144 | UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000), | |
| 145 | UINT32_C(1000000000), | |
| 146 | }; | |
| 147 | ||
| 148 | 121 | template <typename _Tp, typename = void> |
| 149 | struct _LIBCPP_HIDDEN __traits_base | |
| 122 | struct _LIBCPP_HIDDEN __traits_base; | |
| 123 | ||
| 124 | template <typename _Tp> | |
| 125 | struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)>> | |
| 150 | 126 | { |
| 151 | using type = uint64_t; | |
| 127 | using type = uint32_t; | |
| 152 | 128 | |
| 153 | static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) | |
| 129 | /// The width estimation using a log10 algorithm. | |
| 130 | /// | |
| 131 | /// The algorithm is based on | |
| 132 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 | |
| 133 | /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that | |
| 134 | /// function requires its input to have at least one bit set the value of | |
| 135 | /// zero is set to one. This means the first element of the lookup table is | |
| 136 | /// zero. | |
| 137 | static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) | |
| 154 | 138 | { |
| 155 | auto __t = (64 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | |
| 156 | return __t - (__v < __pow10_64[__t]) + 1; | |
| 139 | auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | |
| 140 | return __t - (__v < __table<>::__pow10_32[__t]) + 1; | |
| 157 | 141 | } |
| 158 | 142 | |
| 159 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 160 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) | |
| 143 | static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) | |
| 161 | 144 | { |
| 162 | return __u64toa(__v, __p); | |
| 145 | return __itoa::__base_10_u32(__p, __v); | |
| 163 | 146 | } |
| 164 | 147 | |
| 165 | static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; } | |
| 148 | static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; } | |
| 166 | 149 | }; |
| 167 | 150 | |
| 168 | 151 | template <typename _Tp> |
| 169 | 152 | struct _LIBCPP_HIDDEN |
| 170 | __traits_base<_Tp, decltype(void(uint32_t{declval<_Tp>()}))> | |
| 171 | { | |
| 172 | using type = uint32_t; | |
| 153 | __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)>> { | |
| 154 | using type = uint64_t; | |
| 155 | ||
| 156 | /// The width estimation using a log10 algorithm. | |
| 157 | /// | |
| 158 | /// The algorithm is based on | |
| 159 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 | |
| 160 | /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that | |
| 161 | /// function requires its input to have at least one bit set the value of | |
| 162 | /// zero is set to one. This means the first element of the lookup table is | |
| 163 | /// zero. | |
| 164 | static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { | |
| 165 | auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | |
| 166 | return __t - (__v < __table<>::__pow10_64[__t]) + 1; | |
| 167 | } | |
| 173 | 168 | |
| 174 | static _LIBCPP_INLINE_VISIBILITY int __width(_Tp __v) | |
| 175 | { | |
| 176 | auto __t = (32 - _VSTD::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12; | |
| 177 | return __t - (__v < __pow10_32[__t]) + 1; | |
| 178 | } | |
| 169 | static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u64(__p, __v); } | |
| 179 | 170 | |
| 180 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 181 | static _LIBCPP_INLINE_VISIBILITY char* __convert(_Tp __v, char* __p) | |
| 182 | { | |
| 183 | return __u32toa(__v, __p); | |
| 184 | } | |
| 171 | static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; } | |
| 172 | }; | |
| 173 | ||
| 174 | ||
| 175 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 176 | template <typename _Tp> | |
| 177 | struct _LIBCPP_HIDDEN | |
| 178 | __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > { | |
| 179 | using type = __uint128_t; | |
| 180 | ||
| 181 | /// The width estimation using a log10 algorithm. | |
| 182 | /// | |
| 183 | /// The algorithm is based on | |
| 184 | /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 | |
| 185 | /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that | |
| 186 | /// function requires its input to have at least one bit set the value of | |
| 187 | /// zero is set to one. This means the first element of the lookup table is | |
| 188 | /// zero. | |
| 189 | static _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) { | |
| 190 | _LIBCPP_ASSERT(__v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true."); | |
| 191 | // There's always a bit set in the upper 64-bits. | |
| 192 | auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12; | |
| 193 | _LIBCPP_ASSERT(__t >= __table<>::__pow10_128_offset, "Index out of bounds"); | |
| 194 | // __t is adjusted since the lookup table misses the lower entries. | |
| 195 | return __t - (__v < __table<>::__pow10_128[__t - __table<>::__pow10_128_offset]) + 1; | |
| 196 | } | |
| 197 | ||
| 198 | static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { return __itoa::__base_10_u128(__p, __v); } | |
| 185 | 199 | |
| 186 | static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; } | |
| 200 | // TODO FMT This pow function should get an index. | |
| 201 | // By moving this to its own header it can be reused by the pow function in to_chars_base_10. | |
| 202 | static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_128)& __pow() { return __table<>::__pow10_128; } | |
| 187 | 203 | }; |
| 204 | #endif | |
| 188 | 205 | |
| 189 | 206 | template <typename _Tp> |
| 190 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 207 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 191 | 208 | __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r) |
| 192 | 209 | { |
| 193 | 210 | auto __c = __a * __b; |
| ... | ... | @@ -196,7 +213,7 @@ __mul_overflowed(unsigned char __a, _Tp __b, unsigned char& __r) |
| 196 | 213 | } |
| 197 | 214 | |
| 198 | 215 | template <typename _Tp> |
| 199 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 216 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 200 | 217 | __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) |
| 201 | 218 | { |
| 202 | 219 | auto __c = __a * __b; |
| ... | ... | @@ -205,7 +222,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) |
| 205 | 222 | } |
| 206 | 223 | |
| 207 | 224 | template <typename _Tp> |
| 208 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 225 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 209 | 226 | __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) |
| 210 | 227 | { |
| 211 | 228 | static_assert(is_unsigned<_Tp>::value, ""); |
| ... | ... | @@ -219,7 +236,7 @@ __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) |
| 219 | 236 | } |
| 220 | 237 | |
| 221 | 238 | template <typename _Tp, typename _Up> |
| 222 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 239 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 223 | 240 | __mul_overflowed(_Tp __a, _Up __b, _Tp& __r) |
| 224 | 241 | { |
| 225 | 242 | return __mul_overflowed(__a, static_cast<_Tp>(__b), __r); |
| ... | ... | @@ -228,12 +245,12 @@ __mul_overflowed(_Tp __a, _Up __b, _Tp& __r) |
| 228 | 245 | template <typename _Tp> |
| 229 | 246 | struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> |
| 230 | 247 | { |
| 231 | static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1; | |
| 248 | static constexpr int digits = numeric_limits<_Tp>::digits10 + 1; | |
| 232 | 249 | using __traits_base<_Tp>::__pow; |
| 233 | 250 | using typename __traits_base<_Tp>::type; |
| 234 | 251 | |
| 235 | 252 | // precondition: at least one non-zero character available |
| 236 | static _LIBCPP_INLINE_VISIBILITY char const* | |
| 253 | static _LIBCPP_HIDE_FROM_ABI char const* | |
| 237 | 254 | __read(char const* __p, char const* __ep, type& __a, type& __b) |
| 238 | 255 | { |
| 239 | 256 | type __cprod[digits]; |
| ... | ... | @@ -254,7 +271,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> |
| 254 | 271 | } |
| 255 | 272 | |
| 256 | 273 | template <typename _It1, typename _It2, class _Up> |
| 257 | static _LIBCPP_INLINE_VISIBILITY _Up | |
| 274 | static _LIBCPP_HIDE_FROM_ABI _Up | |
| 258 | 275 | __inner_product(_It1 __first1, _It1 __last1, _It2 __first2, _Up __init) |
| 259 | 276 | { |
| 260 | 277 | for (; __first1 < __last1; ++__first1, ++__first2) |
| ... | ... | @@ -266,7 +283,7 @@ struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> |
| 266 | 283 | } // namespace __itoa |
| 267 | 284 | |
| 268 | 285 | template <typename _Tp> |
| 269 | inline _LIBCPP_INLINE_VISIBILITY _Tp | |
| 286 | inline _LIBCPP_HIDE_FROM_ABI _Tp | |
| 270 | 287 | __complement(_Tp __x) |
| 271 | 288 | { |
| 272 | 289 | static_assert(is_unsigned<_Tp>::value, "cast to unsigned first"); |
| ... | ... | @@ -274,8 +291,7 @@ __complement(_Tp __x) |
| 274 | 291 | } |
| 275 | 292 | |
| 276 | 293 | template <typename _Tp> |
| 277 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 278 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | |
| 294 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 279 | 295 | __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) |
| 280 | 296 | { |
| 281 | 297 | auto __x = __to_unsigned_like(__value); |
| ... | ... | @@ -289,22 +305,42 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) |
| 289 | 305 | } |
| 290 | 306 | |
| 291 | 307 | template <typename _Tp> |
| 292 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 293 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | |
| 308 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 294 | 309 | __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) |
| 295 | 310 | { |
| 296 | 311 | using __tx = __itoa::__traits<_Tp>; |
| 297 | 312 | auto __diff = __last - __first; |
| 298 | 313 | |
| 299 | 314 | if (__tx::digits <= __diff || __tx::__width(__value) <= __diff) |
| 300 | return {__tx::__convert(__value, __first), errc(0)}; | |
| 315 | return {__tx::__convert(__first, __value), errc(0)}; | |
| 316 | else | |
| 317 | return {__last, errc::value_too_large}; | |
| 318 | } | |
| 319 | ||
| 320 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 321 | template <> | |
| 322 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 323 | __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) | |
| 324 | { | |
| 325 | // When the value fits in 64-bits use the 64-bit code path. This reduces | |
| 326 | // the number of expensive calculations on 128-bit values. | |
| 327 | // | |
| 328 | // NOTE the 128-bit code path requires this optimization. | |
| 329 | if(__value <= numeric_limits<uint64_t>::max()) | |
| 330 | return __to_chars_itoa(__first, __last, static_cast<uint64_t>(__value), false_type()); | |
| 331 | ||
| 332 | using __tx = __itoa::__traits<__uint128_t>; | |
| 333 | auto __diff = __last - __first; | |
| 334 | ||
| 335 | if (__tx::digits <= __diff || __tx::__width(__value) <= __diff) | |
| 336 | return {__tx::__convert(__first, __value), errc(0)}; | |
| 301 | 337 | else |
| 302 | 338 | return {__last, errc::value_too_large}; |
| 303 | 339 | } |
| 340 | #endif | |
| 304 | 341 | |
| 305 | 342 | template <typename _Tp> |
| 306 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 307 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | |
| 343 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 308 | 344 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 309 | 345 | true_type) |
| 310 | 346 | { |
| ... | ... | @@ -318,8 +354,151 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 318 | 354 | return __to_chars_integral(__first, __last, __x, __base, false_type()); |
| 319 | 355 | } |
| 320 | 356 | |
| 357 | namespace __itoa { | |
| 358 | ||
| 359 | template <unsigned _Base> | |
| 360 | struct _LIBCPP_HIDDEN __integral; | |
| 361 | ||
| 362 | template <> | |
| 363 | struct _LIBCPP_HIDDEN __integral<2> { | |
| 364 | template <typename _Tp> | |
| 365 | _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { | |
| 366 | // If value == 0 still need one digit. If the value != this has no | |
| 367 | // effect since the code scans for the most significant bit set. (Note | |
| 368 | // that __libcpp_clz doesn't work for 0.) | |
| 369 | return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1); | |
| 370 | } | |
| 371 | ||
| 372 | template <typename _Tp> | |
| 373 | _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) { | |
| 374 | ptrdiff_t __cap = __last - __first; | |
| 375 | int __n = __width(__value); | |
| 376 | if (__n > __cap) | |
| 377 | return {__last, errc::value_too_large}; | |
| 378 | ||
| 379 | __last = __first + __n; | |
| 380 | char* __p = __last; | |
| 381 | const unsigned __divisor = 16; | |
| 382 | while (__value > __divisor) { | |
| 383 | unsigned __c = __value % __divisor; | |
| 384 | __value /= __divisor; | |
| 385 | __p -= 4; | |
| 386 | std::memcpy(__p, &__table<>::__base_2_lut[4 * __c], 4); | |
| 387 | } | |
| 388 | do { | |
| 389 | unsigned __c = __value % 2; | |
| 390 | __value /= 2; | |
| 391 | *--__p = "01"[__c]; | |
| 392 | } while (__value != 0); | |
| 393 | return {__last, errc(0)}; | |
| 394 | } | |
| 395 | }; | |
| 396 | ||
| 397 | template <> | |
| 398 | struct _LIBCPP_HIDDEN __integral<8> { | |
| 399 | template <typename _Tp> | |
| 400 | _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { | |
| 401 | // If value == 0 still need one digit. If the value != this has no | |
| 402 | // effect since the code scans for the most significat bit set. (Note | |
| 403 | // that __libcpp_clz doesn't work for 0.) | |
| 404 | return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3; | |
| 405 | } | |
| 406 | ||
| 407 | template <typename _Tp> | |
| 408 | _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) { | |
| 409 | ptrdiff_t __cap = __last - __first; | |
| 410 | int __n = __width(__value); | |
| 411 | if (__n > __cap) | |
| 412 | return {__last, errc::value_too_large}; | |
| 413 | ||
| 414 | __last = __first + __n; | |
| 415 | char* __p = __last; | |
| 416 | unsigned __divisor = 64; | |
| 417 | while (__value > __divisor) { | |
| 418 | unsigned __c = __value % __divisor; | |
| 419 | __value /= __divisor; | |
| 420 | __p -= 2; | |
| 421 | std::memcpy(__p, &__table<>::__base_8_lut[2 * __c], 2); | |
| 422 | } | |
| 423 | do { | |
| 424 | unsigned __c = __value % 8; | |
| 425 | __value /= 8; | |
| 426 | *--__p = "01234567"[__c]; | |
| 427 | } while (__value != 0); | |
| 428 | return {__last, errc(0)}; | |
| 429 | } | |
| 430 | ||
| 431 | }; | |
| 432 | ||
| 433 | template <> | |
| 434 | struct _LIBCPP_HIDDEN __integral<16> { | |
| 435 | template <typename _Tp> | |
| 436 | _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { | |
| 437 | // If value == 0 still need one digit. If the value != this has no | |
| 438 | // effect since the code scans for the most significat bit set. (Note | |
| 439 | // that __libcpp_clz doesn't work for 0.) | |
| 440 | return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4; | |
| 441 | } | |
| 442 | ||
| 443 | template <typename _Tp> | |
| 444 | _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) { | |
| 445 | ptrdiff_t __cap = __last - __first; | |
| 446 | int __n = __width(__value); | |
| 447 | if (__n > __cap) | |
| 448 | return {__last, errc::value_too_large}; | |
| 449 | ||
| 450 | __last = __first + __n; | |
| 451 | char* __p = __last; | |
| 452 | unsigned __divisor = 256; | |
| 453 | while (__value > __divisor) { | |
| 454 | unsigned __c = __value % __divisor; | |
| 455 | __value /= __divisor; | |
| 456 | __p -= 2; | |
| 457 | std::memcpy(__p, &__table<>::__base_16_lut[2 * __c], 2); | |
| 458 | } | |
| 459 | if (__first != __last) | |
| 460 | do { | |
| 461 | unsigned __c = __value % 16; | |
| 462 | __value /= 16; | |
| 463 | *--__p = "0123456789abcdef"[__c]; | |
| 464 | } while (__value != 0); | |
| 465 | return {__last, errc(0)}; | |
| 466 | } | |
| 467 | }; | |
| 468 | ||
| 469 | } // namespace __itoa | |
| 470 | ||
| 471 | template <unsigned _Base, typename _Tp, | |
| 472 | typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0> | |
| 473 | _LIBCPP_HIDE_FROM_ABI int | |
| 474 | __to_chars_integral_width(_Tp __value) { | |
| 475 | return __itoa::__integral<_Base>::__width(__value); | |
| 476 | } | |
| 477 | ||
| 478 | template <unsigned _Base, typename _Tp, | |
| 479 | typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0> | |
| 480 | _LIBCPP_HIDE_FROM_ABI int | |
| 481 | __to_chars_integral_width(_Tp __value) { | |
| 482 | return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value)); | |
| 483 | } | |
| 484 | ||
| 485 | template <unsigned _Base, typename _Tp, | |
| 486 | typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0> | |
| 487 | _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 488 | __to_chars_integral(char* __first, char* __last, _Tp __value) { | |
| 489 | return __itoa::__integral<_Base>::__to_chars(__first, __last, __value); | |
| 490 | } | |
| 491 | ||
| 492 | template <unsigned _Base, typename _Tp, | |
| 493 | typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0> | |
| 494 | _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 495 | __to_chars_integral(char* __first, char* __last, _Tp __value) { | |
| 496 | return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value)); | |
| 497 | } | |
| 498 | ||
| 321 | 499 | template <typename _Tp> |
| 322 | _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_width(_Tp __value, unsigned __base) { | |
| 500 | _LIBCPP_HIDE_FROM_ABI int | |
| 501 | __to_chars_integral_width(_Tp __value, unsigned __base) { | |
| 323 | 502 | _LIBCPP_ASSERT(__value >= 0, "The function requires a non-negative value."); |
| 324 | 503 | |
| 325 | 504 | unsigned __base_2 = __base * __base; |
| ... | ... | @@ -341,18 +520,26 @@ _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_INLINE_VISIBILITY int __to_chars_integral_ |
| 341 | 520 | __r += 4; |
| 342 | 521 | } |
| 343 | 522 | |
| 344 | _LIBCPP_UNREACHABLE(); | |
| 523 | __libcpp_unreachable(); | |
| 345 | 524 | } |
| 346 | 525 | |
| 347 | 526 | template <typename _Tp> |
| 348 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 349 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | |
| 527 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 350 | 528 | __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 351 | 529 | false_type) |
| 352 | 530 | { |
| 353 | if (__base == 10) | |
| 531 | if (__base == 10) [[likely]] | |
| 354 | 532 | return __to_chars_itoa(__first, __last, __value, false_type()); |
| 355 | 533 | |
| 534 | switch (__base) { | |
| 535 | case 2: | |
| 536 | return __to_chars_integral<2>(__first, __last, __value); | |
| 537 | case 8: | |
| 538 | return __to_chars_integral<8>(__first, __last, __value); | |
| 539 | case 16: | |
| 540 | return __to_chars_integral<16>(__first, __last, __value); | |
| 541 | } | |
| 542 | ||
| 356 | 543 | ptrdiff_t __cap = __last - __first; |
| 357 | 544 | int __n = __to_chars_integral_width(__value, __base); |
| 358 | 545 | if (__n > __cap) |
| ... | ... | @@ -369,25 +556,26 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, |
| 369 | 556 | } |
| 370 | 557 | |
| 371 | 558 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
| 372 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 373 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | |
| 559 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 374 | 560 | to_chars(char* __first, char* __last, _Tp __value) |
| 375 | 561 | { |
| 376 | return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>()); | |
| 562 | using _Type = __make_32_64_or_128_bit_t<_Tp>; | |
| 563 | static_assert(!is_same<_Type, void>::value, "unsupported integral type used in to_chars"); | |
| 564 | return std::__to_chars_itoa(__first, __last, static_cast<_Type>(__value), is_signed<_Tp>()); | |
| 377 | 565 | } |
| 378 | 566 | |
| 379 | 567 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
| 380 | _LIBCPP_AVAILABILITY_TO_CHARS | |
| 381 | inline _LIBCPP_INLINE_VISIBILITY to_chars_result | |
| 568 | inline _LIBCPP_HIDE_FROM_ABI to_chars_result | |
| 382 | 569 | to_chars(char* __first, char* __last, _Tp __value, int __base) |
| 383 | 570 | { |
| 384 | _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); | |
| 385 | return __to_chars_integral(__first, __last, __value, __base, | |
| 386 | is_signed<_Tp>()); | |
| 571 | _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); | |
| 572 | ||
| 573 | using _Type = __make_32_64_or_128_bit_t<_Tp>; | |
| 574 | return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>()); | |
| 387 | 575 | } |
| 388 | 576 | |
| 389 | 577 | template <typename _It, typename _Tp, typename _Fn, typename... _Ts> |
| 390 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 578 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 391 | 579 | __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args) |
| 392 | 580 | { |
| 393 | 581 | using __tl = numeric_limits<_Tp>; |
| ... | ... | @@ -410,13 +598,13 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args) |
| 410 | 598 | if (__x <= __complement(__to_unsigned_like(__tl::min()))) |
| 411 | 599 | { |
| 412 | 600 | __x = __complement(__x); |
| 413 | _VSTD::memcpy(&__value, &__x, sizeof(__x)); | |
| 601 | std::memcpy(&__value, &__x, sizeof(__x)); | |
| 414 | 602 | return __r; |
| 415 | 603 | } |
| 416 | 604 | } |
| 417 | 605 | else |
| 418 | 606 | { |
| 419 | if (__x <= __tl::max()) | |
| 607 | if (__x <= __to_unsigned_like(__tl::max())) | |
| 420 | 608 | { |
| 421 | 609 | __value = __x; |
| 422 | 610 | return __r; |
| ... | ... | @@ -427,7 +615,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args) |
| 427 | 615 | } |
| 428 | 616 | |
| 429 | 617 | template <typename _Tp> |
| 430 | inline _LIBCPP_INLINE_VISIBILITY bool | |
| 618 | inline _LIBCPP_HIDE_FROM_ABI bool | |
| 431 | 619 | __in_pattern(_Tp __c) |
| 432 | 620 | { |
| 433 | 621 | return '0' <= __c && __c <= '9'; |
| ... | ... | @@ -438,11 +626,11 @@ struct _LIBCPP_HIDDEN __in_pattern_result |
| 438 | 626 | bool __ok; |
| 439 | 627 | int __val; |
| 440 | 628 | |
| 441 | explicit _LIBCPP_INLINE_VISIBILITY operator bool() const { return __ok; } | |
| 629 | explicit _LIBCPP_HIDE_FROM_ABI operator bool() const { return __ok; } | |
| 442 | 630 | }; |
| 443 | 631 | |
| 444 | 632 | template <typename _Tp> |
| 445 | inline _LIBCPP_INLINE_VISIBILITY __in_pattern_result | |
| 633 | inline _LIBCPP_HIDE_FROM_ABI __in_pattern_result | |
| 446 | 634 | __in_pattern(_Tp __c, int __base) |
| 447 | 635 | { |
| 448 | 636 | if (__base <= 10) |
| ... | ... | @@ -456,15 +644,15 @@ __in_pattern(_Tp __c, int __base) |
| 456 | 644 | } |
| 457 | 645 | |
| 458 | 646 | template <typename _It, typename _Tp, typename _Fn, typename... _Ts> |
| 459 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 647 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 460 | 648 | __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, |
| 461 | 649 | _Ts... __args) |
| 462 | 650 | { |
| 463 | auto __find_non_zero = [](_It __first, _It __last) { | |
| 464 | for (; __first != __last; ++__first) | |
| 465 | if (*__first != '0') | |
| 651 | auto __find_non_zero = [](_It __firstit, _It __lastit) { | |
| 652 | for (; __firstit != __lastit; ++__firstit) | |
| 653 | if (*__firstit != '0') | |
| 466 | 654 | break; |
| 467 | return __first; | |
| 655 | return __firstit; | |
| 468 | 656 | }; |
| 469 | 657 | |
| 470 | 658 | auto __p = __find_non_zero(__first, __last); |
| ... | ... | @@ -493,7 +681,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, |
| 493 | 681 | } |
| 494 | 682 | |
| 495 | 683 | template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> |
| 496 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 684 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 497 | 685 | __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) |
| 498 | 686 | { |
| 499 | 687 | using __tx = __itoa::__traits<_Tp>; |
| ... | ... | @@ -501,16 +689,16 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) |
| 501 | 689 | |
| 502 | 690 | return __subject_seq_combinator( |
| 503 | 691 | __first, __last, __value, |
| 504 | [](const char* __first, const char* __last, | |
| 505 | _Tp& __value) -> from_chars_result { | |
| 692 | [](const char* __f, const char* __l, | |
| 693 | _Tp& __val) -> from_chars_result { | |
| 506 | 694 | __output_type __a, __b; |
| 507 | auto __p = __tx::__read(__first, __last, __a, __b); | |
| 508 | if (__p == __last || !__in_pattern(*__p)) | |
| 695 | auto __p = __tx::__read(__f, __l, __a, __b); | |
| 696 | if (__p == __l || !__in_pattern(*__p)) | |
| 509 | 697 | { |
| 510 | 698 | __output_type __m = numeric_limits<_Tp>::max(); |
| 511 | 699 | if (__m >= __a && __m - __a >= __b) |
| 512 | 700 | { |
| 513 | __value = __a + __b; | |
| 701 | __val = __a + __b; | |
| 514 | 702 | return {__p, {}}; |
| 515 | 703 | } |
| 516 | 704 | } |
| ... | ... | @@ -519,7 +707,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) |
| 519 | 707 | } |
| 520 | 708 | |
| 521 | 709 | template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> |
| 522 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 710 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 523 | 711 | __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) |
| 524 | 712 | { |
| 525 | 713 | using __t = decltype(__to_unsigned_like(__value)); |
| ... | ... | @@ -527,7 +715,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) |
| 527 | 715 | } |
| 528 | 716 | |
| 529 | 717 | template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> |
| 530 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 718 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 531 | 719 | __from_chars_integral(const char* __first, const char* __last, _Tp& __value, |
| 532 | 720 | int __base) |
| 533 | 721 | { |
| ... | ... | @@ -536,23 +724,23 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, |
| 536 | 724 | |
| 537 | 725 | return __subject_seq_combinator( |
| 538 | 726 | __first, __last, __value, |
| 539 | [](const char* __p, const char* __lastx, _Tp& __value, | |
| 540 | int __base) -> from_chars_result { | |
| 727 | [](const char* __p, const char* __lastp, _Tp& __val, | |
| 728 | int __b) -> from_chars_result { | |
| 541 | 729 | using __tl = numeric_limits<_Tp>; |
| 542 | auto __digits = __tl::digits / log2f(float(__base)); | |
| 543 | _Tp __a = __in_pattern(*__p++, __base).__val, __b = 0; | |
| 730 | auto __digits = __tl::digits / log2f(float(__b)); | |
| 731 | _Tp __x = __in_pattern(*__p++, __b).__val, __y = 0; | |
| 544 | 732 | |
| 545 | for (int __i = 1; __p != __lastx; ++__i, ++__p) | |
| 733 | for (int __i = 1; __p != __lastp; ++__i, ++__p) | |
| 546 | 734 | { |
| 547 | if (auto __c = __in_pattern(*__p, __base)) | |
| 735 | if (auto __c = __in_pattern(*__p, __b)) | |
| 548 | 736 | { |
| 549 | 737 | if (__i < __digits - 1) |
| 550 | __a = __a * __base + __c.__val; | |
| 738 | __x = __x * __b + __c.__val; | |
| 551 | 739 | else |
| 552 | 740 | { |
| 553 | if (!__itoa::__mul_overflowed(__a, __base, __a)) | |
| 741 | if (!__itoa::__mul_overflowed(__x, __b, __x)) | |
| 554 | 742 | ++__p; |
| 555 | __b = __c.__val; | |
| 743 | __y = __c.__val; | |
| 556 | 744 | break; |
| 557 | 745 | } |
| 558 | 746 | } |
| ... | ... | @@ -560,11 +748,11 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, |
| 560 | 748 | break; |
| 561 | 749 | } |
| 562 | 750 | |
| 563 | if (__p == __lastx || !__in_pattern(*__p, __base)) | |
| 751 | if (__p == __lastp || !__in_pattern(*__p, __b)) | |
| 564 | 752 | { |
| 565 | if (__tl::max() - __a >= __b) | |
| 753 | if (__tl::max() - __x >= __y) | |
| 566 | 754 | { |
| 567 | __value = __a + __b; | |
| 755 | __val = __x + __y; | |
| 568 | 756 | return {__p, {}}; |
| 569 | 757 | } |
| 570 | 758 | } |
| ... | ... | @@ -574,7 +762,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, |
| 574 | 762 | } |
| 575 | 763 | |
| 576 | 764 | template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> |
| 577 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 765 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 578 | 766 | __from_chars_integral(const char* __first, const char* __last, _Tp& __value, |
| 579 | 767 | int __base) |
| 580 | 768 | { |
| ... | ... | @@ -584,14 +772,14 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, |
| 584 | 772 | } |
| 585 | 773 | |
| 586 | 774 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
| 587 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 775 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 588 | 776 | from_chars(const char* __first, const char* __last, _Tp& __value) |
| 589 | 777 | { |
| 590 | 778 | return __from_chars_atoi(__first, __last, __value); |
| 591 | 779 | } |
| 592 | 780 | |
| 593 | 781 | template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> |
| 594 | inline _LIBCPP_INLINE_VISIBILITY from_chars_result | |
| 782 | inline _LIBCPP_HIDE_FROM_ABI from_chars_result | |
| 595 | 783 | from_chars(const char* __first, const char* __last, _Tp& __value, int __base) |
| 596 | 784 | { |
| 597 | 785 | _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); |
lib/libcxx/include/chrono+19-7| ... | ... | @@ -13,6 +13,8 @@ |
| 13 | 13 | /* |
| 14 | 14 | chrono synopsis |
| 15 | 15 | |
| 16 | #include <compare> // C++20 | |
| 17 | ||
| 16 | 18 | namespace std |
| 17 | 19 | { |
| 18 | 20 | namespace chrono |
| ... | ... | @@ -325,11 +327,7 @@ struct last_spec; |
| 325 | 327 | |
| 326 | 328 | class day; |
| 327 | 329 | constexpr bool operator==(const day& x, const day& y) noexcept; |
| 328 | constexpr bool operator!=(const day& x, const day& y) noexcept; | |
| 329 | constexpr bool operator< (const day& x, const day& y) noexcept; | |
| 330 | constexpr bool operator> (const day& x, const day& y) noexcept; | |
| 331 | constexpr bool operator<=(const day& x, const day& y) noexcept; | |
| 332 | constexpr bool operator>=(const day& x, const day& y) noexcept; | |
| 330 | constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept; | |
| 333 | 331 | constexpr day operator+(const day& x, const days& y) noexcept; |
| 334 | 332 | constexpr day operator+(const days& x, const day& y) noexcept; |
| 335 | 333 | constexpr day operator-(const day& x, const days& y) noexcept; |
| ... | ... | @@ -694,20 +692,34 @@ constexpr chrono::year operator ""y(unsigned lo |
| 694 | 692 | } // std |
| 695 | 693 | */ |
| 696 | 694 | |
| 695 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 697 | 696 | #include <__chrono/calendar.h> |
| 698 | 697 | #include <__chrono/convert_to_timespec.h> |
| 698 | #include <__chrono/day.h> | |
| 699 | 699 | #include <__chrono/duration.h> |
| 700 | 700 | #include <__chrono/file_clock.h> |
| 701 | #include <__chrono/hh_mm_ss.h> | |
| 701 | 702 | #include <__chrono/high_resolution_clock.h> |
| 703 | #include <__chrono/literals.h> | |
| 704 | #include <__chrono/month.h> | |
| 705 | #include <__chrono/month_weekday.h> | |
| 706 | #include <__chrono/monthday.h> | |
| 702 | 707 | #include <__chrono/steady_clock.h> |
| 703 | 708 | #include <__chrono/system_clock.h> |
| 704 | 709 | #include <__chrono/time_point.h> |
| 710 | #include <__chrono/weekday.h> | |
| 711 | #include <__chrono/year.h> | |
| 712 | #include <__chrono/year_month.h> | |
| 713 | #include <__chrono/year_month_day.h> | |
| 714 | #include <__chrono/year_month_weekday.h> | |
| 705 | 715 | #include <__config> |
| 706 | #include <compare> | |
| 707 | 716 | #include <version> |
| 708 | 717 | |
| 718 | // standard-mandated includes | |
| 719 | #include <compare> | |
| 720 | ||
| 709 | 721 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 710 | #pragma GCC system_header | |
| 722 | # pragma GCC system_header | |
| 711 | 723 | #endif |
| 712 | 724 | |
| 713 | 725 | #endif // _LIBCPP_CHRONO |
lib/libcxx/include/cinttypes+2-1| ... | ... | @@ -234,12 +234,13 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int |
| 234 | 234 | } // std |
| 235 | 235 | */ |
| 236 | 236 | |
| 237 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 237 | 238 | #include <__config> |
| 238 | 239 | #include <cstdint> |
| 239 | 240 | #include <inttypes.h> |
| 240 | 241 | |
| 241 | 242 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 242 | #pragma GCC system_header | |
| 243 | # pragma GCC system_header | |
| 243 | 244 | #endif |
| 244 | 245 | |
| 245 | 246 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/ciso646+2-1| ... | ... | @@ -15,10 +15,11 @@ |
| 15 | 15 | |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 18 | 19 | #include <__config> |
| 19 | 20 | |
| 20 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 22 | 23 | #endif |
| 23 | 24 | |
| 24 | 25 | #endif // _LIBCPP_CISO646 |
lib/libcxx/include/climits+2-1| ... | ... | @@ -37,11 +37,12 @@ Macros: |
| 37 | 37 | |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 40 | 41 | #include <__config> |
| 41 | 42 | #include <limits.h> |
| 42 | 43 | |
| 43 | 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 44 | #pragma GCC system_header | |
| 45 | # pragma GCC system_header | |
| 45 | 46 | #endif |
| 46 | 47 | |
| 47 | 48 | #endif // _LIBCPP_CLIMITS |
lib/libcxx/include/clocale+2-1| ... | ... | @@ -34,11 +34,12 @@ lconv* localeconv(); |
| 34 | 34 | |
| 35 | 35 | */ |
| 36 | 36 | |
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 37 | 38 | #include <__config> |
| 38 | 39 | #include <locale.h> |
| 39 | 40 | |
| 40 | 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | #pragma GCC system_header | |
| 42 | # pragma GCC system_header | |
| 42 | 43 | #endif |
| 43 | 44 | |
| 44 | 45 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cmath+5-4| ... | ... | @@ -304,13 +304,14 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept |
| 304 | 304 | |
| 305 | 305 | */ |
| 306 | 306 | |
| 307 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 307 | 308 | #include <__config> |
| 308 | 309 | #include <math.h> |
| 309 | 310 | #include <type_traits> |
| 310 | 311 | #include <version> |
| 311 | 312 | |
| 312 | 313 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 313 | #pragma GCC system_header | |
| 314 | # pragma GCC system_header | |
| 314 | 315 | #endif |
| 315 | 316 | |
| 316 | 317 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -529,9 +530,9 @@ using ::tgammal _LIBCPP_USING_IF_EXISTS; |
| 529 | 530 | using ::truncl _LIBCPP_USING_IF_EXISTS; |
| 530 | 531 | |
| 531 | 532 | #if _LIBCPP_STD_VER > 14 |
| 532 | inline _LIBCPP_INLINE_VISIBILITY float hypot( float x, float y, float z ) { return sqrt(x*x + y*y + z*z); } | |
| 533 | inline _LIBCPP_INLINE_VISIBILITY double hypot( double x, double y, double z ) { return sqrt(x*x + y*y + z*z); } | |
| 534 | inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); } | |
| 533 | inline _LIBCPP_INLINE_VISIBILITY float hypot( float __x, float __y, float __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } | |
| 534 | inline _LIBCPP_INLINE_VISIBILITY double hypot( double __x, double __y, double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } | |
| 535 | inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double __x, long double __y, long double __z ) { return sqrt(__x*__x + __y*__y + __z*__z); } | |
| 535 | 536 | |
| 536 | 537 | template <class _A1, class _A2, class _A3> |
| 537 | 538 | inline _LIBCPP_INLINE_VISIBILITY |
lib/libcxx/include/codecvt+76-53| ... | ... | @@ -54,17 +54,18 @@ class codecvt_utf8_utf16 |
| 54 | 54 | |
| 55 | 55 | */ |
| 56 | 56 | |
| 57 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 57 | 58 | #include <__config> |
| 58 | 59 | #include <__locale> |
| 59 | 60 | #include <version> |
| 60 | 61 | |
| 61 | 62 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 62 | #pragma GCC system_header | |
| 63 | # pragma GCC system_header | |
| 63 | 64 | #endif |
| 64 | 65 | |
| 65 | 66 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 66 | 67 | |
| 67 | enum codecvt_mode | |
| 68 | enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode | |
| 68 | 69 | { |
| 69 | 70 | consume_header = 4, |
| 70 | 71 | generate_header = 2, |
| ... | ... | @@ -81,17 +82,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t> |
| 81 | 82 | : public codecvt<wchar_t, char, mbstate_t> |
| 82 | 83 | { |
| 83 | 84 | unsigned long _Maxcode_; |
| 85 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 84 | 86 | codecvt_mode _Mode_; |
| 87 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 85 | 88 | public: |
| 86 | 89 | typedef wchar_t intern_type; |
| 87 | 90 | typedef char extern_type; |
| 88 | 91 | typedef mbstate_t state_type; |
| 89 | 92 | |
| 93 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 90 | 94 | _LIBCPP_INLINE_VISIBILITY |
| 91 | explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, | |
| 92 | codecvt_mode _Mode) | |
| 93 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 94 | _Mode_(_Mode) {} | |
| 95 | explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, | |
| 96 | codecvt_mode __mode) | |
| 97 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 98 | _Mode_(__mode) {} | |
| 99 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 95 | 100 | protected: |
| 96 | 101 | virtual result |
| 97 | 102 | do_out(state_type& __st, |
| ... | ... | @@ -125,10 +130,10 @@ public: |
| 125 | 130 | typedef mbstate_t state_type; |
| 126 | 131 | |
| 127 | 132 | _LIBCPP_INLINE_VISIBILITY |
| 128 | explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, | |
| 129 | codecvt_mode _Mode) | |
| 130 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 131 | _Mode_(_Mode) {} | |
| 133 | explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, | |
| 134 | codecvt_mode __mode) | |
| 135 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 136 | _Mode_(__mode) {} | |
| 132 | 137 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 133 | 138 | |
| 134 | 139 | protected: |
| ... | ... | @@ -163,10 +168,10 @@ public: |
| 163 | 168 | typedef mbstate_t state_type; |
| 164 | 169 | |
| 165 | 170 | _LIBCPP_INLINE_VISIBILITY |
| 166 | explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, | |
| 167 | codecvt_mode _Mode) | |
| 168 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 169 | _Mode_(_Mode) {} | |
| 171 | explicit __codecvt_utf8(size_t __refs, unsigned long __maxcode, | |
| 172 | codecvt_mode __mode) | |
| 173 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 174 | _Mode_(__mode) {} | |
| 170 | 175 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 171 | 176 | |
| 172 | 177 | protected: |
| ... | ... | @@ -188,9 +193,10 @@ protected: |
| 188 | 193 | virtual int do_max_length() const _NOEXCEPT; |
| 189 | 194 | }; |
| 190 | 195 | |
| 196 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 191 | 197 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, |
| 192 | 198 | codecvt_mode _Mode = (codecvt_mode)0> |
| 193 | class _LIBCPP_TEMPLATE_VIS codecvt_utf8 | |
| 199 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 | |
| 194 | 200 | : public __codecvt_utf8<_Elem> |
| 195 | 201 | { |
| 196 | 202 | public: |
| ... | ... | @@ -201,6 +207,7 @@ public: |
| 201 | 207 | _LIBCPP_INLINE_VISIBILITY |
| 202 | 208 | ~codecvt_utf8() {} |
| 203 | 209 | }; |
| 210 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 204 | 211 | |
| 205 | 212 | // codecvt_utf16 |
| 206 | 213 | |
| ... | ... | @@ -212,17 +219,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false> |
| 212 | 219 | : public codecvt<wchar_t, char, mbstate_t> |
| 213 | 220 | { |
| 214 | 221 | unsigned long _Maxcode_; |
| 222 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 215 | 223 | codecvt_mode _Mode_; |
| 224 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 216 | 225 | public: |
| 217 | 226 | typedef wchar_t intern_type; |
| 218 | 227 | typedef char extern_type; |
| 219 | 228 | typedef mbstate_t state_type; |
| 220 | 229 | |
| 230 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 221 | 231 | _LIBCPP_INLINE_VISIBILITY |
| 222 | explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, | |
| 223 | codecvt_mode _Mode) | |
| 224 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 225 | _Mode_(_Mode) {} | |
| 232 | explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, | |
| 233 | codecvt_mode __mode) | |
| 234 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 235 | _Mode_(__mode) {} | |
| 236 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 226 | 237 | protected: |
| 227 | 238 | virtual result |
| 228 | 239 | do_out(state_type& __st, |
| ... | ... | @@ -247,17 +258,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true> |
| 247 | 258 | : public codecvt<wchar_t, char, mbstate_t> |
| 248 | 259 | { |
| 249 | 260 | unsigned long _Maxcode_; |
| 261 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 250 | 262 | codecvt_mode _Mode_; |
| 263 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 251 | 264 | public: |
| 252 | 265 | typedef wchar_t intern_type; |
| 253 | 266 | typedef char extern_type; |
| 254 | 267 | typedef mbstate_t state_type; |
| 255 | 268 | |
| 269 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 256 | 270 | _LIBCPP_INLINE_VISIBILITY |
| 257 | explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, | |
| 258 | codecvt_mode _Mode) | |
| 259 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 260 | _Mode_(_Mode) {} | |
| 271 | explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, | |
| 272 | codecvt_mode __mode) | |
| 273 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 274 | _Mode_(__mode) {} | |
| 275 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 261 | 276 | protected: |
| 262 | 277 | virtual result |
| 263 | 278 | do_out(state_type& __st, |
| ... | ... | @@ -291,10 +306,10 @@ public: |
| 291 | 306 | typedef mbstate_t state_type; |
| 292 | 307 | |
| 293 | 308 | _LIBCPP_INLINE_VISIBILITY |
| 294 | explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, | |
| 295 | codecvt_mode _Mode) | |
| 296 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 297 | _Mode_(_Mode) {} | |
| 309 | explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, | |
| 310 | codecvt_mode __mode) | |
| 311 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 312 | _Mode_(__mode) {} | |
| 298 | 313 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 299 | 314 | |
| 300 | 315 | protected: |
| ... | ... | @@ -329,10 +344,10 @@ public: |
| 329 | 344 | typedef mbstate_t state_type; |
| 330 | 345 | |
| 331 | 346 | _LIBCPP_INLINE_VISIBILITY |
| 332 | explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, | |
| 333 | codecvt_mode _Mode) | |
| 334 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 335 | _Mode_(_Mode) {} | |
| 347 | explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, | |
| 348 | codecvt_mode __mode) | |
| 349 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 350 | _Mode_(__mode) {} | |
| 336 | 351 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 337 | 352 | |
| 338 | 353 | protected: |
| ... | ... | @@ -367,10 +382,10 @@ public: |
| 367 | 382 | typedef mbstate_t state_type; |
| 368 | 383 | |
| 369 | 384 | _LIBCPP_INLINE_VISIBILITY |
| 370 | explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, | |
| 371 | codecvt_mode _Mode) | |
| 372 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 373 | _Mode_(_Mode) {} | |
| 385 | explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, | |
| 386 | codecvt_mode __mode) | |
| 387 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 388 | _Mode_(__mode) {} | |
| 374 | 389 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 375 | 390 | |
| 376 | 391 | protected: |
| ... | ... | @@ -405,10 +420,10 @@ public: |
| 405 | 420 | typedef mbstate_t state_type; |
| 406 | 421 | |
| 407 | 422 | _LIBCPP_INLINE_VISIBILITY |
| 408 | explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, | |
| 409 | codecvt_mode _Mode) | |
| 410 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 411 | _Mode_(_Mode) {} | |
| 423 | explicit __codecvt_utf16(size_t __refs, unsigned long __maxcode, | |
| 424 | codecvt_mode __mode) | |
| 425 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 426 | _Mode_(__mode) {} | |
| 412 | 427 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 413 | 428 | |
| 414 | 429 | protected: |
| ... | ... | @@ -430,9 +445,10 @@ protected: |
| 430 | 445 | virtual int do_max_length() const _NOEXCEPT; |
| 431 | 446 | }; |
| 432 | 447 | |
| 448 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 433 | 449 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, |
| 434 | 450 | codecvt_mode _Mode = (codecvt_mode)0> |
| 435 | class _LIBCPP_TEMPLATE_VIS codecvt_utf16 | |
| 451 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 | |
| 436 | 452 | : public __codecvt_utf16<_Elem, _Mode & little_endian> |
| 437 | 453 | { |
| 438 | 454 | public: |
| ... | ... | @@ -443,6 +459,7 @@ public: |
| 443 | 459 | _LIBCPP_INLINE_VISIBILITY |
| 444 | 460 | ~codecvt_utf16() {} |
| 445 | 461 | }; |
| 462 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 446 | 463 | |
| 447 | 464 | // codecvt_utf8_utf16 |
| 448 | 465 | |
| ... | ... | @@ -454,17 +471,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t> |
| 454 | 471 | : public codecvt<wchar_t, char, mbstate_t> |
| 455 | 472 | { |
| 456 | 473 | unsigned long _Maxcode_; |
| 474 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 457 | 475 | codecvt_mode _Mode_; |
| 476 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 458 | 477 | public: |
| 459 | 478 | typedef wchar_t intern_type; |
| 460 | 479 | typedef char extern_type; |
| 461 | 480 | typedef mbstate_t state_type; |
| 462 | 481 | |
| 482 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 463 | 483 | _LIBCPP_INLINE_VISIBILITY |
| 464 | explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, | |
| 465 | codecvt_mode _Mode) | |
| 466 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 467 | _Mode_(_Mode) {} | |
| 484 | explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, | |
| 485 | codecvt_mode __mode) | |
| 486 | : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 487 | _Mode_(__mode) {} | |
| 488 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 468 | 489 | protected: |
| 469 | 490 | virtual result |
| 470 | 491 | do_out(state_type& __st, |
| ... | ... | @@ -498,10 +519,10 @@ public: |
| 498 | 519 | typedef mbstate_t state_type; |
| 499 | 520 | |
| 500 | 521 | _LIBCPP_INLINE_VISIBILITY |
| 501 | explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, | |
| 502 | codecvt_mode _Mode) | |
| 503 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 504 | _Mode_(_Mode) {} | |
| 522 | explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, | |
| 523 | codecvt_mode __mode) | |
| 524 | : codecvt<char32_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 525 | _Mode_(__mode) {} | |
| 505 | 526 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 506 | 527 | |
| 507 | 528 | protected: |
| ... | ... | @@ -536,10 +557,10 @@ public: |
| 536 | 557 | typedef mbstate_t state_type; |
| 537 | 558 | |
| 538 | 559 | _LIBCPP_INLINE_VISIBILITY |
| 539 | explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, | |
| 540 | codecvt_mode _Mode) | |
| 541 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), | |
| 542 | _Mode_(_Mode) {} | |
| 560 | explicit __codecvt_utf8_utf16(size_t __refs, unsigned long __maxcode, | |
| 561 | codecvt_mode __mode) | |
| 562 | : codecvt<char16_t, char, mbstate_t>(__refs), _Maxcode_(__maxcode), | |
| 563 | _Mode_(__mode) {} | |
| 543 | 564 | _LIBCPP_SUPPRESS_DEPRECATED_POP |
| 544 | 565 | |
| 545 | 566 | protected: |
| ... | ... | @@ -561,9 +582,10 @@ protected: |
| 561 | 582 | virtual int do_max_length() const _NOEXCEPT; |
| 562 | 583 | }; |
| 563 | 584 | |
| 585 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 564 | 586 | template <class _Elem, unsigned long _Maxcode = 0x10ffff, |
| 565 | 587 | codecvt_mode _Mode = (codecvt_mode)0> |
| 566 | class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16 | |
| 588 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 | |
| 567 | 589 | : public __codecvt_utf8_utf16<_Elem> |
| 568 | 590 | { |
| 569 | 591 | public: |
| ... | ... | @@ -574,6 +596,7 @@ public: |
| 574 | 596 | _LIBCPP_INLINE_VISIBILITY |
| 575 | 597 | ~codecvt_utf8_utf16() {} |
| 576 | 598 | }; |
| 599 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 577 | 600 | |
| 578 | 601 | _LIBCPP_END_NAMESPACE_STD |
| 579 | 602 |
lib/libcxx/include/compare+2-1| ... | ... | @@ -140,6 +140,7 @@ namespace std { |
| 140 | 140 | } |
| 141 | 141 | */ |
| 142 | 142 | |
| 143 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 143 | 144 | #include <__compare/common_comparison_category.h> |
| 144 | 145 | #include <__compare/compare_partial_order_fallback.h> |
| 145 | 146 | #include <__compare/compare_strong_order_fallback.h> |
| ... | ... | @@ -156,7 +157,7 @@ namespace std { |
| 156 | 157 | #include <version> |
| 157 | 158 | |
| 158 | 159 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 159 | #pragma GCC system_header | |
| 160 | # pragma GCC system_header | |
| 160 | 161 | #endif |
| 161 | 162 | |
| 162 | 163 | #endif // _LIBCPP_COMPARE |
lib/libcxx/include/complex+2-1| ... | ... | @@ -231,6 +231,7 @@ template<class T> complex<T> tanh (const complex<T>&); |
| 231 | 231 | |
| 232 | 232 | */ |
| 233 | 233 | |
| 234 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 234 | 235 | #include <__config> |
| 235 | 236 | #include <cmath> |
| 236 | 237 | #include <iosfwd> |
| ... | ... | @@ -243,7 +244,7 @@ template<class T> complex<T> tanh (const complex<T>&); |
| 243 | 244 | #endif |
| 244 | 245 | |
| 245 | 246 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 246 | #pragma GCC system_header | |
| 247 | # pragma GCC system_header | |
| 247 | 248 | #endif |
| 248 | 249 | |
| 249 | 250 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/complex.h+1-1| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | #include <__config> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | #ifdef __cplusplus |
lib/libcxx/include/concepts+2-1| ... | ... | @@ -129,6 +129,7 @@ namespace std { |
| 129 | 129 | |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 132 | 133 | #include <__concepts/arithmetic.h> |
| 133 | 134 | #include <__concepts/assignable.h> |
| 134 | 135 | #include <__concepts/boolean_testable.h> |
| ... | ... | @@ -155,7 +156,7 @@ namespace std { |
| 155 | 156 | #include <version> |
| 156 | 157 | |
| 157 | 158 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 158 | #pragma GCC system_header | |
| 159 | # pragma GCC system_header | |
| 159 | 160 | #endif |
| 160 | 161 | |
| 161 | 162 | #endif // _LIBCPP_CONCEPTS |
lib/libcxx/include/condition_variable+3-2| ... | ... | @@ -106,13 +106,14 @@ public: |
| 106 | 106 | |
| 107 | 107 | */ |
| 108 | 108 | |
| 109 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 109 | 110 | #include <__config> |
| 110 | 111 | #include <__mutex_base> |
| 111 | 112 | #include <memory> |
| 112 | 113 | #include <version> |
| 113 | 114 | |
| 114 | 115 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 115 | #pragma GCC system_header | |
| 116 | # pragma GCC system_header | |
| 116 | 117 | #endif |
| 117 | 118 | |
| 118 | 119 | #ifndef _LIBCPP_HAS_NO_THREADS |
| ... | ... | @@ -260,7 +261,7 @@ condition_variable_any::wait_for(_Lock& __lock, |
| 260 | 261 | } |
| 261 | 262 | |
| 262 | 263 | _LIBCPP_FUNC_VIS |
| 263 | void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk); | |
| 264 | void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>); | |
| 264 | 265 | |
| 265 | 266 | _LIBCPP_END_NAMESPACE_STD |
| 266 | 267 |
lib/libcxx/include/coroutine+9-1| ... | ... | @@ -38,6 +38,7 @@ struct suspend_always; |
| 38 | 38 | |
| 39 | 39 | */ |
| 40 | 40 | |
| 41 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 41 | 42 | #include <__config> |
| 42 | 43 | #include <__coroutine/coroutine_handle.h> |
| 43 | 44 | #include <__coroutine/coroutine_traits.h> |
| ... | ... | @@ -45,8 +46,15 @@ struct suspend_always; |
| 45 | 46 | #include <__coroutine/trivial_awaitables.h> |
| 46 | 47 | #include <version> |
| 47 | 48 | |
| 49 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 50 | # include <iosfwd> | |
| 51 | #endif | |
| 52 | ||
| 53 | // standard-mandated includes | |
| 54 | #include <compare> | |
| 55 | ||
| 48 | 56 | #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER |
| 49 | #pragma GCC system_header | |
| 57 | # pragma GCC system_header | |
| 50 | 58 | #endif |
| 51 | 59 | |
| 52 | 60 | #endif // _LIBCPP_COROUTINE |
lib/libcxx/include/csetjmp+2-1| ... | ... | @@ -30,11 +30,12 @@ void longjmp(jmp_buf env, int val); |
| 30 | 30 | |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 33 | 34 | #include <__config> |
| 34 | 35 | #include <setjmp.h> |
| 35 | 36 | |
| 36 | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 37 | #pragma GCC system_header | |
| 38 | # pragma GCC system_header | |
| 38 | 39 | #endif |
| 39 | 40 | |
| 40 | 41 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/csignal+6-2| ... | ... | @@ -39,11 +39,15 @@ int raise(int sig); |
| 39 | 39 | |
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 42 | 43 | #include <__config> |
| 43 | #include <signal.h> | |
| 44 | ||
| 45 | #if __has_include(<signal.h>) | |
| 46 | # include <signal.h> | |
| 47 | #endif | |
| 44 | 48 | |
| 45 | 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 46 | #pragma GCC system_header | |
| 50 | # pragma GCC system_header | |
| 47 | 51 | #endif |
| 48 | 52 | |
| 49 | 53 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cstdarg+2-1| ... | ... | @@ -31,11 +31,12 @@ Types: |
| 31 | 31 | |
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 34 | 35 | #include <__config> |
| 35 | 36 | #include <stdarg.h> |
| 36 | 37 | |
| 37 | 38 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 38 | #pragma GCC system_header | |
| 39 | # pragma GCC system_header | |
| 39 | 40 | #endif |
| 40 | 41 | |
| 41 | 42 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cstdbool+2-1| ... | ... | @@ -19,10 +19,11 @@ Macros: |
| 19 | 19 | |
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 22 | 23 | #include <__config> |
| 23 | 24 | |
| 24 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 26 | 27 | #endif |
| 27 | 28 | |
| 28 | 29 | #undef __bool_true_false_are_defined |
lib/libcxx/include/cstddef+11-38| ... | ... | @@ -33,19 +33,21 @@ Types: |
| 33 | 33 | |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 36 | 37 | #include <__config> |
| 38 | #include <__type_traits/enable_if.h> | |
| 39 | #include <__type_traits/integral_constant.h> | |
| 40 | #include <__type_traits/is_integral.h> | |
| 41 | #include <stddef.h> | |
| 37 | 42 | #include <version> |
| 38 | 43 | |
| 39 | 44 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 40 | #pragma GCC system_header | |
| 45 | # pragma GCC system_header | |
| 41 | 46 | #endif |
| 42 | 47 | |
| 43 | // Don't include our own <stddef.h>; we don't want to declare ::nullptr_t. | |
| 44 | #include_next <stddef.h> | |
| 45 | #include <__nullptr> | |
| 46 | ||
| 47 | 48 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 49 | |
| 50 | using ::nullptr_t; | |
| 49 | 51 | using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS; |
| 50 | 52 | using ::size_t _LIBCPP_USING_IF_EXISTS; |
| 51 | 53 | |
| ... | ... | @@ -53,34 +55,6 @@ using ::size_t _LIBCPP_USING_IF_EXISTS; |
| 53 | 55 | using ::max_align_t _LIBCPP_USING_IF_EXISTS; |
| 54 | 56 | #endif |
| 55 | 57 | |
| 56 | template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; }; | |
| 57 | template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; }; | |
| 58 | template <> struct __libcpp_is_integral<char> { enum { value = 1 }; }; | |
| 59 | template <> struct __libcpp_is_integral<signed char> { enum { value = 1 }; }; | |
| 60 | template <> struct __libcpp_is_integral<unsigned char> { enum { value = 1 }; }; | |
| 61 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 62 | template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; }; | |
| 63 | #endif | |
| 64 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 65 | template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; }; | |
| 66 | #endif | |
| 67 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 68 | template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; }; | |
| 69 | template <> struct __libcpp_is_integral<char32_t> { enum { value = 1 }; }; | |
| 70 | #endif | |
| 71 | template <> struct __libcpp_is_integral<short> { enum { value = 1 }; }; | |
| 72 | template <> struct __libcpp_is_integral<unsigned short> { enum { value = 1 }; }; | |
| 73 | template <> struct __libcpp_is_integral<int> { enum { value = 1 }; }; | |
| 74 | template <> struct __libcpp_is_integral<unsigned int> { enum { value = 1 }; }; | |
| 75 | template <> struct __libcpp_is_integral<long> { enum { value = 1 }; }; | |
| 76 | template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; }; | |
| 77 | template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; }; | |
| 78 | template <> struct __libcpp_is_integral<unsigned long long> { enum { value = 1 }; }; | |
| 79 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 80 | template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; | |
| 81 | template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; | |
| 82 | #endif | |
| 83 | ||
| 84 | 58 | _LIBCPP_END_NAMESPACE_STD |
| 85 | 59 | |
| 86 | 60 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -88,11 +62,6 @@ namespace std // purposefully not versioned |
| 88 | 62 | { |
| 89 | 63 | enum class byte : unsigned char {}; |
| 90 | 64 | |
| 91 | ||
| 92 | template <bool> struct __enable_if_integral_imp {}; | |
| 93 | template <> struct __enable_if_integral_imp<true> { using type = byte; }; | |
| 94 | template <class _Tp> using _EnableByteOverload = typename __enable_if_integral_imp<__libcpp_is_integral<_Tp>::value>::type; | |
| 95 | ||
| 96 | 65 | constexpr byte operator| (byte __lhs, byte __rhs) noexcept |
| 97 | 66 | { |
| 98 | 67 | return static_cast<byte>( |
| ... | ... | @@ -133,6 +102,10 @@ constexpr byte operator~ (byte __b) noexcept |
| 133 | 102 | ~static_cast<unsigned int>(__b) |
| 134 | 103 | )); |
| 135 | 104 | } |
| 105 | ||
| 106 | template <class _Tp> | |
| 107 | using _EnableByteOverload = __enable_if_t<is_integral<_Tp>::value, byte>; | |
| 108 | ||
| 136 | 109 | template <class _Integer> |
| 137 | 110 | constexpr _EnableByteOverload<_Integer> & |
| 138 | 111 | operator<<=(byte& __lhs, _Integer __shift) noexcept |
lib/libcxx/include/cstdint+2-1| ... | ... | @@ -140,11 +140,12 @@ Types: |
| 140 | 140 | } // std |
| 141 | 141 | */ |
| 142 | 142 | |
| 143 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 143 | 144 | #include <__config> |
| 144 | 145 | #include <stdint.h> |
| 145 | 146 | |
| 146 | 147 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 147 | #pragma GCC system_header | |
| 148 | # pragma GCC system_header | |
| 148 | 149 | #endif |
| 149 | 150 | |
| 150 | 151 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cstdio+2-1| ... | ... | @@ -95,11 +95,12 @@ void perror(const char* s); |
| 95 | 95 | } // std |
| 96 | 96 | */ |
| 97 | 97 | |
| 98 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 98 | 99 | #include <__config> |
| 99 | 100 | #include <stdio.h> |
| 100 | 101 | |
| 101 | 102 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 102 | #pragma GCC system_header | |
| 103 | # pragma GCC system_header | |
| 103 | 104 | #endif |
| 104 | 105 | |
| 105 | 106 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cstdlib+4-11| ... | ... | @@ -81,17 +81,12 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 81 | 81 | |
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 84 | 85 | #include <__config> |
| 85 | 86 | #include <stdlib.h> |
| 86 | 87 | |
| 87 | 88 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 88 | #pragma GCC system_header | |
| 89 | #endif | |
| 90 | ||
| 91 | #ifdef __GNUC__ | |
| 92 | #define _LIBCPP_UNREACHABLE() __builtin_unreachable() | |
| 93 | #else | |
| 94 | #define _LIBCPP_UNREACHABLE() _VSTD::abort() | |
| 89 | # pragma GCC system_header | |
| 95 | 90 | #endif |
| 96 | 91 | |
| 97 | 92 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -121,10 +116,8 @@ using ::abort _LIBCPP_USING_IF_EXISTS; |
| 121 | 116 | using ::atexit _LIBCPP_USING_IF_EXISTS; |
| 122 | 117 | using ::exit _LIBCPP_USING_IF_EXISTS; |
| 123 | 118 | using ::_Exit _LIBCPP_USING_IF_EXISTS; |
| 124 | #ifndef _LIBCPP_WINDOWS_STORE_APP | |
| 125 | 119 | using ::getenv _LIBCPP_USING_IF_EXISTS; |
| 126 | 120 | using ::system _LIBCPP_USING_IF_EXISTS; |
| 127 | #endif | |
| 128 | 121 | using ::bsearch _LIBCPP_USING_IF_EXISTS; |
| 129 | 122 | using ::qsort _LIBCPP_USING_IF_EXISTS; |
| 130 | 123 | using ::abs _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -138,11 +131,11 @@ using ::mbtowc _LIBCPP_USING_IF_EXISTS; |
| 138 | 131 | using ::wctomb _LIBCPP_USING_IF_EXISTS; |
| 139 | 132 | using ::mbstowcs _LIBCPP_USING_IF_EXISTS; |
| 140 | 133 | using ::wcstombs _LIBCPP_USING_IF_EXISTS; |
| 141 | #if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT) | |
| 134 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 142 | 135 | using ::at_quick_exit _LIBCPP_USING_IF_EXISTS; |
| 143 | 136 | using ::quick_exit _LIBCPP_USING_IF_EXISTS; |
| 144 | 137 | #endif |
| 145 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC) | |
| 138 | #if _LIBCPP_STD_VER > 14 | |
| 146 | 139 | using ::aligned_alloc _LIBCPP_USING_IF_EXISTS; |
| 147 | 140 | #endif |
| 148 | 141 |
lib/libcxx/include/cstring+2-1| ... | ... | @@ -56,11 +56,12 @@ size_t strlen(const char* s); |
| 56 | 56 | |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 59 | 60 | #include <__config> |
| 60 | 61 | #include <string.h> |
| 61 | 62 | |
| 62 | 63 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 63 | #pragma GCC system_header | |
| 64 | # pragma GCC system_header | |
| 64 | 65 | #endif |
| 65 | 66 | |
| 66 | 67 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/ctgmath+2-1| ... | ... | @@ -18,11 +18,12 @@ |
| 18 | 18 | |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 21 | 22 | #include <ccomplex> |
| 22 | 23 | #include <cmath> |
| 23 | 24 | |
| 24 | 25 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 26 | # pragma GCC system_header | |
| 26 | 27 | #endif |
| 27 | 28 | |
| 28 | 29 | #endif // _LIBCPP_CTGMATH |
lib/libcxx/include/ctime+4-17| ... | ... | @@ -45,25 +45,12 @@ int timespec_get( struct timespec *ts, int base); // C++17 |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 48 | 49 | #include <__config> |
| 49 | 50 | #include <time.h> |
| 50 | 51 | |
| 51 | 52 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 52 | #pragma GCC system_header | |
| 53 | #endif | |
| 54 | ||
| 55 | // FIXME: | |
| 56 | // Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This | |
| 57 | // should be fixed in future SDKs, but for the time being we need to avoid | |
| 58 | // trying to use that declaration when the SDK doesn't provide it. Note that | |
| 59 | // we're detecting this here instead of in <__config> because we can't include | |
| 60 | // system headers from <__config>, since it leads to circular module dependencies. | |
| 61 | // This is also meant to be a very temporary workaround until the SDKs are fixed. | |
| 62 | #if defined(__APPLE__) && !__has_attribute(using_if_exists) | |
| 63 | # include <sys/cdefs.h> | |
| 64 | # if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL) | |
| 65 | # define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED | |
| 66 | # endif | |
| 53 | # pragma GCC system_header | |
| 67 | 54 | #endif |
| 68 | 55 | |
| 69 | 56 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -72,7 +59,7 @@ using ::clock_t _LIBCPP_USING_IF_EXISTS; |
| 72 | 59 | using ::size_t _LIBCPP_USING_IF_EXISTS; |
| 73 | 60 | using ::time_t _LIBCPP_USING_IF_EXISTS; |
| 74 | 61 | using ::tm _LIBCPP_USING_IF_EXISTS; |
| 75 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) | |
| 62 | #if _LIBCPP_STD_VER > 14 | |
| 76 | 63 | using ::timespec _LIBCPP_USING_IF_EXISTS; |
| 77 | 64 | #endif |
| 78 | 65 | using ::clock _LIBCPP_USING_IF_EXISTS; |
| ... | ... | @@ -84,7 +71,7 @@ using ::ctime _LIBCPP_USING_IF_EXISTS; |
| 84 | 71 | using ::gmtime _LIBCPP_USING_IF_EXISTS; |
| 85 | 72 | using ::localtime _LIBCPP_USING_IF_EXISTS; |
| 86 | 73 | using ::strftime _LIBCPP_USING_IF_EXISTS; |
| 87 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED) | |
| 74 | #if _LIBCPP_STD_VER > 14 | |
| 88 | 75 | using ::timespec_get _LIBCPP_USING_IF_EXISTS; |
| 89 | 76 | #endif |
| 90 | 77 |
lib/libcxx/include/ctype.h+1-1| ... | ... | @@ -32,7 +32,7 @@ int toupper(int c); |
| 32 | 32 | #include <__config> |
| 33 | 33 | |
| 34 | 34 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 35 | #pragma GCC system_header | |
| 35 | # pragma GCC system_header | |
| 36 | 36 | #endif |
| 37 | 37 | |
| 38 | 38 | #include_next <ctype.h> |
lib/libcxx/include/cuchar created+61| ... | ... | @@ -0,0 +1,61 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_CUCHAR | |
| 11 | #define _LIBCPP_CUCHAR | |
| 12 | ||
| 13 | /* | |
| 14 | cuchar synopsis // since C++11 | |
| 15 | ||
| 16 | Macros: | |
| 17 | ||
| 18 | __STDC_UTF_16__ | |
| 19 | __STDC_UTF_32__ | |
| 20 | ||
| 21 | namespace std { | |
| 22 | ||
| 23 | Types: | |
| 24 | ||
| 25 | mbstate_t | |
| 26 | size_t | |
| 27 | ||
| 28 | size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps); | |
| 29 | size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps); | |
| 30 | size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps); | |
| 31 | size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); | |
| 32 | ||
| 33 | } // std | |
| 34 | ||
| 35 | */ | |
| 36 | ||
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 38 | #include <__config> | |
| 39 | #include <uchar.h> | |
| 40 | ||
| 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 42 | # pragma GCC system_header | |
| 43 | #endif | |
| 44 | ||
| 45 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 46 | ||
| 47 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 48 | ||
| 49 | using ::mbstate_t _LIBCPP_USING_IF_EXISTS; | |
| 50 | using ::size_t _LIBCPP_USING_IF_EXISTS; | |
| 51 | ||
| 52 | using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS; | |
| 53 | using ::c16rtomb _LIBCPP_USING_IF_EXISTS; | |
| 54 | using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS; | |
| 55 | using ::c32rtomb _LIBCPP_USING_IF_EXISTS; | |
| 56 | ||
| 57 | #endif // _LIBCPP_CXX03_LANG | |
| 58 | ||
| 59 | _LIBCPP_END_NAMESPACE_STD | |
| 60 | ||
| 61 | #endif // _LIBCPP_CUCHAR |
lib/libcxx/include/cwchar+2-1| ... | ... | @@ -102,12 +102,13 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 102 | 102 | |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 105 | 106 | #include <__config> |
| 106 | 107 | #include <cwctype> |
| 107 | 108 | #include <wchar.h> |
| 108 | 109 | |
| 109 | 110 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 110 | #pragma GCC system_header | |
| 111 | # pragma GCC system_header | |
| 111 | 112 | #endif |
| 112 | 113 | |
| 113 | 114 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/cwctype+2-1| ... | ... | @@ -49,12 +49,13 @@ wctrans_t wctrans(const char* property); |
| 49 | 49 | |
| 50 | 50 | */ |
| 51 | 51 | |
| 52 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 52 | 53 | #include <__config> |
| 53 | 54 | #include <cctype> |
| 54 | 55 | #include <wctype.h> |
| 55 | 56 | |
| 56 | 57 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 57 | #pragma GCC system_header | |
| 58 | # pragma GCC system_header | |
| 58 | 59 | #endif |
| 59 | 60 | |
| 60 | 61 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/deque+54-23| ... | ... | @@ -160,22 +160,52 @@ template <class T, class Allocator, class Predicate> |
| 160 | 160 | |
| 161 | 161 | */ |
| 162 | 162 | |
| 163 | #include <__algorithm/copy.h> | |
| 164 | #include <__algorithm/copy_backward.h> | |
| 165 | #include <__algorithm/equal.h> | |
| 166 | #include <__algorithm/fill_n.h> | |
| 167 | #include <__algorithm/lexicographical_compare.h> | |
| 168 | #include <__algorithm/min.h> | |
| 169 | #include <__algorithm/remove.h> | |
| 170 | #include <__algorithm/remove_if.h> | |
| 171 | #include <__algorithm/unwrap_iter.h> | |
| 172 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 163 | 173 | #include <__config> |
| 164 | #include <__debug> | |
| 174 | #include <__format/enable_insertable.h> | |
| 165 | 175 | #include <__iterator/iterator_traits.h> |
| 176 | #include <__iterator/next.h> | |
| 177 | #include <__iterator/prev.h> | |
| 178 | #include <__iterator/reverse_iterator.h> | |
| 166 | 179 | #include <__split_buffer> |
| 167 | 180 | #include <__utility/forward.h> |
| 168 | #include <algorithm> | |
| 169 | #include <compare> | |
| 170 | #include <initializer_list> | |
| 171 | #include <iterator> | |
| 181 | #include <__utility/move.h> | |
| 182 | #include <__utility/swap.h> | |
| 172 | 183 | #include <limits> |
| 173 | 184 | #include <stdexcept> |
| 174 | 185 | #include <type_traits> |
| 175 | 186 | #include <version> |
| 176 | 187 | |
| 188 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 189 | # include <algorithm> | |
| 190 | # include <functional> | |
| 191 | # include <iterator> | |
| 192 | #endif | |
| 193 | ||
| 194 | // standard-mandated includes | |
| 195 | ||
| 196 | // [iterator.range] | |
| 197 | #include <__iterator/access.h> | |
| 198 | #include <__iterator/data.h> | |
| 199 | #include <__iterator/empty.h> | |
| 200 | #include <__iterator/reverse_access.h> | |
| 201 | #include <__iterator/size.h> | |
| 202 | ||
| 203 | // [deque.syn] | |
| 204 | #include <compare> | |
| 205 | #include <initializer_list> | |
| 206 | ||
| 177 | 207 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 178 | #pragma GCC system_header | |
| 208 | # pragma GCC system_header | |
| 179 | 209 | #endif |
| 180 | 210 | |
| 181 | 211 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -442,7 +472,7 @@ public: |
| 442 | 472 | {return !(__x < __y);} |
| 443 | 473 | |
| 444 | 474 | private: |
| 445 | _LIBCPP_INLINE_VISIBILITY __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT | |
| 475 | _LIBCPP_INLINE_VISIBILITY explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT | |
| 446 | 476 | : __m_iter_(__m), __ptr_(__p) {} |
| 447 | 477 | |
| 448 | 478 | template <class _Tp, class _Ap> friend class __deque_base; |
| ... | ... | @@ -1304,7 +1334,7 @@ public: |
| 1304 | 1334 | deque(_InputIter __f, _InputIter __l, const allocator_type& __a, |
| 1305 | 1335 | typename enable_if<__is_cpp17_input_iterator<_InputIter>::value>::type* = 0); |
| 1306 | 1336 | deque(const deque& __c); |
| 1307 | deque(const deque& __c, const __identity_t<allocator_type>& __a); | |
| 1337 | deque(const deque& __c, const __type_identity_t<allocator_type>& __a); | |
| 1308 | 1338 | |
| 1309 | 1339 | deque& operator=(const deque& __c); |
| 1310 | 1340 | |
| ... | ... | @@ -1318,7 +1348,7 @@ public: |
| 1318 | 1348 | _LIBCPP_INLINE_VISIBILITY |
| 1319 | 1349 | deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value); |
| 1320 | 1350 | _LIBCPP_INLINE_VISIBILITY |
| 1321 | deque(deque&& __c, const __identity_t<allocator_type>& __a); | |
| 1351 | deque(deque&& __c, const __type_identity_t<allocator_type>& __a); | |
| 1322 | 1352 | _LIBCPP_INLINE_VISIBILITY |
| 1323 | 1353 | deque& operator=(deque&& __c) |
| 1324 | 1354 | _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && |
| ... | ... | @@ -1434,12 +1464,10 @@ public: |
| 1434 | 1464 | iterator insert(const_iterator __p, size_type __n, const value_type& __v); |
| 1435 | 1465 | template <class _InputIter> |
| 1436 | 1466 | iterator insert(const_iterator __p, _InputIter __f, _InputIter __l, |
| 1437 | typename enable_if<__is_cpp17_input_iterator<_InputIter>::value | |
| 1438 | &&!__is_cpp17_forward_iterator<_InputIter>::value>::type* = 0); | |
| 1467 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type* = 0); | |
| 1439 | 1468 | template <class _ForwardIterator> |
| 1440 | 1469 | iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l, |
| 1441 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value | |
| 1442 | &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type* = 0); | |
| 1470 | typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); | |
| 1443 | 1471 | template <class _BiIter> |
| 1444 | 1472 | iterator insert(const_iterator __p, _BiIter __f, _BiIter __l, |
| 1445 | 1473 | typename enable_if<__is_cpp17_bidirectional_iterator<_BiIter>::value>::type* = 0); |
| ... | ... | @@ -1526,8 +1554,7 @@ public: |
| 1526 | 1554 | |
| 1527 | 1555 | template <class _InpIter> |
| 1528 | 1556 | void __append(_InpIter __f, _InpIter __l, |
| 1529 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value && | |
| 1530 | !__is_cpp17_forward_iterator<_InpIter>::value>::type* = 0); | |
| 1557 | typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type* = 0); | |
| 1531 | 1558 | template <class _ForIter> |
| 1532 | 1559 | void __append(_ForIter __f, _ForIter __l, |
| 1533 | 1560 | typename enable_if<__is_cpp17_forward_iterator<_ForIter>::value>::type* = 0); |
| ... | ... | @@ -1640,7 +1667,7 @@ deque<_Tp, _Allocator>::deque(const deque& __c) |
| 1640 | 1667 | } |
| 1641 | 1668 | |
| 1642 | 1669 | template <class _Tp, class _Allocator> |
| 1643 | deque<_Tp, _Allocator>::deque(const deque& __c, const __identity_t<allocator_type>& __a) | |
| 1670 | deque<_Tp, _Allocator>::deque(const deque& __c, const __type_identity_t<allocator_type>& __a) | |
| 1644 | 1671 | : __base(__a) |
| 1645 | 1672 | { |
| 1646 | 1673 | __append(__c.begin(), __c.end()); |
| ... | ... | @@ -1683,7 +1710,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c) |
| 1683 | 1710 | |
| 1684 | 1711 | template <class _Tp, class _Allocator> |
| 1685 | 1712 | inline |
| 1686 | deque<_Tp, _Allocator>::deque(deque&& __c, const __identity_t<allocator_type>& __a) | |
| 1713 | deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<allocator_type>& __a) | |
| 1687 | 1714 | : __base(_VSTD::move(__c), __a) |
| 1688 | 1715 | { |
| 1689 | 1716 | if (__a != __c.__alloc()) |
| ... | ... | @@ -2236,8 +2263,7 @@ template <class _Tp, class _Allocator> |
| 2236 | 2263 | template <class _InputIter> |
| 2237 | 2264 | typename deque<_Tp, _Allocator>::iterator |
| 2238 | 2265 | deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l, |
| 2239 | typename enable_if<__is_cpp17_input_iterator<_InputIter>::value | |
| 2240 | &&!__is_cpp17_forward_iterator<_InputIter>::value>::type*) | |
| 2266 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIter>::value>::type*) | |
| 2241 | 2267 | { |
| 2242 | 2268 | __split_buffer<value_type, allocator_type&> __buf(__base::__alloc()); |
| 2243 | 2269 | __buf.__construct_at_end(__f, __l); |
| ... | ... | @@ -2249,8 +2275,7 @@ template <class _Tp, class _Allocator> |
| 2249 | 2275 | template <class _ForwardIterator> |
| 2250 | 2276 | typename deque<_Tp, _Allocator>::iterator |
| 2251 | 2277 | deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l, |
| 2252 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value | |
| 2253 | &&!__is_cpp17_bidirectional_iterator<_ForwardIterator>::value>::type*) | |
| 2278 | typename enable_if<__is_exactly_cpp17_forward_iterator<_ForwardIterator>::value>::type*) | |
| 2254 | 2279 | { |
| 2255 | 2280 | size_type __n = _VSTD::distance(__f, __l); |
| 2256 | 2281 | __split_buffer<value_type, allocator_type&> __buf(__n, 0, __base::__alloc()); |
| ... | ... | @@ -2332,8 +2357,7 @@ template <class _Tp, class _Allocator> |
| 2332 | 2357 | template <class _InpIter> |
| 2333 | 2358 | void |
| 2334 | 2359 | deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l, |
| 2335 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value && | |
| 2336 | !__is_cpp17_forward_iterator<_InpIter>::value>::type*) | |
| 2360 | typename enable_if<__is_exactly_cpp17_input_iterator<_InpIter>::value>::type*) | |
| 2337 | 2361 | { |
| 2338 | 2362 | for (; __f != __l; ++__f) |
| 2339 | 2363 | #ifdef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -3019,8 +3043,15 @@ erase_if(deque<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 3019 | 3043 | __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); |
| 3020 | 3044 | return __old_size - __c.size(); |
| 3021 | 3045 | } |
| 3046 | ||
| 3047 | template <> | |
| 3048 | inline constexpr bool __format::__enable_insertable<std::deque<char>> = true; | |
| 3049 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3050 | template <> | |
| 3051 | inline constexpr bool __format::__enable_insertable<std::deque<wchar_t>> = true; | |
| 3022 | 3052 | #endif |
| 3023 | 3053 | |
| 3054 | #endif // _LIBCPP_STD_VER > 17 | |
| 3024 | 3055 | |
| 3025 | 3056 | _LIBCPP_END_NAMESPACE_STD |
| 3026 | 3057 |
lib/libcxx/include/errno.h+1-1| ... | ... | @@ -25,7 +25,7 @@ Macros: |
| 25 | 25 | #include <__config> |
| 26 | 26 | |
| 27 | 27 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 28 | #pragma GCC system_header | |
| 28 | # pragma GCC system_header | |
| 29 | 29 | #endif |
| 30 | 30 | |
| 31 | 31 | #include_next <errno.h> |
lib/libcxx/include/exception+10-13| ... | ... | @@ -76,6 +76,7 @@ template <class E> void rethrow_if_nested(const E& e); |
| 76 | 76 | |
| 77 | 77 | */ |
| 78 | 78 | |
| 79 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 79 | 80 | #include <__availability> |
| 80 | 81 | #include <__config> |
| 81 | 82 | #include <__memory/addressof.h> |
| ... | ... | @@ -89,7 +90,7 @@ template <class E> void rethrow_if_nested(const E& e); |
| 89 | 90 | #endif |
| 90 | 91 | |
| 91 | 92 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 92 | #pragma GCC system_header | |
| 93 | # pragma GCC system_header | |
| 93 | 94 | #endif |
| 94 | 95 | |
| 95 | 96 | namespace std // purposefully not using versioning namespace |
| ... | ... | @@ -189,15 +190,11 @@ make_exception_ptr(_Ep __e) _NOEXCEPT |
| 189 | 190 | |
| 190 | 191 | class _LIBCPP_TYPE_VIS exception_ptr |
| 191 | 192 | { |
| 192 | #if defined(__clang__) | |
| 193 | #pragma clang diagnostic push | |
| 194 | #pragma clang diagnostic ignored "-Wunused-private-field" | |
| 195 | #endif | |
| 193 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 194 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field") | |
| 196 | 195 | void* __ptr1_; |
| 197 | 196 | void* __ptr2_; |
| 198 | #if defined(__clang__) | |
| 199 | #pragma clang diagnostic pop | |
| 200 | #endif | |
| 197 | _LIBCPP_DIAGNOSTIC_POP | |
| 201 | 198 | public: |
| 202 | 199 | exception_ptr() _NOEXCEPT; |
| 203 | 200 | exception_ptr(nullptr_t) _NOEXCEPT; |
| ... | ... | @@ -219,7 +216,7 @@ _LIBCPP_FUNC_VIS void swap(exception_ptr&, exception_ptr&) _NOEXCEPT; |
| 219 | 216 | |
| 220 | 217 | _LIBCPP_FUNC_VIS exception_ptr __copy_exception_ptr(void *__except, const void* __ptr); |
| 221 | 218 | _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; |
| 222 | _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr p); | |
| 219 | _LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); | |
| 223 | 220 | |
| 224 | 221 | // This is a built-in template function which automagically extracts the required |
| 225 | 222 | // information. |
| ... | ... | @@ -304,16 +301,16 @@ throw_with_nested(_Tp&& __t) |
| 304 | 301 | } |
| 305 | 302 | |
| 306 | 303 | template <class _From, class _To> |
| 307 | struct __can_dynamic_cast : public _LIBCPP_BOOL_CONSTANT( | |
| 304 | struct __can_dynamic_cast : _BoolConstant< | |
| 308 | 305 | is_polymorphic<_From>::value && |
| 309 | 306 | (!is_base_of<_To, _From>::value || |
| 310 | is_convertible<const _From*, const _To*>::value)) {}; | |
| 307 | is_convertible<const _From*, const _To*>::value)> {}; | |
| 311 | 308 | |
| 312 | 309 | template <class _Ep> |
| 313 | 310 | inline _LIBCPP_INLINE_VISIBILITY |
| 314 | 311 | void |
| 315 | 312 | rethrow_if_nested(const _Ep& __e, |
| 316 | typename enable_if< __can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0) | |
| 313 | __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value>* = 0) | |
| 317 | 314 | { |
| 318 | 315 | const nested_exception* __nep = dynamic_cast<const nested_exception*>(_VSTD::addressof(__e)); |
| 319 | 316 | if (__nep) |
| ... | ... | @@ -324,7 +321,7 @@ template <class _Ep> |
| 324 | 321 | inline _LIBCPP_INLINE_VISIBILITY |
| 325 | 322 | void |
| 326 | 323 | rethrow_if_nested(const _Ep&, |
| 327 | typename enable_if<!__can_dynamic_cast<_Ep, nested_exception>::value>::type* = 0) | |
| 324 | __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value>* = 0) | |
| 328 | 325 | { |
| 329 | 326 | } |
| 330 | 327 |
lib/libcxx/include/execution+2-1| ... | ... | @@ -10,6 +10,7 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXECUTION |
| 11 | 11 | #define _LIBCPP_EXECUTION |
| 12 | 12 | |
| 13 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 13 | 14 | #include <__config> |
| 14 | 15 | #include <version> |
| 15 | 16 | |
| ... | ... | @@ -18,7 +19,7 @@ |
| 18 | 19 | #endif |
| 19 | 20 | |
| 20 | 21 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 22 | # pragma GCC system_header | |
| 22 | 23 | #endif |
| 23 | 24 | |
| 24 | 25 | #endif // _LIBCPP_EXECUTION |
lib/libcxx/include/experimental/__config+1-14| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | #include <__config> |
| 14 | 14 | |
| 15 | 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | #pragma GCC system_header | |
| 16 | # pragma GCC system_header | |
| 17 | 17 | #endif |
| 18 | 18 | |
| 19 | 19 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental { |
| ... | ... | @@ -32,19 +32,6 @@ |
| 32 | 32 | #define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS } |
| 33 | 33 | #define _VSTD_LFTS_PMR _VSTD_LFTS::pmr |
| 34 | 34 | |
| 35 | #if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM) | |
| 36 | # define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */ | |
| 37 | #else | |
| 38 | # define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM __attribute__((deprecated("std::experimental::filesystem has now been deprecated in favor of C++17's std::filesystem. Please stop using it and start using std::filesystem. This experimental version will be removed in LLVM 11. You can remove this warning by defining the _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM macro."))) | |
| 39 | #endif | |
| 40 | ||
| 41 | #define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ | |
| 42 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM { \ | |
| 43 | inline namespace v1 { | |
| 44 | ||
| 45 | #define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \ | |
| 46 | } } _LIBCPP_END_NAMESPACE_EXPERIMENTAL | |
| 47 | ||
| 48 | 35 | #if !defined(__cpp_coroutines) || __cpp_coroutines < 201703L |
| 49 | 36 | #define _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES |
| 50 | 37 | #endif |
lib/libcxx/include/experimental/__memory+1-2| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL___MEMORY |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL___MEMORY |
| 12 | 12 | |
| 13 | #include <__functional_base> | |
| 14 | 13 | #include <__memory/allocator_arg_t.h> |
| 15 | 14 | #include <__memory/uses_allocator.h> |
| 16 | 15 | #include <experimental/__config> |
| ... | ... | @@ -18,7 +17,7 @@ |
| 18 | 17 | #include <type_traits> |
| 19 | 18 | |
| 20 | 19 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 21 | #pragma GCC system_header | |
| 20 | # pragma GCC system_header | |
| 22 | 21 | #endif |
| 23 | 22 | |
| 24 | 23 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
lib/libcxx/include/experimental/algorithm+2-1| ... | ... | @@ -31,13 +31,14 @@ ForwardIterator search(ForwardIterator first, ForwardIterator last, |
| 31 | 31 | |
| 32 | 32 | */ |
| 33 | 33 | |
| 34 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 34 | 35 | #include <__debug> |
| 35 | 36 | #include <algorithm> |
| 36 | 37 | #include <experimental/__config> |
| 37 | 38 | #include <type_traits> |
| 38 | 39 | |
| 39 | 40 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 40 | #pragma GCC system_header | |
| 41 | # pragma GCC system_header | |
| 41 | 42 | #endif |
| 42 | 43 | |
| 43 | 44 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
lib/libcxx/include/experimental/coroutine+4-11| ... | ... | @@ -45,24 +45,17 @@ template <class P> struct hash<coroutine_handle<P>>; |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__debug> | |
| 48 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 49 | #include <__functional/hash.h> | |
| 50 | #include <__functional/operations.h> | |
| 49 | 51 | #include <cstddef> |
| 50 | 52 | #include <experimental/__config> |
| 51 | #include <functional> | |
| 52 | 53 | #include <memory> // for hash<T*> |
| 53 | 54 | #include <new> |
| 54 | 55 | #include <type_traits> |
| 55 | 56 | |
| 56 | 57 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 57 | #pragma GCC system_header | |
| 58 | #endif | |
| 59 | ||
| 60 | #ifdef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES | |
| 61 | # if defined(_LIBCPP_WARNING) | |
| 62 | _LIBCPP_WARNING("<experimental/coroutine> cannot be used with this compiler") | |
| 63 | # else | |
| 64 | # warning <experimental/coroutine> cannot be used with this compiler | |
| 65 | # endif | |
| 58 | # pragma GCC system_header | |
| 66 | 59 | #endif |
| 67 | 60 | |
| 68 | 61 | #ifndef _LIBCPP_HAS_NO_EXPERIMENTAL_COROUTINES |
lib/libcxx/include/experimental/deque+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_DEQUE |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_DEQUE |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/deque synopsis |
| 14 | 15 | |
| ... | ... | @@ -28,12 +29,13 @@ namespace pmr { |
| 28 | 29 | |
| 29 | 30 | */ |
| 30 | 31 | |
| 32 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 31 | 33 | #include <deque> |
| 32 | 34 | #include <experimental/__config> |
| 33 | 35 | #include <experimental/memory_resource> |
| 34 | 36 | |
| 35 | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | #pragma GCC system_header | |
| 38 | # pragma GCC system_header | |
| 37 | 39 | #endif |
| 38 | 40 | |
| 39 | 41 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/filesystem deleted-256| ... | ... | @@ -1,256 +0,0 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | #ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM | |
| 10 | #define _LIBCPP_EXPERIMENTAL_FILESYSTEM | |
| 11 | /* | |
| 12 | filesystem synopsis | |
| 13 | ||
| 14 | namespace std { namespace experimental { namespace filesystem { inline namespace v1 { | |
| 15 | ||
| 16 | class path; | |
| 17 | ||
| 18 | void swap(path& lhs, path& rhs) noexcept; | |
| 19 | size_t hash_value(const path& p) noexcept; | |
| 20 | ||
| 21 | bool operator==(const path& lhs, const path& rhs) noexcept; | |
| 22 | bool operator!=(const path& lhs, const path& rhs) noexcept; | |
| 23 | bool operator< (const path& lhs, const path& rhs) noexcept; | |
| 24 | bool operator<=(const path& lhs, const path& rhs) noexcept; | |
| 25 | bool operator> (const path& lhs, const path& rhs) noexcept; | |
| 26 | bool operator>=(const path& lhs, const path& rhs) noexcept; | |
| 27 | ||
| 28 | path operator/ (const path& lhs, const path& rhs); | |
| 29 | ||
| 30 | // fs.path.io operators are friends of path. | |
| 31 | template <class charT, class traits> | |
| 32 | friend basic_ostream<charT, traits>& | |
| 33 | operator<<(basic_ostream<charT, traits>& os, const path& p); | |
| 34 | ||
| 35 | template <class charT, class traits> | |
| 36 | friend basic_istream<charT, traits>& | |
| 37 | operator>>(basic_istream<charT, traits>& is, path& p); | |
| 38 | ||
| 39 | template <class Source> | |
| 40 | path u8path(const Source& source); | |
| 41 | template <class InputIterator> | |
| 42 | path u8path(InputIterator first, InputIterator last); | |
| 43 | ||
| 44 | class filesystem_error; | |
| 45 | class directory_entry; | |
| 46 | ||
| 47 | class directory_iterator; | |
| 48 | ||
| 49 | // enable directory_iterator range-based for statements | |
| 50 | directory_iterator begin(directory_iterator iter) noexcept; | |
| 51 | directory_iterator end(const directory_iterator&) noexcept; | |
| 52 | ||
| 53 | class recursive_directory_iterator; | |
| 54 | ||
| 55 | // enable recursive_directory_iterator range-based for statements | |
| 56 | recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; | |
| 57 | recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; | |
| 58 | ||
| 59 | class file_status; | |
| 60 | ||
| 61 | struct space_info | |
| 62 | { | |
| 63 | uintmax_t capacity; | |
| 64 | uintmax_t free; | |
| 65 | uintmax_t available; | |
| 66 | }; | |
| 67 | ||
| 68 | enum class file_type; | |
| 69 | enum class perms; | |
| 70 | enum class perm_options; | |
| 71 | enum class copy_options; | |
| 72 | enum class directory_options; | |
| 73 | ||
| 74 | typedef chrono::time_point<trivial-clock> file_time_type; | |
| 75 | ||
| 76 | // operational functions | |
| 77 | ||
| 78 | path absolute(const path& p); | |
| 79 | path absolute(const path& p, error_code &ec); | |
| 80 | ||
| 81 | path canonical(const path& p); | |
| 82 | path canonical(const path& p, error_code& ec); | |
| 83 | ||
| 84 | void copy(const path& from, const path& to); | |
| 85 | void copy(const path& from, const path& to, error_code& ec); | |
| 86 | void copy(const path& from, const path& to, copy_options options); | |
| 87 | void copy(const path& from, const path& to, copy_options options, | |
| 88 | error_code& ec); | |
| 89 | ||
| 90 | bool copy_file(const path& from, const path& to); | |
| 91 | bool copy_file(const path& from, const path& to, error_code& ec); | |
| 92 | bool copy_file(const path& from, const path& to, copy_options option); | |
| 93 | bool copy_file(const path& from, const path& to, copy_options option, | |
| 94 | error_code& ec); | |
| 95 | ||
| 96 | void copy_symlink(const path& existing_symlink, const path& new_symlink); | |
| 97 | void copy_symlink(const path& existing_symlink, const path& new_symlink, | |
| 98 | error_code& ec) noexcept; | |
| 99 | ||
| 100 | bool create_directories(const path& p); | |
| 101 | bool create_directories(const path& p, error_code& ec); | |
| 102 | ||
| 103 | bool create_directory(const path& p); | |
| 104 | bool create_directory(const path& p, error_code& ec) noexcept; | |
| 105 | ||
| 106 | bool create_directory(const path& p, const path& attributes); | |
| 107 | bool create_directory(const path& p, const path& attributes, | |
| 108 | error_code& ec) noexcept; | |
| 109 | ||
| 110 | void create_directory_symlink(const path& to, const path& new_symlink); | |
| 111 | void create_directory_symlink(const path& to, const path& new_symlink, | |
| 112 | error_code& ec) noexcept; | |
| 113 | ||
| 114 | void create_hard_link(const path& to, const path& new_hard_link); | |
| 115 | void create_hard_link(const path& to, const path& new_hard_link, | |
| 116 | error_code& ec) noexcept; | |
| 117 | ||
| 118 | void create_symlink(const path& to, const path& new_symlink); | |
| 119 | void create_symlink(const path& to, const path& new_symlink, | |
| 120 | error_code& ec) noexcept; | |
| 121 | ||
| 122 | path current_path(); | |
| 123 | path current_path(error_code& ec); | |
| 124 | void current_path(const path& p); | |
| 125 | void current_path(const path& p, error_code& ec) noexcept; | |
| 126 | ||
| 127 | bool exists(file_status s) noexcept; | |
| 128 | bool exists(const path& p); | |
| 129 | bool exists(const path& p, error_code& ec) noexcept; | |
| 130 | ||
| 131 | bool equivalent(const path& p1, const path& p2); | |
| 132 | bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; | |
| 133 | ||
| 134 | uintmax_t file_size(const path& p); | |
| 135 | uintmax_t file_size(const path& p, error_code& ec) noexcept; | |
| 136 | ||
| 137 | uintmax_t hard_link_count(const path& p); | |
| 138 | uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; | |
| 139 | ||
| 140 | bool is_block_file(file_status s) noexcept; | |
| 141 | bool is_block_file(const path& p); | |
| 142 | bool is_block_file(const path& p, error_code& ec) noexcept; | |
| 143 | ||
| 144 | bool is_character_file(file_status s) noexcept; | |
| 145 | bool is_character_file(const path& p); | |
| 146 | bool is_character_file(const path& p, error_code& ec) noexcept; | |
| 147 | ||
| 148 | bool is_directory(file_status s) noexcept; | |
| 149 | bool is_directory(const path& p); | |
| 150 | bool is_directory(const path& p, error_code& ec) noexcept; | |
| 151 | ||
| 152 | bool is_empty(const path& p); | |
| 153 | bool is_empty(const path& p, error_code& ec) noexcept; | |
| 154 | ||
| 155 | bool is_fifo(file_status s) noexcept; | |
| 156 | bool is_fifo(const path& p); | |
| 157 | bool is_fifo(const path& p, error_code& ec) noexcept; | |
| 158 | ||
| 159 | bool is_other(file_status s) noexcept; | |
| 160 | bool is_other(const path& p); | |
| 161 | bool is_other(const path& p, error_code& ec) noexcept; | |
| 162 | ||
| 163 | bool is_regular_file(file_status s) noexcept; | |
| 164 | bool is_regular_file(const path& p); | |
| 165 | bool is_regular_file(const path& p, error_code& ec) noexcept; | |
| 166 | ||
| 167 | bool is_socket(file_status s) noexcept; | |
| 168 | bool is_socket(const path& p); | |
| 169 | bool is_socket(const path& p, error_code& ec) noexcept; | |
| 170 | ||
| 171 | bool is_symlink(file_status s) noexcept; | |
| 172 | bool is_symlink(const path& p); | |
| 173 | bool is_symlink(const path& p, error_code& ec) noexcept; | |
| 174 | ||
| 175 | file_time_type last_write_time(const path& p); | |
| 176 | file_time_type last_write_time(const path& p, error_code& ec) noexcept; | |
| 177 | void last_write_time(const path& p, file_time_type new_time); | |
| 178 | void last_write_time(const path& p, file_time_type new_time, | |
| 179 | error_code& ec) noexcept; | |
| 180 | ||
| 181 | void permissions(const path& p, perms prms, | |
| 182 | perm_options opts=perm_options::replace); | |
| 183 | void permissions(const path& p, perms prms, error_code& ec) noexcept; | |
| 184 | void permissions(const path& p, perms prms, perm_options opts, | |
| 185 | error_code& ec); | |
| 186 | ||
| 187 | path proximate(const path& p, error_code& ec); | |
| 188 | path proximate(const path& p, const path& base = current_path()); | |
| 189 | path proximate(const path& p, const path& base, error_code &ec); | |
| 190 | ||
| 191 | path read_symlink(const path& p); | |
| 192 | path read_symlink(const path& p, error_code& ec); | |
| 193 | ||
| 194 | path relative(const path& p, error_code& ec); | |
| 195 | path relative(const path& p, const path& base=current_path()); | |
| 196 | path relative(const path& p, const path& base, error_code& ec); | |
| 197 | ||
| 198 | bool remove(const path& p); | |
| 199 | bool remove(const path& p, error_code& ec) noexcept; | |
| 200 | ||
| 201 | uintmax_t remove_all(const path& p); | |
| 202 | uintmax_t remove_all(const path& p, error_code& ec); | |
| 203 | ||
| 204 | void rename(const path& from, const path& to); | |
| 205 | void rename(const path& from, const path& to, error_code& ec) noexcept; | |
| 206 | ||
| 207 | void resize_file(const path& p, uintmax_t size); | |
| 208 | void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; | |
| 209 | ||
| 210 | space_info space(const path& p); | |
| 211 | space_info space(const path& p, error_code& ec) noexcept; | |
| 212 | ||
| 213 | file_status status(const path& p); | |
| 214 | file_status status(const path& p, error_code& ec) noexcept; | |
| 215 | ||
| 216 | bool status_known(file_status s) noexcept; | |
| 217 | ||
| 218 | file_status symlink_status(const path& p); | |
| 219 | file_status symlink_status(const path& p, error_code& ec) noexcept; | |
| 220 | ||
| 221 | path temp_directory_path(); | |
| 222 | path temp_directory_path(error_code& ec); | |
| 223 | ||
| 224 | path weakly_canonical(path const& p); | |
| 225 | path weakly_canonical(path const& p, error_code& ec); | |
| 226 | ||
| 227 | ||
| 228 | } } } } // namespaces std::experimental::filesystem::v1 | |
| 229 | ||
| 230 | */ | |
| 231 | ||
| 232 | #include <experimental/__config> | |
| 233 | #include <filesystem> | |
| 234 | ||
| 235 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 236 | #pragma GCC system_header | |
| 237 | #endif | |
| 238 | ||
| 239 | _LIBCPP_PUSH_MACROS | |
| 240 | #include <__undef_macros> | |
| 241 | ||
| 242 | #ifndef _LIBCPP_CXX03_LANG | |
| 243 | ||
| 244 | #define __cpp_lib_experimental_filesystem 201406 | |
| 245 | ||
| 246 | _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM | |
| 247 | ||
| 248 | using namespace _VSTD_FS; | |
| 249 | ||
| 250 | _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM | |
| 251 | ||
| 252 | #endif // !_LIBCPP_CXX03_LANG | |
| 253 | ||
| 254 | _LIBCPP_POP_MACROS | |
| 255 | ||
| 256 | #endif // _LIBCPP_EXPERIMENTAL_FILESYSTEM |
lib/libcxx/include/experimental/forward_list+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_FORWARD_LIST |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_FORWARD_LIST |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/forward_list synopsis |
| 14 | 15 | |
| ... | ... | @@ -28,12 +29,13 @@ namespace pmr { |
| 28 | 29 | |
| 29 | 30 | */ |
| 30 | 31 | |
| 32 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 31 | 33 | #include <experimental/__config> |
| 32 | 34 | #include <experimental/memory_resource> |
| 33 | 35 | #include <forward_list> |
| 34 | 36 | |
| 35 | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | #pragma GCC system_header | |
| 38 | # pragma GCC system_header | |
| 37 | 39 | #endif |
| 38 | 40 | |
| 39 | 41 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/functional+30-51| ... | ... | @@ -18,29 +18,6 @@ |
| 18 | 18 | namespace std { |
| 19 | 19 | namespace experimental { |
| 20 | 20 | inline namespace fundamentals_v1 { |
| 21 | ||
| 22 | // See C++14 20.9.9, Function object binders | |
| 23 | template <class T> constexpr bool is_bind_expression_v | |
| 24 | = is_bind_expression<T>::value; | |
| 25 | template <class T> constexpr int is_placeholder_v | |
| 26 | = is_placeholder<T>::value; | |
| 27 | ||
| 28 | // 4.2, Class template function | |
| 29 | template<class> class function; // undefined | |
| 30 | template<class R, class... ArgTypes> class function<R(ArgTypes...)>; | |
| 31 | ||
| 32 | template<class R, class... ArgTypes> | |
| 33 | void swap(function<R(ArgTypes...)>&, function<R(ArgTypes...)>&); | |
| 34 | ||
| 35 | template<class R, class... ArgTypes> | |
| 36 | bool operator==(const function<R(ArgTypes...)>&, nullptr_t) noexcept; | |
| 37 | template<class R, class... ArgTypes> | |
| 38 | bool operator==(nullptr_t, const function<R(ArgTypes...)>&) noexcept; | |
| 39 | template<class R, class... ArgTypes> | |
| 40 | bool operator!=(const function<R(ArgTypes...)>&, nullptr_t) noexcept; | |
| 41 | template<class R, class... ArgTypes> | |
| 42 | bool operator!=(nullptr_t, const function<R(ArgTypes...)>&) noexcept; | |
| 43 | ||
| 44 | 21 | // 4.3, Searchers |
| 45 | 22 | template<class ForwardIterator, class BinaryPredicate = equal_to<>> |
| 46 | 23 | class default_searcher; |
| ... | ... | @@ -79,16 +56,14 @@ inline namespace fundamentals_v1 { |
| 79 | 56 | } // namespace fundamentals_v1 |
| 80 | 57 | } // namespace experimental |
| 81 | 58 | |
| 82 | template<class R, class... ArgTypes, class Alloc> | |
| 83 | struct uses_allocator<experimental::function<R(ArgTypes...)>, Alloc>; | |
| 84 | ||
| 85 | 59 | } // namespace std |
| 86 | 60 | |
| 87 | 61 | */ |
| 88 | 62 | |
| 63 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 89 | 64 | #include <__debug> |
| 65 | #include <__functional/identity.h> | |
| 90 | 66 | #include <__memory/uses_allocator.h> |
| 91 | #include <algorithm> | |
| 92 | 67 | #include <array> |
| 93 | 68 | #include <experimental/__config> |
| 94 | 69 | #include <functional> |
| ... | ... | @@ -97,7 +72,7 @@ inline namespace fundamentals_v1 { |
| 97 | 72 | #include <vector> |
| 98 | 73 | |
| 99 | 74 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 100 | #pragma GCC system_header | |
| 75 | # pragma GCC system_header | |
| 101 | 76 | #endif |
| 102 | 77 | |
| 103 | 78 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -105,10 +80,20 @@ _LIBCPP_PUSH_MACROS |
| 105 | 80 | |
| 106 | 81 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
| 107 | 82 | |
| 83 | #ifdef _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_SEARCHERS | |
| 84 | # define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER | |
| 85 | # define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER | |
| 86 | # define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER | |
| 87 | #else | |
| 88 | # define _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::default_searcher will be removed in LLVM 17. Use std::default_searcher instead") | |
| 89 | # define _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_searcher will be removed in LLVM 17. Use std::boyer_moore_searcher instead") | |
| 90 | # define _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_DEPRECATED_("std::exprerimental::boyer_moore_horspool_searcher will be removed in LLVM 17. Use std::boyer_moore_horspool_searcher instead") | |
| 91 | #endif | |
| 92 | ||
| 108 | 93 | #if _LIBCPP_STD_VER > 11 |
| 109 | 94 | // default searcher |
| 110 | 95 | template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> |
| 111 | class _LIBCPP_TEMPLATE_VIS default_searcher { | |
| 96 | class _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_TEMPLATE_VIS default_searcher { | |
| 112 | 97 | public: |
| 113 | 98 | _LIBCPP_INLINE_VISIBILITY |
| 114 | 99 | default_searcher(_ForwardIterator __f, _ForwardIterator __l, |
| ... | ... | @@ -120,9 +105,8 @@ public: |
| 120 | 105 | pair<_ForwardIterator2, _ForwardIterator2> |
| 121 | 106 | operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const |
| 122 | 107 | { |
| 123 | return _VSTD::__search(__f, __l, __first_, __last_, __pred_, | |
| 124 | typename iterator_traits<_ForwardIterator>::iterator_category(), | |
| 125 | typename iterator_traits<_ForwardIterator2>::iterator_category()); | |
| 108 | auto __proj = __identity(); | |
| 109 | return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj); | |
| 126 | 110 | } |
| 127 | 111 | |
| 128 | 112 | private: |
| ... | ... | @@ -132,7 +116,7 @@ private: |
| 132 | 116 | }; |
| 133 | 117 | |
| 134 | 118 | template<class _ForwardIterator, class _BinaryPredicate = equal_to<>> |
| 135 | _LIBCPP_INLINE_VISIBILITY | |
| 119 | _LIBCPP_DEPRECATED_DEFAULT_SEARCHER _LIBCPP_INLINE_VISIBILITY | |
| 136 | 120 | default_searcher<_ForwardIterator, _BinaryPredicate> |
| 137 | 121 | make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ()) |
| 138 | 122 | { |
| ... | ... | @@ -144,7 +128,6 @@ template<class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*u |
| 144 | 128 | // General case for BM data searching; use a map |
| 145 | 129 | template<class _Key, typename _Value, class _Hash, class _BinaryPredicate> |
| 146 | 130 | class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> { |
| 147 | public: // TODO private: | |
| 148 | 131 | typedef _Value value_type; |
| 149 | 132 | typedef _Key key_type; |
| 150 | 133 | |
| ... | ... | @@ -179,7 +162,7 @@ private: |
| 179 | 162 | typedef _Key key_type; |
| 180 | 163 | |
| 181 | 164 | typedef typename make_unsigned<key_type>::type unsigned_key_type; |
| 182 | typedef std::array<value_type, numeric_limits<unsigned_key_type>::max()> skip_map; | |
| 165 | typedef std::array<value_type, 256> skip_map; | |
| 183 | 166 | skip_map __table; |
| 184 | 167 | |
| 185 | 168 | public: |
| ... | ... | @@ -206,7 +189,7 @@ public: |
| 206 | 189 | template <class _RandomAccessIterator1, |
| 207 | 190 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, |
| 208 | 191 | class _BinaryPredicate = equal_to<>> |
| 209 | class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher { | |
| 192 | class _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_TEMPLATE_VIS boyer_moore_searcher { | |
| 210 | 193 | private: |
| 211 | 194 | typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; |
| 212 | 195 | typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; |
| ... | ... | @@ -236,11 +219,9 @@ public: |
| 236 | 219 | pair<_RandomAccessIterator2, _RandomAccessIterator2> |
| 237 | 220 | operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const |
| 238 | 221 | { |
| 239 | static_assert ( std::is_same< | |
| 240 | typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type, | |
| 241 | typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type | |
| 242 | >::value, | |
| 243 | "Corpus and Pattern iterators must point to the same type" ); | |
| 222 | static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type, | |
| 223 | typename iterator_traits<_RandomAccessIterator2>::value_type>::value, | |
| 224 | "Corpus and Pattern iterators must point to the same type"); | |
| 244 | 225 | |
| 245 | 226 | if (__f == __l ) return make_pair(__l, __l); // empty corpus |
| 246 | 227 | if (__first_ == __last_) return make_pair(__f, __f); // empty pattern |
| ... | ... | @@ -253,7 +234,7 @@ public: |
| 253 | 234 | return this->__search(__f, __l); |
| 254 | 235 | } |
| 255 | 236 | |
| 256 | public: // TODO private: | |
| 237 | private: | |
| 257 | 238 | _RandomAccessIterator1 __first_; |
| 258 | 239 | _RandomAccessIterator1 __last_; |
| 259 | 240 | _BinaryPredicate __pred_; |
| ... | ... | @@ -320,7 +301,7 @@ public: // TODO private: |
| 320 | 301 | vector<difference_type> & __suffix = *__suffix_.get(); |
| 321 | 302 | if (__count > 0) |
| 322 | 303 | { |
| 323 | vector<value_type> __scratch(__count); | |
| 304 | vector<difference_type> __scratch(__count); | |
| 324 | 305 | |
| 325 | 306 | __compute_bm_prefix(__f, __l, __pred, __scratch); |
| 326 | 307 | for ( size_t __i = 0; __i <= __count; __i++ ) |
| ... | ... | @@ -345,7 +326,7 @@ public: // TODO private: |
| 345 | 326 | template<class _RandomAccessIterator, |
| 346 | 327 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>, |
| 347 | 328 | class _BinaryPredicate = equal_to<>> |
| 348 | _LIBCPP_INLINE_VISIBILITY | |
| 329 | _LIBCPP_DEPRECATED_BOYER_MOORE_SEARCHER _LIBCPP_INLINE_VISIBILITY | |
| 349 | 330 | boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> |
| 350 | 331 | make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, |
| 351 | 332 | _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) |
| ... | ... | @@ -357,7 +338,7 @@ make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, |
| 357 | 338 | template <class _RandomAccessIterator1, |
| 358 | 339 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>, |
| 359 | 340 | class _BinaryPredicate = equal_to<>> |
| 360 | class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher { | |
| 341 | class _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher { | |
| 361 | 342 | private: |
| 362 | 343 | typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; |
| 363 | 344 | typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; |
| ... | ... | @@ -388,11 +369,9 @@ public: |
| 388 | 369 | pair<_RandomAccessIterator2, _RandomAccessIterator2> |
| 389 | 370 | operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const |
| 390 | 371 | { |
| 391 | static_assert ( std::is_same< | |
| 392 | typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type>::type, | |
| 393 | typename std::__uncvref<typename std::iterator_traits<_RandomAccessIterator2>::value_type>::type | |
| 394 | >::value, | |
| 395 | "Corpus and Pattern iterators must point to the same type" ); | |
| 372 | static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type, | |
| 373 | typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value, | |
| 374 | "Corpus and Pattern iterators must point to the same type"); | |
| 396 | 375 | |
| 397 | 376 | if (__f == __l ) return make_pair(__l, __l); // empty corpus |
| 398 | 377 | if (__first_ == __last_) return make_pair(__f, __f); // empty pattern |
| ... | ... | @@ -440,7 +419,7 @@ private: |
| 440 | 419 | template<class _RandomAccessIterator, |
| 441 | 420 | class _Hash = hash<typename iterator_traits<_RandomAccessIterator>::value_type>, |
| 442 | 421 | class _BinaryPredicate = equal_to<>> |
| 443 | _LIBCPP_INLINE_VISIBILITY | |
| 422 | _LIBCPP_DEPRECATED_BOYER_MOORE_HORSPOOL_SEARCHER _LIBCPP_INLINE_VISIBILITY | |
| 444 | 423 | boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> |
| 445 | 424 | make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, |
| 446 | 425 | _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) |
lib/libcxx/include/experimental/iterator+3-1| ... | ... | @@ -52,14 +52,16 @@ namespace std { |
| 52 | 52 | |
| 53 | 53 | */ |
| 54 | 54 | |
| 55 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 55 | 56 | #include <__memory/addressof.h> |
| 56 | 57 | #include <__utility/forward.h> |
| 57 | 58 | #include <__utility/move.h> |
| 58 | 59 | #include <experimental/__config> |
| 60 | #include <iosfwd> // char_traits | |
| 59 | 61 | #include <iterator> |
| 60 | 62 | |
| 61 | 63 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 62 | #pragma GCC system_header | |
| 64 | # pragma GCC system_header | |
| 63 | 65 | #endif |
| 64 | 66 | |
| 65 | 67 | #if _LIBCPP_STD_VER > 11 |
lib/libcxx/include/experimental/list+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_LIST |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_LIST |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/list synopsis |
| 14 | 15 | |
| ... | ... | @@ -28,12 +29,13 @@ namespace pmr { |
| 28 | 29 | |
| 29 | 30 | */ |
| 30 | 31 | |
| 32 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 31 | 33 | #include <experimental/__config> |
| 32 | 34 | #include <experimental/memory_resource> |
| 33 | 35 | #include <list> |
| 34 | 36 | |
| 35 | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | #pragma GCC system_header | |
| 38 | # pragma GCC system_header | |
| 37 | 39 | #endif |
| 38 | 40 | |
| 39 | 41 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/map+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_MAP |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_MAP |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/map synopsis |
| 14 | 15 | |
| ... | ... | @@ -33,12 +34,13 @@ namespace pmr { |
| 33 | 34 | |
| 34 | 35 | */ |
| 35 | 36 | |
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 36 | 38 | #include <experimental/__config> |
| 37 | 39 | #include <experimental/memory_resource> |
| 38 | 40 | #include <map> |
| 39 | 41 | |
| 40 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | #pragma GCC system_header | |
| 43 | # pragma GCC system_header | |
| 42 | 44 | #endif |
| 43 | 45 | |
| 44 | 46 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/memory_resource+3-3| ... | ... | @@ -64,8 +64,9 @@ namespace pmr { |
| 64 | 64 | |
| 65 | 65 | */ |
| 66 | 66 | |
| 67 | #include <__debug> | |
| 67 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 68 | 68 | #include <__tuple> |
| 69 | #include <__utility/move.h> | |
| 69 | 70 | #include <cstddef> |
| 70 | 71 | #include <cstdlib> |
| 71 | 72 | #include <experimental/__config> |
| ... | ... | @@ -75,10 +76,9 @@ namespace pmr { |
| 75 | 76 | #include <new> |
| 76 | 77 | #include <stdexcept> |
| 77 | 78 | #include <type_traits> |
| 78 | #include <utility> | |
| 79 | 79 | |
| 80 | 80 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 81 | #pragma GCC system_header | |
| 81 | # pragma GCC system_header | |
| 82 | 82 | #endif |
| 83 | 83 | |
| 84 | 84 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/experimental/propagate_const+7-3| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_PROPAGATE_CONST |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | propagate_const synopsis |
| 14 | 15 | |
| ... | ... | @@ -106,13 +107,16 @@ |
| 106 | 107 | |
| 107 | 108 | */ |
| 108 | 109 | |
| 110 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 111 | #include <__functional/operations.h> | |
| 112 | #include <__utility/forward.h> | |
| 113 | #include <__utility/move.h> | |
| 114 | #include <__utility/swap.h> | |
| 109 | 115 | #include <experimental/__config> |
| 110 | #include <functional> | |
| 111 | 116 | #include <type_traits> |
| 112 | #include <utility> | |
| 113 | 117 | |
| 114 | 118 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 115 | #pragma GCC system_header | |
| 119 | # pragma GCC system_header | |
| 116 | 120 | #endif |
| 117 | 121 | |
| 118 | 122 | #if _LIBCPP_STD_VER > 11 |
lib/libcxx/include/experimental/regex+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_REGEX |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_REGEX |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/regex synopsis |
| 14 | 15 | |
| ... | ... | @@ -35,13 +36,14 @@ namespace pmr { |
| 35 | 36 | |
| 36 | 37 | */ |
| 37 | 38 | |
| 39 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 38 | 40 | #include <experimental/__config> |
| 39 | 41 | #include <experimental/memory_resource> |
| 40 | 42 | #include <experimental/string> |
| 41 | 43 | #include <regex> |
| 42 | 44 | |
| 43 | 45 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 44 | #pragma GCC system_header | |
| 46 | # pragma GCC system_header | |
| 45 | 47 | #endif |
| 46 | 48 | |
| 47 | 49 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/set+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_SET |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_SET |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/set synopsis |
| 14 | 15 | |
| ... | ... | @@ -33,12 +34,13 @@ namespace pmr { |
| 33 | 34 | |
| 34 | 35 | */ |
| 35 | 36 | |
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 36 | 38 | #include <experimental/__config> |
| 37 | 39 | #include <experimental/memory_resource> |
| 38 | 40 | #include <set> |
| 39 | 41 | |
| 40 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | #pragma GCC system_header | |
| 43 | # pragma GCC system_header | |
| 42 | 44 | #endif |
| 43 | 45 | |
| 44 | 46 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/simd+19-9| ... | ... | @@ -649,14 +649,20 @@ public: |
| 649 | 649 | |
| 650 | 650 | */ |
| 651 | 651 | |
| 652 | #include <algorithm> | |
| 652 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 653 | #include <__functional/operations.h> | |
| 653 | 654 | #include <array> |
| 654 | 655 | #include <cstddef> |
| 655 | 656 | #include <experimental/__config> |
| 656 | #include <functional> | |
| 657 | #include <tuple> | |
| 658 | ||
| 659 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 660 | # include <algorithm> | |
| 661 | # include <functional> | |
| 662 | #endif | |
| 657 | 663 | |
| 658 | 664 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 659 | #pragma GCC system_header | |
| 665 | # pragma GCC system_header | |
| 660 | 666 | #endif |
| 661 | 667 | |
| 662 | 668 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -1236,32 +1242,32 @@ _Tp reduce(const simd<_Tp, _Abi>&, _BinaryOp = _BinaryOp()); |
| 1236 | 1242 | template <class _MaskType, class _SimdType, class _BinaryOp> |
| 1237 | 1243 | typename _SimdType::value_type |
| 1238 | 1244 | reduce(const const_where_expression<_MaskType, _SimdType>&, |
| 1239 | typename _SimdType::value_type neutral_element, _BinaryOp binary_op); | |
| 1245 | typename _SimdType::value_type __neutral_element, _BinaryOp); | |
| 1240 | 1246 | |
| 1241 | 1247 | template <class _MaskType, class _SimdType> |
| 1242 | 1248 | typename _SimdType::value_type |
| 1243 | 1249 | reduce(const const_where_expression<_MaskType, _SimdType>&, |
| 1244 | plus<typename _SimdType::value_type> binary_op = {}); | |
| 1250 | plus<typename _SimdType::value_type> = {}); | |
| 1245 | 1251 | |
| 1246 | 1252 | template <class _MaskType, class _SimdType> |
| 1247 | 1253 | typename _SimdType::value_type |
| 1248 | 1254 | reduce(const const_where_expression<_MaskType, _SimdType>&, |
| 1249 | multiplies<typename _SimdType::value_type> binary_op); | |
| 1255 | multiplies<typename _SimdType::value_type>); | |
| 1250 | 1256 | |
| 1251 | 1257 | template <class _MaskType, class _SimdType> |
| 1252 | 1258 | typename _SimdType::value_type |
| 1253 | 1259 | reduce(const const_where_expression<_MaskType, _SimdType>&, |
| 1254 | bit_and<typename _SimdType::value_type> binary_op); | |
| 1260 | bit_and<typename _SimdType::value_type>); | |
| 1255 | 1261 | |
| 1256 | 1262 | template <class _MaskType, class _SimdType> |
| 1257 | 1263 | typename _SimdType::value_type |
| 1258 | 1264 | reduce(const const_where_expression<_MaskType, _SimdType>&, |
| 1259 | bit_or<typename _SimdType::value_type> binary_op); | |
| 1265 | bit_or<typename _SimdType::value_type>); | |
| 1260 | 1266 | |
| 1261 | 1267 | template <class _MaskType, class _SimdType> |
| 1262 | 1268 | typename _SimdType::value_type |
| 1263 | 1269 | reduce(const const_where_expression<_MaskType, _SimdType>&, |
| 1264 | bit_xor<typename _SimdType::value_type> binary_op); | |
| 1270 | bit_xor<typename _SimdType::value_type>); | |
| 1265 | 1271 | |
| 1266 | 1272 | template <class _Tp, class _Abi> |
| 1267 | 1273 | _Tp hmin(const simd<_Tp, _Abi>&); |
| ... | ... | @@ -1471,6 +1477,7 @@ public: |
| 1471 | 1477 | simd operator+() const; |
| 1472 | 1478 | simd operator-() const; |
| 1473 | 1479 | |
| 1480 | #if 0 | |
| 1474 | 1481 | // binary operators [simd.binary] |
| 1475 | 1482 | friend simd operator+(const simd&, const simd&); |
| 1476 | 1483 | friend simd operator-(const simd&, const simd&); |
| ... | ... | @@ -1507,6 +1514,7 @@ public: |
| 1507 | 1514 | friend mask_type operator<=(const simd&, const simd&); |
| 1508 | 1515 | friend mask_type operator>(const simd&, const simd&); |
| 1509 | 1516 | friend mask_type operator<(const simd&, const simd&); |
| 1517 | #endif | |
| 1510 | 1518 | }; |
| 1511 | 1519 | |
| 1512 | 1520 | // [simd.mask.class] |
| ... | ... | @@ -1546,6 +1554,7 @@ public: |
| 1546 | 1554 | // unary operators [simd.mask.unary] |
| 1547 | 1555 | simd_mask operator!() const noexcept; |
| 1548 | 1556 | |
| 1557 | #if 0 | |
| 1549 | 1558 | // simd_mask binary operators [simd.mask.binary] |
| 1550 | 1559 | friend simd_mask operator&&(const simd_mask&, const simd_mask&) noexcept; |
| 1551 | 1560 | friend simd_mask operator||(const simd_mask&, const simd_mask&) noexcept; |
| ... | ... | @@ -1561,6 +1570,7 @@ public: |
| 1561 | 1570 | // simd_mask compares [simd.mask.comparison] |
| 1562 | 1571 | friend simd_mask operator==(const simd_mask&, const simd_mask&) noexcept; |
| 1563 | 1572 | friend simd_mask operator!=(const simd_mask&, const simd_mask&) noexcept; |
| 1573 | #endif | |
| 1564 | 1574 | }; |
| 1565 | 1575 | |
| 1566 | 1576 | #endif // _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/experimental/string+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_STRING |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_STRING |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/string synopsis |
| 14 | 15 | |
| ... | ... | @@ -37,12 +38,13 @@ namespace pmr { |
| 37 | 38 | |
| 38 | 39 | */ |
| 39 | 40 | |
| 41 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 40 | 42 | #include <experimental/__config> |
| 41 | 43 | #include <experimental/memory_resource> |
| 42 | 44 | #include <string> |
| 43 | 45 | |
| 44 | 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 45 | #pragma GCC system_header | |
| 47 | # pragma GCC system_header | |
| 46 | 48 | #endif |
| 47 | 49 | |
| 48 | 50 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/type_traits+2-1| ... | ... | @@ -68,6 +68,7 @@ inline namespace fundamentals_v1 { |
| 68 | 68 | |
| 69 | 69 | */ |
| 70 | 70 | |
| 71 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 71 | 72 | #include <experimental/__config> |
| 72 | 73 | |
| 73 | 74 | #if _LIBCPP_STD_VER > 11 |
| ... | ... | @@ -76,7 +77,7 @@ inline namespace fundamentals_v1 { |
| 76 | 77 | #include <type_traits> |
| 77 | 78 | |
| 78 | 79 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 79 | #pragma GCC system_header | |
| 80 | # pragma GCC system_header | |
| 80 | 81 | #endif |
| 81 | 82 | |
| 82 | 83 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
lib/libcxx/include/experimental/unordered_map+11-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_MAP |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_UNORDERED_MAP |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/unordered_map synopsis |
| 14 | 15 | |
| ... | ... | @@ -39,12 +40,21 @@ namespace pmr { |
| 39 | 40 | |
| 40 | 41 | */ |
| 41 | 42 | |
| 43 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 42 | 44 | #include <experimental/__config> |
| 43 | 45 | #include <experimental/memory_resource> |
| 44 | 46 | #include <unordered_map> |
| 45 | 47 | |
| 48 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 49 | # include <algorithm> | |
| 50 | # include <array> | |
| 51 | # include <bit> | |
| 52 | # include <functional> | |
| 53 | # include <vector> | |
| 54 | #endif | |
| 55 | ||
| 46 | 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 47 | #pragma GCC system_header | |
| 57 | # pragma GCC system_header | |
| 48 | 58 | #endif |
| 49 | 59 | |
| 50 | 60 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/unordered_set+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_UNORDERED_SET |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_UNORDERED_SET |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/unordered_set synopsis |
| 14 | 15 | |
| ... | ... | @@ -33,12 +34,13 @@ namespace pmr { |
| 33 | 34 | |
| 34 | 35 | */ |
| 35 | 36 | |
| 37 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 36 | 38 | #include <experimental/__config> |
| 37 | 39 | #include <experimental/memory_resource> |
| 38 | 40 | #include <unordered_set> |
| 39 | 41 | |
| 40 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 41 | #pragma GCC system_header | |
| 43 | # pragma GCC system_header | |
| 42 | 44 | #endif |
| 43 | 45 | |
| 44 | 46 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/experimental/utility+2-1| ... | ... | @@ -30,11 +30,12 @@ inline namespace fundamentals_v1 { |
| 30 | 30 | |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 33 | 34 | #include <experimental/__config> |
| 34 | 35 | #include <utility> |
| 35 | 36 | |
| 36 | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 37 | #pragma GCC system_header | |
| 38 | # pragma GCC system_header | |
| 38 | 39 | #endif |
| 39 | 40 | |
| 40 | 41 | _LIBCPP_BEGIN_NAMESPACE_LFTS |
lib/libcxx/include/experimental/vector+3-1| ... | ... | @@ -9,6 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | #ifndef _LIBCPP_EXPERIMENTAL_VECTOR |
| 11 | 11 | #define _LIBCPP_EXPERIMENTAL_VECTOR |
| 12 | ||
| 12 | 13 | /* |
| 13 | 14 | experimental/vector synopsis |
| 14 | 15 | |
| ... | ... | @@ -28,12 +29,13 @@ namespace pmr { |
| 28 | 29 | |
| 29 | 30 | */ |
| 30 | 31 | |
| 32 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 31 | 33 | #include <experimental/__config> |
| 32 | 34 | #include <experimental/memory_resource> |
| 33 | 35 | #include <vector> |
| 34 | 36 | |
| 35 | 37 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 36 | #pragma GCC system_header | |
| 38 | # pragma GCC system_header | |
| 37 | 39 | #endif |
| 38 | 40 | |
| 39 | 41 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
lib/libcxx/include/ext/__hash+13-13| ... | ... | @@ -10,9 +10,9 @@ |
| 10 | 10 | #ifndef _LIBCPP_EXT_HASH |
| 11 | 11 | #define _LIBCPP_EXT_HASH |
| 12 | 12 | |
| 13 | #pragma GCC system_header | |
| 13 | # pragma GCC system_header | |
| 14 | 14 | |
| 15 | #include <__string> | |
| 15 | #include <__config> | |
| 16 | 16 | #include <cstring> |
| 17 | 17 | #include <string> |
| 18 | 18 | |
| ... | ... | @@ -21,7 +21,7 @@ namespace __gnu_cxx { |
| 21 | 21 | template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { }; |
| 22 | 22 | |
| 23 | 23 | template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*> |
| 24 | : public std::unary_function<const char*, size_t> | |
| 24 | : public std::__unary_function<const char*, size_t> | |
| 25 | 25 | { |
| 26 | 26 | _LIBCPP_INLINE_VISIBILITY |
| 27 | 27 | size_t operator()(const char *__c) const _NOEXCEPT |
| ... | ... | @@ -31,7 +31,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*> |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | 33 | template <> struct _LIBCPP_TEMPLATE_VIS hash<char *> |
| 34 | : public std::unary_function<char*, size_t> | |
| 34 | : public std::__unary_function<char*, size_t> | |
| 35 | 35 | { |
| 36 | 36 | _LIBCPP_INLINE_VISIBILITY |
| 37 | 37 | size_t operator()(char *__c) const _NOEXCEPT |
| ... | ... | @@ -41,7 +41,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char *> |
| 41 | 41 | }; |
| 42 | 42 | |
| 43 | 43 | template <> struct _LIBCPP_TEMPLATE_VIS hash<char> |
| 44 | : public std::unary_function<char, size_t> | |
| 44 | : public std::__unary_function<char, size_t> | |
| 45 | 45 | { |
| 46 | 46 | _LIBCPP_INLINE_VISIBILITY |
| 47 | 47 | size_t operator()(char __c) const _NOEXCEPT |
| ... | ... | @@ -51,7 +51,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char> |
| 51 | 51 | }; |
| 52 | 52 | |
| 53 | 53 | template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char> |
| 54 | : public std::unary_function<signed char, size_t> | |
| 54 | : public std::__unary_function<signed char, size_t> | |
| 55 | 55 | { |
| 56 | 56 | _LIBCPP_INLINE_VISIBILITY |
| 57 | 57 | size_t operator()(signed char __c) const _NOEXCEPT |
| ... | ... | @@ -61,7 +61,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char> |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | 63 | template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> |
| 64 | : public std::unary_function<unsigned char, size_t> | |
| 64 | : public std::__unary_function<unsigned char, size_t> | |
| 65 | 65 | { |
| 66 | 66 | _LIBCPP_INLINE_VISIBILITY |
| 67 | 67 | size_t operator()(unsigned char __c) const _NOEXCEPT |
| ... | ... | @@ -71,7 +71,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> |
| 71 | 71 | }; |
| 72 | 72 | |
| 73 | 73 | template <> struct _LIBCPP_TEMPLATE_VIS hash<short> |
| 74 | : public std::unary_function<short, size_t> | |
| 74 | : public std::__unary_function<short, size_t> | |
| 75 | 75 | { |
| 76 | 76 | _LIBCPP_INLINE_VISIBILITY |
| 77 | 77 | size_t operator()(short __c) const _NOEXCEPT |
| ... | ... | @@ -81,7 +81,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<short> |
| 81 | 81 | }; |
| 82 | 82 | |
| 83 | 83 | template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> |
| 84 | : public std::unary_function<unsigned short, size_t> | |
| 84 | : public std::__unary_function<unsigned short, size_t> | |
| 85 | 85 | { |
| 86 | 86 | _LIBCPP_INLINE_VISIBILITY |
| 87 | 87 | size_t operator()(unsigned short __c) const _NOEXCEPT |
| ... | ... | @@ -91,7 +91,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> |
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | 93 | template <> struct _LIBCPP_TEMPLATE_VIS hash<int> |
| 94 | : public std::unary_function<int, size_t> | |
| 94 | : public std::__unary_function<int, size_t> | |
| 95 | 95 | { |
| 96 | 96 | _LIBCPP_INLINE_VISIBILITY |
| 97 | 97 | size_t operator()(int __c) const _NOEXCEPT |
| ... | ... | @@ -101,7 +101,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<int> |
| 101 | 101 | }; |
| 102 | 102 | |
| 103 | 103 | template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> |
| 104 | : public std::unary_function<unsigned int, size_t> | |
| 104 | : public std::__unary_function<unsigned int, size_t> | |
| 105 | 105 | { |
| 106 | 106 | _LIBCPP_INLINE_VISIBILITY |
| 107 | 107 | size_t operator()(unsigned int __c) const _NOEXCEPT |
| ... | ... | @@ -111,7 +111,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> |
| 111 | 111 | }; |
| 112 | 112 | |
| 113 | 113 | template <> struct _LIBCPP_TEMPLATE_VIS hash<long> |
| 114 | : public std::unary_function<long, size_t> | |
| 114 | : public std::__unary_function<long, size_t> | |
| 115 | 115 | { |
| 116 | 116 | _LIBCPP_INLINE_VISIBILITY |
| 117 | 117 | size_t operator()(long __c) const _NOEXCEPT |
| ... | ... | @@ -121,7 +121,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<long> |
| 121 | 121 | }; |
| 122 | 122 | |
| 123 | 123 | template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> |
| 124 | : public std::unary_function<unsigned long, size_t> | |
| 124 | : public std::__unary_function<unsigned long, size_t> | |
| 125 | 125 | { |
| 126 | 126 | _LIBCPP_INLINE_VISIBILITY |
| 127 | 127 | size_t operator()(unsigned long __c) const _NOEXCEPT |
lib/libcxx/include/ext/hash_map+19-13| ... | ... | @@ -201,13 +201,19 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 201 | 201 | |
| 202 | 202 | */ |
| 203 | 203 | |
| 204 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 204 | 205 | #include <__config> |
| 205 | 206 | #include <__hash_table> |
| 207 | #include <algorithm> | |
| 206 | 208 | #include <ext/__hash> |
| 207 | 209 | #include <functional> |
| 208 | 210 | #include <stdexcept> |
| 209 | 211 | #include <type_traits> |
| 210 | 212 | |
| 213 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 214 | # include <iterator> | |
| 215 | #endif | |
| 216 | ||
| 211 | 217 | #if defined(__DEPRECATED) && __DEPRECATED |
| 212 | 218 | #if defined(_LIBCPP_WARNING) |
| 213 | 219 | _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>") |
| ... | ... | @@ -217,7 +223,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 217 | 223 | #endif |
| 218 | 224 | |
| 219 | 225 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 220 | #pragma GCC system_header | |
| 226 | # pragma GCC system_header | |
| 221 | 227 | #endif |
| 222 | 228 | |
| 223 | 229 | namespace __gnu_cxx { |
| ... | ... | @@ -599,7 +605,7 @@ public: |
| 599 | 605 | {return __table_.bucket_size(__n);} |
| 600 | 606 | |
| 601 | 607 | _LIBCPP_INLINE_VISIBILITY |
| 602 | void resize(size_type __n) {__table_.rehash(__n);} | |
| 608 | void resize(size_type __n) {__table_.__rehash_unique(__n);} | |
| 603 | 609 | |
| 604 | 610 | private: |
| 605 | 611 | __node_holder __construct_node(const key_type& __k); |
| ... | ... | @@ -610,7 +616,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( |
| 610 | 616 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 611 | 617 | : __table_(__hf, __eql) |
| 612 | 618 | { |
| 613 | __table_.rehash(__n); | |
| 619 | __table_.__rehash_unique(__n); | |
| 614 | 620 | } |
| 615 | 621 | |
| 616 | 622 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -619,7 +625,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( |
| 619 | 625 | const allocator_type& __a) |
| 620 | 626 | : __table_(__hf, __eql, __a) |
| 621 | 627 | { |
| 622 | __table_.rehash(__n); | |
| 628 | __table_.__rehash_unique(__n); | |
| 623 | 629 | } |
| 624 | 630 | |
| 625 | 631 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -637,7 +643,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( |
| 637 | 643 | const hasher& __hf, const key_equal& __eql) |
| 638 | 644 | : __table_(__hf, __eql) |
| 639 | 645 | { |
| 640 | __table_.rehash(__n); | |
| 646 | __table_.__rehash_unique(__n); | |
| 641 | 647 | insert(__first, __last); |
| 642 | 648 | } |
| 643 | 649 | |
| ... | ... | @@ -648,7 +654,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( |
| 648 | 654 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 649 | 655 | : __table_(__hf, __eql, __a) |
| 650 | 656 | { |
| 651 | __table_.rehash(__n); | |
| 657 | __table_.__rehash_unique(__n); | |
| 652 | 658 | insert(__first, __last); |
| 653 | 659 | } |
| 654 | 660 | |
| ... | ... | @@ -657,7 +663,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_map( |
| 657 | 663 | const hash_map& __u) |
| 658 | 664 | : __table_(__u.__table_) |
| 659 | 665 | { |
| 660 | __table_.rehash(__u.bucket_count()); | |
| 666 | __table_.__rehash_unique(__u.bucket_count()); | |
| 661 | 667 | insert(__u.begin(), __u.end()); |
| 662 | 668 | } |
| 663 | 669 | |
| ... | ... | @@ -868,7 +874,7 @@ public: |
| 868 | 874 | {return __table_.bucket_size(__n);} |
| 869 | 875 | |
| 870 | 876 | _LIBCPP_INLINE_VISIBILITY |
| 871 | void resize(size_type __n) {__table_.rehash(__n);} | |
| 877 | void resize(size_type __n) {__table_.__rehash_multi(__n);} | |
| 872 | 878 | }; |
| 873 | 879 | |
| 874 | 880 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -876,7 +882,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( |
| 876 | 882 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 877 | 883 | : __table_(__hf, __eql) |
| 878 | 884 | { |
| 879 | __table_.rehash(__n); | |
| 885 | __table_.__rehash_multi(__n); | |
| 880 | 886 | } |
| 881 | 887 | |
| 882 | 888 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -885,7 +891,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( |
| 885 | 891 | const allocator_type& __a) |
| 886 | 892 | : __table_(__hf, __eql, __a) |
| 887 | 893 | { |
| 888 | __table_.rehash(__n); | |
| 894 | __table_.__rehash_multi(__n); | |
| 889 | 895 | } |
| 890 | 896 | |
| 891 | 897 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -903,7 +909,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( |
| 903 | 909 | const hasher& __hf, const key_equal& __eql) |
| 904 | 910 | : __table_(__hf, __eql) |
| 905 | 911 | { |
| 906 | __table_.rehash(__n); | |
| 912 | __table_.__rehash_multi(__n); | |
| 907 | 913 | insert(__first, __last); |
| 908 | 914 | } |
| 909 | 915 | |
| ... | ... | @@ -914,7 +920,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( |
| 914 | 920 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 915 | 921 | : __table_(__hf, __eql, __a) |
| 916 | 922 | { |
| 917 | __table_.rehash(__n); | |
| 923 | __table_.__rehash_multi(__n); | |
| 918 | 924 | insert(__first, __last); |
| 919 | 925 | } |
| 920 | 926 | |
| ... | ... | @@ -923,7 +929,7 @@ hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::hash_multimap( |
| 923 | 929 | const hash_multimap& __u) |
| 924 | 930 | : __table_(__u.__table_) |
| 925 | 931 | { |
| 926 | __table_.rehash(__u.bucket_count()); | |
| 932 | __table_.__rehash_multi(__u.bucket_count()); | |
| 927 | 933 | insert(__u.begin(), __u.end()); |
| 928 | 934 | } |
| 929 | 935 |
lib/libcxx/include/ext/hash_set+19-13| ... | ... | @@ -192,11 +192,17 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 192 | 192 | |
| 193 | 193 | */ |
| 194 | 194 | |
| 195 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 195 | 196 | #include <__config> |
| 196 | 197 | #include <__hash_table> |
| 198 | #include <algorithm> | |
| 197 | 199 | #include <ext/__hash> |
| 198 | 200 | #include <functional> |
| 199 | 201 | |
| 202 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 203 | # include <iterator> | |
| 204 | #endif | |
| 205 | ||
| 200 | 206 | #if defined(__DEPRECATED) && __DEPRECATED |
| 201 | 207 | #if defined(_LIBCPP_WARNING) |
| 202 | 208 | _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>") |
| ... | ... | @@ -206,7 +212,7 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 206 | 212 | #endif |
| 207 | 213 | |
| 208 | 214 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 209 | #pragma GCC system_header | |
| 215 | # pragma GCC system_header | |
| 210 | 216 | #endif |
| 211 | 217 | |
| 212 | 218 | namespace __gnu_cxx { |
| ... | ... | @@ -327,7 +333,7 @@ public: |
| 327 | 333 | size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);} |
| 328 | 334 | |
| 329 | 335 | _LIBCPP_INLINE_VISIBILITY |
| 330 | void resize(size_type __n) {__table_.rehash(__n);} | |
| 336 | void resize(size_type __n) {__table_.__rehash_unique(__n);} | |
| 331 | 337 | }; |
| 332 | 338 | |
| 333 | 339 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -335,7 +341,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n, |
| 335 | 341 | const hasher& __hf, const key_equal& __eql) |
| 336 | 342 | : __table_(__hf, __eql) |
| 337 | 343 | { |
| 338 | __table_.rehash(__n); | |
| 344 | __table_.__rehash_unique(__n); | |
| 339 | 345 | } |
| 340 | 346 | |
| 341 | 347 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -343,7 +349,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set(size_type __n, |
| 343 | 349 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 344 | 350 | : __table_(__hf, __eql, __a) |
| 345 | 351 | { |
| 346 | __table_.rehash(__n); | |
| 352 | __table_.__rehash_unique(__n); | |
| 347 | 353 | } |
| 348 | 354 | |
| 349 | 355 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -361,7 +367,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set( |
| 361 | 367 | const hasher& __hf, const key_equal& __eql) |
| 362 | 368 | : __table_(__hf, __eql) |
| 363 | 369 | { |
| 364 | __table_.rehash(__n); | |
| 370 | __table_.__rehash_unique(__n); | |
| 365 | 371 | insert(__first, __last); |
| 366 | 372 | } |
| 367 | 373 | |
| ... | ... | @@ -372,7 +378,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set( |
| 372 | 378 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 373 | 379 | : __table_(__hf, __eql, __a) |
| 374 | 380 | { |
| 375 | __table_.rehash(__n); | |
| 381 | __table_.__rehash_unique(__n); | |
| 376 | 382 | insert(__first, __last); |
| 377 | 383 | } |
| 378 | 384 | |
| ... | ... | @@ -381,7 +387,7 @@ hash_set<_Value, _Hash, _Pred, _Alloc>::hash_set( |
| 381 | 387 | const hash_set& __u) |
| 382 | 388 | : __table_(__u.__table_) |
| 383 | 389 | { |
| 384 | __table_.rehash(__u.bucket_count()); | |
| 390 | __table_.__rehash_unique(__u.bucket_count()); | |
| 385 | 391 | insert(__u.begin(), __u.end()); |
| 386 | 392 | } |
| 387 | 393 | |
| ... | ... | @@ -547,7 +553,7 @@ public: |
| 547 | 553 | size_type elems_in_bucket(size_type __n) const {return __table_.bucket_size(__n);} |
| 548 | 554 | |
| 549 | 555 | _LIBCPP_INLINE_VISIBILITY |
| 550 | void resize(size_type __n) {__table_.rehash(__n);} | |
| 556 | void resize(size_type __n) {__table_.__rehash_multi(__n);} | |
| 551 | 557 | }; |
| 552 | 558 | |
| 553 | 559 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -555,7 +561,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( |
| 555 | 561 | size_type __n, const hasher& __hf, const key_equal& __eql) |
| 556 | 562 | : __table_(__hf, __eql) |
| 557 | 563 | { |
| 558 | __table_.rehash(__n); | |
| 564 | __table_.__rehash_multi(__n); | |
| 559 | 565 | } |
| 560 | 566 | |
| 561 | 567 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -564,7 +570,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( |
| 564 | 570 | const allocator_type& __a) |
| 565 | 571 | : __table_(__hf, __eql, __a) |
| 566 | 572 | { |
| 567 | __table_.rehash(__n); | |
| 573 | __table_.__rehash_multi(__n); | |
| 568 | 574 | } |
| 569 | 575 | |
| 570 | 576 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -582,7 +588,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( |
| 582 | 588 | const hasher& __hf, const key_equal& __eql) |
| 583 | 589 | : __table_(__hf, __eql) |
| 584 | 590 | { |
| 585 | __table_.rehash(__n); | |
| 591 | __table_.__rehash_multi(__n); | |
| 586 | 592 | insert(__first, __last); |
| 587 | 593 | } |
| 588 | 594 | |
| ... | ... | @@ -593,7 +599,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( |
| 593 | 599 | const hasher& __hf, const key_equal& __eql, const allocator_type& __a) |
| 594 | 600 | : __table_(__hf, __eql, __a) |
| 595 | 601 | { |
| 596 | __table_.rehash(__n); | |
| 602 | __table_.__rehash_multi(__n); | |
| 597 | 603 | insert(__first, __last); |
| 598 | 604 | } |
| 599 | 605 | |
| ... | ... | @@ -602,7 +608,7 @@ hash_multiset<_Value, _Hash, _Pred, _Alloc>::hash_multiset( |
| 602 | 608 | const hash_multiset& __u) |
| 603 | 609 | : __table_(__u.__table_) |
| 604 | 610 | { |
| 605 | __table_.rehash(__u.bucket_count()); | |
| 611 | __table_.__rehash_multi(__u.bucket_count()); | |
| 606 | 612 | insert(__u.begin(), __u.end()); |
| 607 | 613 | } |
| 608 | 614 |
lib/libcxx/include/fenv.h+1-1| ... | ... | @@ -53,7 +53,7 @@ int feupdateenv(const fenv_t* envp); |
| 53 | 53 | #include <__config> |
| 54 | 54 | |
| 55 | 55 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 56 | #pragma GCC system_header | |
| 56 | # pragma GCC system_header | |
| 57 | 57 | #endif |
| 58 | 58 | |
| 59 | 59 | #include_next <fenv.h> |
lib/libcxx/include/filesystem+7-3| ... | ... | @@ -8,6 +8,7 @@ |
| 8 | 8 | //===----------------------------------------------------------------------===// |
| 9 | 9 | #ifndef _LIBCPP_FILESYSTEM |
| 10 | 10 | #define _LIBCPP_FILESYSTEM |
| 11 | ||
| 11 | 12 | /* |
| 12 | 13 | filesystem synopsis |
| 13 | 14 | |
| ... | ... | @@ -238,6 +239,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct |
| 238 | 239 | |
| 239 | 240 | */ |
| 240 | 241 | |
| 242 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 241 | 243 | #include <__config> |
| 242 | 244 | #include <__filesystem/copy_options.h> |
| 243 | 245 | #include <__filesystem/directory_entry.h> |
| ... | ... | @@ -255,15 +257,17 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct |
| 255 | 257 | #include <__filesystem/recursive_directory_iterator.h> |
| 256 | 258 | #include <__filesystem/space_info.h> |
| 257 | 259 | #include <__filesystem/u8path.h> |
| 258 | #include <compare> | |
| 259 | 260 | #include <version> |
| 260 | 261 | |
| 262 | // standard-mandated includes | |
| 263 | #include <compare> | |
| 264 | ||
| 261 | 265 | #if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) |
| 262 | # error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled" | |
| 266 | # error "The <filesystem> library is not supported since libc++ has been configured without support for a filesystem." | |
| 263 | 267 | #endif |
| 264 | 268 | |
| 265 | 269 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 266 | #pragma GCC system_header | |
| 270 | # pragma GCC system_header | |
| 267 | 271 | #endif |
| 268 | 272 | |
| 269 | 273 | #endif // _LIBCPP_FILESYSTEM |
lib/libcxx/include/float.h+1-1| ... | ... | @@ -73,7 +73,7 @@ Macros: |
| 73 | 73 | #include <__config> |
| 74 | 74 | |
| 75 | 75 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 76 | #pragma GCC system_header | |
| 76 | # pragma GCC system_header | |
| 77 | 77 | #endif |
| 78 | 78 | |
| 79 | 79 | #include_next <float.h> |
lib/libcxx/include/format+383-149| ... | ... | @@ -23,15 +23,26 @@ namespace std { |
| 23 | 23 | using format_args = basic_format_args<format_context>; |
| 24 | 24 | using wformat_args = basic_format_args<wformat_context>; |
| 25 | 25 | |
| 26 | // [format.fmt.string], class template basic-format-string | |
| 27 | template<class charT, class... Args> | |
| 28 | struct basic-format-string; // exposition only | |
| 29 | ||
| 30 | template<class... Args> | |
| 31 | using format-string = // exposition only | |
| 32 | basic-format-string<char, type_identity_t<Args>...>; | |
| 33 | template<class... Args> | |
| 34 | using wformat-string = // exposition only | |
| 35 | basic-format-string<wchar_t, type_identity_t<Args>...>; | |
| 36 | ||
| 26 | 37 | // [format.functions], formatting functions |
| 27 | 38 | template<class... Args> |
| 28 | string format(string_view fmt, const Args&... args); | |
| 39 | string format(format-string<Args...> fmt, Args&&... args); | |
| 29 | 40 | template<class... Args> |
| 30 | wstring format(wstring_view fmt, const Args&... args); | |
| 41 | wstring format(wformat-string<Args...> fmt, Args&&... args); | |
| 31 | 42 | template<class... Args> |
| 32 | string format(const locale& loc, string_view fmt, const Args&... args); | |
| 43 | string format(const locale& loc, format-string<Args...> fmt, Args&&... args); | |
| 33 | 44 | template<class... Args> |
| 34 | wstring format(const locale& loc, wstring_view fmt, const Args&... args); | |
| 45 | wstring format(const locale& loc, wformat-string<Args...> fmt, Args&&... args); | |
| 35 | 46 | |
| 36 | 47 | string vformat(string_view fmt, format_args args); |
| 37 | 48 | wstring vformat(wstring_view fmt, wformat_args args); |
| ... | ... | @@ -39,13 +50,13 @@ namespace std { |
| 39 | 50 | wstring vformat(const locale& loc, wstring_view fmt, wformat_args args); |
| 40 | 51 | |
| 41 | 52 | template<class Out, class... Args> |
| 42 | Out format_to(Out out, string_view fmt, const Args&... args); | |
| 53 | Out format_to(Out out, format-string<Args...> fmt, Args&&... args); | |
| 43 | 54 | template<class Out, class... Args> |
| 44 | Out format_to(Out out, wstring_view fmt, const Args&... args); | |
| 55 | Out format_to(Out out, wformat-string<Args...> fmt, Args&&... args); | |
| 45 | 56 | template<class Out, class... Args> |
| 46 | Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args); | |
| 57 | Out format_to(Out out, const locale& loc, format-string<Args...> fmt, Args&&... args); | |
| 47 | 58 | template<class Out, class... Args> |
| 48 | Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args); | |
| 59 | Out format_to(Out out, const locale& loc, wformat-string<Args...> fmt, Args&&... args); | |
| 49 | 60 | |
| 50 | 61 | template<class Out> |
| 51 | 62 | Out vformat_to(Out out, string_view fmt, format_args args); |
| ... | ... | @@ -64,27 +75,27 @@ namespace std { |
| 64 | 75 | }; |
| 65 | 76 | template<class Out, class... Args> |
| 66 | 77 | format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, |
| 67 | string_view fmt, const Args&... args); | |
| 78 | format-string<Args...> fmt, Args&&... args); | |
| 68 | 79 | template<class Out, class... Args> |
| 69 | 80 | format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, |
| 70 | wstring_view fmt, const Args&... args); | |
| 81 | wformat-string<Args...> fmt, Args&&... args); | |
| 71 | 82 | template<class Out, class... Args> |
| 72 | 83 | 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); | |
| 84 | const locale& loc, format-string<Args...> fmt, | |
| 85 | Args&&... args); | |
| 75 | 86 | template<class Out, class... Args> |
| 76 | 87 | 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); | |
| 88 | const locale& loc, wformat-string<Args...> fmt, | |
| 89 | Args&&... args); | |
| 79 | 90 | |
| 80 | 91 | template<class... Args> |
| 81 | size_t formatted_size(string_view fmt, const Args&... args); | |
| 92 | size_t formatted_size(format-string<Args...> fmt, Args&&... args); | |
| 82 | 93 | template<class... Args> |
| 83 | size_t formatted_size(wstring_view fmt, const Args&... args); | |
| 94 | size_t formatted_size(wformat-string<Args...> fmt, Args&&... args); | |
| 84 | 95 | template<class... Args> |
| 85 | size_t formatted_size(const locale& loc, string_view fmt, const Args&... args); | |
| 96 | size_t formatted_size(const locale& loc, format-string<Args...> fmt, Args&&... args); | |
| 86 | 97 | template<class... Args> |
| 87 | size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args); | |
| 98 | size_t formatted_size(const locale& loc, wformat-string<Args...> fmt, Args&&... args); | |
| 88 | 99 | |
| 89 | 100 | // [format.formatter], formatter |
| 90 | 101 | template<class T, class charT = char> struct formatter; |
| ... | ... | @@ -106,10 +117,10 @@ namespace std { |
| 106 | 117 | |
| 107 | 118 | template<class Context = format_context, class... Args> |
| 108 | 119 | format-arg-store<Context, Args...> |
| 109 | make_format_args(const Args&... args); | |
| 120 | make_format_args(Args&&... args); | |
| 110 | 121 | template<class... Args> |
| 111 | 122 | format-arg-store<wformat_context, Args...> |
| 112 | make_wformat_args(const Args&... args); | |
| 123 | make_wformat_args(Args&&... args); | |
| 113 | 124 | |
| 114 | 125 | // [format.error], class format_error |
| 115 | 126 | class format_error; |
| ... | ... | @@ -117,14 +128,20 @@ namespace std { |
| 117 | 128 | |
| 118 | 129 | */ |
| 119 | 130 | |
| 131 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 120 | 132 | // Make sure all feature-test macros are available. |
| 121 | 133 | #include <version> |
| 122 | // Enable the contents of the header only when libc++ was built with LIBCXX_ENABLE_INCOMPLETE_FEATURES. | |
| 134 | // Enable the contents of the header only when libc++ was built with experimental features enabled. | |
| 123 | 135 | #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) |
| 124 | 136 | |
| 137 | #include <__algorithm/clamp.h> | |
| 125 | 138 | #include <__config> |
| 126 | 139 | #include <__debug> |
| 140 | #include <__format/buffer.h> | |
| 141 | #include <__format/concepts.h> | |
| 142 | #include <__format/enable_insertable.h> | |
| 127 | 143 | #include <__format/format_arg.h> |
| 144 | #include <__format/format_arg_store.h> | |
| 128 | 145 | #include <__format/format_args.h> |
| 129 | 146 | #include <__format/format_context.h> |
| 130 | 147 | #include <__format/format_error.h> |
| ... | ... | @@ -140,6 +157,9 @@ namespace std { |
| 140 | 157 | #include <__format/formatter_pointer.h> |
| 141 | 158 | #include <__format/formatter_string.h> |
| 142 | 159 | #include <__format/parser_std_format_spec.h> |
| 160 | #include <__format/unicode.h> | |
| 161 | #include <__iterator/back_insert_iterator.h> | |
| 162 | #include <__iterator/incrementable_traits.h> | |
| 143 | 163 | #include <__variant/monostate.h> |
| 144 | 164 | #include <array> |
| 145 | 165 | #include <concepts> |
| ... | ... | @@ -152,22 +172,13 @@ namespace std { |
| 152 | 172 | #endif |
| 153 | 173 | |
| 154 | 174 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 155 | #pragma GCC system_header | |
| 175 | # pragma GCC system_header | |
| 156 | 176 | #endif |
| 157 | 177 | |
| 158 | _LIBCPP_PUSH_MACROS | |
| 159 | #include <__undef_macros> | |
| 160 | ||
| 161 | 178 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 162 | 179 | |
| 163 | 180 | #if _LIBCPP_STD_VER > 17 |
| 164 | 181 | |
| 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 | 182 | // TODO FMT Move the implementation in this file to its own granular headers. |
| 172 | 183 | |
| 173 | 184 | // TODO FMT Evaluate which templates should be external templates. This |
| ... | ... | @@ -180,35 +191,193 @@ using format_args = basic_format_args<format_context>; |
| 180 | 191 | using wformat_args = basic_format_args<wformat_context>; |
| 181 | 192 | #endif |
| 182 | 193 | |
| 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 | 194 | 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)...}; | |
| 195 | _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) { | |
| 196 | return _VSTD::__format_arg_store<_Context, _Args...>(__args...); | |
| 193 | 197 | } |
| 194 | 198 | |
| 195 | 199 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 196 | 200 | 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...); | |
| 201 | _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) { | |
| 202 | return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...); | |
| 200 | 203 | } |
| 201 | 204 | #endif |
| 202 | 205 | |
| 203 | 206 | namespace __format { |
| 204 | 207 | |
| 208 | /// Helper class parse and handle argument. | |
| 209 | /// | |
| 210 | /// When parsing a handle which is not enabled the code is ill-formed. | |
| 211 | /// This helper uses the parser of the appropriate formatter for the stored type. | |
| 212 | template <class _CharT> | |
| 213 | class _LIBCPP_TEMPLATE_VIS __compile_time_handle { | |
| 214 | public: | |
| 215 | _LIBCPP_HIDE_FROM_ABI | |
| 216 | constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); } | |
| 217 | ||
| 218 | template <class _Tp> | |
| 219 | _LIBCPP_HIDE_FROM_ABI constexpr void __enable() { | |
| 220 | __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) { | |
| 221 | formatter<_Tp, _CharT> __f; | |
| 222 | __parse_ctx.advance_to(__f.parse(__parse_ctx)); | |
| 223 | }; | |
| 224 | } | |
| 225 | ||
| 226 | // Before calling __parse the proper handler needs to be set with __enable. | |
| 227 | // The default handler isn't a core constant expression. | |
| 228 | _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle() | |
| 229 | : __parse_([](basic_format_parse_context<_CharT>&) { __throw_format_error("Not a handle"); }) {} | |
| 230 | ||
| 231 | private: | |
| 232 | void (*__parse_)(basic_format_parse_context<_CharT>&); | |
| 233 | }; | |
| 234 | ||
| 235 | // Dummy format_context only providing the parts used during constant | |
| 236 | // validation of the basic-format-string. | |
| 237 | template <class _CharT> | |
| 238 | struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context { | |
| 239 | public: | |
| 240 | using char_type = _CharT; | |
| 241 | ||
| 242 | _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context( | |
| 243 | const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size) | |
| 244 | : __args_(__args), __handles_(__handles), __size_(__size) {} | |
| 245 | ||
| 246 | // During the compile-time validation nothing needs to be written. | |
| 247 | // Therefore all operations of this iterator are a NOP. | |
| 248 | struct iterator { | |
| 249 | _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; } | |
| 250 | _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; } | |
| 251 | _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; } | |
| 252 | }; | |
| 253 | ||
| 254 | _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const { | |
| 255 | if (__id >= __size_) | |
| 256 | __throw_format_error("Argument index out of bounds"); | |
| 257 | return __args_[__id]; | |
| 258 | } | |
| 259 | ||
| 260 | _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const { | |
| 261 | if (__id >= __size_) | |
| 262 | __throw_format_error("Argument index out of bounds"); | |
| 263 | return __handles_[__id]; | |
| 264 | } | |
| 265 | ||
| 266 | _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; } | |
| 267 | _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {} | |
| 268 | ||
| 269 | private: | |
| 270 | const __arg_t* __args_; | |
| 271 | const __compile_time_handle<_CharT>* __handles_; | |
| 272 | size_t __size_; | |
| 273 | }; | |
| 274 | ||
| 275 | _LIBCPP_HIDE_FROM_ABI | |
| 276 | constexpr void __compile_time_validate_integral(__arg_t __type) { | |
| 277 | switch (__type) { | |
| 278 | case __arg_t::__int: | |
| 279 | case __arg_t::__long_long: | |
| 280 | case __arg_t::__i128: | |
| 281 | case __arg_t::__unsigned: | |
| 282 | case __arg_t::__unsigned_long_long: | |
| 283 | case __arg_t::__u128: | |
| 284 | return; | |
| 285 | ||
| 286 | default: | |
| 287 | __throw_format_error("Argument isn't an integral type"); | |
| 288 | } | |
| 289 | } | |
| 290 | ||
| 291 | // _HasPrecision does the formatter have a precision? | |
| 292 | template <class _CharT, class _Tp, bool _HasPrecision = false> | |
| 293 | _LIBCPP_HIDE_FROM_ABI constexpr void | |
| 294 | __compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx, | |
| 295 | __compile_time_basic_format_context<_CharT>& __ctx) { | |
| 296 | formatter<_Tp, _CharT> __formatter; | |
| 297 | __parse_ctx.advance_to(__formatter.parse(__parse_ctx)); | |
| 298 | // [format.string.std]/7 | |
| 299 | // ... If the corresponding formatting argument is not of integral type, or | |
| 300 | // its value is negative for precision or non-positive for width, an | |
| 301 | // exception of type format_error is thrown. | |
| 302 | // | |
| 303 | // Validate whether the arguments are integrals. | |
| 304 | if constexpr (requires(formatter<_Tp, _CharT> __f) { __f.__width_needs_substitution(); }) { | |
| 305 | // TODO FMT Remove this when parser v1 has been phased out. | |
| 306 | if (__formatter.__width_needs_substitution()) | |
| 307 | __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width)); | |
| 308 | ||
| 309 | if constexpr (_HasPrecision) | |
| 310 | if (__formatter.__precision_needs_substitution()) | |
| 311 | __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision)); | |
| 312 | } else { | |
| 313 | if (__formatter.__parser_.__width_as_arg_) | |
| 314 | __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_)); | |
| 315 | ||
| 316 | if constexpr (_HasPrecision) | |
| 317 | if (__formatter.__parser_.__precision_as_arg_) | |
| 318 | __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_)); | |
| 319 | } | |
| 320 | } | |
| 321 | ||
| 322 | template <class _CharT> | |
| 323 | _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx, | |
| 324 | __compile_time_basic_format_context<_CharT>& __ctx, | |
| 325 | __arg_t __type) { | |
| 326 | switch (__type) { | |
| 327 | case __arg_t::__none: | |
| 328 | __throw_format_error("Invalid argument"); | |
| 329 | case __arg_t::__boolean: | |
| 330 | return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx); | |
| 331 | case __arg_t::__char_type: | |
| 332 | return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx); | |
| 333 | case __arg_t::__int: | |
| 334 | return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx); | |
| 335 | case __arg_t::__long_long: | |
| 336 | return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx); | |
| 337 | case __arg_t::__i128: | |
| 338 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 339 | return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx); | |
| 340 | # else | |
| 341 | __throw_format_error("Invalid argument"); | |
| 342 | # endif | |
| 343 | return; | |
| 344 | case __arg_t::__unsigned: | |
| 345 | return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx); | |
| 346 | case __arg_t::__unsigned_long_long: | |
| 347 | return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx); | |
| 348 | case __arg_t::__u128: | |
| 349 | # ifndef _LIBCPP_HAS_NO_INT128 | |
| 350 | return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx); | |
| 351 | # else | |
| 352 | __throw_format_error("Invalid argument"); | |
| 353 | # endif | |
| 354 | return; | |
| 355 | case __arg_t::__float: | |
| 356 | return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx); | |
| 357 | case __arg_t::__double: | |
| 358 | return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx); | |
| 359 | case __arg_t::__long_double: | |
| 360 | return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx); | |
| 361 | case __arg_t::__const_char_type_ptr: | |
| 362 | return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx); | |
| 363 | case __arg_t::__string_view: | |
| 364 | return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx); | |
| 365 | case __arg_t::__ptr: | |
| 366 | return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx); | |
| 367 | case __arg_t::__handle: | |
| 368 | __throw_format_error("Handle should use __compile_time_validate_handle_argument"); | |
| 369 | } | |
| 370 | __throw_format_error("Invalid argument"); | |
| 371 | } | |
| 372 | ||
| 205 | 373 | template <class _CharT, class _ParseCtx, class _Ctx> |
| 206 | _LIBCPP_HIDE_FROM_ABI const _CharT* | |
| 374 | _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* | |
| 207 | 375 | __handle_replacement_field(const _CharT* __begin, const _CharT* __end, |
| 208 | 376 | _ParseCtx& __parse_ctx, _Ctx& __ctx) { |
| 209 | 377 | __format::__parse_number_result __r = |
| 210 | 378 | __format::__parse_arg_id(__begin, __end, __parse_ctx); |
| 211 | 379 | |
| 380 | bool __parse = *__r.__ptr == _CharT(':'); | |
| 212 | 381 | switch (*__r.__ptr) { |
| 213 | 382 | case _CharT(':'): |
| 214 | 383 | // The arg-id has a format-specifier, advance the input to the format-spec. |
| ... | ... | @@ -223,19 +392,27 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end, |
| 223 | 392 | "The replacement field arg-id should terminate at a ':' or '}'"); |
| 224 | 393 | } |
| 225 | 394 | |
| 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)); | |
| 395 | if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) { | |
| 396 | __arg_t __type = __ctx.arg(__r.__value); | |
| 397 | if (__type == __arg_t::__handle) | |
| 398 | __ctx.__handle(__r.__value).__parse(__parse_ctx); | |
| 399 | else | |
| 400 | __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type); | |
| 401 | } else | |
| 402 | _VSTD::visit_format_arg( | |
| 403 | [&](auto __arg) { | |
| 404 | if constexpr (same_as<decltype(__arg), monostate>) | |
| 405 | __throw_format_error("Argument index out of bounds"); | |
| 406 | else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>) | |
| 407 | __arg.format(__parse_ctx, __ctx); | |
| 408 | else { | |
| 409 | formatter<decltype(__arg), _CharT> __formatter; | |
| 410 | if (__parse) | |
| 411 | __parse_ctx.advance_to(__formatter.parse(__parse_ctx)); | |
| 412 | __ctx.advance_to(__formatter.format(__arg, __ctx)); | |
| 413 | } | |
| 414 | }, | |
| 415 | __ctx.arg(__r.__value)); | |
| 239 | 416 | |
| 240 | 417 | __begin = __parse_ctx.begin(); |
| 241 | 418 | if (__begin == __end || *__begin != _CharT('}')) |
| ... | ... | @@ -245,7 +422,7 @@ __handle_replacement_field(const _CharT* __begin, const _CharT* __end, |
| 245 | 422 | } |
| 246 | 423 | |
| 247 | 424 | template <class _ParseCtx, class _Ctx> |
| 248 | _LIBCPP_HIDE_FROM_ABI typename _Ctx::iterator | |
| 425 | _LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator | |
| 249 | 426 | __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) { |
| 250 | 427 | using _CharT = typename _ParseCtx::char_type; |
| 251 | 428 | static_assert(same_as<typename _Ctx::char_type, _CharT>); |
| ... | ... | @@ -290,6 +467,56 @@ __vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) { |
| 290 | 467 | |
| 291 | 468 | } // namespace __format |
| 292 | 469 | |
| 470 | template <class _CharT, class... _Args> | |
| 471 | struct _LIBCPP_TEMPLATE_VIS __basic_format_string { | |
| 472 | basic_string_view<_CharT> __str_; | |
| 473 | ||
| 474 | template <class _Tp> | |
| 475 | requires convertible_to<const _Tp&, basic_string_view<_CharT>> | |
| 476 | consteval __basic_format_string(const _Tp& __str) : __str_{__str} { | |
| 477 | __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)}, | |
| 478 | _Context{__types_.data(), __handles_.data(), sizeof...(_Args)}); | |
| 479 | } | |
| 480 | ||
| 481 | private: | |
| 482 | using _Context = __format::__compile_time_basic_format_context<_CharT>; | |
| 483 | ||
| 484 | static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{ | |
| 485 | __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...}; | |
| 486 | ||
| 487 | // TODO FMT remove this work-around when the AIX ICE has been resolved. | |
| 488 | # if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400 | |
| 489 | template <class _Tp> | |
| 490 | static constexpr __format::__compile_time_handle<_CharT> __get_handle() { | |
| 491 | __format::__compile_time_handle<_CharT> __handle; | |
| 492 | if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle) | |
| 493 | __handle.template __enable<_Tp>(); | |
| 494 | ||
| 495 | return __handle; | |
| 496 | } | |
| 497 | ||
| 498 | static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{ | |
| 499 | __get_handle<_Args>()...}; | |
| 500 | # else | |
| 501 | static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] { | |
| 502 | using _Tp = remove_cvref_t<_Args>; | |
| 503 | __format::__compile_time_handle<_CharT> __handle; | |
| 504 | if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle) | |
| 505 | __handle.template __enable<_Tp>(); | |
| 506 | ||
| 507 | return __handle; | |
| 508 | }()...}; | |
| 509 | # endif | |
| 510 | }; | |
| 511 | ||
| 512 | template <class... _Args> | |
| 513 | using __format_string_t = __basic_format_string<char, type_identity_t<_Args>...>; | |
| 514 | ||
| 515 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 516 | template <class... _Args> | |
| 517 | using __wformat_string_t = __basic_format_string<wchar_t, type_identity_t<_Args>...>; | |
| 518 | #endif | |
| 519 | ||
| 293 | 520 | template <class _OutIt, class _CharT, class _FormatOutIt> |
| 294 | 521 | requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt |
| 295 | 522 | __vformat_to( |
| ... | ... | @@ -300,14 +527,18 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt |
| 300 | 527 | basic_format_parse_context{__fmt, __args.__size()}, |
| 301 | 528 | _VSTD::__format_context_create(_VSTD::move(__out_it), __args)); |
| 302 | 529 | else { |
| 303 | basic_string<_CharT> __str; | |
| 530 | __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)}; | |
| 304 | 531 | _VSTD::__format::__vformat_to( |
| 305 | 532 | 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)); | |
| 533 | _VSTD::__format_context_create(__buffer.make_output_iterator(), | |
| 534 | __args)); | |
| 535 | return _VSTD::move(__buffer).out(); | |
| 308 | 536 | } |
| 309 | 537 | } |
| 310 | 538 | |
| 539 | // The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining | |
| 540 | // https://reviews.llvm.org/D110499#inline-1180704 | |
| 541 | // TODO FMT Evaluate whether we want to file a Clang bug report regarding this. | |
| 311 | 542 | template <output_iterator<const char&> _OutIt> |
| 312 | 543 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt |
| 313 | 544 | vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) { |
| ... | ... | @@ -324,16 +555,16 @@ vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) { |
| 324 | 555 | |
| 325 | 556 | template <output_iterator<const char&> _OutIt, class... _Args> |
| 326 | 557 | _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, | |
| 558 | format_to(_OutIt __out_it, __format_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 559 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_, | |
| 329 | 560 | _VSTD::make_format_args(__args...)); |
| 330 | 561 | } |
| 331 | 562 | |
| 332 | 563 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 333 | 564 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 334 | 565 | _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, | |
| 566 | format_to(_OutIt __out_it, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 567 | return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.__str_, | |
| 337 | 568 | _VSTD::make_wformat_args(__args...)); |
| 338 | 569 | } |
| 339 | 570 | #endif |
| ... | ... | @@ -355,60 +586,63 @@ vformat(wstring_view __fmt, wformat_args __args) { |
| 355 | 586 | #endif |
| 356 | 587 | |
| 357 | 588 | 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...)); | |
| 589 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(__format_string_t<_Args...> __fmt, | |
| 590 | _Args&&... __args) { | |
| 591 | return _VSTD::vformat(__fmt.__str_, _VSTD::make_format_args(__args...)); | |
| 361 | 592 | } |
| 362 | 593 | |
| 363 | 594 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 364 | 595 | template <class... _Args> |
| 365 | 596 | _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...)); | |
| 597 | format(__wformat_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 598 | return _VSTD::vformat(__fmt.__str_, _VSTD::make_wformat_args(__args...)); | |
| 368 | 599 | } |
| 369 | 600 | #endif |
| 370 | 601 | |
| 602 | template <class _Context, class _OutIt, class _CharT> | |
| 603 | _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, | |
| 604 | basic_string_view<_CharT> __fmt, | |
| 605 | basic_format_args<_Context> __args) { | |
| 606 | __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n}; | |
| 607 | _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()}, | |
| 608 | _VSTD::__format_context_create(__buffer.make_output_iterator(), __args)); | |
| 609 | return _VSTD::move(__buffer).result(); | |
| 610 | } | |
| 611 | ||
| 371 | 612 | 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}; | |
| 613 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 614 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __format_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 615 | return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_format_args(__args...)); | |
| 382 | 616 | } |
| 383 | 617 | |
| 384 | 618 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 385 | 619 | template <output_iterator<const wchar_t&> _OutIt, class... _Args> |
| 386 | 620 | _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}; | |
| 621 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, __wformat_string_t<_Args...> __fmt, | |
| 622 | _Args&&... __args) { | |
| 623 | return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.__str_, _VSTD::make_wformat_args(__args...)); | |
| 396 | 624 | } |
| 397 | 625 | #endif |
| 398 | 626 | |
| 627 | template <class _CharT> | |
| 628 | _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) { | |
| 629 | __format::__formatted_size_buffer<_CharT> __buffer; | |
| 630 | _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()}, | |
| 631 | _VSTD::__format_context_create(__buffer.make_output_iterator(), __args)); | |
| 632 | return _VSTD::move(__buffer).result(); | |
| 633 | } | |
| 634 | ||
| 399 | 635 | 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(); | |
| 636 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 637 | formatted_size(__format_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 638 | return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)}); | |
| 404 | 639 | } |
| 405 | 640 | |
| 406 | 641 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 407 | 642 | 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(); | |
| 643 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 644 | formatted_size(__wformat_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 645 | return _VSTD::__vformatted_size(__fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)}); | |
| 412 | 646 | } |
| 413 | 647 | #endif |
| 414 | 648 | |
| ... | ... | @@ -425,12 +659,12 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt |
| 425 | 659 | _VSTD::__format_context_create(_VSTD::move(__out_it), __args, |
| 426 | 660 | _VSTD::move(__loc))); |
| 427 | 661 | else { |
| 428 | basic_string<_CharT> __str; | |
| 662 | __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)}; | |
| 429 | 663 | _VSTD::__format::__vformat_to( |
| 430 | 664 | 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)); | |
| 665 | _VSTD::__format_context_create(__buffer.make_output_iterator(), | |
| 666 | __args, _VSTD::move(__loc))); | |
| 667 | return _VSTD::move(__buffer).out(); | |
| 434 | 668 | } |
| 435 | 669 | } |
| 436 | 670 | |
| ... | ... | @@ -451,17 +685,17 @@ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt v |
| 451 | 685 | #endif |
| 452 | 686 | |
| 453 | 687 | 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, | |
| 688 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | |
| 689 | format_to(_OutIt __out_it, locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 690 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_, | |
| 457 | 691 | _VSTD::make_format_args(__args...)); |
| 458 | 692 | } |
| 459 | 693 | |
| 460 | 694 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 461 | 695 | 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, | |
| 696 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt | |
| 697 | format_to(_OutIt __out_it, locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 698 | return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.__str_, | |
| 465 | 699 | _VSTD::make_wformat_args(__args...)); |
| 466 | 700 | } |
| 467 | 701 | #endif |
| ... | ... | @@ -485,80 +719,80 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) { |
| 485 | 719 | #endif |
| 486 | 720 | |
| 487 | 721 | 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, | |
| 722 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc, | |
| 723 | __format_string_t<_Args...> __fmt, | |
| 724 | _Args&&... __args) { | |
| 725 | return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_, | |
| 491 | 726 | _VSTD::make_format_args(__args...)); |
| 492 | 727 | } |
| 493 | 728 | |
| 494 | 729 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 495 | 730 | template <class... _Args> |
| 496 | 731 | _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, | |
| 732 | format(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 733 | return _VSTD::vformat(_VSTD::move(__loc), __fmt.__str_, | |
| 499 | 734 | _VSTD::make_wformat_args(__args...)); |
| 500 | 735 | } |
| 501 | 736 | #endif |
| 502 | 737 | |
| 738 | template <class _Context, class _OutIt, class _CharT> | |
| 739 | _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, | |
| 740 | locale __loc, basic_string_view<_CharT> __fmt, | |
| 741 | basic_format_args<_Context> __args) { | |
| 742 | __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n}; | |
| 743 | _VSTD::__format::__vformat_to( | |
| 744 | basic_format_parse_context{__fmt, __args.__size()}, | |
| 745 | _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc))); | |
| 746 | return _VSTD::move(__buffer).result(); | |
| 747 | } | |
| 748 | ||
| 503 | 749 | 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}; | |
| 750 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 751 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __format_string_t<_Args...> __fmt, | |
| 752 | _Args&&... __args) { | |
| 753 | return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_, | |
| 754 | _VSTD::make_format_args(__args...)); | |
| 515 | 755 | } |
| 516 | 756 | |
| 517 | 757 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 518 | 758 | 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}; | |
| 759 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> | |
| 760 | format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, __wformat_string_t<_Args...> __fmt, | |
| 761 | _Args&&... __args) { | |
| 762 | return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.__str_, | |
| 763 | _VSTD::make_wformat_args(__args...)); | |
| 530 | 764 | } |
| 531 | 765 | #endif |
| 532 | 766 | |
| 767 | template <class _CharT> | |
| 768 | _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) { | |
| 769 | __format::__formatted_size_buffer<_CharT> __buffer; | |
| 770 | _VSTD::__format::__vformat_to( | |
| 771 | basic_format_parse_context{__fmt, __args.__size()}, | |
| 772 | _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc))); | |
| 773 | return _VSTD::move(__buffer).result(); | |
| 774 | } | |
| 775 | ||
| 533 | 776 | 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(); | |
| 777 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 778 | formatted_size(locale __loc, __format_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 779 | return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_format_args(__args...)}); | |
| 540 | 780 | } |
| 541 | 781 | |
| 542 | 782 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 543 | 783 | 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(); | |
| 784 | _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t | |
| 785 | formatted_size(locale __loc, __wformat_string_t<_Args...> __fmt, _Args&&... __args) { | |
| 786 | return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.__str_, basic_format_args{_VSTD::make_wformat_args(__args...)}); | |
| 550 | 787 | } |
| 551 | 788 | #endif |
| 552 | 789 | |
| 553 | 790 | #endif // _LIBCPP_HAS_NO_LOCALIZATION |
| 554 | 791 | |
| 555 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 556 | 792 | #endif //_LIBCPP_STD_VER > 17 |
| 557 | 793 | |
| 558 | 794 | _LIBCPP_END_NAMESPACE_STD |
| 559 | 795 | |
| 560 | _LIBCPP_POP_MACROS | |
| 561 | ||
| 562 | 796 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT) |
| 563 | 797 | |
| 564 | 798 | #endif // _LIBCPP_FORMAT |
lib/libcxx/include/forward_list+42-41| ... | ... | @@ -179,18 +179,43 @@ template <class T, class Allocator, class Predicate> |
| 179 | 179 | |
| 180 | 180 | */ |
| 181 | 181 | |
| 182 | #include <__algorithm/comp.h> | |
| 183 | #include <__algorithm/lexicographical_compare.h> | |
| 184 | #include <__algorithm/min.h> | |
| 185 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 182 | 186 | #include <__config> |
| 187 | #include <__iterator/distance.h> | |
| 188 | #include <__iterator/iterator_traits.h> | |
| 189 | #include <__iterator/move_iterator.h> | |
| 190 | #include <__iterator/next.h> | |
| 191 | #include <__memory/swap_allocator.h> | |
| 183 | 192 | #include <__utility/forward.h> |
| 184 | #include <algorithm> | |
| 185 | #include <initializer_list> | |
| 186 | #include <iterator> | |
| 187 | 193 | #include <limits> |
| 188 | 194 | #include <memory> |
| 189 | 195 | #include <type_traits> |
| 190 | 196 | #include <version> |
| 191 | 197 | |
| 198 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 199 | # include <algorithm> | |
| 200 | # include <functional> | |
| 201 | # include <iterator> | |
| 202 | #endif | |
| 203 | ||
| 204 | // standard-mandated includes | |
| 205 | ||
| 206 | // [iterator.range] | |
| 207 | #include <__iterator/access.h> | |
| 208 | #include <__iterator/data.h> | |
| 209 | #include <__iterator/empty.h> | |
| 210 | #include <__iterator/reverse_access.h> | |
| 211 | #include <__iterator/size.h> | |
| 212 | ||
| 213 | // [forward.list.syn] | |
| 214 | #include <compare> | |
| 215 | #include <initializer_list> | |
| 216 | ||
| 192 | 217 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 193 | #pragma GCC system_header | |
| 218 | # pragma GCC system_header | |
| 194 | 219 | #endif |
| 195 | 220 | |
| 196 | 221 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -679,17 +704,13 @@ public: |
| 679 | 704 | |
| 680 | 705 | template <class _InputIterator> |
| 681 | 706 | forward_list(_InputIterator __f, _InputIterator __l, |
| 682 | typename enable_if< | |
| 683 | __is_cpp17_input_iterator<_InputIterator>::value | |
| 684 | >::type* = nullptr); | |
| 707 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>* = nullptr); | |
| 685 | 708 | template <class _InputIterator> |
| 686 | 709 | forward_list(_InputIterator __f, _InputIterator __l, |
| 687 | 710 | const allocator_type& __a, |
| 688 | typename enable_if< | |
| 689 | __is_cpp17_input_iterator<_InputIterator>::value | |
| 690 | >::type* = nullptr); | |
| 711 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>* = nullptr); | |
| 691 | 712 | forward_list(const forward_list& __x); |
| 692 | forward_list(const forward_list& __x, const __identity_t<allocator_type>& __a); | |
| 713 | forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a); | |
| 693 | 714 | |
| 694 | 715 | forward_list& operator=(const forward_list& __x); |
| 695 | 716 | |
| ... | ... | @@ -698,7 +719,7 @@ public: |
| 698 | 719 | forward_list(forward_list&& __x) |
| 699 | 720 | _NOEXCEPT_(is_nothrow_move_constructible<base>::value) |
| 700 | 721 | : base(_VSTD::move(__x)) {} |
| 701 | forward_list(forward_list&& __x, const __identity_t<allocator_type>& __a); | |
| 722 | forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a); | |
| 702 | 723 | |
| 703 | 724 | forward_list(initializer_list<value_type> __il); |
| 704 | 725 | forward_list(initializer_list<value_type> __il, const allocator_type& __a); |
| ... | ... | @@ -719,11 +740,7 @@ public: |
| 719 | 740 | // ~forward_list() = default; |
| 720 | 741 | |
| 721 | 742 | template <class _InputIterator> |
| 722 | typename enable_if | |
| 723 | < | |
| 724 | __is_cpp17_input_iterator<_InputIterator>::value, | |
| 725 | void | |
| 726 | >::type | |
| 743 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void> | |
| 727 | 744 | assign(_InputIterator __f, _InputIterator __l); |
| 728 | 745 | void assign(size_type __n, const value_type& __v); |
| 729 | 746 | |
| ... | ... | @@ -799,12 +816,8 @@ public: |
| 799 | 816 | iterator insert_after(const_iterator __p, const value_type& __v); |
| 800 | 817 | iterator insert_after(const_iterator __p, size_type __n, const value_type& __v); |
| 801 | 818 | template <class _InputIterator> |
| 802 | _LIBCPP_INLINE_VISIBILITY | |
| 803 | typename enable_if | |
| 804 | < | |
| 805 | __is_cpp17_input_iterator<_InputIterator>::value, | |
| 806 | iterator | |
| 807 | >::type | |
| 819 | _LIBCPP_INLINE_VISIBILITY | |
| 820 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, iterator> | |
| 808 | 821 | insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); |
| 809 | 822 | |
| 810 | 823 | iterator erase_after(const_iterator __p); |
| ... | ... | @@ -953,9 +966,7 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) |
| 953 | 966 | template <class _Tp, class _Alloc> |
| 954 | 967 | template <class _InputIterator> |
| 955 | 968 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, |
| 956 | typename enable_if< | |
| 957 | __is_cpp17_input_iterator<_InputIterator>::value | |
| 958 | >::type*) | |
| 969 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>*) | |
| 959 | 970 | { |
| 960 | 971 | insert_after(cbefore_begin(), __f, __l); |
| 961 | 972 | } |
| ... | ... | @@ -964,9 +975,7 @@ template <class _Tp, class _Alloc> |
| 964 | 975 | template <class _InputIterator> |
| 965 | 976 | forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, |
| 966 | 977 | const allocator_type& __a, |
| 967 | typename enable_if< | |
| 968 | __is_cpp17_input_iterator<_InputIterator>::value | |
| 969 | >::type*) | |
| 978 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>*) | |
| 970 | 979 | : base(__a) |
| 971 | 980 | { |
| 972 | 981 | insert_after(cbefore_begin(), __f, __l); |
| ... | ... | @@ -981,7 +990,7 @@ forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x) |
| 981 | 990 | |
| 982 | 991 | template <class _Tp, class _Alloc> |
| 983 | 992 | forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, |
| 984 | const __identity_t<allocator_type>& __a) | |
| 993 | const __type_identity_t<allocator_type>& __a) | |
| 985 | 994 | : base(__a) |
| 986 | 995 | { |
| 987 | 996 | insert_after(cbefore_begin(), __x.begin(), __x.end()); |
| ... | ... | @@ -1002,7 +1011,7 @@ forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) |
| 1002 | 1011 | #ifndef _LIBCPP_CXX03_LANG |
| 1003 | 1012 | template <class _Tp, class _Alloc> |
| 1004 | 1013 | forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, |
| 1005 | const __identity_t<allocator_type>& __a) | |
| 1014 | const __type_identity_t<allocator_type>& __a) | |
| 1006 | 1015 | : base(_VSTD::move(__x), __a) |
| 1007 | 1016 | { |
| 1008 | 1017 | if (base::__alloc() != __x.__alloc()) |
| ... | ... | @@ -1076,11 +1085,7 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il) |
| 1076 | 1085 | |
| 1077 | 1086 | template <class _Tp, class _Alloc> |
| 1078 | 1087 | template <class _InputIterator> |
| 1079 | typename enable_if | |
| 1080 | < | |
| 1081 | __is_cpp17_input_iterator<_InputIterator>::value, | |
| 1082 | void | |
| 1083 | >::type | |
| 1088 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, void> | |
| 1084 | 1089 | forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) |
| 1085 | 1090 | { |
| 1086 | 1091 | iterator __i = before_begin(); |
| ... | ... | @@ -1272,11 +1277,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, |
| 1272 | 1277 | |
| 1273 | 1278 | template <class _Tp, class _Alloc> |
| 1274 | 1279 | template <class _InputIterator> |
| 1275 | typename enable_if | |
| 1276 | < | |
| 1277 | __is_cpp17_input_iterator<_InputIterator>::value, | |
| 1278 | typename forward_list<_Tp, _Alloc>::iterator | |
| 1279 | >::type | |
| 1280 | __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator> | |
| 1280 | 1281 | forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, |
| 1281 | 1282 | _InputIterator __f, _InputIterator __l) |
| 1282 | 1283 | { |
lib/libcxx/include/fstream+31-13| ... | ... | @@ -179,12 +179,17 @@ typedef basic_fstream<wchar_t> wfstream; |
| 179 | 179 | |
| 180 | 180 | */ |
| 181 | 181 | |
| 182 | #include <__algorithm/max.h> | |
| 183 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 182 | 184 | #include <__availability> |
| 183 | 185 | #include <__config> |
| 184 | #include <__debug> | |
| 185 | 186 | #include <__locale> |
| 187 | #include <__utility/move.h> | |
| 188 | #include <__utility/swap.h> | |
| 189 | #include <__utility/unreachable.h> | |
| 186 | 190 | #include <cstdio> |
| 187 | 191 | #include <cstdlib> |
| 192 | #include <cstring> | |
| 188 | 193 | #include <istream> |
| 189 | 194 | #include <ostream> |
| 190 | 195 | #include <version> |
| ... | ... | @@ -194,7 +199,7 @@ typedef basic_fstream<wchar_t> wfstream; |
| 194 | 199 | #endif |
| 195 | 200 | |
| 196 | 201 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 197 | #pragma GCC system_header | |
| 202 | # pragma GCC system_header | |
| 198 | 203 | #endif |
| 199 | 204 | |
| 200 | 205 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -414,25 +419,38 @@ basic_filebuf<_CharT, _Traits>::swap(basic_filebuf& __rhs) |
| 414 | 419 | basic_streambuf<char_type, traits_type>::swap(__rhs); |
| 415 | 420 | if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_) |
| 416 | 421 | { |
| 417 | _VSTD::swap(__extbuf_, __rhs.__extbuf_); | |
| 418 | _VSTD::swap(__extbufnext_, __rhs.__extbufnext_); | |
| 419 | _VSTD::swap(__extbufend_, __rhs.__extbufend_); | |
| 422 | // Neither *this nor __rhs uses the small buffer, so we can simply swap the pointers. | |
| 423 | std::swap(__extbuf_, __rhs.__extbuf_); | |
| 424 | std::swap(__extbufnext_, __rhs.__extbufnext_); | |
| 425 | std::swap(__extbufend_, __rhs.__extbufend_); | |
| 420 | 426 | } |
| 421 | 427 | else |
| 422 | 428 | { |
| 423 | ptrdiff_t __ln = __extbufnext_ - __extbuf_; | |
| 424 | ptrdiff_t __le = __extbufend_ - __extbuf_; | |
| 425 | ptrdiff_t __rn = __rhs.__extbufnext_ - __rhs.__extbuf_; | |
| 426 | ptrdiff_t __re = __rhs.__extbufend_ - __rhs.__extbuf_; | |
| 429 | ptrdiff_t __ln = __extbufnext_ ? __extbufnext_ - __extbuf_ : 0; | |
| 430 | ptrdiff_t __le = __extbufend_ ? __extbufend_ - __extbuf_ : 0; | |
| 431 | ptrdiff_t __rn = __rhs.__extbufnext_ ? __rhs.__extbufnext_ - __rhs.__extbuf_ : 0; | |
| 432 | ptrdiff_t __re = __rhs.__extbufend_ ? __rhs.__extbufend_ - __rhs.__extbuf_ : 0; | |
| 427 | 433 | if (__extbuf_ == __extbuf_min_ && __rhs.__extbuf_ != __rhs.__extbuf_min_) |
| 428 | 434 | { |
| 435 | // *this uses the small buffer, but __rhs doesn't. | |
| 429 | 436 | __extbuf_ = __rhs.__extbuf_; |
| 430 | 437 | __rhs.__extbuf_ = __rhs.__extbuf_min_; |
| 438 | std::memmove(__rhs.__extbuf_min_, __extbuf_min_, sizeof(__extbuf_min_)); | |
| 431 | 439 | } |
| 432 | 440 | else if (__extbuf_ != __extbuf_min_ && __rhs.__extbuf_ == __rhs.__extbuf_min_) |
| 433 | 441 | { |
| 442 | // *this doesn't use the small buffer, but __rhs does. | |
| 434 | 443 | __rhs.__extbuf_ = __extbuf_; |
| 435 | 444 | __extbuf_ = __extbuf_min_; |
| 445 | std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_)); | |
| 446 | } | |
| 447 | else | |
| 448 | { | |
| 449 | // Both *this and __rhs use the small buffer. | |
| 450 | char __tmp[sizeof(__extbuf_min_)]; | |
| 451 | std::memmove(__tmp, __extbuf_min_, sizeof(__extbuf_min_)); | |
| 452 | std::memmove(__extbuf_min_, __rhs.__extbuf_min_, sizeof(__extbuf_min_)); | |
| 453 | std::memmove(__rhs.__extbuf_min_, __tmp, sizeof(__extbuf_min_)); | |
| 436 | 454 | } |
| 437 | 455 | __extbufnext_ = __extbuf_ + __rn; |
| 438 | 456 | __extbufend_ = __extbuf_ + __re; |
| ... | ... | @@ -538,7 +556,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring( |
| 538 | 556 | default: |
| 539 | 557 | return nullptr; |
| 540 | 558 | } |
| 541 | _LIBCPP_UNREACHABLE(); | |
| 559 | __libcpp_unreachable(); | |
| 542 | 560 | } |
| 543 | 561 | |
| 544 | 562 | template <class _CharT, class _Traits> |
| ... | ... | @@ -1716,9 +1734,9 @@ basic_fstream<_CharT, _Traits>::close() |
| 1716 | 1734 | } |
| 1717 | 1735 | |
| 1718 | 1736 | #if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1) |
| 1719 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>) | |
| 1720 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>) | |
| 1721 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>) | |
| 1737 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>; | |
| 1738 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>; | |
| 1739 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>; | |
| 1722 | 1740 | #endif |
| 1723 | 1741 | |
| 1724 | 1742 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/functional+17-2| ... | ... | @@ -482,6 +482,16 @@ template <> struct hash<long double>; |
| 482 | 482 | template<class T> struct hash<T*>; |
| 483 | 483 | template <> struct hash<nullptr_t>; // C++17 |
| 484 | 484 | |
| 485 | namespace ranges { | |
| 486 | // [range.cmp], concept-constrained comparisons | |
| 487 | struct equal_to; | |
| 488 | struct not_equal_to; | |
| 489 | struct greater; | |
| 490 | struct less; | |
| 491 | struct greater_equal; | |
| 492 | struct less_equal; | |
| 493 | } | |
| 494 | ||
| 485 | 495 | } // std |
| 486 | 496 | |
| 487 | 497 | POLICY: For non-variadic implementations, the number of arguments is limited |
| ... | ... | @@ -491,6 +501,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 491 | 501 | */ |
| 492 | 502 | |
| 493 | 503 | #include <__algorithm/search.h> |
| 504 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 494 | 505 | #include <__compare/compare_three_way.h> |
| 495 | 506 | #include <__config> |
| 496 | 507 | #include <__debug> |
| ... | ... | @@ -501,6 +512,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 501 | 512 | #include <__functional/bind_front.h> |
| 502 | 513 | #include <__functional/binder1st.h> |
| 503 | 514 | #include <__functional/binder2nd.h> |
| 515 | #include <__functional/boyer_moore_searcher.h> | |
| 504 | 516 | #include <__functional/compose.h> |
| 505 | 517 | #include <__functional/default_searcher.h> |
| 506 | 518 | #include <__functional/function.h> |
| ... | ... | @@ -525,11 +537,14 @@ POLICY: For non-variadic implementations, the number of arguments is limited |
| 525 | 537 | #include <tuple> |
| 526 | 538 | #include <type_traits> |
| 527 | 539 | #include <typeinfo> |
| 528 | #include <utility> | |
| 529 | 540 | #include <version> |
| 530 | 541 | |
| 542 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 543 | # include <utility> | |
| 544 | #endif | |
| 545 | ||
| 531 | 546 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 532 | #pragma GCC system_header | |
| 547 | # pragma GCC system_header | |
| 533 | 548 | #endif |
| 534 | 549 | |
| 535 | 550 | #endif // _LIBCPP_FUNCTIONAL |
lib/libcxx/include/future+22-46| ... | ... | @@ -361,14 +361,16 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 361 | 361 | |
| 362 | 362 | */ |
| 363 | 363 | |
| 364 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 364 | 365 | #include <__availability> |
| 366 | #include <__chrono/duration.h> | |
| 367 | #include <__chrono/time_point.h> | |
| 365 | 368 | #include <__config> |
| 366 | #include <__debug> | |
| 367 | 369 | #include <__memory/allocator_arg_t.h> |
| 368 | 370 | #include <__memory/uses_allocator.h> |
| 369 | 371 | #include <__utility/auto_cast.h> |
| 370 | 372 | #include <__utility/forward.h> |
| 371 | #include <chrono> | |
| 373 | #include <__utility/move.h> | |
| 372 | 374 | #include <exception> |
| 373 | 375 | #include <memory> |
| 374 | 376 | #include <mutex> |
| ... | ... | @@ -376,13 +378,17 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; |
| 376 | 378 | #include <thread> |
| 377 | 379 | #include <version> |
| 378 | 380 | |
| 381 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 382 | # include <chrono> | |
| 383 | #endif | |
| 384 | ||
| 379 | 385 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 380 | #pragma GCC system_header | |
| 386 | # pragma GCC system_header | |
| 381 | 387 | #endif |
| 382 | 388 | |
| 383 | 389 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 384 | #error <future> is not supported on this single threaded system | |
| 385 | #else // !_LIBCPP_HAS_NO_THREADS | |
| 390 | # error "<future> is not supported since libc++ has been configured without support for threads." | |
| 391 | #endif | |
| 386 | 392 | |
| 387 | 393 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 388 | 394 | |
| ... | ... | @@ -399,7 +405,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) |
| 399 | 405 | template <> |
| 400 | 406 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {}; |
| 401 | 407 | |
| 402 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 408 | #ifdef _LIBCPP_CXX03_LANG | |
| 403 | 409 | template <> |
| 404 | 410 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type { }; |
| 405 | 411 | #endif |
| ... | ... | @@ -413,7 +419,7 @@ _LIBCPP_DECLARE_STRONG_ENUM(launch) |
| 413 | 419 | }; |
| 414 | 420 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch) |
| 415 | 421 | |
| 416 | #ifndef _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 422 | #ifndef _LIBCPP_CXX03_LANG | |
| 417 | 423 | |
| 418 | 424 | typedef underlying_type<launch>::type __launch_underlying_type; |
| 419 | 425 | |
| ... | ... | @@ -473,7 +479,7 @@ operator^=(launch& __x, launch __y) |
| 473 | 479 | __x = __x ^ __y; return __x; |
| 474 | 480 | } |
| 475 | 481 | |
| 476 | #endif // !_LIBCPP_HAS_NO_STRONG_ENUMS | |
| 482 | #endif // !_LIBCPP_CXX03_LANG | |
| 477 | 483 | |
| 478 | 484 | //enum class future_status |
| 479 | 485 | _LIBCPP_DECLARE_STRONG_ENUM(future_status) |
| ... | ... | @@ -519,12 +525,12 @@ _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
| 519 | 525 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 520 | 526 | _LIBCPP_AVAILABILITY_FUTURE_ERROR |
| 521 | 527 | #endif |
| 522 | void __throw_future_error(future_errc _Ev) | |
| 528 | void __throw_future_error(future_errc __ev) | |
| 523 | 529 | { |
| 524 | 530 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 525 | throw future_error(make_error_code(_Ev)); | |
| 531 | throw future_error(make_error_code(__ev)); | |
| 526 | 532 | #else |
| 527 | ((void)_Ev); | |
| 533 | ((void)__ev); | |
| 528 | 534 | _VSTD::abort(); |
| 529 | 535 | #endif |
| 530 | 536 | } |
| ... | ... | @@ -1100,7 +1106,7 @@ future<_Rp>::future(__assoc_state<_Rp>* __state) |
| 1100 | 1106 | |
| 1101 | 1107 | struct __release_shared_count |
| 1102 | 1108 | { |
| 1103 | void operator()(__shared_count* p) {p->__release_shared();} | |
| 1109 | void operator()(__shared_count* __p) {__p->__release_shared();} | |
| 1104 | 1110 | }; |
| 1105 | 1111 | |
| 1106 | 1112 | template <class _Rp> |
| ... | ... | @@ -1885,25 +1891,11 @@ public: |
| 1885 | 1891 | _LIBCPP_INLINE_VISIBILITY |
| 1886 | 1892 | packaged_task() _NOEXCEPT : __p_(nullptr) {} |
| 1887 | 1893 | template <class _Fp, |
| 1888 | class = typename enable_if | |
| 1889 | < | |
| 1890 | !is_same< | |
| 1891 | typename __uncvref<_Fp>::type, | |
| 1892 | packaged_task | |
| 1893 | >::value | |
| 1894 | >::type | |
| 1895 | > | |
| 1894 | class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> > | |
| 1896 | 1895 | _LIBCPP_INLINE_VISIBILITY |
| 1897 | 1896 | explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} |
| 1898 | 1897 | template <class _Fp, class _Allocator, |
| 1899 | class = typename enable_if | |
| 1900 | < | |
| 1901 | !is_same< | |
| 1902 | typename __uncvref<_Fp>::type, | |
| 1903 | packaged_task | |
| 1904 | >::value | |
| 1905 | >::type | |
| 1906 | > | |
| 1898 | class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> > | |
| 1907 | 1899 | _LIBCPP_INLINE_VISIBILITY |
| 1908 | 1900 | packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) |
| 1909 | 1901 | : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), |
| ... | ... | @@ -2014,25 +2006,11 @@ public: |
| 2014 | 2006 | _LIBCPP_INLINE_VISIBILITY |
| 2015 | 2007 | packaged_task() _NOEXCEPT : __p_(nullptr) {} |
| 2016 | 2008 | template <class _Fp, |
| 2017 | class = typename enable_if | |
| 2018 | < | |
| 2019 | !is_same< | |
| 2020 | typename __uncvref<_Fp>::type, | |
| 2021 | packaged_task | |
| 2022 | >::value | |
| 2023 | >::type | |
| 2024 | > | |
| 2009 | class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> > | |
| 2025 | 2010 | _LIBCPP_INLINE_VISIBILITY |
| 2026 | 2011 | explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} |
| 2027 | 2012 | template <class _Fp, class _Allocator, |
| 2028 | class = typename enable_if | |
| 2029 | < | |
| 2030 | !is_same< | |
| 2031 | typename __uncvref<_Fp>::type, | |
| 2032 | packaged_task | |
| 2033 | >::value | |
| 2034 | >::type | |
| 2035 | > | |
| 2013 | class = __enable_if_t<!is_same<__uncvref_t<_Fp>, packaged_task>::value> > | |
| 2036 | 2014 | _LIBCPP_INLINE_VISIBILITY |
| 2037 | 2015 | packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) |
| 2038 | 2016 | : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), |
| ... | ... | @@ -2458,6 +2436,4 @@ future<void>::share() _NOEXCEPT |
| 2458 | 2436 | |
| 2459 | 2437 | _LIBCPP_END_NAMESPACE_STD |
| 2460 | 2438 | |
| 2461 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 2462 | ||
| 2463 | 2439 | #endif // _LIBCPP_FUTURE |
lib/libcxx/include/initializer_list+2-1| ... | ... | @@ -42,11 +42,12 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in |
| 42 | 42 | |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 45 | 46 | #include <__config> |
| 46 | 47 | #include <cstddef> |
| 47 | 48 | |
| 48 | 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 49 | #pragma GCC system_header | |
| 50 | # pragma GCC system_header | |
| 50 | 51 | #endif |
| 51 | 52 | |
| 52 | 53 | namespace std // purposefully not versioned |
lib/libcxx/include/inttypes.h+1-1| ... | ... | @@ -238,7 +238,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int |
| 238 | 238 | #include <__config> |
| 239 | 239 | |
| 240 | 240 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 241 | #pragma GCC system_header | |
| 241 | # pragma GCC system_header | |
| 242 | 242 | #endif |
| 243 | 243 | |
| 244 | 244 | /* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed |
lib/libcxx/include/iomanip+84-91| ... | ... | @@ -42,13 +42,13 @@ template <class charT, class traits, class Allocator> |
| 42 | 42 | |
| 43 | 43 | */ |
| 44 | 44 | |
| 45 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 45 | 46 | #include <__config> |
| 46 | #include <__string> | |
| 47 | 47 | #include <istream> |
| 48 | 48 | #include <version> |
| 49 | 49 | |
| 50 | 50 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 51 | #pragma GCC system_header | |
| 51 | # pragma GCC system_header | |
| 52 | 52 | #endif |
| 53 | 53 | |
| 54 | 54 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -513,16 +513,17 @@ put_time(const tm* __tm, const _CharT* __fmt) |
| 513 | 513 | return __iom_t10<_CharT>(__tm, __fmt); |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | template <class _CharT, class _Traits, class _ForwardIterator> | |
| 517 | basic_ostream<_CharT, _Traits> & | |
| 518 | __quoted_output ( basic_ostream<_CharT, _Traits> &__os, | |
| 519 | _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) | |
| 516 | #if _LIBCPP_STD_VER >= 11 | |
| 517 | ||
| 518 | template <class _CharT, class _Traits> | |
| 519 | _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | |
| 520 | __quoted_output(basic_ostream<_CharT, _Traits>& __os, | |
| 521 | const _CharT *__first, const _CharT *__last, _CharT __delim, _CharT __escape) | |
| 520 | 522 | { |
| 521 | 523 | basic_string<_CharT, _Traits> __str; |
| 522 | 524 | __str.push_back(__delim); |
| 523 | for ( ; __first != __last; ++ __first ) | |
| 524 | { | |
| 525 | if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) | |
| 525 | for (; __first != __last; ++__first) { | |
| 526 | if (_Traits::eq(*__first, __escape) || _Traits::eq(*__first, __delim)) | |
| 526 | 527 | __str.push_back(__escape); |
| 527 | 528 | __str.push_back(*__first); |
| 528 | 529 | } |
| ... | ... | @@ -531,139 +532,131 @@ __quoted_output ( basic_ostream<_CharT, _Traits> &__os, |
| 531 | 532 | } |
| 532 | 533 | |
| 533 | 534 | template <class _CharT, class _Traits, class _String> |
| 534 | basic_istream<_CharT, _Traits> & | |
| 535 | __quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape ) | |
| 535 | _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& | |
| 536 | __quoted_input(basic_istream<_CharT, _Traits>& __is, _String& __string, _CharT __delim, _CharT __escape) | |
| 536 | 537 | { |
| 537 | __string.clear (); | |
| 538 | __string.clear(); | |
| 538 | 539 | _CharT __c; |
| 539 | 540 | __is >> __c; |
| 540 | if ( __is.fail ()) | |
| 541 | if (__is.fail()) | |
| 541 | 542 | return __is; |
| 542 | 543 | |
| 543 | if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string | |
| 544 | { | |
| 545 | __is.unget (); | |
| 544 | if (!_Traits::eq(__c, __delim)) { | |
| 545 | // no delimiter, read the whole string | |
| 546 | __is.unget(); | |
| 546 | 547 | __is >> __string; |
| 547 | 548 | return __is; |
| 548 | 549 | } |
| 549 | 550 | |
| 550 | __save_flags<_CharT, _Traits> sf(__is); | |
| 551 | noskipws (__is); | |
| 552 | while (true) | |
| 553 | { | |
| 551 | __save_flags<_CharT, _Traits> __sf(__is); | |
| 552 | std::noskipws(__is); | |
| 553 | while (true) { | |
| 554 | 554 | __is >> __c; |
| 555 | if ( __is.fail ()) | |
| 555 | if (__is.fail()) | |
| 556 | 556 | break; |
| 557 | if (_Traits::eq (__c, __escape)) | |
| 558 | { | |
| 557 | if (_Traits::eq(__c, __escape)) { | |
| 559 | 558 | __is >> __c; |
| 560 | if ( __is.fail ()) | |
| 559 | if (__is.fail()) | |
| 561 | 560 | break; |
| 562 | } | |
| 563 | else if (_Traits::eq (__c, __delim)) | |
| 561 | } else if (_Traits::eq(__c, __delim)) | |
| 564 | 562 | break; |
| 565 | __string.push_back ( __c ); | |
| 566 | } | |
| 563 | __string.push_back(__c); | |
| 564 | } | |
| 567 | 565 | return __is; |
| 568 | 566 | } |
| 569 | 567 | |
| 570 | ||
| 571 | template <class _CharT, class _Traits, class _Iter> | |
| 572 | basic_ostream<_CharT, _Traits>& operator<<( | |
| 573 | basic_ostream<_CharT, _Traits>& __os, | |
| 574 | const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy) | |
| 568 | template <class _CharT, class _Traits> | |
| 569 | struct _LIBCPP_HIDDEN __quoted_output_proxy | |
| 575 | 570 | { |
| 576 | return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape); | |
| 577 | } | |
| 571 | const _CharT *__first_; | |
| 572 | const _CharT *__last_; | |
| 573 | _CharT __delim_; | |
| 574 | _CharT __escape_; | |
| 578 | 575 | |
| 579 | template <class _CharT, class _Traits, class _Allocator> | |
| 580 | struct __quoted_proxy | |
| 581 | { | |
| 582 | basic_string<_CharT, _Traits, _Allocator> &__string; | |
| 583 | _CharT __delim; | |
| 584 | _CharT __escape; | |
| 576 | _LIBCPP_HIDE_FROM_ABI | |
| 577 | explicit __quoted_output_proxy(const _CharT *__f, const _CharT *__l, _CharT __d, _CharT __e) | |
| 578 | : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {} | |
| 585 | 579 | |
| 586 | __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e) | |
| 587 | : __string(__s), __delim(__d), __escape(__e) {} | |
| 580 | template<class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value>* = nullptr> | |
| 581 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>& | |
| 582 | operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) { | |
| 583 | return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_); | |
| 584 | } | |
| 588 | 585 | }; |
| 589 | 586 | |
| 590 | 587 | template <class _CharT, class _Traits, class _Allocator> |
| 591 | _LIBCPP_INLINE_VISIBILITY | |
| 592 | basic_ostream<_CharT, _Traits>& operator<<( | |
| 593 | basic_ostream<_CharT, _Traits>& __os, | |
| 594 | const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) | |
| 588 | struct _LIBCPP_HIDDEN __quoted_proxy | |
| 595 | 589 | { |
| 596 | return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape); | |
| 597 | } | |
| 598 | ||
| 599 | // extractor for non-const basic_string& proxies | |
| 600 | template <class _CharT, class _Traits, class _Allocator> | |
| 601 | _LIBCPP_INLINE_VISIBILITY | |
| 602 | basic_istream<_CharT, _Traits>& operator>>( | |
| 603 | basic_istream<_CharT, _Traits>& __is, | |
| 604 | const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) | |
| 605 | { | |
| 606 | return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape ); | |
| 607 | } | |
| 590 | basic_string<_CharT, _Traits, _Allocator>& __string_; | |
| 591 | _CharT __delim_; | |
| 592 | _CharT __escape_; | |
| 608 | 593 | |
| 594 | _LIBCPP_HIDE_FROM_ABI | |
| 595 | explicit __quoted_proxy(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __d, _CharT __e) | |
| 596 | : __string_(__s), __delim_(__d), __escape_(__e) {} | |
| 609 | 597 | |
| 610 | template <class _CharT> | |
| 611 | _LIBCPP_INLINE_VISIBILITY | |
| 612 | __quoted_output_proxy<_CharT, const _CharT *> | |
| 613 | quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\')) | |
| 614 | { | |
| 615 | const _CharT *__end = __s; | |
| 616 | while ( *__end ) ++__end; | |
| 617 | return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); | |
| 618 | } | |
| 598 | friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& | |
| 599 | operator<<(basic_ostream<_CharT, _Traits>& __os, const __quoted_proxy& __p) { | |
| 600 | return std::__quoted_output(__os, __p.__string_.data(), __p.__string_.data() + __p.__string_.size(), __p.__delim_, __p.__escape_); | |
| 601 | } | |
| 619 | 602 | |
| 603 | friend _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& | |
| 604 | operator>>(basic_istream<_CharT, _Traits>& __is, const __quoted_proxy& __p) { | |
| 605 | return std::__quoted_input(__is, __p.__string_, __p.__delim_, __p.__escape_); | |
| 606 | } | |
| 607 | }; | |
| 620 | 608 | |
| 621 | 609 | template <class _CharT, class _Traits, class _Allocator> |
| 622 | _LIBCPP_INLINE_VISIBILITY | |
| 623 | __quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> | |
| 624 | __quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) | |
| 610 | _LIBCPP_HIDE_FROM_ABI | |
| 611 | __quoted_output_proxy<_CharT, _Traits> | |
| 612 | __quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) | |
| 625 | 613 | { |
| 626 | return __quoted_output_proxy<_CharT, | |
| 627 | typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> | |
| 628 | ( __s.cbegin(), __s.cend (), __delim, __escape ); | |
| 614 | return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape); | |
| 629 | 615 | } |
| 630 | 616 | |
| 631 | 617 | template <class _CharT, class _Traits, class _Allocator> |
| 632 | _LIBCPP_INLINE_VISIBILITY | |
| 618 | _LIBCPP_HIDE_FROM_ABI | |
| 633 | 619 | __quoted_proxy<_CharT, _Traits, _Allocator> |
| 634 | __quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) | |
| 620 | __quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) | |
| 635 | 621 | { |
| 636 | return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); | |
| 622 | return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); | |
| 637 | 623 | } |
| 638 | 624 | |
| 625 | #endif // _LIBCPP_STD_VER >= 11 | |
| 639 | 626 | |
| 640 | 627 | #if _LIBCPP_STD_VER > 11 |
| 641 | 628 | |
| 629 | template <class _CharT> | |
| 630 | _LIBCPP_HIDE_FROM_ABI | |
| 631 | auto quoted(const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) | |
| 632 | { | |
| 633 | const _CharT *__end = __s; | |
| 634 | while (*__end) ++__end; | |
| 635 | return __quoted_output_proxy<_CharT, void>(__s, __end, __delim, __escape); | |
| 636 | } | |
| 637 | ||
| 642 | 638 | template <class _CharT, class _Traits, class _Allocator> |
| 643 | _LIBCPP_INLINE_VISIBILITY | |
| 644 | __quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> | |
| 645 | quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) | |
| 639 | _LIBCPP_HIDE_FROM_ABI | |
| 640 | auto quoted(const basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) | |
| 646 | 641 | { |
| 647 | return __quoted(__s, __delim, __escape); | |
| 642 | return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape); | |
| 648 | 643 | } |
| 649 | 644 | |
| 650 | 645 | template <class _CharT, class _Traits, class _Allocator> |
| 651 | _LIBCPP_INLINE_VISIBILITY | |
| 652 | __quoted_proxy<_CharT, _Traits, _Allocator> | |
| 653 | quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) | |
| 646 | _LIBCPP_HIDE_FROM_ABI | |
| 647 | auto quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) | |
| 654 | 648 | { |
| 655 | return __quoted(__s, __delim, __escape); | |
| 649 | return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape); | |
| 656 | 650 | } |
| 657 | 651 | |
| 658 | 652 | template <class _CharT, class _Traits> |
| 659 | __quoted_output_proxy<_CharT, const _CharT *, _Traits> | |
| 660 | quoted (basic_string_view <_CharT, _Traits> __sv, | |
| 661 | _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) | |
| 653 | _LIBCPP_HIDE_FROM_ABI | |
| 654 | auto quoted(basic_string_view<_CharT, _Traits> __sv, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) | |
| 662 | 655 | { |
| 663 | return __quoted_output_proxy<_CharT, const _CharT *, _Traits> | |
| 664 | ( __sv.data(), __sv.data() + __sv.size(), __delim, __escape ); | |
| 656 | return __quoted_output_proxy<_CharT, _Traits>(__sv.data(), __sv.data() + __sv.size(), __delim, __escape); | |
| 665 | 657 | } |
| 666 | #endif | |
| 658 | ||
| 659 | #endif // _LIBCPP_STD_VER > 11 | |
| 667 | 660 | |
| 668 | 661 | _LIBCPP_END_NAMESPACE_STD |
| 669 | 662 |
lib/libcxx/include/ios+15-3| ... | ... | @@ -211,17 +211,27 @@ storage-class-specifier const error_category& iostream_category() noexcept; |
| 211 | 211 | */ |
| 212 | 212 | |
| 213 | 213 | #include <__config> |
| 214 | ||
| 215 | #if defined(_LIBCPP_HAS_NO_LOCALIZATION) | |
| 216 | # error "The iostreams library is not supported since libc++ has been configured without support for localization." | |
| 217 | #endif | |
| 218 | ||
| 219 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 220 | #include <__ios/fpos.h> | |
| 214 | 221 | #include <__locale> |
| 215 | #include <iosfwd> | |
| 222 | #include <__utility/swap.h> | |
| 216 | 223 | #include <system_error> |
| 217 | 224 | #include <version> |
| 218 | 225 | |
| 226 | // standard-mandated includes | |
| 227 | #include <iosfwd> | |
| 228 | ||
| 219 | 229 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
| 220 | 230 | #include <atomic> // for __xindex_ |
| 221 | 231 | #endif |
| 222 | 232 | |
| 223 | 233 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 224 | #pragma GCC system_header | |
| 234 | # pragma GCC system_header | |
| 225 | 235 | #endif |
| 226 | 236 | |
| 227 | 237 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -402,7 +412,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) |
| 402 | 412 | template <> |
| 403 | 413 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { }; |
| 404 | 414 | |
| 405 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 415 | #ifdef _LIBCPP_CXX03_LANG | |
| 406 | 416 | template <> |
| 407 | 417 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { }; |
| 408 | 418 | #endif |
| ... | ... | @@ -780,6 +790,8 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 780 | 790 | _CharT |
| 781 | 791 | basic_ios<_CharT, _Traits>::fill(char_type __ch) |
| 782 | 792 | { |
| 793 | if (traits_type::eq_int_type(traits_type::eof(), __fill_)) | |
| 794 | __fill_ = widen(' '); | |
| 783 | 795 | char_type __r = __fill_; |
| 784 | 796 | __fill_ = __ch; |
| 785 | 797 | return __r; |
lib/libcxx/include/iosfwd+2-3| ... | ... | @@ -94,12 +94,13 @@ using u32streampos = fpos<char_traits<char32_t>::state_type>; |
| 94 | 94 | |
| 95 | 95 | */ |
| 96 | 96 | |
| 97 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 97 | 98 | #include <__config> |
| 98 | 99 | #include <__mbstate_t.h> |
| 99 | 100 | #include <version> |
| 100 | 101 | |
| 101 | 102 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 102 | #pragma GCC system_header | |
| 103 | # pragma GCC system_header | |
| 103 | 104 | #endif |
| 104 | 105 | |
| 105 | 106 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -231,10 +232,8 @@ typedef fpos<mbstate_t> wstreampos; |
| 231 | 232 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 232 | 233 | typedef fpos<mbstate_t> u8streampos; |
| 233 | 234 | #endif |
| 234 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 235 | 235 | typedef fpos<mbstate_t> u16streampos; |
| 236 | 236 | typedef fpos<mbstate_t> u32streampos; |
| 237 | #endif | |
| 238 | 237 | |
| 239 | 238 | #if defined(_NEWLIB_VERSION) |
| 240 | 239 | // On newlib, off_t is 'long int' |
lib/libcxx/include/iostream+5-2| ... | ... | @@ -33,15 +33,18 @@ extern wostream wclog; |
| 33 | 33 | |
| 34 | 34 | */ |
| 35 | 35 | |
| 36 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 36 | 37 | #include <__config> |
| 38 | #include <version> | |
| 39 | ||
| 40 | // standard-mandated includes | |
| 37 | 41 | #include <ios> |
| 38 | 42 | #include <istream> |
| 39 | 43 | #include <ostream> |
| 40 | 44 | #include <streambuf> |
| 41 | #include <version> | |
| 42 | 45 | |
| 43 | 46 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 44 | #pragma GCC system_header | |
| 47 | # pragma GCC system_header | |
| 45 | 48 | #endif |
| 46 | 49 | |
| 47 | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/istream+7-5| ... | ... | @@ -158,13 +158,15 @@ template <class Stream, class T> |
| 158 | 158 | |
| 159 | 159 | */ |
| 160 | 160 | |
| 161 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 161 | 162 | #include <__config> |
| 163 | #include <__iterator/istreambuf_iterator.h> | |
| 162 | 164 | #include <__utility/forward.h> |
| 163 | 165 | #include <ostream> |
| 164 | 166 | #include <version> |
| 165 | 167 | |
| 166 | 168 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 167 | #pragma GCC system_header | |
| 169 | # pragma GCC system_header | |
| 168 | 170 | #endif |
| 169 | 171 | |
| 170 | 172 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -1592,7 +1594,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) |
| 1592 | 1594 | size_t __c = 0; |
| 1593 | 1595 | _CharT __zero = __ct.widen('0'); |
| 1594 | 1596 | _CharT __one = __ct.widen('1'); |
| 1595 | while (__c < _Size) | |
| 1597 | while (__c != _Size) | |
| 1596 | 1598 | { |
| 1597 | 1599 | typename _Traits::int_type __i = __is.rdbuf()->sgetc(); |
| 1598 | 1600 | if (_Traits::eq_int_type(__i, _Traits::eof())) |
| ... | ... | @@ -1627,11 +1629,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) |
| 1627 | 1629 | return __is; |
| 1628 | 1630 | } |
| 1629 | 1631 | |
| 1630 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>) | |
| 1632 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<char>; | |
| 1631 | 1633 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1632 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>) | |
| 1634 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>; | |
| 1633 | 1635 | #endif |
| 1634 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>) | |
| 1636 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>; | |
| 1635 | 1637 | |
| 1636 | 1638 | _LIBCPP_END_NAMESPACE_STD |
| 1637 | 1639 |
lib/libcxx/include/iterator+132-29| ... | ... | @@ -136,6 +136,13 @@ template<class In, class Out> |
| 136 | 136 | template<class In, class Out> |
| 137 | 137 | concept indirectly_movable_storable = see below; // since C++20 |
| 138 | 138 | |
| 139 | // [alg.req.ind.copy], concept indirectly_copyable | |
| 140 | template<class In, class Out> | |
| 141 | concept indirectly_copyable = see below; // since C++20 | |
| 142 | ||
| 143 | template<class In, class Out> | |
| 144 | concept indirectly_copyable_storable = see below; // since C++20 | |
| 145 | ||
| 139 | 146 | // [alg.req.ind.swap], concept indirectly_swappable |
| 140 | 147 | template<class I1, class I2 = I1> |
| 141 | 148 | concept indirectly_swappable = see below; // since C++20 |
| ... | ... | @@ -145,6 +152,19 @@ template<class I1, class I2, class R, class P1 = identity, |
| 145 | 152 | concept indirectly_comparable = |
| 146 | 153 | indirect_binary_predicate<R, projected<I1, P1>, projected<I2, P2>>; // since C++20 |
| 147 | 154 | |
| 155 | // [alg.req.permutable], concept permutable | |
| 156 | template<class I> | |
| 157 | concept permutable = see below; // since C++20 | |
| 158 | ||
| 159 | // [alg.req.mergeable], concept mergeable | |
| 160 | template<class I1, class I2, class Out, | |
| 161 | class R = ranges::less, class P1 = identity, class P2 = identity> | |
| 162 | concept mergeable = see below; // since C++20 | |
| 163 | ||
| 164 | // [alg.req.sortable], concept sortable | |
| 165 | template<class I, class R = ranges::less, class P = identity> | |
| 166 | concept sortable = see below; // since C++20 | |
| 167 | ||
| 148 | 168 | template<input_or_output_iterator I, sentinel_for<I> S> |
| 149 | 169 | requires (!same_as<I, S> && copyable<I>) |
| 150 | 170 | class common_iterator; // since C++20 |
| ... | ... | @@ -165,6 +185,7 @@ struct output_iterator_tag {}; |
| 165 | 185 | struct forward_iterator_tag : public input_iterator_tag {}; |
| 166 | 186 | struct bidirectional_iterator_tag : public forward_iterator_tag {}; |
| 167 | 187 | struct random_access_iterator_tag : public bidirectional_iterator_tag {}; |
| 188 | struct contiguous_iterator_tag : public random_access_iterator_tag {}; | |
| 168 | 189 | |
| 169 | 190 | // 27.4.3, iterator operations |
| 170 | 191 | template <class InputIterator, class Distance> // constexpr in C++17 |
| ... | ... | @@ -204,10 +225,17 @@ class reverse_iterator |
| 204 | 225 | protected: |
| 205 | 226 | Iterator current; |
| 206 | 227 | public: |
| 207 | typedef Iterator iterator_type; | |
| 208 | typedef typename iterator_traits<Iterator>::difference_type difference_type; | |
| 209 | typedef typename iterator_traits<Iterator>::reference reference; | |
| 210 | typedef typename iterator_traits<Iterator>::pointer pointer; | |
| 228 | using iterator_type = Iterator; | |
| 229 | using iterator_concept = see below; // since C++20 | |
| 230 | using iterator_category = typename iterator_traits<Iterator>::iterator_category; // since C++17, until C++20 | |
| 231 | using iterator_category = see below; // since C++20 | |
| 232 | using value_type = typename iterator_traits<Iterator>::value_type; // since C++17, until C++20 | |
| 233 | using value_type = iter_value_t<Iterator>; // since C++20 | |
| 234 | using difference_type = typename iterator_traits<Iterator>::difference_type; // until C++20 | |
| 235 | using difference_type = iter_difference_t<Iterator>; // since C++20 | |
| 236 | using pointer = typename iterator_traits<Iterator>::pointer; | |
| 237 | using reference = typename iterator_traits<Iterator>::reference; // until C++20 | |
| 238 | using reference = iter_reference_t<Iterator>; // since C++20 | |
| 211 | 239 | |
| 212 | 240 | constexpr reverse_iterator(); |
| 213 | 241 | constexpr explicit reverse_iterator(Iterator x); |
| ... | ... | @@ -215,7 +243,8 @@ public: |
| 215 | 243 | template <class U> constexpr reverse_iterator& operator=(const reverse_iterator<U>& u); |
| 216 | 244 | constexpr Iterator base() const; |
| 217 | 245 | constexpr reference operator*() const; |
| 218 | constexpr pointer operator->() const; | |
| 246 | constexpr pointer operator->() const; // until C++20 | |
| 247 | constexpr pointer operator->() const requires see below; // since C++20 | |
| 219 | 248 | constexpr reverse_iterator& operator++(); |
| 220 | 249 | constexpr reverse_iterator operator++(int); |
| 221 | 250 | constexpr reverse_iterator& operator--(); |
| ... | ... | @@ -224,7 +253,14 @@ public: |
| 224 | 253 | constexpr reverse_iterator& operator+=(difference_type n); |
| 225 | 254 | constexpr reverse_iterator operator- (difference_type n) const; |
| 226 | 255 | constexpr reverse_iterator& operator-=(difference_type n); |
| 227 | constexpr reference operator[](difference_type n) const; | |
| 256 | constexpr unspecified operator[](difference_type n) const; | |
| 257 | ||
| 258 | friend constexpr iter_rvalue_reference_t<Iterator> | |
| 259 | iter_move(const reverse_iterator& i) noexcept(see below); | |
| 260 | template<indirectly_swappable<Iterator> Iterator2> | |
| 261 | friend constexpr void | |
| 262 | iter_swap(const reverse_iterator& x, | |
| 263 | const reverse_iterator<Iterator2>& y) noexcept(see below); | |
| 228 | 264 | }; |
| 229 | 265 | |
| 230 | 266 | template <class Iterator1, class Iterator2> |
| ... | ... | @@ -233,11 +269,11 @@ operator==(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator |
| 233 | 269 | |
| 234 | 270 | template <class Iterator1, class Iterator2> |
| 235 | 271 | constexpr bool // constexpr in C++17 |
| 236 | operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 272 | operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 237 | 273 | |
| 238 | 274 | template <class Iterator1, class Iterator2> |
| 239 | 275 | constexpr bool // constexpr in C++17 |
| 240 | operator!=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 276 | operator<(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 241 | 277 | |
| 242 | 278 | template <class Iterator1, class Iterator2> |
| 243 | 279 | constexpr bool // constexpr in C++17 |
| ... | ... | @@ -245,11 +281,16 @@ operator>(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2 |
| 245 | 281 | |
| 246 | 282 | template <class Iterator1, class Iterator2> |
| 247 | 283 | constexpr bool // constexpr in C++17 |
| 248 | operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 284 | operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 249 | 285 | |
| 250 | 286 | template <class Iterator1, class Iterator2> |
| 251 | 287 | constexpr bool // constexpr in C++17 |
| 252 | operator<=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 288 | operator>=(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2>& y); | |
| 289 | ||
| 290 | template<class Iterator1, three_way_comparable_with<Iterator1> Iterator2> | |
| 291 | constexpr compare_three_way_result_t<Iterator1, Iterator2> | |
| 292 | operator<=>(const reverse_iterator<Iterator1>& x, | |
| 293 | const reverse_iterator<Iterator2>& y); | |
| 253 | 294 | |
| 254 | 295 | template <class Iterator1, class Iterator2> |
| 255 | 296 | constexpr auto |
| ... | ... | @@ -264,6 +305,11 @@ operator+(typename reverse_iterator<Iterator>::difference_type n, |
| 264 | 305 | template <class Iterator> |
| 265 | 306 | constexpr reverse_iterator<Iterator> make_reverse_iterator(Iterator i); // C++14, constexpr in C++17 |
| 266 | 307 | |
| 308 | template<class Iterator1, class Iterator2> | |
| 309 | requires (!sized_sentinel_for<Iterator1, Iterator2>) | |
| 310 | inline constexpr bool disable_sized_sentinel_for<reverse_iterator<Iterator1>, | |
| 311 | reverse_iterator<Iterator2>> = true; | |
| 312 | ||
| 267 | 313 | template <class Container> |
| 268 | 314 | class back_insert_iterator |
| 269 | 315 | : public iterator<output_iterator_tag, void, void, void, void> // until C++17 |
| ... | ... | @@ -332,18 +378,21 @@ public: |
| 332 | 378 | insert_iterator& operator++(int); // constexpr in C++20 |
| 333 | 379 | }; |
| 334 | 380 | |
| 335 | template <class Container, class Iterator> | |
| 336 | insert_iterator<Container> inserter(Container& x, Iterator i); // constexpr in C++20 | |
| 381 | template <class Container> | |
| 382 | insert_iterator<Container> inserter(Container& x, typename Container::iterator i); // until C++20 | |
| 383 | template <class Container> | |
| 384 | constexpr insert_iterator<Container> inserter(Container& x, ranges::iterator_t<Container> i); // since C++20 | |
| 337 | 385 | |
| 338 | 386 | template <class Iterator> |
| 339 | 387 | class move_iterator { |
| 340 | 388 | public: |
| 341 | typedef Iterator iterator_type; | |
| 342 | typedef typename iterator_traits<Iterator>::difference_type difference_type; | |
| 343 | typedef Iterator pointer; | |
| 344 | typedef typename iterator_traits<Iterator>::value_type value_type; | |
| 345 | typedef typename iterator_traits<Iterator>::iterator_category iterator_category; | |
| 346 | typedef value_type&& reference; | |
| 389 | using iterator_type = Iterator; | |
| 390 | using iterator_concept = input_iterator_tag; // From C++20 | |
| 391 | using iterator_category = see below; // not always present starting from C++20 | |
| 392 | using value_type = iter_value_t<Iterator>; // Until C++20, iterator_traits<Iterator>::value_type | |
| 393 | using difference_type = iter_difference_t<Iterator>; // Until C++20, iterator_traits<Iterator>::difference_type; | |
| 394 | using pointer = Iterator; | |
| 395 | using reference = iter_rvalue_reference_t<Iterator>; // Until C++20, value_type&& | |
| 347 | 396 | |
| 348 | 397 | constexpr move_iterator(); // all the constexprs are in C++17 |
| 349 | 398 | constexpr explicit move_iterator(Iterator i); |
| ... | ... | @@ -351,18 +400,40 @@ public: |
| 351 | 400 | constexpr move_iterator(const move_iterator<U>& u); |
| 352 | 401 | template <class U> |
| 353 | 402 | constexpr move_iterator& operator=(const move_iterator<U>& u); |
| 354 | constexpr iterator_type base() const; | |
| 403 | ||
| 404 | constexpr iterator_type base() const; // Until C++20 | |
| 405 | constexpr const Iterator& base() const & noexcept; // From C++20 | |
| 406 | constexpr Iterator base() &&; // From C++20 | |
| 407 | ||
| 355 | 408 | constexpr reference operator*() const; |
| 356 | constexpr pointer operator->() const; | |
| 409 | constexpr pointer operator->() const; // Deprecated in C++20 | |
| 357 | 410 | constexpr move_iterator& operator++(); |
| 358 | constexpr move_iterator operator++(int); | |
| 411 | constexpr auto operator++(int); // Return type was move_iterator until C++20 | |
| 359 | 412 | constexpr move_iterator& operator--(); |
| 360 | 413 | constexpr move_iterator operator--(int); |
| 361 | 414 | constexpr move_iterator operator+(difference_type n) const; |
| 362 | 415 | constexpr move_iterator& operator+=(difference_type n); |
| 363 | 416 | constexpr move_iterator operator-(difference_type n) const; |
| 364 | 417 | constexpr move_iterator& operator-=(difference_type n); |
| 365 | constexpr unspecified operator[](difference_type n) const; | |
| 418 | constexpr reference operator[](difference_type n) const; // Return type unspecified until C++20 | |
| 419 | ||
| 420 | template<sentinel_for<Iterator> S> | |
| 421 | friend constexpr bool | |
| 422 | operator==(const move_iterator& x, const move_sentinel<S>& y); // Since C++20 | |
| 423 | template<sized_sentinel_for<Iterator> S> | |
| 424 | friend constexpr iter_difference_t<Iterator> | |
| 425 | operator-(const move_sentinel<S>& x, const move_iterator& y); // Since C++20 | |
| 426 | template<sized_sentinel_for<Iterator> S> | |
| 427 | friend constexpr iter_difference_t<Iterator> | |
| 428 | operator-(const move_iterator& x, const move_sentinel<S>& y); // Since C++20 | |
| 429 | friend constexpr iter_rvalue_reference_t<Iterator> | |
| 430 | iter_move(const move_iterator& i) | |
| 431 | noexcept(noexcept(ranges::iter_move(i.current))); // Since C++20 | |
| 432 | template<indirectly_swappable<Iterator> Iterator2> | |
| 433 | friend constexpr void | |
| 434 | iter_swap(const move_iterator& x, const move_iterator<Iterator2>& y) | |
| 435 | noexcept(noexcept(ranges::iter_swap(x.current, y.current))); // Since C++20 | |
| 436 | ||
| 366 | 437 | private: |
| 367 | 438 | Iterator current; // exposition only |
| 368 | 439 | }; |
| ... | ... | @@ -404,6 +475,23 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17 |
| 404 | 475 | template <class Iterator> // constexpr in C++17 |
| 405 | 476 | constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i); |
| 406 | 477 | |
| 478 | template<semiregular S> | |
| 479 | class move_sentinel { | |
| 480 | public: | |
| 481 | constexpr move_sentinel(); | |
| 482 | constexpr explicit move_sentinel(S s); | |
| 483 | template<class S2> | |
| 484 | requires convertible_to<const S2&, S> | |
| 485 | constexpr move_sentinel(const move_sentinel<S2>& s); | |
| 486 | template<class S2> | |
| 487 | requires assignable_from<S&, const S2&> | |
| 488 | constexpr move_sentinel& operator=(const move_sentinel<S2>& s); | |
| 489 | ||
| 490 | constexpr S base() const; | |
| 491 | private: | |
| 492 | S last; // exposition only | |
| 493 | }; | |
| 494 | ||
| 407 | 495 | // [default.sentinel], default sentinel |
| 408 | 496 | struct default_sentinel_t; |
| 409 | 497 | inline constexpr default_sentinel_t default_sentinel{}; |
| ... | ... | @@ -434,7 +522,8 @@ public: |
| 434 | 522 | typedef traits traits_type; |
| 435 | 523 | typedef basic_istream<charT, traits> istream_type; |
| 436 | 524 | |
| 437 | constexpr istream_iterator(); | |
| 525 | istream_iterator(); // constexpr since C++11 | |
| 526 | constexpr istream_iterator(default_sentinel_t); // since C++20 | |
| 438 | 527 | istream_iterator(istream_type& s); |
| 439 | 528 | istream_iterator(const istream_iterator& x); |
| 440 | 529 | ~istream_iterator(); |
| ... | ... | @@ -443,6 +532,7 @@ public: |
| 443 | 532 | const T* operator->() const; |
| 444 | 533 | istream_iterator& operator++(); |
| 445 | 534 | istream_iterator operator++(int); |
| 535 | friend bool operator==(const istream_iterator& i, default_sentinel_t); // since C++20 | |
| 446 | 536 | }; |
| 447 | 537 | |
| 448 | 538 | template <class T, class charT, class traits, class Distance> |
| ... | ... | @@ -450,7 +540,7 @@ bool operator==(const istream_iterator<T,charT,traits,Distance>& x, |
| 450 | 540 | const istream_iterator<T,charT,traits,Distance>& y); |
| 451 | 541 | template <class T, class charT, class traits, class Distance> |
| 452 | 542 | bool operator!=(const istream_iterator<T,charT,traits,Distance>& x, |
| 453 | const istream_iterator<T,charT,traits,Distance>& y); | |
| 543 | const istream_iterator<T,charT,traits,Distance>& y); // until C++20 | |
| 454 | 544 | |
| 455 | 545 | template <class T, class charT = char, class traits = char_traits<charT> > |
| 456 | 546 | class ostream_iterator |
| ... | ... | @@ -496,7 +586,8 @@ public: |
| 496 | 586 | typedef basic_streambuf<charT, traits> streambuf_type; |
| 497 | 587 | typedef basic_istream<charT, traits> istream_type; |
| 498 | 588 | |
| 499 | istreambuf_iterator() noexcept; | |
| 589 | istreambuf_iterator() noexcept; // constexpr since C++11 | |
| 590 | constexpr istreambuf_iterator(default_sentinel_t) noexcept; // since C++20 | |
| 500 | 591 | istreambuf_iterator(istream_type& s) noexcept; |
| 501 | 592 | istreambuf_iterator(streambuf_type* s) noexcept; |
| 502 | 593 | istreambuf_iterator(a-private-type) noexcept; |
| ... | ... | @@ -507,6 +598,7 @@ public: |
| 507 | 598 | a-private-type operator++(int); |
| 508 | 599 | |
| 509 | 600 | bool equal(const istreambuf_iterator& b) const; |
| 601 | friend bool operator==(const istreambuf_iterator& i, default_sentinel_t s); // since C++20 | |
| 510 | 602 | }; |
| 511 | 603 | |
| 512 | 604 | template <class charT, class traits> |
| ... | ... | @@ -514,7 +606,7 @@ bool operator==(const istreambuf_iterator<charT,traits>& a, |
| 514 | 606 | const istreambuf_iterator<charT,traits>& b); |
| 515 | 607 | template <class charT, class traits> |
| 516 | 608 | bool operator!=(const istreambuf_iterator<charT,traits>& a, |
| 517 | const istreambuf_iterator<charT,traits>& b); | |
| 609 | const istreambuf_iterator<charT,traits>& b); // until C++20 | |
| 518 | 610 | |
| 519 | 611 | template <class charT, class traits = char_traits<charT> > |
| 520 | 612 | class ostreambuf_iterator |
| ... | ... | @@ -582,12 +674,13 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 582 | 674 | |
| 583 | 675 | */ |
| 584 | 676 | |
| 677 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 585 | 678 | #include <__config> |
| 586 | 679 | #include <__debug> |
| 587 | #include <__functional_base> | |
| 588 | 680 | #include <__iterator/access.h> |
| 589 | 681 | #include <__iterator/advance.h> |
| 590 | 682 | #include <__iterator/back_insert_iterator.h> |
| 683 | #include <__iterator/bounded_iter.h> | |
| 591 | 684 | #include <__iterator/common_iterator.h> |
| 592 | 685 | #include <__iterator/concepts.h> |
| 593 | 686 | #include <__iterator/counted_iterator.h> |
| ... | ... | @@ -606,21 +699,24 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 606 | 699 | #include <__iterator/iter_swap.h> |
| 607 | 700 | #include <__iterator/iterator.h> |
| 608 | 701 | #include <__iterator/iterator_traits.h> |
| 702 | #include <__iterator/mergeable.h> | |
| 609 | 703 | #include <__iterator/move_iterator.h> |
| 704 | #include <__iterator/move_sentinel.h> | |
| 610 | 705 | #include <__iterator/next.h> |
| 611 | 706 | #include <__iterator/ostream_iterator.h> |
| 612 | 707 | #include <__iterator/ostreambuf_iterator.h> |
| 708 | #include <__iterator/permutable.h> | |
| 613 | 709 | #include <__iterator/prev.h> |
| 614 | 710 | #include <__iterator/projected.h> |
| 615 | 711 | #include <__iterator/readable_traits.h> |
| 616 | 712 | #include <__iterator/reverse_access.h> |
| 617 | 713 | #include <__iterator/reverse_iterator.h> |
| 618 | 714 | #include <__iterator/size.h> |
| 715 | #include <__iterator/sortable.h> | |
| 619 | 716 | #include <__iterator/unreachable_sentinel.h> |
| 620 | 717 | #include <__iterator/wrap_iter.h> |
| 621 | 718 | #include <__memory/addressof.h> |
| 622 | 719 | #include <__memory/pointer_traits.h> |
| 623 | #include <__utility/forward.h> | |
| 624 | 720 | #include <compare> |
| 625 | 721 | #include <concepts> // Mandated by the Standard. |
| 626 | 722 | #include <cstddef> |
| ... | ... | @@ -628,8 +724,15 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; |
| 628 | 724 | #include <type_traits> |
| 629 | 725 | #include <version> |
| 630 | 726 | |
| 727 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 728 | # include <exception> | |
| 729 | # include <new> | |
| 730 | # include <typeinfo> | |
| 731 | # include <utility> | |
| 732 | #endif | |
| 733 | ||
| 631 | 734 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 632 | #pragma GCC system_header | |
| 735 | # pragma GCC system_header | |
| 633 | 736 | #endif |
| 634 | 737 | |
| 635 | 738 | #endif // _LIBCPP_ITERATOR |
lib/libcxx/include/latch+6-5| ... | ... | @@ -40,17 +40,19 @@ namespace std |
| 40 | 40 | |
| 41 | 41 | */ |
| 42 | 42 | |
| 43 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 43 | 44 | #include <__availability> |
| 44 | 45 | #include <__config> |
| 45 | 46 | #include <atomic> |
| 47 | #include <limits> | |
| 46 | 48 | #include <version> |
| 47 | 49 | |
| 48 | 50 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 49 | #pragma GCC system_header | |
| 51 | # pragma GCC system_header | |
| 50 | 52 | #endif |
| 51 | 53 | |
| 52 | 54 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 53 | # error <latch> is not supported on this single threaded system | |
| 55 | # error "<latch> is not supported since libc++ has been configured without support for threads." | |
| 54 | 56 | #endif |
| 55 | 57 | |
| 56 | 58 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -91,10 +93,9 @@ public: |
| 91 | 93 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 92 | 94 | void wait() const |
| 93 | 95 | { |
| 94 | auto const __test_fn = [=]() -> bool { | |
| 96 | __cxx_atomic_wait(&__a.__a_, [&]() -> bool { | |
| 95 | 97 | return try_wait(); |
| 96 | }; | |
| 97 | __cxx_atomic_wait(&__a.__a_, __test_fn); | |
| 98 | }); | |
| 98 | 99 | } |
| 99 | 100 | inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INLINE_VISIBILITY |
| 100 | 101 | void arrive_and_wait(ptrdiff_t __update = 1) |
lib/libcxx/include/limits+15-5| ... | ... | @@ -101,6 +101,8 @@ template<> class numeric_limits<cv long double>; |
| 101 | 101 | } // std |
| 102 | 102 | |
| 103 | 103 | */ |
| 104 | ||
| 105 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 104 | 106 | #include <__config> |
| 105 | 107 | #include <type_traits> |
| 106 | 108 | |
| ... | ... | @@ -108,12 +110,8 @@ template<> class numeric_limits<cv long double>; |
| 108 | 110 | #include "__support/win32/limits_msvc_win32.h" |
| 109 | 111 | #endif // _LIBCPP_MSVCRT |
| 110 | 112 | |
| 111 | #if defined(__IBMCPP__) | |
| 112 | #include "__support/ibm/limits.h" | |
| 113 | #endif // __IBMCPP__ | |
| 114 | ||
| 115 | 113 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 116 | #pragma GCC system_header | |
| 114 | # pragma GCC system_header | |
| 117 | 115 | #endif |
| 118 | 116 | |
| 119 | 117 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -339,7 +337,11 @@ protected: |
| 339 | 337 | static _LIBCPP_CONSTEXPR const bool is_modulo = false; |
| 340 | 338 | |
| 341 | 339 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 340 | #if (defined(__arm__) || defined(__aarch64__)) | |
| 341 | static _LIBCPP_CONSTEXPR const bool tinyness_before = true; | |
| 342 | #else | |
| 342 | 343 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 344 | #endif | |
| 343 | 345 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; |
| 344 | 346 | }; |
| 345 | 347 | |
| ... | ... | @@ -385,7 +387,11 @@ protected: |
| 385 | 387 | static _LIBCPP_CONSTEXPR const bool is_modulo = false; |
| 386 | 388 | |
| 387 | 389 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 390 | #if (defined(__arm__) || defined(__aarch64__)) | |
| 391 | static _LIBCPP_CONSTEXPR const bool tinyness_before = true; | |
| 392 | #else | |
| 388 | 393 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 394 | #endif | |
| 389 | 395 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; |
| 390 | 396 | }; |
| 391 | 397 | |
| ... | ... | @@ -435,7 +441,11 @@ protected: |
| 435 | 441 | static _LIBCPP_CONSTEXPR const bool is_modulo = false; |
| 436 | 442 | |
| 437 | 443 | static _LIBCPP_CONSTEXPR const bool traps = false; |
| 444 | #if (defined(__arm__) || defined(__aarch64__)) | |
| 445 | static _LIBCPP_CONSTEXPR const bool tinyness_before = true; | |
| 446 | #else | |
| 438 | 447 | static _LIBCPP_CONSTEXPR const bool tinyness_before = false; |
| 448 | #endif | |
| 439 | 449 | static _LIBCPP_CONSTEXPR const float_round_style round_style = round_to_nearest; |
| 440 | 450 | }; |
| 441 | 451 |
lib/libcxx/include/limits.h+1-1| ... | ... | @@ -40,7 +40,7 @@ Macros: |
| 40 | 40 | #include <__config> |
| 41 | 41 | |
| 42 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 43 | #pragma GCC system_header | |
| 43 | # pragma GCC system_header | |
| 44 | 44 | #endif |
| 45 | 45 | |
| 46 | 46 | #ifndef __GNUC__ |
lib/libcxx/include/list+97-148| ... | ... | @@ -180,19 +180,50 @@ template <class T, class Allocator, class Predicate> |
| 180 | 180 | |
| 181 | 181 | */ |
| 182 | 182 | |
| 183 | #include <__algorithm/comp.h> | |
| 184 | #include <__algorithm/equal.h> | |
| 185 | #include <__algorithm/lexicographical_compare.h> | |
| 186 | #include <__algorithm/min.h> | |
| 187 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 183 | 188 | #include <__config> |
| 184 | 189 | #include <__debug> |
| 190 | #include <__format/enable_insertable.h> | |
| 191 | #include <__iterator/distance.h> | |
| 192 | #include <__iterator/iterator_traits.h> | |
| 193 | #include <__iterator/move_iterator.h> | |
| 194 | #include <__iterator/next.h> | |
| 195 | #include <__iterator/prev.h> | |
| 196 | #include <__iterator/reverse_iterator.h> | |
| 197 | #include <__memory/swap_allocator.h> | |
| 185 | 198 | #include <__utility/forward.h> |
| 186 | #include <algorithm> | |
| 187 | #include <initializer_list> | |
| 188 | #include <iterator> | |
| 199 | #include <__utility/move.h> | |
| 200 | #include <__utility/swap.h> | |
| 189 | 201 | #include <limits> |
| 190 | 202 | #include <memory> |
| 191 | 203 | #include <type_traits> |
| 192 | 204 | #include <version> |
| 193 | 205 | |
| 206 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 207 | # include <algorithm> | |
| 208 | # include <functional> | |
| 209 | # include <iterator> | |
| 210 | #endif | |
| 211 | ||
| 212 | // standard-mandated includes | |
| 213 | ||
| 214 | // [iterator.range] | |
| 215 | #include <__iterator/access.h> | |
| 216 | #include <__iterator/data.h> | |
| 217 | #include <__iterator/empty.h> | |
| 218 | #include <__iterator/reverse_access.h> | |
| 219 | #include <__iterator/size.h> | |
| 220 | ||
| 221 | // [list.syn] | |
| 222 | #include <compare> | |
| 223 | #include <initializer_list> | |
| 224 | ||
| 194 | 225 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 195 | #pragma GCC system_header | |
| 226 | # pragma GCC system_header | |
| 196 | 227 | #endif |
| 197 | 228 | |
| 198 | 229 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -292,19 +323,15 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator |
| 292 | 323 | |
| 293 | 324 | __link_pointer __ptr_; |
| 294 | 325 | |
| 295 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 296 | 326 | _LIBCPP_INLINE_VISIBILITY |
| 297 | 327 | explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT |
| 298 | 328 | : __ptr_(__p) |
| 299 | 329 | { |
| 330 | (void)__c; | |
| 331 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 300 | 332 | __get_db()->__insert_ic(this, __c); |
| 301 | } | |
| 302 | #else | |
| 303 | _LIBCPP_INLINE_VISIBILITY | |
| 304 | explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} | |
| 305 | 333 | #endif |
| 306 | ||
| 307 | ||
| 334 | } | |
| 308 | 335 | |
| 309 | 336 | template<class, class> friend class list; |
| 310 | 337 | template<class, class> friend class __list_imp; |
| ... | ... | @@ -322,7 +349,7 @@ public: |
| 322 | 349 | _VSTD::__debug_db_insert_i(this); |
| 323 | 350 | } |
| 324 | 351 | |
| 325 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 352 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 326 | 353 | |
| 327 | 354 | _LIBCPP_INLINE_VISIBILITY |
| 328 | 355 | __list_iterator(const __list_iterator& __p) |
| ... | ... | @@ -348,7 +375,7 @@ public: |
| 348 | 375 | return *this; |
| 349 | 376 | } |
| 350 | 377 | |
| 351 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 378 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 352 | 379 | |
| 353 | 380 | _LIBCPP_INLINE_VISIBILITY |
| 354 | 381 | reference operator*() const |
| ... | ... | @@ -405,17 +432,15 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator |
| 405 | 432 | |
| 406 | 433 | __link_pointer __ptr_; |
| 407 | 434 | |
| 408 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 409 | 435 | _LIBCPP_INLINE_VISIBILITY |
| 410 | 436 | explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT |
| 411 | 437 | : __ptr_(__p) |
| 412 | 438 | { |
| 439 | (void)__c; | |
| 440 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 413 | 441 | __get_db()->__insert_ic(this, __c); |
| 414 | } | |
| 415 | #else | |
| 416 | _LIBCPP_INLINE_VISIBILITY | |
| 417 | explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} | |
| 418 | 442 | #endif |
| 443 | } | |
| 419 | 444 | |
| 420 | 445 | template<class, class> friend class list; |
| 421 | 446 | template<class, class> friend class __list_imp; |
| ... | ... | @@ -435,12 +460,12 @@ public: |
| 435 | 460 | __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT |
| 436 | 461 | : __ptr_(__p.__ptr_) |
| 437 | 462 | { |
| 438 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 463 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 439 | 464 | __get_db()->__iterator_copy(this, _VSTD::addressof(__p)); |
| 440 | 465 | #endif |
| 441 | 466 | } |
| 442 | 467 | |
| 443 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 468 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 444 | 469 | |
| 445 | 470 | _LIBCPP_INLINE_VISIBILITY |
| 446 | 471 | __list_const_iterator(const __list_const_iterator& __p) |
| ... | ... | @@ -466,7 +491,7 @@ public: |
| 466 | 491 | return *this; |
| 467 | 492 | } |
| 468 | 493 | |
| 469 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 494 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 470 | 495 | _LIBCPP_INLINE_VISIBILITY |
| 471 | 496 | reference operator*() const |
| 472 | 497 | { |
| ... | ... | @@ -593,38 +618,22 @@ protected: |
| 593 | 618 | _LIBCPP_INLINE_VISIBILITY |
| 594 | 619 | iterator begin() _NOEXCEPT |
| 595 | 620 | { |
| 596 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 597 | 621 | return iterator(__end_.__next_, this); |
| 598 | #else | |
| 599 | return iterator(__end_.__next_); | |
| 600 | #endif | |
| 601 | 622 | } |
| 602 | 623 | _LIBCPP_INLINE_VISIBILITY |
| 603 | 624 | const_iterator begin() const _NOEXCEPT |
| 604 | 625 | { |
| 605 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 606 | 626 | return const_iterator(__end_.__next_, this); |
| 607 | #else | |
| 608 | return const_iterator(__end_.__next_); | |
| 609 | #endif | |
| 610 | 627 | } |
| 611 | 628 | _LIBCPP_INLINE_VISIBILITY |
| 612 | 629 | iterator end() _NOEXCEPT |
| 613 | 630 | { |
| 614 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 615 | 631 | return iterator(__end_as_link(), this); |
| 616 | #else | |
| 617 | return iterator(__end_as_link()); | |
| 618 | #endif | |
| 619 | 632 | } |
| 620 | 633 | _LIBCPP_INLINE_VISIBILITY |
| 621 | 634 | const_iterator end() const _NOEXCEPT |
| 622 | 635 | { |
| 623 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 624 | 636 | return const_iterator(__end_as_link(), this); |
| 625 | #else | |
| 626 | return const_iterator(__end_as_link()); | |
| 627 | #endif | |
| 628 | 637 | } |
| 629 | 638 | |
| 630 | 639 | void swap(__list_imp& __c) |
| ... | ... | @@ -672,13 +681,6 @@ private: |
| 672 | 681 | void __move_assign_alloc(__list_imp&, false_type) |
| 673 | 682 | _NOEXCEPT |
| 674 | 683 | {} |
| 675 | ||
| 676 | _LIBCPP_INLINE_VISIBILITY | |
| 677 | void __invalidate_all_iterators() { | |
| 678 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 679 | __get_db()->__invalidate_all(this); | |
| 680 | #endif | |
| 681 | } | |
| 682 | 684 | }; |
| 683 | 685 | |
| 684 | 686 | // Unlink nodes [__f, __l] |
| ... | ... | @@ -720,9 +722,7 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT |
| 720 | 722 | template <class _Tp, class _Alloc> |
| 721 | 723 | __list_imp<_Tp, _Alloc>::~__list_imp() { |
| 722 | 724 | clear(); |
| 723 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 724 | __get_db()->__erase_c(this); | |
| 725 | #endif | |
| 725 | std::__debug_db_erase_c(this); | |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | 728 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -743,7 +743,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT |
| 743 | 743 | __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); |
| 744 | 744 | __node_alloc_traits::deallocate(__na, __np, 1); |
| 745 | 745 | } |
| 746 | __invalidate_all_iterators(); | |
| 746 | std::__debug_db_invalidate_all(this); | |
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | |
| ... | ... | @@ -774,7 +774,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) |
| 774 | 774 | else |
| 775 | 775 | __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link(); |
| 776 | 776 | |
| 777 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 777 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 778 | 778 | __libcpp_db* __db = __get_db(); |
| 779 | 779 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 780 | 780 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); |
| ... | ... | @@ -871,13 +871,13 @@ public: |
| 871 | 871 | |
| 872 | 872 | template <class _InpIter> |
| 873 | 873 | list(_InpIter __f, _InpIter __l, |
| 874 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0); | |
| 874 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0); | |
| 875 | 875 | template <class _InpIter> |
| 876 | 876 | list(_InpIter __f, _InpIter __l, const allocator_type& __a, |
| 877 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0); | |
| 877 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0); | |
| 878 | 878 | |
| 879 | 879 | list(const list& __c); |
| 880 | list(const list& __c, const __identity_t<allocator_type>& __a); | |
| 880 | list(const list& __c, const __type_identity_t<allocator_type>& __a); | |
| 881 | 881 | _LIBCPP_INLINE_VISIBILITY |
| 882 | 882 | list& operator=(const list& __c); |
| 883 | 883 | #ifndef _LIBCPP_CXX03_LANG |
| ... | ... | @@ -888,7 +888,7 @@ public: |
| 888 | 888 | list(list&& __c) |
| 889 | 889 | _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value); |
| 890 | 890 | _LIBCPP_INLINE_VISIBILITY |
| 891 | list(list&& __c, const __identity_t<allocator_type>& __a); | |
| 891 | list(list&& __c, const __type_identity_t<allocator_type>& __a); | |
| 892 | 892 | _LIBCPP_INLINE_VISIBILITY |
| 893 | 893 | list& operator=(list&& __c) |
| 894 | 894 | _NOEXCEPT_( |
| ... | ... | @@ -906,7 +906,7 @@ public: |
| 906 | 906 | |
| 907 | 907 | template <class _InpIter> |
| 908 | 908 | void assign(_InpIter __f, _InpIter __l, |
| 909 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0); | |
| 909 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0); | |
| 910 | 910 | void assign(size_type __n, const value_type& __x); |
| 911 | 911 | |
| 912 | 912 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1023,7 +1023,7 @@ public: |
| 1023 | 1023 | iterator insert(const_iterator __p, size_type __n, const value_type& __x); |
| 1024 | 1024 | template <class _InpIter> |
| 1025 | 1025 | iterator insert(const_iterator __p, _InpIter __f, _InpIter __l, |
| 1026 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type* = 0); | |
| 1026 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>* = 0); | |
| 1027 | 1027 | |
| 1028 | 1028 | _LIBCPP_INLINE_VISIBILITY |
| 1029 | 1029 | void swap(list& __c) |
| ... | ... | @@ -1099,14 +1099,14 @@ public: |
| 1099 | 1099 | return __hold_pointer(__p, __node_destructor(__na, 1)); |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1102 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1103 | 1103 | |
| 1104 | 1104 | bool __dereferenceable(const const_iterator* __i) const; |
| 1105 | 1105 | bool __decrementable(const const_iterator* __i) const; |
| 1106 | 1106 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const; |
| 1107 | 1107 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; |
| 1108 | 1108 | |
| 1109 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1109 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1110 | 1110 | |
| 1111 | 1111 | private: |
| 1112 | 1112 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1221,7 +1221,7 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) |
| 1221 | 1221 | template <class _Tp, class _Alloc> |
| 1222 | 1222 | template <class _InpIter> |
| 1223 | 1223 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, |
| 1224 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) | |
| 1224 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*) | |
| 1225 | 1225 | { |
| 1226 | 1226 | _VSTD::__debug_db_insert_c(this); |
| 1227 | 1227 | for (; __f != __l; ++__f) |
| ... | ... | @@ -1231,7 +1231,7 @@ list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, |
| 1231 | 1231 | template <class _Tp, class _Alloc> |
| 1232 | 1232 | template <class _InpIter> |
| 1233 | 1233 | list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a, |
| 1234 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) | |
| 1234 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*) | |
| 1235 | 1235 | : base(__a) |
| 1236 | 1236 | { |
| 1237 | 1237 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1249,7 +1249,7 @@ list<_Tp, _Alloc>::list(const list& __c) |
| 1249 | 1249 | } |
| 1250 | 1250 | |
| 1251 | 1251 | template <class _Tp, class _Alloc> |
| 1252 | list<_Tp, _Alloc>::list(const list& __c, const __identity_t<allocator_type>& __a) | |
| 1252 | list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) | |
| 1253 | 1253 | : base(__a) |
| 1254 | 1254 | { |
| 1255 | 1255 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1288,7 +1288,7 @@ inline list<_Tp, _Alloc>::list(list&& __c) |
| 1288 | 1288 | |
| 1289 | 1289 | template <class _Tp, class _Alloc> |
| 1290 | 1290 | inline |
| 1291 | list<_Tp, _Alloc>::list(list&& __c, const __identity_t<allocator_type>& __a) | |
| 1291 | list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) | |
| 1292 | 1292 | : base(__a) |
| 1293 | 1293 | { |
| 1294 | 1294 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1356,7 +1356,7 @@ template <class _Tp, class _Alloc> |
| 1356 | 1356 | template <class _InpIter> |
| 1357 | 1357 | void |
| 1358 | 1358 | list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l, |
| 1359 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) | |
| 1359 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*) | |
| 1360 | 1360 | { |
| 1361 | 1361 | iterator __i = begin(); |
| 1362 | 1362 | iterator __e = end(); |
| ... | ... | @@ -1366,9 +1366,7 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l, |
| 1366 | 1366 | insert(__e, __f, __l); |
| 1367 | 1367 | else |
| 1368 | 1368 | erase(__i, __e); |
| 1369 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1370 | __get_db()->__invalidate_all(this); | |
| 1371 | #endif | |
| 1369 | std::__debug_db_invalidate_all(this); | |
| 1372 | 1370 | } |
| 1373 | 1371 | |
| 1374 | 1372 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1383,9 +1381,7 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) |
| 1383 | 1381 | insert(__e, __n, __x); |
| 1384 | 1382 | else |
| 1385 | 1383 | erase(__i, __e); |
| 1386 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1387 | __get_db()->__invalidate_all(this); | |
| 1388 | #endif | |
| 1384 | std::__debug_db_invalidate_all(this); | |
| 1389 | 1385 | } |
| 1390 | 1386 | |
| 1391 | 1387 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1407,11 +1403,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) |
| 1407 | 1403 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); |
| 1408 | 1404 | __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link()); |
| 1409 | 1405 | ++base::__sz(); |
| 1410 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1411 | 1406 | return iterator(__hold.release()->__as_link(), this); |
| 1412 | #else | |
| 1413 | return iterator(__hold.release()->__as_link()); | |
| 1414 | #endif | |
| 1415 | 1407 | } |
| 1416 | 1408 | |
| 1417 | 1409 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1420,11 +1412,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1420 | 1412 | { |
| 1421 | 1413 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, |
| 1422 | 1414 | "list::insert(iterator, n, x) called with an iterator not referring to this list"); |
| 1423 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1424 | 1415 | iterator __r(__p.__ptr_, this); |
| 1425 | #else | |
| 1426 | iterator __r(__p.__ptr_); | |
| 1427 | #endif | |
| 1428 | 1416 | if (__n > 0) |
| 1429 | 1417 | { |
| 1430 | 1418 | size_type __ds = 0; |
| ... | ... | @@ -1432,11 +1420,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1432 | 1420 | __hold_pointer __hold = __allocate_node(__na); |
| 1433 | 1421 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); |
| 1434 | 1422 | ++__ds; |
| 1435 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1436 | 1423 | __r = iterator(__hold->__as_link(), this); |
| 1437 | #else | |
| 1438 | __r = iterator(__hold->__as_link()); | |
| 1439 | #endif | |
| 1440 | 1424 | __hold.release(); |
| 1441 | 1425 | iterator __e = __r; |
| 1442 | 1426 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| ... | ... | @@ -1462,11 +1446,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ |
| 1462 | 1446 | __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); |
| 1463 | 1447 | if (__prev == 0) |
| 1464 | 1448 | break; |
| 1465 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1466 | 1449 | __e = iterator(__prev, this); |
| 1467 | #else | |
| 1468 | __e = iterator(__prev); | |
| 1469 | #endif | |
| 1470 | 1450 | } |
| 1471 | 1451 | throw; |
| 1472 | 1452 | } |
| ... | ... | @@ -1481,15 +1461,11 @@ template <class _Tp, class _Alloc> |
| 1481 | 1461 | template <class _InpIter> |
| 1482 | 1462 | typename list<_Tp, _Alloc>::iterator |
| 1483 | 1463 | list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, |
| 1484 | typename enable_if<__is_cpp17_input_iterator<_InpIter>::value>::type*) | |
| 1464 | __enable_if_t<__is_cpp17_input_iterator<_InpIter>::value>*) | |
| 1485 | 1465 | { |
| 1486 | 1466 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, |
| 1487 | 1467 | "list::insert(iterator, range) called with an iterator not referring to this list"); |
| 1488 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1489 | 1468 | iterator __r(__p.__ptr_, this); |
| 1490 | #else | |
| 1491 | iterator __r(__p.__ptr_); | |
| 1492 | #endif | |
| 1493 | 1469 | if (__f != __l) |
| 1494 | 1470 | { |
| 1495 | 1471 | size_type __ds = 0; |
| ... | ... | @@ -1497,11 +1473,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, |
| 1497 | 1473 | __hold_pointer __hold = __allocate_node(__na); |
| 1498 | 1474 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); |
| 1499 | 1475 | ++__ds; |
| 1500 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1501 | 1476 | __r = iterator(__hold.get()->__as_link(), this); |
| 1502 | #else | |
| 1503 | __r = iterator(__hold.get()->__as_link()); | |
| 1504 | #endif | |
| 1505 | 1477 | __hold.release(); |
| 1506 | 1478 | iterator __e = __r; |
| 1507 | 1479 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| ... | ... | @@ -1527,11 +1499,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, |
| 1527 | 1499 | __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); |
| 1528 | 1500 | if (__prev == 0) |
| 1529 | 1501 | break; |
| 1530 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1531 | 1502 | __e = iterator(__prev, this); |
| 1532 | #else | |
| 1533 | __e = iterator(__prev); | |
| 1534 | #endif | |
| 1535 | 1503 | } |
| 1536 | 1504 | throw; |
| 1537 | 1505 | } |
| ... | ... | @@ -1650,11 +1618,7 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) |
| 1650 | 1618 | __link_nodes(__p.__ptr_, __nl, __nl); |
| 1651 | 1619 | ++base::__sz(); |
| 1652 | 1620 | __hold.release(); |
| 1653 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1654 | 1621 | return iterator(__nl, this); |
| 1655 | #else | |
| 1656 | return iterator(__nl); | |
| 1657 | #endif | |
| 1658 | 1622 | } |
| 1659 | 1623 | |
| 1660 | 1624 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1670,11 +1634,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) |
| 1670 | 1634 | __link_nodes(__p.__ptr_, __nl, __nl); |
| 1671 | 1635 | ++base::__sz(); |
| 1672 | 1636 | __hold.release(); |
| 1673 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1674 | 1637 | return iterator(__nl, this); |
| 1675 | #else | |
| 1676 | return iterator(__nl); | |
| 1677 | #endif | |
| 1678 | 1638 | } |
| 1679 | 1639 | |
| 1680 | 1640 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -1688,7 +1648,7 @@ list<_Tp, _Alloc>::pop_front() |
| 1688 | 1648 | __link_pointer __n = base::__end_.__next_; |
| 1689 | 1649 | base::__unlink_nodes(__n, __n); |
| 1690 | 1650 | --base::__sz(); |
| 1691 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1651 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1692 | 1652 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 1693 | 1653 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) |
| 1694 | 1654 | { |
| ... | ... | @@ -1717,7 +1677,7 @@ list<_Tp, _Alloc>::pop_back() |
| 1717 | 1677 | __link_pointer __n = base::__end_.__prev_; |
| 1718 | 1678 | base::__unlink_nodes(__n, __n); |
| 1719 | 1679 | --base::__sz(); |
| 1720 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1680 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1721 | 1681 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 1722 | 1682 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) |
| 1723 | 1683 | { |
| ... | ... | @@ -1750,7 +1710,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p) |
| 1750 | 1710 | __link_pointer __r = __n->__next_; |
| 1751 | 1711 | base::__unlink_nodes(__n, __n); |
| 1752 | 1712 | --base::__sz(); |
| 1753 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1713 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1754 | 1714 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 1755 | 1715 | for (__i_node** __ip = __c->end_; __ip != __c->beg_; ) |
| 1756 | 1716 | { |
| ... | ... | @@ -1768,11 +1728,7 @@ list<_Tp, _Alloc>::erase(const_iterator __p) |
| 1768 | 1728 | __node_pointer __np = __n->__as_node(); |
| 1769 | 1729 | __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); |
| 1770 | 1730 | __node_alloc_traits::deallocate(__na, __np, 1); |
| 1771 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1772 | 1731 | return iterator(__r, this); |
| 1773 | #else | |
| 1774 | return iterator(__r); | |
| 1775 | #endif | |
| 1776 | 1732 | } |
| 1777 | 1733 | |
| 1778 | 1734 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1792,7 +1748,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) |
| 1792 | 1748 | __link_pointer __n = __f.__ptr_; |
| 1793 | 1749 | ++__f; |
| 1794 | 1750 | --base::__sz(); |
| 1795 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1751 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1796 | 1752 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 1797 | 1753 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) |
| 1798 | 1754 | { |
| ... | ... | @@ -1812,11 +1768,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) |
| 1812 | 1768 | __node_alloc_traits::deallocate(__na, __np, 1); |
| 1813 | 1769 | } |
| 1814 | 1770 | } |
| 1815 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1816 | 1771 | return iterator(__l.__ptr_, this); |
| 1817 | #else | |
| 1818 | return iterator(__l.__ptr_); | |
| 1819 | #endif | |
| 1820 | 1772 | } |
| 1821 | 1773 | |
| 1822 | 1774 | template <class _Tp, class _Alloc> |
| ... | ... | @@ -1833,11 +1785,7 @@ list<_Tp, _Alloc>::resize(size_type __n) |
| 1833 | 1785 | __hold_pointer __hold = __allocate_node(__na); |
| 1834 | 1786 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); |
| 1835 | 1787 | ++__ds; |
| 1836 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1837 | 1788 | iterator __r = iterator(__hold.release()->__as_link(), this); |
| 1838 | #else | |
| 1839 | iterator __r = iterator(__hold.release()->__as_link()); | |
| 1840 | #endif | |
| 1841 | 1789 | iterator __e = __r; |
| 1842 | 1790 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1843 | 1791 | try |
| ... | ... | @@ -1862,11 +1810,7 @@ list<_Tp, _Alloc>::resize(size_type __n) |
| 1862 | 1810 | __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); |
| 1863 | 1811 | if (__prev == 0) |
| 1864 | 1812 | break; |
| 1865 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1866 | 1813 | __e = iterator(__prev, this); |
| 1867 | #else | |
| 1868 | __e = iterator(__prev); | |
| 1869 | #endif | |
| 1870 | 1814 | } |
| 1871 | 1815 | throw; |
| 1872 | 1816 | } |
| ... | ... | @@ -1891,11 +1835,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) |
| 1891 | 1835 | __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); |
| 1892 | 1836 | ++__ds; |
| 1893 | 1837 | __link_pointer __nl = __hold.release()->__as_link(); |
| 1894 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1895 | 1838 | iterator __r = iterator(__nl, this); |
| 1896 | #else | |
| 1897 | iterator __r = iterator(__nl); | |
| 1898 | #endif | |
| 1899 | 1839 | iterator __e = __r; |
| 1900 | 1840 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 1901 | 1841 | try |
| ... | ... | @@ -1920,11 +1860,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) |
| 1920 | 1860 | __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); |
| 1921 | 1861 | if (__prev == 0) |
| 1922 | 1862 | break; |
| 1923 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1924 | 1863 | __e = iterator(__prev, this); |
| 1925 | #else | |
| 1926 | __e = iterator(__prev); | |
| 1927 | #endif | |
| 1928 | 1864 | } |
| 1929 | 1865 | throw; |
| 1930 | 1866 | } |
| ... | ... | @@ -1950,7 +1886,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) |
| 1950 | 1886 | __link_nodes(__p.__ptr_, __f, __l); |
| 1951 | 1887 | base::__sz() += __c.__sz(); |
| 1952 | 1888 | __c.__sz() = 0; |
| 1953 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1889 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1954 | 1890 | if (_VSTD::addressof(__c) != this) { |
| 1955 | 1891 | __libcpp_db* __db = __get_db(); |
| 1956 | 1892 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| ... | ... | @@ -1991,7 +1927,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) |
| 1991 | 1927 | __link_nodes(__p.__ptr_, __f, __f); |
| 1992 | 1928 | --__c.__sz(); |
| 1993 | 1929 | ++base::__sz(); |
| 1994 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1930 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1995 | 1931 | if (_VSTD::addressof(__c) != this) { |
| 1996 | 1932 | __libcpp_db* __db = __get_db(); |
| 1997 | 1933 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| ... | ... | @@ -2014,6 +1950,17 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) |
| 2014 | 1950 | } |
| 2015 | 1951 | } |
| 2016 | 1952 | |
| 1953 | template <class _Iterator> | |
| 1954 | _LIBCPP_HIDE_FROM_ABI | |
| 1955 | bool __iterator_in_range(_Iterator __first, _Iterator __last, _Iterator __it) { | |
| 1956 | for (_Iterator __p = __first; __p != __last; ++__p) { | |
| 1957 | if (__p == __it) { | |
| 1958 | return true; | |
| 1959 | } | |
| 1960 | } | |
| 1961 | return false; | |
| 1962 | } | |
| 1963 | ||
| 2017 | 1964 | template <class _Tp, class _Alloc> |
| 2018 | 1965 | void |
| 2019 | 1966 | list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) |
| ... | ... | @@ -2024,16 +1971,10 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con |
| 2024 | 1971 | "list::splice(iterator, list, iterator, iterator) called with second iterator not referring to the list argument"); |
| 2025 | 1972 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__l)) == _VSTD::addressof(__c), |
| 2026 | 1973 | "list::splice(iterator, list, iterator, iterator) called with third iterator not referring to the list argument"); |
| 1974 | _LIBCPP_DEBUG_ASSERT(this != std::addressof(__c) || !std::__iterator_in_range(__f, __l, __p), | |
| 1975 | "list::splice(iterator, list, iterator, iterator)" | |
| 1976 | " called with the first iterator within the range of the second and third iterators"); | |
| 2027 | 1977 | |
| 2028 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2029 | if (this == _VSTD::addressof(__c)) | |
| 2030 | { | |
| 2031 | for (const_iterator __i = __f; __i != __l; ++__i) | |
| 2032 | _LIBCPP_DEBUG_ASSERT(__i != __p, | |
| 2033 | "list::splice(iterator, list, iterator, iterator)" | |
| 2034 | " called with the first iterator within the range of the second and third iterators"); | |
| 2035 | } | |
| 2036 | #endif | |
| 2037 | 1978 | if (__f != __l) |
| 2038 | 1979 | { |
| 2039 | 1980 | __link_pointer __first = __f.__ptr_; |
| ... | ... | @@ -2047,7 +1988,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con |
| 2047 | 1988 | } |
| 2048 | 1989 | base::__unlink_nodes(__first, __last); |
| 2049 | 1990 | __link_nodes(__p.__ptr_, __first, __last); |
| 2050 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1991 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2051 | 1992 | if (_VSTD::addressof(__c) != this) { |
| 2052 | 1993 | __libcpp_db* __db = __get_db(); |
| 2053 | 1994 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| ... | ... | @@ -2184,7 +2125,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) |
| 2184 | 2125 | ++__f1; |
| 2185 | 2126 | } |
| 2186 | 2127 | splice(__e1, __c); |
| 2187 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2128 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2188 | 2129 | __libcpp_db* __db = __get_db(); |
| 2189 | 2130 | __c_node* __cn1 = __db->__find_c_and_lock(this); |
| 2190 | 2131 | __c_node* __cn2 = __db->__find_c(_VSTD::addressof(__c)); |
| ... | ... | @@ -2308,7 +2249,7 @@ list<_Tp, _Alloc>::__invariants() const |
| 2308 | 2249 | return size() == _VSTD::distance(begin(), end()); |
| 2309 | 2250 | } |
| 2310 | 2251 | |
| 2311 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2252 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2312 | 2253 | |
| 2313 | 2254 | template <class _Tp, class _Alloc> |
| 2314 | 2255 | bool |
| ... | ... | @@ -2338,7 +2279,7 @@ list<_Tp, _Alloc>::__subscriptable(const const_iterator*, ptrdiff_t) const |
| 2338 | 2279 | return false; |
| 2339 | 2280 | } |
| 2340 | 2281 | |
| 2341 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 2282 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 2342 | 2283 | |
| 2343 | 2284 | template <class _Tp, class _Alloc> |
| 2344 | 2285 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -2409,8 +2350,16 @@ inline _LIBCPP_INLINE_VISIBILITY typename list<_Tp, _Allocator>::size_type |
| 2409 | 2350 | erase(list<_Tp, _Allocator>& __c, const _Up& __v) { |
| 2410 | 2351 | return _VSTD::erase_if(__c, [&](auto& __elem) { return __elem == __v; }); |
| 2411 | 2352 | } |
| 2353 | ||
| 2354 | template <> | |
| 2355 | inline constexpr bool __format::__enable_insertable<std::list<char>> = true; | |
| 2356 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 2357 | template <> | |
| 2358 | inline constexpr bool __format::__enable_insertable<std::list<wchar_t>> = true; | |
| 2412 | 2359 | #endif |
| 2413 | 2360 | |
| 2361 | #endif // _LIBCPP_STD_VER > 17 | |
| 2362 | ||
| 2414 | 2363 | _LIBCPP_END_NAMESPACE_STD |
| 2415 | 2364 | |
| 2416 | 2365 | _LIBCPP_POP_MACROS |
lib/libcxx/include/locale+85-55| ... | ... | @@ -187,26 +187,37 @@ template <class charT> class messages_byname; |
| 187 | 187 | |
| 188 | 188 | */ |
| 189 | 189 | |
| 190 | #include <__algorithm/copy.h> | |
| 191 | #include <__algorithm/equal.h> | |
| 192 | #include <__algorithm/find.h> | |
| 193 | #include <__algorithm/max.h> | |
| 194 | #include <__algorithm/reverse.h> | |
| 195 | #include <__algorithm/unwrap_iter.h> | |
| 196 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 190 | 197 | #include <__config> |
| 191 | 198 | #include <__debug> |
| 199 | #include <__iterator/access.h> | |
| 200 | #include <__iterator/back_insert_iterator.h> | |
| 201 | #include <__iterator/istreambuf_iterator.h> | |
| 202 | #include <__iterator/ostreambuf_iterator.h> | |
| 192 | 203 | #include <__locale> |
| 193 | #include <algorithm> | |
| 194 | #ifndef __APPLE__ | |
| 195 | # include <cstdarg> | |
| 196 | #endif | |
| 204 | #include <cstdarg> // TODO: Remove this include | |
| 197 | 205 | #include <cstdio> |
| 198 | 206 | #include <cstdlib> |
| 199 | 207 | #include <ctime> |
| 200 | 208 | #include <ios> |
| 201 | #include <iterator> | |
| 202 | 209 | #include <limits> |
| 203 | 210 | #include <memory> |
| 204 | 211 | #include <streambuf> |
| 205 | 212 | #include <version> |
| 206 | 213 | |
| 214 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 215 | # include <iterator> | |
| 216 | #endif | |
| 217 | ||
| 207 | 218 | #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) |
| 208 | 219 | // Most unix variants have catopen. These are the specific ones that don't. |
| 209 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) | |
| 220 | # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) | |
| 210 | 221 | # define _LIBCPP_HAS_CATOPEN 1 |
| 211 | 222 | # include <nl_types.h> |
| 212 | 223 | # endif |
| ... | ... | @@ -219,7 +230,7 @@ template <class charT> class messages_byname; |
| 219 | 230 | #endif |
| 220 | 231 | |
| 221 | 232 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 222 | #pragma GCC system_header | |
| 233 | # pragma GCC system_header | |
| 223 | 234 | #endif |
| 224 | 235 | |
| 225 | 236 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -572,9 +583,9 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex |
| 572 | 583 | return 0; |
| 573 | 584 | } |
| 574 | 585 | |
| 575 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>) | |
| 586 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>; | |
| 576 | 587 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 577 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>) | |
| 588 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>; | |
| 578 | 589 | #endif |
| 579 | 590 | |
| 580 | 591 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| ... | ... | @@ -1112,9 +1123,9 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, |
| 1112 | 1123 | return __b; |
| 1113 | 1124 | } |
| 1114 | 1125 | |
| 1115 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>) | |
| 1126 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>; | |
| 1116 | 1127 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1117 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>) | |
| 1128 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>; | |
| 1118 | 1129 | #endif |
| 1119 | 1130 | |
| 1120 | 1131 | struct _LIBCPP_TYPE_VIS __num_put_base |
| ... | ... | @@ -1264,9 +1275,9 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne, |
| 1264 | 1275 | __op = __ob + (__np - __nb); |
| 1265 | 1276 | } |
| 1266 | 1277 | |
| 1267 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>) | |
| 1278 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>; | |
| 1268 | 1279 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1269 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>) | |
| 1280 | extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>; | |
| 1270 | 1281 | #endif |
| 1271 | 1282 | |
| 1272 | 1283 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| ... | ... | @@ -1456,7 +1467,7 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1456 | 1467 | return do_put(__s, __iob, __fl, (unsigned long)__v); |
| 1457 | 1468 | const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc()); |
| 1458 | 1469 | typedef typename numpunct<char_type>::string_type string_type; |
| 1459 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1470 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1460 | 1471 | string_type __tmp(__v ? __np.truename() : __np.falsename()); |
| 1461 | 1472 | string_type __nm = _VSTD::move(__tmp); |
| 1462 | 1473 | #else |
| ... | ... | @@ -1486,10 +1497,11 @@ num_put<_CharT, _OutputIterator>::__do_put_integral(iter_type __s, ios_base& __i |
| 1486 | 1497 | + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up |
| 1487 | 1498 | + 2; // base prefix + terminating null character |
| 1488 | 1499 | char __nar[__nbuf]; |
| 1489 | #pragma clang diagnostic push | |
| 1490 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 1500 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 1501 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 1502 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 1491 | 1503 | int __nc = __libcpp_snprintf_l(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v); |
| 1492 | #pragma clang diagnostic pop | |
| 1504 | _LIBCPP_DIAGNOSTIC_POP | |
| 1493 | 1505 | char* __ne = __nar + __nc; |
| 1494 | 1506 | char* __np = this->__identify_padding(__nar, __ne, __iob); |
| 1495 | 1507 | // Stage 2 - Widen __nar while adding thousands separators |
| ... | ... | @@ -1549,8 +1561,9 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas |
| 1549 | 1561 | char __nar[__nbuf]; |
| 1550 | 1562 | char* __nb = __nar; |
| 1551 | 1563 | int __nc; |
| 1552 | #pragma clang diagnostic push | |
| 1553 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 1564 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 1565 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 1566 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 1554 | 1567 | if (__specify_precision) |
| 1555 | 1568 | __nc = __libcpp_snprintf_l(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, |
| 1556 | 1569 | (int)__iob.precision(), __v); |
| ... | ... | @@ -1567,7 +1580,7 @@ num_put<_CharT, _OutputIterator>::__do_put_floating_point(iter_type __s, ios_bas |
| 1567 | 1580 | __throw_bad_alloc(); |
| 1568 | 1581 | __nbh.reset(__nb); |
| 1569 | 1582 | } |
| 1570 | #pragma clang diagnostic pop | |
| 1583 | _LIBCPP_DIAGNOSTIC_POP | |
| 1571 | 1584 | char* __ne = __nb + __nc; |
| 1572 | 1585 | char* __np = this->__identify_padding(__nb, __ne, __iob); |
| 1573 | 1586 | // Stage 2 - Widen __nar while adding thousands separators |
| ... | ... | @@ -1633,9 +1646,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, |
| 1633 | 1646 | return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); |
| 1634 | 1647 | } |
| 1635 | 1648 | |
| 1636 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>) | |
| 1649 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>; | |
| 1637 | 1650 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1638 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>) | |
| 1651 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>; | |
| 1639 | 1652 | #endif |
| 1640 | 1653 | |
| 1641 | 1654 | template <class _CharT, class _InputIterator> |
| ... | ... | @@ -1918,7 +1931,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m, |
| 1918 | 1931 | const ctype<char_type>& __ct) const |
| 1919 | 1932 | { |
| 1920 | 1933 | int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1; |
| 1921 | if (!(__err & ios_base::failbit) && __t <= 11) | |
| 1934 | if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11) | |
| 1922 | 1935 | __m = __t; |
| 1923 | 1936 | else |
| 1924 | 1937 | __err |= ios_base::failbit; |
| ... | ... | @@ -2323,9 +2336,9 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, |
| 2323 | 2336 | return __b; |
| 2324 | 2337 | } |
| 2325 | 2338 | |
| 2326 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>) | |
| 2339 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>; | |
| 2327 | 2340 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2328 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>) | |
| 2341 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>; | |
| 2329 | 2342 | #endif |
| 2330 | 2343 | |
| 2331 | 2344 | class _LIBCPP_TYPE_VIS __time_get |
| ... | ... | @@ -2425,9 +2438,9 @@ private: |
| 2425 | 2438 | virtual const string_type& __X() const {return this->__X_;} |
| 2426 | 2439 | }; |
| 2427 | 2440 | |
| 2428 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>) | |
| 2441 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>; | |
| 2429 | 2442 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2430 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>) | |
| 2443 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>; | |
| 2431 | 2444 | #endif |
| 2432 | 2445 | |
| 2433 | 2446 | class _LIBCPP_TYPE_VIS __time_put |
| ... | ... | @@ -2540,9 +2553,9 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&, |
| 2540 | 2553 | return _VSTD::copy(__nb, __ne, __s); |
| 2541 | 2554 | } |
| 2542 | 2555 | |
| 2543 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>) | |
| 2556 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>; | |
| 2544 | 2557 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2545 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>) | |
| 2558 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>; | |
| 2546 | 2559 | #endif |
| 2547 | 2560 | |
| 2548 | 2561 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| ... | ... | @@ -2563,9 +2576,9 @@ protected: |
| 2563 | 2576 | ~time_put_byname() {} |
| 2564 | 2577 | }; |
| 2565 | 2578 | |
| 2566 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>) | |
| 2579 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>; | |
| 2567 | 2580 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2568 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>) | |
| 2581 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>; | |
| 2569 | 2582 | #endif |
| 2570 | 2583 | |
| 2571 | 2584 | // money_base |
| ... | ... | @@ -2632,11 +2645,11 @@ template <class _CharT, bool _International> |
| 2632 | 2645 | const bool |
| 2633 | 2646 | moneypunct<_CharT, _International>::intl; |
| 2634 | 2647 | |
| 2635 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>) | |
| 2636 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>) | |
| 2648 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>; | |
| 2649 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>; | |
| 2637 | 2650 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2638 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>) | |
| 2639 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>) | |
| 2651 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>; | |
| 2652 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>; | |
| 2640 | 2653 | #endif |
| 2641 | 2654 | |
| 2642 | 2655 | // moneypunct_byname |
| ... | ... | @@ -2688,14 +2701,14 @@ private: |
| 2688 | 2701 | |
| 2689 | 2702 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, false>::init(const char*); |
| 2690 | 2703 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<char, true>::init(const char*); |
| 2691 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>) | |
| 2692 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>) | |
| 2704 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>; | |
| 2705 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>; | |
| 2693 | 2706 | |
| 2694 | 2707 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2695 | 2708 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, false>::init(const char*); |
| 2696 | 2709 | template<> _LIBCPP_FUNC_VIS void moneypunct_byname<wchar_t, true>::init(const char*); |
| 2697 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>) | |
| 2698 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>) | |
| 2710 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>; | |
| 2711 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>; | |
| 2699 | 2712 | #endif |
| 2700 | 2713 | |
| 2701 | 2714 | // money_get |
| ... | ... | @@ -2752,9 +2765,9 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc, |
| 2752 | 2765 | } |
| 2753 | 2766 | } |
| 2754 | 2767 | |
| 2755 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>) | |
| 2768 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>; | |
| 2756 | 2769 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 2757 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>) | |
| 2770 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>; | |
| 2758 | 2771 | #endif |
| 2759 | 2772 | |
| 2760 | 2773 | template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > |
| ... | ... | @@ -3121,9 +3134,9 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, |
| 3121 | 3134 | return __b; |
| 3122 | 3135 | } |
| 3123 | 3136 | |
| 3124 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>) | |
| 3137 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>; | |
| 3125 | 3138 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3126 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>) | |
| 3139 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>; | |
| 3127 | 3140 | #endif |
| 3128 | 3141 | |
| 3129 | 3142 | // money_put |
| ... | ... | @@ -3214,9 +3227,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m |
| 3214 | 3227 | int __fd) |
| 3215 | 3228 | { |
| 3216 | 3229 | __me = __mb; |
| 3217 | for (unsigned __p = 0; __p < 4; ++__p) | |
| 3230 | for (char __p : __pat.field) | |
| 3218 | 3231 | { |
| 3219 | switch (__pat.field[__p]) | |
| 3232 | switch (__p) | |
| 3220 | 3233 | { |
| 3221 | 3234 | case money_base::none: |
| 3222 | 3235 | __mi = __me; |
| ... | ... | @@ -3298,9 +3311,9 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m |
| 3298 | 3311 | __mi = __mb; |
| 3299 | 3312 | } |
| 3300 | 3313 | |
| 3301 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>) | |
| 3314 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>; | |
| 3302 | 3315 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3303 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>) | |
| 3316 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>; | |
| 3304 | 3317 | #endif |
| 3305 | 3318 | |
| 3306 | 3319 | template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > |
| ... | ... | @@ -3453,9 +3466,9 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, |
| 3453 | 3466 | return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); |
| 3454 | 3467 | } |
| 3455 | 3468 | |
| 3456 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>) | |
| 3469 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>; | |
| 3457 | 3470 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3458 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>) | |
| 3471 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; | |
| 3459 | 3472 | #endif |
| 3460 | 3473 | |
| 3461 | 3474 | // messages |
| ... | ... | @@ -3571,9 +3584,9 @@ messages<_CharT>::do_close(catalog __c) const |
| 3571 | 3584 | #endif // _LIBCPP_HAS_CATOPEN |
| 3572 | 3585 | } |
| 3573 | 3586 | |
| 3574 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>) | |
| 3587 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>; | |
| 3575 | 3588 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3576 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>) | |
| 3589 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>; | |
| 3577 | 3590 | #endif |
| 3578 | 3591 | |
| 3579 | 3592 | template <class _CharT> |
| ... | ... | @@ -3597,15 +3610,15 @@ protected: |
| 3597 | 3610 | ~messages_byname() {} |
| 3598 | 3611 | }; |
| 3599 | 3612 | |
| 3600 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>) | |
| 3613 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>; | |
| 3601 | 3614 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 3602 | _LIBCPP_EXTERN_TEMPLATE_EVEN_IN_DEBUG_MODE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>) | |
| 3615 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; | |
| 3603 | 3616 | #endif |
| 3604 | 3617 | |
| 3605 | 3618 | template<class _Codecvt, class _Elem = wchar_t, |
| 3606 | 3619 | class _Wide_alloc = allocator<_Elem>, |
| 3607 | 3620 | class _Byte_alloc = allocator<char> > |
| 3608 | class _LIBCPP_TEMPLATE_VIS wstring_convert | |
| 3621 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert | |
| 3609 | 3622 | { |
| 3610 | 3623 | public: |
| 3611 | 3624 | typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string; |
| ... | ... | @@ -3672,6 +3685,7 @@ public: |
| 3672 | 3685 | state_type state() const {return __cvtstate_;} |
| 3673 | 3686 | }; |
| 3674 | 3687 | |
| 3688 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 3675 | 3689 | template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc> |
| 3676 | 3690 | inline |
| 3677 | 3691 | wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: |
| ... | ... | @@ -3679,6 +3693,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: |
| 3679 | 3693 | : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) |
| 3680 | 3694 | { |
| 3681 | 3695 | } |
| 3696 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 3682 | 3697 | |
| 3683 | 3698 | template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc> |
| 3684 | 3699 | inline |
| ... | ... | @@ -3713,6 +3728,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: |
| 3713 | 3728 | |
| 3714 | 3729 | #endif // _LIBCPP_CXX03_LANG |
| 3715 | 3730 | |
| 3731 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 3716 | 3732 | template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc> |
| 3717 | 3733 | wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert() |
| 3718 | 3734 | { |
| ... | ... | @@ -3724,6 +3740,7 @@ typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string |
| 3724 | 3740 | wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: |
| 3725 | 3741 | from_bytes(const char* __frm, const char* __frm_end) |
| 3726 | 3742 | { |
| 3743 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 3727 | 3744 | __cvtcount_ = 0; |
| 3728 | 3745 | if (__cvtptr_ != nullptr) |
| 3729 | 3746 | { |
| ... | ... | @@ -3870,7 +3887,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: |
| 3870 | 3887 | } |
| 3871 | 3888 | |
| 3872 | 3889 | template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> > |
| 3873 | class _LIBCPP_TEMPLATE_VIS wbuffer_convert | |
| 3890 | class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert | |
| 3874 | 3891 | : public basic_streambuf<_Elem, _Tr> |
| 3875 | 3892 | { |
| 3876 | 3893 | public: |
| ... | ... | @@ -3947,6 +3964,7 @@ private: |
| 3947 | 3964 | wbuffer_convert* __close(); |
| 3948 | 3965 | }; |
| 3949 | 3966 | |
| 3967 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 3950 | 3968 | template <class _Codecvt, class _Elem, class _Tr> |
| 3951 | 3969 | wbuffer_convert<_Codecvt, _Elem, _Tr>:: |
| 3952 | 3970 | wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state) |
| ... | ... | @@ -3982,6 +4000,7 @@ template <class _Codecvt, class _Elem, class _Tr> |
| 3982 | 4000 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type |
| 3983 | 4001 | wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() |
| 3984 | 4002 | { |
| 4003 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 3985 | 4004 | if (__cv_ == 0 || __bufptr_ == 0) |
| 3986 | 4005 | return traits_type::eof(); |
| 3987 | 4006 | bool __initial = __read_mode(); |
| ... | ... | @@ -4046,10 +4065,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() |
| 4046 | 4065 | return __c; |
| 4047 | 4066 | } |
| 4048 | 4067 | |
| 4068 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4049 | 4069 | template <class _Codecvt, class _Elem, class _Tr> |
| 4050 | 4070 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type |
| 4051 | 4071 | wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) |
| 4052 | 4072 | { |
| 4073 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4053 | 4074 | if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr()) |
| 4054 | 4075 | { |
| 4055 | 4076 | if (traits_type::eq_int_type(__c, traits_type::eof())) |
| ... | ... | @@ -4067,10 +4088,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) |
| 4067 | 4088 | return traits_type::eof(); |
| 4068 | 4089 | } |
| 4069 | 4090 | |
| 4091 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4070 | 4092 | template <class _Codecvt, class _Elem, class _Tr> |
| 4071 | 4093 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type |
| 4072 | 4094 | wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) |
| 4073 | 4095 | { |
| 4096 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4074 | 4097 | if (__cv_ == 0 || __bufptr_ == 0) |
| 4075 | 4098 | return traits_type::eof(); |
| 4076 | 4099 | __write_mode(); |
| ... | ... | @@ -4129,10 +4152,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) |
| 4129 | 4152 | return traits_type::not_eof(__c); |
| 4130 | 4153 | } |
| 4131 | 4154 | |
| 4155 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4132 | 4156 | template <class _Codecvt, class _Elem, class _Tr> |
| 4133 | 4157 | basic_streambuf<_Elem, _Tr>* |
| 4134 | 4158 | wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) |
| 4135 | 4159 | { |
| 4160 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4136 | 4161 | this->setg(0, 0, 0); |
| 4137 | 4162 | this->setp(0, 0); |
| 4138 | 4163 | if (__owns_eb_) |
| ... | ... | @@ -4182,6 +4207,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) |
| 4182 | 4207 | return this; |
| 4183 | 4208 | } |
| 4184 | 4209 | |
| 4210 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4185 | 4211 | template <class _Codecvt, class _Elem, class _Tr> |
| 4186 | 4212 | typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type |
| 4187 | 4213 | wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, |
| ... | ... | @@ -4213,6 +4239,7 @@ template <class _Codecvt, class _Elem, class _Tr> |
| 4213 | 4239 | int |
| 4214 | 4240 | wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() |
| 4215 | 4241 | { |
| 4242 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4216 | 4243 | if (__cv_ == 0 || __bufptr_ == 0) |
| 4217 | 4244 | return 0; |
| 4218 | 4245 | if (__cm_ & ios_base::out) |
| ... | ... | @@ -4281,6 +4308,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() |
| 4281 | 4308 | return 0; |
| 4282 | 4309 | } |
| 4283 | 4310 | |
| 4311 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4284 | 4312 | template <class _Codecvt, class _Elem, class _Tr> |
| 4285 | 4313 | bool |
| 4286 | 4314 | wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() |
| ... | ... | @@ -4335,6 +4363,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() |
| 4335 | 4363 | return __rt; |
| 4336 | 4364 | } |
| 4337 | 4365 | |
| 4366 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4367 | ||
| 4338 | 4368 | _LIBCPP_END_NAMESPACE_STD |
| 4339 | 4369 | |
| 4340 | 4370 | _LIBCPP_POP_MACROS |
lib/libcxx/include/locale.h+2-2| ... | ... | @@ -36,11 +36,11 @@ Functions: |
| 36 | 36 | #include <__config> |
| 37 | 37 | |
| 38 | 38 | #if defined(_LIBCPP_HAS_NO_LOCALIZATION) |
| 39 | # error "The Localization library is not supported since libc++ has been configured with LIBCXX_ENABLE_LOCALIZATION disabled" | |
| 39 | # error "<locale.h> is not supported since libc++ has been configured without support for localization." | |
| 40 | 40 | #endif |
| 41 | 41 | |
| 42 | 42 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 43 | # pragma GCC system_header | |
| 43 | # pragma GCC system_header | |
| 44 | 44 | #endif |
| 45 | 45 | |
| 46 | 46 | #include_next <locale.h> |
lib/libcxx/include/map+65-64| ... | ... | @@ -528,24 +528,45 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 |
| 528 | 528 | |
| 529 | 529 | */ |
| 530 | 530 | |
| 531 | #include <__algorithm/equal.h> | |
| 532 | #include <__algorithm/lexicographical_compare.h> | |
| 533 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 531 | 534 | #include <__config> |
| 532 | #include <__debug> | |
| 535 | #include <__functional/binary_function.h> | |
| 533 | 536 | #include <__functional/is_transparent.h> |
| 537 | #include <__functional/operations.h> | |
| 538 | #include <__iterator/erase_if_container.h> | |
| 534 | 539 | #include <__iterator/iterator_traits.h> |
| 540 | #include <__iterator/reverse_iterator.h> | |
| 535 | 541 | #include <__node_handle> |
| 536 | 542 | #include <__tree> |
| 537 | 543 | #include <__utility/forward.h> |
| 538 | #include <compare> | |
| 539 | #include <functional> | |
| 540 | #include <initializer_list> | |
| 541 | #include <iterator> // __libcpp_erase_if_container | |
| 544 | #include <__utility/swap.h> | |
| 542 | 545 | #include <memory> |
| 543 | 546 | #include <type_traits> |
| 544 | #include <utility> | |
| 545 | 547 | #include <version> |
| 546 | 548 | |
| 549 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 550 | # include <functional> | |
| 551 | # include <iterator> | |
| 552 | # include <utility> | |
| 553 | #endif | |
| 554 | ||
| 555 | // standard-mandated includes | |
| 556 | ||
| 557 | // [iterator.range] | |
| 558 | #include <__iterator/access.h> | |
| 559 | #include <__iterator/data.h> | |
| 560 | #include <__iterator/empty.h> | |
| 561 | #include <__iterator/reverse_access.h> | |
| 562 | #include <__iterator/size.h> | |
| 563 | ||
| 564 | // [associative.map.syn] | |
| 565 | #include <compare> | |
| 566 | #include <initializer_list> | |
| 567 | ||
| 547 | 568 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 548 | #pragma GCC system_header | |
| 569 | # pragma GCC system_header | |
| 549 | 570 | #endif |
| 550 | 571 | |
| 551 | 572 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -561,9 +582,9 @@ public: |
| 561 | 582 | _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| 562 | 583 | : _Compare() {} |
| 563 | 584 | _LIBCPP_INLINE_VISIBILITY |
| 564 | __map_value_compare(_Compare c) | |
| 585 | __map_value_compare(_Compare __c) | |
| 565 | 586 | _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) |
| 566 | : _Compare(c) {} | |
| 587 | : _Compare(__c) {} | |
| 567 | 588 | _LIBCPP_INLINE_VISIBILITY |
| 568 | 589 | const _Compare& key_comp() const _NOEXCEPT {return *this;} |
| 569 | 590 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -606,9 +627,9 @@ public: |
| 606 | 627 | _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) |
| 607 | 628 | : comp() {} |
| 608 | 629 | _LIBCPP_INLINE_VISIBILITY |
| 609 | __map_value_compare(_Compare c) | |
| 630 | __map_value_compare(_Compare __c) | |
| 610 | 631 | _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) |
| 611 | : comp(c) {} | |
| 632 | : comp(__c) {} | |
| 612 | 633 | _LIBCPP_INLINE_VISIBILITY |
| 613 | 634 | const _Compare& key_comp() const _NOEXCEPT {return comp;} |
| 614 | 635 | |
| ... | ... | @@ -771,9 +792,7 @@ public: |
| 771 | 792 | } |
| 772 | 793 | |
| 773 | 794 | template <class _ValueTp, |
| 774 | class = typename enable_if< | |
| 775 | __is_same_uncvref<_ValueTp, value_type>::value | |
| 776 | >::type | |
| 795 | class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> | |
| 777 | 796 | > |
| 778 | 797 | _LIBCPP_INLINE_VISIBILITY |
| 779 | 798 | __value_type& operator=(_ValueTp&& __v) |
| ... | ... | @@ -956,32 +975,23 @@ public: |
| 956 | 975 | typedef _Key key_type; |
| 957 | 976 | typedef _Tp mapped_type; |
| 958 | 977 | typedef pair<const key_type, mapped_type> value_type; |
| 959 | typedef __identity_t<_Compare> key_compare; | |
| 960 | typedef __identity_t<_Allocator> allocator_type; | |
| 978 | typedef __type_identity_t<_Compare> key_compare; | |
| 979 | typedef __type_identity_t<_Allocator> allocator_type; | |
| 961 | 980 | typedef value_type& reference; |
| 962 | 981 | typedef const value_type& const_reference; |
| 963 | 982 | |
| 964 | 983 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 965 | 984 | "Allocator::value_type must be same type as value_type"); |
| 966 | 985 | |
| 967 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 968 | 986 | class _LIBCPP_TEMPLATE_VIS value_compare |
| 969 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 970 | : public binary_function<value_type, value_type, bool> | |
| 971 | #endif | |
| 987 | : public __binary_function<value_type, value_type, bool> | |
| 972 | 988 | { |
| 973 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 974 | 989 | friend class map; |
| 975 | 990 | protected: |
| 976 | 991 | key_compare comp; |
| 977 | 992 | |
| 978 | _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} | |
| 993 | _LIBCPP_INLINE_VISIBILITY value_compare(key_compare __c) : comp(__c) {} | |
| 979 | 994 | public: |
| 980 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 981 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 982 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type; | |
| 983 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type; | |
| 984 | #endif | |
| 985 | 995 | _LIBCPP_INLINE_VISIBILITY |
| 986 | 996 | bool operator()(const value_type& __x, const value_type& __y) const |
| 987 | 997 | {return comp(__x.first, __y.first);} |
| ... | ... | @@ -1218,13 +1228,13 @@ public: |
| 1218 | 1228 | } |
| 1219 | 1229 | |
| 1220 | 1230 | template <class _Pp, |
| 1221 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 1231 | class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | |
| 1222 | 1232 | _LIBCPP_INLINE_VISIBILITY |
| 1223 | 1233 | pair<iterator, bool> insert(_Pp&& __p) |
| 1224 | 1234 | {return __tree_.__insert_unique(_VSTD::forward<_Pp>(__p));} |
| 1225 | 1235 | |
| 1226 | 1236 | template <class _Pp, |
| 1227 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 1237 | class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | |
| 1228 | 1238 | _LIBCPP_INLINE_VISIBILITY |
| 1229 | 1239 | iterator insert(const_iterator __pos, _Pp&& __p) |
| 1230 | 1240 | {return __tree_.__insert_unique(__pos.__i_, _VSTD::forward<_Pp>(__p));} |
| ... | ... | @@ -1444,11 +1454,11 @@ public: |
| 1444 | 1454 | #if _LIBCPP_STD_VER > 11 |
| 1445 | 1455 | template <typename _K2> |
| 1446 | 1456 | _LIBCPP_INLINE_VISIBILITY |
| 1447 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type | |
| 1457 | __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> | |
| 1448 | 1458 | find(const _K2& __k) {return __tree_.find(__k);} |
| 1449 | 1459 | template <typename _K2> |
| 1450 | 1460 | _LIBCPP_INLINE_VISIBILITY |
| 1451 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type | |
| 1461 | __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> | |
| 1452 | 1462 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 1453 | 1463 | #endif |
| 1454 | 1464 | |
| ... | ... | @@ -1458,7 +1468,7 @@ public: |
| 1458 | 1468 | #if _LIBCPP_STD_VER > 11 |
| 1459 | 1469 | template <typename _K2> |
| 1460 | 1470 | _LIBCPP_INLINE_VISIBILITY |
| 1461 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type | |
| 1471 | __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type> | |
| 1462 | 1472 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
| 1463 | 1473 | #endif |
| 1464 | 1474 | |
| ... | ... | @@ -1467,7 +1477,7 @@ public: |
| 1467 | 1477 | bool contains(const key_type& __k) const {return find(__k) != end();} |
| 1468 | 1478 | template <typename _K2> |
| 1469 | 1479 | _LIBCPP_INLINE_VISIBILITY |
| 1470 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type | |
| 1480 | __enable_if_t<__is_transparent<_Compare, _K2>::value, bool> | |
| 1471 | 1481 | contains(const _K2& __k) const { return find(__k) != end(); } |
| 1472 | 1482 | #endif // _LIBCPP_STD_VER > 17 |
| 1473 | 1483 | |
| ... | ... | @@ -1480,12 +1490,12 @@ public: |
| 1480 | 1490 | #if _LIBCPP_STD_VER > 11 |
| 1481 | 1491 | template <typename _K2> |
| 1482 | 1492 | _LIBCPP_INLINE_VISIBILITY |
| 1483 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type | |
| 1493 | __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> | |
| 1484 | 1494 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 1485 | 1495 | |
| 1486 | 1496 | template <typename _K2> |
| 1487 | 1497 | _LIBCPP_INLINE_VISIBILITY |
| 1488 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type | |
| 1498 | __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> | |
| 1489 | 1499 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 1490 | 1500 | #endif |
| 1491 | 1501 | |
| ... | ... | @@ -1498,11 +1508,11 @@ public: |
| 1498 | 1508 | #if _LIBCPP_STD_VER > 11 |
| 1499 | 1509 | template <typename _K2> |
| 1500 | 1510 | _LIBCPP_INLINE_VISIBILITY |
| 1501 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type | |
| 1511 | __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> | |
| 1502 | 1512 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 1503 | 1513 | template <typename _K2> |
| 1504 | 1514 | _LIBCPP_INLINE_VISIBILITY |
| 1505 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type | |
| 1515 | __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> | |
| 1506 | 1516 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 1507 | 1517 | #endif |
| 1508 | 1518 | |
| ... | ... | @@ -1515,11 +1525,11 @@ public: |
| 1515 | 1525 | #if _LIBCPP_STD_VER > 11 |
| 1516 | 1526 | template <typename _K2> |
| 1517 | 1527 | _LIBCPP_INLINE_VISIBILITY |
| 1518 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type | |
| 1528 | __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>> | |
| 1519 | 1529 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 1520 | 1530 | template <typename _K2> |
| 1521 | 1531 | _LIBCPP_INLINE_VISIBILITY |
| 1522 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type | |
| 1532 | __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>> | |
| 1523 | 1533 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 1524 | 1534 | #endif |
| 1525 | 1535 | |
| ... | ... | @@ -1741,33 +1751,24 @@ public: |
| 1741 | 1751 | typedef _Key key_type; |
| 1742 | 1752 | typedef _Tp mapped_type; |
| 1743 | 1753 | typedef pair<const key_type, mapped_type> value_type; |
| 1744 | typedef __identity_t<_Compare> key_compare; | |
| 1745 | typedef __identity_t<_Allocator> allocator_type; | |
| 1754 | typedef __type_identity_t<_Compare> key_compare; | |
| 1755 | typedef __type_identity_t<_Allocator> allocator_type; | |
| 1746 | 1756 | typedef value_type& reference; |
| 1747 | 1757 | typedef const value_type& const_reference; |
| 1748 | 1758 | |
| 1749 | 1759 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 1750 | 1760 | "Allocator::value_type must be same type as value_type"); |
| 1751 | 1761 | |
| 1752 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 1753 | 1762 | class _LIBCPP_TEMPLATE_VIS value_compare |
| 1754 | #if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 1755 | : public binary_function<value_type, value_type, bool> | |
| 1756 | #endif | |
| 1763 | : public __binary_function<value_type, value_type, bool> | |
| 1757 | 1764 | { |
| 1758 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 1759 | 1765 | friend class multimap; |
| 1760 | 1766 | protected: |
| 1761 | 1767 | key_compare comp; |
| 1762 | 1768 | |
| 1763 | 1769 | _LIBCPP_INLINE_VISIBILITY |
| 1764 | value_compare(key_compare c) : comp(c) {} | |
| 1770 | value_compare(key_compare __c) : comp(__c) {} | |
| 1765 | 1771 | public: |
| 1766 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) | |
| 1767 | _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; | |
| 1768 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type; | |
| 1769 | _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type; | |
| 1770 | #endif | |
| 1771 | 1772 | _LIBCPP_INLINE_VISIBILITY |
| 1772 | 1773 | bool operator()(const value_type& __x, const value_type& __y) const |
| 1773 | 1774 | {return comp(__x.first, __y.first);} |
| ... | ... | @@ -1997,13 +1998,13 @@ public: |
| 1997 | 1998 | } |
| 1998 | 1999 | |
| 1999 | 2000 | template <class _Pp, |
| 2000 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 2001 | class = __enable_if_t<is_constructible<value_type, _Pp>::value>> | |
| 2001 | 2002 | _LIBCPP_INLINE_VISIBILITY |
| 2002 | 2003 | iterator insert(_Pp&& __p) |
| 2003 | 2004 | {return __tree_.__insert_multi(_VSTD::forward<_Pp>(__p));} |
| 2004 | 2005 | |
| 2005 | 2006 | template <class _Pp, |
| 2006 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 2007 | class = __enable_if_t<is_constructible<value_type, _Pp>::value>> | |
| 2007 | 2008 | _LIBCPP_INLINE_VISIBILITY |
| 2008 | 2009 | iterator insert(const_iterator __pos, _Pp&& __p) |
| 2009 | 2010 | {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));} |
| ... | ... | @@ -2125,11 +2126,11 @@ public: |
| 2125 | 2126 | #if _LIBCPP_STD_VER > 11 |
| 2126 | 2127 | template <typename _K2> |
| 2127 | 2128 | _LIBCPP_INLINE_VISIBILITY |
| 2128 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type | |
| 2129 | __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> | |
| 2129 | 2130 | find(const _K2& __k) {return __tree_.find(__k);} |
| 2130 | 2131 | template <typename _K2> |
| 2131 | 2132 | _LIBCPP_INLINE_VISIBILITY |
| 2132 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type | |
| 2133 | __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> | |
| 2133 | 2134 | find(const _K2& __k) const {return __tree_.find(__k);} |
| 2134 | 2135 | #endif |
| 2135 | 2136 | |
| ... | ... | @@ -2139,7 +2140,7 @@ public: |
| 2139 | 2140 | #if _LIBCPP_STD_VER > 11 |
| 2140 | 2141 | template <typename _K2> |
| 2141 | 2142 | _LIBCPP_INLINE_VISIBILITY |
| 2142 | typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type | |
| 2143 | __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type> | |
| 2143 | 2144 | count(const _K2& __k) const {return __tree_.__count_multi(__k);} |
| 2144 | 2145 | #endif |
| 2145 | 2146 | |
| ... | ... | @@ -2148,7 +2149,7 @@ public: |
| 2148 | 2149 | bool contains(const key_type& __k) const {return find(__k) != end();} |
| 2149 | 2150 | template <typename _K2> |
| 2150 | 2151 | _LIBCPP_INLINE_VISIBILITY |
| 2151 | typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type | |
| 2152 | __enable_if_t<__is_transparent<_Compare, _K2>::value, bool> | |
| 2152 | 2153 | contains(const _K2& __k) const { return find(__k) != end(); } |
| 2153 | 2154 | #endif // _LIBCPP_STD_VER > 17 |
| 2154 | 2155 | |
| ... | ... | @@ -2161,12 +2162,12 @@ public: |
| 2161 | 2162 | #if _LIBCPP_STD_VER > 11 |
| 2162 | 2163 | template <typename _K2> |
| 2163 | 2164 | _LIBCPP_INLINE_VISIBILITY |
| 2164 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type | |
| 2165 | __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> | |
| 2165 | 2166 | lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} |
| 2166 | 2167 | |
| 2167 | 2168 | template <typename _K2> |
| 2168 | 2169 | _LIBCPP_INLINE_VISIBILITY |
| 2169 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type | |
| 2170 | __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> | |
| 2170 | 2171 | lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} |
| 2171 | 2172 | #endif |
| 2172 | 2173 | |
| ... | ... | @@ -2179,11 +2180,11 @@ public: |
| 2179 | 2180 | #if _LIBCPP_STD_VER > 11 |
| 2180 | 2181 | template <typename _K2> |
| 2181 | 2182 | _LIBCPP_INLINE_VISIBILITY |
| 2182 | typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type | |
| 2183 | __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> | |
| 2183 | 2184 | upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} |
| 2184 | 2185 | template <typename _K2> |
| 2185 | 2186 | _LIBCPP_INLINE_VISIBILITY |
| 2186 | typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type | |
| 2187 | __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> | |
| 2187 | 2188 | upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} |
| 2188 | 2189 | #endif |
| 2189 | 2190 | |
| ... | ... | @@ -2196,11 +2197,11 @@ public: |
| 2196 | 2197 | #if _LIBCPP_STD_VER > 11 |
| 2197 | 2198 | template <typename _K2> |
| 2198 | 2199 | _LIBCPP_INLINE_VISIBILITY |
| 2199 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type | |
| 2200 | __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>> | |
| 2200 | 2201 | equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} |
| 2201 | 2202 | template <typename _K2> |
| 2202 | 2203 | _LIBCPP_INLINE_VISIBILITY |
| 2203 | typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type | |
| 2204 | __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>> | |
| 2204 | 2205 | equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} |
| 2205 | 2206 | #endif |
| 2206 | 2207 |
lib/libcxx/include/math.h+45-44| ... | ... | @@ -294,7 +294,7 @@ long double truncl(long double x); |
| 294 | 294 | #include <__config> |
| 295 | 295 | |
| 296 | 296 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 297 | #pragma GCC system_header | |
| 297 | # pragma GCC system_header | |
| 298 | 298 | #endif |
| 299 | 299 | |
| 300 | 300 | #include_next <math.h> |
| ... | ... | @@ -305,6 +305,7 @@ 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 <__type_traits/promote.h> | |
| 308 | 309 | #include <limits> |
| 309 | 310 | #include <stdlib.h> |
| 310 | 311 | #include <type_traits> |
| ... | ... | @@ -788,10 +789,10 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT |
| 788 | 789 | |
| 789 | 790 | // acos |
| 790 | 791 | |
| 791 | #if !(defined(_AIX) || defined(__sun__)) | |
| 792 | # if !defined(__sun__) | |
| 792 | 793 | inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);} |
| 793 | 794 | inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);} |
| 794 | #endif | |
| 795 | # endif | |
| 795 | 796 | |
| 796 | 797 | template <class _A1> |
| 797 | 798 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -800,10 +801,10 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);} |
| 800 | 801 | |
| 801 | 802 | // asin |
| 802 | 803 | |
| 803 | #if !(defined(_AIX) || defined(__sun__)) | |
| 804 | # if !defined(__sun__) | |
| 804 | 805 | inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);} |
| 805 | 806 | inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);} |
| 806 | #endif | |
| 807 | # endif | |
| 807 | 808 | |
| 808 | 809 | template <class _A1> |
| 809 | 810 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -812,10 +813,10 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);} |
| 812 | 813 | |
| 813 | 814 | // atan |
| 814 | 815 | |
| 815 | #if !(defined(_AIX) || defined(__sun__)) | |
| 816 | # if !defined(__sun__) | |
| 816 | 817 | inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);} |
| 817 | 818 | inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);} |
| 818 | #endif | |
| 819 | # endif | |
| 819 | 820 | |
| 820 | 821 | template <class _A1> |
| 821 | 822 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -824,10 +825,10 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);} |
| 824 | 825 | |
| 825 | 826 | // atan2 |
| 826 | 827 | |
| 827 | #if !(defined(_AIX) || defined(__sun__)) | |
| 828 | # if !defined(__sun__) | |
| 828 | 829 | inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);} |
| 829 | 830 | inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);} |
| 830 | #endif | |
| 831 | # endif | |
| 831 | 832 | |
| 832 | 833 | template <class _A1, class _A2> |
| 833 | 834 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -847,10 +848,10 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT |
| 847 | 848 | |
| 848 | 849 | // ceil |
| 849 | 850 | |
| 850 | #if !(defined(_AIX) || defined(__sun__)) | |
| 851 | # if !defined(__sun__) | |
| 851 | 852 | inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);} |
| 852 | 853 | inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);} |
| 853 | #endif | |
| 854 | # endif | |
| 854 | 855 | |
| 855 | 856 | template <class _A1> |
| 856 | 857 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -859,10 +860,10 @@ ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);} |
| 859 | 860 | |
| 860 | 861 | // cos |
| 861 | 862 | |
| 862 | #if !(defined(_AIX) || defined(__sun__)) | |
| 863 | # if !defined(__sun__) | |
| 863 | 864 | inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);} |
| 864 | 865 | inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);} |
| 865 | #endif | |
| 866 | # endif | |
| 866 | 867 | |
| 867 | 868 | template <class _A1> |
| 868 | 869 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -871,10 +872,10 @@ cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);} |
| 871 | 872 | |
| 872 | 873 | // cosh |
| 873 | 874 | |
| 874 | #if !(defined(_AIX) || defined(__sun__)) | |
| 875 | # if !defined(__sun__) | |
| 875 | 876 | inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);} |
| 876 | 877 | inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);} |
| 877 | #endif | |
| 878 | # endif | |
| 878 | 879 | |
| 879 | 880 | template <class _A1> |
| 880 | 881 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -883,10 +884,10 @@ cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);} |
| 883 | 884 | |
| 884 | 885 | // exp |
| 885 | 886 | |
| 886 | #if !(defined(_AIX) || defined(__sun__)) | |
| 887 | # if !defined(__sun__) | |
| 887 | 888 | inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);} |
| 888 | 889 | inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);} |
| 889 | #endif | |
| 890 | # endif | |
| 890 | 891 | |
| 891 | 892 | template <class _A1> |
| 892 | 893 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -895,10 +896,10 @@ exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);} |
| 895 | 896 | |
| 896 | 897 | // fabs |
| 897 | 898 | |
| 898 | #if !(defined(_AIX) || defined(__sun__)) | |
| 899 | # if !defined(__sun__) | |
| 899 | 900 | inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);} |
| 900 | 901 | inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);} |
| 901 | #endif | |
| 902 | # endif | |
| 902 | 903 | |
| 903 | 904 | template <class _A1> |
| 904 | 905 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -907,10 +908,10 @@ fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);} |
| 907 | 908 | |
| 908 | 909 | // floor |
| 909 | 910 | |
| 910 | #if !(defined(_AIX) || defined(__sun__)) | |
| 911 | # if !defined(__sun__) | |
| 911 | 912 | inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);} |
| 912 | 913 | inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);} |
| 913 | #endif | |
| 914 | # endif | |
| 914 | 915 | |
| 915 | 916 | template <class _A1> |
| 916 | 917 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -919,10 +920,10 @@ floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);} |
| 919 | 920 | |
| 920 | 921 | // fmod |
| 921 | 922 | |
| 922 | #if !(defined(_AIX) || defined(__sun__)) | |
| 923 | # if !defined(__sun__) | |
| 923 | 924 | inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);} |
| 924 | 925 | inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);} |
| 925 | #endif | |
| 926 | # endif | |
| 926 | 927 | |
| 927 | 928 | template <class _A1, class _A2> |
| 928 | 929 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -942,10 +943,10 @@ fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT |
| 942 | 943 | |
| 943 | 944 | // frexp |
| 944 | 945 | |
| 945 | #if !(defined(_AIX) || defined(__sun__)) | |
| 946 | # if !defined(__sun__) | |
| 946 | 947 | inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);} |
| 947 | 948 | inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);} |
| 948 | #endif | |
| 949 | # endif | |
| 949 | 950 | |
| 950 | 951 | template <class _A1> |
| 951 | 952 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -954,10 +955,10 @@ frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, _ |
| 954 | 955 | |
| 955 | 956 | // ldexp |
| 956 | 957 | |
| 957 | #if !(defined(_AIX) || defined(__sun__)) | |
| 958 | # if !defined(__sun__) | |
| 958 | 959 | inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);} |
| 959 | 960 | inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);} |
| 960 | #endif | |
| 961 | # endif | |
| 961 | 962 | |
| 962 | 963 | template <class _A1> |
| 963 | 964 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -966,10 +967,10 @@ ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __ |
| 966 | 967 | |
| 967 | 968 | // log |
| 968 | 969 | |
| 969 | #if !(defined(_AIX) || defined(__sun__)) | |
| 970 | # if !defined(__sun__) | |
| 970 | 971 | inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);} |
| 971 | 972 | inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);} |
| 972 | #endif | |
| 973 | # endif | |
| 973 | 974 | |
| 974 | 975 | template <class _A1> |
| 975 | 976 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -978,10 +979,10 @@ log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);} |
| 978 | 979 | |
| 979 | 980 | // log10 |
| 980 | 981 | |
| 981 | #if !(defined(_AIX) || defined(__sun__)) | |
| 982 | # if !defined(__sun__) | |
| 982 | 983 | inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);} |
| 983 | 984 | inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);} |
| 984 | #endif | |
| 985 | # endif | |
| 985 | 986 | |
| 986 | 987 | template <class _A1> |
| 987 | 988 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -990,17 +991,17 @@ log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);} |
| 990 | 991 | |
| 991 | 992 | // modf |
| 992 | 993 | |
| 993 | #if !(defined(_AIX) || defined(__sun__)) | |
| 994 | # if !defined(__sun__) | |
| 994 | 995 | inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);} |
| 995 | 996 | inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);} |
| 996 | #endif | |
| 997 | # endif | |
| 997 | 998 | |
| 998 | 999 | // pow |
| 999 | 1000 | |
| 1000 | #if !(defined(_AIX) || defined(__sun__)) | |
| 1001 | # if !defined(__sun__) | |
| 1001 | 1002 | inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);} |
| 1002 | 1003 | inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);} |
| 1003 | #endif | |
| 1004 | # endif | |
| 1004 | 1005 | |
| 1005 | 1006 | template <class _A1, class _A2> |
| 1006 | 1007 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1020,7 +1021,7 @@ pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT |
| 1020 | 1021 | |
| 1021 | 1022 | // sin |
| 1022 | 1023 | |
| 1023 | #if !(defined(_AIX) || defined(__sun__)) | |
| 1024 | # if !defined(__sun__) | |
| 1024 | 1025 | inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);} |
| 1025 | 1026 | inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);} |
| 1026 | 1027 | #endif |
| ... | ... | @@ -1032,10 +1033,10 @@ sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);} |
| 1032 | 1033 | |
| 1033 | 1034 | // sinh |
| 1034 | 1035 | |
| 1035 | #if !(defined(_AIX) || defined(__sun__)) | |
| 1036 | # if !defined(__sun__) | |
| 1036 | 1037 | inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);} |
| 1037 | 1038 | inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);} |
| 1038 | #endif | |
| 1039 | # endif | |
| 1039 | 1040 | |
| 1040 | 1041 | template <class _A1> |
| 1041 | 1042 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1044,10 +1045,10 @@ sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);} |
| 1044 | 1045 | |
| 1045 | 1046 | // sqrt |
| 1046 | 1047 | |
| 1047 | #if !(defined(_AIX) || defined(__sun__)) | |
| 1048 | # if !defined(__sun__) | |
| 1048 | 1049 | inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);} |
| 1049 | 1050 | inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);} |
| 1050 | #endif | |
| 1051 | # endif | |
| 1051 | 1052 | |
| 1052 | 1053 | template <class _A1> |
| 1053 | 1054 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1056,10 +1057,10 @@ sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);} |
| 1056 | 1057 | |
| 1057 | 1058 | // tan |
| 1058 | 1059 | |
| 1059 | #if !(defined(_AIX) || defined(__sun__)) | |
| 1060 | # if !defined(__sun__) | |
| 1060 | 1061 | inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);} |
| 1061 | 1062 | inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);} |
| 1062 | #endif | |
| 1063 | # endif | |
| 1063 | 1064 | |
| 1064 | 1065 | template <class _A1> |
| 1065 | 1066 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1068,10 +1069,10 @@ tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);} |
| 1068 | 1069 | |
| 1069 | 1070 | // tanh |
| 1070 | 1071 | |
| 1071 | #if !(defined(_AIX) || defined(__sun__)) | |
| 1072 | # if !defined(__sun__) | |
| 1072 | 1073 | inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);} |
| 1073 | 1074 | inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);} |
| 1074 | #endif | |
| 1075 | # endif | |
| 1075 | 1076 | |
| 1076 | 1077 | template <class _A1> |
| 1077 | 1078 | inline _LIBCPP_INLINE_VISIBILITY |
lib/libcxx/include/memory+68-137| ... | ... | @@ -98,6 +98,16 @@ struct allocator_traits |
| 98 | 98 | static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20 |
| 99 | 99 | }; |
| 100 | 100 | |
| 101 | template<class Pointer> | |
| 102 | struct allocation_result { | |
| 103 | Pointer ptr; | |
| 104 | size_t count; | |
| 105 | }; // since C++23 | |
| 106 | ||
| 107 | template<class Allocator> | |
| 108 | [[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer> | |
| 109 | allocate_at_least(Allocator& a, size_t n); // since C++23 | |
| 110 | ||
| 101 | 111 | template <> |
| 102 | 112 | class allocator<void> // removed in C++20 |
| 103 | 113 | { |
| ... | ... | @@ -661,9 +671,29 @@ template<class E, class T, class Y> |
| 661 | 671 | template<class D, class T> D* get_deleter(shared_ptr<T> const& p) noexcept; |
| 662 | 672 | |
| 663 | 673 | template<class T, class... Args> |
| 664 | shared_ptr<T> make_shared(Args&&... args); | |
| 674 | shared_ptr<T> make_shared(Args&&... args); // T is not an array | |
| 665 | 675 | template<class T, class A, class... Args> |
| 666 | shared_ptr<T> allocate_shared(const A& a, Args&&... args); | |
| 676 | shared_ptr<T> allocate_shared(const A& a, Args&&... args); // T is not an array | |
| 677 | ||
| 678 | template<class T> | |
| 679 | shared_ptr<T> make_shared(size_t N); // T is U[] (since C++20) | |
| 680 | template<class T, class A> | |
| 681 | shared_ptr<T> allocate_shared(const A& a, size_t N); // T is U[] (since C++20) | |
| 682 | ||
| 683 | template<class T> | |
| 684 | shared_ptr<T> make_shared(); // T is U[N] (since C++20) | |
| 685 | template<class T, class A> | |
| 686 | shared_ptr<T> allocate_shared(const A& a); // T is U[N] (since C++20) | |
| 687 | ||
| 688 | template<class T> | |
| 689 | shared_ptr<T> make_shared(size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20) | |
| 690 | template<class T, class A> | |
| 691 | shared_ptr<T> allocate_shared(const A& a, size_t N, const remove_extent_t<T>& u); // T is U[] (since C++20) | |
| 692 | ||
| 693 | template<class T> shared_ptr<T> | |
| 694 | make_shared(const remove_extent_t<T>& u); // T is U[N] (since C++20) | |
| 695 | template<class T, class A> | |
| 696 | shared_ptr<T> allocate_shared(const A& a, const remove_extent_t<T>& u); // T is U[N] (since C++20) | |
| 667 | 697 | |
| 668 | 698 | template<class T> |
| 669 | 699 | class weak_ptr |
| ... | ... | @@ -798,19 +828,28 @@ template <class T> struct hash<shared_ptr<T> >; |
| 798 | 828 | template <class T, class Alloc> |
| 799 | 829 | inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; |
| 800 | 830 | |
| 831 | // [ptr.align] | |
| 801 | 832 | void* align(size_t alignment, size_t size, void*& ptr, size_t& space); |
| 802 | 833 | |
| 834 | template<size_t N, class T> | |
| 835 | [[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20 | |
| 836 | ||
| 803 | 837 | } // std |
| 804 | 838 | |
| 805 | 839 | */ |
| 806 | 840 | |
| 841 | #include <__algorithm/copy.h> | |
| 842 | #include <__algorithm/move.h> | |
| 843 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 807 | 844 | #include <__config> |
| 808 | #include <__functional_base> | |
| 809 | 845 | #include <__memory/addressof.h> |
| 846 | #include <__memory/allocate_at_least.h> | |
| 810 | 847 | #include <__memory/allocation_guard.h> |
| 811 | 848 | #include <__memory/allocator.h> |
| 812 | 849 | #include <__memory/allocator_arg_t.h> |
| 813 | 850 | #include <__memory/allocator_traits.h> |
| 851 | #include <__memory/assume_aligned.h> | |
| 852 | #include <__memory/auto_ptr.h> | |
| 814 | 853 | #include <__memory/compressed_pair.h> |
| 815 | 854 | #include <__memory/concepts.h> |
| 816 | 855 | #include <__memory/construct_at.h> |
| ... | ... | @@ -823,117 +862,31 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); |
| 823 | 862 | #include <__memory/uninitialized_algorithms.h> |
| 824 | 863 | #include <__memory/unique_ptr.h> |
| 825 | 864 | #include <__memory/uses_allocator.h> |
| 826 | #include <compare> | |
| 827 | 865 | #include <cstddef> |
| 828 | 866 | #include <cstdint> |
| 829 | 867 | #include <cstring> |
| 830 | 868 | #include <iosfwd> |
| 831 | #include <iterator> | |
| 832 | 869 | #include <new> |
| 833 | 870 | #include <stdexcept> |
| 834 | 871 | #include <tuple> |
| 835 | 872 | #include <type_traits> |
| 836 | 873 | #include <typeinfo> |
| 837 | #include <utility> | |
| 838 | 874 | #include <version> |
| 839 | 875 | |
| 840 | #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) | |
| 841 | # include <__memory/auto_ptr.h> | |
| 876 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 877 | # include <iterator> | |
| 878 | # include <utility> | |
| 842 | 879 | #endif |
| 843 | 880 | |
| 881 | // standard-mandated includes | |
| 882 | #include <compare> | |
| 883 | ||
| 844 | 884 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 845 | #pragma GCC system_header | |
| 885 | # pragma GCC system_header | |
| 846 | 886 | #endif |
| 847 | 887 | |
| 848 | 888 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 849 | 889 | |
| 850 | template <class _Alloc, class _Ptr> | |
| 851 | _LIBCPP_INLINE_VISIBILITY | |
| 852 | void __construct_forward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __begin2) { | |
| 853 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, | |
| 854 | "The specified type does not meet the requirements of Cpp17MoveInsertable"); | |
| 855 | typedef allocator_traits<_Alloc> _Traits; | |
| 856 | for (; __begin1 != __end1; ++__begin1, (void)++__begin2) { | |
| 857 | _Traits::construct(__a, _VSTD::__to_address(__begin2), | |
| 858 | #ifdef _LIBCPP_NO_EXCEPTIONS | |
| 859 | _VSTD::move(*__begin1) | |
| 860 | #else | |
| 861 | _VSTD::move_if_noexcept(*__begin1) | |
| 862 | #endif | |
| 863 | ); | |
| 864 | } | |
| 865 | } | |
| 866 | ||
| 867 | template <class _Alloc, class _Tp, typename enable_if< | |
| 868 | (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) && | |
| 869 | is_trivially_move_constructible<_Tp>::value | |
| 870 | >::type> | |
| 871 | _LIBCPP_INLINE_VISIBILITY | |
| 872 | void __construct_forward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __begin2) { | |
| 873 | ptrdiff_t _Np = __end1 - __begin1; | |
| 874 | if (_Np > 0) { | |
| 875 | _VSTD::memcpy(__begin2, __begin1, _Np * sizeof(_Tp)); | |
| 876 | __begin2 += _Np; | |
| 877 | } | |
| 878 | } | |
| 879 | ||
| 880 | template <class _Alloc, class _Iter, class _Ptr> | |
| 881 | _LIBCPP_INLINE_VISIBILITY | |
| 882 | void __construct_range_forward(_Alloc& __a, _Iter __begin1, _Iter __end1, _Ptr& __begin2) { | |
| 883 | typedef allocator_traits<_Alloc> _Traits; | |
| 884 | for (; __begin1 != __end1; ++__begin1, (void) ++__begin2) { | |
| 885 | _Traits::construct(__a, _VSTD::__to_address(__begin2), *__begin1); | |
| 886 | } | |
| 887 | } | |
| 888 | ||
| 889 | template <class _Alloc, class _Source, class _Dest, | |
| 890 | class _RawSource = typename remove_const<_Source>::type, | |
| 891 | class _RawDest = typename remove_const<_Dest>::type, | |
| 892 | class = | |
| 893 | typename enable_if< | |
| 894 | is_trivially_copy_constructible<_Dest>::value && | |
| 895 | is_same<_RawSource, _RawDest>::value && | |
| 896 | (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Dest*, _Source&>::value) | |
| 897 | >::type> | |
| 898 | _LIBCPP_INLINE_VISIBILITY | |
| 899 | void __construct_range_forward(_Alloc&, _Source* __begin1, _Source* __end1, _Dest*& __begin2) { | |
| 900 | ptrdiff_t _Np = __end1 - __begin1; | |
| 901 | if (_Np > 0) { | |
| 902 | _VSTD::memcpy(const_cast<_RawDest*>(__begin2), __begin1, _Np * sizeof(_Dest)); | |
| 903 | __begin2 += _Np; | |
| 904 | } | |
| 905 | } | |
| 906 | ||
| 907 | template <class _Alloc, class _Ptr> | |
| 908 | _LIBCPP_INLINE_VISIBILITY | |
| 909 | void __construct_backward_with_exception_guarantees(_Alloc& __a, _Ptr __begin1, _Ptr __end1, _Ptr& __end2) { | |
| 910 | static_assert(__is_cpp17_move_insertable<_Alloc>::value, | |
| 911 | "The specified type does not meet the requirements of Cpp17MoveInsertable"); | |
| 912 | typedef allocator_traits<_Alloc> _Traits; | |
| 913 | while (__end1 != __begin1) { | |
| 914 | _Traits::construct(__a, _VSTD::__to_address(__end2 - 1), | |
| 915 | #ifdef _LIBCPP_NO_EXCEPTIONS | |
| 916 | _VSTD::move(*--__end1) | |
| 917 | #else | |
| 918 | _VSTD::move_if_noexcept(*--__end1) | |
| 919 | #endif | |
| 920 | ); | |
| 921 | --__end2; | |
| 922 | } | |
| 923 | } | |
| 924 | ||
| 925 | template <class _Alloc, class _Tp, class = typename enable_if< | |
| 926 | (__is_default_allocator<_Alloc>::value || !__has_construct<_Alloc, _Tp*, _Tp>::value) && | |
| 927 | is_trivially_move_constructible<_Tp>::value | |
| 928 | >::type> | |
| 929 | _LIBCPP_INLINE_VISIBILITY | |
| 930 | void __construct_backward_with_exception_guarantees(_Alloc&, _Tp* __begin1, _Tp* __end1, _Tp*& __end2) { | |
| 931 | ptrdiff_t _Np = __end1 - __begin1; | |
| 932 | __end2 -= _Np; | |
| 933 | if (_Np > 0) | |
| 934 | _VSTD::memcpy(static_cast<void*>(__end2), static_cast<void const*>(__begin1), _Np * sizeof(_Tp)); | |
| 935 | } | |
| 936 | ||
| 937 | 890 | struct __destruct_n |
| 938 | 891 | { |
| 939 | 892 | private: |
| ... | ... | @@ -975,37 +928,6 @@ public: |
| 975 | 928 | |
| 976 | 929 | _LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); |
| 977 | 930 | |
| 978 | // --- Helper for container swap -- | |
| 979 | template <typename _Alloc> | |
| 980 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 981 | void __swap_allocator(_Alloc & __a1, _Alloc & __a2, true_type) | |
| 982 | #if _LIBCPP_STD_VER > 11 | |
| 983 | _NOEXCEPT | |
| 984 | #else | |
| 985 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) | |
| 986 | #endif | |
| 987 | { | |
| 988 | using _VSTD::swap; | |
| 989 | swap(__a1, __a2); | |
| 990 | } | |
| 991 | ||
| 992 | template <typename _Alloc> | |
| 993 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 994 | void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} | |
| 995 | ||
| 996 | template <typename _Alloc> | |
| 997 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 998 | void __swap_allocator(_Alloc & __a1, _Alloc & __a2) | |
| 999 | #if _LIBCPP_STD_VER > 11 | |
| 1000 | _NOEXCEPT | |
| 1001 | #else | |
| 1002 | _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value) | |
| 1003 | #endif | |
| 1004 | { | |
| 1005 | _VSTD::__swap_allocator(__a1, __a2, | |
| 1006 | integral_constant<bool, allocator_traits<_Alloc>::propagate_on_container_swap::value>()); | |
| 1007 | } | |
| 1008 | ||
| 1009 | 931 | template <typename _Alloc, typename _Traits=allocator_traits<_Alloc> > |
| 1010 | 932 | struct __noexcept_move_assign_container : public integral_constant<bool, |
| 1011 | 933 | _Traits::propagate_on_container_move_assignment::value |
| ... | ... | @@ -1021,21 +943,31 @@ template <class _Tp, class _Alloc> |
| 1021 | 943 | struct __temp_value { |
| 1022 | 944 | typedef allocator_traits<_Alloc> _Traits; |
| 1023 | 945 | |
| 946 | #ifdef _LIBCPP_CXX03_LANG | |
| 1024 | 947 | typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v; |
| 948 | #else | |
| 949 | union { _Tp __v; }; | |
| 950 | #endif | |
| 1025 | 951 | _Alloc &__a; |
| 1026 | 952 | |
| 1027 | _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); } | |
| 1028 | _Tp & get() { return *__addr(); } | |
| 953 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() { | |
| 954 | #ifdef _LIBCPP_CXX03_LANG | |
| 955 | return reinterpret_cast<_Tp*>(std::addressof(__v)); | |
| 956 | #else | |
| 957 | return std::addressof(__v); | |
| 958 | #endif | |
| 959 | } | |
| 960 | ||
| 961 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp & get() { return *__addr(); } | |
| 1029 | 962 | |
| 1030 | 963 | template<class... _Args> |
| 1031 | 964 | _LIBCPP_NO_CFI |
| 1032 | __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) { | |
| 1033 | _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)), | |
| 1034 | _VSTD::forward<_Args>(__args)...); | |
| 965 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) { | |
| 966 | _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...); | |
| 1035 | 967 | } |
| 1036 | 968 | |
| 1037 | ~__temp_value() { _Traits::destroy(__a, __addr()); } | |
| 1038 | }; | |
| 969 | _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); } | |
| 970 | }; | |
| 1039 | 971 | |
| 1040 | 972 | template<typename _Alloc, typename = void, typename = void> |
| 1041 | 973 | struct __is_allocator : false_type {}; |
| ... | ... | @@ -1058,8 +990,8 @@ struct __builtin_new_allocator { |
| 1058 | 990 | _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align) |
| 1059 | 991 | : __size_(__size), __align_(__align) {} |
| 1060 | 992 | |
| 1061 | void operator()(void* p) const _NOEXCEPT { | |
| 1062 | _VSTD::__libcpp_deallocate(p, __size_, __align_); | |
| 993 | void operator()(void* __p) const _NOEXCEPT { | |
| 994 | _VSTD::__libcpp_deallocate(__p, __size_, __align_); | |
| 1063 | 995 | } |
| 1064 | 996 | |
| 1065 | 997 | private: |
| ... | ... | @@ -1092,7 +1024,6 @@ struct __builtin_new_allocator { |
| 1092 | 1024 | } |
| 1093 | 1025 | }; |
| 1094 | 1026 | |
| 1095 | ||
| 1096 | 1027 | _LIBCPP_END_NAMESPACE_STD |
| 1097 | 1028 | |
| 1098 | 1029 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/module.modulemap deleted-1092| ... | ... | @@ -1,1092 +0,0 @@ |
| 1 | // define the module for __config outside of the top level 'std' module | |
| 2 | // since __config may be included from C headers which may create an | |
| 3 | // include cycle. | |
| 4 | module std_config [system] [extern_c] { | |
| 5 | textual header "__config" | |
| 6 | textual header "__config_site" | |
| 7 | } | |
| 8 | ||
| 9 | module std [system] { | |
| 10 | export std_config | |
| 11 | // FIXME: The standard does not require that each of these submodules | |
| 12 | // re-exports its imported modules. We should provide an alternative form of | |
| 13 | // export that issues a warning if a name from the submodule is used, and | |
| 14 | // use that to provide a 'strict mode' for libc++. | |
| 15 | ||
| 16 | // Deprecated C-compatibility headers. These can all be included from within | |
| 17 | // an 'extern "C"' context. | |
| 18 | module depr [extern_c] { | |
| 19 | // <assert.h> provided by C library. | |
| 20 | module ctype_h { | |
| 21 | header "ctype.h" | |
| 22 | export * | |
| 23 | } | |
| 24 | module errno_h { | |
| 25 | header "errno.h" | |
| 26 | export * | |
| 27 | } | |
| 28 | module fenv_h { | |
| 29 | header "fenv.h" | |
| 30 | export * | |
| 31 | } | |
| 32 | // <float.h> provided by compiler or C library. | |
| 33 | module inttypes_h { | |
| 34 | header "inttypes.h" | |
| 35 | export stdint_h | |
| 36 | export * | |
| 37 | } | |
| 38 | // <iso646.h> provided by compiler. | |
| 39 | // <limits.h> provided by compiler or C library. | |
| 40 | module locale_h { | |
| 41 | header "locale.h" | |
| 42 | export * | |
| 43 | } | |
| 44 | module math_h { | |
| 45 | header "math.h" | |
| 46 | export * | |
| 47 | } | |
| 48 | module setjmp_h { | |
| 49 | header "setjmp.h" | |
| 50 | export * | |
| 51 | } | |
| 52 | // FIXME: <stdalign.h> is missing. | |
| 53 | // <signal.h> provided by C library. | |
| 54 | // <stdarg.h> provided by compiler. | |
| 55 | // <stdbool.h> provided by compiler. | |
| 56 | module stddef_h { | |
| 57 | // <stddef.h>'s __need_* macros require textual inclusion. | |
| 58 | textual header "stddef.h" | |
| 59 | } | |
| 60 | module stdint_h { | |
| 61 | header "stdint.h" | |
| 62 | export * | |
| 63 | // FIXME: This module only exists on OS X and for some reason the | |
| 64 | // wildcard above doesn't export it. | |
| 65 | export Darwin.C.stdint | |
| 66 | } | |
| 67 | module stdio_h { | |
| 68 | // <stdio.h>'s __need_* macros require textual inclusion. | |
| 69 | textual header "stdio.h" | |
| 70 | export * | |
| 71 | export Darwin.C.stdio | |
| 72 | } | |
| 73 | module stdlib_h { | |
| 74 | // <stdlib.h>'s __need_* macros require textual inclusion. | |
| 75 | textual header "stdlib.h" | |
| 76 | export * | |
| 77 | } | |
| 78 | module string_h { | |
| 79 | header "string.h" | |
| 80 | export * | |
| 81 | } | |
| 82 | // FIXME: <uchar.h> is missing. | |
| 83 | // <time.h> provided by C library. | |
| 84 | module wchar_h { | |
| 85 | // <wchar.h>'s __need_* macros require textual inclusion. | |
| 86 | textual header "wchar.h" | |
| 87 | export * | |
| 88 | } | |
| 89 | module wctype_h { | |
| 90 | header "wctype.h" | |
| 91 | export * | |
| 92 | } | |
| 93 | } | |
| 94 | ||
| 95 | // <complex.h> and <tgmath.h> are not C headers in any real sense, do not | |
| 96 | // allow their use in extern "C" contexts. | |
| 97 | module complex_h { | |
| 98 | header "complex.h" | |
| 99 | export ccomplex | |
| 100 | export * | |
| 101 | } | |
| 102 | module tgmath_h { | |
| 103 | header "tgmath.h" | |
| 104 | export ccomplex | |
| 105 | export cmath | |
| 106 | export * | |
| 107 | } | |
| 108 | ||
| 109 | // C compatibility headers. | |
| 110 | module compat { | |
| 111 | module cassert { | |
| 112 | // <cassert>'s use of NDEBUG requires textual inclusion. | |
| 113 | textual header "cassert" | |
| 114 | } | |
| 115 | module ccomplex { | |
| 116 | header "ccomplex" | |
| 117 | export complex | |
| 118 | export * | |
| 119 | } | |
| 120 | module cctype { | |
| 121 | header "cctype" | |
| 122 | export * | |
| 123 | } | |
| 124 | module cerrno { | |
| 125 | header "cerrno" | |
| 126 | export * | |
| 127 | } | |
| 128 | module cfenv { | |
| 129 | header "cfenv" | |
| 130 | export * | |
| 131 | } | |
| 132 | module cfloat { | |
| 133 | header "cfloat" | |
| 134 | export * | |
| 135 | } | |
| 136 | module cinttypes { | |
| 137 | header "cinttypes" | |
| 138 | export cstdint | |
| 139 | export * | |
| 140 | } | |
| 141 | module ciso646 { | |
| 142 | header "ciso646" | |
| 143 | export * | |
| 144 | } | |
| 145 | module climits { | |
| 146 | header "climits" | |
| 147 | export * | |
| 148 | } | |
| 149 | module clocale { | |
| 150 | header "clocale" | |
| 151 | export * | |
| 152 | } | |
| 153 | module cmath { | |
| 154 | header "cmath" | |
| 155 | export * | |
| 156 | } | |
| 157 | module csetjmp { | |
| 158 | header "csetjmp" | |
| 159 | export * | |
| 160 | } | |
| 161 | module csignal { | |
| 162 | header "csignal" | |
| 163 | export * | |
| 164 | } | |
| 165 | // FIXME: <cstdalign> is missing. | |
| 166 | module cstdarg { | |
| 167 | header "cstdarg" | |
| 168 | export * | |
| 169 | } | |
| 170 | module cstdbool { | |
| 171 | header "cstdbool" | |
| 172 | export * | |
| 173 | } | |
| 174 | module cstddef { | |
| 175 | header "cstddef" | |
| 176 | export * | |
| 177 | } | |
| 178 | module cstdint { | |
| 179 | header "cstdint" | |
| 180 | export depr.stdint_h | |
| 181 | export * | |
| 182 | } | |
| 183 | module cstdio { | |
| 184 | header "cstdio" | |
| 185 | export * | |
| 186 | } | |
| 187 | module cstdlib { | |
| 188 | header "cstdlib" | |
| 189 | export * | |
| 190 | } | |
| 191 | module cstring { | |
| 192 | header "cstring" | |
| 193 | export * | |
| 194 | } | |
| 195 | module ctgmath { | |
| 196 | header "ctgmath" | |
| 197 | export ccomplex | |
| 198 | export cmath | |
| 199 | export * | |
| 200 | } | |
| 201 | module ctime { | |
| 202 | header "ctime" | |
| 203 | export * | |
| 204 | } | |
| 205 | // FIXME: <cuchar> is missing. | |
| 206 | module cwchar { | |
| 207 | header "cwchar" | |
| 208 | export depr.stdio_h | |
| 209 | export * | |
| 210 | } | |
| 211 | module cwctype { | |
| 212 | header "cwctype" | |
| 213 | export * | |
| 214 | } | |
| 215 | } | |
| 216 | ||
| 217 | module algorithm { | |
| 218 | header "algorithm" | |
| 219 | export initializer_list | |
| 220 | export * | |
| 221 | ||
| 222 | module __algorithm { | |
| 223 | module adjacent_find { private header "__algorithm/adjacent_find.h" } | |
| 224 | module all_of { private header "__algorithm/all_of.h" } | |
| 225 | module any_of { private header "__algorithm/any_of.h" } | |
| 226 | module binary_search { private header "__algorithm/binary_search.h" } | |
| 227 | module clamp { private header "__algorithm/clamp.h" } | |
| 228 | module comp { private header "__algorithm/comp.h" } | |
| 229 | module comp_ref_type { private header "__algorithm/comp_ref_type.h" } | |
| 230 | module copy { private header "__algorithm/copy.h" } | |
| 231 | module copy_backward { private header "__algorithm/copy_backward.h" } | |
| 232 | module copy_if { private header "__algorithm/copy_if.h" } | |
| 233 | module copy_n { private header "__algorithm/copy_n.h" } | |
| 234 | module count { private header "__algorithm/count.h" } | |
| 235 | module count_if { private header "__algorithm/count_if.h" } | |
| 236 | module equal { private header "__algorithm/equal.h" } | |
| 237 | module equal_range { private header "__algorithm/equal_range.h" } | |
| 238 | module fill { private header "__algorithm/fill.h" } | |
| 239 | module fill_n { private header "__algorithm/fill_n.h" } | |
| 240 | module find { private header "__algorithm/find.h" } | |
| 241 | module find_end { private header "__algorithm/find_end.h" } | |
| 242 | module find_first_of { private header "__algorithm/find_first_of.h" } | |
| 243 | module find_if { private header "__algorithm/find_if.h" } | |
| 244 | module find_if_not { private header "__algorithm/find_if_not.h" } | |
| 245 | module for_each { private header "__algorithm/for_each.h" } | |
| 246 | module for_each_n { private header "__algorithm/for_each_n.h" } | |
| 247 | module generate { private header "__algorithm/generate.h" } | |
| 248 | module generate_n { private header "__algorithm/generate_n.h" } | |
| 249 | module half_positive { private header "__algorithm/half_positive.h" } | |
| 250 | module in_in_out_result { private header "__algorithm/in_in_out_result.h" } | |
| 251 | module in_in_result { private header "__algorithm/in_in_result.h" } | |
| 252 | module in_out_result { private header "__algorithm/in_out_result.h" } | |
| 253 | module includes { private header "__algorithm/includes.h" } | |
| 254 | module inplace_merge { private header "__algorithm/inplace_merge.h" } | |
| 255 | module is_heap { private header "__algorithm/is_heap.h" } | |
| 256 | module is_heap_until { private header "__algorithm/is_heap_until.h" } | |
| 257 | module is_partitioned { private header "__algorithm/is_partitioned.h" } | |
| 258 | module is_permutation { private header "__algorithm/is_permutation.h" } | |
| 259 | module is_sorted { private header "__algorithm/is_sorted.h" } | |
| 260 | module is_sorted_until { private header "__algorithm/is_sorted_until.h" } | |
| 261 | module iter_swap { private header "__algorithm/iter_swap.h" } | |
| 262 | module lexicographical_compare { private header "__algorithm/lexicographical_compare.h" } | |
| 263 | module lower_bound { private header "__algorithm/lower_bound.h" } | |
| 264 | module make_heap { private header "__algorithm/make_heap.h" } | |
| 265 | module max { private header "__algorithm/max.h" } | |
| 266 | module max_element { private header "__algorithm/max_element.h" } | |
| 267 | module merge { private header "__algorithm/merge.h" } | |
| 268 | module min { private header "__algorithm/min.h" } | |
| 269 | module min_element { private header "__algorithm/min_element.h" } | |
| 270 | module minmax { private header "__algorithm/minmax.h" } | |
| 271 | module minmax_element { private header "__algorithm/minmax_element.h" } | |
| 272 | module mismatch { private header "__algorithm/mismatch.h" } | |
| 273 | module move { private header "__algorithm/move.h" } | |
| 274 | module move_backward { private header "__algorithm/move_backward.h" } | |
| 275 | module next_permutation { private header "__algorithm/next_permutation.h" } | |
| 276 | module none_of { private header "__algorithm/none_of.h" } | |
| 277 | module nth_element { private header "__algorithm/nth_element.h" } | |
| 278 | module partial_sort { private header "__algorithm/partial_sort.h" } | |
| 279 | module partial_sort_copy { private header "__algorithm/partial_sort_copy.h" } | |
| 280 | module partition { private header "__algorithm/partition.h" } | |
| 281 | module partition_copy { private header "__algorithm/partition_copy.h" } | |
| 282 | module partition_point { private header "__algorithm/partition_point.h" } | |
| 283 | module pop_heap { private header "__algorithm/pop_heap.h" } | |
| 284 | module prev_permutation { private header "__algorithm/prev_permutation.h" } | |
| 285 | module push_heap { private header "__algorithm/push_heap.h" } | |
| 286 | module remove { private header "__algorithm/remove.h" } | |
| 287 | module remove_copy { private header "__algorithm/remove_copy.h" } | |
| 288 | module remove_copy_if { private header "__algorithm/remove_copy_if.h" } | |
| 289 | module remove_if { private header "__algorithm/remove_if.h" } | |
| 290 | module replace { private header "__algorithm/replace.h" } | |
| 291 | module replace_copy { private header "__algorithm/replace_copy.h" } | |
| 292 | module replace_copy_if { private header "__algorithm/replace_copy_if.h" } | |
| 293 | module replace_if { private header "__algorithm/replace_if.h" } | |
| 294 | module reverse { private header "__algorithm/reverse.h" } | |
| 295 | module reverse_copy { private header "__algorithm/reverse_copy.h" } | |
| 296 | module rotate { private header "__algorithm/rotate.h" } | |
| 297 | module rotate_copy { private header "__algorithm/rotate_copy.h" } | |
| 298 | module sample { private header "__algorithm/sample.h" } | |
| 299 | module search { private header "__algorithm/search.h" } | |
| 300 | module search_n { private header "__algorithm/search_n.h" } | |
| 301 | module set_difference { private header "__algorithm/set_difference.h" } | |
| 302 | module set_intersection { private header "__algorithm/set_intersection.h" } | |
| 303 | module set_symmetric_difference { private header "__algorithm/set_symmetric_difference.h" } | |
| 304 | module set_union { private header "__algorithm/set_union.h" } | |
| 305 | module shift_left { private header "__algorithm/shift_left.h" } | |
| 306 | module shift_right { private header "__algorithm/shift_right.h" } | |
| 307 | module shuffle { private header "__algorithm/shuffle.h" } | |
| 308 | module sift_down { private header "__algorithm/sift_down.h" } | |
| 309 | module sort { private header "__algorithm/sort.h" } | |
| 310 | module sort_heap { private header "__algorithm/sort_heap.h" } | |
| 311 | module stable_partition { private header "__algorithm/stable_partition.h" } | |
| 312 | module stable_sort { private header "__algorithm/stable_sort.h" } | |
| 313 | module swap_ranges { private header "__algorithm/swap_ranges.h" } | |
| 314 | module transform { private header "__algorithm/transform.h" } | |
| 315 | module unique { private header "__algorithm/unique.h" } | |
| 316 | module unique_copy { private header "__algorithm/unique_copy.h" } | |
| 317 | module unwrap_iter { private header "__algorithm/unwrap_iter.h" } | |
| 318 | module upper_bound { private header "__algorithm/upper_bound.h" } | |
| 319 | } | |
| 320 | } | |
| 321 | module any { | |
| 322 | header "any" | |
| 323 | export * | |
| 324 | } | |
| 325 | module array { | |
| 326 | header "array" | |
| 327 | export initializer_list | |
| 328 | export * | |
| 329 | } | |
| 330 | module atomic { | |
| 331 | header "atomic" | |
| 332 | export * | |
| 333 | } | |
| 334 | module barrier { | |
| 335 | requires cplusplus14 | |
| 336 | header "barrier" | |
| 337 | export * | |
| 338 | } | |
| 339 | module bit { | |
| 340 | header "bit" | |
| 341 | export * | |
| 342 | ||
| 343 | module __bit { | |
| 344 | module bit_cast { private header "__bit/bit_cast.h" } | |
| 345 | module byteswap { private header "__bit/byteswap.h" } | |
| 346 | } | |
| 347 | } | |
| 348 | module bitset { | |
| 349 | header "bitset" | |
| 350 | export string | |
| 351 | export iosfwd | |
| 352 | export * | |
| 353 | } | |
| 354 | // No submodule for cassert. It fundamentally needs repeated, textual inclusion. | |
| 355 | module charconv { | |
| 356 | header "charconv" | |
| 357 | export * | |
| 358 | ||
| 359 | module __charconv { | |
| 360 | module chars_format { private header "__charconv/chars_format.h" } | |
| 361 | module from_chars_result { private header "__charconv/from_chars_result.h" } | |
| 362 | module to_chars_result { private header "__charconv/to_chars_result.h" } | |
| 363 | } | |
| 364 | ||
| 365 | } | |
| 366 | module chrono { | |
| 367 | header "chrono" | |
| 368 | export * | |
| 369 | ||
| 370 | module __chrono { | |
| 371 | module calendar { private header "__chrono/calendar.h" } | |
| 372 | module convert_to_timespec { private header "__chrono/convert_to_timespec.h" } | |
| 373 | module duration { private header "__chrono/duration.h" } | |
| 374 | module file_clock { private header "__chrono/file_clock.h" } | |
| 375 | module high_resolution_clock { private header "__chrono/high_resolution_clock.h" } | |
| 376 | module steady_clock { private header "__chrono/steady_clock.h" } | |
| 377 | module system_clock { private header "__chrono/system_clock.h" } | |
| 378 | module time_point { private header "__chrono/time_point.h" } | |
| 379 | } | |
| 380 | } | |
| 381 | module codecvt { | |
| 382 | header "codecvt" | |
| 383 | export * | |
| 384 | } | |
| 385 | module compare { | |
| 386 | header "compare" | |
| 387 | export * | |
| 388 | ||
| 389 | module __compare { | |
| 390 | module common_comparison_category { private header "__compare/common_comparison_category.h" } | |
| 391 | module compare_partial_order_fallback { private header "__compare/compare_partial_order_fallback.h" } | |
| 392 | module compare_strong_order_fallback { private header "__compare/compare_strong_order_fallback.h" } | |
| 393 | module compare_three_way { private header "__compare/compare_three_way.h" } | |
| 394 | module compare_three_way_result { private header "__compare/compare_three_way_result.h" } | |
| 395 | module compare_weak_order_fallback { private header "__compare/compare_weak_order_fallback.h" } | |
| 396 | module is_eq { private header "__compare/is_eq.h" } | |
| 397 | module ordering { private header "__compare/ordering.h" } | |
| 398 | module partial_order { private header "__compare/partial_order.h" } | |
| 399 | module strong_order { private header "__compare/strong_order.h" } | |
| 400 | module synth_three_way { private header "__compare/synth_three_way.h" } | |
| 401 | module three_way_comparable { private header "__compare/three_way_comparable.h" } | |
| 402 | module weak_order { private header "__compare/weak_order.h" } | |
| 403 | } | |
| 404 | } | |
| 405 | module complex { | |
| 406 | header "complex" | |
| 407 | export * | |
| 408 | } | |
| 409 | module concepts { | |
| 410 | header "concepts" | |
| 411 | export * | |
| 412 | ||
| 413 | module __concepts { | |
| 414 | module arithmetic { private header "__concepts/arithmetic.h" } | |
| 415 | module assignable { private header "__concepts/assignable.h" } | |
| 416 | module boolean_testable { private header "__concepts/boolean_testable.h" } | |
| 417 | module class_or_enum { private header "__concepts/class_or_enum.h" } | |
| 418 | module common_reference_with { private header "__concepts/common_reference_with.h" } | |
| 419 | module common_with { private header "__concepts/common_with.h" } | |
| 420 | module constructible { private header "__concepts/constructible.h" } | |
| 421 | module convertible_to { private header "__concepts/convertible_to.h" } | |
| 422 | module copyable { private header "__concepts/copyable.h" } | |
| 423 | module derived_from { private header "__concepts/derived_from.h" } | |
| 424 | module destructible { private header "__concepts/destructible.h" } | |
| 425 | module different_from { private header "__concepts/different_from.h" } | |
| 426 | module equality_comparable { private header "__concepts/equality_comparable.h" } | |
| 427 | module invocable { private header "__concepts/invocable.h" } | |
| 428 | module movable { private header "__concepts/movable.h" } | |
| 429 | module predicate { private header "__concepts/predicate.h" } | |
| 430 | module regular { private header "__concepts/regular.h" } | |
| 431 | module relation { private header "__concepts/relation.h" } | |
| 432 | module same_as { private header "__concepts/same_as.h" } | |
| 433 | module semiregular { private header "__concepts/semiregular.h" } | |
| 434 | module swappable { private header "__concepts/swappable.h" } | |
| 435 | module totally_ordered { private header "__concepts/totally_ordered.h" } | |
| 436 | } | |
| 437 | } | |
| 438 | module condition_variable { | |
| 439 | header "condition_variable" | |
| 440 | export * | |
| 441 | } | |
| 442 | module coroutine { | |
| 443 | requires coroutines | |
| 444 | header "coroutine" | |
| 445 | export compare | |
| 446 | export * | |
| 447 | ||
| 448 | module __coroutine { | |
| 449 | module coroutine_handle { private header "__coroutine/coroutine_handle.h" } | |
| 450 | module coroutine_traits { private header "__coroutine/coroutine_traits.h" } | |
| 451 | module noop_coroutine_handle { private header "__coroutine/noop_coroutine_handle.h" } | |
| 452 | module trivial_awaitables { private header "__coroutine/trivial_awaitables.h" } | |
| 453 | } | |
| 454 | } | |
| 455 | module deque { | |
| 456 | header "deque" | |
| 457 | export initializer_list | |
| 458 | export * | |
| 459 | } | |
| 460 | module exception { | |
| 461 | header "exception" | |
| 462 | export * | |
| 463 | } | |
| 464 | module execution { | |
| 465 | header "execution" | |
| 466 | export * | |
| 467 | } | |
| 468 | module filesystem { | |
| 469 | header "filesystem" | |
| 470 | export * | |
| 471 | ||
| 472 | module __filesystem { | |
| 473 | module copy_options { private header "__filesystem/copy_options.h" } | |
| 474 | module directory_entry { private header "__filesystem/directory_entry.h" } | |
| 475 | module directory_iterator { private header "__filesystem/directory_iterator.h" } | |
| 476 | module directory_options { private header "__filesystem/directory_options.h" } | |
| 477 | module file_status { private header "__filesystem/file_status.h" } | |
| 478 | module file_time_type { private header "__filesystem/file_time_type.h" } | |
| 479 | module file_type { private header "__filesystem/file_type.h" } | |
| 480 | module filesystem_error { private header "__filesystem/filesystem_error.h" } | |
| 481 | module operations { private header "__filesystem/operations.h" } | |
| 482 | module path { private header "__filesystem/path.h" } | |
| 483 | module path_iterator { private header "__filesystem/path_iterator.h" } | |
| 484 | module perm_options { private header "__filesystem/perm_options.h" } | |
| 485 | module perms { private header "__filesystem/perms.h" } | |
| 486 | module recursive_directory_iterator { private header "__filesystem/recursive_directory_iterator.h" } | |
| 487 | module space_info { private header "__filesystem/space_info.h" } | |
| 488 | module u8path { private header "__filesystem/u8path.h" } | |
| 489 | } | |
| 490 | } | |
| 491 | module format { | |
| 492 | header "format" | |
| 493 | export * | |
| 494 | ||
| 495 | module __format { | |
| 496 | module format_arg { private header "__format/format_arg.h" } | |
| 497 | module format_args { private header "__format/format_args.h" } | |
| 498 | module format_context { | |
| 499 | private header "__format/format_context.h" | |
| 500 | export optional | |
| 501 | export locale | |
| 502 | } | |
| 503 | module format_error { private header "__format/format_error.h" } | |
| 504 | module format_fwd { private header "__format/format_fwd.h" } | |
| 505 | module format_parse_context { private header "__format/format_parse_context.h" } | |
| 506 | module format_string { private header "__format/format_string.h" } | |
| 507 | module format_to_n_result { private header "__format/format_to_n_result.h" } | |
| 508 | module formatter { private header "__format/formatter.h" } | |
| 509 | module formatter_bool { private header "__format/formatter_bool.h" } | |
| 510 | module formatter_char { private header "__format/formatter_char.h" } | |
| 511 | module formatter_floating_point { private header "__format/formatter_floating_point.h" } | |
| 512 | module formatter_integer { private header "__format/formatter_integer.h" } | |
| 513 | module formatter_integral { private header "__format/formatter_integral.h" } | |
| 514 | module formatter_pointer { private header "__format/formatter_pointer.h" } | |
| 515 | module formatter_string { private header "__format/formatter_string.h" } | |
| 516 | module parser_std_format_spec { private header "__format/parser_std_format_spec.h" } | |
| 517 | } | |
| 518 | } | |
| 519 | module forward_list { | |
| 520 | header "forward_list" | |
| 521 | export initializer_list | |
| 522 | export * | |
| 523 | } | |
| 524 | module fstream { | |
| 525 | header "fstream" | |
| 526 | export * | |
| 527 | } | |
| 528 | module functional { | |
| 529 | header "functional" | |
| 530 | export * | |
| 531 | ||
| 532 | module __functional { | |
| 533 | module binary_function { private header "__functional/binary_function.h" } | |
| 534 | module binary_negate { private header "__functional/binary_negate.h" } | |
| 535 | module bind { private header "__functional/bind.h" } | |
| 536 | module bind_back { private header "__functional/bind_back.h" } | |
| 537 | module bind_front { private header "__functional/bind_front.h" } | |
| 538 | module binder1st { private header "__functional/binder1st.h" } | |
| 539 | module binder2nd { private header "__functional/binder2nd.h" } | |
| 540 | module compose { private header "__functional/compose.h" } | |
| 541 | module default_searcher { private header "__functional/default_searcher.h" } | |
| 542 | module function { private header "__functional/function.h" } | |
| 543 | module hash { private header "__functional/hash.h" } | |
| 544 | module identity { private header "__functional/identity.h" } | |
| 545 | module invoke { private header "__functional/invoke.h" } | |
| 546 | module is_transparent { private header "__functional/is_transparent.h" } | |
| 547 | module mem_fn { private header "__functional/mem_fn.h" } | |
| 548 | module mem_fun_ref { private header "__functional/mem_fun_ref.h" } | |
| 549 | module not_fn { private header "__functional/not_fn.h" } | |
| 550 | module operations { private header "__functional/operations.h" } | |
| 551 | module perfect_forward { private header "__functional/perfect_forward.h" } | |
| 552 | module pointer_to_binary_function { private header "__functional/pointer_to_binary_function.h" } | |
| 553 | module pointer_to_unary_function { private header "__functional/pointer_to_unary_function.h" } | |
| 554 | module ranges_operations { private header "__functional/ranges_operations.h" } | |
| 555 | module reference_wrapper { private header "__functional/reference_wrapper.h" } | |
| 556 | module unary_function { private header "__functional/unary_function.h" } | |
| 557 | module unary_negate { private header "__functional/unary_negate.h" } | |
| 558 | module unwrap_ref { private header "__functional/unwrap_ref.h" } | |
| 559 | module weak_result_type { private header "__functional/weak_result_type.h" } | |
| 560 | } | |
| 561 | } | |
| 562 | module future { | |
| 563 | header "future" | |
| 564 | export * | |
| 565 | } | |
| 566 | module initializer_list { | |
| 567 | header "initializer_list" | |
| 568 | export * | |
| 569 | } | |
| 570 | module iomanip { | |
| 571 | header "iomanip" | |
| 572 | export * | |
| 573 | } | |
| 574 | module ios { | |
| 575 | header "ios" | |
| 576 | export iosfwd | |
| 577 | export * | |
| 578 | } | |
| 579 | module iosfwd { | |
| 580 | header "iosfwd" | |
| 581 | export * | |
| 582 | } | |
| 583 | module iostream { | |
| 584 | header "iostream" | |
| 585 | export ios | |
| 586 | export streambuf | |
| 587 | export istream | |
| 588 | export ostream | |
| 589 | export * | |
| 590 | } | |
| 591 | module istream { | |
| 592 | header "istream" | |
| 593 | // FIXME: should re-export ios, streambuf? | |
| 594 | export * | |
| 595 | } | |
| 596 | module iterator { | |
| 597 | header "iterator" | |
| 598 | export * | |
| 599 | ||
| 600 | module __iterator { | |
| 601 | module access { private header "__iterator/access.h" } | |
| 602 | module advance { private header "__iterator/advance.h" } | |
| 603 | module back_insert_iterator { private header "__iterator/back_insert_iterator.h" } | |
| 604 | module common_iterator { private header "__iterator/common_iterator.h" } | |
| 605 | module concepts { private header "__iterator/concepts.h" } | |
| 606 | module counted_iterator { private header "__iterator/counted_iterator.h" } | |
| 607 | module data { private header "__iterator/data.h" } | |
| 608 | module default_sentinel { private header "__iterator/default_sentinel.h" } | |
| 609 | module distance { private header "__iterator/distance.h" } | |
| 610 | module empty { private header "__iterator/empty.h" } | |
| 611 | module erase_if_container { private header "__iterator/erase_if_container.h" } | |
| 612 | module front_insert_iterator { private header "__iterator/front_insert_iterator.h" } | |
| 613 | module incrementable_traits { private header "__iterator/incrementable_traits.h" } | |
| 614 | module indirectly_comparable { private header "__iterator/indirectly_comparable.h" } | |
| 615 | module insert_iterator { private header "__iterator/insert_iterator.h" } | |
| 616 | module istream_iterator { private header "__iterator/istream_iterator.h" } | |
| 617 | module istreambuf_iterator { private header "__iterator/istreambuf_iterator.h" } | |
| 618 | module iter_move { private header "__iterator/iter_move.h" } | |
| 619 | module iter_swap { private header "__iterator/iter_swap.h" } | |
| 620 | module iterator { private header "__iterator/iterator.h" } | |
| 621 | module iterator_traits { private header "__iterator/iterator_traits.h" } | |
| 622 | module move_iterator { private header "__iterator/move_iterator.h" } | |
| 623 | module next { private header "__iterator/next.h" } | |
| 624 | module ostream_iterator { private header "__iterator/ostream_iterator.h" } | |
| 625 | module ostreambuf_iterator { private header "__iterator/ostreambuf_iterator.h" } | |
| 626 | module prev { private header "__iterator/prev.h" } | |
| 627 | module projected { private header "__iterator/projected.h" } | |
| 628 | module readable_traits { private header "__iterator/readable_traits.h" } | |
| 629 | module reverse_access { private header "__iterator/reverse_access.h" } | |
| 630 | module reverse_iterator { private header "__iterator/reverse_iterator.h" } | |
| 631 | module size { private header "__iterator/size.h" } | |
| 632 | module unreachable_sentinel { private header "__iterator/unreachable_sentinel.h" } | |
| 633 | module wrap_iter { private header "__iterator/wrap_iter.h" } | |
| 634 | } | |
| 635 | } | |
| 636 | module latch { | |
| 637 | requires cplusplus14 | |
| 638 | header "latch" | |
| 639 | export * | |
| 640 | } | |
| 641 | module limits { | |
| 642 | header "limits" | |
| 643 | export * | |
| 644 | } | |
| 645 | module list { | |
| 646 | header "list" | |
| 647 | export initializer_list | |
| 648 | export * | |
| 649 | } | |
| 650 | module locale { | |
| 651 | header "locale" | |
| 652 | export * | |
| 653 | } | |
| 654 | module map { | |
| 655 | header "map" | |
| 656 | export initializer_list | |
| 657 | export * | |
| 658 | } | |
| 659 | module memory { | |
| 660 | header "memory" | |
| 661 | export * | |
| 662 | ||
| 663 | module __memory { | |
| 664 | module addressof { private header "__memory/addressof.h" } | |
| 665 | module allocation_guard { private header "__memory/allocation_guard.h" } | |
| 666 | module allocator { private header "__memory/allocator.h" } | |
| 667 | module allocator_arg_t { private header "__memory/allocator_arg_t.h" } | |
| 668 | module allocator_traits { private header "__memory/allocator_traits.h" } | |
| 669 | module auto_ptr { private header "__memory/auto_ptr.h" } | |
| 670 | module compressed_pair { private header "__memory/compressed_pair.h" } | |
| 671 | module concepts { private header "__memory/concepts.h" } | |
| 672 | module construct_at { private header "__memory/construct_at.h" } | |
| 673 | module pointer_traits { private header "__memory/pointer_traits.h" } | |
| 674 | module ranges_construct_at { private header "__memory/ranges_construct_at.h" } | |
| 675 | module ranges_uninitialized_algorithms { private header "__memory/ranges_uninitialized_algorithms.h" } | |
| 676 | module raw_storage_iterator { private header "__memory/raw_storage_iterator.h" } | |
| 677 | module shared_ptr { private header "__memory/shared_ptr.h" } | |
| 678 | module temporary_buffer { private header "__memory/temporary_buffer.h" } | |
| 679 | module uninitialized_algorithms { private header "__memory/uninitialized_algorithms.h" } | |
| 680 | module unique_ptr { private header "__memory/unique_ptr.h" } | |
| 681 | module uses_allocator { private header "__memory/uses_allocator.h" } | |
| 682 | module voidify { private header "__memory/voidify.h" } | |
| 683 | } | |
| 684 | } | |
| 685 | module mutex { | |
| 686 | header "mutex" | |
| 687 | export * | |
| 688 | } | |
| 689 | module new { | |
| 690 | header "new" | |
| 691 | export * | |
| 692 | } | |
| 693 | module numbers { | |
| 694 | header "numbers" | |
| 695 | export * | |
| 696 | } | |
| 697 | module numeric { | |
| 698 | header "numeric" | |
| 699 | export * | |
| 700 | ||
| 701 | module __numeric { | |
| 702 | module accumulate { private header "__numeric/accumulate.h" } | |
| 703 | module adjacent_difference { private header "__numeric/adjacent_difference.h" } | |
| 704 | module exclusive_scan { private header "__numeric/exclusive_scan.h" } | |
| 705 | module gcd_lcm { private header "__numeric/gcd_lcm.h" } | |
| 706 | module inclusive_scan { private header "__numeric/inclusive_scan.h" } | |
| 707 | module inner_product { private header "__numeric/inner_product.h" } | |
| 708 | module iota { private header "__numeric/iota.h" } | |
| 709 | module midpoint { private header "__numeric/midpoint.h" } | |
| 710 | module partial_sum { private header "__numeric/partial_sum.h" } | |
| 711 | module reduce { private header "__numeric/reduce.h" } | |
| 712 | module transform_exclusive_scan { private header "__numeric/transform_exclusive_scan.h" } | |
| 713 | module transform_inclusive_scan { private header "__numeric/transform_inclusive_scan.h" } | |
| 714 | module transform_reduce { private header "__numeric/transform_reduce.h" } | |
| 715 | } | |
| 716 | } | |
| 717 | module optional { | |
| 718 | header "optional" | |
| 719 | export * | |
| 720 | } | |
| 721 | module ostream { | |
| 722 | header "ostream" | |
| 723 | // FIXME: should re-export ios, streambuf? | |
| 724 | export * | |
| 725 | } | |
| 726 | module queue { | |
| 727 | header "queue" | |
| 728 | export initializer_list | |
| 729 | export * | |
| 730 | } | |
| 731 | module random { | |
| 732 | header "random" | |
| 733 | export initializer_list | |
| 734 | export * | |
| 735 | ||
| 736 | module __random { | |
| 737 | module bernoulli_distribution { private header "__random/bernoulli_distribution.h" } | |
| 738 | module binomial_distribution { private header "__random/binomial_distribution.h" } | |
| 739 | module cauchy_distribution { private header "__random/cauchy_distribution.h" } | |
| 740 | module chi_squared_distribution { private header "__random/chi_squared_distribution.h" } | |
| 741 | module clamp_to_integral { private header "__random/clamp_to_integral.h" } | |
| 742 | module default_random_engine { private header "__random/default_random_engine.h" } | |
| 743 | module discard_block_engine { private header "__random/discard_block_engine.h" } | |
| 744 | module discrete_distribution { private header "__random/discrete_distribution.h" } | |
| 745 | module exponential_distribution { private header "__random/exponential_distribution.h" } | |
| 746 | module extreme_value_distribution { private header "__random/extreme_value_distribution.h" } | |
| 747 | module fisher_f_distribution { private header "__random/fisher_f_distribution.h" } | |
| 748 | module gamma_distribution { private header "__random/gamma_distribution.h" } | |
| 749 | module generate_canonical { private header "__random/generate_canonical.h" } | |
| 750 | module geometric_distribution { private header "__random/geometric_distribution.h" } | |
| 751 | module independent_bits_engine { private header "__random/independent_bits_engine.h" } | |
| 752 | module is_seed_sequence { private header "__random/is_seed_sequence.h" } | |
| 753 | module knuth_b { private header "__random/knuth_b.h" } | |
| 754 | module linear_congruential_engine { private header "__random/linear_congruential_engine.h" } | |
| 755 | module log2 { private header "__random/log2.h" } | |
| 756 | module lognormal_distribution { private header "__random/lognormal_distribution.h" } | |
| 757 | module mersenne_twister_engine { private header "__random/mersenne_twister_engine.h" } | |
| 758 | module negative_binomial_distribution { private header "__random/negative_binomial_distribution.h" } | |
| 759 | module normal_distribution { private header "__random/normal_distribution.h" } | |
| 760 | module piecewise_constant_distribution { private header "__random/piecewise_constant_distribution.h" } | |
| 761 | module piecewise_linear_distribution { private header "__random/piecewise_linear_distribution.h" } | |
| 762 | module poisson_distribution { private header "__random/poisson_distribution.h" } | |
| 763 | module random_device { private header "__random/random_device.h" } | |
| 764 | module ranlux { private header "__random/ranlux.h" } | |
| 765 | module seed_seq { private header "__random/seed_seq.h" } | |
| 766 | module shuffle_order_engine { private header "__random/shuffle_order_engine.h" } | |
| 767 | module student_t_distribution { private header "__random/student_t_distribution.h" } | |
| 768 | module subtract_with_carry_engine { private header "__random/subtract_with_carry_engine.h" } | |
| 769 | module uniform_int_distribution { private header "__random/uniform_int_distribution.h" } | |
| 770 | module uniform_random_bit_generator { private header "__random/uniform_random_bit_generator.h" } | |
| 771 | module uniform_real_distribution { private header "__random/uniform_real_distribution.h" } | |
| 772 | module weibull_distribution { private header "__random/weibull_distribution.h" } | |
| 773 | } | |
| 774 | } | |
| 775 | module ranges { | |
| 776 | header "ranges" | |
| 777 | export compare | |
| 778 | export initializer_list | |
| 779 | export iterator | |
| 780 | export * | |
| 781 | ||
| 782 | module __ranges { | |
| 783 | module access { private header "__ranges/access.h" } | |
| 784 | module all { | |
| 785 | private header "__ranges/all.h" | |
| 786 | export functional.__functional.compose | |
| 787 | export functional.__functional.perfect_forward | |
| 788 | } | |
| 789 | module common_view { private header "__ranges/common_view.h" } | |
| 790 | module concepts { private header "__ranges/concepts.h" } | |
| 791 | module copyable_box { private header "__ranges/copyable_box.h" } | |
| 792 | module counted { | |
| 793 | private header "__ranges/counted.h" | |
| 794 | export span | |
| 795 | } | |
| 796 | module dangling { private header "__ranges/dangling.h" } | |
| 797 | module data { private header "__ranges/data.h" } | |
| 798 | module drop_view { private header "__ranges/drop_view.h" } | |
| 799 | module empty { private header "__ranges/empty.h" } | |
| 800 | module empty_view { private header "__ranges/empty_view.h" } | |
| 801 | module enable_borrowed_range { private header "__ranges/enable_borrowed_range.h" } | |
| 802 | module enable_view { private header "__ranges/enable_view.h" } | |
| 803 | module iota_view { private header "__ranges/iota_view.h" } | |
| 804 | module join_view { private header "__ranges/join_view.h" } | |
| 805 | module non_propagating_cache { private header "__ranges/non_propagating_cache.h" } | |
| 806 | module owning_view { private header "__ranges/owning_view.h" } | |
| 807 | module range_adaptor { private header "__ranges/range_adaptor.h" } | |
| 808 | module ref_view { private header "__ranges/ref_view.h" } | |
| 809 | module reverse_view { private header "__ranges/reverse_view.h" } | |
| 810 | module single_view { private header "__ranges/single_view.h" } | |
| 811 | module size { private header "__ranges/size.h" } | |
| 812 | module subrange { private header "__ranges/subrange.h" } | |
| 813 | module take_view { private header "__ranges/take_view.h" } | |
| 814 | module transform_view { | |
| 815 | private header "__ranges/transform_view.h" | |
| 816 | export functional.__functional.bind_back | |
| 817 | export functional.__functional.perfect_forward | |
| 818 | } | |
| 819 | module view_interface { private header "__ranges/view_interface.h" } | |
| 820 | module views { private header "__ranges/views.h" } | |
| 821 | } | |
| 822 | } | |
| 823 | module ratio { | |
| 824 | header "ratio" | |
| 825 | export * | |
| 826 | } | |
| 827 | module regex { | |
| 828 | header "regex" | |
| 829 | export initializer_list | |
| 830 | export * | |
| 831 | } | |
| 832 | module scoped_allocator { | |
| 833 | header "scoped_allocator" | |
| 834 | export * | |
| 835 | } | |
| 836 | module semaphore { | |
| 837 | requires cplusplus14 | |
| 838 | header "semaphore" | |
| 839 | export * | |
| 840 | } | |
| 841 | module set { | |
| 842 | header "set" | |
| 843 | export initializer_list | |
| 844 | export * | |
| 845 | } | |
| 846 | module shared_mutex { | |
| 847 | header "shared_mutex" | |
| 848 | export version | |
| 849 | } | |
| 850 | module span { | |
| 851 | header "span" | |
| 852 | export ranges.__ranges.enable_borrowed_range | |
| 853 | export version | |
| 854 | } | |
| 855 | module sstream { | |
| 856 | header "sstream" | |
| 857 | // FIXME: should re-export istream, ostream, ios, streambuf, string? | |
| 858 | export * | |
| 859 | } | |
| 860 | module stack { | |
| 861 | header "stack" | |
| 862 | export initializer_list | |
| 863 | export * | |
| 864 | } | |
| 865 | module stdexcept { | |
| 866 | header "stdexcept" | |
| 867 | export * | |
| 868 | } | |
| 869 | module streambuf { | |
| 870 | header "streambuf" | |
| 871 | export * | |
| 872 | } | |
| 873 | module string { | |
| 874 | header "string" | |
| 875 | export initializer_list | |
| 876 | export string_view | |
| 877 | export __string | |
| 878 | export * | |
| 879 | } | |
| 880 | module string_view { | |
| 881 | header "string_view" | |
| 882 | export initializer_list | |
| 883 | export __string | |
| 884 | export * | |
| 885 | } | |
| 886 | module strstream { | |
| 887 | header "strstream" | |
| 888 | export * | |
| 889 | } | |
| 890 | module system_error { | |
| 891 | header "system_error" | |
| 892 | export * | |
| 893 | } | |
| 894 | module thread { | |
| 895 | header "thread" | |
| 896 | export * | |
| 897 | ||
| 898 | module __thread { | |
| 899 | module poll_with_backoff { private header "__thread/poll_with_backoff.h" } | |
| 900 | module timed_backoff_policy { private header "__thread/timed_backoff_policy.h" } | |
| 901 | } | |
| 902 | } | |
| 903 | module tuple { | |
| 904 | header "tuple" | |
| 905 | export * | |
| 906 | } | |
| 907 | module type_traits { | |
| 908 | header "type_traits" | |
| 909 | export functional.__functional.unwrap_ref | |
| 910 | export * | |
| 911 | } | |
| 912 | module typeindex { | |
| 913 | header "typeindex" | |
| 914 | export * | |
| 915 | } | |
| 916 | module typeinfo { | |
| 917 | header "typeinfo" | |
| 918 | export * | |
| 919 | } | |
| 920 | module unordered_map { | |
| 921 | header "unordered_map" | |
| 922 | export initializer_list | |
| 923 | export * | |
| 924 | } | |
| 925 | module unordered_set { | |
| 926 | header "unordered_set" | |
| 927 | export initializer_list | |
| 928 | export * | |
| 929 | } | |
| 930 | module utility { | |
| 931 | header "utility" | |
| 932 | export initializer_list | |
| 933 | export * | |
| 934 | ||
| 935 | module __utility { | |
| 936 | module as_const { private header "__utility/as_const.h" } | |
| 937 | module auto_cast { private header "__utility/auto_cast.h" } | |
| 938 | module cmp { private header "__utility/cmp.h" } | |
| 939 | module declval { private header "__utility/declval.h" } | |
| 940 | module exchange { private header "__utility/exchange.h" } | |
| 941 | module forward { private header "__utility/forward.h" } | |
| 942 | module in_place { private header "__utility/in_place.h" } | |
| 943 | module integer_sequence { private header "__utility/integer_sequence.h" } | |
| 944 | module move { private header "__utility/move.h" } | |
| 945 | module pair { private header "__utility/pair.h" } | |
| 946 | module piecewise_construct { private header "__utility/piecewise_construct.h" } | |
| 947 | module priority_tag { private header "__utility/priority_tag.h" } | |
| 948 | module rel_ops { private header "__utility/rel_ops.h" } | |
| 949 | module swap { private header "__utility/swap.h" } | |
| 950 | module to_underlying { private header "__utility/to_underlying.h" } | |
| 951 | module transaction { private header "__utility/transaction.h" } | |
| 952 | } | |
| 953 | } | |
| 954 | module valarray { | |
| 955 | header "valarray" | |
| 956 | export initializer_list | |
| 957 | export * | |
| 958 | } | |
| 959 | module variant { | |
| 960 | header "variant" | |
| 961 | export * | |
| 962 | ||
| 963 | module __variant { | |
| 964 | module monostate { private header "__variant/monostate.h" } | |
| 965 | } | |
| 966 | } | |
| 967 | module vector { | |
| 968 | header "vector" | |
| 969 | export initializer_list | |
| 970 | export * | |
| 971 | } | |
| 972 | module version { | |
| 973 | header "version" | |
| 974 | export * | |
| 975 | } | |
| 976 | ||
| 977 | // __config not modularised due to a bug in Clang | |
| 978 | // FIXME: These should be private. | |
| 979 | module __availability { private header "__availability" export * } | |
| 980 | module __bit_reference { private header "__bit_reference" export * } | |
| 981 | module __bits { private header "__bits" export * } | |
| 982 | module __debug { header "__debug" export * } | |
| 983 | module __errc { private header "__errc" export * } | |
| 984 | module __hash_table { header "__hash_table" export * } | |
| 985 | module __locale { private header "__locale" export * } | |
| 986 | module __mbstate_t { private header "__mbstate_t.h" export * } | |
| 987 | module __mutex_base { private header "__mutex_base" export * } | |
| 988 | module __node_handle { private header "__node_handle" export * } | |
| 989 | module __nullptr { header "__nullptr" export * } | |
| 990 | module __split_buffer { private header "__split_buffer" export * } | |
| 991 | module __std_stream { private header "__std_stream" export * } | |
| 992 | module __string { private header "__string" export * } | |
| 993 | module __threading_support { header "__threading_support" export * } | |
| 994 | module __tree { header "__tree" export * } | |
| 995 | module __tuple { private header "__tuple" export * } | |
| 996 | module __undef_macros { header "__undef_macros" export * } | |
| 997 | ||
| 998 | module experimental { | |
| 999 | requires cplusplus11 | |
| 1000 | ||
| 1001 | module algorithm { | |
| 1002 | header "experimental/algorithm" | |
| 1003 | export * | |
| 1004 | } | |
| 1005 | module coroutine { | |
| 1006 | requires coroutines | |
| 1007 | header "experimental/coroutine" | |
| 1008 | export * | |
| 1009 | } | |
| 1010 | module deque { | |
| 1011 | header "experimental/deque" | |
| 1012 | export * | |
| 1013 | } | |
| 1014 | module filesystem { | |
| 1015 | header "experimental/filesystem" | |
| 1016 | export * | |
| 1017 | } | |
| 1018 | module forward_list { | |
| 1019 | header "experimental/forward_list" | |
| 1020 | export * | |
| 1021 | } | |
| 1022 | module functional { | |
| 1023 | header "experimental/functional" | |
| 1024 | export * | |
| 1025 | } | |
| 1026 | module iterator { | |
| 1027 | header "experimental/iterator" | |
| 1028 | export * | |
| 1029 | } | |
| 1030 | module list { | |
| 1031 | header "experimental/list" | |
| 1032 | export * | |
| 1033 | } | |
| 1034 | module map { | |
| 1035 | header "experimental/map" | |
| 1036 | export * | |
| 1037 | } | |
| 1038 | module memory_resource { | |
| 1039 | header "experimental/memory_resource" | |
| 1040 | export * | |
| 1041 | } | |
| 1042 | module propagate_const { | |
| 1043 | header "experimental/propagate_const" | |
| 1044 | export * | |
| 1045 | } | |
| 1046 | module regex { | |
| 1047 | header "experimental/regex" | |
| 1048 | export * | |
| 1049 | } | |
| 1050 | module simd { | |
| 1051 | header "experimental/simd" | |
| 1052 | export * | |
| 1053 | } | |
| 1054 | module set { | |
| 1055 | header "experimental/set" | |
| 1056 | export * | |
| 1057 | } | |
| 1058 | module span { | |
| 1059 | header "span" | |
| 1060 | export * | |
| 1061 | } | |
| 1062 | module string { | |
| 1063 | header "experimental/string" | |
| 1064 | export * | |
| 1065 | } | |
| 1066 | module type_traits { | |
| 1067 | header "experimental/type_traits" | |
| 1068 | export * | |
| 1069 | } | |
| 1070 | module unordered_map { | |
| 1071 | header "experimental/unordered_map" | |
| 1072 | export * | |
| 1073 | } | |
| 1074 | module unordered_set { | |
| 1075 | header "experimental/unordered_set" | |
| 1076 | export * | |
| 1077 | } | |
| 1078 | module utility { | |
| 1079 | header "experimental/utility" | |
| 1080 | export * | |
| 1081 | } | |
| 1082 | module vector { | |
| 1083 | header "experimental/vector" | |
| 1084 | export * | |
| 1085 | } | |
| 1086 | // FIXME these should be private | |
| 1087 | module __memory { | |
| 1088 | header "experimental/__memory" | |
| 1089 | export * | |
| 1090 | } | |
| 1091 | } // end experimental | |
| 1092 | } |
lib/libcxx/include/mutex+6-2| ... | ... | @@ -186,20 +186,24 @@ template<class Callable, class ...Args> |
| 186 | 186 | |
| 187 | 187 | */ |
| 188 | 188 | |
| 189 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 189 | 190 | #include <__config> |
| 190 | 191 | #include <__mutex_base> |
| 191 | 192 | #include <__threading_support> |
| 192 | 193 | #include <__utility/forward.h> |
| 193 | 194 | #include <cstdint> |
| 194 | #include <functional> | |
| 195 | 195 | #include <memory> |
| 196 | 196 | #ifndef _LIBCPP_CXX03_LANG |
| 197 | 197 | # include <tuple> |
| 198 | 198 | #endif |
| 199 | 199 | #include <version> |
| 200 | 200 | |
| 201 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 202 | # include <functional> | |
| 203 | #endif | |
| 204 | ||
| 201 | 205 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 202 | #pragma GCC system_header | |
| 206 | # pragma GCC system_header | |
| 203 | 207 | #endif |
| 204 | 208 | |
| 205 | 209 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/new+13-1| ... | ... | @@ -86,6 +86,7 @@ void operator delete[](void* ptr, void*) noexcept; |
| 86 | 86 | |
| 87 | 87 | */ |
| 88 | 88 | |
| 89 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 89 | 90 | #include <__availability> |
| 90 | 91 | #include <__config> |
| 91 | 92 | #include <cstddef> |
| ... | ... | @@ -99,7 +100,7 @@ void operator delete[](void* ptr, void*) noexcept; |
| 99 | 100 | #endif |
| 100 | 101 | |
| 101 | 102 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 102 | #pragma GCC system_header | |
| 103 | # pragma GCC system_header | |
| 103 | 104 | #endif |
| 104 | 105 | |
| 105 | 106 | #if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L |
| ... | ... | @@ -359,6 +360,17 @@ constexpr _Tp* launder(_Tp* __p) noexcept |
| 359 | 360 | } |
| 360 | 361 | #endif |
| 361 | 362 | |
| 363 | #if _LIBCPP_STD_VER > 14 | |
| 364 | ||
| 365 | #if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 366 | ||
| 367 | inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; | |
| 368 | inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; | |
| 369 | ||
| 370 | #endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 371 | ||
| 372 | #endif // _LIBCPP_STD_VER > 14 | |
| 373 | ||
| 362 | 374 | _LIBCPP_END_NAMESPACE_STD |
| 363 | 375 | |
| 364 | 376 | #endif // _LIBCPP_NEW |
lib/libcxx/include/numbers+4-3| ... | ... | @@ -58,15 +58,16 @@ namespace std::numbers { |
| 58 | 58 | } |
| 59 | 59 | */ |
| 60 | 60 | |
| 61 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 61 | 62 | #include <__config> |
| 62 | 63 | #include <concepts> |
| 63 | 64 | #include <type_traits> |
| 64 | 65 | #include <version> |
| 65 | 66 | |
| 66 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 67 | #if _LIBCPP_STD_VER > 17 | |
| 67 | 68 | |
| 68 | 69 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 69 | #pragma GCC system_header | |
| 70 | # pragma GCC system_header | |
| 70 | 71 | #endif |
| 71 | 72 | |
| 72 | 73 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -128,6 +129,6 @@ inline constexpr double phi = phi_v<double>; |
| 128 | 129 | |
| 129 | 130 | _LIBCPP_END_NAMESPACE_STD |
| 130 | 131 | |
| 131 | #endif //!defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 132 | #endif // _LIBCPP_STD_VER > 17 | |
| 132 | 133 | |
| 133 | 134 | #endif // _LIBCPP_NUMBERS |
lib/libcxx/include/numeric+7-3| ... | ... | @@ -144,10 +144,9 @@ template<class T> |
| 144 | 144 | |
| 145 | 145 | */ |
| 146 | 146 | |
| 147 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 147 | 148 | #include <__config> |
| 148 | 149 | #include <cmath> // for isnormal |
| 149 | #include <functional> | |
| 150 | #include <iterator> | |
| 151 | 150 | #include <version> |
| 152 | 151 | |
| 153 | 152 | #include <__numeric/accumulate.h> |
| ... | ... | @@ -164,8 +163,13 @@ template<class T> |
| 164 | 163 | #include <__numeric/transform_inclusive_scan.h> |
| 165 | 164 | #include <__numeric/transform_reduce.h> |
| 166 | 165 | |
| 166 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 167 | # include <functional> | |
| 168 | # include <iterator> | |
| 169 | #endif | |
| 170 | ||
| 167 | 171 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 168 | #pragma GCC system_header | |
| 172 | # pragma GCC system_header | |
| 169 | 173 | #endif |
| 170 | 174 | |
| 171 | 175 | #if defined(_LIBCPP_HAS_PARALLEL_ALGORITHMS) && _LIBCPP_STD_VER >= 17 |
lib/libcxx/include/optional+42-19| ... | ... | @@ -93,11 +93,11 @@ namespace std { |
| 93 | 93 | template <class U, class... Args> |
| 94 | 94 | constexpr explicit optional(in_place_t, initializer_list<U>, Args &&...); |
| 95 | 95 | template <class U = T> |
| 96 | constexpr EXPLICIT optional(U &&); | |
| 96 | constexpr explicit(see-below) optional(U &&); | |
| 97 | 97 | template <class U> |
| 98 | EXPLICIT optional(const optional<U> &); // constexpr in C++20 | |
| 98 | explicit(see-below) optional(const optional<U> &); // constexpr in C++20 | |
| 99 | 99 | template <class U> |
| 100 | EXPLICIT optional(optional<U> &&); // constexpr in C++20 | |
| 100 | explicit(see-below) optional(optional<U> &&); // constexpr in C++20 | |
| 101 | 101 | |
| 102 | 102 | // 23.6.3.2, destructor |
| 103 | 103 | ~optional(); // constexpr in C++20 |
| ... | ... | @@ -158,22 +158,45 @@ template<class T> |
| 158 | 158 | |
| 159 | 159 | */ |
| 160 | 160 | |
| 161 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 161 | 162 | #include <__availability> |
| 162 | 163 | #include <__concepts/invocable.h> |
| 163 | 164 | #include <__config> |
| 164 | #include <__debug> | |
| 165 | #include <__functional_base> | |
| 166 | #include <compare> | |
| 167 | #include <functional> | |
| 165 | #include <__functional/hash.h> | |
| 166 | #include <__functional/invoke.h> | |
| 167 | #include <__functional/unary_function.h> | |
| 168 | #include <__memory/construct_at.h> | |
| 169 | #include <__tuple> | |
| 170 | #include <__utility/forward.h> | |
| 171 | #include <__utility/in_place.h> | |
| 172 | #include <__utility/move.h> | |
| 173 | #include <__utility/swap.h> | |
| 168 | 174 | #include <initializer_list> |
| 169 | 175 | #include <new> |
| 170 | 176 | #include <stdexcept> |
| 171 | 177 | #include <type_traits> |
| 172 | #include <utility> | |
| 173 | 178 | #include <version> |
| 174 | 179 | |
| 180 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 181 | # include <atomic> | |
| 182 | # include <chrono> | |
| 183 | # include <climits> | |
| 184 | # include <concepts> | |
| 185 | # include <ctime> | |
| 186 | # include <iterator> | |
| 187 | # include <memory> | |
| 188 | # include <ratio> | |
| 189 | # include <tuple> | |
| 190 | # include <typeinfo> | |
| 191 | # include <utility> | |
| 192 | # include <variant> | |
| 193 | #endif | |
| 194 | ||
| 195 | // standard-mandated includes | |
| 196 | #include <compare> | |
| 197 | ||
| 175 | 198 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 176 | #pragma GCC system_header | |
| 199 | # pragma GCC system_header | |
| 177 | 200 | #endif |
| 178 | 201 | |
| 179 | 202 | namespace std // purposefully not using versioning namespace |
| ... | ... | @@ -382,9 +405,9 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> |
| 382 | 405 | } |
| 383 | 406 | }; |
| 384 | 407 | |
| 385 | // optional<T&> is currently required ill-formed, however it may to be in the | |
| 386 | // future. For this reason it has already been implemented to ensure we can | |
| 387 | // make the change in an ABI compatible manner. | |
| 408 | // optional<T&> is currently required to be ill-formed. However, it may | |
| 409 | // be allowed in the future. For this reason, it has already been implemented | |
| 410 | // to ensure we can make the change in an ABI-compatible manner. | |
| 388 | 411 | template <class _Tp> |
| 389 | 412 | struct __optional_storage_base<_Tp, true> |
| 390 | 413 | { |
| ... | ... | @@ -1039,7 +1062,7 @@ public: |
| 1039 | 1062 | |
| 1040 | 1063 | #if _LIBCPP_STD_VER > 20 |
| 1041 | 1064 | template<class _Func> |
| 1042 | _LIBCPP_HIDE_FROM_ABI | |
| 1065 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1043 | 1066 | constexpr auto and_then(_Func&& __f) & { |
| 1044 | 1067 | using _Up = invoke_result_t<_Func, value_type&>; |
| 1045 | 1068 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| ... | ... | @@ -1050,7 +1073,7 @@ public: |
| 1050 | 1073 | } |
| 1051 | 1074 | |
| 1052 | 1075 | template<class _Func> |
| 1053 | _LIBCPP_HIDE_FROM_ABI | |
| 1076 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1054 | 1077 | constexpr auto and_then(_Func&& __f) const& { |
| 1055 | 1078 | using _Up = invoke_result_t<_Func, const value_type&>; |
| 1056 | 1079 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| ... | ... | @@ -1061,7 +1084,7 @@ public: |
| 1061 | 1084 | } |
| 1062 | 1085 | |
| 1063 | 1086 | template<class _Func> |
| 1064 | _LIBCPP_HIDE_FROM_ABI | |
| 1087 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1065 | 1088 | constexpr auto and_then(_Func&& __f) && { |
| 1066 | 1089 | using _Up = invoke_result_t<_Func, value_type&&>; |
| 1067 | 1090 | static_assert(__is_std_optional<remove_cvref_t<_Up>>::value, |
| ... | ... | @@ -1083,7 +1106,7 @@ public: |
| 1083 | 1106 | } |
| 1084 | 1107 | |
| 1085 | 1108 | template<class _Func> |
| 1086 | _LIBCPP_HIDE_FROM_ABI | |
| 1109 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1087 | 1110 | constexpr auto transform(_Func&& __f) & { |
| 1088 | 1111 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>; |
| 1089 | 1112 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); |
| ... | ... | @@ -1098,7 +1121,7 @@ public: |
| 1098 | 1121 | } |
| 1099 | 1122 | |
| 1100 | 1123 | template<class _Func> |
| 1101 | _LIBCPP_HIDE_FROM_ABI | |
| 1124 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1102 | 1125 | constexpr auto transform(_Func&& __f) const& { |
| 1103 | 1126 | using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>; |
| 1104 | 1127 | static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array"); |
| ... | ... | @@ -1113,7 +1136,7 @@ public: |
| 1113 | 1136 | } |
| 1114 | 1137 | |
| 1115 | 1138 | template<class _Func> |
| 1116 | _LIBCPP_HIDE_FROM_ABI | |
| 1139 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1117 | 1140 | constexpr auto transform(_Func&& __f) && { |
| 1118 | 1141 | using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>; |
| 1119 | 1142 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); |
| ... | ... | @@ -1128,7 +1151,7 @@ public: |
| 1128 | 1151 | } |
| 1129 | 1152 | |
| 1130 | 1153 | template<class _Func> |
| 1131 | _LIBCPP_HIDE_FROM_ABI | |
| 1154 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS | |
| 1132 | 1155 | constexpr auto transform(_Func&& __f) const&& { |
| 1133 | 1156 | using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>; |
| 1134 | 1157 | static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array"); |
lib/libcxx/include/ostream+92-4| ... | ... | @@ -130,20 +130,53 @@ template <class charT, class traits> |
| 130 | 130 | template <class Stream, class T> |
| 131 | 131 | Stream&& operator<<(Stream&& os, const T& x); |
| 132 | 132 | |
| 133 | template<class traits> | |
| 134 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete; // since C++20 | |
| 135 | template<class traits> | |
| 136 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete; // since C++20 | |
| 137 | template<class traits> | |
| 138 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete; // since C++20 | |
| 139 | template<class traits> | |
| 140 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete; // since C++20 | |
| 141 | template<class traits> | |
| 142 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete; // since C++20 | |
| 143 | template<class traits> | |
| 144 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete; // since C++20 | |
| 145 | template<class traits> | |
| 146 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete; // since C++20 | |
| 147 | template<class traits> | |
| 148 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete; // since C++20 | |
| 149 | template<class traits> | |
| 150 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char8_t*) = delete; // since C++20 | |
| 151 | template<class traits> | |
| 152 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char16_t*) = delete; // since C++20 | |
| 153 | template<class traits> | |
| 154 | basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char32_t*) = delete; // since C++20 | |
| 155 | template<class traits> | |
| 156 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete; // since C++20 | |
| 157 | template<class traits> | |
| 158 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete; // since C++20 | |
| 159 | template<class traits> | |
| 160 | basic_ostream<wchar_t, traits>& operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete; // since C++20 | |
| 161 | ||
| 133 | 162 | } // std |
| 134 | 163 | |
| 135 | 164 | */ |
| 136 | 165 | |
| 166 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 137 | 167 | #include <__config> |
| 138 | 168 | #include <bitset> |
| 139 | 169 | #include <ios> |
| 140 | #include <iterator> | |
| 141 | 170 | #include <locale> |
| 142 | 171 | #include <streambuf> |
| 143 | 172 | #include <version> |
| 144 | 173 | |
| 174 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 175 | # include <iterator> | |
| 176 | #endif | |
| 177 | ||
| 145 | 178 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 146 | #pragma GCC system_header | |
| 179 | # pragma GCC system_header | |
| 147 | 180 | #endif |
| 148 | 181 | |
| 149 | 182 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -221,9 +254,13 @@ public: |
| 221 | 254 | |
| 222 | 255 | basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb); |
| 223 | 256 | |
| 257 | #if _LIBCPP_STD_VER > 14 | |
| 258 | // LWG 2221 - nullptr. This is not backported to older standards modes. | |
| 259 | // See https://reviews.llvm.org/D127033 for more info on the rationale. | |
| 224 | 260 | _LIBCPP_INLINE_VISIBILITY |
| 225 | 261 | basic_ostream& operator<<(nullptr_t) |
| 226 | 262 | { return *this << "nullptr"; } |
| 263 | #endif | |
| 227 | 264 | |
| 228 | 265 | // 27.7.2.7 Unformatted output: |
| 229 | 266 | basic_ostream& put(char_type __c); |
| ... | ... | @@ -1094,9 +1131,60 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) |
| 1094 | 1131 | use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); |
| 1095 | 1132 | } |
| 1096 | 1133 | |
| 1097 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>) | |
| 1134 | #if _LIBCPP_STD_VER > 17 | |
| 1135 | ||
| 1136 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1137 | template <class _Traits> | |
| 1138 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete; | |
| 1139 | ||
| 1140 | template <class _Traits> | |
| 1141 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete; | |
| 1142 | ||
| 1143 | template <class _Traits> | |
| 1144 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete; | |
| 1145 | ||
| 1146 | template <class _Traits> | |
| 1147 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete; | |
| 1148 | ||
| 1149 | template <class _Traits> | |
| 1150 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete; | |
| 1151 | ||
| 1152 | template <class _Traits> | |
| 1153 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete; | |
| 1154 | ||
| 1155 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 1156 | ||
| 1157 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 1158 | template <class _Traits> | |
| 1159 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete; | |
| 1160 | ||
| 1161 | template <class _Traits> | |
| 1162 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete; | |
| 1163 | ||
| 1164 | template <class _Traits> | |
| 1165 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete; | |
| 1166 | ||
| 1167 | template <class _Traits> | |
| 1168 | basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete; | |
| 1169 | #endif | |
| 1170 | ||
| 1171 | template <class _Traits> | |
| 1172 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete; | |
| 1173 | ||
| 1174 | template <class _Traits> | |
| 1175 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete; | |
| 1176 | ||
| 1177 | template <class _Traits> | |
| 1178 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete; | |
| 1179 | ||
| 1180 | template <class _Traits> | |
| 1181 | basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete; | |
| 1182 | ||
| 1183 | #endif // _LIBCPP_STD_VER > 17 | |
| 1184 | ||
| 1185 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>; | |
| 1098 | 1186 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1099 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>) | |
| 1187 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>; | |
| 1100 | 1188 | #endif |
| 1101 | 1189 | |
| 1102 | 1190 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/queue+14-4| ... | ... | @@ -217,20 +217,30 @@ template <class T, class Container, class Compare> |
| 217 | 217 | |
| 218 | 218 | */ |
| 219 | 219 | |
| 220 | #include <__algorithm/make_heap.h> | |
| 221 | #include <__algorithm/pop_heap.h> | |
| 222 | #include <__algorithm/push_heap.h> | |
| 223 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 220 | 224 | #include <__config> |
| 225 | #include <__functional/operations.h> | |
| 221 | 226 | #include <__iterator/iterator_traits.h> |
| 222 | 227 | #include <__memory/uses_allocator.h> |
| 223 | 228 | #include <__utility/forward.h> |
| 224 | #include <algorithm> | |
| 225 | #include <compare> | |
| 226 | 229 | #include <deque> |
| 227 | #include <functional> | |
| 228 | 230 | #include <type_traits> |
| 229 | 231 | #include <vector> |
| 230 | 232 | #include <version> |
| 231 | 233 | |
| 234 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 235 | # include <functional> | |
| 236 | #endif | |
| 237 | ||
| 238 | // standard-mandated includes | |
| 239 | #include <compare> | |
| 240 | #include <initializer_list> | |
| 241 | ||
| 232 | 242 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 233 | #pragma GCC system_header | |
| 243 | # pragma GCC system_header | |
| 234 | 244 | #endif |
| 235 | 245 | |
| 236 | 246 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/random+10-3| ... | ... | @@ -1677,6 +1677,7 @@ class piecewise_linear_distribution |
| 1677 | 1677 | } // std |
| 1678 | 1678 | */ |
| 1679 | 1679 | |
| 1680 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 1680 | 1681 | #include <__config> |
| 1681 | 1682 | #include <__random/bernoulli_distribution.h> |
| 1682 | 1683 | #include <__random/binomial_distribution.h> |
| ... | ... | @@ -1694,6 +1695,7 @@ class piecewise_linear_distribution |
| 1694 | 1695 | #include <__random/geometric_distribution.h> |
| 1695 | 1696 | #include <__random/independent_bits_engine.h> |
| 1696 | 1697 | #include <__random/is_seed_sequence.h> |
| 1698 | #include <__random/is_valid.h> | |
| 1697 | 1699 | #include <__random/knuth_b.h> |
| 1698 | 1700 | #include <__random/linear_congruential_engine.h> |
| 1699 | 1701 | #include <__random/log2.h> |
| ... | ... | @@ -1714,10 +1716,15 @@ class piecewise_linear_distribution |
| 1714 | 1716 | #include <__random/uniform_random_bit_generator.h> |
| 1715 | 1717 | #include <__random/uniform_real_distribution.h> |
| 1716 | 1718 | #include <__random/weibull_distribution.h> |
| 1717 | #include <initializer_list> | |
| 1718 | 1719 | #include <version> |
| 1719 | 1720 | |
| 1720 | #include <algorithm> // for backward compatibility; TODO remove it | |
| 1721 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 1722 | # include <algorithm> | |
| 1723 | #endif | |
| 1724 | ||
| 1725 | // standard-mandated includes | |
| 1726 | #include <initializer_list> | |
| 1727 | ||
| 1721 | 1728 | #include <cmath> // for backward compatibility; TODO remove it |
| 1722 | 1729 | #include <cstddef> // for backward compatibility; TODO remove it |
| 1723 | 1730 | #include <cstdint> // for backward compatibility; TODO remove it |
| ... | ... | @@ -1729,7 +1736,7 @@ class piecewise_linear_distribution |
| 1729 | 1736 | #include <vector> // for backward compatibility; TODO remove it |
| 1730 | 1737 | |
| 1731 | 1738 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 1732 | #pragma GCC system_header | |
| 1739 | # pragma GCC system_header | |
| 1733 | 1740 | #endif |
| 1734 | 1741 | |
| 1735 | 1742 | #endif // _LIBCPP_RANDOM |
lib/libcxx/include/ranges+80-1| ... | ... | @@ -120,6 +120,14 @@ namespace std::ranges { |
| 120 | 120 | requires is_object_v<T> |
| 121 | 121 | class empty_view; |
| 122 | 122 | |
| 123 | template<class T> | |
| 124 | inline constexpr bool enable_borrowed_range<empty_view<T>> = true; | |
| 125 | ||
| 126 | namespace views { | |
| 127 | template<class T> | |
| 128 | inline constexpr empty_view<T> empty{}; | |
| 129 | } | |
| 130 | ||
| 123 | 131 | // [range.all], all view |
| 124 | 132 | namespace views { |
| 125 | 133 | inline constexpr unspecified all = unspecified; |
| ... | ... | @@ -142,6 +150,15 @@ namespace std::ranges { |
| 142 | 150 | template<class T> |
| 143 | 151 | inline constexpr bool enable_borrowed_range<owning_view<T>> = enable_borrowed_range<T>; |
| 144 | 152 | |
| 153 | // [range.filter], filter view | |
| 154 | template<input_range V, indirect_unary_predicate<iterator_t<V>> Pred> | |
| 155 | requires view<V> && is_object_v<Pred> | |
| 156 | class filter_view; | |
| 157 | ||
| 158 | namespace views { | |
| 159 | inline constexpr unspecified filter = unspecified; | |
| 160 | } | |
| 161 | ||
| 145 | 162 | // [range.drop], drop view |
| 146 | 163 | template<view V> |
| 147 | 164 | class drop_view; |
| ... | ... | @@ -196,10 +213,66 @@ namespace std::ranges { |
| 196 | 213 | template<input_range V> |
| 197 | 214 | requires view<V> && input_range<range_reference_t<V>> |
| 198 | 215 | class join_view; |
| 216 | ||
| 217 | // [range.lazy.split], lazy split view | |
| 218 | template<class R> | |
| 219 | concept tiny-range = see below; // exposition only | |
| 220 | ||
| 221 | template<input_range V, forward_range Pattern> | |
| 222 | requires view<V> && view<Pattern> && | |
| 223 | indirectly_comparable<iterator_t<V>, iterator_t<Pattern>, ranges::equal_to> && | |
| 224 | (forward_range<V> || tiny-range<Pattern>) | |
| 225 | class lazy_split_view; | |
| 226 | ||
| 227 | namespace views { | |
| 228 | inline constexpr unspecified lazy_split = unspecified; | |
| 229 | } | |
| 230 | ||
| 231 | // [range.zip], zip view | |
| 232 | template<input_range... Views> | |
| 233 | requires (view<Views> && ...) && (sizeof...(Views) > 0) | |
| 234 | class zip_view; // C++2b | |
| 235 | ||
| 236 | template<class... Views> | |
| 237 | inline constexpr bool enable_borrowed_range<zip_view<Views...>> = // C++2b | |
| 238 | (enable_borrowed_range<Views> && ...); | |
| 239 | ||
| 240 | namespace views { inline constexpr unspecified zip = unspecified; } // C++2b | |
| 199 | 241 | } |
| 200 | 242 | |
| 243 | namespace std { | |
| 244 | namespace views = ranges::views; | |
| 245 | ||
| 246 | template<class T> struct tuple_size; | |
| 247 | template<size_t I, class T> struct tuple_element; | |
| 248 | ||
| 249 | template<class I, class S, ranges::subrange_kind K> | |
| 250 | struct tuple_size<ranges::subrange<I, S, K>> | |
| 251 | : integral_constant<size_t, 2> {}; | |
| 252 | ||
| 253 | template<class I, class S, ranges::subrange_kind K> | |
| 254 | struct tuple_element<0, ranges::subrange<I, S, K>> { | |
| 255 | using type = I; | |
| 256 | }; | |
| 257 | ||
| 258 | template<class I, class S, ranges::subrange_kind K> | |
| 259 | struct tuple_element<1, ranges::subrange<I, S, K>> { | |
| 260 | using type = S; | |
| 261 | }; | |
| 262 | ||
| 263 | template<class I, class S, ranges::subrange_kind K> | |
| 264 | struct tuple_element<0, const ranges::subrange<I, S, K>> { | |
| 265 | using type = I; | |
| 266 | }; | |
| 267 | ||
| 268 | template<class I, class S, ranges::subrange_kind K> | |
| 269 | struct tuple_element<1, const ranges::subrange<I, S, K>> { | |
| 270 | using type = S; | |
| 271 | }; | |
| 272 | } | |
| 201 | 273 | */ |
| 202 | 274 | |
| 275 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 203 | 276 | #include <__config> |
| 204 | 277 | #include <__ranges/access.h> |
| 205 | 278 | #include <__ranges/all.h> |
| ... | ... | @@ -213,9 +286,13 @@ namespace std::ranges { |
| 213 | 286 | #include <__ranges/empty_view.h> |
| 214 | 287 | #include <__ranges/enable_borrowed_range.h> |
| 215 | 288 | #include <__ranges/enable_view.h> |
| 289 | #include <__ranges/filter_view.h> | |
| 216 | 290 | #include <__ranges/iota_view.h> |
| 217 | 291 | #include <__ranges/join_view.h> |
| 292 | #include <__ranges/lazy_split_view.h> | |
| 293 | #include <__ranges/rbegin.h> | |
| 218 | 294 | #include <__ranges/ref_view.h> |
| 295 | #include <__ranges/rend.h> | |
| 219 | 296 | #include <__ranges/reverse_view.h> |
| 220 | 297 | #include <__ranges/single_view.h> |
| 221 | 298 | #include <__ranges/size.h> |
| ... | ... | @@ -224,6 +301,8 @@ namespace std::ranges { |
| 224 | 301 | #include <__ranges/transform_view.h> |
| 225 | 302 | #include <__ranges/view_interface.h> |
| 226 | 303 | #include <__ranges/views.h> |
| 304 | #include <__ranges/zip_view.h> | |
| 305 | #include <__tuple> // TODO: <ranges> has to export std::tuple_size. Replace this, once <tuple> is granularized. | |
| 227 | 306 | #include <compare> // Required by the standard. |
| 228 | 307 | #include <initializer_list> // Required by the standard. |
| 229 | 308 | #include <iterator> // Required by the standard. |
| ... | ... | @@ -231,7 +310,7 @@ namespace std::ranges { |
| 231 | 310 | #include <version> |
| 232 | 311 | |
| 233 | 312 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 234 | #pragma GCC system_header | |
| 313 | # pragma GCC system_header | |
| 235 | 314 | #endif |
| 236 | 315 | |
| 237 | 316 | #endif // _LIBCPP_RANGES |
lib/libcxx/include/ratio+8-7| ... | ... | @@ -77,6 +77,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported |
| 77 | 77 | } |
| 78 | 78 | */ |
| 79 | 79 | |
| 80 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 80 | 81 | #include <__config> |
| 81 | 82 | #include <climits> |
| 82 | 83 | #include <cstdint> |
| ... | ... | @@ -84,7 +85,7 @@ typedef ratio<1000000000000000000000000, 1> yotta; // not supported |
| 84 | 85 | #include <version> |
| 85 | 86 | |
| 86 | 87 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 87 | #pragma GCC system_header | |
| 88 | # pragma GCC system_header | |
| 88 | 89 | #endif |
| 89 | 90 | |
| 90 | 91 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -416,11 +417,11 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract |
| 416 | 417 | |
| 417 | 418 | template <class _R1, class _R2> |
| 418 | 419 | struct _LIBCPP_TEMPLATE_VIS ratio_equal |
| 419 | : public _LIBCPP_BOOL_CONSTANT((_R1::num == _R2::num && _R1::den == _R2::den)) {}; | |
| 420 | : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {}; | |
| 420 | 421 | |
| 421 | 422 | template <class _R1, class _R2> |
| 422 | 423 | struct _LIBCPP_TEMPLATE_VIS ratio_not_equal |
| 423 | : public _LIBCPP_BOOL_CONSTANT((!ratio_equal<_R1, _R2>::value)) {}; | |
| 424 | : _BoolConstant<!ratio_equal<_R1, _R2>::value> {}; | |
| 424 | 425 | |
| 425 | 426 | // ratio_less |
| 426 | 427 | |
| ... | ... | @@ -479,19 +480,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> |
| 479 | 480 | |
| 480 | 481 | template <class _R1, class _R2> |
| 481 | 482 | struct _LIBCPP_TEMPLATE_VIS ratio_less |
| 482 | : public _LIBCPP_BOOL_CONSTANT((__ratio_less<_R1, _R2>::value)) {}; | |
| 483 | : _BoolConstant<__ratio_less<_R1, _R2>::value> {}; | |
| 483 | 484 | |
| 484 | 485 | template <class _R1, class _R2> |
| 485 | 486 | struct _LIBCPP_TEMPLATE_VIS ratio_less_equal |
| 486 | : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R2, _R1>::value)) {}; | |
| 487 | : _BoolConstant<!ratio_less<_R2, _R1>::value> {}; | |
| 487 | 488 | |
| 488 | 489 | template <class _R1, class _R2> |
| 489 | 490 | struct _LIBCPP_TEMPLATE_VIS ratio_greater |
| 490 | : public _LIBCPP_BOOL_CONSTANT((ratio_less<_R2, _R1>::value)) {}; | |
| 491 | : _BoolConstant<ratio_less<_R2, _R1>::value> {}; | |
| 491 | 492 | |
| 492 | 493 | template <class _R1, class _R2> |
| 493 | 494 | struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal |
| 494 | : public _LIBCPP_BOOL_CONSTANT((!ratio_less<_R1, _R2>::value)) {}; | |
| 495 | : _BoolConstant<!ratio_less<_R1, _R2>::value> {}; | |
| 495 | 496 | |
| 496 | 497 | template <class _R1, class _R2> |
| 497 | 498 | struct __ratio_gcd |
lib/libcxx/include/regex+40-26| ... | ... | @@ -762,23 +762,42 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; |
| 762 | 762 | } // std |
| 763 | 763 | */ |
| 764 | 764 | |
| 765 | #include <__algorithm/find.h> | |
| 766 | #include <__algorithm/search.h> | |
| 767 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 765 | 768 | #include <__config> |
| 766 | #include <__debug> | |
| 769 | #include <__iterator/back_insert_iterator.h> | |
| 767 | 770 | #include <__iterator/wrap_iter.h> |
| 768 | 771 | #include <__locale> |
| 769 | #include <compare> | |
| 772 | #include <__utility/move.h> | |
| 773 | #include <__utility/swap.h> | |
| 770 | 774 | #include <deque> |
| 771 | #include <initializer_list> | |
| 772 | #include <iterator> | |
| 773 | 775 | #include <memory> |
| 774 | 776 | #include <stdexcept> |
| 775 | 777 | #include <string> |
| 776 | #include <utility> | |
| 777 | 778 | #include <vector> |
| 778 | 779 | #include <version> |
| 779 | 780 | |
| 781 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 782 | # include <iterator> | |
| 783 | # include <utility> | |
| 784 | #endif | |
| 785 | ||
| 786 | // standard-mandated includes | |
| 787 | ||
| 788 | // [iterator.range] | |
| 789 | #include <__iterator/access.h> | |
| 790 | #include <__iterator/data.h> | |
| 791 | #include <__iterator/empty.h> | |
| 792 | #include <__iterator/reverse_access.h> | |
| 793 | #include <__iterator/size.h> | |
| 794 | ||
| 795 | // [re.syn] | |
| 796 | #include <compare> | |
| 797 | #include <initializer_list> | |
| 798 | ||
| 780 | 799 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 781 | #pragma GCC system_header | |
| 800 | # pragma GCC system_header | |
| 782 | 801 | #endif |
| 783 | 802 | |
| 784 | 803 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -1311,9 +1330,9 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const |
| 1311 | 1330 | } |
| 1312 | 1331 | |
| 1313 | 1332 | inline _LIBCPP_INLINE_VISIBILITY |
| 1314 | bool __is_07(unsigned char c) | |
| 1333 | bool __is_07(unsigned char __c) | |
| 1315 | 1334 | { |
| 1316 | return (c & 0xF8u) == | |
| 1335 | return (__c & 0xF8u) == | |
| 1317 | 1336 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) |
| 1318 | 1337 | 0xF0; |
| 1319 | 1338 | #else |
| ... | ... | @@ -1322,9 +1341,9 @@ bool __is_07(unsigned char c) |
| 1322 | 1341 | } |
| 1323 | 1342 | |
| 1324 | 1343 | inline _LIBCPP_INLINE_VISIBILITY |
| 1325 | bool __is_89(unsigned char c) | |
| 1344 | bool __is_89(unsigned char __c) | |
| 1326 | 1345 | { |
| 1327 | return (c & 0xFEu) == | |
| 1346 | return (__c & 0xFEu) == | |
| 1328 | 1347 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) |
| 1329 | 1348 | 0xF8; |
| 1330 | 1349 | #else |
| ... | ... | @@ -1333,12 +1352,12 @@ bool __is_89(unsigned char c) |
| 1333 | 1352 | } |
| 1334 | 1353 | |
| 1335 | 1354 | inline _LIBCPP_INLINE_VISIBILITY |
| 1336 | unsigned char __to_lower(unsigned char c) | |
| 1355 | unsigned char __to_lower(unsigned char __c) | |
| 1337 | 1356 | { |
| 1338 | 1357 | #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) |
| 1339 | 1358 | return c & 0xBF; |
| 1340 | 1359 | #else |
| 1341 | return c | 0x20; | |
| 1360 | return __c | 0x20; | |
| 1342 | 1361 | #endif |
| 1343 | 1362 | } |
| 1344 | 1363 | |
| ... | ... | @@ -2038,9 +2057,9 @@ __word_boundary<_CharT, _Traits>::__exec(__state& __s) const |
| 2038 | 2057 | |
| 2039 | 2058 | template <class _CharT> |
| 2040 | 2059 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 2041 | bool __is_eol(_CharT c) | |
| 2060 | bool __is_eol(_CharT __c) | |
| 2042 | 2061 | { |
| 2043 | return c == '\r' || c == '\n'; | |
| 2062 | return __c == '\r' || __c == '\n'; | |
| 2044 | 2063 | } |
| 2045 | 2064 | |
| 2046 | 2065 | template <class _CharT> |
| ... | ... | @@ -2093,14 +2112,14 @@ class __r_anchor_multiline |
| 2093 | 2112 | { |
| 2094 | 2113 | typedef __owns_one_state<_CharT> base; |
| 2095 | 2114 | |
| 2096 | bool __multiline; | |
| 2115 | bool __multiline_; | |
| 2097 | 2116 | |
| 2098 | 2117 | public: |
| 2099 | 2118 | typedef _VSTD::__state<_CharT> __state; |
| 2100 | 2119 | |
| 2101 | 2120 | _LIBCPP_INLINE_VISIBILITY |
| 2102 | 2121 | __r_anchor_multiline(bool __multiline, __node<_CharT>* __s) |
| 2103 | : base(__s), __multiline(__multiline) {} | |
| 2122 | : base(__s), __multiline_(__multiline) {} | |
| 2104 | 2123 | |
| 2105 | 2124 | virtual void __exec(__state&) const; |
| 2106 | 2125 | }; |
| ... | ... | @@ -2115,7 +2134,7 @@ __r_anchor_multiline<_CharT>::__exec(__state& __s) const |
| 2115 | 2134 | __s.__do_ = __state::__accept_but_not_consume; |
| 2116 | 2135 | __s.__node_ = this->first(); |
| 2117 | 2136 | } |
| 2118 | else if (__multiline && __is_eol(*__s.__current_)) | |
| 2137 | else if (__multiline_ && __is_eol(*__s.__current_)) | |
| 2119 | 2138 | { |
| 2120 | 2139 | __s.__do_ = __state::__accept_but_not_consume; |
| 2121 | 2140 | __s.__node_ = this->first(); |
| ... | ... | @@ -2729,12 +2748,7 @@ public: |
| 2729 | 2748 | |
| 2730 | 2749 | template <class _InputIterator> |
| 2731 | 2750 | _LIBCPP_INLINE_VISIBILITY |
| 2732 | typename enable_if | |
| 2733 | < | |
| 2734 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 2735 | !__is_cpp17_forward_iterator<_InputIterator>::value, | |
| 2736 | basic_regex& | |
| 2737 | >::type | |
| 2751 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value, basic_regex&>::type | |
| 2738 | 2752 | assign(_InputIterator __first, _InputIterator __last, |
| 2739 | 2753 | flag_type __f = regex_constants::ECMAScript) |
| 2740 | 2754 | { |
| ... | ... | @@ -2949,7 +2963,7 @@ private: |
| 2949 | 2963 | __parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, |
| 2950 | 2964 | basic_string<_CharT>* __str = nullptr); |
| 2951 | 2965 | |
| 2952 | bool __test_back_ref(_CharT c); | |
| 2966 | bool __test_back_ref(_CharT); | |
| 2953 | 2967 | |
| 2954 | 2968 | _LIBCPP_INLINE_VISIBILITY |
| 2955 | 2969 | void __push_l_anchor(); |
| ... | ... | @@ -4768,9 +4782,9 @@ basic_regex<_CharT, _Traits>::__parse_egrep(_ForwardIterator __first, |
| 4768 | 4782 | |
| 4769 | 4783 | template <class _CharT, class _Traits> |
| 4770 | 4784 | bool |
| 4771 | basic_regex<_CharT, _Traits>::__test_back_ref(_CharT c) | |
| 4785 | basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c) | |
| 4772 | 4786 | { |
| 4773 | unsigned __val = __traits_.value(c, 10); | |
| 4787 | unsigned __val = __traits_.value(__c, 10); | |
| 4774 | 4788 | if (__val >= 1 && __val <= 9) |
| 4775 | 4789 | { |
| 4776 | 4790 | if (__val > mark_count()) |
lib/libcxx/include/scoped_allocator+11-10| ... | ... | @@ -109,13 +109,14 @@ template <class OuterA1, class OuterA2, class... InnerAllocs> |
| 109 | 109 | |
| 110 | 110 | */ |
| 111 | 111 | |
| 112 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 112 | 113 | #include <__config> |
| 113 | 114 | #include <__utility/forward.h> |
| 114 | 115 | #include <memory> |
| 115 | 116 | #include <version> |
| 116 | 117 | |
| 117 | 118 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 118 | #pragma GCC system_header | |
| 119 | # pragma GCC system_header | |
| 119 | 120 | #endif |
| 120 | 121 | |
| 121 | 122 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -218,10 +219,10 @@ protected: |
| 218 | 219 | is_constructible<outer_allocator_type, _OuterA2>::value |
| 219 | 220 | >::type> |
| 220 | 221 | _LIBCPP_INLINE_VISIBILITY |
| 221 | __scoped_allocator_storage(_OuterA2&& __outerAlloc, | |
| 222 | const _InnerAllocs& ...__innerAllocs) _NOEXCEPT | |
| 223 | : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)), | |
| 224 | __inner_(__innerAllocs...) {} | |
| 222 | __scoped_allocator_storage(_OuterA2&& __outer_alloc, | |
| 223 | const _InnerAllocs& ...__inner_allocs) _NOEXCEPT | |
| 224 | : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)), | |
| 225 | __inner_(__inner_allocs...) {} | |
| 225 | 226 | |
| 226 | 227 | template <class _OuterA2, |
| 227 | 228 | class = typename enable_if< |
| ... | ... | @@ -299,8 +300,8 @@ protected: |
| 299 | 300 | is_constructible<outer_allocator_type, _OuterA2>::value |
| 300 | 301 | >::type> |
| 301 | 302 | _LIBCPP_INLINE_VISIBILITY |
| 302 | __scoped_allocator_storage(_OuterA2&& __outerAlloc) _NOEXCEPT | |
| 303 | : outer_allocator_type(_VSTD::forward<_OuterA2>(__outerAlloc)) {} | |
| 303 | __scoped_allocator_storage(_OuterA2&& __outer_alloc) _NOEXCEPT | |
| 304 | : outer_allocator_type(_VSTD::forward<_OuterA2>(__outer_alloc)) {} | |
| 304 | 305 | |
| 305 | 306 | template <class _OuterA2, |
| 306 | 307 | class = typename enable_if< |
| ... | ... | @@ -443,9 +444,9 @@ public: |
| 443 | 444 | is_constructible<outer_allocator_type, _OuterA2>::value |
| 444 | 445 | >::type> |
| 445 | 446 | _LIBCPP_INLINE_VISIBILITY |
| 446 | scoped_allocator_adaptor(_OuterA2&& __outerAlloc, | |
| 447 | const _InnerAllocs& ...__innerAllocs) _NOEXCEPT | |
| 448 | : base(_VSTD::forward<_OuterA2>(__outerAlloc), __innerAllocs...) {} | |
| 447 | scoped_allocator_adaptor(_OuterA2&& __outer_alloc, | |
| 448 | const _InnerAllocs& ...__inner_allocs) _NOEXCEPT | |
| 449 | : base(_VSTD::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {} | |
| 449 | 450 | // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default; |
| 450 | 451 | template <class _OuterA2, |
| 451 | 452 | class = typename enable_if< |
lib/libcxx/include/semaphore+5-2| ... | ... | @@ -45,19 +45,22 @@ using binary_semaphore = counting_semaphore<1>; |
| 45 | 45 | |
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 48 | 49 | #include <__availability> |
| 50 | #include <__chrono/time_point.h> | |
| 49 | 51 | #include <__config> |
| 50 | 52 | #include <__thread/timed_backoff_policy.h> |
| 51 | 53 | #include <__threading_support> |
| 52 | 54 | #include <atomic> |
| 55 | #include <limits> | |
| 53 | 56 | #include <version> |
| 54 | 57 | |
| 55 | 58 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 56 | #pragma GCC system_header | |
| 59 | # pragma GCC system_header | |
| 57 | 60 | #endif |
| 58 | 61 | |
| 59 | 62 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 60 | # error <semaphore> is not supported on this single threaded system | |
| 63 | # error "<semaphore> is not supported since libc++ has been configured without support for threads." | |
| 61 | 64 | #endif |
| 62 | 65 | |
| 63 | 66 | _LIBCPP_PUSH_MACROS |
lib/libcxx/include/set+28-9| ... | ... | @@ -471,21 +471,40 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 |
| 471 | 471 | |
| 472 | 472 | */ |
| 473 | 473 | |
| 474 | #include <__algorithm/equal.h> | |
| 475 | #include <__algorithm/lexicographical_compare.h> | |
| 476 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 474 | 477 | #include <__config> |
| 475 | #include <__debug> | |
| 476 | 478 | #include <__functional/is_transparent.h> |
| 479 | #include <__functional/operations.h> | |
| 480 | #include <__iterator/erase_if_container.h> | |
| 477 | 481 | #include <__iterator/iterator_traits.h> |
| 482 | #include <__iterator/reverse_iterator.h> | |
| 478 | 483 | #include <__node_handle> |
| 479 | 484 | #include <__tree> |
| 480 | 485 | #include <__utility/forward.h> |
| 486 | #include <version> | |
| 487 | ||
| 488 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 489 | # include <functional> | |
| 490 | # include <iterator> | |
| 491 | #endif | |
| 492 | ||
| 493 | // standard-mandated includes | |
| 494 | ||
| 495 | // [iterator.range] | |
| 496 | #include <__iterator/access.h> | |
| 497 | #include <__iterator/data.h> | |
| 498 | #include <__iterator/empty.h> | |
| 499 | #include <__iterator/reverse_access.h> | |
| 500 | #include <__iterator/size.h> | |
| 501 | ||
| 502 | // [associative.set.syn] | |
| 481 | 503 | #include <compare> |
| 482 | #include <functional> | |
| 483 | 504 | #include <initializer_list> |
| 484 | #include <iterator> // __libcpp_erase_if_container | |
| 485 | #include <version> | |
| 486 | 505 | |
| 487 | 506 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 488 | #pragma GCC system_header | |
| 507 | # pragma GCC system_header | |
| 489 | 508 | #endif |
| 490 | 509 | |
| 491 | 510 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -501,9 +520,9 @@ public: |
| 501 | 520 | // types: |
| 502 | 521 | typedef _Key key_type; |
| 503 | 522 | typedef key_type value_type; |
| 504 | typedef __identity_t<_Compare> key_compare; | |
| 523 | typedef __type_identity_t<_Compare> key_compare; | |
| 505 | 524 | typedef key_compare value_compare; |
| 506 | typedef __identity_t<_Allocator> allocator_type; | |
| 525 | typedef __type_identity_t<_Allocator> allocator_type; | |
| 507 | 526 | typedef value_type& reference; |
| 508 | 527 | typedef const value_type& const_reference; |
| 509 | 528 | |
| ... | ... | @@ -1034,9 +1053,9 @@ public: |
| 1034 | 1053 | // types: |
| 1035 | 1054 | typedef _Key key_type; |
| 1036 | 1055 | typedef key_type value_type; |
| 1037 | typedef __identity_t<_Compare> key_compare; | |
| 1056 | typedef __type_identity_t<_Compare> key_compare; | |
| 1038 | 1057 | typedef key_compare value_compare; |
| 1039 | typedef __identity_t<_Allocator> allocator_type; | |
| 1058 | typedef __type_identity_t<_Allocator> allocator_type; | |
| 1040 | 1059 | typedef value_type& reference; |
| 1041 | 1060 | typedef const value_type& const_reference; |
| 1042 | 1061 |
lib/libcxx/include/setjmp.h+1-1| ... | ... | @@ -28,7 +28,7 @@ void longjmp(jmp_buf env, int val); |
| 28 | 28 | #include <__config> |
| 29 | 29 | |
| 30 | 30 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 31 | #pragma GCC system_header | |
| 31 | # pragma GCC system_header | |
| 32 | 32 | #endif |
| 33 | 33 | |
| 34 | 34 | #include_next <setjmp.h> |
lib/libcxx/include/shared_mutex+6-7| ... | ... | @@ -122,6 +122,7 @@ template <class Mutex> |
| 122 | 122 | |
| 123 | 123 | */ |
| 124 | 124 | |
| 125 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 125 | 126 | #include <__availability> |
| 126 | 127 | #include <__config> |
| 127 | 128 | #include <version> |
| ... | ... | @@ -135,12 +136,12 @@ _LIBCPP_PUSH_MACROS |
| 135 | 136 | #include <__mutex_base> |
| 136 | 137 | |
| 137 | 138 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 138 | #pragma GCC system_header | |
| 139 | # pragma GCC system_header | |
| 139 | 140 | #endif |
| 140 | 141 | |
| 141 | 142 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 142 | #error <shared_mutex> is not supported on this single threaded system | |
| 143 | #else // !_LIBCPP_HAS_NO_THREADS | |
| 143 | # error "<shared_mutex> is not supported since libc++ has been configured without support for threads." | |
| 144 | #endif | |
| 144 | 145 | |
| 145 | 146 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 146 | 147 | |
| ... | ... | @@ -399,9 +400,9 @@ public: |
| 399 | 400 | void lock(); |
| 400 | 401 | bool try_lock(); |
| 401 | 402 | template <class Rep, class Period> |
| 402 | bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); | |
| 403 | bool try_lock_for(const chrono::duration<Rep, Period>& __rel_time); | |
| 403 | 404 | template <class Clock, class Duration> |
| 404 | bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); | |
| 405 | bool try_lock_until(const chrono::time_point<Clock, Duration>& __abs_time); | |
| 405 | 406 | void unlock(); |
| 406 | 407 | |
| 407 | 408 | // Setters |
| ... | ... | @@ -500,8 +501,6 @@ swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) _NOEXCEPT |
| 500 | 501 | |
| 501 | 502 | _LIBCPP_END_NAMESPACE_STD |
| 502 | 503 | |
| 503 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 504 | ||
| 505 | 504 | #endif // _LIBCPP_STD_VER > 11 |
| 506 | 505 | |
| 507 | 506 | _LIBCPP_POP_MACROS |
lib/libcxx/include/span+129-123| ... | ... | @@ -127,24 +127,43 @@ template<class R> |
| 127 | 127 | |
| 128 | 128 | */ |
| 129 | 129 | |
| 130 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 130 | 131 | #include <__config> |
| 131 | 132 | #include <__debug> |
| 133 | #include <__fwd/span.h> | |
| 134 | #include <__iterator/bounded_iter.h> | |
| 132 | 135 | #include <__iterator/concepts.h> |
| 136 | #include <__iterator/iterator_traits.h> | |
| 133 | 137 | #include <__iterator/wrap_iter.h> |
| 138 | #include <__memory/pointer_traits.h> | |
| 134 | 139 | #include <__ranges/concepts.h> |
| 135 | 140 | #include <__ranges/data.h> |
| 136 | 141 | #include <__ranges/enable_borrowed_range.h> |
| 137 | 142 | #include <__ranges/enable_view.h> |
| 138 | 143 | #include <__ranges/size.h> |
| 144 | #include <__utility/forward.h> | |
| 139 | 145 | #include <array> // for array |
| 140 | 146 | #include <cstddef> // for byte |
| 141 | #include <iterator> // for iterators | |
| 142 | 147 | #include <limits> |
| 143 | 148 | #include <type_traits> // for remove_cv, etc |
| 144 | 149 | #include <version> |
| 145 | 150 | |
| 151 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 152 | # include <functional> | |
| 153 | # include <iterator> | |
| 154 | #endif | |
| 155 | ||
| 156 | // standard-mandated includes | |
| 157 | ||
| 158 | // [iterator.range] | |
| 159 | #include <__iterator/access.h> | |
| 160 | #include <__iterator/data.h> | |
| 161 | #include <__iterator/empty.h> | |
| 162 | #include <__iterator/reverse_access.h> | |
| 163 | #include <__iterator/size.h> | |
| 164 | ||
| 146 | 165 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 147 | #pragma GCC system_header | |
| 166 | # pragma GCC system_header | |
| 148 | 167 | #endif |
| 149 | 168 | |
| 150 | 169 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -154,10 +173,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 154 | 173 | |
| 155 | 174 | #if _LIBCPP_STD_VER > 17 |
| 156 | 175 | |
| 157 | inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); | |
| 158 | template <typename _Tp, size_t _Extent = dynamic_extent> class span; | |
| 159 | ||
| 160 | ||
| 161 | 176 | template <class _Tp> |
| 162 | 177 | struct __is_std_array : false_type {}; |
| 163 | 178 | |
| ... | ... | @@ -170,24 +185,22 @@ struct __is_std_span : false_type {}; |
| 170 | 185 | template <class _Tp, size_t _Sz> |
| 171 | 186 | struct __is_std_span<span<_Tp, _Sz>> : true_type {}; |
| 172 | 187 | |
| 173 | #if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 188 | #if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 174 | 189 | // This is a temporary workaround until we ship <ranges> -- we've unfortunately been |
| 175 | 190 | // shipping <span> before its API was finalized, and we used to provide a constructor |
| 176 | 191 | // from container types that had the requirements below. To avoid breaking code that |
| 177 | 192 | // has started relying on the range-based constructor until we ship all of <ranges>, |
| 178 | 193 | // we emulate the constructor requirements like this. |
| 179 | template <class _Range, class _ElementType, class = void> | |
| 180 | struct __span_compatible_range : false_type { }; | |
| 181 | ||
| 182 | 194 | 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 { }; | |
| 195 | concept __span_compatible_range = | |
| 196 | !__is_std_span<remove_cvref_t<_Range>>::value && | |
| 197 | !__is_std_array<remove_cvref_t<_Range>>::value && | |
| 198 | !is_array_v<remove_cvref_t<_Range>> && | |
| 199 | requires (_Range&& __r) { | |
| 200 | data(std::forward<_Range>(__r)); | |
| 201 | size(std::forward<_Range>(__r)); | |
| 202 | } && | |
| 203 | is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>; | |
| 191 | 204 | #else |
| 192 | 205 | template <class _Range, class _ElementType> |
| 193 | 206 | concept __span_compatible_range = |
| ... | ... | @@ -198,7 +211,16 @@ concept __span_compatible_range = |
| 198 | 211 | !__is_std_array<remove_cvref_t<_Range>>::value && |
| 199 | 212 | !is_array_v<remove_cvref_t<_Range>> && |
| 200 | 213 | is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>>(*)[], _ElementType(*)[]>; |
| 201 | #endif | |
| 214 | #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 215 | ||
| 216 | template <class _From, class _To> | |
| 217 | concept __span_array_convertible = is_convertible_v<_From(*)[], _To(*)[]>; | |
| 218 | ||
| 219 | template <class _It, class _Tp> | |
| 220 | concept __span_compatible_iterator = contiguous_iterator<_It> && __span_array_convertible<remove_reference_t<iter_reference_t<_It>>, _Tp>; | |
| 221 | ||
| 222 | template <class _Sentinel, class _It> | |
| 223 | concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>; | |
| 202 | 224 | |
| 203 | 225 | template <typename _Tp, size_t _Extent> |
| 204 | 226 | class _LIBCPP_TEMPLATE_VIS span { |
| ... | ... | @@ -212,8 +234,8 @@ public: |
| 212 | 234 | using const_pointer = const _Tp *; |
| 213 | 235 | using reference = _Tp &; |
| 214 | 236 | using const_reference = const _Tp &; |
| 215 | #if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS) | |
| 216 | using iterator = pointer; | |
| 237 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 238 | using iterator = __bounded_iter<pointer>; | |
| 217 | 239 | #else |
| 218 | 240 | using iterator = __wrap_iter<pointer>; |
| 219 | 241 | #endif |
| ... | ... | @@ -222,17 +244,13 @@ public: |
| 222 | 244 | static constexpr size_type extent = _Extent; |
| 223 | 245 | |
| 224 | 246 | // [span.cons], span constructors, copy, assignment, and destructor |
| 225 | template <size_t _Sz = _Extent, enable_if_t<_Sz == 0, nullptr_t> = nullptr> | |
| 247 | template <size_t _Sz = _Extent> requires(_Sz == 0) | |
| 226 | 248 | _LIBCPP_INLINE_VISIBILITY constexpr span() noexcept : __data{nullptr} {} |
| 227 | 249 | |
| 228 | 250 | constexpr span (const span&) noexcept = default; |
| 229 | 251 | constexpr span& operator=(const span&) noexcept = default; |
| 230 | 252 | |
| 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> | |
| 253 | template <__span_compatible_iterator<element_type> _It> | |
| 236 | 254 | _LIBCPP_INLINE_VISIBILITY |
| 237 | 255 | constexpr explicit span(_It __first, size_type __count) |
| 238 | 256 | : __data{_VSTD::to_address(__first)} { |
| ... | ... | @@ -240,11 +258,7 @@ public: |
| 240 | 258 | _LIBCPP_ASSERT(_Extent == __count, "size mismatch in span's constructor (iterator, len)"); |
| 241 | 259 | } |
| 242 | 260 | |
| 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> | |
| 261 | template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End> | |
| 248 | 262 | _LIBCPP_INLINE_VISIBILITY |
| 249 | 263 | constexpr explicit span(_It __first, _End __last) : __data{_VSTD::to_address(__first)} { |
| 250 | 264 | (void)__last; |
| ... | ... | @@ -252,31 +266,27 @@ public: |
| 252 | 266 | _LIBCPP_ASSERT(__last - __first == _Extent, |
| 253 | 267 | "invalid range in span's constructor (iterator, sentinel): last - first != extent"); |
| 254 | 268 | } |
| 255 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 256 | 269 | |
| 257 | 270 | _LIBCPP_INLINE_VISIBILITY constexpr span(type_identity_t<element_type> (&__arr)[_Extent]) noexcept : __data{__arr} {} |
| 258 | 271 | |
| 259 | template <class _OtherElementType, | |
| 260 | enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | |
| 272 | template <__span_array_convertible<element_type> _OtherElementType> | |
| 261 | 273 | _LIBCPP_INLINE_VISIBILITY |
| 262 | 274 | constexpr span(array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} |
| 263 | 275 | |
| 264 | template <class _OtherElementType, | |
| 265 | enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | |
| 276 | template <class _OtherElementType> | |
| 277 | requires __span_array_convertible<const _OtherElementType, element_type> | |
| 266 | 278 | _LIBCPP_INLINE_VISIBILITY |
| 267 | 279 | constexpr span(const array<_OtherElementType, _Extent>& __arr) noexcept : __data{__arr.data()} {} |
| 268 | 280 | |
| 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 | >> | |
| 281 | #if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 282 | template <class _Container> | |
| 283 | requires __span_compatible_range<_Container, element_type> | |
| 273 | 284 | _LIBCPP_INLINE_VISIBILITY |
| 274 | 285 | constexpr explicit span(_Container& __c) : __data{std::data(__c)} { |
| 275 | 286 | _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)"); |
| 276 | 287 | } |
| 277 | template <class _Container, class = enable_if_t< | |
| 278 | __span_compatible_range<const _Container, element_type>::value | |
| 279 | >> | |
| 288 | template <class _Container> | |
| 289 | requires __span_compatible_range<const _Container, element_type> | |
| 280 | 290 | _LIBCPP_INLINE_VISIBILITY |
| 281 | 291 | constexpr explicit span(const _Container& __c) : __data{std::data(__c)} { |
| 282 | 292 | _LIBCPP_ASSERT(std::size(__c) == _Extent, "size mismatch in span's constructor (range)"); |
| ... | ... | @@ -287,22 +297,16 @@ public: |
| 287 | 297 | constexpr explicit span(_Range&& __r) : __data{ranges::data(__r)} { |
| 288 | 298 | _LIBCPP_ASSERT(ranges::size(__r) == _Extent, "size mismatch in span's constructor (range)"); |
| 289 | 299 | } |
| 290 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 300 | #endif | |
| 291 | 301 | |
| 292 | template <class _OtherElementType> | |
| 302 | template <__span_array_convertible<element_type> _OtherElementType> | |
| 293 | 303 | _LIBCPP_INLINE_VISIBILITY |
| 294 | constexpr span(const span<_OtherElementType, _Extent>& __other, | |
| 295 | enable_if_t< | |
| 296 | is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, | |
| 297 | nullptr_t> = nullptr) | |
| 304 | constexpr span(const span<_OtherElementType, _Extent>& __other) | |
| 298 | 305 | : __data{__other.data()} {} |
| 299 | 306 | |
| 300 | template <class _OtherElementType> | |
| 307 | template <__span_array_convertible<element_type> _OtherElementType> | |
| 301 | 308 | _LIBCPP_INLINE_VISIBILITY |
| 302 | constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other, | |
| 303 | enable_if_t< | |
| 304 | is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, | |
| 305 | nullptr_t> = nullptr) noexcept | |
| 309 | constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept | |
| 306 | 310 | : __data{__other.data()} { _LIBCPP_ASSERT(_Extent == __other.size(), "size mismatch in span's constructor (other span)"); } |
| 307 | 311 | |
| 308 | 312 | |
| ... | ... | @@ -312,7 +316,7 @@ public: |
| 312 | 316 | _LIBCPP_INLINE_VISIBILITY |
| 313 | 317 | constexpr span<element_type, _Count> first() const noexcept |
| 314 | 318 | { |
| 315 | static_assert(_Count <= _Extent, "Count out of range in span::first()"); | |
| 319 | static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range"); | |
| 316 | 320 | return span<element_type, _Count>{data(), _Count}; |
| 317 | 321 | } |
| 318 | 322 | |
| ... | ... | @@ -320,21 +324,21 @@ public: |
| 320 | 324 | _LIBCPP_INLINE_VISIBILITY |
| 321 | 325 | constexpr span<element_type, _Count> last() const noexcept |
| 322 | 326 | { |
| 323 | static_assert(_Count <= _Extent, "Count out of range in span::last()"); | |
| 327 | static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range"); | |
| 324 | 328 | return span<element_type, _Count>{data() + size() - _Count, _Count}; |
| 325 | 329 | } |
| 326 | 330 | |
| 327 | 331 | _LIBCPP_INLINE_VISIBILITY |
| 328 | 332 | constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept |
| 329 | 333 | { |
| 330 | _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)"); | |
| 334 | _LIBCPP_ASSERT(__count <= size(), "span<T, N>::first(count): count out of range"); | |
| 331 | 335 | return {data(), __count}; |
| 332 | 336 | } |
| 333 | 337 | |
| 334 | 338 | _LIBCPP_INLINE_VISIBILITY |
| 335 | 339 | constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept |
| 336 | 340 | { |
| 337 | _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)"); | |
| 341 | _LIBCPP_ASSERT(__count <= size(), "span<T, N>::last(count): count out of range"); | |
| 338 | 342 | return {data() + size() - __count, __count}; |
| 339 | 343 | } |
| 340 | 344 | |
| ... | ... | @@ -343,8 +347,8 @@ public: |
| 343 | 347 | constexpr auto subspan() const noexcept |
| 344 | 348 | -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> |
| 345 | 349 | { |
| 346 | static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()"); | |
| 347 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()"); | |
| 350 | static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range"); | |
| 351 | static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range"); | |
| 348 | 352 | |
| 349 | 353 | using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>; |
| 350 | 354 | return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; |
| ... | ... | @@ -355,11 +359,11 @@ public: |
| 355 | 359 | constexpr span<element_type, dynamic_extent> |
| 356 | 360 | subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept |
| 357 | 361 | { |
| 358 | _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)"); | |
| 359 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)"); | |
| 362 | _LIBCPP_ASSERT(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range"); | |
| 363 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T, N>::subspan(offset, count): count out of range"); | |
| 360 | 364 | if (__count == dynamic_extent) |
| 361 | 365 | return {data() + __offset, size() - __offset}; |
| 362 | _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)"); | |
| 366 | _LIBCPP_ASSERT(__count <= size() - __offset, "span<T, N>::subspan(offset, count): offset + count out of range"); | |
| 363 | 367 | return {data() + __offset, __count}; |
| 364 | 368 | } |
| 365 | 369 | |
| ... | ... | @@ -369,7 +373,7 @@ public: |
| 369 | 373 | |
| 370 | 374 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept |
| 371 | 375 | { |
| 372 | _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds"); | |
| 376 | _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range"); | |
| 373 | 377 | return __data[__idx]; |
| 374 | 378 | } |
| 375 | 379 | |
| ... | ... | @@ -388,8 +392,20 @@ public: |
| 388 | 392 | _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; } |
| 389 | 393 | |
| 390 | 394 | // [span.iter], span iterator support |
| 391 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); } | |
| 392 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); } | |
| 395 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { | |
| 396 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 397 | return std::__make_bounded_iter(data(), data(), data() + size()); | |
| 398 | #else | |
| 399 | return iterator(this, data()); | |
| 400 | #endif | |
| 401 | } | |
| 402 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { | |
| 403 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 404 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); | |
| 405 | #else | |
| 406 | return iterator(this, data() + size()); | |
| 407 | #endif | |
| 408 | } | |
| 393 | 409 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } |
| 394 | 410 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } |
| 395 | 411 | |
| ... | ... | @@ -401,14 +417,11 @@ public: |
| 401 | 417 | |
| 402 | 418 | private: |
| 403 | 419 | pointer __data; |
| 404 | ||
| 405 | 420 | }; |
| 406 | 421 | |
| 407 | 422 | |
| 408 | 423 | template <typename _Tp> |
| 409 | 424 | class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> { |
| 410 | private: | |
| 411 | ||
| 412 | 425 | public: |
| 413 | 426 | // constants and types |
| 414 | 427 | using element_type = _Tp; |
| ... | ... | @@ -419,8 +432,8 @@ public: |
| 419 | 432 | using const_pointer = const _Tp *; |
| 420 | 433 | using reference = _Tp &; |
| 421 | 434 | using const_reference = const _Tp &; |
| 422 | #if (_LIBCPP_DEBUG_LEVEL == 2) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS) | |
| 423 | using iterator = pointer; | |
| 435 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 436 | using iterator = __bounded_iter<pointer>; | |
| 424 | 437 | #else |
| 425 | 438 | using iterator = __wrap_iter<pointer>; |
| 426 | 439 | #endif |
| ... | ... | @@ -434,62 +447,47 @@ public: |
| 434 | 447 | constexpr span (const span&) noexcept = default; |
| 435 | 448 | constexpr span& operator=(const span&) noexcept = default; |
| 436 | 449 | |
| 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> | |
| 450 | template <__span_compatible_iterator<element_type> _It> | |
| 442 | 451 | _LIBCPP_INLINE_VISIBILITY |
| 443 | 452 | constexpr span(_It __first, size_type __count) |
| 444 | 453 | : __data{_VSTD::to_address(__first)}, __size{__count} {} |
| 445 | 454 | |
| 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> | |
| 455 | template <__span_compatible_iterator<element_type> _It, __span_compatible_sentinel_for<_It> _End> | |
| 451 | 456 | _LIBCPP_INLINE_VISIBILITY |
| 452 | 457 | constexpr span(_It __first, _End __last) |
| 453 | 458 | : __data(_VSTD::to_address(__first)), __size(__last - __first) {} |
| 454 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 455 | 459 | |
| 456 | 460 | template <size_t _Sz> |
| 457 | 461 | _LIBCPP_INLINE_VISIBILITY |
| 458 | 462 | constexpr span(type_identity_t<element_type> (&__arr)[_Sz]) noexcept : __data{__arr}, __size{_Sz} {} |
| 459 | 463 | |
| 460 | template <class _OtherElementType, size_t _Sz, | |
| 461 | enable_if_t<is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | |
| 464 | template <__span_array_convertible<element_type> _OtherElementType, size_t _Sz> | |
| 462 | 465 | _LIBCPP_INLINE_VISIBILITY |
| 463 | 466 | constexpr span(array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} |
| 464 | 467 | |
| 465 | template <class _OtherElementType, size_t _Sz, | |
| 466 | enable_if_t<is_convertible_v<const _OtherElementType(*)[], element_type (*)[]>, nullptr_t> = nullptr> | |
| 468 | template <class _OtherElementType, size_t _Sz> | |
| 469 | requires __span_array_convertible<const _OtherElementType, element_type> | |
| 467 | 470 | _LIBCPP_INLINE_VISIBILITY |
| 468 | 471 | constexpr span(const array<_OtherElementType, _Sz>& __arr) noexcept : __data{__arr.data()}, __size{_Sz} {} |
| 469 | 472 | |
| 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 | >> | |
| 473 | #if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 474 | template <class _Container> | |
| 475 | requires __span_compatible_range<_Container, element_type> | |
| 474 | 476 | _LIBCPP_INLINE_VISIBILITY |
| 475 | 477 | 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 | >> | |
| 478 | template <class _Container> | |
| 479 | requires __span_compatible_range<const _Container, element_type> | |
| 479 | 480 | _LIBCPP_INLINE_VISIBILITY |
| 480 | 481 | constexpr span(const _Container& __c) : __data(std::data(__c)), __size{std::size(__c)} {} |
| 481 | 482 | #else |
| 482 | 483 | template <__span_compatible_range<element_type> _Range> |
| 483 | 484 | _LIBCPP_INLINE_VISIBILITY |
| 484 | 485 | constexpr span(_Range&& __r) : __data(ranges::data(__r)), __size{ranges::size(__r)} {} |
| 485 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 486 | #endif | |
| 486 | 487 | |
| 487 | template <class _OtherElementType, size_t _OtherExtent> | |
| 488 | template <__span_array_convertible<element_type> _OtherElementType, size_t _OtherExtent> | |
| 488 | 489 | _LIBCPP_INLINE_VISIBILITY |
| 489 | constexpr span(const span<_OtherElementType, _OtherExtent>& __other, | |
| 490 | enable_if_t< | |
| 491 | is_convertible_v<_OtherElementType(*)[], element_type (*)[]>, | |
| 492 | nullptr_t> = nullptr) noexcept | |
| 490 | constexpr span(const span<_OtherElementType, _OtherExtent>& __other) noexcept | |
| 493 | 491 | : __data{__other.data()}, __size{__other.size()} {} |
| 494 | 492 | |
| 495 | 493 | // ~span() noexcept = default; |
| ... | ... | @@ -498,7 +496,7 @@ public: |
| 498 | 496 | _LIBCPP_INLINE_VISIBILITY |
| 499 | 497 | constexpr span<element_type, _Count> first() const noexcept |
| 500 | 498 | { |
| 501 | _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()"); | |
| 499 | _LIBCPP_ASSERT(_Count <= size(), "span<T>::first<Count>(): Count out of range"); | |
| 502 | 500 | return span<element_type, _Count>{data(), _Count}; |
| 503 | 501 | } |
| 504 | 502 | |
| ... | ... | @@ -506,21 +504,21 @@ public: |
| 506 | 504 | _LIBCPP_INLINE_VISIBILITY |
| 507 | 505 | constexpr span<element_type, _Count> last() const noexcept |
| 508 | 506 | { |
| 509 | _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()"); | |
| 507 | _LIBCPP_ASSERT(_Count <= size(), "span<T>::last<Count>(): Count out of range"); | |
| 510 | 508 | return span<element_type, _Count>{data() + size() - _Count, _Count}; |
| 511 | 509 | } |
| 512 | 510 | |
| 513 | 511 | _LIBCPP_INLINE_VISIBILITY |
| 514 | 512 | constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept |
| 515 | 513 | { |
| 516 | _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)"); | |
| 514 | _LIBCPP_ASSERT(__count <= size(), "span<T>::first(count): count out of range"); | |
| 517 | 515 | return {data(), __count}; |
| 518 | 516 | } |
| 519 | 517 | |
| 520 | 518 | _LIBCPP_INLINE_VISIBILITY |
| 521 | 519 | constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept |
| 522 | 520 | { |
| 523 | _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)"); | |
| 521 | _LIBCPP_ASSERT(__count <= size(), "span<T>::last(count): count out of range"); | |
| 524 | 522 | return {data() + size() - __count, __count}; |
| 525 | 523 | } |
| 526 | 524 | |
| ... | ... | @@ -528,8 +526,8 @@ public: |
| 528 | 526 | _LIBCPP_INLINE_VISIBILITY |
| 529 | 527 | constexpr span<element_type, _Count> subspan() const noexcept |
| 530 | 528 | { |
| 531 | _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()"); | |
| 532 | _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()"); | |
| 529 | _LIBCPP_ASSERT(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range"); | |
| 530 | _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "span<T>::subspan<Offset, Count>(): Offset + Count out of range"); | |
| 533 | 531 | return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; |
| 534 | 532 | } |
| 535 | 533 | |
| ... | ... | @@ -537,11 +535,11 @@ public: |
| 537 | 535 | _LIBCPP_INLINE_VISIBILITY |
| 538 | 536 | subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept |
| 539 | 537 | { |
| 540 | _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)"); | |
| 541 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)"); | |
| 538 | _LIBCPP_ASSERT(__offset <= size(), "span<T>::subspan(offset, count): offset out of range"); | |
| 539 | _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T>::subspan(offset, count): count out of range"); | |
| 542 | 540 | if (__count == dynamic_extent) |
| 543 | 541 | return {data() + __offset, size() - __offset}; |
| 544 | _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)"); | |
| 542 | _LIBCPP_ASSERT(__count <= size() - __offset, "span<T>::subspan(offset, count): offset + count out of range"); | |
| 545 | 543 | return {data() + __offset, __count}; |
| 546 | 544 | } |
| 547 | 545 | |
| ... | ... | @@ -551,19 +549,19 @@ public: |
| 551 | 549 | |
| 552 | 550 | _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept |
| 553 | 551 | { |
| 554 | _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds"); | |
| 552 | _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range"); | |
| 555 | 553 | return __data[__idx]; |
| 556 | 554 | } |
| 557 | 555 | |
| 558 | 556 | _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept |
| 559 | 557 | { |
| 560 | _LIBCPP_ASSERT(!empty(), "span<T>[].front() on empty span"); | |
| 558 | _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span"); | |
| 561 | 559 | return __data[0]; |
| 562 | 560 | } |
| 563 | 561 | |
| 564 | 562 | _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept |
| 565 | 563 | { |
| 566 | _LIBCPP_ASSERT(!empty(), "span<T>[].back() on empty span"); | |
| 564 | _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span"); | |
| 567 | 565 | return __data[size()-1]; |
| 568 | 566 | } |
| 569 | 567 | |
| ... | ... | @@ -571,8 +569,20 @@ public: |
| 571 | 569 | _LIBCPP_INLINE_VISIBILITY constexpr pointer data() const noexcept { return __data; } |
| 572 | 570 | |
| 573 | 571 | // [span.iter], span iterator support |
| 574 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { return iterator(data()); } | |
| 575 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { return iterator(data() + size()); } | |
| 572 | _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { | |
| 573 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 574 | return std::__make_bounded_iter(data(), data(), data() + size()); | |
| 575 | #else | |
| 576 | return iterator(this, data()); | |
| 577 | #endif | |
| 578 | } | |
| 579 | _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { | |
| 580 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 581 | return std::__make_bounded_iter(data() + size(), data(), data() + size()); | |
| 582 | #else | |
| 583 | return iterator(this, data() + size()); | |
| 584 | #endif | |
| 585 | } | |
| 576 | 586 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rbegin() const noexcept { return reverse_iterator(end()); } |
| 577 | 587 | _LIBCPP_INLINE_VISIBILITY constexpr reverse_iterator rend() const noexcept { return reverse_iterator(begin()); } |
| 578 | 588 | |
| ... | ... | @@ -587,31 +597,27 @@ private: |
| 587 | 597 | size_type __size; |
| 588 | 598 | }; |
| 589 | 599 | |
| 590 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 591 | 600 | template <class _Tp, size_t _Extent> |
| 592 | 601 | inline constexpr bool ranges::enable_borrowed_range<span<_Tp, _Extent> > = true; |
| 593 | 602 | |
| 594 | 603 | template <class _ElementType, size_t _Extent> |
| 595 | 604 | inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true; |
| 596 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 597 | 605 | |
| 598 | 606 | // as_bytes & as_writable_bytes |
| 599 | 607 | template <class _Tp, size_t _Extent> |
| 600 | 608 | _LIBCPP_INLINE_VISIBILITY |
| 601 | 609 | auto as_bytes(span<_Tp, _Extent> __s) noexcept |
| 602 | -> decltype(__s.__as_bytes()) | |
| 603 | { return __s.__as_bytes(); } | |
| 610 | { return __s.__as_bytes(); } | |
| 604 | 611 | |
| 605 | template <class _Tp, size_t _Extent> | |
| 612 | template <class _Tp, size_t _Extent> requires(!is_const_v<_Tp>) | |
| 606 | 613 | _LIBCPP_INLINE_VISIBILITY |
| 607 | 614 | auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept |
| 608 | -> enable_if_t<!is_const_v<_Tp>, decltype(__s.__as_writable_bytes())> | |
| 609 | 615 | { return __s.__as_writable_bytes(); } |
| 610 | 616 | |
| 611 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 617 | #if _LIBCPP_STD_VER > 17 | |
| 612 | 618 | template<contiguous_iterator _It, class _EndOrSize> |
| 613 | 619 | span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; |
| 614 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 620 | #endif // _LIBCPP_STD_VER > 17 | |
| 615 | 621 | |
| 616 | 622 | template<class _Tp, size_t _Sz> |
| 617 | 623 | span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>; |
| ... | ... | @@ -622,7 +628,7 @@ template<class _Tp, size_t _Sz> |
| 622 | 628 | template<class _Tp, size_t _Sz> |
| 623 | 629 | span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>; |
| 624 | 630 | |
| 625 | #if defined(_LIBCPP_HAS_NO_CONCEPTS) || defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 631 | #if defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 626 | 632 | template<class _Container> |
| 627 | 633 | span(_Container&) -> span<typename _Container::value_type>; |
| 628 | 634 |
lib/libcxx/include/sstream+7-5| ... | ... | @@ -180,14 +180,16 @@ typedef basic_stringstream<wchar_t> wstringstream; |
| 180 | 180 | |
| 181 | 181 | */ |
| 182 | 182 | |
| 183 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 183 | 184 | #include <__config> |
| 185 | #include <__utility/swap.h> | |
| 184 | 186 | #include <istream> |
| 185 | 187 | #include <ostream> |
| 186 | 188 | #include <string> |
| 187 | 189 | #include <version> |
| 188 | 190 | |
| 189 | 191 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 190 | #pragma GCC system_header | |
| 192 | # pragma GCC system_header | |
| 191 | 193 | #endif |
| 192 | 194 | |
| 193 | 195 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -859,10 +861,10 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, |
| 859 | 861 | } |
| 860 | 862 | |
| 861 | 863 | #if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1) |
| 862 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>) | |
| 863 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>) | |
| 864 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>) | |
| 865 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>) | |
| 864 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>; | |
| 865 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>; | |
| 866 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>; | |
| 867 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>; | |
| 866 | 868 | #endif |
| 867 | 869 | |
| 868 | 870 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/stack+10-1| ... | ... | @@ -98,6 +98,7 @@ template <class T, class Container> |
| 98 | 98 | |
| 99 | 99 | */ |
| 100 | 100 | |
| 101 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 101 | 102 | #include <__config> |
| 102 | 103 | #include <__iterator/iterator_traits.h> |
| 103 | 104 | #include <__memory/uses_allocator.h> |
| ... | ... | @@ -106,8 +107,16 @@ template <class T, class Container> |
| 106 | 107 | #include <type_traits> |
| 107 | 108 | #include <version> |
| 108 | 109 | |
| 110 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 111 | # include <functional> | |
| 112 | #endif | |
| 113 | ||
| 114 | // standard-mandated includes | |
| 115 | #include <compare> | |
| 116 | #include <initializer_list> | |
| 117 | ||
| 109 | 118 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 110 | #pragma GCC system_header | |
| 119 | # pragma GCC system_header | |
| 111 | 120 | #endif |
| 112 | 121 | |
| 113 | 122 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/stdatomic.h created+235| ... | ... | @@ -0,0 +1,235 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_STDATOMIC_H | |
| 11 | #define _LIBCPP_STDATOMIC_H | |
| 12 | ||
| 13 | /* | |
| 14 | stdatomic.h synopsis | |
| 15 | ||
| 16 | template<class T> | |
| 17 | using std-atomic = std::atomic<T>; // exposition only | |
| 18 | ||
| 19 | #define _Atomic(T) std-atomic<T> | |
| 20 | ||
| 21 | #define ATOMIC_BOOL_LOCK_FREE see below | |
| 22 | #define ATOMIC_CHAR_LOCK_FREE see below | |
| 23 | #define ATOMIC_CHAR16_T_LOCK_FREE see below | |
| 24 | #define ATOMIC_CHAR32_T_LOCK_FREE see below | |
| 25 | #define ATOMIC_WCHAR_T_LOCK_FREE see below | |
| 26 | #define ATOMIC_SHORT_LOCK_FREE see below | |
| 27 | #define ATOMIC_INT_LOCK_FREE see below | |
| 28 | #define ATOMIC_LONG_LOCK_FREE see below | |
| 29 | #define ATOMIC_LLONG_LOCK_FREE see below | |
| 30 | #define ATOMIC_POINTER_LOCK_FREE see below | |
| 31 | ||
| 32 | using std::memory_order // see below | |
| 33 | using std::memory_order_relaxed // see below | |
| 34 | using std::memory_order_consume // see below | |
| 35 | using std::memory_order_acquire // see below | |
| 36 | using std::memory_order_release // see below | |
| 37 | using std::memory_order_acq_rel // see below | |
| 38 | using std::memory_order_seq_cst // see below | |
| 39 | ||
| 40 | using std::atomic_flag // see below | |
| 41 | ||
| 42 | using std::atomic_bool // see below | |
| 43 | using std::atomic_char // see below | |
| 44 | using std::atomic_schar // see below | |
| 45 | using std::atomic_uchar // see below | |
| 46 | using std::atomic_short // see below | |
| 47 | using std::atomic_ushort // see below | |
| 48 | using std::atomic_int // see below | |
| 49 | using std::atomic_uint // see below | |
| 50 | using std::atomic_long // see below | |
| 51 | using std::atomic_ulong // see below | |
| 52 | using std::atomic_llong // see below | |
| 53 | using std::atomic_ullong // see below | |
| 54 | using std::atomic_char8_t // see below | |
| 55 | using std::atomic_char16_t // see below | |
| 56 | using std::atomic_char32_t // see below | |
| 57 | using std::atomic_wchar_t // see below | |
| 58 | using std::atomic_int8_t // see below | |
| 59 | using std::atomic_uint8_t // see below | |
| 60 | using std::atomic_int16_t // see below | |
| 61 | using std::atomic_uint16_t // see below | |
| 62 | using std::atomic_int32_t // see below | |
| 63 | using std::atomic_uint32_t // see below | |
| 64 | using std::atomic_int64_t // see below | |
| 65 | using std::atomic_uint64_t // see below | |
| 66 | using std::atomic_int_least8_t // see below | |
| 67 | using std::atomic_uint_least8_t // see below | |
| 68 | using std::atomic_int_least16_t // see below | |
| 69 | using std::atomic_uint_least16_t // see below | |
| 70 | using std::atomic_int_least32_t // see below | |
| 71 | using std::atomic_uint_least32_t // see below | |
| 72 | using std::atomic_int_least64_t // see below | |
| 73 | using std::atomic_uint_least64_t // see below | |
| 74 | using std::atomic_int_fast8_t // see below | |
| 75 | using std::atomic_uint_fast8_t // see below | |
| 76 | using std::atomic_int_fast16_t // see below | |
| 77 | using std::atomic_uint_fast16_t // see below | |
| 78 | using std::atomic_int_fast32_t // see below | |
| 79 | using std::atomic_uint_fast32_t // see below | |
| 80 | using std::atomic_int_fast64_t // see below | |
| 81 | using std::atomic_uint_fast64_t // see below | |
| 82 | using std::atomic_intptr_t // see below | |
| 83 | using std::atomic_uintptr_t // see below | |
| 84 | using std::atomic_size_t // see below | |
| 85 | using std::atomic_ptrdiff_t // see below | |
| 86 | using std::atomic_intmax_t // see below | |
| 87 | using std::atomic_uintmax_t // see below | |
| 88 | ||
| 89 | using std::atomic_is_lock_free // see below | |
| 90 | using std::atomic_load // see below | |
| 91 | using std::atomic_load_explicit // see below | |
| 92 | using std::atomic_store // see below | |
| 93 | using std::atomic_store_explicit // see below | |
| 94 | using std::atomic_exchange // see below | |
| 95 | using std::atomic_exchange_explicit // see below | |
| 96 | using std::atomic_compare_exchange_strong // see below | |
| 97 | using std::atomic_compare_exchange_strong_explicit // see below | |
| 98 | using std::atomic_compare_exchange_weak // see below | |
| 99 | using std::atomic_compare_exchange_weak_explicit // see below | |
| 100 | using std::atomic_fetch_add // see below | |
| 101 | using std::atomic_fetch_add_explicit // see below | |
| 102 | using std::atomic_fetch_sub // see below | |
| 103 | using std::atomic_fetch_sub_explicit // see below | |
| 104 | using std::atomic_fetch_or // see below | |
| 105 | using std::atomic_fetch_or_explicit // see below | |
| 106 | using std::atomic_fetch_and // see below | |
| 107 | using std::atomic_fetch_and_explicit // see below | |
| 108 | using std::atomic_flag_test_and_set // see below | |
| 109 | using std::atomic_flag_test_and_set_explicit // see below | |
| 110 | using std::atomic_flag_clear // see below | |
| 111 | using std::atomic_flag_clear_explicit // see below | |
| 112 | ||
| 113 | using std::atomic_thread_fence // see below | |
| 114 | using std::atomic_signal_fence // see below | |
| 115 | ||
| 116 | */ | |
| 117 | ||
| 118 | #include <__config> | |
| 119 | ||
| 120 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 121 | # pragma GCC system_header | |
| 122 | #endif | |
| 123 | ||
| 124 | #if _LIBCPP_STD_VER > 20 | |
| 125 | ||
| 126 | #include <atomic> | |
| 127 | #include <version> | |
| 128 | ||
| 129 | #ifdef _Atomic | |
| 130 | # undef _Atomic | |
| 131 | #endif | |
| 132 | ||
| 133 | #define _Atomic(_Tp) ::std::atomic<_Tp> | |
| 134 | ||
| 135 | using std::memory_order _LIBCPP_USING_IF_EXISTS; | |
| 136 | using std::memory_order_relaxed _LIBCPP_USING_IF_EXISTS; | |
| 137 | using std::memory_order_consume _LIBCPP_USING_IF_EXISTS; | |
| 138 | using std::memory_order_acquire _LIBCPP_USING_IF_EXISTS; | |
| 139 | using std::memory_order_release _LIBCPP_USING_IF_EXISTS; | |
| 140 | using std::memory_order_acq_rel _LIBCPP_USING_IF_EXISTS; | |
| 141 | using std::memory_order_seq_cst _LIBCPP_USING_IF_EXISTS; | |
| 142 | ||
| 143 | using std::atomic_flag _LIBCPP_USING_IF_EXISTS; | |
| 144 | ||
| 145 | using std::atomic_bool _LIBCPP_USING_IF_EXISTS; | |
| 146 | using std::atomic_char _LIBCPP_USING_IF_EXISTS; | |
| 147 | using std::atomic_schar _LIBCPP_USING_IF_EXISTS; | |
| 148 | using std::atomic_uchar _LIBCPP_USING_IF_EXISTS; | |
| 149 | using std::atomic_short _LIBCPP_USING_IF_EXISTS; | |
| 150 | using std::atomic_ushort _LIBCPP_USING_IF_EXISTS; | |
| 151 | using std::atomic_int _LIBCPP_USING_IF_EXISTS; | |
| 152 | using std::atomic_uint _LIBCPP_USING_IF_EXISTS; | |
| 153 | using std::atomic_long _LIBCPP_USING_IF_EXISTS; | |
| 154 | using std::atomic_ulong _LIBCPP_USING_IF_EXISTS; | |
| 155 | using std::atomic_llong _LIBCPP_USING_IF_EXISTS; | |
| 156 | using std::atomic_ullong _LIBCPP_USING_IF_EXISTS; | |
| 157 | using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS; | |
| 158 | using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS; | |
| 159 | using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS; | |
| 160 | using std::atomic_wchar_t _LIBCPP_USING_IF_EXISTS; | |
| 161 | ||
| 162 | using std::atomic_int8_t _LIBCPP_USING_IF_EXISTS; | |
| 163 | using std::atomic_uint8_t _LIBCPP_USING_IF_EXISTS; | |
| 164 | using std::atomic_int16_t _LIBCPP_USING_IF_EXISTS; | |
| 165 | using std::atomic_uint16_t _LIBCPP_USING_IF_EXISTS; | |
| 166 | using std::atomic_int32_t _LIBCPP_USING_IF_EXISTS; | |
| 167 | using std::atomic_uint32_t _LIBCPP_USING_IF_EXISTS; | |
| 168 | using std::atomic_int64_t _LIBCPP_USING_IF_EXISTS; | |
| 169 | using std::atomic_uint64_t _LIBCPP_USING_IF_EXISTS; | |
| 170 | ||
| 171 | using std::atomic_int_least8_t _LIBCPP_USING_IF_EXISTS; | |
| 172 | using std::atomic_uint_least8_t _LIBCPP_USING_IF_EXISTS; | |
| 173 | using std::atomic_int_least16_t _LIBCPP_USING_IF_EXISTS; | |
| 174 | using std::atomic_uint_least16_t _LIBCPP_USING_IF_EXISTS; | |
| 175 | using std::atomic_int_least32_t _LIBCPP_USING_IF_EXISTS; | |
| 176 | using std::atomic_uint_least32_t _LIBCPP_USING_IF_EXISTS; | |
| 177 | using std::atomic_int_least64_t _LIBCPP_USING_IF_EXISTS; | |
| 178 | using std::atomic_uint_least64_t _LIBCPP_USING_IF_EXISTS; | |
| 179 | ||
| 180 | using std::atomic_int_fast8_t _LIBCPP_USING_IF_EXISTS; | |
| 181 | using std::atomic_uint_fast8_t _LIBCPP_USING_IF_EXISTS; | |
| 182 | using std::atomic_int_fast16_t _LIBCPP_USING_IF_EXISTS; | |
| 183 | using std::atomic_uint_fast16_t _LIBCPP_USING_IF_EXISTS; | |
| 184 | using std::atomic_int_fast32_t _LIBCPP_USING_IF_EXISTS; | |
| 185 | using std::atomic_uint_fast32_t _LIBCPP_USING_IF_EXISTS; | |
| 186 | using std::atomic_int_fast64_t _LIBCPP_USING_IF_EXISTS; | |
| 187 | using std::atomic_uint_fast64_t _LIBCPP_USING_IF_EXISTS; | |
| 188 | ||
| 189 | using std::atomic_intptr_t _LIBCPP_USING_IF_EXISTS; | |
| 190 | using std::atomic_uintptr_t _LIBCPP_USING_IF_EXISTS; | |
| 191 | using std::atomic_size_t _LIBCPP_USING_IF_EXISTS; | |
| 192 | using std::atomic_ptrdiff_t _LIBCPP_USING_IF_EXISTS; | |
| 193 | using std::atomic_intmax_t _LIBCPP_USING_IF_EXISTS; | |
| 194 | using std::atomic_uintmax_t _LIBCPP_USING_IF_EXISTS; | |
| 195 | ||
| 196 | using std::atomic_compare_exchange_strong _LIBCPP_USING_IF_EXISTS; | |
| 197 | using std::atomic_compare_exchange_strong_explicit _LIBCPP_USING_IF_EXISTS; | |
| 198 | using std::atomic_compare_exchange_weak _LIBCPP_USING_IF_EXISTS; | |
| 199 | using std::atomic_compare_exchange_weak_explicit _LIBCPP_USING_IF_EXISTS; | |
| 200 | using std::atomic_exchange _LIBCPP_USING_IF_EXISTS; | |
| 201 | using std::atomic_exchange_explicit _LIBCPP_USING_IF_EXISTS; | |
| 202 | using std::atomic_fetch_add _LIBCPP_USING_IF_EXISTS; | |
| 203 | using std::atomic_fetch_add_explicit _LIBCPP_USING_IF_EXISTS; | |
| 204 | using std::atomic_fetch_and _LIBCPP_USING_IF_EXISTS; | |
| 205 | using std::atomic_fetch_and_explicit _LIBCPP_USING_IF_EXISTS; | |
| 206 | using std::atomic_fetch_or _LIBCPP_USING_IF_EXISTS; | |
| 207 | using std::atomic_fetch_or_explicit _LIBCPP_USING_IF_EXISTS; | |
| 208 | using std::atomic_fetch_sub _LIBCPP_USING_IF_EXISTS; | |
| 209 | using std::atomic_fetch_sub_explicit _LIBCPP_USING_IF_EXISTS; | |
| 210 | using std::atomic_flag_clear _LIBCPP_USING_IF_EXISTS; | |
| 211 | using std::atomic_flag_clear_explicit _LIBCPP_USING_IF_EXISTS; | |
| 212 | using std::atomic_flag_test_and_set _LIBCPP_USING_IF_EXISTS; | |
| 213 | using std::atomic_flag_test_and_set_explicit _LIBCPP_USING_IF_EXISTS; | |
| 214 | using std::atomic_is_lock_free _LIBCPP_USING_IF_EXISTS; | |
| 215 | using std::atomic_load _LIBCPP_USING_IF_EXISTS; | |
| 216 | using std::atomic_load_explicit _LIBCPP_USING_IF_EXISTS; | |
| 217 | using std::atomic_store _LIBCPP_USING_IF_EXISTS; | |
| 218 | using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS; | |
| 219 | ||
| 220 | using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS; | |
| 221 | using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS; | |
| 222 | ||
| 223 | #elif defined(_LIBCPP_COMPILER_CLANG_BASED) | |
| 224 | ||
| 225 | // Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking | |
| 226 | // the header. We do this because Clang has historically shipped a <stdatomic.h> | |
| 227 | // header that would be available in all Standard modes, and we don't want to | |
| 228 | // break that use case. | |
| 229 | # if __has_include_next(<stdatomic.h>) | |
| 230 | # include_next <stdatomic.h> | |
| 231 | # endif | |
| 232 | ||
| 233 | #endif // _LIBCPP_STD_VER > 20 | |
| 234 | ||
| 235 | #endif // _LIBCPP_STDATOMIC_H |
lib/libcxx/include/stdbool.h+1-2| ... | ... | @@ -9,7 +9,6 @@ |
| 9 | 9 | #ifndef _LIBCPP_STDBOOL_H |
| 10 | 10 | #define _LIBCPP_STDBOOL_H |
| 11 | 11 | |
| 12 | ||
| 13 | 12 | /* |
| 14 | 13 | stdbool.h synopsis |
| 15 | 14 | |
| ... | ... | @@ -22,7 +21,7 @@ Macros: |
| 22 | 21 | #include <__config> |
| 23 | 22 | |
| 24 | 23 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 25 | #pragma GCC system_header | |
| 24 | # pragma GCC system_header | |
| 26 | 25 | #endif |
| 27 | 26 | |
| 28 | 27 | #include_next <stdbool.h> |
lib/libcxx/include/stddef.h+3-8| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t) |
| 12 | 12 | |
| 13 | 13 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 14 | #pragma GCC system_header | |
| 14 | # pragma GCC system_header | |
| 15 | 15 | #endif |
| 16 | 16 | |
| 17 | 17 | #include_next <stddef.h> |
| ... | ... | @@ -39,18 +39,13 @@ Types: |
| 39 | 39 | #include <__config> |
| 40 | 40 | |
| 41 | 41 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 42 | #pragma GCC system_header | |
| 42 | # pragma GCC system_header | |
| 43 | 43 | #endif |
| 44 | 44 | |
| 45 | 45 | #include_next <stddef.h> |
| 46 | 46 | |
| 47 | 47 | #ifdef __cplusplus |
| 48 | ||
| 49 | extern "C++" { | |
| 50 | #include <__nullptr> | |
| 51 | using std::nullptr_t; | |
| 52 | } | |
| 53 | ||
| 48 | typedef decltype(nullptr) nullptr_t; | |
| 54 | 49 | #endif |
| 55 | 50 | |
| 56 | 51 | #endif // _LIBCPP_STDDEF_H |
lib/libcxx/include/stdexcept+2-1| ... | ... | @@ -41,13 +41,14 @@ public: |
| 41 | 41 | |
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 44 | 45 | #include <__config> |
| 45 | 46 | #include <cstdlib> |
| 46 | 47 | #include <exception> |
| 47 | 48 | #include <iosfwd> // for string forward decl |
| 48 | 49 | |
| 49 | 50 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 50 | #pragma GCC system_header | |
| 51 | # pragma GCC system_header | |
| 51 | 52 | #endif |
| 52 | 53 | |
| 53 | 54 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/include/stdint.h+1-1| ... | ... | @@ -106,7 +106,7 @@ Macros: |
| 106 | 106 | #include <__config> |
| 107 | 107 | |
| 108 | 108 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 109 | #pragma GCC system_header | |
| 109 | # pragma GCC system_header | |
| 110 | 110 | #endif |
| 111 | 111 | |
| 112 | 112 | /* C99 stdlib (e.g. glibc < 2.18) does not provide macros needed |
lib/libcxx/include/stdio.h+2-2| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #if defined(__need_FILE) || defined(__need___FILE) |
| 11 | 11 | |
| 12 | 12 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 13 | #pragma GCC system_header | |
| 13 | # pragma GCC system_header | |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | 16 | #include_next <stdio.h> |
| ... | ... | @@ -101,7 +101,7 @@ void perror(const char* s); |
| 101 | 101 | #include <__config> |
| 102 | 102 | |
| 103 | 103 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 104 | #pragma GCC system_header | |
| 104 | # pragma GCC system_header | |
| 105 | 105 | #endif |
| 106 | 106 | |
| 107 | 107 | #include_next <stdio.h> |
lib/libcxx/include/stdlib.h+2-2| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #if defined(__need_malloc_and_calloc) |
| 11 | 11 | |
| 12 | 12 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 13 | #pragma GCC system_header | |
| 13 | # pragma GCC system_header | |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | 16 | #include_next <stdlib.h> |
| ... | ... | @@ -87,7 +87,7 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 |
| 87 | 87 | #include <__config> |
| 88 | 88 | |
| 89 | 89 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 90 | #pragma GCC system_header | |
| 90 | # pragma GCC system_header | |
| 91 | 91 | #endif |
| 92 | 92 | |
| 93 | 93 | #include_next <stdlib.h> |
lib/libcxx/include/streambuf+6-5| ... | ... | @@ -107,6 +107,7 @@ protected: |
| 107 | 107 | |
| 108 | 108 | */ |
| 109 | 109 | |
| 110 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 110 | 111 | #include <__config> |
| 111 | 112 | #include <cstdint> |
| 112 | 113 | #include <ios> |
| ... | ... | @@ -114,7 +115,7 @@ protected: |
| 114 | 115 | #include <version> |
| 115 | 116 | |
| 116 | 117 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 117 | #pragma GCC system_header | |
| 118 | # pragma GCC system_header | |
| 118 | 119 | #endif |
| 119 | 120 | |
| 120 | 121 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -487,11 +488,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type) |
| 487 | 488 | return traits_type::eof(); |
| 488 | 489 | } |
| 489 | 490 | |
| 490 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>) | |
| 491 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>) | |
| 491 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>; | |
| 492 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>; | |
| 492 | 493 | |
| 493 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>) | |
| 494 | _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>) | |
| 494 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>; | |
| 495 | extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>; | |
| 495 | 496 | |
| 496 | 497 | _LIBCPP_END_NAMESPACE_STD |
| 497 | 498 |
lib/libcxx/include/string+1145-942| ... | ... | @@ -95,248 +95,246 @@ public: |
| 95 | 95 | static const size_type npos = -1; |
| 96 | 96 | |
| 97 | 97 | basic_string() |
| 98 | noexcept(is_nothrow_default_constructible<allocator_type>::value); | |
| 99 | explicit basic_string(const allocator_type& a); | |
| 100 | basic_string(const basic_string& str); | |
| 98 | noexcept(is_nothrow_default_constructible<allocator_type>::value); // constexpr since C++20 | |
| 99 | explicit basic_string(const allocator_type& a); // constexpr since C++20 | |
| 100 | basic_string(const basic_string& str); // constexpr since C++20 | |
| 101 | 101 | basic_string(basic_string&& str) |
| 102 | noexcept(is_nothrow_move_constructible<allocator_type>::value); | |
| 102 | noexcept(is_nothrow_move_constructible<allocator_type>::value); // constexpr since C++20 | |
| 103 | 103 | basic_string(const basic_string& str, size_type pos, |
| 104 | const allocator_type& a = allocator_type()); | |
| 104 | const allocator_type& a = allocator_type()); // constexpr since C++20 | |
| 105 | 105 | basic_string(const basic_string& str, size_type pos, size_type n, |
| 106 | const Allocator& a = Allocator()); | |
| 106 | const Allocator& a = Allocator()); // constexpr since C++20 | |
| 107 | 107 | template<class T> |
| 108 | basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17 | |
| 108 | basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); // C++17, constexpr since C++20 | |
| 109 | 109 | template <class T> |
| 110 | explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17 | |
| 111 | basic_string(const value_type* s, const allocator_type& a = allocator_type()); | |
| 112 | basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); | |
| 110 | explicit basic_string(const T& t, const Allocator& a = Allocator()); // C++17, constexpr since C++20 | |
| 111 | basic_string(const value_type* s, const allocator_type& a = allocator_type()); // constexpr since C++20 | |
| 112 | basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); // constexpr since C++20 | |
| 113 | 113 | basic_string(nullptr_t) = delete; // C++2b |
| 114 | basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); | |
| 114 | basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); // constexpr since C++20 | |
| 115 | 115 | template<class InputIterator> |
| 116 | 116 | basic_string(InputIterator begin, InputIterator end, |
| 117 | const allocator_type& a = allocator_type()); | |
| 118 | basic_string(initializer_list<value_type>, const Allocator& = Allocator()); | |
| 119 | basic_string(const basic_string&, const Allocator&); | |
| 120 | basic_string(basic_string&&, const Allocator&); | |
| 117 | const allocator_type& a = allocator_type()); // constexpr since C++20 | |
| 118 | basic_string(initializer_list<value_type>, const Allocator& = Allocator()); // constexpr since C++20 | |
| 119 | basic_string(const basic_string&, const Allocator&); // constexpr since C++20 | |
| 120 | basic_string(basic_string&&, const Allocator&); // constexpr since C++20 | |
| 121 | 121 | |
| 122 | ~basic_string(); | |
| 122 | ~basic_string(); // constexpr since C++20 | |
| 123 | 123 | |
| 124 | operator basic_string_view<charT, traits>() const noexcept; | |
| 124 | operator basic_string_view<charT, traits>() const noexcept; // constexpr since C++20 | |
| 125 | 125 | |
| 126 | basic_string& operator=(const basic_string& str); | |
| 126 | basic_string& operator=(const basic_string& str); // constexpr since C++20 | |
| 127 | 127 | template <class T> |
| 128 | basic_string& operator=(const T& t); // C++17 | |
| 128 | basic_string& operator=(const T& t); // C++17, constexpr since C++20 | |
| 129 | 129 | basic_string& operator=(basic_string&& str) |
| 130 | 130 | noexcept( |
| 131 | 131 | allocator_type::propagate_on_container_move_assignment::value || |
| 132 | allocator_type::is_always_equal::value ); // C++17 | |
| 133 | basic_string& operator=(const value_type* s); | |
| 132 | allocator_type::is_always_equal::value ); // C++17, constexpr since C++20 | |
| 133 | basic_string& operator=(const value_type* s); // constexpr since C++20 | |
| 134 | 134 | basic_string& operator=(nullptr_t) = delete; // C++2b |
| 135 | basic_string& operator=(value_type c); | |
| 136 | basic_string& operator=(initializer_list<value_type>); | |
| 135 | basic_string& operator=(value_type c); // constexpr since C++20 | |
| 136 | basic_string& operator=(initializer_list<value_type>); // constexpr since C++20 | |
| 137 | 137 | |
| 138 | iterator begin() noexcept; | |
| 139 | const_iterator begin() const noexcept; | |
| 140 | iterator end() noexcept; | |
| 141 | const_iterator end() const noexcept; | |
| 138 | iterator begin() noexcept; // constexpr since C++20 | |
| 139 | const_iterator begin() const noexcept; // constexpr since C++20 | |
| 140 | iterator end() noexcept; // constexpr since C++20 | |
| 141 | const_iterator end() const noexcept; // constexpr since C++20 | |
| 142 | 142 | |
| 143 | reverse_iterator rbegin() noexcept; | |
| 144 | const_reverse_iterator rbegin() const noexcept; | |
| 145 | reverse_iterator rend() noexcept; | |
| 146 | const_reverse_iterator rend() const noexcept; | |
| 143 | reverse_iterator rbegin() noexcept; // constexpr since C++20 | |
| 144 | const_reverse_iterator rbegin() const noexcept; // constexpr since C++20 | |
| 145 | reverse_iterator rend() noexcept; // constexpr since C++20 | |
| 146 | const_reverse_iterator rend() const noexcept; // constexpr since C++20 | |
| 147 | 147 | |
| 148 | const_iterator cbegin() const noexcept; | |
| 149 | const_iterator cend() const noexcept; | |
| 150 | const_reverse_iterator crbegin() const noexcept; | |
| 151 | const_reverse_iterator crend() const noexcept; | |
| 148 | const_iterator cbegin() const noexcept; // constexpr since C++20 | |
| 149 | const_iterator cend() const noexcept; // constexpr since C++20 | |
| 150 | const_reverse_iterator crbegin() const noexcept; // constexpr since C++20 | |
| 151 | const_reverse_iterator crend() const noexcept; // constexpr since C++20 | |
| 152 | 152 | |
| 153 | size_type size() const noexcept; | |
| 154 | size_type length() const noexcept; | |
| 155 | size_type max_size() const noexcept; | |
| 156 | size_type capacity() const noexcept; | |
| 153 | size_type size() const noexcept; // constexpr since C++20 | |
| 154 | size_type length() const noexcept; // constexpr since C++20 | |
| 155 | size_type max_size() const noexcept; // constexpr since C++20 | |
| 156 | size_type capacity() const noexcept; // constexpr since C++20 | |
| 157 | 157 | |
| 158 | void resize(size_type n, value_type c); | |
| 159 | void resize(size_type n); | |
| 158 | void resize(size_type n, value_type c); // constexpr since C++20 | |
| 159 | void resize(size_type n); // constexpr since C++20 | |
| 160 | 160 | |
| 161 | 161 | template<class Operation> |
| 162 | 162 | constexpr void resize_and_overwrite(size_type n, Operation op); // since C++23 |
| 163 | 163 | |
| 164 | void reserve(size_type res_arg); | |
| 164 | void reserve(size_type res_arg); // constexpr since C++20 | |
| 165 | 165 | void reserve(); // deprecated in C++20 |
| 166 | void shrink_to_fit(); | |
| 167 | void clear() noexcept; | |
| 168 | bool empty() const noexcept; | |
| 166 | void shrink_to_fit(); // constexpr since C++20 | |
| 167 | void clear() noexcept; // constexpr since C++20 | |
| 168 | bool empty() const noexcept; // constexpr since C++20 | |
| 169 | 169 | |
| 170 | const_reference operator[](size_type pos) const; | |
| 171 | reference operator[](size_type pos); | |
| 170 | const_reference operator[](size_type pos) const; // constexpr since C++20 | |
| 171 | reference operator[](size_type pos); // constexpr since C++20 | |
| 172 | 172 | |
| 173 | const_reference at(size_type n) const; | |
| 174 | reference at(size_type n); | |
| 173 | const_reference at(size_type n) const; // constexpr since C++20 | |
| 174 | reference at(size_type n); // constexpr since C++20 | |
| 175 | 175 | |
| 176 | basic_string& operator+=(const basic_string& str); | |
| 176 | basic_string& operator+=(const basic_string& str); // constexpr since C++20 | |
| 177 | 177 | template <class T> |
| 178 | basic_string& operator+=(const T& t); // C++17 | |
| 179 | basic_string& operator+=(const value_type* s); | |
| 180 | basic_string& operator+=(value_type c); | |
| 181 | basic_string& operator+=(initializer_list<value_type>); | |
| 178 | basic_string& operator+=(const T& t); // C++17, constexpr since C++20 | |
| 179 | basic_string& operator+=(const value_type* s); // constexpr since C++20 | |
| 180 | basic_string& operator+=(value_type c); // constexpr since C++20 | |
| 181 | basic_string& operator+=(initializer_list<value_type>); // constexpr since C++20 | |
| 182 | 182 | |
| 183 | basic_string& append(const basic_string& str); | |
| 183 | basic_string& append(const basic_string& str); // constexpr since C++20 | |
| 184 | 184 | template <class T> |
| 185 | basic_string& append(const T& t); // C++17 | |
| 186 | basic_string& append(const basic_string& str, size_type pos, size_type n=npos); //C++14 | |
| 185 | basic_string& append(const T& t); // C++17, constexpr since C++20 | |
| 186 | basic_string& append(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20 | |
| 187 | 187 | template <class T> |
| 188 | basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17 | |
| 189 | basic_string& append(const value_type* s, size_type n); | |
| 190 | basic_string& append(const value_type* s); | |
| 191 | basic_string& append(size_type n, value_type c); | |
| 188 | basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20 | |
| 189 | basic_string& append(const value_type* s, size_type n); // constexpr since C++20 | |
| 190 | basic_string& append(const value_type* s); // constexpr since C++20 | |
| 191 | basic_string& append(size_type n, value_type c); // constexpr since C++20 | |
| 192 | 192 | template<class InputIterator> |
| 193 | basic_string& append(InputIterator first, InputIterator last); | |
| 194 | basic_string& append(initializer_list<value_type>); | |
| 193 | basic_string& append(InputIterator first, InputIterator last); // constexpr since C++20 | |
| 194 | basic_string& append(initializer_list<value_type>); // constexpr since C++20 | |
| 195 | 195 | |
| 196 | void push_back(value_type c); | |
| 197 | void pop_back(); | |
| 198 | reference front(); | |
| 199 | const_reference front() const; | |
| 200 | reference back(); | |
| 201 | const_reference back() const; | |
| 196 | void push_back(value_type c); // constexpr since C++20 | |
| 197 | void pop_back(); // constexpr since C++20 | |
| 198 | reference front(); // constexpr since C++20 | |
| 199 | const_reference front() const; // constexpr since C++20 | |
| 200 | reference back(); // constexpr since C++20 | |
| 201 | const_reference back() const; // constexpr since C++20 | |
| 202 | 202 | |
| 203 | basic_string& assign(const basic_string& str); | |
| 203 | basic_string& assign(const basic_string& str); // constexpr since C++20 | |
| 204 | 204 | template <class T> |
| 205 | basic_string& assign(const T& t); // C++17 | |
| 206 | basic_string& assign(basic_string&& str); | |
| 207 | basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14 | |
| 205 | basic_string& assign(const T& t); // C++17, constexpr since C++20 | |
| 206 | basic_string& assign(basic_string&& str); // constexpr since C++20 | |
| 207 | basic_string& assign(const basic_string& str, size_type pos, size_type n=npos); // C++14, constexpr since C++20 | |
| 208 | 208 | template <class T> |
| 209 | basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17 | |
| 210 | basic_string& assign(const value_type* s, size_type n); | |
| 211 | basic_string& assign(const value_type* s); | |
| 212 | basic_string& assign(size_type n, value_type c); | |
| 209 | basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20 | |
| 210 | basic_string& assign(const value_type* s, size_type n); // constexpr since C++20 | |
| 211 | basic_string& assign(const value_type* s); // constexpr since C++20 | |
| 212 | basic_string& assign(size_type n, value_type c); // constexpr since C++20 | |
| 213 | 213 | template<class InputIterator> |
| 214 | basic_string& assign(InputIterator first, InputIterator last); | |
| 215 | basic_string& assign(initializer_list<value_type>); | |
| 214 | basic_string& assign(InputIterator first, InputIterator last); // constexpr since C++20 | |
| 215 | basic_string& assign(initializer_list<value_type>); // constexpr since C++20 | |
| 216 | 216 | |
| 217 | basic_string& insert(size_type pos1, const basic_string& str); | |
| 217 | basic_string& insert(size_type pos1, const basic_string& str); // constexpr since C++20 | |
| 218 | 218 | template <class T> |
| 219 | basic_string& insert(size_type pos1, const T& t); | |
| 219 | basic_string& insert(size_type pos1, const T& t); // constexpr since C++20 | |
| 220 | 220 | basic_string& insert(size_type pos1, const basic_string& str, |
| 221 | size_type pos2, size_type n); | |
| 221 | size_type pos2, size_type n); // constexpr since C++20 | |
| 222 | 222 | template <class T> |
| 223 | basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17 | |
| 224 | basic_string& insert(size_type pos, const value_type* s, size_type n=npos); //C++14 | |
| 225 | basic_string& insert(size_type pos, const value_type* s); | |
| 226 | basic_string& insert(size_type pos, size_type n, value_type c); | |
| 227 | iterator insert(const_iterator p, value_type c); | |
| 228 | iterator insert(const_iterator p, size_type n, value_type c); | |
| 223 | basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17, constexpr since C++20 | |
| 224 | basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20 | |
| 225 | basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20 | |
| 226 | basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20 | |
| 227 | iterator insert(const_iterator p, value_type c); // constexpr since C++20 | |
| 228 | iterator insert(const_iterator p, size_type n, value_type c); // constexpr since C++20 | |
| 229 | 229 | template<class InputIterator> |
| 230 | iterator insert(const_iterator p, InputIterator first, InputIterator last); | |
| 231 | iterator insert(const_iterator p, initializer_list<value_type>); | |
| 230 | iterator insert(const_iterator p, InputIterator first, InputIterator last); // constexpr since C++20 | |
| 231 | iterator insert(const_iterator p, initializer_list<value_type>); // constexpr since C++20 | |
| 232 | 232 | |
| 233 | basic_string& erase(size_type pos = 0, size_type n = npos); | |
| 234 | iterator erase(const_iterator position); | |
| 235 | iterator erase(const_iterator first, const_iterator last); | |
| 233 | basic_string& erase(size_type pos = 0, size_type n = npos); // constexpr since C++20 | |
| 234 | iterator erase(const_iterator position); // constexpr since C++20 | |
| 235 | iterator erase(const_iterator first, const_iterator last); // constexpr since C++20 | |
| 236 | 236 | |
| 237 | basic_string& replace(size_type pos1, size_type n1, const basic_string& str); | |
| 237 | basic_string& replace(size_type pos1, size_type n1, const basic_string& str); // constexpr since C++20 | |
| 238 | 238 | template <class T> |
| 239 | basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17 | |
| 239 | basic_string& replace(size_type pos1, size_type n1, const T& t); // C++17, constexpr since C++20 | |
| 240 | 240 | basic_string& replace(size_type pos1, size_type n1, const basic_string& str, |
| 241 | size_type pos2, size_type n2=npos); // C++14 | |
| 241 | size_type pos2, size_type n2=npos); // C++14, constexpr since C++20 | |
| 242 | 242 | template <class T> |
| 243 | 243 | basic_string& replace(size_type pos1, size_type n1, const T& t, |
| 244 | size_type pos2, size_type n); // C++17 | |
| 245 | basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); | |
| 246 | basic_string& replace(size_type pos, size_type n1, const value_type* s); | |
| 247 | basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); | |
| 248 | basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); | |
| 244 | size_type pos2, size_type n); // C++17, constexpr since C++20 | |
| 245 | basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20 | |
| 246 | basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20 | |
| 247 | basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20 | |
| 248 | basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); // constexpr since C++20 | |
| 249 | 249 | template <class T> |
| 250 | basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17 | |
| 251 | basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); | |
| 252 | basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); | |
| 253 | basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); | |
| 250 | basic_string& replace(const_iterator i1, const_iterator i2, const T& t); // C++17, constexpr since C++20 | |
| 251 | basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s, size_type n); // constexpr since C++20 | |
| 252 | basic_string& replace(const_iterator i1, const_iterator i2, const value_type* s); // constexpr since C++20 | |
| 253 | basic_string& replace(const_iterator i1, const_iterator i2, size_type n, value_type c); // constexpr since C++20 | |
| 254 | 254 | template<class InputIterator> |
| 255 | basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); | |
| 256 | basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); | |
| 255 | basic_string& replace(const_iterator i1, const_iterator i2, InputIterator j1, InputIterator j2); // constexpr since C++20 | |
| 256 | basic_string& replace(const_iterator i1, const_iterator i2, initializer_list<value_type>); // constexpr since C++20 | |
| 257 | 257 | |
| 258 | size_type copy(value_type* s, size_type n, size_type pos = 0) const; | |
| 259 | basic_string substr(size_type pos = 0, size_type n = npos) const; | |
| 258 | size_type copy(value_type* s, size_type n, size_type pos = 0) const; // constexpr since C++20 | |
| 259 | basic_string substr(size_type pos = 0, size_type n = npos) const; // constexpr since C++20 | |
| 260 | 260 | |
| 261 | 261 | void swap(basic_string& str) |
| 262 | 262 | noexcept(allocator_traits<allocator_type>::propagate_on_container_swap::value || |
| 263 | allocator_traits<allocator_type>::is_always_equal::value); // C++17 | |
| 263 | allocator_traits<allocator_type>::is_always_equal::value); // C++17, constexpr since C++20 | |
| 264 | 264 | |
| 265 | const value_type* c_str() const noexcept; | |
| 266 | const value_type* data() const noexcept; | |
| 267 | value_type* data() noexcept; // C++17 | |
| 265 | const value_type* c_str() const noexcept; // constexpr since C++20 | |
| 266 | const value_type* data() const noexcept; // constexpr since C++20 | |
| 267 | value_type* data() noexcept; // C++17, constexpr since C++20 | |
| 268 | 268 | |
| 269 | allocator_type get_allocator() const noexcept; | |
| 269 | allocator_type get_allocator() const noexcept; // constexpr since C++20 | |
| 270 | 270 | |
| 271 | size_type find(const basic_string& str, size_type pos = 0) const noexcept; | |
| 271 | size_type find(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 272 | 272 | template <class T> |
| 273 | size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension | |
| 274 | size_type find(const value_type* s, size_type pos, size_type n) const noexcept; | |
| 275 | size_type find(const value_type* s, size_type pos = 0) const noexcept; | |
| 276 | size_type find(value_type c, size_type pos = 0) const noexcept; | |
| 273 | size_type find(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 274 | size_type find(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20 | |
| 275 | size_type find(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 276 | size_type find(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 277 | 277 | |
| 278 | size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; | |
| 278 | size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 279 | 279 | template <class T> |
| 280 | size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension | |
| 281 | size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; | |
| 282 | size_type rfind(const value_type* s, size_type pos = npos) const noexcept; | |
| 283 | size_type rfind(value_type c, size_type pos = npos) const noexcept; | |
| 280 | size_type rfind(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 281 | size_type rfind(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20 | |
| 282 | size_type rfind(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 283 | size_type rfind(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 284 | 284 | |
| 285 | size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; | |
| 285 | size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 286 | 286 | template <class T> |
| 287 | size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension | |
| 288 | size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; | |
| 289 | size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; | |
| 290 | size_type find_first_of(value_type c, size_type pos = 0) const noexcept; | |
| 287 | size_type find_first_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 288 | size_type find_first_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20 | |
| 289 | size_type find_first_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 290 | size_type find_first_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 291 | 291 | |
| 292 | size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; | |
| 292 | size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 293 | 293 | template <class T> |
| 294 | size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension | |
| 295 | size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; | |
| 296 | size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; | |
| 297 | size_type find_last_of(value_type c, size_type pos = npos) const noexcept; | |
| 294 | size_type find_last_of(const T& t, size_type pos = npos) const noexcept noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 295 | size_type find_last_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20 | |
| 296 | size_type find_last_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 297 | size_type find_last_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 298 | 298 | |
| 299 | size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; | |
| 299 | size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 300 | 300 | template <class T> |
| 301 | size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension | |
| 302 | size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; | |
| 303 | size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; | |
| 304 | size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; | |
| 301 | size_type find_first_not_of(const T& t, size_type pos = 0) const noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 302 | size_type find_first_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20 | |
| 303 | size_type find_first_not_of(const value_type* s, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 304 | size_type find_first_not_of(value_type c, size_type pos = 0) const noexcept; // constexpr since C++20 | |
| 305 | 305 | |
| 306 | size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; | |
| 306 | size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 307 | 307 | template <class T> |
| 308 | size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension | |
| 309 | size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; | |
| 310 | size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; | |
| 311 | size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; | |
| 308 | size_type find_last_not_of(const T& t, size_type pos = npos) const noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 309 | size_type find_last_not_of(const value_type* s, size_type pos, size_type n) const noexcept; // constexpr since C++20 | |
| 310 | size_type find_last_not_of(const value_type* s, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 311 | size_type find_last_not_of(value_type c, size_type pos = npos) const noexcept; // constexpr since C++20 | |
| 312 | 312 | |
| 313 | int compare(const basic_string& str) const noexcept; | |
| 313 | int compare(const basic_string& str) const noexcept; // constexpr since C++20 | |
| 314 | 314 | template <class T> |
| 315 | int compare(const T& t) const noexcept; // C++17, noexcept as an extension | |
| 316 | int compare(size_type pos1, size_type n1, const basic_string& str) const; | |
| 315 | int compare(const T& t) const noexcept; // C++17, noexcept as an extension, constexpr since C++20 | |
| 316 | int compare(size_type pos1, size_type n1, const basic_string& str) const; // constexpr since C++20 | |
| 317 | 317 | template <class T> |
| 318 | int compare(size_type pos1, size_type n1, const T& t) const; // C++17 | |
| 318 | int compare(size_type pos1, size_type n1, const T& t) const; // C++17, constexpr since C++20 | |
| 319 | 319 | int compare(size_type pos1, size_type n1, const basic_string& str, |
| 320 | size_type pos2, size_type n2=npos) const; // C++14 | |
| 320 | size_type pos2, size_type n2=npos) const; // C++14, constexpr since C++20 | |
| 321 | 321 | template <class T> |
| 322 | 322 | int compare(size_type pos1, size_type n1, const T& t, |
| 323 | size_type pos2, size_type n2=npos) const; // C++17 | |
| 324 | int compare(const value_type* s) const noexcept; | |
| 325 | int compare(size_type pos1, size_type n1, const value_type* s) const; | |
| 326 | int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; | |
| 327 | ||
| 328 | bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20 | |
| 329 | bool starts_with(charT c) const noexcept; // C++20 | |
| 330 | bool starts_with(const charT* s) const; // C++20 | |
| 331 | bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20 | |
| 332 | bool ends_with(charT c) const noexcept; // C++20 | |
| 333 | bool ends_with(const charT* s) const; // C++20 | |
| 334 | ||
| 335 | constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b | |
| 336 | constexpr bool contains(charT c) const noexcept; // C++2b | |
| 337 | constexpr bool contains(const charT* s) const; // C++2b | |
| 338 | ||
| 339 | bool __invariants() const; | |
| 323 | size_type pos2, size_type n2=npos) const; // C++17, constexpr since C++20 | |
| 324 | int compare(const value_type* s) const noexcept; // constexpr since C++20 | |
| 325 | int compare(size_type pos1, size_type n1, const value_type* s) const; // constexpr since C++20 | |
| 326 | int compare(size_type pos1, size_type n1, const value_type* s, size_type n2) const; // constexpr since C++20 | |
| 327 | ||
| 328 | constexpr bool starts_with(basic_string_view<charT, traits> sv) const noexcept; // C++20 | |
| 329 | constexpr bool starts_with(charT c) const noexcept; // C++20 | |
| 330 | constexpr bool starts_with(const charT* s) const; // C++20 | |
| 331 | constexpr bool ends_with(basic_string_view<charT, traits> sv) const noexcept; // C++20 | |
| 332 | constexpr bool ends_with(charT c) const noexcept; // C++20 | |
| 333 | constexpr bool ends_with(const charT* s) const; // C++20 | |
| 334 | ||
| 335 | constexpr bool contains(basic_string_view<charT, traits> sv) const noexcept; // C++2b | |
| 336 | constexpr bool contains(charT c) const noexcept; // C++2b | |
| 337 | constexpr bool contains(const charT* s) const; // C++2b | |
| 340 | 338 | }; |
| 341 | 339 | |
| 342 | 340 | template<class InputIterator, |
| ... | ... | @@ -349,88 +347,88 @@ basic_string(InputIterator, InputIterator, Allocator = Allocator()) |
| 349 | 347 | template<class charT, class traits, class Allocator> |
| 350 | 348 | basic_string<charT, traits, Allocator> |
| 351 | 349 | operator+(const basic_string<charT, traits, Allocator>& lhs, |
| 352 | const basic_string<charT, traits, Allocator>& rhs); | |
| 350 | const basic_string<charT, traits, Allocator>& rhs); // constexpr since C++20 | |
| 353 | 351 | |
| 354 | 352 | template<class charT, class traits, class Allocator> |
| 355 | 353 | basic_string<charT, traits, Allocator> |
| 356 | operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); | |
| 354 | operator+(const charT* lhs , const basic_string<charT,traits,Allocator>&rhs); // constexpr since C++20 | |
| 357 | 355 | |
| 358 | 356 | template<class charT, class traits, class Allocator> |
| 359 | 357 | basic_string<charT, traits, Allocator> |
| 360 | operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); | |
| 358 | operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs); // constexpr since C++20 | |
| 361 | 359 | |
| 362 | 360 | template<class charT, class traits, class Allocator> |
| 363 | 361 | basic_string<charT, traits, Allocator> |
| 364 | operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); | |
| 362 | operator+(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs); // constexpr since C++20 | |
| 365 | 363 | |
| 366 | 364 | template<class charT, class traits, class Allocator> |
| 367 | 365 | basic_string<charT, traits, Allocator> |
| 368 | operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); | |
| 366 | operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20 | |
| 369 | 367 | |
| 370 | 368 | template<class charT, class traits, class Allocator> |
| 371 | 369 | bool operator==(const basic_string<charT, traits, Allocator>& lhs, |
| 372 | const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 370 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 373 | 371 | |
| 374 | 372 | template<class charT, class traits, class Allocator> |
| 375 | bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 373 | bool operator==(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 376 | 374 | |
| 377 | 375 | template<class charT, class traits, class Allocator> |
| 378 | bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; | |
| 376 | bool operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20 | |
| 379 | 377 | |
| 380 | 378 | template<class charT, class traits, class Allocator> |
| 381 | 379 | bool operator!=(const basic_string<charT,traits,Allocator>& lhs, |
| 382 | const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 380 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 383 | 381 | |
| 384 | 382 | template<class charT, class traits, class Allocator> |
| 385 | bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 383 | bool operator!=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 386 | 384 | |
| 387 | 385 | template<class charT, class traits, class Allocator> |
| 388 | bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | |
| 386 | bool operator!=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20 | |
| 389 | 387 | |
| 390 | 388 | template<class charT, class traits, class Allocator> |
| 391 | 389 | bool operator< (const basic_string<charT, traits, Allocator>& lhs, |
| 392 | const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 390 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 393 | 391 | |
| 394 | 392 | template<class charT, class traits, class Allocator> |
| 395 | bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | |
| 393 | bool operator< (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20 | |
| 396 | 394 | |
| 397 | 395 | template<class charT, class traits, class Allocator> |
| 398 | bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 396 | bool operator< (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 399 | 397 | |
| 400 | 398 | template<class charT, class traits, class Allocator> |
| 401 | 399 | bool operator> (const basic_string<charT, traits, Allocator>& lhs, |
| 402 | const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 400 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 403 | 401 | |
| 404 | 402 | template<class charT, class traits, class Allocator> |
| 405 | bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | |
| 403 | bool operator> (const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20 | |
| 406 | 404 | |
| 407 | 405 | template<class charT, class traits, class Allocator> |
| 408 | bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 406 | bool operator> (const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 409 | 407 | |
| 410 | 408 | template<class charT, class traits, class Allocator> |
| 411 | 409 | bool operator<=(const basic_string<charT, traits, Allocator>& lhs, |
| 412 | const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 410 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 413 | 411 | |
| 414 | 412 | template<class charT, class traits, class Allocator> |
| 415 | bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | |
| 413 | bool operator<=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20 | |
| 416 | 414 | |
| 417 | 415 | template<class charT, class traits, class Allocator> |
| 418 | bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 416 | bool operator<=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 419 | 417 | |
| 420 | 418 | template<class charT, class traits, class Allocator> |
| 421 | 419 | bool operator>=(const basic_string<charT, traits, Allocator>& lhs, |
| 422 | const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 420 | const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 423 | 421 | |
| 424 | 422 | template<class charT, class traits, class Allocator> |
| 425 | bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; | |
| 423 | bool operator>=(const basic_string<charT, traits, Allocator>& lhs, const charT* rhs) noexcept; // constexpr since C++20 | |
| 426 | 424 | |
| 427 | 425 | template<class charT, class traits, class Allocator> |
| 428 | bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; | |
| 426 | bool operator>=(const charT* lhs, const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20 | |
| 429 | 427 | |
| 430 | 428 | template<class charT, class traits, class Allocator> |
| 431 | 429 | void swap(basic_string<charT, traits, Allocator>& lhs, |
| 432 | 430 | basic_string<charT, traits, Allocator>& rhs) |
| 433 | noexcept(noexcept(lhs.swap(rhs))); | |
| 431 | noexcept(noexcept(lhs.swap(rhs))); // constexpr since C++20 | |
| 434 | 432 | |
| 435 | 433 | template<class charT, class traits, class Allocator> |
| 436 | 434 | basic_istream<charT, traits>& |
| ... | ... | @@ -508,45 +506,81 @@ template <> struct hash<u16string>; |
| 508 | 506 | template <> struct hash<u32string>; |
| 509 | 507 | template <> struct hash<wstring>; |
| 510 | 508 | |
| 511 | basic_string<char> operator "" s( const char *str, size_t len ); // C++14 | |
| 512 | basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14 | |
| 513 | basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20 | |
| 514 | basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14 | |
| 515 | basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14 | |
| 509 | basic_string<char> operator "" s( const char *str, size_t len ); // C++14, constexpr since C++20 | |
| 510 | basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++14, constexpr since C++20 | |
| 511 | constexpr basic_string<char8_t> operator "" s( const char8_t *str, size_t len ); // C++20 | |
| 512 | basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++14, constexpr since C++20 | |
| 513 | basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++14, constexpr since C++20 | |
| 516 | 514 | |
| 517 | 515 | } // std |
| 518 | 516 | |
| 519 | 517 | */ |
| 520 | 518 | |
| 519 | #include <__algorithm/max.h> | |
| 520 | #include <__algorithm/min.h> | |
| 521 | #include <__algorithm/remove.h> | |
| 522 | #include <__algorithm/remove_if.h> | |
| 523 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 521 | 524 | #include <__config> |
| 522 | 525 | #include <__debug> |
| 523 | #include <__functional_base> | |
| 526 | #include <__format/enable_insertable.h> | |
| 527 | #include <__functional/hash.h> | |
| 528 | #include <__functional/unary_function.h> | |
| 529 | #include <__ios/fpos.h> | |
| 530 | #include <__iterator/distance.h> | |
| 531 | #include <__iterator/iterator_traits.h> | |
| 532 | #include <__iterator/reverse_iterator.h> | |
| 524 | 533 | #include <__iterator/wrap_iter.h> |
| 525 | #include <algorithm> | |
| 526 | #include <compare> | |
| 534 | #include <__memory/allocate_at_least.h> | |
| 535 | #include <__memory/swap_allocator.h> | |
| 536 | #include <__string/char_traits.h> | |
| 537 | #include <__string/extern_template_lists.h> | |
| 538 | #include <__utility/auto_cast.h> | |
| 539 | #include <__utility/move.h> | |
| 540 | #include <__utility/swap.h> | |
| 541 | #include <__utility/unreachable.h> | |
| 542 | #include <climits> | |
| 543 | #include <cstdint> | |
| 527 | 544 | #include <cstdio> // EOF |
| 528 | 545 | #include <cstdlib> |
| 529 | 546 | #include <cstring> |
| 530 | #include <initializer_list> | |
| 531 | 547 | #include <iosfwd> |
| 532 | #include <iterator> | |
| 548 | #include <limits> | |
| 533 | 549 | #include <memory> |
| 534 | 550 | #include <stdexcept> |
| 535 | 551 | #include <string_view> |
| 536 | 552 | #include <type_traits> |
| 537 | #include <utility> | |
| 538 | 553 | #include <version> |
| 539 | 554 | |
| 540 | 555 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 541 | # include <cwchar> | |
| 556 | # include <cwchar> | |
| 542 | 557 | #endif |
| 543 | 558 | |
| 544 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 545 | # include <cstdint> | |
| 559 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 560 | # include <algorithm> | |
| 561 | # include <functional> | |
| 562 | # include <iterator> | |
| 563 | # include <new> | |
| 564 | # include <typeinfo> | |
| 565 | # include <utility> | |
| 566 | # include <vector> | |
| 546 | 567 | #endif |
| 547 | 568 | |
| 569 | // standard-mandated includes | |
| 570 | ||
| 571 | // [iterator.range] | |
| 572 | #include <__iterator/access.h> | |
| 573 | #include <__iterator/data.h> | |
| 574 | #include <__iterator/empty.h> | |
| 575 | #include <__iterator/reverse_access.h> | |
| 576 | #include <__iterator/size.h> | |
| 577 | ||
| 578 | // [string.syn] | |
| 579 | #include <compare> | |
| 580 | #include <initializer_list> | |
| 581 | ||
| 548 | 582 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 549 | #pragma GCC system_header | |
| 583 | # pragma GCC system_header | |
| 550 | 584 | #endif |
| 551 | 585 | |
| 552 | 586 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -555,68 +589,35 @@ _LIBCPP_PUSH_MACROS |
| 555 | 589 | |
| 556 | 590 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 557 | 591 | |
| 558 | // fpos | |
| 559 | ||
| 560 | template <class _StateT> | |
| 561 | class _LIBCPP_TEMPLATE_VIS fpos | |
| 562 | { | |
| 563 | private: | |
| 564 | _StateT __st_; | |
| 565 | streamoff __off_; | |
| 566 | public: | |
| 567 | _LIBCPP_INLINE_VISIBILITY fpos(streamoff __off = streamoff()) : __st_(), __off_(__off) {} | |
| 568 | ||
| 569 | _LIBCPP_INLINE_VISIBILITY operator streamoff() const {return __off_;} | |
| 570 | ||
| 571 | _LIBCPP_INLINE_VISIBILITY _StateT state() const {return __st_;} | |
| 572 | _LIBCPP_INLINE_VISIBILITY void state(_StateT __st) {__st_ = __st;} | |
| 573 | ||
| 574 | _LIBCPP_INLINE_VISIBILITY fpos& operator+=(streamoff __off) {__off_ += __off; return *this;} | |
| 575 | _LIBCPP_INLINE_VISIBILITY fpos operator+ (streamoff __off) const {fpos __t(*this); __t += __off; return __t;} | |
| 576 | _LIBCPP_INLINE_VISIBILITY fpos& operator-=(streamoff __off) {__off_ -= __off; return *this;} | |
| 577 | _LIBCPP_INLINE_VISIBILITY fpos operator- (streamoff __off) const {fpos __t(*this); __t -= __off; return __t;} | |
| 578 | }; | |
| 579 | ||
| 580 | template <class _StateT> | |
| 581 | inline _LIBCPP_INLINE_VISIBILITY | |
| 582 | streamoff operator-(const fpos<_StateT>& __x, const fpos<_StateT>& __y) | |
| 583 | {return streamoff(__x) - streamoff(__y);} | |
| 584 | ||
| 585 | template <class _StateT> | |
| 586 | inline _LIBCPP_INLINE_VISIBILITY | |
| 587 | bool operator==(const fpos<_StateT>& __x, const fpos<_StateT>& __y) | |
| 588 | {return streamoff(__x) == streamoff(__y);} | |
| 589 | ||
| 590 | template <class _StateT> | |
| 591 | inline _LIBCPP_INLINE_VISIBILITY | |
| 592 | bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) | |
| 593 | {return streamoff(__x) != streamoff(__y);} | |
| 594 | ||
| 595 | 592 | // basic_string |
| 596 | 593 | |
| 597 | 594 | template<class _CharT, class _Traits, class _Allocator> |
| 598 | 595 | basic_string<_CharT, _Traits, _Allocator> |
| 596 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 599 | 597 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, |
| 600 | 598 | const basic_string<_CharT, _Traits, _Allocator>& __y); |
| 601 | 599 | |
| 602 | 600 | template<class _CharT, class _Traits, class _Allocator> |
| 601 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 603 | 602 | basic_string<_CharT, _Traits, _Allocator> |
| 604 | 603 | operator+(const _CharT* __x, const basic_string<_CharT,_Traits,_Allocator>& __y); |
| 605 | 604 | |
| 606 | 605 | template<class _CharT, class _Traits, class _Allocator> |
| 606 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 607 | 607 | basic_string<_CharT, _Traits, _Allocator> |
| 608 | 608 | operator+(_CharT __x, const basic_string<_CharT,_Traits,_Allocator>& __y); |
| 609 | 609 | |
| 610 | 610 | template<class _CharT, class _Traits, class _Allocator> |
| 611 | inline _LIBCPP_INLINE_VISIBILITY | |
| 611 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 612 | 612 | basic_string<_CharT, _Traits, _Allocator> |
| 613 | 613 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y); |
| 614 | 614 | |
| 615 | 615 | template<class _CharT, class _Traits, class _Allocator> |
| 616 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 616 | 617 | basic_string<_CharT, _Traits, _Allocator> |
| 617 | 618 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); |
| 618 | 619 | |
| 619 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) | |
| 620 | extern template _LIBCPP_FUNC_VIS string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&); | |
| 620 | 621 | |
| 621 | 622 | template <class _Iter> |
| 622 | 623 | struct __string_is_trivial_iterator : public false_type {}; |
| ... | ... | @@ -635,29 +636,13 @@ struct __can_be_converted_to_string_view : public _BoolConstant< |
| 635 | 636 | !is_convertible<const _Tp&, const _CharT*>::value |
| 636 | 637 | > {}; |
| 637 | 638 | |
| 638 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 639 | ||
| 640 | template <class _CharT, size_t = sizeof(_CharT)> | |
| 641 | struct __padding | |
| 642 | { | |
| 643 | unsigned char __xx[sizeof(_CharT)-1]; | |
| 644 | }; | |
| 645 | ||
| 646 | template <class _CharT> | |
| 647 | struct __padding<_CharT, 1> | |
| 648 | { | |
| 649 | }; | |
| 650 | ||
| 651 | #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 652 | ||
| 653 | 639 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 654 | 640 | typedef basic_string<char8_t> u8string; |
| 655 | 641 | #endif |
| 656 | ||
| 657 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 658 | 642 | typedef basic_string<char16_t> u16string; |
| 659 | 643 | typedef basic_string<char32_t> u32string; |
| 660 | #endif | |
| 644 | ||
| 645 | struct __uninitialized_size_tag {}; | |
| 661 | 646 | |
| 662 | 647 | template<class _CharT, class _Traits, class _Allocator> |
| 663 | 648 | class |
| ... | ... | @@ -665,10 +650,8 @@ class |
| 665 | 650 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 666 | 651 | _LIBCPP_PREFERRED_NAME(u8string) |
| 667 | 652 | #endif |
| 668 | #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS | |
| 669 | 653 | _LIBCPP_PREFERRED_NAME(u16string) |
| 670 | 654 | _LIBCPP_PREFERRED_NAME(u32string) |
| 671 | #endif | |
| 672 | 655 | basic_string |
| 673 | 656 | { |
| 674 | 657 | public: |
| ... | ... | @@ -695,10 +678,11 @@ public: |
| 695 | 678 | |
| 696 | 679 | typedef __wrap_iter<pointer> iterator; |
| 697 | 680 | typedef __wrap_iter<const_pointer> const_iterator; |
| 698 | typedef _VSTD::reverse_iterator<iterator> reverse_iterator; | |
| 699 | typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 681 | typedef std::reverse_iterator<iterator> reverse_iterator; | |
| 682 | typedef std::reverse_iterator<const_iterator> const_reverse_iterator; | |
| 700 | 683 | |
| 701 | 684 | private: |
| 685 | static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); | |
| 702 | 686 | |
| 703 | 687 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
| 704 | 688 | |
| ... | ... | @@ -706,62 +690,79 @@ private: |
| 706 | 690 | { |
| 707 | 691 | pointer __data_; |
| 708 | 692 | size_type __size_; |
| 709 | size_type __cap_; | |
| 693 | size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; | |
| 694 | size_type __is_long_ : 1; | |
| 710 | 695 | }; |
| 711 | 696 | |
| 712 | #ifdef _LIBCPP_BIG_ENDIAN | |
| 713 | static const size_type __short_mask = 0x01; | |
| 714 | static const size_type __long_mask = 0x1ul; | |
| 715 | #else // _LIBCPP_BIG_ENDIAN | |
| 716 | static const size_type __short_mask = 0x80; | |
| 717 | static const size_type __long_mask = ~(size_type(~0) >> 1); | |
| 718 | #endif // _LIBCPP_BIG_ENDIAN | |
| 719 | ||
| 720 | 697 | enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? |
| 721 | 698 | (sizeof(__long) - 1)/sizeof(value_type) : 2}; |
| 722 | 699 | |
| 723 | 700 | struct __short |
| 724 | 701 | { |
| 725 | 702 | value_type __data_[__min_cap]; |
| 726 | struct | |
| 727 | : __padding<value_type> | |
| 728 | { | |
| 729 | unsigned char __size_; | |
| 730 | }; | |
| 703 | unsigned char __padding_[sizeof(value_type) - 1]; | |
| 704 | unsigned char __size_ : 7; | |
| 705 | unsigned char __is_long_ : 1; | |
| 731 | 706 | }; |
| 732 | 707 | |
| 708 | // The __endian_factor is required because the field we use to store the size | |
| 709 | // has one fewer bit than it would if it were not a bitfield. | |
| 710 | // | |
| 711 | // If the LSB is used to store the short-flag in the short string representation, | |
| 712 | // we have to multiply the size by two when it is stored and divide it by two when | |
| 713 | // it is loaded to make sure that we always store an even number. In the long string | |
| 714 | // representation, we can ignore this because we can assume that we always allocate | |
| 715 | // an even amount of value_types. | |
| 716 | // | |
| 717 | // If the MSB is used for the short-flag, the max_size() is numeric_limits<size_type>::max() / 2. | |
| 718 | // This does not impact the short string representation, since we never need the MSB | |
| 719 | // for representing the size of a short string anyway. | |
| 720 | ||
| 721 | #ifdef _LIBCPP_BIG_ENDIAN | |
| 722 | static const size_type __endian_factor = 2; | |
| 733 | 723 | #else |
| 724 | static const size_type __endian_factor = 1; | |
| 725 | #endif | |
| 734 | 726 | |
| 727 | #else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 728 | ||
| 729 | #ifdef _LIBCPP_BIG_ENDIAN | |
| 730 | static const size_type __endian_factor = 1; | |
| 731 | #else | |
| 732 | static const size_type __endian_factor = 2; | |
| 733 | #endif | |
| 734 | ||
| 735 | // Attribute 'packed' is used to keep the layout compatible with the | |
| 736 | // previous definition that did not use bit fields. This is because on | |
| 737 | // some platforms bit fields have a default size rather than the actual | |
| 738 | // size used, e.g., it is 4 bytes on AIX. See D128285 for details. | |
| 735 | 739 | struct __long |
| 736 | 740 | { |
| 737 | size_type __cap_; | |
| 741 | struct _LIBCPP_PACKED { | |
| 742 | size_type __is_long_ : 1; | |
| 743 | size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; | |
| 744 | }; | |
| 738 | 745 | size_type __size_; |
| 739 | 746 | pointer __data_; |
| 740 | 747 | }; |
| 741 | 748 | |
| 742 | #ifdef _LIBCPP_BIG_ENDIAN | |
| 743 | static const size_type __short_mask = 0x80; | |
| 744 | static const size_type __long_mask = ~(size_type(~0) >> 1); | |
| 745 | #else // _LIBCPP_BIG_ENDIAN | |
| 746 | static const size_type __short_mask = 0x01; | |
| 747 | static const size_type __long_mask = 0x1ul; | |
| 748 | #endif // _LIBCPP_BIG_ENDIAN | |
| 749 | ||
| 750 | 749 | enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ? |
| 751 | 750 | (sizeof(__long) - 1)/sizeof(value_type) : 2}; |
| 752 | 751 | |
| 753 | 752 | struct __short |
| 754 | 753 | { |
| 755 | union | |
| 756 | { | |
| 757 | unsigned char __size_; | |
| 758 | value_type __lx; | |
| 754 | struct _LIBCPP_PACKED { | |
| 755 | unsigned char __is_long_ : 1; | |
| 756 | unsigned char __size_ : 7; | |
| 759 | 757 | }; |
| 758 | char __padding_[sizeof(value_type) - 1]; | |
| 760 | 759 | value_type __data_[__min_cap]; |
| 761 | 760 | }; |
| 762 | 761 | |
| 763 | 762 | #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT |
| 764 | 763 | |
| 764 | static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size."); | |
| 765 | ||
| 765 | 766 | union __ulx{__long __lx; __short __lxx;}; |
| 766 | 767 | |
| 767 | 768 | enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; |
| ... | ... | @@ -783,25 +784,47 @@ private: |
| 783 | 784 | |
| 784 | 785 | __compressed_pair<__rep, allocator_type> __r_; |
| 785 | 786 | |
| 787 | // Construct a string with the given allocator and enough storage to hold `__size` characters, but | |
| 788 | // don't initialize the characters. The contents of the string, including the null terminator, must be | |
| 789 | // initialized separately. | |
| 790 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 791 | explicit basic_string(__uninitialized_size_tag, size_type __size, const allocator_type& __a) | |
| 792 | : __r_(__default_init_tag(), __a) { | |
| 793 | if (__size > max_size()) | |
| 794 | __throw_length_error(); | |
| 795 | if (__fits_in_sso(__size)) { | |
| 796 | __zero(); | |
| 797 | __set_short_size(__size); | |
| 798 | } else { | |
| 799 | auto __capacity = __recommend(__size) + 1; | |
| 800 | auto __allocation = __alloc_traits::allocate(__alloc(), __capacity); | |
| 801 | __begin_lifetime(__allocation, __capacity); | |
| 802 | __set_long_cap(__capacity); | |
| 803 | __set_long_pointer(__allocation); | |
| 804 | __set_long_size(__size); | |
| 805 | } | |
| 806 | std::__debug_db_insert_c(this); | |
| 807 | } | |
| 808 | ||
| 786 | 809 | public: |
| 787 | 810 | _LIBCPP_TEMPLATE_DATA_VIS |
| 788 | 811 | static const size_type npos = -1; |
| 789 | 812 | |
| 790 | _LIBCPP_INLINE_VISIBILITY basic_string() | |
| 813 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string() | |
| 791 | 814 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); |
| 792 | 815 | |
| 793 | _LIBCPP_INLINE_VISIBILITY explicit basic_string(const allocator_type& __a) | |
| 816 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit basic_string(const allocator_type& __a) | |
| 794 | 817 | #if _LIBCPP_STD_VER <= 14 |
| 795 | 818 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); |
| 796 | 819 | #else |
| 797 | 820 | _NOEXCEPT; |
| 798 | 821 | #endif |
| 799 | 822 | |
| 800 | basic_string(const basic_string& __str); | |
| 801 | basic_string(const basic_string& __str, const allocator_type& __a); | |
| 823 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str); | |
| 824 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string(const basic_string& __str, const allocator_type& __a); | |
| 802 | 825 | |
| 803 | 826 | #ifndef _LIBCPP_CXX03_LANG |
| 804 | _LIBCPP_INLINE_VISIBILITY | |
| 827 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 805 | 828 | basic_string(basic_string&& __str) |
| 806 | 829 | #if _LIBCPP_STD_VER <= 14 |
| 807 | 830 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
| ... | ... | @@ -809,218 +832,221 @@ public: |
| 809 | 832 | _NOEXCEPT; |
| 810 | 833 | #endif |
| 811 | 834 | |
| 812 | _LIBCPP_INLINE_VISIBILITY | |
| 835 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 813 | 836 | basic_string(basic_string&& __str, const allocator_type& __a); |
| 814 | 837 | #endif // _LIBCPP_CXX03_LANG |
| 815 | 838 | |
| 816 | 839 | template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> > |
| 817 | _LIBCPP_INLINE_VISIBILITY | |
| 840 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 818 | 841 | basic_string(const _CharT* __s) : __r_(__default_init_tag(), __default_init_tag()) { |
| 819 | 842 | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); |
| 820 | 843 | __init(__s, traits_type::length(__s)); |
| 821 | _VSTD::__debug_db_insert_c(this); | |
| 844 | std::__debug_db_insert_c(this); | |
| 822 | 845 | } |
| 823 | 846 | |
| 824 | 847 | template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> > |
| 825 | _LIBCPP_INLINE_VISIBILITY | |
| 848 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 826 | 849 | basic_string(const _CharT* __s, const _Allocator& __a); |
| 827 | 850 | |
| 828 | 851 | #if _LIBCPP_STD_VER > 20 |
| 829 | 852 | basic_string(nullptr_t) = delete; |
| 830 | 853 | #endif |
| 831 | 854 | |
| 832 | _LIBCPP_INLINE_VISIBILITY | |
| 855 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 833 | 856 | basic_string(const _CharT* __s, size_type __n); |
| 834 | _LIBCPP_INLINE_VISIBILITY | |
| 857 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 835 | 858 | basic_string(const _CharT* __s, size_type __n, const _Allocator& __a); |
| 836 | _LIBCPP_INLINE_VISIBILITY | |
| 859 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 837 | 860 | basic_string(size_type __n, _CharT __c); |
| 838 | 861 | |
| 839 | 862 | template <class = __enable_if_t<__is_allocator<_Allocator>::value, nullptr_t> > |
| 840 | _LIBCPP_INLINE_VISIBILITY | |
| 863 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 841 | 864 | basic_string(size_type __n, _CharT __c, const _Allocator& __a); |
| 842 | 865 | |
| 866 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 843 | 867 | basic_string(const basic_string& __str, size_type __pos, size_type __n, |
| 844 | 868 | const _Allocator& __a = _Allocator()); |
| 845 | _LIBCPP_INLINE_VISIBILITY | |
| 869 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 846 | 870 | basic_string(const basic_string& __str, size_type __pos, |
| 847 | 871 | const _Allocator& __a = _Allocator()); |
| 848 | 872 | |
| 849 | 873 | template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > |
| 850 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 874 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 851 | 875 | basic_string(const _Tp& __t, size_type __pos, size_type __n, |
| 852 | 876 | const allocator_type& __a = allocator_type()); |
| 853 | 877 | |
| 854 | 878 | template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && |
| 855 | 879 | !__is_same_uncvref<_Tp, basic_string>::value> > |
| 856 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 880 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 857 | 881 | explicit basic_string(const _Tp& __t); |
| 858 | 882 | |
| 859 | 883 | template<class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > |
| 860 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 884 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 861 | 885 | explicit basic_string(const _Tp& __t, const allocator_type& __a); |
| 862 | 886 | |
| 863 | 887 | template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> > |
| 864 | _LIBCPP_INLINE_VISIBILITY | |
| 888 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 865 | 889 | basic_string(_InputIterator __first, _InputIterator __last); |
| 866 | 890 | template<class _InputIterator, class = __enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value> > |
| 867 | _LIBCPP_INLINE_VISIBILITY | |
| 891 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 868 | 892 | basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a); |
| 869 | 893 | #ifndef _LIBCPP_CXX03_LANG |
| 870 | _LIBCPP_INLINE_VISIBILITY | |
| 894 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 871 | 895 | basic_string(initializer_list<_CharT> __il); |
| 872 | _LIBCPP_INLINE_VISIBILITY | |
| 896 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 873 | 897 | basic_string(initializer_list<_CharT> __il, const _Allocator& __a); |
| 874 | 898 | #endif // _LIBCPP_CXX03_LANG |
| 875 | 899 | |
| 876 | inline ~basic_string(); | |
| 900 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 ~basic_string(); | |
| 877 | 901 | |
| 878 | _LIBCPP_INLINE_VISIBILITY | |
| 902 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 879 | 903 | operator __self_view() const _NOEXCEPT { return __self_view(data(), size()); } |
| 880 | 904 | |
| 881 | basic_string& operator=(const basic_string& __str); | |
| 905 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const basic_string& __str); | |
| 882 | 906 | |
| 883 | template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value> > | |
| 884 | basic_string& operator=(const _Tp& __t) | |
| 885 | {__self_view __sv = __t; return assign(__sv);} | |
| 907 | template <class _Tp, class = __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && | |
| 908 | !__is_same_uncvref<_Tp, basic_string>::value> > | |
| 909 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(const _Tp& __t) { | |
| 910 | __self_view __sv = __t; | |
| 911 | return assign(__sv); | |
| 912 | } | |
| 886 | 913 | |
| 887 | 914 | #ifndef _LIBCPP_CXX03_LANG |
| 888 | _LIBCPP_INLINE_VISIBILITY | |
| 915 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 889 | 916 | basic_string& operator=(basic_string&& __str) |
| 890 | 917 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); |
| 891 | _LIBCPP_INLINE_VISIBILITY | |
| 918 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 892 | 919 | basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} |
| 893 | 920 | #endif |
| 894 | _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} | |
| 921 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 922 | basic_string& operator=(const value_type* __s) {return assign(__s);} | |
| 895 | 923 | #if _LIBCPP_STD_VER > 20 |
| 896 | 924 | basic_string& operator=(nullptr_t) = delete; |
| 897 | 925 | #endif |
| 898 | basic_string& operator=(value_type __c); | |
| 926 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator=(value_type __c); | |
| 899 | 927 | |
| 900 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 901 | _LIBCPP_INLINE_VISIBILITY | |
| 928 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 902 | 929 | iterator begin() _NOEXCEPT |
| 903 | 930 | {return iterator(this, __get_pointer());} |
| 904 | _LIBCPP_INLINE_VISIBILITY | |
| 931 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 905 | 932 | const_iterator begin() const _NOEXCEPT |
| 906 | 933 | {return const_iterator(this, __get_pointer());} |
| 907 | _LIBCPP_INLINE_VISIBILITY | |
| 934 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 908 | 935 | iterator end() _NOEXCEPT |
| 909 | 936 | {return iterator(this, __get_pointer() + size());} |
| 910 | _LIBCPP_INLINE_VISIBILITY | |
| 937 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 911 | 938 | const_iterator end() const _NOEXCEPT |
| 912 | 939 | {return const_iterator(this, __get_pointer() + size());} |
| 913 | #else | |
| 914 | _LIBCPP_INLINE_VISIBILITY | |
| 915 | iterator begin() _NOEXCEPT | |
| 916 | {return iterator(__get_pointer());} | |
| 917 | _LIBCPP_INLINE_VISIBILITY | |
| 918 | const_iterator begin() const _NOEXCEPT | |
| 919 | {return const_iterator(__get_pointer());} | |
| 920 | _LIBCPP_INLINE_VISIBILITY | |
| 921 | iterator end() _NOEXCEPT | |
| 922 | {return iterator(__get_pointer() + size());} | |
| 923 | _LIBCPP_INLINE_VISIBILITY | |
| 924 | const_iterator end() const _NOEXCEPT | |
| 925 | {return const_iterator(__get_pointer() + size());} | |
| 926 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 927 | _LIBCPP_INLINE_VISIBILITY | |
| 940 | ||
| 941 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 928 | 942 | reverse_iterator rbegin() _NOEXCEPT |
| 929 | 943 | {return reverse_iterator(end());} |
| 930 | _LIBCPP_INLINE_VISIBILITY | |
| 944 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 931 | 945 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 932 | 946 | {return const_reverse_iterator(end());} |
| 933 | _LIBCPP_INLINE_VISIBILITY | |
| 947 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 934 | 948 | reverse_iterator rend() _NOEXCEPT |
| 935 | 949 | {return reverse_iterator(begin());} |
| 936 | _LIBCPP_INLINE_VISIBILITY | |
| 950 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 937 | 951 | const_reverse_iterator rend() const _NOEXCEPT |
| 938 | 952 | {return const_reverse_iterator(begin());} |
| 939 | 953 | |
| 940 | _LIBCPP_INLINE_VISIBILITY | |
| 954 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 941 | 955 | const_iterator cbegin() const _NOEXCEPT |
| 942 | 956 | {return begin();} |
| 943 | _LIBCPP_INLINE_VISIBILITY | |
| 957 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 944 | 958 | const_iterator cend() const _NOEXCEPT |
| 945 | 959 | {return end();} |
| 946 | _LIBCPP_INLINE_VISIBILITY | |
| 960 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 947 | 961 | const_reverse_iterator crbegin() const _NOEXCEPT |
| 948 | 962 | {return rbegin();} |
| 949 | _LIBCPP_INLINE_VISIBILITY | |
| 963 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 950 | 964 | const_reverse_iterator crend() const _NOEXCEPT |
| 951 | 965 | {return rend();} |
| 952 | 966 | |
| 953 | _LIBCPP_INLINE_VISIBILITY size_type size() const _NOEXCEPT | |
| 967 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type size() const _NOEXCEPT | |
| 954 | 968 | {return __is_long() ? __get_long_size() : __get_short_size();} |
| 955 | _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} | |
| 956 | _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; | |
| 957 | _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT | |
| 958 | {return (__is_long() ? __get_long_cap() | |
| 959 | : static_cast<size_type>(__min_cap)) - 1;} | |
| 969 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type length() const _NOEXCEPT {return size();} | |
| 970 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; | |
| 971 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type capacity() const _NOEXCEPT { | |
| 972 | return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1; | |
| 973 | } | |
| 960 | 974 | |
| 961 | void resize(size_type __n, value_type __c); | |
| 962 | _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} | |
| 975 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n, value_type __c); | |
| 976 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __n) { resize(__n, value_type()); } | |
| 963 | 977 | |
| 964 | void reserve(size_type __requested_capacity); | |
| 978 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __requested_capacity); | |
| 965 | 979 | |
| 966 | 980 | #if _LIBCPP_STD_VER > 20 |
| 967 | 981 | template <class _Op> |
| 968 | 982 | _LIBCPP_HIDE_FROM_ABI constexpr |
| 969 | 983 | void resize_and_overwrite(size_type __n, _Op __op) { |
| 970 | 984 | __resize_default_init(__n); |
| 971 | __erase_to_end(_VSTD::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); | |
| 985 | __erase_to_end(std::move(__op)(data(), _LIBCPP_AUTO_CAST(__n))); | |
| 972 | 986 | } |
| 973 | 987 | #endif |
| 974 | 988 | |
| 975 | _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n); | |
| 989 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __resize_default_init(size_type __n); | |
| 976 | 990 | |
| 977 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_INLINE_VISIBILITY | |
| 978 | void reserve() _NOEXCEPT {shrink_to_fit();} | |
| 979 | _LIBCPP_INLINE_VISIBILITY | |
| 980 | void shrink_to_fit() _NOEXCEPT; | |
| 981 | _LIBCPP_INLINE_VISIBILITY | |
| 982 | void clear() _NOEXCEPT; | |
| 983 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 991 | _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve() _NOEXCEPT { shrink_to_fit(); } | |
| 992 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; | |
| 993 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void clear() _NOEXCEPT; | |
| 994 | ||
| 995 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 984 | 996 | bool empty() const _NOEXCEPT {return size() == 0;} |
| 985 | 997 | |
| 986 | _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __pos) const _NOEXCEPT; | |
| 987 | _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __pos) _NOEXCEPT; | |
| 998 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 999 | const_reference operator[](size_type __pos) const _NOEXCEPT; | |
| 1000 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __pos) _NOEXCEPT; | |
| 988 | 1001 | |
| 989 | const_reference at(size_type __n) const; | |
| 990 | reference at(size_type __n); | |
| 1002 | _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const; | |
| 1003 | _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n); | |
| 991 | 1004 | |
| 992 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const basic_string& __str) {return append(__str);} | |
| 1005 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const basic_string& __str) { | |
| 1006 | return append(__str); | |
| 1007 | } | |
| 993 | 1008 | |
| 994 | 1009 | template <class _Tp> |
| 995 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1010 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 996 | 1011 | __enable_if_t |
| 997 | 1012 | < |
| 998 | 1013 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 999 | 1014 | && !__is_same_uncvref<_Tp, basic_string >::value, |
| 1000 | 1015 | basic_string& |
| 1001 | 1016 | > |
| 1002 | operator+=(const _Tp& __t) {__self_view __sv = __t; return append(__sv);} | |
| 1003 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(const value_type* __s) {return append(__s);} | |
| 1004 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(value_type __c) {push_back(__c); return *this;} | |
| 1017 | operator+=(const _Tp& __t) { | |
| 1018 | __self_view __sv = __t; return append(__sv); | |
| 1019 | } | |
| 1020 | ||
| 1021 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(const value_type* __s) { | |
| 1022 | return append(__s); | |
| 1023 | } | |
| 1024 | ||
| 1025 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& operator+=(value_type __c) { | |
| 1026 | push_back(__c); | |
| 1027 | return *this; | |
| 1028 | } | |
| 1029 | ||
| 1005 | 1030 | #ifndef _LIBCPP_CXX03_LANG |
| 1006 | _LIBCPP_INLINE_VISIBILITY basic_string& operator+=(initializer_list<value_type> __il) {return append(__il);} | |
| 1031 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1032 | basic_string& operator+=(initializer_list<value_type> __il) { return append(__il); } | |
| 1007 | 1033 | #endif // _LIBCPP_CXX03_LANG |
| 1008 | 1034 | |
| 1009 | _LIBCPP_INLINE_VISIBILITY | |
| 1035 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1010 | 1036 | basic_string& append(const basic_string& __str); |
| 1011 | 1037 | |
| 1012 | 1038 | template <class _Tp> |
| 1013 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1039 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1014 | 1040 | __enable_if_t< |
| 1015 | 1041 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| 1016 | 1042 | && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1017 | 1043 | basic_string& |
| 1018 | 1044 | > |
| 1019 | 1045 | append(const _Tp& __t) { __self_view __sv = __t; return append(__sv.data(), __sv.size()); } |
| 1020 | basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); | |
| 1046 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const basic_string& __str, size_type __pos, size_type __n=npos); | |
| 1021 | 1047 | |
| 1022 | 1048 | template <class _Tp> |
| 1023 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1049 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1024 | 1050 | __enable_if_t |
| 1025 | 1051 | < |
| 1026 | 1052 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| ... | ... | @@ -1028,11 +1054,11 @@ public: |
| 1028 | 1054 | basic_string& |
| 1029 | 1055 | > |
| 1030 | 1056 | append(const _Tp& __t, size_type __pos, size_type __n=npos); |
| 1031 | basic_string& append(const value_type* __s, size_type __n); | |
| 1032 | basic_string& append(const value_type* __s); | |
| 1033 | basic_string& append(size_type __n, value_type __c); | |
| 1057 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s, size_type __n); | |
| 1058 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(const value_type* __s); | |
| 1059 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& append(size_type __n, value_type __c); | |
| 1034 | 1060 | |
| 1035 | _LIBCPP_INLINE_VISIBILITY | |
| 1061 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1036 | 1062 | void __append_default_init(size_type __n); |
| 1037 | 1063 | |
| 1038 | 1064 | template<class _InputIterator> |
| ... | ... | @@ -1042,7 +1068,7 @@ public: |
| 1042 | 1068 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| 1043 | 1069 | basic_string& |
| 1044 | 1070 | > |
| 1045 | _LIBCPP_INLINE_VISIBILITY | |
| 1071 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1046 | 1072 | append(_InputIterator __first, _InputIterator __last) { |
| 1047 | 1073 | const basic_string __temp(__first, __last, __alloc()); |
| 1048 | 1074 | append(__temp.data(), __temp.size()); |
| ... | ... | @@ -1055,41 +1081,40 @@ public: |
| 1055 | 1081 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 1056 | 1082 | basic_string& |
| 1057 | 1083 | > |
| 1058 | _LIBCPP_INLINE_VISIBILITY | |
| 1084 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1059 | 1085 | append(_ForwardIterator __first, _ForwardIterator __last); |
| 1060 | 1086 | |
| 1061 | 1087 | #ifndef _LIBCPP_CXX03_LANG |
| 1062 | _LIBCPP_INLINE_VISIBILITY | |
| 1088 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1063 | 1089 | basic_string& append(initializer_list<value_type> __il) {return append(__il.begin(), __il.size());} |
| 1064 | 1090 | #endif // _LIBCPP_CXX03_LANG |
| 1065 | 1091 | |
| 1066 | void push_back(value_type __c); | |
| 1067 | _LIBCPP_INLINE_VISIBILITY | |
| 1068 | void pop_back(); | |
| 1069 | _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT; | |
| 1070 | _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT; | |
| 1071 | _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT; | |
| 1072 | _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT; | |
| 1092 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type __c); | |
| 1093 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back(); | |
| 1094 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() _NOEXCEPT; | |
| 1095 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const _NOEXCEPT; | |
| 1096 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() _NOEXCEPT; | |
| 1097 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const _NOEXCEPT; | |
| 1073 | 1098 | |
| 1074 | 1099 | template <class _Tp> |
| 1075 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1100 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1076 | 1101 | __enable_if_t |
| 1077 | 1102 | < |
| 1078 | 1103 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1079 | 1104 | basic_string& |
| 1080 | 1105 | > |
| 1081 | 1106 | assign(const _Tp & __t) { __self_view __sv = __t; return assign(__sv.data(), __sv.size()); } |
| 1082 | _LIBCPP_INLINE_VISIBILITY | |
| 1107 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1083 | 1108 | basic_string& assign(const basic_string& __str) { return *this = __str; } |
| 1084 | 1109 | #ifndef _LIBCPP_CXX03_LANG |
| 1085 | _LIBCPP_INLINE_VISIBILITY | |
| 1110 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1086 | 1111 | basic_string& assign(basic_string&& __str) |
| 1087 | 1112 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) |
| 1088 | {*this = _VSTD::move(__str); return *this;} | |
| 1113 | {*this = std::move(__str); return *this;} | |
| 1089 | 1114 | #endif |
| 1090 | basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); | |
| 1115 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); | |
| 1091 | 1116 | template <class _Tp> |
| 1092 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1117 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1093 | 1118 | __enable_if_t |
| 1094 | 1119 | < |
| 1095 | 1120 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| ... | ... | @@ -1097,11 +1122,11 @@ public: |
| 1097 | 1122 | basic_string& |
| 1098 | 1123 | > |
| 1099 | 1124 | assign(const _Tp & __t, size_type __pos, size_type __n=npos); |
| 1100 | basic_string& assign(const value_type* __s, size_type __n); | |
| 1101 | basic_string& assign(const value_type* __s); | |
| 1102 | basic_string& assign(size_type __n, value_type __c); | |
| 1125 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s, size_type __n); | |
| 1126 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(const value_type* __s); | |
| 1127 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& assign(size_type __n, value_type __c); | |
| 1103 | 1128 | template<class _InputIterator> |
| 1104 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1129 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1105 | 1130 | __enable_if_t |
| 1106 | 1131 | < |
| 1107 | 1132 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| ... | ... | @@ -1109,7 +1134,7 @@ public: |
| 1109 | 1134 | > |
| 1110 | 1135 | assign(_InputIterator __first, _InputIterator __last); |
| 1111 | 1136 | template<class _ForwardIterator> |
| 1112 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1137 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1113 | 1138 | __enable_if_t |
| 1114 | 1139 | < |
| 1115 | 1140 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -1117,15 +1142,15 @@ public: |
| 1117 | 1142 | > |
| 1118 | 1143 | assign(_ForwardIterator __first, _ForwardIterator __last); |
| 1119 | 1144 | #ifndef _LIBCPP_CXX03_LANG |
| 1120 | _LIBCPP_INLINE_VISIBILITY | |
| 1145 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1121 | 1146 | basic_string& assign(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} |
| 1122 | 1147 | #endif // _LIBCPP_CXX03_LANG |
| 1123 | 1148 | |
| 1124 | _LIBCPP_INLINE_VISIBILITY | |
| 1149 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1125 | 1150 | basic_string& insert(size_type __pos1, const basic_string& __str); |
| 1126 | 1151 | |
| 1127 | 1152 | template <class _Tp> |
| 1128 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1153 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1129 | 1154 | __enable_if_t |
| 1130 | 1155 | < |
| 1131 | 1156 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -1135,22 +1160,23 @@ public: |
| 1135 | 1160 | { __self_view __sv = __t; return insert(__pos1, __sv.data(), __sv.size()); } |
| 1136 | 1161 | |
| 1137 | 1162 | template <class _Tp> |
| 1138 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1163 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1139 | 1164 | __enable_if_t |
| 1140 | 1165 | < |
| 1141 | 1166 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1142 | 1167 | basic_string& |
| 1143 | 1168 | > |
| 1144 | 1169 | insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n=npos); |
| 1170 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1145 | 1171 | basic_string& insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n=npos); |
| 1146 | basic_string& insert(size_type __pos, const value_type* __s, size_type __n); | |
| 1147 | basic_string& insert(size_type __pos, const value_type* __s); | |
| 1148 | basic_string& insert(size_type __pos, size_type __n, value_type __c); | |
| 1149 | iterator insert(const_iterator __pos, value_type __c); | |
| 1150 | _LIBCPP_INLINE_VISIBILITY | |
| 1172 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s, size_type __n); | |
| 1173 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, const value_type* __s); | |
| 1174 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& insert(size_type __pos, size_type __n, value_type __c); | |
| 1175 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __pos, value_type __c); | |
| 1176 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1151 | 1177 | iterator insert(const_iterator __pos, size_type __n, value_type __c); |
| 1152 | 1178 | template<class _InputIterator> |
| 1153 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1179 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1154 | 1180 | __enable_if_t |
| 1155 | 1181 | < |
| 1156 | 1182 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| ... | ... | @@ -1158,7 +1184,7 @@ public: |
| 1158 | 1184 | > |
| 1159 | 1185 | insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); |
| 1160 | 1186 | template<class _ForwardIterator> |
| 1161 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1187 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1162 | 1188 | __enable_if_t |
| 1163 | 1189 | < |
| 1164 | 1190 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -1166,45 +1192,47 @@ public: |
| 1166 | 1192 | > |
| 1167 | 1193 | insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); |
| 1168 | 1194 | #ifndef _LIBCPP_CXX03_LANG |
| 1169 | _LIBCPP_INLINE_VISIBILITY | |
| 1195 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1170 | 1196 | iterator insert(const_iterator __pos, initializer_list<value_type> __il) |
| 1171 | 1197 | {return insert(__pos, __il.begin(), __il.end());} |
| 1172 | 1198 | #endif // _LIBCPP_CXX03_LANG |
| 1173 | 1199 | |
| 1174 | basic_string& erase(size_type __pos = 0, size_type __n = npos); | |
| 1175 | _LIBCPP_INLINE_VISIBILITY | |
| 1200 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& erase(size_type __pos = 0, size_type __n = npos); | |
| 1201 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1176 | 1202 | iterator erase(const_iterator __pos); |
| 1177 | _LIBCPP_INLINE_VISIBILITY | |
| 1203 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1178 | 1204 | iterator erase(const_iterator __first, const_iterator __last); |
| 1179 | 1205 | |
| 1180 | _LIBCPP_INLINE_VISIBILITY | |
| 1206 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1181 | 1207 | basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str); |
| 1182 | 1208 | |
| 1183 | 1209 | template <class _Tp> |
| 1184 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1210 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1185 | 1211 | __enable_if_t |
| 1186 | 1212 | < |
| 1187 | 1213 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1188 | 1214 | basic_string& |
| 1189 | 1215 | > |
| 1190 | 1216 | replace(size_type __pos1, size_type __n1, const _Tp& __t) { __self_view __sv = __t; return replace(__pos1, __n1, __sv.data(), __sv.size()); } |
| 1217 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1191 | 1218 | basic_string& replace(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos); |
| 1192 | 1219 | template <class _Tp> |
| 1193 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1220 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1194 | 1221 | __enable_if_t |
| 1195 | 1222 | < |
| 1196 | 1223 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1197 | 1224 | basic_string& |
| 1198 | 1225 | > |
| 1199 | 1226 | replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos); |
| 1227 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1200 | 1228 | basic_string& replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2); |
| 1201 | basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); | |
| 1202 | basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); | |
| 1203 | _LIBCPP_INLINE_VISIBILITY | |
| 1229 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, const value_type* __s); | |
| 1230 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& replace(size_type __pos, size_type __n1, size_type __n2, value_type __c); | |
| 1231 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1204 | 1232 | basic_string& replace(const_iterator __i1, const_iterator __i2, const basic_string& __str); |
| 1205 | 1233 | |
| 1206 | 1234 | template <class _Tp> |
| 1207 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1235 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1208 | 1236 | __enable_if_t |
| 1209 | 1237 | < |
| 1210 | 1238 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -1212,14 +1240,14 @@ public: |
| 1212 | 1240 | > |
| 1213 | 1241 | replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) { __self_view __sv = __t; return replace(__i1 - begin(), __i2 - __i1, __sv); } |
| 1214 | 1242 | |
| 1215 | _LIBCPP_INLINE_VISIBILITY | |
| 1243 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1216 | 1244 | basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n); |
| 1217 | _LIBCPP_INLINE_VISIBILITY | |
| 1245 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1218 | 1246 | basic_string& replace(const_iterator __i1, const_iterator __i2, const value_type* __s); |
| 1219 | _LIBCPP_INLINE_VISIBILITY | |
| 1247 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1220 | 1248 | basic_string& replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c); |
| 1221 | 1249 | template<class _InputIterator> |
| 1222 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1250 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1223 | 1251 | __enable_if_t |
| 1224 | 1252 | < |
| 1225 | 1253 | __is_cpp17_input_iterator<_InputIterator>::value, |
| ... | ... | @@ -1227,16 +1255,16 @@ public: |
| 1227 | 1255 | > |
| 1228 | 1256 | replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2); |
| 1229 | 1257 | #ifndef _LIBCPP_CXX03_LANG |
| 1230 | _LIBCPP_INLINE_VISIBILITY | |
| 1258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1231 | 1259 | basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<value_type> __il) |
| 1232 | 1260 | {return replace(__i1, __i2, __il.begin(), __il.end());} |
| 1233 | 1261 | #endif // _LIBCPP_CXX03_LANG |
| 1234 | 1262 | |
| 1235 | size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; | |
| 1236 | _LIBCPP_INLINE_VISIBILITY | |
| 1263 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type copy(value_type* __s, size_type __n, size_type __pos = 0) const; | |
| 1264 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1237 | 1265 | basic_string substr(size_type __pos = 0, size_type __n = npos) const; |
| 1238 | 1266 | |
| 1239 | _LIBCPP_INLINE_VISIBILITY | |
| 1267 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1240 | 1268 | void swap(basic_string& __str) |
| 1241 | 1269 | #if _LIBCPP_STD_VER >= 14 |
| 1242 | 1270 | _NOEXCEPT; |
| ... | ... | @@ -1245,123 +1273,129 @@ public: |
| 1245 | 1273 | __is_nothrow_swappable<allocator_type>::value); |
| 1246 | 1274 | #endif |
| 1247 | 1275 | |
| 1248 | _LIBCPP_INLINE_VISIBILITY | |
| 1276 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1249 | 1277 | const value_type* c_str() const _NOEXCEPT {return data();} |
| 1250 | _LIBCPP_INLINE_VISIBILITY | |
| 1251 | const value_type* data() const _NOEXCEPT {return _VSTD::__to_address(__get_pointer());} | |
| 1278 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1279 | const value_type* data() const _NOEXCEPT {return std::__to_address(__get_pointer());} | |
| 1252 | 1280 | #if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY) |
| 1253 | _LIBCPP_INLINE_VISIBILITY | |
| 1254 | value_type* data() _NOEXCEPT {return _VSTD::__to_address(__get_pointer());} | |
| 1281 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1282 | value_type* data() _NOEXCEPT {return std::__to_address(__get_pointer());} | |
| 1255 | 1283 | #endif |
| 1256 | 1284 | |
| 1257 | _LIBCPP_INLINE_VISIBILITY | |
| 1285 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1258 | 1286 | allocator_type get_allocator() const _NOEXCEPT {return __alloc();} |
| 1259 | 1287 | |
| 1260 | _LIBCPP_INLINE_VISIBILITY | |
| 1288 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1261 | 1289 | size_type find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; |
| 1262 | 1290 | |
| 1263 | 1291 | template <class _Tp> |
| 1264 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1292 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1265 | 1293 | __enable_if_t |
| 1266 | 1294 | < |
| 1267 | 1295 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1268 | 1296 | size_type |
| 1269 | 1297 | > |
| 1270 | 1298 | find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; |
| 1299 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1271 | 1300 | size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1272 | _LIBCPP_INLINE_VISIBILITY | |
| 1301 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1273 | 1302 | size_type find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; |
| 1274 | size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; | |
| 1303 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT; | |
| 1275 | 1304 | |
| 1276 | _LIBCPP_INLINE_VISIBILITY | |
| 1305 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1277 | 1306 | size_type rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; |
| 1278 | 1307 | |
| 1279 | 1308 | template <class _Tp> |
| 1280 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1309 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1281 | 1310 | __enable_if_t |
| 1282 | 1311 | < |
| 1283 | 1312 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1284 | 1313 | size_type |
| 1285 | 1314 | > |
| 1286 | 1315 | rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; |
| 1316 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1287 | 1317 | size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1288 | _LIBCPP_INLINE_VISIBILITY | |
| 1318 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1289 | 1319 | size_type rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; |
| 1290 | size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; | |
| 1320 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT; | |
| 1291 | 1321 | |
| 1292 | _LIBCPP_INLINE_VISIBILITY | |
| 1322 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1293 | 1323 | size_type find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; |
| 1294 | 1324 | |
| 1295 | 1325 | template <class _Tp> |
| 1296 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1326 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1297 | 1327 | __enable_if_t |
| 1298 | 1328 | < |
| 1299 | 1329 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1300 | 1330 | size_type |
| 1301 | 1331 | > |
| 1302 | 1332 | find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT; |
| 1333 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1303 | 1334 | size_type find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1304 | _LIBCPP_INLINE_VISIBILITY | |
| 1335 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1305 | 1336 | size_type find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; |
| 1306 | _LIBCPP_INLINE_VISIBILITY | |
| 1337 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1307 | 1338 | size_type find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; |
| 1308 | 1339 | |
| 1309 | _LIBCPP_INLINE_VISIBILITY | |
| 1340 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1310 | 1341 | size_type find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; |
| 1311 | 1342 | |
| 1312 | 1343 | template <class _Tp> |
| 1313 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1344 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1314 | 1345 | __enable_if_t |
| 1315 | 1346 | < |
| 1316 | 1347 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1317 | 1348 | size_type |
| 1318 | 1349 | > |
| 1319 | 1350 | find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; |
| 1351 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1320 | 1352 | size_type find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1321 | _LIBCPP_INLINE_VISIBILITY | |
| 1353 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1322 | 1354 | size_type find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; |
| 1323 | _LIBCPP_INLINE_VISIBILITY | |
| 1355 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1324 | 1356 | size_type find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; |
| 1325 | 1357 | |
| 1326 | _LIBCPP_INLINE_VISIBILITY | |
| 1358 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1327 | 1359 | size_type find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT; |
| 1328 | 1360 | |
| 1329 | 1361 | template <class _Tp> |
| 1330 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1362 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1331 | 1363 | __enable_if_t |
| 1332 | 1364 | < |
| 1333 | 1365 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1334 | 1366 | size_type |
| 1335 | 1367 | > |
| 1336 | 1368 | find_first_not_of(const _Tp &__t, size_type __pos = 0) const _NOEXCEPT; |
| 1369 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1337 | 1370 | size_type find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1338 | _LIBCPP_INLINE_VISIBILITY | |
| 1371 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1339 | 1372 | size_type find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT; |
| 1340 | _LIBCPP_INLINE_VISIBILITY | |
| 1373 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1341 | 1374 | size_type find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT; |
| 1342 | 1375 | |
| 1343 | _LIBCPP_INLINE_VISIBILITY | |
| 1376 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1344 | 1377 | size_type find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT; |
| 1345 | 1378 | |
| 1346 | 1379 | template <class _Tp> |
| 1347 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1380 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1348 | 1381 | __enable_if_t |
| 1349 | 1382 | < |
| 1350 | 1383 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| 1351 | 1384 | size_type |
| 1352 | 1385 | > |
| 1353 | 1386 | find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT; |
| 1387 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1354 | 1388 | size_type find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT; |
| 1355 | _LIBCPP_INLINE_VISIBILITY | |
| 1389 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1356 | 1390 | size_type find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT; |
| 1357 | _LIBCPP_INLINE_VISIBILITY | |
| 1391 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1358 | 1392 | size_type find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT; |
| 1359 | 1393 | |
| 1360 | _LIBCPP_INLINE_VISIBILITY | |
| 1394 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1361 | 1395 | int compare(const basic_string& __str) const _NOEXCEPT; |
| 1362 | 1396 | |
| 1363 | 1397 | template <class _Tp> |
| 1364 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1398 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1365 | 1399 | __enable_if_t |
| 1366 | 1400 | < |
| 1367 | 1401 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -1370,7 +1404,7 @@ public: |
| 1370 | 1404 | compare(const _Tp &__t) const _NOEXCEPT; |
| 1371 | 1405 | |
| 1372 | 1406 | template <class _Tp> |
| 1373 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS | |
| 1407 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1374 | 1408 | __enable_if_t |
| 1375 | 1409 | < |
| 1376 | 1410 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -1378,199 +1412,243 @@ public: |
| 1378 | 1412 | > |
| 1379 | 1413 | compare(size_type __pos1, size_type __n1, const _Tp& __t) const; |
| 1380 | 1414 | |
| 1381 | _LIBCPP_INLINE_VISIBILITY | |
| 1415 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1382 | 1416 | int compare(size_type __pos1, size_type __n1, const basic_string& __str) const; |
| 1383 | int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2=npos) const; | |
| 1417 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1418 | int compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, | |
| 1419 | size_type __n2 = npos) const; | |
| 1384 | 1420 | |
| 1385 | 1421 | template <class _Tp> |
| 1386 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1422 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1387 | 1423 | __enable_if_t |
| 1388 | 1424 | < |
| 1389 | 1425 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string>::value, |
| 1390 | 1426 | int |
| 1391 | 1427 | > |
| 1392 | 1428 | compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2=npos) const; |
| 1393 | int compare(const value_type* __s) const _NOEXCEPT; | |
| 1394 | int compare(size_type __pos1, size_type __n1, const value_type* __s) const; | |
| 1429 | _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(const value_type* __s) const _NOEXCEPT; | |
| 1430 | _LIBCPP_CONSTEXPR_AFTER_CXX17 int compare(size_type __pos1, size_type __n1, const value_type* __s) const; | |
| 1431 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1395 | 1432 | int compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const; |
| 1396 | 1433 | |
| 1397 | 1434 | #if _LIBCPP_STD_VER > 17 |
| 1398 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1435 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1399 | 1436 | bool starts_with(__self_view __sv) const noexcept |
| 1400 | 1437 | { return __self_view(data(), size()).starts_with(__sv); } |
| 1401 | 1438 | |
| 1402 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1439 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1403 | 1440 | bool starts_with(value_type __c) const noexcept |
| 1404 | 1441 | { return !empty() && _Traits::eq(front(), __c); } |
| 1405 | 1442 | |
| 1406 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1443 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1407 | 1444 | bool starts_with(const value_type* __s) const noexcept |
| 1408 | 1445 | { return starts_with(__self_view(__s)); } |
| 1409 | 1446 | |
| 1410 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1447 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1411 | 1448 | bool ends_with(__self_view __sv) const noexcept |
| 1412 | 1449 | { return __self_view(data(), size()).ends_with( __sv); } |
| 1413 | 1450 | |
| 1414 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1451 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1415 | 1452 | bool ends_with(value_type __c) const noexcept |
| 1416 | 1453 | { return !empty() && _Traits::eq(back(), __c); } |
| 1417 | 1454 | |
| 1418 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1455 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1419 | 1456 | bool ends_with(const value_type* __s) const noexcept |
| 1420 | 1457 | { return ends_with(__self_view(__s)); } |
| 1421 | 1458 | #endif |
| 1422 | 1459 | |
| 1423 | 1460 | #if _LIBCPP_STD_VER > 20 |
| 1424 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1461 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1425 | 1462 | bool contains(__self_view __sv) const noexcept |
| 1426 | 1463 | { return __self_view(data(), size()).contains(__sv); } |
| 1427 | 1464 | |
| 1428 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1465 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1429 | 1466 | bool contains(value_type __c) const noexcept |
| 1430 | 1467 | { return __self_view(data(), size()).contains(__c); } |
| 1431 | 1468 | |
| 1432 | constexpr _LIBCPP_INLINE_VISIBILITY | |
| 1469 | constexpr _LIBCPP_HIDE_FROM_ABI | |
| 1433 | 1470 | bool contains(const value_type* __s) const |
| 1434 | 1471 | { return __self_view(data(), size()).contains(__s); } |
| 1435 | 1472 | #endif |
| 1436 | 1473 | |
| 1437 | _LIBCPP_INLINE_VISIBILITY bool __invariants() const; | |
| 1438 | ||
| 1439 | _LIBCPP_INLINE_VISIBILITY void __clear_and_shrink() _NOEXCEPT; | |
| 1440 | ||
| 1441 | _LIBCPP_INLINE_VISIBILITY void __shrink_or_extend(size_type __target_capacity); | |
| 1474 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; | |
| 1442 | 1475 | |
| 1443 | _LIBCPP_INLINE_VISIBILITY | |
| 1444 | bool __is_long() const _NOEXCEPT | |
| 1445 | {return bool(__r_.first().__s.__size_ & __short_mask);} | |
| 1476 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __clear_and_shrink() _NOEXCEPT; | |
| 1446 | 1477 | |
| 1447 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1478 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1448 | 1479 | |
| 1449 | 1480 | bool __dereferenceable(const const_iterator* __i) const; |
| 1450 | 1481 | bool __decrementable(const const_iterator* __i) const; |
| 1451 | 1482 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const; |
| 1452 | 1483 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; |
| 1453 | 1484 | |
| 1454 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1485 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1455 | 1486 | |
| 1456 | 1487 | 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); | |
| 1488 | template<class _Alloc> | |
| 1489 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1490 | bool friend operator==(const basic_string<char, char_traits<char>, _Alloc>& __lhs, | |
| 1491 | const basic_string<char, char_traits<char>, _Alloc>& __rhs) _NOEXCEPT; | |
| 1492 | ||
| 1493 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __shrink_or_extend(size_type __target_capacity); | |
| 1494 | ||
| 1495 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1496 | bool __is_long() const _NOEXCEPT { | |
| 1497 | if (__libcpp_is_constant_evaluated()) | |
| 1498 | return true; | |
| 1499 | return __r_.first().__s.__is_long_; | |
| 1460 | 1500 | } |
| 1461 | 1501 | |
| 1462 | _LIBCPP_INLINE_VISIBILITY | |
| 1463 | allocator_type& __alloc() _NOEXCEPT | |
| 1464 | {return __r_.second();} | |
| 1465 | _LIBCPP_INLINE_VISIBILITY | |
| 1466 | const allocator_type& __alloc() const _NOEXCEPT | |
| 1467 | {return __r_.second();} | |
| 1502 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __begin_lifetime(pointer __begin, size_type __n) { | |
| 1503 | #if _LIBCPP_STD_VER > 17 | |
| 1504 | if (__libcpp_is_constant_evaluated()) { | |
| 1505 | for (size_type __i = 0; __i != __n; ++__i) | |
| 1506 | std::construct_at(std::addressof(__begin[__i])); | |
| 1507 | } | |
| 1508 | #else | |
| 1509 | (void)__begin; | |
| 1510 | (void)__n; | |
| 1511 | #endif // _LIBCPP_STD_VER > 17 | |
| 1512 | } | |
| 1468 | 1513 | |
| 1469 | #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 1514 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __default_init() { | |
| 1515 | __zero(); | |
| 1516 | if (__libcpp_is_constant_evaluated()) { | |
| 1517 | size_type __sz = __recommend(0) + 1; | |
| 1518 | pointer __ptr = __alloc_traits::allocate(__alloc(), __sz); | |
| 1519 | __begin_lifetime(__ptr, __sz); | |
| 1520 | __set_long_pointer(__ptr); | |
| 1521 | __set_long_cap(__sz); | |
| 1522 | __set_long_size(0); | |
| 1523 | } | |
| 1524 | } | |
| 1470 | 1525 | |
| 1471 | _LIBCPP_INLINE_VISIBILITY | |
| 1472 | void __set_short_size(size_type __s) _NOEXCEPT | |
| 1473 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 1474 | {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} | |
| 1475 | # else | |
| 1476 | {__r_.first().__s.__size_ = (unsigned char)(__s);} | |
| 1477 | # endif | |
| 1526 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __deallocate_constexpr() { | |
| 1527 | if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr) | |
| 1528 | __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap()); | |
| 1529 | } | |
| 1478 | 1530 | |
| 1479 | _LIBCPP_INLINE_VISIBILITY | |
| 1480 | size_type __get_short_size() const _NOEXCEPT | |
| 1481 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 1482 | {return __r_.first().__s.__size_ >> 1;} | |
| 1483 | # else | |
| 1484 | {return __r_.first().__s.__size_;} | |
| 1485 | # endif | |
| 1531 | _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { | |
| 1532 | // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly | |
| 1533 | return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); | |
| 1534 | } | |
| 1535 | ||
| 1536 | template <class _ForwardIterator> | |
| 1537 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 1538 | iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) { | |
| 1539 | size_type __sz = size(); | |
| 1540 | size_type __cap = capacity(); | |
| 1541 | value_type* __p; | |
| 1542 | if (__cap - __sz >= __n) | |
| 1543 | { | |
| 1544 | __p = std::__to_address(__get_pointer()); | |
| 1545 | size_type __n_move = __sz - __ip; | |
| 1546 | if (__n_move != 0) | |
| 1547 | traits_type::move(__p + __ip + __n, __p + __ip, __n_move); | |
| 1548 | } | |
| 1549 | else | |
| 1550 | { | |
| 1551 | __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); | |
| 1552 | __p = std::__to_address(__get_long_pointer()); | |
| 1553 | } | |
| 1554 | __sz += __n; | |
| 1555 | __set_size(__sz); | |
| 1556 | traits_type::assign(__p[__sz], value_type()); | |
| 1557 | for (__p += __ip; __first != __last; ++__p, ++__first) | |
| 1558 | traits_type::assign(*__p, *__first); | |
| 1486 | 1559 | |
| 1487 | #else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 1560 | return begin() + __ip; | |
| 1561 | } | |
| 1488 | 1562 | |
| 1489 | _LIBCPP_INLINE_VISIBILITY | |
| 1490 | void __set_short_size(size_type __s) _NOEXCEPT | |
| 1491 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 1492 | {__r_.first().__s.__size_ = (unsigned char)(__s);} | |
| 1493 | # else | |
| 1494 | {__r_.first().__s.__size_ = (unsigned char)(__s << 1);} | |
| 1495 | # endif | |
| 1563 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 allocator_type& __alloc() _NOEXCEPT { return __r_.second(); } | |
| 1564 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); } | |
| 1496 | 1565 | |
| 1497 | _LIBCPP_INLINE_VISIBILITY | |
| 1498 | size_type __get_short_size() const _NOEXCEPT | |
| 1499 | # ifdef _LIBCPP_BIG_ENDIAN | |
| 1500 | {return __r_.first().__s.__size_;} | |
| 1501 | # else | |
| 1502 | {return __r_.first().__s.__size_ >> 1;} | |
| 1503 | # endif | |
| 1566 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1567 | void __set_short_size(size_type __s) _NOEXCEPT { | |
| 1568 | _LIBCPP_ASSERT(__s < __min_cap, "__s should never be greater than or equal to the short string capacity"); | |
| 1569 | __r_.first().__s.__size_ = __s; | |
| 1570 | __r_.first().__s.__is_long_ = false; | |
| 1571 | } | |
| 1504 | 1572 | |
| 1505 | #endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT | |
| 1573 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1574 | size_type __get_short_size() const _NOEXCEPT { | |
| 1575 | _LIBCPP_ASSERT(!__r_.first().__s.__is_long_, "String has to be short when trying to get the short size"); | |
| 1576 | return __r_.first().__s.__size_; | |
| 1577 | } | |
| 1506 | 1578 | |
| 1507 | _LIBCPP_INLINE_VISIBILITY | |
| 1579 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1508 | 1580 | void __set_long_size(size_type __s) _NOEXCEPT |
| 1509 | 1581 | {__r_.first().__l.__size_ = __s;} |
| 1510 | _LIBCPP_INLINE_VISIBILITY | |
| 1582 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1511 | 1583 | size_type __get_long_size() const _NOEXCEPT |
| 1512 | 1584 | {return __r_.first().__l.__size_;} |
| 1513 | _LIBCPP_INLINE_VISIBILITY | |
| 1585 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1514 | 1586 | void __set_size(size_type __s) _NOEXCEPT |
| 1515 | 1587 | {if (__is_long()) __set_long_size(__s); else __set_short_size(__s);} |
| 1516 | 1588 | |
| 1517 | _LIBCPP_INLINE_VISIBILITY | |
| 1518 | void __set_long_cap(size_type __s) _NOEXCEPT | |
| 1519 | {__r_.first().__l.__cap_ = __long_mask | __s;} | |
| 1520 | _LIBCPP_INLINE_VISIBILITY | |
| 1521 | size_type __get_long_cap() const _NOEXCEPT | |
| 1522 | {return __r_.first().__l.__cap_ & size_type(~__long_mask);} | |
| 1589 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1590 | void __set_long_cap(size_type __s) _NOEXCEPT { | |
| 1591 | __r_.first().__l.__cap_ = __s / __endian_factor; | |
| 1592 | __r_.first().__l.__is_long_ = true; | |
| 1593 | } | |
| 1523 | 1594 | |
| 1524 | _LIBCPP_INLINE_VISIBILITY | |
| 1595 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1596 | size_type __get_long_cap() const _NOEXCEPT { | |
| 1597 | return __r_.first().__l.__cap_ * __endian_factor; | |
| 1598 | } | |
| 1599 | ||
| 1600 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1525 | 1601 | void __set_long_pointer(pointer __p) _NOEXCEPT |
| 1526 | 1602 | {__r_.first().__l.__data_ = __p;} |
| 1527 | _LIBCPP_INLINE_VISIBILITY | |
| 1603 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1528 | 1604 | pointer __get_long_pointer() _NOEXCEPT |
| 1529 | 1605 | {return __r_.first().__l.__data_;} |
| 1530 | _LIBCPP_INLINE_VISIBILITY | |
| 1606 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1531 | 1607 | const_pointer __get_long_pointer() const _NOEXCEPT |
| 1532 | 1608 | {return __r_.first().__l.__data_;} |
| 1533 | _LIBCPP_INLINE_VISIBILITY | |
| 1609 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1534 | 1610 | pointer __get_short_pointer() _NOEXCEPT |
| 1535 | 1611 | {return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);} |
| 1536 | _LIBCPP_INLINE_VISIBILITY | |
| 1612 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1537 | 1613 | const_pointer __get_short_pointer() const _NOEXCEPT |
| 1538 | 1614 | {return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);} |
| 1539 | _LIBCPP_INLINE_VISIBILITY | |
| 1615 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1540 | 1616 | pointer __get_pointer() _NOEXCEPT |
| 1541 | 1617 | {return __is_long() ? __get_long_pointer() : __get_short_pointer();} |
| 1542 | _LIBCPP_INLINE_VISIBILITY | |
| 1618 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1543 | 1619 | const_pointer __get_pointer() const _NOEXCEPT |
| 1544 | 1620 | {return __is_long() ? __get_long_pointer() : __get_short_pointer();} |
| 1545 | 1621 | |
| 1546 | _LIBCPP_INLINE_VISIBILITY | |
| 1547 | void __zero() _NOEXCEPT | |
| 1548 | { | |
| 1549 | size_type (&__a)[__n_words] = __r_.first().__r.__words; | |
| 1550 | for (unsigned __i = 0; __i < __n_words; ++__i) | |
| 1551 | __a[__i] = 0; | |
| 1552 | } | |
| 1622 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1623 | void __zero() _NOEXCEPT { | |
| 1624 | __r_.first() = __rep(); | |
| 1625 | } | |
| 1553 | 1626 | |
| 1554 | 1627 | template <size_type __a> static |
| 1555 | _LIBCPP_INLINE_VISIBILITY | |
| 1628 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1556 | 1629 | size_type __align_it(size_type __s) _NOEXCEPT |
| 1557 | 1630 | {return (__s + (__a-1)) & ~(__a-1);} |
| 1558 | 1631 | enum {__alignment = 16}; |
| 1559 | static _LIBCPP_INLINE_VISIBILITY | |
| 1632 | static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1560 | 1633 | size_type __recommend(size_type __s) _NOEXCEPT |
| 1561 | { | |
| 1562 | if (__s < __min_cap) return static_cast<size_type>(__min_cap) - 1; | |
| 1634 | { | |
| 1635 | if (__s < __min_cap) { | |
| 1636 | if (__libcpp_is_constant_evaluated()) | |
| 1637 | return static_cast<size_type>(__min_cap); | |
| 1638 | else | |
| 1639 | return static_cast<size_type>(__min_cap) - 1; | |
| 1640 | } | |
| 1563 | 1641 | size_type __guess = __align_it<sizeof(value_type) < __alignment ? |
| 1564 | 1642 | __alignment/sizeof(value_type) : 1 > (__s+1) - 1; |
| 1565 | 1643 | if (__guess == __min_cap) ++__guess; |
| 1566 | 1644 | return __guess; |
| 1567 | } | |
| 1645 | } | |
| 1568 | 1646 | |
| 1569 | inline | |
| 1647 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1570 | 1648 | void __init(const value_type* __s, size_type __sz, size_type __reserve); |
| 1571 | inline | |
| 1649 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1572 | 1650 | void __init(const value_type* __s, size_type __sz); |
| 1573 | inline | |
| 1651 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1574 | 1652 | void __init(size_type __n, value_type __c); |
| 1575 | 1653 | |
| 1576 | 1654 | // Slow path for the (inlined) copy constructor for 'long' strings. |
| ... | ... | @@ -1581,10 +1659,10 @@ private: |
| 1581 | 1659 | // to call the __init() functions as those are marked as inline which may |
| 1582 | 1660 | // result in over-aggressive inlining by the compiler, where our aim is |
| 1583 | 1661 | // to only inline the fast path code directly in the ctor. |
| 1584 | void __init_copy_ctor_external(const value_type* __s, size_type __sz); | |
| 1662 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __init_copy_ctor_external(const value_type* __s, size_type __sz); | |
| 1585 | 1663 | |
| 1586 | 1664 | template <class _InputIterator> |
| 1587 | inline | |
| 1665 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1588 | 1666 | __enable_if_t |
| 1589 | 1667 | < |
| 1590 | 1668 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| ... | ... | @@ -1592,15 +1670,17 @@ private: |
| 1592 | 1670 | __init(_InputIterator __first, _InputIterator __last); |
| 1593 | 1671 | |
| 1594 | 1672 | template <class _ForwardIterator> |
| 1595 | inline | |
| 1673 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1596 | 1674 | __enable_if_t |
| 1597 | 1675 | < |
| 1598 | 1676 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 1599 | 1677 | > |
| 1600 | 1678 | __init(_ForwardIterator __first, _ForwardIterator __last); |
| 1601 | 1679 | |
| 1680 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1602 | 1681 | void __grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, |
| 1603 | 1682 | size_type __n_copy, size_type __n_del, size_type __n_add = 0); |
| 1683 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1604 | 1684 | void __grow_by_and_replace(size_type __old_cap, size_type __delta_cap, size_type __old_sz, |
| 1605 | 1685 | size_type __n_copy, size_type __n_del, |
| 1606 | 1686 | size_type __n_add, const value_type* __p_new_stuff); |
| ... | ... | @@ -1609,21 +1689,21 @@ private: |
| 1609 | 1689 | // have proof that the input does not alias the current instance. |
| 1610 | 1690 | // For example, operator=(basic_string) performs a 'self' check. |
| 1611 | 1691 | template <bool __is_short> |
| 1612 | basic_string& __assign_no_alias(const value_type* __s, size_type __n); | |
| 1692 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_no_alias(const value_type* __s, size_type __n); | |
| 1613 | 1693 | |
| 1614 | _LIBCPP_INLINE_VISIBILITY | |
| 1694 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1615 | 1695 | void __erase_to_end(size_type __pos); |
| 1616 | 1696 | |
| 1617 | 1697 | // __erase_external_with_move is invoked for erase() invocations where |
| 1618 | 1698 | // `n ~= npos`, likely requiring memory moves on the string data. |
| 1619 | void __erase_external_with_move(size_type __pos, size_type __n); | |
| 1699 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __erase_external_with_move(size_type __pos, size_type __n); | |
| 1620 | 1700 | |
| 1621 | _LIBCPP_INLINE_VISIBILITY | |
| 1701 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1622 | 1702 | void __copy_assign_alloc(const basic_string& __str) |
| 1623 | 1703 | {__copy_assign_alloc(__str, integral_constant<bool, |
| 1624 | 1704 | __alloc_traits::propagate_on_container_copy_assignment::value>());} |
| 1625 | 1705 | |
| 1626 | _LIBCPP_INLINE_VISIBILITY | |
| 1706 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1627 | 1707 | void __copy_assign_alloc(const basic_string& __str, true_type) |
| 1628 | 1708 | { |
| 1629 | 1709 | if (__alloc() == __str.__alloc()) |
| ... | ... | @@ -1638,25 +1718,26 @@ private: |
| 1638 | 1718 | else |
| 1639 | 1719 | { |
| 1640 | 1720 | allocator_type __a = __str.__alloc(); |
| 1641 | pointer __p = __alloc_traits::allocate(__a, __str.__get_long_cap()); | |
| 1721 | auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); | |
| 1722 | __begin_lifetime(__allocation.ptr, __allocation.count); | |
| 1642 | 1723 | __clear_and_shrink(); |
| 1643 | __alloc() = _VSTD::move(__a); | |
| 1644 | __set_long_pointer(__p); | |
| 1645 | __set_long_cap(__str.__get_long_cap()); | |
| 1724 | __alloc() = std::move(__a); | |
| 1725 | __set_long_pointer(__allocation.ptr); | |
| 1726 | __set_long_cap(__allocation.count); | |
| 1646 | 1727 | __set_long_size(__str.size()); |
| 1647 | 1728 | } |
| 1648 | 1729 | } |
| 1649 | 1730 | } |
| 1650 | 1731 | |
| 1651 | _LIBCPP_INLINE_VISIBILITY | |
| 1732 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1652 | 1733 | void __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT |
| 1653 | 1734 | {} |
| 1654 | 1735 | |
| 1655 | 1736 | #ifndef _LIBCPP_CXX03_LANG |
| 1656 | _LIBCPP_INLINE_VISIBILITY | |
| 1737 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1657 | 1738 | void __move_assign(basic_string& __str, false_type) |
| 1658 | 1739 | _NOEXCEPT_(__alloc_traits::is_always_equal::value); |
| 1659 | _LIBCPP_INLINE_VISIBILITY | |
| 1740 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1660 | 1741 | void __move_assign(basic_string& __str, true_type) |
| 1661 | 1742 | #if _LIBCPP_STD_VER > 14 |
| 1662 | 1743 | _NOEXCEPT; |
| ... | ... | @@ -1665,7 +1746,7 @@ private: |
| 1665 | 1746 | #endif |
| 1666 | 1747 | #endif |
| 1667 | 1748 | |
| 1668 | _LIBCPP_INLINE_VISIBILITY | |
| 1749 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1669 | 1750 | void |
| 1670 | 1751 | __move_assign_alloc(basic_string& __str) |
| 1671 | 1752 | _NOEXCEPT_( |
| ... | ... | @@ -1674,78 +1755,83 @@ private: |
| 1674 | 1755 | {__move_assign_alloc(__str, integral_constant<bool, |
| 1675 | 1756 | __alloc_traits::propagate_on_container_move_assignment::value>());} |
| 1676 | 1757 | |
| 1677 | _LIBCPP_INLINE_VISIBILITY | |
| 1758 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1678 | 1759 | void __move_assign_alloc(basic_string& __c, true_type) |
| 1679 | 1760 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| 1680 | 1761 | { |
| 1681 | __alloc() = _VSTD::move(__c.__alloc()); | |
| 1762 | __alloc() = std::move(__c.__alloc()); | |
| 1682 | 1763 | } |
| 1683 | 1764 | |
| 1684 | _LIBCPP_INLINE_VISIBILITY | |
| 1765 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1685 | 1766 | void __move_assign_alloc(basic_string&, false_type) |
| 1686 | 1767 | _NOEXCEPT |
| 1687 | 1768 | {} |
| 1688 | 1769 | |
| 1689 | basic_string& __assign_external(const value_type* __s); | |
| 1690 | basic_string& __assign_external(const value_type* __s, size_type __n); | |
| 1770 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s); | |
| 1771 | _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string& __assign_external(const value_type* __s, size_type __n); | |
| 1691 | 1772 | |
| 1692 | 1773 | // Assigns the value in __s, guaranteed to be __n < __min_cap in length. |
| 1693 | 1774 | inline basic_string& __assign_short(const value_type* __s, size_type __n) { |
| 1694 | 1775 | pointer __p = __is_long() |
| 1695 | 1776 | ? (__set_long_size(__n), __get_long_pointer()) |
| 1696 | 1777 | : (__set_short_size(__n), __get_short_pointer()); |
| 1697 | traits_type::move(_VSTD::__to_address(__p), __s, __n); | |
| 1778 | traits_type::move(std::__to_address(__p), __s, __n); | |
| 1698 | 1779 | traits_type::assign(__p[__n], value_type()); |
| 1699 | 1780 | return *this; |
| 1700 | 1781 | } |
| 1701 | 1782 | |
| 1702 | _LIBCPP_HIDE_FROM_ABI basic_string& __null_terminate_at(value_type* __p, size_type __newsz) { | |
| 1783 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1784 | basic_string& __null_terminate_at(value_type* __p, size_type __newsz) { | |
| 1703 | 1785 | __set_size(__newsz); |
| 1704 | 1786 | __invalidate_iterators_past(__newsz); |
| 1705 | 1787 | traits_type::assign(__p[__newsz], value_type()); |
| 1706 | 1788 | return *this; |
| 1707 | 1789 | } |
| 1708 | 1790 | |
| 1709 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | |
| 1710 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(size_type); | |
| 1791 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type); | |
| 1711 | 1792 | |
| 1712 | 1793 | template<class _Tp> |
| 1713 | _LIBCPP_INLINE_VISIBILITY | |
| 1794 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1714 | 1795 | bool __addr_in_range(_Tp&& __t) const { |
| 1715 | const volatile void *__p = _VSTD::addressof(__t); | |
| 1796 | // assume that the ranges overlap, because we can't check during constant evaluation | |
| 1797 | if (__libcpp_is_constant_evaluated()) | |
| 1798 | return true; | |
| 1799 | const volatile void *__p = std::addressof(__t); | |
| 1716 | 1800 | return data() <= __p && __p <= data() + size(); |
| 1717 | 1801 | } |
| 1718 | 1802 | |
| 1719 | 1803 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI |
| 1720 | 1804 | void __throw_length_error() const { |
| 1721 | _VSTD::__throw_length_error("basic_string"); | |
| 1805 | std::__throw_length_error("basic_string"); | |
| 1722 | 1806 | } |
| 1723 | 1807 | |
| 1724 | 1808 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI |
| 1725 | 1809 | void __throw_out_of_range() const { |
| 1726 | _VSTD::__throw_out_of_range("basic_string"); | |
| 1810 | std::__throw_out_of_range("basic_string"); | |
| 1727 | 1811 | } |
| 1728 | 1812 | |
| 1729 | friend basic_string operator+<>(const basic_string&, const basic_string&); | |
| 1730 | friend basic_string operator+<>(const value_type*, const basic_string&); | |
| 1731 | friend basic_string operator+<>(value_type, const basic_string&); | |
| 1732 | friend basic_string operator+<>(const basic_string&, const value_type*); | |
| 1733 | friend basic_string operator+<>(const basic_string&, value_type); | |
| 1813 | friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const basic_string&); | |
| 1814 | friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const value_type*, const basic_string&); | |
| 1815 | friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(value_type, const basic_string&); | |
| 1816 | friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, const value_type*); | |
| 1817 | friend _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string operator+<>(const basic_string&, value_type); | |
| 1734 | 1818 | }; |
| 1735 | 1819 | |
| 1736 | 1820 | // These declarations must appear before any functions are implicitly used |
| 1737 | 1821 | // so that they have the correct visibility specifier. |
| 1822 | #define _LIBCPP_DECLARE(...) extern template __VA_ARGS__; | |
| 1738 | 1823 | #ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION |
| 1739 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | |
| 1824 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) | |
| 1740 | 1825 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1741 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | |
| 1826 | _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) | |
| 1742 | 1827 | # endif |
| 1743 | 1828 | #else |
| 1744 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, char) | |
| 1829 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char) | |
| 1745 | 1830 | # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 1746 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE, wchar_t) | |
| 1831 | _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, wchar_t) | |
| 1747 | 1832 | # endif |
| 1748 | 1833 | #endif |
| 1834 | #undef _LIBCPP_DECLARE | |
| 1749 | 1835 | |
| 1750 | 1836 | |
| 1751 | 1837 | #if _LIBCPP_STD_VER >= 17 |
| ... | ... | @@ -1777,22 +1863,11 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _ |
| 1777 | 1863 | #endif |
| 1778 | 1864 | |
| 1779 | 1865 | template <class _CharT, class _Traits, class _Allocator> |
| 1780 | inline | |
| 1781 | void | |
| 1782 | basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() | |
| 1783 | { | |
| 1784 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1785 | if (!__libcpp_is_constant_evaluated()) | |
| 1786 | __get_db()->__invalidate_all(this); | |
| 1787 | #endif | |
| 1788 | } | |
| 1789 | ||
| 1790 | template <class _CharT, class _Traits, class _Allocator> | |
| 1791 | inline | |
| 1866 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1792 | 1867 | void |
| 1793 | 1868 | basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos) |
| 1794 | 1869 | { |
| 1795 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1870 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1796 | 1871 | if (!__libcpp_is_constant_evaluated()) { |
| 1797 | 1872 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 1798 | 1873 | if (__c) |
| ... | ... | @@ -1806,7 +1881,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type |
| 1806 | 1881 | { |
| 1807 | 1882 | (*__p)->__c_ = nullptr; |
| 1808 | 1883 | if (--__c->end_ != __p) |
| 1809 | _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | |
| 1884 | std::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); | |
| 1810 | 1885 | } |
| 1811 | 1886 | } |
| 1812 | 1887 | __get_db()->unlock(); |
| ... | ... | @@ -1814,21 +1889,21 @@ basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type |
| 1814 | 1889 | } |
| 1815 | 1890 | #else |
| 1816 | 1891 | (void)__pos; |
| 1817 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1892 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1818 | 1893 | } |
| 1819 | 1894 | |
| 1820 | 1895 | template <class _CharT, class _Traits, class _Allocator> |
| 1821 | inline | |
| 1896 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1822 | 1897 | basic_string<_CharT, _Traits, _Allocator>::basic_string() |
| 1823 | 1898 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 1824 | 1899 | : __r_(__default_init_tag(), __default_init_tag()) |
| 1825 | 1900 | { |
| 1826 | _VSTD::__debug_db_insert_c(this); | |
| 1827 | __zero(); | |
| 1901 | std::__debug_db_insert_c(this); | |
| 1902 | __default_init(); | |
| 1828 | 1903 | } |
| 1829 | 1904 | |
| 1830 | 1905 | template <class _CharT, class _Traits, class _Allocator> |
| 1831 | inline | |
| 1906 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1832 | 1907 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) |
| 1833 | 1908 | #if _LIBCPP_STD_VER <= 14 |
| 1834 | 1909 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
| ... | ... | @@ -1837,15 +1912,18 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __ |
| 1837 | 1912 | #endif |
| 1838 | 1913 | : __r_(__default_init_tag(), __a) |
| 1839 | 1914 | { |
| 1840 | _VSTD::__debug_db_insert_c(this); | |
| 1841 | __zero(); | |
| 1915 | std::__debug_db_insert_c(this); | |
| 1916 | __default_init(); | |
| 1842 | 1917 | } |
| 1843 | 1918 | |
| 1844 | 1919 | template <class _CharT, class _Traits, class _Allocator> |
| 1920 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1845 | 1921 | void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, |
| 1846 | 1922 | size_type __sz, |
| 1847 | 1923 | size_type __reserve) |
| 1848 | 1924 | { |
| 1925 | if (__libcpp_is_constant_evaluated()) | |
| 1926 | __zero(); | |
| 1849 | 1927 | if (__reserve > max_size()) |
| 1850 | 1928 | __throw_length_error(); |
| 1851 | 1929 | pointer __p; |
| ... | ... | @@ -1856,20 +1934,24 @@ void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, |
| 1856 | 1934 | } |
| 1857 | 1935 | else |
| 1858 | 1936 | { |
| 1859 | size_type __cap = __recommend(__reserve); | |
| 1860 | __p = __alloc_traits::allocate(__alloc(), __cap+1); | |
| 1937 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__reserve) + 1); | |
| 1938 | __p = __allocation.ptr; | |
| 1939 | __begin_lifetime(__p, __allocation.count); | |
| 1861 | 1940 | __set_long_pointer(__p); |
| 1862 | __set_long_cap(__cap+1); | |
| 1941 | __set_long_cap(__allocation.count); | |
| 1863 | 1942 | __set_long_size(__sz); |
| 1864 | 1943 | } |
| 1865 | traits_type::copy(_VSTD::__to_address(__p), __s, __sz); | |
| 1944 | traits_type::copy(std::__to_address(__p), __s, __sz); | |
| 1866 | 1945 | traits_type::assign(__p[__sz], value_type()); |
| 1867 | 1946 | } |
| 1868 | 1947 | |
| 1869 | 1948 | template <class _CharT, class _Traits, class _Allocator> |
| 1949 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1870 | 1950 | void |
| 1871 | 1951 | basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) |
| 1872 | 1952 | { |
| 1953 | if (__libcpp_is_constant_evaluated()) | |
| 1954 | __zero(); | |
| 1873 | 1955 | if (__sz > max_size()) |
| 1874 | 1956 | __throw_length_error(); |
| 1875 | 1957 | pointer __p; |
| ... | ... | @@ -1880,59 +1962,63 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty |
| 1880 | 1962 | } |
| 1881 | 1963 | else |
| 1882 | 1964 | { |
| 1883 | size_type __cap = __recommend(__sz); | |
| 1884 | __p = __alloc_traits::allocate(__alloc(), __cap+1); | |
| 1965 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); | |
| 1966 | __p = __allocation.ptr; | |
| 1967 | __begin_lifetime(__p, __allocation.count); | |
| 1885 | 1968 | __set_long_pointer(__p); |
| 1886 | __set_long_cap(__cap+1); | |
| 1969 | __set_long_cap(__allocation.count); | |
| 1887 | 1970 | __set_long_size(__sz); |
| 1888 | 1971 | } |
| 1889 | traits_type::copy(_VSTD::__to_address(__p), __s, __sz); | |
| 1972 | traits_type::copy(std::__to_address(__p), __s, __sz); | |
| 1890 | 1973 | traits_type::assign(__p[__sz], value_type()); |
| 1891 | 1974 | } |
| 1892 | 1975 | |
| 1893 | 1976 | template <class _CharT, class _Traits, class _Allocator> |
| 1894 | 1977 | template <class> |
| 1978 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1895 | 1979 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) |
| 1896 | 1980 | : __r_(__default_init_tag(), __a) |
| 1897 | 1981 | { |
| 1898 | 1982 | _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); |
| 1899 | 1983 | __init(__s, traits_type::length(__s)); |
| 1900 | _VSTD::__debug_db_insert_c(this); | |
| 1984 | std::__debug_db_insert_c(this); | |
| 1901 | 1985 | } |
| 1902 | 1986 | |
| 1903 | 1987 | template <class _CharT, class _Traits, class _Allocator> |
| 1904 | inline | |
| 1988 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1905 | 1989 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n) |
| 1906 | 1990 | : __r_(__default_init_tag(), __default_init_tag()) |
| 1907 | 1991 | { |
| 1908 | 1992 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); |
| 1909 | 1993 | __init(__s, __n); |
| 1910 | _VSTD::__debug_db_insert_c(this); | |
| 1994 | std::__debug_db_insert_c(this); | |
| 1911 | 1995 | } |
| 1912 | 1996 | |
| 1913 | 1997 | template <class _CharT, class _Traits, class _Allocator> |
| 1914 | inline | |
| 1998 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1915 | 1999 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) |
| 1916 | 2000 | : __r_(__default_init_tag(), __a) |
| 1917 | 2001 | { |
| 1918 | 2002 | _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); |
| 1919 | 2003 | __init(__s, __n); |
| 1920 | _VSTD::__debug_db_insert_c(this); | |
| 2004 | std::__debug_db_insert_c(this); | |
| 1921 | 2005 | } |
| 1922 | 2006 | |
| 1923 | 2007 | template <class _CharT, class _Traits, class _Allocator> |
| 2008 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1924 | 2009 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) |
| 1925 | 2010 | : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) |
| 1926 | 2011 | { |
| 1927 | 2012 | if (!__str.__is_long()) |
| 1928 | 2013 | __r_.first().__r = __str.__r_.first().__r; |
| 1929 | 2014 | else |
| 1930 | __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), | |
| 2015 | __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), | |
| 1931 | 2016 | __str.__get_long_size()); |
| 1932 | _VSTD::__debug_db_insert_c(this); | |
| 2017 | std::__debug_db_insert_c(this); | |
| 1933 | 2018 | } |
| 1934 | 2019 | |
| 1935 | 2020 | template <class _CharT, class _Traits, class _Allocator> |
| 2021 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1936 | 2022 | basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 1937 | 2023 | const basic_string& __str, const allocator_type& __a) |
| 1938 | 2024 | : __r_(__default_init_tag(), __a) |
| ... | ... | @@ -1940,14 +2026,17 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 1940 | 2026 | if (!__str.__is_long()) |
| 1941 | 2027 | __r_.first().__r = __str.__r_.first().__r; |
| 1942 | 2028 | else |
| 1943 | __init_copy_ctor_external(_VSTD::__to_address(__str.__get_long_pointer()), | |
| 2029 | __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), | |
| 1944 | 2030 | __str.__get_long_size()); |
| 1945 | _VSTD::__debug_db_insert_c(this); | |
| 2031 | std::__debug_db_insert_c(this); | |
| 1946 | 2032 | } |
| 1947 | 2033 | |
| 1948 | 2034 | template <class _CharT, class _Traits, class _Allocator> |
| 2035 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1949 | 2036 | void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( |
| 1950 | 2037 | const value_type* __s, size_type __sz) { |
| 2038 | if (__libcpp_is_constant_evaluated()) | |
| 2039 | __zero(); | |
| 1951 | 2040 | pointer __p; |
| 1952 | 2041 | if (__fits_in_sso(__sz)) { |
| 1953 | 2042 | __p = __get_short_pointer(); |
| ... | ... | @@ -1955,60 +2044,65 @@ void basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external( |
| 1955 | 2044 | } else { |
| 1956 | 2045 | if (__sz > max_size()) |
| 1957 | 2046 | __throw_length_error(); |
| 1958 | size_t __cap = __recommend(__sz); | |
| 1959 | __p = __alloc_traits::allocate(__alloc(), __cap + 1); | |
| 2047 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); | |
| 2048 | __p = __allocation.ptr; | |
| 2049 | __begin_lifetime(__p, __allocation.count); | |
| 1960 | 2050 | __set_long_pointer(__p); |
| 1961 | __set_long_cap(__cap + 1); | |
| 2051 | __set_long_cap(__allocation.count); | |
| 1962 | 2052 | __set_long_size(__sz); |
| 1963 | 2053 | } |
| 1964 | traits_type::copy(_VSTD::__to_address(__p), __s, __sz + 1); | |
| 2054 | traits_type::copy(std::__to_address(__p), __s, __sz + 1); | |
| 1965 | 2055 | } |
| 1966 | 2056 | |
| 1967 | 2057 | #ifndef _LIBCPP_CXX03_LANG |
| 1968 | 2058 | |
| 1969 | 2059 | template <class _CharT, class _Traits, class _Allocator> |
| 1970 | inline | |
| 2060 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1971 | 2061 | basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) |
| 1972 | 2062 | #if _LIBCPP_STD_VER <= 14 |
| 1973 | 2063 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 1974 | 2064 | #else |
| 1975 | 2065 | _NOEXCEPT |
| 1976 | 2066 | #endif |
| 1977 | : __r_(_VSTD::move(__str.__r_)) | |
| 2067 | : __r_(std::move(__str.__r_)) | |
| 1978 | 2068 | { |
| 1979 | __str.__zero(); | |
| 1980 | _VSTD::__debug_db_insert_c(this); | |
| 1981 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1982 | if (!__libcpp_is_constant_evaluated() && __is_long()) | |
| 1983 | __get_db()->swap(this, &__str); | |
| 1984 | #endif | |
| 2069 | __str.__default_init(); | |
| 2070 | std::__debug_db_insert_c(this); | |
| 2071 | if (__is_long()) | |
| 2072 | std::__debug_db_swap(this, &__str); | |
| 1985 | 2073 | } |
| 1986 | 2074 | |
| 1987 | 2075 | template <class _CharT, class _Traits, class _Allocator> |
| 1988 | inline | |
| 2076 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1989 | 2077 | basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) |
| 1990 | 2078 | : __r_(__default_init_tag(), __a) |
| 1991 | 2079 | { |
| 1992 | 2080 | if (__str.__is_long() && __a != __str.__alloc()) // copy, not move |
| 1993 | __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); | |
| 2081 | __init(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); | |
| 1994 | 2082 | else |
| 1995 | 2083 | { |
| 1996 | __r_.first().__r = __str.__r_.first().__r; | |
| 1997 | __str.__zero(); | |
| 2084 | if (__libcpp_is_constant_evaluated()) { | |
| 2085 | __zero(); | |
| 2086 | __r_.first().__l = __str.__r_.first().__l; | |
| 2087 | } else { | |
| 2088 | __r_.first().__r = __str.__r_.first().__r; | |
| 2089 | } | |
| 2090 | __str.__default_init(); | |
| 1998 | 2091 | } |
| 1999 | _VSTD::__debug_db_insert_c(this); | |
| 2000 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2001 | if (!__libcpp_is_constant_evaluated() && __is_long()) | |
| 2002 | __get_db()->swap(this, &__str); | |
| 2003 | #endif | |
| 2092 | std::__debug_db_insert_c(this); | |
| 2093 | if (__is_long()) | |
| 2094 | std::__debug_db_swap(this, &__str); | |
| 2004 | 2095 | } |
| 2005 | 2096 | |
| 2006 | 2097 | #endif // _LIBCPP_CXX03_LANG |
| 2007 | 2098 | |
| 2008 | 2099 | template <class _CharT, class _Traits, class _Allocator> |
| 2100 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2009 | 2101 | void |
| 2010 | 2102 | basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) |
| 2011 | 2103 | { |
| 2104 | if (__libcpp_is_constant_evaluated()) | |
| 2105 | __zero(); | |
| 2012 | 2106 | if (__n > max_size()) |
| 2013 | 2107 | __throw_length_error(); |
| 2014 | 2108 | pointer __p; |
| ... | ... | @@ -2019,35 +2113,38 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) |
| 2019 | 2113 | } |
| 2020 | 2114 | else |
| 2021 | 2115 | { |
| 2022 | size_type __cap = __recommend(__n); | |
| 2023 | __p = __alloc_traits::allocate(__alloc(), __cap+1); | |
| 2116 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__n) + 1); | |
| 2117 | __p = __allocation.ptr; | |
| 2118 | __begin_lifetime(__p, __allocation.count); | |
| 2024 | 2119 | __set_long_pointer(__p); |
| 2025 | __set_long_cap(__cap+1); | |
| 2120 | __set_long_cap(__allocation.count); | |
| 2026 | 2121 | __set_long_size(__n); |
| 2027 | 2122 | } |
| 2028 | traits_type::assign(_VSTD::__to_address(__p), __n, __c); | |
| 2123 | traits_type::assign(std::__to_address(__p), __n, __c); | |
| 2029 | 2124 | traits_type::assign(__p[__n], value_type()); |
| 2030 | 2125 | } |
| 2031 | 2126 | |
| 2032 | 2127 | template <class _CharT, class _Traits, class _Allocator> |
| 2033 | inline | |
| 2128 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2034 | 2129 | basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c) |
| 2035 | 2130 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2036 | 2131 | { |
| 2037 | 2132 | __init(__n, __c); |
| 2038 | _VSTD::__debug_db_insert_c(this); | |
| 2133 | std::__debug_db_insert_c(this); | |
| 2039 | 2134 | } |
| 2040 | 2135 | |
| 2041 | 2136 | template <class _CharT, class _Traits, class _Allocator> |
| 2042 | 2137 | template <class> |
| 2138 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2043 | 2139 | basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) |
| 2044 | 2140 | : __r_(__default_init_tag(), __a) |
| 2045 | 2141 | { |
| 2046 | 2142 | __init(__n, __c); |
| 2047 | _VSTD::__debug_db_insert_c(this); | |
| 2143 | std::__debug_db_insert_c(this); | |
| 2048 | 2144 | } |
| 2049 | 2145 | |
| 2050 | 2146 | template <class _CharT, class _Traits, class _Allocator> |
| 2147 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2051 | 2148 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, |
| 2052 | 2149 | size_type __pos, size_type __n, |
| 2053 | 2150 | const _Allocator& __a) |
| ... | ... | @@ -2056,12 +2153,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st |
| 2056 | 2153 | size_type __str_sz = __str.size(); |
| 2057 | 2154 | if (__pos > __str_sz) |
| 2058 | 2155 | __throw_out_of_range(); |
| 2059 | __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); | |
| 2060 | _VSTD::__debug_db_insert_c(this); | |
| 2156 | __init(__str.data() + __pos, std::min(__n, __str_sz - __pos)); | |
| 2157 | std::__debug_db_insert_c(this); | |
| 2061 | 2158 | } |
| 2062 | 2159 | |
| 2063 | 2160 | template <class _CharT, class _Traits, class _Allocator> |
| 2064 | inline | |
| 2161 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2065 | 2162 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, |
| 2066 | 2163 | const _Allocator& __a) |
| 2067 | 2164 | : __r_(__default_init_tag(), __a) |
| ... | ... | @@ -2070,11 +2167,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st |
| 2070 | 2167 | if (__pos > __str_sz) |
| 2071 | 2168 | __throw_out_of_range(); |
| 2072 | 2169 | __init(__str.data() + __pos, __str_sz - __pos); |
| 2073 | _VSTD::__debug_db_insert_c(this); | |
| 2170 | std::__debug_db_insert_c(this); | |
| 2074 | 2171 | } |
| 2075 | 2172 | |
| 2076 | 2173 | template <class _CharT, class _Traits, class _Allocator> |
| 2077 | 2174 | template <class _Tp, class> |
| 2175 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2078 | 2176 | basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2079 | 2177 | const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) |
| 2080 | 2178 | : __r_(__default_init_tag(), __a) |
| ... | ... | @@ -2082,38 +2180,41 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2082 | 2180 | __self_view __sv0 = __t; |
| 2083 | 2181 | __self_view __sv = __sv0.substr(__pos, __n); |
| 2084 | 2182 | __init(__sv.data(), __sv.size()); |
| 2085 | _VSTD::__debug_db_insert_c(this); | |
| 2183 | std::__debug_db_insert_c(this); | |
| 2086 | 2184 | } |
| 2087 | 2185 | |
| 2088 | 2186 | template <class _CharT, class _Traits, class _Allocator> |
| 2089 | 2187 | template <class _Tp, class> |
| 2188 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2090 | 2189 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) |
| 2091 | 2190 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2092 | 2191 | { |
| 2093 | 2192 | __self_view __sv = __t; |
| 2094 | 2193 | __init(__sv.data(), __sv.size()); |
| 2095 | _VSTD::__debug_db_insert_c(this); | |
| 2194 | std::__debug_db_insert_c(this); | |
| 2096 | 2195 | } |
| 2097 | 2196 | |
| 2098 | 2197 | template <class _CharT, class _Traits, class _Allocator> |
| 2099 | 2198 | template <class _Tp, class> |
| 2199 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2100 | 2200 | basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a) |
| 2101 | 2201 | : __r_(__default_init_tag(), __a) |
| 2102 | 2202 | { |
| 2103 | 2203 | __self_view __sv = __t; |
| 2104 | 2204 | __init(__sv.data(), __sv.size()); |
| 2105 | _VSTD::__debug_db_insert_c(this); | |
| 2205 | std::__debug_db_insert_c(this); | |
| 2106 | 2206 | } |
| 2107 | 2207 | |
| 2108 | 2208 | template <class _CharT, class _Traits, class _Allocator> |
| 2109 | 2209 | template <class _InputIterator> |
| 2210 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2110 | 2211 | __enable_if_t |
| 2111 | 2212 | < |
| 2112 | 2213 | __is_exactly_cpp17_input_iterator<_InputIterator>::value |
| 2113 | 2214 | > |
| 2114 | 2215 | basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) |
| 2115 | 2216 | { |
| 2116 | __zero(); | |
| 2217 | __default_init(); | |
| 2117 | 2218 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 2118 | 2219 | try |
| 2119 | 2220 | { |
| ... | ... | @@ -2133,13 +2234,16 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _Input |
| 2133 | 2234 | |
| 2134 | 2235 | template <class _CharT, class _Traits, class _Allocator> |
| 2135 | 2236 | template <class _ForwardIterator> |
| 2237 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2136 | 2238 | __enable_if_t |
| 2137 | 2239 | < |
| 2138 | 2240 | __is_cpp17_forward_iterator<_ForwardIterator>::value |
| 2139 | 2241 | > |
| 2140 | 2242 | basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _ForwardIterator __last) |
| 2141 | 2243 | { |
| 2142 | size_type __sz = static_cast<size_type>(_VSTD::distance(__first, __last)); | |
| 2244 | if (__libcpp_is_constant_evaluated()) | |
| 2245 | __zero(); | |
| 2246 | size_type __sz = static_cast<size_type>(std::distance(__first, __last)); | |
| 2143 | 2247 | if (__sz > max_size()) |
| 2144 | 2248 | __throw_length_error(); |
| 2145 | 2249 | pointer __p; |
| ... | ... | @@ -2150,10 +2254,11 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For |
| 2150 | 2254 | } |
| 2151 | 2255 | else |
| 2152 | 2256 | { |
| 2153 | size_type __cap = __recommend(__sz); | |
| 2154 | __p = __alloc_traits::allocate(__alloc(), __cap+1); | |
| 2257 | auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1); | |
| 2258 | __p = __allocation.ptr; | |
| 2259 | __begin_lifetime(__p, __allocation.count); | |
| 2155 | 2260 | __set_long_pointer(__p); |
| 2156 | __set_long_cap(__cap+1); | |
| 2261 | __set_long_cap(__allocation.count); | |
| 2157 | 2262 | __set_long_size(__sz); |
| 2158 | 2263 | } |
| 2159 | 2264 | |
| ... | ... | @@ -2177,62 +2282,60 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For |
| 2177 | 2282 | |
| 2178 | 2283 | template <class _CharT, class _Traits, class _Allocator> |
| 2179 | 2284 | template<class _InputIterator, class> |
| 2180 | inline | |
| 2285 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2181 | 2286 | basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) |
| 2182 | 2287 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2183 | 2288 | { |
| 2184 | 2289 | __init(__first, __last); |
| 2185 | _VSTD::__debug_db_insert_c(this); | |
| 2290 | std::__debug_db_insert_c(this); | |
| 2186 | 2291 | } |
| 2187 | 2292 | |
| 2188 | 2293 | template <class _CharT, class _Traits, class _Allocator> |
| 2189 | 2294 | template<class _InputIterator, class> |
| 2190 | inline | |
| 2295 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2191 | 2296 | basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, |
| 2192 | 2297 | const allocator_type& __a) |
| 2193 | 2298 | : __r_(__default_init_tag(), __a) |
| 2194 | 2299 | { |
| 2195 | 2300 | __init(__first, __last); |
| 2196 | _VSTD::__debug_db_insert_c(this); | |
| 2301 | std::__debug_db_insert_c(this); | |
| 2197 | 2302 | } |
| 2198 | 2303 | |
| 2199 | 2304 | #ifndef _LIBCPP_CXX03_LANG |
| 2200 | 2305 | |
| 2201 | 2306 | template <class _CharT, class _Traits, class _Allocator> |
| 2202 | inline | |
| 2307 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2203 | 2308 | basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2204 | 2309 | initializer_list<_CharT> __il) |
| 2205 | 2310 | : __r_(__default_init_tag(), __default_init_tag()) |
| 2206 | 2311 | { |
| 2207 | 2312 | __init(__il.begin(), __il.end()); |
| 2208 | _VSTD::__debug_db_insert_c(this); | |
| 2313 | std::__debug_db_insert_c(this); | |
| 2209 | 2314 | } |
| 2210 | 2315 | |
| 2211 | 2316 | template <class _CharT, class _Traits, class _Allocator> |
| 2212 | inline | |
| 2213 | ||
| 2317 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2214 | 2318 | basic_string<_CharT, _Traits, _Allocator>::basic_string( |
| 2215 | 2319 | initializer_list<_CharT> __il, const _Allocator& __a) |
| 2216 | 2320 | : __r_(__default_init_tag(), __a) |
| 2217 | 2321 | { |
| 2218 | 2322 | __init(__il.begin(), __il.end()); |
| 2219 | _VSTD::__debug_db_insert_c(this); | |
| 2323 | std::__debug_db_insert_c(this); | |
| 2220 | 2324 | } |
| 2221 | 2325 | |
| 2222 | 2326 | #endif // _LIBCPP_CXX03_LANG |
| 2223 | 2327 | |
| 2224 | 2328 | template <class _CharT, class _Traits, class _Allocator> |
| 2329 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2225 | 2330 | basic_string<_CharT, _Traits, _Allocator>::~basic_string() |
| 2226 | 2331 | { |
| 2227 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2228 | if (!__libcpp_is_constant_evaluated()) | |
| 2229 | __get_db()->__erase_c(this); | |
| 2230 | #endif | |
| 2332 | std::__debug_db_erase_c(this); | |
| 2231 | 2333 | if (__is_long()) |
| 2232 | 2334 | __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); |
| 2233 | 2335 | } |
| 2234 | 2336 | |
| 2235 | 2337 | template <class _CharT, class _Traits, class _Allocator> |
| 2338 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2236 | 2339 | void |
| 2237 | 2340 | basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace |
| 2238 | 2341 | (size_type __old_cap, size_type __delta_cap, size_type __old_sz, |
| ... | ... | @@ -2243,23 +2346,25 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace |
| 2243 | 2346 | __throw_length_error(); |
| 2244 | 2347 | pointer __old_p = __get_pointer(); |
| 2245 | 2348 | size_type __cap = __old_cap < __ms / 2 - __alignment ? |
| 2246 | __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : | |
| 2349 | __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : | |
| 2247 | 2350 | __ms - 1; |
| 2248 | pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); | |
| 2249 | __invalidate_all_iterators(); | |
| 2351 | auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); | |
| 2352 | pointer __p = __allocation.ptr; | |
| 2353 | __begin_lifetime(__p, __allocation.count); | |
| 2354 | std::__debug_db_invalidate_all(this); | |
| 2250 | 2355 | if (__n_copy != 0) |
| 2251 | traits_type::copy(_VSTD::__to_address(__p), | |
| 2252 | _VSTD::__to_address(__old_p), __n_copy); | |
| 2356 | traits_type::copy(std::__to_address(__p), | |
| 2357 | std::__to_address(__old_p), __n_copy); | |
| 2253 | 2358 | if (__n_add != 0) |
| 2254 | traits_type::copy(_VSTD::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); | |
| 2359 | traits_type::copy(std::__to_address(__p) + __n_copy, __p_new_stuff, __n_add); | |
| 2255 | 2360 | size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; |
| 2256 | 2361 | if (__sec_cp_sz != 0) |
| 2257 | traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add, | |
| 2258 | _VSTD::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); | |
| 2259 | if (__old_cap+1 != __min_cap) | |
| 2362 | traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, | |
| 2363 | std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); | |
| 2364 | if (__old_cap+1 != __min_cap || __libcpp_is_constant_evaluated()) | |
| 2260 | 2365 | __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); |
| 2261 | 2366 | __set_long_pointer(__p); |
| 2262 | __set_long_cap(__cap+1); | |
| 2367 | __set_long_cap(__allocation.count); | |
| 2263 | 2368 | __old_sz = __n_copy + __n_add + __sec_cp_sz; |
| 2264 | 2369 | __set_long_size(__old_sz); |
| 2265 | 2370 | traits_type::assign(__p[__old_sz], value_type()); |
| ... | ... | @@ -2267,6 +2372,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace |
| 2267 | 2372 | |
| 2268 | 2373 | template <class _CharT, class _Traits, class _Allocator> |
| 2269 | 2374 | void |
| 2375 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2270 | 2376 | basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_type __delta_cap, size_type __old_sz, |
| 2271 | 2377 | size_type __n_copy, size_type __n_del, size_type __n_add) |
| 2272 | 2378 | { |
| ... | ... | @@ -2275,36 +2381,39 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t |
| 2275 | 2381 | __throw_length_error(); |
| 2276 | 2382 | pointer __old_p = __get_pointer(); |
| 2277 | 2383 | size_type __cap = __old_cap < __ms / 2 - __alignment ? |
| 2278 | __recommend(_VSTD::max(__old_cap + __delta_cap, 2 * __old_cap)) : | |
| 2384 | __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : | |
| 2279 | 2385 | __ms - 1; |
| 2280 | pointer __p = __alloc_traits::allocate(__alloc(), __cap+1); | |
| 2281 | __invalidate_all_iterators(); | |
| 2386 | auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); | |
| 2387 | pointer __p = __allocation.ptr; | |
| 2388 | __begin_lifetime(__p, __allocation.count); | |
| 2389 | std::__debug_db_invalidate_all(this); | |
| 2282 | 2390 | if (__n_copy != 0) |
| 2283 | traits_type::copy(_VSTD::__to_address(__p), | |
| 2284 | _VSTD::__to_address(__old_p), __n_copy); | |
| 2391 | traits_type::copy(std::__to_address(__p), | |
| 2392 | std::__to_address(__old_p), __n_copy); | |
| 2285 | 2393 | size_type __sec_cp_sz = __old_sz - __n_del - __n_copy; |
| 2286 | 2394 | if (__sec_cp_sz != 0) |
| 2287 | traits_type::copy(_VSTD::__to_address(__p) + __n_copy + __n_add, | |
| 2288 | _VSTD::__to_address(__old_p) + __n_copy + __n_del, | |
| 2395 | traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, | |
| 2396 | std::__to_address(__old_p) + __n_copy + __n_del, | |
| 2289 | 2397 | __sec_cp_sz); |
| 2290 | if (__old_cap+1 != __min_cap) | |
| 2291 | __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); | |
| 2398 | if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap) | |
| 2399 | __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); | |
| 2292 | 2400 | __set_long_pointer(__p); |
| 2293 | __set_long_cap(__cap+1); | |
| 2401 | __set_long_cap(__allocation.count); | |
| 2294 | 2402 | } |
| 2295 | 2403 | |
| 2296 | 2404 | // assign |
| 2297 | 2405 | |
| 2298 | 2406 | template <class _CharT, class _Traits, class _Allocator> |
| 2299 | 2407 | template <bool __is_short> |
| 2408 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2300 | 2409 | basic_string<_CharT, _Traits, _Allocator>& |
| 2301 | 2410 | basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( |
| 2302 | 2411 | const value_type* __s, size_type __n) { |
| 2303 | size_type __cap = __is_short ? __min_cap : __get_long_cap(); | |
| 2412 | size_type __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap(); | |
| 2304 | 2413 | if (__n < __cap) { |
| 2305 | 2414 | pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer(); |
| 2306 | 2415 | __is_short ? __set_short_size(__n) : __set_long_size(__n); |
| 2307 | traits_type::copy(_VSTD::__to_address(__p), __s, __n); | |
| 2416 | traits_type::copy(std::__to_address(__p), __s, __n); | |
| 2308 | 2417 | traits_type::assign(__p[__n], value_type()); |
| 2309 | 2418 | __invalidate_iterators_past(__n); |
| 2310 | 2419 | } else { |
| ... | ... | @@ -2315,12 +2424,13 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias( |
| 2315 | 2424 | } |
| 2316 | 2425 | |
| 2317 | 2426 | template <class _CharT, class _Traits, class _Allocator> |
| 2427 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2318 | 2428 | basic_string<_CharT, _Traits, _Allocator>& |
| 2319 | 2429 | basic_string<_CharT, _Traits, _Allocator>::__assign_external( |
| 2320 | 2430 | const value_type* __s, size_type __n) { |
| 2321 | 2431 | size_type __cap = capacity(); |
| 2322 | 2432 | if (__cap >= __n) { |
| 2323 | value_type* __p = _VSTD::__to_address(__get_pointer()); | |
| 2433 | value_type* __p = std::__to_address(__get_pointer()); | |
| 2324 | 2434 | traits_type::move(__p, __s, __n); |
| 2325 | 2435 | return __null_terminate_at(__p, __n); |
| 2326 | 2436 | } else { |
| ... | ... | @@ -2331,6 +2441,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external( |
| 2331 | 2441 | } |
| 2332 | 2442 | |
| 2333 | 2443 | template <class _CharT, class _Traits, class _Allocator> |
| 2444 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2334 | 2445 | basic_string<_CharT, _Traits, _Allocator>& |
| 2335 | 2446 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) |
| 2336 | 2447 | { |
| ... | ... | @@ -2341,6 +2452,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty |
| 2341 | 2452 | } |
| 2342 | 2453 | |
| 2343 | 2454 | template <class _CharT, class _Traits, class _Allocator> |
| 2455 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2344 | 2456 | basic_string<_CharT, _Traits, _Allocator>& |
| 2345 | 2457 | basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) |
| 2346 | 2458 | { |
| ... | ... | @@ -2350,12 +2462,13 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) |
| 2350 | 2462 | size_type __sz = size(); |
| 2351 | 2463 | __grow_by(__cap, __n - __cap, __sz, 0, __sz); |
| 2352 | 2464 | } |
| 2353 | value_type* __p = _VSTD::__to_address(__get_pointer()); | |
| 2465 | value_type* __p = std::__to_address(__get_pointer()); | |
| 2354 | 2466 | traits_type::assign(__p, __n, __c); |
| 2355 | 2467 | return __null_terminate_at(__p, __n); |
| 2356 | 2468 | } |
| 2357 | 2469 | |
| 2358 | 2470 | template <class _CharT, class _Traits, class _Allocator> |
| 2471 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2359 | 2472 | basic_string<_CharT, _Traits, _Allocator>& |
| 2360 | 2473 | basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) |
| 2361 | 2474 | { |
| ... | ... | @@ -2377,6 +2490,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) |
| 2377 | 2490 | } |
| 2378 | 2491 | |
| 2379 | 2492 | template <class _CharT, class _Traits, class _Allocator> |
| 2493 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2380 | 2494 | basic_string<_CharT, _Traits, _Allocator>& |
| 2381 | 2495 | basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) |
| 2382 | 2496 | { |
| ... | ... | @@ -2398,7 +2512,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) |
| 2398 | 2512 | #ifndef _LIBCPP_CXX03_LANG |
| 2399 | 2513 | |
| 2400 | 2514 | template <class _CharT, class _Traits, class _Allocator> |
| 2401 | inline | |
| 2515 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2402 | 2516 | void |
| 2403 | 2517 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) |
| 2404 | 2518 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) |
| ... | ... | @@ -2410,7 +2524,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa |
| 2410 | 2524 | } |
| 2411 | 2525 | |
| 2412 | 2526 | template <class _CharT, class _Traits, class _Allocator> |
| 2413 | inline | |
| 2527 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2414 | 2528 | void |
| 2415 | 2529 | basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) |
| 2416 | 2530 | #if _LIBCPP_STD_VER > 14 |
| ... | ... | @@ -2431,12 +2545,16 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr |
| 2431 | 2545 | } |
| 2432 | 2546 | __move_assign_alloc(__str); |
| 2433 | 2547 | __r_.first() = __str.__r_.first(); |
| 2434 | __str.__set_short_size(0); | |
| 2435 | traits_type::assign(__str.__get_short_pointer()[0], value_type()); | |
| 2548 | if (__libcpp_is_constant_evaluated()) { | |
| 2549 | __str.__default_init(); | |
| 2550 | } else { | |
| 2551 | __str.__set_short_size(0); | |
| 2552 | traits_type::assign(__str.__get_short_pointer()[0], value_type()); | |
| 2553 | } | |
| 2436 | 2554 | } |
| 2437 | 2555 | |
| 2438 | 2556 | template <class _CharT, class _Traits, class _Allocator> |
| 2439 | inline | |
| 2557 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2440 | 2558 | basic_string<_CharT, _Traits, _Allocator>& |
| 2441 | 2559 | basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) |
| 2442 | 2560 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) |
| ... | ... | @@ -2450,6 +2568,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) |
| 2450 | 2568 | |
| 2451 | 2569 | template <class _CharT, class _Traits, class _Allocator> |
| 2452 | 2570 | template<class _InputIterator> |
| 2571 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2453 | 2572 | __enable_if_t |
| 2454 | 2573 | < |
| 2455 | 2574 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| ... | ... | @@ -2464,6 +2583,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input |
| 2464 | 2583 | |
| 2465 | 2584 | template <class _CharT, class _Traits, class _Allocator> |
| 2466 | 2585 | template<class _ForwardIterator> |
| 2586 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2467 | 2587 | __enable_if_t |
| 2468 | 2588 | < |
| 2469 | 2589 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -2473,7 +2593,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For |
| 2473 | 2593 | { |
| 2474 | 2594 | size_type __cap = capacity(); |
| 2475 | 2595 | size_type __n = __string_is_trivial_iterator<_ForwardIterator>::value ? |
| 2476 | static_cast<size_type>(_VSTD::distance(__first, __last)) : 0; | |
| 2596 | static_cast<size_type>(std::distance(__first, __last)) : 0; | |
| 2477 | 2597 | |
| 2478 | 2598 | if (__string_is_trivial_iterator<_ForwardIterator>::value && |
| 2479 | 2599 | (__cap >= __n || !__addr_in_range(*__first))) |
| ... | ... | @@ -2499,17 +2619,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For |
| 2499 | 2619 | } |
| 2500 | 2620 | |
| 2501 | 2621 | template <class _CharT, class _Traits, class _Allocator> |
| 2622 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2502 | 2623 | basic_string<_CharT, _Traits, _Allocator>& |
| 2503 | 2624 | basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) |
| 2504 | 2625 | { |
| 2505 | 2626 | size_type __sz = __str.size(); |
| 2506 | 2627 | if (__pos > __sz) |
| 2507 | 2628 | __throw_out_of_range(); |
| 2508 | return assign(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); | |
| 2629 | return assign(__str.data() + __pos, std::min(__n, __sz - __pos)); | |
| 2509 | 2630 | } |
| 2510 | 2631 | |
| 2511 | 2632 | template <class _CharT, class _Traits, class _Allocator> |
| 2512 | 2633 | template <class _Tp> |
| 2634 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2513 | 2635 | __enable_if_t |
| 2514 | 2636 | < |
| 2515 | 2637 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| ... | ... | @@ -2522,17 +2644,19 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp & __t, size_type __p |
| 2522 | 2644 | size_type __sz = __sv.size(); |
| 2523 | 2645 | if (__pos > __sz) |
| 2524 | 2646 | __throw_out_of_range(); |
| 2525 | return assign(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); | |
| 2647 | return assign(__sv.data() + __pos, std::min(__n, __sz - __pos)); | |
| 2526 | 2648 | } |
| 2527 | 2649 | |
| 2528 | 2650 | |
| 2529 | 2651 | template <class _CharT, class _Traits, class _Allocator> |
| 2652 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2530 | 2653 | basic_string<_CharT, _Traits, _Allocator>& |
| 2531 | 2654 | basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) { |
| 2532 | 2655 | return __assign_external(__s, traits_type::length(__s)); |
| 2533 | 2656 | } |
| 2534 | 2657 | |
| 2535 | 2658 | template <class _CharT, class _Traits, class _Allocator> |
| 2659 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2536 | 2660 | basic_string<_CharT, _Traits, _Allocator>& |
| 2537 | 2661 | basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) |
| 2538 | 2662 | { |
| ... | ... | @@ -2546,6 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) |
| 2546 | 2670 | // append |
| 2547 | 2671 | |
| 2548 | 2672 | template <class _CharT, class _Traits, class _Allocator> |
| 2673 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2549 | 2674 | basic_string<_CharT, _Traits, _Allocator>& |
| 2550 | 2675 | basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) |
| 2551 | 2676 | { |
| ... | ... | @@ -2556,7 +2681,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty |
| 2556 | 2681 | { |
| 2557 | 2682 | if (__n) |
| 2558 | 2683 | { |
| 2559 | value_type* __p = _VSTD::__to_address(__get_pointer()); | |
| 2684 | value_type* __p = std::__to_address(__get_pointer()); | |
| 2560 | 2685 | traits_type::copy(__p + __sz, __s, __n); |
| 2561 | 2686 | __sz += __n; |
| 2562 | 2687 | __set_size(__sz); |
| ... | ... | @@ -2569,6 +2694,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty |
| 2569 | 2694 | } |
| 2570 | 2695 | |
| 2571 | 2696 | template <class _CharT, class _Traits, class _Allocator> |
| 2697 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2572 | 2698 | basic_string<_CharT, _Traits, _Allocator>& |
| 2573 | 2699 | basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) |
| 2574 | 2700 | { |
| ... | ... | @@ -2579,7 +2705,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) |
| 2579 | 2705 | if (__cap - __sz < __n) |
| 2580 | 2706 | __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); |
| 2581 | 2707 | pointer __p = __get_pointer(); |
| 2582 | traits_type::assign(_VSTD::__to_address(__p) + __sz, __n, __c); | |
| 2708 | traits_type::assign(std::__to_address(__p) + __sz, __n, __c); | |
| 2583 | 2709 | __sz += __n; |
| 2584 | 2710 | __set_size(__sz); |
| 2585 | 2711 | traits_type::assign(__p[__sz], value_type()); |
| ... | ... | @@ -2588,7 +2714,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) |
| 2588 | 2714 | } |
| 2589 | 2715 | |
| 2590 | 2716 | template <class _CharT, class _Traits, class _Allocator> |
| 2591 | inline void | |
| 2717 | _LIBCPP_CONSTEXPR_AFTER_CXX17 inline void | |
| 2592 | 2718 | basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) |
| 2593 | 2719 | { |
| 2594 | 2720 | if (__n) |
| ... | ... | @@ -2605,6 +2731,7 @@ basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) |
| 2605 | 2731 | } |
| 2606 | 2732 | |
| 2607 | 2733 | template <class _CharT, class _Traits, class _Allocator> |
| 2734 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2608 | 2735 | void |
| 2609 | 2736 | basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) |
| 2610 | 2737 | { |
| ... | ... | @@ -2626,7 +2753,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) |
| 2626 | 2753 | __grow_by(__cap, 1, __sz, __sz, 0); |
| 2627 | 2754 | __is_short = false; // the string is always long after __grow_by |
| 2628 | 2755 | } |
| 2629 | pointer __p; | |
| 2756 | pointer __p = __get_pointer(); | |
| 2630 | 2757 | if (__is_short) |
| 2631 | 2758 | { |
| 2632 | 2759 | __p = __get_short_pointer() + __sz; |
| ... | ... | @@ -2643,6 +2770,7 @@ basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) |
| 2643 | 2770 | |
| 2644 | 2771 | template <class _CharT, class _Traits, class _Allocator> |
| 2645 | 2772 | template<class _ForwardIterator> |
| 2773 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2646 | 2774 | __enable_if_t |
| 2647 | 2775 | < |
| 2648 | 2776 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -2653,7 +2781,7 @@ basic_string<_CharT, _Traits, _Allocator>::append( |
| 2653 | 2781 | { |
| 2654 | 2782 | size_type __sz = size(); |
| 2655 | 2783 | size_type __cap = capacity(); |
| 2656 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | |
| 2784 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 2657 | 2785 | if (__n) |
| 2658 | 2786 | { |
| 2659 | 2787 | if (__string_is_trivial_iterator<_ForwardIterator>::value && |
| ... | ... | @@ -2677,7 +2805,7 @@ basic_string<_CharT, _Traits, _Allocator>::append( |
| 2677 | 2805 | } |
| 2678 | 2806 | |
| 2679 | 2807 | template <class _CharT, class _Traits, class _Allocator> |
| 2680 | inline | |
| 2808 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2681 | 2809 | basic_string<_CharT, _Traits, _Allocator>& |
| 2682 | 2810 | basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) |
| 2683 | 2811 | { |
| ... | ... | @@ -2685,17 +2813,19 @@ basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) |
| 2685 | 2813 | } |
| 2686 | 2814 | |
| 2687 | 2815 | template <class _CharT, class _Traits, class _Allocator> |
| 2816 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2688 | 2817 | basic_string<_CharT, _Traits, _Allocator>& |
| 2689 | 2818 | basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) |
| 2690 | 2819 | { |
| 2691 | 2820 | size_type __sz = __str.size(); |
| 2692 | 2821 | if (__pos > __sz) |
| 2693 | 2822 | __throw_out_of_range(); |
| 2694 | return append(__str.data() + __pos, _VSTD::min(__n, __sz - __pos)); | |
| 2823 | return append(__str.data() + __pos, std::min(__n, __sz - __pos)); | |
| 2695 | 2824 | } |
| 2696 | 2825 | |
| 2697 | 2826 | template <class _CharT, class _Traits, class _Allocator> |
| 2698 | 2827 | template <class _Tp> |
| 2828 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2699 | 2829 | __enable_if_t |
| 2700 | 2830 | < |
| 2701 | 2831 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| ... | ... | @@ -2707,10 +2837,11 @@ basic_string<_CharT, _Traits, _Allocator>::append(const _Tp & __t, size_type __p |
| 2707 | 2837 | size_type __sz = __sv.size(); |
| 2708 | 2838 | if (__pos > __sz) |
| 2709 | 2839 | __throw_out_of_range(); |
| 2710 | return append(__sv.data() + __pos, _VSTD::min(__n, __sz - __pos)); | |
| 2840 | return append(__sv.data() + __pos, std::min(__n, __sz - __pos)); | |
| 2711 | 2841 | } |
| 2712 | 2842 | |
| 2713 | 2843 | template <class _CharT, class _Traits, class _Allocator> |
| 2844 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2714 | 2845 | basic_string<_CharT, _Traits, _Allocator>& |
| 2715 | 2846 | basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) |
| 2716 | 2847 | { |
| ... | ... | @@ -2721,6 +2852,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) |
| 2721 | 2852 | // insert |
| 2722 | 2853 | |
| 2723 | 2854 | template <class _CharT, class _Traits, class _Allocator> |
| 2855 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2724 | 2856 | basic_string<_CharT, _Traits, _Allocator>& |
| 2725 | 2857 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) |
| 2726 | 2858 | { |
| ... | ... | @@ -2729,11 +2861,18 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t |
| 2729 | 2861 | if (__pos > __sz) |
| 2730 | 2862 | __throw_out_of_range(); |
| 2731 | 2863 | size_type __cap = capacity(); |
| 2864 | if (__libcpp_is_constant_evaluated()) { | |
| 2865 | if (__cap - __sz >= __n) | |
| 2866 | __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s); | |
| 2867 | else | |
| 2868 | __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); | |
| 2869 | return *this; | |
| 2870 | } | |
| 2732 | 2871 | if (__cap - __sz >= __n) |
| 2733 | 2872 | { |
| 2734 | 2873 | if (__n) |
| 2735 | 2874 | { |
| 2736 | value_type* __p = _VSTD::__to_address(__get_pointer()); | |
| 2875 | value_type* __p = std::__to_address(__get_pointer()); | |
| 2737 | 2876 | size_type __n_move = __sz - __pos; |
| 2738 | 2877 | if (__n_move != 0) |
| 2739 | 2878 | { |
| ... | ... | @@ -2753,6 +2892,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t |
| 2753 | 2892 | } |
| 2754 | 2893 | |
| 2755 | 2894 | template <class _CharT, class _Traits, class _Allocator> |
| 2895 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2756 | 2896 | basic_string<_CharT, _Traits, _Allocator>& |
| 2757 | 2897 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) |
| 2758 | 2898 | { |
| ... | ... | @@ -2765,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 2765 | 2905 | value_type* __p; |
| 2766 | 2906 | if (__cap - __sz >= __n) |
| 2767 | 2907 | { |
| 2768 | __p = _VSTD::__to_address(__get_pointer()); | |
| 2908 | __p = std::__to_address(__get_pointer()); | |
| 2769 | 2909 | size_type __n_move = __sz - __pos; |
| 2770 | 2910 | if (__n_move != 0) |
| 2771 | 2911 | traits_type::move(__p + __pos + __n, __p + __pos, __n_move); |
| ... | ... | @@ -2773,7 +2913,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 2773 | 2913 | else |
| 2774 | 2914 | { |
| 2775 | 2915 | __grow_by(__cap, __sz + __n - __cap, __sz, __pos, 0, __n); |
| 2776 | __p = _VSTD::__to_address(__get_long_pointer()); | |
| 2916 | __p = std::__to_address(__get_long_pointer()); | |
| 2777 | 2917 | } |
| 2778 | 2918 | traits_type::assign(__p + __pos, __n, __c); |
| 2779 | 2919 | __sz += __n; |
| ... | ... | @@ -2785,6 +2925,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n |
| 2785 | 2925 | |
| 2786 | 2926 | template <class _CharT, class _Traits, class _Allocator> |
| 2787 | 2927 | template<class _InputIterator> |
| 2928 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2788 | 2929 | __enable_if_t |
| 2789 | 2930 | < |
| 2790 | 2931 | __is_exactly_cpp17_input_iterator<_InputIterator>::value, |
| ... | ... | @@ -2801,6 +2942,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt |
| 2801 | 2942 | |
| 2802 | 2943 | template <class _CharT, class _Traits, class _Allocator> |
| 2803 | 2944 | template<class _ForwardIterator> |
| 2945 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2804 | 2946 | __enable_if_t |
| 2805 | 2947 | < |
| 2806 | 2948 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -2808,49 +2950,27 @@ __enable_if_t |
| 2808 | 2950 | > |
| 2809 | 2951 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) |
| 2810 | 2952 | { |
| 2811 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2812 | "string::insert(iterator, range) called with an iterator not" | |
| 2813 | " referring to this string"); | |
| 2953 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, | |
| 2954 | "string::insert(iterator, range) called with an iterator not referring to this string"); | |
| 2814 | 2955 | |
| 2815 | 2956 | size_type __ip = static_cast<size_type>(__pos - begin()); |
| 2816 | size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); | |
| 2817 | if (__n) | |
| 2957 | size_type __n = static_cast<size_type>(std::distance(__first, __last)); | |
| 2958 | if (__n == 0) | |
| 2959 | return begin() + __ip; | |
| 2960 | ||
| 2961 | if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) | |
| 2818 | 2962 | { |
| 2819 | if (__string_is_trivial_iterator<_ForwardIterator>::value && | |
| 2820 | !__addr_in_range(*__first)) | |
| 2821 | { | |
| 2822 | size_type __sz = size(); | |
| 2823 | size_type __cap = capacity(); | |
| 2824 | value_type* __p; | |
| 2825 | if (__cap - __sz >= __n) | |
| 2826 | { | |
| 2827 | __p = _VSTD::__to_address(__get_pointer()); | |
| 2828 | size_type __n_move = __sz - __ip; | |
| 2829 | if (__n_move != 0) | |
| 2830 | traits_type::move(__p + __ip + __n, __p + __ip, __n_move); | |
| 2831 | } | |
| 2832 | else | |
| 2833 | { | |
| 2834 | __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n); | |
| 2835 | __p = _VSTD::__to_address(__get_long_pointer()); | |
| 2836 | } | |
| 2837 | __sz += __n; | |
| 2838 | __set_size(__sz); | |
| 2839 | traits_type::assign(__p[__sz], value_type()); | |
| 2840 | for (__p += __ip; __first != __last; ++__p, (void) ++__first) | |
| 2841 | traits_type::assign(*__p, *__first); | |
| 2842 | } | |
| 2843 | else | |
| 2844 | { | |
| 2845 | const basic_string __temp(__first, __last, __alloc()); | |
| 2846 | return insert(__pos, __temp.data(), __temp.data() + __temp.size()); | |
| 2847 | } | |
| 2963 | return __insert_from_safe_copy(__n, __ip, __first, __last); | |
| 2964 | } | |
| 2965 | else | |
| 2966 | { | |
| 2967 | const basic_string __temp(__first, __last, __alloc()); | |
| 2968 | return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end()); | |
| 2848 | 2969 | } |
| 2849 | return begin() + __ip; | |
| 2850 | 2970 | } |
| 2851 | 2971 | |
| 2852 | 2972 | template <class _CharT, class _Traits, class _Allocator> |
| 2853 | inline | |
| 2973 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2854 | 2974 | basic_string<_CharT, _Traits, _Allocator>& |
| 2855 | 2975 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) |
| 2856 | 2976 | { |
| ... | ... | @@ -2858,6 +2978,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_ |
| 2858 | 2978 | } |
| 2859 | 2979 | |
| 2860 | 2980 | template <class _CharT, class _Traits, class _Allocator> |
| 2981 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2861 | 2982 | basic_string<_CharT, _Traits, _Allocator>& |
| 2862 | 2983 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str, |
| 2863 | 2984 | size_type __pos2, size_type __n) |
| ... | ... | @@ -2865,11 +2986,12 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_ |
| 2865 | 2986 | size_type __str_sz = __str.size(); |
| 2866 | 2987 | if (__pos2 > __str_sz) |
| 2867 | 2988 | __throw_out_of_range(); |
| 2868 | return insert(__pos1, __str.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); | |
| 2989 | return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2)); | |
| 2869 | 2990 | } |
| 2870 | 2991 | |
| 2871 | 2992 | template <class _CharT, class _Traits, class _Allocator> |
| 2872 | 2993 | template <class _Tp> |
| 2994 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2873 | 2995 | __enable_if_t |
| 2874 | 2996 | < |
| 2875 | 2997 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| ... | ... | @@ -2882,10 +3004,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& _ |
| 2882 | 3004 | size_type __str_sz = __sv.size(); |
| 2883 | 3005 | if (__pos2 > __str_sz) |
| 2884 | 3006 | __throw_out_of_range(); |
| 2885 | return insert(__pos1, __sv.data() + __pos2, _VSTD::min(__n, __str_sz - __pos2)); | |
| 3007 | return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2)); | |
| 2886 | 3008 | } |
| 2887 | 3009 | |
| 2888 | 3010 | template <class _CharT, class _Traits, class _Allocator> |
| 3011 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2889 | 3012 | basic_string<_CharT, _Traits, _Allocator>& |
| 2890 | 3013 | basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) |
| 2891 | 3014 | { |
| ... | ... | @@ -2894,6 +3017,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t |
| 2894 | 3017 | } |
| 2895 | 3018 | |
| 2896 | 3019 | template <class _CharT, class _Traits, class _Allocator> |
| 3020 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2897 | 3021 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2898 | 3022 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_type __c) |
| 2899 | 3023 | { |
| ... | ... | @@ -2908,11 +3032,11 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty |
| 2908 | 3032 | if (__cap == __sz) |
| 2909 | 3033 | { |
| 2910 | 3034 | __grow_by(__cap, 1, __sz, __ip, 0, 1); |
| 2911 | __p = _VSTD::__to_address(__get_long_pointer()); | |
| 3035 | __p = std::__to_address(__get_long_pointer()); | |
| 2912 | 3036 | } |
| 2913 | 3037 | else |
| 2914 | 3038 | { |
| 2915 | __p = _VSTD::__to_address(__get_pointer()); | |
| 3039 | __p = std::__to_address(__get_pointer()); | |
| 2916 | 3040 | size_type __n_move = __sz - __ip; |
| 2917 | 3041 | if (__n_move != 0) |
| 2918 | 3042 | traits_type::move(__p + __ip + 1, __p + __ip, __n_move); |
| ... | ... | @@ -2924,7 +3048,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty |
| 2924 | 3048 | } |
| 2925 | 3049 | |
| 2926 | 3050 | template <class _CharT, class _Traits, class _Allocator> |
| 2927 | inline | |
| 3051 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2928 | 3052 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 2929 | 3053 | basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) |
| 2930 | 3054 | { |
| ... | ... | @@ -2939,6 +3063,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_typ |
| 2939 | 3063 | // replace |
| 2940 | 3064 | |
| 2941 | 3065 | template <class _CharT, class _Traits, class _Allocator> |
| 3066 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2942 | 3067 | basic_string<_CharT, _Traits, _Allocator>& |
| 2943 | 3068 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) |
| 2944 | 3069 | _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK |
| ... | ... | @@ -2947,11 +3072,15 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 2947 | 3072 | size_type __sz = size(); |
| 2948 | 3073 | if (__pos > __sz) |
| 2949 | 3074 | __throw_out_of_range(); |
| 2950 | __n1 = _VSTD::min(__n1, __sz - __pos); | |
| 3075 | __n1 = std::min(__n1, __sz - __pos); | |
| 2951 | 3076 | size_type __cap = capacity(); |
| 2952 | 3077 | if (__cap - __sz + __n1 >= __n2) |
| 2953 | 3078 | { |
| 2954 | value_type* __p = _VSTD::__to_address(__get_pointer()); | |
| 3079 | if (__libcpp_is_constant_evaluated()) { | |
| 3080 | __grow_by_and_replace(__cap, 0, __sz, __pos, __n1, __n2, __s); | |
| 3081 | return *this; | |
| 3082 | } | |
| 3083 | value_type* __p = std::__to_address(__get_pointer()); | |
| 2955 | 3084 | if (__n1 != __n2) |
| 2956 | 3085 | { |
| 2957 | 3086 | size_type __n_move = __sz - __pos - __n1; |
| ... | ... | @@ -2988,18 +3117,19 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 2988 | 3117 | } |
| 2989 | 3118 | |
| 2990 | 3119 | template <class _CharT, class _Traits, class _Allocator> |
| 3120 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2991 | 3121 | basic_string<_CharT, _Traits, _Allocator>& |
| 2992 | 3122 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) |
| 2993 | 3123 | { |
| 2994 | 3124 | size_type __sz = size(); |
| 2995 | 3125 | if (__pos > __sz) |
| 2996 | 3126 | __throw_out_of_range(); |
| 2997 | __n1 = _VSTD::min(__n1, __sz - __pos); | |
| 3127 | __n1 = std::min(__n1, __sz - __pos); | |
| 2998 | 3128 | size_type __cap = capacity(); |
| 2999 | 3129 | value_type* __p; |
| 3000 | 3130 | if (__cap - __sz + __n1 >= __n2) |
| 3001 | 3131 | { |
| 3002 | __p = _VSTD::__to_address(__get_pointer()); | |
| 3132 | __p = std::__to_address(__get_pointer()); | |
| 3003 | 3133 | if (__n1 != __n2) |
| 3004 | 3134 | { |
| 3005 | 3135 | size_type __n_move = __sz - __pos - __n1; |
| ... | ... | @@ -3010,7 +3140,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3010 | 3140 | else |
| 3011 | 3141 | { |
| 3012 | 3142 | __grow_by(__cap, __sz - __n1 + __n2 - __cap, __sz, __pos, __n1, __n2); |
| 3013 | __p = _VSTD::__to_address(__get_long_pointer()); | |
| 3143 | __p = std::__to_address(__get_long_pointer()); | |
| 3014 | 3144 | } |
| 3015 | 3145 | traits_type::assign(__p + __pos, __n2, __c); |
| 3016 | 3146 | return __null_terminate_at(__p, __sz - (__n1 - __n2)); |
| ... | ... | @@ -3018,6 +3148,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3018 | 3148 | |
| 3019 | 3149 | template <class _CharT, class _Traits, class _Allocator> |
| 3020 | 3150 | template<class _InputIterator> |
| 3151 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3021 | 3152 | __enable_if_t |
| 3022 | 3153 | < |
| 3023 | 3154 | __is_cpp17_input_iterator<_InputIterator>::value, |
| ... | ... | @@ -3031,7 +3162,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 3031 | 3162 | } |
| 3032 | 3163 | |
| 3033 | 3164 | template <class _CharT, class _Traits, class _Allocator> |
| 3034 | inline | |
| 3165 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3035 | 3166 | basic_string<_CharT, _Traits, _Allocator>& |
| 3036 | 3167 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) |
| 3037 | 3168 | { |
| ... | ... | @@ -3039,6 +3170,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ |
| 3039 | 3170 | } |
| 3040 | 3171 | |
| 3041 | 3172 | template <class _CharT, class _Traits, class _Allocator> |
| 3173 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3042 | 3174 | basic_string<_CharT, _Traits, _Allocator>& |
| 3043 | 3175 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str, |
| 3044 | 3176 | size_type __pos2, size_type __n2) |
| ... | ... | @@ -3046,11 +3178,12 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ |
| 3046 | 3178 | size_type __str_sz = __str.size(); |
| 3047 | 3179 | if (__pos2 > __str_sz) |
| 3048 | 3180 | __throw_out_of_range(); |
| 3049 | return replace(__pos1, __n1, __str.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); | |
| 3181 | return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2)); | |
| 3050 | 3182 | } |
| 3051 | 3183 | |
| 3052 | 3184 | template <class _CharT, class _Traits, class _Allocator> |
| 3053 | 3185 | template <class _Tp> |
| 3186 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3054 | 3187 | __enable_if_t |
| 3055 | 3188 | < |
| 3056 | 3189 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value && !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value, |
| ... | ... | @@ -3063,10 +3196,11 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type _ |
| 3063 | 3196 | size_type __str_sz = __sv.size(); |
| 3064 | 3197 | if (__pos2 > __str_sz) |
| 3065 | 3198 | __throw_out_of_range(); |
| 3066 | return replace(__pos1, __n1, __sv.data() + __pos2, _VSTD::min(__n2, __str_sz - __pos2)); | |
| 3199 | return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2)); | |
| 3067 | 3200 | } |
| 3068 | 3201 | |
| 3069 | 3202 | template <class _CharT, class _Traits, class _Allocator> |
| 3203 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3070 | 3204 | basic_string<_CharT, _Traits, _Allocator>& |
| 3071 | 3205 | basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) |
| 3072 | 3206 | { |
| ... | ... | @@ -3075,7 +3209,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __ |
| 3075 | 3209 | } |
| 3076 | 3210 | |
| 3077 | 3211 | template <class _CharT, class _Traits, class _Allocator> |
| 3078 | inline | |
| 3212 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3079 | 3213 | basic_string<_CharT, _Traits, _Allocator>& |
| 3080 | 3214 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) |
| 3081 | 3215 | { |
| ... | ... | @@ -3084,7 +3218,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 3084 | 3218 | } |
| 3085 | 3219 | |
| 3086 | 3220 | template <class _CharT, class _Traits, class _Allocator> |
| 3087 | inline | |
| 3221 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3088 | 3222 | basic_string<_CharT, _Traits, _Allocator>& |
| 3089 | 3223 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) |
| 3090 | 3224 | { |
| ... | ... | @@ -3092,7 +3226,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 3092 | 3226 | } |
| 3093 | 3227 | |
| 3094 | 3228 | template <class _CharT, class _Traits, class _Allocator> |
| 3095 | inline | |
| 3229 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3096 | 3230 | basic_string<_CharT, _Traits, _Allocator>& |
| 3097 | 3231 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) |
| 3098 | 3232 | { |
| ... | ... | @@ -3100,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 3100 | 3234 | } |
| 3101 | 3235 | |
| 3102 | 3236 | template <class _CharT, class _Traits, class _Allocator> |
| 3103 | inline | |
| 3237 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3104 | 3238 | basic_string<_CharT, _Traits, _Allocator>& |
| 3105 | 3239 | basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) |
| 3106 | 3240 | { |
| ... | ... | @@ -3112,6 +3246,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it |
| 3112 | 3246 | // 'externally instantiated' erase() implementation, called when __n != npos. |
| 3113 | 3247 | // Does not check __pos against size() |
| 3114 | 3248 | template <class _CharT, class _Traits, class _Allocator> |
| 3249 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3115 | 3250 | void |
| 3116 | 3251 | basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( |
| 3117 | 3252 | size_type __pos, size_type __n) |
| ... | ... | @@ -3119,8 +3254,8 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( |
| 3119 | 3254 | if (__n) |
| 3120 | 3255 | { |
| 3121 | 3256 | size_type __sz = size(); |
| 3122 | value_type* __p = _VSTD::__to_address(__get_pointer()); | |
| 3123 | __n = _VSTD::min(__n, __sz - __pos); | |
| 3257 | value_type* __p = std::__to_address(__get_pointer()); | |
| 3258 | __n = std::min(__n, __sz - __pos); | |
| 3124 | 3259 | size_type __n_move = __sz - __pos - __n; |
| 3125 | 3260 | if (__n_move != 0) |
| 3126 | 3261 | traits_type::move(__p + __pos, __p + __pos + __n, __n_move); |
| ... | ... | @@ -3129,6 +3264,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move( |
| 3129 | 3264 | } |
| 3130 | 3265 | |
| 3131 | 3266 | template <class _CharT, class _Traits, class _Allocator> |
| 3267 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3132 | 3268 | basic_string<_CharT, _Traits, _Allocator>& |
| 3133 | 3269 | basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, |
| 3134 | 3270 | size_type __n) { |
| ... | ... | @@ -3143,7 +3279,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, |
| 3143 | 3279 | } |
| 3144 | 3280 | |
| 3145 | 3281 | template <class _CharT, class _Traits, class _Allocator> |
| 3146 | inline | |
| 3282 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3147 | 3283 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 3148 | 3284 | basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) |
| 3149 | 3285 | { |
| ... | ... | @@ -3159,7 +3295,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) |
| 3159 | 3295 | } |
| 3160 | 3296 | |
| 3161 | 3297 | template <class _CharT, class _Traits, class _Allocator> |
| 3162 | inline | |
| 3298 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3163 | 3299 | typename basic_string<_CharT, _Traits, _Allocator>::iterator |
| 3164 | 3300 | basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 3165 | 3301 | { |
| ... | ... | @@ -3175,7 +3311,7 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i |
| 3175 | 3311 | } |
| 3176 | 3312 | |
| 3177 | 3313 | template <class _CharT, class _Traits, class _Allocator> |
| 3178 | inline | |
| 3314 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3179 | 3315 | void |
| 3180 | 3316 | basic_string<_CharT, _Traits, _Allocator>::pop_back() |
| 3181 | 3317 | { |
| ... | ... | @@ -3184,11 +3320,11 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back() |
| 3184 | 3320 | } |
| 3185 | 3321 | |
| 3186 | 3322 | template <class _CharT, class _Traits, class _Allocator> |
| 3187 | inline | |
| 3323 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3188 | 3324 | void |
| 3189 | 3325 | basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT |
| 3190 | 3326 | { |
| 3191 | __invalidate_all_iterators(); | |
| 3327 | std::__debug_db_invalidate_all(this); | |
| 3192 | 3328 | if (__is_long()) |
| 3193 | 3329 | { |
| 3194 | 3330 | traits_type::assign(*__get_long_pointer(), value_type()); |
| ... | ... | @@ -3202,14 +3338,15 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT |
| 3202 | 3338 | } |
| 3203 | 3339 | |
| 3204 | 3340 | template <class _CharT, class _Traits, class _Allocator> |
| 3205 | inline | |
| 3341 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3206 | 3342 | void |
| 3207 | 3343 | basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) |
| 3208 | 3344 | { |
| 3209 | __null_terminate_at(_VSTD::__to_address(__get_pointer()), __pos); | |
| 3345 | __null_terminate_at(std::__to_address(__get_pointer()), __pos); | |
| 3210 | 3346 | } |
| 3211 | 3347 | |
| 3212 | 3348 | template <class _CharT, class _Traits, class _Allocator> |
| 3349 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3213 | 3350 | void |
| 3214 | 3351 | basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) |
| 3215 | 3352 | { |
| ... | ... | @@ -3221,7 +3358,7 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) |
| 3221 | 3358 | } |
| 3222 | 3359 | |
| 3223 | 3360 | template <class _CharT, class _Traits, class _Allocator> |
| 3224 | inline void | |
| 3361 | _LIBCPP_CONSTEXPR_AFTER_CXX17 inline void | |
| 3225 | 3362 | basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) |
| 3226 | 3363 | { |
| 3227 | 3364 | size_type __sz = size(); |
| ... | ... | @@ -3232,19 +3369,21 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) |
| 3232 | 3369 | } |
| 3233 | 3370 | |
| 3234 | 3371 | template <class _CharT, class _Traits, class _Allocator> |
| 3235 | inline | |
| 3372 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3236 | 3373 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3237 | 3374 | basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT |
| 3238 | 3375 | { |
| 3239 | 3376 | size_type __m = __alloc_traits::max_size(__alloc()); |
| 3240 | #ifdef _LIBCPP_BIG_ENDIAN | |
| 3241 | return (__m <= ~__long_mask ? __m : __m/2) - __alignment; | |
| 3242 | #else | |
| 3243 | return __m - __alignment; | |
| 3244 | #endif | |
| 3377 | if (__m <= std::numeric_limits<size_type>::max() / 2) { | |
| 3378 | return __m - __alignment; | |
| 3379 | } else { | |
| 3380 | bool __uses_lsb = __endian_factor == 2; | |
| 3381 | return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment; | |
| 3382 | } | |
| 3245 | 3383 | } |
| 3246 | 3384 | |
| 3247 | 3385 | template <class _CharT, class _Traits, class _Allocator> |
| 3386 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3248 | 3387 | void |
| 3249 | 3388 | basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) |
| 3250 | 3389 | { |
| ... | ... | @@ -3257,7 +3396,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit |
| 3257 | 3396 | if (__requested_capacity <= capacity()) |
| 3258 | 3397 | return; |
| 3259 | 3398 | |
| 3260 | size_type __target_capacity = _VSTD::max(__requested_capacity, size()); | |
| 3399 | size_type __target_capacity = std::max(__requested_capacity, size()); | |
| 3261 | 3400 | __target_capacity = __recommend(__target_capacity); |
| 3262 | 3401 | if (__target_capacity == capacity()) return; |
| 3263 | 3402 | |
| ... | ... | @@ -3265,7 +3404,7 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacit |
| 3265 | 3404 | } |
| 3266 | 3405 | |
| 3267 | 3406 | template <class _CharT, class _Traits, class _Allocator> |
| 3268 | inline | |
| 3407 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3269 | 3408 | void |
| 3270 | 3409 | basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 3271 | 3410 | { |
| ... | ... | @@ -3276,7 +3415,7 @@ basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 3276 | 3415 | } |
| 3277 | 3416 | |
| 3278 | 3417 | template <class _CharT, class _Traits, class _Allocator> |
| 3279 | inline | |
| 3418 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3280 | 3419 | void |
| 3281 | 3420 | basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) |
| 3282 | 3421 | { |
| ... | ... | @@ -3285,7 +3424,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3285 | 3424 | |
| 3286 | 3425 | pointer __new_data, __p; |
| 3287 | 3426 | bool __was_long, __now_long; |
| 3288 | if (__target_capacity == __min_cap - 1) | |
| 3427 | if (__fits_in_sso(__target_capacity)) | |
| 3289 | 3428 | { |
| 3290 | 3429 | __was_long = true; |
| 3291 | 3430 | __now_long = false; |
| ... | ... | @@ -3294,15 +3433,20 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3294 | 3433 | } |
| 3295 | 3434 | else |
| 3296 | 3435 | { |
| 3297 | if (__target_capacity > __cap) | |
| 3298 | __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1); | |
| 3436 | if (__target_capacity > __cap) { | |
| 3437 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); | |
| 3438 | __new_data = __allocation.ptr; | |
| 3439 | __target_capacity = __allocation.count - 1; | |
| 3440 | } | |
| 3299 | 3441 | else |
| 3300 | 3442 | { |
| 3301 | 3443 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3302 | 3444 | try |
| 3303 | 3445 | { |
| 3304 | 3446 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 3305 | __new_data = __alloc_traits::allocate(__alloc(), __target_capacity+1); | |
| 3447 | auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1); | |
| 3448 | __new_data = __allocation.ptr; | |
| 3449 | __target_capacity = __allocation.count - 1; | |
| 3306 | 3450 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 3307 | 3451 | } |
| 3308 | 3452 | catch (...) |
| ... | ... | @@ -3314,12 +3458,13 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3314 | 3458 | return; |
| 3315 | 3459 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 3316 | 3460 | } |
| 3461 | __begin_lifetime(__new_data, __target_capacity + 1); | |
| 3317 | 3462 | __now_long = true; |
| 3318 | 3463 | __was_long = __is_long(); |
| 3319 | 3464 | __p = __get_pointer(); |
| 3320 | 3465 | } |
| 3321 | traits_type::copy(_VSTD::__to_address(__new_data), | |
| 3322 | _VSTD::__to_address(__p), size()+1); | |
| 3466 | traits_type::copy(std::__to_address(__new_data), | |
| 3467 | std::__to_address(__p), size()+1); | |
| 3323 | 3468 | if (__was_long) |
| 3324 | 3469 | __alloc_traits::deallocate(__alloc(), __p, __cap+1); |
| 3325 | 3470 | if (__now_long) |
| ... | ... | @@ -3330,11 +3475,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target |
| 3330 | 3475 | } |
| 3331 | 3476 | else |
| 3332 | 3477 | __set_short_size(__sz); |
| 3333 | __invalidate_all_iterators(); | |
| 3478 | std::__debug_db_invalidate_all(this); | |
| 3334 | 3479 | } |
| 3335 | 3480 | |
| 3336 | 3481 | template <class _CharT, class _Traits, class _Allocator> |
| 3337 | inline | |
| 3482 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3338 | 3483 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference |
| 3339 | 3484 | basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NOEXCEPT |
| 3340 | 3485 | { |
| ... | ... | @@ -3343,7 +3488,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const _NO |
| 3343 | 3488 | } |
| 3344 | 3489 | |
| 3345 | 3490 | template <class _CharT, class _Traits, class _Allocator> |
| 3346 | inline | |
| 3491 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3347 | 3492 | typename basic_string<_CharT, _Traits, _Allocator>::reference |
| 3348 | 3493 | basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT |
| 3349 | 3494 | { |
| ... | ... | @@ -3352,6 +3497,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) _NOEXCEPT |
| 3352 | 3497 | } |
| 3353 | 3498 | |
| 3354 | 3499 | template <class _CharT, class _Traits, class _Allocator> |
| 3500 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3355 | 3501 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference |
| 3356 | 3502 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const |
| 3357 | 3503 | { |
| ... | ... | @@ -3361,6 +3507,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const |
| 3361 | 3507 | } |
| 3362 | 3508 | |
| 3363 | 3509 | template <class _CharT, class _Traits, class _Allocator> |
| 3510 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3364 | 3511 | typename basic_string<_CharT, _Traits, _Allocator>::reference |
| 3365 | 3512 | basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) |
| 3366 | 3513 | { |
| ... | ... | @@ -3370,7 +3517,7 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) |
| 3370 | 3517 | } |
| 3371 | 3518 | |
| 3372 | 3519 | template <class _CharT, class _Traits, class _Allocator> |
| 3373 | inline | |
| 3520 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3374 | 3521 | typename basic_string<_CharT, _Traits, _Allocator>::reference |
| 3375 | 3522 | basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT |
| 3376 | 3523 | { |
| ... | ... | @@ -3379,7 +3526,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() _NOEXCEPT |
| 3379 | 3526 | } |
| 3380 | 3527 | |
| 3381 | 3528 | template <class _CharT, class _Traits, class _Allocator> |
| 3382 | inline | |
| 3529 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3383 | 3530 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference |
| 3384 | 3531 | basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT |
| 3385 | 3532 | { |
| ... | ... | @@ -3388,7 +3535,7 @@ basic_string<_CharT, _Traits, _Allocator>::front() const _NOEXCEPT |
| 3388 | 3535 | } |
| 3389 | 3536 | |
| 3390 | 3537 | template <class _CharT, class _Traits, class _Allocator> |
| 3391 | inline | |
| 3538 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3392 | 3539 | typename basic_string<_CharT, _Traits, _Allocator>::reference |
| 3393 | 3540 | basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT |
| 3394 | 3541 | { |
| ... | ... | @@ -3397,7 +3544,7 @@ basic_string<_CharT, _Traits, _Allocator>::back() _NOEXCEPT |
| 3397 | 3544 | } |
| 3398 | 3545 | |
| 3399 | 3546 | template <class _CharT, class _Traits, class _Allocator> |
| 3400 | inline | |
| 3547 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3401 | 3548 | typename basic_string<_CharT, _Traits, _Allocator>::const_reference |
| 3402 | 3549 | basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT |
| 3403 | 3550 | { |
| ... | ... | @@ -3406,19 +3553,20 @@ basic_string<_CharT, _Traits, _Allocator>::back() const _NOEXCEPT |
| 3406 | 3553 | } |
| 3407 | 3554 | |
| 3408 | 3555 | template <class _CharT, class _Traits, class _Allocator> |
| 3556 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3409 | 3557 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3410 | 3558 | basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const |
| 3411 | 3559 | { |
| 3412 | 3560 | size_type __sz = size(); |
| 3413 | 3561 | if (__pos > __sz) |
| 3414 | 3562 | __throw_out_of_range(); |
| 3415 | size_type __rlen = _VSTD::min(__n, __sz - __pos); | |
| 3563 | size_type __rlen = std::min(__n, __sz - __pos); | |
| 3416 | 3564 | traits_type::copy(__s, data() + __pos, __rlen); |
| 3417 | 3565 | return __rlen; |
| 3418 | 3566 | } |
| 3419 | 3567 | |
| 3420 | 3568 | template <class _CharT, class _Traits, class _Allocator> |
| 3421 | inline | |
| 3569 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3422 | 3570 | basic_string<_CharT, _Traits, _Allocator> |
| 3423 | 3571 | basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const |
| 3424 | 3572 | { |
| ... | ... | @@ -3426,7 +3574,7 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n |
| 3426 | 3574 | } |
| 3427 | 3575 | |
| 3428 | 3576 | template <class _CharT, class _Traits, class _Allocator> |
| 3429 | inline | |
| 3577 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3430 | 3578 | void |
| 3431 | 3579 | basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) |
| 3432 | 3580 | #if _LIBCPP_STD_VER >= 14 |
| ... | ... | @@ -3436,21 +3584,18 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) |
| 3436 | 3584 | __is_nothrow_swappable<allocator_type>::value) |
| 3437 | 3585 | #endif |
| 3438 | 3586 | { |
| 3439 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 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 | } | |
| 3447 | #endif | |
| 3587 | if (!__is_long()) | |
| 3588 | std::__debug_db_invalidate_all(this); | |
| 3589 | if (!__str.__is_long()) | |
| 3590 | std::__debug_db_invalidate_all(&__str); | |
| 3591 | std::__debug_db_swap(this, &__str); | |
| 3592 | ||
| 3448 | 3593 | _LIBCPP_ASSERT( |
| 3449 | 3594 | __alloc_traits::propagate_on_container_swap::value || |
| 3450 | 3595 | __alloc_traits::is_always_equal::value || |
| 3451 | 3596 | __alloc() == __str.__alloc(), "swapping non-equal allocators"); |
| 3452 | _VSTD::swap(__r_.first(), __str.__r_.first()); | |
| 3453 | _VSTD::__swap_allocator(__alloc(), __str.__alloc()); | |
| 3597 | std::swap(__r_.first(), __str.__r_.first()); | |
| 3598 | std::__swap_allocator(__alloc(), __str.__alloc()); | |
| 3454 | 3599 | } |
| 3455 | 3600 | |
| 3456 | 3601 | // find |
| ... | ... | @@ -3459,12 +3604,13 @@ template <class _Traits> |
| 3459 | 3604 | struct _LIBCPP_HIDDEN __traits_eq |
| 3460 | 3605 | { |
| 3461 | 3606 | typedef typename _Traits::char_type char_type; |
| 3462 | _LIBCPP_INLINE_VISIBILITY | |
| 3607 | _LIBCPP_HIDE_FROM_ABI | |
| 3463 | 3608 | bool operator()(const char_type& __x, const char_type& __y) _NOEXCEPT |
| 3464 | 3609 | {return _Traits::eq(__x, __y);} |
| 3465 | 3610 | }; |
| 3466 | 3611 | |
| 3467 | 3612 | template<class _CharT, class _Traits, class _Allocator> |
| 3613 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3468 | 3614 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3469 | 3615 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, |
| 3470 | 3616 | size_type __pos, |
| ... | ... | @@ -3476,7 +3622,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, |
| 3476 | 3622 | } |
| 3477 | 3623 | |
| 3478 | 3624 | template<class _CharT, class _Traits, class _Allocator> |
| 3479 | inline | |
| 3625 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3480 | 3626 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3481 | 3627 | basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, |
| 3482 | 3628 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3487,6 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, |
| 3487 | 3633 | |
| 3488 | 3634 | template<class _CharT, class _Traits, class _Allocator> |
| 3489 | 3635 | template <class _Tp> |
| 3636 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3490 | 3637 | __enable_if_t |
| 3491 | 3638 | < |
| 3492 | 3639 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3501,7 +3648,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const _Tp &__t, |
| 3501 | 3648 | } |
| 3502 | 3649 | |
| 3503 | 3650 | template<class _CharT, class _Traits, class _Allocator> |
| 3504 | inline | |
| 3651 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3505 | 3652 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3506 | 3653 | basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, |
| 3507 | 3654 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3512,6 +3659,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, |
| 3512 | 3659 | } |
| 3513 | 3660 | |
| 3514 | 3661 | template<class _CharT, class _Traits, class _Allocator> |
| 3662 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3515 | 3663 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3516 | 3664 | basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, |
| 3517 | 3665 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3523,6 +3671,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, |
| 3523 | 3671 | // rfind |
| 3524 | 3672 | |
| 3525 | 3673 | template<class _CharT, class _Traits, class _Allocator> |
| 3674 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3526 | 3675 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3527 | 3676 | basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, |
| 3528 | 3677 | size_type __pos, |
| ... | ... | @@ -3534,7 +3683,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, |
| 3534 | 3683 | } |
| 3535 | 3684 | |
| 3536 | 3685 | template<class _CharT, class _Traits, class _Allocator> |
| 3537 | inline | |
| 3686 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3538 | 3687 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3539 | 3688 | basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, |
| 3540 | 3689 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3545,6 +3694,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, |
| 3545 | 3694 | |
| 3546 | 3695 | template<class _CharT, class _Traits, class _Allocator> |
| 3547 | 3696 | template <class _Tp> |
| 3697 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3548 | 3698 | __enable_if_t |
| 3549 | 3699 | < |
| 3550 | 3700 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3559,7 +3709,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, |
| 3559 | 3709 | } |
| 3560 | 3710 | |
| 3561 | 3711 | template<class _CharT, class _Traits, class _Allocator> |
| 3562 | inline | |
| 3712 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3563 | 3713 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3564 | 3714 | basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, |
| 3565 | 3715 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3570,6 +3720,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, |
| 3570 | 3720 | } |
| 3571 | 3721 | |
| 3572 | 3722 | template<class _CharT, class _Traits, class _Allocator> |
| 3723 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3573 | 3724 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3574 | 3725 | basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, |
| 3575 | 3726 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3581,6 +3732,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, |
| 3581 | 3732 | // find_first_of |
| 3582 | 3733 | |
| 3583 | 3734 | template<class _CharT, class _Traits, class _Allocator> |
| 3735 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3584 | 3736 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3585 | 3737 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, |
| 3586 | 3738 | size_type __pos, |
| ... | ... | @@ -3592,7 +3744,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, |
| 3592 | 3744 | } |
| 3593 | 3745 | |
| 3594 | 3746 | template<class _CharT, class _Traits, class _Allocator> |
| 3595 | inline | |
| 3747 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3596 | 3748 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3597 | 3749 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, |
| 3598 | 3750 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3603,6 +3755,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s |
| 3603 | 3755 | |
| 3604 | 3756 | template<class _CharT, class _Traits, class _Allocator> |
| 3605 | 3757 | template <class _Tp> |
| 3758 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3606 | 3759 | __enable_if_t |
| 3607 | 3760 | < |
| 3608 | 3761 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3617,7 +3770,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, |
| 3617 | 3770 | } |
| 3618 | 3771 | |
| 3619 | 3772 | template<class _CharT, class _Traits, class _Allocator> |
| 3620 | inline | |
| 3773 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3621 | 3774 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3622 | 3775 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, |
| 3623 | 3776 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3628,7 +3781,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, |
| 3628 | 3781 | } |
| 3629 | 3782 | |
| 3630 | 3783 | template<class _CharT, class _Traits, class _Allocator> |
| 3631 | inline | |
| 3784 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3632 | 3785 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3633 | 3786 | basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, |
| 3634 | 3787 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3639,6 +3792,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, |
| 3639 | 3792 | // find_last_of |
| 3640 | 3793 | |
| 3641 | 3794 | template<class _CharT, class _Traits, class _Allocator> |
| 3795 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3642 | 3796 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3643 | 3797 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, |
| 3644 | 3798 | size_type __pos, |
| ... | ... | @@ -3650,7 +3804,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, |
| 3650 | 3804 | } |
| 3651 | 3805 | |
| 3652 | 3806 | template<class _CharT, class _Traits, class _Allocator> |
| 3653 | inline | |
| 3807 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3654 | 3808 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3655 | 3809 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, |
| 3656 | 3810 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3661,6 +3815,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st |
| 3661 | 3815 | |
| 3662 | 3816 | template<class _CharT, class _Traits, class _Allocator> |
| 3663 | 3817 | template <class _Tp> |
| 3818 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3664 | 3819 | __enable_if_t |
| 3665 | 3820 | < |
| 3666 | 3821 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3675,7 +3830,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, |
| 3675 | 3830 | } |
| 3676 | 3831 | |
| 3677 | 3832 | template<class _CharT, class _Traits, class _Allocator> |
| 3678 | inline | |
| 3833 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3679 | 3834 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3680 | 3835 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, |
| 3681 | 3836 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3686,7 +3841,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, |
| 3686 | 3841 | } |
| 3687 | 3842 | |
| 3688 | 3843 | template<class _CharT, class _Traits, class _Allocator> |
| 3689 | inline | |
| 3844 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3690 | 3845 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3691 | 3846 | basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, |
| 3692 | 3847 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3697,6 +3852,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, |
| 3697 | 3852 | // find_first_not_of |
| 3698 | 3853 | |
| 3699 | 3854 | template<class _CharT, class _Traits, class _Allocator> |
| 3855 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3700 | 3856 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3701 | 3857 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, |
| 3702 | 3858 | size_type __pos, |
| ... | ... | @@ -3708,7 +3864,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ |
| 3708 | 3864 | } |
| 3709 | 3865 | |
| 3710 | 3866 | template<class _CharT, class _Traits, class _Allocator> |
| 3711 | inline | |
| 3867 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3712 | 3868 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3713 | 3869 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, |
| 3714 | 3870 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3719,6 +3875,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& |
| 3719 | 3875 | |
| 3720 | 3876 | template<class _CharT, class _Traits, class _Allocator> |
| 3721 | 3877 | template <class _Tp> |
| 3878 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3722 | 3879 | __enable_if_t |
| 3723 | 3880 | < |
| 3724 | 3881 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3733,7 +3890,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, |
| 3733 | 3890 | } |
| 3734 | 3891 | |
| 3735 | 3892 | template<class _CharT, class _Traits, class _Allocator> |
| 3736 | inline | |
| 3893 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3737 | 3894 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3738 | 3895 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, |
| 3739 | 3896 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3744,7 +3901,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ |
| 3744 | 3901 | } |
| 3745 | 3902 | |
| 3746 | 3903 | template<class _CharT, class _Traits, class _Allocator> |
| 3747 | inline | |
| 3904 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3748 | 3905 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3749 | 3906 | basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, |
| 3750 | 3907 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3756,6 +3913,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, |
| 3756 | 3913 | // find_last_not_of |
| 3757 | 3914 | |
| 3758 | 3915 | template<class _CharT, class _Traits, class _Allocator> |
| 3916 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3759 | 3917 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3760 | 3918 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, |
| 3761 | 3919 | size_type __pos, |
| ... | ... | @@ -3767,7 +3925,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ |
| 3767 | 3925 | } |
| 3768 | 3926 | |
| 3769 | 3927 | template<class _CharT, class _Traits, class _Allocator> |
| 3770 | inline | |
| 3928 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3771 | 3929 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3772 | 3930 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, |
| 3773 | 3931 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3778,6 +3936,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& |
| 3778 | 3936 | |
| 3779 | 3937 | template<class _CharT, class _Traits, class _Allocator> |
| 3780 | 3938 | template <class _Tp> |
| 3939 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3781 | 3940 | __enable_if_t |
| 3782 | 3941 | < |
| 3783 | 3942 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3792,7 +3951,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, |
| 3792 | 3951 | } |
| 3793 | 3952 | |
| 3794 | 3953 | template<class _CharT, class _Traits, class _Allocator> |
| 3795 | inline | |
| 3954 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3796 | 3955 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3797 | 3956 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, |
| 3798 | 3957 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3803,7 +3962,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ |
| 3803 | 3962 | } |
| 3804 | 3963 | |
| 3805 | 3964 | template<class _CharT, class _Traits, class _Allocator> |
| 3806 | inline | |
| 3965 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3807 | 3966 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 3808 | 3967 | basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, |
| 3809 | 3968 | size_type __pos) const _NOEXCEPT |
| ... | ... | @@ -3816,6 +3975,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, |
| 3816 | 3975 | |
| 3817 | 3976 | template <class _CharT, class _Traits, class _Allocator> |
| 3818 | 3977 | template <class _Tp> |
| 3978 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3819 | 3979 | __enable_if_t |
| 3820 | 3980 | < |
| 3821 | 3981 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3827,7 +3987,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE |
| 3827 | 3987 | size_t __lhs_sz = size(); |
| 3828 | 3988 | size_t __rhs_sz = __sv.size(); |
| 3829 | 3989 | int __result = traits_type::compare(data(), __sv.data(), |
| 3830 | _VSTD::min(__lhs_sz, __rhs_sz)); | |
| 3990 | std::min(__lhs_sz, __rhs_sz)); | |
| 3831 | 3991 | if (__result != 0) |
| 3832 | 3992 | return __result; |
| 3833 | 3993 | if (__lhs_sz < __rhs_sz) |
| ... | ... | @@ -3838,7 +3998,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCE |
| 3838 | 3998 | } |
| 3839 | 3999 | |
| 3840 | 4000 | template <class _CharT, class _Traits, class _Allocator> |
| 3841 | inline | |
| 4001 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3842 | 4002 | int |
| 3843 | 4003 | basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT |
| 3844 | 4004 | { |
| ... | ... | @@ -3846,6 +4006,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co |
| 3846 | 4006 | } |
| 3847 | 4007 | |
| 3848 | 4008 | template <class _CharT, class _Traits, class _Allocator> |
| 4009 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3849 | 4010 | int |
| 3850 | 4011 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3851 | 4012 | size_type __n1, |
| ... | ... | @@ -3856,8 +4017,8 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3856 | 4017 | size_type __sz = size(); |
| 3857 | 4018 | if (__pos1 > __sz || __n2 == npos) |
| 3858 | 4019 | __throw_out_of_range(); |
| 3859 | size_type __rlen = _VSTD::min(__n1, __sz - __pos1); | |
| 3860 | int __r = traits_type::compare(data() + __pos1, __s, _VSTD::min(__rlen, __n2)); | |
| 4020 | size_type __rlen = std::min(__n1, __sz - __pos1); | |
| 4021 | int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2)); | |
| 3861 | 4022 | if (__r == 0) |
| 3862 | 4023 | { |
| 3863 | 4024 | if (__rlen < __n2) |
| ... | ... | @@ -3870,6 +4031,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3870 | 4031 | |
| 3871 | 4032 | template <class _CharT, class _Traits, class _Allocator> |
| 3872 | 4033 | template <class _Tp> |
| 4034 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3873 | 4035 | __enable_if_t |
| 3874 | 4036 | < |
| 3875 | 4037 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, |
| ... | ... | @@ -3884,7 +4046,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3884 | 4046 | } |
| 3885 | 4047 | |
| 3886 | 4048 | template <class _CharT, class _Traits, class _Allocator> |
| 3887 | inline | |
| 4049 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3888 | 4050 | int |
| 3889 | 4051 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3890 | 4052 | size_type __n1, |
| ... | ... | @@ -3895,6 +4057,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3895 | 4057 | |
| 3896 | 4058 | template <class _CharT, class _Traits, class _Allocator> |
| 3897 | 4059 | template <class _Tp> |
| 4060 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3898 | 4061 | __enable_if_t |
| 3899 | 4062 | < |
| 3900 | 4063 | __can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value |
| ... | ... | @@ -3912,6 +4075,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3912 | 4075 | } |
| 3913 | 4076 | |
| 3914 | 4077 | template <class _CharT, class _Traits, class _Allocator> |
| 4078 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3915 | 4079 | int |
| 3916 | 4080 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3917 | 4081 | size_type __n1, |
| ... | ... | @@ -3923,6 +4087,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3923 | 4087 | } |
| 3924 | 4088 | |
| 3925 | 4089 | template <class _CharT, class _Traits, class _Allocator> |
| 4090 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3926 | 4091 | int |
| 3927 | 4092 | basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT |
| 3928 | 4093 | { |
| ... | ... | @@ -3931,6 +4096,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const |
| 3931 | 4096 | } |
| 3932 | 4097 | |
| 3933 | 4098 | template <class _CharT, class _Traits, class _Allocator> |
| 4099 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3934 | 4100 | int |
| 3935 | 4101 | basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3936 | 4102 | size_type __n1, |
| ... | ... | @@ -3943,7 +4109,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, |
| 3943 | 4109 | // __invariants |
| 3944 | 4110 | |
| 3945 | 4111 | template<class _CharT, class _Traits, class _Allocator> |
| 3946 | inline | |
| 4112 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3947 | 4113 | bool |
| 3948 | 4114 | basic_string<_CharT, _Traits, _Allocator>::__invariants() const |
| 3949 | 4115 | { |
| ... | ... | @@ -3961,7 +4127,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const |
| 3961 | 4127 | // __clear_and_shrink |
| 3962 | 4128 | |
| 3963 | 4129 | template<class _CharT, class _Traits, class _Allocator> |
| 3964 | inline | |
| 4130 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3965 | 4131 | void |
| 3966 | 4132 | basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT |
| 3967 | 4133 | { |
| ... | ... | @@ -3978,7 +4144,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT |
| 3978 | 4144 | // operator== |
| 3979 | 4145 | |
| 3980 | 4146 | template<class _CharT, class _Traits, class _Allocator> |
| 3981 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4147 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 3982 | 4148 | bool |
| 3983 | 4149 | operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 3984 | 4150 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -3990,7 +4156,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 3990 | 4156 | } |
| 3991 | 4157 | |
| 3992 | 4158 | template<class _Allocator> |
| 3993 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4159 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 3994 | 4160 | bool |
| 3995 | 4161 | operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, |
| 3996 | 4162 | const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4009,7 +4175,7 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, |
| 4009 | 4175 | } |
| 4010 | 4176 | |
| 4011 | 4177 | template<class _CharT, class _Traits, class _Allocator> |
| 4012 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4178 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4013 | 4179 | bool |
| 4014 | 4180 | operator==(const _CharT* __lhs, |
| 4015 | 4181 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4022,7 +4188,7 @@ operator==(const _CharT* __lhs, |
| 4022 | 4188 | } |
| 4023 | 4189 | |
| 4024 | 4190 | template<class _CharT, class _Traits, class _Allocator> |
| 4025 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4191 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4026 | 4192 | bool |
| 4027 | 4193 | operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, |
| 4028 | 4194 | const _CharT* __rhs) _NOEXCEPT |
| ... | ... | @@ -4035,7 +4201,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, |
| 4035 | 4201 | } |
| 4036 | 4202 | |
| 4037 | 4203 | template<class _CharT, class _Traits, class _Allocator> |
| 4038 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4204 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4039 | 4205 | bool |
| 4040 | 4206 | operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, |
| 4041 | 4207 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4044,7 +4210,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, |
| 4044 | 4210 | } |
| 4045 | 4211 | |
| 4046 | 4212 | template<class _CharT, class _Traits, class _Allocator> |
| 4047 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4213 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4048 | 4214 | bool |
| 4049 | 4215 | operator!=(const _CharT* __lhs, |
| 4050 | 4216 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4053,7 +4219,7 @@ operator!=(const _CharT* __lhs, |
| 4053 | 4219 | } |
| 4054 | 4220 | |
| 4055 | 4221 | template<class _CharT, class _Traits, class _Allocator> |
| 4056 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4222 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4057 | 4223 | bool |
| 4058 | 4224 | operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4059 | 4225 | const _CharT* __rhs) _NOEXCEPT |
| ... | ... | @@ -4064,7 +4230,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4064 | 4230 | // operator< |
| 4065 | 4231 | |
| 4066 | 4232 | template<class _CharT, class _Traits, class _Allocator> |
| 4067 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4233 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4068 | 4234 | bool |
| 4069 | 4235 | operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4070 | 4236 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4073,7 +4239,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4073 | 4239 | } |
| 4074 | 4240 | |
| 4075 | 4241 | template<class _CharT, class _Traits, class _Allocator> |
| 4076 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4242 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4077 | 4243 | bool |
| 4078 | 4244 | operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4079 | 4245 | const _CharT* __rhs) _NOEXCEPT |
| ... | ... | @@ -4082,7 +4248,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4082 | 4248 | } |
| 4083 | 4249 | |
| 4084 | 4250 | template<class _CharT, class _Traits, class _Allocator> |
| 4085 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4251 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4086 | 4252 | bool |
| 4087 | 4253 | operator< (const _CharT* __lhs, |
| 4088 | 4254 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4093,7 +4259,7 @@ operator< (const _CharT* __lhs, |
| 4093 | 4259 | // operator> |
| 4094 | 4260 | |
| 4095 | 4261 | template<class _CharT, class _Traits, class _Allocator> |
| 4096 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4262 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4097 | 4263 | bool |
| 4098 | 4264 | operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4099 | 4265 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4102,7 +4268,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4102 | 4268 | } |
| 4103 | 4269 | |
| 4104 | 4270 | template<class _CharT, class _Traits, class _Allocator> |
| 4105 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4271 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4106 | 4272 | bool |
| 4107 | 4273 | operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4108 | 4274 | const _CharT* __rhs) _NOEXCEPT |
| ... | ... | @@ -4111,7 +4277,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4111 | 4277 | } |
| 4112 | 4278 | |
| 4113 | 4279 | template<class _CharT, class _Traits, class _Allocator> |
| 4114 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4280 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4115 | 4281 | bool |
| 4116 | 4282 | operator> (const _CharT* __lhs, |
| 4117 | 4283 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4122,7 +4288,7 @@ operator> (const _CharT* __lhs, |
| 4122 | 4288 | // operator<= |
| 4123 | 4289 | |
| 4124 | 4290 | template<class _CharT, class _Traits, class _Allocator> |
| 4125 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4291 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4126 | 4292 | bool |
| 4127 | 4293 | operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4128 | 4294 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4131,7 +4297,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4131 | 4297 | } |
| 4132 | 4298 | |
| 4133 | 4299 | template<class _CharT, class _Traits, class _Allocator> |
| 4134 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4300 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4135 | 4301 | bool |
| 4136 | 4302 | operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4137 | 4303 | const _CharT* __rhs) _NOEXCEPT |
| ... | ... | @@ -4140,7 +4306,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4140 | 4306 | } |
| 4141 | 4307 | |
| 4142 | 4308 | template<class _CharT, class _Traits, class _Allocator> |
| 4143 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4309 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4144 | 4310 | bool |
| 4145 | 4311 | operator<=(const _CharT* __lhs, |
| 4146 | 4312 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4151,7 +4317,7 @@ operator<=(const _CharT* __lhs, |
| 4151 | 4317 | // operator>= |
| 4152 | 4318 | |
| 4153 | 4319 | template<class _CharT, class _Traits, class _Allocator> |
| 4154 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4320 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4155 | 4321 | bool |
| 4156 | 4322 | operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4157 | 4323 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4160,7 +4326,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4160 | 4326 | } |
| 4161 | 4327 | |
| 4162 | 4328 | template<class _CharT, class _Traits, class _Allocator> |
| 4163 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4329 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4164 | 4330 | bool |
| 4165 | 4331 | operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4166 | 4332 | const _CharT* __rhs) _NOEXCEPT |
| ... | ... | @@ -4169,7 +4335,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4169 | 4335 | } |
| 4170 | 4336 | |
| 4171 | 4337 | template<class _CharT, class _Traits, class _Allocator> |
| 4172 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4338 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI | |
| 4173 | 4339 | bool |
| 4174 | 4340 | operator>=(const _CharT* __lhs, |
| 4175 | 4341 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT |
| ... | ... | @@ -4180,123 +4346,152 @@ operator>=(const _CharT* __lhs, |
| 4180 | 4346 | // operator + |
| 4181 | 4347 | |
| 4182 | 4348 | template<class _CharT, class _Traits, class _Allocator> |
| 4349 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4183 | 4350 | basic_string<_CharT, _Traits, _Allocator> |
| 4184 | 4351 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4185 | 4352 | const basic_string<_CharT, _Traits, _Allocator>& __rhs) |
| 4186 | 4353 | { |
| 4187 | basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); | |
| 4188 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); | |
| 4189 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); | |
| 4190 | __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); | |
| 4191 | __r.append(__rhs.data(), __rhs_sz); | |
| 4354 | using _String = basic_string<_CharT, _Traits, _Allocator>; | |
| 4355 | auto __lhs_sz = __lhs.size(); | |
| 4356 | auto __rhs_sz = __rhs.size(); | |
| 4357 | _String __r(__uninitialized_size_tag(), | |
| 4358 | __lhs_sz + __rhs_sz, | |
| 4359 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | |
| 4360 | auto __ptr = std::__to_address(__r.__get_pointer()); | |
| 4361 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | |
| 4362 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | |
| 4363 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | |
| 4192 | 4364 | return __r; |
| 4193 | 4365 | } |
| 4194 | 4366 | |
| 4195 | 4367 | template<class _CharT, class _Traits, class _Allocator> |
| 4368 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4196 | 4369 | basic_string<_CharT, _Traits, _Allocator> |
| 4197 | 4370 | operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) |
| 4198 | 4371 | { |
| 4199 | basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); | |
| 4200 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); | |
| 4201 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); | |
| 4202 | __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); | |
| 4203 | __r.append(__rhs.data(), __rhs_sz); | |
| 4372 | using _String = basic_string<_CharT, _Traits, _Allocator>; | |
| 4373 | auto __lhs_sz = _Traits::length(__lhs); | |
| 4374 | auto __rhs_sz = __rhs.size(); | |
| 4375 | _String __r(__uninitialized_size_tag(), | |
| 4376 | __lhs_sz + __rhs_sz, | |
| 4377 | _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); | |
| 4378 | auto __ptr = std::__to_address(__r.__get_pointer()); | |
| 4379 | _Traits::copy(__ptr, __lhs, __lhs_sz); | |
| 4380 | _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz); | |
| 4381 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | |
| 4204 | 4382 | return __r; |
| 4205 | 4383 | } |
| 4206 | 4384 | |
| 4207 | 4385 | template<class _CharT, class _Traits, class _Allocator> |
| 4386 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4208 | 4387 | basic_string<_CharT, _Traits, _Allocator> |
| 4209 | 4388 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) |
| 4210 | 4389 | { |
| 4211 | basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); | |
| 4212 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); | |
| 4213 | __r.__init(&__lhs, 1, 1 + __rhs_sz); | |
| 4214 | __r.append(__rhs.data(), __rhs_sz); | |
| 4390 | using _String = basic_string<_CharT, _Traits, _Allocator>; | |
| 4391 | typename _String::size_type __rhs_sz = __rhs.size(); | |
| 4392 | _String __r(__uninitialized_size_tag(), | |
| 4393 | __rhs_sz + 1, | |
| 4394 | _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); | |
| 4395 | auto __ptr = std::__to_address(__r.__get_pointer()); | |
| 4396 | _Traits::assign(__ptr, 1, __lhs); | |
| 4397 | _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz); | |
| 4398 | _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT()); | |
| 4215 | 4399 | return __r; |
| 4216 | 4400 | } |
| 4217 | 4401 | |
| 4218 | 4402 | template<class _CharT, class _Traits, class _Allocator> |
| 4219 | inline | |
| 4403 | inline _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4220 | 4404 | basic_string<_CharT, _Traits, _Allocator> |
| 4221 | 4405 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) |
| 4222 | 4406 | { |
| 4223 | basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); | |
| 4224 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); | |
| 4225 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); | |
| 4226 | __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); | |
| 4227 | __r.append(__rhs, __rhs_sz); | |
| 4407 | using _String = basic_string<_CharT, _Traits, _Allocator>; | |
| 4408 | typename _String::size_type __lhs_sz = __lhs.size(); | |
| 4409 | typename _String::size_type __rhs_sz = _Traits::length(__rhs); | |
| 4410 | _String __r(__uninitialized_size_tag(), | |
| 4411 | __lhs_sz + __rhs_sz, | |
| 4412 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | |
| 4413 | auto __ptr = std::__to_address(__r.__get_pointer()); | |
| 4414 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | |
| 4415 | _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz); | |
| 4416 | _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT()); | |
| 4228 | 4417 | return __r; |
| 4229 | 4418 | } |
| 4230 | 4419 | |
| 4231 | 4420 | template<class _CharT, class _Traits, class _Allocator> |
| 4421 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4232 | 4422 | basic_string<_CharT, _Traits, _Allocator> |
| 4233 | 4423 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) |
| 4234 | 4424 | { |
| 4235 | basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); | |
| 4236 | typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); | |
| 4237 | __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); | |
| 4238 | __r.push_back(__rhs); | |
| 4425 | using _String = basic_string<_CharT, _Traits, _Allocator>; | |
| 4426 | typename _String::size_type __lhs_sz = __lhs.size(); | |
| 4427 | _String __r(__uninitialized_size_tag(), | |
| 4428 | __lhs_sz + 1, | |
| 4429 | _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); | |
| 4430 | auto __ptr = std::__to_address(__r.__get_pointer()); | |
| 4431 | _Traits::copy(__ptr, __lhs.data(), __lhs_sz); | |
| 4432 | _Traits::assign(__ptr + __lhs_sz, 1, __rhs); | |
| 4433 | _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT()); | |
| 4239 | 4434 | return __r; |
| 4240 | 4435 | } |
| 4241 | 4436 | |
| 4242 | 4437 | #ifndef _LIBCPP_CXX03_LANG |
| 4243 | 4438 | |
| 4244 | 4439 | template<class _CharT, class _Traits, class _Allocator> |
| 4245 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4440 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4246 | 4441 | basic_string<_CharT, _Traits, _Allocator> |
| 4247 | 4442 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) |
| 4248 | 4443 | { |
| 4249 | return _VSTD::move(__lhs.append(__rhs)); | |
| 4444 | return std::move(__lhs.append(__rhs)); | |
| 4250 | 4445 | } |
| 4251 | 4446 | |
| 4252 | 4447 | template<class _CharT, class _Traits, class _Allocator> |
| 4253 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4448 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4254 | 4449 | basic_string<_CharT, _Traits, _Allocator> |
| 4255 | 4450 | operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) |
| 4256 | 4451 | { |
| 4257 | return _VSTD::move(__rhs.insert(0, __lhs)); | |
| 4452 | return std::move(__rhs.insert(0, __lhs)); | |
| 4258 | 4453 | } |
| 4259 | 4454 | |
| 4260 | 4455 | template<class _CharT, class _Traits, class _Allocator> |
| 4261 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4456 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4262 | 4457 | basic_string<_CharT, _Traits, _Allocator> |
| 4263 | 4458 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) |
| 4264 | 4459 | { |
| 4265 | return _VSTD::move(__lhs.append(__rhs)); | |
| 4460 | return std::move(__lhs.append(__rhs)); | |
| 4266 | 4461 | } |
| 4267 | 4462 | |
| 4268 | 4463 | template<class _CharT, class _Traits, class _Allocator> |
| 4269 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4464 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4270 | 4465 | basic_string<_CharT, _Traits, _Allocator> |
| 4271 | 4466 | operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) |
| 4272 | 4467 | { |
| 4273 | return _VSTD::move(__rhs.insert(0, __lhs)); | |
| 4468 | return std::move(__rhs.insert(0, __lhs)); | |
| 4274 | 4469 | } |
| 4275 | 4470 | |
| 4276 | 4471 | template<class _CharT, class _Traits, class _Allocator> |
| 4277 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4472 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4278 | 4473 | basic_string<_CharT, _Traits, _Allocator> |
| 4279 | 4474 | operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) |
| 4280 | 4475 | { |
| 4281 | 4476 | __rhs.insert(__rhs.begin(), __lhs); |
| 4282 | return _VSTD::move(__rhs); | |
| 4477 | return std::move(__rhs); | |
| 4283 | 4478 | } |
| 4284 | 4479 | |
| 4285 | 4480 | template<class _CharT, class _Traits, class _Allocator> |
| 4286 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4481 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4287 | 4482 | basic_string<_CharT, _Traits, _Allocator> |
| 4288 | 4483 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) |
| 4289 | 4484 | { |
| 4290 | return _VSTD::move(__lhs.append(__rhs)); | |
| 4485 | return std::move(__lhs.append(__rhs)); | |
| 4291 | 4486 | } |
| 4292 | 4487 | |
| 4293 | 4488 | template<class _CharT, class _Traits, class _Allocator> |
| 4294 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4489 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4295 | 4490 | basic_string<_CharT, _Traits, _Allocator> |
| 4296 | 4491 | operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) |
| 4297 | 4492 | { |
| 4298 | 4493 | __lhs.push_back(__rhs); |
| 4299 | return _VSTD::move(__lhs); | |
| 4494 | return std::move(__lhs); | |
| 4300 | 4495 | } |
| 4301 | 4496 | |
| 4302 | 4497 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -4304,7 +4499,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) |
| 4304 | 4499 | // swap |
| 4305 | 4500 | |
| 4306 | 4501 | template<class _CharT, class _Traits, class _Allocator> |
| 4307 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4502 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4308 | 4503 | void |
| 4309 | 4504 | swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, |
| 4310 | 4505 | basic_string<_CharT, _Traits, _Allocator>& __rhs) |
| ... | ... | @@ -4363,15 +4558,13 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4363 | 4558 | template <class _CharT, class _Allocator> |
| 4364 | 4559 | struct _LIBCPP_TEMPLATE_VIS |
| 4365 | 4560 | hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> > |
| 4366 | : public unary_function< | |
| 4367 | basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> | |
| 4561 | : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> | |
| 4368 | 4562 | { |
| 4369 | 4563 | size_t |
| 4370 | 4564 | operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT |
| 4371 | 4565 | { return __do_string_hash(__val.data(), __val.data() + __val.size()); } |
| 4372 | 4566 | }; |
| 4373 | 4567 | |
| 4374 | ||
| 4375 | 4568 | template<class _CharT, class _Traits, class _Allocator> |
| 4376 | 4569 | basic_ostream<_CharT, _Traits>& |
| 4377 | 4570 | operator<<(basic_ostream<_CharT, _Traits>& __os, |
| ... | ... | @@ -4388,68 +4581,68 @@ getline(basic_istream<_CharT, _Traits>& __is, |
| 4388 | 4581 | basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); |
| 4389 | 4582 | |
| 4390 | 4583 | template<class _CharT, class _Traits, class _Allocator> |
| 4391 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4584 | inline _LIBCPP_HIDE_FROM_ABI | |
| 4392 | 4585 | basic_istream<_CharT, _Traits>& |
| 4393 | 4586 | getline(basic_istream<_CharT, _Traits>& __is, |
| 4394 | 4587 | basic_string<_CharT, _Traits, _Allocator>& __str); |
| 4395 | 4588 | |
| 4396 | 4589 | template<class _CharT, class _Traits, class _Allocator> |
| 4397 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4590 | inline _LIBCPP_HIDE_FROM_ABI | |
| 4398 | 4591 | basic_istream<_CharT, _Traits>& |
| 4399 | 4592 | getline(basic_istream<_CharT, _Traits>&& __is, |
| 4400 | 4593 | basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm); |
| 4401 | 4594 | |
| 4402 | 4595 | template<class _CharT, class _Traits, class _Allocator> |
| 4403 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4596 | inline _LIBCPP_HIDE_FROM_ABI | |
| 4404 | 4597 | basic_istream<_CharT, _Traits>& |
| 4405 | 4598 | getline(basic_istream<_CharT, _Traits>&& __is, |
| 4406 | 4599 | basic_string<_CharT, _Traits, _Allocator>& __str); |
| 4407 | 4600 | |
| 4408 | 4601 | #if _LIBCPP_STD_VER > 17 |
| 4409 | 4602 | template <class _CharT, class _Traits, class _Allocator, class _Up> |
| 4410 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4603 | inline _LIBCPP_HIDE_FROM_ABI | |
| 4411 | 4604 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4412 | 4605 | erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) { |
| 4413 | 4606 | auto __old_size = __str.size(); |
| 4414 | __str.erase(_VSTD::remove(__str.begin(), __str.end(), __v), __str.end()); | |
| 4607 | __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end()); | |
| 4415 | 4608 | return __old_size - __str.size(); |
| 4416 | 4609 | } |
| 4417 | 4610 | |
| 4418 | 4611 | template <class _CharT, class _Traits, class _Allocator, class _Predicate> |
| 4419 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4612 | inline _LIBCPP_HIDE_FROM_ABI | |
| 4420 | 4613 | typename basic_string<_CharT, _Traits, _Allocator>::size_type |
| 4421 | 4614 | erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, |
| 4422 | 4615 | _Predicate __pred) { |
| 4423 | 4616 | auto __old_size = __str.size(); |
| 4424 | __str.erase(_VSTD::remove_if(__str.begin(), __str.end(), __pred), | |
| 4617 | __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), | |
| 4425 | 4618 | __str.end()); |
| 4426 | 4619 | return __old_size - __str.size(); |
| 4427 | 4620 | } |
| 4428 | 4621 | #endif |
| 4429 | 4622 | |
| 4430 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 4623 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 4431 | 4624 | |
| 4432 | 4625 | template<class _CharT, class _Traits, class _Allocator> |
| 4433 | 4626 | bool |
| 4434 | 4627 | basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const |
| 4435 | 4628 | { |
| 4436 | return data() <= _VSTD::__to_address(__i->base()) && | |
| 4437 | _VSTD::__to_address(__i->base()) < data() + size(); | |
| 4629 | return data() <= std::__to_address(__i->base()) && | |
| 4630 | std::__to_address(__i->base()) < data() + size(); | |
| 4438 | 4631 | } |
| 4439 | 4632 | |
| 4440 | 4633 | template<class _CharT, class _Traits, class _Allocator> |
| 4441 | 4634 | bool |
| 4442 | 4635 | basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const |
| 4443 | 4636 | { |
| 4444 | return data() < _VSTD::__to_address(__i->base()) && | |
| 4445 | _VSTD::__to_address(__i->base()) <= data() + size(); | |
| 4637 | return data() < std::__to_address(__i->base()) && | |
| 4638 | std::__to_address(__i->base()) <= data() + size(); | |
| 4446 | 4639 | } |
| 4447 | 4640 | |
| 4448 | 4641 | template<class _CharT, class _Traits, class _Allocator> |
| 4449 | 4642 | bool |
| 4450 | 4643 | basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const |
| 4451 | 4644 | { |
| 4452 | const value_type* __p = _VSTD::__to_address(__i->base()) + __n; | |
| 4645 | const value_type* __p = std::__to_address(__i->base()) + __n; | |
| 4453 | 4646 | return data() <= __p && __p <= data() + size(); |
| 4454 | 4647 | } |
| 4455 | 4648 | |
| ... | ... | @@ -4457,11 +4650,11 @@ template<class _CharT, class _Traits, class _Allocator> |
| 4457 | 4650 | bool |
| 4458 | 4651 | basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 4459 | 4652 | { |
| 4460 | const value_type* __p = _VSTD::__to_address(__i->base()) + __n; | |
| 4653 | const value_type* __p = std::__to_address(__i->base()) + __n; | |
| 4461 | 4654 | return data() <= __p && __p < data() + size(); |
| 4462 | 4655 | } |
| 4463 | 4656 | |
| 4464 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 4657 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 4465 | 4658 | |
| 4466 | 4659 | #if _LIBCPP_STD_VER > 11 |
| 4467 | 4660 | // Literal suffixes for basic_string [basic.string.literals] |
| ... | ... | @@ -4469,14 +4662,14 @@ inline namespace literals |
| 4469 | 4662 | { |
| 4470 | 4663 | inline namespace string_literals |
| 4471 | 4664 | { |
| 4472 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4665 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4473 | 4666 | basic_string<char> operator "" s( const char *__str, size_t __len ) |
| 4474 | 4667 | { |
| 4475 | 4668 | return basic_string<char> (__str, __len); |
| 4476 | 4669 | } |
| 4477 | 4670 | |
| 4478 | 4671 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 4479 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4672 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4480 | 4673 | basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len ) |
| 4481 | 4674 | { |
| 4482 | 4675 | return basic_string<wchar_t> (__str, __len); |
| ... | ... | @@ -4484,26 +4677,36 @@ inline namespace literals |
| 4484 | 4677 | #endif |
| 4485 | 4678 | |
| 4486 | 4679 | #ifndef _LIBCPP_HAS_NO_CHAR8_T |
| 4487 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4680 | inline _LIBCPP_HIDE_FROM_ABI constexpr | |
| 4488 | 4681 | basic_string<char8_t> operator "" s(const char8_t *__str, size_t __len) _NOEXCEPT |
| 4489 | 4682 | { |
| 4490 | 4683 | return basic_string<char8_t> (__str, __len); |
| 4491 | 4684 | } |
| 4492 | 4685 | #endif |
| 4493 | 4686 | |
| 4494 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4687 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4495 | 4688 | basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len ) |
| 4496 | 4689 | { |
| 4497 | 4690 | return basic_string<char16_t> (__str, __len); |
| 4498 | 4691 | } |
| 4499 | 4692 | |
| 4500 | inline _LIBCPP_INLINE_VISIBILITY | |
| 4693 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 4501 | 4694 | basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len ) |
| 4502 | 4695 | { |
| 4503 | 4696 | return basic_string<char32_t> (__str, __len); |
| 4504 | 4697 | } |
| 4505 | 4698 | } // namespace string_literals |
| 4506 | 4699 | } // namespace literals |
| 4700 | ||
| 4701 | #if _LIBCPP_STD_VER > 17 | |
| 4702 | template <> | |
| 4703 | inline constexpr bool __format::__enable_insertable<std::basic_string<char>> = true; | |
| 4704 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 4705 | template <> | |
| 4706 | inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>> = true; | |
| 4707 | #endif | |
| 4708 | #endif | |
| 4709 | ||
| 4507 | 4710 | #endif |
| 4508 | 4711 | |
| 4509 | 4712 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/include/string.h+1-1| ... | ... | @@ -54,7 +54,7 @@ size_t strlen(const char* s); |
| 54 | 54 | #include <__config> |
| 55 | 55 | |
| 56 | 56 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 57 | #pragma GCC system_header | |
| 57 | # pragma GCC system_header | |
| 58 | 58 | #endif |
| 59 | 59 | |
| 60 | 60 | #include_next <string.h> |
lib/libcxx/include/string_view+52-33| ... | ... | @@ -11,7 +11,8 @@ |
| 11 | 11 | #define _LIBCPP_STRING_VIEW |
| 12 | 12 | |
| 13 | 13 | /* |
| 14 | string_view synopsis | |
| 14 | ||
| 15 | string_view synopsis | |
| 15 | 16 | |
| 16 | 17 | namespace std { |
| 17 | 18 | |
| ... | ... | @@ -195,25 +196,48 @@ namespace std { |
| 195 | 196 | |
| 196 | 197 | */ |
| 197 | 198 | |
| 199 | #include <__algorithm/min.h> | |
| 200 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 198 | 201 | #include <__config> |
| 199 | #include <__debug> | |
| 202 | #include <__functional/hash.h> | |
| 203 | #include <__functional/unary_function.h> | |
| 204 | #include <__fwd/string_view.h> | |
| 205 | #include <__iterator/concepts.h> | |
| 206 | #include <__iterator/readable_traits.h> | |
| 207 | #include <__iterator/reverse_iterator.h> | |
| 208 | #include <__memory/pointer_traits.h> | |
| 200 | 209 | #include <__ranges/concepts.h> |
| 201 | 210 | #include <__ranges/data.h> |
| 202 | 211 | #include <__ranges/enable_borrowed_range.h> |
| 203 | 212 | #include <__ranges/enable_view.h> |
| 204 | 213 | #include <__ranges/size.h> |
| 205 | #include <__string> | |
| 206 | #include <algorithm> | |
| 207 | #include <compare> | |
| 214 | #include <__string/char_traits.h> | |
| 208 | 215 | #include <iosfwd> |
| 209 | #include <iterator> | |
| 210 | 216 | #include <limits> |
| 211 | 217 | #include <stdexcept> |
| 212 | 218 | #include <type_traits> |
| 213 | 219 | #include <version> |
| 214 | 220 | |
| 221 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 222 | # include <algorithm> | |
| 223 | # include <functional> | |
| 224 | # include <iterator> | |
| 225 | #endif | |
| 226 | ||
| 227 | // standard-mandated includes | |
| 228 | ||
| 229 | // [iterator.range] | |
| 230 | #include <__iterator/access.h> | |
| 231 | #include <__iterator/data.h> | |
| 232 | #include <__iterator/empty.h> | |
| 233 | #include <__iterator/reverse_access.h> | |
| 234 | #include <__iterator/size.h> | |
| 235 | ||
| 236 | // [string.view.synop] | |
| 237 | #include <compare> | |
| 238 | ||
| 215 | 239 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 216 | #pragma GCC system_header | |
| 240 | # pragma GCC system_header | |
| 217 | 241 | #endif |
| 218 | 242 | |
| 219 | 243 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -222,18 +246,14 @@ _LIBCPP_PUSH_MACROS |
| 222 | 246 | |
| 223 | 247 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 224 | 248 | |
| 225 | template<class _CharT, class _Traits = char_traits<_CharT> > | |
| 226 | class _LIBCPP_TEMPLATE_VIS basic_string_view; | |
| 227 | ||
| 228 | typedef basic_string_view<char> string_view; | |
| 229 | #ifndef _LIBCPP_HAS_NO_CHAR8_T | |
| 230 | typedef basic_string_view<char8_t> u8string_view; | |
| 231 | #endif | |
| 232 | typedef basic_string_view<char16_t> u16string_view; | |
| 233 | typedef basic_string_view<char32_t> u32string_view; | |
| 234 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 235 | typedef basic_string_view<wchar_t> wstring_view; | |
| 236 | #endif | |
| 249 | // TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in | |
| 250 | // string_view constructors. This can be refactored when this exact form isn't needed anymore. | |
| 251 | template <class _Traits> | |
| 252 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR | |
| 253 | inline size_t __char_traits_length_checked(const typename _Traits::char_type* __s) _NOEXCEPT { | |
| 254 | // This needs to be a single statement for C++11 constexpr | |
| 255 | return _LIBCPP_ASSERT(__s != nullptr, "null pointer passed to non-null argument of char_traits<...>::length"), _Traits::length(__s); | |
| 256 | } | |
| 237 | 257 | |
| 238 | 258 | template<class _CharT, class _Traits> |
| 239 | 259 | class |
| ... | ... | @@ -286,7 +306,7 @@ public: |
| 286 | 306 | #endif |
| 287 | 307 | } |
| 288 | 308 | |
| 289 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 309 | #if _LIBCPP_STD_VER > 17 | |
| 290 | 310 | template <contiguous_iterator _It, sized_sentinel_for<_It> _End> |
| 291 | 311 | requires (is_same_v<iter_value_t<_It>, _CharT> && !is_convertible_v<_End, size_type>) |
| 292 | 312 | constexpr _LIBCPP_HIDE_FROM_ABI basic_string_view(_It __begin, _End __end) |
| ... | ... | @@ -294,9 +314,9 @@ public: |
| 294 | 314 | { |
| 295 | 315 | _LIBCPP_ASSERT((__end - __begin) >= 0, "std::string_view::string_view(iterator, sentinel) received invalid range"); |
| 296 | 316 | } |
| 297 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 317 | #endif // _LIBCPP_STD_VER > 17 | |
| 298 | 318 | |
| 299 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 319 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 300 | 320 | template <class _Range> |
| 301 | 321 | requires ( |
| 302 | 322 | !is_same_v<remove_cvref_t<_Range>, basic_string_view> && |
| ... | ... | @@ -304,8 +324,8 @@ public: |
| 304 | 324 | ranges::sized_range<_Range> && |
| 305 | 325 | is_same_v<ranges::range_value_t<_Range>, _CharT> && |
| 306 | 326 | !is_convertible_v<_Range, const _CharT*> && |
| 307 | (!requires(remove_cvref_t<_Range>& d) { | |
| 308 | d.operator _VSTD::basic_string_view<_CharT, _Traits>(); | |
| 327 | (!requires(remove_cvref_t<_Range>& __d) { | |
| 328 | __d.operator _VSTD::basic_string_view<_CharT, _Traits>(); | |
| 309 | 329 | }) && |
| 310 | 330 | (!requires { |
| 311 | 331 | typename remove_reference_t<_Range>::traits_type; |
| ... | ... | @@ -313,7 +333,7 @@ public: |
| 313 | 333 | ) |
| 314 | 334 | constexpr _LIBCPP_HIDE_FROM_ABI |
| 315 | 335 | basic_string_view(_Range&& __r) : __data(ranges::data(__r)), __size(ranges::size(__r)) {} |
| 316 | #endif | |
| 336 | #endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 317 | 337 | |
| 318 | 338 | _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY |
| 319 | 339 | basic_string_view(const _CharT* __s) |
| ... | ... | @@ -707,26 +727,26 @@ private: |
| 707 | 727 | size_type __size; |
| 708 | 728 | }; |
| 709 | 729 | |
| 710 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 730 | #if _LIBCPP_STD_VER > 17 | |
| 711 | 731 | template <class _CharT, class _Traits> |
| 712 | 732 | inline constexpr bool ranges::enable_view<basic_string_view<_CharT, _Traits>> = true; |
| 713 | 733 | |
| 714 | 734 | template <class _CharT, class _Traits> |
| 715 | 735 | inline constexpr bool ranges::enable_borrowed_range<basic_string_view<_CharT, _Traits> > = true; |
| 716 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 736 | #endif // _LIBCPP_STD_VER > 17 | |
| 717 | 737 | |
| 718 | 738 | // [string.view.deduct] |
| 719 | 739 | |
| 720 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 740 | #if _LIBCPP_STD_VER > 17 | |
| 721 | 741 | template <contiguous_iterator _It, sized_sentinel_for<_It> _End> |
| 722 | 742 | basic_string_view(_It, _End) -> basic_string_view<iter_value_t<_It>>; |
| 723 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 743 | #endif // _LIBCPP_STD_VER > 17 | |
| 724 | 744 | |
| 725 | 745 | |
| 726 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 746 | #if _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 727 | 747 | template <ranges::contiguous_range _Range> |
| 728 | 748 | basic_string_view(_Range) -> basic_string_view<ranges::range_value_t<_Range>>; |
| 729 | #endif | |
| 749 | #endif // _LIBCPP_STD_VER > 20 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) | |
| 730 | 750 | |
| 731 | 751 | // [string.view.comparison] |
| 732 | 752 | // operator == |
| ... | ... | @@ -900,7 +920,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, |
| 900 | 920 | // [string.view.hash] |
| 901 | 921 | template<class _CharT> |
| 902 | 922 | struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > > |
| 903 | : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> | |
| 923 | : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> | |
| 904 | 924 | { |
| 905 | 925 | _LIBCPP_INLINE_VISIBILITY |
| 906 | 926 | size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT { |
| ... | ... | @@ -908,7 +928,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > |
| 908 | 928 | } |
| 909 | 929 | }; |
| 910 | 930 | |
| 911 | ||
| 912 | 931 | #if _LIBCPP_STD_VER > 11 |
| 913 | 932 | inline namespace literals |
| 914 | 933 | { |
lib/libcxx/include/strstream+5-4| ... | ... | @@ -129,13 +129,14 @@ private: |
| 129 | 129 | |
| 130 | 130 | */ |
| 131 | 131 | |
| 132 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 132 | 133 | #include <__config> |
| 133 | 134 | #include <istream> |
| 134 | 135 | #include <ostream> |
| 135 | 136 | #include <version> |
| 136 | 137 | |
| 137 | 138 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 138 | #pragma GCC system_header | |
| 139 | # pragma GCC system_header | |
| 139 | 140 | #endif |
| 140 | 141 | |
| 141 | 142 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -265,8 +266,8 @@ public: |
| 265 | 266 | _LIBCPP_INLINE_VISIBILITY |
| 266 | 267 | istrstream& operator=(istrstream&& __rhs) |
| 267 | 268 | { |
| 268 | istream::operator=(_VSTD::move(__rhs)); | |
| 269 | 269 | __sb_ = _VSTD::move(__rhs.__sb_); |
| 270 | istream::operator=(_VSTD::move(__rhs)); | |
| 270 | 271 | return *this; |
| 271 | 272 | } |
| 272 | 273 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -314,8 +315,8 @@ public: |
| 314 | 315 | _LIBCPP_INLINE_VISIBILITY |
| 315 | 316 | ostrstream& operator=(ostrstream&& __rhs) |
| 316 | 317 | { |
| 317 | ostream::operator=(_VSTD::move(__rhs)); | |
| 318 | 318 | __sb_ = _VSTD::move(__rhs.__sb_); |
| 319 | ostream::operator=(_VSTD::move(__rhs)); | |
| 319 | 320 | return *this; |
| 320 | 321 | } |
| 321 | 322 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -374,8 +375,8 @@ public: |
| 374 | 375 | _LIBCPP_INLINE_VISIBILITY |
| 375 | 376 | strstream& operator=(strstream&& __rhs) |
| 376 | 377 | { |
| 377 | iostream::operator=(_VSTD::move(__rhs)); | |
| 378 | 378 | __sb_ = _VSTD::move(__rhs.__sb_); |
| 379 | iostream::operator=(_VSTD::move(__rhs)); | |
| 379 | 380 | return *this; |
| 380 | 381 | } |
| 381 | 382 | #endif // _LIBCPP_CXX03_LANG |
lib/libcxx/include/system_error+13-11| ... | ... | @@ -142,18 +142,21 @@ template <> struct hash<std::error_condition>; |
| 142 | 142 | |
| 143 | 143 | */ |
| 144 | 144 | |
| 145 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 145 | 146 | #include <__config> |
| 146 | 147 | #include <__errc> |
| 148 | #include <__functional/hash.h> | |
| 147 | 149 | #include <__functional/unary_function.h> |
| 148 | #include <__functional_base> | |
| 149 | #include <compare> | |
| 150 | 150 | #include <stdexcept> |
| 151 | 151 | #include <string> |
| 152 | 152 | #include <type_traits> |
| 153 | 153 | #include <version> |
| 154 | 154 | |
| 155 | // standard-mandated includes | |
| 156 | #include <compare> | |
| 157 | ||
| 155 | 158 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 156 | #pragma GCC system_header | |
| 159 | # pragma GCC system_header | |
| 157 | 160 | #endif |
| 158 | 161 | |
| 159 | 162 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -184,7 +187,7 @@ template <> |
| 184 | 187 | struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc> |
| 185 | 188 | : true_type { }; |
| 186 | 189 | |
| 187 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS | |
| 190 | #ifdef _LIBCPP_CXX03_LANG | |
| 188 | 191 | template <> |
| 189 | 192 | struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx> |
| 190 | 193 | : true_type { }; |
| ... | ... | @@ -202,9 +205,8 @@ class _LIBCPP_TYPE_VIS error_category |
| 202 | 205 | public: |
| 203 | 206 | virtual ~error_category() _NOEXCEPT; |
| 204 | 207 | |
| 205 | #if defined(_LIBCPP_BUILDING_LIBRARY) && \ | |
| 206 | defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) | |
| 207 | error_category() _NOEXCEPT; | |
| 208 | #if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 209 | error_category() noexcept; | |
| 208 | 210 | #else |
| 209 | 211 | _LIBCPP_INLINE_VISIBILITY |
| 210 | 212 | _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT = default; |
| ... | ... | @@ -234,7 +236,7 @@ class _LIBCPP_HIDDEN __do_message |
| 234 | 236 | : public error_category |
| 235 | 237 | { |
| 236 | 238 | public: |
| 237 | virtual string message(int ev) const; | |
| 239 | virtual string message(int __ev) const; | |
| 238 | 240 | }; |
| 239 | 241 | |
| 240 | 242 | _LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; |
| ... | ... | @@ -436,7 +438,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT |
| 436 | 438 | |
| 437 | 439 | template <> |
| 438 | 440 | struct _LIBCPP_TEMPLATE_VIS hash<error_code> |
| 439 | : public unary_function<error_code, size_t> | |
| 441 | : public __unary_function<error_code, size_t> | |
| 440 | 442 | { |
| 441 | 443 | _LIBCPP_INLINE_VISIBILITY |
| 442 | 444 | size_t operator()(const error_code& __ec) const _NOEXCEPT |
| ... | ... | @@ -447,7 +449,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<error_code> |
| 447 | 449 | |
| 448 | 450 | template <> |
| 449 | 451 | struct _LIBCPP_TEMPLATE_VIS hash<error_condition> |
| 450 | : public unary_function<error_condition, size_t> | |
| 452 | : public __unary_function<error_condition, size_t> | |
| 451 | 453 | { |
| 452 | 454 | _LIBCPP_INLINE_VISIBILITY |
| 453 | 455 | size_t operator()(const error_condition& __ec) const _NOEXCEPT |
| ... | ... | @@ -480,7 +482,7 @@ private: |
| 480 | 482 | }; |
| 481 | 483 | |
| 482 | 484 | _LIBCPP_NORETURN _LIBCPP_FUNC_VIS |
| 483 | void __throw_system_error(int ev, const char* what_arg); | |
| 485 | void __throw_system_error(int __ev, const char* __what_arg); | |
| 484 | 486 | |
| 485 | 487 | _LIBCPP_END_NAMESPACE_STD |
| 486 | 488 |
lib/libcxx/include/tgmath.h+1-1| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | #include <__config> |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 23 | #pragma GCC system_header | |
| 23 | # pragma GCC system_header | |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | 26 | #ifdef __cplusplus |
lib/libcxx/include/thread+15-15| ... | ... | @@ -82,17 +82,15 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
| 82 | 82 | |
| 83 | 83 | */ |
| 84 | 84 | |
| 85 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 85 | 86 | #include <__config> |
| 86 | #include <__debug> | |
| 87 | #include <__functional_base> | |
| 87 | #include <__functional/hash.h> | |
| 88 | 88 | #include <__mutex_base> |
| 89 | 89 | #include <__thread/poll_with_backoff.h> |
| 90 | 90 | #include <__thread/timed_backoff_policy.h> |
| 91 | 91 | #include <__threading_support> |
| 92 | 92 | #include <__utility/forward.h> |
| 93 | #include <chrono> | |
| 94 | 93 | #include <cstddef> |
| 95 | #include <functional> | |
| 96 | 94 | #include <iosfwd> |
| 97 | 95 | #include <memory> |
| 98 | 96 | #include <system_error> |
| ... | ... | @@ -100,16 +98,24 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
| 100 | 98 | #include <type_traits> |
| 101 | 99 | #include <version> |
| 102 | 100 | |
| 101 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 102 | # include <chrono> | |
| 103 | # include <functional> | |
| 104 | #endif | |
| 105 | ||
| 106 | // standard-mandated includes | |
| 107 | #include <compare> | |
| 108 | ||
| 103 | 109 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 104 | #pragma GCC system_header | |
| 110 | # pragma GCC system_header | |
| 105 | 111 | #endif |
| 106 | 112 | |
| 107 | 113 | _LIBCPP_PUSH_MACROS |
| 108 | 114 | #include <__undef_macros> |
| 109 | 115 | |
| 110 | 116 | #ifdef _LIBCPP_HAS_NO_THREADS |
| 111 | #error <thread> is not supported on this single threaded system | |
| 112 | #else // !_LIBCPP_HAS_NO_THREADS | |
| 117 | # error "<thread> is not supported since libc++ has been configured without support for threads." | |
| 118 | #endif | |
| 113 | 119 | |
| 114 | 120 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 115 | 121 | |
| ... | ... | @@ -200,7 +206,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p) |
| 200 | 206 | |
| 201 | 207 | template<> |
| 202 | 208 | struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> |
| 203 | : public unary_function<__thread_id, size_t> | |
| 209 | : public __unary_function<__thread_id, size_t> | |
| 204 | 210 | { |
| 205 | 211 | _LIBCPP_INLINE_VISIBILITY |
| 206 | 212 | size_t operator()(__thread_id __v) const _NOEXCEPT |
| ... | ... | @@ -229,11 +235,7 @@ public: |
| 229 | 235 | thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {} |
| 230 | 236 | #ifndef _LIBCPP_CXX03_LANG |
| 231 | 237 | template <class _Fp, class ..._Args, |
| 232 | class = typename enable_if | |
| 233 | < | |
| 234 | !is_same<typename __uncvref<_Fp>::type, thread>::value | |
| 235 | >::type | |
| 236 | > | |
| 238 | class = __enable_if_t<!is_same<__uncvref_t<_Fp>, thread>::value> > | |
| 237 | 239 | _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS |
| 238 | 240 | explicit thread(_Fp&& __f, _Args&&... __args); |
| 239 | 241 | #else // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -408,8 +410,6 @@ void yield() _NOEXCEPT {__libcpp_thread_yield();} |
| 408 | 410 | |
| 409 | 411 | _LIBCPP_END_NAMESPACE_STD |
| 410 | 412 | |
| 411 | #endif // !_LIBCPP_HAS_NO_THREADS | |
| 412 | ||
| 413 | 413 | _LIBCPP_POP_MACROS |
| 414 | 414 | |
| 415 | 415 | #endif // _LIBCPP_THREAD |
lib/libcxx/include/tuple+341-147| ... | ... | @@ -25,14 +25,24 @@ public: |
| 25 | 25 | explicit(see-below) tuple(U&&...); // constexpr in C++14 |
| 26 | 26 | tuple(const tuple&) = default; |
| 27 | 27 | tuple(tuple&&) = default; |
| 28 | ||
| 29 | template<class... UTypes> | |
| 30 | constexpr explicit(see-below) tuple(tuple<UTypes...>&); // C++23 | |
| 28 | 31 | template <class... U> |
| 29 | 32 | explicit(see-below) tuple(const tuple<U...>&); // constexpr in C++14 |
| 30 | 33 | template <class... U> |
| 31 | 34 | explicit(see-below) tuple(tuple<U...>&&); // constexpr in C++14 |
| 35 | template<class... UTypes> | |
| 36 | constexpr explicit(see-below) tuple(const tuple<UTypes...>&&); // C++23 | |
| 37 | ||
| 38 | template<class U1, class U2> | |
| 39 | constexpr explicit(see-below) tuple(pair<U1, U2>&); // iff sizeof...(Types) == 2 // C++23 | |
| 32 | 40 | template <class U1, class U2> |
| 33 | 41 | explicit(see-below) tuple(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++14 |
| 34 | 42 | template <class U1, class U2> |
| 35 | 43 | explicit(see-below) tuple(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++14 |
| 44 | template<class U1, class U2> | |
| 45 | constexpr explicit(see-below) tuple(const pair<U1, U2>&&); // iff sizeof...(Types) == 2 // C++23 | |
| 36 | 46 | |
| 37 | 47 | // allocator-extended constructors |
| 38 | 48 | template <class Alloc> |
| ... | ... | @@ -45,25 +55,47 @@ public: |
| 45 | 55 | tuple(allocator_arg_t, const Alloc& a, const tuple&); // constexpr in C++20 |
| 46 | 56 | template <class Alloc> |
| 47 | 57 | tuple(allocator_arg_t, const Alloc& a, tuple&&); // constexpr in C++20 |
| 58 | template<class Alloc, class... UTypes> | |
| 59 | constexpr explicit(see-below) | |
| 60 | tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&); // C++23 | |
| 48 | 61 | template <class Alloc, class... U> |
| 49 | 62 | explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const tuple<U...>&); // constexpr in C++20 |
| 50 | 63 | template <class Alloc, class... U> |
| 51 | 64 | explicit(see-below) tuple(allocator_arg_t, const Alloc& a, tuple<U...>&&); // constexpr in C++20 |
| 65 | template<class Alloc, class... UTypes> | |
| 66 | constexpr explicit(see-below) | |
| 67 | tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&&); // C++23 | |
| 68 | template<class Alloc, class U1, class U2> | |
| 69 | constexpr explicit(see-below) | |
| 70 | tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&); // C++23 | |
| 52 | 71 | template <class Alloc, class U1, class U2> |
| 53 | 72 | explicit(see-below) tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&); // constexpr in C++20 |
| 54 | 73 | template <class Alloc, class U1, class U2> |
| 55 | 74 | explicit(see-below) tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&); // constexpr in C++20 |
| 75 | template<class Alloc, class U1, class U2> | |
| 76 | constexpr explicit(see-below) | |
| 77 | tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&&); // C++23 | |
| 56 | 78 | |
| 57 | 79 | tuple& operator=(const tuple&); // constexpr in C++20 |
| 80 | constexpr const tuple& operator=(const tuple&) const; // C++23 | |
| 58 | 81 | tuple& operator=(tuple&&) noexcept(is_nothrow_move_assignable_v<T> && ...); // constexpr in C++20 |
| 82 | constexpr const tuple& operator=(tuple&&) const; // C++23 | |
| 59 | 83 | template <class... U> |
| 60 | 84 | tuple& operator=(const tuple<U...>&); // constexpr in C++20 |
| 85 | template<class... UTypes> | |
| 86 | constexpr const tuple& operator=(const tuple<UTypes...>&) const; // C++23 | |
| 61 | 87 | template <class... U> |
| 62 | 88 | tuple& operator=(tuple<U...>&&); // constexpr in C++20 |
| 89 | template<class... UTypes> | |
| 90 | constexpr const tuple& operator=(tuple<UTypes...>&&) const; // C++23 | |
| 63 | 91 | template <class U1, class U2> |
| 64 | 92 | tuple& operator=(const pair<U1, U2>&); // iff sizeof...(T) == 2 // constexpr in C++20 |
| 93 | template<class U1, class U2> | |
| 94 | constexpr const tuple& operator=(const pair<U1, U2>&) const; // iff sizeof...(Types) == 2 // C++23 | |
| 65 | 95 | template <class U1, class U2> |
| 66 | 96 | tuple& operator=(pair<U1, U2>&&); // iff sizeof...(T) == 2 // constexpr in C++20 |
| 97 | template<class U1, class U2> | |
| 98 | constexpr const tuple& operator=(pair<U1, U2>&&) const; // iff sizeof...(Types) == 2 // C++23 | |
| 67 | 99 | |
| 68 | 100 | template<class U, size_t N> |
| 69 | 101 | tuple& operator=(array<U, N> const&) // iff sizeof...(T) == N, EXTENSION |
| ... | ... | @@ -71,6 +103,7 @@ public: |
| 71 | 103 | tuple& operator=(array<U, N>&&) // iff sizeof...(T) == N, EXTENSION |
| 72 | 104 | |
| 73 | 105 | void swap(tuple&) noexcept(AND(swap(declval<T&>(), declval<T&>())...)); // constexpr in C++20 |
| 106 | constexpr void swap(const tuple&) const noexcept(see-below); // C++23 | |
| 74 | 107 | }; |
| 75 | 108 | |
| 76 | 109 | |
| ... | ... | @@ -161,29 +194,44 @@ template <class... Types> |
| 161 | 194 | void |
| 162 | 195 | swap(tuple<Types...>& x, tuple<Types...>& y) noexcept(noexcept(x.swap(y))); |
| 163 | 196 | |
| 197 | template <class... Types> | |
| 198 | constexpr void swap(const tuple<Types...>& x, const tuple<Types...>& y) noexcept(see-below); // C++23 | |
| 199 | ||
| 164 | 200 | } // std |
| 165 | 201 | |
| 166 | 202 | */ |
| 167 | 203 | |
| 204 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 168 | 205 | #include <__compare/common_comparison_category.h> |
| 169 | 206 | #include <__compare/synth_three_way.h> |
| 170 | 207 | #include <__config> |
| 171 | 208 | #include <__functional/unwrap_ref.h> |
| 172 | #include <__functional_base> | |
| 173 | 209 | #include <__memory/allocator_arg_t.h> |
| 174 | 210 | #include <__memory/uses_allocator.h> |
| 175 | 211 | #include <__tuple> |
| 176 | 212 | #include <__utility/forward.h> |
| 177 | 213 | #include <__utility/integer_sequence.h> |
| 178 | 214 | #include <__utility/move.h> |
| 179 | #include <compare> | |
| 215 | #include <__utility/pair.h> | |
| 216 | #include <__utility/piecewise_construct.h> | |
| 217 | #include <__utility/swap.h> | |
| 180 | 218 | #include <cstddef> |
| 181 | 219 | #include <type_traits> |
| 182 | #include <utility> | |
| 183 | 220 | #include <version> |
| 184 | 221 | |
| 222 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 223 | # include <exception> | |
| 224 | # include <iosfwd> | |
| 225 | # include <new> | |
| 226 | # include <typeinfo> | |
| 227 | # include <utility> | |
| 228 | #endif | |
| 229 | ||
| 230 | // standard-mandated includes | |
| 231 | #include <compare> | |
| 232 | ||
| 185 | 233 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 186 | #pragma GCC system_header | |
| 234 | # pragma GCC system_header | |
| 187 | 235 | #endif |
| 188 | 236 | |
| 189 | 237 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -206,6 +254,13 @@ void swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) |
| 206 | 254 | swap(__x.get(), __y.get()); |
| 207 | 255 | } |
| 208 | 256 | |
| 257 | template <size_t _Ip, class _Hp, bool _Ep> | |
| 258 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 259 | void swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y) | |
| 260 | _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) { | |
| 261 | swap(__x.get(), __y.get()); | |
| 262 | } | |
| 263 | ||
| 209 | 264 | template <size_t _Ip, class _Hp, bool> |
| 210 | 265 | class __tuple_leaf |
| 211 | 266 | { |
| ... | ... | @@ -294,6 +349,12 @@ public: |
| 294 | 349 | return 0; |
| 295 | 350 | } |
| 296 | 351 | |
| 352 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 353 | int swap(const __tuple_leaf& __t) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) { | |
| 354 | _VSTD::swap(*this, __t); | |
| 355 | return 0; | |
| 356 | } | |
| 357 | ||
| 297 | 358 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return __value_;} |
| 298 | 359 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return __value_;} |
| 299 | 360 | }; |
| ... | ... | @@ -360,6 +421,12 @@ public: |
| 360 | 421 | return 0; |
| 361 | 422 | } |
| 362 | 423 | |
| 424 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 425 | int swap(const __tuple_leaf& __rhs) const _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) { | |
| 426 | _VSTD::swap(*this, __rhs); | |
| 427 | return 0; | |
| 428 | } | |
| 429 | ||
| 363 | 430 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Hp& get() _NOEXCEPT {return static_cast<_Hp&>(*this);} |
| 364 | 431 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Hp& get() const _NOEXCEPT {return static_cast<const _Hp&>(*this);} |
| 365 | 432 | }; |
| ... | ... | @@ -415,10 +482,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. |
| 415 | 482 | {} |
| 416 | 483 | |
| 417 | 484 | template <class _Tuple, |
| 418 | class = typename enable_if | |
| 419 | < | |
| 420 | __tuple_constructible<_Tuple, tuple<_Tp...> >::value | |
| 421 | >::type | |
| 485 | class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value> | |
| 422 | 486 | > |
| 423 | 487 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 424 | 488 | __tuple_impl(_Tuple&& __t) _NOEXCEPT_((__all<is_nothrow_constructible<_Tp, typename tuple_element<_Indx, |
| ... | ... | @@ -428,10 +492,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. |
| 428 | 492 | {} |
| 429 | 493 | |
| 430 | 494 | template <class _Alloc, class _Tuple, |
| 431 | class = typename enable_if | |
| 432 | < | |
| 433 | __tuple_constructible<_Tuple, tuple<_Tp...> >::value | |
| 434 | >::type | |
| 495 | class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value> | |
| 435 | 496 | > |
| 436 | 497 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 437 | 498 | __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t) |
| ... | ... | @@ -450,6 +511,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp. |
| 450 | 511 | { |
| 451 | 512 | _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...); |
| 452 | 513 | } |
| 514 | ||
| 515 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 | |
| 516 | void swap(const __tuple_impl& __t) const | |
| 517 | _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value) | |
| 518 | { | |
| 519 | _VSTD::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...); | |
| 520 | } | |
| 453 | 521 | }; |
| 454 | 522 | |
| 455 | 523 | template<class _Dest, class _Source, size_t ..._Np> |
| ... | ... | @@ -685,6 +753,7 @@ public: |
| 685 | 753 | template <class _Alloc, template<class...> class _And = _And, __enable_if_t< |
| 686 | 754 | _And<is_copy_constructible<_Tp>...>::value |
| 687 | 755 | , int> = 0> |
| 756 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 688 | 757 | tuple(allocator_arg_t, const _Alloc& __alloc, const tuple& __t) |
| 689 | 758 | : __base_(allocator_arg_t(), __alloc, __t) |
| 690 | 759 | { } |
| ... | ... | @@ -692,30 +761,39 @@ public: |
| 692 | 761 | template <class _Alloc, template<class...> class _And = _And, __enable_if_t< |
| 693 | 762 | _And<is_move_constructible<_Tp>...>::value |
| 694 | 763 | , int> = 0> |
| 764 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 695 | 765 | tuple(allocator_arg_t, const _Alloc& __alloc, tuple&& __t) |
| 696 | 766 | : __base_(allocator_arg_t(), __alloc, _VSTD::move(__t)) |
| 697 | 767 | { } |
| 698 | 768 | |
| 699 | 769 | // tuple(const tuple<U...>&) constructors (including allocator_arg_t variants) |
| 700 | template <class ..._Up> | |
| 701 | struct _EnableCopyFromOtherTuple : _And< | |
| 702 | _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >, | |
| 703 | _Lazy<_Or, | |
| 704 | _BoolConstant<sizeof...(_Tp) != 1>, | |
| 770 | ||
| 771 | template <class _OtherTuple, class _DecayedOtherTuple = __uncvref_t<_OtherTuple>, class = void> | |
| 772 | struct _EnableCtorFromUTypesTuple : false_type {}; | |
| 773 | ||
| 774 | template <class _OtherTuple, class... _Up> | |
| 775 | struct _EnableCtorFromUTypesTuple<_OtherTuple, tuple<_Up...>, | |
| 776 | // the length of the packs needs to checked first otherwise the 2 packs cannot be expanded simultaneously below | |
| 777 | __enable_if_t<sizeof...(_Up) == sizeof...(_Tp)>> : _And< | |
| 778 | // the two conditions below are not in spec. The purpose is to disable the UTypes Ctor when copy/move Ctor can work. | |
| 779 | // Otherwise, is_constructible can trigger hard error in those cases https://godbolt.org/z/M94cGdKcE | |
| 780 | _Not<is_same<_OtherTuple, const tuple&> >, | |
| 781 | _Not<is_same<_OtherTuple, tuple&&> >, | |
| 782 | is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >..., | |
| 783 | _Lazy<_Or, _BoolConstant<sizeof...(_Tp) != 1>, | |
| 705 | 784 | // _Tp and _Up are 1-element packs - the pack expansions look |
| 706 | 785 | // weird to avoid tripping up the type traits in degenerate cases |
| 707 | 786 | _Lazy<_And, |
| 708 | _Not<is_convertible<const tuple<_Up>&, _Tp> >..., | |
| 709 | _Not<is_constructible<_Tp, const tuple<_Up>&> >... | |
| 787 | _Not<is_same<_Tp, _Up> >..., | |
| 788 | _Not<is_convertible<_OtherTuple, _Tp> >..., | |
| 789 | _Not<is_constructible<_Tp, _OtherTuple> >... | |
| 710 | 790 | > |
| 711 | >, | |
| 712 | is_constructible<_Tp, const _Up&>... | |
| 713 | > { }; | |
| 791 | > | |
| 792 | > {}; | |
| 714 | 793 | |
| 715 | 794 | template <class ..._Up, __enable_if_t< |
| 716 | 795 | _And< |
| 717 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 718 | _EnableCopyFromOtherTuple<_Up...>, | |
| 796 | _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, | |
| 719 | 797 | is_convertible<const _Up&, _Tp>... // explicit check |
| 720 | 798 | >::value |
| 721 | 799 | , int> = 0> |
| ... | ... | @@ -727,8 +805,7 @@ public: |
| 727 | 805 | |
| 728 | 806 | template <class ..._Up, __enable_if_t< |
| 729 | 807 | _And< |
| 730 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 731 | _EnableCopyFromOtherTuple<_Up...>, | |
| 808 | _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, | |
| 732 | 809 | _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check |
| 733 | 810 | >::value |
| 734 | 811 | , int> = 0> |
| ... | ... | @@ -740,8 +817,7 @@ public: |
| 740 | 817 | |
| 741 | 818 | template <class ..._Up, class _Alloc, __enable_if_t< |
| 742 | 819 | _And< |
| 743 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 744 | _EnableCopyFromOtherTuple<_Up...>, | |
| 820 | _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, | |
| 745 | 821 | is_convertible<const _Up&, _Tp>... // explicit check |
| 746 | 822 | >::value |
| 747 | 823 | , int> = 0> |
| ... | ... | @@ -752,8 +828,7 @@ public: |
| 752 | 828 | |
| 753 | 829 | template <class ..._Up, class _Alloc, __enable_if_t< |
| 754 | 830 | _And< |
| 755 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 756 | _EnableCopyFromOtherTuple<_Up...>, | |
| 831 | _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, | |
| 757 | 832 | _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check |
| 758 | 833 | >::value |
| 759 | 834 | , int> = 0> |
| ... | ... | @@ -762,26 +837,27 @@ public: |
| 762 | 837 | : __base_(allocator_arg_t(), __a, __t) |
| 763 | 838 | { } |
| 764 | 839 | |
| 840 | #if _LIBCPP_STD_VER > 20 | |
| 841 | // tuple(tuple<U...>&) constructors (including allocator_arg_t variants) | |
| 842 | ||
| 843 | template <class... _Up, enable_if_t< | |
| 844 | _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> | |
| 845 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 846 | explicit(!(is_convertible_v<_Up&, _Tp> && ...)) | |
| 847 | tuple(tuple<_Up...>& __t) : __base_(__t) {} | |
| 848 | ||
| 849 | template <class _Alloc, class... _Up, enable_if_t< | |
| 850 | _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> | |
| 851 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 852 | explicit(!(is_convertible_v<_Up&, _Tp> && ...)) | |
| 853 | tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {} | |
| 854 | #endif // _LIBCPP_STD_VER > 20 | |
| 855 | ||
| 765 | 856 | // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) |
| 766 | template <class ..._Up> | |
| 767 | struct _EnableMoveFromOtherTuple : _And< | |
| 768 | _Not<is_same<tuple<_Tp...>, tuple<_Up...> > >, | |
| 769 | _Lazy<_Or, | |
| 770 | _BoolConstant<sizeof...(_Tp) != 1>, | |
| 771 | // _Tp and _Up are 1-element packs - the pack expansions look | |
| 772 | // weird to avoid tripping up the type traits in degenerate cases | |
| 773 | _Lazy<_And, | |
| 774 | _Not<is_convertible<tuple<_Up>, _Tp> >..., | |
| 775 | _Not<is_constructible<_Tp, tuple<_Up> > >... | |
| 776 | > | |
| 777 | >, | |
| 778 | is_constructible<_Tp, _Up>... | |
| 779 | > { }; | |
| 780 | 857 | |
| 781 | 858 | template <class ..._Up, __enable_if_t< |
| 782 | 859 | _And< |
| 783 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 784 | _EnableMoveFromOtherTuple<_Up...>, | |
| 860 | _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, | |
| 785 | 861 | is_convertible<_Up, _Tp>... // explicit check |
| 786 | 862 | >::value |
| 787 | 863 | , int> = 0> |
| ... | ... | @@ -793,8 +869,7 @@ public: |
| 793 | 869 | |
| 794 | 870 | template <class ..._Up, __enable_if_t< |
| 795 | 871 | _And< |
| 796 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 797 | _EnableMoveFromOtherTuple<_Up...>, | |
| 872 | _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, | |
| 798 | 873 | _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check |
| 799 | 874 | >::value |
| 800 | 875 | , int> = 0> |
| ... | ... | @@ -806,8 +881,7 @@ public: |
| 806 | 881 | |
| 807 | 882 | template <class _Alloc, class ..._Up, __enable_if_t< |
| 808 | 883 | _And< |
| 809 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 810 | _EnableMoveFromOtherTuple<_Up...>, | |
| 884 | _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, | |
| 811 | 885 | is_convertible<_Up, _Tp>... // explicit check |
| 812 | 886 | >::value |
| 813 | 887 | , int> = 0> |
| ... | ... | @@ -818,8 +892,7 @@ public: |
| 818 | 892 | |
| 819 | 893 | template <class _Alloc, class ..._Up, __enable_if_t< |
| 820 | 894 | _And< |
| 821 | _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, | |
| 822 | _EnableMoveFromOtherTuple<_Up...>, | |
| 895 | _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, | |
| 823 | 896 | _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check |
| 824 | 897 | >::value |
| 825 | 898 | , int> = 0> |
| ... | ... | @@ -828,57 +901,77 @@ public: |
| 828 | 901 | : __base_(allocator_arg_t(), __a, _VSTD::move(__t)) |
| 829 | 902 | { } |
| 830 | 903 | |
| 904 | #if _LIBCPP_STD_VER > 20 | |
| 905 | // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants) | |
| 906 | ||
| 907 | template <class... _Up, enable_if_t< | |
| 908 | _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> | |
| 909 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 910 | explicit(!(is_convertible_v<const _Up&&, _Tp> && ...)) | |
| 911 | tuple(const tuple<_Up...>&& __t) : __base_(std::move(__t)) {} | |
| 912 | ||
| 913 | template <class _Alloc, class... _Up, enable_if_t< | |
| 914 | _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> | |
| 915 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 916 | explicit(!(is_convertible_v<const _Up&&, _Tp> && ...)) | |
| 917 | tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t) | |
| 918 | : __base_(allocator_arg_t(), __alloc, std::move(__t)) {} | |
| 919 | #endif // _LIBCPP_STD_VER > 20 | |
| 920 | ||
| 831 | 921 | // tuple(const pair<U1, U2>&) constructors (including allocator_arg_t variants) |
| 832 | template <class _Up1, class _Up2, class ..._DependentTp> | |
| 833 | struct _EnableImplicitCopyFromPair : _And< | |
| 834 | is_constructible<_FirstType<_DependentTp...>, const _Up1&>, | |
| 835 | is_constructible<_SecondType<_DependentTp...>, const _Up2&>, | |
| 836 | is_convertible<const _Up1&, _FirstType<_DependentTp...> >, // explicit check | |
| 837 | is_convertible<const _Up2&, _SecondType<_DependentTp...> > | |
| 838 | > { }; | |
| 839 | 922 | |
| 840 | template <class _Up1, class _Up2, class ..._DependentTp> | |
| 841 | struct _EnableExplicitCopyFromPair : _And< | |
| 842 | is_constructible<_FirstType<_DependentTp...>, const _Up1&>, | |
| 843 | is_constructible<_SecondType<_DependentTp...>, const _Up2&>, | |
| 844 | _Not<is_convertible<const _Up1&, _FirstType<_DependentTp...> > >, // explicit check | |
| 845 | _Not<is_convertible<const _Up2&, _SecondType<_DependentTp...> > > | |
| 846 | > { }; | |
| 923 | template <template <class...> class Pred, class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple> | |
| 924 | struct _CtorPredicateFromPair : false_type{}; | |
| 925 | ||
| 926 | template <template <class...> class Pred, class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2> | |
| 927 | struct _CtorPredicateFromPair<Pred, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And< | |
| 928 | Pred<_Tp1, __copy_cvref_t<_Pair, _Up1> >, | |
| 929 | Pred<_Tp2, __copy_cvref_t<_Pair, _Up2> > | |
| 930 | > {}; | |
| 931 | ||
| 932 | template <class _Pair> | |
| 933 | struct _EnableCtorFromPair : _CtorPredicateFromPair<is_constructible, _Pair>{}; | |
| 934 | ||
| 935 | template <class _Pair> | |
| 936 | struct _NothrowConstructibleFromPair : _CtorPredicateFromPair<is_nothrow_constructible, _Pair>{}; | |
| 937 | ||
| 938 | template <class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple> | |
| 939 | struct _BothImplicitlyConvertible : false_type{}; | |
| 940 | ||
| 941 | template <class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2> | |
| 942 | struct _BothImplicitlyConvertible<_Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : _And< | |
| 943 | is_convertible<__copy_cvref_t<_Pair, _Up1>, _Tp1>, | |
| 944 | is_convertible<__copy_cvref_t<_Pair, _Up2>, _Tp2> | |
| 945 | > {}; | |
| 847 | 946 | |
| 848 | 947 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 849 | 948 | _And< |
| 850 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 851 | _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...> | |
| 949 | _EnableCtorFromPair<const pair<_Up1, _Up2>&>, | |
| 950 | _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check | |
| 852 | 951 | >::value |
| 853 | 952 | , int> = 0> |
| 854 | 953 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 855 | 954 | tuple(const pair<_Up1, _Up2>& __p) |
| 856 | _NOEXCEPT_((_And< | |
| 857 | is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>, | |
| 858 | is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&> | |
| 859 | >::value)) | |
| 955 | _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)) | |
| 860 | 956 | : __base_(__p) |
| 861 | 957 | { } |
| 862 | 958 | |
| 863 | 959 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 864 | 960 | _And< |
| 865 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 866 | _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...> | |
| 961 | _EnableCtorFromPair<const pair<_Up1, _Up2>&>, | |
| 962 | _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check | |
| 867 | 963 | >::value |
| 868 | 964 | , int> = 0> |
| 869 | 965 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 870 | 966 | explicit tuple(const pair<_Up1, _Up2>& __p) |
| 871 | _NOEXCEPT_((_And< | |
| 872 | is_nothrow_constructible<_FirstType<_Tp...>, const _Up1&>, | |
| 873 | is_nothrow_constructible<_SecondType<_Tp...>, const _Up2&> | |
| 874 | >::value)) | |
| 967 | _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)) | |
| 875 | 968 | : __base_(__p) |
| 876 | 969 | { } |
| 877 | 970 | |
| 878 | 971 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 879 | 972 | _And< |
| 880 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 881 | _EnableImplicitCopyFromPair<_Up1, _Up2, _Tp...> | |
| 973 | _EnableCtorFromPair<const pair<_Up1, _Up2>&>, | |
| 974 | _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check | |
| 882 | 975 | >::value |
| 883 | 976 | , int> = 0> |
| 884 | 977 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -888,8 +981,8 @@ public: |
| 888 | 981 | |
| 889 | 982 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 890 | 983 | _And< |
| 891 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 892 | _EnableExplicitCopyFromPair<_Up1, _Up2, _Tp...> | |
| 984 | _EnableCtorFromPair<const pair<_Up1, _Up2>&>, | |
| 985 | _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check | |
| 893 | 986 | >::value |
| 894 | 987 | , int> = 0> |
| 895 | 988 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -897,57 +990,52 @@ public: |
| 897 | 990 | : __base_(allocator_arg_t(), __a, __p) |
| 898 | 991 | { } |
| 899 | 992 | |
| 900 | // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants) | |
| 901 | template <class _Up1, class _Up2, class ..._DependentTp> | |
| 902 | struct _EnableImplicitMoveFromPair : _And< | |
| 903 | is_constructible<_FirstType<_DependentTp...>, _Up1>, | |
| 904 | is_constructible<_SecondType<_DependentTp...>, _Up2>, | |
| 905 | is_convertible<_Up1, _FirstType<_DependentTp...> >, // explicit check | |
| 906 | is_convertible<_Up2, _SecondType<_DependentTp...> > | |
| 907 | > { }; | |
| 993 | #if _LIBCPP_STD_VER > 20 | |
| 994 | // tuple(pair<U1, U2>&) constructors (including allocator_arg_t variants) | |
| 995 | ||
| 996 | template <class _U1, class _U2, enable_if_t< | |
| 997 | _EnableCtorFromPair<pair<_U1, _U2>&>::value>* = nullptr> | |
| 998 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 999 | explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) | |
| 1000 | tuple(pair<_U1, _U2>& __p) : __base_(__p) {} | |
| 1001 | ||
| 1002 | template <class _Alloc, class _U1, class _U2, enable_if_t< | |
| 1003 | _EnableCtorFromPair<std::pair<_U1, _U2>&>::value>* = nullptr> | |
| 1004 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1005 | explicit(!_BothImplicitlyConvertible<pair<_U1, _U2>&>::value) | |
| 1006 | tuple(allocator_arg_t, const _Alloc& __alloc, pair<_U1, _U2>& __p) : __base_(allocator_arg_t(), __alloc, __p) {} | |
| 1007 | #endif | |
| 908 | 1008 | |
| 909 | template <class _Up1, class _Up2, class ..._DependentTp> | |
| 910 | struct _EnableExplicitMoveFromPair : _And< | |
| 911 | is_constructible<_FirstType<_DependentTp...>, _Up1>, | |
| 912 | is_constructible<_SecondType<_DependentTp...>, _Up2>, | |
| 913 | _Not<is_convertible<_Up1, _FirstType<_DependentTp...> > >, // explicit check | |
| 914 | _Not<is_convertible<_Up2, _SecondType<_DependentTp...> > > | |
| 915 | > { }; | |
| 1009 | // tuple(pair<U1, U2>&&) constructors (including allocator_arg_t variants) | |
| 916 | 1010 | |
| 917 | 1011 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 918 | 1012 | _And< |
| 919 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 920 | _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...> | |
| 1013 | _EnableCtorFromPair<pair<_Up1, _Up2>&&>, | |
| 1014 | _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check | |
| 921 | 1015 | >::value |
| 922 | 1016 | , int> = 0> |
| 923 | 1017 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 924 | 1018 | tuple(pair<_Up1, _Up2>&& __p) |
| 925 | _NOEXCEPT_((_And< | |
| 926 | is_nothrow_constructible<_FirstType<_Tp...>, _Up1>, | |
| 927 | is_nothrow_constructible<_SecondType<_Tp...>, _Up2> | |
| 928 | >::value)) | |
| 1019 | _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)) | |
| 929 | 1020 | : __base_(_VSTD::move(__p)) |
| 930 | 1021 | { } |
| 931 | 1022 | |
| 932 | 1023 | template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 933 | 1024 | _And< |
| 934 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 935 | _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...> | |
| 1025 | _EnableCtorFromPair<pair<_Up1, _Up2>&&>, | |
| 1026 | _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check | |
| 936 | 1027 | >::value |
| 937 | 1028 | , int> = 0> |
| 938 | 1029 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| 939 | 1030 | explicit tuple(pair<_Up1, _Up2>&& __p) |
| 940 | _NOEXCEPT_((_And< | |
| 941 | is_nothrow_constructible<_FirstType<_Tp...>, _Up1>, | |
| 942 | is_nothrow_constructible<_SecondType<_Tp...>, _Up2> | |
| 943 | >::value)) | |
| 1031 | _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)) | |
| 944 | 1032 | : __base_(_VSTD::move(__p)) |
| 945 | 1033 | { } |
| 946 | 1034 | |
| 947 | 1035 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 948 | 1036 | _And< |
| 949 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 950 | _EnableImplicitMoveFromPair<_Up1, _Up2, _Tp...> | |
| 1037 | _EnableCtorFromPair<pair<_Up1, _Up2>&&>, | |
| 1038 | _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check | |
| 951 | 1039 | >::value |
| 952 | 1040 | , int> = 0> |
| 953 | 1041 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -957,8 +1045,8 @@ public: |
| 957 | 1045 | |
| 958 | 1046 | template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< |
| 959 | 1047 | _And< |
| 960 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 961 | _EnableExplicitMoveFromPair<_Up1, _Up2, _Tp...> | |
| 1048 | _EnableCtorFromPair<pair<_Up1, _Up2>&&>, | |
| 1049 | _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check | |
| 962 | 1050 | >::value |
| 963 | 1051 | , int> = 0> |
| 964 | 1052 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| ... | ... | @@ -966,6 +1054,23 @@ public: |
| 966 | 1054 | : __base_(allocator_arg_t(), __a, _VSTD::move(__p)) |
| 967 | 1055 | { } |
| 968 | 1056 | |
| 1057 | #if _LIBCPP_STD_VER > 20 | |
| 1058 | // tuple(const pair<U1, U2>&&) constructors (including allocator_arg_t variants) | |
| 1059 | ||
| 1060 | template <class _U1, class _U2, enable_if_t< | |
| 1061 | _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> | |
| 1062 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1063 | explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) | |
| 1064 | tuple(const pair<_U1, _U2>&& __p) : __base_(std::move(__p)) {} | |
| 1065 | ||
| 1066 | template <class _Alloc, class _U1, class _U2, enable_if_t< | |
| 1067 | _EnableCtorFromPair<const pair<_U1, _U2>&&>::value>* = nullptr> | |
| 1068 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1069 | explicit(!_BothImplicitlyConvertible<const pair<_U1, _U2>&&>::value) | |
| 1070 | tuple(allocator_arg_t, const _Alloc& __alloc, const pair<_U1, _U2>&& __p) | |
| 1071 | : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} | |
| 1072 | #endif // _LIBCPP_STD_VER > 20 | |
| 1073 | ||
| 969 | 1074 | // [tuple.assign] |
| 970 | 1075 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 971 | 1076 | tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) |
| ... | ... | @@ -976,6 +1081,25 @@ public: |
| 976 | 1081 | return *this; |
| 977 | 1082 | } |
| 978 | 1083 | |
| 1084 | #if _LIBCPP_STD_VER > 20 | |
| 1085 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1086 | const tuple& operator=(tuple const& __tuple) const | |
| 1087 | requires (_And<is_copy_assignable<const _Tp>...>::value) { | |
| 1088 | std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type()); | |
| 1089 | return *this; | |
| 1090 | } | |
| 1091 | ||
| 1092 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1093 | const tuple& operator=(tuple&& __tuple) const | |
| 1094 | requires (_And<is_assignable<const _Tp&, _Tp>...>::value) { | |
| 1095 | std::__memberwise_forward_assign(*this, | |
| 1096 | std::move(__tuple), | |
| 1097 | __tuple_types<_Tp...>(), | |
| 1098 | typename __make_tuple_indices<sizeof...(_Tp)>::type()); | |
| 1099 | return *this; | |
| 1100 | } | |
| 1101 | #endif // _LIBCPP_STD_VER > 20 | |
| 1102 | ||
| 979 | 1103 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 980 | 1104 | tuple& operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) |
| 981 | 1105 | _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value)) |
| ... | ... | @@ -1017,38 +1141,89 @@ public: |
| 1017 | 1141 | return *this; |
| 1018 | 1142 | } |
| 1019 | 1143 | |
| 1020 | template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t< | |
| 1021 | _And<_Dep, | |
| 1022 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 1023 | is_assignable<_FirstType<_Tp..., _Dep>&, _Up1 const&>, | |
| 1024 | is_assignable<_SecondType<_Tp..., _Dep>&, _Up2 const&> | |
| 1025 | >::value | |
| 1144 | ||
| 1145 | #if _LIBCPP_STD_VER > 20 | |
| 1146 | template <class... _UTypes, enable_if_t< | |
| 1147 | _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, | |
| 1148 | is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr> | |
| 1149 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1150 | const tuple& operator=(const tuple<_UTypes...>& __u) const { | |
| 1151 | std::__memberwise_copy_assign(*this, | |
| 1152 | __u, | |
| 1153 | typename __make_tuple_indices<sizeof...(_Tp)>::type()); | |
| 1154 | return *this; | |
| 1155 | } | |
| 1156 | ||
| 1157 | template <class... _UTypes, enable_if_t< | |
| 1158 | _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>, | |
| 1159 | is_assignable<const _Tp&, _UTypes>...>::value>* = nullptr> | |
| 1160 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1161 | const tuple& operator=(tuple<_UTypes...>&& __u) const { | |
| 1162 | std::__memberwise_forward_assign(*this, | |
| 1163 | __u, | |
| 1164 | __tuple_types<_UTypes...>(), | |
| 1165 | typename __make_tuple_indices<sizeof...(_Tp)>::type()); | |
| 1166 | return *this; | |
| 1167 | } | |
| 1168 | #endif // _LIBCPP_STD_VER > 20 | |
| 1169 | ||
| 1170 | template <template<class...> class Pred, bool _Const, | |
| 1171 | class _Pair, class _DecayedPair = __uncvref_t<_Pair>, class _Tuple = tuple> | |
| 1172 | struct _AssignPredicateFromPair : false_type {}; | |
| 1173 | ||
| 1174 | template <template<class...> class Pred, bool _Const, | |
| 1175 | class _Pair, class _Up1, class _Up2, class _Tp1, class _Tp2> | |
| 1176 | struct _AssignPredicateFromPair<Pred, _Const, _Pair, pair<_Up1, _Up2>, tuple<_Tp1, _Tp2> > : | |
| 1177 | _And<Pred<__maybe_const<_Const, _Tp1>&, __copy_cvref_t<_Pair, _Up1> >, | |
| 1178 | Pred<__maybe_const<_Const, _Tp2>&, __copy_cvref_t<_Pair, _Up2> > | |
| 1179 | > {}; | |
| 1180 | ||
| 1181 | template <bool _Const, class _Pair> | |
| 1182 | struct _EnableAssignFromPair : _AssignPredicateFromPair<is_assignable, _Const, _Pair> {}; | |
| 1183 | ||
| 1184 | template <bool _Const, class _Pair> | |
| 1185 | struct _NothrowAssignFromPair : _AssignPredicateFromPair<is_nothrow_assignable, _Const, _Pair> {}; | |
| 1186 | ||
| 1187 | #if _LIBCPP_STD_VER > 20 | |
| 1188 | template <class _U1, class _U2, enable_if_t< | |
| 1189 | _EnableAssignFromPair<true, const pair<_U1, _U2>&>::value>* = nullptr> | |
| 1190 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1191 | const tuple& operator=(const pair<_U1, _U2>& __pair) const | |
| 1192 | noexcept(_NothrowAssignFromPair<true, const pair<_U1, _U2>&>::value) { | |
| 1193 | std::get<0>(*this) = __pair.first; | |
| 1194 | std::get<1>(*this) = __pair.second; | |
| 1195 | return *this; | |
| 1196 | } | |
| 1197 | ||
| 1198 | template <class _U1, class _U2, enable_if_t< | |
| 1199 | _EnableAssignFromPair<true, pair<_U1, _U2>&&>::value>* = nullptr> | |
| 1200 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1201 | const tuple& operator=(pair<_U1, _U2>&& __pair) const | |
| 1202 | noexcept(_NothrowAssignFromPair<true, pair<_U1, _U2>&&>::value) { | |
| 1203 | std::get<0>(*this) = std::move(__pair.first); | |
| 1204 | std::get<1>(*this) = std::move(__pair.second); | |
| 1205 | return *this; | |
| 1206 | } | |
| 1207 | #endif // _LIBCPP_STD_VER > 20 | |
| 1208 | ||
| 1209 | template<class _Up1, class _Up2, __enable_if_t< | |
| 1210 | _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value | |
| 1026 | 1211 | ,int> = 0> |
| 1027 | 1212 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1028 | 1213 | tuple& operator=(pair<_Up1, _Up2> const& __pair) |
| 1029 | _NOEXCEPT_((_And< | |
| 1030 | is_nothrow_assignable<_FirstType<_Tp...>&, _Up1 const&>, | |
| 1031 | is_nothrow_assignable<_SecondType<_Tp...>&, _Up2 const&> | |
| 1032 | >::value)) | |
| 1214 | _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value)) | |
| 1033 | 1215 | { |
| 1034 | 1216 | _VSTD::get<0>(*this) = __pair.first; |
| 1035 | 1217 | _VSTD::get<1>(*this) = __pair.second; |
| 1036 | 1218 | return *this; |
| 1037 | 1219 | } |
| 1038 | 1220 | |
| 1039 | template<class _Up1, class _Up2, class _Dep = true_type, __enable_if_t< | |
| 1040 | _And<_Dep, | |
| 1041 | _BoolConstant<sizeof...(_Tp) == 2>, | |
| 1042 | is_assignable<_FirstType<_Tp..., _Dep>&, _Up1>, | |
| 1043 | is_assignable<_SecondType<_Tp..., _Dep>&, _Up2> | |
| 1044 | >::value | |
| 1221 | template<class _Up1, class _Up2, __enable_if_t< | |
| 1222 | _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value | |
| 1045 | 1223 | ,int> = 0> |
| 1046 | 1224 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1047 | 1225 | tuple& operator=(pair<_Up1, _Up2>&& __pair) |
| 1048 | _NOEXCEPT_((_And< | |
| 1049 | is_nothrow_assignable<_FirstType<_Tp...>&, _Up1>, | |
| 1050 | is_nothrow_assignable<_SecondType<_Tp...>&, _Up2> | |
| 1051 | >::value)) | |
| 1226 | _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value)) | |
| 1052 | 1227 | { |
| 1053 | 1228 | _VSTD::get<0>(*this) = _VSTD::forward<_Up1>(__pair.first); |
| 1054 | 1229 | _VSTD::get<1>(*this) = _VSTD::forward<_Up2>(__pair.second); |
| ... | ... | @@ -1092,6 +1267,13 @@ public: |
| 1092 | 1267 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1093 | 1268 | void swap(tuple& __t) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) |
| 1094 | 1269 | {__base_.swap(__t.__base_);} |
| 1270 | ||
| 1271 | #if _LIBCPP_STD_VER > 20 | |
| 1272 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1273 | void swap(const tuple& __t) const noexcept(__all<is_nothrow_swappable_v<const _Tp&>...>::value) { | |
| 1274 | __base_.swap(__t.__base_); | |
| 1275 | } | |
| 1276 | #endif // _LIBCPP_STD_VER > 20 | |
| 1095 | 1277 | }; |
| 1096 | 1278 | |
| 1097 | 1279 | template <> |
| ... | ... | @@ -1114,6 +1296,9 @@ public: |
| 1114 | 1296 | tuple(allocator_arg_t, const _Alloc&, array<_Up, 0>) _NOEXCEPT {} |
| 1115 | 1297 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1116 | 1298 | void swap(tuple&) _NOEXCEPT {} |
| 1299 | #if _LIBCPP_STD_VER > 20 | |
| 1300 | _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {} | |
| 1301 | #endif | |
| 1117 | 1302 | }; |
| 1118 | 1303 | |
| 1119 | 1304 | #if _LIBCPP_STD_VER > 20 |
| ... | ... | @@ -1128,7 +1313,7 @@ template <class... _TTypes, class... _UTypes> |
| 1128 | 1313 | struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> { |
| 1129 | 1314 | using type = tuple<common_type_t<_TTypes, _UTypes>...>; |
| 1130 | 1315 | }; |
| 1131 | #endif | |
| 1316 | #endif // _LIBCPP_STD_VER > 20 | |
| 1132 | 1317 | |
| 1133 | 1318 | #if _LIBCPP_STD_VER > 14 |
| 1134 | 1319 | template <class ..._Tp> |
| ... | ... | @@ -1145,15 +1330,21 @@ tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; |
| 1145 | 1330 | |
| 1146 | 1331 | template <class ..._Tp> |
| 1147 | 1332 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 |
| 1148 | typename enable_if | |
| 1149 | < | |
| 1150 | __all<__is_swappable<_Tp>::value...>::value, | |
| 1151 | void | |
| 1152 | >::type | |
| 1333 | __enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void> | |
| 1153 | 1334 | swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) |
| 1154 | 1335 | _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) |
| 1155 | 1336 | {__t.swap(__u);} |
| 1156 | 1337 | |
| 1338 | #if _LIBCPP_STD_VER > 20 | |
| 1339 | template <class... _Tp> | |
| 1340 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 1341 | enable_if_t<__all<is_swappable_v<const _Tp>...>::value, void> | |
| 1342 | swap(const tuple<_Tp...>& __lhs, const tuple<_Tp...>& __rhs) | |
| 1343 | noexcept(__all<is_nothrow_swappable_v<const _Tp>...>::value) { | |
| 1344 | __lhs.swap(__rhs); | |
| 1345 | } | |
| 1346 | #endif | |
| 1347 | ||
| 1157 | 1348 | // get |
| 1158 | 1349 | |
| 1159 | 1350 | template <size_t _Ip, class ..._Tp> |
| ... | ... | @@ -1333,7 +1524,7 @@ operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 1333 | 1524 | return __tuple_equal<sizeof...(_Tp)>()(__x, __y); |
| 1334 | 1525 | } |
| 1335 | 1526 | |
| 1336 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1527 | #if _LIBCPP_STD_VER > 17 | |
| 1337 | 1528 | |
| 1338 | 1529 | // operator<=> |
| 1339 | 1530 | |
| ... | ... | @@ -1355,7 +1546,7 @@ operator<=>(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 1355 | 1546 | return _VSTD::__tuple_compare_three_way(__x, __y, index_sequence_for<_Tp...>{}); |
| 1356 | 1547 | } |
| 1357 | 1548 | |
| 1358 | #else // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1549 | #else // _LIBCPP_STD_VER > 17 | |
| 1359 | 1550 | |
| 1360 | 1551 | template <class ..._Tp, class ..._Up> |
| 1361 | 1552 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 |
| ... | ... | @@ -1425,7 +1616,7 @@ operator<=(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) |
| 1425 | 1616 | return !(__y < __x); |
| 1426 | 1617 | } |
| 1427 | 1618 | |
| 1428 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 1619 | #endif // _LIBCPP_STD_VER > 17 | |
| 1429 | 1620 | |
| 1430 | 1621 | // tuple_cat |
| 1431 | 1622 | |
| ... | ... | @@ -1445,9 +1636,10 @@ struct __tuple_cat_return_1 |
| 1445 | 1636 | template <class ..._Types, class _Tuple0> |
| 1446 | 1637 | struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0> |
| 1447 | 1638 | { |
| 1448 | typedef _LIBCPP_NODEBUG typename __tuple_cat_type<tuple<_Types...>, | |
| 1449 | typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type | |
| 1450 | type; | |
| 1639 | using type _LIBCPP_NODEBUG = typename __tuple_cat_type< | |
| 1640 | tuple<_Types...>, | |
| 1641 | typename __make_tuple_types<__uncvref_t<_Tuple0> >::type | |
| 1642 | >::type; | |
| 1451 | 1643 | }; |
| 1452 | 1644 | |
| 1453 | 1645 | template <class ..._Types, class _Tuple0, class _Tuple1, class ..._Tuples> |
| ... | ... | @@ -1455,7 +1647,7 @@ struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0, _Tuple1, _Tuples... |
| 1455 | 1647 | : public __tuple_cat_return_1< |
| 1456 | 1648 | typename __tuple_cat_type< |
| 1457 | 1649 | tuple<_Types...>, |
| 1458 | typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type | |
| 1650 | typename __make_tuple_types<__uncvref_t<_Tuple0> >::type | |
| 1459 | 1651 | >::type, |
| 1460 | 1652 | __tuple_like<typename remove_reference<_Tuple1>::type>::value, |
| 1461 | 1653 | _Tuple1, _Tuples...> |
| ... | ... | @@ -1529,6 +1721,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1529 | 1721 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type |
| 1530 | 1722 | operator()(tuple<_Types...> __t, _Tuple0&& __t0) |
| 1531 | 1723 | { |
| 1724 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty | |
| 1532 | 1725 | return _VSTD::forward_as_tuple( |
| 1533 | 1726 | _VSTD::forward<_Types>(_VSTD::get<_I0>(__t))..., |
| 1534 | 1727 | _VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); |
| ... | ... | @@ -1539,6 +1732,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J |
| 1539 | 1732 | typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type |
| 1540 | 1733 | operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&& ...__tpls) |
| 1541 | 1734 | { |
| 1735 | (void)__t; // avoid unused parameter warning on GCC when _I0 is empty | |
| 1542 | 1736 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple0>::type _T0; |
| 1543 | 1737 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tuple1>::type _T1; |
| 1544 | 1738 | return __tuple_cat< |
| ... | ... | @@ -1593,7 +1787,7 @@ inline _LIBCPP_INLINE_VISIBILITY |
| 1593 | 1787 | constexpr decltype(auto) __apply_tuple_impl(_Fn && __f, _Tuple && __t, |
| 1594 | 1788 | __tuple_indices<_Id...>) |
| 1595 | 1789 | _LIBCPP_NOEXCEPT_RETURN( |
| 1596 | _VSTD::__invoke_constexpr( | |
| 1790 | _VSTD::__invoke( | |
| 1597 | 1791 | _VSTD::forward<_Fn>(__f), |
| 1598 | 1792 | _VSTD::get<_Id>(_VSTD::forward<_Tuple>(__t))...) |
| 1599 | 1793 | ) |
lib/libcxx/include/type_traits+132-3477| ... | ... | @@ -416,3457 +416,178 @@ namespace std |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | */ |
| 419 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 419 | 420 | #include <__config> |
| 421 | #include <__functional/invoke.h> | |
| 422 | #include <__type_traits/add_const.h> | |
| 423 | #include <__type_traits/add_cv.h> | |
| 424 | #include <__type_traits/add_lvalue_reference.h> | |
| 425 | #include <__type_traits/add_pointer.h> | |
| 426 | #include <__type_traits/add_rvalue_reference.h> | |
| 427 | #include <__type_traits/add_volatile.h> | |
| 428 | #include <__type_traits/aligned_storage.h> | |
| 429 | #include <__type_traits/aligned_union.h> | |
| 430 | #include <__type_traits/alignment_of.h> | |
| 431 | #include <__type_traits/apply_cv.h> | |
| 432 | #include <__type_traits/common_reference.h> | |
| 433 | #include <__type_traits/common_type.h> | |
| 434 | #include <__type_traits/conditional.h> | |
| 435 | #include <__type_traits/conjunction.h> | |
| 436 | #include <__type_traits/decay.h> | |
| 437 | #include <__type_traits/disjunction.h> | |
| 438 | #include <__type_traits/enable_if.h> | |
| 439 | #include <__type_traits/extent.h> | |
| 440 | #include <__type_traits/has_unique_object_representation.h> | |
| 441 | #include <__type_traits/has_virtual_destructor.h> | |
| 442 | #include <__type_traits/integral_constant.h> | |
| 443 | #include <__type_traits/is_abstract.h> | |
| 444 | #include <__type_traits/is_aggregate.h> | |
| 445 | #include <__type_traits/is_arithmetic.h> | |
| 446 | #include <__type_traits/is_array.h> | |
| 447 | #include <__type_traits/is_assignable.h> | |
| 448 | #include <__type_traits/is_base_of.h> | |
| 449 | #include <__type_traits/is_bounded_array.h> | |
| 450 | #include <__type_traits/is_callable.h> | |
| 451 | #include <__type_traits/is_class.h> | |
| 452 | #include <__type_traits/is_compound.h> | |
| 453 | #include <__type_traits/is_const.h> | |
| 454 | #include <__type_traits/is_constant_evaluated.h> | |
| 455 | #include <__type_traits/is_constructible.h> | |
| 456 | #include <__type_traits/is_convertible.h> | |
| 457 | #include <__type_traits/is_copy_assignable.h> | |
| 458 | #include <__type_traits/is_copy_constructible.h> | |
| 459 | #include <__type_traits/is_default_constructible.h> | |
| 460 | #include <__type_traits/is_destructible.h> | |
| 461 | #include <__type_traits/is_empty.h> | |
| 462 | #include <__type_traits/is_enum.h> | |
| 463 | #include <__type_traits/is_final.h> | |
| 464 | #include <__type_traits/is_floating_point.h> | |
| 465 | #include <__type_traits/is_function.h> | |
| 466 | #include <__type_traits/is_fundamental.h> | |
| 467 | #include <__type_traits/is_integral.h> | |
| 468 | #include <__type_traits/is_literal_type.h> | |
| 469 | #include <__type_traits/is_member_function_pointer.h> | |
| 470 | #include <__type_traits/is_member_object_pointer.h> | |
| 471 | #include <__type_traits/is_member_pointer.h> | |
| 472 | #include <__type_traits/is_move_assignable.h> | |
| 473 | #include <__type_traits/is_move_constructible.h> | |
| 474 | #include <__type_traits/is_nothrow_assignable.h> | |
| 475 | #include <__type_traits/is_nothrow_constructible.h> | |
| 476 | #include <__type_traits/is_nothrow_convertible.h> | |
| 477 | #include <__type_traits/is_nothrow_copy_assignable.h> | |
| 478 | #include <__type_traits/is_nothrow_copy_constructible.h> | |
| 479 | #include <__type_traits/is_nothrow_default_constructible.h> | |
| 480 | #include <__type_traits/is_nothrow_destructible.h> | |
| 481 | #include <__type_traits/is_nothrow_move_assignable.h> | |
| 482 | #include <__type_traits/is_nothrow_move_constructible.h> | |
| 483 | #include <__type_traits/is_null_pointer.h> | |
| 484 | #include <__type_traits/is_object.h> | |
| 485 | #include <__type_traits/is_pod.h> | |
| 486 | #include <__type_traits/is_pointer.h> | |
| 487 | #include <__type_traits/is_polymorphic.h> | |
| 488 | #include <__type_traits/is_reference.h> | |
| 489 | #include <__type_traits/is_reference_wrapper.h> | |
| 490 | #include <__type_traits/is_referenceable.h> | |
| 491 | #include <__type_traits/is_same.h> | |
| 492 | #include <__type_traits/is_scalar.h> | |
| 493 | #include <__type_traits/is_scoped_enum.h> | |
| 494 | #include <__type_traits/is_signed.h> | |
| 495 | #include <__type_traits/is_standard_layout.h> | |
| 496 | #include <__type_traits/is_trivial.h> | |
| 497 | #include <__type_traits/is_trivially_assignable.h> | |
| 498 | #include <__type_traits/is_trivially_constructible.h> | |
| 499 | #include <__type_traits/is_trivially_copy_assignable.h> | |
| 500 | #include <__type_traits/is_trivially_copy_constructible.h> | |
| 501 | #include <__type_traits/is_trivially_copyable.h> | |
| 502 | #include <__type_traits/is_trivially_default_constructible.h> | |
| 503 | #include <__type_traits/is_trivially_destructible.h> | |
| 504 | #include <__type_traits/is_trivially_move_assignable.h> | |
| 505 | #include <__type_traits/is_trivially_move_constructible.h> | |
| 506 | #include <__type_traits/is_unbounded_array.h> | |
| 507 | #include <__type_traits/is_union.h> | |
| 508 | #include <__type_traits/is_unsigned.h> | |
| 509 | #include <__type_traits/is_void.h> | |
| 510 | #include <__type_traits/is_volatile.h> | |
| 511 | #include <__type_traits/make_signed.h> | |
| 512 | #include <__type_traits/make_unsigned.h> | |
| 513 | #include <__type_traits/negation.h> | |
| 514 | #include <__type_traits/rank.h> | |
| 515 | #include <__type_traits/remove_all_extents.h> | |
| 516 | #include <__type_traits/remove_const.h> | |
| 517 | #include <__type_traits/remove_cv.h> | |
| 518 | #include <__type_traits/remove_extent.h> | |
| 519 | #include <__type_traits/remove_pointer.h> | |
| 520 | #include <__type_traits/remove_reference.h> | |
| 521 | #include <__type_traits/remove_volatile.h> | |
| 522 | #include <__type_traits/type_identity.h> | |
| 523 | #include <__type_traits/underlying_type.h> | |
| 524 | #include <__type_traits/void_t.h> | |
| 525 | #include <__utility/declval.h> | |
| 420 | 526 | #include <cstddef> |
| 527 | #include <cstdint> | |
| 421 | 528 | #include <version> |
| 422 | 529 | |
| 423 | 530 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 424 | #pragma GCC system_header | |
| 531 | # pragma GCC system_header | |
| 425 | 532 | #endif |
| 426 | 533 | |
| 427 | 534 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 428 | 535 | |
| 429 | 536 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS pair; |
| 430 | template <class _Tp> class _LIBCPP_TEMPLATE_VIS reference_wrapper; | |
| 431 | 537 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; |
| 432 | 538 | |
| 433 | template <class _Tp, _Tp __v> | |
| 434 | struct _LIBCPP_TEMPLATE_VIS integral_constant | |
| 435 | { | |
| 436 | static _LIBCPP_CONSTEXPR const _Tp value = __v; | |
| 437 | typedef _Tp value_type; | |
| 438 | typedef integral_constant type; | |
| 439 | _LIBCPP_INLINE_VISIBILITY | |
| 440 | _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT {return value;} | |
| 441 | #if _LIBCPP_STD_VER > 11 | |
| 442 | _LIBCPP_INLINE_VISIBILITY | |
| 443 | constexpr value_type operator ()() const _NOEXCEPT {return value;} | |
| 444 | #endif | |
| 445 | }; | |
| 446 | ||
| 447 | template <class _Tp, _Tp __v> | |
| 448 | _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; | |
| 449 | ||
| 450 | #if _LIBCPP_STD_VER > 14 | |
| 451 | template <bool __b> | |
| 452 | using bool_constant = integral_constant<bool, __b>; | |
| 453 | #define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> | |
| 454 | #else | |
| 455 | #define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> | |
| 456 | #endif | |
| 457 | ||
| 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 | ||
| 467 | typedef _LIBCPP_BOOL_CONSTANT(true) true_type; | |
| 468 | typedef _LIBCPP_BOOL_CONSTANT(false) false_type; | |
| 469 | ||
| 470 | template <bool _Val> | |
| 471 | using _BoolConstant _LIBCPP_NODEBUG = integral_constant<bool, _Val>; | |
| 472 | ||
| 473 | template <bool> struct _MetaBase; | |
| 474 | template <> | |
| 475 | struct _MetaBase<true> { | |
| 476 | template <class _Tp, class _Up> | |
| 477 | using _SelectImpl _LIBCPP_NODEBUG = _Tp; | |
| 478 | template <template <class...> class _FirstFn, template <class...> class, class ..._Args> | |
| 479 | using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>; | |
| 480 | template <class _First, class...> | |
| 481 | using _FirstImpl _LIBCPP_NODEBUG = _First; | |
| 482 | template <class, class _Second, class...> | |
| 483 | using _SecondImpl _LIBCPP_NODEBUG = _Second; | |
| 484 | template <class _Result, class _First, class ..._Rest> | |
| 485 | using _OrImpl _LIBCPP_NODEBUG = typename _MetaBase<_First::value != true && sizeof...(_Rest) != 0>::template _OrImpl<_First, _Rest...>; | |
| 486 | }; | |
| 487 | ||
| 488 | template <> | |
| 489 | struct _MetaBase<false> { | |
| 490 | template <class _Tp, class _Up> | |
| 491 | using _SelectImpl _LIBCPP_NODEBUG = _Up; | |
| 492 | template <template <class...> class, template <class...> class _SecondFn, class ..._Args> | |
| 493 | using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>; | |
| 494 | template <class _Result, class ...> | |
| 495 | using _OrImpl _LIBCPP_NODEBUG = _Result; | |
| 496 | }; | |
| 497 | template <bool _Cond, class _IfRes, class _ElseRes> | |
| 498 | using _If _LIBCPP_NODEBUG = typename _MetaBase<_Cond>::template _SelectImpl<_IfRes, _ElseRes>; | |
| 499 | template <class ..._Rest> | |
| 500 | using _Or _LIBCPP_NODEBUG = typename _MetaBase< sizeof...(_Rest) != 0 >::template _OrImpl<false_type, _Rest...>; | |
| 501 | template <class _Pred> | |
| 502 | struct _Not : _BoolConstant<!_Pred::value> {}; | |
| 503 | template <class ..._Args> | |
| 504 | using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; | |
| 505 | template <class ..._Args> | |
| 506 | using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; | |
| 507 | ||
| 508 | template <class ...> using __expand_to_true = true_type; | |
| 509 | template <class ..._Pred> | |
| 510 | __expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); | |
| 511 | template <class ...> | |
| 512 | false_type __and_helper(...); | |
| 513 | template <class ..._Pred> | |
| 514 | using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0)); | |
| 515 | ||
| 516 | template <template <class...> class _Func, class ..._Args> | |
| 517 | struct _Lazy : _Func<_Args...> {}; | |
| 518 | ||
| 519 | // Member detector base | |
| 520 | ||
| 521 | template <template <class...> class _Templ, class ..._Args, class = _Templ<_Args...> > | |
| 522 | true_type __sfinae_test_impl(int); | |
| 523 | template <template <class...> class, class ...> | |
| 524 | false_type __sfinae_test_impl(...); | |
| 525 | ||
| 526 | template <template <class ...> class _Templ, class ..._Args> | |
| 527 | using _IsValidExpansion _LIBCPP_NODEBUG = decltype(__sfinae_test_impl<_Templ, _Args...>(0)); | |
| 528 | ||
| 529 | template <class> | |
| 530 | struct __void_t { typedef void type; }; | |
| 531 | ||
| 532 | template <class _Tp> | |
| 533 | struct __identity { typedef _Tp type; }; | |
| 534 | ||
| 535 | template <class _Tp> | |
| 536 | using __identity_t _LIBCPP_NODEBUG = typename __identity<_Tp>::type; | |
| 537 | ||
| 538 | template <class _Tp, bool> | |
| 539 | struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; | |
| 540 | ||
| 541 | ||
| 542 | template <bool _Bp, class _If, class _Then> | |
| 543 | struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; | |
| 544 | template <class _If, class _Then> | |
| 545 | struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {typedef _Then type;}; | |
| 546 | ||
| 547 | #if _LIBCPP_STD_VER > 11 | |
| 548 | template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; | |
| 549 | #endif | |
| 550 | ||
| 551 | // is_same | |
| 552 | ||
| 553 | template <class _Tp, class _Up> | |
| 554 | struct _LIBCPP_TEMPLATE_VIS is_same : _BoolConstant<__is_same(_Tp, _Up)> { }; | |
| 555 | ||
| 556 | #if _LIBCPP_STD_VER > 14 | |
| 557 | template <class _Tp, class _Up> | |
| 558 | inline constexpr bool is_same_v = __is_same(_Tp, _Up); | |
| 559 | #endif | |
| 560 | ||
| 561 | // _IsSame<T,U> has the same effect as is_same<T,U> but instantiates fewer types: | |
| 562 | // is_same<A,B> and is_same<C,D> are guaranteed to be different types, but | |
| 563 | // _IsSame<A,B> and _IsSame<C,D> are the same type (namely, false_type). | |
| 564 | // Neither GCC nor Clang can mangle the __is_same builtin, so _IsSame | |
| 565 | // mustn't be directly used anywhere that contributes to name-mangling | |
| 566 | // (such as in a dependent return type). | |
| 567 | ||
| 568 | template <class _Tp, class _Up> | |
| 569 | using _IsSame = _BoolConstant<__is_same(_Tp, _Up)>; | |
| 570 | ||
| 571 | template <class _Tp, class _Up> | |
| 572 | using _IsNotSame = _BoolConstant<!__is_same(_Tp, _Up)>; | |
| 573 | ||
| 574 | template <class _Tp> | |
| 575 | using __test_for_primary_template = __enable_if_t< | |
| 576 | _IsSame<_Tp, typename _Tp::__primary_template>::value | |
| 577 | >; | |
| 578 | template <class _Tp> | |
| 579 | using __is_primary_template = _IsValidExpansion< | |
| 580 | __test_for_primary_template, _Tp | |
| 581 | >; | |
| 582 | ||
| 583 | // helper class | |
| 584 | ||
| 585 | struct __two {char __lx[2];}; | |
| 586 | ||
| 587 | // is_const | |
| 588 | ||
| 589 | #if __has_keyword(__is_const) | |
| 590 | ||
| 591 | template <class _Tp> | |
| 592 | struct _LIBCPP_TEMPLATE_VIS is_const : _BoolConstant<__is_const(_Tp)> { }; | |
| 593 | ||
| 594 | #if _LIBCPP_STD_VER > 14 | |
| 595 | template <class _Tp> | |
| 596 | inline constexpr bool is_const_v = __is_const(_Tp); | |
| 597 | #endif | |
| 598 | ||
| 599 | #else | |
| 600 | ||
| 601 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {}; | |
| 602 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {}; | |
| 603 | ||
| 604 | #if _LIBCPP_STD_VER > 14 | |
| 605 | template <class _Tp> | |
| 606 | inline constexpr bool is_const_v = is_const<_Tp>::value; | |
| 607 | #endif | |
| 608 | ||
| 609 | #endif // __has_keyword(__is_const) | |
| 610 | ||
| 611 | // is_volatile | |
| 612 | ||
| 613 | #if __has_keyword(__is_volatile) | |
| 614 | ||
| 615 | template <class _Tp> | |
| 616 | struct _LIBCPP_TEMPLATE_VIS is_volatile : _BoolConstant<__is_volatile(_Tp)> { }; | |
| 617 | ||
| 618 | #if _LIBCPP_STD_VER > 14 | |
| 619 | template <class _Tp> | |
| 620 | inline constexpr bool is_volatile_v = __is_volatile(_Tp); | |
| 621 | #endif | |
| 622 | ||
| 623 | #else | |
| 624 | ||
| 625 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {}; | |
| 626 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {}; | |
| 627 | ||
| 628 | #if _LIBCPP_STD_VER > 14 | |
| 629 | template <class _Tp> | |
| 630 | inline constexpr bool is_volatile_v = is_volatile<_Tp>::value; | |
| 631 | #endif | |
| 632 | ||
| 633 | #endif // __has_keyword(__is_volatile) | |
| 634 | ||
| 635 | // remove_const | |
| 636 | ||
| 637 | #if __has_keyword(__remove_const) | |
| 638 | ||
| 639 | template <class _Tp> | |
| 640 | struct _LIBCPP_TEMPLATE_VIS remove_const {typedef __remove_const(_Tp) type;}; | |
| 641 | ||
| 642 | #if _LIBCPP_STD_VER > 11 | |
| 643 | template <class _Tp> using remove_const_t = __remove_const(_Tp); | |
| 644 | #endif | |
| 645 | ||
| 646 | #else | |
| 647 | ||
| 648 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const {typedef _Tp type;}; | |
| 649 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {typedef _Tp type;}; | |
| 650 | #if _LIBCPP_STD_VER > 11 | |
| 651 | template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; | |
| 652 | #endif | |
| 653 | ||
| 654 | #endif // __has_keyword(__remove_const) | |
| 655 | ||
| 656 | // remove_volatile | |
| 657 | ||
| 658 | #if __has_keyword(__remove_volatile) | |
| 659 | ||
| 660 | template <class _Tp> | |
| 661 | struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef __remove_volatile(_Tp) type;}; | |
| 662 | ||
| 663 | #if _LIBCPP_STD_VER > 11 | |
| 664 | template <class _Tp> using remove_volatile_t = __remove_volatile(_Tp); | |
| 665 | #endif | |
| 666 | ||
| 667 | #else | |
| 668 | ||
| 669 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile {typedef _Tp type;}; | |
| 670 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; | |
| 671 | #if _LIBCPP_STD_VER > 11 | |
| 672 | template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; | |
| 673 | #endif | |
| 674 | ||
| 675 | #endif // __has_keyword(__remove_volatile) | |
| 676 | ||
| 677 | // remove_cv | |
| 678 | ||
| 679 | #if __has_keyword(__remove_cv) | |
| 680 | ||
| 681 | template <class _Tp> | |
| 682 | struct _LIBCPP_TEMPLATE_VIS remove_cv {typedef __remove_cv(_Tp) type;}; | |
| 683 | ||
| 684 | #if _LIBCPP_STD_VER > 11 | |
| 685 | template <class _Tp> using remove_cv_t = __remove_cv(_Tp); | |
| 686 | #endif | |
| 687 | ||
| 688 | #else | |
| 689 | ||
| 690 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv | |
| 691 | {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; | |
| 692 | #if _LIBCPP_STD_VER > 11 | |
| 693 | template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; | |
| 694 | #endif | |
| 695 | ||
| 696 | #endif // __has_keyword(__remove_cv) | |
| 697 | ||
| 698 | // is_void | |
| 699 | ||
| 700 | #if __has_keyword(__is_void) | |
| 701 | ||
| 702 | template <class _Tp> | |
| 703 | struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> { }; | |
| 704 | ||
| 705 | #if _LIBCPP_STD_VER > 14 | |
| 706 | template <class _Tp> | |
| 707 | inline constexpr bool is_void_v = __is_void(_Tp); | |
| 708 | #endif | |
| 709 | ||
| 710 | #else | |
| 711 | ||
| 712 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_void | |
| 713 | : public is_same<typename remove_cv<_Tp>::type, void> {}; | |
| 714 | ||
| 715 | #if _LIBCPP_STD_VER > 14 | |
| 716 | template <class _Tp> | |
| 717 | inline constexpr bool is_void_v = is_void<_Tp>::value; | |
| 718 | #endif | |
| 719 | ||
| 720 | #endif // __has_keyword(__is_void) | |
| 721 | ||
| 722 | // __is_nullptr_t | |
| 723 | ||
| 724 | template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; | |
| 725 | template <> struct __is_nullptr_t_impl<nullptr_t> : public true_type {}; | |
| 726 | ||
| 727 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t | |
| 728 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; | |
| 729 | ||
| 730 | #if _LIBCPP_STD_VER > 11 | |
| 731 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_null_pointer | |
| 732 | : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; | |
| 733 | ||
| 734 | #if _LIBCPP_STD_VER > 14 | |
| 735 | template <class _Tp> | |
| 736 | inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value; | |
| 737 | #endif | |
| 738 | #endif // _LIBCPP_STD_VER > 11 | |
| 739 | ||
| 740 | // is_integral | |
| 741 | ||
| 742 | #if __has_keyword(__is_integral) | |
| 743 | ||
| 744 | template <class _Tp> | |
| 745 | struct _LIBCPP_TEMPLATE_VIS is_integral : _BoolConstant<__is_integral(_Tp)> { }; | |
| 746 | ||
| 747 | #if _LIBCPP_STD_VER > 14 | |
| 748 | template <class _Tp> | |
| 749 | inline constexpr bool is_integral_v = __is_integral(_Tp); | |
| 750 | #endif | |
| 751 | ||
| 752 | #else | |
| 753 | ||
| 754 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_integral | |
| 755 | : public _BoolConstant<__libcpp_is_integral<typename remove_cv<_Tp>::type>::value> {}; | |
| 756 | ||
| 757 | #if _LIBCPP_STD_VER > 14 | |
| 758 | template <class _Tp> | |
| 759 | inline constexpr bool is_integral_v = is_integral<_Tp>::value; | |
| 760 | #endif | |
| 761 | ||
| 762 | #endif // __has_keyword(__is_integral) | |
| 763 | ||
| 764 | // [basic.fundamental] defines five standard signed integer types; | |
| 765 | // __int128_t is an extended signed integer type. | |
| 766 | // The signed and unsigned integer types, plus bool and the | |
| 767 | // five types with "char" in their name, compose the "integral" types. | |
| 768 | ||
| 769 | template <class _Tp> struct __libcpp_is_signed_integer : public false_type {}; | |
| 770 | template <> struct __libcpp_is_signed_integer<signed char> : public true_type {}; | |
| 771 | template <> struct __libcpp_is_signed_integer<signed short> : public true_type {}; | |
| 772 | template <> struct __libcpp_is_signed_integer<signed int> : public true_type {}; | |
| 773 | template <> struct __libcpp_is_signed_integer<signed long> : public true_type {}; | |
| 774 | template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {}; | |
| 775 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 776 | template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; | |
| 777 | #endif | |
| 778 | ||
| 779 | template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {}; | |
| 780 | template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {}; | |
| 781 | template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {}; | |
| 782 | template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {}; | |
| 783 | template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {}; | |
| 784 | template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {}; | |
| 785 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 786 | template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; | |
| 787 | #endif | |
| 788 | ||
| 789 | // is_floating_point | |
| 790 | // <concepts> implements __libcpp_floating_point | |
| 791 | ||
| 792 | template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; | |
| 793 | template <> struct __libcpp_is_floating_point<float> : public true_type {}; | |
| 794 | template <> struct __libcpp_is_floating_point<double> : public true_type {}; | |
| 795 | template <> struct __libcpp_is_floating_point<long double> : public true_type {}; | |
| 796 | ||
| 797 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_floating_point | |
| 798 | : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; | |
| 799 | ||
| 800 | #if _LIBCPP_STD_VER > 14 | |
| 801 | template <class _Tp> | |
| 802 | inline constexpr bool is_floating_point_v = is_floating_point<_Tp>::value; | |
| 803 | #endif | |
| 804 | ||
| 805 | // is_array | |
| 806 | ||
| 807 | #if __has_keyword(__is_array) | |
| 808 | ||
| 809 | template <class _Tp> | |
| 810 | struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> { }; | |
| 811 | ||
| 812 | #if _LIBCPP_STD_VER > 14 | |
| 813 | template <class _Tp> | |
| 814 | inline constexpr bool is_array_v = __is_array(_Tp); | |
| 815 | #endif | |
| 816 | ||
| 817 | #else | |
| 818 | ||
| 819 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array | |
| 820 | : public false_type {}; | |
| 821 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> | |
| 822 | : public true_type {}; | |
| 823 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> | |
| 824 | : public true_type {}; | |
| 825 | ||
| 826 | #if _LIBCPP_STD_VER > 14 | |
| 827 | template <class _Tp> | |
| 828 | inline constexpr bool is_array_v = is_array<_Tp>::value; | |
| 829 | #endif | |
| 830 | ||
| 831 | #endif // __has_keyword(__is_array) | |
| 832 | ||
| 833 | // is_pointer | |
| 834 | ||
| 835 | // Before AppleClang 12.0.5, __is_pointer didn't work for Objective-C types. | |
| 836 | #if __has_keyword(__is_pointer) && \ | |
| 837 | !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1205) | |
| 838 | ||
| 839 | template<class _Tp> | |
| 840 | struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { }; | |
| 841 | ||
| 842 | #if _LIBCPP_STD_VER > 14 | |
| 843 | template <class _Tp> | |
| 844 | inline constexpr bool is_pointer_v = __is_pointer(_Tp); | |
| 845 | #endif | |
| 846 | ||
| 847 | #else // __has_keyword(__is_pointer) | |
| 848 | ||
| 849 | template <class _Tp> struct __libcpp_is_pointer : public false_type {}; | |
| 850 | template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; | |
| 851 | ||
| 852 | template <class _Tp> struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; | |
| 853 | #if defined(_LIBCPP_HAS_OBJC_ARC) | |
| 854 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; | |
| 855 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; | |
| 856 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; }; | |
| 857 | template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; }; | |
| 858 | #endif | |
| 859 | ||
| 860 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer | |
| 861 | : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {}; | |
| 862 | ||
| 863 | #if _LIBCPP_STD_VER > 14 | |
| 864 | template <class _Tp> | |
| 865 | inline constexpr bool is_pointer_v = is_pointer<_Tp>::value; | |
| 866 | #endif | |
| 867 | ||
| 868 | #endif // __has_keyword(__is_pointer) | |
| 869 | ||
| 870 | // is_reference | |
| 871 | ||
| 872 | #if __has_keyword(__is_lvalue_reference) && \ | |
| 873 | __has_keyword(__is_rvalue_reference) && \ | |
| 874 | __has_keyword(__is_reference) | |
| 875 | ||
| 876 | template<class _Tp> | |
| 877 | struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> { }; | |
| 878 | ||
| 879 | template<class _Tp> | |
| 880 | struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> { }; | |
| 881 | ||
| 882 | template<class _Tp> | |
| 883 | struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> { }; | |
| 884 | ||
| 885 | #if _LIBCPP_STD_VER > 14 | |
| 886 | template <class _Tp> | |
| 887 | inline constexpr bool is_reference_v = __is_reference(_Tp); | |
| 888 | template <class _Tp> | |
| 889 | inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp); | |
| 890 | template <class _Tp> | |
| 891 | inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp); | |
| 892 | #endif | |
| 893 | ||
| 894 | #else // __has_keyword(__is_lvalue_reference) && etc... | |
| 895 | ||
| 896 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {}; | |
| 897 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {}; | |
| 898 | ||
| 899 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {}; | |
| 900 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; | |
| 901 | ||
| 902 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {}; | |
| 903 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {}; | |
| 904 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {}; | |
| 905 | ||
| 906 | #if _LIBCPP_STD_VER > 14 | |
| 907 | template <class _Tp> | |
| 908 | inline constexpr bool is_reference_v = is_reference<_Tp>::value; | |
| 909 | ||
| 910 | template <class _Tp> | |
| 911 | inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value; | |
| 912 | ||
| 913 | template <class _Tp> | |
| 914 | inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value; | |
| 915 | #endif | |
| 916 | ||
| 917 | #endif // __has_keyword(__is_lvalue_reference) && etc... | |
| 918 | ||
| 919 | // is_union | |
| 920 | ||
| 921 | #if __has_feature(is_union) || defined(_LIBCPP_COMPILER_GCC) | |
| 922 | ||
| 923 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union | |
| 924 | : public integral_constant<bool, __is_union(_Tp)> {}; | |
| 925 | ||
| 926 | #else | |
| 927 | ||
| 928 | template <class _Tp> struct __libcpp_union : public false_type {}; | |
| 929 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_union | |
| 930 | : public __libcpp_union<typename remove_cv<_Tp>::type> {}; | |
| 931 | ||
| 932 | #endif | |
| 933 | ||
| 934 | #if _LIBCPP_STD_VER > 14 | |
| 935 | template <class _Tp> | |
| 936 | inline constexpr bool is_union_v = is_union<_Tp>::value; | |
| 937 | #endif | |
| 938 | ||
| 939 | // is_class | |
| 940 | ||
| 941 | #if __has_feature(is_class) || defined(_LIBCPP_COMPILER_GCC) | |
| 942 | ||
| 943 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class | |
| 944 | : public integral_constant<bool, __is_class(_Tp)> {}; | |
| 945 | ||
| 946 | #else | |
| 947 | ||
| 948 | namespace __is_class_imp | |
| 949 | { | |
| 950 | template <class _Tp> char __test(int _Tp::*); | |
| 951 | template <class _Tp> __two __test(...); | |
| 952 | } | |
| 953 | ||
| 954 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_class | |
| 955 | : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; | |
| 956 | ||
| 957 | #endif | |
| 958 | ||
| 959 | #if _LIBCPP_STD_VER > 14 | |
| 960 | template <class _Tp> | |
| 961 | inline constexpr bool is_class_v = is_class<_Tp>::value; | |
| 962 | #endif | |
| 963 | ||
| 964 | // is_function | |
| 965 | ||
| 966 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_function | |
| 967 | : public _BoolConstant< | |
| 968 | #ifdef __clang__ | |
| 969 | __is_function(_Tp) | |
| 970 | #else | |
| 971 | !(is_reference<_Tp>::value || is_const<const _Tp>::value) | |
| 972 | #endif | |
| 973 | > {}; | |
| 974 | ||
| 975 | ||
| 976 | #if _LIBCPP_STD_VER > 14 | |
| 977 | template <class _Tp> | |
| 978 | inline constexpr bool is_function_v = is_function<_Tp>::value; | |
| 979 | #endif | |
| 980 | ||
| 981 | template <class _Tp> struct __libcpp_is_member_pointer { | |
| 982 | enum { | |
| 983 | __is_member = false, | |
| 984 | __is_func = false, | |
| 985 | __is_obj = false | |
| 986 | }; | |
| 987 | }; | |
| 988 | template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> { | |
| 989 | enum { | |
| 990 | __is_member = true, | |
| 991 | __is_func = is_function<_Tp>::value, | |
| 992 | __is_obj = !__is_func, | |
| 993 | }; | |
| 994 | }; | |
| 995 | ||
| 996 | #if __has_keyword(__is_member_function_pointer) | |
| 997 | ||
| 998 | template<class _Tp> | |
| 999 | struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | |
| 1000 | : _BoolConstant<__is_member_function_pointer(_Tp)> { }; | |
| 1001 | ||
| 1002 | #if _LIBCPP_STD_VER > 14 | |
| 1003 | template <class _Tp> | |
| 1004 | inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp); | |
| 1005 | #endif | |
| 1006 | ||
| 1007 | #else // __has_keyword(__is_member_function_pointer) | |
| 1008 | ||
| 1009 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer | |
| 1010 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_func > {}; | |
| 1011 | ||
| 1012 | #if _LIBCPP_STD_VER > 14 | |
| 1013 | template <class _Tp> | |
| 1014 | inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value; | |
| 1015 | #endif | |
| 1016 | ||
| 1017 | #endif // __has_keyword(__is_member_function_pointer) | |
| 1018 | ||
| 1019 | // is_member_pointer | |
| 1020 | ||
| 1021 | #if __has_keyword(__is_member_pointer) | |
| 1022 | ||
| 1023 | template<class _Tp> | |
| 1024 | struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> { }; | |
| 1025 | ||
| 1026 | #if _LIBCPP_STD_VER > 14 | |
| 1027 | template <class _Tp> | |
| 1028 | inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp); | |
| 1029 | #endif | |
| 1030 | ||
| 1031 | #else // __has_keyword(__is_member_pointer) | |
| 1032 | ||
| 1033 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_pointer | |
| 1034 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_member > {}; | |
| 1035 | ||
| 1036 | #if _LIBCPP_STD_VER > 14 | |
| 1037 | template <class _Tp> | |
| 1038 | inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value; | |
| 1039 | #endif | |
| 1040 | ||
| 1041 | #endif // __has_keyword(__is_member_pointer) | |
| 1042 | ||
| 1043 | // is_member_object_pointer | |
| 1044 | ||
| 1045 | #if __has_keyword(__is_member_object_pointer) | |
| 1046 | ||
| 1047 | template<class _Tp> | |
| 1048 | struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | |
| 1049 | : _BoolConstant<__is_member_object_pointer(_Tp)> { }; | |
| 1050 | ||
| 1051 | #if _LIBCPP_STD_VER > 14 | |
| 1052 | template <class _Tp> | |
| 1053 | inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp); | |
| 1054 | #endif | |
| 1055 | ||
| 1056 | #else // __has_keyword(__is_member_object_pointer) | |
| 1057 | ||
| 1058 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer | |
| 1059 | : public _BoolConstant< __libcpp_is_member_pointer<typename remove_cv<_Tp>::type>::__is_obj > {}; | |
| 1060 | ||
| 1061 | #if _LIBCPP_STD_VER > 14 | |
| 1062 | template <class _Tp> | |
| 1063 | inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value; | |
| 1064 | #endif | |
| 1065 | ||
| 1066 | #endif // __has_keyword(__is_member_object_pointer) | |
| 1067 | ||
| 1068 | // is_enum | |
| 1069 | ||
| 1070 | #if __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) | |
| 1071 | ||
| 1072 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum | |
| 1073 | : public integral_constant<bool, __is_enum(_Tp)> {}; | |
| 1074 | ||
| 1075 | #if _LIBCPP_STD_VER > 14 | |
| 1076 | template <class _Tp> | |
| 1077 | inline constexpr bool is_enum_v = __is_enum(_Tp); | |
| 1078 | #endif | |
| 1079 | ||
| 1080 | #else | |
| 1081 | ||
| 1082 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_enum | |
| 1083 | : public integral_constant<bool, !is_void<_Tp>::value && | |
| 1084 | !is_integral<_Tp>::value && | |
| 1085 | !is_floating_point<_Tp>::value && | |
| 1086 | !is_array<_Tp>::value && | |
| 1087 | !is_pointer<_Tp>::value && | |
| 1088 | !is_reference<_Tp>::value && | |
| 1089 | !is_member_pointer<_Tp>::value && | |
| 1090 | !is_union<_Tp>::value && | |
| 1091 | !is_class<_Tp>::value && | |
| 1092 | !is_function<_Tp>::value > {}; | |
| 1093 | ||
| 1094 | #if _LIBCPP_STD_VER > 14 | |
| 1095 | template <class _Tp> | |
| 1096 | inline constexpr bool is_enum_v = is_enum<_Tp>::value; | |
| 1097 | #endif | |
| 1098 | ||
| 1099 | #endif // __has_feature(is_enum) || defined(_LIBCPP_COMPILER_GCC) | |
| 1100 | ||
| 1101 | // is_arithmetic | |
| 1102 | ||
| 1103 | ||
| 1104 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic | |
| 1105 | : public integral_constant<bool, is_integral<_Tp>::value || | |
| 1106 | is_floating_point<_Tp>::value> {}; | |
| 1107 | ||
| 1108 | #if _LIBCPP_STD_VER > 14 | |
| 1109 | template <class _Tp> | |
| 1110 | inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; | |
| 1111 | #endif | |
| 1112 | ||
| 1113 | // is_fundamental | |
| 1114 | ||
| 1115 | // Before Clang 10, __is_fundamental didn't work for nullptr_t. | |
| 1116 | // In C++03 nullptr_t is library-provided but must still count as "fundamental." | |
| 1117 | #if __has_keyword(__is_fundamental) && \ | |
| 1118 | !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1000) && \ | |
| 1119 | !defined(_LIBCPP_CXX03_LANG) | |
| 1120 | ||
| 1121 | template<class _Tp> | |
| 1122 | struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { }; | |
| 1123 | ||
| 1124 | #if _LIBCPP_STD_VER > 14 | |
| 1125 | template <class _Tp> | |
| 1126 | inline constexpr bool is_fundamental_v = __is_fundamental(_Tp); | |
| 1127 | #endif | |
| 1128 | ||
| 1129 | #else // __has_keyword(__is_fundamental) | |
| 1130 | ||
| 1131 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_fundamental | |
| 1132 | : public integral_constant<bool, is_void<_Tp>::value || | |
| 1133 | __is_nullptr_t<_Tp>::value || | |
| 1134 | is_arithmetic<_Tp>::value> {}; | |
| 1135 | ||
| 1136 | #if _LIBCPP_STD_VER > 14 | |
| 1137 | template <class _Tp> | |
| 1138 | inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; | |
| 1139 | #endif | |
| 1140 | ||
| 1141 | #endif // __has_keyword(__is_fundamental) | |
| 1142 | ||
| 1143 | // is_scalar | |
| 1144 | ||
| 1145 | // In C++03 nullptr_t is library-provided but must still count as "scalar." | |
| 1146 | #if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG) | |
| 1147 | ||
| 1148 | template<class _Tp> | |
| 1149 | struct _LIBCPP_TEMPLATE_VIS is_scalar : _BoolConstant<__is_scalar(_Tp)> { }; | |
| 1150 | ||
| 1151 | #if _LIBCPP_STD_VER > 14 | |
| 1152 | template <class _Tp> | |
| 1153 | inline constexpr bool is_scalar_v = __is_scalar(_Tp); | |
| 1154 | #endif | |
| 1155 | ||
| 1156 | #else // __has_keyword(__is_scalar) | |
| 1157 | ||
| 1158 | template <class _Tp> struct __is_block : false_type {}; | |
| 1159 | #if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) | |
| 1160 | template <class _Rp, class ..._Args> struct __is_block<_Rp (^)(_Args...)> : true_type {}; | |
| 1161 | #endif | |
| 1162 | ||
| 1163 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_scalar | |
| 1164 | : public integral_constant<bool, is_arithmetic<_Tp>::value || | |
| 1165 | is_member_pointer<_Tp>::value || | |
| 1166 | is_pointer<_Tp>::value || | |
| 1167 | __is_nullptr_t<_Tp>::value || | |
| 1168 | __is_block<_Tp>::value || | |
| 1169 | is_enum<_Tp>::value > {}; | |
| 1170 | ||
| 1171 | template <> struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {}; | |
| 1172 | ||
| 1173 | #if _LIBCPP_STD_VER > 14 | |
| 1174 | template <class _Tp> | |
| 1175 | inline constexpr bool is_scalar_v = is_scalar<_Tp>::value; | |
| 1176 | #endif | |
| 1177 | ||
| 1178 | #endif // __has_keyword(__is_scalar) | |
| 1179 | ||
| 1180 | // is_object | |
| 1181 | ||
| 1182 | #if __has_keyword(__is_object) | |
| 1183 | ||
| 1184 | template<class _Tp> | |
| 1185 | struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> { }; | |
| 1186 | ||
| 1187 | #if _LIBCPP_STD_VER > 14 | |
| 1188 | template <class _Tp> | |
| 1189 | inline constexpr bool is_object_v = __is_object(_Tp); | |
| 1190 | #endif | |
| 1191 | ||
| 1192 | #else // __has_keyword(__is_object) | |
| 1193 | ||
| 1194 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_object | |
| 1195 | : public integral_constant<bool, is_scalar<_Tp>::value || | |
| 1196 | is_array<_Tp>::value || | |
| 1197 | is_union<_Tp>::value || | |
| 1198 | is_class<_Tp>::value > {}; | |
| 1199 | ||
| 1200 | #if _LIBCPP_STD_VER > 14 | |
| 1201 | template <class _Tp> | |
| 1202 | inline constexpr bool is_object_v = is_object<_Tp>::value; | |
| 1203 | #endif | |
| 1204 | ||
| 1205 | #endif // __has_keyword(__is_object) | |
| 1206 | ||
| 1207 | // is_compound | |
| 1208 | ||
| 1209 | // >= 11 because in C++03 nullptr isn't actually nullptr | |
| 1210 | #if __has_keyword(__is_compound) && !defined(_LIBCPP_CXX03_LANG) | |
| 1211 | ||
| 1212 | template<class _Tp> | |
| 1213 | struct _LIBCPP_TEMPLATE_VIS is_compound : _BoolConstant<__is_compound(_Tp)> { }; | |
| 1214 | ||
| 1215 | #if _LIBCPP_STD_VER > 14 | |
| 1216 | template <class _Tp> | |
| 1217 | inline constexpr bool is_compound_v = __is_compound(_Tp); | |
| 1218 | #endif | |
| 1219 | ||
| 1220 | #else // __has_keyword(__is_compound) | |
| 1221 | ||
| 1222 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_compound | |
| 1223 | : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; | |
| 1224 | ||
| 1225 | #if _LIBCPP_STD_VER > 14 | |
| 1226 | template <class _Tp> | |
| 1227 | inline constexpr bool is_compound_v = is_compound<_Tp>::value; | |
| 1228 | #endif | |
| 1229 | ||
| 1230 | #endif // __has_keyword(__is_compound) | |
| 1231 | ||
| 1232 | // __is_referenceable [defns.referenceable] | |
| 1233 | ||
| 1234 | struct __is_referenceable_impl { | |
| 1235 | template <class _Tp> static _Tp& __test(int); | |
| 1236 | template <class _Tp> static __two __test(...); | |
| 1237 | }; | |
| 1238 | ||
| 1239 | template <class _Tp> | |
| 1240 | struct __is_referenceable : integral_constant<bool, | |
| 1241 | _IsNotSame<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {}; | |
| 1242 | ||
| 1243 | ||
| 1244 | // add_const | |
| 1245 | ||
| 1246 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const { | |
| 1247 | typedef _LIBCPP_NODEBUG const _Tp type; | |
| 1248 | }; | |
| 1249 | ||
| 1250 | #if _LIBCPP_STD_VER > 11 | |
| 1251 | template <class _Tp> using add_const_t = typename add_const<_Tp>::type; | |
| 1252 | #endif | |
| 1253 | ||
| 1254 | // add_volatile | |
| 1255 | ||
| 1256 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile { | |
| 1257 | typedef _LIBCPP_NODEBUG volatile _Tp type; | |
| 1258 | }; | |
| 1259 | ||
| 1260 | #if _LIBCPP_STD_VER > 11 | |
| 1261 | template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; | |
| 1262 | #endif | |
| 1263 | ||
| 1264 | // add_cv | |
| 1265 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv { | |
| 1266 | typedef _LIBCPP_NODEBUG const volatile _Tp type; | |
| 1267 | }; | |
| 1268 | ||
| 1269 | #if _LIBCPP_STD_VER > 11 | |
| 1270 | template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; | |
| 1271 | #endif | |
| 1272 | ||
| 1273 | // remove_reference | |
| 1274 | ||
| 1275 | #if __has_keyword(__remove_reference) | |
| 1276 | ||
| 1277 | template<class _Tp> | |
| 1278 | struct _LIBCPP_TEMPLATE_VIS remove_reference { typedef __remove_reference(_Tp) type; }; | |
| 1279 | ||
| 1280 | #else // __has_keyword(__remove_reference) | |
| 1281 | ||
| 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;}; | |
| 1285 | ||
| 1286 | #if _LIBCPP_STD_VER > 11 | |
| 1287 | template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>::type; | |
| 1288 | #endif | |
| 1289 | ||
| 1290 | #endif // __has_keyword(__remove_reference) | |
| 1291 | ||
| 1292 | // add_lvalue_reference | |
| 1293 | ||
| 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; }; | |
| 1296 | ||
| 1297 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference | |
| 1298 | {typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;}; | |
| 1299 | ||
| 1300 | #if _LIBCPP_STD_VER > 11 | |
| 1301 | template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; | |
| 1302 | #endif | |
| 1303 | ||
| 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; }; | |
| 1306 | ||
| 1307 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference | |
| 1308 | {typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;}; | |
| 1309 | ||
| 1310 | #if _LIBCPP_STD_VER > 11 | |
| 1311 | template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; | |
| 1312 | #endif | |
| 1313 | ||
| 1314 | // Suppress deprecation notice for volatile-qualified return type resulting | |
| 1315 | // from volatile-qualified types _Tp. | |
| 1316 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 1317 | template <class _Tp> _Tp&& __declval(int); | |
| 1318 | template <class _Tp> _Tp __declval(long); | |
| 1319 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 1320 | ||
| 1321 | template <class _Tp> | |
| 1322 | decltype(__declval<_Tp>(0)) | |
| 1323 | declval() _NOEXCEPT; | |
| 1324 | ||
| 1325 | // __uncvref | |
| 1326 | ||
| 1327 | template <class _Tp> | |
| 1328 | struct __uncvref { | |
| 1329 | typedef _LIBCPP_NODEBUG typename remove_cv<typename remove_reference<_Tp>::type>::type type; | |
| 1330 | }; | |
| 1331 | ||
| 1332 | template <class _Tp> | |
| 1333 | struct __unconstref { | |
| 1334 | typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type; | |
| 1335 | }; | |
| 1336 | ||
| 1337 | #ifndef _LIBCPP_CXX03_LANG | |
| 1338 | template <class _Tp> | |
| 1339 | using __uncvref_t _LIBCPP_NODEBUG = typename __uncvref<_Tp>::type; | |
| 1340 | #endif | |
| 1341 | ||
| 1342 | // __is_same_uncvref | |
| 1343 | ||
| 1344 | template <class _Tp, class _Up> | |
| 1345 | struct __is_same_uncvref : _IsSame<typename __uncvref<_Tp>::type, | |
| 1346 | typename __uncvref<_Up>::type> {}; | |
| 1347 | ||
| 1348 | #if _LIBCPP_STD_VER > 17 | |
| 1349 | // remove_cvref - same as __uncvref | |
| 1350 | template <class _Tp> | |
| 1351 | struct remove_cvref : public __uncvref<_Tp> {}; | |
| 1352 | ||
| 1353 | template <class _Tp> using remove_cvref_t = typename remove_cvref<_Tp>::type; | |
| 1354 | #endif | |
| 1355 | ||
| 1356 | ||
| 1357 | struct __any | |
| 1358 | { | |
| 1359 | __any(...); | |
| 1360 | }; | |
| 1361 | ||
| 1362 | // remove_pointer | |
| 1363 | ||
| 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;}; | |
| 1369 | ||
| 1370 | #if _LIBCPP_STD_VER > 11 | |
| 1371 | template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; | |
| 1372 | #endif | |
| 1373 | ||
| 1374 | // add_pointer | |
| 1375 | ||
| 1376 | template <class _Tp, | |
| 1377 | bool = __is_referenceable<_Tp>::value || | |
| 1378 | _IsSame<typename remove_cv<_Tp>::type, void>::value> | |
| 1379 | struct __add_pointer_impl | |
| 1380 | {typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type* type;}; | |
| 1381 | template <class _Tp> struct __add_pointer_impl<_Tp, false> | |
| 1382 | {typedef _LIBCPP_NODEBUG _Tp type;}; | |
| 1383 | ||
| 1384 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_pointer | |
| 1385 | {typedef _LIBCPP_NODEBUG typename __add_pointer_impl<_Tp>::type type;}; | |
| 1386 | ||
| 1387 | #if _LIBCPP_STD_VER > 11 | |
| 1388 | template <class _Tp> using add_pointer_t = typename add_pointer<_Tp>::type; | |
| 1389 | #endif | |
| 1390 | ||
| 1391 | // type_identity | |
| 1392 | #if _LIBCPP_STD_VER > 17 | |
| 1393 | template<class _Tp> struct type_identity { typedef _Tp type; }; | |
| 1394 | template<class _Tp> using type_identity_t = typename type_identity<_Tp>::type; | |
| 1395 | #endif | |
| 1396 | ||
| 1397 | // is_signed | |
| 1398 | ||
| 1399 | #if __has_keyword(__is_signed) | |
| 1400 | ||
| 1401 | template<class _Tp> | |
| 1402 | struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { }; | |
| 1403 | ||
| 1404 | #if _LIBCPP_STD_VER > 14 | |
| 1405 | template <class _Tp> | |
| 1406 | inline constexpr bool is_signed_v = __is_signed(_Tp); | |
| 1407 | #endif | |
| 1408 | ||
| 1409 | #else // __has_keyword(__is_signed) | |
| 1410 | ||
| 1411 | template <class _Tp, bool = is_integral<_Tp>::value> | |
| 1412 | struct __libcpp_is_signed_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(-1) < _Tp(0)) {}; | |
| 1413 | ||
| 1414 | template <class _Tp> | |
| 1415 | struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point | |
| 1416 | ||
| 1417 | template <class _Tp, bool = is_arithmetic<_Tp>::value> | |
| 1418 | struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {}; | |
| 1419 | ||
| 1420 | template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type {}; | |
| 1421 | ||
| 1422 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {}; | |
| 1423 | ||
| 1424 | #if _LIBCPP_STD_VER > 14 | |
| 1425 | template <class _Tp> | |
| 1426 | inline constexpr bool is_signed_v = is_signed<_Tp>::value; | |
| 1427 | #endif | |
| 1428 | ||
| 1429 | #endif // __has_keyword(__is_signed) | |
| 1430 | ||
| 1431 | // is_unsigned | |
| 1432 | ||
| 1433 | // Before Clang 13, __is_unsigned returned true for enums with signed underlying type. | |
| 1434 | // No currently-released version of AppleClang contains the fixed intrinsic. | |
| 1435 | #if __has_keyword(__is_unsigned) && \ | |
| 1436 | !(defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1300) && \ | |
| 1437 | !defined(_LIBCPP_APPLE_CLANG_VER) | |
| 1438 | ||
| 1439 | template<class _Tp> | |
| 1440 | struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { }; | |
| 1441 | ||
| 1442 | #if _LIBCPP_STD_VER > 14 | |
| 1443 | template <class _Tp> | |
| 1444 | inline constexpr bool is_unsigned_v = __is_unsigned(_Tp); | |
| 1445 | #endif | |
| 1446 | ||
| 1447 | #else // __has_keyword(__is_unsigned) | |
| 1448 | ||
| 1449 | template <class _Tp, bool = is_integral<_Tp>::value> | |
| 1450 | struct __libcpp_is_unsigned_impl : public _LIBCPP_BOOL_CONSTANT(_Tp(0) < _Tp(-1)) {}; | |
| 1451 | ||
| 1452 | template <class _Tp> | |
| 1453 | struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point | |
| 1454 | ||
| 1455 | template <class _Tp, bool = is_arithmetic<_Tp>::value> | |
| 1456 | struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {}; | |
| 1457 | ||
| 1458 | template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type {}; | |
| 1459 | ||
| 1460 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {}; | |
| 1461 | ||
| 1462 | #if _LIBCPP_STD_VER > 14 | |
| 1463 | template <class _Tp> | |
| 1464 | inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value; | |
| 1465 | #endif | |
| 1466 | ||
| 1467 | #endif // __has_keyword(__is_unsigned) | |
| 1468 | ||
| 1469 | // rank | |
| 1470 | ||
| 1471 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank | |
| 1472 | : public integral_constant<size_t, 0> {}; | |
| 1473 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> | |
| 1474 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; | |
| 1475 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> | |
| 1476 | : public integral_constant<size_t, rank<_Tp>::value + 1> {}; | |
| 1477 | ||
| 1478 | #if _LIBCPP_STD_VER > 14 | |
| 1479 | template <class _Tp> | |
| 1480 | inline constexpr size_t rank_v = rank<_Tp>::value; | |
| 1481 | #endif | |
| 1482 | ||
| 1483 | // extent | |
| 1484 | ||
| 1485 | #if __has_keyword(__array_extent) | |
| 1486 | ||
| 1487 | template<class _Tp, size_t _Dim = 0> | |
| 1488 | struct _LIBCPP_TEMPLATE_VIS extent | |
| 1489 | : integral_constant<size_t, __array_extent(_Tp, _Dim)> { }; | |
| 1490 | ||
| 1491 | #if _LIBCPP_STD_VER > 14 | |
| 1492 | template <class _Tp, unsigned _Ip = 0> | |
| 1493 | inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); | |
| 1494 | #endif | |
| 1495 | ||
| 1496 | #else // __has_keyword(__array_extent) | |
| 1497 | ||
| 1498 | template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent | |
| 1499 | : public integral_constant<size_t, 0> {}; | |
| 1500 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> | |
| 1501 | : public integral_constant<size_t, 0> {}; | |
| 1502 | template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> | |
| 1503 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; | |
| 1504 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> | |
| 1505 | : public integral_constant<size_t, _Np> {}; | |
| 1506 | template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> | |
| 1507 | : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; | |
| 1508 | ||
| 1509 | #if _LIBCPP_STD_VER > 14 | |
| 1510 | template <class _Tp, unsigned _Ip = 0> | |
| 1511 | inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; | |
| 1512 | #endif | |
| 1513 | ||
| 1514 | #endif // __has_keyword(__array_extent) | |
| 1515 | ||
| 1516 | // remove_extent | |
| 1517 | ||
| 1518 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent | |
| 1519 | {typedef _Tp type;}; | |
| 1520 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> | |
| 1521 | {typedef _Tp type;}; | |
| 1522 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> | |
| 1523 | {typedef _Tp type;}; | |
| 1524 | ||
| 1525 | #if _LIBCPP_STD_VER > 11 | |
| 1526 | template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; | |
| 1527 | #endif | |
| 1528 | ||
| 1529 | // remove_all_extents | |
| 1530 | ||
| 1531 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents | |
| 1532 | {typedef _Tp type;}; | |
| 1533 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> | |
| 1534 | {typedef typename remove_all_extents<_Tp>::type type;}; | |
| 1535 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> | |
| 1536 | {typedef typename remove_all_extents<_Tp>::type type;}; | |
| 1537 | ||
| 1538 | #if _LIBCPP_STD_VER > 11 | |
| 1539 | template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; | |
| 1540 | #endif | |
| 1541 | ||
| 1542 | #if _LIBCPP_STD_VER > 17 | |
| 1543 | // is_bounded_array | |
| 1544 | ||
| 1545 | template <class> struct _LIBCPP_TEMPLATE_VIS is_bounded_array : false_type {}; | |
| 1546 | template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {}; | |
| 1547 | ||
| 1548 | template <class _Tp> | |
| 1549 | inline constexpr | |
| 1550 | bool is_bounded_array_v = is_bounded_array<_Tp>::value; | |
| 1551 | ||
| 1552 | // is_unbounded_array | |
| 1553 | ||
| 1554 | template <class> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array : false_type {}; | |
| 1555 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {}; | |
| 1556 | ||
| 1557 | template <class _Tp> | |
| 1558 | inline constexpr | |
| 1559 | bool is_unbounded_array_v = is_unbounded_array<_Tp>::value; | |
| 1560 | #endif | |
| 1561 | ||
| 1562 | // decay | |
| 1563 | ||
| 1564 | template <class _Up, bool> | |
| 1565 | struct __decay { | |
| 1566 | typedef _LIBCPP_NODEBUG typename remove_cv<_Up>::type type; | |
| 1567 | }; | |
| 1568 | ||
| 1569 | template <class _Up> | |
| 1570 | struct __decay<_Up, true> { | |
| 1571 | public: | |
| 1572 | typedef _LIBCPP_NODEBUG typename conditional | |
| 1573 | < | |
| 1574 | is_array<_Up>::value, | |
| 1575 | typename remove_extent<_Up>::type*, | |
| 1576 | typename conditional | |
| 1577 | < | |
| 1578 | is_function<_Up>::value, | |
| 1579 | typename add_pointer<_Up>::type, | |
| 1580 | typename remove_cv<_Up>::type | |
| 1581 | >::type | |
| 1582 | >::type type; | |
| 1583 | }; | |
| 1584 | ||
| 1585 | template <class _Tp> | |
| 1586 | struct _LIBCPP_TEMPLATE_VIS decay | |
| 1587 | { | |
| 1588 | private: | |
| 1589 | typedef _LIBCPP_NODEBUG typename remove_reference<_Tp>::type _Up; | |
| 1590 | public: | |
| 1591 | typedef _LIBCPP_NODEBUG typename __decay<_Up, __is_referenceable<_Up>::value>::type type; | |
| 1592 | }; | |
| 1593 | ||
| 1594 | #if _LIBCPP_STD_VER > 11 | |
| 1595 | template <class _Tp> using decay_t = typename decay<_Tp>::type; | |
| 1596 | #endif | |
| 1597 | ||
| 1598 | // is_abstract | |
| 1599 | ||
| 1600 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract | |
| 1601 | : public integral_constant<bool, __is_abstract(_Tp)> {}; | |
| 1602 | ||
| 1603 | #if _LIBCPP_STD_VER > 14 | |
| 1604 | template <class _Tp> | |
| 1605 | inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; | |
| 1606 | #endif | |
| 1607 | ||
| 1608 | // is_final | |
| 1609 | ||
| 1610 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | |
| 1611 | __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {}; | |
| 1612 | ||
| 1613 | #if _LIBCPP_STD_VER > 11 | |
| 1614 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | |
| 1615 | is_final : public integral_constant<bool, __is_final(_Tp)> {}; | |
| 1616 | #endif | |
| 1617 | ||
| 1618 | #if _LIBCPP_STD_VER > 14 | |
| 1619 | template <class _Tp> | |
| 1620 | inline constexpr bool is_final_v = is_final<_Tp>::value; | |
| 1621 | #endif | |
| 1622 | ||
| 1623 | // is_aggregate | |
| 1624 | #if _LIBCPP_STD_VER > 14 | |
| 1625 | ||
| 1626 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | |
| 1627 | is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; | |
| 1628 | ||
| 1629 | template <class _Tp> | |
| 1630 | inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; | |
| 1631 | ||
| 1632 | #endif // _LIBCPP_STD_VER > 14 | |
| 1633 | ||
| 1634 | // is_base_of | |
| 1635 | ||
| 1636 | template <class _Bp, class _Dp> | |
| 1637 | struct _LIBCPP_TEMPLATE_VIS is_base_of | |
| 1638 | : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; | |
| 1639 | ||
| 1640 | #if _LIBCPP_STD_VER > 14 | |
| 1641 | template <class _Bp, class _Dp> | |
| 1642 | inline constexpr bool is_base_of_v = is_base_of<_Bp, _Dp>::value; | |
| 1643 | #endif | |
| 1644 | ||
| 1645 | // __is_core_convertible | |
| 1646 | ||
| 1647 | // [conv.general]/3 says "E is convertible to T" whenever "T t=E;" is well-formed. | |
| 1648 | // We can't test for that, but we can test implicit convertibility by passing it | |
| 1649 | // to a function. Notice that __is_core_convertible<void,void> is false, | |
| 1650 | // and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later. | |
| 1651 | ||
| 1652 | template <class _Tp, class _Up, class = void> | |
| 1653 | struct __is_core_convertible : public false_type {}; | |
| 1654 | ||
| 1655 | template <class _Tp, class _Up> | |
| 1656 | struct __is_core_convertible<_Tp, _Up, decltype( | |
| 1657 | static_cast<void(*)(_Up)>(0) ( static_cast<_Tp(*)()>(0)() ) | |
| 1658 | )> : public true_type {}; | |
| 1659 | ||
| 1660 | // is_convertible | |
| 1661 | ||
| 1662 | #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) | |
| 1663 | ||
| 1664 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible | |
| 1665 | : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {}; | |
| 1666 | ||
| 1667 | #else // __has_feature(is_convertible_to) | |
| 1668 | ||
| 1669 | namespace __is_convertible_imp | |
| 1670 | { | |
| 1671 | template <class _Tp> void __test_convert(_Tp); | |
| 1672 | ||
| 1673 | template <class _From, class _To, class = void> | |
| 1674 | struct __is_convertible_test : public false_type {}; | |
| 1675 | ||
| 1676 | template <class _From, class _To> | |
| 1677 | struct __is_convertible_test<_From, _To, | |
| 1678 | decltype(__is_convertible_imp::__test_convert<_To>(declval<_From>()))> : public true_type | |
| 1679 | {}; | |
| 1680 | ||
| 1681 | template <class _Tp, bool _IsArray = is_array<_Tp>::value, | |
| 1682 | bool _IsFunction = is_function<_Tp>::value, | |
| 1683 | bool _IsVoid = is_void<_Tp>::value> | |
| 1684 | struct __is_array_function_or_void {enum {value = 0};}; | |
| 1685 | template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> {enum {value = 1};}; | |
| 1686 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> {enum {value = 2};}; | |
| 1687 | template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> {enum {value = 3};}; | |
| 1688 | } | |
| 1689 | ||
| 1690 | template <class _Tp, | |
| 1691 | unsigned = __is_convertible_imp::__is_array_function_or_void<typename remove_reference<_Tp>::type>::value> | |
| 1692 | struct __is_convertible_check | |
| 1693 | { | |
| 1694 | static const size_t __v = 0; | |
| 1695 | }; | |
| 1696 | ||
| 1697 | template <class _Tp> | |
| 1698 | struct __is_convertible_check<_Tp, 0> | |
| 1699 | { | |
| 1700 | static const size_t __v = sizeof(_Tp); | |
| 1701 | }; | |
| 1702 | ||
| 1703 | template <class _T1, class _T2, | |
| 1704 | unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, | |
| 1705 | unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> | |
| 1706 | struct __is_convertible | |
| 1707 | : public integral_constant<bool, | |
| 1708 | __is_convertible_imp::__is_convertible_test<_T1, _T2>::value | |
| 1709 | > | |
| 1710 | {}; | |
| 1711 | ||
| 1712 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type {}; | |
| 1713 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type {}; | |
| 1714 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type {}; | |
| 1715 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type {}; | |
| 1716 | ||
| 1717 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type {}; | |
| 1718 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type {}; | |
| 1719 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type {}; | |
| 1720 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type {}; | |
| 1721 | ||
| 1722 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type {}; | |
| 1723 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type {}; | |
| 1724 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; | |
| 1725 | template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; | |
| 1726 | ||
| 1727 | template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible | |
| 1728 | : public __is_convertible<_T1, _T2> | |
| 1729 | { | |
| 1730 | static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; | |
| 1731 | static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; | |
| 1732 | }; | |
| 1733 | ||
| 1734 | #endif // __has_feature(is_convertible_to) | |
| 1735 | ||
| 1736 | #if _LIBCPP_STD_VER > 14 | |
| 1737 | template <class _From, class _To> | |
| 1738 | inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; | |
| 1739 | #endif | |
| 1740 | ||
| 1741 | // is_nothrow_convertible | |
| 1742 | ||
| 1743 | #if _LIBCPP_STD_VER > 17 | |
| 1744 | ||
| 1745 | template <typename _Tp> | |
| 1746 | static void __test_noexcept(_Tp) noexcept; | |
| 1747 | ||
| 1748 | template<typename _Fm, typename _To> | |
| 1749 | static bool_constant<noexcept(_VSTD::__test_noexcept<_To>(declval<_Fm>()))> | |
| 1750 | __is_nothrow_convertible_test(); | |
| 1751 | ||
| 1752 | template <typename _Fm, typename _To> | |
| 1753 | struct __is_nothrow_convertible_helper: decltype(__is_nothrow_convertible_test<_Fm, _To>()) | |
| 1754 | { }; | |
| 1755 | ||
| 1756 | template <typename _Fm, typename _To> | |
| 1757 | struct is_nothrow_convertible : _Or< | |
| 1758 | _And<is_void<_To>, is_void<_Fm>>, | |
| 1759 | _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To>> | |
| 1760 | >::type { }; | |
| 1761 | ||
| 1762 | template <typename _Fm, typename _To> | |
| 1763 | inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value; | |
| 1764 | ||
| 1765 | #endif // _LIBCPP_STD_VER > 17 | |
| 1766 | ||
| 1767 | // is_empty | |
| 1768 | ||
| 1769 | #if __has_feature(is_empty) || defined(_LIBCPP_COMPILER_GCC) | |
| 1770 | ||
| 1771 | template <class _Tp> | |
| 1772 | struct _LIBCPP_TEMPLATE_VIS is_empty | |
| 1773 | : public integral_constant<bool, __is_empty(_Tp)> {}; | |
| 1774 | ||
| 1775 | #else // __has_feature(is_empty) | |
| 1776 | ||
| 1777 | template <class _Tp> | |
| 1778 | struct __is_empty1 | |
| 1779 | : public _Tp | |
| 1780 | { | |
| 1781 | double __lx; | |
| 1782 | }; | |
| 1783 | ||
| 1784 | struct __is_empty2 | |
| 1785 | { | |
| 1786 | double __lx; | |
| 1787 | }; | |
| 1788 | ||
| 1789 | template <class _Tp, bool = is_class<_Tp>::value> | |
| 1790 | struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) == sizeof(__is_empty2)> {}; | |
| 1791 | ||
| 1792 | template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; | |
| 1793 | ||
| 1794 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_empty : public __libcpp_empty<_Tp> {}; | |
| 1795 | ||
| 1796 | #endif // __has_feature(is_empty) | |
| 1797 | ||
| 1798 | #if _LIBCPP_STD_VER > 14 | |
| 1799 | template <class _Tp> | |
| 1800 | inline constexpr bool is_empty_v = is_empty<_Tp>::value; | |
| 1801 | #endif | |
| 1802 | ||
| 1803 | // is_polymorphic | |
| 1804 | ||
| 1805 | #if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) | |
| 1806 | ||
| 1807 | template <class _Tp> | |
| 1808 | struct _LIBCPP_TEMPLATE_VIS is_polymorphic | |
| 1809 | : public integral_constant<bool, __is_polymorphic(_Tp)> {}; | |
| 1810 | ||
| 1811 | #else | |
| 1812 | ||
| 1813 | template<typename _Tp> char &__is_polymorphic_impl( | |
| 1814 | typename enable_if<sizeof((_Tp*)dynamic_cast<const volatile void*>(declval<_Tp*>())) != 0, | |
| 1815 | int>::type); | |
| 1816 | template<typename _Tp> __two &__is_polymorphic_impl(...); | |
| 1817 | ||
| 1818 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_polymorphic | |
| 1819 | : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; | |
| 1820 | ||
| 1821 | #endif // __has_feature(is_polymorphic) | |
| 1822 | ||
| 1823 | #if _LIBCPP_STD_VER > 14 | |
| 1824 | template <class _Tp> | |
| 1825 | inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; | |
| 1826 | #endif | |
| 1827 | ||
| 1828 | // has_virtual_destructor | |
| 1829 | ||
| 1830 | #if __has_feature(has_virtual_destructor) || defined(_LIBCPP_COMPILER_GCC) | |
| 1831 | ||
| 1832 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor | |
| 1833 | : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; | |
| 1834 | ||
| 1835 | #else | |
| 1836 | ||
| 1837 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor | |
| 1838 | : public false_type {}; | |
| 1839 | ||
| 1840 | #endif | |
| 1841 | ||
| 1842 | #if _LIBCPP_STD_VER > 14 | |
| 1843 | template <class _Tp> | |
| 1844 | inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; | |
| 1845 | #endif | |
| 1846 | ||
| 1847 | // has_unique_object_representations | |
| 1848 | ||
| 1849 | #if _LIBCPP_STD_VER > 14 | |
| 1850 | ||
| 1851 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations | |
| 1852 | : public integral_constant<bool, | |
| 1853 | __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {}; | |
| 1854 | ||
| 1855 | template <class _Tp> | |
| 1856 | inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value; | |
| 1857 | ||
| 1858 | #endif | |
| 1859 | ||
| 1860 | // alignment_of | |
| 1861 | ||
| 1862 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS alignment_of | |
| 1863 | : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {}; | |
| 1864 | ||
| 1865 | #if _LIBCPP_STD_VER > 14 | |
| 1866 | template <class _Tp> | |
| 1867 | inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; | |
| 1868 | #endif | |
| 1869 | ||
| 1870 | // aligned_storage | |
| 1871 | ||
| 1872 | template <class _Hp, class _Tp> | |
| 1873 | struct __type_list | |
| 1874 | { | |
| 1875 | typedef _Hp _Head; | |
| 1876 | typedef _Tp _Tail; | |
| 1877 | }; | |
| 1878 | ||
| 1879 | struct __nat | |
| 1880 | { | |
| 1881 | #ifndef _LIBCPP_CXX03_LANG | |
| 1882 | __nat() = delete; | |
| 1883 | __nat(const __nat&) = delete; | |
| 1884 | __nat& operator=(const __nat&) = delete; | |
| 1885 | ~__nat() = delete; | |
| 1886 | #endif | |
| 1887 | }; | |
| 1888 | ||
| 1889 | template <class _Tp> | |
| 1890 | struct __align_type | |
| 1891 | { | |
| 1892 | static const size_t value = _LIBCPP_PREFERRED_ALIGNOF(_Tp); | |
| 1893 | typedef _Tp type; | |
| 1894 | }; | |
| 1895 | ||
| 1896 | struct __struct_double {long double __lx;}; | |
| 1897 | struct __struct_double4 {double __lx[4];}; | |
| 1898 | ||
| 1899 | typedef | |
| 1900 | __type_list<__align_type<unsigned char>, | |
| 1901 | __type_list<__align_type<unsigned short>, | |
| 1902 | __type_list<__align_type<unsigned int>, | |
| 1903 | __type_list<__align_type<unsigned long>, | |
| 1904 | __type_list<__align_type<unsigned long long>, | |
| 1905 | __type_list<__align_type<double>, | |
| 1906 | __type_list<__align_type<long double>, | |
| 1907 | __type_list<__align_type<__struct_double>, | |
| 1908 | __type_list<__align_type<__struct_double4>, | |
| 1909 | __type_list<__align_type<int*>, | |
| 1910 | __nat | |
| 1911 | > > > > > > > > > > __all_types; | |
| 1912 | ||
| 1913 | template <size_t _Align> | |
| 1914 | struct _ALIGNAS(_Align) __fallback_overaligned {}; | |
| 1915 | ||
| 1916 | template <class _TL, size_t _Align> struct __find_pod; | |
| 1917 | ||
| 1918 | template <class _Hp, size_t _Align> | |
| 1919 | struct __find_pod<__type_list<_Hp, __nat>, _Align> | |
| 1920 | { | |
| 1921 | typedef typename conditional< | |
| 1922 | _Align == _Hp::value, | |
| 1923 | typename _Hp::type, | |
| 1924 | __fallback_overaligned<_Align> | |
| 1925 | >::type type; | |
| 1926 | }; | |
| 1927 | ||
| 1928 | template <class _Hp, class _Tp, size_t _Align> | |
| 1929 | struct __find_pod<__type_list<_Hp, _Tp>, _Align> | |
| 1930 | { | |
| 1931 | typedef typename conditional< | |
| 1932 | _Align == _Hp::value, | |
| 1933 | typename _Hp::type, | |
| 1934 | typename __find_pod<_Tp, _Align>::type | |
| 1935 | >::type type; | |
| 1936 | }; | |
| 1937 | ||
| 1938 | template <class _TL, size_t _Len> struct __find_max_align; | |
| 1939 | ||
| 1940 | template <class _Hp, size_t _Len> | |
| 1941 | struct __find_max_align<__type_list<_Hp, __nat>, _Len> : public integral_constant<size_t, _Hp::value> {}; | |
| 1942 | ||
| 1943 | template <size_t _Len, size_t _A1, size_t _A2> | |
| 1944 | struct __select_align | |
| 1945 | { | |
| 1946 | private: | |
| 1947 | static const size_t __min = _A2 < _A1 ? _A2 : _A1; | |
| 1948 | static const size_t __max = _A1 < _A2 ? _A2 : _A1; | |
| 1949 | public: | |
| 1950 | static const size_t value = _Len < __max ? __min : __max; | |
| 1951 | }; | |
| 1952 | ||
| 1953 | template <class _Hp, class _Tp, size_t _Len> | |
| 1954 | struct __find_max_align<__type_list<_Hp, _Tp>, _Len> | |
| 1955 | : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; | |
| 1956 | ||
| 1957 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | |
| 1958 | struct _LIBCPP_TEMPLATE_VIS aligned_storage | |
| 1959 | { | |
| 1960 | typedef typename __find_pod<__all_types, _Align>::type _Aligner; | |
| 1961 | union type | |
| 1962 | { | |
| 1963 | _Aligner __align; | |
| 1964 | unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; | |
| 1965 | }; | |
| 1966 | }; | |
| 1967 | ||
| 1968 | #if _LIBCPP_STD_VER > 11 | |
| 1969 | template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> | |
| 1970 | using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; | |
| 1971 | #endif | |
| 1972 | ||
| 1973 | #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ | |
| 1974 | template <size_t _Len>\ | |
| 1975 | struct _LIBCPP_TEMPLATE_VIS aligned_storage<_Len, n>\ | |
| 1976 | {\ | |
| 1977 | struct _ALIGNAS(n) type\ | |
| 1978 | {\ | |
| 1979 | unsigned char __lx[(_Len + n - 1)/n * n];\ | |
| 1980 | };\ | |
| 1981 | } | |
| 1982 | ||
| 1983 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1); | |
| 1984 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2); | |
| 1985 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4); | |
| 1986 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x8); | |
| 1987 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x10); | |
| 1988 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x20); | |
| 1989 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x40); | |
| 1990 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x80); | |
| 1991 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x100); | |
| 1992 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x200); | |
| 1993 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x400); | |
| 1994 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800); | |
| 1995 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000); | |
| 1996 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000); | |
| 1997 | // PE/COFF does not support alignment beyond 8192 (=0x2000) | |
| 1998 | #if !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 1999 | _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000); | |
| 2000 | #endif // !defined(_LIBCPP_OBJECT_FORMAT_COFF) | |
| 2001 | ||
| 2002 | #undef _CREATE_ALIGNED_STORAGE_SPECIALIZATION | |
| 2003 | ||
| 2004 | ||
| 2005 | // aligned_union | |
| 2006 | ||
| 2007 | template <size_t _I0, size_t ..._In> | |
| 2008 | struct __static_max; | |
| 2009 | ||
| 2010 | template <size_t _I0> | |
| 2011 | struct __static_max<_I0> | |
| 2012 | { | |
| 2013 | static const size_t value = _I0; | |
| 2014 | }; | |
| 2015 | ||
| 2016 | template <size_t _I0, size_t _I1, size_t ..._In> | |
| 2017 | struct __static_max<_I0, _I1, _In...> | |
| 2018 | { | |
| 2019 | static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : | |
| 2020 | __static_max<_I1, _In...>::value; | |
| 2021 | }; | |
| 2022 | ||
| 2023 | template <size_t _Len, class _Type0, class ..._Types> | |
| 2024 | struct aligned_union | |
| 2025 | { | |
| 2026 | static const size_t alignment_value = __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), | |
| 2027 | _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value; | |
| 2028 | static const size_t __len = __static_max<_Len, sizeof(_Type0), | |
| 2029 | sizeof(_Types)...>::value; | |
| 2030 | typedef typename aligned_storage<__len, alignment_value>::type type; | |
| 2031 | }; | |
| 2032 | ||
| 2033 | #if _LIBCPP_STD_VER > 11 | |
| 2034 | template <size_t _Len, class ..._Types> using aligned_union_t = typename aligned_union<_Len, _Types...>::type; | |
| 2035 | #endif | |
| 2036 | ||
| 2037 | template <class _Tp> | |
| 2038 | struct __numeric_type | |
| 2039 | { | |
| 2040 | static void __test(...); | |
| 2041 | static float __test(float); | |
| 2042 | static double __test(char); | |
| 2043 | static double __test(int); | |
| 2044 | static double __test(unsigned); | |
| 2045 | static double __test(long); | |
| 2046 | static double __test(unsigned long); | |
| 2047 | static double __test(long long); | |
| 2048 | static double __test(unsigned long long); | |
| 2049 | static double __test(double); | |
| 2050 | static long double __test(long double); | |
| 2051 | ||
| 2052 | typedef decltype(__test(declval<_Tp>())) type; | |
| 2053 | static const bool value = _IsNotSame<type, void>::value; | |
| 2054 | }; | |
| 2055 | ||
| 2056 | template <> | |
| 2057 | struct __numeric_type<void> | |
| 2058 | { | |
| 2059 | static const bool value = true; | |
| 2060 | }; | |
| 2061 | ||
| 2062 | // __promote | |
| 2063 | ||
| 2064 | template <class _A1, class _A2 = void, class _A3 = void, | |
| 2065 | bool = __numeric_type<_A1>::value && | |
| 2066 | __numeric_type<_A2>::value && | |
| 2067 | __numeric_type<_A3>::value> | |
| 2068 | class __promote_imp | |
| 2069 | { | |
| 2070 | public: | |
| 2071 | static const bool value = false; | |
| 2072 | }; | |
| 2073 | ||
| 2074 | template <class _A1, class _A2, class _A3> | |
| 2075 | class __promote_imp<_A1, _A2, _A3, true> | |
| 2076 | { | |
| 2077 | private: | |
| 2078 | typedef typename __promote_imp<_A1>::type __type1; | |
| 2079 | typedef typename __promote_imp<_A2>::type __type2; | |
| 2080 | typedef typename __promote_imp<_A3>::type __type3; | |
| 2081 | public: | |
| 2082 | typedef decltype(__type1() + __type2() + __type3()) type; | |
| 2083 | static const bool value = true; | |
| 2084 | }; | |
| 2085 | ||
| 2086 | template <class _A1, class _A2> | |
| 2087 | class __promote_imp<_A1, _A2, void, true> | |
| 2088 | { | |
| 2089 | private: | |
| 2090 | typedef typename __promote_imp<_A1>::type __type1; | |
| 2091 | typedef typename __promote_imp<_A2>::type __type2; | |
| 2092 | public: | |
| 2093 | typedef decltype(__type1() + __type2()) type; | |
| 2094 | static const bool value = true; | |
| 2095 | }; | |
| 2096 | ||
| 2097 | template <class _A1> | |
| 2098 | class __promote_imp<_A1, void, void, true> | |
| 2099 | { | |
| 2100 | public: | |
| 2101 | typedef typename __numeric_type<_A1>::type type; | |
| 2102 | static const bool value = true; | |
| 2103 | }; | |
| 2104 | ||
| 2105 | template <class _A1, class _A2 = void, class _A3 = void> | |
| 2106 | class __promote : public __promote_imp<_A1, _A2, _A3> {}; | |
| 2107 | ||
| 2108 | // make_signed / make_unsigned | |
| 2109 | ||
| 2110 | typedef | |
| 2111 | __type_list<signed char, | |
| 2112 | __type_list<signed short, | |
| 2113 | __type_list<signed int, | |
| 2114 | __type_list<signed long, | |
| 2115 | __type_list<signed long long, | |
| 2116 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 2117 | __type_list<__int128_t, | |
| 2118 | #endif | |
| 2119 | __nat | |
| 2120 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 2121 | > | |
| 2122 | #endif | |
| 2123 | > > > > > __signed_types; | |
| 2124 | ||
| 2125 | typedef | |
| 2126 | __type_list<unsigned char, | |
| 2127 | __type_list<unsigned short, | |
| 2128 | __type_list<unsigned int, | |
| 2129 | __type_list<unsigned long, | |
| 2130 | __type_list<unsigned long long, | |
| 2131 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 2132 | __type_list<__uint128_t, | |
| 2133 | #endif | |
| 2134 | __nat | |
| 2135 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 2136 | > | |
| 2137 | #endif | |
| 2138 | > > > > > __unsigned_types; | |
| 2139 | ||
| 2140 | template <class _TypeList, size_t _Size, bool = _Size <= sizeof(typename _TypeList::_Head)> struct __find_first; | |
| 2141 | ||
| 2142 | template <class _Hp, class _Tp, size_t _Size> | |
| 2143 | struct __find_first<__type_list<_Hp, _Tp>, _Size, true> | |
| 2144 | { | |
| 2145 | typedef _LIBCPP_NODEBUG _Hp type; | |
| 2146 | }; | |
| 2147 | ||
| 2148 | template <class _Hp, class _Tp, size_t _Size> | |
| 2149 | struct __find_first<__type_list<_Hp, _Tp>, _Size, false> | |
| 2150 | { | |
| 2151 | typedef _LIBCPP_NODEBUG typename __find_first<_Tp, _Size>::type type; | |
| 2152 | }; | |
| 2153 | ||
| 2154 | template <class _Tp, class _Up, bool = is_const<typename remove_reference<_Tp>::type>::value, | |
| 2155 | bool = is_volatile<typename remove_reference<_Tp>::type>::value> | |
| 2156 | struct __apply_cv | |
| 2157 | { | |
| 2158 | typedef _LIBCPP_NODEBUG _Up type; | |
| 2159 | }; | |
| 2160 | ||
| 2161 | template <class _Tp, class _Up> | |
| 2162 | struct __apply_cv<_Tp, _Up, true, false> | |
| 2163 | { | |
| 2164 | typedef _LIBCPP_NODEBUG const _Up type; | |
| 2165 | }; | |
| 2166 | ||
| 2167 | template <class _Tp, class _Up> | |
| 2168 | struct __apply_cv<_Tp, _Up, false, true> | |
| 2169 | { | |
| 2170 | typedef volatile _Up type; | |
| 2171 | }; | |
| 2172 | ||
| 2173 | template <class _Tp, class _Up> | |
| 2174 | struct __apply_cv<_Tp, _Up, true, true> | |
| 2175 | { | |
| 2176 | typedef const volatile _Up type; | |
| 2177 | }; | |
| 2178 | ||
| 2179 | template <class _Tp, class _Up> | |
| 2180 | struct __apply_cv<_Tp&, _Up, false, false> | |
| 2181 | { | |
| 2182 | typedef _Up& type; | |
| 2183 | }; | |
| 2184 | ||
| 2185 | template <class _Tp, class _Up> | |
| 2186 | struct __apply_cv<_Tp&, _Up, true, false> | |
| 2187 | { | |
| 2188 | typedef const _Up& type; | |
| 2189 | }; | |
| 2190 | ||
| 2191 | template <class _Tp, class _Up> | |
| 2192 | struct __apply_cv<_Tp&, _Up, false, true> | |
| 2193 | { | |
| 2194 | typedef volatile _Up& type; | |
| 2195 | }; | |
| 2196 | ||
| 2197 | template <class _Tp, class _Up> | |
| 2198 | struct __apply_cv<_Tp&, _Up, true, true> | |
| 2199 | { | |
| 2200 | typedef const volatile _Up& type; | |
| 2201 | }; | |
| 2202 | ||
| 2203 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> | |
| 2204 | struct __make_signed {}; | |
| 2205 | ||
| 2206 | template <class _Tp> | |
| 2207 | struct __make_signed<_Tp, true> | |
| 2208 | { | |
| 2209 | typedef typename __find_first<__signed_types, sizeof(_Tp)>::type type; | |
| 2210 | }; | |
| 2211 | ||
| 2212 | template <> struct __make_signed<bool, true> {}; | |
| 2213 | template <> struct __make_signed< signed short, true> {typedef short type;}; | |
| 2214 | template <> struct __make_signed<unsigned short, true> {typedef short type;}; | |
| 2215 | template <> struct __make_signed< signed int, true> {typedef int type;}; | |
| 2216 | template <> struct __make_signed<unsigned int, true> {typedef int type;}; | |
| 2217 | template <> struct __make_signed< signed long, true> {typedef long type;}; | |
| 2218 | template <> struct __make_signed<unsigned long, true> {typedef long type;}; | |
| 2219 | template <> struct __make_signed< signed long long, true> {typedef long long type;}; | |
| 2220 | template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; | |
| 2221 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 2222 | template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; | |
| 2223 | template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; | |
| 2224 | #endif | |
| 2225 | ||
| 2226 | template <class _Tp> | |
| 2227 | struct _LIBCPP_TEMPLATE_VIS make_signed | |
| 2228 | { | |
| 2229 | typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; | |
| 2230 | }; | |
| 2231 | ||
| 2232 | #if _LIBCPP_STD_VER > 11 | |
| 2233 | template <class _Tp> using make_signed_t = typename make_signed<_Tp>::type; | |
| 2234 | #endif | |
| 2235 | ||
| 2236 | template <class _Tp, bool = is_integral<_Tp>::value || is_enum<_Tp>::value> | |
| 2237 | struct __make_unsigned {}; | |
| 2238 | ||
| 2239 | template <class _Tp> | |
| 2240 | struct __make_unsigned<_Tp, true> | |
| 2241 | { | |
| 2242 | typedef typename __find_first<__unsigned_types, sizeof(_Tp)>::type type; | |
| 2243 | }; | |
| 2244 | ||
| 2245 | template <> struct __make_unsigned<bool, true> {}; | |
| 2246 | template <> struct __make_unsigned< signed short, true> {typedef unsigned short type;}; | |
| 2247 | template <> struct __make_unsigned<unsigned short, true> {typedef unsigned short type;}; | |
| 2248 | template <> struct __make_unsigned< signed int, true> {typedef unsigned int type;}; | |
| 2249 | template <> struct __make_unsigned<unsigned int, true> {typedef unsigned int type;}; | |
| 2250 | template <> struct __make_unsigned< signed long, true> {typedef unsigned long type;}; | |
| 2251 | template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;}; | |
| 2252 | template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; | |
| 2253 | template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; | |
| 2254 | #ifndef _LIBCPP_HAS_NO_INT128 | |
| 2255 | template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; | |
| 2256 | template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; | |
| 2257 | #endif | |
| 2258 | ||
| 2259 | template <class _Tp> | |
| 2260 | struct _LIBCPP_TEMPLATE_VIS make_unsigned | |
| 2261 | { | |
| 2262 | typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; | |
| 2263 | }; | |
| 2264 | ||
| 2265 | #if _LIBCPP_STD_VER > 11 | |
| 2266 | template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; | |
| 2267 | #endif | |
| 2268 | ||
| 2269 | #ifndef _LIBCPP_CXX03_LANG | |
| 2270 | template <class _Tp> | |
| 2271 | _LIBCPP_HIDE_FROM_ABI constexpr | |
| 2272 | typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { | |
| 2273 | return static_cast<typename make_unsigned<_Tp>::type>(__x); | |
| 2274 | } | |
| 2275 | #endif | |
| 2276 | ||
| 2277 | #if _LIBCPP_STD_VER > 14 | |
| 2278 | template <class...> using void_t = void; | |
| 2279 | #endif | |
| 2280 | ||
| 2281 | #if _LIBCPP_STD_VER > 17 | |
| 2282 | // Let COND_RES(X, Y) be: | |
| 2283 | template <class _Tp, class _Up> | |
| 2284 | using __cond_type = decltype(false ? declval<_Tp>() : declval<_Up>()); | |
| 2285 | ||
| 2286 | template <class _Tp, class _Up, class = void> | |
| 2287 | struct __common_type3 {}; | |
| 2288 | ||
| 2289 | // sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..." | |
| 2290 | template <class _Tp, class _Up> | |
| 2291 | struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> | |
| 2292 | { | |
| 2293 | using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>; | |
| 2294 | }; | |
| 2295 | ||
| 2296 | template <class _Tp, class _Up, class = void> | |
| 2297 | struct __common_type2_imp : __common_type3<_Tp, _Up> {}; | |
| 2298 | #else | |
| 2299 | template <class _Tp, class _Up, class = void> | |
| 2300 | struct __common_type2_imp {}; | |
| 2301 | #endif | |
| 2302 | ||
| 2303 | // sub-bullet 3 - "if decay_t<decltype(false ? declval<D1>() : declval<D2>())> ..." | |
| 2304 | template <class _Tp, class _Up> | |
| 2305 | struct __common_type2_imp<_Tp, _Up, | |
| 2306 | typename __void_t<decltype( | |
| 2307 | true ? declval<_Tp>() : declval<_Up>() | |
| 2308 | )>::type> | |
| 2309 | { | |
| 2310 | typedef _LIBCPP_NODEBUG typename decay<decltype( | |
| 2311 | true ? declval<_Tp>() : declval<_Up>() | |
| 2312 | )>::type type; | |
| 2313 | }; | |
| 2314 | ||
| 2315 | template <class, class = void> | |
| 2316 | struct __common_type_impl {}; | |
| 2317 | ||
| 2318 | // Clang provides variadic templates in C++03 as an extension. | |
| 2319 | #if !defined(_LIBCPP_CXX03_LANG) || defined(__clang__) | |
| 2320 | # define _LIBCPP_OPTIONAL_PACK(...) , __VA_ARGS__ | |
| 2321 | template <class... _Tp> | |
| 2322 | struct __common_types; | |
| 2323 | template <class... _Tp> | |
| 2324 | struct _LIBCPP_TEMPLATE_VIS common_type; | |
| 2325 | #else | |
| 2326 | # define _LIBCPP_OPTIONAL_PACK(...) | |
| 2327 | struct __no_arg; | |
| 2328 | template <class _Tp, class _Up, class = __no_arg> | |
| 2329 | struct __common_types; | |
| 2330 | template <class _Tp = __no_arg, class _Up = __no_arg, class _Vp = __no_arg, | |
| 2331 | class _Unused = __no_arg> | |
| 2332 | struct common_type { | |
| 2333 | static_assert(sizeof(_Unused) == 0, | |
| 2334 | "common_type accepts at most 3 arguments in C++03"); | |
| 2335 | }; | |
| 2336 | #endif // _LIBCPP_CXX03_LANG | |
| 2337 | ||
| 2338 | template <class _Tp, class _Up> | |
| 2339 | struct __common_type_impl< | |
| 2340 | __common_types<_Tp, _Up>, | |
| 2341 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> | |
| 2342 | { | |
| 2343 | typedef typename common_type<_Tp, _Up>::type type; | |
| 2344 | }; | |
| 2345 | ||
| 2346 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> | |
| 2347 | struct __common_type_impl< | |
| 2348 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)>, | |
| 2349 | typename __void_t<typename common_type<_Tp, _Up>::type>::type> | |
| 2350 | : __common_type_impl<__common_types<typename common_type<_Tp, _Up>::type, | |
| 2351 | _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > { | |
| 2352 | }; | |
| 2353 | ||
| 2354 | // bullet 1 - sizeof...(Tp) == 0 | |
| 2355 | ||
| 2356 | template <> | |
| 2357 | struct _LIBCPP_TEMPLATE_VIS common_type<> {}; | |
| 2358 | ||
| 2359 | // bullet 2 - sizeof...(Tp) == 1 | |
| 2360 | ||
| 2361 | template <class _Tp> | |
| 2362 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> | |
| 2363 | : public common_type<_Tp, _Tp> {}; | |
| 2364 | ||
| 2365 | // bullet 3 - sizeof...(Tp) == 2 | |
| 2366 | ||
| 2367 | // sub-bullet 1 - "If is_same_v<T1, D1> is false or ..." | |
| 2368 | template <class _Tp, class _Up> | |
| 2369 | struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up> | |
| 2370 | : conditional< | |
| 2371 | _IsSame<_Tp, typename decay<_Tp>::type>::value && _IsSame<_Up, typename decay<_Up>::type>::value, | |
| 2372 | __common_type2_imp<_Tp, _Up>, | |
| 2373 | common_type<typename decay<_Tp>::type, typename decay<_Up>::type> | |
| 2374 | >::type | |
| 2375 | {}; | |
| 2376 | ||
| 2377 | // bullet 4 - sizeof...(Tp) > 2 | |
| 2378 | ||
| 2379 | template <class _Tp, class _Up, class _Vp _LIBCPP_OPTIONAL_PACK(class... _Rest)> | |
| 2380 | struct _LIBCPP_TEMPLATE_VIS | |
| 2381 | common_type<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> | |
| 2382 | : __common_type_impl< | |
| 2383 | __common_types<_Tp, _Up, _Vp _LIBCPP_OPTIONAL_PACK(_Rest...)> > {}; | |
| 2384 | ||
| 2385 | #undef _LIBCPP_OPTIONAL_PACK | |
| 2386 | ||
| 2387 | #if _LIBCPP_STD_VER > 11 | |
| 2388 | template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; | |
| 2389 | #endif | |
| 2390 | ||
| 2391 | #if _LIBCPP_STD_VER > 11 | |
| 2392 | // Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's | |
| 2393 | // top-level cv-qualifiers. | |
| 2394 | template <class _From, class _To> | |
| 2395 | struct __copy_cv | |
| 2396 | { | |
| 2397 | using type = _To; | |
| 2398 | }; | |
| 2399 | ||
| 2400 | template <class _From, class _To> | |
| 2401 | struct __copy_cv<const _From, _To> | |
| 2402 | { | |
| 2403 | using type = add_const_t<_To>; | |
| 2404 | }; | |
| 2405 | ||
| 2406 | template <class _From, class _To> | |
| 2407 | struct __copy_cv<volatile _From, _To> | |
| 2408 | { | |
| 2409 | using type = add_volatile_t<_To>; | |
| 2410 | }; | |
| 2411 | ||
| 2412 | template <class _From, class _To> | |
| 2413 | struct __copy_cv<const volatile _From, _To> | |
| 2414 | { | |
| 2415 | using type = add_cv_t<_To>; | |
| 2416 | }; | |
| 2417 | ||
| 2418 | template <class _From, class _To> | |
| 2419 | using __copy_cv_t = typename __copy_cv<_From, _To>::type; | |
| 2420 | ||
| 2421 | template <class _From, class _To> | |
| 2422 | struct __copy_cvref | |
| 2423 | { | |
| 2424 | using type = __copy_cv_t<_From, _To>; | |
| 2425 | }; | |
| 2426 | ||
| 2427 | template <class _From, class _To> | |
| 2428 | struct __copy_cvref<_From&, _To> | |
| 2429 | { | |
| 2430 | using type = add_lvalue_reference_t<__copy_cv_t<_From, _To>>; | |
| 2431 | }; | |
| 2432 | ||
| 2433 | template <class _From, class _To> | |
| 2434 | struct __copy_cvref<_From&&, _To> | |
| 2435 | { | |
| 2436 | using type = add_rvalue_reference_t<__copy_cv_t<_From, _To>>; | |
| 2437 | }; | |
| 2438 | ||
| 2439 | template <class _From, class _To> | |
| 2440 | using __copy_cvref_t = typename __copy_cvref<_From, _To>::type; | |
| 2441 | ||
| 2442 | #endif // _LIBCPP_STD_VER > 11 | |
| 2443 | ||
| 2444 | // common_reference | |
| 2445 | #if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 2446 | // Let COND_RES(X, Y) be: | |
| 2447 | template <class _Xp, class _Yp> | |
| 2448 | using __cond_res = | |
| 2449 | decltype(false ? declval<_Xp(&)()>()() : declval<_Yp(&)()>()()); | |
| 2450 | ||
| 2451 | // Let `XREF(A)` denote a unary alias template `T` such that `T<U>` denotes the same type as `U` | |
| 2452 | // with the addition of `A`'s cv and reference qualifiers, for a non-reference cv-unqualified type | |
| 2453 | // `U`. | |
| 2454 | // [Note: `XREF(A)` is `__xref<A>::template __apply`] | |
| 2455 | template <class _Tp> | |
| 2456 | struct __xref { | |
| 2457 | template<class _Up> | |
| 2458 | using __apply = __copy_cvref_t<_Tp, _Up>; | |
| 2459 | }; | |
| 2460 | ||
| 2461 | // Given types A and B, let X be remove_reference_t<A>, let Y be remove_reference_t<B>, | |
| 2462 | // and let COMMON-REF(A, B) be: | |
| 2463 | template<class _Ap, class _Bp, class _Xp = remove_reference_t<_Ap>, class _Yp = remove_reference_t<_Bp>> | |
| 2464 | struct __common_ref; | |
| 2465 | ||
| 2466 | template<class _Xp, class _Yp> | |
| 2467 | using __common_ref_t = typename __common_ref<_Xp, _Yp>::__type; | |
| 2468 | ||
| 2469 | template<class _Xp, class _Yp> | |
| 2470 | using __cv_cond_res = __cond_res<__copy_cv_t<_Xp, _Yp>&, __copy_cv_t<_Yp, _Xp>&>; | |
| 2471 | ||
| 2472 | ||
| 2473 | // If A and B are both lvalue reference types, COMMON-REF(A, B) is | |
| 2474 | // COND-RES(COPYCV(X, Y)&, COPYCV(Y, X)&) if that type exists and is a reference type. | |
| 2475 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 2476 | requires requires { typename __cv_cond_res<_Xp, _Yp>; } && is_reference_v<__cv_cond_res<_Xp, _Yp>> | |
| 2477 | struct __common_ref<_Ap&, _Bp&, _Xp, _Yp> | |
| 2478 | { | |
| 2479 | using __type = __cv_cond_res<_Xp, _Yp>; | |
| 2480 | }; | |
| 2481 | ||
| 2482 | // Otherwise, let C be remove_reference_t<COMMON-REF(X&, Y&)>&&. ... | |
| 2483 | template <class _Xp, class _Yp> | |
| 2484 | using __common_ref_C = remove_reference_t<__common_ref_t<_Xp&, _Yp&>>&&; | |
| 2485 | ||
| 2486 | ||
| 2487 | // .... If A and B are both rvalue reference types, C is well-formed, and | |
| 2488 | // is_convertible_v<A, C> && is_convertible_v<B, C> is true, then COMMON-REF(A, B) is C. | |
| 2489 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 2490 | requires | |
| 2491 | requires { typename __common_ref_C<_Xp, _Yp>; } && | |
| 2492 | is_convertible_v<_Ap&&, __common_ref_C<_Xp, _Yp>> && | |
| 2493 | is_convertible_v<_Bp&&, __common_ref_C<_Xp, _Yp>> | |
| 2494 | struct __common_ref<_Ap&&, _Bp&&, _Xp, _Yp> | |
| 2495 | { | |
| 2496 | using __type = __common_ref_C<_Xp, _Yp>; | |
| 2497 | }; | |
| 2498 | ||
| 2499 | // Otherwise, let D be COMMON-REF(const X&, Y&). ... | |
| 2500 | template <class _Tp, class _Up> | |
| 2501 | using __common_ref_D = __common_ref_t<const _Tp&, _Up&>; | |
| 2502 | ||
| 2503 | // ... If A is an rvalue reference and B is an lvalue reference and D is well-formed and | |
| 2504 | // is_convertible_v<A, D> is true, then COMMON-REF(A, B) is D. | |
| 2505 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 2506 | requires requires { typename __common_ref_D<_Xp, _Yp>; } && | |
| 2507 | is_convertible_v<_Ap&&, __common_ref_D<_Xp, _Yp>> | |
| 2508 | struct __common_ref<_Ap&&, _Bp&, _Xp, _Yp> | |
| 2509 | { | |
| 2510 | using __type = __common_ref_D<_Xp, _Yp>; | |
| 2511 | }; | |
| 2512 | ||
| 2513 | // Otherwise, if A is an lvalue reference and B is an rvalue reference, then | |
| 2514 | // COMMON-REF(A, B) is COMMON-REF(B, A). | |
| 2515 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 2516 | struct __common_ref<_Ap&, _Bp&&, _Xp, _Yp> : __common_ref<_Bp&&, _Ap&> {}; | |
| 2517 | ||
| 2518 | // Otherwise, COMMON-REF(A, B) is ill-formed. | |
| 2519 | template<class _Ap, class _Bp, class _Xp, class _Yp> | |
| 2520 | struct __common_ref {}; | |
| 2521 | ||
| 2522 | // Note C: For the common_reference trait applied to a parameter pack [...] | |
| 2523 | ||
| 2524 | template <class...> | |
| 2525 | struct common_reference; | |
| 2526 | ||
| 2527 | template <class... _Types> | |
| 2528 | using common_reference_t = typename common_reference<_Types...>::type; | |
| 2529 | ||
| 2530 | // bullet 1 - sizeof...(T) == 0 | |
| 2531 | template<> | |
| 2532 | struct common_reference<> {}; | |
| 2533 | ||
| 2534 | // bullet 2 - sizeof...(T) == 1 | |
| 2535 | template <class _Tp> | |
| 2536 | struct common_reference<_Tp> | |
| 2537 | { | |
| 2538 | using type = _Tp; | |
| 2539 | }; | |
| 2540 | ||
| 2541 | // bullet 3 - sizeof...(T) == 2 | |
| 2542 | template <class _Tp, class _Up> struct __common_reference_sub_bullet3; | |
| 2543 | template <class _Tp, class _Up> struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up> {}; | |
| 2544 | template <class _Tp, class _Up> struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {}; | |
| 2545 | ||
| 2546 | // sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then | |
| 2547 | // the member typedef `type` denotes that type. | |
| 2548 | template <class _Tp, class _Up> struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {}; | |
| 2549 | ||
| 2550 | template <class _Tp, class _Up> | |
| 2551 | requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } | |
| 2552 | struct __common_reference_sub_bullet1<_Tp, _Up> | |
| 2553 | { | |
| 2554 | using type = __common_ref_t<_Tp, _Up>; | |
| 2555 | }; | |
| 2556 | ||
| 2557 | // sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type | |
| 2558 | // is well-formed, then the member typedef `type` denotes that type. | |
| 2559 | template <class, class, template <class> class, template <class> class> struct basic_common_reference {}; | |
| 2560 | ||
| 2561 | template <class _Tp, class _Up> | |
| 2562 | using __basic_common_reference_t = typename basic_common_reference< | |
| 2563 | remove_cvref_t<_Tp>, remove_cvref_t<_Up>, | |
| 2564 | __xref<_Tp>::template __apply, __xref<_Up>::template __apply>::type; | |
| 2565 | ||
| 2566 | template <class _Tp, class _Up> | |
| 2567 | requires requires { typename __basic_common_reference_t<_Tp, _Up>; } | |
| 2568 | struct __common_reference_sub_bullet2<_Tp, _Up> | |
| 2569 | { | |
| 2570 | using type = __basic_common_reference_t<_Tp, _Up>; | |
| 2571 | }; | |
| 2572 | ||
| 2573 | // sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed, | |
| 2574 | // then the member typedef `type` denotes that type. | |
| 2575 | template <class _Tp, class _Up> | |
| 2576 | requires requires { typename __cond_res<_Tp, _Up>; } | |
| 2577 | struct __common_reference_sub_bullet3<_Tp, _Up> | |
| 2578 | { | |
| 2579 | using type = __cond_res<_Tp, _Up>; | |
| 2580 | }; | |
| 2581 | ||
| 2582 | ||
| 2583 | // sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed, | |
| 2584 | // then the member typedef `type` denotes that type. | |
| 2585 | // - Otherwise, there shall be no member `type`. | |
| 2586 | template <class _Tp, class _Up> struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {}; | |
| 2587 | ||
| 2588 | // bullet 4 - If there is such a type `C`, the member typedef type shall denote the same type, if | |
| 2589 | // any, as `common_reference_t<C, Rest...>`. | |
| 2590 | template <class _Tp, class _Up, class _Vp, class... _Rest> | |
| 2591 | requires requires { typename common_reference_t<_Tp, _Up>; } | |
| 2592 | struct common_reference<_Tp, _Up, _Vp, _Rest...> | |
| 2593 | : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> | |
| 2594 | {}; | |
| 2595 | ||
| 2596 | // bullet 5 - Otherwise, there shall be no member `type`. | |
| 2597 | template <class...> struct common_reference {}; | |
| 2598 | ||
| 2599 | #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 2600 | ||
| 2601 | // is_assignable | |
| 2602 | ||
| 2603 | template<typename, typename _Tp> struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; }; | |
| 2604 | ||
| 2605 | #if __has_keyword(__is_assignable) | |
| 2606 | ||
| 2607 | template<class _Tp, class _Up> | |
| 2608 | struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { }; | |
| 2609 | ||
| 2610 | #if _LIBCPP_STD_VER > 14 | |
| 2611 | template <class _Tp, class _Arg> | |
| 2612 | inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); | |
| 2613 | #endif | |
| 2614 | ||
| 2615 | #else // __has_keyword(__is_assignable) | |
| 2616 | ||
| 2617 | template <class _Tp, class _Arg> | |
| 2618 | typename __select_2nd<decltype((declval<_Tp>() = declval<_Arg>())), true_type>::type | |
| 2619 | __is_assignable_test(int); | |
| 2620 | ||
| 2621 | template <class, class> | |
| 2622 | false_type __is_assignable_test(...); | |
| 2623 | ||
| 2624 | ||
| 2625 | template <class _Tp, class _Arg, bool = is_void<_Tp>::value || is_void<_Arg>::value> | |
| 2626 | struct __is_assignable_imp | |
| 2627 | : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; | |
| 2628 | ||
| 2629 | template <class _Tp, class _Arg> | |
| 2630 | struct __is_assignable_imp<_Tp, _Arg, true> | |
| 2631 | : public false_type | |
| 2632 | { | |
| 2633 | }; | |
| 2634 | ||
| 2635 | template <class _Tp, class _Arg> | |
| 2636 | struct is_assignable | |
| 2637 | : public __is_assignable_imp<_Tp, _Arg> {}; | |
| 2638 | ||
| 2639 | #if _LIBCPP_STD_VER > 14 | |
| 2640 | template <class _Tp, class _Arg> | |
| 2641 | inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value; | |
| 2642 | #endif | |
| 2643 | ||
| 2644 | #endif // __has_keyword(__is_assignable) | |
| 2645 | ||
| 2646 | // is_copy_assignable | |
| 2647 | ||
| 2648 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_copy_assignable | |
| 2649 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 2650 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 2651 | ||
| 2652 | #if _LIBCPP_STD_VER > 14 | |
| 2653 | template <class _Tp> | |
| 2654 | inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value; | |
| 2655 | #endif | |
| 2656 | ||
| 2657 | // is_move_assignable | |
| 2658 | ||
| 2659 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_move_assignable | |
| 2660 | : public is_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 2661 | typename add_rvalue_reference<_Tp>::type> {}; | |
| 2662 | ||
| 2663 | #if _LIBCPP_STD_VER > 14 | |
| 2664 | template <class _Tp> | |
| 2665 | inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value; | |
| 2666 | #endif | |
| 2667 | ||
| 2668 | // is_destructible | |
| 2669 | ||
| 2670 | #if __has_keyword(__is_destructible) | |
| 2671 | ||
| 2672 | template<class _Tp> | |
| 2673 | struct _LIBCPP_TEMPLATE_VIS is_destructible : _BoolConstant<__is_destructible(_Tp)> { }; | |
| 2674 | ||
| 2675 | #if _LIBCPP_STD_VER > 14 | |
| 2676 | template <class _Tp> | |
| 2677 | inline constexpr bool is_destructible_v = __is_destructible(_Tp); | |
| 2678 | #endif | |
| 2679 | ||
| 2680 | #else // __has_keyword(__is_destructible) | |
| 2681 | ||
| 2682 | // if it's a reference, return true | |
| 2683 | // if it's a function, return false | |
| 2684 | // if it's void, return false | |
| 2685 | // if it's an array of unknown bound, return false | |
| 2686 | // Otherwise, return "declval<_Up&>().~_Up()" is well-formed | |
| 2687 | // where _Up is remove_all_extents<_Tp>::type | |
| 2688 | ||
| 2689 | template <class> | |
| 2690 | struct __is_destructible_apply { typedef int type; }; | |
| 2691 | ||
| 2692 | template <typename _Tp> | |
| 2693 | struct __is_destructor_wellformed { | |
| 2694 | template <typename _Tp1> | |
| 2695 | static char __test ( | |
| 2696 | typename __is_destructible_apply<decltype(declval<_Tp1&>().~_Tp1())>::type | |
| 2697 | ); | |
| 2698 | ||
| 2699 | template <typename _Tp1> | |
| 2700 | static __two __test (...); | |
| 2701 | ||
| 2702 | static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); | |
| 2703 | }; | |
| 2704 | ||
| 2705 | template <class _Tp, bool> | |
| 2706 | struct __destructible_imp; | |
| 2707 | ||
| 2708 | template <class _Tp> | |
| 2709 | struct __destructible_imp<_Tp, false> | |
| 2710 | : public integral_constant<bool, | |
| 2711 | __is_destructor_wellformed<typename remove_all_extents<_Tp>::type>::value> {}; | |
| 2712 | ||
| 2713 | template <class _Tp> | |
| 2714 | struct __destructible_imp<_Tp, true> | |
| 2715 | : public true_type {}; | |
| 2716 | ||
| 2717 | template <class _Tp, bool> | |
| 2718 | struct __destructible_false; | |
| 2719 | ||
| 2720 | template <class _Tp> | |
| 2721 | struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {}; | |
| 2722 | ||
| 2723 | template <class _Tp> | |
| 2724 | struct __destructible_false<_Tp, true> : public false_type {}; | |
| 2725 | ||
| 2726 | template <class _Tp> | |
| 2727 | struct is_destructible | |
| 2728 | : public __destructible_false<_Tp, is_function<_Tp>::value> {}; | |
| 2729 | ||
| 2730 | template <class _Tp> | |
| 2731 | struct is_destructible<_Tp[]> | |
| 2732 | : public false_type {}; | |
| 2733 | ||
| 2734 | template <> | |
| 2735 | struct is_destructible<void> | |
| 2736 | : public false_type {}; | |
| 2737 | ||
| 2738 | #if _LIBCPP_STD_VER > 14 | |
| 2739 | template <class _Tp> | |
| 2740 | inline constexpr bool is_destructible_v = is_destructible<_Tp>::value; | |
| 2741 | #endif | |
| 2742 | ||
| 2743 | #endif // __has_keyword(__is_destructible) | |
| 2744 | ||
| 2745 | template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> | |
| 2746 | struct __member_pointer_traits_imp | |
| 2747 | { | |
| 2748 | }; | |
| 2749 | ||
| 2750 | template <class _Rp, class _Class, class ..._Param> | |
| 2751 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> | |
| 2752 | { | |
| 2753 | typedef _Class _ClassType; | |
| 2754 | typedef _Rp _ReturnType; | |
| 2755 | typedef _Rp (_FnType) (_Param...); | |
| 2756 | }; | |
| 2757 | ||
| 2758 | template <class _Rp, class _Class, class ..._Param> | |
| 2759 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> | |
| 2760 | { | |
| 2761 | typedef _Class _ClassType; | |
| 2762 | typedef _Rp _ReturnType; | |
| 2763 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2764 | }; | |
| 2765 | ||
| 2766 | template <class _Rp, class _Class, class ..._Param> | |
| 2767 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> | |
| 2768 | { | |
| 2769 | typedef _Class const _ClassType; | |
| 2770 | typedef _Rp _ReturnType; | |
| 2771 | typedef _Rp (_FnType) (_Param...); | |
| 2772 | }; | |
| 2773 | ||
| 2774 | template <class _Rp, class _Class, class ..._Param> | |
| 2775 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> | |
| 2776 | { | |
| 2777 | typedef _Class const _ClassType; | |
| 2778 | typedef _Rp _ReturnType; | |
| 2779 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2780 | }; | |
| 2781 | ||
| 2782 | template <class _Rp, class _Class, class ..._Param> | |
| 2783 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> | |
| 2784 | { | |
| 2785 | typedef _Class volatile _ClassType; | |
| 2786 | typedef _Rp _ReturnType; | |
| 2787 | typedef _Rp (_FnType) (_Param...); | |
| 2788 | }; | |
| 2789 | ||
| 2790 | template <class _Rp, class _Class, class ..._Param> | |
| 2791 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> | |
| 2792 | { | |
| 2793 | typedef _Class volatile _ClassType; | |
| 2794 | typedef _Rp _ReturnType; | |
| 2795 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2796 | }; | |
| 2797 | ||
| 2798 | template <class _Rp, class _Class, class ..._Param> | |
| 2799 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> | |
| 2800 | { | |
| 2801 | typedef _Class const volatile _ClassType; | |
| 2802 | typedef _Rp _ReturnType; | |
| 2803 | typedef _Rp (_FnType) (_Param...); | |
| 2804 | }; | |
| 2805 | ||
| 2806 | template <class _Rp, class _Class, class ..._Param> | |
| 2807 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> | |
| 2808 | { | |
| 2809 | typedef _Class const volatile _ClassType; | |
| 2810 | typedef _Rp _ReturnType; | |
| 2811 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2812 | }; | |
| 2813 | ||
| 2814 | #if __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC) | |
| 2815 | ||
| 2816 | template <class _Rp, class _Class, class ..._Param> | |
| 2817 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &, true, false> | |
| 2818 | { | |
| 2819 | typedef _Class& _ClassType; | |
| 2820 | typedef _Rp _ReturnType; | |
| 2821 | typedef _Rp (_FnType) (_Param...); | |
| 2822 | }; | |
| 2823 | ||
| 2824 | template <class _Rp, class _Class, class ..._Param> | |
| 2825 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &, true, false> | |
| 2826 | { | |
| 2827 | typedef _Class& _ClassType; | |
| 2828 | typedef _Rp _ReturnType; | |
| 2829 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2830 | }; | |
| 2831 | ||
| 2832 | template <class _Rp, class _Class, class ..._Param> | |
| 2833 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> | |
| 2834 | { | |
| 2835 | typedef _Class const& _ClassType; | |
| 2836 | typedef _Rp _ReturnType; | |
| 2837 | typedef _Rp (_FnType) (_Param...); | |
| 2838 | }; | |
| 2839 | ||
| 2840 | template <class _Rp, class _Class, class ..._Param> | |
| 2841 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> | |
| 2842 | { | |
| 2843 | typedef _Class const& _ClassType; | |
| 2844 | typedef _Rp _ReturnType; | |
| 2845 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2846 | }; | |
| 2847 | ||
| 2848 | template <class _Rp, class _Class, class ..._Param> | |
| 2849 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> | |
| 2850 | { | |
| 2851 | typedef _Class volatile& _ClassType; | |
| 2852 | typedef _Rp _ReturnType; | |
| 2853 | typedef _Rp (_FnType) (_Param...); | |
| 2854 | }; | |
| 2855 | ||
| 2856 | template <class _Rp, class _Class, class ..._Param> | |
| 2857 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> | |
| 2858 | { | |
| 2859 | typedef _Class volatile& _ClassType; | |
| 2860 | typedef _Rp _ReturnType; | |
| 2861 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2862 | }; | |
| 2863 | ||
| 2864 | template <class _Rp, class _Class, class ..._Param> | |
| 2865 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> | |
| 2866 | { | |
| 2867 | typedef _Class const volatile& _ClassType; | |
| 2868 | typedef _Rp _ReturnType; | |
| 2869 | typedef _Rp (_FnType) (_Param...); | |
| 2870 | }; | |
| 2871 | ||
| 2872 | template <class _Rp, class _Class, class ..._Param> | |
| 2873 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> | |
| 2874 | { | |
| 2875 | typedef _Class const volatile& _ClassType; | |
| 2876 | typedef _Rp _ReturnType; | |
| 2877 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2878 | }; | |
| 2879 | ||
| 2880 | template <class _Rp, class _Class, class ..._Param> | |
| 2881 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) &&, true, false> | |
| 2882 | { | |
| 2883 | typedef _Class&& _ClassType; | |
| 2884 | typedef _Rp _ReturnType; | |
| 2885 | typedef _Rp (_FnType) (_Param...); | |
| 2886 | }; | |
| 2887 | ||
| 2888 | template <class _Rp, class _Class, class ..._Param> | |
| 2889 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) &&, true, false> | |
| 2890 | { | |
| 2891 | typedef _Class&& _ClassType; | |
| 2892 | typedef _Rp _ReturnType; | |
| 2893 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2894 | }; | |
| 2895 | ||
| 2896 | template <class _Rp, class _Class, class ..._Param> | |
| 2897 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> | |
| 2898 | { | |
| 2899 | typedef _Class const&& _ClassType; | |
| 2900 | typedef _Rp _ReturnType; | |
| 2901 | typedef _Rp (_FnType) (_Param...); | |
| 2902 | }; | |
| 2903 | ||
| 2904 | template <class _Rp, class _Class, class ..._Param> | |
| 2905 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> | |
| 2906 | { | |
| 2907 | typedef _Class const&& _ClassType; | |
| 2908 | typedef _Rp _ReturnType; | |
| 2909 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2910 | }; | |
| 2911 | ||
| 2912 | template <class _Rp, class _Class, class ..._Param> | |
| 2913 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> | |
| 2914 | { | |
| 2915 | typedef _Class volatile&& _ClassType; | |
| 2916 | typedef _Rp _ReturnType; | |
| 2917 | typedef _Rp (_FnType) (_Param...); | |
| 2918 | }; | |
| 2919 | ||
| 2920 | template <class _Rp, class _Class, class ..._Param> | |
| 2921 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> | |
| 2922 | { | |
| 2923 | typedef _Class volatile&& _ClassType; | |
| 2924 | typedef _Rp _ReturnType; | |
| 2925 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2926 | }; | |
| 2927 | ||
| 2928 | template <class _Rp, class _Class, class ..._Param> | |
| 2929 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> | |
| 2930 | { | |
| 2931 | typedef _Class const volatile&& _ClassType; | |
| 2932 | typedef _Rp _ReturnType; | |
| 2933 | typedef _Rp (_FnType) (_Param...); | |
| 2934 | }; | |
| 2935 | ||
| 2936 | template <class _Rp, class _Class, class ..._Param> | |
| 2937 | struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> | |
| 2938 | { | |
| 2939 | typedef _Class const volatile&& _ClassType; | |
| 2940 | typedef _Rp _ReturnType; | |
| 2941 | typedef _Rp (_FnType) (_Param..., ...); | |
| 2942 | }; | |
| 2943 | ||
| 2944 | #endif // __has_feature(cxx_reference_qualified_functions) || defined(_LIBCPP_COMPILER_GCC) | |
| 2945 | ||
| 2946 | ||
| 2947 | template <class _Rp, class _Class> | |
| 2948 | struct __member_pointer_traits_imp<_Rp _Class::*, false, true> | |
| 2949 | { | |
| 2950 | typedef _Class _ClassType; | |
| 2951 | typedef _Rp _ReturnType; | |
| 2952 | }; | |
| 2953 | ||
| 2954 | template <class _MP> | |
| 2955 | struct __member_pointer_traits | |
| 2956 | : public __member_pointer_traits_imp<typename remove_cv<_MP>::type, | |
| 2957 | is_member_function_pointer<_MP>::value, | |
| 2958 | is_member_object_pointer<_MP>::value> | |
| 2959 | { | |
| 2960 | // typedef ... _ClassType; | |
| 2961 | // typedef ... _ReturnType; | |
| 2962 | // typedef ... _FnType; | |
| 2963 | }; | |
| 2964 | ||
| 2965 | ||
| 2966 | template <class _DecayedFp> | |
| 2967 | struct __member_pointer_class_type {}; | |
| 2968 | ||
| 2969 | template <class _Ret, class _ClassType> | |
| 2970 | struct __member_pointer_class_type<_Ret _ClassType::*> { | |
| 2971 | typedef _ClassType type; | |
| 2972 | }; | |
| 2973 | ||
| 2974 | // template <class T, class... Args> struct is_constructible; | |
| 2975 | ||
| 2976 | template <class _Tp, class ..._Args> | |
| 2977 | struct _LIBCPP_TEMPLATE_VIS is_constructible | |
| 2978 | : public integral_constant<bool, __is_constructible(_Tp, _Args...)> | |
| 2979 | { }; | |
| 2980 | ||
| 2981 | #if _LIBCPP_STD_VER > 14 | |
| 2982 | template <class _Tp, class ..._Args> | |
| 2983 | inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; | |
| 2984 | #endif | |
| 2985 | ||
| 2986 | // is_default_constructible | |
| 2987 | ||
| 2988 | template <class _Tp> | |
| 2989 | struct _LIBCPP_TEMPLATE_VIS is_default_constructible | |
| 2990 | : public is_constructible<_Tp> | |
| 2991 | {}; | |
| 2992 | ||
| 2993 | #if _LIBCPP_STD_VER > 14 | |
| 2994 | template <class _Tp> | |
| 2995 | inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; | |
| 2996 | #endif | |
| 2997 | ||
| 2998 | #ifndef _LIBCPP_CXX03_LANG | |
| 2999 | // First of all, we can't implement this check in C++03 mode because the {} | |
| 3000 | // default initialization syntax isn't valid. | |
| 3001 | // Second, we implement the trait in a funny manner with two defaulted template | |
| 3002 | // arguments to workaround Clang's PR43454. | |
| 3003 | template <class _Tp> | |
| 3004 | void __test_implicit_default_constructible(_Tp); | |
| 3005 | ||
| 3006 | template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type> | |
| 3007 | struct __is_implicitly_default_constructible | |
| 3008 | : false_type | |
| 3009 | { }; | |
| 3010 | ||
| 3011 | template <class _Tp> | |
| 3012 | struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type> | |
| 3013 | : true_type | |
| 3014 | { }; | |
| 3015 | ||
| 3016 | template <class _Tp> | |
| 3017 | struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type> | |
| 3018 | : false_type | |
| 3019 | { }; | |
| 3020 | #endif // !C++03 | |
| 3021 | ||
| 3022 | // is_copy_constructible | |
| 3023 | ||
| 3024 | template <class _Tp> | |
| 3025 | struct _LIBCPP_TEMPLATE_VIS is_copy_constructible | |
| 3026 | : public is_constructible<_Tp, | |
| 3027 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 3028 | ||
| 3029 | #if _LIBCPP_STD_VER > 14 | |
| 3030 | template <class _Tp> | |
| 3031 | inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value; | |
| 3032 | #endif | |
| 3033 | ||
| 3034 | // is_move_constructible | |
| 3035 | ||
| 3036 | template <class _Tp> | |
| 3037 | struct _LIBCPP_TEMPLATE_VIS is_move_constructible | |
| 3038 | : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> | |
| 3039 | {}; | |
| 3040 | ||
| 3041 | #if _LIBCPP_STD_VER > 14 | |
| 3042 | template <class _Tp> | |
| 3043 | inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value; | |
| 3044 | #endif | |
| 3045 | ||
| 3046 | // is_trivially_constructible | |
| 3047 | ||
| 3048 | template <class _Tp, class... _Args> | |
| 3049 | struct _LIBCPP_TEMPLATE_VIS is_trivially_constructible | |
| 3050 | : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> | |
| 3051 | { | |
| 3052 | }; | |
| 3053 | ||
| 3054 | #if _LIBCPP_STD_VER > 14 | |
| 3055 | template <class _Tp, class... _Args> | |
| 3056 | inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; | |
| 3057 | #endif | |
| 3058 | ||
| 3059 | // is_trivially_default_constructible | |
| 3060 | ||
| 3061 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible | |
| 3062 | : public is_trivially_constructible<_Tp> | |
| 3063 | {}; | |
| 3064 | ||
| 3065 | #if _LIBCPP_STD_VER > 14 | |
| 3066 | template <class _Tp> | |
| 3067 | inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; | |
| 3068 | #endif | |
| 3069 | ||
| 3070 | // is_trivially_copy_constructible | |
| 3071 | ||
| 3072 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible | |
| 3073 | : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> | |
| 3074 | {}; | |
| 3075 | ||
| 3076 | #if _LIBCPP_STD_VER > 14 | |
| 3077 | template <class _Tp> | |
| 3078 | inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value; | |
| 3079 | #endif | |
| 3080 | ||
| 3081 | // is_trivially_move_constructible | |
| 3082 | ||
| 3083 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible | |
| 3084 | : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> | |
| 3085 | {}; | |
| 3086 | ||
| 3087 | #if _LIBCPP_STD_VER > 14 | |
| 3088 | template <class _Tp> | |
| 3089 | inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value; | |
| 3090 | #endif | |
| 3091 | ||
| 3092 | // is_trivially_assignable | |
| 3093 | ||
| 3094 | template <class _Tp, class _Arg> | |
| 3095 | struct is_trivially_assignable | |
| 3096 | : integral_constant<bool, __is_trivially_assignable(_Tp, _Arg)> | |
| 3097 | { }; | |
| 3098 | ||
| 3099 | #if _LIBCPP_STD_VER > 14 | |
| 3100 | template <class _Tp, class _Arg> | |
| 3101 | inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value; | |
| 3102 | #endif | |
| 3103 | ||
| 3104 | // is_trivially_copy_assignable | |
| 3105 | ||
| 3106 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable | |
| 3107 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 3108 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 3109 | ||
| 3110 | #if _LIBCPP_STD_VER > 14 | |
| 3111 | template <class _Tp> | |
| 3112 | inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value; | |
| 3113 | #endif | |
| 3114 | ||
| 3115 | // is_trivially_move_assignable | |
| 3116 | ||
| 3117 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable | |
| 3118 | : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 3119 | typename add_rvalue_reference<_Tp>::type> | |
| 3120 | {}; | |
| 3121 | ||
| 3122 | #if _LIBCPP_STD_VER > 14 | |
| 3123 | template <class _Tp> | |
| 3124 | inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value; | |
| 3125 | #endif | |
| 3126 | ||
| 3127 | // is_trivially_destructible | |
| 3128 | ||
| 3129 | #if __has_keyword(__is_trivially_destructible) | |
| 3130 | ||
| 3131 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 3132 | : public integral_constant<bool, __is_trivially_destructible(_Tp)> {}; | |
| 3133 | ||
| 3134 | #elif __has_feature(has_trivial_destructor) || defined(_LIBCPP_COMPILER_GCC) | |
| 3135 | ||
| 3136 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 3137 | : public integral_constant<bool, is_destructible<_Tp>::value && __has_trivial_destructor(_Tp)> {}; | |
| 3138 | ||
| 3139 | #else | |
| 3140 | ||
| 3141 | template <class _Tp> struct __libcpp_trivial_destructor | |
| 3142 | : public integral_constant<bool, is_scalar<_Tp>::value || | |
| 3143 | is_reference<_Tp>::value> {}; | |
| 3144 | ||
| 3145 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible | |
| 3146 | : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; | |
| 3147 | ||
| 3148 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> | |
| 3149 | : public false_type {}; | |
| 3150 | ||
| 3151 | #endif | |
| 3152 | ||
| 3153 | #if _LIBCPP_STD_VER > 14 | |
| 3154 | template <class _Tp> | |
| 3155 | inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<_Tp>::value; | |
| 3156 | #endif | |
| 3157 | ||
| 3158 | // is_nothrow_constructible | |
| 3159 | ||
| 3160 | #if __has_keyword(__is_nothrow_constructible) | |
| 3161 | ||
| 3162 | template <class _Tp, class... _Args> | |
| 3163 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | |
| 3164 | : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {}; | |
| 3165 | ||
| 3166 | #else | |
| 3167 | ||
| 3168 | template <bool, bool, class _Tp, class... _Args> struct __libcpp_is_nothrow_constructible; | |
| 3169 | ||
| 3170 | template <class _Tp, class... _Args> | |
| 3171 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/false, _Tp, _Args...> | |
| 3172 | : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> | |
| 3173 | { | |
| 3174 | }; | |
| 3175 | ||
| 3176 | template <class _Tp> | |
| 3177 | void __implicit_conversion_to(_Tp) noexcept { } | |
| 3178 | ||
| 3179 | template <class _Tp, class _Arg> | |
| 3180 | struct __libcpp_is_nothrow_constructible</*is constructible*/true, /*is reference*/true, _Tp, _Arg> | |
| 3181 | : public integral_constant<bool, noexcept(_VSTD::__implicit_conversion_to<_Tp>(declval<_Arg>()))> | |
| 3182 | { | |
| 3183 | }; | |
| 3184 | ||
| 3185 | template <class _Tp, bool _IsReference, class... _Args> | |
| 3186 | struct __libcpp_is_nothrow_constructible</*is constructible*/false, _IsReference, _Tp, _Args...> | |
| 3187 | : public false_type | |
| 3188 | { | |
| 3189 | }; | |
| 3190 | ||
| 3191 | template <class _Tp, class... _Args> | |
| 3192 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible | |
| 3193 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...> | |
| 3194 | { | |
| 3195 | }; | |
| 3196 | ||
| 3197 | template <class _Tp, size_t _Ns> | |
| 3198 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]> | |
| 3199 | : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> | |
| 3200 | { | |
| 3201 | }; | |
| 3202 | ||
| 3203 | #endif // _LIBCPP_HAS_NO_NOEXCEPT | |
| 3204 | ||
| 3205 | ||
| 3206 | #if _LIBCPP_STD_VER > 14 | |
| 3207 | template <class _Tp, class ..._Args> | |
| 3208 | inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value; | |
| 3209 | #endif | |
| 3210 | ||
| 3211 | // is_nothrow_default_constructible | |
| 3212 | ||
| 3213 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible | |
| 3214 | : public is_nothrow_constructible<_Tp> | |
| 3215 | {}; | |
| 3216 | ||
| 3217 | #if _LIBCPP_STD_VER > 14 | |
| 3218 | template <class _Tp> | |
| 3219 | inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; | |
| 3220 | #endif | |
| 3221 | ||
| 3222 | // is_nothrow_copy_constructible | |
| 3223 | ||
| 3224 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible | |
| 3225 | : public is_nothrow_constructible<_Tp, | |
| 3226 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 3227 | ||
| 3228 | #if _LIBCPP_STD_VER > 14 | |
| 3229 | template <class _Tp> | |
| 3230 | inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; | |
| 3231 | #endif | |
| 3232 | ||
| 3233 | // is_nothrow_move_constructible | |
| 3234 | ||
| 3235 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible | |
| 3236 | : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> | |
| 3237 | {}; | |
| 3238 | ||
| 3239 | #if _LIBCPP_STD_VER > 14 | |
| 3240 | template <class _Tp> | |
| 3241 | inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; | |
| 3242 | #endif | |
| 3243 | ||
| 3244 | // is_nothrow_assignable | |
| 3245 | ||
| 3246 | #if __has_keyword(__is_nothrow_assignable) | |
| 3247 | ||
| 3248 | template <class _Tp, class _Arg> | |
| 3249 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable | |
| 3250 | : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {}; | |
| 3251 | ||
| 3252 | #else | |
| 3253 | ||
| 3254 | template <bool, class _Tp, class _Arg> struct __libcpp_is_nothrow_assignable; | |
| 3255 | ||
| 3256 | template <class _Tp, class _Arg> | |
| 3257 | struct __libcpp_is_nothrow_assignable<false, _Tp, _Arg> | |
| 3258 | : public false_type | |
| 3259 | { | |
| 3260 | }; | |
| 3261 | ||
| 3262 | template <class _Tp, class _Arg> | |
| 3263 | struct __libcpp_is_nothrow_assignable<true, _Tp, _Arg> | |
| 3264 | : public integral_constant<bool, noexcept(declval<_Tp>() = declval<_Arg>()) > | |
| 3265 | { | |
| 3266 | }; | |
| 3267 | ||
| 3268 | template <class _Tp, class _Arg> | |
| 3269 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable | |
| 3270 | : public __libcpp_is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> | |
| 3271 | { | |
| 3272 | }; | |
| 3273 | ||
| 3274 | #endif // _LIBCPP_HAS_NO_NOEXCEPT | |
| 3275 | ||
| 3276 | #if _LIBCPP_STD_VER > 14 | |
| 3277 | template <class _Tp, class _Arg> | |
| 3278 | inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value; | |
| 3279 | #endif | |
| 3280 | ||
| 3281 | // is_nothrow_copy_assignable | |
| 3282 | ||
| 3283 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable | |
| 3284 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 3285 | typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; | |
| 3286 | ||
| 3287 | #if _LIBCPP_STD_VER > 14 | |
| 3288 | template <class _Tp> | |
| 3289 | inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value; | |
| 3290 | #endif | |
| 3291 | ||
| 3292 | // is_nothrow_move_assignable | |
| 3293 | ||
| 3294 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable | |
| 3295 | : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, | |
| 3296 | typename add_rvalue_reference<_Tp>::type> | |
| 3297 | {}; | |
| 3298 | ||
| 3299 | #if _LIBCPP_STD_VER > 14 | |
| 3300 | template <class _Tp> | |
| 3301 | inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value; | |
| 3302 | #endif | |
| 3303 | ||
| 3304 | // is_nothrow_destructible | |
| 3305 | ||
| 3306 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 3307 | ||
| 3308 | template <bool, class _Tp> struct __libcpp_is_nothrow_destructible; | |
| 3309 | ||
| 3310 | template <class _Tp> | |
| 3311 | struct __libcpp_is_nothrow_destructible<false, _Tp> | |
| 3312 | : public false_type | |
| 3313 | { | |
| 3314 | }; | |
| 3315 | ||
| 3316 | template <class _Tp> | |
| 3317 | struct __libcpp_is_nothrow_destructible<true, _Tp> | |
| 3318 | : public integral_constant<bool, noexcept(declval<_Tp>().~_Tp()) > | |
| 3319 | { | |
| 3320 | }; | |
| 3321 | ||
| 3322 | template <class _Tp> | |
| 3323 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible | |
| 3324 | : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> | |
| 3325 | { | |
| 3326 | }; | |
| 539 | // Member detector base | |
| 3327 | 540 | |
| 3328 | template <class _Tp, size_t _Ns> | |
| 3329 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> | |
| 3330 | : public is_nothrow_destructible<_Tp> | |
| 3331 | { | |
| 3332 | }; | |
| 541 | template <class _Tp, bool> | |
| 542 | struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; | |
| 3333 | 543 | |
| 3334 | template <class _Tp> | |
| 3335 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> | |
| 3336 | : public true_type | |
| 3337 | { | |
| 3338 | }; | |
| 544 | // is_integral | |
| 3339 | 545 | |
| 3340 | 546 | template <class _Tp> |
| 3341 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> | |
| 3342 | : public true_type | |
| 3343 | { | |
| 547 | struct __unconstref { | |
| 548 | typedef _LIBCPP_NODEBUG typename remove_const<typename remove_reference<_Tp>::type>::type type; | |
| 3344 | 549 | }; |
| 3345 | 550 | |
| 3346 | #else | |
| 3347 | ||
| 3348 | template <class _Tp> struct __libcpp_nothrow_destructor | |
| 3349 | : public integral_constant<bool, is_scalar<_Tp>::value || | |
| 3350 | is_reference<_Tp>::value> {}; | |
| 3351 | ||
| 3352 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible | |
| 3353 | : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; | |
| 3354 | ||
| 3355 | template <class _Tp> | |
| 3356 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> | |
| 3357 | : public false_type {}; | |
| 3358 | ||
| 3359 | #endif | |
| 3360 | ||
| 3361 | #if _LIBCPP_STD_VER > 14 | |
| 3362 | template <class _Tp> | |
| 3363 | inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<_Tp>::value; | |
| 3364 | #endif | |
| 3365 | ||
| 3366 | // is_pod | |
| 3367 | ||
| 3368 | #if __has_feature(is_pod) || defined(_LIBCPP_COMPILER_GCC) | |
| 3369 | ||
| 3370 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod | |
| 3371 | : public integral_constant<bool, __is_pod(_Tp)> {}; | |
| 3372 | ||
| 3373 | #else | |
| 3374 | ||
| 3375 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pod | |
| 3376 | : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && | |
| 3377 | is_trivially_copy_constructible<_Tp>::value && | |
| 3378 | is_trivially_copy_assignable<_Tp>::value && | |
| 3379 | is_trivially_destructible<_Tp>::value> {}; | |
| 3380 | ||
| 3381 | #endif | |
| 3382 | ||
| 3383 | #if _LIBCPP_STD_VER > 14 | |
| 3384 | template <class _Tp> | |
| 3385 | inline constexpr bool is_pod_v = is_pod<_Tp>::value; | |
| 3386 | #endif | |
| 3387 | ||
| 3388 | // is_literal_type; | |
| 3389 | ||
| 3390 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) | |
| 3391 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type | |
| 3392 | : public integral_constant<bool, __is_literal_type(_Tp)> | |
| 3393 | {}; | |
| 3394 | ||
| 3395 | #if _LIBCPP_STD_VER > 14 | |
| 3396 | template <class _Tp> | |
| 3397 | _LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; | |
| 3398 | #endif // _LIBCPP_STD_VER > 14 | |
| 3399 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) | |
| 3400 | ||
| 3401 | // is_standard_layout; | |
| 3402 | ||
| 3403 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_standard_layout | |
| 3404 | #if __has_feature(is_standard_layout) || defined(_LIBCPP_COMPILER_GCC) | |
| 3405 | : public integral_constant<bool, __is_standard_layout(_Tp)> | |
| 3406 | #else | |
| 3407 | : integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value> | |
| 3408 | #endif | |
| 3409 | {}; | |
| 3410 | ||
| 3411 | #if _LIBCPP_STD_VER > 14 | |
| 551 | #ifndef _LIBCPP_CXX03_LANG | |
| 552 | // First of all, we can't implement this check in C++03 mode because the {} | |
| 553 | // default initialization syntax isn't valid. | |
| 554 | // Second, we implement the trait in a funny manner with two defaulted template | |
| 555 | // arguments to workaround Clang's PR43454. | |
| 3412 | 556 | template <class _Tp> |
| 3413 | inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; | |
| 3414 | #endif | |
| 3415 | ||
| 3416 | // is_trivially_copyable; | |
| 557 | void __test_implicit_default_constructible(_Tp); | |
| 3417 | 558 | |
| 3418 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivially_copyable | |
| 3419 | : public integral_constant<bool, __is_trivially_copyable(_Tp)> | |
| 3420 | {}; | |
| 559 | template <class _Tp, class = void, class = typename is_default_constructible<_Tp>::type> | |
| 560 | struct __is_implicitly_default_constructible | |
| 561 | : false_type | |
| 562 | { }; | |
| 3421 | 563 | |
| 3422 | #if _LIBCPP_STD_VER > 14 | |
| 3423 | 564 | template <class _Tp> |
| 3424 | inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; | |
| 3425 | #endif | |
| 3426 | ||
| 3427 | // is_trivial; | |
| 3428 | ||
| 3429 | template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_trivial | |
| 3430 | #if __has_feature(is_trivial) || defined(_LIBCPP_COMPILER_GCC) | |
| 3431 | : public integral_constant<bool, __is_trivial(_Tp)> | |
| 3432 | #else | |
| 3433 | : integral_constant<bool, is_trivially_copyable<_Tp>::value && | |
| 3434 | is_trivially_default_constructible<_Tp>::value> | |
| 3435 | #endif | |
| 3436 | {}; | |
| 565 | struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), true_type> | |
| 566 | : true_type | |
| 567 | { }; | |
| 3437 | 568 | |
| 3438 | #if _LIBCPP_STD_VER > 14 | |
| 3439 | 569 | template <class _Tp> |
| 3440 | inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; | |
| 3441 | #endif | |
| 3442 | ||
| 3443 | template <class _Tp> struct __is_reference_wrapper_impl : public false_type {}; | |
| 3444 | template <class _Tp> struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {}; | |
| 3445 | template <class _Tp> struct __is_reference_wrapper | |
| 3446 | : public __is_reference_wrapper_impl<typename remove_cv<_Tp>::type> {}; | |
| 3447 | ||
| 3448 | #ifndef _LIBCPP_CXX03_LANG | |
| 3449 | ||
| 3450 | template <class _Fp, class _A0, | |
| 3451 | class _DecayFp = typename decay<_Fp>::type, | |
| 3452 | class _DecayA0 = typename decay<_A0>::type, | |
| 3453 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 3454 | using __enable_if_bullet1 = typename enable_if | |
| 3455 | < | |
| 3456 | is_member_function_pointer<_DecayFp>::value | |
| 3457 | && is_base_of<_ClassT, _DecayA0>::value | |
| 3458 | >::type; | |
| 3459 | ||
| 3460 | template <class _Fp, class _A0, | |
| 3461 | class _DecayFp = typename decay<_Fp>::type, | |
| 3462 | class _DecayA0 = typename decay<_A0>::type> | |
| 3463 | using __enable_if_bullet2 = typename enable_if | |
| 3464 | < | |
| 3465 | is_member_function_pointer<_DecayFp>::value | |
| 3466 | && __is_reference_wrapper<_DecayA0>::value | |
| 3467 | >::type; | |
| 3468 | ||
| 3469 | template <class _Fp, class _A0, | |
| 3470 | class _DecayFp = typename decay<_Fp>::type, | |
| 3471 | class _DecayA0 = typename decay<_A0>::type, | |
| 3472 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 3473 | using __enable_if_bullet3 = typename enable_if | |
| 3474 | < | |
| 3475 | is_member_function_pointer<_DecayFp>::value | |
| 3476 | && !is_base_of<_ClassT, _DecayA0>::value | |
| 3477 | && !__is_reference_wrapper<_DecayA0>::value | |
| 3478 | >::type; | |
| 3479 | ||
| 3480 | template <class _Fp, class _A0, | |
| 3481 | class _DecayFp = typename decay<_Fp>::type, | |
| 3482 | class _DecayA0 = typename decay<_A0>::type, | |
| 3483 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 3484 | using __enable_if_bullet4 = typename enable_if | |
| 3485 | < | |
| 3486 | is_member_object_pointer<_DecayFp>::value | |
| 3487 | && is_base_of<_ClassT, _DecayA0>::value | |
| 3488 | >::type; | |
| 3489 | ||
| 3490 | template <class _Fp, class _A0, | |
| 3491 | class _DecayFp = typename decay<_Fp>::type, | |
| 3492 | class _DecayA0 = typename decay<_A0>::type> | |
| 3493 | using __enable_if_bullet5 = typename enable_if | |
| 3494 | < | |
| 3495 | is_member_object_pointer<_DecayFp>::value | |
| 3496 | && __is_reference_wrapper<_DecayA0>::value | |
| 3497 | >::type; | |
| 3498 | ||
| 3499 | template <class _Fp, class _A0, | |
| 3500 | class _DecayFp = typename decay<_Fp>::type, | |
| 3501 | class _DecayA0 = typename decay<_A0>::type, | |
| 3502 | class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> | |
| 3503 | using __enable_if_bullet6 = typename enable_if | |
| 3504 | < | |
| 3505 | is_member_object_pointer<_DecayFp>::value | |
| 3506 | && !is_base_of<_ClassT, _DecayA0>::value | |
| 3507 | && !__is_reference_wrapper<_DecayA0>::value | |
| 3508 | >::type; | |
| 3509 | ||
| 3510 | // __invoke forward declarations | |
| 3511 | ||
| 3512 | // fall back - none of the bullets | |
| 3513 | ||
| 3514 | template <class ..._Args> | |
| 3515 | auto __invoke(__any, _Args&& ...__args) -> __nat; | |
| 3516 | ||
| 3517 | template <class ..._Args> | |
| 3518 | auto __invoke_constexpr(__any, _Args&& ...__args) -> __nat; | |
| 3519 | ||
| 3520 | // bullets 1, 2 and 3 | |
| 3521 | ||
| 3522 | template <class _Fp, class _A0, class ..._Args, | |
| 3523 | class = __enable_if_bullet1<_Fp, _A0>> | |
| 3524 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3525 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3526 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 3527 | noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))) | |
| 3528 | -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)) | |
| 3529 | { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); } | |
| 3530 | ||
| 3531 | template <class _Fp, class _A0, class ..._Args, | |
| 3532 | class = __enable_if_bullet1<_Fp, _A0>> | |
| 3533 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3534 | _LIBCPP_CONSTEXPR auto | |
| 3535 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 3536 | noexcept(noexcept((static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...))) | |
| 3537 | -> decltype( (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...)) | |
| 3538 | { return (static_cast<_A0&&>(__a0).*__f)(static_cast<_Args&&>(__args)...); } | |
| 3539 | ||
| 3540 | template <class _Fp, class _A0, class ..._Args, | |
| 3541 | class = __enable_if_bullet2<_Fp, _A0>> | |
| 3542 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3543 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3544 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 3545 | noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...))) | |
| 3546 | -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...)) | |
| 3547 | { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); } | |
| 3548 | ||
| 3549 | template <class _Fp, class _A0, class ..._Args, | |
| 3550 | class = __enable_if_bullet2<_Fp, _A0>> | |
| 3551 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3552 | _LIBCPP_CONSTEXPR auto | |
| 3553 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 3554 | noexcept(noexcept((__a0.get().*__f)(static_cast<_Args&&>(__args)...))) | |
| 3555 | -> decltype( (__a0.get().*__f)(static_cast<_Args&&>(__args)...)) | |
| 3556 | { return (__a0.get().*__f)(static_cast<_Args&&>(__args)...); } | |
| 3557 | ||
| 3558 | template <class _Fp, class _A0, class ..._Args, | |
| 3559 | class = __enable_if_bullet3<_Fp, _A0>> | |
| 3560 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3561 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3562 | __invoke(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 3563 | noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))) | |
| 3564 | -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)) | |
| 3565 | { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); } | |
| 3566 | ||
| 3567 | template <class _Fp, class _A0, class ..._Args, | |
| 3568 | class = __enable_if_bullet3<_Fp, _A0>> | |
| 3569 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3570 | _LIBCPP_CONSTEXPR auto | |
| 3571 | __invoke_constexpr(_Fp&& __f, _A0&& __a0, _Args&& ...__args) | |
| 3572 | noexcept(noexcept(((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...))) | |
| 3573 | -> decltype( ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...)) | |
| 3574 | { return ((*static_cast<_A0&&>(__a0)).*__f)(static_cast<_Args&&>(__args)...); } | |
| 3575 | ||
| 3576 | // bullets 4, 5 and 6 | |
| 3577 | ||
| 3578 | template <class _Fp, class _A0, | |
| 3579 | class = __enable_if_bullet4<_Fp, _A0>> | |
| 3580 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3581 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3582 | __invoke(_Fp&& __f, _A0&& __a0) | |
| 3583 | noexcept(noexcept(static_cast<_A0&&>(__a0).*__f)) | |
| 3584 | -> decltype( static_cast<_A0&&>(__a0).*__f) | |
| 3585 | { return static_cast<_A0&&>(__a0).*__f; } | |
| 3586 | ||
| 3587 | template <class _Fp, class _A0, | |
| 3588 | class = __enable_if_bullet4<_Fp, _A0>> | |
| 3589 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3590 | _LIBCPP_CONSTEXPR auto | |
| 3591 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) | |
| 3592 | noexcept(noexcept(static_cast<_A0&&>(__a0).*__f)) | |
| 3593 | -> decltype( static_cast<_A0&&>(__a0).*__f) | |
| 3594 | { return static_cast<_A0&&>(__a0).*__f; } | |
| 3595 | ||
| 3596 | template <class _Fp, class _A0, | |
| 3597 | class = __enable_if_bullet5<_Fp, _A0>> | |
| 3598 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3599 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3600 | __invoke(_Fp&& __f, _A0&& __a0) | |
| 3601 | noexcept(noexcept(__a0.get().*__f)) | |
| 3602 | -> decltype( __a0.get().*__f) | |
| 3603 | { return __a0.get().*__f; } | |
| 3604 | ||
| 3605 | template <class _Fp, class _A0, | |
| 3606 | class = __enable_if_bullet5<_Fp, _A0>> | |
| 3607 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3608 | _LIBCPP_CONSTEXPR auto | |
| 3609 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) | |
| 3610 | noexcept(noexcept(__a0.get().*__f)) | |
| 3611 | -> decltype( __a0.get().*__f) | |
| 3612 | { return __a0.get().*__f; } | |
| 3613 | ||
| 3614 | template <class _Fp, class _A0, | |
| 3615 | class = __enable_if_bullet6<_Fp, _A0>> | |
| 3616 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3617 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3618 | __invoke(_Fp&& __f, _A0&& __a0) | |
| 3619 | noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f)) | |
| 3620 | -> decltype( (*static_cast<_A0&&>(__a0)).*__f) | |
| 3621 | { return (*static_cast<_A0&&>(__a0)).*__f; } | |
| 3622 | ||
| 3623 | template <class _Fp, class _A0, | |
| 3624 | class = __enable_if_bullet6<_Fp, _A0>> | |
| 3625 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3626 | _LIBCPP_CONSTEXPR auto | |
| 3627 | __invoke_constexpr(_Fp&& __f, _A0&& __a0) | |
| 3628 | noexcept(noexcept((*static_cast<_A0&&>(__a0)).*__f)) | |
| 3629 | -> decltype( (*static_cast<_A0&&>(__a0)).*__f) | |
| 3630 | { return (*static_cast<_A0&&>(__a0)).*__f; } | |
| 3631 | ||
| 3632 | // bullet 7 | |
| 3633 | ||
| 3634 | template <class _Fp, class ..._Args> | |
| 3635 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3636 | _LIBCPP_CONSTEXPR_AFTER_CXX17 auto | |
| 3637 | __invoke(_Fp&& __f, _Args&& ...__args) | |
| 3638 | noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))) | |
| 3639 | -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)) | |
| 3640 | { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); } | |
| 3641 | ||
| 3642 | template <class _Fp, class ..._Args> | |
| 3643 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3644 | _LIBCPP_CONSTEXPR auto | |
| 3645 | __invoke_constexpr(_Fp&& __f, _Args&& ...__args) | |
| 3646 | noexcept(noexcept(static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...))) | |
| 3647 | -> decltype( static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...)) | |
| 3648 | { return static_cast<_Fp&&>(__f)(static_cast<_Args&&>(__args)...); } | |
| 3649 | ||
| 3650 | // __invokable | |
| 3651 | template <class _Ret, class _Fp, class ..._Args> | |
| 3652 | struct __invokable_r | |
| 3653 | { | |
| 3654 | template <class _XFp, class ..._XArgs> | |
| 3655 | static auto __try_call(int) -> decltype( | |
| 3656 | _VSTD::__invoke(declval<_XFp>(), declval<_XArgs>()...)); | |
| 3657 | template <class _XFp, class ..._XArgs> | |
| 3658 | static __nat __try_call(...); | |
| 3659 | ||
| 3660 | // FIXME: Check that _Ret, _Fp, and _Args... are all complete types, cv void, | |
| 3661 | // or incomplete array types as required by the standard. | |
| 3662 | using _Result = decltype(__try_call<_Fp, _Args...>(0)); | |
| 3663 | ||
| 3664 | using type = | |
| 3665 | typename conditional< | |
| 3666 | _IsNotSame<_Result, __nat>::value, | |
| 3667 | typename conditional< | |
| 3668 | is_void<_Ret>::value, | |
| 3669 | true_type, | |
| 3670 | is_convertible<_Result, _Ret> | |
| 3671 | >::type, | |
| 3672 | false_type | |
| 3673 | >::type; | |
| 3674 | static const bool value = type::value; | |
| 3675 | }; | |
| 3676 | template <class _Fp, class ..._Args> | |
| 3677 | using __invokable = __invokable_r<void, _Fp, _Args...>; | |
| 3678 | ||
| 3679 | template <bool _IsInvokable, bool _IsCVVoid, class _Ret, class _Fp, class ..._Args> | |
| 3680 | struct __nothrow_invokable_r_imp { | |
| 3681 | static const bool value = false; | |
| 3682 | }; | |
| 3683 | ||
| 3684 | template <class _Ret, class _Fp, class ..._Args> | |
| 3685 | struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> | |
| 3686 | { | |
| 3687 | typedef __nothrow_invokable_r_imp _ThisT; | |
| 3688 | ||
| 3689 | template <class _Tp> | |
| 3690 | static void __test_noexcept(_Tp) noexcept; | |
| 3691 | ||
| 3692 | static const bool value = noexcept(_ThisT::__test_noexcept<_Ret>( | |
| 3693 | _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...))); | |
| 3694 | }; | |
| 3695 | ||
| 3696 | template <class _Ret, class _Fp, class ..._Args> | |
| 3697 | struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> | |
| 3698 | { | |
| 3699 | static const bool value = noexcept( | |
| 3700 | _VSTD::__invoke(declval<_Fp>(), declval<_Args>()...)); | |
| 3701 | }; | |
| 3702 | ||
| 3703 | template <class _Ret, class _Fp, class ..._Args> | |
| 3704 | using __nothrow_invokable_r = | |
| 3705 | __nothrow_invokable_r_imp< | |
| 3706 | __invokable_r<_Ret, _Fp, _Args...>::value, | |
| 3707 | is_void<_Ret>::value, | |
| 3708 | _Ret, _Fp, _Args... | |
| 3709 | >; | |
| 3710 | ||
| 3711 | template <class _Fp, class ..._Args> | |
| 3712 | using __nothrow_invokable = | |
| 3713 | __nothrow_invokable_r_imp< | |
| 3714 | __invokable<_Fp, _Args...>::value, | |
| 3715 | true, void, _Fp, _Args... | |
| 3716 | >; | |
| 3717 | ||
| 3718 | template <class _Fp, class ..._Args> | |
| 3719 | struct __invoke_of | |
| 3720 | : public enable_if< | |
| 3721 | __invokable<_Fp, _Args...>::value, | |
| 3722 | typename __invokable_r<void, _Fp, _Args...>::_Result> | |
| 3723 | { | |
| 3724 | }; | |
| 3725 | ||
| 3726 | #endif // _LIBCPP_CXX03_LANG | |
| 570 | struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_default_constructible<_Tp const&>({})), false_type> | |
| 571 | : false_type | |
| 572 | { }; | |
| 573 | #endif // !C++03 | |
| 3727 | 574 | |
| 3728 | 575 | // result_of |
| 3729 | 576 | |
| 3730 | 577 | #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 3731 | 578 | template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of; |
| 3732 | 579 | |
| 3733 | #ifndef _LIBCPP_CXX03_LANG | |
| 3734 | ||
| 3735 | 580 | template <class _Fp, class ..._Args> |
| 3736 | 581 | class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> |
| 3737 | 582 | : public __invoke_of<_Fp, _Args...> |
| 3738 | 583 | { |
| 3739 | 584 | }; |
| 3740 | 585 | |
| 3741 | #else // C++03 | |
| 3742 | ||
| 3743 | template <class _Fn, bool, bool> | |
| 3744 | class __result_of | |
| 3745 | { | |
| 3746 | }; | |
| 3747 | ||
| 3748 | template <class _Fn, class ..._Args> | |
| 3749 | class __result_of<_Fn(_Args...), true, false> | |
| 3750 | { | |
| 3751 | public: | |
| 3752 | typedef decltype(declval<_Fn>()(declval<_Args>()...)) type; | |
| 3753 | }; | |
| 3754 | ||
| 3755 | template <class _MP, class _Tp, bool _IsMemberFunctionPtr> | |
| 3756 | struct __result_of_mp; | |
| 3757 | ||
| 3758 | // member function pointer | |
| 3759 | ||
| 3760 | template <class _MP, class _Tp> | |
| 3761 | struct __result_of_mp<_MP, _Tp, true> | |
| 3762 | { | |
| 3763 | using type = typename __member_pointer_traits<_MP>::_ReturnType; | |
| 3764 | }; | |
| 3765 | ||
| 3766 | // member data pointer | |
| 3767 | ||
| 3768 | template <class _MP, class _Tp, bool> | |
| 3769 | struct __result_of_mdp; | |
| 3770 | ||
| 3771 | template <class _Rp, class _Class, class _Tp> | |
| 3772 | struct __result_of_mdp<_Rp _Class::*, _Tp, false> | |
| 3773 | { | |
| 3774 | using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&; | |
| 3775 | }; | |
| 3776 | ||
| 3777 | template <class _Rp, class _Class, class _Tp> | |
| 3778 | struct __result_of_mdp<_Rp _Class::*, _Tp, true> | |
| 3779 | { | |
| 3780 | using type = typename __apply_cv<_Tp, _Rp>::type&; | |
| 3781 | }; | |
| 3782 | ||
| 3783 | template <class _Rp, class _Class, class _Tp> | |
| 3784 | struct __result_of_mp<_Rp _Class::*, _Tp, false> | |
| 3785 | : public __result_of_mdp<_Rp _Class::*, _Tp, | |
| 3786 | is_base_of<_Class, typename remove_reference<_Tp>::type>::value> | |
| 3787 | { | |
| 3788 | }; | |
| 3789 | ||
| 3790 | template <class _Fn, class _Tp> | |
| 3791 | class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer | |
| 3792 | : public __result_of_mp<typename remove_reference<_Fn>::type, | |
| 3793 | _Tp, | |
| 3794 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> | |
| 3795 | { | |
| 3796 | }; | |
| 3797 | ||
| 3798 | template <class _Fn, class _Tp, class ..._Args> | |
| 3799 | class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer | |
| 3800 | : public __result_of_mp<typename remove_reference<_Fn>::type, | |
| 3801 | _Tp, | |
| 3802 | is_member_function_pointer<typename remove_reference<_Fn>::type>::value> | |
| 3803 | { | |
| 3804 | }; | |
| 3805 | ||
| 3806 | template <class _Fn, class ..._Args> | |
| 3807 | class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)> | |
| 3808 | : public __result_of<_Fn(_Args...), | |
| 3809 | is_class<typename remove_reference<_Fn>::type>::value || | |
| 3810 | is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, | |
| 3811 | is_member_pointer<typename remove_reference<_Fn>::type>::value | |
| 3812 | > | |
| 3813 | { | |
| 3814 | }; | |
| 3815 | ||
| 3816 | #endif // C++03 | |
| 3817 | ||
| 3818 | 586 | #if _LIBCPP_STD_VER > 11 |
| 3819 | 587 | template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type; |
| 3820 | 588 | #endif // _LIBCPP_STD_VER > 11 |
| 3821 | 589 | #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) |
| 3822 | 590 | |
| 3823 | #if _LIBCPP_STD_VER > 14 | |
| 3824 | ||
| 3825 | // invoke_result | |
| 3826 | ||
| 3827 | template <class _Fn, class... _Args> | |
| 3828 | struct _LIBCPP_TEMPLATE_VIS invoke_result | |
| 3829 | : __invoke_of<_Fn, _Args...> | |
| 3830 | { | |
| 3831 | }; | |
| 3832 | ||
| 3833 | template <class _Fn, class... _Args> | |
| 3834 | using invoke_result_t = typename invoke_result<_Fn, _Args...>::type; | |
| 3835 | ||
| 3836 | // is_invocable | |
| 3837 | ||
| 3838 | template <class _Fn, class ..._Args> | |
| 3839 | struct _LIBCPP_TEMPLATE_VIS is_invocable | |
| 3840 | : integral_constant<bool, __invokable<_Fn, _Args...>::value> {}; | |
| 3841 | ||
| 3842 | template <class _Ret, class _Fn, class ..._Args> | |
| 3843 | struct _LIBCPP_TEMPLATE_VIS is_invocable_r | |
| 3844 | : integral_constant<bool, __invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 3845 | ||
| 3846 | template <class _Fn, class ..._Args> | |
| 3847 | inline constexpr bool is_invocable_v = is_invocable<_Fn, _Args...>::value; | |
| 3848 | ||
| 3849 | template <class _Ret, class _Fn, class ..._Args> | |
| 3850 | inline constexpr bool is_invocable_r_v = is_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 3851 | ||
| 3852 | // is_nothrow_invocable | |
| 3853 | ||
| 3854 | template <class _Fn, class ..._Args> | |
| 3855 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable | |
| 3856 | : integral_constant<bool, __nothrow_invokable<_Fn, _Args...>::value> {}; | |
| 3857 | ||
| 3858 | template <class _Ret, class _Fn, class ..._Args> | |
| 3859 | struct _LIBCPP_TEMPLATE_VIS is_nothrow_invocable_r | |
| 3860 | : integral_constant<bool, __nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {}; | |
| 3861 | ||
| 3862 | template <class _Fn, class ..._Args> | |
| 3863 | inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value; | |
| 3864 | ||
| 3865 | template <class _Ret, class _Fn, class ..._Args> | |
| 3866 | inline constexpr bool is_nothrow_invocable_r_v = is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value; | |
| 3867 | ||
| 3868 | #endif // _LIBCPP_STD_VER > 14 | |
| 3869 | ||
| 3870 | 591 | // __swappable |
| 3871 | 592 | |
| 3872 | 593 | template <class _Tp> struct __is_swappable; |
| ... | ... | @@ -3999,24 +720,6 @@ inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value; |
| 3999 | 720 | |
| 4000 | 721 | #endif // _LIBCPP_STD_VER > 14 |
| 4001 | 722 | |
| 4002 | template <class _Tp, bool = is_enum<_Tp>::value> struct __underlying_type_impl; | |
| 4003 | ||
| 4004 | template <class _Tp> | |
| 4005 | struct __underlying_type_impl<_Tp, false> {}; | |
| 4006 | ||
| 4007 | template <class _Tp> | |
| 4008 | struct __underlying_type_impl<_Tp, true> | |
| 4009 | { | |
| 4010 | typedef __underlying_type(_Tp) type; | |
| 4011 | }; | |
| 4012 | ||
| 4013 | template <class _Tp> | |
| 4014 | struct underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {}; | |
| 4015 | ||
| 4016 | #if _LIBCPP_STD_VER > 11 | |
| 4017 | template <class _Tp> using underlying_type_t = typename underlying_type<_Tp>::type; | |
| 4018 | #endif | |
| 4019 | ||
| 4020 | 723 | template <class _Tp, bool = is_enum<_Tp>::value> |
| 4021 | 724 | struct __sfinae_underlying_type |
| 4022 | 725 | { |
| ... | ... | @@ -4063,42 +766,6 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR |
| 4063 | 766 | typename __sfinae_underlying_type<_Tp>::__promoted_type |
| 4064 | 767 | __convert_to_integral(_Tp __val) { return __val; } |
| 4065 | 768 | |
| 4066 | // is_scoped_enum [meta.unary.prop] | |
| 4067 | ||
| 4068 | #if _LIBCPP_STD_VER > 20 | |
| 4069 | template <class _Tp, bool = is_enum_v<_Tp> > | |
| 4070 | struct __is_scoped_enum_helper : false_type {}; | |
| 4071 | ||
| 4072 | template <class _Tp> | |
| 4073 | struct __is_scoped_enum_helper<_Tp, true> | |
| 4074 | : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {}; | |
| 4075 | ||
| 4076 | template <class _Tp> | |
| 4077 | struct _LIBCPP_TEMPLATE_VIS is_scoped_enum | |
| 4078 | : public __is_scoped_enum_helper<_Tp> {}; | |
| 4079 | ||
| 4080 | template <class _Tp> | |
| 4081 | inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value; | |
| 4082 | #endif | |
| 4083 | ||
| 4084 | #if _LIBCPP_STD_VER > 14 | |
| 4085 | ||
| 4086 | template <class... _Args> | |
| 4087 | struct conjunction : _And<_Args...> {}; | |
| 4088 | template<class... _Args> | |
| 4089 | inline constexpr bool conjunction_v = conjunction<_Args...>::value; | |
| 4090 | ||
| 4091 | template <class... _Args> | |
| 4092 | struct disjunction : _Or<_Args...> {}; | |
| 4093 | template<class... _Args> | |
| 4094 | inline constexpr bool disjunction_v = disjunction<_Args...>::value; | |
| 4095 | ||
| 4096 | template <class _Tp> | |
| 4097 | struct negation : _Not<_Tp> {}; | |
| 4098 | template<class _Tp> | |
| 4099 | inline constexpr bool negation_v = negation<_Tp>::value; | |
| 4100 | #endif // _LIBCPP_STD_VER > 14 | |
| 4101 | ||
| 4102 | 769 | // These traits are used in __tree and __hash_table |
| 4103 | 770 | struct __extract_key_fail_tag {}; |
| 4104 | 771 | struct __extract_key_self_tag {}; |
| ... | ... | @@ -4129,26 +796,14 @@ template <class _ValTy, class _Key, class _RawValTy> |
| 4129 | 796 | struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> |
| 4130 | 797 | : false_type {}; |
| 4131 | 798 | |
| 4132 | #if _LIBCPP_STD_VER > 17 | |
| 4133 | _LIBCPP_INLINE_VISIBILITY | |
| 4134 | inline constexpr bool is_constant_evaluated() noexcept { | |
| 4135 | return __builtin_is_constant_evaluated(); | |
| 4136 | } | |
| 4137 | #endif | |
| 4138 | ||
| 4139 | inline _LIBCPP_CONSTEXPR | |
| 4140 | bool __libcpp_is_constant_evaluated() _NOEXCEPT { return __builtin_is_constant_evaluated(); } | |
| 4141 | ||
| 4142 | 799 | template <class _CharT> |
| 4143 | 800 | using _IsCharLikeType = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >; |
| 4144 | 801 | |
| 4145 | 802 | template<class _Tp> |
| 4146 | 803 | using __make_const_lvalue_ref = const typename remove_reference<_Tp>::type&; |
| 4147 | 804 | |
| 4148 | #if _LIBCPP_STD_VER > 17 | |
| 4149 | 805 | template<bool _Const, class _Tp> |
| 4150 | using __maybe_const = conditional_t<_Const, const _Tp, _Tp>; | |
| 4151 | #endif // _LIBCPP_STD_VER > 17 | |
| 806 | using __maybe_const = typename conditional<_Const, const _Tp, _Tp>::type; | |
| 4152 | 807 | |
| 4153 | 808 | _LIBCPP_END_NAMESPACE_STD |
| 4154 | 809 |
lib/libcxx/include/typeindex+12-4| ... | ... | @@ -44,15 +44,23 @@ struct hash<type_index> |
| 44 | 44 | |
| 45 | 45 | */ |
| 46 | 46 | |
| 47 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 47 | 48 | #include <__config> |
| 48 | 49 | #include <__functional/unary_function.h> |
| 49 | #include <__functional_base> | |
| 50 | #include <compare> | |
| 51 | 50 | #include <typeinfo> |
| 52 | 51 | #include <version> |
| 53 | 52 | |
| 53 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 54 | # include <iosfwd> | |
| 55 | # include <new> | |
| 56 | # include <utility> | |
| 57 | #endif | |
| 58 | ||
| 59 | // standard-mandated includes | |
| 60 | #include <compare> | |
| 61 | ||
| 54 | 62 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 55 | #pragma GCC system_header | |
| 63 | # pragma GCC system_header | |
| 56 | 64 | #endif |
| 57 | 65 | |
| 58 | 66 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -93,7 +101,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; |
| 93 | 101 | |
| 94 | 102 | template <> |
| 95 | 103 | struct _LIBCPP_TEMPLATE_VIS hash<type_index> |
| 96 | : public unary_function<type_index, size_t> | |
| 104 | : public __unary_function<type_index, size_t> | |
| 97 | 105 | { |
| 98 | 106 | _LIBCPP_INLINE_VISIBILITY |
| 99 | 107 | size_t operator()(type_index __index) const _NOEXCEPT |
lib/libcxx/include/typeinfo+2-1| ... | ... | @@ -56,6 +56,7 @@ public: |
| 56 | 56 | |
| 57 | 57 | */ |
| 58 | 58 | |
| 59 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 59 | 60 | #include <__availability> |
| 60 | 61 | #include <__config> |
| 61 | 62 | #include <cstddef> |
| ... | ... | @@ -68,7 +69,7 @@ public: |
| 68 | 69 | #endif |
| 69 | 70 | |
| 70 | 71 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 71 | #pragma GCC system_header | |
| 72 | # pragma GCC system_header | |
| 72 | 73 | #endif |
| 73 | 74 | |
| 74 | 75 | #if defined(_LIBCPP_ABI_VCRUNTIME) |
lib/libcxx/include/uchar.h created+52| ... | ... | @@ -0,0 +1,52 @@ |
| 1 | // -*- C++ -*- | |
| 2 | //===----------------------------------------------------------------------===// | |
| 3 | // | |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 5 | // See https://llvm.org/LICENSE.txt for license information. | |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 7 | // | |
| 8 | //===----------------------------------------------------------------------===// | |
| 9 | ||
| 10 | #ifndef _LIBCPP_UCHAR_H | |
| 11 | #define _LIBCPP_UCHAR_H | |
| 12 | ||
| 13 | /* | |
| 14 | uchar.h synopsis // since C++11 | |
| 15 | ||
| 16 | Macros: | |
| 17 | ||
| 18 | __STDC_UTF_16__ | |
| 19 | __STDC_UTF_32__ | |
| 20 | ||
| 21 | Types: | |
| 22 | ||
| 23 | mbstate_t | |
| 24 | size_t | |
| 25 | ||
| 26 | size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps); | |
| 27 | size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps); | |
| 28 | size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps); | |
| 29 | size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps); | |
| 30 | ||
| 31 | */ | |
| 32 | ||
| 33 | #include <__config> | |
| 34 | ||
| 35 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | |
| 36 | # pragma GCC system_header | |
| 37 | #endif | |
| 38 | ||
| 39 | #if !defined(_LIBCPP_CXX03_LANG) | |
| 40 | ||
| 41 | // Some platforms don't implement <uchar.h> and we don't want to give a hard | |
| 42 | // error on those platforms. When the platform doesn't provide <uchar.h>, at | |
| 43 | // least include <stddef.h> so we get the declaration for size_t. | |
| 44 | #if __has_include_next(<uchar.h>) | |
| 45 | # include_next <uchar.h> | |
| 46 | #else | |
| 47 | # include <stddef.h> | |
| 48 | #endif | |
| 49 | ||
| 50 | #endif // _LIBCPP_CXX03_LANG | |
| 51 | ||
| 52 | #endif // _LIBCPP_UCHAR_H |
lib/libcxx/include/unordered_map+64-53| ... | ... | @@ -514,23 +514,44 @@ template <class Key, class T, class Hash, class Pred, class Alloc> |
| 514 | 514 | |
| 515 | 515 | */ |
| 516 | 516 | |
| 517 | #include <__algorithm/is_permutation.h> | |
| 518 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 517 | 519 | #include <__config> |
| 518 | 520 | #include <__debug> |
| 519 | 521 | #include <__functional/is_transparent.h> |
| 522 | #include <__functional/operations.h> | |
| 520 | 523 | #include <__hash_table> |
| 524 | #include <__iterator/distance.h> | |
| 525 | #include <__iterator/erase_if_container.h> | |
| 521 | 526 | #include <__iterator/iterator_traits.h> |
| 522 | 527 | #include <__memory/addressof.h> |
| 523 | 528 | #include <__node_handle> |
| 524 | 529 | #include <__utility/forward.h> |
| 525 | #include <compare> | |
| 526 | #include <functional> | |
| 527 | #include <iterator> // __libcpp_erase_if_container | |
| 528 | 530 | #include <stdexcept> |
| 529 | 531 | #include <tuple> |
| 530 | 532 | #include <version> |
| 531 | 533 | |
| 534 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 535 | # include <algorithm> | |
| 536 | # include <bit> | |
| 537 | # include <iterator> | |
| 538 | #endif | |
| 539 | ||
| 540 | // standard-mandated includes | |
| 541 | ||
| 542 | // [iterator.range] | |
| 543 | #include <__iterator/access.h> | |
| 544 | #include <__iterator/data.h> | |
| 545 | #include <__iterator/empty.h> | |
| 546 | #include <__iterator/reverse_access.h> | |
| 547 | #include <__iterator/size.h> | |
| 548 | ||
| 549 | // [unord.map.syn] | |
| 550 | #include <compare> | |
| 551 | #include <initializer_list> | |
| 552 | ||
| 532 | 553 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 533 | #pragma GCC system_header | |
| 554 | # pragma GCC system_header | |
| 534 | 555 | #endif |
| 535 | 556 | |
| 536 | 557 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -855,9 +876,7 @@ public: |
| 855 | 876 | } |
| 856 | 877 | |
| 857 | 878 | template <class _ValueTp, |
| 858 | class = typename enable_if< | |
| 859 | __is_same_uncvref<_ValueTp, value_type>::value | |
| 860 | >::type | |
| 879 | class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> | |
| 861 | 880 | > |
| 862 | 881 | _LIBCPP_INLINE_VISIBILITY |
| 863 | 882 | __hash_value_type& operator=(_ValueTp&& __v) |
| ... | ... | @@ -1012,9 +1031,9 @@ public: |
| 1012 | 1031 | // types |
| 1013 | 1032 | typedef _Key key_type; |
| 1014 | 1033 | typedef _Tp mapped_type; |
| 1015 | typedef __identity_t<_Hash> hasher; | |
| 1016 | typedef __identity_t<_Pred> key_equal; | |
| 1017 | typedef __identity_t<_Alloc> allocator_type; | |
| 1034 | typedef __type_identity_t<_Hash> hasher; | |
| 1035 | typedef __type_identity_t<_Pred> key_equal; | |
| 1036 | typedef __type_identity_t<_Alloc> allocator_type; | |
| 1018 | 1037 | typedef pair<const key_type, mapped_type> value_type; |
| 1019 | 1038 | typedef value_type& reference; |
| 1020 | 1039 | typedef const value_type& const_reference; |
| ... | ... | @@ -1216,13 +1235,13 @@ public: |
| 1216 | 1235 | } |
| 1217 | 1236 | |
| 1218 | 1237 | template <class _Pp, |
| 1219 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 1238 | class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | |
| 1220 | 1239 | _LIBCPP_INLINE_VISIBILITY |
| 1221 | 1240 | pair<iterator, bool> insert(_Pp&& __x) |
| 1222 | 1241 | {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));} |
| 1223 | 1242 | |
| 1224 | 1243 | template <class _Pp, |
| 1225 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 1244 | class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | |
| 1226 | 1245 | _LIBCPP_INLINE_VISIBILITY |
| 1227 | 1246 | iterator insert(const_iterator __p, _Pp&& __x) |
| 1228 | 1247 | { |
| ... | ... | @@ -1506,11 +1525,11 @@ public: |
| 1506 | 1525 | _LIBCPP_INLINE_VISIBILITY |
| 1507 | 1526 | void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} |
| 1508 | 1527 | _LIBCPP_INLINE_VISIBILITY |
| 1509 | void rehash(size_type __n) {__table_.rehash(__n);} | |
| 1528 | void rehash(size_type __n) {__table_.__rehash_unique(__n);} | |
| 1510 | 1529 | _LIBCPP_INLINE_VISIBILITY |
| 1511 | void reserve(size_type __n) {__table_.reserve(__n);} | |
| 1530 | void reserve(size_type __n) {__table_.__reserve_unique(__n);} | |
| 1512 | 1531 | |
| 1513 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1532 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1514 | 1533 | |
| 1515 | 1534 | bool __dereferenceable(const const_iterator* __i) const |
| 1516 | 1535 | {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));} |
| ... | ... | @@ -1521,7 +1540,7 @@ public: |
| 1521 | 1540 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 1522 | 1541 | {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);} |
| 1523 | 1542 | |
| 1524 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1543 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1525 | 1544 | |
| 1526 | 1545 | private: |
| 1527 | 1546 | |
| ... | ... | @@ -1607,7 +1626,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1607 | 1626 | : __table_(__hf, __eql) |
| 1608 | 1627 | { |
| 1609 | 1628 | _VSTD::__debug_db_insert_c(this); |
| 1610 | __table_.rehash(__n); | |
| 1629 | __table_.__rehash_unique(__n); | |
| 1611 | 1630 | } |
| 1612 | 1631 | |
| 1613 | 1632 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1617,7 +1636,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1617 | 1636 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 1618 | 1637 | { |
| 1619 | 1638 | _VSTD::__debug_db_insert_c(this); |
| 1620 | __table_.rehash(__n); | |
| 1639 | __table_.__rehash_unique(__n); | |
| 1621 | 1640 | } |
| 1622 | 1641 | |
| 1623 | 1642 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1646,7 +1665,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1646 | 1665 | : __table_(__hf, __eql) |
| 1647 | 1666 | { |
| 1648 | 1667 | _VSTD::__debug_db_insert_c(this); |
| 1649 | __table_.rehash(__n); | |
| 1668 | __table_.__rehash_unique(__n); | |
| 1650 | 1669 | insert(__first, __last); |
| 1651 | 1670 | } |
| 1652 | 1671 | |
| ... | ... | @@ -1658,7 +1677,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1658 | 1677 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 1659 | 1678 | { |
| 1660 | 1679 | _VSTD::__debug_db_insert_c(this); |
| 1661 | __table_.rehash(__n); | |
| 1680 | __table_.__rehash_unique(__n); | |
| 1662 | 1681 | insert(__first, __last); |
| 1663 | 1682 | } |
| 1664 | 1683 | |
| ... | ... | @@ -1668,7 +1687,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1668 | 1687 | : __table_(__u.__table_) |
| 1669 | 1688 | { |
| 1670 | 1689 | _VSTD::__debug_db_insert_c(this); |
| 1671 | __table_.rehash(__u.bucket_count()); | |
| 1690 | __table_.__rehash_unique(__u.bucket_count()); | |
| 1672 | 1691 | insert(__u.begin(), __u.end()); |
| 1673 | 1692 | } |
| 1674 | 1693 | |
| ... | ... | @@ -1678,7 +1697,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1678 | 1697 | : __table_(__u.__table_, typename __table::allocator_type(__a)) |
| 1679 | 1698 | { |
| 1680 | 1699 | _VSTD::__debug_db_insert_c(this); |
| 1681 | __table_.rehash(__u.bucket_count()); | |
| 1700 | __table_.__rehash_unique(__u.bucket_count()); | |
| 1682 | 1701 | insert(__u.begin(), __u.end()); |
| 1683 | 1702 | } |
| 1684 | 1703 | |
| ... | ... | @@ -1692,9 +1711,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1692 | 1711 | : __table_(_VSTD::move(__u.__table_)) |
| 1693 | 1712 | { |
| 1694 | 1713 | _VSTD::__debug_db_insert_c(this); |
| 1695 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1696 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1697 | #endif | |
| 1714 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1698 | 1715 | } |
| 1699 | 1716 | |
| 1700 | 1717 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1711,10 +1728,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1711 | 1728 | __u.__table_.remove((__i++).__i_)->__value_.__move()); |
| 1712 | 1729 | } |
| 1713 | 1730 | } |
| 1714 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1715 | 1731 | else |
| 1716 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1717 | #endif | |
| 1732 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1718 | 1733 | } |
| 1719 | 1734 | |
| 1720 | 1735 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1732,7 +1747,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1732 | 1747 | : __table_(__hf, __eql) |
| 1733 | 1748 | { |
| 1734 | 1749 | _VSTD::__debug_db_insert_c(this); |
| 1735 | __table_.rehash(__n); | |
| 1750 | __table_.__rehash_unique(__n); | |
| 1736 | 1751 | insert(__il.begin(), __il.end()); |
| 1737 | 1752 | } |
| 1738 | 1753 | |
| ... | ... | @@ -1743,7 +1758,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( |
| 1743 | 1758 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 1744 | 1759 | { |
| 1745 | 1760 | _VSTD::__debug_db_insert_c(this); |
| 1746 | __table_.rehash(__n); | |
| 1761 | __table_.__rehash_unique(__n); | |
| 1747 | 1762 | insert(__il.begin(), __il.end()); |
| 1748 | 1763 | } |
| 1749 | 1764 | |
| ... | ... | @@ -1906,9 +1921,9 @@ public: |
| 1906 | 1921 | // types |
| 1907 | 1922 | typedef _Key key_type; |
| 1908 | 1923 | typedef _Tp mapped_type; |
| 1909 | typedef __identity_t<_Hash> hasher; | |
| 1910 | typedef __identity_t<_Pred> key_equal; | |
| 1911 | typedef __identity_t<_Alloc> allocator_type; | |
| 1924 | typedef __type_identity_t<_Hash> hasher; | |
| 1925 | typedef __type_identity_t<_Pred> key_equal; | |
| 1926 | typedef __type_identity_t<_Alloc> allocator_type; | |
| 1912 | 1927 | typedef pair<const key_type, mapped_type> value_type; |
| 1913 | 1928 | typedef value_type& reference; |
| 1914 | 1929 | typedef const value_type& const_reference; |
| ... | ... | @@ -2097,13 +2112,13 @@ public: |
| 2097 | 2112 | {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));} |
| 2098 | 2113 | |
| 2099 | 2114 | template <class _Pp, |
| 2100 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 2115 | class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | |
| 2101 | 2116 | _LIBCPP_INLINE_VISIBILITY |
| 2102 | 2117 | iterator insert(_Pp&& __x) |
| 2103 | 2118 | {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));} |
| 2104 | 2119 | |
| 2105 | 2120 | template <class _Pp, |
| 2106 | class = typename enable_if<is_constructible<value_type, _Pp>::value>::type> | |
| 2121 | class = __enable_if_t<is_constructible<value_type, _Pp>::value> > | |
| 2107 | 2122 | _LIBCPP_INLINE_VISIBILITY |
| 2108 | 2123 | iterator insert(const_iterator __p, _Pp&& __x) |
| 2109 | 2124 | {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));} |
| ... | ... | @@ -2286,11 +2301,11 @@ public: |
| 2286 | 2301 | _LIBCPP_INLINE_VISIBILITY |
| 2287 | 2302 | void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} |
| 2288 | 2303 | _LIBCPP_INLINE_VISIBILITY |
| 2289 | void rehash(size_type __n) {__table_.rehash(__n);} | |
| 2304 | void rehash(size_type __n) {__table_.__rehash_multi(__n);} | |
| 2290 | 2305 | _LIBCPP_INLINE_VISIBILITY |
| 2291 | void reserve(size_type __n) {__table_.reserve(__n);} | |
| 2306 | void reserve(size_type __n) {__table_.__reserve_multi(__n);} | |
| 2292 | 2307 | |
| 2293 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2308 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2294 | 2309 | |
| 2295 | 2310 | bool __dereferenceable(const const_iterator* __i) const |
| 2296 | 2311 | {return __table_.__dereferenceable(_VSTD::addressof(__i->__i_));} |
| ... | ... | @@ -2301,7 +2316,7 @@ public: |
| 2301 | 2316 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 2302 | 2317 | {return __table_.__addable(_VSTD::addressof(__i->__i_), __n);} |
| 2303 | 2318 | |
| 2304 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 2319 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 2305 | 2320 | |
| 2306 | 2321 | |
| 2307 | 2322 | }; |
| ... | ... | @@ -2383,7 +2398,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2383 | 2398 | : __table_(__hf, __eql) |
| 2384 | 2399 | { |
| 2385 | 2400 | _VSTD::__debug_db_insert_c(this); |
| 2386 | __table_.rehash(__n); | |
| 2401 | __table_.__rehash_multi(__n); | |
| 2387 | 2402 | } |
| 2388 | 2403 | |
| 2389 | 2404 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -2393,7 +2408,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2393 | 2408 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 2394 | 2409 | { |
| 2395 | 2410 | _VSTD::__debug_db_insert_c(this); |
| 2396 | __table_.rehash(__n); | |
| 2411 | __table_.__rehash_multi(__n); | |
| 2397 | 2412 | } |
| 2398 | 2413 | |
| 2399 | 2414 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -2413,7 +2428,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2413 | 2428 | : __table_(__hf, __eql) |
| 2414 | 2429 | { |
| 2415 | 2430 | _VSTD::__debug_db_insert_c(this); |
| 2416 | __table_.rehash(__n); | |
| 2431 | __table_.__rehash_multi(__n); | |
| 2417 | 2432 | insert(__first, __last); |
| 2418 | 2433 | } |
| 2419 | 2434 | |
| ... | ... | @@ -2425,7 +2440,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2425 | 2440 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 2426 | 2441 | { |
| 2427 | 2442 | _VSTD::__debug_db_insert_c(this); |
| 2428 | __table_.rehash(__n); | |
| 2443 | __table_.__rehash_multi(__n); | |
| 2429 | 2444 | insert(__first, __last); |
| 2430 | 2445 | } |
| 2431 | 2446 | |
| ... | ... | @@ -2444,7 +2459,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2444 | 2459 | : __table_(__u.__table_) |
| 2445 | 2460 | { |
| 2446 | 2461 | _VSTD::__debug_db_insert_c(this); |
| 2447 | __table_.rehash(__u.bucket_count()); | |
| 2462 | __table_.__rehash_multi(__u.bucket_count()); | |
| 2448 | 2463 | insert(__u.begin(), __u.end()); |
| 2449 | 2464 | } |
| 2450 | 2465 | |
| ... | ... | @@ -2454,7 +2469,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2454 | 2469 | : __table_(__u.__table_, typename __table::allocator_type(__a)) |
| 2455 | 2470 | { |
| 2456 | 2471 | _VSTD::__debug_db_insert_c(this); |
| 2457 | __table_.rehash(__u.bucket_count()); | |
| 2472 | __table_.__rehash_multi(__u.bucket_count()); | |
| 2458 | 2473 | insert(__u.begin(), __u.end()); |
| 2459 | 2474 | } |
| 2460 | 2475 | |
| ... | ... | @@ -2468,9 +2483,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2468 | 2483 | : __table_(_VSTD::move(__u.__table_)) |
| 2469 | 2484 | { |
| 2470 | 2485 | _VSTD::__debug_db_insert_c(this); |
| 2471 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2472 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 2473 | #endif | |
| 2486 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 2474 | 2487 | } |
| 2475 | 2488 | |
| 2476 | 2489 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -2488,10 +2501,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2488 | 2501 | __u.__table_.remove((__i++).__i_)->__value_.__move()); |
| 2489 | 2502 | } |
| 2490 | 2503 | } |
| 2491 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2492 | 2504 | else |
| 2493 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 2494 | #endif | |
| 2505 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 2495 | 2506 | } |
| 2496 | 2507 | |
| 2497 | 2508 | template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -2509,7 +2520,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2509 | 2520 | : __table_(__hf, __eql) |
| 2510 | 2521 | { |
| 2511 | 2522 | _VSTD::__debug_db_insert_c(this); |
| 2512 | __table_.rehash(__n); | |
| 2523 | __table_.__rehash_multi(__n); | |
| 2513 | 2524 | insert(__il.begin(), __il.end()); |
| 2514 | 2525 | } |
| 2515 | 2526 | |
| ... | ... | @@ -2520,7 +2531,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( |
| 2520 | 2531 | : __table_(__hf, __eql, typename __table::allocator_type(__a)) |
| 2521 | 2532 | { |
| 2522 | 2533 | _VSTD::__debug_db_insert_c(this); |
| 2523 | __table_.rehash(__n); | |
| 2534 | __table_.__rehash_multi(__n); | |
| 2524 | 2535 | insert(__il.begin(), __il.end()); |
| 2525 | 2536 | } |
| 2526 | 2537 |
lib/libcxx/include/unordered_set+82-83| ... | ... | @@ -459,20 +459,41 @@ template <class Value, class Hash, class Pred, class Alloc> |
| 459 | 459 | |
| 460 | 460 | */ |
| 461 | 461 | |
| 462 | #include <__algorithm/is_permutation.h> | |
| 463 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 462 | 464 | #include <__config> |
| 463 | 465 | #include <__debug> |
| 464 | 466 | #include <__functional/is_transparent.h> |
| 467 | #include <__functional/operations.h> | |
| 465 | 468 | #include <__hash_table> |
| 469 | #include <__iterator/distance.h> | |
| 470 | #include <__iterator/erase_if_container.h> | |
| 471 | #include <__iterator/iterator_traits.h> | |
| 466 | 472 | #include <__memory/addressof.h> |
| 467 | 473 | #include <__node_handle> |
| 468 | 474 | #include <__utility/forward.h> |
| 469 | #include <compare> | |
| 470 | #include <functional> | |
| 471 | #include <iterator> // __libcpp_erase_if_container | |
| 472 | 475 | #include <version> |
| 473 | 476 | |
| 477 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 478 | # include <functional> | |
| 479 | # include <iterator> | |
| 480 | #endif | |
| 481 | ||
| 482 | // standard-mandated includes | |
| 483 | ||
| 484 | // [iterator.range] | |
| 485 | #include <__iterator/access.h> | |
| 486 | #include <__iterator/data.h> | |
| 487 | #include <__iterator/empty.h> | |
| 488 | #include <__iterator/reverse_access.h> | |
| 489 | #include <__iterator/size.h> | |
| 490 | ||
| 491 | // [unord.set.syn] | |
| 492 | #include <compare> | |
| 493 | #include <initializer_list> | |
| 494 | ||
| 474 | 495 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 475 | #pragma GCC system_header | |
| 496 | # pragma GCC system_header | |
| 476 | 497 | #endif |
| 477 | 498 | |
| 478 | 499 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -488,9 +509,9 @@ public: |
| 488 | 509 | // types |
| 489 | 510 | typedef _Value key_type; |
| 490 | 511 | typedef key_type value_type; |
| 491 | typedef __identity_t<_Hash> hasher; | |
| 492 | typedef __identity_t<_Pred> key_equal; | |
| 493 | typedef __identity_t<_Alloc> allocator_type; | |
| 512 | typedef __type_identity_t<_Hash> hasher; | |
| 513 | typedef __type_identity_t<_Pred> key_equal; | |
| 514 | typedef __type_identity_t<_Alloc> allocator_type; | |
| 494 | 515 | typedef value_type& reference; |
| 495 | 516 | typedef const value_type& const_reference; |
| 496 | 517 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), |
| ... | ... | @@ -637,36 +658,27 @@ public: |
| 637 | 658 | pair<iterator, bool> emplace(_Args&&... __args) |
| 638 | 659 | {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...);} |
| 639 | 660 | template <class... _Args> |
| 640 | _LIBCPP_INLINE_VISIBILITY | |
| 641 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 642 | iterator emplace_hint(const_iterator __p, _Args&&... __args) | |
| 643 | { | |
| 644 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 645 | "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 646 | " referring to this unordered_set"); | |
| 647 | return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; | |
| 648 | } | |
| 649 | #else | |
| 650 | iterator emplace_hint(const_iterator, _Args&&... __args) | |
| 651 | {return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first;} | |
| 652 | #endif | |
| 661 | _LIBCPP_INLINE_VISIBILITY | |
| 662 | iterator emplace_hint(const_iterator __p, _Args&&... __args) { | |
| 663 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this, | |
| 664 | "unordered_set::emplace_hint(const_iterator, args...) called with an iterator not" | |
| 665 | " referring to this unordered_set"); | |
| 666 | (void)__p; | |
| 667 | return __table_.__emplace_unique(std::forward<_Args>(__args)...).first; | |
| 668 | } | |
| 653 | 669 | |
| 654 | 670 | _LIBCPP_INLINE_VISIBILITY |
| 655 | 671 | pair<iterator, bool> insert(value_type&& __x) |
| 656 | 672 | {return __table_.__insert_unique(_VSTD::move(__x));} |
| 657 | 673 | _LIBCPP_INLINE_VISIBILITY |
| 658 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 659 | iterator insert(const_iterator __p, value_type&& __x) | |
| 660 | { | |
| 661 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 662 | "unordered_set::insert(const_iterator, value_type&&) called with an iterator not" | |
| 663 | " referring to this unordered_set"); | |
| 664 | return insert(_VSTD::move(__x)).first; | |
| 665 | } | |
| 666 | #else | |
| 667 | iterator insert(const_iterator, value_type&& __x) | |
| 668 | {return insert(_VSTD::move(__x)).first;} | |
| 669 | #endif | |
| 674 | iterator insert(const_iterator __p, value_type&& __x) { | |
| 675 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this, | |
| 676 | "unordered_set::insert(const_iterator, value_type&&) called with an iterator not" | |
| 677 | " referring to this unordered_set"); | |
| 678 | (void)__p; | |
| 679 | return insert(std::move(__x)).first; | |
| 680 | } | |
| 681 | ||
| 670 | 682 | _LIBCPP_INLINE_VISIBILITY |
| 671 | 683 | void insert(initializer_list<value_type> __il) |
| 672 | 684 | {insert(__il.begin(), __il.end());} |
| ... | ... | @@ -676,18 +688,13 @@ public: |
| 676 | 688 | {return __table_.__insert_unique(__x);} |
| 677 | 689 | |
| 678 | 690 | _LIBCPP_INLINE_VISIBILITY |
| 679 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 680 | iterator insert(const_iterator __p, const value_type& __x) | |
| 681 | { | |
| 682 | _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__p)) == this, | |
| 683 | "unordered_set::insert(const_iterator, const value_type&) called with an iterator not" | |
| 684 | " referring to this unordered_set"); | |
| 685 | return insert(__x).first; | |
| 686 | } | |
| 687 | #else | |
| 688 | iterator insert(const_iterator, const value_type& __x) | |
| 689 | {return insert(__x).first;} | |
| 690 | #endif | |
| 691 | iterator insert(const_iterator __p, const value_type& __x) { | |
| 692 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(std::addressof(__p)) == this, | |
| 693 | "unordered_set::insert(const_iterator, const value_type&) called with an iterator not" | |
| 694 | " referring to this unordered_set"); | |
| 695 | (void)__p; | |
| 696 | return insert(__x).first; | |
| 697 | } | |
| 691 | 698 | template <class _InputIterator> |
| 692 | 699 | _LIBCPP_INLINE_VISIBILITY |
| 693 | 700 | void insert(_InputIterator __first, _InputIterator __last); |
| ... | ... | @@ -851,11 +858,11 @@ public: |
| 851 | 858 | _LIBCPP_INLINE_VISIBILITY |
| 852 | 859 | void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} |
| 853 | 860 | _LIBCPP_INLINE_VISIBILITY |
| 854 | void rehash(size_type __n) {__table_.rehash(__n);} | |
| 861 | void rehash(size_type __n) {__table_.__rehash_unique(__n);} | |
| 855 | 862 | _LIBCPP_INLINE_VISIBILITY |
| 856 | void reserve(size_type __n) {__table_.reserve(__n);} | |
| 863 | void reserve(size_type __n) {__table_.__reserve_unique(__n);} | |
| 857 | 864 | |
| 858 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 865 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 859 | 866 | |
| 860 | 867 | bool __dereferenceable(const const_iterator* __i) const |
| 861 | 868 | {return __table_.__dereferenceable(__i);} |
| ... | ... | @@ -866,7 +873,7 @@ public: |
| 866 | 873 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 867 | 874 | {return __table_.__addable(__i, __n);} |
| 868 | 875 | |
| 869 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 876 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 870 | 877 | |
| 871 | 878 | }; |
| 872 | 879 | |
| ... | ... | @@ -935,7 +942,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, |
| 935 | 942 | : __table_(__hf, __eql) |
| 936 | 943 | { |
| 937 | 944 | _VSTD::__debug_db_insert_c(this); |
| 938 | __table_.rehash(__n); | |
| 945 | __table_.__rehash_unique(__n); | |
| 939 | 946 | } |
| 940 | 947 | |
| 941 | 948 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -944,7 +951,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(size_type __n, |
| 944 | 951 | : __table_(__hf, __eql, __a) |
| 945 | 952 | { |
| 946 | 953 | _VSTD::__debug_db_insert_c(this); |
| 947 | __table_.rehash(__n); | |
| 954 | __table_.__rehash_unique(__n); | |
| 948 | 955 | } |
| 949 | 956 | |
| 950 | 957 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -964,7 +971,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 964 | 971 | : __table_(__hf, __eql) |
| 965 | 972 | { |
| 966 | 973 | _VSTD::__debug_db_insert_c(this); |
| 967 | __table_.rehash(__n); | |
| 974 | __table_.__rehash_unique(__n); | |
| 968 | 975 | insert(__first, __last); |
| 969 | 976 | } |
| 970 | 977 | |
| ... | ... | @@ -976,7 +983,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 976 | 983 | : __table_(__hf, __eql, __a) |
| 977 | 984 | { |
| 978 | 985 | _VSTD::__debug_db_insert_c(this); |
| 979 | __table_.rehash(__n); | |
| 986 | __table_.__rehash_unique(__n); | |
| 980 | 987 | insert(__first, __last); |
| 981 | 988 | } |
| 982 | 989 | |
| ... | ... | @@ -995,7 +1002,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 995 | 1002 | : __table_(__u.__table_) |
| 996 | 1003 | { |
| 997 | 1004 | _VSTD::__debug_db_insert_c(this); |
| 998 | __table_.rehash(__u.bucket_count()); | |
| 1005 | __table_.__rehash_unique(__u.bucket_count()); | |
| 999 | 1006 | insert(__u.begin(), __u.end()); |
| 1000 | 1007 | } |
| 1001 | 1008 | |
| ... | ... | @@ -1005,7 +1012,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1005 | 1012 | : __table_(__u.__table_, __a) |
| 1006 | 1013 | { |
| 1007 | 1014 | _VSTD::__debug_db_insert_c(this); |
| 1008 | __table_.rehash(__u.bucket_count()); | |
| 1015 | __table_.__rehash_unique(__u.bucket_count()); | |
| 1009 | 1016 | insert(__u.begin(), __u.end()); |
| 1010 | 1017 | } |
| 1011 | 1018 | |
| ... | ... | @@ -1019,9 +1026,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1019 | 1026 | : __table_(_VSTD::move(__u.__table_)) |
| 1020 | 1027 | { |
| 1021 | 1028 | _VSTD::__debug_db_insert_c(this); |
| 1022 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1023 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1024 | #endif | |
| 1029 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1025 | 1030 | } |
| 1026 | 1031 | |
| 1027 | 1032 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1036,10 +1041,8 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1036 | 1041 | while (__u.size() != 0) |
| 1037 | 1042 | __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_)); |
| 1038 | 1043 | } |
| 1039 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1040 | 1044 | else |
| 1041 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1042 | #endif | |
| 1045 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1043 | 1046 | } |
| 1044 | 1047 | |
| 1045 | 1048 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1057,7 +1060,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1057 | 1060 | : __table_(__hf, __eql) |
| 1058 | 1061 | { |
| 1059 | 1062 | _VSTD::__debug_db_insert_c(this); |
| 1060 | __table_.rehash(__n); | |
| 1063 | __table_.__rehash_unique(__n); | |
| 1061 | 1064 | insert(__il.begin(), __il.end()); |
| 1062 | 1065 | } |
| 1063 | 1066 | |
| ... | ... | @@ -1068,7 +1071,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( |
| 1068 | 1071 | : __table_(__hf, __eql, __a) |
| 1069 | 1072 | { |
| 1070 | 1073 | _VSTD::__debug_db_insert_c(this); |
| 1071 | __table_.rehash(__n); | |
| 1074 | __table_.__rehash_unique(__n); | |
| 1072 | 1075 | insert(__il.begin(), __il.end()); |
| 1073 | 1076 | } |
| 1074 | 1077 | |
| ... | ... | @@ -1162,9 +1165,9 @@ public: |
| 1162 | 1165 | // types |
| 1163 | 1166 | typedef _Value key_type; |
| 1164 | 1167 | typedef key_type value_type; |
| 1165 | typedef __identity_t<_Hash> hasher; | |
| 1166 | typedef __identity_t<_Pred> key_equal; | |
| 1167 | typedef __identity_t<_Alloc> allocator_type; | |
| 1168 | typedef __type_identity_t<_Hash> hasher; | |
| 1169 | typedef __type_identity_t<_Pred> key_equal; | |
| 1170 | typedef __type_identity_t<_Alloc> allocator_type; | |
| 1168 | 1171 | typedef value_type& reference; |
| 1169 | 1172 | typedef const value_type& const_reference; |
| 1170 | 1173 | static_assert((is_same<value_type, typename allocator_type::value_type>::value), |
| ... | ... | @@ -1493,11 +1496,11 @@ public: |
| 1493 | 1496 | _LIBCPP_INLINE_VISIBILITY |
| 1494 | 1497 | void max_load_factor(float __mlf) {__table_.max_load_factor(__mlf);} |
| 1495 | 1498 | _LIBCPP_INLINE_VISIBILITY |
| 1496 | void rehash(size_type __n) {__table_.rehash(__n);} | |
| 1499 | void rehash(size_type __n) {__table_.__rehash_multi(__n);} | |
| 1497 | 1500 | _LIBCPP_INLINE_VISIBILITY |
| 1498 | void reserve(size_type __n) {__table_.reserve(__n);} | |
| 1501 | void reserve(size_type __n) {__table_.__reserve_multi(__n);} | |
| 1499 | 1502 | |
| 1500 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1503 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1501 | 1504 | |
| 1502 | 1505 | bool __dereferenceable(const const_iterator* __i) const |
| 1503 | 1506 | {return __table_.__dereferenceable(__i);} |
| ... | ... | @@ -1508,7 +1511,7 @@ public: |
| 1508 | 1511 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const |
| 1509 | 1512 | {return __table_.__addable(__i, __n);} |
| 1510 | 1513 | |
| 1511 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1514 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1512 | 1515 | |
| 1513 | 1516 | }; |
| 1514 | 1517 | |
| ... | ... | @@ -1575,7 +1578,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1575 | 1578 | : __table_(__hf, __eql) |
| 1576 | 1579 | { |
| 1577 | 1580 | _VSTD::__debug_db_insert_c(this); |
| 1578 | __table_.rehash(__n); | |
| 1581 | __table_.__rehash_multi(__n); | |
| 1579 | 1582 | } |
| 1580 | 1583 | |
| 1581 | 1584 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1585,7 +1588,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1585 | 1588 | : __table_(__hf, __eql, __a) |
| 1586 | 1589 | { |
| 1587 | 1590 | _VSTD::__debug_db_insert_c(this); |
| 1588 | __table_.rehash(__n); | |
| 1591 | __table_.__rehash_multi(__n); | |
| 1589 | 1592 | } |
| 1590 | 1593 | |
| 1591 | 1594 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1605,7 +1608,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1605 | 1608 | : __table_(__hf, __eql) |
| 1606 | 1609 | { |
| 1607 | 1610 | _VSTD::__debug_db_insert_c(this); |
| 1608 | __table_.rehash(__n); | |
| 1611 | __table_.__rehash_multi(__n); | |
| 1609 | 1612 | insert(__first, __last); |
| 1610 | 1613 | } |
| 1611 | 1614 | |
| ... | ... | @@ -1617,7 +1620,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1617 | 1620 | : __table_(__hf, __eql, __a) |
| 1618 | 1621 | { |
| 1619 | 1622 | _VSTD::__debug_db_insert_c(this); |
| 1620 | __table_.rehash(__n); | |
| 1623 | __table_.__rehash_multi(__n); | |
| 1621 | 1624 | insert(__first, __last); |
| 1622 | 1625 | } |
| 1623 | 1626 | |
| ... | ... | @@ -1636,7 +1639,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1636 | 1639 | : __table_(__u.__table_) |
| 1637 | 1640 | { |
| 1638 | 1641 | _VSTD::__debug_db_insert_c(this); |
| 1639 | __table_.rehash(__u.bucket_count()); | |
| 1642 | __table_.__rehash_multi(__u.bucket_count()); | |
| 1640 | 1643 | insert(__u.begin(), __u.end()); |
| 1641 | 1644 | } |
| 1642 | 1645 | |
| ... | ... | @@ -1646,7 +1649,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1646 | 1649 | : __table_(__u.__table_, __a) |
| 1647 | 1650 | { |
| 1648 | 1651 | _VSTD::__debug_db_insert_c(this); |
| 1649 | __table_.rehash(__u.bucket_count()); | |
| 1652 | __table_.__rehash_multi(__u.bucket_count()); | |
| 1650 | 1653 | insert(__u.begin(), __u.end()); |
| 1651 | 1654 | } |
| 1652 | 1655 | |
| ... | ... | @@ -1660,9 +1663,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1660 | 1663 | : __table_(_VSTD::move(__u.__table_)) |
| 1661 | 1664 | { |
| 1662 | 1665 | _VSTD::__debug_db_insert_c(this); |
| 1663 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1664 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1665 | #endif | |
| 1666 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1666 | 1667 | } |
| 1667 | 1668 | |
| 1668 | 1669 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1677,10 +1678,8 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1677 | 1678 | while (__u.size() != 0) |
| 1678 | 1679 | __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_)); |
| 1679 | 1680 | } |
| 1680 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1681 | 1681 | else |
| 1682 | __get_db()->swap(this, _VSTD::addressof(__u)); | |
| 1683 | #endif | |
| 1682 | std::__debug_db_swap(this, std::addressof(__u)); | |
| 1684 | 1683 | } |
| 1685 | 1684 | |
| 1686 | 1685 | template <class _Value, class _Hash, class _Pred, class _Alloc> |
| ... | ... | @@ -1698,7 +1697,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1698 | 1697 | : __table_(__hf, __eql) |
| 1699 | 1698 | { |
| 1700 | 1699 | _VSTD::__debug_db_insert_c(this); |
| 1701 | __table_.rehash(__n); | |
| 1700 | __table_.__rehash_multi(__n); | |
| 1702 | 1701 | insert(__il.begin(), __il.end()); |
| 1703 | 1702 | } |
| 1704 | 1703 | |
| ... | ... | @@ -1709,7 +1708,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( |
| 1709 | 1708 | : __table_(__hf, __eql, __a) |
| 1710 | 1709 | { |
| 1711 | 1710 | _VSTD::__debug_db_insert_c(this); |
| 1712 | __table_.rehash(__n); | |
| 1711 | __table_.__rehash_multi(__n); | |
| 1713 | 1712 | insert(__il.begin(), __il.end()); |
| 1714 | 1713 | } |
| 1715 | 1714 |
lib/libcxx/include/utility+17-3| ... | ... | @@ -95,6 +95,12 @@ struct pair |
| 95 | 95 | is_nothrow_swappable_v<T2>); // constexpr in C++20 |
| 96 | 96 | }; |
| 97 | 97 | |
| 98 | template<class T1, class T2, class U1, class U2, template<class> class TQual, template<class> class UQual> | |
| 99 | struct basic_common_reference<pair<T1, T2>, pair<U1, U2>, TQual, UQual>; // since C++23 | |
| 100 | ||
| 101 | template<class T1, class T2, class U1, class U2> | |
| 102 | struct common_type<pair<T1, T2>, pair<U1, U2>>; // since C++23 | |
| 103 | ||
| 98 | 104 | template<class T1, class T2> pair(T1, T2) -> pair<T1, T2>; |
| 99 | 105 | |
| 100 | 106 | template <class T1, class T2> bool operator==(const pair<T1,T2>&, const pair<T1,T2>&); // constexpr in C++14 |
| ... | ... | @@ -214,8 +220,8 @@ template <class T> |
| 214 | 220 | |
| 215 | 221 | */ |
| 216 | 222 | |
| 223 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 217 | 224 | #include <__config> |
| 218 | #include <__debug> | |
| 219 | 225 | #include <__tuple> |
| 220 | 226 | #include <__utility/as_const.h> |
| 221 | 227 | #include <__utility/auto_cast.h> |
| ... | ... | @@ -233,12 +239,20 @@ template <class T> |
| 233 | 239 | #include <__utility/swap.h> |
| 234 | 240 | #include <__utility/to_underlying.h> |
| 235 | 241 | #include <__utility/transaction.h> |
| 242 | #include <__utility/unreachable.h> | |
| 243 | #include <type_traits> | |
| 244 | #include <version> | |
| 245 | ||
| 246 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 247 | # include <iosfwd> | |
| 248 | #endif | |
| 249 | ||
| 250 | // standard-mandated includes | |
| 236 | 251 | #include <compare> |
| 237 | 252 | #include <initializer_list> |
| 238 | #include <version> | |
| 239 | 253 | |
| 240 | 254 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 241 | #pragma GCC system_header | |
| 255 | # pragma GCC system_header | |
| 242 | 256 | #endif |
| 243 | 257 | |
| 244 | 258 | #endif // _LIBCPP_UTILITY |
lib/libcxx/include/valarray+60-62| ... | ... | @@ -341,17 +341,35 @@ template <class T> unspecified2 end(const valarray<T>& v); |
| 341 | 341 | |
| 342 | 342 | */ |
| 343 | 343 | |
| 344 | #include <__algorithm/copy.h> | |
| 345 | #include <__algorithm/count.h> | |
| 346 | #include <__algorithm/fill.h> | |
| 347 | #include <__algorithm/max_element.h> | |
| 348 | #include <__algorithm/min.h> | |
| 349 | #include <__algorithm/min_element.h> | |
| 350 | #include <__algorithm/unwrap_iter.h> | |
| 351 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 344 | 352 | #include <__config> |
| 345 | #include <algorithm> | |
| 353 | #include <__functional/operations.h> | |
| 354 | #include <__memory/allocator.h> | |
| 355 | #include <__memory/uninitialized_algorithms.h> | |
| 356 | #include <__utility/move.h> | |
| 357 | #include <__utility/swap.h> | |
| 346 | 358 | #include <cmath> |
| 347 | 359 | #include <cstddef> |
| 348 | #include <functional> | |
| 349 | #include <initializer_list> | |
| 350 | 360 | #include <new> |
| 351 | 361 | #include <version> |
| 352 | 362 | |
| 363 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 364 | # include <algorithm> | |
| 365 | # include <functional> | |
| 366 | #endif | |
| 367 | ||
| 368 | // standard-mandated includes | |
| 369 | #include <initializer_list> | |
| 370 | ||
| 353 | 371 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 354 | #pragma GCC system_header | |
| 372 | # pragma GCC system_header | |
| 355 | 373 | #endif |
| 356 | 374 | |
| 357 | 375 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -912,10 +930,14 @@ public: |
| 912 | 930 | #endif // _LIBCPP_CXX03_LANG |
| 913 | 931 | |
| 914 | 932 | // unary operators: |
| 915 | valarray operator+() const; | |
| 916 | valarray operator-() const; | |
| 917 | valarray operator~() const; | |
| 918 | valarray<bool> operator!() const; | |
| 933 | _LIBCPP_INLINE_VISIBILITY | |
| 934 | __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray&> > operator+() const; | |
| 935 | _LIBCPP_INLINE_VISIBILITY | |
| 936 | __val_expr<_UnaryOp<negate<_Tp>, const valarray&> > operator-() const; | |
| 937 | _LIBCPP_INLINE_VISIBILITY | |
| 938 | __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray&> > operator~() const; | |
| 939 | _LIBCPP_INLINE_VISIBILITY | |
| 940 | __val_expr<_UnaryOp<logical_not<_Tp>, const valarray&> > operator!() const; | |
| 919 | 941 | |
| 920 | 942 | // computed assignment: |
| 921 | 943 | _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1089,7 +1111,7 @@ template<class _Tp, size_t _Size> |
| 1089 | 1111 | valarray(const _Tp(&)[_Size], size_t) -> valarray<_Tp>; |
| 1090 | 1112 | #endif |
| 1091 | 1113 | |
| 1092 | _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t)) | |
| 1114 | extern template _LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t); | |
| 1093 | 1115 | |
| 1094 | 1116 | template <class _Op, class _Tp> |
| 1095 | 1117 | struct _UnaryOp<_Op, valarray<_Tp> > |
| ... | ... | @@ -1530,21 +1552,21 @@ public: |
| 1530 | 1552 | gslice(size_t __start, const valarray<size_t>& __size, |
| 1531 | 1553 | valarray<size_t>&& __stride) |
| 1532 | 1554 | : __size_(__size), |
| 1533 | __stride_(move(__stride)) | |
| 1555 | __stride_(std::move(__stride)) | |
| 1534 | 1556 | {__init(__start);} |
| 1535 | 1557 | |
| 1536 | 1558 | _LIBCPP_INLINE_VISIBILITY |
| 1537 | 1559 | gslice(size_t __start, valarray<size_t>&& __size, |
| 1538 | 1560 | const valarray<size_t>& __stride) |
| 1539 | : __size_(move(__size)), | |
| 1561 | : __size_(std::move(__size)), | |
| 1540 | 1562 | __stride_(__stride) |
| 1541 | 1563 | {__init(__start);} |
| 1542 | 1564 | |
| 1543 | 1565 | _LIBCPP_INLINE_VISIBILITY |
| 1544 | 1566 | gslice(size_t __start, valarray<size_t>&& __size, |
| 1545 | 1567 | valarray<size_t>&& __stride) |
| 1546 | : __size_(move(__size)), | |
| 1547 | __stride_(move(__stride)) | |
| 1568 | : __size_(std::move(__size)), | |
| 1569 | __stride_(std::move(__stride)) | |
| 1548 | 1570 | {__init(__start);} |
| 1549 | 1571 | |
| 1550 | 1572 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -1695,7 +1717,7 @@ private: |
| 1695 | 1717 | #ifndef _LIBCPP_CXX03_LANG |
| 1696 | 1718 | gslice_array(gslice&& __gs, const valarray<value_type>& __v) |
| 1697 | 1719 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| 1698 | __1d_(move(__gs.__1d_)) | |
| 1720 | __1d_(std::move(__gs.__1d_)) | |
| 1699 | 1721 | {} |
| 1700 | 1722 | #endif // _LIBCPP_CXX03_LANG |
| 1701 | 1723 | |
| ... | ... | @@ -2389,7 +2411,7 @@ private: |
| 2389 | 2411 | _LIBCPP_INLINE_VISIBILITY |
| 2390 | 2412 | indirect_array(valarray<size_t>&& __ia, const valarray<value_type>& __v) |
| 2391 | 2413 | : __vp_(const_cast<value_type*>(__v.__begin_)), |
| 2392 | __1d_(move(__ia)) | |
| 2414 | __1d_(std::move(__ia)) | |
| 2393 | 2415 | {} |
| 2394 | 2416 | |
| 2395 | 2417 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -2608,7 +2630,7 @@ private: |
| 2608 | 2630 | _LIBCPP_INLINE_VISIBILITY |
| 2609 | 2631 | __indirect_expr(valarray<size_t>&& __ia, const _RmExpr& __e) |
| 2610 | 2632 | : __expr_(__e), |
| 2611 | __1d_(move(__ia)) | |
| 2633 | __1d_(std::move(__ia)) | |
| 2612 | 2634 | {} |
| 2613 | 2635 | |
| 2614 | 2636 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -3203,7 +3225,7 @@ inline |
| 3203 | 3225 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3204 | 3226 | valarray<_Tp>::operator[](gslice&& __gs) const |
| 3205 | 3227 | { |
| 3206 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__gs.__1d_), *this)); | |
| 3228 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__gs.__1d_), *this)); | |
| 3207 | 3229 | } |
| 3208 | 3230 | |
| 3209 | 3231 | template <class _Tp> |
| ... | ... | @@ -3211,7 +3233,7 @@ inline |
| 3211 | 3233 | gslice_array<_Tp> |
| 3212 | 3234 | valarray<_Tp>::operator[](gslice&& __gs) |
| 3213 | 3235 | { |
| 3214 | return gslice_array<value_type>(move(__gs), *this); | |
| 3236 | return gslice_array<value_type>(std::move(__gs), *this); | |
| 3215 | 3237 | } |
| 3216 | 3238 | |
| 3217 | 3239 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -3239,7 +3261,7 @@ inline |
| 3239 | 3261 | __val_expr<__mask_expr<const valarray<_Tp>&> > |
| 3240 | 3262 | valarray<_Tp>::operator[](valarray<bool>&& __vb) const |
| 3241 | 3263 | { |
| 3242 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(move(__vb), *this)); | |
| 3264 | return __val_expr<__mask_expr<const valarray&> >(__mask_expr<const valarray&>(std::move(__vb), *this)); | |
| 3243 | 3265 | } |
| 3244 | 3266 | |
| 3245 | 3267 | template <class _Tp> |
| ... | ... | @@ -3247,7 +3269,7 @@ inline |
| 3247 | 3269 | mask_array<_Tp> |
| 3248 | 3270 | valarray<_Tp>::operator[](valarray<bool>&& __vb) |
| 3249 | 3271 | { |
| 3250 | return mask_array<value_type>(move(__vb), *this); | |
| 3272 | return mask_array<value_type>(std::move(__vb), *this); | |
| 3251 | 3273 | } |
| 3252 | 3274 | |
| 3253 | 3275 | #endif // _LIBCPP_CXX03_LANG |
| ... | ... | @@ -3275,7 +3297,7 @@ inline |
| 3275 | 3297 | __val_expr<__indirect_expr<const valarray<_Tp>&> > |
| 3276 | 3298 | valarray<_Tp>::operator[](valarray<size_t>&& __vs) const |
| 3277 | 3299 | { |
| 3278 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(move(__vs), *this)); | |
| 3300 | return __val_expr<__indirect_expr<const valarray&> >(__indirect_expr<const valarray&>(std::move(__vs), *this)); | |
| 3279 | 3301 | } |
| 3280 | 3302 | |
| 3281 | 3303 | template <class _Tp> |
| ... | ... | @@ -3283,69 +3305,45 @@ inline |
| 3283 | 3305 | indirect_array<_Tp> |
| 3284 | 3306 | valarray<_Tp>::operator[](valarray<size_t>&& __vs) |
| 3285 | 3307 | { |
| 3286 | return indirect_array<value_type>(move(__vs), *this); | |
| 3308 | return indirect_array<value_type>(std::move(__vs), *this); | |
| 3287 | 3309 | } |
| 3288 | 3310 | |
| 3289 | 3311 | #endif // _LIBCPP_CXX03_LANG |
| 3290 | 3312 | |
| 3291 | 3313 | template <class _Tp> |
| 3292 | valarray<_Tp> | |
| 3314 | inline | |
| 3315 | __val_expr<_UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&> > | |
| 3293 | 3316 | valarray<_Tp>::operator+() const |
| 3294 | 3317 | { |
| 3295 | valarray<value_type> __r; | |
| 3296 | size_t __n = size(); | |
| 3297 | if (__n) | |
| 3298 | { | |
| 3299 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); | |
| 3300 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) | |
| 3301 | ::new ((void*)__r.__end_) value_type(+*__p); | |
| 3302 | } | |
| 3303 | return __r; | |
| 3318 | using _Op = _UnaryOp<__unary_plus<_Tp>, const valarray<_Tp>&>; | |
| 3319 | return __val_expr<_Op>(_Op(__unary_plus<_Tp>(), *this)); | |
| 3304 | 3320 | } |
| 3305 | 3321 | |
| 3306 | 3322 | template <class _Tp> |
| 3307 | valarray<_Tp> | |
| 3323 | inline | |
| 3324 | __val_expr<_UnaryOp<negate<_Tp>, const valarray<_Tp>&> > | |
| 3308 | 3325 | valarray<_Tp>::operator-() const |
| 3309 | 3326 | { |
| 3310 | valarray<value_type> __r; | |
| 3311 | size_t __n = size(); | |
| 3312 | if (__n) | |
| 3313 | { | |
| 3314 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); | |
| 3315 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) | |
| 3316 | ::new ((void*)__r.__end_) value_type(-*__p); | |
| 3317 | } | |
| 3318 | return __r; | |
| 3327 | using _Op = _UnaryOp<negate<_Tp>, const valarray<_Tp>&>; | |
| 3328 | return __val_expr<_Op>(_Op(negate<_Tp>(), *this)); | |
| 3319 | 3329 | } |
| 3320 | 3330 | |
| 3321 | 3331 | template <class _Tp> |
| 3322 | valarray<_Tp> | |
| 3332 | inline | |
| 3333 | __val_expr<_UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&> > | |
| 3323 | 3334 | valarray<_Tp>::operator~() const |
| 3324 | 3335 | { |
| 3325 | valarray<value_type> __r; | |
| 3326 | size_t __n = size(); | |
| 3327 | if (__n) | |
| 3328 | { | |
| 3329 | __r.__begin_ = __r.__end_ = allocator<value_type>().allocate(__n); | |
| 3330 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) | |
| 3331 | ::new ((void*)__r.__end_) value_type(~*__p); | |
| 3332 | } | |
| 3333 | return __r; | |
| 3336 | using _Op = _UnaryOp<__bit_not<_Tp>, const valarray<_Tp>&>; | |
| 3337 | return __val_expr<_Op>(_Op(__bit_not<_Tp>(), *this)); | |
| 3334 | 3338 | } |
| 3335 | 3339 | |
| 3336 | 3340 | template <class _Tp> |
| 3337 | valarray<bool> | |
| 3341 | inline | |
| 3342 | __val_expr<_UnaryOp<logical_not<_Tp>, const valarray<_Tp>&> > | |
| 3338 | 3343 | valarray<_Tp>::operator!() const |
| 3339 | 3344 | { |
| 3340 | valarray<bool> __r; | |
| 3341 | size_t __n = size(); | |
| 3342 | if (__n) | |
| 3343 | { | |
| 3344 | __r.__begin_ = __r.__end_ = allocator<bool>().allocate(__n); | |
| 3345 | for (const value_type* __p = __begin_; __n; ++__r.__end_, ++__p, --__n) | |
| 3346 | ::new ((void*)__r.__end_) bool(!*__p); | |
| 3347 | } | |
| 3348 | return __r; | |
| 3345 | using _Op = _UnaryOp<logical_not<_Tp>, const valarray<_Tp>&>; | |
| 3346 | return __val_expr<_Op>(_Op(logical_not<_Tp>(), *this)); | |
| 3349 | 3347 | } |
| 3350 | 3348 | |
| 3351 | 3349 | template <class _Tp> |
lib/libcxx/include/variant+33-18| ... | ... | @@ -199,24 +199,36 @@ namespace std { |
| 199 | 199 | |
| 200 | 200 | */ |
| 201 | 201 | |
| 202 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 202 | 203 | #include <__availability> |
| 203 | 204 | #include <__config> |
| 204 | 205 | #include <__functional/hash.h> |
| 206 | #include <__functional/operations.h> | |
| 207 | #include <__functional/unary_function.h> | |
| 205 | 208 | #include <__tuple> |
| 206 | 209 | #include <__utility/forward.h> |
| 210 | #include <__utility/in_place.h> | |
| 211 | #include <__utility/move.h> | |
| 212 | #include <__utility/swap.h> | |
| 207 | 213 | #include <__variant/monostate.h> |
| 208 | #include <compare> | |
| 209 | 214 | #include <exception> |
| 210 | 215 | #include <initializer_list> |
| 211 | 216 | #include <limits> |
| 212 | 217 | #include <new> |
| 213 | 218 | #include <tuple> |
| 214 | 219 | #include <type_traits> |
| 215 | #include <utility> | |
| 216 | 220 | #include <version> |
| 217 | 221 | |
| 222 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 223 | # include <typeinfo> | |
| 224 | # include <utility> | |
| 225 | #endif | |
| 226 | ||
| 227 | // standard-mandated includes | |
| 228 | #include <compare> | |
| 229 | ||
| 218 | 230 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 219 | #pragma GCC system_header | |
| 231 | # pragma GCC system_header | |
| 220 | 232 | #endif |
| 221 | 233 | |
| 222 | 234 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -533,7 +545,7 @@ private: |
| 533 | 545 | template <class _Fp, class... _Vs> |
| 534 | 546 | inline _LIBCPP_INLINE_VISIBILITY |
| 535 | 547 | static constexpr decltype(auto) __dispatch(_Fp __f, _Vs... __vs) { |
| 536 | return _VSTD::__invoke_constexpr( | |
| 548 | return _VSTD::__invoke( | |
| 537 | 549 | static_cast<_Fp>(__f), |
| 538 | 550 | __access::__base::__get_alt<_Is>(static_cast<_Vs>(__vs))...); |
| 539 | 551 | } |
| ... | ... | @@ -549,7 +561,7 @@ private: |
| 549 | 561 | inline _LIBCPP_INLINE_VISIBILITY |
| 550 | 562 | static constexpr auto __make_fdiagonal_impl() { |
| 551 | 563 | return __make_dispatch<_Fp, _Vs...>( |
| 552 | index_sequence<((void)__identity<_Vs>{}, _Ip)...>{}); | |
| 564 | index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{}); | |
| 553 | 565 | } |
| 554 | 566 | |
| 555 | 567 | template <class _Fp, class... _Vs, size_t... _Is> |
| ... | ... | @@ -653,8 +665,8 @@ private: |
| 653 | 665 | __std_visit_exhaustive_visitor_check< |
| 654 | 666 | _Visitor, |
| 655 | 667 | decltype((_VSTD::forward<_Alts>(__alts).__value))...>(); |
| 656 | return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor), | |
| 657 | _VSTD::forward<_Alts>(__alts).__value...); | |
| 668 | return _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor), | |
| 669 | _VSTD::forward<_Alts>(__alts).__value...); | |
| 658 | 670 | } |
| 659 | 671 | _Visitor&& __visitor; |
| 660 | 672 | }; |
| ... | ... | @@ -669,12 +681,12 @@ private: |
| 669 | 681 | _Visitor, |
| 670 | 682 | decltype((_VSTD::forward<_Alts>(__alts).__value))...>(); |
| 671 | 683 | if constexpr (is_void_v<_Rp>) { |
| 672 | _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor), | |
| 673 | _VSTD::forward<_Alts>(__alts).__value...); | |
| 684 | _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor), | |
| 685 | _VSTD::forward<_Alts>(__alts).__value...); | |
| 674 | 686 | } |
| 675 | 687 | else { |
| 676 | return _VSTD::__invoke_constexpr(_VSTD::forward<_Visitor>(__visitor), | |
| 677 | _VSTD::forward<_Alts>(__alts).__value...); | |
| 688 | return _VSTD::__invoke(_VSTD::forward<_Visitor>(__visitor), | |
| 689 | _VSTD::forward<_Alts>(__alts).__value...); | |
| 678 | 690 | } |
| 679 | 691 | } |
| 680 | 692 | |
| ... | ... | @@ -765,8 +777,8 @@ public: |
| 765 | 777 | using __index_t = __variant_index_t<sizeof...(_Types)>; |
| 766 | 778 | |
| 767 | 779 | inline _LIBCPP_INLINE_VISIBILITY |
| 768 | explicit constexpr __base(__valueless_t tag) noexcept | |
| 769 | : __data(tag), __index(__variant_npos<__index_t>) {} | |
| 780 | explicit constexpr __base(__valueless_t __tag) noexcept | |
| 781 | : __data(__tag), __index(__variant_npos<__index_t>) {} | |
| 770 | 782 | |
| 771 | 783 | template <size_t _Ip, class... _Args> |
| 772 | 784 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1121,8 +1133,11 @@ class _LIBCPP_TEMPLATE_VIS __impl |
| 1121 | 1133 | using __base_type = __copy_assignment<__traits<_Types...>>; |
| 1122 | 1134 | |
| 1123 | 1135 | public: |
| 1124 | using __base_type::__base_type; | |
| 1125 | using __base_type::operator=; | |
| 1136 | using __base_type::__base_type; // get in_place_index_t constructor & friends | |
| 1137 | __impl(__impl const&) = default; | |
| 1138 | __impl(__impl&&) = default; | |
| 1139 | __impl& operator=(__impl const&) = default; | |
| 1140 | __impl& operator=(__impl&&) = default; | |
| 1126 | 1141 | |
| 1127 | 1142 | template <size_t _Ip, class _Arg> |
| 1128 | 1143 | inline _LIBCPP_INLINE_VISIBILITY |
| ... | ... | @@ -1186,12 +1201,12 @@ private: |
| 1186 | 1201 | |
| 1187 | 1202 | struct __no_narrowing_check { |
| 1188 | 1203 | template <class _Dest, class _Source> |
| 1189 | using _Apply = __identity<_Dest>; | |
| 1204 | using _Apply = __type_identity<_Dest>; | |
| 1190 | 1205 | }; |
| 1191 | 1206 | |
| 1192 | 1207 | struct __narrowing_check { |
| 1193 | 1208 | template <class _Dest> |
| 1194 | static auto __test_impl(_Dest (&&)[1]) -> __identity<_Dest>; | |
| 1209 | static auto __test_impl(_Dest (&&)[1]) -> __type_identity<_Dest>; | |
| 1195 | 1210 | template <class _Dest, class _Source> |
| 1196 | 1211 | using _Apply _LIBCPP_NODEBUG = decltype(__test_impl<_Dest>({declval<_Source>()})); |
| 1197 | 1212 | }; |
| ... | ... | @@ -1217,7 +1232,7 @@ template <class _Tp, size_t> |
| 1217 | 1232 | struct __overload_bool { |
| 1218 | 1233 | template <class _Up, class _Ap = __uncvref_t<_Up>> |
| 1219 | 1234 | auto operator()(bool, _Up&&) const |
| 1220 | -> enable_if_t<is_same_v<_Ap, bool>, __identity<_Tp>>; | |
| 1235 | -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>; | |
| 1221 | 1236 | }; |
| 1222 | 1237 | |
| 1223 | 1238 | template <size_t _Idx> |
lib/libcxx/include/vector+500-471| ... | ... | @@ -271,20 +271,35 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 |
| 271 | 271 | |
| 272 | 272 | */ |
| 273 | 273 | |
| 274 | #include <__algorithm/copy.h> | |
| 275 | #include <__algorithm/equal.h> | |
| 276 | #include <__algorithm/fill_n.h> | |
| 277 | #include <__algorithm/lexicographical_compare.h> | |
| 278 | #include <__algorithm/remove.h> | |
| 279 | #include <__algorithm/remove_if.h> | |
| 280 | #include <__algorithm/rotate.h> | |
| 281 | #include <__algorithm/unwrap_iter.h> | |
| 282 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 274 | 283 | #include <__bit_reference> |
| 275 | 284 | #include <__config> |
| 276 | 285 | #include <__debug> |
| 277 | #include <__functional_base> | |
| 286 | #include <__format/enable_insertable.h> | |
| 287 | #include <__functional/hash.h> | |
| 288 | #include <__functional/unary_function.h> | |
| 289 | #include <__iterator/advance.h> | |
| 278 | 290 | #include <__iterator/iterator_traits.h> |
| 291 | #include <__iterator/reverse_iterator.h> | |
| 279 | 292 | #include <__iterator/wrap_iter.h> |
| 293 | #include <__memory/allocate_at_least.h> | |
| 294 | #include <__memory/pointer_traits.h> | |
| 295 | #include <__memory/swap_allocator.h> | |
| 280 | 296 | #include <__split_buffer> |
| 281 | 297 | #include <__utility/forward.h> |
| 282 | #include <algorithm> | |
| 298 | #include <__utility/move.h> | |
| 299 | #include <__utility/swap.h> | |
| 283 | 300 | #include <climits> |
| 284 | #include <compare> | |
| 285 | 301 | #include <cstdlib> |
| 286 | 302 | #include <cstring> |
| 287 | #include <initializer_list> | |
| 288 | 303 | #include <iosfwd> // for forward declaration of vector |
| 289 | 304 | #include <limits> |
| 290 | 305 | #include <memory> |
| ... | ... | @@ -292,8 +307,27 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 |
| 292 | 307 | #include <type_traits> |
| 293 | 308 | #include <version> |
| 294 | 309 | |
| 310 | #ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES | |
| 311 | # include <algorithm> | |
| 312 | # include <typeinfo> | |
| 313 | # include <utility> | |
| 314 | #endif | |
| 315 | ||
| 316 | // standard-mandated includes | |
| 317 | ||
| 318 | // [iterator.range] | |
| 319 | #include <__iterator/access.h> | |
| 320 | #include <__iterator/data.h> | |
| 321 | #include <__iterator/empty.h> | |
| 322 | #include <__iterator/reverse_access.h> | |
| 323 | #include <__iterator/size.h> | |
| 324 | ||
| 325 | // [vector.syn] | |
| 326 | #include <compare> | |
| 327 | #include <initializer_list> | |
| 328 | ||
| 295 | 329 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 296 | #pragma GCC system_header | |
| 330 | # pragma GCC system_header | |
| 297 | 331 | #endif |
| 298 | 332 | |
| 299 | 333 | _LIBCPP_PUSH_MACROS |
| ... | ... | @@ -326,12 +360,12 @@ public: |
| 326 | 360 | static_assert((is_same<typename allocator_type::value_type, value_type>::value), |
| 327 | 361 | "Allocator::value_type must be same type as value_type"); |
| 328 | 362 | |
| 329 | _LIBCPP_INLINE_VISIBILITY | |
| 363 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 330 | 364 | vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 331 | 365 | { |
| 332 | 366 | _VSTD::__debug_db_insert_c(this); |
| 333 | 367 | } |
| 334 | _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | |
| 368 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | |
| 335 | 369 | #if _LIBCPP_STD_VER <= 14 |
| 336 | 370 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
| 337 | 371 | #else |
| ... | ... | @@ -341,13 +375,14 @@ public: |
| 341 | 375 | { |
| 342 | 376 | _VSTD::__debug_db_insert_c(this); |
| 343 | 377 | } |
| 344 | explicit vector(size_type __n); | |
| 378 | _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n); | |
| 345 | 379 | #if _LIBCPP_STD_VER > 11 |
| 346 | explicit vector(size_type __n, const allocator_type& __a); | |
| 380 | _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a); | |
| 347 | 381 | #endif |
| 348 | vector(size_type __n, const value_type& __x); | |
| 382 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x); | |
| 349 | 383 | |
| 350 | 384 | template <class = __enable_if_t<__is_allocator<_Allocator>::value> > |
| 385 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 351 | 386 | vector(size_type __n, const value_type& __x, const allocator_type& __a) |
| 352 | 387 | : __end_cap_(nullptr, __a) |
| 353 | 388 | { |
| ... | ... | @@ -360,21 +395,22 @@ public: |
| 360 | 395 | } |
| 361 | 396 | |
| 362 | 397 | template <class _InputIterator> |
| 398 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 363 | 399 | vector(_InputIterator __first, |
| 364 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 365 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 400 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 366 | 401 | is_constructible< |
| 367 | 402 | value_type, |
| 368 | 403 | typename iterator_traits<_InputIterator>::reference>::value, |
| 369 | 404 | _InputIterator>::type __last); |
| 370 | 405 | template <class _InputIterator> |
| 406 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 371 | 407 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, |
| 372 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 373 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 408 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 374 | 409 | is_constructible< |
| 375 | 410 | value_type, |
| 376 | 411 | typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); |
| 377 | 412 | template <class _ForwardIterator> |
| 413 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 378 | 414 | vector(_ForwardIterator __first, |
| 379 | 415 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
| 380 | 416 | is_constructible< |
| ... | ... | @@ -382,19 +418,18 @@ public: |
| 382 | 418 | typename iterator_traits<_ForwardIterator>::reference>::value, |
| 383 | 419 | _ForwardIterator>::type __last); |
| 384 | 420 | template <class _ForwardIterator> |
| 421 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 385 | 422 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, |
| 386 | 423 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
| 387 | 424 | is_constructible< |
| 388 | 425 | value_type, |
| 389 | 426 | typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); |
| 390 | 427 | |
| 391 | _LIBCPP_INLINE_VISIBILITY | |
| 428 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 392 | 429 | ~vector() |
| 393 | 430 | { |
| 394 | 431 | __annotate_delete(); |
| 395 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 396 | __get_db()->__erase_c(this); | |
| 397 | #endif | |
| 432 | std::__debug_db_erase_c(this); | |
| 398 | 433 | |
| 399 | 434 | if (this->__begin_ != nullptr) |
| 400 | 435 | { |
| ... | ... | @@ -403,43 +438,39 @@ public: |
| 403 | 438 | } |
| 404 | 439 | } |
| 405 | 440 | |
| 406 | vector(const vector& __x); | |
| 407 | vector(const vector& __x, const __identity_t<allocator_type>& __a); | |
| 408 | _LIBCPP_INLINE_VISIBILITY | |
| 441 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x); | |
| 442 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a); | |
| 443 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 409 | 444 | vector& operator=(const vector& __x); |
| 410 | 445 | |
| 411 | 446 | #ifndef _LIBCPP_CXX03_LANG |
| 412 | _LIBCPP_INLINE_VISIBILITY | |
| 447 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 413 | 448 | vector(initializer_list<value_type> __il); |
| 414 | 449 | |
| 415 | _LIBCPP_INLINE_VISIBILITY | |
| 450 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 416 | 451 | vector(initializer_list<value_type> __il, const allocator_type& __a); |
| 417 | 452 | |
| 418 | _LIBCPP_INLINE_VISIBILITY | |
| 453 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 454 | vector& operator=(initializer_list<value_type> __il) | |
| 455 | {assign(__il.begin(), __il.end()); return *this;} | |
| 456 | #endif // !_LIBCPP_CXX03_LANG | |
| 457 | ||
| 458 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 419 | 459 | vector(vector&& __x) |
| 420 | 460 | #if _LIBCPP_STD_VER > 14 |
| 421 | _NOEXCEPT; | |
| 461 | noexcept; | |
| 422 | 462 | #else |
| 423 | 463 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
| 424 | 464 | #endif |
| 425 | 465 | |
| 426 | _LIBCPP_INLINE_VISIBILITY | |
| 427 | vector(vector&& __x, const __identity_t<allocator_type>& __a); | |
| 428 | _LIBCPP_INLINE_VISIBILITY | |
| 466 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 467 | vector(vector&& __x, const __type_identity_t<allocator_type>& __a); | |
| 468 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 429 | 469 | vector& operator=(vector&& __x) |
| 430 | 470 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); |
| 431 | 471 | |
| 432 | _LIBCPP_INLINE_VISIBILITY | |
| 433 | vector& operator=(initializer_list<value_type> __il) | |
| 434 | {assign(__il.begin(), __il.end()); return *this;} | |
| 435 | ||
| 436 | #endif // !_LIBCPP_CXX03_LANG | |
| 437 | ||
| 438 | 472 | template <class _InputIterator> |
| 439 | typename enable_if | |
| 440 | < | |
| 441 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 442 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 473 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 443 | 474 | is_constructible< |
| 444 | 475 | value_type, |
| 445 | 476 | typename iterator_traits<_InputIterator>::reference>::value, |
| ... | ... | @@ -447,6 +478,7 @@ public: |
| 447 | 478 | >::type |
| 448 | 479 | assign(_InputIterator __first, _InputIterator __last); |
| 449 | 480 | template <class _ForwardIterator> |
| 481 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 450 | 482 | typename enable_if |
| 451 | 483 | < |
| 452 | 484 | __is_cpp17_forward_iterator<_ForwardIterator>::value && |
| ... | ... | @@ -457,137 +489,120 @@ public: |
| 457 | 489 | >::type |
| 458 | 490 | assign(_ForwardIterator __first, _ForwardIterator __last); |
| 459 | 491 | |
| 460 | void assign(size_type __n, const_reference __u); | |
| 492 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u); | |
| 461 | 493 | |
| 462 | 494 | #ifndef _LIBCPP_CXX03_LANG |
| 463 | _LIBCPP_INLINE_VISIBILITY | |
| 495 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 464 | 496 | void assign(initializer_list<value_type> __il) |
| 465 | 497 | {assign(__il.begin(), __il.end());} |
| 466 | 498 | #endif |
| 467 | 499 | |
| 468 | _LIBCPP_INLINE_VISIBILITY | |
| 500 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 469 | 501 | allocator_type get_allocator() const _NOEXCEPT |
| 470 | 502 | {return this->__alloc();} |
| 471 | 503 | |
| 472 | _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; | |
| 473 | _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; | |
| 474 | _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; | |
| 475 | _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; | |
| 504 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; | |
| 505 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; | |
| 506 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; | |
| 507 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; | |
| 476 | 508 | |
| 477 | _LIBCPP_INLINE_VISIBILITY | |
| 509 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 478 | 510 | reverse_iterator rbegin() _NOEXCEPT |
| 479 | 511 | {return reverse_iterator(end());} |
| 480 | _LIBCPP_INLINE_VISIBILITY | |
| 512 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 481 | 513 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 482 | 514 | {return const_reverse_iterator(end());} |
| 483 | _LIBCPP_INLINE_VISIBILITY | |
| 515 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 484 | 516 | reverse_iterator rend() _NOEXCEPT |
| 485 | 517 | {return reverse_iterator(begin());} |
| 486 | _LIBCPP_INLINE_VISIBILITY | |
| 518 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 487 | 519 | const_reverse_iterator rend() const _NOEXCEPT |
| 488 | 520 | {return const_reverse_iterator(begin());} |
| 489 | 521 | |
| 490 | _LIBCPP_INLINE_VISIBILITY | |
| 522 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 491 | 523 | const_iterator cbegin() const _NOEXCEPT |
| 492 | 524 | {return begin();} |
| 493 | _LIBCPP_INLINE_VISIBILITY | |
| 525 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 494 | 526 | const_iterator cend() const _NOEXCEPT |
| 495 | 527 | {return end();} |
| 496 | _LIBCPP_INLINE_VISIBILITY | |
| 528 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 497 | 529 | const_reverse_iterator crbegin() const _NOEXCEPT |
| 498 | 530 | {return rbegin();} |
| 499 | _LIBCPP_INLINE_VISIBILITY | |
| 531 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 500 | 532 | const_reverse_iterator crend() const _NOEXCEPT |
| 501 | 533 | {return rend();} |
| 502 | 534 | |
| 503 | _LIBCPP_INLINE_VISIBILITY | |
| 535 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 504 | 536 | size_type size() const _NOEXCEPT |
| 505 | 537 | {return static_cast<size_type>(this->__end_ - this->__begin_);} |
| 506 | _LIBCPP_INLINE_VISIBILITY | |
| 538 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 507 | 539 | size_type capacity() const _NOEXCEPT |
| 508 | 540 | {return static_cast<size_type>(__end_cap() - this->__begin_);} |
| 509 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 541 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 510 | 542 | bool empty() const _NOEXCEPT |
| 511 | 543 | {return this->__begin_ == this->__end_;} |
| 512 | size_type max_size() const _NOEXCEPT; | |
| 513 | void reserve(size_type __n); | |
| 514 | void shrink_to_fit() _NOEXCEPT; | |
| 544 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; | |
| 545 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n); | |
| 546 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; | |
| 515 | 547 | |
| 516 | _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT; | |
| 517 | _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT; | |
| 518 | reference at(size_type __n); | |
| 519 | const_reference at(size_type __n) const; | |
| 548 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) _NOEXCEPT; | |
| 549 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT; | |
| 550 | _LIBCPP_CONSTEXPR_AFTER_CXX17 reference at(size_type __n); | |
| 551 | _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const; | |
| 520 | 552 | |
| 521 | _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT | |
| 553 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference front() _NOEXCEPT | |
| 522 | 554 | { |
| 523 | 555 | _LIBCPP_ASSERT(!empty(), "front() called on an empty vector"); |
| 524 | 556 | return *this->__begin_; |
| 525 | 557 | } |
| 526 | _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT | |
| 558 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT | |
| 527 | 559 | { |
| 528 | 560 | _LIBCPP_ASSERT(!empty(), "front() called on an empty vector"); |
| 529 | 561 | return *this->__begin_; |
| 530 | 562 | } |
| 531 | _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT | |
| 563 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference back() _NOEXCEPT | |
| 532 | 564 | { |
| 533 | 565 | _LIBCPP_ASSERT(!empty(), "back() called on an empty vector"); |
| 534 | 566 | return *(this->__end_ - 1); |
| 535 | 567 | } |
| 536 | _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT | |
| 568 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const _NOEXCEPT | |
| 537 | 569 | { |
| 538 | 570 | _LIBCPP_ASSERT(!empty(), "back() called on an empty vector"); |
| 539 | 571 | return *(this->__end_ - 1); |
| 540 | 572 | } |
| 541 | 573 | |
| 542 | _LIBCPP_INLINE_VISIBILITY | |
| 574 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 543 | 575 | value_type* data() _NOEXCEPT |
| 544 | 576 | {return _VSTD::__to_address(this->__begin_);} |
| 545 | _LIBCPP_INLINE_VISIBILITY | |
| 577 | ||
| 578 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 546 | 579 | const value_type* data() const _NOEXCEPT |
| 547 | 580 | {return _VSTD::__to_address(this->__begin_);} |
| 548 | 581 | |
| 549 | #ifdef _LIBCPP_CXX03_LANG | |
| 550 | _LIBCPP_INLINE_VISIBILITY | |
| 551 | void __emplace_back(const value_type& __x) { push_back(__x); } | |
| 552 | #else | |
| 553 | template <class _Arg> | |
| 554 | _LIBCPP_INLINE_VISIBILITY | |
| 555 | void __emplace_back(_Arg&& __arg) { | |
| 556 | emplace_back(_VSTD::forward<_Arg>(__arg)); | |
| 557 | } | |
| 558 | #endif | |
| 559 | ||
| 560 | _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); | |
| 582 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x); | |
| 561 | 583 | |
| 562 | #ifndef _LIBCPP_CXX03_LANG | |
| 563 | _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); | |
| 584 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); | |
| 564 | 585 | |
| 565 | 586 | template <class... _Args> |
| 566 | _LIBCPP_INLINE_VISIBILITY | |
| 587 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 567 | 588 | #if _LIBCPP_STD_VER > 14 |
| 568 | 589 | reference emplace_back(_Args&&... __args); |
| 569 | 590 | #else |
| 570 | 591 | void emplace_back(_Args&&... __args); |
| 571 | 592 | #endif |
| 572 | #endif // !_LIBCPP_CXX03_LANG | |
| 573 | 593 | |
| 574 | _LIBCPP_INLINE_VISIBILITY | |
| 594 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 575 | 595 | void pop_back(); |
| 576 | 596 | |
| 577 | iterator insert(const_iterator __position, const_reference __x); | |
| 597 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x); | |
| 578 | 598 | |
| 579 | #ifndef _LIBCPP_CXX03_LANG | |
| 580 | iterator insert(const_iterator __position, value_type&& __x); | |
| 599 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x); | |
| 581 | 600 | template <class... _Args> |
| 582 | iterator emplace(const_iterator __position, _Args&&... __args); | |
| 583 | #endif // !_LIBCPP_CXX03_LANG | |
| 601 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args); | |
| 584 | 602 | |
| 585 | iterator insert(const_iterator __position, size_type __n, const_reference __x); | |
| 603 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x); | |
| 586 | 604 | template <class _InputIterator> |
| 587 | typename enable_if | |
| 588 | < | |
| 589 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 590 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 605 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 591 | 606 | is_constructible< |
| 592 | 607 | value_type, |
| 593 | 608 | typename iterator_traits<_InputIterator>::reference>::value, |
| ... | ... | @@ -595,6 +610,7 @@ public: |
| 595 | 610 | >::type |
| 596 | 611 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); |
| 597 | 612 | template <class _ForwardIterator> |
| 613 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 598 | 614 | typename enable_if |
| 599 | 615 | < |
| 600 | 616 | __is_cpp17_forward_iterator<_ForwardIterator>::value && |
| ... | ... | @@ -606,27 +622,27 @@ public: |
| 606 | 622 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); |
| 607 | 623 | |
| 608 | 624 | #ifndef _LIBCPP_CXX03_LANG |
| 609 | _LIBCPP_INLINE_VISIBILITY | |
| 625 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 610 | 626 | iterator insert(const_iterator __position, initializer_list<value_type> __il) |
| 611 | 627 | {return insert(__position, __il.begin(), __il.end());} |
| 612 | 628 | #endif |
| 613 | 629 | |
| 614 | _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | |
| 615 | iterator erase(const_iterator __first, const_iterator __last); | |
| 630 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | |
| 631 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last); | |
| 616 | 632 | |
| 617 | _LIBCPP_INLINE_VISIBILITY | |
| 633 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 618 | 634 | void clear() _NOEXCEPT |
| 619 | 635 | { |
| 620 | 636 | size_type __old_size = size(); |
| 621 | 637 | __clear(); |
| 622 | 638 | __annotate_shrink(__old_size); |
| 623 | __invalidate_all_iterators(); | |
| 639 | std::__debug_db_invalidate_all(this); | |
| 624 | 640 | } |
| 625 | 641 | |
| 626 | void resize(size_type __sz); | |
| 627 | void resize(size_type __sz, const_reference __x); | |
| 642 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz); | |
| 643 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x); | |
| 628 | 644 | |
| 629 | void swap(vector&) | |
| 645 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&) | |
| 630 | 646 | #if _LIBCPP_STD_VER >= 14 |
| 631 | 647 | _NOEXCEPT; |
| 632 | 648 | #else |
| ... | ... | @@ -634,16 +650,16 @@ public: |
| 634 | 650 | __is_nothrow_swappable<allocator_type>::value); |
| 635 | 651 | #endif |
| 636 | 652 | |
| 637 | bool __invariants() const; | |
| 653 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; | |
| 638 | 654 | |
| 639 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 655 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 640 | 656 | |
| 641 | 657 | bool __dereferenceable(const const_iterator* __i) const; |
| 642 | 658 | bool __decrementable(const const_iterator* __i) const; |
| 643 | 659 | bool __addable(const const_iterator* __i, ptrdiff_t __n) const; |
| 644 | 660 | bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; |
| 645 | 661 | |
| 646 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 662 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 647 | 663 | |
| 648 | 664 | private: |
| 649 | 665 | pointer __begin_ = nullptr; |
| ... | ... | @@ -651,95 +667,108 @@ private: |
| 651 | 667 | __compressed_pair<pointer, allocator_type> __end_cap_ = |
| 652 | 668 | __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag()); |
| 653 | 669 | |
| 654 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | |
| 655 | 670 | _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); |
| 656 | void __vallocate(size_type __n); | |
| 657 | void __vdeallocate() _NOEXCEPT; | |
| 658 | _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | |
| 659 | void __construct_at_end(size_type __n); | |
| 660 | _LIBCPP_INLINE_VISIBILITY | |
| 671 | ||
| 672 | // Allocate space for __n objects | |
| 673 | // throws length_error if __n > max_size() | |
| 674 | // throws (probably bad_alloc) if memory run out | |
| 675 | // Precondition: __begin_ == __end_ == __end_cap() == 0 | |
| 676 | // Precondition: __n > 0 | |
| 677 | // Postcondition: capacity() >= __n | |
| 678 | // Postcondition: size() == 0 | |
| 679 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { | |
| 680 | if (__n > max_size()) | |
| 681 | __throw_length_error(); | |
| 682 | auto __allocation = std::__allocate_at_least(__alloc(), __n); | |
| 683 | __begin_ = __allocation.ptr; | |
| 684 | __end_ = __allocation.ptr; | |
| 685 | __end_cap() = __begin_ + __allocation.count; | |
| 686 | __annotate_new(0); | |
| 687 | } | |
| 688 | ||
| 689 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT; | |
| 690 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | |
| 691 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n); | |
| 692 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 661 | 693 | void __construct_at_end(size_type __n, const_reference __x); |
| 662 | 694 | template <class _ForwardIterator> |
| 695 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 663 | 696 | typename enable_if |
| 664 | 697 | < |
| 665 | 698 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 666 | 699 | void |
| 667 | 700 | >::type |
| 668 | 701 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n); |
| 669 | void __append(size_type __n); | |
| 670 | void __append(size_type __n, const_reference __x); | |
| 671 | _LIBCPP_INLINE_VISIBILITY | |
| 702 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n); | |
| 703 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x); | |
| 704 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 672 | 705 | iterator __make_iter(pointer __p) _NOEXCEPT; |
| 673 | _LIBCPP_INLINE_VISIBILITY | |
| 706 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 674 | 707 | const_iterator __make_iter(const_pointer __p) const _NOEXCEPT; |
| 675 | void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | |
| 676 | pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | |
| 677 | void __move_range(pointer __from_s, pointer __from_e, pointer __to); | |
| 678 | void __move_assign(vector& __c, true_type) | |
| 708 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v); | |
| 709 | _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p); | |
| 710 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to); | |
| 711 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type) | |
| 679 | 712 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); |
| 680 | void __move_assign(vector& __c, false_type) | |
| 713 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type) | |
| 681 | 714 | _NOEXCEPT_(__alloc_traits::is_always_equal::value); |
| 682 | _LIBCPP_INLINE_VISIBILITY | |
| 715 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 683 | 716 | void __destruct_at_end(pointer __new_last) _NOEXCEPT |
| 684 | 717 | { |
| 685 | __invalidate_iterators_past(__new_last); | |
| 718 | if (!__libcpp_is_constant_evaluated()) | |
| 719 | __invalidate_iterators_past(__new_last); | |
| 686 | 720 | size_type __old_size = size(); |
| 687 | 721 | __base_destruct_at_end(__new_last); |
| 688 | 722 | __annotate_shrink(__old_size); |
| 689 | 723 | } |
| 690 | 724 | |
| 691 | #ifndef _LIBCPP_CXX03_LANG | |
| 692 | 725 | template <class _Up> |
| 693 | _LIBCPP_INLINE_VISIBILITY | |
| 726 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 694 | 727 | inline void __push_back_slow_path(_Up&& __x); |
| 695 | 728 | |
| 696 | 729 | template <class... _Args> |
| 697 | _LIBCPP_INLINE_VISIBILITY | |
| 730 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 698 | 731 | inline void __emplace_back_slow_path(_Args&&... __args); |
| 699 | #else | |
| 700 | template <class _Up> | |
| 701 | _LIBCPP_INLINE_VISIBILITY | |
| 702 | inline void __push_back_slow_path(_Up& __x); | |
| 703 | #endif | |
| 704 | 732 | |
| 705 | 733 | // The following functions are no-ops outside of AddressSanitizer mode. |
| 706 | 734 | // We call annotatations only for the default Allocator because other allocators |
| 707 | 735 | // may not meet the AddressSanitizer alignment constraints. |
| 708 | 736 | // See the documentation for __sanitizer_annotate_contiguous_container for more details. |
| 709 | 737 | #ifndef _LIBCPP_HAS_NO_ASAN |
| 738 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 710 | 739 | void __annotate_contiguous_container(const void *__beg, const void *__end, |
| 711 | 740 | const void *__old_mid, |
| 712 | 741 | const void *__new_mid) const |
| 713 | 742 | { |
| 714 | 743 | |
| 715 | if (__beg && is_same<allocator_type, __default_allocator_type>::value) | |
| 744 | if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value) | |
| 716 | 745 | __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid); |
| 717 | 746 | } |
| 718 | 747 | #else |
| 719 | _LIBCPP_INLINE_VISIBILITY | |
| 748 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 720 | 749 | void __annotate_contiguous_container(const void*, const void*, const void*, |
| 721 | 750 | const void*) const _NOEXCEPT {} |
| 722 | 751 | #endif |
| 723 | _LIBCPP_INLINE_VISIBILITY | |
| 752 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 724 | 753 | void __annotate_new(size_type __current_size) const _NOEXCEPT { |
| 725 | 754 | __annotate_contiguous_container(data(), data() + capacity(), |
| 726 | 755 | data() + capacity(), data() + __current_size); |
| 727 | 756 | } |
| 728 | 757 | |
| 729 | _LIBCPP_INLINE_VISIBILITY | |
| 758 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 730 | 759 | void __annotate_delete() const _NOEXCEPT { |
| 731 | 760 | __annotate_contiguous_container(data(), data() + capacity(), |
| 732 | 761 | data() + size(), data() + capacity()); |
| 733 | 762 | } |
| 734 | 763 | |
| 735 | _LIBCPP_INLINE_VISIBILITY | |
| 764 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 736 | 765 | void __annotate_increase(size_type __n) const _NOEXCEPT |
| 737 | 766 | { |
| 738 | 767 | __annotate_contiguous_container(data(), data() + capacity(), |
| 739 | 768 | data() + size(), data() + size() + __n); |
| 740 | 769 | } |
| 741 | 770 | |
| 742 | _LIBCPP_INLINE_VISIBILITY | |
| 771 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 743 | 772 | void __annotate_shrink(size_type __old_size) const _NOEXCEPT |
| 744 | 773 | { |
| 745 | 774 | __annotate_contiguous_container(data(), data() + capacity(), |
| ... | ... | @@ -747,13 +776,14 @@ private: |
| 747 | 776 | } |
| 748 | 777 | |
| 749 | 778 | struct _ConstructTransaction { |
| 779 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 750 | 780 | explicit _ConstructTransaction(vector &__v, size_type __n) |
| 751 | 781 | : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { |
| 752 | 782 | #ifndef _LIBCPP_HAS_NO_ASAN |
| 753 | 783 | __v_.__annotate_increase(__n); |
| 754 | 784 | #endif |
| 755 | 785 | } |
| 756 | ~_ConstructTransaction() { | |
| 786 | _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() { | |
| 757 | 787 | __v_.__end_ = __pos_; |
| 758 | 788 | #ifndef _LIBCPP_HAS_NO_ASAN |
| 759 | 789 | if (__pos_ != __new_end_) { |
| ... | ... | @@ -772,7 +802,7 @@ private: |
| 772 | 802 | }; |
| 773 | 803 | |
| 774 | 804 | template <class ..._Args> |
| 775 | _LIBCPP_INLINE_VISIBILITY | |
| 805 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 776 | 806 | void __construct_one_at_end(_Args&& ...__args) { |
| 777 | 807 | _ConstructTransaction __tx(*this, 1); |
| 778 | 808 | __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_), |
| ... | ... | @@ -780,23 +810,23 @@ private: |
| 780 | 810 | ++__tx.__pos_; |
| 781 | 811 | } |
| 782 | 812 | |
| 783 | _LIBCPP_INLINE_VISIBILITY | |
| 813 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 784 | 814 | allocator_type& __alloc() _NOEXCEPT |
| 785 | 815 | {return this->__end_cap_.second();} |
| 786 | _LIBCPP_INLINE_VISIBILITY | |
| 816 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 787 | 817 | const allocator_type& __alloc() const _NOEXCEPT |
| 788 | 818 | {return this->__end_cap_.second();} |
| 789 | _LIBCPP_INLINE_VISIBILITY | |
| 819 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 790 | 820 | pointer& __end_cap() _NOEXCEPT |
| 791 | 821 | {return this->__end_cap_.first();} |
| 792 | _LIBCPP_INLINE_VISIBILITY | |
| 822 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 793 | 823 | const pointer& __end_cap() const _NOEXCEPT |
| 794 | 824 | {return this->__end_cap_.first();} |
| 795 | 825 | |
| 796 | _LIBCPP_INLINE_VISIBILITY | |
| 826 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 797 | 827 | void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);} |
| 798 | 828 | |
| 799 | _LIBCPP_INLINE_VISIBILITY | |
| 829 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 800 | 830 | void __base_destruct_at_end(pointer __new_last) _NOEXCEPT { |
| 801 | 831 | pointer __soon_to_be_end = this->__end_; |
| 802 | 832 | while (__new_last != __soon_to_be_end) |
| ... | ... | @@ -804,12 +834,12 @@ private: |
| 804 | 834 | this->__end_ = __new_last; |
| 805 | 835 | } |
| 806 | 836 | |
| 807 | _LIBCPP_INLINE_VISIBILITY | |
| 837 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 808 | 838 | void __copy_assign_alloc(const vector& __c) |
| 809 | 839 | {__copy_assign_alloc(__c, integral_constant<bool, |
| 810 | 840 | __alloc_traits::propagate_on_container_copy_assignment::value>());} |
| 811 | 841 | |
| 812 | _LIBCPP_INLINE_VISIBILITY | |
| 842 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 813 | 843 | void __move_assign_alloc(vector& __c) |
| 814 | 844 | _NOEXCEPT_( |
| 815 | 845 | !__alloc_traits::propagate_on_container_move_assignment::value || |
| ... | ... | @@ -827,7 +857,7 @@ private: |
| 827 | 857 | _VSTD::__throw_out_of_range("vector"); |
| 828 | 858 | } |
| 829 | 859 | |
| 830 | _LIBCPP_INLINE_VISIBILITY | |
| 860 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 831 | 861 | void __copy_assign_alloc(const vector& __c, true_type) |
| 832 | 862 | { |
| 833 | 863 | if (__alloc() != __c.__alloc()) |
| ... | ... | @@ -839,18 +869,18 @@ private: |
| 839 | 869 | __alloc() = __c.__alloc(); |
| 840 | 870 | } |
| 841 | 871 | |
| 842 | _LIBCPP_INLINE_VISIBILITY | |
| 872 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 843 | 873 | void __copy_assign_alloc(const vector&, false_type) |
| 844 | 874 | {} |
| 845 | 875 | |
| 846 | _LIBCPP_INLINE_VISIBILITY | |
| 876 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 847 | 877 | void __move_assign_alloc(vector& __c, true_type) |
| 848 | 878 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| 849 | 879 | { |
| 850 | 880 | __alloc() = _VSTD::move(__c.__alloc()); |
| 851 | 881 | } |
| 852 | 882 | |
| 853 | _LIBCPP_INLINE_VISIBILITY | |
| 883 | _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 854 | 884 | void __move_assign_alloc(vector&, false_type) |
| 855 | 885 | _NOEXCEPT |
| 856 | 886 | {} |
| ... | ... | @@ -875,56 +905,46 @@ vector(_InputIterator, _InputIterator, _Alloc) |
| 875 | 905 | #endif |
| 876 | 906 | |
| 877 | 907 | template <class _Tp, class _Allocator> |
| 908 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 878 | 909 | void |
| 879 | 910 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) |
| 880 | 911 | { |
| 881 | ||
| 882 | 912 | __annotate_delete(); |
| 883 | _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_); | |
| 913 | using _RevIter = std::reverse_iterator<pointer>; | |
| 914 | __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( | |
| 915 | __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_)) | |
| 916 | .base(); | |
| 884 | 917 | _VSTD::swap(this->__begin_, __v.__begin_); |
| 885 | 918 | _VSTD::swap(this->__end_, __v.__end_); |
| 886 | 919 | _VSTD::swap(this->__end_cap(), __v.__end_cap()); |
| 887 | 920 | __v.__first_ = __v.__begin_; |
| 888 | 921 | __annotate_new(size()); |
| 889 | __invalidate_all_iterators(); | |
| 922 | std::__debug_db_invalidate_all(this); | |
| 890 | 923 | } |
| 891 | 924 | |
| 892 | 925 | template <class _Tp, class _Allocator> |
| 926 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 893 | 927 | typename vector<_Tp, _Allocator>::pointer |
| 894 | 928 | vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) |
| 895 | 929 | { |
| 896 | 930 | __annotate_delete(); |
| 897 | 931 | pointer __r = __v.__begin_; |
| 898 | _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_); | |
| 899 | _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_); | |
| 932 | using _RevIter = std::reverse_iterator<pointer>; | |
| 933 | __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept( | |
| 934 | __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_)) | |
| 935 | .base(); | |
| 936 | __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_); | |
| 900 | 937 | _VSTD::swap(this->__begin_, __v.__begin_); |
| 901 | 938 | _VSTD::swap(this->__end_, __v.__end_); |
| 902 | 939 | _VSTD::swap(this->__end_cap(), __v.__end_cap()); |
| 903 | 940 | __v.__first_ = __v.__begin_; |
| 904 | 941 | __annotate_new(size()); |
| 905 | __invalidate_all_iterators(); | |
| 942 | std::__debug_db_invalidate_all(this); | |
| 906 | 943 | return __r; |
| 907 | 944 | } |
| 908 | 945 | |
| 909 | // Allocate space for __n objects | |
| 910 | // throws length_error if __n > max_size() | |
| 911 | // throws (probably bad_alloc) if memory run out | |
| 912 | // Precondition: __begin_ == __end_ == __end_cap() == 0 | |
| 913 | // Precondition: __n > 0 | |
| 914 | // Postcondition: capacity() == __n | |
| 915 | // Postcondition: size() == 0 | |
| 916 | template <class _Tp, class _Allocator> | |
| 917 | void | |
| 918 | vector<_Tp, _Allocator>::__vallocate(size_type __n) | |
| 919 | { | |
| 920 | if (__n > max_size()) | |
| 921 | this->__throw_length_error(); | |
| 922 | this->__begin_ = this->__end_ = __alloc_traits::allocate(this->__alloc(), __n); | |
| 923 | this->__end_cap() = this->__begin_ + __n; | |
| 924 | __annotate_new(0); | |
| 925 | } | |
| 926 | ||
| 927 | 946 | template <class _Tp, class _Allocator> |
| 947 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 928 | 948 | void |
| 929 | 949 | vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT |
| 930 | 950 | { |
| ... | ... | @@ -937,6 +957,7 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT |
| 937 | 957 | } |
| 938 | 958 | |
| 939 | 959 | template <class _Tp, class _Allocator> |
| 960 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 940 | 961 | typename vector<_Tp, _Allocator>::size_type |
| 941 | 962 | vector<_Tp, _Allocator>::max_size() const _NOEXCEPT |
| 942 | 963 | { |
| ... | ... | @@ -946,6 +967,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT |
| 946 | 967 | |
| 947 | 968 | // Precondition: __new_size > capacity() |
| 948 | 969 | template <class _Tp, class _Allocator> |
| 970 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 949 | 971 | inline _LIBCPP_INLINE_VISIBILITY |
| 950 | 972 | typename vector<_Tp, _Allocator>::size_type |
| 951 | 973 | vector<_Tp, _Allocator>::__recommend(size_type __new_size) const |
| ... | ... | @@ -965,6 +987,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const |
| 965 | 987 | // Precondition: size() + __n <= capacity() |
| 966 | 988 | // Postcondition: size() == size() + __n |
| 967 | 989 | template <class _Tp, class _Allocator> |
| 990 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 968 | 991 | void |
| 969 | 992 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 970 | 993 | { |
| ... | ... | @@ -982,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) |
| 982 | 1005 | // Postcondition: size() == old size() + __n |
| 983 | 1006 | // Postcondition: [i] == __x for all i in [size() - __n, __n) |
| 984 | 1007 | template <class _Tp, class _Allocator> |
| 1008 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 985 | 1009 | inline |
| 986 | 1010 | void |
| 987 | 1011 | vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
| ... | ... | @@ -995,6 +1019,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) |
| 995 | 1019 | |
| 996 | 1020 | template <class _Tp, class _Allocator> |
| 997 | 1021 | template <class _ForwardIterator> |
| 1022 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 998 | 1023 | typename enable_if |
| 999 | 1024 | < |
| 1000 | 1025 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -1002,8 +1027,8 @@ typename enable_if |
| 1002 | 1027 | >::type |
| 1003 | 1028 | vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n) |
| 1004 | 1029 | { |
| 1005 | _ConstructTransaction __tx(*this, __n); | |
| 1006 | _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_); | |
| 1030 | _ConstructTransaction __tx(*this, __n); | |
| 1031 | __tx.__pos_ = std::__uninitialized_allocator_copy(__alloc(), __first, __last, __tx.__pos_); | |
| 1007 | 1032 | } |
| 1008 | 1033 | |
| 1009 | 1034 | // Default constructs __n objects starting at __end_ |
| ... | ... | @@ -1011,6 +1036,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt |
| 1011 | 1036 | // Postcondition: size() == size() + __n |
| 1012 | 1037 | // Exception safety: strong. |
| 1013 | 1038 | template <class _Tp, class _Allocator> |
| 1039 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1014 | 1040 | void |
| 1015 | 1041 | vector<_Tp, _Allocator>::__append(size_type __n) |
| 1016 | 1042 | { |
| ... | ... | @@ -1030,6 +1056,7 @@ vector<_Tp, _Allocator>::__append(size_type __n) |
| 1030 | 1056 | // Postcondition: size() == size() + __n |
| 1031 | 1057 | // Exception safety: strong. |
| 1032 | 1058 | template <class _Tp, class _Allocator> |
| 1059 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1033 | 1060 | void |
| 1034 | 1061 | vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) |
| 1035 | 1062 | { |
| ... | ... | @@ -1045,6 +1072,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) |
| 1045 | 1072 | } |
| 1046 | 1073 | |
| 1047 | 1074 | template <class _Tp, class _Allocator> |
| 1075 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1048 | 1076 | vector<_Tp, _Allocator>::vector(size_type __n) |
| 1049 | 1077 | { |
| 1050 | 1078 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1057,6 +1085,7 @@ vector<_Tp, _Allocator>::vector(size_type __n) |
| 1057 | 1085 | |
| 1058 | 1086 | #if _LIBCPP_STD_VER > 11 |
| 1059 | 1087 | template <class _Tp, class _Allocator> |
| 1088 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1060 | 1089 | vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) |
| 1061 | 1090 | : __end_cap_(nullptr, __a) |
| 1062 | 1091 | { |
| ... | ... | @@ -1070,6 +1099,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) |
| 1070 | 1099 | #endif |
| 1071 | 1100 | |
| 1072 | 1101 | template <class _Tp, class _Allocator> |
| 1102 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1073 | 1103 | vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) |
| 1074 | 1104 | { |
| 1075 | 1105 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1082,9 +1112,9 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) |
| 1082 | 1112 | |
| 1083 | 1113 | template <class _Tp, class _Allocator> |
| 1084 | 1114 | template <class _InputIterator> |
| 1115 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1085 | 1116 | vector<_Tp, _Allocator>::vector(_InputIterator __first, |
| 1086 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 1087 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 1117 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 1088 | 1118 | is_constructible< |
| 1089 | 1119 | value_type, |
| 1090 | 1120 | typename iterator_traits<_InputIterator>::reference>::value, |
| ... | ... | @@ -1092,14 +1122,14 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, |
| 1092 | 1122 | { |
| 1093 | 1123 | _VSTD::__debug_db_insert_c(this); |
| 1094 | 1124 | for (; __first != __last; ++__first) |
| 1095 | __emplace_back(*__first); | |
| 1125 | emplace_back(*__first); | |
| 1096 | 1126 | } |
| 1097 | 1127 | |
| 1098 | 1128 | template <class _Tp, class _Allocator> |
| 1099 | 1129 | template <class _InputIterator> |
| 1130 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1100 | 1131 | vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, |
| 1101 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 1102 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 1132 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 1103 | 1133 | is_constructible< |
| 1104 | 1134 | value_type, |
| 1105 | 1135 | typename iterator_traits<_InputIterator>::reference>::value>::type*) |
| ... | ... | @@ -1107,11 +1137,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c |
| 1107 | 1137 | { |
| 1108 | 1138 | _VSTD::__debug_db_insert_c(this); |
| 1109 | 1139 | for (; __first != __last; ++__first) |
| 1110 | __emplace_back(*__first); | |
| 1140 | emplace_back(*__first); | |
| 1111 | 1141 | } |
| 1112 | 1142 | |
| 1113 | 1143 | template <class _Tp, class _Allocator> |
| 1114 | 1144 | template <class _ForwardIterator> |
| 1145 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1115 | 1146 | vector<_Tp, _Allocator>::vector(_ForwardIterator __first, |
| 1116 | 1147 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
| 1117 | 1148 | is_constructible< |
| ... | ... | @@ -1130,6 +1161,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, |
| 1130 | 1161 | |
| 1131 | 1162 | template <class _Tp, class _Allocator> |
| 1132 | 1163 | template <class _ForwardIterator> |
| 1164 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1133 | 1165 | vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, |
| 1134 | 1166 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value && |
| 1135 | 1167 | is_constructible< |
| ... | ... | @@ -1147,6 +1179,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las |
| 1147 | 1179 | } |
| 1148 | 1180 | |
| 1149 | 1181 | template <class _Tp, class _Allocator> |
| 1182 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1150 | 1183 | vector<_Tp, _Allocator>::vector(const vector& __x) |
| 1151 | 1184 | : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) |
| 1152 | 1185 | { |
| ... | ... | @@ -1160,7 +1193,8 @@ vector<_Tp, _Allocator>::vector(const vector& __x) |
| 1160 | 1193 | } |
| 1161 | 1194 | |
| 1162 | 1195 | template <class _Tp, class _Allocator> |
| 1163 | vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_type>& __a) | |
| 1196 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1197 | vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | |
| 1164 | 1198 | : __end_cap_(nullptr, __a) |
| 1165 | 1199 | { |
| 1166 | 1200 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1172,22 +1206,19 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t<allocator_ |
| 1172 | 1206 | } |
| 1173 | 1207 | } |
| 1174 | 1208 | |
| 1175 | #ifndef _LIBCPP_CXX03_LANG | |
| 1176 | ||
| 1177 | 1209 | template <class _Tp, class _Allocator> |
| 1210 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1178 | 1211 | inline _LIBCPP_INLINE_VISIBILITY |
| 1179 | 1212 | vector<_Tp, _Allocator>::vector(vector&& __x) |
| 1180 | 1213 | #if _LIBCPP_STD_VER > 14 |
| 1181 | _NOEXCEPT | |
| 1214 | noexcept | |
| 1182 | 1215 | #else |
| 1183 | 1216 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) |
| 1184 | 1217 | #endif |
| 1185 | 1218 | : __end_cap_(nullptr, _VSTD::move(__x.__alloc())) |
| 1186 | 1219 | { |
| 1187 | 1220 | _VSTD::__debug_db_insert_c(this); |
| 1188 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1189 | __get_db()->swap(this, _VSTD::addressof(__x)); | |
| 1190 | #endif | |
| 1221 | std::__debug_db_swap(this, std::addressof(__x)); | |
| 1191 | 1222 | this->__begin_ = __x.__begin_; |
| 1192 | 1223 | this->__end_ = __x.__end_; |
| 1193 | 1224 | this->__end_cap() = __x.__end_cap(); |
| ... | ... | @@ -1195,8 +1226,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x) |
| 1195 | 1226 | } |
| 1196 | 1227 | |
| 1197 | 1228 | template <class _Tp, class _Allocator> |
| 1229 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1198 | 1230 | inline _LIBCPP_INLINE_VISIBILITY |
| 1199 | vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type>& __a) | |
| 1231 | vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a) | |
| 1200 | 1232 | : __end_cap_(nullptr, __a) |
| 1201 | 1233 | { |
| 1202 | 1234 | _VSTD::__debug_db_insert_c(this); |
| ... | ... | @@ -1206,9 +1238,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type> |
| 1206 | 1238 | this->__end_ = __x.__end_; |
| 1207 | 1239 | this->__end_cap() = __x.__end_cap(); |
| 1208 | 1240 | __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; |
| 1209 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1210 | __get_db()->swap(this, _VSTD::addressof(__x)); | |
| 1211 | #endif | |
| 1241 | std::__debug_db_swap(this, std::addressof(__x)); | |
| 1212 | 1242 | } |
| 1213 | 1243 | else |
| 1214 | 1244 | { |
| ... | ... | @@ -1217,7 +1247,10 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t<allocator_type> |
| 1217 | 1247 | } |
| 1218 | 1248 | } |
| 1219 | 1249 | |
| 1250 | #ifndef _LIBCPP_CXX03_LANG | |
| 1251 | ||
| 1220 | 1252 | template <class _Tp, class _Allocator> |
| 1253 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1221 | 1254 | inline _LIBCPP_INLINE_VISIBILITY |
| 1222 | 1255 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) |
| 1223 | 1256 | { |
| ... | ... | @@ -1230,6 +1263,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) |
| 1230 | 1263 | } |
| 1231 | 1264 | |
| 1232 | 1265 | template <class _Tp, class _Allocator> |
| 1266 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1233 | 1267 | inline _LIBCPP_INLINE_VISIBILITY |
| 1234 | 1268 | vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) |
| 1235 | 1269 | : __end_cap_(nullptr, __a) |
| ... | ... | @@ -1242,7 +1276,10 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat |
| 1242 | 1276 | } |
| 1243 | 1277 | } |
| 1244 | 1278 | |
| 1279 | #endif // _LIBCPP_CXX03_LANG | |
| 1280 | ||
| 1245 | 1281 | template <class _Tp, class _Allocator> |
| 1282 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1246 | 1283 | inline _LIBCPP_INLINE_VISIBILITY |
| 1247 | 1284 | vector<_Tp, _Allocator>& |
| 1248 | 1285 | vector<_Tp, _Allocator>::operator=(vector&& __x) |
| ... | ... | @@ -1254,6 +1291,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x) |
| 1254 | 1291 | } |
| 1255 | 1292 | |
| 1256 | 1293 | template <class _Tp, class _Allocator> |
| 1294 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1257 | 1295 | void |
| 1258 | 1296 | vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) |
| 1259 | 1297 | _NOEXCEPT_(__alloc_traits::is_always_equal::value) |
| ... | ... | @@ -1268,6 +1306,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) |
| 1268 | 1306 | } |
| 1269 | 1307 | |
| 1270 | 1308 | template <class _Tp, class _Allocator> |
| 1309 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1271 | 1310 | void |
| 1272 | 1311 | vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) |
| 1273 | 1312 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| ... | ... | @@ -1278,14 +1317,11 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) |
| 1278 | 1317 | this->__end_ = __c.__end_; |
| 1279 | 1318 | this->__end_cap() = __c.__end_cap(); |
| 1280 | 1319 | __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; |
| 1281 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1282 | __get_db()->swap(this, _VSTD::addressof(__c)); | |
| 1283 | #endif | |
| 1320 | std::__debug_db_swap(this, std::addressof(__c)); | |
| 1284 | 1321 | } |
| 1285 | 1322 | |
| 1286 | #endif // !_LIBCPP_CXX03_LANG | |
| 1287 | ||
| 1288 | 1323 | template <class _Tp, class _Allocator> |
| 1324 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1289 | 1325 | inline _LIBCPP_INLINE_VISIBILITY |
| 1290 | 1326 | vector<_Tp, _Allocator>& |
| 1291 | 1327 | vector<_Tp, _Allocator>::operator=(const vector& __x) |
| ... | ... | @@ -1300,10 +1336,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x) |
| 1300 | 1336 | |
| 1301 | 1337 | template <class _Tp, class _Allocator> |
| 1302 | 1338 | template <class _InputIterator> |
| 1303 | typename enable_if | |
| 1304 | < | |
| 1305 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 1306 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 1339 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 1307 | 1340 | is_constructible< |
| 1308 | 1341 | _Tp, |
| 1309 | 1342 | typename iterator_traits<_InputIterator>::reference>::value, |
| ... | ... | @@ -1313,11 +1346,12 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last) |
| 1313 | 1346 | { |
| 1314 | 1347 | clear(); |
| 1315 | 1348 | for (; __first != __last; ++__first) |
| 1316 | __emplace_back(*__first); | |
| 1349 | emplace_back(*__first); | |
| 1317 | 1350 | } |
| 1318 | 1351 | |
| 1319 | 1352 | template <class _Tp, class _Allocator> |
| 1320 | 1353 | template <class _ForwardIterator> |
| 1354 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1321 | 1355 | typename enable_if |
| 1322 | 1356 | < |
| 1323 | 1357 | __is_cpp17_forward_iterator<_ForwardIterator>::value && |
| ... | ... | @@ -1351,10 +1385,11 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las |
| 1351 | 1385 | __vallocate(__recommend(__new_size)); |
| 1352 | 1386 | __construct_at_end(__first, __last, __new_size); |
| 1353 | 1387 | } |
| 1354 | __invalidate_all_iterators(); | |
| 1388 | std::__debug_db_invalidate_all(this); | |
| 1355 | 1389 | } |
| 1356 | 1390 | |
| 1357 | 1391 | template <class _Tp, class _Allocator> |
| 1392 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1358 | 1393 | void |
| 1359 | 1394 | vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) |
| 1360 | 1395 | { |
| ... | ... | @@ -1373,66 +1408,47 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) |
| 1373 | 1408 | __vallocate(__recommend(static_cast<size_type>(__n))); |
| 1374 | 1409 | __construct_at_end(__n, __u); |
| 1375 | 1410 | } |
| 1376 | __invalidate_all_iterators(); | |
| 1377 | } | |
| 1378 | ||
| 1379 | template <class _Tp, class _Allocator> | |
| 1380 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1381 | typename vector<_Tp, _Allocator>::iterator | |
| 1382 | vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT | |
| 1383 | { | |
| 1384 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1385 | return iterator(this, __p); | |
| 1386 | #else | |
| 1387 | return iterator(__p); | |
| 1388 | #endif | |
| 1389 | } | |
| 1390 | ||
| 1391 | template <class _Tp, class _Allocator> | |
| 1392 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1393 | typename vector<_Tp, _Allocator>::const_iterator | |
| 1394 | vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT | |
| 1395 | { | |
| 1396 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1397 | return const_iterator(this, __p); | |
| 1398 | #else | |
| 1399 | return const_iterator(__p); | |
| 1400 | #endif | |
| 1411 | std::__debug_db_invalidate_all(this); | |
| 1401 | 1412 | } |
| 1402 | 1413 | |
| 1403 | 1414 | template <class _Tp, class _Allocator> |
| 1415 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1404 | 1416 | inline _LIBCPP_INLINE_VISIBILITY |
| 1405 | 1417 | typename vector<_Tp, _Allocator>::iterator |
| 1406 | 1418 | vector<_Tp, _Allocator>::begin() _NOEXCEPT |
| 1407 | 1419 | { |
| 1408 | return __make_iter(this->__begin_); | |
| 1420 | return iterator(this, this->__begin_); | |
| 1409 | 1421 | } |
| 1410 | 1422 | |
| 1411 | 1423 | template <class _Tp, class _Allocator> |
| 1424 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1412 | 1425 | inline _LIBCPP_INLINE_VISIBILITY |
| 1413 | 1426 | typename vector<_Tp, _Allocator>::const_iterator |
| 1414 | 1427 | vector<_Tp, _Allocator>::begin() const _NOEXCEPT |
| 1415 | 1428 | { |
| 1416 | return __make_iter(this->__begin_); | |
| 1429 | return const_iterator(this, this->__begin_); | |
| 1417 | 1430 | } |
| 1418 | 1431 | |
| 1419 | 1432 | template <class _Tp, class _Allocator> |
| 1433 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1420 | 1434 | inline _LIBCPP_INLINE_VISIBILITY |
| 1421 | 1435 | typename vector<_Tp, _Allocator>::iterator |
| 1422 | 1436 | vector<_Tp, _Allocator>::end() _NOEXCEPT |
| 1423 | 1437 | { |
| 1424 | return __make_iter(this->__end_); | |
| 1438 | return iterator(this, this->__end_); | |
| 1425 | 1439 | } |
| 1426 | 1440 | |
| 1427 | 1441 | template <class _Tp, class _Allocator> |
| 1442 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1428 | 1443 | inline _LIBCPP_INLINE_VISIBILITY |
| 1429 | 1444 | typename vector<_Tp, _Allocator>::const_iterator |
| 1430 | 1445 | vector<_Tp, _Allocator>::end() const _NOEXCEPT |
| 1431 | 1446 | { |
| 1432 | return __make_iter(this->__end_); | |
| 1447 | return const_iterator(this, this->__end_); | |
| 1433 | 1448 | } |
| 1434 | 1449 | |
| 1435 | 1450 | template <class _Tp, class _Allocator> |
| 1451 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1436 | 1452 | inline _LIBCPP_INLINE_VISIBILITY |
| 1437 | 1453 | typename vector<_Tp, _Allocator>::reference |
| 1438 | 1454 | vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT |
| ... | ... | @@ -1442,6 +1458,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT |
| 1442 | 1458 | } |
| 1443 | 1459 | |
| 1444 | 1460 | template <class _Tp, class _Allocator> |
| 1461 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1445 | 1462 | inline _LIBCPP_INLINE_VISIBILITY |
| 1446 | 1463 | typename vector<_Tp, _Allocator>::const_reference |
| 1447 | 1464 | vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT |
| ... | ... | @@ -1451,6 +1468,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT |
| 1451 | 1468 | } |
| 1452 | 1469 | |
| 1453 | 1470 | template <class _Tp, class _Allocator> |
| 1471 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1454 | 1472 | typename vector<_Tp, _Allocator>::reference |
| 1455 | 1473 | vector<_Tp, _Allocator>::at(size_type __n) |
| 1456 | 1474 | { |
| ... | ... | @@ -1460,6 +1478,7 @@ vector<_Tp, _Allocator>::at(size_type __n) |
| 1460 | 1478 | } |
| 1461 | 1479 | |
| 1462 | 1480 | template <class _Tp, class _Allocator> |
| 1481 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1463 | 1482 | typename vector<_Tp, _Allocator>::const_reference |
| 1464 | 1483 | vector<_Tp, _Allocator>::at(size_type __n) const |
| 1465 | 1484 | { |
| ... | ... | @@ -1469,6 +1488,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const |
| 1469 | 1488 | } |
| 1470 | 1489 | |
| 1471 | 1490 | template <class _Tp, class _Allocator> |
| 1491 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1472 | 1492 | void |
| 1473 | 1493 | vector<_Tp, _Allocator>::reserve(size_type __n) |
| 1474 | 1494 | { |
| ... | ... | @@ -1483,6 +1503,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n) |
| 1483 | 1503 | } |
| 1484 | 1504 | |
| 1485 | 1505 | template <class _Tp, class _Allocator> |
| 1506 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1486 | 1507 | void |
| 1487 | 1508 | vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 1488 | 1509 | { |
| ... | ... | @@ -1506,12 +1527,9 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 1506 | 1527 | |
| 1507 | 1528 | template <class _Tp, class _Allocator> |
| 1508 | 1529 | template <class _Up> |
| 1530 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1509 | 1531 | void |
| 1510 | #ifndef _LIBCPP_CXX03_LANG | |
| 1511 | 1532 | vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) |
| 1512 | #else | |
| 1513 | vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) | |
| 1514 | #endif | |
| 1515 | 1533 | { |
| 1516 | 1534 | allocator_type& __a = this->__alloc(); |
| 1517 | 1535 | __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a); |
| ... | ... | @@ -1522,6 +1540,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) |
| 1522 | 1540 | } |
| 1523 | 1541 | |
| 1524 | 1542 | template <class _Tp, class _Allocator> |
| 1543 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1525 | 1544 | inline _LIBCPP_INLINE_VISIBILITY |
| 1526 | 1545 | void |
| 1527 | 1546 | vector<_Tp, _Allocator>::push_back(const_reference __x) |
| ... | ... | @@ -1534,9 +1553,8 @@ vector<_Tp, _Allocator>::push_back(const_reference __x) |
| 1534 | 1553 | __push_back_slow_path(__x); |
| 1535 | 1554 | } |
| 1536 | 1555 | |
| 1537 | #ifndef _LIBCPP_CXX03_LANG | |
| 1538 | ||
| 1539 | 1556 | template <class _Tp, class _Allocator> |
| 1557 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1540 | 1558 | inline _LIBCPP_INLINE_VISIBILITY |
| 1541 | 1559 | void |
| 1542 | 1560 | vector<_Tp, _Allocator>::push_back(value_type&& __x) |
| ... | ... | @@ -1551,6 +1569,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x) |
| 1551 | 1569 | |
| 1552 | 1570 | template <class _Tp, class _Allocator> |
| 1553 | 1571 | template <class... _Args> |
| 1572 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1554 | 1573 | void |
| 1555 | 1574 | vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) |
| 1556 | 1575 | { |
| ... | ... | @@ -1564,6 +1583,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) |
| 1564 | 1583 | |
| 1565 | 1584 | template <class _Tp, class _Allocator> |
| 1566 | 1585 | template <class... _Args> |
| 1586 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1567 | 1587 | inline |
| 1568 | 1588 | #if _LIBCPP_STD_VER > 14 |
| 1569 | 1589 | typename vector<_Tp, _Allocator>::reference |
| ... | ... | @@ -1583,9 +1603,8 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) |
| 1583 | 1603 | #endif |
| 1584 | 1604 | } |
| 1585 | 1605 | |
| 1586 | #endif // !_LIBCPP_CXX03_LANG | |
| 1587 | ||
| 1588 | 1606 | template <class _Tp, class _Allocator> |
| 1607 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1589 | 1608 | inline |
| 1590 | 1609 | void |
| 1591 | 1610 | vector<_Tp, _Allocator>::pop_back() |
| ... | ... | @@ -1595,6 +1614,7 @@ vector<_Tp, _Allocator>::pop_back() |
| 1595 | 1614 | } |
| 1596 | 1615 | |
| 1597 | 1616 | template <class _Tp, class _Allocator> |
| 1617 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1598 | 1618 | inline _LIBCPP_INLINE_VISIBILITY |
| 1599 | 1619 | typename vector<_Tp, _Allocator>::iterator |
| 1600 | 1620 | vector<_Tp, _Allocator>::erase(const_iterator __position) |
| ... | ... | @@ -1606,12 +1626,14 @@ vector<_Tp, _Allocator>::erase(const_iterator __position) |
| 1606 | 1626 | difference_type __ps = __position - cbegin(); |
| 1607 | 1627 | pointer __p = this->__begin_ + __ps; |
| 1608 | 1628 | this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p)); |
| 1609 | this->__invalidate_iterators_past(__p-1); | |
| 1610 | iterator __r = __make_iter(__p); | |
| 1629 | if (!__libcpp_is_constant_evaluated()) | |
| 1630 | this->__invalidate_iterators_past(__p - 1); | |
| 1631 | iterator __r = iterator(this, __p); | |
| 1611 | 1632 | return __r; |
| 1612 | 1633 | } |
| 1613 | 1634 | |
| 1614 | 1635 | template <class _Tp, class _Allocator> |
| 1636 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1615 | 1637 | typename vector<_Tp, _Allocator>::iterator |
| 1616 | 1638 | vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 1617 | 1639 | { |
| ... | ... | @@ -1624,13 +1646,15 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 1624 | 1646 | pointer __p = this->__begin_ + (__first - begin()); |
| 1625 | 1647 | if (__first != __last) { |
| 1626 | 1648 | this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p)); |
| 1627 | this->__invalidate_iterators_past(__p - 1); | |
| 1649 | if (!__libcpp_is_constant_evaluated()) | |
| 1650 | this->__invalidate_iterators_past(__p - 1); | |
| 1628 | 1651 | } |
| 1629 | iterator __r = __make_iter(__p); | |
| 1652 | iterator __r = iterator(this, __p); | |
| 1630 | 1653 | return __r; |
| 1631 | 1654 | } |
| 1632 | 1655 | |
| 1633 | 1656 | template <class _Tp, class _Allocator> |
| 1657 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1634 | 1658 | void |
| 1635 | 1659 | vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) |
| 1636 | 1660 | { |
| ... | ... | @@ -1650,13 +1674,15 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe |
| 1650 | 1674 | } |
| 1651 | 1675 | |
| 1652 | 1676 | template <class _Tp, class _Allocator> |
| 1677 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1653 | 1678 | typename vector<_Tp, _Allocator>::iterator |
| 1654 | 1679 | vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) |
| 1655 | 1680 | { |
| 1656 | 1681 | _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this, |
| 1657 | 1682 | "vector::insert(iterator, x) called with an iterator not referring to this vector"); |
| 1658 | 1683 | pointer __p = this->__begin_ + (__position - begin()); |
| 1659 | if (this->__end_ < this->__end_cap()) | |
| 1684 | // We can't compare unrelated pointers inside constant expressions | |
| 1685 | if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap()) | |
| 1660 | 1686 | { |
| 1661 | 1687 | if (__p == this->__end_) |
| 1662 | 1688 | { |
| ... | ... | @@ -1678,12 +1704,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) |
| 1678 | 1704 | __v.push_back(__x); |
| 1679 | 1705 | __p = __swap_out_circular_buffer(__v, __p); |
| 1680 | 1706 | } |
| 1681 | return __make_iter(__p); | |
| 1707 | return iterator(this, __p); | |
| 1682 | 1708 | } |
| 1683 | 1709 | |
| 1684 | #ifndef _LIBCPP_CXX03_LANG | |
| 1685 | ||
| 1686 | 1710 | template <class _Tp, class _Allocator> |
| 1711 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1687 | 1712 | typename vector<_Tp, _Allocator>::iterator |
| 1688 | 1713 | vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) |
| 1689 | 1714 | { |
| ... | ... | @@ -1709,11 +1734,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) |
| 1709 | 1734 | __v.push_back(_VSTD::move(__x)); |
| 1710 | 1735 | __p = __swap_out_circular_buffer(__v, __p); |
| 1711 | 1736 | } |
| 1712 | return __make_iter(__p); | |
| 1737 | return iterator(this, __p); | |
| 1713 | 1738 | } |
| 1714 | 1739 | |
| 1715 | 1740 | template <class _Tp, class _Allocator> |
| 1716 | 1741 | template <class... _Args> |
| 1742 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1717 | 1743 | typename vector<_Tp, _Allocator>::iterator |
| 1718 | 1744 | vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) |
| 1719 | 1745 | { |
| ... | ... | @@ -1740,12 +1766,11 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) |
| 1740 | 1766 | __v.emplace_back(_VSTD::forward<_Args>(__args)...); |
| 1741 | 1767 | __p = __swap_out_circular_buffer(__v, __p); |
| 1742 | 1768 | } |
| 1743 | return __make_iter(__p); | |
| 1769 | return iterator(this, __p); | |
| 1744 | 1770 | } |
| 1745 | 1771 | |
| 1746 | #endif // !_LIBCPP_CXX03_LANG | |
| 1747 | ||
| 1748 | 1772 | template <class _Tp, class _Allocator> |
| 1773 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1749 | 1774 | typename vector<_Tp, _Allocator>::iterator |
| 1750 | 1775 | vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) |
| 1751 | 1776 | { |
| ... | ... | @@ -1754,7 +1779,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ |
| 1754 | 1779 | pointer __p = this->__begin_ + (__position - begin()); |
| 1755 | 1780 | if (__n > 0) |
| 1756 | 1781 | { |
| 1757 | if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_)) | |
| 1782 | // We can't compare unrelated pointers inside constant expressions | |
| 1783 | if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_)) | |
| 1758 | 1784 | { |
| 1759 | 1785 | size_type __old_n = __n; |
| 1760 | 1786 | pointer __old_last = this->__end_; |
| ... | ... | @@ -1781,15 +1807,12 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_ |
| 1781 | 1807 | __p = __swap_out_circular_buffer(__v, __p); |
| 1782 | 1808 | } |
| 1783 | 1809 | } |
| 1784 | return __make_iter(__p); | |
| 1810 | return iterator(this, __p); | |
| 1785 | 1811 | } |
| 1786 | 1812 | |
| 1787 | 1813 | template <class _Tp, class _Allocator> |
| 1788 | 1814 | template <class _InputIterator> |
| 1789 | typename enable_if | |
| 1790 | < | |
| 1791 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 1792 | !__is_cpp17_forward_iterator<_InputIterator>::value && | |
| 1815 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value && | |
| 1793 | 1816 | is_constructible< |
| 1794 | 1817 | _Tp, |
| 1795 | 1818 | typename iterator_traits<_InputIterator>::reference>::value, |
| ... | ... | @@ -1824,19 +1847,20 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs |
| 1824 | 1847 | } |
| 1825 | 1848 | catch (...) |
| 1826 | 1849 | { |
| 1827 | erase(__make_iter(__old_last), end()); | |
| 1850 | erase(iterator(this, __old_last), end()); | |
| 1828 | 1851 | throw; |
| 1829 | 1852 | } |
| 1830 | 1853 | #endif // _LIBCPP_NO_EXCEPTIONS |
| 1831 | 1854 | } |
| 1832 | 1855 | __p = _VSTD::rotate(__p, __old_last, this->__end_); |
| 1833 | insert(__make_iter(__p), _VSTD::make_move_iterator(__v.begin()), | |
| 1834 | _VSTD::make_move_iterator(__v.end())); | |
| 1856 | insert(iterator(this, __p), _VSTD::make_move_iterator(__v.begin()), | |
| 1857 | _VSTD::make_move_iterator(__v.end())); | |
| 1835 | 1858 | return begin() + __off; |
| 1836 | 1859 | } |
| 1837 | 1860 | |
| 1838 | 1861 | template <class _Tp, class _Allocator> |
| 1839 | 1862 | template <class _ForwardIterator> |
| 1863 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1840 | 1864 | typename enable_if |
| 1841 | 1865 | < |
| 1842 | 1866 | __is_cpp17_forward_iterator<_ForwardIterator>::value && |
| ... | ... | @@ -1881,10 +1905,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi |
| 1881 | 1905 | __p = __swap_out_circular_buffer(__v, __p); |
| 1882 | 1906 | } |
| 1883 | 1907 | } |
| 1884 | return __make_iter(__p); | |
| 1908 | return iterator(this, __p); | |
| 1885 | 1909 | } |
| 1886 | 1910 | |
| 1887 | 1911 | template <class _Tp, class _Allocator> |
| 1912 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1888 | 1913 | void |
| 1889 | 1914 | vector<_Tp, _Allocator>::resize(size_type __sz) |
| 1890 | 1915 | { |
| ... | ... | @@ -1896,6 +1921,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz) |
| 1896 | 1921 | } |
| 1897 | 1922 | |
| 1898 | 1923 | template <class _Tp, class _Allocator> |
| 1924 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1899 | 1925 | void |
| 1900 | 1926 | vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) |
| 1901 | 1927 | { |
| ... | ... | @@ -1907,6 +1933,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) |
| 1907 | 1933 | } |
| 1908 | 1934 | |
| 1909 | 1935 | template <class _Tp, class _Allocator> |
| 1936 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1910 | 1937 | void |
| 1911 | 1938 | vector<_Tp, _Allocator>::swap(vector& __x) |
| 1912 | 1939 | #if _LIBCPP_STD_VER >= 14 |
| ... | ... | @@ -1925,12 +1952,11 @@ vector<_Tp, _Allocator>::swap(vector& __x) |
| 1925 | 1952 | _VSTD::swap(this->__end_cap(), __x.__end_cap()); |
| 1926 | 1953 | _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(), |
| 1927 | 1954 | integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); |
| 1928 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1929 | __get_db()->swap(this, _VSTD::addressof(__x)); | |
| 1930 | #endif | |
| 1955 | std::__debug_db_swap(this, std::addressof(__x)); | |
| 1931 | 1956 | } |
| 1932 | 1957 | |
| 1933 | 1958 | template <class _Tp, class _Allocator> |
| 1959 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 1934 | 1960 | bool |
| 1935 | 1961 | vector<_Tp, _Allocator>::__invariants() const |
| 1936 | 1962 | { |
| ... | ... | @@ -1951,7 +1977,7 @@ vector<_Tp, _Allocator>::__invariants() const |
| 1951 | 1977 | return true; |
| 1952 | 1978 | } |
| 1953 | 1979 | |
| 1954 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1980 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 1955 | 1981 | |
| 1956 | 1982 | template <class _Tp, class _Allocator> |
| 1957 | 1983 | bool |
| ... | ... | @@ -1983,24 +2009,13 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __ |
| 1983 | 2009 | return this->__begin_ <= __p && __p < this->__end_; |
| 1984 | 2010 | } |
| 1985 | 2011 | |
| 1986 | #endif // _LIBCPP_DEBUG_LEVEL == 2 | |
| 1987 | ||
| 1988 | template <class _Tp, class _Allocator> | |
| 1989 | inline _LIBCPP_INLINE_VISIBILITY | |
| 1990 | void | |
| 1991 | vector<_Tp, _Allocator>::__invalidate_all_iterators() | |
| 1992 | { | |
| 1993 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 1994 | __get_db()->__invalidate_all(this); | |
| 1995 | #endif | |
| 1996 | } | |
| 1997 | ||
| 2012 | #endif // _LIBCPP_ENABLE_DEBUG_MODE | |
| 1998 | 2013 | |
| 1999 | 2014 | template <class _Tp, class _Allocator> |
| 2000 | 2015 | inline _LIBCPP_INLINE_VISIBILITY |
| 2001 | 2016 | void |
| 2002 | 2017 | vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { |
| 2003 | #if _LIBCPP_DEBUG_LEVEL == 2 | |
| 2018 | #ifdef _LIBCPP_ENABLE_DEBUG_MODE | |
| 2004 | 2019 | __c_node* __c = __get_db()->__find_c_and_lock(this); |
| 2005 | 2020 | for (__i_node** __p = __c->end_; __p != __c->beg_; ) { |
| 2006 | 2021 | --__p; |
| ... | ... | @@ -2058,182 +2073,181 @@ private: |
| 2058 | 2073 | __compressed_pair<size_type, __storage_allocator> __cap_alloc_; |
| 2059 | 2074 | public: |
| 2060 | 2075 | typedef __bit_reference<vector> reference; |
| 2076 | #ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL | |
| 2077 | using const_reference = bool; | |
| 2078 | #else | |
| 2061 | 2079 | typedef __bit_const_reference<vector> const_reference; |
| 2080 | #endif | |
| 2062 | 2081 | private: |
| 2063 | _LIBCPP_INLINE_VISIBILITY | |
| 2082 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2064 | 2083 | size_type& __cap() _NOEXCEPT |
| 2065 | 2084 | {return __cap_alloc_.first();} |
| 2066 | _LIBCPP_INLINE_VISIBILITY | |
| 2085 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2067 | 2086 | const size_type& __cap() const _NOEXCEPT |
| 2068 | 2087 | {return __cap_alloc_.first();} |
| 2069 | _LIBCPP_INLINE_VISIBILITY | |
| 2088 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2070 | 2089 | __storage_allocator& __alloc() _NOEXCEPT |
| 2071 | 2090 | {return __cap_alloc_.second();} |
| 2072 | _LIBCPP_INLINE_VISIBILITY | |
| 2091 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2073 | 2092 | const __storage_allocator& __alloc() const _NOEXCEPT |
| 2074 | 2093 | {return __cap_alloc_.second();} |
| 2075 | 2094 | |
| 2076 | 2095 | static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT); |
| 2077 | 2096 | |
| 2078 | _LIBCPP_INLINE_VISIBILITY | |
| 2097 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2079 | 2098 | static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT |
| 2080 | 2099 | {return __n * __bits_per_word;} |
| 2081 | _LIBCPP_INLINE_VISIBILITY | |
| 2100 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2082 | 2101 | static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT |
| 2083 | 2102 | {return (__n - 1) / __bits_per_word + 1;} |
| 2084 | 2103 | |
| 2085 | 2104 | public: |
| 2086 | _LIBCPP_INLINE_VISIBILITY | |
| 2105 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2087 | 2106 | vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value); |
| 2088 | 2107 | |
| 2089 | _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) | |
| 2108 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a) | |
| 2090 | 2109 | #if _LIBCPP_STD_VER <= 14 |
| 2091 | 2110 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value); |
| 2092 | 2111 | #else |
| 2093 | 2112 | _NOEXCEPT; |
| 2094 | 2113 | #endif |
| 2095 | ~vector(); | |
| 2096 | explicit vector(size_type __n); | |
| 2114 | _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector(); | |
| 2115 | _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n); | |
| 2097 | 2116 | #if _LIBCPP_STD_VER > 11 |
| 2098 | explicit vector(size_type __n, const allocator_type& __a); | |
| 2117 | _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a); | |
| 2099 | 2118 | #endif |
| 2100 | vector(size_type __n, const value_type& __v); | |
| 2101 | vector(size_type __n, const value_type& __v, const allocator_type& __a); | |
| 2119 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v); | |
| 2120 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a); | |
| 2102 | 2121 | template <class _InputIterator> |
| 2103 | vector(_InputIterator __first, _InputIterator __last, | |
| 2104 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 2105 | !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0); | |
| 2122 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, | |
| 2123 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0); | |
| 2106 | 2124 | template <class _InputIterator> |
| 2107 | vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | |
| 2108 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 2109 | !__is_cpp17_forward_iterator<_InputIterator>::value>::type* = 0); | |
| 2125 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, | |
| 2126 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0); | |
| 2110 | 2127 | template <class _ForwardIterator> |
| 2111 | vector(_ForwardIterator __first, _ForwardIterator __last, | |
| 2128 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, | |
| 2112 | 2129 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); |
| 2113 | 2130 | template <class _ForwardIterator> |
| 2114 | vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | |
| 2131 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, | |
| 2115 | 2132 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0); |
| 2116 | 2133 | |
| 2117 | vector(const vector& __v); | |
| 2118 | vector(const vector& __v, const allocator_type& __a); | |
| 2119 | vector& operator=(const vector& __v); | |
| 2134 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v); | |
| 2135 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a); | |
| 2136 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v); | |
| 2120 | 2137 | |
| 2121 | 2138 | #ifndef _LIBCPP_CXX03_LANG |
| 2122 | vector(initializer_list<value_type> __il); | |
| 2123 | vector(initializer_list<value_type> __il, const allocator_type& __a); | |
| 2139 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il); | |
| 2140 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a); | |
| 2141 | ||
| 2142 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2143 | vector& operator=(initializer_list<value_type> __il) | |
| 2144 | {assign(__il.begin(), __il.end()); return *this;} | |
| 2145 | ||
| 2146 | #endif // !_LIBCPP_CXX03_LANG | |
| 2124 | 2147 | |
| 2125 | _LIBCPP_INLINE_VISIBILITY | |
| 2148 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2126 | 2149 | vector(vector&& __v) |
| 2127 | 2150 | #if _LIBCPP_STD_VER > 14 |
| 2128 | _NOEXCEPT; | |
| 2151 | noexcept; | |
| 2129 | 2152 | #else |
| 2130 | 2153 | _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value); |
| 2131 | 2154 | #endif |
| 2132 | vector(vector&& __v, const __identity_t<allocator_type>& __a); | |
| 2133 | _LIBCPP_INLINE_VISIBILITY | |
| 2155 | _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a); | |
| 2156 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2134 | 2157 | vector& operator=(vector&& __v) |
| 2135 | 2158 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); |
| 2136 | 2159 | |
| 2137 | _LIBCPP_INLINE_VISIBILITY | |
| 2138 | vector& operator=(initializer_list<value_type> __il) | |
| 2139 | {assign(__il.begin(), __il.end()); return *this;} | |
| 2140 | ||
| 2141 | #endif // !_LIBCPP_CXX03_LANG | |
| 2142 | ||
| 2143 | 2160 | template <class _InputIterator> |
| 2144 | typename enable_if | |
| 2145 | < | |
| 2146 | __is_cpp17_input_iterator<_InputIterator>::value && | |
| 2147 | !__is_cpp17_forward_iterator<_InputIterator>::value, | |
| 2161 | typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, | |
| 2148 | 2162 | void |
| 2149 | 2163 | >::type |
| 2150 | assign(_InputIterator __first, _InputIterator __last); | |
| 2164 | _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last); | |
| 2151 | 2165 | template <class _ForwardIterator> |
| 2152 | 2166 | typename enable_if |
| 2153 | 2167 | < |
| 2154 | 2168 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 2155 | 2169 | void |
| 2156 | 2170 | >::type |
| 2157 | assign(_ForwardIterator __first, _ForwardIterator __last); | |
| 2171 | _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last); | |
| 2158 | 2172 | |
| 2159 | void assign(size_type __n, const value_type& __x); | |
| 2173 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x); | |
| 2160 | 2174 | |
| 2161 | 2175 | #ifndef _LIBCPP_CXX03_LANG |
| 2162 | _LIBCPP_INLINE_VISIBILITY | |
| 2176 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2163 | 2177 | void assign(initializer_list<value_type> __il) |
| 2164 | 2178 | {assign(__il.begin(), __il.end());} |
| 2165 | 2179 | #endif |
| 2166 | 2180 | |
| 2167 | _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT | |
| 2181 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT | |
| 2168 | 2182 | {return allocator_type(this->__alloc());} |
| 2169 | 2183 | |
| 2170 | size_type max_size() const _NOEXCEPT; | |
| 2171 | _LIBCPP_INLINE_VISIBILITY | |
| 2184 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT; | |
| 2185 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2172 | 2186 | size_type capacity() const _NOEXCEPT |
| 2173 | 2187 | {return __internal_cap_to_external(__cap());} |
| 2174 | _LIBCPP_INLINE_VISIBILITY | |
| 2188 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2175 | 2189 | size_type size() const _NOEXCEPT |
| 2176 | 2190 | {return __size_;} |
| 2177 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY | |
| 2191 | _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2178 | 2192 | bool empty() const _NOEXCEPT |
| 2179 | 2193 | {return __size_ == 0;} |
| 2180 | void reserve(size_type __n); | |
| 2181 | void shrink_to_fit() _NOEXCEPT; | |
| 2194 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n); | |
| 2195 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT; | |
| 2182 | 2196 | |
| 2183 | _LIBCPP_INLINE_VISIBILITY | |
| 2197 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2184 | 2198 | iterator begin() _NOEXCEPT |
| 2185 | 2199 | {return __make_iter(0);} |
| 2186 | _LIBCPP_INLINE_VISIBILITY | |
| 2200 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2187 | 2201 | const_iterator begin() const _NOEXCEPT |
| 2188 | 2202 | {return __make_iter(0);} |
| 2189 | _LIBCPP_INLINE_VISIBILITY | |
| 2203 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2190 | 2204 | iterator end() _NOEXCEPT |
| 2191 | 2205 | {return __make_iter(__size_);} |
| 2192 | _LIBCPP_INLINE_VISIBILITY | |
| 2206 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2193 | 2207 | const_iterator end() const _NOEXCEPT |
| 2194 | 2208 | {return __make_iter(__size_);} |
| 2195 | 2209 | |
| 2196 | _LIBCPP_INLINE_VISIBILITY | |
| 2210 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2197 | 2211 | reverse_iterator rbegin() _NOEXCEPT |
| 2198 | 2212 | {return reverse_iterator(end());} |
| 2199 | _LIBCPP_INLINE_VISIBILITY | |
| 2213 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2200 | 2214 | const_reverse_iterator rbegin() const _NOEXCEPT |
| 2201 | 2215 | {return const_reverse_iterator(end());} |
| 2202 | _LIBCPP_INLINE_VISIBILITY | |
| 2216 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2203 | 2217 | reverse_iterator rend() _NOEXCEPT |
| 2204 | 2218 | {return reverse_iterator(begin());} |
| 2205 | _LIBCPP_INLINE_VISIBILITY | |
| 2219 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2206 | 2220 | const_reverse_iterator rend() const _NOEXCEPT |
| 2207 | 2221 | {return const_reverse_iterator(begin());} |
| 2208 | 2222 | |
| 2209 | _LIBCPP_INLINE_VISIBILITY | |
| 2223 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2210 | 2224 | const_iterator cbegin() const _NOEXCEPT |
| 2211 | 2225 | {return __make_iter(0);} |
| 2212 | _LIBCPP_INLINE_VISIBILITY | |
| 2226 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2213 | 2227 | const_iterator cend() const _NOEXCEPT |
| 2214 | 2228 | {return __make_iter(__size_);} |
| 2215 | _LIBCPP_INLINE_VISIBILITY | |
| 2229 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2216 | 2230 | const_reverse_iterator crbegin() const _NOEXCEPT |
| 2217 | 2231 | {return rbegin();} |
| 2218 | _LIBCPP_INLINE_VISIBILITY | |
| 2232 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2219 | 2233 | const_reverse_iterator crend() const _NOEXCEPT |
| 2220 | 2234 | {return rend();} |
| 2221 | 2235 | |
| 2222 | _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) {return __make_ref(__n);} | |
| 2223 | _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);} | |
| 2236 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](size_type __n) {return __make_ref(__n);} | |
| 2237 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);} | |
| 2224 | 2238 | reference at(size_type __n); |
| 2225 | 2239 | const_reference at(size_type __n) const; |
| 2226 | 2240 | |
| 2227 | _LIBCPP_INLINE_VISIBILITY reference front() {return __make_ref(0);} | |
| 2228 | _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);} | |
| 2229 | _LIBCPP_INLINE_VISIBILITY reference back() {return __make_ref(__size_ - 1);} | |
| 2230 | _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} | |
| 2241 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference front() {return __make_ref(0);} | |
| 2242 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);} | |
| 2243 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference back() {return __make_ref(__size_ - 1);} | |
| 2244 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back() const {return __make_ref(__size_ - 1);} | |
| 2231 | 2245 | |
| 2232 | void push_back(const value_type& __x); | |
| 2246 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x); | |
| 2233 | 2247 | #if _LIBCPP_STD_VER > 11 |
| 2234 | 2248 | template <class... _Args> |
| 2235 | 2249 | #if _LIBCPP_STD_VER > 14 |
| 2236 | _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args) | |
| 2250 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args) | |
| 2237 | 2251 | #else |
| 2238 | 2252 | _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) |
| 2239 | 2253 | #endif |
| ... | ... | @@ -2245,58 +2259,54 @@ public: |
| 2245 | 2259 | } |
| 2246 | 2260 | #endif |
| 2247 | 2261 | |
| 2248 | _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} | |
| 2262 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;} | |
| 2249 | 2263 | |
| 2250 | 2264 | #if _LIBCPP_STD_VER > 11 |
| 2251 | 2265 | template <class... _Args> |
| 2252 | _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) | |
| 2253 | { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } | |
| 2266 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args) | |
| 2267 | { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); } | |
| 2254 | 2268 | #endif |
| 2255 | 2269 | |
| 2256 | iterator insert(const_iterator __position, const value_type& __x); | |
| 2257 | iterator insert(const_iterator __position, size_type __n, const value_type& __x); | |
| 2258 | iterator insert(const_iterator __position, size_type __n, const_reference __x); | |
| 2270 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x); | |
| 2271 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x); | |
| 2259 | 2272 | template <class _InputIterator> |
| 2260 | typename enable_if | |
| 2261 | < | |
| 2262 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 2263 | !__is_cpp17_forward_iterator<_InputIterator>::value, | |
| 2273 | typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, | |
| 2264 | 2274 | iterator |
| 2265 | 2275 | >::type |
| 2266 | insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
| 2276 | _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); | |
| 2267 | 2277 | template <class _ForwardIterator> |
| 2268 | 2278 | typename enable_if |
| 2269 | 2279 | < |
| 2270 | 2280 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 2271 | 2281 | iterator |
| 2272 | 2282 | >::type |
| 2273 | insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
| 2283 | _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); | |
| 2274 | 2284 | |
| 2275 | 2285 | #ifndef _LIBCPP_CXX03_LANG |
| 2276 | _LIBCPP_INLINE_VISIBILITY | |
| 2286 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2277 | 2287 | iterator insert(const_iterator __position, initializer_list<value_type> __il) |
| 2278 | 2288 | {return insert(__position, __il.begin(), __il.end());} |
| 2279 | 2289 | #endif |
| 2280 | 2290 | |
| 2281 | _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position); | |
| 2282 | iterator erase(const_iterator __first, const_iterator __last); | |
| 2291 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position); | |
| 2292 | _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last); | |
| 2283 | 2293 | |
| 2284 | _LIBCPP_INLINE_VISIBILITY | |
| 2294 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2285 | 2295 | void clear() _NOEXCEPT {__size_ = 0;} |
| 2286 | 2296 | |
| 2287 | void swap(vector&) | |
| 2297 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&) | |
| 2288 | 2298 | #if _LIBCPP_STD_VER >= 14 |
| 2289 | 2299 | _NOEXCEPT; |
| 2290 | 2300 | #else |
| 2291 | 2301 | _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || |
| 2292 | 2302 | __is_nothrow_swappable<allocator_type>::value); |
| 2293 | 2303 | #endif |
| 2294 | static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } | |
| 2304 | _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); } | |
| 2295 | 2305 | |
| 2296 | void resize(size_type __sz, value_type __x = false); | |
| 2297 | void flip() _NOEXCEPT; | |
| 2306 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false); | |
| 2307 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT; | |
| 2298 | 2308 | |
| 2299 | bool __invariants() const; | |
| 2309 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const; | |
| 2300 | 2310 | |
| 2301 | 2311 | private: |
| 2302 | 2312 | _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI |
| ... | ... | @@ -2309,43 +2319,63 @@ private: |
| 2309 | 2319 | _VSTD::__throw_out_of_range("vector"); |
| 2310 | 2320 | } |
| 2311 | 2321 | |
| 2312 | _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); | |
| 2313 | void __vallocate(size_type __n); | |
| 2314 | void __vdeallocate() _NOEXCEPT; | |
| 2315 | _LIBCPP_INLINE_VISIBILITY | |
| 2322 | // Allocate space for __n objects | |
| 2323 | // throws length_error if __n > max_size() | |
| 2324 | // throws (probably bad_alloc) if memory run out | |
| 2325 | // Precondition: __begin_ == __end_ == __cap() == 0 | |
| 2326 | // Precondition: __n > 0 | |
| 2327 | // Postcondition: capacity() >= __n | |
| 2328 | // Postcondition: size() == 0 | |
| 2329 | _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) { | |
| 2330 | if (__n > max_size()) | |
| 2331 | __throw_length_error(); | |
| 2332 | auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n)); | |
| 2333 | __begin_ = __allocation.ptr; | |
| 2334 | __size_ = 0; | |
| 2335 | __cap() = __allocation.count; | |
| 2336 | if (__libcpp_is_constant_evaluated()) { | |
| 2337 | for (size_type __i = 0; __i != __cap(); ++__i) | |
| 2338 | std::__construct_at(std::__to_address(__begin_) + __i); | |
| 2339 | } | |
| 2340 | } | |
| 2341 | ||
| 2342 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT; | |
| 2343 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2316 | 2344 | static size_type __align_it(size_type __new_size) _NOEXCEPT |
| 2317 | {return __new_size + (__bits_per_word-1) & ~((size_type)__bits_per_word-1);} | |
| 2318 | _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; | |
| 2319 | _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); | |
| 2345 | {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);} | |
| 2346 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type __recommend(size_type __new_size) const; | |
| 2347 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x); | |
| 2320 | 2348 | template <class _ForwardIterator> |
| 2321 | 2349 | typename enable_if |
| 2322 | 2350 | < |
| 2323 | 2351 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| 2324 | 2352 | void |
| 2325 | 2353 | >::type |
| 2326 | __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); | |
| 2327 | void __append(size_type __n, const_reference __x); | |
| 2328 | _LIBCPP_INLINE_VISIBILITY | |
| 2354 | _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); | |
| 2355 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x); | |
| 2356 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2329 | 2357 | reference __make_ref(size_type __pos) _NOEXCEPT |
| 2330 | 2358 | {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} |
| 2331 | _LIBCPP_INLINE_VISIBILITY | |
| 2332 | const_reference __make_ref(size_type __pos) const _NOEXCEPT | |
| 2333 | {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} | |
| 2334 | _LIBCPP_INLINE_VISIBILITY | |
| 2359 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2360 | const_reference __make_ref(size_type __pos) const _NOEXCEPT { | |
| 2361 | return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word, | |
| 2362 | __storage_type(1) << __pos % __bits_per_word); | |
| 2363 | } | |
| 2364 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2335 | 2365 | iterator __make_iter(size_type __pos) _NOEXCEPT |
| 2336 | 2366 | {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} |
| 2337 | _LIBCPP_INLINE_VISIBILITY | |
| 2367 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2338 | 2368 | const_iterator __make_iter(size_type __pos) const _NOEXCEPT |
| 2339 | 2369 | {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} |
| 2340 | _LIBCPP_INLINE_VISIBILITY | |
| 2370 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2341 | 2371 | iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT |
| 2342 | 2372 | {return begin() + (__p - cbegin());} |
| 2343 | 2373 | |
| 2344 | _LIBCPP_INLINE_VISIBILITY | |
| 2374 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2345 | 2375 | void __copy_assign_alloc(const vector& __v) |
| 2346 | 2376 | {__copy_assign_alloc(__v, integral_constant<bool, |
| 2347 | 2377 | __storage_traits::propagate_on_container_copy_assignment::value>());} |
| 2348 | _LIBCPP_INLINE_VISIBILITY | |
| 2378 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2349 | 2379 | void __copy_assign_alloc(const vector& __c, true_type) |
| 2350 | 2380 | { |
| 2351 | 2381 | if (__alloc() != __c.__alloc()) |
| ... | ... | @@ -2353,33 +2383,33 @@ private: |
| 2353 | 2383 | __alloc() = __c.__alloc(); |
| 2354 | 2384 | } |
| 2355 | 2385 | |
| 2356 | _LIBCPP_INLINE_VISIBILITY | |
| 2386 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2357 | 2387 | void __copy_assign_alloc(const vector&, false_type) |
| 2358 | 2388 | {} |
| 2359 | 2389 | |
| 2360 | void __move_assign(vector& __c, false_type); | |
| 2361 | void __move_assign(vector& __c, true_type) | |
| 2390 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type); | |
| 2391 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type) | |
| 2362 | 2392 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value); |
| 2363 | _LIBCPP_INLINE_VISIBILITY | |
| 2393 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2364 | 2394 | void __move_assign_alloc(vector& __c) |
| 2365 | 2395 | _NOEXCEPT_( |
| 2366 | 2396 | !__storage_traits::propagate_on_container_move_assignment::value || |
| 2367 | 2397 | is_nothrow_move_assignable<allocator_type>::value) |
| 2368 | 2398 | {__move_assign_alloc(__c, integral_constant<bool, |
| 2369 | 2399 | __storage_traits::propagate_on_container_move_assignment::value>());} |
| 2370 | _LIBCPP_INLINE_VISIBILITY | |
| 2400 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2371 | 2401 | void __move_assign_alloc(vector& __c, true_type) |
| 2372 | 2402 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| 2373 | 2403 | { |
| 2374 | 2404 | __alloc() = _VSTD::move(__c.__alloc()); |
| 2375 | 2405 | } |
| 2376 | 2406 | |
| 2377 | _LIBCPP_INLINE_VISIBILITY | |
| 2407 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2378 | 2408 | void __move_assign_alloc(vector&, false_type) |
| 2379 | 2409 | _NOEXCEPT |
| 2380 | 2410 | {} |
| 2381 | 2411 | |
| 2382 | size_t __hash_code() const _NOEXCEPT; | |
| 2412 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT; | |
| 2383 | 2413 | |
| 2384 | 2414 | friend class __bit_reference<vector>; |
| 2385 | 2415 | friend class __bit_const_reference<vector>; |
| ... | ... | @@ -2390,45 +2420,20 @@ private: |
| 2390 | 2420 | }; |
| 2391 | 2421 | |
| 2392 | 2422 | template <class _Allocator> |
| 2393 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2394 | void | |
| 2395 | vector<bool, _Allocator>::__invalidate_all_iterators() | |
| 2396 | { | |
| 2397 | } | |
| 2398 | ||
| 2399 | // Allocate space for __n objects | |
| 2400 | // throws length_error if __n > max_size() | |
| 2401 | // throws (probably bad_alloc) if memory run out | |
| 2402 | // Precondition: __begin_ == __end_ == __cap() == 0 | |
| 2403 | // Precondition: __n > 0 | |
| 2404 | // Postcondition: capacity() == __n | |
| 2405 | // Postcondition: size() == 0 | |
| 2406 | template <class _Allocator> | |
| 2407 | void | |
| 2408 | vector<bool, _Allocator>::__vallocate(size_type __n) | |
| 2409 | { | |
| 2410 | if (__n > max_size()) | |
| 2411 | this->__throw_length_error(); | |
| 2412 | __n = __external_cap_to_internal(__n); | |
| 2413 | this->__begin_ = __storage_traits::allocate(this->__alloc(), __n); | |
| 2414 | this->__size_ = 0; | |
| 2415 | this->__cap() = __n; | |
| 2416 | } | |
| 2417 | ||
| 2418 | template <class _Allocator> | |
| 2419 | void | |
| 2423 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2420 | 2424 | vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT |
| 2421 | 2425 | { |
| 2422 | 2426 | if (this->__begin_ != nullptr) |
| 2423 | 2427 | { |
| 2424 | 2428 | __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); |
| 2425 | __invalidate_all_iterators(); | |
| 2429 | std::__debug_db_invalidate_all(this); | |
| 2426 | 2430 | this->__begin_ = nullptr; |
| 2427 | 2431 | this->__size_ = this->__cap() = 0; |
| 2428 | 2432 | } |
| 2429 | 2433 | } |
| 2430 | 2434 | |
| 2431 | 2435 | template <class _Allocator> |
| 2436 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2432 | 2437 | typename vector<bool, _Allocator>::size_type |
| 2433 | 2438 | vector<bool, _Allocator>::max_size() const _NOEXCEPT |
| 2434 | 2439 | { |
| ... | ... | @@ -2441,7 +2446,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT |
| 2441 | 2446 | |
| 2442 | 2447 | // Precondition: __new_size > capacity() |
| 2443 | 2448 | template <class _Allocator> |
| 2444 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2449 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2445 | 2450 | typename vector<bool, _Allocator>::size_type |
| 2446 | 2451 | vector<bool, _Allocator>::__recommend(size_type __new_size) const |
| 2447 | 2452 | { |
| ... | ... | @@ -2459,7 +2464,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const |
| 2459 | 2464 | // Precondition: size() + __n <= capacity() |
| 2460 | 2465 | // Postcondition: size() == size() + __n |
| 2461 | 2466 | template <class _Allocator> |
| 2462 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2467 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2463 | 2468 | void |
| 2464 | 2469 | vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) |
| 2465 | 2470 | { |
| ... | ... | @@ -2477,6 +2482,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) |
| 2477 | 2482 | |
| 2478 | 2483 | template <class _Allocator> |
| 2479 | 2484 | template <class _ForwardIterator> |
| 2485 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2480 | 2486 | typename enable_if |
| 2481 | 2487 | < |
| 2482 | 2488 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -2497,7 +2503,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI |
| 2497 | 2503 | } |
| 2498 | 2504 | |
| 2499 | 2505 | template <class _Allocator> |
| 2500 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2506 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2501 | 2507 | vector<bool, _Allocator>::vector() |
| 2502 | 2508 | _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) |
| 2503 | 2509 | : __begin_(nullptr), |
| ... | ... | @@ -2507,7 +2513,7 @@ vector<bool, _Allocator>::vector() |
| 2507 | 2513 | } |
| 2508 | 2514 | |
| 2509 | 2515 | template <class _Allocator> |
| 2510 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2516 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2511 | 2517 | vector<bool, _Allocator>::vector(const allocator_type& __a) |
| 2512 | 2518 | #if _LIBCPP_STD_VER <= 14 |
| 2513 | 2519 | _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value) |
| ... | ... | @@ -2521,6 +2527,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a) |
| 2521 | 2527 | } |
| 2522 | 2528 | |
| 2523 | 2529 | template <class _Allocator> |
| 2530 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2524 | 2531 | vector<bool, _Allocator>::vector(size_type __n) |
| 2525 | 2532 | : __begin_(nullptr), |
| 2526 | 2533 | __size_(0), |
| ... | ... | @@ -2535,6 +2542,7 @@ vector<bool, _Allocator>::vector(size_type __n) |
| 2535 | 2542 | |
| 2536 | 2543 | #if _LIBCPP_STD_VER > 11 |
| 2537 | 2544 | template <class _Allocator> |
| 2545 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2538 | 2546 | vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) |
| 2539 | 2547 | : __begin_(nullptr), |
| 2540 | 2548 | __size_(0), |
| ... | ... | @@ -2549,6 +2557,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) |
| 2549 | 2557 | #endif |
| 2550 | 2558 | |
| 2551 | 2559 | template <class _Allocator> |
| 2560 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2552 | 2561 | vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) |
| 2553 | 2562 | : __begin_(nullptr), |
| 2554 | 2563 | __size_(0), |
| ... | ... | @@ -2562,6 +2571,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) |
| 2562 | 2571 | } |
| 2563 | 2572 | |
| 2564 | 2573 | template <class _Allocator> |
| 2574 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2565 | 2575 | vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a) |
| 2566 | 2576 | : __begin_(nullptr), |
| 2567 | 2577 | __size_(0), |
| ... | ... | @@ -2576,9 +2586,9 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all |
| 2576 | 2586 | |
| 2577 | 2587 | template <class _Allocator> |
| 2578 | 2588 | template <class _InputIterator> |
| 2589 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2579 | 2590 | vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, |
| 2580 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 2581 | !__is_cpp17_forward_iterator<_InputIterator>::value>::type*) | |
| 2591 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*) | |
| 2582 | 2592 | : __begin_(nullptr), |
| 2583 | 2593 | __size_(0), |
| 2584 | 2594 | __cap_alloc_(0, __default_init_tag()) |
| ... | ... | @@ -2595,7 +2605,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, |
| 2595 | 2605 | { |
| 2596 | 2606 | if (__begin_ != nullptr) |
| 2597 | 2607 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); |
| 2598 | __invalidate_all_iterators(); | |
| 2608 | std::__debug_db_invalidate_all(this); | |
| 2599 | 2609 | throw; |
| 2600 | 2610 | } |
| 2601 | 2611 | #endif // _LIBCPP_NO_EXCEPTIONS |
| ... | ... | @@ -2603,9 +2613,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, |
| 2603 | 2613 | |
| 2604 | 2614 | template <class _Allocator> |
| 2605 | 2615 | template <class _InputIterator> |
| 2616 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2606 | 2617 | vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, |
| 2607 | typename enable_if<__is_cpp17_input_iterator <_InputIterator>::value && | |
| 2608 | !__is_cpp17_forward_iterator<_InputIterator>::value>::type*) | |
| 2618 | typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*) | |
| 2609 | 2619 | : __begin_(nullptr), |
| 2610 | 2620 | __size_(0), |
| 2611 | 2621 | __cap_alloc_(0, static_cast<__storage_allocator>(__a)) |
| ... | ... | @@ -2622,7 +2632,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, |
| 2622 | 2632 | { |
| 2623 | 2633 | if (__begin_ != nullptr) |
| 2624 | 2634 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); |
| 2625 | __invalidate_all_iterators(); | |
| 2635 | std::__debug_db_invalidate_all(this); | |
| 2626 | 2636 | throw; |
| 2627 | 2637 | } |
| 2628 | 2638 | #endif // _LIBCPP_NO_EXCEPTIONS |
| ... | ... | @@ -2630,6 +2640,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, |
| 2630 | 2640 | |
| 2631 | 2641 | template <class _Allocator> |
| 2632 | 2642 | template <class _ForwardIterator> |
| 2643 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2633 | 2644 | vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, |
| 2634 | 2645 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) |
| 2635 | 2646 | : __begin_(nullptr), |
| ... | ... | @@ -2646,6 +2657,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la |
| 2646 | 2657 | |
| 2647 | 2658 | template <class _Allocator> |
| 2648 | 2659 | template <class _ForwardIterator> |
| 2660 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2649 | 2661 | vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, |
| 2650 | 2662 | typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) |
| 2651 | 2663 | : __begin_(nullptr), |
| ... | ... | @@ -2663,6 +2675,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la |
| 2663 | 2675 | #ifndef _LIBCPP_CXX03_LANG |
| 2664 | 2676 | |
| 2665 | 2677 | template <class _Allocator> |
| 2678 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2666 | 2679 | vector<bool, _Allocator>::vector(initializer_list<value_type> __il) |
| 2667 | 2680 | : __begin_(nullptr), |
| 2668 | 2681 | __size_(0), |
| ... | ... | @@ -2677,6 +2690,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il) |
| 2677 | 2690 | } |
| 2678 | 2691 | |
| 2679 | 2692 | template <class _Allocator> |
| 2693 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2680 | 2694 | vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) |
| 2681 | 2695 | : __begin_(nullptr), |
| 2682 | 2696 | __size_(0), |
| ... | ... | @@ -2693,14 +2707,16 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca |
| 2693 | 2707 | #endif // _LIBCPP_CXX03_LANG |
| 2694 | 2708 | |
| 2695 | 2709 | template <class _Allocator> |
| 2710 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2696 | 2711 | vector<bool, _Allocator>::~vector() |
| 2697 | 2712 | { |
| 2698 | 2713 | if (__begin_ != nullptr) |
| 2699 | 2714 | __storage_traits::deallocate(__alloc(), __begin_, __cap()); |
| 2700 | __invalidate_all_iterators(); | |
| 2715 | std::__debug_db_invalidate_all(this); | |
| 2701 | 2716 | } |
| 2702 | 2717 | |
| 2703 | 2718 | template <class _Allocator> |
| 2719 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2704 | 2720 | vector<bool, _Allocator>::vector(const vector& __v) |
| 2705 | 2721 | : __begin_(nullptr), |
| 2706 | 2722 | __size_(0), |
| ... | ... | @@ -2714,6 +2730,7 @@ vector<bool, _Allocator>::vector(const vector& __v) |
| 2714 | 2730 | } |
| 2715 | 2731 | |
| 2716 | 2732 | template <class _Allocator> |
| 2733 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2717 | 2734 | vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) |
| 2718 | 2735 | : __begin_(nullptr), |
| 2719 | 2736 | __size_(0), |
| ... | ... | @@ -2727,6 +2744,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a) |
| 2727 | 2744 | } |
| 2728 | 2745 | |
| 2729 | 2746 | template <class _Allocator> |
| 2747 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2730 | 2748 | vector<bool, _Allocator>& |
| 2731 | 2749 | vector<bool, _Allocator>::operator=(const vector& __v) |
| 2732 | 2750 | { |
| ... | ... | @@ -2747,10 +2765,8 @@ vector<bool, _Allocator>::operator=(const vector& __v) |
| 2747 | 2765 | return *this; |
| 2748 | 2766 | } |
| 2749 | 2767 | |
| 2750 | #ifndef _LIBCPP_CXX03_LANG | |
| 2751 | ||
| 2752 | 2768 | template <class _Allocator> |
| 2753 | inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v) | |
| 2769 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _Allocator>::vector(vector&& __v) | |
| 2754 | 2770 | #if _LIBCPP_STD_VER > 14 |
| 2755 | 2771 | _NOEXCEPT |
| 2756 | 2772 | #else |
| ... | ... | @@ -2765,7 +2781,8 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v) |
| 2765 | 2781 | } |
| 2766 | 2782 | |
| 2767 | 2783 | template <class _Allocator> |
| 2768 | vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type>& __a) | |
| 2784 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2785 | vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a) | |
| 2769 | 2786 | : __begin_(nullptr), |
| 2770 | 2787 | __size_(0), |
| 2771 | 2788 | __cap_alloc_(0, __a) |
| ... | ... | @@ -2786,7 +2803,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __identity_t<allocator_type |
| 2786 | 2803 | } |
| 2787 | 2804 | |
| 2788 | 2805 | template <class _Allocator> |
| 2789 | inline _LIBCPP_INLINE_VISIBILITY | |
| 2806 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2790 | 2807 | vector<bool, _Allocator>& |
| 2791 | 2808 | vector<bool, _Allocator>::operator=(vector&& __v) |
| 2792 | 2809 | _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) |
| ... | ... | @@ -2797,7 +2814,7 @@ vector<bool, _Allocator>::operator=(vector&& __v) |
| 2797 | 2814 | } |
| 2798 | 2815 | |
| 2799 | 2816 | template <class _Allocator> |
| 2800 | void | |
| 2817 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2801 | 2818 | vector<bool, _Allocator>::__move_assign(vector& __c, false_type) |
| 2802 | 2819 | { |
| 2803 | 2820 | if (__alloc() != __c.__alloc()) |
| ... | ... | @@ -2807,7 +2824,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type) |
| 2807 | 2824 | } |
| 2808 | 2825 | |
| 2809 | 2826 | template <class _Allocator> |
| 2810 | void | |
| 2827 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2811 | 2828 | vector<bool, _Allocator>::__move_assign(vector& __c, true_type) |
| 2812 | 2829 | _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) |
| 2813 | 2830 | { |
| ... | ... | @@ -2820,10 +2837,8 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type) |
| 2820 | 2837 | __c.__cap() = __c.__size_ = 0; |
| 2821 | 2838 | } |
| 2822 | 2839 | |
| 2823 | #endif // !_LIBCPP_CXX03_LANG | |
| 2824 | ||
| 2825 | 2840 | template <class _Allocator> |
| 2826 | void | |
| 2841 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2827 | 2842 | vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) |
| 2828 | 2843 | { |
| 2829 | 2844 | __size_ = 0; |
| ... | ... | @@ -2841,15 +2856,12 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) |
| 2841 | 2856 | } |
| 2842 | 2857 | _VSTD::fill_n(begin(), __n, __x); |
| 2843 | 2858 | } |
| 2844 | __invalidate_all_iterators(); | |
| 2859 | std::__debug_db_invalidate_all(this); | |
| 2845 | 2860 | } |
| 2846 | 2861 | |
| 2847 | 2862 | template <class _Allocator> |
| 2848 | 2863 | template <class _InputIterator> |
| 2849 | typename enable_if | |
| 2850 | < | |
| 2851 | __is_cpp17_input_iterator<_InputIterator>::value && | |
| 2852 | !__is_cpp17_forward_iterator<_InputIterator>::value, | |
| 2864 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, | |
| 2853 | 2865 | void |
| 2854 | 2866 | >::type |
| 2855 | 2867 | vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) |
| ... | ... | @@ -2861,6 +2873,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) |
| 2861 | 2873 | |
| 2862 | 2874 | template <class _Allocator> |
| 2863 | 2875 | template <class _ForwardIterator> |
| 2876 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 2864 | 2877 | typename enable_if |
| 2865 | 2878 | < |
| 2866 | 2879 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -2884,7 +2897,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la |
| 2884 | 2897 | } |
| 2885 | 2898 | |
| 2886 | 2899 | template <class _Allocator> |
| 2887 | void | |
| 2900 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2888 | 2901 | vector<bool, _Allocator>::reserve(size_type __n) |
| 2889 | 2902 | { |
| 2890 | 2903 | if (__n > capacity()) |
| ... | ... | @@ -2895,12 +2908,12 @@ vector<bool, _Allocator>::reserve(size_type __n) |
| 2895 | 2908 | __v.__vallocate(__n); |
| 2896 | 2909 | __v.__construct_at_end(this->begin(), this->end()); |
| 2897 | 2910 | swap(__v); |
| 2898 | __invalidate_all_iterators(); | |
| 2911 | std::__debug_db_invalidate_all(this); | |
| 2899 | 2912 | } |
| 2900 | 2913 | } |
| 2901 | 2914 | |
| 2902 | 2915 | template <class _Allocator> |
| 2903 | void | |
| 2916 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2904 | 2917 | vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT |
| 2905 | 2918 | { |
| 2906 | 2919 | if (__external_cap_to_internal(size()) > __cap()) |
| ... | ... | @@ -2938,7 +2951,7 @@ vector<bool, _Allocator>::at(size_type __n) const |
| 2938 | 2951 | } |
| 2939 | 2952 | |
| 2940 | 2953 | template <class _Allocator> |
| 2941 | void | |
| 2954 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 2942 | 2955 | vector<bool, _Allocator>::push_back(const value_type& __x) |
| 2943 | 2956 | { |
| 2944 | 2957 | if (this->__size_ == this->capacity()) |
| ... | ... | @@ -2948,7 +2961,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x) |
| 2948 | 2961 | } |
| 2949 | 2962 | |
| 2950 | 2963 | template <class _Allocator> |
| 2951 | typename vector<bool, _Allocator>::iterator | |
| 2964 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator | |
| 2952 | 2965 | vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x) |
| 2953 | 2966 | { |
| 2954 | 2967 | iterator __r; |
| ... | ... | @@ -2973,7 +2986,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __ |
| 2973 | 2986 | } |
| 2974 | 2987 | |
| 2975 | 2988 | template <class _Allocator> |
| 2976 | typename vector<bool, _Allocator>::iterator | |
| 2989 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator | |
| 2977 | 2990 | vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x) |
| 2978 | 2991 | { |
| 2979 | 2992 | iterator __r; |
| ... | ... | @@ -3000,10 +3013,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const |
| 3000 | 3013 | |
| 3001 | 3014 | template <class _Allocator> |
| 3002 | 3015 | template <class _InputIterator> |
| 3003 | typename enable_if | |
| 3004 | < | |
| 3005 | __is_cpp17_input_iterator <_InputIterator>::value && | |
| 3006 | !__is_cpp17_forward_iterator<_InputIterator>::value, | |
| 3016 | _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value, | |
| 3007 | 3017 | typename vector<bool, _Allocator>::iterator |
| 3008 | 3018 | >::type |
| 3009 | 3019 | vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) |
| ... | ... | @@ -3045,6 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir |
| 3045 | 3055 | |
| 3046 | 3056 | template <class _Allocator> |
| 3047 | 3057 | template <class _ForwardIterator> |
| 3058 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3048 | 3059 | typename enable_if |
| 3049 | 3060 | < |
| 3050 | 3061 | __is_cpp17_forward_iterator<_ForwardIterator>::value, |
| ... | ... | @@ -3078,7 +3089,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f |
| 3078 | 3089 | } |
| 3079 | 3090 | |
| 3080 | 3091 | template <class _Allocator> |
| 3081 | inline _LIBCPP_INLINE_VISIBILITY | |
| 3092 | inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3082 | 3093 | typename vector<bool, _Allocator>::iterator |
| 3083 | 3094 | vector<bool, _Allocator>::erase(const_iterator __position) |
| 3084 | 3095 | { |
| ... | ... | @@ -3089,6 +3100,7 @@ vector<bool, _Allocator>::erase(const_iterator __position) |
| 3089 | 3100 | } |
| 3090 | 3101 | |
| 3091 | 3102 | template <class _Allocator> |
| 3103 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3092 | 3104 | typename vector<bool, _Allocator>::iterator |
| 3093 | 3105 | vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 3094 | 3106 | { |
| ... | ... | @@ -3100,7 +3112,7 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last) |
| 3100 | 3112 | } |
| 3101 | 3113 | |
| 3102 | 3114 | template <class _Allocator> |
| 3103 | void | |
| 3115 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 3104 | 3116 | vector<bool, _Allocator>::swap(vector& __x) |
| 3105 | 3117 | #if _LIBCPP_STD_VER >= 14 |
| 3106 | 3118 | _NOEXCEPT |
| ... | ... | @@ -3117,7 +3129,7 @@ vector<bool, _Allocator>::swap(vector& __x) |
| 3117 | 3129 | } |
| 3118 | 3130 | |
| 3119 | 3131 | template <class _Allocator> |
| 3120 | void | |
| 3132 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 3121 | 3133 | vector<bool, _Allocator>::resize(size_type __sz, value_type __x) |
| 3122 | 3134 | { |
| 3123 | 3135 | size_type __cs = size(); |
| ... | ... | @@ -3146,7 +3158,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x) |
| 3146 | 3158 | } |
| 3147 | 3159 | |
| 3148 | 3160 | template <class _Allocator> |
| 3149 | void | |
| 3161 | _LIBCPP_CONSTEXPR_AFTER_CXX17 void | |
| 3150 | 3162 | vector<bool, _Allocator>::flip() _NOEXCEPT |
| 3151 | 3163 | { |
| 3152 | 3164 | // do middle whole words |
| ... | ... | @@ -3165,7 +3177,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT |
| 3165 | 3177 | } |
| 3166 | 3178 | |
| 3167 | 3179 | template <class _Allocator> |
| 3168 | bool | |
| 3180 | _LIBCPP_CONSTEXPR_AFTER_CXX17 bool | |
| 3169 | 3181 | vector<bool, _Allocator>::__invariants() const |
| 3170 | 3182 | { |
| 3171 | 3183 | if (this->__begin_ == nullptr) |
| ... | ... | @@ -3184,7 +3196,7 @@ vector<bool, _Allocator>::__invariants() const |
| 3184 | 3196 | } |
| 3185 | 3197 | |
| 3186 | 3198 | template <class _Allocator> |
| 3187 | size_t | |
| 3199 | _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t | |
| 3188 | 3200 | vector<bool, _Allocator>::__hash_code() const _NOEXCEPT |
| 3189 | 3201 | { |
| 3190 | 3202 | size_t __h = 0; |
| ... | ... | @@ -3204,14 +3216,15 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT |
| 3204 | 3216 | |
| 3205 | 3217 | template <class _Allocator> |
| 3206 | 3218 | struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > |
| 3207 | : public unary_function<vector<bool, _Allocator>, size_t> | |
| 3219 | : public __unary_function<vector<bool, _Allocator>, size_t> | |
| 3208 | 3220 | { |
| 3209 | _LIBCPP_INLINE_VISIBILITY | |
| 3221 | _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3210 | 3222 | size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT |
| 3211 | 3223 | {return __vec.__hash_code();} |
| 3212 | 3224 | }; |
| 3213 | 3225 | |
| 3214 | 3226 | template <class _Tp, class _Allocator> |
| 3227 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3215 | 3228 | inline _LIBCPP_INLINE_VISIBILITY |
| 3216 | 3229 | bool |
| 3217 | 3230 | operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3221,6 +3234,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ |
| 3221 | 3234 | } |
| 3222 | 3235 | |
| 3223 | 3236 | template <class _Tp, class _Allocator> |
| 3237 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3224 | 3238 | inline _LIBCPP_INLINE_VISIBILITY |
| 3225 | 3239 | bool |
| 3226 | 3240 | operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3229,6 +3243,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ |
| 3229 | 3243 | } |
| 3230 | 3244 | |
| 3231 | 3245 | template <class _Tp, class _Allocator> |
| 3246 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3232 | 3247 | inline _LIBCPP_INLINE_VISIBILITY |
| 3233 | 3248 | bool |
| 3234 | 3249 | operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3237,6 +3252,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ |
| 3237 | 3252 | } |
| 3238 | 3253 | |
| 3239 | 3254 | template <class _Tp, class _Allocator> |
| 3255 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3240 | 3256 | inline _LIBCPP_INLINE_VISIBILITY |
| 3241 | 3257 | bool |
| 3242 | 3258 | operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3245,6 +3261,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ |
| 3245 | 3261 | } |
| 3246 | 3262 | |
| 3247 | 3263 | template <class _Tp, class _Allocator> |
| 3264 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3248 | 3265 | inline _LIBCPP_INLINE_VISIBILITY |
| 3249 | 3266 | bool |
| 3250 | 3267 | operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3253,6 +3270,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ |
| 3253 | 3270 | } |
| 3254 | 3271 | |
| 3255 | 3272 | template <class _Tp, class _Allocator> |
| 3273 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3256 | 3274 | inline _LIBCPP_INLINE_VISIBILITY |
| 3257 | 3275 | bool |
| 3258 | 3276 | operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3261,6 +3279,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ |
| 3261 | 3279 | } |
| 3262 | 3280 | |
| 3263 | 3281 | template <class _Tp, class _Allocator> |
| 3282 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3264 | 3283 | inline _LIBCPP_INLINE_VISIBILITY |
| 3265 | 3284 | void |
| 3266 | 3285 | swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) |
| ... | ... | @@ -3271,6 +3290,7 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) |
| 3271 | 3290 | |
| 3272 | 3291 | #if _LIBCPP_STD_VER > 17 |
| 3273 | 3292 | template <class _Tp, class _Allocator, class _Up> |
| 3293 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3274 | 3294 | inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type |
| 3275 | 3295 | erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { |
| 3276 | 3296 | auto __old_size = __c.size(); |
| ... | ... | @@ -3279,14 +3299,23 @@ erase(vector<_Tp, _Allocator>& __c, const _Up& __v) { |
| 3279 | 3299 | } |
| 3280 | 3300 | |
| 3281 | 3301 | template <class _Tp, class _Allocator, class _Predicate> |
| 3302 | _LIBCPP_CONSTEXPR_AFTER_CXX17 | |
| 3282 | 3303 | inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type |
| 3283 | 3304 | erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) { |
| 3284 | 3305 | auto __old_size = __c.size(); |
| 3285 | 3306 | __c.erase(_VSTD::remove_if(__c.begin(), __c.end(), __pred), __c.end()); |
| 3286 | 3307 | return __old_size - __c.size(); |
| 3287 | 3308 | } |
| 3309 | ||
| 3310 | template <> | |
| 3311 | inline constexpr bool __format::__enable_insertable<std::vector<char>> = true; | |
| 3312 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 3313 | template <> | |
| 3314 | inline constexpr bool __format::__enable_insertable<std::vector<wchar_t>> = true; | |
| 3288 | 3315 | #endif |
| 3289 | 3316 | |
| 3317 | #endif // _LIBCPP_STD_VER > 17 | |
| 3318 | ||
| 3290 | 3319 | _LIBCPP_END_NAMESPACE_STD |
| 3291 | 3320 | |
| 3292 | 3321 | _LIBCPP_POP_MACROS |
lib/libcxx/include/version+46-20| ... | ... | @@ -38,6 +38,7 @@ __cpp_lib_atomic_shared_ptr 201711L <atomic> |
| 38 | 38 | __cpp_lib_atomic_value_initialization 201911L <atomic> <memory> |
| 39 | 39 | __cpp_lib_atomic_wait 201907L <atomic> |
| 40 | 40 | __cpp_lib_barrier 201907L <barrier> |
| 41 | __cpp_lib_bind_back 202202L <functional> | |
| 41 | 42 | __cpp_lib_bind_front 201907L <functional> |
| 42 | 43 | __cpp_lib_bit_cast 201806L <bit> |
| 43 | 44 | __cpp_lib_bitops 201907L <bit> |
| ... | ... | @@ -46,7 +47,7 @@ __cpp_lib_bounded_array_traits 201902L <type_traits> |
| 46 | 47 | __cpp_lib_boyer_moore_searcher 201603L <functional> |
| 47 | 48 | __cpp_lib_byte 201603L <cstddef> |
| 48 | 49 | __cpp_lib_byteswap 202110L <bit> |
| 49 | __cpp_lib_char8_t 201811L <atomic> <filesystem> <istream> | |
| 50 | __cpp_lib_char8_t 201907L <atomic> <filesystem> <istream> | |
| 50 | 51 | <limits> <locale> <ostream> |
| 51 | 52 | <string> <string_view> |
| 52 | 53 | __cpp_lib_chrono 201611L <chrono> |
| ... | ... | @@ -55,13 +56,14 @@ __cpp_lib_clamp 201603L <algorithm> |
| 55 | 56 | __cpp_lib_complex_udls 201309L <complex> |
| 56 | 57 | __cpp_lib_concepts 202002L <concepts> |
| 57 | 58 | __cpp_lib_constexpr_algorithms 201806L <algorithm> |
| 59 | __cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib> | |
| 58 | 60 | __cpp_lib_constexpr_complex 201711L <complex> |
| 59 | 61 | __cpp_lib_constexpr_dynamic_alloc 201907L <memory> |
| 60 | 62 | __cpp_lib_constexpr_functional 201907L <functional> |
| 61 | 63 | __cpp_lib_constexpr_iterator 201811L <iterator> |
| 62 | 64 | __cpp_lib_constexpr_memory 201811L <memory> |
| 63 | 65 | __cpp_lib_constexpr_numeric 201911L <numeric> |
| 64 | __cpp_lib_constexpr_string 201811L <string> | |
| 66 | __cpp_lib_constexpr_string 201907L <string> | |
| 65 | 67 | __cpp_lib_constexpr_string_view 201811L <string_view> |
| 66 | 68 | __cpp_lib_constexpr_tuple 201811L <tuple> |
| 67 | 69 | __cpp_lib_constexpr_typeinfo 202106L <typeinfo> |
| ... | ... | @@ -115,7 +117,6 @@ __cpp_lib_map_try_emplace 201411L <map> |
| 115 | 117 | __cpp_lib_math_constants 201907L <numbers> |
| 116 | 118 | __cpp_lib_math_special_functions 201603L <cmath> |
| 117 | 119 | __cpp_lib_memory_resource 201603L <memory_resource> |
| 118 | __cpp_lib_monadic_optional 202110L <optional> | |
| 119 | 120 | __cpp_lib_move_only_function 202110L <functional> |
| 120 | 121 | __cpp_lib_node_extract 201606L <map> <set> <unordered_map> |
| 121 | 122 | <unordered_set> |
| ... | ... | @@ -125,16 +126,27 @@ __cpp_lib_nonmember_container_access 201411L <array> <deque> |
| 125 | 126 | <unordered_map> <unordered_set> <vector> |
| 126 | 127 | __cpp_lib_not_fn 201603L <functional> |
| 127 | 128 | __cpp_lib_null_iterators 201304L <iterator> |
| 128 | __cpp_lib_optional 201606L <optional> | |
| 129 | __cpp_lib_optional 202110L <optional> | |
| 130 | 201606L // C++17 | |
| 129 | 131 | __cpp_lib_out_ptr 202106L <memory> |
| 130 | 132 | __cpp_lib_parallel_algorithm 201603L <algorithm> <numeric> |
| 131 | 133 | __cpp_lib_polymorphic_allocator 201902L <memory_resource> |
| 132 | 134 | __cpp_lib_quoted_string_io 201304L <iomanip> |
| 133 | 135 | __cpp_lib_ranges 201811L <algorithm> <functional> <iterator> |
| 134 | 136 | <memory> <ranges> |
| 137 | __cpp_lib_ranges_chunk 202202L <ranges> | |
| 138 | __cpp_lib_ranges_chunk_by 202202L <ranges> | |
| 139 | __cpp_lib_ranges_iota 202202L <numeric> | |
| 140 | __cpp_lib_ranges_join_with 202202L <ranges> | |
| 141 | __cpp_lib_ranges_slide 202202L <ranges> | |
| 135 | 142 | __cpp_lib_ranges_starts_ends_with 202106L <algorithm> |
| 143 | __cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list> | |
| 144 | <map> <priority_queue> <queue> | |
| 145 | <set> <stack> <string> | |
| 146 | <unordered_map> <unordered_set> <vector> | |
| 136 | 147 | __cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility> |
| 137 | 148 | __cpp_lib_raw_memory_algorithms 201606L <memory> |
| 149 | __cpp_lib_reference_from_temporary 202202L <type_traits> | |
| 138 | 150 | __cpp_lib_remove_cvref 201711L <type_traits> |
| 139 | 151 | __cpp_lib_result_of_sfinae 201210L <functional> <type_traits> |
| 140 | 152 | __cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm> |
| ... | ... | @@ -142,7 +154,8 @@ __cpp_lib_sample 201603L <algorithm> |
| 142 | 154 | __cpp_lib_scoped_lock 201703L <mutex> |
| 143 | 155 | __cpp_lib_semaphore 201907L <semaphore> |
| 144 | 156 | __cpp_lib_shared_mutex 201505L <shared_mutex> |
| 145 | __cpp_lib_shared_ptr_arrays 201611L <memory> | |
| 157 | __cpp_lib_shared_ptr_arrays 201707L <memory> | |
| 158 | 201611L // C++17 | |
| 146 | 159 | __cpp_lib_shared_ptr_weak_type 201606L <memory> |
| 147 | 160 | __cpp_lib_shared_timed_mutex 201402L <shared_mutex> |
| 148 | 161 | __cpp_lib_shift 201806L <algorithm> |
| ... | ... | @@ -174,16 +187,18 @@ __cpp_lib_type_identity 201806L <type_traits> |
| 174 | 187 | __cpp_lib_type_trait_variable_templates 201510L <type_traits> |
| 175 | 188 | __cpp_lib_uncaught_exceptions 201411L <exception> |
| 176 | 189 | __cpp_lib_unordered_map_try_emplace 201411L <unordered_map> |
| 190 | __cpp_lib_unreachable 202202L <utility> | |
| 177 | 191 | __cpp_lib_unwrap_ref 201811L <functional> |
| 178 | 192 | __cpp_lib_variant 202102L <variant> |
| 179 | 193 | __cpp_lib_void_t 201411L <type_traits> |
| 180 | 194 | |
| 181 | 195 | */ |
| 182 | 196 | |
| 197 | #include <__assert> // all public C++ headers provide the assertion handler | |
| 183 | 198 | #include <__config> |
| 184 | 199 | |
| 185 | 200 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 186 | #pragma GCC system_header | |
| 201 | # pragma GCC system_header | |
| 187 | 202 | #endif |
| 188 | 203 | |
| 189 | 204 | // clang-format off |
| ... | ... | @@ -222,7 +237,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 222 | 237 | # define __cpp_lib_as_const 201510L |
| 223 | 238 | # define __cpp_lib_atomic_is_always_lock_free 201603L |
| 224 | 239 | # define __cpp_lib_bool_constant 201505L |
| 225 | // # define __cpp_lib_boyer_moore_searcher 201603L | |
| 240 | # define __cpp_lib_boyer_moore_searcher 201603L | |
| 226 | 241 | # define __cpp_lib_byte 201603L |
| 227 | 242 | # define __cpp_lib_chrono 201611L |
| 228 | 243 | # define __cpp_lib_clamp 201603L |
| ... | ... | @@ -232,7 +247,9 @@ __cpp_lib_void_t 201411L <type_traits> |
| 232 | 247 | # define __cpp_lib_filesystem 201703L |
| 233 | 248 | # endif |
| 234 | 249 | # define __cpp_lib_gcd_lcm 201606L |
| 235 | // # define __cpp_lib_hardware_interference_size 201703L | |
| 250 | # if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) | |
| 251 | # define __cpp_lib_hardware_interference_size 201703L | |
| 252 | # endif | |
| 236 | 253 | # define __cpp_lib_has_unique_object_representations 201606L |
| 237 | 254 | # define __cpp_lib_hypot 201603L |
| 238 | 255 | # define __cpp_lib_incomplete_container_elements 201505L |
| ... | ... | @@ -273,7 +290,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 273 | 290 | #if _LIBCPP_STD_VER > 17 |
| 274 | 291 | # undef __cpp_lib_array_constexpr |
| 275 | 292 | # define __cpp_lib_array_constexpr 201811L |
| 276 | // # define __cpp_lib_assume_aligned 201811L | |
| 293 | # define __cpp_lib_assume_aligned 201811L | |
| 277 | 294 | # define __cpp_lib_atomic_flag_test 201907L |
| 278 | 295 | // # define __cpp_lib_atomic_float 201711L |
| 279 | 296 | # define __cpp_lib_atomic_lock_free_type_aliases 201907L |
| ... | ... | @@ -291,7 +308,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 291 | 308 | // # define __cpp_lib_bitops 201907L |
| 292 | 309 | # define __cpp_lib_bounded_array_traits 201902L |
| 293 | 310 | # if !defined(_LIBCPP_HAS_NO_CHAR8_T) |
| 294 | # define __cpp_lib_char8_t 201811L | |
| 311 | # define __cpp_lib_char8_t 201907L | |
| 295 | 312 | # endif |
| 296 | 313 | # define __cpp_lib_concepts 202002L |
| 297 | 314 | # define __cpp_lib_constexpr_algorithms 201806L |
| ... | ... | @@ -301,7 +318,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 301 | 318 | # define __cpp_lib_constexpr_iterator 201811L |
| 302 | 319 | # define __cpp_lib_constexpr_memory 201811L |
| 303 | 320 | # define __cpp_lib_constexpr_numeric 201911L |
| 304 | # define __cpp_lib_constexpr_string 201811L | |
| 321 | # define __cpp_lib_constexpr_string 201907L | |
| 305 | 322 | # define __cpp_lib_constexpr_string_view 201811L |
| 306 | 323 | # define __cpp_lib_constexpr_tuple 201811L |
| 307 | 324 | # define __cpp_lib_constexpr_utility 201811L |
| ... | ... | @@ -319,9 +336,7 @@ __cpp_lib_void_t 201411L <type_traits> |
| 319 | 336 | # endif |
| 320 | 337 | # define __cpp_lib_generic_unordered_lookup 201811L |
| 321 | 338 | # define __cpp_lib_int_pow2 202002L |
| 322 | # if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 323 | # define __cpp_lib_integer_comparison_functions 202002L | |
| 324 | # endif | |
| 339 | # define __cpp_lib_integer_comparison_functions 202002L | |
| 325 | 340 | # define __cpp_lib_interpolate 201902L |
| 326 | 341 | # define __cpp_lib_is_constant_evaluated 201811L |
| 327 | 342 | // # define __cpp_lib_is_layout_compatible 201907L |
| ... | ... | @@ -334,15 +349,15 @@ __cpp_lib_void_t 201411L <type_traits> |
| 334 | 349 | # define __cpp_lib_latch 201907L |
| 335 | 350 | # endif |
| 336 | 351 | # define __cpp_lib_list_remove_return_type 201806L |
| 337 | # if !defined(_LIBCPP_HAS_NO_CONCEPTS) | |
| 338 | # define __cpp_lib_math_constants 201907L | |
| 339 | # endif | |
| 352 | # define __cpp_lib_math_constants 201907L | |
| 340 | 353 | // # define __cpp_lib_polymorphic_allocator 201902L |
| 341 | 354 | // # define __cpp_lib_ranges 201811L |
| 342 | 355 | # define __cpp_lib_remove_cvref 201711L |
| 343 | 356 | # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore) |
| 344 | 357 | # define __cpp_lib_semaphore 201907L |
| 345 | 358 | # endif |
| 359 | # undef __cpp_lib_shared_ptr_arrays | |
| 360 | # define __cpp_lib_shared_ptr_arrays 201707L | |
| 346 | 361 | # define __cpp_lib_shift 201806L |
| 347 | 362 | // # define __cpp_lib_smart_ptr_for_overwrite 202002L |
| 348 | 363 | // # define __cpp_lib_source_location 201907L |
| ... | ... | @@ -361,23 +376,34 @@ __cpp_lib_void_t 201411L <type_traits> |
| 361 | 376 | |
| 362 | 377 | #if _LIBCPP_STD_VER > 20 |
| 363 | 378 | # define __cpp_lib_adaptor_iterator_pair_constructor 202106L |
| 364 | // # define __cpp_lib_allocate_at_least 202106L | |
| 379 | # define __cpp_lib_allocate_at_least 202106L | |
| 365 | 380 | // # define __cpp_lib_associative_heterogeneous_erasure 202110L |
| 381 | // # define __cpp_lib_bind_back 202202L | |
| 366 | 382 | # define __cpp_lib_byteswap 202110L |
| 383 | // # define __cpp_lib_constexpr_cmath 202202L | |
| 367 | 384 | // # define __cpp_lib_constexpr_typeinfo 202106L |
| 368 | 385 | // # define __cpp_lib_invoke_r 202106L |
| 369 | 386 | # define __cpp_lib_is_scoped_enum 202011L |
| 370 | # define __cpp_lib_monadic_optional 202110L | |
| 371 | 387 | // # define __cpp_lib_move_only_function 202110L |
| 388 | # undef __cpp_lib_optional | |
| 389 | # define __cpp_lib_optional 202110L | |
| 372 | 390 | // # define __cpp_lib_out_ptr 202106L |
| 391 | // # define __cpp_lib_ranges_chunk 202202L | |
| 392 | // # define __cpp_lib_ranges_chunk_by 202202L | |
| 393 | // # define __cpp_lib_ranges_iota 202202L | |
| 394 | // # define __cpp_lib_ranges_join_with 202202L | |
| 395 | // # define __cpp_lib_ranges_slide 202202L | |
| 373 | 396 | // # define __cpp_lib_ranges_starts_ends_with 202106L |
| 397 | // # define __cpp_lib_ranges_to_container 202202L | |
| 374 | 398 | // # define __cpp_lib_ranges_zip 202110L |
| 399 | // # define __cpp_lib_reference_from_temporary 202202L | |
| 375 | 400 | // # define __cpp_lib_spanstream 202106L |
| 376 | 401 | // # define __cpp_lib_stacktrace 202011L |
| 377 | // # define __cpp_lib_stdatomic_h 202011L | |
| 402 | # define __cpp_lib_stdatomic_h 202011L | |
| 378 | 403 | # define __cpp_lib_string_contains 202011L |
| 379 | 404 | # define __cpp_lib_string_resize_and_overwrite 202110L |
| 380 | 405 | # define __cpp_lib_to_underlying 202102L |
| 406 | # define __cpp_lib_unreachable 202202L | |
| 381 | 407 | #endif |
| 382 | 408 | |
| 383 | 409 | // clang-format on |
lib/libcxx/include/wchar.h+6-6| ... | ... | @@ -10,7 +10,7 @@ |
| 10 | 10 | #if defined(__need_wint_t) || defined(__need_mbstate_t) |
| 11 | 11 | |
| 12 | 12 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 13 | #pragma GCC system_header | |
| 13 | # pragma GCC system_header | |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | 16 | #include_next <wchar.h> |
| ... | ... | @@ -113,7 +113,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, |
| 113 | 113 | #endif |
| 114 | 114 | |
| 115 | 115 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 116 | #pragma GCC system_header | |
| 116 | # pragma GCC system_header | |
| 117 | 117 | #endif |
| 118 | 118 | |
| 119 | 119 | #ifdef __cplusplus |
| ... | ... | @@ -176,10 +176,10 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_PREFERRED_OVERLOAD |
| 176 | 176 | |
| 177 | 177 | #if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT_LIKE) || defined(__MVS__)) |
| 178 | 178 | extern "C" { |
| 179 | size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src, | |
| 180 | size_t nmc, size_t len, mbstate_t *__restrict ps); | |
| 181 | size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src, | |
| 182 | size_t nwc, size_t len, mbstate_t *__restrict ps); | |
| 179 | size_t mbsnrtowcs(wchar_t *__restrict __dst, const char **__restrict __src, | |
| 180 | size_t __nmc, size_t __len, mbstate_t *__restrict __ps); | |
| 181 | size_t wcsnrtombs(char *__restrict __dst, const wchar_t **__restrict __src, | |
| 182 | size_t __nwc, size_t __len, mbstate_t *__restrict __ps); | |
| 183 | 183 | } // extern "C" |
| 184 | 184 | #endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) |
| 185 | 185 |
lib/libcxx/include/wctype.h+1-1| ... | ... | @@ -51,7 +51,7 @@ wctrans_t wctrans(const char* property); |
| 51 | 51 | #endif |
| 52 | 52 | |
| 53 | 53 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 54 | #pragma GCC system_header | |
| 54 | # pragma GCC system_header | |
| 55 | 55 | #endif |
| 56 | 56 | |
| 57 | 57 | // TODO: |
lib/libcxx/src/algorithm.cpp+3-1| ... | ... | @@ -6,10 +6,12 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "algorithm" | |
| 9 | #include <algorithm> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 | |
| 13 | // TODO(varconst): this currently doesn't benefit `ranges::sort` because it uses `ranges::less` instead of `__less`. | |
| 14 | ||
| 13 | 15 | template void __sort<__less<char>&, char*>(char*, char*, __less<char>&); |
| 14 | 16 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 15 | 17 | template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&); |
lib/libcxx/src/any.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "any" | |
| 9 | #include <any> | |
| 10 | 10 | |
| 11 | 11 | namespace std { |
| 12 | 12 | const char* bad_any_cast::what() const noexcept { |
lib/libcxx/src/barrier.cpp+1-1| ... | ... | @@ -90,7 +90,7 @@ void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) |
| 90 | 90 | delete __barrier; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | #endif //!defined(_LIBCPP_HAS_NO_TREE_BARRIER) | |
| 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| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "functional" | |
| 9 | #include <functional> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 |
lib/libcxx/src/charconv.cpp+9-119| ... | ... | @@ -6,144 +6,34 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "charconv" | |
| 9 | #include <charconv> | |
| 10 | 10 | #include <string.h> |
| 11 | 11 | |
| 12 | #include "include/ryu/digit_table.h" | |
| 13 | 12 | #include "include/to_chars_floating_point.h" |
| 14 | 13 | |
| 15 | 14 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 16 | 15 | |
| 17 | namespace __itoa | |
| 18 | { | |
| 19 | ||
| 20 | template <typename T> | |
| 21 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 22 | append1(char* buffer, T i) noexcept | |
| 23 | { | |
| 24 | *buffer = '0' + static_cast<char>(i); | |
| 25 | return buffer + 1; | |
| 26 | } | |
| 27 | ||
| 28 | template <typename T> | |
| 29 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 30 | append2(char* buffer, T i) noexcept | |
| 31 | { | |
| 32 | memcpy(buffer, &__DIGIT_TABLE[(i)*2], 2); | |
| 33 | return buffer + 2; | |
| 34 | } | |
| 35 | ||
| 36 | template <typename T> | |
| 37 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 38 | append3(char* buffer, T i) noexcept | |
| 39 | { | |
| 40 | return append2(append1(buffer, (i) / 100), (i) % 100); | |
| 41 | } | |
| 16 | #ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | |
| 42 | 17 | |
| 43 | template <typename T> | |
| 44 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 45 | append4(char* buffer, T i) noexcept | |
| 46 | { | |
| 47 | return append2(append2(buffer, (i) / 100), (i) % 100); | |
| 48 | } | |
| 49 | ||
| 50 | template <typename T> | |
| 51 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 52 | append2_no_zeros(char* buffer, T v) noexcept | |
| 53 | { | |
| 54 | if (v < 10) | |
| 55 | return append1(buffer, v); | |
| 56 | else | |
| 57 | return append2(buffer, v); | |
| 58 | } | |
| 59 | ||
| 60 | template <typename T> | |
| 61 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 62 | append4_no_zeros(char* buffer, T v) noexcept | |
| 63 | { | |
| 64 | if (v < 100) | |
| 65 | return append2_no_zeros(buffer, v); | |
| 66 | else if (v < 1000) | |
| 67 | return append3(buffer, v); | |
| 68 | else | |
| 69 | return append4(buffer, v); | |
| 70 | } | |
| 71 | ||
| 72 | template <typename T> | |
| 73 | inline _LIBCPP_INLINE_VISIBILITY char* | |
| 74 | append8_no_zeros(char* buffer, T v) noexcept | |
| 18 | namespace __itoa | |
| 75 | 19 | { |
| 76 | if (v < 10000) | |
| 77 | { | |
| 78 | buffer = append4_no_zeros(buffer, v); | |
| 79 | } | |
| 80 | else | |
| 81 | { | |
| 82 | buffer = append4_no_zeros(buffer, v / 10000); | |
| 83 | buffer = append4(buffer, v % 10000); | |
| 84 | } | |
| 85 | return buffer; | |
| 86 | } | |
| 87 | 20 | |
| 88 | char* | |
| 21 | _LIBCPP_FUNC_VIS char* | |
| 89 | 22 | __u32toa(uint32_t value, char* buffer) noexcept |
| 90 | 23 | { |
| 91 | if (value < 100000000) | |
| 92 | { | |
| 93 | buffer = append8_no_zeros(buffer, value); | |
| 94 | } | |
| 95 | else | |
| 96 | { | |
| 97 | // value = aabbbbcccc in decimal | |
| 98 | const uint32_t a = value / 100000000; // 1 to 42 | |
| 99 | value %= 100000000; | |
| 100 | ||
| 101 | buffer = append2_no_zeros(buffer, a); | |
| 102 | buffer = append4(buffer, value / 10000); | |
| 103 | buffer = append4(buffer, value % 10000); | |
| 104 | } | |
| 105 | ||
| 106 | return buffer; | |
| 24 | 	return __base_10_u32(buffer, value); | |
| 107 | 25 | } |
| 108 | 26 | |
| 109 | char* | |
| 27 | _LIBCPP_FUNC_VIS char* | |
| 110 | 28 | __u64toa(uint64_t value, char* buffer) noexcept |
| 111 | 29 | { |
| 112 | if (value < 100000000) | |
| 113 | { | |
| 114 | uint32_t v = static_cast<uint32_t>(value); | |
| 115 | buffer = append8_no_zeros(buffer, v); | |
| 116 | } | |
| 117 | else if (value < 10000000000000000) | |
| 118 | { | |
| 119 | const uint32_t v0 = static_cast<uint32_t>(value / 100000000); | |
| 120 | const uint32_t v1 = static_cast<uint32_t>(value % 100000000); | |
| 121 | ||
| 122 | buffer = append8_no_zeros(buffer, v0); | |
| 123 | buffer = append4(buffer, v1 / 10000); | |
| 124 | buffer = append4(buffer, v1 % 10000); | |
| 125 | } | |
| 126 | else | |
| 127 | { | |
| 128 | const uint32_t a = | |
| 129 | static_cast<uint32_t>(value / 10000000000000000); // 1 to 1844 | |
| 130 | value %= 10000000000000000; | |
| 131 | ||
| 132 | buffer = append4_no_zeros(buffer, a); | |
| 133 | ||
| 134 | const uint32_t v0 = static_cast<uint32_t>(value / 100000000); | |
| 135 | const uint32_t v1 = static_cast<uint32_t>(value % 100000000); | |
| 136 | buffer = append4(buffer, v0 / 10000); | |
| 137 | buffer = append4(buffer, v0 % 10000); | |
| 138 | buffer = append4(buffer, v1 / 10000); | |
| 139 | buffer = append4(buffer, v1 % 10000); | |
| 140 | } | |
| 141 | ||
| 142 | return buffer; | |
| 30 | 	return __base_10_u64(buffer, value); | |
| 143 | 31 | } |
| 144 | 32 | |
| 145 | 33 | } // namespace __itoa |
| 146 | 34 | |
| 35 | #endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 | |
| 36 | ||
| 147 | 37 | // The original version of floating-point to_chars was written by Microsoft and |
| 148 | 38 | // contributed with the following license. |
| 149 | 39 |
lib/libcxx/src/chrono.cpp+3-3| ... | ... | @@ -12,9 +12,9 @@ |
| 12 | 12 | #define _LARGE_TIME_API |
| 13 | 13 | #endif |
| 14 | 14 | |
| 15 | #include "chrono" | |
| 16 | #include "cerrno" // errno | |
| 17 | #include "system_error" // __throw_system_error | |
| 15 | #include <cerrno> // errno | |
| 16 | #include <chrono> | |
| 17 | #include <system_error> // __throw_system_error | |
| 18 | 18 | |
| 19 | 19 | #if defined(__MVS__) |
| 20 | 20 | #include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic |
lib/libcxx/src/condition_variable.cpp+10-6| ... | ... | @@ -6,19 +6,21 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 9 | #include <__config> | |
| 10 | 10 | |
| 11 | 11 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 12 | 12 | |
| 13 | #include "condition_variable" | |
| 14 | #include "thread" | |
| 15 | #include "system_error" | |
| 16 | #include "__undef_macros" | |
| 13 | #include <condition_variable> | |
| 14 | #include <thread> | |
| 15 | #include <system_error> | |
| 17 | 16 | |
| 18 | 17 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) |
| 19 | #pragma comment(lib, "pthread") | |
| 18 | # pragma comment(lib, "pthread") | |
| 20 | 19 | #endif |
| 21 | 20 | |
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | ||
| 22 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 23 | 25 | |
| 24 | 26 | // ~condition_variable is defined elsewhere. |
| ... | ... | @@ -90,4 +92,6 @@ notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) |
| 90 | 92 | |
| 91 | 93 | _LIBCPP_END_NAMESPACE_STD |
| 92 | 94 | |
| 95 | _LIBCPP_POP_MACROS | |
| 96 | ||
| 93 | 97 | #endif // !_LIBCPP_HAS_NO_THREADS |
lib/libcxx/src/condition_variable_destructor.cpp+2-2| ... | ... | @@ -11,8 +11,8 @@ |
| 11 | 11 | // On some platforms ~condition_variable has been made trivial and the |
| 12 | 12 | // definition is only provided for ABI compatibility. |
| 13 | 13 | |
| 14 | #include "__config" | |
| 15 | #include "__threading_support" | |
| 14 | #include <__config> | |
| 15 | #include <__threading_support> | |
| 16 | 16 | |
| 17 | 17 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 18 | 18 | # if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION) |
lib/libcxx/src/debug.cpp+13-32| ... | ... | @@ -6,43 +6,24 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 10 | #include "__debug" | |
| 11 | #include "functional" | |
| 12 | #include "algorithm" | |
| 13 | #include "string" | |
| 14 | #include "cstdio" | |
| 15 | #include "__hash_table" | |
| 9 | #include <__assert> | |
| 10 | #include <__config> | |
| 11 | #include <__debug> | |
| 12 | #include <__hash_table> | |
| 13 | #include <algorithm> | |
| 14 | #include <cstdio> | |
| 15 | #include <functional> | |
| 16 | #include <string> | |
| 17 | ||
| 16 | 18 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 17 | #include "mutex" | |
| 18 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 19 | #pragma comment(lib, "pthread") | |
| 20 | #endif | |
| 19 | # include <mutex> | |
| 20 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 21 | # pragma comment(lib, "pthread") | |
| 22 | # endif | |
| 21 | 23 | #endif |
| 22 | 24 | |
| 23 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 24 | 26 | |
| 25 | std::string __libcpp_debug_info::what() const { | |
| 26 | string msg = __file_; | |
| 27 | msg += ":" + to_string(__line_) + ": _LIBCPP_ASSERT '"; | |
| 28 | msg += __pred_; | |
| 29 | msg += "' failed. "; | |
| 30 | msg += __msg_; | |
| 31 | return msg; | |
| 32 | } | |
| 33 | _LIBCPP_NORETURN void __libcpp_abort_debug_function(__libcpp_debug_info const& info) { | |
| 34 | std::fprintf(stderr, "%s\n", info.what().c_str()); | |
| 35 | std::abort(); | |
| 36 | } | |
| 37 | ||
| 38 | _LIBCPP_SAFE_STATIC __libcpp_debug_function_type | |
| 39 | __libcpp_debug_function = __libcpp_abort_debug_function; | |
| 40 | ||
| 41 | bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) { | |
| 42 | __libcpp_debug_function = __func; | |
| 43 | return true; | |
| 44 | } | |
| 45 | ||
| 46 | 27 | _LIBCPP_FUNC_VIS |
| 47 | 28 | __libcpp_db* |
| 48 | 29 | __get_db() |
lib/libcxx/src/exception.cpp+3-3| ... | ... | @@ -6,9 +6,9 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "exception" | |
| 10 | #include "new" | |
| 11 | #include "typeinfo" | |
| 9 | #include <exception> | |
| 10 | #include <new> | |
| 11 | #include <typeinfo> | |
| 12 | 12 | |
| 13 | 13 | #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) |
| 14 | 14 | #include <cxxabi.h> |
lib/libcxx/src/experimental/memory_resource.cpp+9-9| ... | ... | @@ -6,15 +6,15 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "experimental/memory_resource" | |
| 9 | #include <experimental/memory_resource> | |
| 10 | 10 | |
| 11 | 11 | #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 12 | #include "atomic" | |
| 12 | # include <atomic> | |
| 13 | 13 | #elif !defined(_LIBCPP_HAS_NO_THREADS) |
| 14 | #include "mutex" | |
| 15 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 16 | #pragma comment(lib, "pthread") | |
| 17 | #endif | |
| 14 | # include <mutex> | |
| 15 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 16 | # pragma comment(lib, "pthread") | |
| 17 | # endif | |
| 18 | 18 | #endif |
| 19 | 19 | |
| 20 | 20 | _LIBCPP_BEGIN_NAMESPACE_LFTS_PMR |
| ... | ... | @@ -97,7 +97,7 @@ static memory_resource * |
| 97 | 97 | __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) noexcept |
| 98 | 98 | { |
| 99 | 99 | #ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER |
| 100 | _LIBCPP_SAFE_STATIC static atomic<memory_resource*> __res{&res_init.resources.new_delete_res}; | |
| 100 | static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res}; | |
| 101 | 101 | if (set) { |
| 102 | 102 | new_res = new_res ? new_res : new_delete_resource(); |
| 103 | 103 | // TODO: Can a weaker ordering be used? |
| ... | ... | @@ -109,7 +109,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) |
| 109 | 109 | &__res, memory_order_acquire); |
| 110 | 110 | } |
| 111 | 111 | #elif !defined(_LIBCPP_HAS_NO_THREADS) |
| 112 | _LIBCPP_SAFE_STATIC static memory_resource * res = &res_init.resources.new_delete_res; | |
| 112 | static constinit memory_resource *res = &res_init.resources.new_delete_res; | |
| 113 | 113 | static mutex res_lock; |
| 114 | 114 | if (set) { |
| 115 | 115 | new_res = new_res ? new_res : new_delete_resource(); |
| ... | ... | @@ -122,7 +122,7 @@ __default_memory_resource(bool set = false, memory_resource * new_res = nullptr) |
| 122 | 122 | return res; |
| 123 | 123 | } |
| 124 | 124 | #else |
| 125 | _LIBCPP_SAFE_STATIC static memory_resource* res = &res_init.resources.new_delete_res; | |
| 125 | static constinit memory_resource *res = &res_init.resources.new_delete_res; | |
| 126 | 126 | if (set) { |
| 127 | 127 | new_res = new_res ? new_res : new_delete_resource(); |
| 128 | 128 | memory_resource * old_res = res; |
lib/libcxx/src/experimental/memory_resource_init_helper.h+1-1| ... | ... | @@ -1,2 +1,2 @@ |
| 1 | 1 | #pragma GCC system_header |
| 2 | _LIBCPP_SAFE_STATIC ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX; | |
| 2 | static constinit ResourceInitHelper res_init _LIBCPP_INIT_PRIORITY_MAX; |
lib/libcxx/src/filesystem/directory_iterator.cpp+13-12| ... | ... | @@ -6,10 +6,11 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 10 | #include "filesystem" | |
| 11 | #include "stack" | |
| 9 | #include <__assert> | |
| 10 | #include <__config> | |
| 12 | 11 | #include <errno.h> |
| 12 | #include <filesystem> | |
| 13 | #include <stack> | |
| 13 | 14 | |
| 14 | 15 | #include "filesystem_common.h" |
| 15 | 16 | |
| ... | ... | @@ -24,8 +25,8 @@ public: |
| 24 | 25 | __dir_stream& operator=(const __dir_stream&) = delete; |
| 25 | 26 | |
| 26 | 27 | __dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_), |
| 27 | __root_(move(__ds.__root_)), | |
| 28 | __entry_(move(__ds.__entry_)) { | |
| 28 | __root_(std::move(__ds.__root_)), | |
| 29 | __entry_(std::move(__ds.__entry_)) { | |
| 29 | 30 | __ds.__stream_ = INVALID_HANDLE_VALUE; |
| 30 | 31 | } |
| 31 | 32 | |
| ... | ... | @@ -103,8 +104,8 @@ public: |
| 103 | 104 | __dir_stream& operator=(const __dir_stream&) = delete; |
| 104 | 105 | |
| 105 | 106 | __dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_), |
| 106 | __root_(move(other.__root_)), | |
| 107 | __entry_(move(other.__entry_)) { | |
| 107 | __root_(std::move(other.__root_)), | |
| 108 | __entry_(std::move(other.__entry_)) { | |
| 108 | 109 | other.__stream_ = nullptr; |
| 109 | 110 | } |
| 110 | 111 | |
| ... | ... | @@ -186,7 +187,7 @@ directory_iterator& directory_iterator::__increment(error_code* ec) { |
| 186 | 187 | |
| 187 | 188 | error_code m_ec; |
| 188 | 189 | if (!__imp_->advance(m_ec)) { |
| 189 | path root = move(__imp_->__root_); | |
| 190 | path root = std::move(__imp_->__root_); | |
| 190 | 191 | __imp_.reset(); |
| 191 | 192 | if (m_ec) |
| 192 | 193 | err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str()); |
| ... | ... | @@ -220,7 +221,7 @@ recursive_directory_iterator::recursive_directory_iterator( |
| 220 | 221 | |
| 221 | 222 | __imp_ = make_shared<__shared_imp>(); |
| 222 | 223 | __imp_->__options_ = opt; |
| 223 | __imp_->__stack_.push(move(new_s)); | |
| 224 | __imp_->__stack_.push(std::move(new_s)); | |
| 224 | 225 | } |
| 225 | 226 | |
| 226 | 227 | void recursive_directory_iterator::__pop(error_code* ec) { |
| ... | ... | @@ -274,7 +275,7 @@ void recursive_directory_iterator::__advance(error_code* ec) { |
| 274 | 275 | } |
| 275 | 276 | |
| 276 | 277 | if (m_ec) { |
| 277 | path root = move(stack.top().__root_); | |
| 278 | path root = std::move(stack.top().__root_); | |
| 278 | 279 | __imp_.reset(); |
| 279 | 280 | err.report(m_ec, "at root " PATH_CSTR_FMT, root.c_str()); |
| 280 | 281 | } else { |
| ... | ... | @@ -308,7 +309,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) { |
| 308 | 309 | if (!skip_rec) { |
| 309 | 310 | __dir_stream new_it(curr_it.__entry_.path(), __imp_->__options_, m_ec); |
| 310 | 311 | if (new_it.good()) { |
| 311 | __imp_->__stack_.push(move(new_it)); | |
| 312 | __imp_->__stack_.push(std::move(new_it)); | |
| 312 | 313 | return true; |
| 313 | 314 | } |
| 314 | 315 | } |
| ... | ... | @@ -319,7 +320,7 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) { |
| 319 | 320 | if (ec) |
| 320 | 321 | ec->clear(); |
| 321 | 322 | } else { |
| 322 | path at_ent = move(curr_it.__entry_.__p_); | |
| 323 | path at_ent = std::move(curr_it.__entry_.__p_); | |
| 323 | 324 | __imp_.reset(); |
| 324 | 325 | err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT, |
| 325 | 326 | at_ent.c_str()); |
lib/libcxx/src/filesystem/filesystem_common.h+25-25| ... | ... | @@ -9,31 +9,30 @@ |
| 9 | 9 | #ifndef FILESYSTEM_COMMON_H |
| 10 | 10 | #define FILESYSTEM_COMMON_H |
| 11 | 11 | |
| 12 | #include "__config" | |
| 13 | #include "array" | |
| 14 | #include "chrono" | |
| 15 | #include "climits" | |
| 16 | #include "cstdarg" | |
| 17 | #include "cstdlib" | |
| 18 | #include "ctime" | |
| 19 | #include "filesystem" | |
| 20 | #include "ratio" | |
| 21 | #include "system_error" | |
| 12 | #include <__assert> | |
| 13 | #include <__config> | |
| 14 | #include <array> | |
| 15 | #include <chrono> | |
| 16 | #include <climits> | |
| 17 | #include <cstdarg> | |
| 18 | #include <ctime> | |
| 19 | #include <filesystem> | |
| 20 | #include <ratio> | |
| 21 | #include <system_error> | |
| 22 | #include <utility> | |
| 22 | 23 | |
| 23 | 24 | #if defined(_LIBCPP_WIN32API) |
| 24 | 25 | # define WIN32_LEAN_AND_MEAN |
| 25 | 26 | # define NOMINMAX |
| 26 | 27 | # include <windows.h> |
| 27 | #endif | |
| 28 | ||
| 29 | #if !defined(_LIBCPP_WIN32API) | |
| 28 | #else | |
| 30 | 29 | # include <dirent.h> // for DIR & friends |
| 31 | 30 | # include <fcntl.h> /* values for fchmodat */ |
| 32 | 31 | # include <sys/stat.h> |
| 33 | 32 | # include <sys/statvfs.h> |
| 34 | 33 | # include <sys/time.h> // for ::utimes as used in __last_write_time |
| 35 | 34 | # include <unistd.h> |
| 36 | #endif | |
| 35 | #endif // defined(_LIBCPP_WIN32API) | |
| 37 | 36 | |
| 38 | 37 | #include "../include/apple_availability.h" |
| 39 | 38 | |
| ... | ... | @@ -45,17 +44,16 @@ |
| 45 | 44 | #endif |
| 46 | 45 | #endif |
| 47 | 46 | |
| 48 | #if defined(__GNUC__) || defined(__clang__) | |
| 49 | #pragma GCC diagnostic push | |
| 50 | #pragma GCC diagnostic ignored "-Wunused-function" | |
| 51 | #endif | |
| 47 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 48 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wunused-function") | |
| 49 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-function") | |
| 52 | 50 | |
| 53 | 51 | #if defined(_LIBCPP_WIN32API) |
| 54 | #define PS(x) (L##x) | |
| 55 | #define PATH_CSTR_FMT "\"%ls\"" | |
| 52 | # define PATHSTR(x) (L##x) | |
| 53 | # define PATH_CSTR_FMT "\"%ls\"" | |
| 56 | 54 | #else |
| 57 | #define PS(x) (x) | |
| 58 | #define PATH_CSTR_FMT "\"%s\"" | |
| 55 | # define PATHSTR(x) (x) | |
| 56 | # define PATH_CSTR_FMT "\"%s\"" | |
| 59 | 57 | #endif |
| 60 | 58 | |
| 61 | 59 | _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM |
| ... | ... | @@ -113,7 +111,7 @@ format_string(const char* msg, ...) { |
| 113 | 111 | } |
| 114 | 112 | |
| 115 | 113 | error_code capture_errno() { |
| 116 | _LIBCPP_ASSERT(errno, "Expected errno to be non-zero"); | |
| 114 | _LIBCPP_ASSERT(errno != 0, "Expected errno to be non-zero"); | |
| 117 | 115 | return error_code(errno, generic_category()); |
| 118 | 116 | } |
| 119 | 117 | |
| ... | ... | @@ -178,7 +176,7 @@ struct ErrorHandler { |
| 178 | 176 | case 2: |
| 179 | 177 | __throw_filesystem_error(what, *p1_, *p2_, ec); |
| 180 | 178 | } |
| 181 | _LIBCPP_UNREACHABLE(); | |
| 179 | __libcpp_unreachable(); | |
| 182 | 180 | } |
| 183 | 181 | |
| 184 | 182 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 0) |
| ... | ... | @@ -197,7 +195,7 @@ struct ErrorHandler { |
| 197 | 195 | case 2: |
| 198 | 196 | __throw_filesystem_error(what, *p1_, *p2_, ec); |
| 199 | 197 | } |
| 200 | _LIBCPP_UNREACHABLE(); | |
| 198 | __libcpp_unreachable(); | |
| 201 | 199 | } |
| 202 | 200 | |
| 203 | 201 | _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) |
| ... | ... | @@ -610,4 +608,6 @@ static file_time_type get_write_time(const WIN32_FIND_DATAW& data) { |
| 610 | 608 | |
| 611 | 609 | _LIBCPP_END_NAMESPACE_FILESYSTEM |
| 612 | 610 | |
| 611 | _LIBCPP_DIAGNOSTIC_POP | |
| 612 | ||
| 613 | 613 | #endif // FILESYSTEM_COMMON_H |
lib/libcxx/src/filesystem/int128_builtins.cpp+2-2| ... | ... | @@ -13,8 +13,8 @@ |
| 13 | 13 | * |
| 14 | 14 | * ===----------------------------------------------------------------------=== |
| 15 | 15 | */ |
| 16 | #include "__config" | |
| 17 | #include "climits" | |
| 16 | #include <__config> | |
| 17 | #include <climits> | |
| 18 | 18 | |
| 19 | 19 | #if !defined(_LIBCPP_HAS_NO_INT128) |
| 20 | 20 |
lib/libcxx/src/filesystem/operations.cpp+40-38| ... | ... | @@ -6,14 +6,16 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "filesystem" | |
| 10 | #include "array" | |
| 11 | #include "iterator" | |
| 12 | #include "string_view" | |
| 13 | #include "type_traits" | |
| 14 | #include "vector" | |
| 15 | #include "cstdlib" | |
| 16 | #include "climits" | |
| 9 | #include <__assert> | |
| 10 | #include <__utility/unreachable.h> | |
| 11 | #include <array> | |
| 12 | #include <climits> | |
| 13 | #include <cstdlib> | |
| 14 | #include <filesystem> | |
| 15 | #include <iterator> | |
| 16 | #include <string_view> | |
| 17 | #include <type_traits> | |
| 18 | #include <vector> | |
| 17 | 19 | |
| 18 | 20 | #include "filesystem_common.h" |
| 19 | 21 | |
| ... | ... | @@ -39,7 +41,7 @@ |
| 39 | 41 | # include <copyfile.h> |
| 40 | 42 | # define _LIBCPP_FILESYSTEM_USE_COPYFILE |
| 41 | 43 | #else |
| 42 | # include "fstream" | |
| 44 | # include <fstream> | |
| 43 | 45 | # define _LIBCPP_FILESYSTEM_USE_FSTREAM |
| 44 | 46 | #endif |
| 45 | 47 | |
| ... | ... | @@ -154,7 +156,7 @@ public: |
| 154 | 156 | return makeState(PS_AtEnd); |
| 155 | 157 | |
| 156 | 158 | case PS_AtEnd: |
| 157 | _LIBCPP_UNREACHABLE(); | |
| 159 | __libcpp_unreachable(); | |
| 158 | 160 | } |
| 159 | 161 | } |
| 160 | 162 | |
| ... | ... | @@ -202,7 +204,7 @@ public: |
| 202 | 204 | return makeState(PS_InRootName, Path.data(), RStart + 1); |
| 203 | 205 | case PS_InRootName: |
| 204 | 206 | case PS_BeforeBegin: |
| 205 | _LIBCPP_UNREACHABLE(); | |
| 207 | __libcpp_unreachable(); | |
| 206 | 208 | } |
| 207 | 209 | } |
| 208 | 210 | |
| ... | ... | @@ -212,19 +214,19 @@ public: |
| 212 | 214 | switch (State) { |
| 213 | 215 | case PS_BeforeBegin: |
| 214 | 216 | case PS_AtEnd: |
| 215 | return PS(""); | |
| 217 | return PATHSTR(""); | |
| 216 | 218 | case PS_InRootDir: |
| 217 | 219 | if (RawEntry[0] == '\\') |
| 218 | return PS("\\"); | |
| 220 | return PATHSTR("\\"); | |
| 219 | 221 | else |
| 220 | return PS("/"); | |
| 222 | return PATHSTR("/"); | |
| 221 | 223 | case PS_InTrailingSep: |
| 222 | return PS(""); | |
| 224 | return PATHSTR(""); | |
| 223 | 225 | case PS_InRootName: |
| 224 | 226 | case PS_InFilenames: |
| 225 | 227 | return RawEntry; |
| 226 | 228 | } |
| 227 | _LIBCPP_UNREACHABLE(); | |
| 229 | __libcpp_unreachable(); | |
| 228 | 230 | } |
| 229 | 231 | |
| 230 | 232 | explicit operator bool() const noexcept { |
| ... | ... | @@ -285,7 +287,7 @@ private: |
| 285 | 287 | case PS_AtEnd: |
| 286 | 288 | return getAfterBack(); |
| 287 | 289 | } |
| 288 | _LIBCPP_UNREACHABLE(); | |
| 290 | __libcpp_unreachable(); | |
| 289 | 291 | } |
| 290 | 292 | |
| 291 | 293 | /// \brief Return a pointer to the first character in the currently lexed |
| ... | ... | @@ -302,7 +304,7 @@ private: |
| 302 | 304 | case PS_AtEnd: |
| 303 | 305 | return &Path.back() + 1; |
| 304 | 306 | } |
| 305 | _LIBCPP_UNREACHABLE(); | |
| 307 | __libcpp_unreachable(); | |
| 306 | 308 | } |
| 307 | 309 | |
| 308 | 310 | // Consume all consecutive separators. |
| ... | ... | @@ -385,8 +387,8 @@ private: |
| 385 | 387 | }; |
| 386 | 388 | |
| 387 | 389 | string_view_pair separate_filename(string_view_t const& s) { |
| 388 | if (s == PS(".") || s == PS("..") || s.empty()) | |
| 389 | return string_view_pair{s, PS("")}; | |
| 390 | if (s == PATHSTR(".") || s == PATHSTR("..") || s.empty()) | |
| 391 | return string_view_pair{s, PATHSTR("")}; | |
| 390 | 392 | auto pos = s.find_last_of('.'); |
| 391 | 393 | if (pos == string_view_t::npos || pos == 0) |
| 392 | 394 | return string_view_pair{s, string_view_t{}}; |
| ... | ... | @@ -681,7 +683,7 @@ void filesystem_error::__create_what(int __num_paths) { |
| 681 | 683 | return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]", |
| 682 | 684 | derived_what, path1().c_str(), path2().c_str()); |
| 683 | 685 | } |
| 684 | _LIBCPP_UNREACHABLE(); | |
| 686 | __libcpp_unreachable(); | |
| 685 | 687 | }(); |
| 686 | 688 | } |
| 687 | 689 | |
| ... | ... | @@ -1188,7 +1190,7 @@ bool __fs_is_empty(const path& p, error_code* ec) { |
| 1188 | 1190 | } else if (is_regular_file(st)) |
| 1189 | 1191 | return static_cast<uintmax_t>(pst.st_size) == 0; |
| 1190 | 1192 | |
| 1191 | _LIBCPP_UNREACHABLE(); | |
| 1193 | __libcpp_unreachable(); | |
| 1192 | 1194 | } |
| 1193 | 1195 | |
| 1194 | 1196 | static file_time_type __extract_last_write_time(const path& p, const StatT& st, |
| ... | ... | @@ -1614,7 +1616,7 @@ path& path::replace_extension(path const& replacement) { |
| 1614 | 1616 | } |
| 1615 | 1617 | if (!replacement.empty()) { |
| 1616 | 1618 | if (replacement.native()[0] != '.') { |
| 1617 | __pn_ += PS("."); | |
| 1619 | __pn_ += PATHSTR("."); | |
| 1618 | 1620 | } |
| 1619 | 1621 | __pn_.append(replacement.__pn_); |
| 1620 | 1622 | } |
| ... | ... | @@ -1736,14 +1738,14 @@ enum PathPartKind : unsigned char { |
| 1736 | 1738 | static PathPartKind ClassifyPathPart(string_view_t Part) { |
| 1737 | 1739 | if (Part.empty()) |
| 1738 | 1740 | return PK_TrailingSep; |
| 1739 | if (Part == PS(".")) | |
| 1741 | if (Part == PATHSTR(".")) | |
| 1740 | 1742 | return PK_Dot; |
| 1741 | if (Part == PS("..")) | |
| 1743 | if (Part == PATHSTR("..")) | |
| 1742 | 1744 | return PK_DotDot; |
| 1743 | if (Part == PS("/")) | |
| 1745 | if (Part == PATHSTR("/")) | |
| 1744 | 1746 | return PK_RootSep; |
| 1745 | 1747 | #if defined(_LIBCPP_WIN32API) |
| 1746 | if (Part == PS("\\")) | |
| 1748 | if (Part == PATHSTR("\\")) | |
| 1747 | 1749 | return PK_RootSep; |
| 1748 | 1750 | #endif |
| 1749 | 1751 | return PK_Filename; |
| ... | ... | @@ -1793,7 +1795,7 @@ path path::lexically_normal() const { |
| 1793 | 1795 | NewPathSize -= Parts.back().first.size(); |
| 1794 | 1796 | Parts.pop_back(); |
| 1795 | 1797 | } else if (LastKind != PK_RootSep) |
| 1796 | AddPart(PK_DotDot, PS("..")); | |
| 1798 | AddPart(PK_DotDot, PATHSTR("..")); | |
| 1797 | 1799 | MaybeNeedTrailingSep = LastKind == PK_Filename; |
| 1798 | 1800 | break; |
| 1799 | 1801 | } |
| ... | ... | @@ -1803,12 +1805,12 @@ path path::lexically_normal() const { |
| 1803 | 1805 | break; |
| 1804 | 1806 | } |
| 1805 | 1807 | case PK_None: |
| 1806 | _LIBCPP_UNREACHABLE(); | |
| 1808 | __libcpp_unreachable(); | |
| 1807 | 1809 | } |
| 1808 | 1810 | } |
| 1809 | 1811 | // [fs.path.generic]p6.8: If the path is empty, add a dot. |
| 1810 | 1812 | if (Parts.empty()) |
| 1811 | return PS("."); | |
| 1813 | return PATHSTR("."); | |
| 1812 | 1814 | |
| 1813 | 1815 | // [fs.path.generic]p6.7: If the last filename is dot-dot, remove any |
| 1814 | 1816 | // trailing directory-separator. |
| ... | ... | @@ -1820,7 +1822,7 @@ path path::lexically_normal() const { |
| 1820 | 1822 | Result /= PK.first; |
| 1821 | 1823 | |
| 1822 | 1824 | if (NeedTrailingSep) |
| 1823 | Result /= PS(""); | |
| 1825 | Result /= PATHSTR(""); | |
| 1824 | 1826 | |
| 1825 | 1827 | Result.make_preferred(); |
| 1826 | 1828 | return Result; |
| ... | ... | @@ -1830,9 +1832,9 @@ static int DetermineLexicalElementCount(PathParser PP) { |
| 1830 | 1832 | int Count = 0; |
| 1831 | 1833 | for (; PP; ++PP) { |
| 1832 | 1834 | auto Elem = *PP; |
| 1833 | if (Elem == PS("..")) | |
| 1835 | if (Elem == PATHSTR("..")) | |
| 1834 | 1836 | --Count; |
| 1835 | else if (Elem != PS(".") && Elem != PS("")) | |
| 1837 | else if (Elem != PATHSTR(".") && Elem != PATHSTR("")) | |
| 1836 | 1838 | ++Count; |
| 1837 | 1839 | } |
| 1838 | 1840 | return Count; |
| ... | ... | @@ -1879,15 +1881,15 @@ path path::lexically_relative(const path& base) const { |
| 1879 | 1881 | return {}; |
| 1880 | 1882 | |
| 1881 | 1883 | // if n == 0 and (a == end() || a->empty()), returns path("."); otherwise |
| 1882 | if (ElemCount == 0 && (PP.atEnd() || *PP == PS(""))) | |
| 1883 | return PS("."); | |
| 1884 | if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR(""))) | |
| 1885 | return PATHSTR("."); | |
| 1884 | 1886 | |
| 1885 | // return a path constructed with 'n' dot-dot elements, followed by the the | |
| 1887 | // return a path constructed with 'n' dot-dot elements, followed by the | |
| 1886 | 1888 | // elements of '*this' after the mismatch. |
| 1887 | 1889 | path Result; |
| 1888 | 1890 | // FIXME: Reserve enough room in Result that it won't have to re-allocate. |
| 1889 | 1891 | while (ElemCount--) |
| 1890 | Result /= PS(".."); | |
| 1892 | Result /= PATHSTR(".."); | |
| 1891 | 1893 | for (; PP; ++PP) |
| 1892 | 1894 | Result /= *PP; |
| 1893 | 1895 | return Result; |
| ... | ... | @@ -1900,7 +1902,7 @@ static int CompareRootName(PathParser *LHS, PathParser *RHS) { |
| 1900 | 1902 | return 0; |
| 1901 | 1903 | |
| 1902 | 1904 | auto GetRootName = [](PathParser *Parser) -> string_view_t { |
| 1903 | return Parser->inRootName() ? **Parser : PS(""); | |
| 1905 | return Parser->inRootName() ? **Parser : PATHSTR(""); | |
| 1904 | 1906 | }; |
| 1905 | 1907 | int res = GetRootName(LHS).compare(GetRootName(RHS)); |
| 1906 | 1908 | ConsumeRootName(LHS); |
lib/libcxx/src/filesystem/posix_compat.h+2-1| ... | ... | @@ -23,7 +23,8 @@ |
| 23 | 23 | #ifndef POSIX_COMPAT_H |
| 24 | 24 | #define POSIX_COMPAT_H |
| 25 | 25 | |
| 26 | #include "filesystem" | |
| 26 | #include <__assert> | |
| 27 | #include <filesystem> | |
| 27 | 28 | |
| 28 | 29 | #include "filesystem_common.h" |
| 29 | 30 |
lib/libcxx/src/format.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "format" | |
| 9 | #include <format> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 |
lib/libcxx/src/functional.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "functional" | |
| 9 | #include <functional> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 |
lib/libcxx/src/future.cpp+7-15| ... | ... | @@ -6,12 +6,12 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 9 | #include <__config> | |
| 10 | 10 | |
| 11 | 11 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 12 | 12 | |
| 13 | #include "future" | |
| 14 | #include "string" | |
| 13 | #include <future> | |
| 14 | #include <string> | |
| 15 | 15 | |
| 16 | 16 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 17 | 17 | |
| ... | ... | @@ -29,13 +29,9 @@ __future_error_category::name() const noexcept |
| 29 | 29 | return "future"; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | #if defined(__clang__) | |
| 33 | #pragma clang diagnostic push | |
| 34 | #pragma clang diagnostic ignored "-Wswitch" | |
| 35 | #elif defined(__GNUC__) || defined(__GNUG__) | |
| 36 | #pragma GCC diagnostic push | |
| 37 | #pragma GCC diagnostic ignored "-Wswitch" | |
| 38 | #endif | |
| 32 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 33 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wswitch") | |
| 34 | _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wswitch") | |
| 39 | 35 | |
| 40 | 36 | string |
| 41 | 37 | __future_error_category::message(int ev) const |
| ... | ... | @@ -58,11 +54,7 @@ __future_error_category::message(int ev) const |
| 58 | 54 | return string("unspecified future_errc value\n"); |
| 59 | 55 | } |
| 60 | 56 | |
| 61 | #if defined(__clang__) | |
| 62 | #pragma clang diagnostic pop | |
| 63 | #elif defined(__GNUC__) || defined(__GNUG__) | |
| 64 | #pragma GCC diagnostic pop | |
| 65 | #endif | |
| 57 | _LIBCPP_DIAGNOSTIC_POP | |
| 66 | 58 | |
| 67 | 59 | const error_category& |
| 68 | 60 | future_category() noexcept |
lib/libcxx/src/hash.cpp+6-8| ... | ... | @@ -6,14 +6,12 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__hash_table" | |
| 10 | #include "algorithm" | |
| 11 | #include "stdexcept" | |
| 12 | #include "type_traits" | |
| 13 | ||
| 14 | #ifdef __clang__ | |
| 15 | #pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare" | |
| 16 | #endif | |
| 9 | #include <__hash_table> | |
| 10 | #include <algorithm> | |
| 11 | #include <stdexcept> | |
| 12 | #include <type_traits> | |
| 13 | ||
| 14 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare") | |
| 17 | 15 | |
| 18 | 16 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 17 |
lib/libcxx/src/include/atomic_support.h+2-2| ... | ... | @@ -9,8 +9,8 @@ |
| 9 | 9 | #ifndef ATOMIC_SUPPORT_H |
| 10 | 10 | #define ATOMIC_SUPPORT_H |
| 11 | 11 | |
| 12 | #include "__config" | |
| 13 | #include "memory" // for __libcpp_relaxed_load | |
| 12 | #include <__config> | |
| 13 | #include <memory> // for __libcpp_relaxed_load | |
| 14 | 14 | |
| 15 | 15 | #if defined(__clang__) && __has_builtin(__atomic_load_n) \ |
| 16 | 16 | && __has_builtin(__atomic_store_n) \ |
lib/libcxx/src/include/config_elast.h+2| ... | ... | @@ -29,6 +29,8 @@ |
| 29 | 29 | // No _LIBCPP_ELAST needed on Fuchsia |
| 30 | 30 | #elif defined(__wasi__) |
| 31 | 31 | // No _LIBCPP_ELAST needed on WASI |
| 32 | #elif defined(__EMSCRIPTEN__) | |
| 33 | // No _LIBCPP_ELAST needed on Emscripten | |
| 32 | 34 | #elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC) |
| 33 | 35 | #define _LIBCPP_ELAST 4095 |
| 34 | 36 | #elif defined(__APPLE__) |
lib/libcxx/src/include/ryu/common.h+1| ... | ... | @@ -42,6 +42,7 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include <__assert> | |
| 45 | 46 | #include "__config" |
| 46 | 47 | |
| 47 | 48 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/src/include/ryu/d2fixed.h+2-2| ... | ... | @@ -42,8 +42,8 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include "__config" | |
| 46 | #include "cstdint" | |
| 45 | #include <__config> | |
| 46 | #include <cstdint> | |
| 47 | 47 | |
| 48 | 48 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 49 | 49 |
lib/libcxx/src/include/ryu/d2fixed_full_table.h+1-1| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include "__config" | |
| 45 | #include <__config> | |
| 46 | 46 | |
| 47 | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 48 |
lib/libcxx/src/include/ryu/d2s.h+1-1| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include "__config" | |
| 45 | #include <__config> | |
| 46 | 46 | |
| 47 | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 48 |
lib/libcxx/src/include/ryu/d2s_full_table.h+1-1| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include "__config" | |
| 45 | #include <__config> | |
| 46 | 46 | |
| 47 | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 48 |
lib/libcxx/src/include/ryu/d2s_intrinsics.h+4-1| ... | ... | @@ -42,7 +42,10 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include "__config" | |
| 45 | #include <__assert> | |
| 46 | #include <__config> | |
| 47 | ||
| 48 | #include "include/ryu/ryu.h" | |
| 46 | 49 | |
| 47 | 50 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 51 |
lib/libcxx/src/include/ryu/digit_table.h+7-18| ... | ... | @@ -39,30 +39,19 @@ |
| 39 | 39 | #ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H |
| 40 | 40 | #define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H |
| 41 | 41 | |
| 42 | // Avoid formatting to keep the changes with the original code minimal. | |
| 43 | // clang-format off | |
| 44 | ||
| 45 | #include "__config" | |
| 42 | #include <__charconv/tables.h> | |
| 43 | #include <__config> | |
| 46 | 44 | |
| 47 | 45 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 46 | |
| 49 | 47 | // A table of all two-digit numbers. This is used to speed up decimal digit |
| 50 | 48 | // 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 | }; | |
| 49 | // | |
| 50 | // In order to minimize the diff in the Ryu code between MSVC STL and libc++ | |
| 51 | // the code uses the name __DIGIT_TABLE. In order to avoid code duplication it | |
| 52 | // reuses the table already available in libc++. | |
| 53 | inline constexpr auto& __DIGIT_TABLE = __itoa::__table<>::__digits_base_10; | |
| 63 | 54 | |
| 64 | 55 | _LIBCPP_END_NAMESPACE_STD |
| 65 | 56 | |
| 66 | // clang-format on | |
| 67 | ||
| 68 | 57 | #endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H |
lib/libcxx/src/include/ryu/f2s.h+1-1| ... | ... | @@ -42,7 +42,7 @@ |
| 42 | 42 | // Avoid formatting to keep the changes with the original code minimal. |
| 43 | 43 | // clang-format off |
| 44 | 44 | |
| 45 | #include "__config" | |
| 45 | #include <__config> | |
| 46 | 46 | |
| 47 | 47 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 48 | 48 |
lib/libcxx/src/include/ryu/ryu.h+14-13| ... | ... | @@ -44,21 +44,22 @@ |
| 44 | 44 | // Avoid formatting to keep the changes with the original code minimal. |
| 45 | 45 | // clang-format off |
| 46 | 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" | |
| 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 | ||
| 55 | 56 | #include "include/ryu/f2s.h" |
| 56 | 57 | #include "include/ryu/d2s.h" |
| 57 | 58 | #include "include/ryu/d2fixed.h" |
| 58 | 59 | |
| 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) | |
| 60 | #if defined(_MSC_VER) | |
| 61 | #include <intrin.h> // for _umul128(), __shiftright128(), _BitScanForward{,64} | |
| 62 | #endif // defined(_MSC_VER) | |
| 62 | 63 | |
| 63 | 64 | #if defined(_WIN64) || defined(_M_AMD64) || defined(__x86_64__) || defined(__aarch64__) |
| 64 | 65 | #define _LIBCPP_64_BIT |
| ... | ... | @@ -68,7 +69,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 68 | 69 | |
| 69 | 70 | // https://github.com/ulfjack/ryu/tree/59661c3/ryu |
| 70 | 71 | |
| 71 | #if !defined(_LIBCPP_COMPILER_MSVC) | |
| 72 | #if !defined(_MSC_VER) | |
| 72 | 73 | _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) { |
| 73 | 74 | if (__mask == 0) { |
| 74 | 75 | return false; |
| ... | ... | @@ -84,7 +85,7 @@ _LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __inde |
| 84 | 85 | *__index = __builtin_ctz(__mask); |
| 85 | 86 | return true; |
| 86 | 87 | } |
| 87 | #endif // _LIBCPP_COMPILER_MSVC | |
| 88 | #endif // !_MSC_VER | |
| 88 | 89 | |
| 89 | 90 | template <class _Floating> |
| 90 | 91 | [[nodiscard]] to_chars_result _Floating_to_chars_ryu( |
lib/libcxx/src/include/sso_allocator.h+5| ... | ... | @@ -41,6 +41,11 @@ public: |
| 41 | 41 | typedef _Tp* pointer; |
| 42 | 42 | typedef _Tp value_type; |
| 43 | 43 | |
| 44 | template <class U> | |
| 45 | struct rebind { | |
| 46 | using other = __sso_allocator<U, _Np>; | |
| 47 | }; | |
| 48 | ||
| 44 | 49 | _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {} |
| 45 | 50 | _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {} |
| 46 | 51 | template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() |
lib/libcxx/src/include/to_chars_floating_point.h+13-10| ... | ... | @@ -17,16 +17,19 @@ |
| 17 | 17 | // Avoid formatting to keep the changes with the original code minimal. |
| 18 | 18 | // clang-format off |
| 19 | 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" | |
| 20 | #include <__algorithm/find.h> | |
| 21 | #include <__algorithm/find_if.h> | |
| 22 | #include <__algorithm/lower_bound.h> | |
| 23 | #include <__algorithm/min.h> | |
| 24 | #include <__assert> | |
| 25 | #include <__config> | |
| 26 | #include <__functional/operations.h> | |
| 27 | #include <__iterator/access.h> | |
| 28 | #include <__iterator/size.h> | |
| 29 | #include <bit> | |
| 30 | #include <cfloat> | |
| 31 | #include <climits> | |
| 32 | ||
| 30 | 33 | #include "include/ryu/ryu.h" |
| 31 | 34 | |
| 32 | 35 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/src/ios.cpp+13-11| ... | ... | @@ -6,20 +6,20 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 10 | ||
| 11 | #include "ios" | |
| 12 | ||
| 9 | #include <__config> | |
| 10 | #include <__locale> | |
| 11 | #include <algorithm> | |
| 12 | #include <ios> | |
| 13 | #include <limits> | |
| 14 | #include <memory> | |
| 15 | #include <new> | |
| 13 | 16 | #include <stdlib.h> |
| 17 | #include <string> | |
| 14 | 18 | |
| 15 | #include "__locale" | |
| 16 | #include "algorithm" | |
| 17 | 19 | #include "include/config_elast.h" |
| 18 | #include "limits" | |
| 19 | #include "memory" | |
| 20 | #include "new" | |
| 21 | #include "string" | |
| 22 | #include "__undef_macros" | |
| 20 | ||
| 21 | _LIBCPP_PUSH_MACROS | |
| 22 | #include <__undef_macros> | |
| 23 | 23 | |
| 24 | 24 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 25 | 25 | |
| ... | ... | @@ -439,3 +439,5 @@ ios_base::sync_with_stdio(bool sync) |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | _LIBCPP_END_NAMESPACE_STD |
| 442 | ||
| 443 | _LIBCPP_POP_MACROS |
lib/libcxx/src/ios.instantiations.cpp+7-8| ... | ... | @@ -6,14 +6,13 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 10 | #include "fstream" | |
| 11 | #include "ios" | |
| 12 | #include "istream" | |
| 13 | #include "ostream" | |
| 14 | #include "sstream" | |
| 15 | #include "streambuf" | |
| 16 | ||
| 9 | #include <__config> | |
| 10 | #include <fstream> | |
| 11 | #include <ios> | |
| 12 | #include <istream> | |
| 13 | #include <ostream> | |
| 14 | #include <sstream> | |
| 15 | #include <streambuf> | |
| 17 | 16 | |
| 18 | 17 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 18 |
lib/libcxx/src/iostream.cpp+4-4| ... | ... | @@ -6,10 +6,10 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__std_stream" | |
| 10 | #include "__locale" | |
| 11 | #include "string" | |
| 12 | #include "new" | |
| 9 | #include <__locale> | |
| 10 | #include <__std_stream> | |
| 11 | #include <new> | |
| 12 | #include <string> | |
| 13 | 13 | |
| 14 | 14 | #define _str(s) #s |
| 15 | 15 | #define str(s) _str(s) |
lib/libcxx/src/legacy_debug_handler.cpp created+54| ... | ... | @@ -0,0 +1,54 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #include <__config> | |
| 10 | #include <cstdio> | |
| 11 | #include <cstdlib> | |
| 12 | #include <string> | |
| 13 | ||
| 14 | // This file defines the legacy default debug handler and related mechanisms | |
| 15 | // to set it. This is for backwards ABI compatibility with code that has been | |
| 16 | // using this debug handler previously. | |
| 17 | ||
| 18 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 19 | ||
| 20 | struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { | |
| 21 | _LIBCPP_EXPORTED_FROM_ABI string what() const; | |
| 22 | ||
| 23 | const char* __file_; | |
| 24 | int __line_; | |
| 25 | const char* __pred_; | |
| 26 | const char* __msg_; | |
| 27 | }; | |
| 28 | ||
| 29 | std::string __libcpp_debug_info::what() const { | |
| 30 | string msg = __file_; | |
| 31 | msg += ":" + std::to_string(__line_) + ": _LIBCPP_ASSERT '"; | |
| 32 | msg += __pred_; | |
| 33 | msg += "' failed. "; | |
| 34 | msg += __msg_; | |
| 35 | return msg; | |
| 36 | } | |
| 37 | ||
| 38 | _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __libcpp_abort_debug_function(__libcpp_debug_info const& info) { | |
| 39 | std::fprintf(stderr, "%s\n", info.what().c_str()); | |
| 40 | std::abort(); | |
| 41 | } | |
| 42 | ||
| 43 | typedef void (*__libcpp_debug_function_type)(__libcpp_debug_info const&); | |
| 44 | ||
| 45 | _LIBCPP_EXPORTED_FROM_ABI | |
| 46 | constinit __libcpp_debug_function_type __libcpp_debug_function = __libcpp_abort_debug_function; | |
| 47 | ||
| 48 | _LIBCPP_EXPORTED_FROM_ABI | |
| 49 | bool __libcpp_set_debug_function(__libcpp_debug_function_type __func) { | |
| 50 | __libcpp_debug_function = __func; | |
| 51 | return true; | |
| 52 | } | |
| 53 | ||
| 54 | _LIBCPP_END_NAMESPACE_STD |
lib/libcxx/src/legacy_pointer_safety.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 9 | #include <__config> | |
| 10 | 10 | #include <memory> |
| 11 | 11 | |
| 12 | 12 | // Support for garbage collection was removed in C++23 by https://wg21.link/P2186R2. Libc++ implements |
lib/libcxx/src/locale.cpp+45-33| ... | ... | @@ -12,20 +12,21 @@ |
| 12 | 12 | #define _LCONV_C99 |
| 13 | 13 | #endif |
| 14 | 14 | |
| 15 | #include "algorithm" | |
| 16 | #include "clocale" | |
| 17 | #include "codecvt" | |
| 18 | #include "cstdio" | |
| 19 | #include "cstdlib" | |
| 20 | #include "cstring" | |
| 21 | #include "locale" | |
| 22 | #include "string" | |
| 23 | #include "type_traits" | |
| 24 | #include "typeinfo" | |
| 25 | #include "vector" | |
| 15 | #include <__utility/unreachable.h> | |
| 16 | #include <algorithm> | |
| 17 | #include <clocale> | |
| 18 | #include <codecvt> | |
| 19 | #include <cstdio> | |
| 20 | #include <cstdlib> | |
| 21 | #include <cstring> | |
| 22 | #include <locale> | |
| 23 | #include <string> | |
| 24 | #include <type_traits> | |
| 25 | #include <typeinfo> | |
| 26 | #include <vector> | |
| 26 | 27 | |
| 27 | 28 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 28 | # include "cwctype" | |
| 29 | # include <cwctype> | |
| 29 | 30 | #endif |
| 30 | 31 | |
| 31 | 32 | #if defined(_AIX) |
| ... | ... | @@ -44,13 +45,13 @@ |
| 44 | 45 | |
| 45 | 46 | #include "include/atomic_support.h" |
| 46 | 47 | #include "include/sso_allocator.h" |
| 47 | #include "__undef_macros" | |
| 48 | 48 | |
| 49 | 49 | // On Linux, wint_t and wchar_t have different signed-ness, and this causes |
| 50 | 50 | // lots of noise in the build log, but no bugs that I know of. |
| 51 | #if defined(__clang__) | |
| 52 | #pragma clang diagnostic ignored "-Wsign-conversion" | |
| 53 | #endif | |
| 51 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wsign-conversion") | |
| 52 | ||
| 53 | _LIBCPP_PUSH_MACROS | |
| 54 | #include <__undef_macros> | |
| 54 | 55 | |
| 55 | 56 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 56 | 57 | |
| ... | ... | @@ -127,11 +128,6 @@ _LIBCPP_NORETURN static void __throw_runtime_error(const string &msg) |
| 127 | 128 | |
| 128 | 129 | } |
| 129 | 130 | |
| 130 | #if defined(_AIX) | |
| 131 | // Set priority to INT_MIN + 256 + 150 | |
| 132 | # pragma priority ( -2147483242 ) | |
| 133 | #endif | |
| 134 | ||
| 135 | 131 | const locale::category locale::none; |
| 136 | 132 | const locale::category locale::collate; |
| 137 | 133 | const locale::category locale::ctype; |
| ... | ... | @@ -1528,7 +1524,7 @@ char |
| 1528 | 1524 | ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const |
| 1529 | 1525 | { |
| 1530 | 1526 | int r = __libcpp_wctob_l(c, __l); |
| 1531 | return r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault; | |
| 1527 | return (r != EOF) ? static_cast<char>(r) : dfault; | |
| 1532 | 1528 | } |
| 1533 | 1529 | |
| 1534 | 1530 | const wchar_t* |
| ... | ... | @@ -1537,7 +1533,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch |
| 1537 | 1533 | for (; low != high; ++low, ++dest) |
| 1538 | 1534 | { |
| 1539 | 1535 | int r = __libcpp_wctob_l(*low, __l); |
| 1540 | *dest = r != static_cast<int>(WEOF) ? static_cast<char>(r) : dfault; | |
| 1536 | *dest = (r != EOF) ? static_cast<char>(r) : dfault; | |
| 1541 | 1537 | } |
| 1542 | 1538 | return low; |
| 1543 | 1539 | } |
| ... | ... | @@ -1835,6 +1831,7 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept |
| 1835 | 1831 | // 040000 - 0FFFFF D8C0 - DBBF, DC00 - DFFF F1 - F3, 80 - BF, 80 - BF, 80 - BF 786432 |
| 1836 | 1832 | // 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 65536 |
| 1837 | 1833 | |
| 1834 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 1838 | 1835 | static |
| 1839 | 1836 | codecvt_base::result |
| 1840 | 1837 | utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt, |
| ... | ... | @@ -3208,6 +3205,8 @@ utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end, |
| 3208 | 3205 | return static_cast<int>(frm_nxt - frm); |
| 3209 | 3206 | } |
| 3210 | 3207 | |
| 3208 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 3209 | ||
| 3211 | 3210 | // template <> class codecvt<char16_t, char, mbstate_t> |
| 3212 | 3211 | |
| 3213 | 3212 | locale::id codecvt<char16_t, char, mbstate_t>::id; |
| ... | ... | @@ -3615,6 +3614,7 @@ __codecvt_utf8<wchar_t>::do_length(state_type&, |
| 3615 | 3614 | #endif |
| 3616 | 3615 | } |
| 3617 | 3616 | |
| 3617 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 3618 | 3618 | int |
| 3619 | 3619 | __codecvt_utf8<wchar_t>::do_max_length() const noexcept |
| 3620 | 3620 | { |
| ... | ... | @@ -3697,6 +3697,7 @@ __codecvt_utf8<char16_t>::do_length(state_type&, |
| 3697 | 3697 | return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 3698 | 3698 | } |
| 3699 | 3699 | |
| 3700 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 3700 | 3701 | int |
| 3701 | 3702 | __codecvt_utf8<char16_t>::do_max_length() const noexcept |
| 3702 | 3703 | { |
| ... | ... | @@ -3704,6 +3705,7 @@ __codecvt_utf8<char16_t>::do_max_length() const noexcept |
| 3704 | 3705 | return 6; |
| 3705 | 3706 | return 3; |
| 3706 | 3707 | } |
| 3708 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 3707 | 3709 | |
| 3708 | 3710 | // __codecvt_utf8<char32_t> |
| 3709 | 3711 | |
| ... | ... | @@ -3772,6 +3774,7 @@ __codecvt_utf8<char32_t>::do_length(state_type&, |
| 3772 | 3774 | return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 3773 | 3775 | } |
| 3774 | 3776 | |
| 3777 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 3775 | 3778 | int |
| 3776 | 3779 | __codecvt_utf8<char32_t>::do_max_length() const noexcept |
| 3777 | 3780 | { |
| ... | ... | @@ -3779,6 +3782,7 @@ __codecvt_utf8<char32_t>::do_max_length() const noexcept |
| 3779 | 3782 | return 7; |
| 3780 | 3783 | return 4; |
| 3781 | 3784 | } |
| 3785 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 3782 | 3786 | |
| 3783 | 3787 | // __codecvt_utf16<wchar_t, false> |
| 3784 | 3788 | |
| ... | ... | @@ -4057,6 +4061,7 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&, |
| 4057 | 4061 | return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 4058 | 4062 | } |
| 4059 | 4063 | |
| 4064 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4060 | 4065 | int |
| 4061 | 4066 | __codecvt_utf16<char16_t, false>::do_max_length() const noexcept |
| 4062 | 4067 | { |
| ... | ... | @@ -4064,6 +4069,7 @@ __codecvt_utf16<char16_t, false>::do_max_length() const noexcept |
| 4064 | 4069 | return 4; |
| 4065 | 4070 | return 2; |
| 4066 | 4071 | } |
| 4072 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4067 | 4073 | |
| 4068 | 4074 | // __codecvt_utf16<char16_t, true> |
| 4069 | 4075 | |
| ... | ... | @@ -4132,6 +4138,7 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&, |
| 4132 | 4138 | return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 4133 | 4139 | } |
| 4134 | 4140 | |
| 4141 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4135 | 4142 | int |
| 4136 | 4143 | __codecvt_utf16<char16_t, true>::do_max_length() const noexcept |
| 4137 | 4144 | { |
| ... | ... | @@ -4139,6 +4146,7 @@ __codecvt_utf16<char16_t, true>::do_max_length() const noexcept |
| 4139 | 4146 | return 4; |
| 4140 | 4147 | return 2; |
| 4141 | 4148 | } |
| 4149 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4142 | 4150 | |
| 4143 | 4151 | // __codecvt_utf16<char32_t, false> |
| 4144 | 4152 | |
| ... | ... | @@ -4207,6 +4215,7 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&, |
| 4207 | 4215 | return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 4208 | 4216 | } |
| 4209 | 4217 | |
| 4218 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4210 | 4219 | int |
| 4211 | 4220 | __codecvt_utf16<char32_t, false>::do_max_length() const noexcept |
| 4212 | 4221 | { |
| ... | ... | @@ -4214,6 +4223,7 @@ __codecvt_utf16<char32_t, false>::do_max_length() const noexcept |
| 4214 | 4223 | return 6; |
| 4215 | 4224 | return 4; |
| 4216 | 4225 | } |
| 4226 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4217 | 4227 | |
| 4218 | 4228 | // __codecvt_utf16<char32_t, true> |
| 4219 | 4229 | |
| ... | ... | @@ -4282,6 +4292,7 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&, |
| 4282 | 4292 | return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 4283 | 4293 | } |
| 4284 | 4294 | |
| 4295 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4285 | 4296 | int |
| 4286 | 4297 | __codecvt_utf16<char32_t, true>::do_max_length() const noexcept |
| 4287 | 4298 | { |
| ... | ... | @@ -4289,6 +4300,7 @@ __codecvt_utf16<char32_t, true>::do_max_length() const noexcept |
| 4289 | 4300 | return 6; |
| 4290 | 4301 | return 4; |
| 4291 | 4302 | } |
| 4303 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4292 | 4304 | |
| 4293 | 4305 | // __codecvt_utf8_utf16<wchar_t> |
| 4294 | 4306 | |
| ... | ... | @@ -4446,6 +4458,7 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&, |
| 4446 | 4458 | return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 4447 | 4459 | } |
| 4448 | 4460 | |
| 4461 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4449 | 4462 | int |
| 4450 | 4463 | __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept |
| 4451 | 4464 | { |
| ... | ... | @@ -4453,6 +4466,7 @@ __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept |
| 4453 | 4466 | return 7; |
| 4454 | 4467 | return 4; |
| 4455 | 4468 | } |
| 4469 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4456 | 4470 | |
| 4457 | 4471 | // __codecvt_utf8_utf16<char32_t> |
| 4458 | 4472 | |
| ... | ... | @@ -4521,6 +4535,7 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&, |
| 4521 | 4535 | return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); |
| 4522 | 4536 | } |
| 4523 | 4537 | |
| 4538 | _LIBCPP_SUPPRESS_DEPRECATED_PUSH | |
| 4524 | 4539 | int |
| 4525 | 4540 | __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept |
| 4526 | 4541 | { |
| ... | ... | @@ -4528,6 +4543,7 @@ __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept |
| 4528 | 4543 | return 7; |
| 4529 | 4544 | return 4; |
| 4530 | 4545 | } |
| 4546 | _LIBCPP_SUPPRESS_DEPRECATED_POP | |
| 4531 | 4547 | |
| 4532 | 4548 | // __narrow_to_utf8<16> |
| 4533 | 4549 | |
| ... | ... | @@ -4623,7 +4639,7 @@ static bool checked_string_to_char_convert(char& dest, |
| 4623 | 4639 | |
| 4624 | 4640 | return false; |
| 4625 | 4641 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 4626 | _LIBCPP_UNREACHABLE(); | |
| 4642 | __libcpp_unreachable(); | |
| 4627 | 4643 | } |
| 4628 | 4644 | |
| 4629 | 4645 | |
| ... | ... | @@ -5200,12 +5216,8 @@ __time_get::~__time_get() |
| 5200 | 5216 | { |
| 5201 | 5217 | freelocale(__loc_); |
| 5202 | 5218 | } |
| 5203 | #if defined(__clang__) | |
| 5204 | #pragma clang diagnostic ignored "-Wmissing-field-initializers" | |
| 5205 | #endif | |
| 5206 | #if defined(__GNUG__) | |
| 5207 | #pragma GCC diagnostic ignored "-Wmissing-field-initializers" | |
| 5208 | #endif | |
| 5219 | ||
| 5220 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers") | |
| 5209 | 5221 | |
| 5210 | 5222 | template <> |
| 5211 | 5223 | string |
| ... | ... | @@ -5351,9 +5363,7 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) |
| 5351 | 5363 | return result; |
| 5352 | 5364 | } |
| 5353 | 5365 | |
| 5354 | #if defined(__clang__) | |
| 5355 | #pragma clang diagnostic ignored "-Wmissing-braces" | |
| 5356 | #endif | |
| 5366 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces") | |
| 5357 | 5367 | |
| 5358 | 5368 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 5359 | 5369 | template <> |
| ... | ... | @@ -6599,3 +6609,5 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, |
| 6599 | 6609 | #endif |
| 6600 | 6610 | |
| 6601 | 6611 | _LIBCPP_END_NAMESPACE_STD |
| 6612 | ||
| 6613 | _LIBCPP_POP_MACROS |
lib/libcxx/src/memory.cpp+28-24| ... | ... | @@ -6,14 +6,21 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "memory" | |
| 9 | #include <__config> | |
| 10 | #ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | |
| 11 | # define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS | |
| 12 | #endif | |
| 13 | ||
| 14 | #include <memory> | |
| 15 | ||
| 10 | 16 | #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 | |
| 17 | # include <mutex> | |
| 18 | # include <thread> | |
| 19 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 20 | # pragma comment(lib, "pthread") | |
| 21 | # endif | |
| 16 | 22 | #endif |
| 23 | ||
| 17 | 24 | #include "include/atomic_support.h" |
| 18 | 25 | |
| 19 | 26 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -36,7 +43,7 @@ __shared_weak_count::~__shared_weak_count() |
| 36 | 43 | { |
| 37 | 44 | } |
| 38 | 45 | |
| 39 | #if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) | |
| 46 | #if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 40 | 47 | void |
| 41 | 48 | __shared_count::__add_shared() noexcept |
| 42 | 49 | { |
| ... | ... | @@ -72,8 +79,7 @@ __shared_weak_count::__release_shared() noexcept |
| 72 | 79 | if (__shared_count::__release_shared()) |
| 73 | 80 | __release_weak(); |
| 74 | 81 | } |
| 75 | ||
| 76 | #endif // _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | |
| 82 | #endif // _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS | |
| 77 | 83 | |
| 78 | 84 | void |
| 79 | 85 | __shared_weak_count::__release_weak() noexcept |
| ... | ... | @@ -132,9 +138,13 @@ __shared_weak_count::__get_deleter(const type_info&) const noexcept |
| 132 | 138 | |
| 133 | 139 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 134 | 140 | |
| 135 | _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16; | |
| 136 | _LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut_back[__sp_mut_count] = | |
| 141 | static constexpr std::size_t __sp_mut_count = 32; | |
| 142 | static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = | |
| 137 | 143 | { |
| 144 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, | |
| 145 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, | |
| 146 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, | |
| 147 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, | |
| 138 | 148 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, |
| 139 | 149 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, |
| 140 | 150 | _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, |
| ... | ... | @@ -150,16 +160,7 @@ void |
| 150 | 160 | __sp_mut::lock() noexcept |
| 151 | 161 | { |
| 152 | 162 | auto m = static_cast<__libcpp_mutex_t*>(__lx); |
| 153 | unsigned count = 0; | |
| 154 | while (!__libcpp_mutex_trylock(m)) | |
| 155 | { | |
| 156 | if (++count > 16) | |
| 157 | { | |
| 158 | __libcpp_mutex_lock(m); | |
| 159 | break; | |
| 160 | } | |
| 161 | this_thread::yield(); | |
| 162 | } | |
| 163 | __libcpp_mutex_lock(m); | |
| 163 | 164 | } |
| 164 | 165 | |
| 165 | 166 | void |
| ... | ... | @@ -171,12 +172,15 @@ __sp_mut::unlock() noexcept |
| 171 | 172 | __sp_mut& |
| 172 | 173 | __get_sp_mut(const void* p) |
| 173 | 174 | { |
| 174 | static __sp_mut muts[__sp_mut_count] | |
| 175 | { | |
| 175 | static constinit __sp_mut muts[__sp_mut_count] = { | |
| 176 | 176 | &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3], |
| 177 | 177 | &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7], |
| 178 | 178 | &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11], |
| 179 | &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15] | |
| 179 | &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15], | |
| 180 | &mut_back[16], &mut_back[17], &mut_back[18], &mut_back[19], | |
| 181 | &mut_back[20], &mut_back[21], &mut_back[22], &mut_back[23], | |
| 182 | &mut_back[24], &mut_back[25], &mut_back[26], &mut_back[27], | |
| 183 | &mut_back[28], &mut_back[29], &mut_back[30], &mut_back[31] | |
| 180 | 184 | }; |
| 181 | 185 | return muts[hash<const void*>()(p) & (__sp_mut_count-1)]; |
| 182 | 186 | } |
lib/libcxx/src/mutex.cpp+16-9| ... | ... | @@ -6,19 +6,24 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "mutex" | |
| 10 | #include "limits" | |
| 11 | #include "system_error" | |
| 9 | #include <__assert> | |
| 10 | #include <limits> | |
| 11 | #include <mutex> | |
| 12 | #include <system_error> | |
| 13 | ||
| 12 | 14 | #include "include/atomic_support.h" |
| 13 | #include "__undef_macros" | |
| 14 | 15 | |
| 15 | 16 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 16 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 17 | #pragma comment(lib, "pthread") | |
| 18 | #endif | |
| 17 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 18 | # pragma comment(lib, "pthread") | |
| 19 | # endif | |
| 19 | 20 | #endif |
| 20 | 21 | |
| 22 | _LIBCPP_PUSH_MACROS | |
| 23 | #include <__undef_macros> | |
| 24 | ||
| 21 | 25 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 26 | ||
| 22 | 27 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 23 | 28 | |
| 24 | 29 | const defer_lock_t defer_lock{}; |
| ... | ... | @@ -196,8 +201,8 @@ recursive_timed_mutex::unlock() noexcept |
| 196 | 201 | // keep in sync with: 7741191. |
| 197 | 202 | |
| 198 | 203 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 199 | _LIBCPP_SAFE_STATIC static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; | |
| 200 | _LIBCPP_SAFE_STATIC static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; | |
| 204 | static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER; | |
| 205 | static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER; | |
| 201 | 206 | #endif |
| 202 | 207 | |
| 203 | 208 | void __call_once(volatile once_flag::_State_type& flag, void* arg, |
| ... | ... | @@ -258,3 +263,5 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, |
| 258 | 263 | } |
| 259 | 264 | |
| 260 | 265 | _LIBCPP_END_NAMESPACE_STD |
| 266 | ||
| 267 | _LIBCPP_POP_MACROS |
lib/libcxx/src/mutex_destructor.cpp+5-5| ... | ... | @@ -16,13 +16,13 @@ |
| 16 | 16 | // we re-declare the entire class in this file instead of using |
| 17 | 17 | // _LIBCPP_BUILDING_LIBRARY to change the definition in the headers. |
| 18 | 18 | |
| 19 | #include "__config" | |
| 20 | #include "__threading_support" | |
| 19 | #include <__config> | |
| 20 | #include <__threading_support> | |
| 21 | 21 | |
| 22 | 22 | #if !defined(_LIBCPP_HAS_NO_THREADS) |
| 23 | #if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) | |
| 24 | #define NEEDS_MUTEX_DESTRUCTOR | |
| 25 | #endif | |
| 23 | # if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) | |
| 24 | # define NEEDS_MUTEX_DESTRUCTOR | |
| 25 | # endif | |
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | 28 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/src/new.cpp+1-1| ... | ... | @@ -6,9 +6,9 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include <new> | |
| 9 | 10 | #include <stdlib.h> |
| 10 | 11 | |
| 11 | #include "new" | |
| 12 | 12 | #include "include/atomic_support.h" |
| 13 | 13 | |
| 14 | 14 | #if defined(_LIBCPP_ABI_MICROSOFT) |
lib/libcxx/src/optional.cpp+2-2| ... | ... | @@ -6,8 +6,8 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "optional" | |
| 10 | #include "__availability" | |
| 9 | #include <__availability> | |
| 10 | #include <optional> | |
| 11 | 11 | |
| 12 | 12 | namespace std |
| 13 | 13 | { |
lib/libcxx/src/random.cpp+3-3| ... | ... | @@ -13,9 +13,9 @@ |
| 13 | 13 | # define _CRT_RAND_S |
| 14 | 14 | #endif // defined(_LIBCPP_USING_WIN32_RANDOM) |
| 15 | 15 | |
| 16 | #include "limits" | |
| 17 | #include "random" | |
| 18 | #include "system_error" | |
| 16 | #include <limits> | |
| 17 | #include <random> | |
| 18 | #include <system_error> | |
| 19 | 19 | |
| 20 | 20 | #if defined(__sun__) |
| 21 | 21 | # define rename solaris_headers_are_broken |
lib/libcxx/src/random_shuffle.cpp+8-7| ... | ... | @@ -6,19 +6,20 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "algorithm" | |
| 10 | #include "random" | |
| 9 | #include <algorithm> | |
| 10 | #include <random> | |
| 11 | ||
| 11 | 12 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 12 | # include "mutex" | |
| 13 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 14 | # pragma comment(lib, "pthread") | |
| 15 | # endif | |
| 13 | # include <mutex> | |
| 14 | # if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) | |
| 15 | # pragma comment(lib, "pthread") | |
| 16 | # endif | |
| 16 | 17 | #endif |
| 17 | 18 | |
| 18 | 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 19 | 20 | |
| 20 | 21 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 21 | _LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; | |
| 22 | static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER; | |
| 22 | 23 | #endif |
| 23 | 24 | unsigned __rs_default::__c_ = 0; |
| 24 | 25 |
lib/libcxx/src/regex.cpp+3-3| ... | ... | @@ -6,9 +6,9 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "regex" | |
| 10 | #include "algorithm" | |
| 11 | #include "iterator" | |
| 9 | #include <algorithm> | |
| 10 | #include <iterator> | |
| 11 | #include <regex> | |
| 12 | 12 | |
| 13 | 13 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 14 | 14 |
lib/libcxx/src/ryu/d2fixed.cpp+5-4| ... | ... | @@ -39,10 +39,11 @@ |
| 39 | 39 | // Avoid formatting to keep the changes with the original code minimal. |
| 40 | 40 | // clang-format off |
| 41 | 41 | |
| 42 | #include "__config" | |
| 43 | #include "charconv" | |
| 44 | #include "cstring" | |
| 45 | #include "system_error" | |
| 42 | #include <__assert> | |
| 43 | #include <__config> | |
| 44 | #include <charconv> | |
| 45 | #include <cstring> | |
| 46 | #include <system_error> | |
| 46 | 47 | |
| 47 | 48 | #include "include/ryu/common.h" |
| 48 | 49 | #include "include/ryu/d2fixed.h" |
lib/libcxx/src/ryu/d2s.cpp+3-2| ... | ... | @@ -39,8 +39,9 @@ |
| 39 | 39 | // Avoid formatting to keep the changes with the original code minimal. |
| 40 | 40 | // clang-format off |
| 41 | 41 | |
| 42 | #include "__config" | |
| 43 | #include "charconv" | |
| 42 | #include <__assert> | |
| 43 | #include <__config> | |
| 44 | #include <charconv> | |
| 44 | 45 | |
| 45 | 46 | #include "include/ryu/common.h" |
| 46 | 47 | #include "include/ryu/d2fixed.h" |
lib/libcxx/src/ryu/f2s.cpp+3-2| ... | ... | @@ -39,8 +39,9 @@ |
| 39 | 39 | // Avoid formatting to keep the changes with the original code minimal. |
| 40 | 40 | // clang-format off |
| 41 | 41 | |
| 42 | #include "__config" | |
| 43 | #include "charconv" | |
| 42 | #include <__assert> | |
| 43 | #include <__config> | |
| 44 | #include <charconv> | |
| 44 | 45 | |
| 45 | 46 | #include "include/ryu/common.h" |
| 46 | 47 | #include "include/ryu/d2fixed.h" |
lib/libcxx/src/shared_mutex.cpp+4-3| ... | ... | @@ -6,12 +6,13 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 9 | #include <__config> | |
| 10 | ||
| 10 | 11 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 11 | 12 | |
| 12 | #include "shared_mutex" | |
| 13 | #include <shared_mutex> | |
| 13 | 14 | #if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB) |
| 14 | #pragma comment(lib, "pthread") | |
| 15 | # pragma comment(lib, "pthread") | |
| 15 | 16 | #endif |
| 16 | 17 | |
| 17 | 18 | _LIBCPP_BEGIN_NAMESPACE_STD |
lib/libcxx/src/stdexcept.cpp+4-5| ... | ... | @@ -6,11 +6,10 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "stdexcept" | |
| 10 | #include "new" | |
| 11 | #include "string" | |
| 12 | #include "system_error" | |
| 13 | ||
| 9 | #include <new> | |
| 10 | #include <stdexcept> | |
| 11 | #include <string> | |
| 12 | #include <system_error> | |
| 14 | 13 | |
| 15 | 14 | #ifdef _LIBCPP_ABI_VCRUNTIME |
| 16 | 15 | #include "support/runtime/stdexcept_vcruntime.ipp" |
lib/libcxx/src/string.cpp+94-216| ... | ... | @@ -6,17 +6,17 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "string" | |
| 10 | #include "charconv" | |
| 11 | #include "cstdlib" | |
| 12 | #include "cerrno" | |
| 13 | #include "limits" | |
| 14 | #include "stdexcept" | |
| 9 | #include <__assert> | |
| 10 | #include <cerrno> | |
| 11 | #include <charconv> | |
| 12 | #include <cstdlib> | |
| 13 | #include <limits> | |
| 14 | #include <stdexcept> | |
| 15 | 15 | #include <stdio.h> |
| 16 | #include "__debug" | |
| 16 | #include <string> | |
| 17 | 17 | |
| 18 | 18 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 19 | # include "cwchar" | |
| 19 | # include <cwchar> | |
| 20 | 20 | #endif |
| 21 | 21 | |
| 22 | 22 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | ... | @@ -56,42 +56,33 @@ void __basic_string_common<true>::__throw_out_of_range() const { |
| 56 | 56 | #endif |
| 57 | 57 | #undef _LIBCPP_EXTERN_TEMPLATE_DEFINE |
| 58 | 58 | |
| 59 | template string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&); | |
| 59 | template string operator+<char, char_traits<char>, allocator<char>>(char const*, string const&); | |
| 60 | 60 | |
| 61 | 61 | namespace |
| 62 | 62 | { |
| 63 | 63 | |
| 64 | 64 | template<typename T> |
| 65 | inline | |
| 66 | void throw_helper( const string& msg ) | |
| 67 | { | |
| 65 | inline void throw_helper(const string& msg) { | |
| 68 | 66 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 69 | throw T( msg ); | |
| 67 | throw T(msg); | |
| 70 | 68 | #else |
| 71 | 69 | fprintf(stderr, "%s\n", msg.c_str()); |
| 72 | 70 | _VSTD::abort(); |
| 73 | 71 | #endif |
| 74 | 72 | } |
| 75 | 73 | |
| 76 | inline | |
| 77 | void throw_from_string_out_of_range( const string& func ) | |
| 78 | { | |
| 74 | inline void throw_from_string_out_of_range(const string& func) { | |
| 79 | 75 | throw_helper<out_of_range>(func + ": out of range"); |
| 80 | 76 | } |
| 81 | 77 | |
| 82 | inline | |
| 83 | void throw_from_string_invalid_arg( const string& func ) | |
| 84 | { | |
| 78 | inline void throw_from_string_invalid_arg(const string& func) { | |
| 85 | 79 | throw_helper<invalid_argument>(func + ": no conversion"); |
| 86 | 80 | } |
| 87 | 81 | |
| 88 | 82 | // as_integer |
| 89 | 83 | |
| 90 | 84 | template<typename V, typename S, typename F> |
| 91 | inline | |
| 92 | V | |
| 93 | as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) | |
| 94 | { | |
| 85 | inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) { | |
| 95 | 86 | typename S::value_type* ptr = nullptr; |
| 96 | 87 | const typename S::value_type* const p = str.c_str(); |
| 97 | 88 | typename remove_reference<decltype(errno)>::type errno_save = errno; |
| ... | ... | @@ -108,109 +99,77 @@ as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) |
| 108 | 99 | } |
| 109 | 100 | |
| 110 | 101 | template<typename V, typename S> |
| 111 | inline | |
| 112 | V | |
| 113 | as_integer(const string& func, const S& s, size_t* idx, int base); | |
| 102 | inline V as_integer(const string& func, const S& s, size_t* idx, int base); | |
| 114 | 103 | |
| 115 | 104 | // string |
| 116 | 105 | template<> |
| 117 | inline | |
| 118 | int | |
| 119 | as_integer(const string& func, const string& s, size_t* idx, int base ) | |
| 120 | { | |
| 106 | inline int as_integer(const string& func, const string& s, size_t* idx, int base) { | |
| 121 | 107 | // Use long as no Standard string to integer exists. |
| 122 | long r = as_integer_helper<long>( func, s, idx, base, strtol ); | |
| 108 | long r = as_integer_helper<long>(func, s, idx, base, strtol); | |
| 123 | 109 | if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r) |
| 124 | 110 | throw_from_string_out_of_range(func); |
| 125 | 111 | return static_cast<int>(r); |
| 126 | 112 | } |
| 127 | 113 | |
| 128 | 114 | template<> |
| 129 | inline | |
| 130 | long | |
| 131 | as_integer(const string& func, const string& s, size_t* idx, int base ) | |
| 132 | { | |
| 133 | return as_integer_helper<long>( func, s, idx, base, strtol ); | |
| 115 | inline long as_integer(const string& func, const string& s, size_t* idx, int base) { | |
| 116 | return as_integer_helper<long>(func, s, idx, base, strtol); | |
| 134 | 117 | } |
| 135 | 118 | |
| 136 | 119 | template<> |
| 137 | inline | |
| 138 | unsigned long | |
| 139 | as_integer( const string& func, const string& s, size_t* idx, int base ) | |
| 140 | { | |
| 141 | return as_integer_helper<unsigned long>( func, s, idx, base, strtoul ); | |
| 120 | inline unsigned long as_integer(const string& func, const string& s, size_t* idx, int base) { | |
| 121 | return as_integer_helper<unsigned long>(func, s, idx, base, strtoul); | |
| 142 | 122 | } |
| 143 | 123 | |
| 144 | 124 | template<> |
| 145 | inline | |
| 146 | long long | |
| 147 | as_integer( const string& func, const string& s, size_t* idx, int base ) | |
| 148 | { | |
| 149 | return as_integer_helper<long long>( func, s, idx, base, strtoll ); | |
| 125 | inline long long as_integer(const string& func, const string& s, size_t* idx, int base) { | |
| 126 | return as_integer_helper<long long>(func, s, idx, base, strtoll); | |
| 150 | 127 | } |
| 151 | 128 | |
| 152 | 129 | template<> |
| 153 | inline | |
| 154 | unsigned long long | |
| 155 | as_integer( const string& func, const string& s, size_t* idx, int base ) | |
| 156 | { | |
| 157 | return as_integer_helper<unsigned long long>( func, s, idx, base, strtoull ); | |
| 130 | inline unsigned long long as_integer(const string& func, const string& s, size_t* idx, int base) { | |
| 131 | return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull); | |
| 158 | 132 | } |
| 159 | 133 | |
| 160 | 134 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 161 | 135 | // wstring |
| 162 | 136 | template<> |
| 163 | inline | |
| 164 | int | |
| 165 | as_integer( const string& func, const wstring& s, size_t* idx, int base ) | |
| 166 | { | |
| 137 | inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) { | |
| 167 | 138 | // Use long as no Stantard string to integer exists. |
| 168 | long r = as_integer_helper<long>( func, s, idx, base, wcstol ); | |
| 139 | long r = as_integer_helper<long>(func, s, idx, base, wcstol); | |
| 169 | 140 | if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r) |
| 170 | 141 | throw_from_string_out_of_range(func); |
| 171 | 142 | return static_cast<int>(r); |
| 172 | 143 | } |
| 173 | 144 | |
| 174 | 145 | template<> |
| 175 | inline | |
| 176 | long | |
| 177 | as_integer( const string& func, const wstring& s, size_t* idx, int base ) | |
| 178 | { | |
| 179 | return as_integer_helper<long>( func, s, idx, base, wcstol ); | |
| 146 | inline long as_integer(const string& func, const wstring& s, size_t* idx, int base) { | |
| 147 | return as_integer_helper<long>(func, s, idx, base, wcstol); | |
| 180 | 148 | } |
| 181 | 149 | |
| 182 | 150 | template<> |
| 183 | 151 | inline |
| 184 | 152 | unsigned long |
| 185 | as_integer( const string& func, const wstring& s, size_t* idx, int base ) | |
| 153 | as_integer(const string& func, const wstring& s, size_t* idx, int base) | |
| 186 | 154 | { |
| 187 | return as_integer_helper<unsigned long>( func, s, idx, base, wcstoul ); | |
| 155 | return as_integer_helper<unsigned long>(func, s, idx, base, wcstoul); | |
| 188 | 156 | } |
| 189 | 157 | |
| 190 | 158 | template<> |
| 191 | inline | |
| 192 | long long | |
| 193 | as_integer( const string& func, const wstring& s, size_t* idx, int base ) | |
| 194 | { | |
| 195 | return as_integer_helper<long long>( func, s, idx, base, wcstoll ); | |
| 159 | inline long long as_integer(const string& func, const wstring& s, size_t* idx, int base) { | |
| 160 | return as_integer_helper<long long>(func, s, idx, base, wcstoll); | |
| 196 | 161 | } |
| 197 | 162 | |
| 198 | 163 | template<> |
| 199 | inline | |
| 200 | unsigned long long | |
| 201 | as_integer( const string& func, const wstring& s, size_t* idx, int base ) | |
| 202 | { | |
| 203 | return as_integer_helper<unsigned long long>( func, s, idx, base, wcstoull ); | |
| 164 | inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) { | |
| 165 | return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull); | |
| 204 | 166 | } |
| 205 | 167 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 206 | 168 | |
| 207 | 169 | // as_float |
| 208 | 170 | |
| 209 | 171 | template<typename V, typename S, typename F> |
| 210 | inline | |
| 211 | V | |
| 212 | as_float_helper(const string& func, const S& str, size_t* idx, F f ) | |
| 213 | { | |
| 172 | inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) { | |
| 214 | 173 | typename S::value_type* ptr = nullptr; |
| 215 | 174 | const typename S::value_type* const p = str.c_str(); |
| 216 | 175 | typename remove_reference<decltype(errno)>::type errno_save = errno; |
| ... | ... | @@ -227,172 +186,107 @@ as_float_helper(const string& func, const S& str, size_t* idx, F f ) |
| 227 | 186 | } |
| 228 | 187 | |
| 229 | 188 | template<typename V, typename S> |
| 230 | inline | |
| 231 | V as_float( const string& func, const S& s, size_t* idx = nullptr ); | |
| 189 | inline V as_float(const string& func, const S& s, size_t* idx = nullptr); | |
| 232 | 190 | |
| 233 | 191 | template<> |
| 234 | inline | |
| 235 | float | |
| 236 | as_float( const string& func, const string& s, size_t* idx ) | |
| 237 | { | |
| 238 | return as_float_helper<float>( func, s, idx, strtof ); | |
| 192 | inline float as_float(const string& func, const string& s, size_t* idx) { | |
| 193 | return as_float_helper<float>(func, s, idx, strtof); | |
| 239 | 194 | } |
| 240 | 195 | |
| 241 | 196 | template<> |
| 242 | inline | |
| 243 | double | |
| 244 | as_float(const string& func, const string& s, size_t* idx ) | |
| 245 | { | |
| 246 | return as_float_helper<double>( func, s, idx, strtod ); | |
| 197 | inline double as_float(const string& func, const string& s, size_t* idx) { | |
| 198 | return as_float_helper<double>(func, s, idx, strtod); | |
| 247 | 199 | } |
| 248 | 200 | |
| 249 | 201 | template<> |
| 250 | inline | |
| 251 | long double | |
| 252 | as_float( const string& func, const string& s, size_t* idx ) | |
| 253 | { | |
| 254 | return as_float_helper<long double>( func, s, idx, strtold ); | |
| 202 | inline long double as_float(const string& func, const string& s, size_t* idx) { | |
| 203 | return as_float_helper<long double>(func, s, idx, strtold); | |
| 255 | 204 | } |
| 256 | 205 | |
| 257 | 206 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 258 | 207 | template<> |
| 259 | inline | |
| 260 | float | |
| 261 | as_float( const string& func, const wstring& s, size_t* idx ) | |
| 262 | { | |
| 263 | return as_float_helper<float>( func, s, idx, wcstof ); | |
| 208 | inline float as_float(const string& func, const wstring& s, size_t* idx) { | |
| 209 | return as_float_helper<float>(func, s, idx, wcstof); | |
| 264 | 210 | } |
| 265 | 211 | |
| 266 | 212 | template<> |
| 267 | inline | |
| 268 | double | |
| 269 | as_float( const string& func, const wstring& s, size_t* idx ) | |
| 270 | { | |
| 271 | return as_float_helper<double>( func, s, idx, wcstod ); | |
| 213 | inline double as_float(const string& func, const wstring& s, size_t* idx) { | |
| 214 | return as_float_helper<double>(func, s, idx, wcstod); | |
| 272 | 215 | } |
| 273 | 216 | |
| 274 | 217 | template<> |
| 275 | inline | |
| 276 | long double | |
| 277 | as_float( const string& func, const wstring& s, size_t* idx ) | |
| 278 | { | |
| 279 | return as_float_helper<long double>( func, s, idx, wcstold ); | |
| 218 | inline long double as_float(const string& func, const wstring& s, size_t* idx) { | |
| 219 | return as_float_helper<long double>(func, s, idx, wcstold); | |
| 280 | 220 | } |
| 281 | 221 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 282 | 222 | |
| 283 | 223 | } // unnamed namespace |
| 284 | 224 | |
| 285 | int | |
| 286 | stoi(const string& str, size_t* idx, int base) | |
| 287 | { | |
| 288 | return as_integer<int>( "stoi", str, idx, base ); | |
| 225 | int stoi(const string& str, size_t* idx, int base) { | |
| 226 | return as_integer<int>("stoi", str, idx, base); | |
| 289 | 227 | } |
| 290 | 228 | |
| 291 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 292 | int | |
| 293 | stoi(const wstring& str, size_t* idx, int base) | |
| 294 | { | |
| 295 | return as_integer<int>( "stoi", str, idx, base ); | |
| 229 | long stol(const string& str, size_t* idx, int base) { | |
| 230 | return as_integer<long>("stol", str, idx, base); | |
| 296 | 231 | } |
| 297 | #endif | |
| 298 | 232 | |
| 299 | long | |
| 300 | stol(const string& str, size_t* idx, int base) | |
| 301 | { | |
| 302 | return as_integer<long>( "stol", str, idx, base ); | |
| 233 | unsigned long stoul(const string& str, size_t* idx, int base) { | |
| 234 | return as_integer<unsigned long>("stoul", str, idx, base); | |
| 303 | 235 | } |
| 304 | 236 | |
| 305 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 306 | long | |
| 307 | stol(const wstring& str, size_t* idx, int base) | |
| 308 | { | |
| 309 | return as_integer<long>( "stol", str, idx, base ); | |
| 237 | long long stoll(const string& str, size_t* idx, int base) { | |
| 238 | return as_integer<long long>("stoll", str, idx, base); | |
| 310 | 239 | } |
| 311 | #endif | |
| 312 | 240 | |
| 313 | unsigned long | |
| 314 | stoul(const string& str, size_t* idx, int base) | |
| 315 | { | |
| 316 | return as_integer<unsigned long>( "stoul", str, idx, base ); | |
| 241 | unsigned long long stoull(const string& str, size_t* idx, int base) { | |
| 242 | return as_integer<unsigned long long>("stoull", str, idx, base); | |
| 317 | 243 | } |
| 318 | 244 | |
| 319 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 320 | unsigned long | |
| 321 | stoul(const wstring& str, size_t* idx, int base) | |
| 322 | { | |
| 323 | return as_integer<unsigned long>( "stoul", str, idx, base ); | |
| 245 | float stof(const string& str, size_t* idx) { | |
| 246 | return as_float<float>("stof", str, idx); | |
| 324 | 247 | } |
| 325 | #endif | |
| 326 | 248 | |
| 327 | long long | |
| 328 | stoll(const string& str, size_t* idx, int base) | |
| 329 | { | |
| 330 | return as_integer<long long>( "stoll", str, idx, base ); | |
| 249 | double stod(const string& str, size_t* idx) { | |
| 250 | return as_float<double>("stod", str, idx); | |
| 331 | 251 | } |
| 332 | 252 | |
| 333 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 334 | long long | |
| 335 | stoll(const wstring& str, size_t* idx, int base) | |
| 336 | { | |
| 337 | return as_integer<long long>( "stoll", str, idx, base ); | |
| 253 | long double stold(const string& str, size_t* idx) { | |
| 254 | return as_float<long double>("stold", str, idx); | |
| 338 | 255 | } |
| 339 | #endif | |
| 340 | 256 | |
| 341 | unsigned long long | |
| 342 | stoull(const string& str, size_t* idx, int base) | |
| 343 | { | |
| 344 | return as_integer<unsigned long long>( "stoull", str, idx, base ); | |
| 257 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 258 | int stoi(const wstring& str, size_t* idx, int base) { | |
| 259 | return as_integer<int>("stoi", str, idx, base); | |
| 345 | 260 | } |
| 346 | 261 | |
| 347 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 348 | unsigned long long | |
| 349 | stoull(const wstring& str, size_t* idx, int base) | |
| 350 | { | |
| 351 | return as_integer<unsigned long long>( "stoull", str, idx, base ); | |
| 262 | long stol(const wstring& str, size_t* idx, int base) { | |
| 263 | return as_integer<long>("stol", str, idx, base); | |
| 352 | 264 | } |
| 353 | #endif | |
| 354 | 265 | |
| 355 | float | |
| 356 | stof(const string& str, size_t* idx) | |
| 357 | { | |
| 358 | return as_float<float>( "stof", str, idx ); | |
| 266 | unsigned long stoul(const wstring& str, size_t* idx, int base) { | |
| 267 | return as_integer<unsigned long>("stoul", str, idx, base); | |
| 359 | 268 | } |
| 360 | 269 | |
| 361 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 362 | float | |
| 363 | stof(const wstring& str, size_t* idx) | |
| 364 | { | |
| 365 | return as_float<float>( "stof", str, idx ); | |
| 270 | long long stoll(const wstring& str, size_t* idx, int base) { | |
| 271 | return as_integer<long long>("stoll", str, idx, base); | |
| 366 | 272 | } |
| 367 | #endif | |
| 368 | 273 | |
| 369 | double | |
| 370 | stod(const string& str, size_t* idx) | |
| 371 | { | |
| 372 | return as_float<double>( "stod", str, idx ); | |
| 274 | unsigned long long stoull(const wstring& str, size_t* idx, int base) { | |
| 275 | return as_integer<unsigned long long>("stoull", str, idx, base); | |
| 373 | 276 | } |
| 374 | 277 | |
| 375 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 376 | double | |
| 377 | stod(const wstring& str, size_t* idx) | |
| 378 | { | |
| 379 | return as_float<double>( "stod", str, idx ); | |
| 278 | float stof(const wstring& str, size_t* idx) { | |
| 279 | return as_float<float>("stof", str, idx); | |
| 380 | 280 | } |
| 381 | #endif | |
| 382 | 281 | |
| 383 | long double | |
| 384 | stold(const string& str, size_t* idx) | |
| 385 | { | |
| 386 | return as_float<long double>( "stold", str, idx ); | |
| 282 | double stod(const wstring& str, size_t* idx) { | |
| 283 | return as_float<double>("stod", str, idx); | |
| 387 | 284 | } |
| 388 | 285 | |
| 389 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 390 | long double | |
| 391 | stold(const wstring& str, size_t* idx) | |
| 392 | { | |
| 393 | return as_float<long double>( "stold", str, idx ); | |
| 286 | long double stold(const wstring& str, size_t* idx) { | |
| 287 | return as_float<long double>("stold", str, idx); | |
| 394 | 288 | } |
| 395 | #endif | |
| 289 | #endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS | |
| 396 | 290 | |
| 397 | 291 | // to_string |
| 398 | 292 | |
| ... | ... | @@ -402,21 +296,15 @@ namespace |
| 402 | 296 | // as_string |
| 403 | 297 | |
| 404 | 298 | template<typename S, typename P, typename V > |
| 405 | inline | |
| 406 | S | |
| 407 | as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a) | |
| 408 | { | |
| 299 | inline S as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a) { | |
| 409 | 300 | typedef typename S::size_type size_type; |
| 410 | 301 | size_type available = s.size(); |
| 411 | while (true) | |
| 412 | { | |
| 302 | while (true) { | |
| 413 | 303 | int status = sprintf_like(&s[0], available + 1, fmt, a); |
| 414 | if ( status >= 0 ) | |
| 415 | { | |
| 304 | if (status >= 0) { | |
| 416 | 305 | size_type used = static_cast<size_type>(status); |
| 417 | if ( used <= available ) | |
| 418 | { | |
| 419 | s.resize( used ); | |
| 306 | if (used <= available) { | |
| 307 | s.resize(used); | |
| 420 | 308 | break; |
| 421 | 309 | } |
| 422 | 310 | available = used; // Assume this is advice of how much space we need. |
| ... | ... | @@ -432,11 +320,8 @@ template <class S> |
| 432 | 320 | struct initial_string; |
| 433 | 321 | |
| 434 | 322 | template <> |
| 435 | struct initial_string<string> | |
| 436 | { | |
| 437 | string | |
| 438 | operator()() const | |
| 439 | { | |
| 323 | struct initial_string<string> { | |
| 324 | string operator()() const { | |
| 440 | 325 | string s; |
| 441 | 326 | s.resize(s.capacity()); |
| 442 | 327 | return s; |
| ... | ... | @@ -445,11 +330,8 @@ struct initial_string<string> |
| 445 | 330 | |
| 446 | 331 | #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 447 | 332 | template <> |
| 448 | struct initial_string<wstring> | |
| 449 | { | |
| 450 | wstring | |
| 451 | operator()() const | |
| 452 | { | |
| 333 | struct initial_string<wstring> { | |
| 334 | wstring operator()() const { | |
| 453 | 335 | wstring s(20, wchar_t()); |
| 454 | 336 | s.resize(s.capacity()); |
| 455 | 337 | return s; |
| ... | ... | @@ -458,10 +340,7 @@ struct initial_string<wstring> |
| 458 | 340 | |
| 459 | 341 | typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...); |
| 460 | 342 | |
| 461 | inline | |
| 462 | wide_printf | |
| 463 | get_swprintf() | |
| 464 | { | |
| 343 | inline wide_printf get_swprintf() { | |
| 465 | 344 | #ifndef _LIBCPP_MSVCRT |
| 466 | 345 | return swprintf; |
| 467 | 346 | #else |
| ... | ... | @@ -471,8 +350,7 @@ get_swprintf() |
| 471 | 350 | #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS |
| 472 | 351 | |
| 473 | 352 | template <typename S, typename V> |
| 474 | S i_to_string(V v) | |
| 475 | { | |
| 353 | S i_to_string(V v) { | |
| 476 | 354 | // numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers. |
| 477 | 355 | // For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented), |
| 478 | 356 | // so we need +1 here. |
lib/libcxx/src/strstream.cpp+13-8| ... | ... | @@ -6,13 +6,16 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "strstream" | |
| 10 | #include "algorithm" | |
| 11 | #include "climits" | |
| 12 | #include "cstring" | |
| 13 | #include "cstdlib" | |
| 14 | #include "__debug" | |
| 15 | #include "__undef_macros" | |
| 9 | #include <__assert> | |
| 10 | #include <__utility/unreachable.h> | |
| 11 | #include <algorithm> | |
| 12 | #include <climits> | |
| 13 | #include <cstdlib> | |
| 14 | #include <cstring> | |
| 15 | #include <strstream> | |
| 16 | ||
| 17 | _LIBCPP_PUSH_MACROS | |
| 18 | #include <__undef_macros> | |
| 16 | 19 | |
| 17 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 18 | 21 | |
| ... | ... | @@ -268,7 +271,7 @@ strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmod |
| 268 | 271 | newoff = seekhigh - eback(); |
| 269 | 272 | break; |
| 270 | 273 | default: |
| 271 | _LIBCPP_UNREACHABLE(); | |
| 274 | __libcpp_unreachable(); | |
| 272 | 275 | } |
| 273 | 276 | newoff += __off; |
| 274 | 277 | if (0 <= newoff && newoff <= seekhigh - eback()) |
| ... | ... | @@ -333,3 +336,5 @@ strstream::~strstream() |
| 333 | 336 | } |
| 334 | 337 | |
| 335 | 338 | _LIBCPP_END_NAMESPACE_STD |
| 339 | ||
| 340 | _LIBCPP_POP_MACROS |
lib/libcxx/src/support/ibm/xlocale_zos.cpp+9-8| ... | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include <__assert> | |
| 9 | 10 | #include <__support/ibm/xlocale.h> |
| 10 | 11 | #include <sstream> |
| 11 | 12 | #include <vector> |
| ... | ... | @@ -31,7 +32,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) { |
| 31 | 32 | } |
| 32 | 33 | } |
| 33 | 34 | } |
| 34 | ||
| 35 | ||
| 35 | 36 | // Create new locale. |
| 36 | 37 | locale_t newloc = new locale_struct(); |
| 37 | 38 | |
| ... | ... | @@ -74,18 +75,18 @@ locale_t uselocale(locale_t newloc) { |
| 74 | 75 | |
| 75 | 76 | if (newloc) { |
| 76 | 77 | // Set locales and check for errors. |
| 77 | bool is_error = | |
| 78 | (newloc->category_mask & LC_COLLATE_MASK && | |
| 78 | bool is_error = | |
| 79 | (newloc->category_mask & LC_COLLATE_MASK && | |
| 79 | 80 | setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) || |
| 80 | (newloc->category_mask & LC_CTYPE_MASK && | |
| 81 | (newloc->category_mask & LC_CTYPE_MASK && | |
| 81 | 82 | setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) || |
| 82 | (newloc->category_mask & LC_MONETARY_MASK && | |
| 83 | (newloc->category_mask & LC_MONETARY_MASK && | |
| 83 | 84 | setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) || |
| 84 | (newloc->category_mask & LC_NUMERIC_MASK && | |
| 85 | (newloc->category_mask & LC_NUMERIC_MASK && | |
| 85 | 86 | setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) || |
| 86 | (newloc->category_mask & LC_TIME_MASK && | |
| 87 | (newloc->category_mask & LC_TIME_MASK && | |
| 87 | 88 | setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) || |
| 88 | (newloc->category_mask & LC_MESSAGES_MASK && | |
| 89 | (newloc->category_mask & LC_MESSAGES_MASK && | |
| 89 | 90 | setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL); |
| 90 | 91 | |
| 91 | 92 | if (is_error) { |
lib/libcxx/src/support/runtime/exception_fallback.ipp+2-4| ... | ... | @@ -11,9 +11,8 @@ |
| 11 | 11 | |
| 12 | 12 | namespace std { |
| 13 | 13 | |
| 14 | _LIBCPP_SAFE_STATIC static std::terminate_handler __terminate_handler; | |
| 15 | _LIBCPP_SAFE_STATIC static std::unexpected_handler __unexpected_handler; | |
| 16 | ||
| 14 | static constinit std::terminate_handler __terminate_handler = nullptr; | |
| 15 | static constinit std::unexpected_handler __unexpected_handler = nullptr; | |
| 17 | 16 | |
| 18 | 17 | // libcxxrt provides implementations of these functions itself. |
| 19 | 18 | unexpected_handler |
| ... | ... | @@ -26,7 +25,6 @@ unexpected_handler |
| 26 | 25 | get_unexpected() noexcept |
| 27 | 26 | { |
| 28 | 27 | return __libcpp_atomic_load(&__unexpected_handler); |
| 29 | ||
| 30 | 28 | } |
| 31 | 29 | |
| 32 | 30 | _LIBCPP_NORETURN |
lib/libcxx/src/support/runtime/new_handler_fallback.ipp+1-1| ... | ... | @@ -9,7 +9,7 @@ |
| 9 | 9 | |
| 10 | 10 | namespace std { |
| 11 | 11 | |
| 12 | _LIBCPP_SAFE_STATIC static std::new_handler __new_handler; | |
| 12 | static constinit std::new_handler __new_handler = nullptr; | |
| 13 | 13 | |
| 14 | 14 | new_handler |
| 15 | 15 | set_new_handler(new_handler handler) noexcept |
lib/libcxx/src/support/win32/locale_win32.cpp+3-3| ... | ... | @@ -97,10 +97,10 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...) |
| 97 | 97 | ret, n, format, loc, ap); |
| 98 | 98 | #else |
| 99 | 99 | __libcpp_locale_guard __current(loc); |
| 100 | #pragma clang diagnostic push | |
| 101 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 100 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 101 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 102 | 102 | int result = vsnprintf( ret, n, format, ap ); |
| 103 | #pragma clang diagnostic pop | |
| 103 | _LIBCPP_DIAGNOSTIC_POP | |
| 104 | 104 | #endif |
| 105 | 105 | va_end(ap); |
| 106 | 106 | return result; |
lib/libcxx/src/support/win32/support.cpp+6-6| ... | ... | @@ -23,10 +23,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap ) |
| 23 | 23 | // Query the count required. |
| 24 | 24 | va_list ap_copy; |
| 25 | 25 | va_copy(ap_copy, ap); |
| 26 | #pragma clang diagnostic push | |
| 27 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 26 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 27 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 28 | 28 | int count = vsnprintf( NULL, 0, format, ap_copy ); |
| 29 | #pragma clang diagnostic pop | |
| 29 | _LIBCPP_DIAGNOSTIC_POP | |
| 30 | 30 | va_end(ap_copy); |
| 31 | 31 | if (count < 0) |
| 32 | 32 | return count; |
| ... | ... | @@ -36,10 +36,10 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap ) |
| 36 | 36 | return -1; |
| 37 | 37 | // If we haven't used exactly what was required, something is wrong. |
| 38 | 38 | // Maybe bug in vsnprintf. Report the error and return. |
| 39 | #pragma clang diagnostic push | |
| 40 | #pragma clang diagnostic ignored "-Wformat-nonliteral" | |
| 39 | _LIBCPP_DIAGNOSTIC_PUSH | |
| 40 | _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") | |
| 41 | 41 | if (vsnprintf(p, buffer_size, format, ap) != count) { |
| 42 | #pragma clang diagnostic pop | |
| 42 | _LIBCPP_DIAGNOSTIC_POP | |
| 43 | 43 | free(p); |
| 44 | 44 | return -1; |
| 45 | 45 | } |
lib/libcxx/src/system_error.cpp+13-10| ... | ... | @@ -6,18 +6,21 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 9 | #include <__config> | |
| 10 | #ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS | |
| 11 | # define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS | |
| 12 | #endif | |
| 10 | 13 | |
| 11 | #include "system_error" | |
| 14 | #include <__assert> | |
| 15 | #include <cerrno> | |
| 16 | #include <cstdio> | |
| 17 | #include <cstdlib> | |
| 18 | #include <cstring> | |
| 19 | #include <string> | |
| 20 | #include <string.h> | |
| 21 | #include <system_error> | |
| 12 | 22 | |
| 13 | 23 | #include "include/config_elast.h" |
| 14 | #include "cerrno" | |
| 15 | #include "cstring" | |
| 16 | #include "cstdio" | |
| 17 | #include "cstdlib" | |
| 18 | #include "string" | |
| 19 | #include "string.h" | |
| 20 | #include "__debug" | |
| 21 | 24 | |
| 22 | 25 | #if defined(__ANDROID__) |
| 23 | 26 | #include <android/api-level.h> |
| ... | ... | @@ -27,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 27 | 30 | |
| 28 | 31 | // class error_category |
| 29 | 32 | |
| 30 | #if defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS) | |
| 33 | #if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS) | |
| 31 | 34 | error_category::error_category() noexcept |
| 32 | 35 | { |
| 33 | 36 | } |
lib/libcxx/src/thread.cpp+14-8| ... | ... | @@ -6,14 +6,15 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "__config" | |
| 9 | #include <__config> | |
| 10 | ||
| 10 | 11 | #ifndef _LIBCPP_HAS_NO_THREADS |
| 11 | 12 | |
| 12 | #include "thread" | |
| 13 | #include "exception" | |
| 14 | #include "vector" | |
| 15 | #include "future" | |
| 16 | #include "limits" | |
| 13 | #include <exception> | |
| 14 | #include <future> | |
| 15 | #include <limits> | |
| 16 | #include <thread> | |
| 17 | #include <vector> | |
| 17 | 18 | |
| 18 | 19 | #if __has_include(<unistd.h>) |
| 19 | 20 | # include <unistd.h> // for sysconf |
| ... | ... | @@ -114,8 +115,13 @@ sleep_for(const chrono::nanoseconds& ns) |
| 114 | 115 | __thread_specific_ptr<__thread_struct>& |
| 115 | 116 | __thread_local_data() |
| 116 | 117 | { |
| 117 | static __thread_specific_ptr<__thread_struct> __p; | |
| 118 | return __p; | |
| 118 | // Even though __thread_specific_ptr's destructor doesn't actually destroy | |
| 119 | // anything (see comments there), we can't call it at all because threads may | |
| 120 | // outlive the static variable and calling its destructor means accessing an | |
| 121 | // object outside of its lifetime, which is UB. | |
| 122 | alignas(__thread_specific_ptr<__thread_struct>) static char __b[sizeof(__thread_specific_ptr<__thread_struct>)]; | |
| 123 | static __thread_specific_ptr<__thread_struct>* __p = new (__b) __thread_specific_ptr<__thread_struct>(); | |
| 124 | return *__p; | |
| 119 | 125 | } |
| 120 | 126 | |
| 121 | 127 | // __thread_struct_imp |
lib/libcxx/src/typeinfo.cpp+2-1| ... | ... | @@ -6,9 +6,10 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "typeinfo" | |
| 9 | #include <typeinfo> | |
| 10 | 10 | |
| 11 | 11 | #if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_VCRUNTIME) |
| 12 | ||
| 12 | 13 | #include <string.h> |
| 13 | 14 | |
| 14 | 15 | int std::type_info::__compare(const type_info &__rhs) const noexcept { |
lib/libcxx/src/utility.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "utility" | |
| 9 | #include <utility> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 |
lib/libcxx/src/valarray.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "valarray" | |
| 9 | #include <valarray> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 |
lib/libcxx/src/variant.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "variant" | |
| 9 | #include <variant> | |
| 10 | 10 | |
| 11 | 11 | namespace std { |
| 12 | 12 |
lib/libcxx/src/vector.cpp+1-1| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | // |
| 7 | 7 | //===----------------------------------------------------------------------===// |
| 8 | 8 | |
| 9 | #include "vector" | |
| 9 | #include <vector> | |
| 10 | 10 | |
| 11 | 11 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 12 | 12 |
lib/libcxx/src/verbose_abort.cpp created+77| ... | ... | @@ -0,0 +1,77 @@ |
| 1 | //===----------------------------------------------------------------------===// | |
| 2 | // | |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| 4 | // See https://llvm.org/LICENSE.txt for license information. | |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| 6 | // | |
| 7 | //===----------------------------------------------------------------------===// | |
| 8 | ||
| 9 | #include <__config> | |
| 10 | #include <__verbose_abort> | |
| 11 | #include <cstdarg> | |
| 12 | #include <cstdio> | |
| 13 | #include <cstdlib> | |
| 14 | ||
| 15 | #ifdef __BIONIC__ | |
| 16 | # include <android/api-level.h> | |
| 17 | # if __ANDROID_API__ >= 21 | |
| 18 | # include <syslog.h> | |
| 19 | extern "C" void android_set_abort_message(const char* msg); | |
| 20 | # else | |
| 21 | # include <assert.h> | |
| 22 | # endif // __ANDROID_API__ >= 21 | |
| 23 | #endif // __BIONIC__ | |
| 24 | ||
| 25 | #if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) | |
| 26 | # include <CrashReporterClient.h> | |
| 27 | #endif | |
| 28 | ||
| 29 | _LIBCPP_BEGIN_NAMESPACE_STD | |
| 30 | ||
| 31 | _LIBCPP_WEAK | |
| 32 | void __libcpp_verbose_abort(char const* format, ...) { | |
| 33 | // Write message to stderr. We do this before formatting into a | |
| 34 | // buffer so that we still get some information out if that fails. | |
| 35 | { | |
| 36 | va_list list; | |
| 37 | va_start(list, format); | |
| 38 | std::vfprintf(stderr, format, list); | |
| 39 | va_end(list); | |
| 40 | } | |
| 41 | ||
| 42 | // Format the arguments into an allocated buffer for CrashReport & friends. | |
| 43 | // We leak the buffer on purpose, since we're about to abort() anyway. | |
| 44 | char* buffer; (void)buffer; | |
| 45 | va_list list; | |
| 46 | va_start(list, format); | |
| 47 | ||
| 48 | #if defined(__APPLE__) && __has_include(<CrashReporterClient.h>) | |
| 49 | // Note that we should technically synchronize accesses here (by e.g. taking a lock), | |
| 50 | // however concretely we're only setting a pointer, so the likelihood of a race here | |
| 51 | // is low. | |
| 52 | vasprintf(&buffer, format, list); | |
| 53 | CRSetCrashLogMessage(buffer); | |
| 54 | #elif defined(__BIONIC__) | |
| 55 | vasprintf(&buffer, format, list); | |
| 56 | ||
| 57 | # if __ANDROID_API__ >= 21 | |
| 58 | // Show error in tombstone. | |
| 59 | android_set_abort_message(buffer); | |
| 60 | ||
| 61 | // Show error in logcat. | |
| 62 | openlog("libc++", 0, 0); | |
| 63 | syslog(LOG_CRIT, "%s", buffer); | |
| 64 | closelog(); | |
| 65 | # else | |
| 66 | // The good error reporting wasn't available in Android until L. Since we're | |
| 67 | // about to abort anyway, just call __assert2, which will log _somewhere_ | |
| 68 | // (tombstone and/or logcat) in older releases. | |
| 69 | __assert2(__FILE__, __LINE__, __func__, buffer); | |
| 70 | # endif // __ANDROID_API__ >= 21 | |
| 71 | #endif | |
| 72 | va_end(list); | |
| 73 | ||
| 74 | std::abort(); | |
| 75 | } | |
| 76 | ||
| 77 | _LIBCPP_END_NAMESPACE_STD |
src/libcxx.zig+2| ... | ... | @@ -54,6 +54,7 @@ const libcxx_files = [_][]const u8{ |
| 54 | 54 | "src/ios.cpp", |
| 55 | 55 | "src/ios.instantiations.cpp", |
| 56 | 56 | "src/iostream.cpp", |
| 57 | "src/legacy_debug_handler.cpp", | |
| 57 | 58 | "src/legacy_pointer_safety.cpp", |
| 58 | 59 | "src/locale.cpp", |
| 59 | 60 | "src/memory.cpp", |
| ... | ... | @@ -85,6 +86,7 @@ const libcxx_files = [_][]const u8{ |
| 85 | 86 | "src/valarray.cpp", |
| 86 | 87 | "src/variant.cpp", |
| 87 | 88 | "src/vector.cpp", |
| 89 | "src/verbose_abort.cpp", | |
| 88 | 90 | }; |
| 89 | 91 | |
| 90 | 92 | pub fn buildLibCXX(comp: *Compilation) !void { |