diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2024-03-27 10:35:27 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2024-03-27 10:47:39 +0300 |
commit | 9b902baa4a858f2176c82aa0b20f88232f0da0d8 (patch) | |
tree | 7165a551c2244c4b3c28479ac3a3f6d62346ec89 /contrib/libs | |
parent | a1c989e67e438005fa0c34ed0e910536c8941862 (diff) | |
download | ydb-9b902baa4a858f2176c82aa0b20f88232f0da0d8.tar.gz |
Update libcxx to 10 Oct 2023 dc129d6f715cf83a2072fc8de8b4e4c70bca6935
97ce40d276e44357a49b7a945af841896126dca8
Diffstat (limited to 'contrib/libs')
212 files changed, 8931 insertions, 6150 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/clamp.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/clamp.h index 31deb4fd94..fc08827919 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/clamp.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/clamp.h @@ -20,24 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 -template<class _Tp, class _Compare> -_LIBCPP_NODISCARD_EXT inline -_LIBCPP_INLINE_VISIBILITY constexpr -const _Tp& -clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) -{ - _LIBCPP_ASSERT_UNCATEGORIZED(!__comp(__hi, __lo), "Bad bounds passed to std::clamp"); - return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v; - +template <class _Tp, class _Compare> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& +clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, + _LIBCPP_LIFETIMEBOUND const _Tp& __lo, + _LIBCPP_LIFETIMEBOUND const _Tp& __hi, + _Compare __comp) { + _LIBCPP_ASSERT_UNCATEGORIZED(!__comp(__hi, __lo), "Bad bounds passed to std::clamp"); + return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v; } -template<class _Tp> -_LIBCPP_NODISCARD_EXT inline -_LIBCPP_INLINE_VISIBILITY constexpr -const _Tp& -clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) -{ - return _VSTD::clamp(__v, __lo, __hi, __less<>()); +template <class _Tp> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& +clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v, + _LIBCPP_LIFETIMEBOUND const _Tp& __lo, + _LIBCPP_LIFETIMEBOUND const _Tp& __hi) { + return _VSTD::clamp(__v, __lo, __hi, __less<>()); } #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h index f3701662aa..c138d59e97 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h @@ -21,14 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template<class _InputIterator, class _Size, class _OutputIterator> +template<class _InputIterator, class _Size, class _OutputIterator, + __enable_if_t<__has_input_iterator_category<_InputIterator>::value && + !__has_random_access_iterator_category<_InputIterator>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - __has_input_iterator_category<_InputIterator>::value && - !__has_random_access_iterator_category<_InputIterator>::value, - _OutputIterator ->::type +_OutputIterator copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; @@ -47,13 +44,10 @@ copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) return __result; } -template<class _InputIterator, class _Size, class _OutputIterator> +template<class _InputIterator, class _Size, class _OutputIterator, + __enable_if_t<__has_random_access_iterator_category<_InputIterator>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - __has_random_access_iterator_category<_InputIterator>::value, - _OutputIterator ->::type +_OutputIterator copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) { typedef typename iterator_traits<_InputIterator>::difference_type difference_type; diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h index e0de503287..d7c268bc6b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find.h @@ -10,10 +10,14 @@ #ifndef _LIBCPP___ALGORITHM_FIND_H #define _LIBCPP___ALGORITHM_FIND_H +#include <__algorithm/min.h> #include <__algorithm/unwrap_iter.h> +#include <__bit/countr.h> +#include <__bit/invert_if.h> #include <__config> #include <__functional/identity.h> #include <__functional/invoke.h> +#include <__fwd/bit_reference.h> #include <__string/constexpr_c_functions.h> #include <__type_traits/is_same.h> @@ -25,8 +29,12 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD +// generic implementation template <class _Iter, class _Sent, class _Tp, class _Proj> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __find_impl(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { @@ -36,6 +44,7 @@ __find_impl(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { return __first; } +// trivially equality comparable implementations template <class _Tp, class _Up, class _Proj, @@ -64,6 +73,51 @@ __find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) { } #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +// __bit_iterator implementation +template <bool _ToFind, class _Cp, bool _IsConst> +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst> +__find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { + using _It = __bit_iterator<_Cp, _IsConst>; + using __storage_type = typename _It::__storage_type; + + const int __bits_per_word = _It::__bits_per_word; + // do first partial word + if (__first.__ctz_ != 0) { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = std::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m; + if (__b) + return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b))); + if (__n == __dn) + return __first + __n; + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) { + __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_); + if (__b) + return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b))); + } + // do last partial word + if (__n > 0) { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m; + if (__b) + return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b))); + } + return _It(__first.__seg_, static_cast<unsigned>(__n)); +} + +template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst> +__find_impl(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { + if (static_cast<bool>(__value)) + return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); + return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); +} + template <class _InputIterator, class _Tp> _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { @@ -74,4 +128,6 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_FIND_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/half_positive.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/half_positive.h index 5a0f4baf6a..e90666d134 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/half_positive.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/half_positive.h @@ -22,25 +22,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD // Perform division by two quickly for positive integers (llvm.org/PR39129) -template <typename _Integral> +template <typename _Integral, __enable_if_t<is_integral<_Integral>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - is_integral<_Integral>::value, - _Integral ->::type +_Integral __half_positive(_Integral __value) { return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2); } -template <typename _Tp> +template <typename _Tp, __enable_if_t<!is_integral<_Tp>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - !is_integral<_Tp>::value, - _Tp ->::type +_Tp __half_positive(_Tp __value) { return __value / 2; diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h index 002978014c..e6176da4f5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/iterator_operations.h @@ -110,27 +110,23 @@ struct _IterOps<_ClassicAlgPolicy> { } // iter_move - template <class _Iter> + template <class _Iter, __enable_if_t<is_reference<__deref_t<_Iter> >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static // If the result of dereferencing `_Iter` is a reference type, deduce the result of calling `std::move` on it. Note // that the C++03 mode doesn't support `decltype(auto)` as the return type. - __enable_if_t< - is_reference<__deref_t<_Iter> >::value, - __move_t<_Iter> > + __move_t<_Iter> __iter_move(_Iter&& __i) { __validate_iter_reference<_Iter>(); return std::move(*std::forward<_Iter>(__i)); } - template <class _Iter> + template <class _Iter, __enable_if_t<!is_reference<__deref_t<_Iter> >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static // If the result of dereferencing `_Iter` is a value type, deduce the return value of this function to also be a // value -- otherwise, after `operator*` returns a temporary, this function would return a dangling reference to that // temporary. Note that the C++03 mode doesn't support `auto` as the return type. - __enable_if_t< - !is_reference<__deref_t<_Iter> >::value, - __deref_t<_Iter> > + __deref_t<_Iter> __iter_move(_Iter&& __i) { __validate_iter_reference<_Iter>(); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_any_all_none_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_any_all_none_of.h index 0e50e0ed36..47d280c431 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_any_all_none_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_any_all_none_of.h @@ -13,7 +13,6 @@ #include <__algorithm/pstl_frontend_dispatch.h> #include <__config> #include <__iterator/cpp17_iterator_concepts.h> -#include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> @@ -40,7 +39,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_any_of), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_any_of, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { return std::find_if(__policy, __g_first, __g_last, __g_pred) != __g_last; }, @@ -61,7 +60,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_all_of), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_all_of, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) { return !std::any_of(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) { return !__g_pred(__value); @@ -84,7 +83,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_none_of), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_none_of, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) { return !std::any_of(__policy, __g_first, __g_last, __g_pred); }, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h index 93372f0190..3d9459ef5f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h @@ -35,11 +35,29 @@ A PSTL parallel backend is a tag type to which the following functions are assoc template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp> void __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp); + template <class _ExecutionPolicy, + class _ForwardIterator1, + class _ForwardIterator2, + class _ForwardOutIterator, + class _Comp> + _ForwardOutIterator __pstl_merge(_Backend, + _ForwardIterator1 __first1, + _ForwardIterator1 __last1, + _ForwardIterator2 __first2, + _ForwardIterator2 __last2, + _ForwardOutIterator __result, + _Comp __comp); + template <class _ExecutionPolicy, class _InIterator, class _OutIterator, class _UnaryOperation> - _OutIterator __pstl_transform(_InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op); + _OutIterator __pstl_transform(_Backend, + _InIterator __first, + _InIterator __last, + _OutIterator __result, + _UnaryOperation __op); template <class _ExecutionPolicy, class _InIterator1, class _InIterator2, class _OutIterator, class _BinaryOperation> - _OutIterator __pstl_transform(_InIterator1 __first1, + _OutIterator __pstl_transform(_Backend, + _InIterator1 __first1, _InIterator1 __last1, _InIterator2 __first2, _OutIterator __result, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h index 8fe26797bf..c8a071af82 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h @@ -16,7 +16,7 @@ #include <__atomic/memory_order.h> #include <__config> #include <__functional/operations.h> -#include <__iterator/iterator_traits.h> +#include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> #include <__utility/pair.h> #include <__utility/terminate_on_exception.h> @@ -67,7 +67,7 @@ template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate> _LIBCPP_HIDE_FROM_ABI bool __pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__terminate_on_exception([&] { return std::__parallel_or( __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { @@ -76,7 +76,7 @@ __pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __la }); }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__simd_or(__first, __last - __first, __pred); } else { return std::any_of(__first, __last, __pred); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h index 5e5e0a23bf..8b531887c7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h @@ -12,7 +12,7 @@ #include <__algorithm/fill.h> #include <__algorithm/pstl_backends/cpu_backends/backend.h> #include <__config> -#include <__iterator/iterator_traits.h> +#include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> #include <__utility/terminate_on_exception.h> @@ -37,7 +37,7 @@ template <class _ExecutionPolicy, class _ForwardIterator, class _Tp> _LIBCPP_HIDE_FROM_ABI void __pstl_fill(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { std::__terminate_on_exception([&] { __par_backend::__parallel_for( __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { @@ -46,7 +46,7 @@ __pstl_fill(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last }); }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { std::__simd_fill_n(__first, __last - __first, __value); } else { std::fill(__first, __last, __value); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h index 3fa49549e6..91610c0408 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h @@ -14,6 +14,7 @@ #include <__atomic/atomic.h> #include <__config> #include <__functional/operations.h> +#include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__type_traits/is_execution_policy.h> #include <__utility/pair.h> @@ -93,7 +94,7 @@ template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate> _LIBCPP_HIDE_FROM_ABI _ForwardIterator __pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__terminate_on_exception([&] { return std::__parallel_find( __first, @@ -106,7 +107,7 @@ __pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __l true); }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { using __diff_t = __iter_diff_t<_ForwardIterator>; return std::__simd_first(__first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) { return __pred(__iter[__i]); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h index 36d0ac238e..f6f22fdd87 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h @@ -12,7 +12,7 @@ #include <__algorithm/for_each.h> #include <__algorithm/pstl_backends/cpu_backends/backend.h> #include <__config> -#include <__iterator/iterator_traits.h> +#include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> #include <__utility/terminate_on_exception.h> @@ -37,7 +37,7 @@ template <class _ExecutionPolicy, class _ForwardIterator, class _Functor> _LIBCPP_HIDE_FROM_ABI void __pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Functor __func) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { std::__terminate_on_exception([&] { std::__par_backend::__parallel_for( __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { @@ -46,7 +46,7 @@ __pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __ }); }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { std::__simd_walk_1(__first, __last - __first, __func); } else { std::for_each(__first, __last, __func); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h index bab6a3639b..50b6e0b1d0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h @@ -9,8 +9,10 @@ #ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H +#include <__algorithm/inplace_merge.h> #include <__algorithm/lower_bound.h> #include <__algorithm/max.h> +#include <__algorithm/merge.h> #include <__algorithm/upper_bound.h> #include <__atomic/atomic.h> #include <__config> @@ -21,7 +23,6 @@ #include <__memory/construct_at.h> #include <__memory/unique_ptr.h> #include <__numeric/reduce.h> -#include <__utility/exception_guard.h> #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/terminate_on_exception.h> @@ -57,14 +58,11 @@ struct __chunk_partitions { ptrdiff_t __first_chunk_size_; }; -[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size); +[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept; template <class _RandomAccessIterator, class _Functor> _LIBCPP_HIDE_FROM_ABI void -__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) { - auto __partitions = __libdispatch::__partition_chunks(__last - __first); - - // Perform the chunked execution. +__dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) { __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) { auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_; auto __index = @@ -75,6 +73,13 @@ __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fun }); } +template <class _RandomAccessIterator, class _Functor> +_LIBCPP_HIDE_FROM_ABI void +__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) { + return __libdispatch::__dispatch_parallel_for( + __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func)); +} + template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _RandomAccessIteratorOut> struct __merge_range { __merge_range(_RandomAccessIterator1 __mid1, _RandomAccessIterator2 __mid2, _RandomAccessIteratorOut __result) @@ -220,11 +225,92 @@ _LIBCPP_HIDE_FROM_ABI _Value __parallel_transform_reduce( }); } -// TODO: parallelize this template <class _RandomAccessIterator, class _Comp, class _LeafSort> _LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort( _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) { - __leaf_sort(__first, __last, __comp); + const auto __size = __last - __first; + auto __partitions = __libdispatch::__partition_chunks(__size); + + if (__partitions.__chunk_count_ == 0) + return; + + if (__partitions.__chunk_count_ == 1) + return __leaf_sort(__first, __last, __comp); + + using _Value = __iter_value_type<_RandomAccessIterator>; + + auto __destroy = [__size](_Value* __ptr) { + std::destroy_n(__ptr, __size); + std::allocator<_Value>().deallocate(__ptr, __size); + }; + + // TODO: use __uninitialized_buffer + unique_ptr<_Value[], decltype(__destroy)> __values(std::allocator<_Value>().allocate(__size), __destroy); + + return std::__terminate_on_exception([&] { + // Initialize all elements to a moved-from state + // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928 + std::__construct_at(__values.get(), std::move(*__first)); + for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) { + std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1])); + } + *__first = std::move(__values.get()[__size - 1]); + + __libdispatch::__dispatch_parallel_for( + __partitions, + __first, + [&__leaf_sort, &__comp](_RandomAccessIterator __chunk_first, _RandomAccessIterator __chunk_last) { + __leaf_sort(std::move(__chunk_first), std::move(__chunk_last), __comp); + }); + + bool __objects_are_in_buffer = false; + do { + const auto __old_chunk_size = __partitions.__chunk_size_; + if (__partitions.__chunk_count_ % 2 == 1) { + auto __inplace_merge_chunks = [&__comp, &__partitions](auto __first_chunk_begin) { + std::inplace_merge( + __first_chunk_begin, + __first_chunk_begin + __partitions.__first_chunk_size_, + __first_chunk_begin + __partitions.__first_chunk_size_ + __partitions.__chunk_size_, + __comp); + }; + if (__objects_are_in_buffer) + __inplace_merge_chunks(__values.get()); + else + __inplace_merge_chunks(__first); + __partitions.__first_chunk_size_ += 2 * __partitions.__chunk_size_; + } else { + __partitions.__first_chunk_size_ += __partitions.__chunk_size_; + } + + __partitions.__chunk_size_ *= 2; + __partitions.__chunk_count_ /= 2; + + auto __merge_chunks = [__partitions, __old_chunk_size, &__comp](auto __from_first, auto __to_first) { + __libdispatch::__dispatch_parallel_for( + __partitions, + __from_first, + [__old_chunk_size, &__from_first, &__to_first, &__comp](auto __chunk_first, auto __chunk_last) { + std::merge(std::make_move_iterator(__chunk_first), + std::make_move_iterator(__chunk_last - __old_chunk_size), + std::make_move_iterator(__chunk_last - __old_chunk_size), + std::make_move_iterator(__chunk_last), + __to_first + (__chunk_first - __from_first), + __comp); + }); + }; + + if (__objects_are_in_buffer) + __merge_chunks(__values.get(), __first); + else + __merge_chunks(__first, __values.get()); + __objects_are_in_buffer = !__objects_are_in_buffer; + } while (__partitions.__chunk_count_ > 1); + + if (__objects_are_in_buffer) { + std::move(__values.get(), __values.get() + __size, __first); + } + }); } _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {} diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h index d5be1e302d..c4b28e9502 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h @@ -12,7 +12,7 @@ #include <__algorithm/merge.h> #include <__algorithm/pstl_backends/cpu_backends/backend.h> #include <__config> -#include <__iterator/iterator_traits.h> +#include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> #include <__utility/move.h> #include <__utility/terminate_on_exception.h> @@ -39,9 +39,9 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge( _ForwardOutIterator __result, _Comp __comp) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator1>::value && - __has_random_access_iterator_category<_ForwardIterator2>::value && - __has_random_access_iterator_category<_ForwardOutIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && + __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && + __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { return std::__terminate_on_exception([&] { __par_backend::__parallel_merge( __first1, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h index ef25ff0238..0259d8a84b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h @@ -12,6 +12,7 @@ #include <__algorithm/pstl_backends/cpu_backends/backend.h> #include <__algorithm/transform.h> #include <__config> +#include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> @@ -43,8 +44,8 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( _ForwardOutIterator __result, _UnaryOperation __op) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value && - __has_random_access_iterator_category<_ForwardOutIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && + __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { std::__terminate_on_exception([&] { std::__par_backend::__parallel_for( __first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { @@ -54,8 +55,8 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( }); return __result + (__last - __first); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value && - __has_random_access_iterator_category<_ForwardOutIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && + __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { return std::__simd_walk_2( __first, __last - __first, @@ -90,9 +91,9 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( _ForwardOutIterator __result, _BinaryOperation __op) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator1>::value && - __has_random_access_iterator_category<_ForwardIterator2>::value && - __has_random_access_iterator_category<_ForwardOutIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && + __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && + __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { std::__terminate_on_exception([&] { std::__par_backend::__parallel_for( __first1, @@ -109,9 +110,9 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( }); return __result + (__last1 - __first1); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator1>::value && - __has_random_access_iterator_category<_ForwardIterator2>::value && - __has_random_access_iterator_category<_ForwardOutIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && + __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value && + __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { return std::__simd_walk_3( __first1, __last1 - __first1, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h index c51c312d93..2afe5c7d10 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h @@ -11,6 +11,7 @@ #include <__algorithm/pstl_backends/cpu_backends/backend.h> #include <__config> +#include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__numeric/transform_reduce.h> #include <__type_traits/is_arithmetic.h> @@ -106,8 +107,8 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( _BinaryOperation1 __reduce, _BinaryOperation2 __transform) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator1>::value && - __has_random_access_iterator_category<_ForwardIterator2>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && + __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { return std::__terminate_on_exception([&] { return __par_backend::__parallel_transform_reduce( __first1, @@ -130,8 +131,8 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( }); }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator1>::value && - __has_random_access_iterator_category<_ForwardIterator2>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && + __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { return std::__simd_transform_reduce( __last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) { return __transform(__first1[__i], __first2[__i]); @@ -156,7 +157,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( _BinaryOperation __reduce, _UnaryOperation __transform) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__terminate_on_exception([&] { return __par_backend::__parallel_transform_reduce( std::move(__first), @@ -175,7 +176,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( }); }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && - __has_random_access_iterator_category<_ForwardIterator>::value) { + __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__simd_transform_reduce( __last - __first, std::move(__init), diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h index 83c712c354..e4a6e5a54e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h @@ -10,15 +10,18 @@ #define _LIBCPP___ALGORITHM_PSTL_COPY_H #include <__algorithm/copy_n.h> +#include <__algorithm/pstl_backend.h> +#include <__algorithm/pstl_frontend_dispatch.h> #include <__algorithm/pstl_transform.h> #include <__config> #include <__functional/identity.h> -#include <__iterator/iterator_traits.h> +#include <__iterator/concepts.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_constant_evaluated.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/remove_cvref.h> +#include <__utility/move.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -30,26 +33,48 @@ _LIBCPP_BEGIN_NAMESPACE_STD // TODO: Use the std::copy/move shenanigans to forward to std::memmove +template <class> +void __pstl_copy(); + template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, - enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) { - return std::transform(__policy, __first, __last, __result, __identity()); + return std::__pstl_frontend_dispatch( + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy, _RawPolicy), + [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) { + return std::transform(__policy, __g_first, __g_last, __g_result, __identity()); + }, + std::move(__first), + std::move(__last), + std::move(__result)); } +template <class> +void __pstl_copy_n(); + template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, class _Size, - enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) { - if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) - return std::copy(__policy, __first, __first + __n, __result); - else - return std::copy_n(__first, __n, __result); + return std::__pstl_frontend_dispatch( + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy_n, _RawPolicy), + [&__policy](_ForwardIterator __g_first, _Size __g_n, _ForwardOutIterator __g_result) { + if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) + return std::copy(__policy, __g_first, __g_first + __g_n, __g_result); + else + return std::copy_n(__g_first, __g_n, __g_result); + }, + std::move(__first), + __n, + std::move(__result)); } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h index 15acb85de0..cc1e824570 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h @@ -45,7 +45,7 @@ _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { using __diff_t = __iter_diff_t<_ForwardIterator>; return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { return std::transform_reduce( __policy, @@ -71,7 +71,7 @@ template <class _ExecutionPolicy, _LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) { return std::count_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __v) { return __v == __g_value; diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h index d64c828d90..fc817b5c9e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h @@ -13,6 +13,7 @@ #include <__algorithm/pstl_for_each.h> #include <__algorithm/pstl_frontend_dispatch.h> #include <__config> +#include <__iterator/concepts.h> #include <__iterator/cpp17_iterator_concepts.h> #include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> @@ -41,7 +42,7 @@ _LIBCPP_HIDE_FROM_ABI void fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) { std::for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) { __element = __g_value; @@ -65,9 +66,9 @@ _LIBCPP_HIDE_FROM_ABI void fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill_n), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill_n, _RawPolicy), [&](_ForwardIterator __g_first, _SizeT __g_n, const _Tp& __g_value) { - if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) + if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) std::fill(__policy, __g_first, __g_first + __g_n, __g_value); else std::fill_n(__g_first, __g_n, __g_value); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h index 8e8adfecfa..c2894d0875 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h @@ -15,7 +15,6 @@ #include <__algorithm/pstl_frontend_dispatch.h> #include <__config> #include <__iterator/cpp17_iterator_concepts.h> -#include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> @@ -54,7 +53,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find_if_not), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find_if_not, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { return std::find_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) { return !__g_pred(__value); @@ -77,7 +76,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find, _RawPolicy), [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) { return std::find_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) { return __element == __g_value; diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_for_each.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_for_each.h index 09efc24950..6e6c73d19f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_for_each.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_for_each.h @@ -14,8 +14,8 @@ #include <__algorithm/pstl_backend.h> #include <__algorithm/pstl_frontend_dispatch.h> #include <__config> +#include <__iterator/concepts.h> #include <__iterator/cpp17_iterator_concepts.h> -#include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> @@ -56,9 +56,9 @@ _LIBCPP_HIDE_FROM_ABI void for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n, _RawPolicy), [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) { - if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) { + if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { std::for_each(__policy, std::move(__g_first), __g_first + __g_size, std::move(__g_func)); } else { std::for_each_n(std::move(__g_first), __g_size, std::move(__g_func)); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_frontend_dispatch.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_frontend_dispatch.h index dc49f3e516..6fa1107491 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_frontend_dispatch.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_frontend_dispatch.h @@ -21,11 +21,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD -# define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name) \ - [](auto&&... __args) -> decltype(std::name<_RawPolicy>(typename __select_backend<_RawPolicy>::type{}, \ - std::forward<decltype(__args)>(__args)...)) { \ - return std::name<_RawPolicy>( \ - typename __select_backend<_RawPolicy>::type{}, std::forward<decltype(__args)>(__args)...); \ +# define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name, policy) \ + [](auto&&... __args) -> decltype(std::name<policy>( \ + typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...)) { \ + return std::name<policy>(typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...); \ } template <class _SpecializedImpl, class _GenericImpl, class... _Args> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h index e1ba0183dc..9a70e2e26b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h @@ -14,6 +14,7 @@ #include <__algorithm/pstl_frontend_dispatch.h> #include <__config> #include <__iterator/cpp17_iterator_concepts.h> +#include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> @@ -39,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI void generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Generator __g_gen) { std::for_each( __policy, std::move(__g_first), std::move(__g_last), [&](__iter_reference<_ForwardIterator> __element) { @@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI void generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate_n), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate_n, _RawPolicy), [&__policy](_ForwardIterator __g_first, _Size __g_n, _Generator __g_gen) { std::for_each_n(__policy, std::move(__g_first), __g_n, [&](__iter_reference<_ForwardIterator> __element) { __element = __g_gen(); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_is_partitioned.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_is_partitioned.h index 6f6e9b2f44..1492ce2127 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_is_partitioned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_is_partitioned.h @@ -38,7 +38,7 @@ template <class _ExecutionPolicy, _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { __g_first = std::find_if_not(__policy, __g_first, __g_last, __g_pred); if (__g_first == __g_last) diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h index 04ffaaba59..08f59ce2de 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h @@ -43,7 +43,7 @@ replace_if(_ExecutionPolicy&& __policy, _Pred __pred, const _Tp& __new_value) { std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred, const _Tp& __g_new_value) { std::for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) { if (__g_pred(__element)) @@ -71,7 +71,7 @@ replace(_ExecutionPolicy&& __policy, const _Tp& __old_value, const _Tp& __new_value) { std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace, _RawPolicy), [&__policy]( _ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_old_value, const _Tp& __g_new_value) { std::replace_if( @@ -105,7 +105,7 @@ _LIBCPP_HIDE_FROM_ABI void replace_copy_if( _Pred __pred, const _Tp& __new_value) { std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result, @@ -139,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI void replace_copy( const _Tp& __old_value, const _Tp& __new_value) { std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h index 75c77ed405..85239df0ab 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h @@ -38,7 +38,7 @@ template <class _ExecutionPolicy, _LIBCPP_HIDE_FROM_ABI void sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_sort), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_sort, _RawPolicy), [&__policy](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) { std::stable_sort(__policy, std::move(__g_first), std::move(__g_last), std::move(__g_comp)); }, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h index 27d95349fc..a34439304a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h @@ -12,7 +12,6 @@ #include <__algorithm/pstl_backend.h> #include <__config> #include <__iterator/cpp17_iterator_concepts.h> -#include <__iterator/iterator_traits.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h index 5f33192666..a10b04167e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_adjacent_find.h @@ -24,6 +24,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + #if _LIBCPP_STD_VER >= 20 _LIBCPP_BEGIN_NAMESPACE_STD @@ -75,4 +78,6 @@ _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_STD_VER >= 20 +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_RANGES_ADJACENT_FIND_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h new file mode 100644 index 0000000000..2afb74bff0 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_ends_with.h @@ -0,0 +1,196 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___ALGORITHM_RANGES_ENDS_WITH_H +#define _LIBCPP___ALGORITHM_RANGES_ENDS_WITH_H + +#include <__algorithm/ranges_equal.h> +#include <__algorithm/ranges_starts_with.h> +#include <__config> +#include <__functional/identity.h> +#include <__functional/ranges_operations.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/advance.h> +#include <__iterator/concepts.h> +#include <__iterator/distance.h> +#include <__iterator/indirectly_comparable.h> +#include <__iterator/reverse_iterator.h> +#include <__ranges/access.h> +#include <__ranges/concepts.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace ranges { +namespace __ends_with { +struct __fn { + template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_bidirectional( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2) { + auto __rbegin1 = std::make_reverse_iterator(__last1); + auto __rend1 = std::make_reverse_iterator(__first1); + auto __rbegin2 = std::make_reverse_iterator(__last2); + auto __rend2 = std::make_reverse_iterator(__first2); + return ranges::starts_with( + __rbegin1, __rend1, __rbegin2, __rend2, std::ref(__pred), std::ref(__proj1), std::ref(__proj2)); + } + + template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2) { + if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> && + (!std::random_access_iterator<_Sent1>)&&(!std::random_access_iterator<_Sent2>)) { + return __ends_with_fn_impl_bidirectional(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2); + + } else { + auto __n1 = ranges::distance(__first1, __last1); + auto __n2 = ranges::distance(__first2, __last2); + if (__n2 == 0) + return true; + if (__n2 > __n1) + return false; + + return __ends_with_fn_impl_with_offset( + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__last2), + __pred, + __proj1, + __proj2, + __n1 - __n2); + } + } + + template <class _Iter1, + class _Sent1, + class _Iter2, + class _Sent2, + class _Pred, + class _Proj1, + class _Proj2, + class _Offset> + static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_with_offset( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred& __pred, + _Proj1& __proj1, + _Proj2& __proj2, + _Offset __offset) { + if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> && + !std::random_access_iterator<_Sent1> && !std::random_access_iterator<_Sent2>) { + return __ends_with_fn_impl_bidirectional( + std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2); + + } else { + ranges::advance(__first1, __offset); + return ranges::equal( + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__last2), + std::ref(__pred), + std::ref(__proj1), + std::ref(__proj2)); + } + } + + template <input_iterator _Iter1, + sentinel_for<_Iter1> _Sent1, + input_iterator _Iter2, + sentinel_for<_Iter2> _Sent2, + class _Pred = ranges::equal_to, + class _Proj1 = identity, + class _Proj2 = identity> + requires(forward_iterator<_Iter1> || sized_sentinel_for<_Sent1, _Iter1>) && + (forward_iterator<_Iter2> || sized_sentinel_for<_Sent2, _Iter2>) && + indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Iter1 __first1, + _Sent1 __last1, + _Iter2 __first2, + _Sent2 __last2, + _Pred __pred = {}, + _Proj1 __proj1 = {}, + _Proj2 __proj2 = {}) const { + return __ends_with_fn_impl( + std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2); + } + + template <input_range _Range1, + input_range _Range2, + class _Pred = ranges::equal_to, + class _Proj1 = identity, + class _Proj2 = identity> + requires(forward_range<_Range1> || sized_range<_Range1>) && (forward_range<_Range2> || sized_range<_Range2>) && + indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()( + _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const { + if constexpr (sized_range<_Range1> && sized_range<_Range2>) { + auto __n1 = ranges::size(__range1); + auto __n2 = ranges::size(__range2); + if (__n2 == 0) + return true; + if (__n2 > __n1) + return false; + auto __offset = __n1 - __n2; + + return __ends_with_fn_impl_with_offset( + ranges::begin(__range1), + ranges::end(__range1), + ranges::begin(__range2), + ranges::end(__range2), + __pred, + __proj1, + __proj2, + __offset); + + } else { + return __ends_with_fn_impl( + ranges::begin(__range1), + ranges::end(__range1), + ranges::begin(__range2), + ranges::end(__range2), + __pred, + __proj1, + __proj2); + } + } +}; +} // namespace __ends_with + +inline namespace __cpo { +inline constexpr auto ends_with = __ends_with::__fn{}; +} // namespace __cpo +} // namespace ranges + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER >= 23 + +#endif // _LIBCPP___ALGORITHM_RANGES_ENDS_WITH_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h index 40c32442b1..258c6a5fa3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h @@ -175,23 +175,26 @@ inline _LIBCPP_HIDE_FROM_ABI void __partially_sorted_swap(_RandomAccessIterator *__y = __r ? *__y : __tmp; } -template <class, class _Compare, class _RandomAccessIterator> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> +template <class, class _Compare, class _RandomAccessIterator, + __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI void __sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) { std::__cond_swap<_Compare>(__x2, __x3, __c); std::__partially_sorted_swap<_Compare>(__x1, __x2, __x3, __c); } -template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> +template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, + __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI void __sort3_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _Compare __c) { std::__sort3<_AlgPolicy, _Compare>(__x1, __x2, __x3, __c); } -template <class, class _Compare, class _RandomAccessIterator> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> +template <class, class _Compare, class _RandomAccessIterator, + __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _RandomAccessIterator __x4, _Compare __c) { std::__cond_swap<_Compare>(__x1, __x3, __c); @@ -201,15 +204,17 @@ __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, std::__cond_swap<_Compare>(__x2, __x3, __c); } -template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> +template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, + __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI void __sort4_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _RandomAccessIterator __x4, _Compare __c) { std::__sort4<_AlgPolicy, _Compare>(__x1, __x2, __x3, __x4, __c); } -template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> +template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, + __enable_if_t<__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless( _RandomAccessIterator __x1, _RandomAccessIterator __x2, @@ -225,8 +230,9 @@ __sort5_maybe_branchless( std::__partially_sorted_swap<_Compare>(__x2, __x3, __x4, __c); } -template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, void> +template <class _AlgPolicy, class _Compare, class _RandomAccessIterator, + __enable_if_t<!__use_branchless_sort<_Compare, _RandomAccessIterator>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI void __sort5_maybe_branchless(_RandomAccessIterator __x1, _RandomAccessIterator __x2, _RandomAccessIterator __x3, _RandomAccessIterator __x4, _RandomAccessIterator __x5, _Compare __c) { std::__sort5<_AlgPolicy, _Compare, _RandomAccessIterator>( diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h index 19c102f4c9..7731c0fd79 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/three_way_comp_ref_type.h @@ -50,7 +50,7 @@ struct __debug_three_way_comp { __expected = _Order::greater; if (__o == _Order::greater) __expected = _Order::less; - _LIBCPP_ASSERT(__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering"); + _LIBCPP_ASSERT_UNCATEGORIZED(__comp_(__l, __r) == __expected, "Comparator does not induce a strict weak ordering"); (void)__l; (void)__r; } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_range.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_range.h index 2c75c8f49d..053fd550b3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_range.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_range.h @@ -50,7 +50,7 @@ struct __unwrap_range_impl { } _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter) - requires (!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>)) + requires(!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>)) { return __iter; } @@ -73,10 +73,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last)); } -template < - class _Sent, - class _Iter, - class _Unwrapped = decltype(std::__unwrap_range(std::declval<_Iter>(), std::declval<_Sent>()))> +template < class _Sent, class _Iter, class _Unwrapped> _LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) { return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter)); } @@ -86,7 +83,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair<_Unwrapped, _Unwrapped> __unwrap_ra return std::make_pair(std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))); } -template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))> +template <class _Iter, class _Unwrapped> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) { return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter)); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h index 68df7f12c1..47de6b958a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic.h @@ -505,25 +505,17 @@ _Tp atomic_fetch_sub_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::difference // atomic_fetch_and -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_and(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT { return __o->fetch_and(__op); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_and(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT { return __o->fetch_and(__op); @@ -531,25 +523,17 @@ atomic_fetch_and(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXC // atomic_fetch_and_explicit -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT { return __o->fetch_and(__op, __m); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_and_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT { return __o->fetch_and(__op, __m); @@ -557,25 +541,17 @@ atomic_fetch_and_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __o // atomic_fetch_or -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_or(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT { return __o->fetch_or(__op); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_or(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT { return __o->fetch_or(__op); @@ -583,25 +559,17 @@ atomic_fetch_or(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCE // atomic_fetch_or_explicit -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT { return __o->fetch_or(__op, __m); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_or_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT { return __o->fetch_or(__op, __m); @@ -609,25 +577,17 @@ atomic_fetch_or_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op // atomic_fetch_xor -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_xor(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT { return __o->fetch_xor(__op); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_xor(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXCEPT { return __o->fetch_xor(__op); @@ -635,25 +595,17 @@ atomic_fetch_xor(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op) _NOEXC // atomic_fetch_xor_explicit -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT { return __o->fetch_xor(__op, __m); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value && !is_same<_Tp, bool>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if -< - is_integral<_Tp>::value && !is_same<_Tp, bool>::value, - _Tp ->::type +_Tp atomic_fetch_xor_explicit(atomic<_Tp>* __o, typename atomic<_Tp>::value_type __op, memory_order __m) _NOEXCEPT { return __o->fetch_xor(__op, __m); diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/cxx_atomic_impl.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/cxx_atomic_impl.h index 167cee7f0b..d670fddc39 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/cxx_atomic_impl.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/cxx_atomic_impl.h @@ -32,14 +32,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because // the default operator= in an object is not volatile, a byte-by-byte copy // is required. -template <typename _Tp, typename _Tv> _LIBCPP_HIDE_FROM_ABI -typename enable_if<is_assignable<_Tp&, _Tv>::value>::type -__cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) { +template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI +void __cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) { __a_value = __val; } -template <typename _Tp, typename _Tv> _LIBCPP_HIDE_FROM_ABI -typename enable_if<is_assignable<_Tp&, _Tv>::value>::type -__cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) { +template <typename _Tp, typename _Tv, __enable_if_t<is_assignable<_Tp&, _Tv>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI +void __cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) { volatile char* __to = reinterpret_cast<volatile char*>(std::addressof(__a_value)); volatile char* __end = __to + sizeof(_Tp); volatile const char* __from = reinterpret_cast<volatile const char*>(std::addressof(__val)); diff --git a/contrib/libs/cxxsupp/libcxx/include/__availability b/contrib/libs/cxxsupp/libcxx/include/__availability index 7807f22b71..579698ec1e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__availability +++ b/contrib/libs/cxxsupp/libcxx/include/__availability @@ -174,6 +174,11 @@ // # define _LIBCPP_AVAILABILITY_HAS_NO_PMR # define _LIBCPP_AVAILABILITY_PMR + // This controls the availability of the C++20 time zone database. + // The parser code is built in the library. +// # define _LIBCPP_AVAILABILITY_HAS_NO_TZDB +# define _LIBCPP_AVAILABILITY_TZDB + #elif defined(__APPLE__) // shared_mutex and shared_timed_mutex @@ -348,6 +353,9 @@ # define _LIBCPP_AVAILABILITY_PMR # endif +# define _LIBCPP_AVAILABILITY_HAS_NO_TZDB +# define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable)) + #else // ...New vendors can add availability markup here... diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/bit_ceil.h b/contrib/libs/cxxsupp/libcxx/include/__bit/bit_ceil.h index 706d446359..9eae5c391a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/bit_ceil.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/bit_ceil.h @@ -21,13 +21,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 +#if _LIBCPP_STD_VER >= 17 -template <__libcpp_unsigned_integer _Tp> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { +template <class _Tp> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) noexcept { if (__t < 2) return 1; - const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u)); + const unsigned __n = numeric_limits<_Tp>::digits - std::__countl_zero((_Tp)(__t - 1u)); _LIBCPP_ASSERT_UNCATEGORIZED(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); if constexpr (sizeof(_Tp) >= sizeof(unsigned)) @@ -39,7 +39,15 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noex } } -#endif // _LIBCPP_STD_VER >= 20 +# if _LIBCPP_STD_VER >= 20 + +template <__libcpp_unsigned_integer _Tp> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { + return std::__bit_ceil(__t); +} + +# endif // _LIBCPP_STD_VER >= 20 +#endif // _LIBCPP_STD_VER >= 17 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h b/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h index 5d5744ac9a..23a7c42773 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/countl.h @@ -74,7 +74,7 @@ int __countl_zero(_Tp __t) _NOEXCEPT int __iter = 0; const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; while (true) { - __t = std::__rotr(__t, __ulldigits); + __t = std::__rotl(__t, __ulldigits); if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits) break; __ret += __iter; diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/invert_if.h b/contrib/libs/cxxsupp/libcxx/include/__bit/invert_if.h new file mode 100644 index 0000000000..f7606ede26 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/invert_if.h @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___BIT_INVERT_IF_H +#define _LIBCPP___BIT_INVERT_IF_H + +#include <__concepts/arithmetic.h> +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <bool _Invert, class _Tp> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __invert_if(_Tp __v) { + if (_Invert) + return ~__v; + return __v; +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___BIT_INVERT_IF_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h b/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h index e9f4c8d474..d848056c33 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__bit/rotate.h @@ -20,29 +20,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 -_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); - const unsigned int __dig = numeric_limits<_Tp>::digits; - if ((__cnt % __dig) == 0) - return __t; - return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig))); +template <class _Tp> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __t, int __cnt) _NOEXCEPT { + static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); + const unsigned int __dig = numeric_limits<_Tp>::digits; + if ((__cnt % __dig) == 0) + return __t; + + if (__cnt < 0) { + __cnt *= -1; + return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); // rotr with negative __cnt is similar to rotl + } + + return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig))); +} + +template <class _Tp> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __t, int __cnt) _NOEXCEPT { + return std::__rotr(__t, -__cnt); } #if _LIBCPP_STD_VER >= 20 template <__libcpp_unsigned_integer _Tp> -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept { - const unsigned int __dig = numeric_limits<_Tp>::digits; - if ((__cnt % __dig) == 0) - return __t; - return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept { + return std::__rotl(__t, __cnt); } template <__libcpp_unsigned_integer _Tp> -[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept { return std::__rotr(__t, __cnt); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit_reference b/contrib/libs/cxxsupp/libcxx/include/__bit_reference index 0563c3e619..107368759c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit_reference +++ b/contrib/libs/cxxsupp/libcxx/include/__bit_reference @@ -14,8 +14,10 @@ #include <__algorithm/fill_n.h> #include <__algorithm/min.h> #include <__bit/countr.h> +#include <__bit/invert_if.h> #include <__bit/popcount.h> #include <__config> +#include <__fwd/bit_reference.h> #include <__iterator/iterator_traits.h> #include <__memory/construct_at.h> #include <__memory/pointer_traits.h> @@ -30,1330 +32,1068 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> - _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Cp, bool _IsConst, class = typename _Cp::__storage_type> class __bit_iterator; -template <class _Cp> class __bit_const_reference; +template <class _Cp> +class __bit_const_reference; template <class _Tp> -struct __has_storage_type -{ - static const bool value = false; +struct __has_storage_type { + static const bool value = false; }; template <class _Cp, bool = __has_storage_type<_Cp>::value> -class __bit_reference -{ - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__storage_pointer __storage_pointer; +class __bit_reference { + using __storage_type = typename _Cp::__storage_type; + using __storage_pointer = typename _Cp::__storage_pointer; - __storage_pointer __seg_; - __storage_type __mask_; + __storage_pointer __seg_; + __storage_type __mask_; - friend typename _Cp::__self; + friend typename _Cp::__self; + + friend class __bit_const_reference<_Cp>; + friend class __bit_iterator<_Cp, false>; - friend class __bit_const_reference<_Cp>; - friend class __bit_iterator<_Cp, false>; public: - using __container = typename _Cp::__self; + using __container = typename _Cp::__self; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - __bit_reference(const __bit_reference&) = default; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference(const __bit_reference&) = default; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT - {return static_cast<bool>(*__seg_ & __mask_);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator ~() const _NOEXCEPT - {return !static_cast<bool>(*this);} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator bool() const _NOEXCEPT { + return static_cast<bool>(*__seg_ & __mask_); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool operator~() const _NOEXCEPT { + return !static_cast<bool>(*this); + } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - __bit_reference& operator=(bool __x) _NOEXCEPT - { - if (__x) - *__seg_ |= __mask_; - else - *__seg_ &= ~__mask_; - return *this; - } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference& operator=(bool __x) _NOEXCEPT { + if (__x) + *__seg_ |= __mask_; + else + *__seg_ &= ~__mask_; + return *this; + } #if _LIBCPP_STD_VER >= 23 - _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept { - if (__x) - *__seg_ |= __mask_; - else - *__seg_ &= ~__mask_; - return *this; - } + _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept { + if (__x) + *__seg_ |= __mask_; + else + *__seg_ &= ~__mask_; + return *this; + } #endif - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT - {return operator=(static_cast<bool>(__x));} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT { + return operator=(static_cast<bool>(__x)); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT { *__seg_ ^= __mask_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT { + return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_))); + } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT {*__seg_ ^= __mask_;} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT - {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));} private: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT - : __seg_(__s), __mask_(__m) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_reference( + __storage_pointer __s, __storage_type __m) _NOEXCEPT + : __seg_(__s), + __mask_(__m) {} }; template <class _Cp> -class __bit_reference<_Cp, false> -{ -}; +class __bit_reference<_Cp, false> {}; template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -void -swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void +swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT { + bool __t = __x; + __x = __y; + __y = __t; } template <class _Cp, class _Dp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -void -swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void +swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT { + bool __t = __x; + __x = __y; + __y = __t; } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -void -swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT { + bool __t = __x; + __x = __y; + __y = __t; } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -void -swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT -{ - bool __t = __x; - __x = __y; - __y = __t; +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT { + bool __t = __x; + __x = __y; + __y = __t; } template <class _Cp> -class __bit_const_reference -{ - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__const_storage_pointer __storage_pointer; +class __bit_const_reference { + using __storage_type = typename _Cp::__storage_type; + using __storage_pointer = typename _Cp::__const_storage_pointer; + + __storage_pointer __seg_; + __storage_type __mask_; - __storage_pointer __seg_; - __storage_type __mask_; + friend typename _Cp::__self; + friend class __bit_iterator<_Cp, true>; - friend typename _Cp::__self; - friend class __bit_iterator<_Cp, true>; public: - using __container = typename _Cp::__self; + using __container = typename _Cp::__self; - _LIBCPP_INLINE_VISIBILITY - __bit_const_reference(const __bit_const_reference&) = default; + _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default; - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT - : __seg_(__x.__seg_), __mask_(__x.__mask_) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT + : __seg_(__x.__seg_), + __mask_(__x.__mask_) {} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT - {return static_cast<bool>(*__seg_ & __mask_);} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT { + return static_cast<bool>(*__seg_ & __mask_); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT { + return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_))); + } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT - {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));} private: - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR - explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT - : __seg_(__s), __mask_(__m) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __bit_const_reference( + __storage_pointer __s, __storage_type __m) _NOEXCEPT + : __seg_(__s), + __mask_(__m) {} - __bit_const_reference& operator=(const __bit_const_reference&) = delete; + __bit_const_reference& operator=(const __bit_const_reference&) = delete; }; -// find - -template <class _Cp, bool _IsConst> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst> -__find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b))); - if (__n == __dn) - return __first + __n; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - if (*__first.__seg_) - return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(*__first.__seg_))); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b))); - } - return _It(__first.__seg_, static_cast<unsigned>(__n)); -} - -template <class _Cp, bool _IsConst> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, _IsConst> -__find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = ~*__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b))); - if (__n == __dn) - return __first + __n; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - { - __storage_type __b = ~*__first.__seg_; - if (__b) - return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b))); - } - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = ~*__first.__seg_ & __m; - if (__b) - return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b))); - } - return _It(__first.__seg_, static_cast<unsigned>(__n)); -} - -template <class _Cp, bool _IsConst, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -__bit_iterator<_Cp, _IsConst> -find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) -{ - if (static_cast<bool>(__value)) - return _VSTD::__find_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first)); - return _VSTD::__find_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first)); -} - // count -template <class _Cp, bool _IsConst> +template <bool _ToCount, class _Cp, bool _IsConst> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - typedef typename _It::difference_type difference_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = _VSTD::__libcpp_popcount(*__first.__seg_ & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += _VSTD::__libcpp_popcount(*__first.__seg_); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += _VSTD::__libcpp_popcount(*__first.__seg_ & __m); - } - return __r; -} - -template <class _Cp, bool _IsConst> -_LIBCPP_HIDE_FROM_ABI typename __bit_iterator<_Cp, _IsConst>::difference_type -__count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, _IsConst> _It; - typedef typename _It::__storage_type __storage_type; - typedef typename _It::difference_type difference_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __r = 0; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __r = _VSTD::__libcpp_popcount(~*__first.__seg_ & __m); - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) - __r += _VSTD::__libcpp_popcount(~*__first.__seg_); - // do last partial word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __r += _VSTD::__libcpp_popcount(~*__first.__seg_ & __m); - } - return __r; +__count_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n) { + using _It = __bit_iterator<_Cp, _IsConst>; + using __storage_type = typename _It::__storage_type; + using difference_type = typename _It::difference_type; + + const int __bits_per_word = _It::__bits_per_word; + difference_type __r = 0; + // do first partial word + if (__first.__ctz_ != 0) { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = std::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __r = std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m); + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) + __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_)); + // do last partial word + if (__n > 0) { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m); + } + return __r; } template <class _Cp, bool _IsConst, class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -typename __bit_iterator<_Cp, _IsConst>::difference_type -count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) -{ - if (static_cast<bool>(__value)) - return _VSTD::__count_bool_true(__first, static_cast<typename _Cp::size_type>(__last - __first)); - return _VSTD::__count_bool_false(__first, static_cast<typename _Cp::size_type>(__last - __first)); +inline _LIBCPP_HIDE_FROM_ABI typename __bit_iterator<_Cp, _IsConst>::difference_type +count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value) { + if (static_cast<bool>(__value)) + return std::__count_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first)); + return std::__count_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first)); } // fill_n -template <class _Cp> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void -__fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, false> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - *__first.__seg_ &= ~__m; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - __storage_type __nw = __n / __bits_per_word; - std::fill_n(std::__to_address(__first.__seg_), __nw, 0); - __n -= __nw * __bits_per_word; - // do last partial word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__first.__seg_ &= ~__m; - } -} - -template <class _Cp> +template <bool _FillValue, class _Cp> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void -__fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) -{ - typedef __bit_iterator<_Cp, false> _It; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - // do first partial word - if (__first.__ctz_ != 0) - { - __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); - __storage_type __dn = _VSTD::min(__clz_f, __n); - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - *__first.__seg_ |= __m; - __n -= __dn; - ++__first.__seg_; - } - // do middle whole words - __storage_type __nw = __n / __bits_per_word; - // __storage_type is always an unsigned type, so -1 sets all bits - std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1)); - __n -= __nw * __bits_per_word; - // do last partial word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__first.__seg_ |= __m; - } +__fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) { + using _It = __bit_iterator<_Cp, false>; + using __storage_type = typename _It::__storage_type; + + const int __bits_per_word = _It::__bits_per_word; + // do first partial word + if (__first.__ctz_ != 0) { + __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_); + __storage_type __dn = std::min(__clz_f, __n); + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + if (_FillValue) + *__first.__seg_ |= __m; + else + *__first.__seg_ &= ~__m; + __n -= __dn; + ++__first.__seg_; + } + // do middle whole words + __storage_type __nw = __n / __bits_per_word; + std::fill_n(std::__to_address(__first.__seg_), __nw, _FillValue ? static_cast<__storage_type>(-1) : 0); + __n -= __nw * __bits_per_word; + // do last partial word + if (__n > 0) { + __first.__seg_ += __nw; + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + if (_FillValue) + *__first.__seg_ |= __m; + else + *__first.__seg_ &= ~__m; + } } template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -void -fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value) -{ - if (__n > 0) - { - if (__value) - _VSTD::__fill_n_true(__first, __n); - else - _VSTD::__fill_n_false(__first, __n); - } +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void +fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value) { + if (__n > 0) { + if (__value) + std::__fill_n<true>(__first, __n); + else + std::__fill_n<false>(__first, __n); + } } // fill template <class _Cp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -void -fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value) -{ - _VSTD::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value); +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void +fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value) { + std::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value); } // copy template <class _Cp, bool _IsConst> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> -__copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - __storage_type __b = *__first.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - __storage_type __nw = __n / __bits_per_word; - std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_)); - __n -= __nw * __bits_per_word; - __result.__seg_ += __nw; - // do last word - if (__n > 0) - { - __first.__seg_ += __nw; - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast<unsigned>(__n); - } +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_aligned( + __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + using _In = __bit_iterator<_Cp, _IsConst>; + using difference_type = typename _In::difference_type; + using __storage_type = typename _In::__storage_type; + + const int __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) { + // do first word + if (__first.__ctz_ != 0) { + unsigned __clz = __bits_per_word - __first.__ctz_; + difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); + __storage_type __b = *__first.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); + ++__first.__seg_; + // __first.__ctz_ = 0; } - return __result; + // __first.__ctz_ == 0; + // do middle words + __storage_type __nw = __n / __bits_per_word; + std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_)); + __n -= __nw * __bits_per_word; + __result.__seg_ += __nw; + // do last word + if (__n > 0) { + __first.__seg_ += __nw; + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__ctz_ = static_cast<unsigned>(__n); + } + } + return __result; } template <class _Cp, bool _IsConst> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> -__copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __first.__ctz_) - *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); - else - *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); - __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); - __result.__ctz_ = static_cast<unsigned>(__dn); - } - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __m = ~__storage_type(0) << __result.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) - { - __storage_type __b = *__first.__seg_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << __result.__ctz_; - ++__result.__seg_; - *__result.__seg_ &= __m; - *__result.__seg_ |= __b >> __clz_r; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first.__seg_ & __m; - __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__clz_r)); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << __result.__ctz_; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> __dn; - __result.__ctz_ = static_cast<unsigned>(__n); - } - } +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_unaligned( + __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + using _In = __bit_iterator<_Cp, _IsConst>; + using difference_type = typename _In::difference_type; + using __storage_type = typename _In::__storage_type; + + const int __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) { + // do first word + if (__first.__ctz_ != 0) { + unsigned __clz_f = __bits_per_word - __first.__ctz_; + difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = *__first.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); + *__result.__seg_ &= ~__m; + if (__result.__ctz_ > __first.__ctz_) + *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_); + else + *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_); + __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); + __dn -= __ddn; + if (__dn > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __dn); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn); + __result.__ctz_ = static_cast<unsigned>(__dn); + } + ++__first.__seg_; + // __first.__ctz_ = 0; + } + // __first.__ctz_ == 0; + // do middle words + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __m = ~__storage_type(0) << __result.__ctz_; + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { + __storage_type __b = *__first.__seg_; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b << __result.__ctz_; + ++__result.__seg_; + *__result.__seg_ &= __m; + *__result.__seg_ |= __b >> __clz_r; + } + // do last word + if (__n > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first.__seg_ & __m; + __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b << __result.__ctz_; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> __dn; + __result.__ctz_ = static_cast<unsigned>(__n); + } } - return __result; + } + return __result; } template <class _Cp, bool _IsConst> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -__bit_iterator<_Cp, false> -copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - if (__first.__ctz_ == __result.__ctz_) - return _VSTD::__copy_aligned(__first, __last, __result); - return _VSTD::__copy_unaligned(__first, __last, __result); +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> +copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + if (__first.__ctz_ == __result.__ctz_) + return std::__copy_aligned(__first, __last, __result); + return std::__copy_unaligned(__first, __last, __result); } // copy_backward template <class _Cp, bool _IsConst> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> -__copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__last.__ctz_ != 0) - { - difference_type __dn = _VSTD::min(static_cast<difference_type>(__last.__ctz_), __n); - __n -= __dn; - unsigned __clz = __bits_per_word - __last.__ctz_; - __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz); - __storage_type __b = *__last.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - // __last.__ctz_ = 0 - } - // __last.__ctz_ == 0 || __n == 0 - // __result.__ctz_ == 0 || __n == 0 - // do middle words - __storage_type __nw = __n / __bits_per_word; - __result.__seg_ -= __nw; - __last.__seg_ -= __nw; - std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_)); - __n -= __nw * __bits_per_word; - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n); - __storage_type __b = *--__last.__seg_ & __m; - *--__result.__seg_ &= ~__m; - *__result.__seg_ |= __b; - __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); - } +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_aligned( + __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + using _In = __bit_iterator<_Cp, _IsConst>; + using difference_type = typename _In::difference_type; + using __storage_type = typename _In::__storage_type; + + const int __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) { + // do first word + if (__last.__ctz_ != 0) { + difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n); + __n -= __dn; + unsigned __clz = __bits_per_word - __last.__ctz_; + __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz); + __storage_type __b = *__last.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); + // __last.__ctz_ = 0 } - return __result; + // __last.__ctz_ == 0 || __n == 0 + // __result.__ctz_ == 0 || __n == 0 + // do middle words + __storage_type __nw = __n / __bits_per_word; + __result.__seg_ -= __nw; + __last.__seg_ -= __nw; + std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_)); + __n -= __nw * __bits_per_word; + // do last word + if (__n > 0) { + __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n); + __storage_type __b = *--__last.__seg_ & __m; + *--__result.__seg_ &= ~__m; + *__result.__seg_ |= __b; + __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); + } + } + return __result; } template <class _Cp, bool _IsConst> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> -__copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, - __bit_iterator<_Cp, false> __result) -{ - typedef __bit_iterator<_Cp, _IsConst> _In; - typedef typename _In::difference_type difference_type; - typedef typename _In::__storage_type __storage_type; - const int __bits_per_word = _In::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__last.__ctz_ != 0) - { - difference_type __dn = _VSTD::min(static_cast<difference_type>(__last.__ctz_), __n); - __n -= __dn; - unsigned __clz_l = __bits_per_word - __last.__ctz_; - __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l); - __storage_type __b = *__last.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min(__dn, static_cast<difference_type>(__result.__ctz_)); - if (__ddn > 0) - { - __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r); - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __last.__ctz_) - *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); - else - *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); - __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - } - if (__dn > 0) - { - // __result.__ctz_ == 0 - --__result.__seg_; - __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1)); - __m = ~__storage_type(0) << __result.__ctz_; - *__result.__seg_ &= ~__m; - __last.__ctz_ -= __dn + __ddn; - *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); - } - // __last.__ctz_ = 0 - } - // __last.__ctz_ == 0 || __n == 0 - // __result.__ctz_ != 0 || __n == 0 - // do middle words - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __m = ~__storage_type(0) >> __clz_r; - for (; __n >= __bits_per_word; __n -= __bits_per_word) - { - __storage_type __b = *--__last.__seg_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> __clz_r; - *--__result.__seg_ &= __m; - *__result.__seg_ |= __b << __result.__ctz_; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) << (__bits_per_word - __n); - __storage_type __b = *--__last.__seg_ & __m; - __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__result.__ctz_)); - __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r); - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); - __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + - __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - // __result.__ctz_ == 0 - --__result.__seg_; - __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); - __m = ~__storage_type(0) << __result.__ctz_; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); - } - } +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_unaligned( + __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + using _In = __bit_iterator<_Cp, _IsConst>; + using difference_type = typename _In::difference_type; + using __storage_type = typename _In::__storage_type; + + const int __bits_per_word = _In::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) { + // do first word + if (__last.__ctz_ != 0) { + difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n); + __n -= __dn; + unsigned __clz_l = __bits_per_word - __last.__ctz_; + __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l); + __storage_type __b = *__last.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __ddn = std::min(__dn, static_cast<difference_type>(__result.__ctz_)); + if (__ddn > 0) { + __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r); + *__result.__seg_ &= ~__m; + if (__result.__ctz_ > __last.__ctz_) + *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); + else + *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_); + __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); + __dn -= __ddn; + } + if (__dn > 0) { + // __result.__ctz_ == 0 + --__result.__seg_; + __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1)); + __m = ~__storage_type(0) << __result.__ctz_; + *__result.__seg_ &= ~__m; + __last.__ctz_ -= __dn + __ddn; + *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_); + } + // __last.__ctz_ = 0 } - return __result; + // __last.__ctz_ == 0 || __n == 0 + // __result.__ctz_ != 0 || __n == 0 + // do middle words + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __m = ~__storage_type(0) >> __clz_r; + for (; __n >= __bits_per_word; __n -= __bits_per_word) { + __storage_type __b = *--__last.__seg_; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> __clz_r; + *--__result.__seg_ &= __m; + *__result.__seg_ |= __b << __result.__ctz_; + } + // do last word + if (__n > 0) { + __m = ~__storage_type(0) << (__bits_per_word - __n); + __storage_type __b = *--__last.__seg_ & __m; + __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __dn = std::min(__n, static_cast<difference_type>(__result.__ctz_)); + __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r); + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_); + __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) { + // __result.__ctz_ == 0 + --__result.__seg_; + __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1)); + __m = ~__storage_type(0) << __result.__ctz_; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn)); + } + } + } + return __result; } template <class _Cp, bool _IsConst> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -__bit_iterator<_Cp, false> -copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - if (__last.__ctz_ == __result.__ctz_) - return _VSTD::__copy_backward_aligned(__first, __last, __result); - return _VSTD::__copy_backward_unaligned(__first, __last, __result); +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> copy_backward( + __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + if (__last.__ctz_ == __result.__ctz_) + return std::__copy_backward_aligned(__first, __last, __result); + return std::__copy_backward_unaligned(__first, __last, __result); } // move template <class _Cp, bool _IsConst> -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - return _VSTD::copy(__first, __last, __result); +inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> +move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + return std::copy(__first, __last, __result); } // move_backward template <class _Cp, bool _IsConst> -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cp, false> -move_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) -{ - return _VSTD::copy_backward(__first, __last, __result); +inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> move_backward( + __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { + return std::copy_backward(__first, __last, __result); } // swap_ranges template <class _Cl, class _Cr> -_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> -__swap_ranges_aligned(__bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, - __bit_iterator<_Cr, false> __result) -{ - typedef __bit_iterator<_Cl, false> _I1; - typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; - const int __bits_per_word = _I1::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1; - *__first.__seg_ |= __b2; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) - swap(*__first.__seg_, *__result.__seg_); - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1; - *__first.__seg_ |= __b2; - __result.__ctz_ = static_cast<unsigned>(__n); - } +_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> __swap_ranges_aligned( + __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) { + using _I1 = __bit_iterator<_Cl, false>; + using difference_type = typename _I1::difference_type; + using __storage_type = typename _I1::__storage_type; + + const int __bits_per_word = _I1::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) { + // do first word + if (__first.__ctz_ != 0) { + unsigned __clz = __bits_per_word - __first.__ctz_; + difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1; + *__first.__seg_ |= __b2; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); + ++__first.__seg_; + // __first.__ctz_ = 0; + } + // __first.__ctz_ == 0; + // do middle words + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_) + swap(*__first.__seg_, *__result.__seg_); + // do last word + if (__n > 0) { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1; + *__first.__seg_ |= __b2; + __result.__ctz_ = static_cast<unsigned>(__n); } - return __result; + } + return __result; } template <class _Cl, class _Cr> -_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> -__swap_ranges_unaligned(__bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, - __bit_iterator<_Cr, false> __result) -{ - typedef __bit_iterator<_Cl, false> _I1; - typedef typename _I1::difference_type difference_type; - typedef typename _I1::__storage_type __storage_type; - const int __bits_per_word = _I1::__bits_per_word; - difference_type __n = __last - __first; - if (__n > 0) - { - // do first word - if (__first.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first.__ctz_; - difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - if (__result.__ctz_ > __first.__ctz_) - { - unsigned __s = __result.__ctz_ - __first.__ctz_; - *__result.__seg_ |= __b1 << __s; - *__first.__seg_ |= __b2 >> __s; - } - else - { - unsigned __s = __first.__ctz_ - __result.__ctz_; - *__result.__seg_ |= __b1 >> __s; - *__first.__seg_ |= __b2 << __s; - } - __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - unsigned __s = __first.__ctz_ + __ddn; - *__result.__seg_ |= __b1 >> __s; - *__first.__seg_ |= __b2 << __s; - __result.__ctz_ = static_cast<unsigned>(__dn); - } - ++__first.__seg_; - // __first.__ctz_ = 0; - } - // __first.__ctz_ == 0; - // do middle words - __storage_type __m = ~__storage_type(0) << __result.__ctz_; - unsigned __clz_r = __bits_per_word - __result.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) - { - __storage_type __b1 = *__first.__seg_; - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 << __result.__ctz_; - *__first.__seg_ = __b2 >> __result.__ctz_; - ++__result.__seg_; - __b2 = *__result.__seg_ & ~__m; - *__result.__seg_ &= __m; - *__result.__seg_ |= __b1 >> __clz_r; - *__first.__seg_ |= __b2 << __clz_r; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b1 = *__first.__seg_ & __m; - *__first.__seg_ &= ~__m; - __storage_type __dn = _VSTD::min<__storage_type>(__n, __clz_r); - __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - __storage_type __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 << __result.__ctz_; - *__first.__seg_ |= __b2 >> __result.__ctz_; - __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; - __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __b2 = *__result.__seg_ & __m; - *__result.__seg_ &= ~__m; - *__result.__seg_ |= __b1 >> __dn; - *__first.__seg_ |= __b2 << __dn; - __result.__ctz_ = static_cast<unsigned>(__n); - } - } +_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> __swap_ranges_unaligned( + __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) { + using _I1 = __bit_iterator<_Cl, false>; + using difference_type = typename _I1::difference_type; + using __storage_type = typename _I1::__storage_type; + + const int __bits_per_word = _I1::__bits_per_word; + difference_type __n = __last - __first; + if (__n > 0) { + // do first word + if (__first.__ctz_ != 0) { + unsigned __clz_f = __bits_per_word - __first.__ctz_; + difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + if (__result.__ctz_ > __first.__ctz_) { + unsigned __s = __result.__ctz_ - __first.__ctz_; + *__result.__seg_ |= __b1 << __s; + *__first.__seg_ |= __b2 >> __s; + } else { + unsigned __s = __first.__ctz_ - __result.__ctz_; + *__result.__seg_ |= __b1 >> __s; + *__first.__seg_ |= __b2 << __s; + } + __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word); + __dn -= __ddn; + if (__dn > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __dn); + __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + unsigned __s = __first.__ctz_ + __ddn; + *__result.__seg_ |= __b1 >> __s; + *__first.__seg_ |= __b2 << __s; + __result.__ctz_ = static_cast<unsigned>(__dn); + } + ++__first.__seg_; + // __first.__ctz_ = 0; } - return __result; + // __first.__ctz_ == 0; + // do middle words + __storage_type __m = ~__storage_type(0) << __result.__ctz_; + unsigned __clz_r = __bits_per_word - __result.__ctz_; + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) { + __storage_type __b1 = *__first.__seg_; + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1 << __result.__ctz_; + *__first.__seg_ = __b2 >> __result.__ctz_; + ++__result.__seg_; + __b2 = *__result.__seg_ & ~__m; + *__result.__seg_ &= __m; + *__result.__seg_ |= __b1 >> __clz_r; + *__first.__seg_ |= __b2 << __clz_r; + } + // do last word + if (__n > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b1 = *__first.__seg_ & __m; + *__first.__seg_ &= ~__m; + __storage_type __dn = std::min<__storage_type>(__n, __clz_r); + __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); + __storage_type __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1 << __result.__ctz_; + *__first.__seg_ |= __b2 >> __result.__ctz_; + __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word; + __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __b2 = *__result.__seg_ & __m; + *__result.__seg_ &= ~__m; + *__result.__seg_ |= __b1 >> __dn; + *__first.__seg_ |= __b2 << __dn; + __result.__ctz_ = static_cast<unsigned>(__n); + } + } + } + return __result; } template <class _Cl, class _Cr> -inline _LIBCPP_INLINE_VISIBILITY -__bit_iterator<_Cr, false> -swap_ranges(__bit_iterator<_Cl, false> __first1, __bit_iterator<_Cl, false> __last1, - __bit_iterator<_Cr, false> __first2) -{ - if (__first1.__ctz_ == __first2.__ctz_) - return _VSTD::__swap_ranges_aligned(__first1, __last1, __first2); - return _VSTD::__swap_ranges_unaligned(__first1, __last1, __first2); +inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges( + __bit_iterator<_Cl, false> __first1, __bit_iterator<_Cl, false> __last1, __bit_iterator<_Cr, false> __first2) { + if (__first1.__ctz_ == __first2.__ctz_) + return std::__swap_ranges_aligned(__first1, __last1, __first2); + return std::__swap_ranges_unaligned(__first1, __last1, __first2); } // rotate template <class _Cp> -struct __bit_array -{ - typedef typename _Cp::difference_type difference_type; - typedef typename _Cp::__storage_type __storage_type; - typedef typename _Cp::__storage_pointer __storage_pointer; - typedef typename _Cp::iterator iterator; - static const unsigned __bits_per_word = _Cp::__bits_per_word; - static const unsigned _Np = 4; - - difference_type __size_; - __storage_type __word_[_Np]; - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 static difference_type capacity() - {return static_cast<difference_type>(_Np * __bits_per_word);} - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_array(difference_type __s) : __size_(__s) { - if (__libcpp_is_constant_evaluated()) { - for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i) - std::__construct_at(__word_ + __i, 0); - } - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() - { - return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); - } - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() - { - return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, - static_cast<unsigned>(__size_ % __bits_per_word)); +struct __bit_array { + using difference_type = typename _Cp::difference_type; + using __storage_type = typename _Cp::__storage_type; + using __storage_pointer = typename _Cp::__storage_pointer; + using iterator = typename _Cp::iterator; + + static const unsigned __bits_per_word = _Cp::__bits_per_word; + static const unsigned _Np = 4; + + difference_type __size_; + __storage_type __word_[_Np]; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static difference_type capacity() { + return static_cast<difference_type>(_Np * __bits_per_word); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_array(difference_type __s) : __size_(__s) { + if (__libcpp_is_constant_evaluated()) { + for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i) + std::__construct_at(__word_ + __i, 0); } + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() { + return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator end() { + return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word, + static_cast<unsigned>(__size_ % __bits_per_word)); + } }; template <class _Cp> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> -rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) -{ - typedef __bit_iterator<_Cp, false> _I1; - typedef typename _I1::difference_type difference_type; - difference_type __d1 = __middle - __first; - difference_type __d2 = __last - __middle; - _I1 __r = __first + __d2; - while (__d1 != 0 && __d2 != 0) - { - if (__d1 <= __d2) - { - if (__d1 <= __bit_array<_Cp>::capacity()) - { - __bit_array<_Cp> __b(__d1); - _VSTD::copy(__first, __middle, __b.begin()); - _VSTD::copy(__b.begin(), __b.end(), _VSTD::copy(__middle, __last, __first)); - break; - } - else - { - __bit_iterator<_Cp, false> __mp = _VSTD::swap_ranges(__first, __middle, __middle); - __first = __middle; - __middle = __mp; - __d2 -= __d1; - } - } - else - { - if (__d2 <= __bit_array<_Cp>::capacity()) - { - __bit_array<_Cp> __b(__d2); - _VSTD::copy(__middle, __last, __b.begin()); - _VSTD::copy_backward(__b.begin(), __b.end(), _VSTD::copy_backward(__first, __middle, __last)); - break; - } - else - { - __bit_iterator<_Cp, false> __mp = __first + __d2; - _VSTD::swap_ranges(__first, __mp, __middle); - __first = __mp; - __d1 -= __d2; - } - } +rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) { + using _I1 = __bit_iterator<_Cp, false>; + using difference_type = typename _I1::difference_type; + + difference_type __d1 = __middle - __first; + difference_type __d2 = __last - __middle; + _I1 __r = __first + __d2; + while (__d1 != 0 && __d2 != 0) { + if (__d1 <= __d2) { + if (__d1 <= __bit_array<_Cp>::capacity()) { + __bit_array<_Cp> __b(__d1); + std::copy(__first, __middle, __b.begin()); + std::copy(__b.begin(), __b.end(), std::copy(__middle, __last, __first)); + break; + } else { + __bit_iterator<_Cp, false> __mp = std::swap_ranges(__first, __middle, __middle); + __first = __middle; + __middle = __mp; + __d2 -= __d1; + } + } else { + if (__d2 <= __bit_array<_Cp>::capacity()) { + __bit_array<_Cp> __b(__d2); + std::copy(__middle, __last, __b.begin()); + std::copy_backward(__b.begin(), __b.end(), std::copy_backward(__first, __middle, __last)); + break; + } else { + __bit_iterator<_Cp, false> __mp = __first + __d2; + std::swap_ranges(__first, __mp, __middle); + __first = __mp; + __d1 -= __d2; + } } - return __r; + } + return __r; } // equal template <class _Cp, bool _IC1, bool _IC2> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool -__equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, - __bit_iterator<_Cp, _IC2> __first2) -{ - typedef __bit_iterator<_Cp, _IC1> _It; - typedef typename _It::difference_type difference_type; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __n = __last1 - __first1; - if (__n > 0) - { - // do first word - if (__first1.__ctz_ != 0) - { - unsigned __clz_f = __bits_per_word - __first1.__ctz_; - difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz_f), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); - __storage_type __b = *__first1.__seg_ & __m; - unsigned __clz_r = __bits_per_word - __first2.__ctz_; - __storage_type __ddn = _VSTD::min<__storage_type>(__dn, __clz_r); - __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); - if (__first2.__ctz_ > __first1.__ctz_) - { - if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_))) - return false; - } - else - { - if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_))) - return false; - } - __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; - __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word); - __dn -= __ddn; - if (__dn > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __dn); - if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn))) - return false; - __first2.__ctz_ = static_cast<unsigned>(__dn); - } - ++__first1.__seg_; - // __first1.__ctz_ = 0; - } - // __first1.__ctz_ == 0; - // do middle words - unsigned __clz_r = __bits_per_word - __first2.__ctz_; - __storage_type __m = ~__storage_type(0) << __first2.__ctz_; - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) - { - __storage_type __b = *__first1.__seg_; - if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) - return false; - ++__first2.__seg_; - if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r)) - return false; - } - // do last word - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - __storage_type __b = *__first1.__seg_ & __m; - __storage_type __dn = _VSTD::min(__n, static_cast<difference_type>(__clz_r)); - __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); - if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) - return false; - __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; - __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word); - __n -= __dn; - if (__n > 0) - { - __m = ~__storage_type(0) >> (__bits_per_word - __n); - if ((*__first2.__seg_ & __m) != (__b >> __dn)) - return false; - } - } +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __equal_unaligned( + __bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { + using _It = __bit_iterator<_Cp, _IC1>; + using difference_type = typename _It::difference_type; + using __storage_type = typename _It::__storage_type; + + const int __bits_per_word = _It::__bits_per_word; + difference_type __n = __last1 - __first1; + if (__n > 0) { + // do first word + if (__first1.__ctz_ != 0) { + unsigned __clz_f = __bits_per_word - __first1.__ctz_; + difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn)); + __storage_type __b = *__first1.__seg_ & __m; + unsigned __clz_r = __bits_per_word - __first2.__ctz_; + __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r); + __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn)); + if (__first2.__ctz_ > __first1.__ctz_) { + if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_))) + return false; + } else { + if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_))) + return false; + } + __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word; + __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word); + __dn -= __ddn; + if (__dn > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __dn); + if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn))) + return false; + __first2.__ctz_ = static_cast<unsigned>(__dn); + } + ++__first1.__seg_; + // __first1.__ctz_ = 0; + } + // __first1.__ctz_ == 0; + // do middle words + unsigned __clz_r = __bits_per_word - __first2.__ctz_; + __storage_type __m = ~__storage_type(0) << __first2.__ctz_; + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) { + __storage_type __b = *__first1.__seg_; + if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) + return false; + ++__first2.__seg_; + if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r)) + return false; + } + // do last word + if (__n > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + __storage_type __b = *__first1.__seg_ & __m; + __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r)); + __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn)); + if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_)) + return false; + __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word; + __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word); + __n -= __dn; + if (__n > 0) { + __m = ~__storage_type(0) >> (__bits_per_word - __n); + if ((*__first2.__seg_ & __m) != (__b >> __dn)) + return false; + } } - return true; + } + return true; } template <class _Cp, bool _IC1, bool _IC2> -_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool -__equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, - __bit_iterator<_Cp, _IC2> __first2) -{ - typedef __bit_iterator<_Cp, _IC1> _It; - typedef typename _It::difference_type difference_type; - typedef typename _It::__storage_type __storage_type; - const int __bits_per_word = _It::__bits_per_word; - difference_type __n = __last1 - __first1; - if (__n > 0) - { - // do first word - if (__first1.__ctz_ != 0) - { - unsigned __clz = __bits_per_word - __first1.__ctz_; - difference_type __dn = _VSTD::min(static_cast<difference_type>(__clz), __n); - __n -= __dn; - __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); - if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) - return false; - ++__first2.__seg_; - ++__first1.__seg_; - // __first1.__ctz_ = 0; - // __first2.__ctz_ = 0; - } - // __first1.__ctz_ == 0; - // __first2.__ctz_ == 0; - // do middle words - for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_) - if (*__first2.__seg_ != *__first1.__seg_) - return false; - // do last word - if (__n > 0) - { - __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); - if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) - return false; - } +_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __equal_aligned( + __bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { + using _It = __bit_iterator<_Cp, _IC1>; + using difference_type = typename _It::difference_type; + using __storage_type = typename _It::__storage_type; + + const int __bits_per_word = _It::__bits_per_word; + difference_type __n = __last1 - __first1; + if (__n > 0) { + // do first word + if (__first1.__ctz_ != 0) { + unsigned __clz = __bits_per_word - __first1.__ctz_; + difference_type __dn = std::min(static_cast<difference_type>(__clz), __n); + __n -= __dn; + __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn)); + if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) + return false; + ++__first2.__seg_; + ++__first1.__seg_; + // __first1.__ctz_ = 0; + // __first2.__ctz_ = 0; } - return true; + // __first1.__ctz_ == 0; + // __first2.__ctz_ == 0; + // do middle words + for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_) + if (*__first2.__seg_ != *__first1.__seg_) + return false; + // do last word + if (__n > 0) { + __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n); + if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m)) + return false; + } + } + return true; } template <class _Cp, bool _IC1, bool _IC2> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -bool -equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) -{ - if (__first1.__ctz_ == __first2.__ctz_) - return _VSTD::__equal_aligned(__first1, __last1, __first2); - return _VSTD::__equal_unaligned(__first1, __last1, __first2); +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool +equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { + if (__first1.__ctz_ == __first2.__ctz_) + return std::__equal_aligned(__first1, __last1, __first2); + return std::__equal_unaligned(__first1, __last1, __first2); } -template <class _Cp, bool _IsConst, - class> -class __bit_iterator -{ +template <class _Cp, bool _IsConst, typename _Cp::__storage_type> +class __bit_iterator { public: - typedef typename _Cp::difference_type difference_type; - typedef bool value_type; - typedef __bit_iterator pointer; + using difference_type = typename _Cp::difference_type; + using value_type = bool; + using pointer = __bit_iterator; #ifndef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL - typedef __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> > reference; + using reference = __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >; #else - using reference = __conditional_t<_IsConst, bool, __bit_reference<_Cp> >; + using reference = __conditional_t<_IsConst, bool, __bit_reference<_Cp> >; #endif - typedef random_access_iterator_tag iterator_category; + using iterator_category = random_access_iterator_tag; private: - typedef typename _Cp::__storage_type __storage_type; - typedef __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer> - __storage_pointer; - static const unsigned __bits_per_word = _Cp::__bits_per_word; + using __storage_type = typename _Cp::__storage_type; + using __storage_pointer = + __conditional_t<_IsConst, typename _Cp::__const_storage_pointer, typename _Cp::__storage_pointer>; + + static const unsigned __bits_per_word = _Cp::__bits_per_word; - __storage_pointer __seg_; - unsigned __ctz_; + __storage_pointer __seg_; + unsigned __ctz_; public: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator() _NOEXCEPT #if _LIBCPP_STD_VER >= 14 - : __seg_(nullptr), __ctz_(0) + : __seg_(nullptr), + __ctz_(0) #endif - {} - - // When _IsConst=false, this is the copy constructor. - // It is non-trivial. Making it trivial would break ABI. - // When _IsConst=true, this is a converting constructor; - // the copy and move constructors are implicitly generated - // and trivial. - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT - : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} - - // When _IsConst=false, we have a user-provided copy constructor, - // so we must also provide a copy assignment operator because - // the implicit generation of a defaulted one is deprecated. - // When _IsConst=true, the assignment operators are - // implicitly generated and trivial. - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) { - __seg_ = __it.__seg_; - __ctz_ = __it.__ctz_; - return *this; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT { - return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >( - __seg_, __storage_type(1) << __ctz_); + { + } + + // When _IsConst=false, this is the copy constructor. + // It is non-trivial. Making it trivial would break ABI. + // When _IsConst=true, this is a converting constructor; + // the copy and move constructors are implicitly generated + // and trivial. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT + : __seg_(__it.__seg_), + __ctz_(__it.__ctz_) {} + + // When _IsConst=false, we have a user-provided copy constructor, + // so we must also provide a copy assignment operator because + // the implicit generation of a defaulted one is deprecated. + // When _IsConst=true, the assignment operators are + // implicitly generated and trivial. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& + operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) { + __seg_ = __it.__seg_; + __ctz_ = __it.__ctz_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT { + return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >( + __seg_, __storage_type(1) << __ctz_); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator++() { + if (__ctz_ != __bits_per_word - 1) + ++__ctz_; + else { + __ctz_ = 0; + ++__seg_; } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator++() - { - if (__ctz_ != __bits_per_word-1) - ++__ctz_; - else - { - __ctz_ = 0; - ++__seg_; - } - return *this; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator++(int) { + __bit_iterator __tmp = *this; + ++(*this); + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator--() { + if (__ctz_ != 0) + --__ctz_; + else { + __ctz_ = __bits_per_word - 1; + --__seg_; } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator++(int) - { - __bit_iterator __tmp = *this; - ++(*this); - return __tmp; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator--() - { - if (__ctz_ != 0) - --__ctz_; - else - { - __ctz_ = __bits_per_word - 1; - --__seg_; - } - return *this; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator--(int) - { - __bit_iterator __tmp = *this; - --(*this); - return __tmp; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator+=(difference_type __n) - { - if (__n >= 0) - __seg_ += (__n + __ctz_) / __bits_per_word; - else - __seg_ += static_cast<difference_type>(__n - __bits_per_word + __ctz_ + 1) - / static_cast<difference_type>(__bits_per_word); - __n &= (__bits_per_word - 1); - __ctz_ = static_cast<unsigned>((__n + __ctz_) % __bits_per_word); - return *this; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator-=(difference_type __n) - { - return *this += -__n; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator+(difference_type __n) const - { - __bit_iterator __t(*this); - __t += __n; - return __t; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const - { - __bit_iterator __t(*this); - __t -= __n; - return __t; - } - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator operator+(difference_type __n, const __bit_iterator& __it) {return __it + __n;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend difference_type operator-(const __bit_iterator& __x, const __bit_iterator& __y) - {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const {return *(*this + __n);} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y) - {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__x == __y);} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y) - {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y) - {return __y < __x;} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__y < __x);} - - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y) - {return !(__x < __y);} + return *this; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator--(int) { + __bit_iterator __tmp = *this; + --(*this); + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator+=(difference_type __n) { + if (__n >= 0) + __seg_ += (__n + __ctz_) / __bits_per_word; + else + __seg_ += static_cast<difference_type>(__n - __bits_per_word + __ctz_ + 1) / + static_cast<difference_type>(__bits_per_word); + __n &= (__bits_per_word - 1); + __ctz_ = static_cast<unsigned>((__n + __ctz_) % __bits_per_word); + return *this; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator& operator-=(difference_type __n) { + return *this += -__n; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator+(difference_type __n) const { + __bit_iterator __t(*this); + __t += __n; + return __t; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const { + __bit_iterator __t(*this); + __t -= __n; + return __t; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator + operator+(difference_type __n, const __bit_iterator& __it) { + return __it + __n; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend difference_type + operator-(const __bit_iterator& __x, const __bit_iterator& __y) { + return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const { + return *(*this + __n); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + operator==(const __bit_iterator& __x, const __bit_iterator& __y) { + return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + operator!=(const __bit_iterator& __x, const __bit_iterator& __y) { + return !(__x == __y); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + operator<(const __bit_iterator& __x, const __bit_iterator& __y) { + return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + operator>(const __bit_iterator& __x, const __bit_iterator& __y) { + return __y < __x; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + operator<=(const __bit_iterator& __x, const __bit_iterator& __y) { + return !(__y < __x); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + operator>=(const __bit_iterator& __x, const __bit_iterator& __y) { + return !(__x < __y); + } private: - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT - : __seg_(__s), __ctz_(__ctz) {} - - friend typename _Cp::__self; - - friend class __bit_reference<_Cp>; - friend class __bit_const_reference<_Cp>; - friend class __bit_iterator<_Cp, true>; - template <class _Dp> friend struct __bit_array; - template <class _Dp> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - - template <class _Dp> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); - - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first, - __bit_iterator<_Dp, _IC> __last, - __bit_iterator<_Dp, false> __result); - template <class _Cl, class _Cr>friend __bit_iterator<_Cr, false> __swap_ranges_aligned(__bit_iterator<_Cl, false>, - __bit_iterator<_Cl, false>, - __bit_iterator<_Cr, false>); - template <class _Cl, class _Cr>friend __bit_iterator<_Cr, false> __swap_ranges_unaligned(__bit_iterator<_Cl, false>, - __bit_iterator<_Cl, false>, - __bit_iterator<_Cr, false>); - template <class _Cl, class _Cr>friend __bit_iterator<_Cr, false> swap_ranges(__bit_iterator<_Cl, false>, - __bit_iterator<_Cl, false>, - __bit_iterator<_Cr, false>); - template <class _Dp> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>, - __bit_iterator<_Dp, false>); - template <class _Dp, bool _IC1, bool _IC2> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template <class _Dp, bool _IC1, bool _IC2> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template <class _Dp, bool _IC1, bool _IC2> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend bool equal(__bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC1>, - __bit_iterator<_Dp, _IC2>); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); - template <class _Dp, bool _IC> - _LIBCPP_CONSTEXPR_SINCE_CXX20 - friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); - template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 - __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); - template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::difference_type - __count_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator( + __storage_pointer __s, unsigned __ctz) _NOEXCEPT + : __seg_(__s), + __ctz_(__ctz) {} + + friend typename _Cp::__self; + + friend class __bit_reference<_Cp>; + friend class __bit_const_reference<_Cp>; + friend class __bit_iterator<_Cp, true>; + template <class _Dp> + friend struct __bit_array; + template <bool _FillValue, class _Dp> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void __fill_n(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n); + + template <class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned( + __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); + template <class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_unaligned( + __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); + template <class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> + copy(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); + template <class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned( + __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); + template <class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_unaligned( + __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); + template <class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> + copy_backward(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result); + template <class _Cl, class _Cr> + friend __bit_iterator<_Cr, false> + __swap_ranges_aligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); + template <class _Cl, class _Cr> + friend __bit_iterator<_Cr, false> + __swap_ranges_unaligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); + template <class _Cl, class _Cr> + friend __bit_iterator<_Cr, false> + swap_ranges(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>); + template <class _Dp> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> + rotate(__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>); + template <class _Dp, bool _IC1, bool _IC2> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + __equal_aligned(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); + template <class _Dp, bool _IC1, bool _IC2> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + __equal_unaligned(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); + template <class _Dp, bool _IC1, bool _IC2> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool + equal(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>); + template <bool _ToFind, class _Dp, bool _IC> + _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC> + __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); + template <bool _ToCount, class _Dp, bool _IC> + friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 + __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); }; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/chars_format.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/chars_format.h index 0e781c047e..95faa29010 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/chars_format.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/chars_format.h @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 -enum class _LIBCPP_ENUM_VIS chars_format { scientific = 0x1, fixed = 0x2, hex = 0x4, general = fixed | scientific }; +enum class chars_format { scientific = 0x1, fixed = 0x2, hex = 0x4, general = fixed | scientific }; inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator~(chars_format __x) { return chars_format(~std::__to_underlying(__x)); diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_integral.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_integral.h index acfdf4b30d..e969cedb33 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_integral.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_integral.h @@ -124,7 +124,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... return __r; } -template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_unsigned<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) { using __tx = __itoa::__traits<_Tp>; @@ -145,7 +145,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) { }); } -template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result __from_chars_atoi(const char* __first, const char* __last, _Tp& __value) { using __t = decltype(std::__to_unsigned_like(__value)); @@ -170,7 +170,7 @@ inline constexpr float __from_chars_log2f_lut[35] = { 4.321928, 4.3923173, 4.4594316, 4.523562, 4.5849624, 4.643856, 4.70044, 4.7548876, 4.807355, 4.857981, 4.9068904, 4.9541965, 5, 5.044394, 5.087463, 5.129283, 5.169925}; -template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_unsigned<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result __from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base) { if (__base == 10) @@ -211,20 +211,20 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base); } -template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result __from_chars_integral(const char* __first, const char* __last, _Tp& __value, int __base) { using __t = decltype(std::__to_unsigned_like(__value)); return std::__sign_combinator(__first, __last, __value, __from_chars_integral<__t>, __base); } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result from_chars(const char* __first, const char* __last, _Tp& __value) { return std::__from_chars_atoi(__first, __last, __value); } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI from_chars_result from_chars(const char* __first, const char* __last, _Tp& __value, int __base) { _LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_result.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_result.h index fa98616a0c..a7bfd6530a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_result.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/from_chars_result.h @@ -27,6 +27,9 @@ struct _LIBCPP_EXPORTED_FROM_ABI from_chars_result { # if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const from_chars_result&, const from_chars_result&) = default; # endif +# if _LIBCPP_STD_VER >= 26 + _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return ec == errc{}; } +# endif }; #endif // _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h index 28fac7524c..f50cc55a4c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_integral.h @@ -222,23 +222,23 @@ struct _LIBCPP_HIDDEN __integral<16> { } // namespace __itoa -template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0> +template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_width(_Tp __value) { return __itoa::__integral<_Base>::__width(__value); } -template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0> +template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_width(_Tp __value) { return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value)); } -template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0> +template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result __to_chars_integral(char* __first, char* __last, _Tp __value) { return __itoa::__integral<_Base>::__to_chars(__first, __last, __value); } -template <unsigned _Base, typename _Tp, typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0> +template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result __to_chars_integral(char* __first, char* __last, _Tp __value) { return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value)); @@ -300,7 +300,7 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_ return {__last, errc(0)}; } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result to_chars(char* __first, char* __last, _Tp __value) { using _Type = __make_32_64_or_128_bit_t<_Tp>; @@ -308,7 +308,7 @@ to_chars(char* __first, char* __last, _Tp __value) { return std::__to_chars_itoa(__first, __last, static_cast<_Type>(__value), is_signed<_Tp>()); } -template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> +template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result to_chars(char* __first, char* __last, _Tp __value, int __base) { _LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_result.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_result.h index aba5e5f06b..8df0897a49 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_result.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_result.h @@ -27,6 +27,9 @@ struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result { # if _LIBCPP_STD_VER >= 20 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const to_chars_result&, const to_chars_result&) = default; # endif +# if _LIBCPP_STD_VER >= 26 + _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return ec == errc{}; } +# endif }; #endif // _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/duration.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/duration.h index 96e9671eb5..e4e5f03b48 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/duration.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/duration.h @@ -116,14 +116,10 @@ struct __duration_cast<_FromDuration, _ToDuration, _Period, false, false> } }; -template <class _ToDuration, class _Rep, class _Period> +template <class _ToDuration, class _Rep, class _Period, __enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type +_ToDuration duration_cast(const duration<_Rep, _Period>& __fd) { return __duration_cast<duration<_Rep, _Period>, _ToDuration>()(__fd); @@ -147,13 +143,9 @@ public: }; #if _LIBCPP_STD_VER >= 17 -template <class _ToDuration, class _Rep, class _Period> +template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type +_ToDuration floor(const duration<_Rep, _Period>& __d) { _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); @@ -162,13 +154,9 @@ floor(const duration<_Rep, _Period>& __d) return __t; } -template <class _ToDuration, class _Rep, class _Period> +template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type +_ToDuration ceil(const duration<_Rep, _Period>& __d) { _ToDuration __t = chrono::duration_cast<_ToDuration>(__d); @@ -177,13 +165,9 @@ ceil(const duration<_Rep, _Period>& __d) return __t; } -template <class _ToDuration, class _Rep, class _Period> +template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - _ToDuration ->::type +_ToDuration round(const duration<_Rep, _Period>& __d) { _ToDuration __lower = chrono::floor<_ToDuration>(__d); @@ -250,28 +234,20 @@ public: _LIBCPP_HIDE_FROM_ABI duration() {} #endif - template <class _Rep2> + template <class _Rep2, __enable_if_t<is_convertible<const _Rep2&, rep>::value && + (treat_as_floating_point<rep>::value || + !treat_as_floating_point<_Rep2>::value), int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - explicit duration(const _Rep2& __r, - typename enable_if - < - is_convertible<const _Rep2&, rep>::value && - (treat_as_floating_point<rep>::value || - !treat_as_floating_point<_Rep2>::value) - >::type* = nullptr) + explicit duration(const _Rep2& __r) : __rep_(__r) {} // conversions - template <class _Rep2, class _Period2> + template <class _Rep2, class _Period2, __enable_if_t<__no_overflow<_Period2, period>::value && ( + treat_as_floating_point<rep>::value || + (__no_overflow<_Period2, period>::type::den == 1 && + !treat_as_floating_point<_Rep2>::value)), int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - duration(const duration<_Rep2, _Period2>& __d, - typename enable_if - < - __no_overflow<_Period2, period>::value && ( - treat_as_floating_point<rep>::value || - (__no_overflow<_Period2, period>::type::den == 1 && - !treat_as_floating_point<_Rep2>::value)) - >::type* = nullptr) + duration(const duration<_Rep2, _Period2>& __d) : __rep_(chrono::duration_cast<duration>(__d).count()) {} // observer @@ -462,14 +438,11 @@ operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 // Duration * -template <class _Rep1, class _Period, class _Rep2> +template <class _Rep1, class _Period, class _Rep2, + __enable_if_t<is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type +duration<typename common_type<_Rep1, _Rep2>::type, _Period> operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; @@ -477,14 +450,11 @@ operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) return _Cd(_Cd(__d).count() * static_cast<_Cr>(__s)); } -template <class _Rep1, class _Period, class _Rep2> +template <class _Rep1, class _Period, class _Rep2, + __enable_if_t<is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type +duration<typename common_type<_Rep1, _Rep2>::type, _Period> operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) { return __d * __s; @@ -492,15 +462,11 @@ operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) // Duration / -template <class _Rep1, class _Period, class _Rep2> +template <class _Rep1, class _Period, class _Rep2, + __enable_if_t<!__is_duration<_Rep2>::value && is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - !__is_duration<_Rep2>::value && - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type +duration<typename common_type<_Rep1, _Rep2>::type, _Period> operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; @@ -520,15 +486,11 @@ operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 // Duration % -template <class _Rep1, class _Period, class _Rep2> +template <class _Rep1, class _Period, class _Rep2, + __enable_if_t<!__is_duration<_Rep2>::value && is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - !__is_duration<_Rep2>::value && - is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, - duration<typename common_type<_Rep1, _Rep2>::type, _Period> ->::type +duration<typename common_type<_Rep1, _Rep2>::type, _Period> operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) { typedef typename common_type<_Rep1, _Rep2>::type _Cr; diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/time_point.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/time_point.h index c14835401f..741165bd3f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__chrono/time_point.h +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/time_point.h @@ -49,13 +49,9 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit time_point(const duration& __d) : __d_(__d) {} // conversions - template <class _Duration2> + template <class _Duration2, __enable_if_t<is_convertible<_Duration2, duration>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - time_point(const time_point<clock, _Duration2>& __t, - typename enable_if - < - is_convertible<_Duration2, duration>::value - >::type* = nullptr) + time_point(const time_point<clock, _Duration2>& __t) : __d_(__t.time_since_epoch()) {} // observer @@ -93,49 +89,33 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) } #if _LIBCPP_STD_VER >= 17 -template <class _ToDuration, class _Clock, class _Duration> +template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type +time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) { return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())}; } -template <class _ToDuration, class _Clock, class _Duration> +template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type +time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) { return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())}; } -template <class _ToDuration, class _Clock, class _Duration> +template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - __is_duration<_ToDuration>::value, - time_point<_Clock, _ToDuration> ->::type +time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) { return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())}; } -template <class _Rep, class _Period> +template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if -< - numeric_limits<_Rep>::is_signed, - duration<_Rep, _Period> ->::type +duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) { return __d >= __d.zero() ? +__d : -__d; diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h new file mode 100644 index 0000000000..bd7b05d478 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_TZDB_H +#define _LIBCPP___CHRONO_TZDB_H + +#include <version> +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) + +# include <string> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ + !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +namespace chrono { + +struct _LIBCPP_AVAILABILITY_TZDB tzdb { + string version; +}; + +} // namespace chrono + +# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +_LIBCPP_END_NAMESPACE_STD + +#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) + +#endif // _LIBCPP___CHRONO_TZDB_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h new file mode 100644 index 0000000000..0494826c01 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__chrono/tzdb_list.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#ifndef _LIBCPP___CHRONO_TZDB_LIST_H +#define _LIBCPP___CHRONO_TZDB_LIST_H + +#include <version> +// Enable the contents of the header only when libc++ was built with experimental features enabled. +#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) + +# include <__availability> +# include <__chrono/tzdb.h> +# include <forward_list> +# include <string_view> + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ + !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +namespace chrono { + +class _LIBCPP_AVAILABILITY_TZDB tzdb_list { +public: + _LIBCPP_EXPORTED_FROM_ABI explicit tzdb_list(tzdb&& __tzdb); + _LIBCPP_EXPORTED_FROM_ABI ~tzdb_list(); + + tzdb_list(const tzdb_list&) = delete; + tzdb_list& operator=(const tzdb_list&) = delete; + + using const_iterator = forward_list<tzdb>::const_iterator; + + _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const tzdb& front() const noexcept; + + _LIBCPP_EXPORTED_FROM_ABI const_iterator erase_after(const_iterator __p); + + _LIBCPP_EXPORTED_FROM_ABI tzdb& __emplace_front(tzdb&& __tzdb); + + _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator begin() const noexcept; + _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator end() const noexcept; + + _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator cbegin() const noexcept; + _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator cend() const noexcept; + +private: + class __impl; + __impl* __impl_; +}; + +_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list(); + +_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const tzdb& get_tzdb() { + return get_tzdb_list().front(); +} + +_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb(); + +_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version(); + +} // namespace chrono + +# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) + // && !defined(_LIBCPP_HAS_NO_LOCALIZATION) + +_LIBCPP_END_NAMESPACE_STD + +#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB) + +#endif // _LIBCPP___CHRONO_TZDB_LIST_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h b/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h index c348f0433a..c9a15efb3c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h +++ b/contrib/libs/cxxsupp/libcxx/include/__compare/ordering.h @@ -22,13 +22,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 20 // exposition only -enum class _LIBCPP_ENUM_VIS _OrdResult : signed char { +enum class _OrdResult : signed char { __less = -1, __equiv = 0, __greater = 1 }; -enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char { +enum class _NCmpResult : signed char { __unordered = -127 }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__condition_variable/condition_variable.h b/contrib/libs/cxxsupp/libcxx/include/__condition_variable/condition_variable.h index 7cbf21fe73..4d8e590e29 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__condition_variable/condition_variable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__condition_variable/condition_variable.h @@ -92,9 +92,8 @@ private: }; #endif // !_LIBCPP_HAS_NO_THREADS -template <class _Rep, class _Period> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<is_floating_point<_Rep>::value, chrono::nanoseconds> -__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { +template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { using namespace chrono; using __ratio = ratio_divide<_Period, nano>; using __ns_rep = nanoseconds::rep; @@ -113,9 +112,8 @@ __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { return nanoseconds(static_cast<__ns_rep>(__result_float)); } -template <class _Rep, class _Period> -inline _LIBCPP_HIDE_FROM_ABI __enable_if_t<!is_floating_point<_Rep>::value, chrono::nanoseconds> -__safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { +template <class _Rep, class _Period, __enable_if_t<!is_floating_point<_Rep>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) { using namespace chrono; if (__d.count() == 0) { return nanoseconds(0); diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config index ee3b3413f6..7b934651b4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config +++ b/contrib/libs/cxxsupp/libcxx/include/__config @@ -12,12 +12,6 @@ #include <__config_site> -#if defined(_MSC_VER) && !defined(__clang__) -# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -# endif -#endif - #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER # pragma GCC system_header #endif @@ -31,6 +25,7 @@ # define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__) #elif defined(__GNUC__) # define _LIBCPP_COMPILER_GCC +# define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__) #endif // Move outside #ifdef __cplusplus because this needs to work in both C and C++ headers. @@ -57,16 +52,36 @@ #ifdef __cplusplus +// Warn if a compiler version is used that is not supported anymore +// LLVM RELEASE Update the minimum compiler versions +# if defined(_LIBCPP_CLANG_VER) +# if _LIBCPP_CLANG_VER < 1500 +// we temporary allow old clang-s # warning "Libc++ only supports Clang 15 and later" +# endif +# elif defined(_LIBCPP_APPLE_CLANG_VER) +# if _LIBCPP_APPLE_CLANG_VER < 1500 +# warning "Libc++ only supports AppleClang 15 and later" +# endif +# elif defined(_LIBCPP_GCC_VER) +# if _LIBCPP_GCC_VER < 1300 +# warning "Libc++ only supports GCC 13 and later" +# endif +# endif + // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM. // Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is // defined to XXYYZZ. -# define _LIBCPP_VERSION 170006 +# define _LIBCPP_VERSION 180000 # define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y # define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y) +// Valid C++ identifier that revs with every libc++ version. This can be used to +// generate identifiers that must be unique for every released libc++ version. +# define _LIBCPP_VERSIONED_IDENTIFIER _LIBCPP_CONCAT(v, _LIBCPP_VERSION) + # if __STDC_HOSTED__ == 0 # define _LIBCPP_FREESTANDING # endif @@ -193,7 +208,7 @@ # endif // Feature macros for disabling pre ABI v1 features. All of these options // are deprecated. -# if defined(__FreeBSD__) +# if defined(__FreeBSD__) && __FreeBSD__ < 14 # define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR # endif // For XCOFF linkers, we have problems if we see a weak hidden version of a symbol @@ -231,25 +246,34 @@ // HARDENING { -# ifndef _LIBCPP_ENABLE_ASSERTIONS -# define _LIBCPP_ENABLE_ASSERTIONS _LIBCPP_ENABLE_ASSERTIONS_DEFAULT -# endif -# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 -# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" +// TODO(hardening): remove this in LLVM 19. +// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes) +// equivalent to setting the safe mode. +# ifdef _LIBCPP_ENABLE_ASSERTIONS +# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_ENABLE_SAFE_MODE instead." +# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1 +# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1" +# endif +# if _LIBCPP_ENABLE_ASSERTIONS +# define _LIBCPP_ENABLE_SAFE_MODE 1 +# endif # endif -// NOTE: These modes are experimental and are not stable yet in LLVM 17. Please refrain from using them and use the -// documented libc++ "safe" mode instead. -// // Enables the hardened mode which consists of all checks intended to be used in production. Hardened mode prioritizes // security-critical checks that can be done with relatively little overhead in constant time. Mutually exclusive with -// `_LIBCPP_ENABLE_DEBUG_MODE`. +// `_LIBCPP_ENABLE_SAFE_MODE` and `_LIBCPP_ENABLE_DEBUG_MODE`. // // #define _LIBCPP_ENABLE_HARDENED_MODE 1 +// Enables the safe mode which extends the hardened mode with checks that are relatively cheap and prevent common types +// of errors but are not security-critical. Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE` and +// `_LIBCPP_ENABLE_DEBUG_MODE`. +// +// #define _LIBCPP_ENABLE_SAFE_MODE 1 + // Enables the debug mode which contains all the checks from the hardened mode and additionally more expensive checks // that may affect the complexity of algorithms. The debug mode is intended to be used for testing, not in production. -// Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE`. +// Mutually exclusive with `_LIBCPP_ENABLE_HARDENED_MODE` and `_LIBCPP_ENABLE_SAFE_MODE`. // // #define _LIBCPP_ENABLE_DEBUG_MODE 1 @@ -284,6 +308,13 @@ # error "_LIBCPP_ENABLE_HARDENED_MODE must be set to 0 or 1." # endif +# ifndef _LIBCPP_ENABLE_SAFE_MODE +# define _LIBCPP_ENABLE_SAFE_MODE _LIBCPP_ENABLE_SAFE_MODE_DEFAULT +# endif +# if _LIBCPP_ENABLE_SAFE_MODE != 0 && _LIBCPP_ENABLE_SAFE_MODE != 1 +# error "_LIBCPP_ENABLE_SAFE_MODE must be set to 0 or 1." +# endif + # ifndef _LIBCPP_ENABLE_DEBUG_MODE # define _LIBCPP_ENABLE_DEBUG_MODE _LIBCPP_ENABLE_DEBUG_MODE_DEFAULT # endif @@ -291,18 +322,16 @@ # error "_LIBCPP_ENABLE_DEBUG_MODE must be set to 0 or 1." # endif -# if _LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_DEBUG_MODE -# error "Only one of _LIBCPP_ENABLE_HARDENED_MODE and _LIBCPP_ENABLE_DEBUG_MODE can be enabled." -# endif - -# if _LIBCPP_ENABLE_ASSERTIONS && (_LIBCPP_ENABLE_HARDENED_MODE || _LIBCPP_ENABLE_DEBUG_MODE) +# if (_LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_SAFE_MODE) || \ + (_LIBCPP_ENABLE_HARDENED_MODE && _LIBCPP_ENABLE_DEBUG_MODE) || \ + (_LIBCPP_ENABLE_SAFE_MODE && _LIBCPP_ENABLE_DEBUG_MODE) # error \ - "_LIBCPP_ENABLE_ASSERTIONS is mutually exclusive with _LIBCPP_ENABLE_HARDENED_MODE and _LIBCPP_ENABLE_DEBUG_MODE." + "Only one of _LIBCPP_ENABLE_HARDENED_MODE, _LIBCPP_ENABLE_SAFE_MODE and _LIBCPP_ENABLE_DEBUG_MODE can be enabled." # endif +// clang-format off // Hardened mode checks. -// clang-format off # if _LIBCPP_ENABLE_HARDENED_MODE // Enabled checks. @@ -316,21 +345,22 @@ # define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) # define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression) -// Debug mode checks. +// Safe mode checks. -# elif _LIBCPP_ENABLE_DEBUG_MODE +# elif _LIBCPP_ENABLE_SAFE_MODE -// All checks enabled. -# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) -# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) -# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) -# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) -# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message) -# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) +// Enabled checks. +# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) +# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message) +# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message) +# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message) +# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message) +// Disabled checks. +# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression) -// Safe mode checks. +// Debug mode checks. -# elif _LIBCPP_ENABLE_ASSERTIONS +# elif _LIBCPP_ENABLE_DEBUG_MODE // All checks enabled. # define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message) @@ -442,10 +472,8 @@ // easier to grep for target specific flags once the feature is complete. # if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_HAS_NO_INCOMPLETE_PSTL -# endif - -# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY) # define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN +# define _LIBCPP_HAS_NO_INCOMPLETE_TZDB # endif // Need to detect which libc we're using if we're on Linux. @@ -462,48 +490,19 @@ # include <features.h> // for __NATIVE_ASCII_F # endif -# ifdef __LITTLE_ENDIAN__ -# if __LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# endif // __LITTLE_ENDIAN__ -# endif // __LITTLE_ENDIAN__ - -# ifdef __BIG_ENDIAN__ -# if __BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BIG_ENDIAN__ -# endif // __BIG_ENDIAN__ - -# ifdef __BYTE_ORDER__ -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define _LIBCPP_LITTLE_ENDIAN -# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define _LIBCPP_BIG_ENDIAN -# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# endif // __BYTE_ORDER__ +# ifndef __BYTE_ORDER__ +# error \ + "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform" +# endif -# ifdef __FreeBSD__ -# include <osreldate.h> -# include <sys/endian.h> -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -# endif // __FreeBSD__ - -# if defined(__NetBSD__) || defined(__OpenBSD__) -# include <sys/endian.h> -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# else // _BYTE_ORDER == _LITTLE_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# endif // _BYTE_ORDER == _LITTLE_ENDIAN -# endif // defined(__NetBSD__) || defined(__OpenBSD__) +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +# define _LIBCPP_LITTLE_ENDIAN +# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +# define _LIBCPP_BIG_ENDIAN +# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # if defined(_WIN32) # define _LIBCPP_WIN32API -# define _LIBCPP_LITTLE_ENDIAN # define _LIBCPP_SHORT_WCHAR 1 // Both MinGW and native MSVC provide a "MSVC"-like environment # define _LIBCPP_MSVCRT_LIKE @@ -576,17 +575,6 @@ # define _LIBCPP_USING_DEV_RANDOM # endif -# if !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) -# include <endian.h> -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define _LIBCPP_LITTLE_ENDIAN -# elif __BYTE_ORDER == __BIG_ENDIAN -# define _LIBCPP_BIG_ENDIAN -# else // __BYTE_ORDER == __BIG_ENDIAN -# error unable to determine endian -# endif -# endif // !defined(_LIBCPP_LITTLE_ENDIAN) && !defined(_LIBCPP_BIG_ENDIAN) - # if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC) # define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi"))) # else @@ -722,7 +710,7 @@ typedef __char32_t char32_t; # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS # define _LIBCPP_TEMPLATE_VIS # define _LIBCPP_TEMPLATE_DATA_VIS -# define _LIBCPP_ENUM_VIS +# define _LIBCPP_TYPE_VISIBILITY_DEFAULT # else @@ -750,20 +738,17 @@ typedef __char32_t char32_t; # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS # endif -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# if __has_attribute(__type_visibility__) -# define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) -# else -# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) -# endif +// GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates +# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__) +# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default"))) # else # define _LIBCPP_TEMPLATE_VIS # endif # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) -# define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) +# define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default"))) # else -# define _LIBCPP_ENUM_VIS +# define _LIBCPP_TYPE_VISIBILITY_DEFAULT # endif # endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) @@ -777,54 +762,22 @@ typedef __char32_t char32_t; # define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE # endif -# if _LIBCPP_ENABLE_HARDENED_MODE -# define _LIBCPP_HARDENING_SIG h -# elif _LIBCPP_ENABLE_ASSERTIONS -# define _LIBCPP_HARDENING_SIG s -# elif _LIBCPP_ENABLE_DEBUG_MODE -# define _LIBCPP_HARDENING_SIG d -# else -# define _LIBCPP_HARDENING_SIG u // for unchecked -# endif - -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS -# define _LIBCPP_EXCEPTIONS_SIG n -# else -# define _LIBCPP_EXCEPTIONS_SIG e -# endif - -# define _LIBCPP_ODR_SIGNATURE \ - _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION) - // This macro marks a symbol as being hidden from libc++'s ABI. This is achieved // on two levels: // 1. The symbol is given hidden visibility, which ensures that users won't start exporting // symbols from their dynamic library by means of using the libc++ headers. This ensures // that those symbols stay private to the dynamic library in which it is defined. // -// 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library. -// This ensures that no ODR violation can arise from mixing two TUs compiled with different -// versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the -// program contains two definitions of a function, the ODR requires them to be token-by-token -// equivalent, and the linker is allowed to pick either definition and discard the other one. -// -// For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled -// *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs -// compiled with different settings), the two definitions are both visible by the linker and they -// have the same name, but they have a meaningfully different implementation (one throws an exception -// and the other aborts the program). This violates the ODR and makes the program ill-formed, and in -// practice what will happen is that the linker will pick one of the definitions at random and will -// discard the other one. This can quite clearly lead to incorrect program behavior. -// -// A similar reasoning holds for many other properties that are ODR-affecting. Essentially any -// property that causes the code of a function to differ from the code in another configuration -// can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI -// tag, but we encode the ones that we think are most important: library version, exceptions, and -// hardening mode. -// -// Note that historically, solving this problem has been achieved in various ways, including -// force-inlining all functions or giving internal linkage to all functions. Both these previous -// solutions suffer from drawbacks that lead notably to code bloat. +// 2. The symbol is given an ABI tag that changes with each version of libc++. This ensures +// that no ODR violation can arise from mixing two TUs compiled with different versions +// of libc++ where we would have changed the definition of a symbol. If the symbols shared +// the same name, the ODR would require that their definitions be token-by-token equivalent, +// which basically prevents us from being able to make any change to any function in our +// headers. Using this ABI tag ensures that the symbol name is "bumped" artificially at +// each release, which lets us change the definition of these symbols at our leisure. +// Note that historically, this has been achieved in various ways, including force-inlining +// all functions or giving internal linkage to all functions. Both these (previous) solutions +// suffer from drawbacks that lead notably to code bloat. // // Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend // on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library. @@ -844,7 +797,7 @@ typedef __char32_t char32_t; # if !defined(_LIBCPP_NO_ABI_TAG) && !defined(__CUDACC__) # define _LIBCPP_HIDE_FROM_ABI \ _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ - __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))) + __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER)))) # else # define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION # endif @@ -869,7 +822,8 @@ typedef __char32_t char32_t; // Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect. // clang-format off -# define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { inline namespace _LIBCPP_ABI_NAMESPACE { +# define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \ + inline namespace _LIBCPP_ABI_NAMESPACE { # define _LIBCPP_END_NAMESPACE_STD }} # define _VSTD std @@ -922,7 +876,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD // clang-format on # else // _LIBCPP_CXX03_LANG -# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class _LIBCPP_ENUM_VIS x +# define _LIBCPP_DECLARE_STRONG_ENUM(x) enum class x # define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) # endif // _LIBCPP_CXX03_LANG @@ -1537,6 +1491,16 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c # define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \ _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig)) +# elif defined(_LIBCPP_COMPILER_CLANG_BASED) + +# define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)") +# define _PSTL_PRAGMA_DECLARE_SIMD +# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)") +# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)") +# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) +# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) +# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) + # else // (defined(_OPENMP) && _OPENMP >= 201307) # define _PSTL_PRAGMA_SIMD diff --git a/contrib/libs/cxxsupp/libcxx/include/__exception/exception.h b/contrib/libs/cxxsupp/libcxx/include/__exception/exception.h index 3db0126da2..e724e1b99b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__exception/exception.h +++ b/contrib/libs/cxxsupp/libcxx/include/__exception/exception.h @@ -72,7 +72,8 @@ public: class _LIBCPP_EXPORTED_FROM_ABI exception { public: _LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {} - _LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default; virtual ~exception() _NOEXCEPT; virtual const char* what() const _NOEXCEPT; @@ -81,6 +82,8 @@ public: class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception { public: _LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {} + _LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default; ~bad_exception() _NOEXCEPT override; const char* what() const _NOEXCEPT override; }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h b/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h index 1136c92748..769da191aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h +++ b/contrib/libs/cxxsupp/libcxx/include/__exception/nested_exception.h @@ -33,8 +33,8 @@ class _LIBCPP_EXPORTED_FROM_ABI nested_exception { public: nested_exception() _NOEXCEPT; - // nested_exception(const nested_exception&) noexcept = default; - // nested_exception& operator=(const nested_exception&) noexcept = default; + _LIBCPP_HIDE_FROM_ABI nested_exception(const nested_exception&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI nested_exception& operator=(const nested_exception&) _NOEXCEPT = default; virtual ~nested_exception() _NOEXCEPT; // access functions diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/copy_options.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/copy_options.h index 11962e494c..bc99d55d49 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/copy_options.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/copy_options.h @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM -enum class _LIBCPP_ENUM_VIS copy_options : unsigned short { +enum class copy_options : unsigned short { none = 0, skip_existing = 1, overwrite_existing = 2, diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_options.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_options.h index 4c323ccb0c..699412fbe4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_options.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/directory_options.h @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM -enum class _LIBCPP_ENUM_VIS directory_options : unsigned char { +enum class directory_options : unsigned char { none = 0, follow_directory_symlink = 1, skip_permission_denied = 2 diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/file_type.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/file_type.h index c756a05c84..70ea765d99 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/file_type.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/file_type.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM // On Windows, the library never identifies files as block, character, fifo // or socket. -enum class _LIBCPP_ENUM_VIS file_type : signed char { +enum class file_type : signed char { none = 0, not_found = -1, regular = 1, diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h index 77699c5ae4..c104b00357 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/path.h @@ -76,9 +76,9 @@ struct __can_convert_char<char32_t> { using __char_type = char32_t; }; -template <class _ECharT> +template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI -typename enable_if<__can_convert_char<_ECharT>::value, bool>::type +bool __is_separator(_ECharT __e) { #if defined(_LIBCPP_WIN32API) return __e == _ECharT('/') || __e == _ECharT('\\'); @@ -305,17 +305,17 @@ struct _PathCVT { template <> struct _PathCVT<__path_value> { - template <class _Iter> + template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI - static typename enable_if<__has_exactly_input_iterator_category<_Iter>::value>::type + static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { for (; __b != __e; ++__b) __dest.push_back(*__b); } - template <class _Iter> + template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI - static typename enable_if<__has_forward_iterator_category<_Iter>::value>::type + static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { __dest.append(__b, __e); } @@ -350,17 +350,17 @@ struct _PathCVT<char> { __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size); } - template <class _Iter> + template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI - static typename enable_if<__has_exactly_input_iterator_category<_Iter>::value>::type + static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { basic_string<char> __tmp(__b, __e); __append_string(__dest, __tmp); } - template <class _Iter> + template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI - static typename enable_if<__has_forward_iterator_category<_Iter>::value>::type + static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) { basic_string<char> __tmp(__b, __e); __append_string(__dest, __tmp); @@ -445,8 +445,7 @@ struct _PathExport<char8_t> { class _LIBCPP_EXPORTED_FROM_ABI path { template <class _SourceOrIter, class _Tp = path&> - using _EnableIfPathable = - typename enable_if<__is_pathable<_SourceOrIter>::value, _Tp>::type; + using _EnableIfPathable = __enable_if_t<__is_pathable<_SourceOrIter>::value, _Tp>; template <class _Tp> using _SourceChar = typename __is_pathable<_Tp>::__char_type; @@ -465,7 +464,7 @@ public: typedef basic_string<value_type> string_type; typedef basic_string_view<value_type> __string_view; - enum _LIBCPP_ENUM_VIS format : unsigned char { + enum format : unsigned char { auto_format, native_format, generic_format @@ -678,9 +677,9 @@ public: return *this; } - template <class _ECharT> + template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI - typename enable_if<__can_convert_char<_ECharT>::value, path&>::type + path& operator+=(_ECharT __x) { _PathCVT<_ECharT>::__append_source(__pn_, basic_string_view<_ECharT>(&__x, 1)); @@ -1040,21 +1039,19 @@ public: iterator end() const; #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) - template <class _CharT, class _Traits> + template <class _CharT, class _Traits, __enable_if_t<is_same<_CharT, value_type>::value && + is_same<_Traits, char_traits<value_type> >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI friend - typename enable_if<is_same<_CharT, value_type>::value && - is_same<_Traits, char_traits<value_type> >::value, - basic_ostream<_CharT, _Traits>&>::type + basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { __os << _VSTD::__quoted(__p.native()); return __os; } - template <class _CharT, class _Traits> + template <class _CharT, class _Traits, __enable_if_t<!is_same<_CharT, value_type>::value || + !is_same<_Traits, char_traits<value_type> >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI friend - typename enable_if<!is_same<_CharT, value_type>::value || - !is_same<_Traits, char_traits<value_type> >::value, - basic_ostream<_CharT, _Traits>&>::type + basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) { __os << _VSTD::__quoted(__p.string<_CharT, _Traits>()); return __os; @@ -1071,8 +1068,7 @@ public: #endif // !_LIBCPP_HAS_NO_LOCALIZATION private: - inline _LIBCPP_HIDE_FROM_ABI path& - __assign_view(__string_view const& __s) noexcept { + inline _LIBCPP_HIDE_FROM_ABI path& __assign_view(__string_view const& __s) { __pn_ = string_type(__s); return *this; } diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/perm_options.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/perm_options.h index e77af9ef97..82b73a7f77 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/perm_options.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/perm_options.h @@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM -enum class _LIBCPP_ENUM_VIS perm_options : unsigned char { +enum class perm_options : unsigned char { replace = 1, add = 2, remove = 4, diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/perms.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/perms.h index 77bc652103..f2b5dfaae9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/perms.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/perms.h @@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM // file, and the executable bit is always returned as set. When setting // permissions, as long as the write bit is set for either owner, group or // others, the readonly flag is cleared. -enum class _LIBCPP_ENUM_VIS perms : unsigned { +enum class perms : unsigned { none = 0, owner_read = 0400, diff --git a/contrib/libs/cxxsupp/libcxx/include/__filesystem/u8path.h b/contrib/libs/cxxsupp/libcxx/include/__filesystem/u8path.h index 90b879aec2..1db60c3960 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__filesystem/u8path.h +++ b/contrib/libs/cxxsupp/libcxx/include/__filesystem/u8path.h @@ -32,9 +32,9 @@ _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH -template <class _InputIt> +template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T - typename enable_if<__is_pathable<_InputIt>::value, path>::type + path u8path(_InputIt __f, _InputIt __l) { static_assert( #ifndef _LIBCPP_HAS_NO_CHAR8_T @@ -56,9 +56,9 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T } #if defined(_LIBCPP_WIN32API) -template <class _InputIt> +template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T - typename enable_if<__is_pathable<_InputIt>::value, path>::type + path u8path(_InputIt __f, _NullSentinel) { static_assert( #ifndef _LIBCPP_HAS_NO_CHAR8_T @@ -79,9 +79,9 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T } #endif /* _LIBCPP_WIN32API */ -template <class _Source> +template <class _Source, __enable_if_t<__is_pathable<_Source>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T - typename enable_if<__is_pathable<_Source>::value, path>::type + path u8path(const _Source& __s) { static_assert( #ifndef _LIBCPP_HAS_NO_CHAR8_T diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h b/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h index 45f9da8017..c0502971ce 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h @@ -95,7 +95,7 @@ public: _LIBCPP_HIDE_FROM_ABI void __copy(basic_string_view<_InCharT> __str) { // When the underlying iterator is a simple iterator the __capacity_ is // infinite. For a string or container back_inserter it isn't. This means - // adding a large string the the buffer can cause some overhead. In that + // that adding a large string to the buffer can cause some overhead. In that // case a better approach could be: // - flush the buffer // - container.append(__str.begin(), __str.end()); diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h index 5cbfe81234..ca06107f55 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h @@ -53,7 +53,7 @@ namespace __format { /// handle to satisfy the user observable behaviour. The internal function /// __visit_format_arg doesn't do this wrapping. So in the format functions /// this function is used to avoid unneeded overhead. -enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { +enum class __arg_t : uint8_t { __none, __boolean, __char_type, diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h index f22cb0b81e..51d6c58230 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_error.h @@ -30,6 +30,8 @@ public: : runtime_error(__s) {} _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s) : runtime_error(__s) {} + _LIBCPP_HIDE_FROM_ABI format_error(const format_error&) = default; + _LIBCPP_HIDE_FROM_ABI format_error& operator=(const format_error&) = default; _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~format_error() noexcept override = default; }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h index c01e5866a4..e79fc8fc48 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h @@ -176,7 +176,7 @@ inline constexpr __fields __fields_range{.__use_range_fill_ = true, .__clear_bra inline constexpr __fields __fields_fill_align_width{}; # endif -enum class _LIBCPP_ENUM_VIS __alignment : uint8_t { +enum class __alignment : uint8_t { /// No alignment is set in the format string. __default, __left, @@ -185,7 +185,7 @@ enum class _LIBCPP_ENUM_VIS __alignment : uint8_t { __zero_padding }; -enum class _LIBCPP_ENUM_VIS __sign : uint8_t { +enum class __sign : uint8_t { /// No sign is set in the format string. /// /// The sign isn't allowed for certain format-types. By using this value @@ -197,7 +197,7 @@ enum class _LIBCPP_ENUM_VIS __sign : uint8_t { __space }; -enum class _LIBCPP_ENUM_VIS __type : uint8_t { +enum class __type : uint8_t { __default = 0, __string, __binary_lower_case, diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h b/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h index bcab5d6afd..b35223ae93 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/range_default_formatter.h @@ -24,6 +24,7 @@ #include <__iterator/back_insert_iterator.h> #include <__ranges/concepts.h> #include <__ranges/data.h> +#include <__ranges/from_range.h> #include <__ranges/size.h> #include <__type_traits/conditional.h> #include <__type_traits/remove_cvref.h> @@ -197,15 +198,8 @@ public: // specialization is the "basic" string formatter in libc++. if constexpr (ranges::contiguous_range<_Rp> && std::ranges::sized_range<_Rp>) return __underlying_.format(basic_string_view<_CharT>{ranges::data(__range), ranges::size(__range)}, __ctx); - else { - // P2106's from_range has not been implemented yet. Instead use a simple - // copy operation. - // TODO FMT use basic_string's "from_range" constructor. - // return __underlying_.format(basic_string<_CharT>{from_range, __range}, __ctx); - basic_string<_CharT> __str; - std::ranges::copy(__range, back_insert_iterator{__str}); - return __underlying_.format(static_cast<basic_string_view<_CharT>>(__str), __ctx); - } + else + return __underlying_.format(basic_string<_CharT>{from_range, __range}, __ctx); } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h b/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h index 27870972c9..d13278009f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/range_formatter.h @@ -28,6 +28,7 @@ #include <__iterator/back_insert_iterator.h> #include <__ranges/concepts.h> #include <__ranges/data.h> +#include <__ranges/from_range.h> #include <__ranges/size.h> #include <__type_traits/remove_cvref.h> #include <string_view> @@ -184,13 +185,7 @@ struct _LIBCPP_TEMPLATE_VIS range_formatter { std::formatter<basic_string<_CharT>, _CharT> __formatter; if (__debug_format) __formatter.set_debug_format(); - // P2106's from_range has not been implemented yet. Instead use a simple - // copy operation. - // TODO FMT use basic_string's "from_range" constructor. - // return std::formatter<basic_string<_CharT>, _CharT>{}.format(basic_string<_CharT>{from_range, __range}, __ctx); - basic_string<_CharT> __str; - ranges::copy(__range, back_insert_iterator{__str}); - return __formatter.format(__str, __ctx); + return __formatter.format(basic_string<_CharT>{from_range, __range}, __ctx); } } diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h b/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h index 8c51d0b1f1..e415fc5f05 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/write_escaped.h @@ -118,7 +118,7 @@ template <class _CharT> return static_cast<make_unsigned_t<_CharT>>(__value); } -enum class _LIBCPP_ENUM_VIS __escape_quotation_mark { __apostrophe, __double_quote }; +enum class __escape_quotation_mark { __apostrophe, __double_quote }; // [format.string.escaped]/2 template <class _CharT> diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h b/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h index 69b13df8ab..c91cfc14fb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h @@ -98,13 +98,9 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); } -template <class _Ti, class ..._Uj> +template <class _Ti, class ..._Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename __enable_if_t -< - is_bind_expression<_Ti>::value, - __invoke_of<_Ti&, _Uj...> ->::type +typename __invoke_of<_Ti&, _Uj...>::type __mu(_Ti& __ti, tuple<_Uj...>& __uj) { typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices; @@ -120,28 +116,20 @@ struct __mu_return2<true, _Ti, _Uj> typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type; }; -template <class _Ti, class _Uj> +template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - 0 < is_placeholder<_Ti>::value, - typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type ->::type +typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type __mu(_Ti&, _Uj& __uj) { const size_t __indx = is_placeholder<_Ti>::value - 1; return _VSTD::forward<typename tuple_element<__indx, _Uj>::type>(_VSTD::get<__indx>(__uj)); } -template <class _Ti, class _Uj> +template <class _Ti, class _Uj, __enable_if_t<!is_bind_expression<_Ti>::value && + is_placeholder<_Ti>::value == 0 && + !__is_reference_wrapper<_Ti>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - !is_bind_expression<_Ti>::value && - is_placeholder<_Ti>::value == 0 && - !__is_reference_wrapper<_Ti>::value, - _Ti& ->::type +_Ti& __mu(_Ti& __ti, _Uj&) { return __ti; @@ -273,12 +261,7 @@ private: typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices; public: template <class _Gp, class ..._BA, - class = typename enable_if - < - is_constructible<_Fd, _Gp>::value && - !is_same<__libcpp_remove_reference_t<_Gp>, - __bind>::value - >::type> + __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind(_Gp&& __f, _BA&& ...__bound_args) : __f_(_VSTD::forward<_Gp>(__f)), @@ -326,39 +309,26 @@ public: template <class _Gp, class ..._BA, - class = typename enable_if - < - is_constructible<_Fd, _Gp>::value && - !is_same<__libcpp_remove_reference_t<_Gp>, - __bind_r>::value - >::type> + __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind_r>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) : base(_VSTD::forward<_Gp>(__f), _VSTD::forward<_BA>(__bound_args)...) {} - template <class ..._Args> + template <class ..._Args, __enable_if_t<is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, + result_type>::value || is_void<_Rp>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - typename enable_if - < - is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, - result_type>::value || is_void<_Rp>::value, - result_type - >::type + result_type operator()(_Args&& ...__args) { typedef __invoke_void_return_wrapper<_Rp> _Invoker; return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...); } - template <class ..._Args> + template <class ..._Args, __enable_if_t<is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, + result_type>::value || is_void<_Rp>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - typename enable_if - < - is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type, - result_type>::value || is_void<_Rp>::value, - result_type - >::type + result_type operator()(_Args&& ...__args) const { typedef __invoke_void_return_wrapper<_Rp> _Invoker; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h b/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h index 71dc63c86b..0dd2befb52 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h @@ -43,14 +43,9 @@ struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs> using __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs>::__perfect_forward; }; -template <class _Fn, class ..._Args, class = enable_if_t< - _And< - is_constructible<decay_t<_Fn>, _Fn>, - is_move_constructible<decay_t<_Fn>>, - is_constructible<decay_t<_Args>, _Args>..., - is_move_constructible<decay_t<_Args>>... - >::value ->> +template <class _Fn, class... _Args> + requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> && + (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...) _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) noexcept(noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)))) diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/bind_front.h b/contrib/libs/cxxsupp/libcxx/include/__functional/bind_front.h index 72bb664809..7ccd6e563b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/bind_front.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/bind_front.h @@ -42,14 +42,9 @@ struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> { using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward; }; -template <class _Fn, class... _Args, class = enable_if_t< - _And< - is_constructible<decay_t<_Fn>, _Fn>, - is_move_constructible<decay_t<_Fn>>, - is_constructible<decay_t<_Args>, _Args>..., - is_move_constructible<decay_t<_Args>>... - >::value ->> +template <class _Fn, class... _Args> + requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> && + (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...) _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) { return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/function.h index 3c6e3f450d..580dcf9aee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/function.h @@ -57,6 +57,9 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception { public: + _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_function_call(const bad_function_call&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_function_call& operator=(const bad_function_call&) _NOEXCEPT = default; // Note that when a key function is not used, every translation unit that uses // bad_function_call will end up containing a weak definition of the vtable and // typeinfo. @@ -433,8 +436,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)> } } - template <class _Fp, - class = typename enable_if<!is_same<__decay_t<_Fp>, __value_func>::value>::type> + template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f) : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {} @@ -778,7 +780,7 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)> } } - template <class _Fp, class = typename enable_if<!is_same<__decay_t<_Fp>, __policy_func>::value>::type> + template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) { typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun; @@ -1002,7 +1004,7 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> }; template <class _Fp> - using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type; + using _EnableIfLValueCallable = __enable_if_t<__callable<_Fp&>::value>; public: typedef _Rp result_type; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h b/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h index fa09748b14..87307f7f99 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h @@ -673,7 +673,7 @@ using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type; template <class _Type, class ..._Keys> using __enable_hash_helper _LIBCPP_NODEBUG = __enable_hash_helper_imp<_Type, - typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type + __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >; #else template <class _Type, class ...> diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/bit_reference.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/bit_reference.h new file mode 100644 index 0000000000..237efb6db6 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/bit_reference.h @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___FWD_BIT_REFERENCE_H +#define _LIBCPP___FWD_BIT_REFERENCE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0> +class __bit_iterator; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FWD_BIT_REFERENCE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h index 8f7239247e..24db670575 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__fwd/subrange.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -enum class _LIBCPP_ENUM_VIS subrange_kind : bool { unsized, sized }; +enum class subrange_kind : bool { unsized, sized }; template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind> requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>) diff --git a/contrib/libs/cxxsupp/libcxx/include/__hash_table b/contrib/libs/cxxsupp/libcxx/include/__hash_table index 2ae7afdc10..1732c82178 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__hash_table +++ b/contrib/libs/cxxsupp/libcxx/include/__hash_table @@ -21,6 +21,7 @@ #include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> +#include <__memory/construct_at.h> #include <__memory/pointer_traits.h> #include <__memory/swap_allocator.h> #include <__memory/unique_ptr.h> @@ -45,6 +46,7 @@ #include <cmath> #include <cstring> #include <initializer_list> +#include <new> // __launder #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -107,19 +109,44 @@ struct __hash_node_base } _LIBCPP_INLINE_VISIBILITY __hash_node_base() _NOEXCEPT : __next_(nullptr) {} + _LIBCPP_HIDE_FROM_ABI explicit __hash_node_base(__next_pointer __next) _NOEXCEPT : __next_(__next) {} }; template <class _Tp, class _VoidPtr> -struct _LIBCPP_STANDALONE_DEBUG __hash_node +struct __hash_node : public __hash_node_base < __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > { typedef _Tp __node_value_type; + using _Base = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >; + using __next_pointer = typename _Base::__next_pointer; size_t __hash_; - __node_value_type __value_; + + // We allow starting the lifetime of nodes without initializing the value held by the node, + // since that is handled by the hash table itself in order to be allocator-aware. +#ifndef _LIBCPP_CXX03_LANG +private: + union { + _Tp __value_; + }; + +public: + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } +#else +private: + _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; + +public: + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { + return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); + } +#endif + + _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {} + _LIBCPP_HIDE_FROM_ABI ~__hash_node() {} }; inline _LIBCPP_INLINE_VISIBILITY @@ -194,16 +221,16 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { return __v.first; } - template <class _Up> + template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - static __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, __container_value_type const&> + static __container_value_type const& __get_value(_Up& __t) { return __t.__get_value(); } - template <class _Up> + template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, __container_value_type const&> + static __container_value_type const& __get_value(_Up& __t) { return __t; } @@ -311,12 +338,12 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __node_->__upcast()->__value_; + return __node_->__upcast()->__get_value(); } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_); + return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -387,11 +414,11 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __node_->__upcast()->__value_; + return __node_->__upcast()->__get_value(); } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_); + return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -453,12 +480,12 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __node_->__upcast()->__value_; + return __node_->__upcast()->__get_value(); } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_); + return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -543,12 +570,12 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __node_->__upcast()->__value_; + return __node_->__upcast()->__get_value(); } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__value_); + return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -670,8 +697,10 @@ public: _LIBCPP_INLINE_VISIBILITY void operator()(pointer __p) _NOEXCEPT { - if (__value_constructed) - __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_)); + if (__value_constructed) { + __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__get_value())); + std::__destroy_at(std::addressof(*__p)); + } if (__p) __alloc_traits::deallocate(__na_, __p, 1); } @@ -904,9 +933,10 @@ public: __can_extract_key<_Pp, key_type>()); } - template <class _First, class _Second> + template <class _First, class _Second, + __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> > + pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) { return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), _VSTD::forward<_Second>(__s)); @@ -1364,7 +1394,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) { __next_pointer __next = __np->__next_; __node_pointer __real_np = __np->__upcast(); - __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__value_)); + __node_traits::destroy(__na, _NodeTypes::__get_ptr(__real_np->__get_value())); + std::__destroy_at(std::addressof(*__real_np)); __node_traits::deallocate(__na, __real_np, 1); __np = __next; } @@ -1433,8 +1464,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( const_iterator __i = __u.begin(); while (__cache != nullptr && __u.size() != 0) { - __cache->__upcast()->__value_ = - _VSTD::move(__u.remove(__i++)->__value_); + __cache->__upcast()->__get_value() = + _VSTD::move(__u.remove(__i++)->__get_value()); __next_pointer __next = __cache->__next_; __node_insert_multi(__cache->__upcast()); __cache = __next; @@ -1452,7 +1483,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( const_iterator __i = __u.begin(); while (__u.size() != 0) { - __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__value_)); + __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__get_value())); __node_insert_multi(__h.get()); __h.release(); } @@ -1494,7 +1525,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { - __cache->__upcast()->__value_ = *__first; + __cache->__upcast()->__get_value() = *__first; __next_pointer __next = __cache->__next_; __node_insert_unique(__cache->__upcast()); __cache = __next; @@ -1534,7 +1565,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { - __cache->__upcast()->__value_ = *__first; + __cache->__upcast()->__get_value() = *__first; __next_pointer __next = __cache->__next_; __node_insert_multi(__cache->__upcast()); __cache = __next; @@ -1628,7 +1659,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare( __ndptr = __ndptr->__next_) { if ((__ndptr->__hash() == __hash) && - key_eq()(__ndptr->__upcast()->__value_, __value)) + key_eq()(__ndptr->__upcast()->__get_value(), __value)) return __ndptr; } } @@ -1677,9 +1708,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> pair<typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __nd) { - __nd->__hash_ = hash_function()(__nd->__value_); + __nd->__hash_ = hash_function()(__nd->__get_value()); __next_pointer __existing_node = - __node_insert_unique_prepare(__nd->__hash(), __nd->__value_); + __node_insert_unique_prepare(__nd->__hash(), __nd->__get_value()); // Insert the node, unless it already exists in the container. bool __inserted = false; @@ -1725,7 +1756,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare( // false true set __found to true // true false break if (__found != (__pn->__next_->__hash() == __cp_hash && - key_eq()(__pn->__next_->__upcast()->__value_, __cp_val))) + key_eq()(__pn->__next_->__upcast()->__get_value(), __cp_val))) { if (!__found) __found = true; @@ -1779,8 +1810,8 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __cp) { - __cp->__hash_ = hash_function()(__cp->__value_); - __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_); + __cp->__hash_ = hash_function()(__cp->__get_value()); + __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__get_value()); __node_insert_multi_perform(__cp, __pn); return iterator(__cp->__ptr()); @@ -1791,7 +1822,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( const_iterator __p, __node_pointer __cp) { - if (__p != end() && key_eq()(*__p, __cp->__value_)) + if (__p != end() && key_eq()(*__p, __cp->__get_value())) { __next_pointer __np = __p.__node_; __cp->__hash_ = __np->__hash(); @@ -1838,7 +1869,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __nd = __nd->__next_) { if ((__nd->__hash() == __hash) && - key_eq()(__nd->__upcast()->__value_, __k)) + key_eq()(__nd->__upcast()->__get_value(), __k)) goto __done; } } @@ -1982,9 +2013,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_unique( __it != __source.end();) { __node_pointer __src_ptr = __it.__node_->__upcast(); - size_t __hash = hash_function()(__src_ptr->__value_); + size_t __hash = hash_function()(__src_ptr->__get_value()); __next_pointer __existing_node = - __node_insert_unique_prepare(__hash, __src_ptr->__value_); + __node_insert_unique_prepare(__hash, __src_ptr->__get_value()); auto __prev_iter = __it++; if (__existing_node == nullptr) { @@ -2036,9 +2067,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi( __it != __source.end();) { __node_pointer __src_ptr = __it.__node_->__upcast(); - size_t __src_hash = hash_function()(__src_ptr->__value_); + size_t __src_hash = hash_function()(__src_ptr->__get_value()); __next_pointer __pn = - __node_insert_multi_prepare(__src_hash, __src_ptr->__value_); + __node_insert_multi_prepare(__src_hash, __src_ptr->__get_value()); (void)__source.remove(__it++).release(); __src_ptr->__hash_ = __src_hash; __node_insert_multi_perform(__src_ptr, __pn); @@ -2112,8 +2143,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__do_rehash(size_type __nbc) if _LIBCPP_CONSTEXPR_SINCE_CXX17 (!_UniqueKeys) { for (; __np->__next_ != nullptr && - key_eq()(__cp->__upcast()->__value_, - __np->__next_->__upcast()->__value_); + key_eq()(__cp->__upcast()->__get_value(), + __np->__next_->__upcast()->__get_value()); __np = __np->__next_) ; } @@ -2147,7 +2178,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) __nd = __nd->__next_) { if ((__nd->__hash() == __hash) - && key_eq()(__nd->__upcast()->__value_, __k)) + && key_eq()(__nd->__upcast()->__get_value(), __k)) return iterator(__nd); } } @@ -2174,7 +2205,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const __nd = __nd->__next_) { if ((__nd->__hash() == __hash) - && key_eq()(__nd->__upcast()->__value_, __k)) + && key_eq()(__nd->__upcast()->__get_value(), __k)) return const_iterator(__nd); } } @@ -2192,10 +2223,20 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args) "Construct cannot be called with a hash value type"); __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), _VSTD::forward<_Args>(__args)...); + + // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value + // held inside the node, since we need to use the allocator's construct() method for that. + // + // We don't use the allocator's construct() method to construct the node itself since the + // Cpp17FooInsertable named requirements don't require the allocator's construct() method + // to work on anything other than the value_type. + std::__construct_at(std::addressof(*__h), /* next = */nullptr, /* hash = */0); + + // Now construct the value_type using the allocator's construct() method. + __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__get_value()), _VSTD::forward<_Args>(__args)...); __h.get_deleter().__value_constructed = true; - __h->__hash_ = hash_function()(__h->__value_); - __h->__next_ = nullptr; + + __h->__hash_ = hash_function()(__h->__get_value()); return __h; } @@ -2209,12 +2250,11 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash( "Construct cannot be called with a hash value type"); __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), + std::__construct_at(std::addressof(*__h), /* next = */nullptr, /* hash = */__hash); + __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__get_value()), _VSTD::forward<_First>(__f), _VSTD::forward<_Rest>(__rest)...); __h.get_deleter().__value_constructed = true; - __h->__hash_ = __hash; - __h->__next_ = nullptr; return __h; } diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h index dd9e8d6ac5..d317273a7b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/concepts.h @@ -295,6 +295,14 @@ concept indirectly_copyable_storable = #endif // _LIBCPP_STD_VER >= 20 +template <class _Tp> +using __has_random_access_iterator_category_or_concept +#if _LIBCPP_STD_VER >= 20 + = integral_constant<bool, random_access_iterator<_Tp>>; +#else // _LIBCPP_STD_VER < 20 + = __has_random_access_iterator_category<_Tp>; +#endif // _LIBCPP_STD_VER + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___ITERATOR_CONCEPTS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h index 07fcd56509..e1d3f43903 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h @@ -24,9 +24,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _InputIter> +template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 - typename enable_if<__has_input_iterator_category<_InputIter>::value, _InputIter>::type + _InputIter next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { _LIBCPP_ASSERT_UNCATEGORIZED(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value, "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h index 2406558a15..3821b32390 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h @@ -24,9 +24,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _InputIter> +template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 - typename enable_if<__has_input_iterator_category<_InputIter>::value, _InputIter>::type + _InputIter prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { _LIBCPP_ASSERT_UNCATEGORIZED(__n <= 0 || __has_bidirectional_iterator_category<_InputIter>::value, "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h index e74e56d6fb..463d07b0d3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/projected.h @@ -12,7 +12,7 @@ #include <__config> #include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> +#include <__iterator/incrementable_traits.h> // iter_difference_t #include <__type_traits/remove_cvref.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -23,17 +23,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 20 -template<indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> -struct projected { - using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; - indirect_result_t<_Proj&, _It> operator*() const; // not defined +template <class _It, class _Proj> +struct __projected_impl { + struct __type { + using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; + indirect_result_t<_Proj&, _It> operator*() const; // not defined + }; }; -template<weakly_incrementable _It, class _Proj> -struct incrementable_traits<projected<_It, _Proj>> { - using difference_type = iter_difference_t<_It>; +template <weakly_incrementable _It, class _Proj> +struct __projected_impl<_It, _Proj> { + struct __type { + using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>; + using difference_type = iter_difference_t<_It>; + indirect_result_t<_Proj&, _It> operator*() const; // not defined + }; }; +// Note that we implement std::projected in a way that satisfies P2538R1 even in standard +// modes before C++26 to avoid breaking the ABI between standard modes (even though ABI +// breaks with std::projected are expected to have essentially no impact). +template <indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj> +using projected = typename __projected_impl<_It, _Proj>::__type; + #endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h index 774276baa8..8cab2179cf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/wrap_iter.h @@ -45,9 +45,8 @@ public: : __i_() { } - template <class _Up> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 - __wrap_iter(const __wrap_iter<_Up>& __u, - typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = nullptr) _NOEXCEPT + template <class _Up, __enable_if_t<is_convertible<_Up, iterator_type>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_Up>& __u) _NOEXCEPT : __i_(__u.base()) { } diff --git a/contrib/libs/cxxsupp/libcxx/include/__locale b/contrib/libs/cxxsupp/libcxx/include/__locale index d28ad50099..538bf7abe3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__locale +++ b/contrib/libs/cxxsupp/libcxx/include/__locale @@ -13,13 +13,13 @@ #include <__availability> #include <__config> #include <__memory/shared_ptr.h> // __shared_count +#include <__mutex/once_flag.h> #include <__type_traits/make_unsigned.h> #include <atomic> #include <cctype> #include <clocale> #include <cstdint> #include <cstdlib> -#include <mutex> #include <string> // Some platforms require more includes than others. Keep the includes on all plaforms for now. diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/abs.h b/contrib/libs/cxxsupp/libcxx/include/__math/abs.h new file mode 100644 index 0000000000..6004690f4c --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/abs.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_ABS_H +#define _LIBCPP___MATH_ABS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// fabs + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { + return __builtin_fabs(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT { + return __builtin_fabsl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT { + return __builtin_fabs((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_ABS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h b/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h new file mode 100644 index 0000000000..2219297e8b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/copysign.h @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_COPYSIGN_H +#define _LIBCPP___MATH_COPYSIGN_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/promote.h> +#include <limits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// copysign + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { + return ::__builtin_copysignf(__x, __y); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { + return ::__builtin_copysignl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type +copysign(_A1 __x, _A2 __y) _NOEXCEPT { + return ::__builtin_copysign(__x, __y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_COPYSIGN_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/error_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/error_functions.h new file mode 100644 index 0000000000..6b528bb290 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/error_functions.h @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_ERROR_FUNCTIONS_H +#define _LIBCPP___MATH_ERROR_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// erf + +inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT { return __builtin_erff(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT { + return __builtin_erf(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT { return __builtin_erfl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double erf(_A1 __x) _NOEXCEPT { + return __builtin_erf((double)__x); +} + +// erfc + +inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT { return __builtin_erfcf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT { + return __builtin_erfc(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT { return __builtin_erfcl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double erfc(_A1 __x) _NOEXCEPT { + return __builtin_erfc((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_ERROR_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/exponential_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/exponential_functions.h new file mode 100644 index 0000000000..f8d611b9e4 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/exponential_functions.h @@ -0,0 +1,171 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_EXPONENTIAL_FUNCTIONS_H +#define _LIBCPP___MATH_EXPONENTIAL_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// exp + +inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT { return __builtin_expf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT { + return __builtin_exp(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT { return __builtin_expl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double exp(_A1 __x) _NOEXCEPT { + return __builtin_exp((double)__x); +} + +// frexp + +inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT { return __builtin_frexpf(__x, __e); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT { + return __builtin_frexp(__x, __e); +} + +inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT { + return __builtin_frexpl(__x, __e); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double frexp(_A1 __x, int* __e) _NOEXCEPT { + return __builtin_frexp((double)__x, __e); +} + +// ldexp + +inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT { return __builtin_ldexpf(__x, __e); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT { + return __builtin_ldexp(__x, __e); +} + +inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT { + return __builtin_ldexpl(__x, __e); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double ldexp(_A1 __x, int __e) _NOEXCEPT { + return __builtin_ldexp((double)__x, __e); +} + +// exp2 + +inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT { return __builtin_exp2f(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT { + return __builtin_exp2(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT { return __builtin_exp2l(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double exp2(_A1 __x) _NOEXCEPT { + return __builtin_exp2((double)__x); +} + +// expm1 + +inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT { return __builtin_expm1f(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT { + return __builtin_expm1(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT { return __builtin_expm1l(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double expm1(_A1 __x) _NOEXCEPT { + return __builtin_expm1((double)__x); +} + +// scalbln + +inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT { return __builtin_scalblnf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT { + return __builtin_scalbln(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT { + return __builtin_scalblnl(__x, __y); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double scalbln(_A1 __x, long __y) _NOEXCEPT { + return __builtin_scalbln((double)__x, __y); +} + +// scalbn + +inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT { return __builtin_scalbnf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT { + return __builtin_scalbn(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT { + return __builtin_scalbnl(__x, __y); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double scalbn(_A1 __x, int __y) _NOEXCEPT { + return __builtin_scalbn((double)__x, __y); +} + +// pow + +inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT { return __builtin_powf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT { + return __builtin_pow(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT { + return __builtin_powl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type pow(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::pow((__result_type)__x, (__result_type)__y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_EXPONENTIAL_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/fdim.h b/contrib/libs/cxxsupp/libcxx/include/__math/fdim.h new file mode 100644 index 0000000000..6f90809302 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/fdim.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_FDIM_H +#define _LIBCPP___MATH_FDIM_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT { return __builtin_fdimf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT { + return __builtin_fdim(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT { + return __builtin_fdiml(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fdim(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::fdim((__result_type)__x, (__result_type)__y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_FDIM_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/fma.h b/contrib/libs/cxxsupp/libcxx/include/__math/fma.h new file mode 100644 index 0000000000..9e14f72dca --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/fma.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_FMA_H +#define _LIBCPP___MATH_FMA_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT { + return __builtin_fmaf(__x, __y, __z); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT { + return __builtin_fma(__x, __y, __z); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT { + return __builtin_fmal(__x, __y, __z); +} + +template <class _A1, + class _A2, + class _A3, + __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2, _A3>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && + _IsSame<_A3, __result_type>::value)), + ""); + return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_FMA_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/gamma.h b/contrib/libs/cxxsupp/libcxx/include/__math/gamma.h new file mode 100644 index 0000000000..693e111a84 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/gamma.h @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_GAMMA_H +#define _LIBCPP___MATH_GAMMA_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// lgamma + +inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT { return __builtin_lgammaf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT { + return __builtin_lgamma(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT { return __builtin_lgammal(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double lgamma(_A1 __x) _NOEXCEPT { + return __builtin_lgamma((double)__x); +} + +// nan + +// tgamma + +inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT { return __builtin_tgammaf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT { + return __builtin_tgamma(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT { return __builtin_tgammal(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double tgamma(_A1 __x) _NOEXCEPT { + return __builtin_tgamma((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_GAMMA_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/hyperbolic_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/hyperbolic_functions.h new file mode 100644 index 0000000000..78832bae70 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/hyperbolic_functions.h @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_HYPERBOLIC_FUNCTIONS_H +#define _LIBCPP___MATH_HYPERBOLIC_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// cosh + +inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT { return __builtin_coshf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT { + return __builtin_cosh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT { return __builtin_coshl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double cosh(_A1 __x) _NOEXCEPT { + return __builtin_cosh((double)__x); +} + +// sinh + +inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT { return __builtin_sinhf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT { + return __builtin_sinh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT { return __builtin_sinhl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double sinh(_A1 __x) _NOEXCEPT { + return __builtin_sinh((double)__x); +} + +// tanh + +inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT { return __builtin_tanhf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT { + return __builtin_tanh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT { return __builtin_tanhl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double tanh(_A1 __x) _NOEXCEPT { + return __builtin_tanh((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_HYPERBOLIC_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h b/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h new file mode 100644 index 0000000000..8e2c0f5b6b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/hypot.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_HYPOT_H +#define _LIBCPP___MATH_HYPOT_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT { return __builtin_hypotf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT { + return __builtin_hypot(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT { + return __builtin_hypotl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::hypot((__result_type)__x, (__result_type)__y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_HYPOT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/inverse_hyperbolic_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/inverse_hyperbolic_functions.h new file mode 100644 index 0000000000..4660a58e4e --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/inverse_hyperbolic_functions.h @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_INVERSE_HYPERBOLIC_FUNCTIONS_H +#define _LIBCPP___MATH_INVERSE_HYPERBOLIC_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// acosh + +inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT { return __builtin_acoshf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT { + return __builtin_acosh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT { return __builtin_acoshl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double acosh(_A1 __x) _NOEXCEPT { + return __builtin_acosh((double)__x); +} + +// asinh + +inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT { return __builtin_asinhf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT { + return __builtin_asinh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT { return __builtin_asinhl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double asinh(_A1 __x) _NOEXCEPT { + return __builtin_asinh((double)__x); +} + +// atanh + +inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT { return __builtin_atanhf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT { + return __builtin_atanh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT { return __builtin_atanhl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double atanh(_A1 __x) _NOEXCEPT { + return __builtin_atanh((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_INVERSE_HYPERBOLIC_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/inverse_trigonometric_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/inverse_trigonometric_functions.h new file mode 100644 index 0000000000..30b1440b0b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/inverse_trigonometric_functions.h @@ -0,0 +1,99 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_INVERSE_TRIGONOMETRIC_FUNCTIONS_H +#define _LIBCPP___MATH_INVERSE_TRIGONOMETRIC_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// acos + +inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT { return __builtin_acosf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT { + return __builtin_acos(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT { return __builtin_acosl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double acos(_A1 __x) _NOEXCEPT { + return __builtin_acos((double)__x); +} + +// asin + +inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT { return __builtin_asinf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT { + return __builtin_asin(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT { return __builtin_asinl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double asin(_A1 __x) _NOEXCEPT { + return __builtin_asin((double)__x); +} + +// atan + +inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT { return __builtin_atanf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT { + return __builtin_atan(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT { return __builtin_atanl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double atan(_A1 __x) _NOEXCEPT { + return __builtin_atan((double)__x); +} + +// atan2 + +inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT { return __builtin_atan2f(__y, __x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT { + return __builtin_atan2(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT { + return __builtin_atan2l(__y, __x); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type atan2(_A1 __y, _A2 __x) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::atan2((__result_type)__y, (__result_type)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_INVERSE_TRIGONOMETRIC_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/logarithms.h b/contrib/libs/cxxsupp/libcxx/include/__math/logarithms.h new file mode 100644 index 0000000000..5f5f943977 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/logarithms.h @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_LOGARITHMS_H +#define _LIBCPP___MATH_LOGARITHMS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// log + +inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT { return __builtin_logf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT { + return __builtin_log(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT { return __builtin_logl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double log(_A1 __x) _NOEXCEPT { + return __builtin_log((double)__x); +} + +// log10 + +inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT { return __builtin_log10f(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT { + return __builtin_log10(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT { return __builtin_log10l(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double log10(_A1 __x) _NOEXCEPT { + return __builtin_log10((double)__x); +} + +// ilogb + +inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT { return __builtin_ilogbf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT { + return __builtin_ilogb(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT { return __builtin_ilogbl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI int ilogb(_A1 __x) _NOEXCEPT { + return __builtin_ilogb((double)__x); +} + +// log1p + +inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT { return __builtin_log1pf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT { + return __builtin_log1p(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT { return __builtin_log1pl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double log1p(_A1 __x) _NOEXCEPT { + return __builtin_log1p((double)__x); +} + +// log2 + +inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT { return __builtin_log2f(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT { + return __builtin_log2(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT { return __builtin_log2l(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double log2(_A1 __x) _NOEXCEPT { + return __builtin_log2((double)__x); +} + +// logb + +inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT { return __builtin_logbf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT { + return __builtin_logb(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT { return __builtin_logbl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double logb(_A1 __x) _NOEXCEPT { + return __builtin_logb((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_LOGARITHMS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h b/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h new file mode 100644 index 0000000000..381b2af4a5 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/min_max.h @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_MIN_MAX_H +#define _LIBCPP___MATH_MIN_MAX_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// fmax + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT { + return __builtin_fmaxf(__x, __y); +} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { + return __builtin_fmax(__x, __y); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT { + return __builtin_fmaxl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::fmax((__result_type)__x, (__result_type)__y); +} + +// fmin + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT { + return __builtin_fminf(__x, __y); +} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { + return __builtin_fmin(__x, __y); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT { + return __builtin_fminl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::fmin((__result_type)__x, (__result_type)__y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_MIN_MAX_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/modulo.h b/contrib/libs/cxxsupp/libcxx/include/__math/modulo.h new file mode 100644 index 0000000000..f6cdb956cf --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/modulo.h @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_MODULO_H +#define _LIBCPP___MATH_MODULO_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// fmod + +inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT { return __builtin_fmodf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT { + return __builtin_fmod(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT { + return __builtin_fmodl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmod(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::fmod((__result_type)__x, (__result_type)__y); +} + +// modf + +inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT { return __builtin_modff(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT { + return __builtin_modf(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT { + return __builtin_modfl(__x, __y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_MODULO_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h b/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h new file mode 100644 index 0000000000..025fb53aaa --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/remainder.h @@ -0,0 +1,73 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_REMAINDER_H +#define _LIBCPP___MATH_REMAINDER_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> +#include <limits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// remainder + +inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT { return __builtin_remainderf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT { + return __builtin_remainder(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT { + return __builtin_remainderl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remainder(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::remainder((__result_type)__x, (__result_type)__y); +} + +// remquo + +inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT { + return __builtin_remquof(__x, __y, __z); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT { + return __builtin_remquo(__x, __y, __z); +} + +inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT { + return __builtin_remquol(__x, __y, __z); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::remquo((__result_type)__x, (__result_type)__y, __z); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_REMAINDER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/roots.h b/contrib/libs/cxxsupp/libcxx/include/__math/roots.h new file mode 100644 index 0000000000..faee688bc9 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/roots.h @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_ROOTS_H +#define _LIBCPP___MATH_ROOTS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// sqrt + +inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT { return __builtin_sqrtf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT { + return __builtin_sqrt(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT { return __builtin_sqrtl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT { + return __builtin_sqrt((double)__x); +} + +// cbrt + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { + return __builtin_cbrt(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT { + return __builtin_cbrtl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT { + return __builtin_cbrt((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_ROOTS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h new file mode 100644 index 0000000000..7943b6f3aa --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/rounding_functions.h @@ -0,0 +1,245 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_ROUNDING_FUNCTIONS_H +#define _LIBCPP___MATH_ROUNDING_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// ceil + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { + return __builtin_ceil(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT { + return __builtin_ceill(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT { + return __builtin_ceil((double)__x); +} + +// floor + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { + return __builtin_floor(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT { + return __builtin_floorl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT { + return __builtin_floor((double)__x); +} + +// llrint + +inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT { return __builtin_llrintf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT { + return __builtin_llrint(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT { return __builtin_llrintl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI long long llrint(_A1 __x) _NOEXCEPT { + return __builtin_llrint((double)__x); +} + +// llround + +inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT { return __builtin_llroundf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT { + return __builtin_llround(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT { return __builtin_llroundl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI long long llround(_A1 __x) _NOEXCEPT { + return __builtin_llround((double)__x); +} + +// lrint + +inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT { return __builtin_lrintf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT { + return __builtin_lrint(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT { return __builtin_lrintl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI long lrint(_A1 __x) _NOEXCEPT { + return __builtin_lrint((double)__x); +} + +// lround + +inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT { return __builtin_lroundf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT { + return __builtin_lround(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT { return __builtin_lroundl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT { + return __builtin_lround((double)__x); +} + +// nearbyint + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT { + return __builtin_nearbyintf(__x); +} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { + return __builtin_nearbyint(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT { + return __builtin_nearbyintl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT { + return __builtin_nearbyint((double)__x); +} + +// nextafter + +inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT { return __builtin_nextafterf(__x, __y); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT { + return __builtin_nextafter(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT { + return __builtin_nextafterl(__x, __y); +} + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type nextafter(_A1 __x, _A2 __y) _NOEXCEPT { + using __result_type = typename __promote<_A1, _A2>::type; + static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), ""); + return __math::nextafter((__result_type)__x, (__result_type)__y); +} + +// nexttoward + +inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT { + return __builtin_nexttowardf(__x, __y); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT { + return __builtin_nexttoward(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT { + return __builtin_nexttowardl(__x, __y); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCEPT { + return __builtin_nexttoward((double)__x, __y); +} + +// rint + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { + return __builtin_rint(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT { + return __builtin_rintl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT { + return __builtin_rint((double)__x); +} + +// round + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_roundf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { + return __builtin_round(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT { + return __builtin_roundl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT { + return __builtin_round((double)__x); +} + +// trunc + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_truncf(__x); } + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { + return __builtin_trunc(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT { + return __builtin_truncl(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT { + return __builtin_trunc((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_ROUNDING_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/traits.h b/contrib/libs/cxxsupp/libcxx/include/__math/traits.h new file mode 100644 index 0000000000..bc68e78c52 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/traits.h @@ -0,0 +1,176 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_TRAITS_H +#define _LIBCPP___MATH_TRAITS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_arithmetic.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_signed.h> +#include <__type_traits/promote.h> +#include <limits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// signbit + +template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { + return __builtin_signbit(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { + return __x < 0; +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { + return false; +} + +// isfinite + +template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { + return __builtin_isfinite((typename __promote<_A1>::type)__x); +} + +template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { + return true; +} + +// isinf + +template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { + return __builtin_isinf((typename __promote<_A1>::type)__x); +} + +template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT { + return false; +} + +#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { + return __builtin_isinf(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool +isinf(double __x) _NOEXCEPT { + return __builtin_isinf(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { + return __builtin_isinf(__x); +} +#endif + +// isnan + +template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { + return __builtin_isnan(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { + return false; +} + +#ifdef _LIBCPP_PREFERRED_OVERLOAD && !defined(__CUDACC__) +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { + return __builtin_isnan(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool +isnan(double __x) _NOEXCEPT { + return __builtin_isnan(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { + return __builtin_isnan(__x); +} +#endif + +// isnormal + +template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { + return __builtin_isnormal(__x); +} + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { + return __x != 0; +} + +// isgreater + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { + using type = typename __promote<_A1, _A2>::type; + return __builtin_isgreater((type)__x, (type)__y); +} + +// isgreaterequal + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { + using type = typename __promote<_A1, _A2>::type; + return __builtin_isgreaterequal((type)__x, (type)__y); +} + +// isless + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { + using type = typename __promote<_A1, _A2>::type; + return __builtin_isless((type)__x, (type)__y); +} + +// islessequal + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { + using type = typename __promote<_A1, _A2>::type; + return __builtin_islessequal((type)__x, (type)__y); +} + +// islessgreater + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { + using type = typename __promote<_A1, _A2>::type; + return __builtin_islessgreater((type)__x, (type)__y); +} + +// isunordered + +template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { + using type = typename __promote<_A1, _A2>::type; + return __builtin_isunordered((type)__x, (type)__y); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_TRAITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__math/trigonometric_functions.h b/contrib/libs/cxxsupp/libcxx/include/__math/trigonometric_functions.h new file mode 100644 index 0000000000..0ad91c7631 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__math/trigonometric_functions.h @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MATH_TRIGONOMETRIC_FUNCTIONS_H +#define _LIBCPP___MATH_TRIGONOMETRIC_FUNCTIONS_H + +#include <__config> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_integral.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace __math { + +// cos + +inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT { return __builtin_cosf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT { + return __builtin_cos(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT { return __builtin_cosl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double cos(_A1 __x) _NOEXCEPT { + return __builtin_cos((double)__x); +} + +// sin + +inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT { return __builtin_sinf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT { + return __builtin_sin(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT { return __builtin_sinl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double sin(_A1 __x) _NOEXCEPT { + return __builtin_sin((double)__x); +} + +// tan + +inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT { return __builtin_tanf(__x); } + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT { + return __builtin_tan(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT { return __builtin_tanl(__x); } + +template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI double tan(_A1 __x) _NOEXCEPT { + return __builtin_tan((double)__x); +} + +} // namespace __math + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MATH_TRIGONOMETRIC_FUNCTIONS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h b/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h index 00c2928dcc..bce00bf02a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/assume_aligned.h @@ -22,16 +22,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if _LIBCPP_STD_VER >= 20 - template <size_t _Np, class _Tp> -[[nodiscard]] -_LIBCPP_HIDE_FROM_ABI -constexpr _Tp* assume_aligned(_Tp* __ptr) { +_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __assume_aligned(_Tp* __ptr) { static_assert(_Np != 0 && (_Np & (_Np - 1)) == 0, "std::assume_aligned<N>(p) requires N to be a power of two"); - if (is_constant_evaluated()) { + if (__libcpp_is_constant_evaluated()) { return __ptr; } else { _LIBCPP_ASSERT_UNCATEGORIZED(reinterpret_cast<uintptr_t>(__ptr) % _Np == 0, "Alignment assumption is violated"); @@ -39,6 +35,13 @@ constexpr _Tp* assume_aligned(_Tp* __ptr) { } } +#if _LIBCPP_STD_VER >= 20 + +template <size_t _Np, class _Tp> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* assume_aligned(_Tp* __ptr) { + return std::__assume_aligned<_Np>(__ptr); +} + #endif // _LIBCPP_STD_VER >= 20 _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h b/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h index a032c33b47..0b4a228f95 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/construct_at.h @@ -62,7 +62,7 @@ template <class _ForwardIterator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator); -template <class _Tp, typename enable_if<!is_array<_Tp>::value, int>::type = 0> +template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { _LIBCPP_ASSERT_UNCATEGORIZED(__loc != nullptr, "null pointer given to destroy_at"); @@ -70,7 +70,7 @@ void __destroy_at(_Tp* __loc) { } #if _LIBCPP_STD_VER >= 20 -template <class _Tp, typename enable_if<is_array<_Tp>::value, int>::type = 0> +template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) { _LIBCPP_ASSERT_UNCATEGORIZED(__loc != nullptr, "null pointer given to destroy_at"); diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h b/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h index c33e7bd43f..7617948ed7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/pointer_traits.h @@ -35,7 +35,7 @@ template <class _Tp> struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {}; template <class _Ptr, bool = __has_element_type<_Ptr>::value> -struct __pointer_traits_element_type; +struct __pointer_traits_element_type {}; template <class _Ptr> struct __pointer_traits_element_type<_Ptr, true> @@ -111,12 +111,14 @@ struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> typedef _Sp<_Up, _Args...> type; }; +template <class _Ptr, class = void> +struct __pointer_traits_impl {}; + template <class _Ptr> -struct _LIBCPP_TEMPLATE_VIS pointer_traits -{ - typedef _Ptr pointer; - typedef typename __pointer_traits_element_type<pointer>::type element_type; - typedef typename __pointer_traits_difference_type<pointer>::type difference_type; +struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_type<_Ptr>::type> > { + typedef _Ptr pointer; + typedef typename __pointer_traits_element_type<pointer>::type element_type; + typedef typename __pointer_traits_difference_type<pointer>::type difference_type; #ifndef _LIBCPP_CXX03_LANG template <class _Up> using rebind = typename __pointer_traits_rebind<pointer, _Up>::type; @@ -133,6 +135,9 @@ public: {return pointer::pointer_to(__r);} }; +template <class _Ptr> +struct _LIBCPP_TEMPLATE_VIS pointer_traits : __pointer_traits_impl<_Ptr> {}; + template <class _Tp> struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> { diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h index d8395dc735..4b9da003e5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h @@ -126,6 +126,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr public: _LIBCPP_HIDE_FROM_ABI bad_weak_ptr() _NOEXCEPT = default; _LIBCPP_HIDE_FROM_ABI bad_weak_ptr(const bad_weak_ptr&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_weak_ptr& operator=(const bad_weak_ptr&) _NOEXCEPT = default; ~bad_weak_ptr() _NOEXCEPT override; const char* what() const _NOEXCEPT override; }; @@ -310,23 +311,23 @@ template <class _Tp, class _Alloc> struct __shared_ptr_emplace : __shared_weak_count { - template<class ..._Args> + template <class... _Args, class _Allocator = _Alloc, __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI + explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...) + : __storage_(_VSTD::move(__a)) + { + static_assert(sizeof...(_Args) == 0, "No argument should be provided to the control block when using _for_overwrite"); + ::new ((void*)__get_elem()) _Tp; + } + + template <class... _Args, class _Allocator = _Alloc, __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) : __storage_(_VSTD::move(__a)) { -#if _LIBCPP_STD_VER >= 20 - if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) { - static_assert(sizeof...(_Args) == 0, "No argument should be provided to the control block when using _for_overwrite"); - ::new ((void*)__get_elem()) _Tp; - } else { - using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type; - _TpAlloc __tmp(*__get_alloc()); - allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), _VSTD::forward<_Args>(__args)...); - } -#else - ::new ((void*)__get_elem()) _Tp(_VSTD::forward<_Args>(__args)...); -#endif + using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type; + _TpAlloc __tmp(*__get_alloc()); + allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), _VSTD::forward<_Args>(__args)...); } _LIBCPP_HIDE_FROM_ABI @@ -336,18 +337,20 @@ struct __shared_ptr_emplace _Tp* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); } private: - _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { -#if _LIBCPP_STD_VER >= 20 - if constexpr (is_same_v<typename _Alloc::value_type, __for_overwrite_tag>) { - __get_elem()->~_Tp(); - } else { - using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type; - _TpAlloc __tmp(*__get_alloc()); - allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem()); - } -#else + template <class _Allocator = _Alloc, __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT { __get_elem()->~_Tp(); -#endif + } + + template <class _Allocator = _Alloc, __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT { + using _TpAlloc = typename __allocator_traits_rebind<_Allocator, _Tp>::type; + _TpAlloc __tmp(*__get_alloc()); + allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem()); + } + + _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { + __on_zero_shared_impl(); } _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override { @@ -1651,51 +1654,38 @@ private: public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; - template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r, - typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) - _NOEXCEPT; + + template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr const& __r) _NOEXCEPT; - template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r, - typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) - _NOEXCEPT; + + template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr&& __r) _NOEXCEPT; - template<class _Yp> _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r, - typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type = 0) - _NOEXCEPT; + + template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r) _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI ~weak_ptr(); _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; - template<class _Yp> - typename enable_if - < - __compatible_with<_Yp, _Tp>::value, - weak_ptr& - >::type - _LIBCPP_INLINE_VISIBILITY + template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; - template<class _Yp> - typename enable_if - < - __compatible_with<_Yp, _Tp>::value, - weak_ptr& - >::type - _LIBCPP_INLINE_VISIBILITY + template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; - template<class _Yp> - typename enable_if - < - __compatible_with<_Yp, _Tp>::value, - weak_ptr& - >::type - _LIBCPP_INLINE_VISIBILITY + template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -1748,10 +1738,9 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT } template<class _Tp> -template<class _Yp> +template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> > inline -weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, - typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) +weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -1761,16 +1750,15 @@ weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, } template<class _Tp> -template<class _Yp> +template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> > inline -weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, - typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) +weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r) _NOEXCEPT - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_) + : __ptr_(nullptr), + __cntrl_(nullptr) { - if (__cntrl_) - __cntrl_->__add_weak(); + shared_ptr<_Yp> __s = __r.lock(); + *this = weak_ptr<_Tp>(__s); } template<class _Tp> @@ -1784,16 +1772,16 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT } template<class _Tp> -template<class _Yp> +template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> > inline -weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, - typename enable_if<__compatible_with<_Yp, _Tp>::value, __nat*>::type) +weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r) _NOEXCEPT - : __ptr_(__r.__ptr_), - __cntrl_(__r.__cntrl_) + : __ptr_(nullptr), + __cntrl_(nullptr) { - __r.__ptr_ = nullptr; - __r.__cntrl_ = nullptr; + shared_ptr<_Yp> __s = __r.lock(); + *this = weak_ptr<_Tp>(__s); + __r.reset(); } template<class _Tp> @@ -1813,13 +1801,9 @@ weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT } template<class _Tp> -template<class _Yp> +template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> > inline -typename enable_if -< - __compatible_with<_Yp, _Tp>::value, - weak_ptr<_Tp>& ->::type +weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT { weak_ptr(__r).swap(*this); @@ -1836,13 +1820,9 @@ weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT } template<class _Tp> -template<class _Yp> +template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> > inline -typename enable_if -< - __compatible_with<_Yp, _Tp>::value, - weak_ptr<_Tp>& ->::type +weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT { weak_ptr(_VSTD::move(__r)).swap(*this); @@ -1850,13 +1830,9 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT } template<class _Tp> -template<class _Yp> +template<class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> > inline -typename enable_if -< - __compatible_with<_Yp, _Tp>::value, - weak_ptr<_Tp>& ->::type +weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT { weak_ptr(__r).swap(*this); diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h index e554d1a857..e746d562cf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h @@ -59,9 +59,9 @@ struct _LIBCPP_TEMPLATE_VIS default_delete { #else _LIBCPP_INLINE_VISIBILITY default_delete() {} #endif - template <class _Up> + template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete( - const default_delete<_Up>&, typename enable_if<is_convertible<_Up*, _Tp*>::value>::type* = 0) _NOEXCEPT {} + const default_delete<_Up>&) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT { static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type"); @@ -156,29 +156,29 @@ private: template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type> using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG = - typename enable_if<is_default_constructible<_Deleter>::value && - !is_pointer<_Deleter>::value>::type; + __enable_if_t<is_default_constructible<_Deleter>::value && + !is_pointer<_Deleter>::value>; template <class _ArgType> using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = - typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type; + __enable_if_t<is_constructible<deleter_type, _ArgType>::value>; template <class _UPtr, class _Up> - using _EnableIfMoveConvertible _LIBCPP_NODEBUG = typename enable_if< + using _EnableIfMoveConvertible _LIBCPP_NODEBUG = __enable_if_t< is_convertible<typename _UPtr::pointer, pointer>::value && !is_array<_Up>::value - >::type; + >; template <class _UDel> - using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = typename enable_if< + using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = __enable_if_t< (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) || (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) - >::type; + >; template <class _UDel> - using _EnableIfDeleterAssignable = typename enable_if< + using _EnableIfDeleterAssignable = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value - >::type; + >; public: template <bool _Dummy = true, @@ -222,12 +222,10 @@ public: : __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {} #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) - template <class _Up> + template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value && + is_same<_Dp, default_delete<_Tp> >::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - unique_ptr(auto_ptr<_Up>&& __p, - typename enable_if<is_convertible<_Up*, _Tp*>::value && - is_same<_Dp, default_delete<_Tp> >::value, - __nat>::type = __nat()) _NOEXCEPT + unique_ptr(auto_ptr<_Up>&& __p) _NOEXCEPT : __ptr_(__p.release(), __value_init_tag()) {} #endif @@ -248,11 +246,10 @@ public: } #if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) - template <class _Up> + template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value && + is_same<_Dp, default_delete<_Tp> >::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<is_convertible<_Up*, _Tp*>::value && - is_same<_Dp, default_delete<_Tp> >::value, - unique_ptr&>::type + unique_ptr& operator=(auto_ptr<_Up> __p) { reset(__p.release()); return *this; @@ -346,37 +343,37 @@ private: template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type> using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG = - typename enable_if<is_default_constructible<_Deleter>::value && - !is_pointer<_Deleter>::value>::type; + __enable_if_t<is_default_constructible<_Deleter>::value && + !is_pointer<_Deleter>::value>; template <class _ArgType> using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = - typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type; + __enable_if_t<is_constructible<deleter_type, _ArgType>::value>; template <class _Pp> - using _EnableIfPointerConvertible _LIBCPP_NODEBUG = typename enable_if< + using _EnableIfPointerConvertible _LIBCPP_NODEBUG = __enable_if_t< _CheckArrayPointerConversion<_Pp>::value - >::type; + >; template <class _UPtr, class _Up, class _ElemT = typename _UPtr::element_type> - using _EnableIfMoveConvertible _LIBCPP_NODEBUG = typename enable_if< + using _EnableIfMoveConvertible _LIBCPP_NODEBUG = __enable_if_t< is_array<_Up>::value && is_same<pointer, element_type*>::value && is_same<typename _UPtr::pointer, _ElemT*>::value && is_convertible<_ElemT(*)[], element_type(*)[]>::value - >::type; + >; template <class _UDel> - using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = typename enable_if< + using _EnableIfDeleterConvertible _LIBCPP_NODEBUG = __enable_if_t< (is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) || (!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value) - >::type; + >; template <class _UDel> - using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = typename enable_if< + using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value - >::type; + >; public: template <bool _Dummy = true, @@ -491,10 +488,9 @@ public: return __t; } - template <class _Pp> + template <class _Pp, __enable_if_t<_CheckArrayPointerConversion<_Pp>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 - typename enable_if< _CheckArrayPointerConversion<_Pp>::value >::type - reset(_Pp __p) _NOEXCEPT { + void reset(_Pp __p) _NOEXCEPT { pointer __tmp = __ptr_.first(); __ptr_.first() = __p; if (__tmp) @@ -513,9 +509,9 @@ public: } }; -template <class _Tp, class _Dp> +template <class _Tp, class _Dp, __enable_if_t<__is_swappable<_Dp>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 - typename enable_if< __is_swappable<_Dp>::value, void >::type + void swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT { __x.swap(__y); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__mutex/once_flag.h b/contrib/libs/cxxsupp/libcxx/include/__mutex/once_flag.h new file mode 100644 index 0000000000..d66bb87db2 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__mutex/once_flag.h @@ -0,0 +1,178 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MUTEX_ONCE_FLAG_H +#define _LIBCPP___MUTEX_ONCE_FLAG_H + +#include <__config> +#include <__functional/invoke.h> +#include <__memory/shared_ptr.h> // __libcpp_acquire_load +#include <__tuple/tuple_indices.h> +#include <__tuple/tuple_size.h> +#include <__utility/forward.h> +#include <__utility/move.h> +#include <cstdint> +#ifndef _LIBCPP_CXX03_LANG +# include <tuple> +#endif + +#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG) +#include <atomic> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct _LIBCPP_TEMPLATE_VIS once_flag; + +#ifndef _LIBCPP_CXX03_LANG + +template <class _Callable, class... _Args> +_LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, _Callable&&, _Args&&...); + +#else // _LIBCPP_CXX03_LANG + +template <class _Callable> +_LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, _Callable&); + +template <class _Callable> +_LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, const _Callable&); + +#endif // _LIBCPP_CXX03_LANG + +struct _LIBCPP_TEMPLATE_VIS once_flag { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(_Unset) {} + once_flag(const once_flag&) = delete; + once_flag& operator=(const once_flag&) = delete; + +#if defined(_LIBCPP_ABI_MICROSOFT) + typedef uintptr_t _State_type; +#else + typedef unsigned long _State_type; +#endif + + static const _State_type _Unset = 0; + static const _State_type _Pending = 1; + static const _State_type _Complete = ~_State_type(0); + +private: +#if defined(_LIBCPP_ABI_MICROSOFT) + atomic<_State_type> __state_; +#else + _State_type __state_; +#endif + +#ifndef _LIBCPP_CXX03_LANG + template <class _Callable, class... _Args> + friend void call_once(once_flag&, _Callable&&, _Args&&...); +#else // _LIBCPP_CXX03_LANG + template <class _Callable> + friend void call_once(once_flag&, _Callable&); + + template <class _Callable> + friend void call_once(once_flag&, const _Callable&); +#endif // _LIBCPP_CXX03_LANG +}; + +#ifndef _LIBCPP_CXX03_LANG + +template <class _Fp> +class __call_once_param { + _Fp& __f_; + +public: + _LIBCPP_HIDE_FROM_ABI explicit __call_once_param(_Fp& __f) : __f_(__f) {} + + _LIBCPP_HIDE_FROM_ABI void operator()() { + typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index; + __execute(_Index()); + } + +private: + template <size_t... _Indices> + _LIBCPP_HIDE_FROM_ABI void __execute(__tuple_indices<_Indices...>) { + _VSTD::__invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...); + } +}; + +#else + +template <class _Fp> +class __call_once_param { + _Fp& __f_; + +public: + _LIBCPP_HIDE_FROM_ABI explicit __call_once_param(_Fp& __f) : __f_(__f) {} + + _LIBCPP_HIDE_FROM_ABI void operator()() { __f_(); } +}; + +#endif + +template <class _Fp> +void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) { + __call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp); + (*__p)(); +} + +#ifdef _LIBCPP_ABI_MICROSOFT +_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile atomic<once_flag::_State_type>&, void*, void (*)(void*)); +#else +_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*)); +#endif + +#ifndef _LIBCPP_CXX03_LANG + +template <class _Callable, class... _Args> +inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) { +#if defined(_LIBCPP_ABI_MICROSOFT) + if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0)) { +#else + if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { +#endif + typedef tuple<_Callable&&, _Args&&...> _Gp; + _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...); + __call_once_param<_Gp> __p(__f); + std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>); + } +} + +#else // _LIBCPP_CXX03_LANG + +template <class _Callable> +inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) { +#if defined(_LIBCPP_ABI_MICROSOFT) + if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0)) { +#else + if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { +#endif + __call_once_param<_Callable> __p(__func); + std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); + } +} + +template <class _Callable> +inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) { +#if defined(_LIBCPP_ABI_MICROSOFT) + if (__flag.__state_.load(memory_order_relaxed) != ~once_flag::_State_type(0)) { +#else + if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) { +#endif + __call_once_param<const _Callable> __p(__func); + std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>); + } +} + +#endif // _LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MUTEX_ONCE_FLAG_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__node_handle b/contrib/libs/cxxsupp/libcxx/include/__node_handle index cc4eaf73c0..b3cc3619dd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__node_handle +++ b/contrib/libs/cxxsupp/libcxx/include/__node_handle @@ -209,7 +209,7 @@ struct __set_node_handle_specifics _LIBCPP_INLINE_VISIBILITY value_type& value() const { - return static_cast<_Derived const*>(this)->__ptr_->__value_; + return static_cast<_Derived const*>(this)->__ptr_->__get_value(); } }; @@ -223,14 +223,14 @@ struct __map_node_handle_specifics key_type& key() const { return static_cast<_Derived const*>(this)-> - __ptr_->__value_.__ref().first; + __ptr_->__get_value().__ref().first; } _LIBCPP_INLINE_VISIBILITY mapped_type& mapped() const { return static_cast<_Derived const*>(this)-> - __ptr_->__value_.__ref().second; + __ptr_->__get_value().__ref().second; } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h b/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h index 163e0078e1..22ef2707d7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h +++ b/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h @@ -40,7 +40,7 @@ reduce(_ExecutionPolicy&& __policy, _Tp __init, _BinaryOperation __op = {}) { return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Tp __g_init, _BinaryOperation __g_op) { return std::transform_reduce( __policy, std::move(__g_first), std::move(__g_last), std::move(__g_init), std::move(__g_op), __identity{}); @@ -58,7 +58,7 @@ template <class _ExecutionPolicy, _LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { return std::__pstl_frontend_dispatch( - _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce), + _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last) { return std::reduce(__policy, __g_first, __g_last, __iter_value_type<_ForwardIterator>()); }, diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/discard_block_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/discard_block_engine.h index 7bdcb6555c..734cb257c3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/discard_block_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/discard_block_engine.h @@ -72,23 +72,18 @@ public: #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, discard_block_engine>::value && + !is_convertible<_Sseq, _Engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - explicit discard_block_engine(_Sseq& __q, - typename enable_if<__is_seed_sequence<_Sseq, discard_block_engine>::value && - !is_convertible<_Sseq, _Engine>::value>::type* = 0) + explicit discard_block_engine(_Sseq& __q) : __e_(__q), __n_(0) {} _LIBCPP_INLINE_VISIBILITY void seed() {__e_.seed(); __n_ = 0;} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd) {__e_.seed(__sd); __n_ = 0;} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, discard_block_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __is_seed_sequence<_Sseq, discard_block_engine>::value, - void - >::type + void seed(_Sseq& __q) {__e_.seed(__q); __n_ = 0;} // generating functions diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/independent_bits_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/independent_bits_engine.h index a86c22157d..0164ce08fb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/independent_bits_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/independent_bits_engine.h @@ -104,23 +104,18 @@ public: #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY explicit independent_bits_engine(result_type __sd) : __e_(__sd) {} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, independent_bits_engine>::value && + !is_convertible<_Sseq, _Engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - explicit independent_bits_engine(_Sseq& __q, - typename enable_if<__is_seed_sequence<_Sseq, independent_bits_engine>::value && - !is_convertible<_Sseq, _Engine>::value>::type* = 0) + explicit independent_bits_engine(_Sseq& __q) : __e_(__q) {} _LIBCPP_INLINE_VISIBILITY void seed() {__e_.seed();} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd) {__e_.seed(__sd);} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, independent_bits_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __is_seed_sequence<_Sseq, independent_bits_engine>::value, - void - >::type + void seed(_Sseq& __q) {__e_.seed(__q);} // generating functions @@ -166,24 +161,16 @@ private: result_type __eval(false_type); _LIBCPP_HIDE_FROM_ABI result_type __eval(true_type); - template <size_t __count> + template <size_t __count, __enable_if_t<__count < _Dt, int> = 0> _LIBCPP_INLINE_VISIBILITY static - typename enable_if - < - __count < _Dt, - result_type - >::type + result_type __lshift(result_type __x) {return __x << __count;} - template <size_t __count> + template <size_t __count, __enable_if_t<(__count >= _Dt), int> = 0> _LIBCPP_INLINE_VISIBILITY static - typename enable_if - < - (__count >= _Dt), - result_type - >::type + result_type __lshift(result_type) {return result_type(0);} }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/linear_congruential_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/linear_congruential_engine.h index 2c2276eccf..3a2a344406 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/linear_congruential_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/linear_congruential_engine.h @@ -246,22 +246,17 @@ public: seed(__s); } #endif - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, linear_congruential_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - explicit linear_congruential_engine(_Sseq& __q, - typename enable_if<__is_seed_sequence<_Sseq, linear_congruential_engine>::value>::type* = 0) + explicit linear_congruential_engine(_Sseq& __q) {seed(__q);} _LIBCPP_INLINE_VISIBILITY void seed(result_type __s = default_seed) {seed(integral_constant<bool, __m == 0>(), integral_constant<bool, __c == 0>(), __s);} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, linear_congruential_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __is_seed_sequence<_Sseq, linear_congruential_engine>::value, - void - >::type + void seed(_Sseq& __q) {__seed(__q, integral_constant<unsigned, 1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1)/32 diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h index 663a6c704b..9a06cfdb00 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/mersenne_twister_engine.h @@ -135,19 +135,14 @@ public: seed(__sd); } #endif - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - explicit mersenne_twister_engine(_Sseq& __q, - typename enable_if<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value>::type* = 0) + explicit mersenne_twister_engine(_Sseq& __q) {seed(__q);} _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd = default_seed); - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __is_seed_sequence<_Sseq, mersenne_twister_engine>::value, - void - >::type + void seed(_Sseq& __q) {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());} @@ -202,44 +197,28 @@ private: template<class _Sseq> _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>); - template <size_t __count> + template <size_t __count, __enable_if_t<__count < __w, int> = 0> _LIBCPP_INLINE_VISIBILITY static - typename enable_if - < - __count < __w, - result_type - >::type + result_type __lshift(result_type __x) {return (__x << __count) & _Max;} - template <size_t __count> + template <size_t __count, __enable_if_t<(__count >= __w), int> = 0> _LIBCPP_INLINE_VISIBILITY static - typename enable_if - < - (__count >= __w), - result_type - >::type + result_type __lshift(result_type) {return result_type(0);} - template <size_t __count> + template <size_t __count, __enable_if_t<__count < _Dt, int> = 0> _LIBCPP_INLINE_VISIBILITY static - typename enable_if - < - __count < _Dt, - result_type - >::type + result_type __rshift(result_type __x) {return __x >> __count;} - template <size_t __count> + template <size_t __count, __enable_if_t<(__count >= _Dt), int> = 0> _LIBCPP_INLINE_VISIBILITY static - typename enable_if - < - (__count >= _Dt), - result_type - >::type + result_type __rshift(result_type) {return result_type(0);} }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/shuffle_order_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/shuffle_order_engine.h index e07f230d21..2c7c22db1f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/shuffle_order_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/shuffle_order_engine.h @@ -98,23 +98,18 @@ public: #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY explicit shuffle_order_engine(result_type __sd) : __e_(__sd) {__init();} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, shuffle_order_engine>::value && + !is_convertible<_Sseq, _Engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - explicit shuffle_order_engine(_Sseq& __q, - typename enable_if<__is_seed_sequence<_Sseq, shuffle_order_engine>::value && - !is_convertible<_Sseq, _Engine>::value>::type* = 0) + explicit shuffle_order_engine(_Sseq& __q) : __e_(__q) {__init();} _LIBCPP_INLINE_VISIBILITY void seed() {__e_.seed(); __init();} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd) {__e_.seed(__sd); __init();} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, shuffle_order_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __is_seed_sequence<_Sseq, shuffle_order_engine>::value, - void - >::type + void seed(_Sseq& __q) {__e_.seed(__q); __init();} // generating functions @@ -174,23 +169,15 @@ private: _LIBCPP_INLINE_VISIBILITY result_type __eval2(true_type) {return __evalf<__k, 0>();} - template <uint64_t _Np, uint64_t _Dp> + template <uint64_t _Np, uint64_t _Dp, __enable_if_t<(__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)), int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - (__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)), - result_type - >::type + result_type __eval(__uratio<_Np, _Dp>) {return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();} - template <uint64_t _Np, uint64_t _Dp> + template <uint64_t _Np, uint64_t _Dp, __enable_if_t<__uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min), int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min), - result_type - >::type + result_type __eval(__uratio<_Np, _Dp>) { const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (__y_ - _Min) diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h b/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h index c8954ca111..2f0b1c7a65 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/subtract_with_carry_engine.h @@ -101,21 +101,16 @@ public: seed(__sd); } #endif - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - explicit subtract_with_carry_engine(_Sseq& __q, - typename enable_if<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value>::type* = 0) + explicit subtract_with_carry_engine(_Sseq& __q) {seed(__q);} _LIBCPP_INLINE_VISIBILITY void seed(result_type __sd = default_seed) {seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());} - template<class _Sseq> + template<class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, - void - >::type + void seed(_Sseq& __q) {__seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());} diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/chunk_by_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/chunk_by_view.h new file mode 100644 index 0000000000..cfb149b443 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/chunk_by_view.h @@ -0,0 +1,230 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___RANGES_CHUNK_BY_VIEW_H +#define _LIBCPP___RANGES_CHUNK_BY_VIEW_H + +#include <__algorithm/ranges_adjacent_find.h> +#include <__assert> +#include <__concepts/constructible.h> +#include <__config> +#include <__functional/bind_back.h> +#include <__functional/invoke.h> +#include <__functional/not_fn.h> +#include <__functional/reference_wrapper.h> +#include <__iterator/concepts.h> +#include <__iterator/default_sentinel.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/next.h> +#include <__iterator/prev.h> +#include <__memory/addressof.h> +#include <__ranges/access.h> +#include <__ranges/all.h> +#include <__ranges/concepts.h> +#include <__ranges/movable_box.h> +#include <__ranges/non_propagating_cache.h> +#include <__ranges/range_adaptor.h> +#include <__ranges/reverse_view.h> +#include <__ranges/subrange.h> +#include <__ranges/view_interface.h> +#include <__type_traits/conditional.h> +#include <__type_traits/decay.h> +#include <__type_traits/is_nothrow_constructible.h> +#include <__type_traits/is_object.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 23 + +namespace ranges { + +template <forward_range _View, indirect_binary_predicate<iterator_t<_View>, iterator_t<_View>> _Pred> + requires view<_View> && is_object_v<_Pred> +class chunk_by_view : public view_interface<chunk_by_view<_View, _Pred>> { + _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View(); + _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_; + + // We cache the result of begin() to allow providing an amortized O(1). + using _Cache = __non_propagating_cache<iterator_t<_View>>; + _Cache __cached_begin_; + + class __iterator; + + _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> __find_next(iterator_t<_View> __current) { + _LIBCPP_ASSERT_UNCATEGORIZED( + __pred_.__has_value(), "Trying to call __find_next() on a chunk_by_view that does not have a valid predicate."); + + return ranges::next(ranges::adjacent_find(__current, ranges::end(__base_), std::not_fn(std::ref(*__pred_))), + 1, + ranges::end(__base_)); + } + + _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> __find_prev(iterator_t<_View> __current) + requires bidirectional_range<_View> + { + _LIBCPP_ASSERT_UNCATEGORIZED( + __current != ranges::begin(__base_), "Trying to call __find_prev() on a begin iterator."); + _LIBCPP_ASSERT_UNCATEGORIZED( + __pred_.__has_value(), "Trying to call __find_prev() on a chunk_by_view that does not have a valid predicate."); + + auto __first = ranges::begin(__base_); + reverse_view __reversed{subrange{__first, __current}}; + auto __reversed_pred = [this]<class _Tp, class _Up>(_Tp&& __x, _Up&& __y) { + return !std::invoke(*__pred_, std::forward<_Up>(__y), std::forward<_Tp>(__x)); + }; + return ranges::prev(ranges::adjacent_find(__reversed, __reversed_pred).base(), 1, std::move(__first)); + } + +public: + _LIBCPP_HIDE_FROM_ABI chunk_by_view() + requires default_initializable<_View> && default_initializable<_Pred> + = default; + + _LIBCPP_HIDE_FROM_ABI constexpr explicit chunk_by_view(_View __base, _Pred __pred) + : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {} + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& + requires copy_constructible<_View> + { + return __base_; + } + + _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); } + + _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; } + + _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() { + _LIBCPP_ASSERT_UNCATEGORIZED( + __pred_.__has_value(), "Trying to call begin() on a chunk_by_view that does not have a valid predicate."); + + auto __first = ranges::begin(__base_); + if (!__cached_begin_.__has_value()) { + __cached_begin_.__emplace(__find_next(__first)); + } + return {*this, std::move(__first), *__cached_begin_}; + } + + _LIBCPP_HIDE_FROM_ABI constexpr auto end() { + if constexpr (common_range<_View>) { + return __iterator{*this, ranges::end(__base_), ranges::end(__base_)}; + } else { + return default_sentinel; + } + } +}; + +template <class _Range, class _Pred> +chunk_by_view(_Range&&, _Pred) -> chunk_by_view<views::all_t<_Range>, _Pred>; + +template <forward_range _View, indirect_binary_predicate<iterator_t<_View>, iterator_t<_View>> _Pred> + requires view<_View> && is_object_v<_Pred> +class chunk_by_view<_View, _Pred>::__iterator { + friend chunk_by_view; + + chunk_by_view* __parent_ = nullptr; + _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __current_ = iterator_t<_View>(); + _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_View> __next_ = iterator_t<_View>(); + + _LIBCPP_HIDE_FROM_ABI constexpr __iterator( + chunk_by_view& __parent, iterator_t<_View> __current, iterator_t<_View> __next) + : __parent_(std::addressof(__parent)), __current_(__current), __next_(__next) {} + +public: + using value_type = subrange<iterator_t<_View>>; + using difference_type = range_difference_t<_View>; + using iterator_category = input_iterator_tag; + using iterator_concept = conditional_t<bidirectional_range<_View>, bidirectional_iterator_tag, forward_iterator_tag>; + + _LIBCPP_HIDE_FROM_ABI __iterator() = default; + + _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { + _LIBCPP_ASSERT_UNCATEGORIZED(__current_ != __next_, "Trying to dereference past-the-end chunk_by_view iterator."); + return {__current_, __next_}; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() { + _LIBCPP_ASSERT_UNCATEGORIZED(__current_ != __next_, "Trying to increment past end chunk_by_view iterator."); + __current_ = __next_; + __next_ = __parent_->__find_next(__current_); + return *this; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int) { + auto __tmp = *this; + ++*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() + requires bidirectional_range<_View> + { + __next_ = __current_; + __current_ = __parent_->__find_prev(__next_); + return *this; + } + + _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int) + requires bidirectional_range<_View> + { + auto __tmp = *this; + --*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) { + return __x.__current_ == __y.__current_; + } + + _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, default_sentinel_t) { + return __x.__current_ == __x.__next_; + } +}; + +namespace views { +namespace __chunk_by { +struct __fn { + template <class _Range, class _Pred> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const + noexcept(noexcept(/**/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)))) + -> decltype(/*--*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) { + return /*-------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred)); + } + + template <class _Pred> + requires constructible_from<decay_t<_Pred>, _Pred> + _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const + noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) { + return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred))); + } +}; +} // namespace __chunk_by + +inline namespace __cpo { +inline constexpr auto chunk_by = __chunk_by::__fn{}; +} // namespace __cpo +} // namespace views +} // namespace ranges + +#endif // _LIBCPP_STD_VER >= 23 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___RANGES_CHUNK_BY_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h index f372688abf..ccf0c7a8e8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h @@ -363,15 +363,14 @@ namespace ranges { (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> { if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) { - if (__value_ < 0) { - if (__bound_sentinel_ < 0) { - return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_); - } - return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_); - } - return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_); + return (__value_ < 0) + ? ((__bound_sentinel_ < 0) + ? std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_) + : std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_)) + : std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_); + } else { + return std::__to_unsigned_like(__bound_sentinel_ - __value_); } - return std::__to_unsigned_like(__bound_sentinel_ - __value_); } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/movable_box.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/movable_box.h index 8b3716a06c..6615533d37 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/movable_box.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/movable_box.h @@ -26,6 +26,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 20 @@ -203,4 +206,6 @@ public: _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___RANGES_MOVABLE_BOX_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/repeat_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/repeat_view.h index fddf4baac8..459a1e2296 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/repeat_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/repeat_view.h @@ -82,13 +82,13 @@ public: requires copy_constructible<_Tp> : __value_(in_place, __value), __bound_(__bound_sentinel) { if constexpr (!same_as<_Bound, unreachable_sentinel_t>) - _LIBCPP_ASSERT(__bound_ >= 0, "The value of bound must be greater than or equal to 0"); + _LIBCPP_ASSERT_UNCATEGORIZED(__bound_ >= 0, "The value of bound must be greater than or equal to 0"); } _LIBCPP_HIDE_FROM_ABI constexpr explicit repeat_view(_Tp&& __value, _Bound __bound_sentinel = _Bound()) : __value_(in_place, std::move(__value)), __bound_(__bound_sentinel) { if constexpr (!same_as<_Bound, unreachable_sentinel_t>) - _LIBCPP_ASSERT(__bound_ >= 0, "The value of bound must be greater than or equal to 0"); + _LIBCPP_ASSERT_UNCATEGORIZED(__bound_ >= 0, "The value of bound must be greater than or equal to 0"); } template <class... _TpArgs, class... _BoundArgs> @@ -98,7 +98,7 @@ public: : __value_(in_place, std::make_from_tuple<_Tp>(std::move(__value_args))), __bound_(std::make_from_tuple<_Bound>(std::move(__bound_args))) { if constexpr (!same_as<_Bound, unreachable_sentinel_t>) - _LIBCPP_ASSERT( + _LIBCPP_ASSERT_UNCATEGORIZED( __bound_ >= 0, "The behavior is undefined if Bound is not unreachable_sentinel_t and bound is negative"); } @@ -161,7 +161,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--() { if constexpr (!same_as<_Bound, unreachable_sentinel_t>) - _LIBCPP_ASSERT(__current_ > 0, "The value of bound must be greater than or equal to 0"); + _LIBCPP_ASSERT_UNCATEGORIZED(__current_ > 0, "The value of bound must be greater than or equal to 0"); --__current_; return *this; } @@ -174,14 +174,14 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __n) { if constexpr (!same_as<_Bound, unreachable_sentinel_t>) - _LIBCPP_ASSERT(__current_ + __n >= 0, "The value of bound must be greater than or equal to 0"); + _LIBCPP_ASSERT_UNCATEGORIZED(__current_ + __n >= 0, "The value of bound must be greater than or equal to 0"); __current_ += __n; return *this; } _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __n) { if constexpr (!same_as<_Bound, unreachable_sentinel_t>) - _LIBCPP_ASSERT(__current_ - __n >= 0, "The value of bound must be greater than or equal to 0"); + _LIBCPP_ASSERT_UNCATEGORIZED(__current_ - __n >= 0, "The value of bound must be greater than or equal to 0"); __current_ -= __n; return *this; } diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h index b4bdd1865d..a6f7f80ca7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_while_view.h @@ -41,18 +41,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -// The spec uses the unnamed requirement inside the `begin` and `end` member functions: -// constexpr auto begin() const -// requires range<const V> && indirect_unary_predicate<const Pred, iterator_t<const V>> -// However, due to a clang-14 and clang-15 bug, the above produces a hard error when `const V` is not a range. -// The workaround is to create a named concept and use the concept instead. -// As of take_while_view is implemented, the clang-trunk has already fixed the bug. -// It is OK to remove the workaround once our CI no longer uses clang-14, clang-15 based compilers, -// because we don't actually expect a lot of vendors to ship a new libc++ with an old clang. -template <class _View, class _Pred> -concept __take_while_const_is_range = - range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>; - template <view _View, class _Pred> requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>> class take_while_view : public view_interface<take_while_view<_View, _Pred>> { @@ -87,7 +75,7 @@ public: } _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const - requires __take_while_const_is_range<_View, _Pred> + requires range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>> { return ranges::begin(__base_); } @@ -99,7 +87,7 @@ public: } _LIBCPP_HIDE_FROM_ABI constexpr auto end() const - requires __take_while_const_is_range<_View, _Pred> + requires range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>> { return __sentinel</*_Const=*/true>(ranges::end(__base_), std::addressof(*__pred_)); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h index 95c300bfa6..a519662e75 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h @@ -44,14 +44,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { -// TODO(clang-15): in the Standard, it's a `constexpr bool` variable, not a concept, but constexpr variables don't -// short-circuit properly on Clang 15 (fixed in later versions), so use a concept as a workaround. template <class _Container> -concept __reservable_container = sized_range<_Container> && requires(_Container& __c, range_size_t<_Container> __n) { - __c.reserve(__n); - { __c.capacity() } -> same_as<decltype(__n)>; - { __c.max_size() } -> same_as<decltype(__n)>; -}; +constexpr bool __reservable_container = + sized_range<_Container> && requires(_Container& __c, range_size_t<_Container> __n) { + __c.reserve(__n); + { __c.capacity() } -> same_as<decltype(__n)>; + { __c.max_size() } -> same_as<decltype(__n)>; + }; template <class _Container, class _Ref> constexpr bool __container_insertable = requires(_Container& __c, _Ref&& __ref) { diff --git a/contrib/libs/cxxsupp/libcxx/include/__split_buffer b/contrib/libs/cxxsupp/libcxx/include/__split_buffer index 4e70256450..7131932d6b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__split_buffer +++ b/contrib/libs/cxxsupp/libcxx/include/__split_buffer @@ -160,15 +160,13 @@ public: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n); _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_at_end(size_type __n, const_reference __x); - template <class _InputIter> + template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI - __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value> - __construct_at_end(_InputIter __first, _InputIter __last); + void __construct_at_end(_InputIter __first, _InputIter __last); - template <class _ForwardIterator> + template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI - __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value> - __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); + void __construct_at_end(_ForwardIterator __first, _ForwardIterator __last); template <class _Iterator, class _Sentinel> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI @@ -290,9 +288,9 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen } template <class _Tp, class _Allocator> -template <class _InputIter> -_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value> -__split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) +template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> > +_LIBCPP_CONSTEXPR_SINCE_CXX20 +void __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last) { __construct_at_end_with_sentinel(__first, __last); } @@ -319,9 +317,9 @@ void __split_buffer<_Tp, _Allocator>::__construct_at_end_with_sentinel(_Iterator } } template <class _Tp, class _Allocator> -template <class _ForwardIterator> -_LIBCPP_CONSTEXPR_SINCE_CXX20 __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value> -__split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) +template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > +_LIBCPP_CONSTEXPR_SINCE_CXX20 +void __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last) { __construct_at_end_with_size(__first, std::distance(__first, __last)); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h new file mode 100644 index 0000000000..13e59f9f0d --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/atomic_unique_lock.h @@ -0,0 +1,140 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H +#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H + +#include <__bit/popcount.h> +#include <__config> +#include <atomic> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 + +// This class implements an RAII unique_lock without a mutex. +// It uses std::atomic<State>, +// where State contains a lock bit and might contain other data, +// and LockedBit is the value of State when the lock bit is set, e.g 1 << 2 +template <class _State, _State _LockedBit> +class _LIBCPP_AVAILABILITY_SYNC __atomic_unique_lock { + static_assert(std::__libcpp_popcount(static_cast<unsigned long long>(_LockedBit)) == 1, + "LockedBit must be an integer where only one bit is set"); + + std::atomic<_State>& __state_; + bool __is_locked_; + +public: + _LIBCPP_HIDE_FROM_ABI explicit __atomic_unique_lock(std::atomic<_State>& __state) noexcept + : __state_(__state), __is_locked_(true) { + __lock(); + } + + template <class _Pred> + _LIBCPP_HIDE_FROM_ABI __atomic_unique_lock(std::atomic<_State>& __state, _Pred&& __give_up_locking) noexcept + : __state_(__state), __is_locked_(false) { + __is_locked_ = __lock_impl(__give_up_locking, __set_locked_bit, std::memory_order_acquire); + } + + template <class _Pred, class _UnaryFunction> + _LIBCPP_HIDE_FROM_ABI __atomic_unique_lock( + std::atomic<_State>& __state, + _Pred&& __give_up_locking, + _UnaryFunction&& __state_after_lock, + std::memory_order __locked_ordering) noexcept + : __state_(__state), __is_locked_(false) { + __is_locked_ = __lock_impl(__give_up_locking, __state_after_lock, __locked_ordering); + } + + __atomic_unique_lock(const __atomic_unique_lock&) = delete; + __atomic_unique_lock(__atomic_unique_lock&&) = delete; + __atomic_unique_lock& operator=(const __atomic_unique_lock&) = delete; + __atomic_unique_lock& operator=(__atomic_unique_lock&&) = delete; + + _LIBCPP_HIDE_FROM_ABI ~__atomic_unique_lock() { + if (__is_locked_) { + __unlock(); + } + } + + _LIBCPP_HIDE_FROM_ABI bool __owns_lock() const noexcept { return __is_locked_; } + + _LIBCPP_HIDE_FROM_ABI void __lock() noexcept { + const auto __never_give_up_locking = [](_State) { return false; }; + // std::memory_order_acquire because we'd like to make sure that all the read operations after the lock can read the + // up-to-date values. + __lock_impl(__never_give_up_locking, __set_locked_bit, std::memory_order_acquire); + __is_locked_ = true; + } + + _LIBCPP_HIDE_FROM_ABI void __unlock() noexcept { + // unset the _LockedBit. `memory_order_release` because we need to make sure all the write operations before calling + // `__unlock` will be made visible to other threads + __state_.fetch_and(static_cast<_State>(~_LockedBit), std::memory_order_release); + __state_.notify_all(); + __is_locked_ = false; + } + +private: + template <class _Pred, class _UnaryFunction> + _LIBCPP_HIDE_FROM_ABI bool + __lock_impl(_Pred&& __give_up_locking, // while trying to lock the state, if the predicate returns true, give up + // locking and return + _UnaryFunction&& __state_after_lock, + std::memory_order __locked_ordering) noexcept { + // At this stage, until we exit the inner while loop, other than the atomic state, we are not reading any order + // dependent values that is written on other threads, or writing anything that needs to be seen on other threads. + // Therefore `memory_order_relaxed` is enough. + _State __current_state = __state_.load(std::memory_order_relaxed); + do { + while (true) { + if (__give_up_locking(__current_state)) { + // user provided early return condition. fail to lock + return false; + } else if ((__current_state & _LockedBit) != 0) { + // another thread has locked the state, we need to wait + __state_.wait(__current_state, std::memory_order_relaxed); + // when it is woken up by notifyAll or spuriously, the __state_ + // might have changed. reload the state + // Note that the new state's _LockedBit may or may not equal to 0 + __current_state = __state_.load(std::memory_order_relaxed); + } else { + // at least for now, it is not locked. we can try `compare_exchange_weak` to lock it. + // Note that the variable `__current_state`'s lock bit has to be 0 at this point. + break; + } + } + } while (!__state_.compare_exchange_weak( + __current_state, // if __state_ has the same value of __current_state, lock bit must be zero before exchange and + // we are good to lock/exchange and return. If _state has a different value, because other + // threads locked it between the `break` statement above and this statement, exchange will fail + // and go back to the inner while loop above. + __state_after_lock(__current_state), // state after lock. Usually it should be __current_state | _LockedBit. + // Some use cases need to set other bits at the same time as an atomic + // operation therefore we accept a function + __locked_ordering, // sucessful exchange order. Usually it should be std::memory_order_acquire. + // Some use cases need more strict ordering therefore we accept it as a parameter + std::memory_order_relaxed // fail to exchange order. We don't need any ordering as we are going back to the + // inner while loop + )); + return true; + } + + _LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; }; +}; + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/intrusive_list_view.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/intrusive_list_view.h new file mode 100644 index 0000000000..11a3e267e7 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/intrusive_list_view.h @@ -0,0 +1,85 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___STOP_TOKEN_INTRUSIVE_LIST_VIEW_H +#define _LIBCPP___STOP_TOKEN_INTRUSIVE_LIST_VIEW_H + +#include <__assert> +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 + +template <class _Derived> +struct __intrusive_node_base { + _Derived* __next_ = nullptr; + _Derived* __prev_ = nullptr; +}; + +// This class is a view of underlying double-linked list. +// It does not own the nodes. It provides user-friendly +// operations on the linked list. +template <class _Node> +struct __intrusive_list_view { + _LIBCPP_HIDE_FROM_ABI __intrusive_list_view() = default; + _LIBCPP_HIDE_FROM_ABI __intrusive_list_view(__intrusive_list_view const&) = default; + _LIBCPP_HIDE_FROM_ABI __intrusive_list_view(__intrusive_list_view&&) = default; + _LIBCPP_HIDE_FROM_ABI __intrusive_list_view& operator=(__intrusive_list_view const&) = default; + _LIBCPP_HIDE_FROM_ABI __intrusive_list_view& operator=(__intrusive_list_view&&) = default; + _LIBCPP_HIDE_FROM_ABI ~__intrusive_list_view() = default; + + _LIBCPP_HIDE_FROM_ABI bool __empty() const noexcept { return __head_ == nullptr; } + + _LIBCPP_HIDE_FROM_ABI void __push_front(_Node* __node) noexcept { + __node->__next_ = __head_; + if (__head_) { + __head_->__prev_ = __node; + } + __head_ = __node; + } + + _LIBCPP_HIDE_FROM_ABI _Node* __pop_front() noexcept { + _Node* __front = __head_; + __head_ = __head_->__next_; + if (__head_) { + __head_->__prev_ = nullptr; + } + // OK not to set __front->__next_ = nullptr as __front is not part of the list anymore + return __front; + } + + _LIBCPP_HIDE_FROM_ABI void __remove(_Node* __node) noexcept { + if (__node->__prev_) { + // prev exists, set its next to our next to skip __node + __node->__prev_->__next_ = __node->__next_; + if (__node->__next_) { + __node->__next_->__prev_ = __node->__prev_; + } + } else { + _LIBCPP_ASSERT_INTERNAL(__node == __head_, "Node to be removed has no prev node, so it has to be the head"); + __pop_front(); + } + } + + _LIBCPP_HIDE_FROM_ABI bool __is_head(_Node* __node) noexcept { return __node == __head_; } + +private: + _Node* __head_ = nullptr; +}; + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___STOP_TOKEN_INTRUSIVE_LIST_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/intrusive_shared_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/intrusive_shared_ptr.h new file mode 100644 index 0000000000..f00cea5bc2 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/intrusive_shared_ptr.h @@ -0,0 +1,134 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___STOP_TOKEN_INTRUSIVE_SHARED_PTR_H +#define _LIBCPP___STOP_TOKEN_INTRUSIVE_SHARED_PTR_H + +#include <__atomic/atomic.h> +#include <__atomic/memory_order.h> +#include <__config> +#include <__type_traits/is_reference.h> +#include <__utility/move.h> +#include <__utility/swap.h> +#include <cstddef> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 + +// For intrusive_shared_ptr to work with a type T, specialize __intrusive_shared_ptr_traits<T> and implement +// the following function: +// +// static std::atomic<U>& __get_atomic_ref_count(T&); +// +// where U must be an integral type representing the number of references to the object. +template <class _Tp> +struct __intrusive_shared_ptr_traits; + +// A reference counting shared_ptr for types whose reference counter +// is stored inside the class _Tp itself. +// When the reference count goes to zero, the destructor of _Tp will be called +template <class _Tp> +struct __intrusive_shared_ptr { + _LIBCPP_HIDE_FROM_ABI __intrusive_shared_ptr() = default; + + _LIBCPP_HIDE_FROM_ABI explicit __intrusive_shared_ptr(_Tp* __raw_ptr) : __raw_ptr_(__raw_ptr) { + if (__raw_ptr_) + __increment_ref_count(*__raw_ptr_); + } + + _LIBCPP_HIDE_FROM_ABI __intrusive_shared_ptr(const __intrusive_shared_ptr& __other) noexcept + : __raw_ptr_(__other.__raw_ptr_) { + if (__raw_ptr_) + __increment_ref_count(*__raw_ptr_); + } + + _LIBCPP_HIDE_FROM_ABI __intrusive_shared_ptr(__intrusive_shared_ptr&& __other) noexcept + : __raw_ptr_(__other.__raw_ptr_) { + __other.__raw_ptr_ = nullptr; + } + + _LIBCPP_HIDE_FROM_ABI __intrusive_shared_ptr& operator=(const __intrusive_shared_ptr& __other) noexcept { + if (__other.__raw_ptr_ != __raw_ptr_) { + if (__other.__raw_ptr_) { + __increment_ref_count(*__other.__raw_ptr_); + } + if (__raw_ptr_) { + __decrement_ref_count(*__raw_ptr_); + } + __raw_ptr_ = __other.__raw_ptr_; + } + return *this; + } + + _LIBCPP_HIDE_FROM_ABI __intrusive_shared_ptr& operator=(__intrusive_shared_ptr&& __other) noexcept { + __intrusive_shared_ptr(std::move(__other)).swap(*this); + return *this; + } + + _LIBCPP_HIDE_FROM_ABI ~__intrusive_shared_ptr() { + if (__raw_ptr_) { + __decrement_ref_count(*__raw_ptr_); + } + } + + _LIBCPP_HIDE_FROM_ABI _Tp* operator->() const noexcept { return __raw_ptr_; } + _LIBCPP_HIDE_FROM_ABI _Tp& operator*() const noexcept { return *__raw_ptr_; } + _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __raw_ptr_ != nullptr; } + + _LIBCPP_HIDE_FROM_ABI void swap(__intrusive_shared_ptr& __other) { std::swap(__raw_ptr_, __other.__raw_ptr_); } + + _LIBCPP_HIDE_FROM_ABI friend void swap(__intrusive_shared_ptr& __lhs, __intrusive_shared_ptr& __rhs) { + __lhs.swap(__rhs); + } + + _LIBCPP_HIDE_FROM_ABI friend bool constexpr + operator==(const __intrusive_shared_ptr&, const __intrusive_shared_ptr&) = default; + + _LIBCPP_HIDE_FROM_ABI friend bool constexpr operator==(const __intrusive_shared_ptr& __ptr, std::nullptr_t) { + return __ptr.__raw_ptr_ == nullptr; + } + +private: + _Tp* __raw_ptr_ = nullptr; + + // the memory order for increment/decrement the counter is the same for shared_ptr + // increment is relaxed and decrement is acq_rel + _LIBCPP_HIDE_FROM_ABI static void __increment_ref_count(_Tp& __obj) { + __get_atomic_ref_count(__obj).fetch_add(1, std::memory_order_relaxed); + } + + _LIBCPP_HIDE_FROM_ABI static void __decrement_ref_count(_Tp& __obj) { + if (__get_atomic_ref_count(__obj).fetch_sub(1, std::memory_order_acq_rel) == 1) { + delete &__obj; + } + } + + _LIBCPP_HIDE_FROM_ABI static decltype(auto) __get_atomic_ref_count(_Tp& __obj) { + using __ret_type = decltype(__intrusive_shared_ptr_traits<_Tp>::__get_atomic_ref_count(__obj)); + static_assert( + std::is_reference_v<__ret_type>, "__get_atomic_ref_count should return a reference to the atomic counter"); + return __intrusive_shared_ptr_traits<_Tp>::__get_atomic_ref_count(__obj); + } +}; + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___STOP_TOKEN_INTRUSIVE_SHARED_PTR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h new file mode 100644 index 0000000000..1080069cf3 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_source.h @@ -0,0 +1,92 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___STOP_TOKEN_STOP_SOURCE_H +#define _LIBCPP___STOP_TOKEN_STOP_SOURCE_H + +#include <__availability> +#include <__config> +#include <__stop_token/intrusive_shared_ptr.h> +#include <__stop_token/stop_state.h> +#include <__stop_token/stop_token.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) + +struct nostopstate_t { + explicit nostopstate_t() = default; +}; + +inline constexpr nostopstate_t nostopstate{}; + +class _LIBCPP_AVAILABILITY_SYNC stop_source { +public: + _LIBCPP_HIDE_FROM_ABI stop_source() : __state_(new __stop_state()) { __state_->__increment_stop_source_counter(); } + + _LIBCPP_HIDE_FROM_ABI explicit stop_source(nostopstate_t) noexcept : __state_(nullptr) {} + + _LIBCPP_HIDE_FROM_ABI stop_source(const stop_source& __other) noexcept : __state_(__other.__state_) { + if (__state_) { + __state_->__increment_stop_source_counter(); + } + } + + _LIBCPP_HIDE_FROM_ABI stop_source(stop_source&& __other) noexcept = default; + + _LIBCPP_HIDE_FROM_ABI stop_source& operator=(const stop_source& __other) noexcept { + // increment `__other` first so that we don't hit 0 in case of self-assignment + if (__other.__state_) { + __other.__state_->__increment_stop_source_counter(); + } + if (__state_) { + __state_->__decrement_stop_source_counter(); + } + __state_ = __other.__state_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI stop_source& operator=(stop_source&&) noexcept = default; + + _LIBCPP_HIDE_FROM_ABI ~stop_source() { + if (__state_) { + __state_->__decrement_stop_source_counter(); + } + } + + _LIBCPP_HIDE_FROM_ABI void swap(stop_source& __other) noexcept { __state_.swap(__other.__state_); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI stop_token get_token() const noexcept { return stop_token(__state_); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool stop_possible() const noexcept { return __state_ != nullptr; } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool stop_requested() const noexcept { + return __state_ != nullptr && __state_->__stop_requested(); + } + + _LIBCPP_HIDE_FROM_ABI bool request_stop() noexcept { return __state_ && __state_->__request_stop(); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend bool operator==(const stop_source&, const stop_source&) noexcept = default; + + _LIBCPP_HIDE_FROM_ABI friend void swap(stop_source& __lhs, stop_source& __rhs) noexcept { __lhs.swap(__rhs); } + +private: + __intrusive_shared_ptr<__stop_state> __state_; +}; + +#endif // _LIBCPP_STD_VER >= 20 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_state.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_state.h new file mode 100644 index 0000000000..462aa73952 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_state.h @@ -0,0 +1,236 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___STOP_TOKEN_STOP_STATE_H +#define _LIBCPP___STOP_TOKEN_STOP_STATE_H + +#include <__availability> +#include <__config> +#include <__stop_token/atomic_unique_lock.h> +#include <__stop_token/intrusive_list_view.h> +#include <__thread/id.h> +#include <atomic> +#include <cstdint> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) + +struct __stop_callback_base : __intrusive_node_base<__stop_callback_base> { + using __callback_fn_t = void(__stop_callback_base*) noexcept; + _LIBCPP_HIDE_FROM_ABI explicit __stop_callback_base(__callback_fn_t* __callback_fn) : __callback_fn_(__callback_fn) {} + + _LIBCPP_HIDE_FROM_ABI void __invoke() noexcept { __callback_fn_(this); } + + __callback_fn_t* __callback_fn_; + atomic<bool> __completed_ = false; + bool* __destroyed_ = nullptr; +}; + +class __stop_state { + static constexpr uint32_t __stop_requested_bit = 1; + static constexpr uint32_t __callback_list_locked_bit = 1 << 1; + static constexpr uint32_t __stop_source_counter_shift = 2; + + // The "stop_source counter" is not used for lifetime reference counting. + // When the number of stop_source reaches 0, the remaining stop_tokens's + // stop_possible will return false. We need this counter to track this. + // + // The "callback list locked" bit implements the atomic_unique_lock to + // guard the operations on the callback list + // + // 31 - 2 | 1 | 0 | + // stop_source counter | callback list locked | stop_requested | + atomic<uint32_t> __state_ = 0; + + // Reference count for stop_token + stop_callback + stop_source + // When the counter reaches zero, the state is destroyed + // It is used by __intrusive_shared_ptr, but it is stored here for better layout + atomic<uint32_t> __ref_count_ = 0; + + using __state_t = uint32_t; + using __callback_list_lock = __atomic_unique_lock<__state_t, __callback_list_locked_bit>; + using __callback_list = __intrusive_list_view<__stop_callback_base>; + + __callback_list __callback_list_; + __thread_id __requesting_thread_; + +public: + _LIBCPP_HIDE_FROM_ABI __stop_state() noexcept = default; + + _LIBCPP_HIDE_FROM_ABI void __increment_stop_source_counter() noexcept { + _LIBCPP_ASSERT_UNCATEGORIZED( + __state_.load(std::memory_order_relaxed) <= static_cast<__state_t>(~(1 << __stop_source_counter_shift)), + "stop_source's counter reaches the maximum. Incrementing the counter will overflow"); + __state_.fetch_add(1 << __stop_source_counter_shift, std::memory_order_relaxed); + } + + // We are not destroying the object after counter decrements to zero, nor do we have + // operations depend on the ordering of decrementing the counter. relaxed is enough. + _LIBCPP_HIDE_FROM_ABI void __decrement_stop_source_counter() noexcept { + _LIBCPP_ASSERT_UNCATEGORIZED( + __state_.load(std::memory_order_relaxed) >= static_cast<__state_t>(1 << __stop_source_counter_shift), + "stop_source's counter is 0. Decrementing the counter will underflow"); + __state_.fetch_sub(1 << __stop_source_counter_shift, std::memory_order_relaxed); + } + + _LIBCPP_HIDE_FROM_ABI bool __stop_requested() const noexcept { + // acquire because [thread.stoptoken.intro] A call to request_stop that returns true + // synchronizes with a call to stop_requested on an associated stop_token or stop_source + // object that returns true. + // request_stop's compare_exchange_weak has release which syncs with this acquire + return (__state_.load(std::memory_order_acquire) & __stop_requested_bit) != 0; + } + + _LIBCPP_HIDE_FROM_ABI bool __stop_possible_for_stop_token() const noexcept { + // [stoptoken.mem] false if "a stop request was not made and there are no associated stop_source objects" + // Todo: Can this be std::memory_order_relaxed as the standard does not say anything except not to introduce data + // race? + __state_t __curent_state = __state_.load(std::memory_order_acquire); + return ((__curent_state & __stop_requested_bit) != 0) || ((__curent_state >> __stop_source_counter_shift) != 0); + } + + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __request_stop() noexcept { + auto __cb_list_lock = __try_lock_for_request_stop(); + if (!__cb_list_lock.__owns_lock()) { + return false; + } + __requesting_thread_ = this_thread::get_id(); + + while (!__callback_list_.__empty()) { + auto __cb = __callback_list_.__pop_front(); + + // allow other callbacks to be removed while invoking the current callback + __cb_list_lock.__unlock(); + + bool __destroyed = false; + __cb->__destroyed_ = &__destroyed; + + __cb->__invoke(); + + // __cb's invoke function could potentially delete itself. We need to check before accessing __cb's member + if (!__destroyed) { + // needs to set __destroyed_ pointer to nullptr, otherwise it points to a local variable + // which is to be destroyed at the end of the loop + __cb->__destroyed_ = nullptr; + + // [stopcallback.cons] If callback is concurrently executing on another thread, then the return + // from the invocation of callback strongly happens before ([intro.races]) callback is destroyed. + // this release syncs with the acquire in the remove_callback + __cb->__completed_.store(true, std::memory_order_release); + __cb->__completed_.notify_all(); + } + + __cb_list_lock.__lock(); + } + + return true; + } + + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __add_callback(__stop_callback_base* __cb) noexcept { + // If it is already stop_requested. Do not try to request it again. + const auto __give_up_trying_to_lock_condition = [__cb](__state_t __state) { + if ((__state & __stop_requested_bit) != 0) { + // already stop requested, synchronously run the callback and no need to lock the list again + __cb->__invoke(); + return true; + } + // no stop source. no need to lock the list to add the callback as it can never be invoked + return (__state >> __stop_source_counter_shift) == 0; + }; + + __callback_list_lock __cb_list_lock(__state_, __give_up_trying_to_lock_condition); + + if (!__cb_list_lock.__owns_lock()) { + return false; + } + + __callback_list_.__push_front(__cb); + + return true; + // unlock here: [thread.stoptoken.intro] Registration of a callback synchronizes with the invocation of + // that callback. + // Note: this release sync with the acquire in the request_stop' __try_lock_for_request_stop + } + + // called by the destructor of stop_callback + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __remove_callback(__stop_callback_base* __cb) noexcept { + __callback_list_lock __cb_list_lock(__state_); + + // under below condition, the request_stop call just popped __cb from the list and could execute it now + bool __potentially_executing_now = __cb->__prev_ == nullptr && !__callback_list_.__is_head(__cb); + + if (__potentially_executing_now) { + auto __requested_thread = __requesting_thread_; + __cb_list_lock.__unlock(); + + if (std::this_thread::get_id() != __requested_thread) { + // [stopcallback.cons] If callback is concurrently executing on another thread, then the return + // from the invocation of callback strongly happens before ([intro.races]) callback is destroyed. + __cb->__completed_.wait(false, std::memory_order_acquire); + } else { + // The destructor of stop_callback runs on the same thread of the thread that invokes the callback. + // The callback is potentially invoking its own destuctor. Set the flag to avoid accessing destroyed + // members on the invoking side + if (__cb->__destroyed_) { + *__cb->__destroyed_ = true; + } + } + } else { + __callback_list_.__remove(__cb); + } + } + +private: + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI __callback_list_lock __try_lock_for_request_stop() noexcept { + // If it is already stop_requested, do not try to request stop or lock the list again. + const auto __lock_fail_condition = [](__state_t __state) { return (__state & __stop_requested_bit) != 0; }; + + // set locked and requested bit at the same time + const auto __after_lock_state = [](__state_t __state) { + return __state | __callback_list_locked_bit | __stop_requested_bit; + }; + + // acq because [thread.stoptoken.intro] Registration of a callback synchronizes with the invocation of that + // callback. We are going to invoke the callback after getting the lock, acquire so that we can see the + // registration of a callback (and other writes that happens-before the add_callback) + // Note: the rel (unlock) in the add_callback syncs with this acq + // rel because [thread.stoptoken.intro] A call to request_stop that returns true synchronizes with a call + // to stop_requested on an associated stop_token or stop_source object that returns true. + // We need to make sure that all writes (including user code) before request_stop will be made visible + // to the threads that waiting for `stop_requested == true` + // Note: this rel syncs with the acq in `stop_requested` + const auto __locked_ordering = std::memory_order_acq_rel; + + return __callback_list_lock(__state_, __lock_fail_condition, __after_lock_state, __locked_ordering); + } + + template <class _Tp> + friend struct __intrusive_shared_ptr_traits; +}; + +template <class _Tp> +struct __intrusive_shared_ptr_traits; + +template <> +struct __intrusive_shared_ptr_traits<__stop_state> { + _LIBCPP_HIDE_FROM_ABI static atomic<uint32_t>& __get_atomic_ref_count(__stop_state& __state) { + return __state.__ref_count_; + } +}; + +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___STOP_TOKEN_STOP_STATE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h new file mode 100644 index 0000000000..f2eadb990b --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__stop_token/stop_token.h @@ -0,0 +1,64 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H +#define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H + +#include <__availability> +#include <__config> +#include <__stop_token/intrusive_shared_ptr.h> +#include <__stop_token/stop_state.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) + +class _LIBCPP_AVAILABILITY_SYNC stop_token { +public: + _LIBCPP_HIDE_FROM_ABI stop_token() noexcept = default; + + _LIBCPP_HIDE_FROM_ABI stop_token(const stop_token&) noexcept = default; + _LIBCPP_HIDE_FROM_ABI stop_token(stop_token&&) noexcept = default; + _LIBCPP_HIDE_FROM_ABI stop_token& operator=(const stop_token&) noexcept = default; + _LIBCPP_HIDE_FROM_ABI stop_token& operator=(stop_token&&) noexcept = default; + _LIBCPP_HIDE_FROM_ABI ~stop_token() = default; + + _LIBCPP_HIDE_FROM_ABI void swap(stop_token& __other) noexcept { __state_.swap(__other.__state_); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool stop_requested() const noexcept { + return __state_ != nullptr && __state_->__stop_requested(); + } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool stop_possible() const noexcept { + return __state_ != nullptr && __state_->__stop_possible_for_stop_token(); + } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend bool operator==(const stop_token&, const stop_token&) noexcept = default; + + _LIBCPP_HIDE_FROM_ABI friend void swap(stop_token& __lhs, stop_token& __rhs) noexcept { __lhs.swap(__rhs); } + +private: + __intrusive_shared_ptr<__stop_state> __state_; + + friend class stop_source; + template <class _Tp> + friend class stop_callback; + + _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {} +}; + +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___STOP_TOKEN_STOP_TOKEN_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h b/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h index c201fc9a1c..ca9867c390 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h +++ b/contrib/libs/cxxsupp/libcxx/include/__string/char_traits.h @@ -73,8 +73,9 @@ exposition-only to document what members a char_traits specialization should pro // // Temporary extension to provide a base template for std::char_traits. -// TODO(LLVM-18): Remove this class. +// TODO(LLVM-19): Remove this class. // +#if !defined(_LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION) template <class _CharT> struct _LIBCPP_DEPRECATED_("char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 18, so please migrate off of it.") char_traits @@ -170,6 +171,7 @@ struct _LIBCPP_DEPRECATED_("char_traits<T> for T not equal to char, wchar_t, cha static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(EOF);} }; +#endif // !defined(_LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION) // char_traits<char> diff --git a/contrib/libs/cxxsupp/libcxx/include/__system_error/error_code.h b/contrib/libs/cxxsupp/libcxx/include/__system_error/error_code.h index d05e68529f..475f2bb96a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__system_error/error_code.h +++ b/contrib/libs/cxxsupp/libcxx/include/__system_error/error_code.h @@ -49,9 +49,8 @@ public: _LIBCPP_HIDE_FROM_ABI error_code(int __val, const error_category& __cat) _NOEXCEPT : __val_(__val), __cat_(&__cat) {} - template <class _Ep> - _LIBCPP_HIDE_FROM_ABI - error_code(_Ep __e, typename enable_if<is_error_code_enum<_Ep>::value>::type* = nullptr) _NOEXCEPT { + template <class _Ep, __enable_if_t<is_error_code_enum<_Ep>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI error_code(_Ep __e) _NOEXCEPT { using __adl_only::make_error_code; *this = make_error_code(__e); } @@ -61,9 +60,8 @@ public: __cat_ = &__cat; } - template <class _Ep> - _LIBCPP_HIDE_FROM_ABI typename enable_if< is_error_code_enum<_Ep>::value, error_code& >::type - operator=(_Ep __e) _NOEXCEPT { + template <class _Ep, __enable_if_t<is_error_code_enum<_Ep>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI error_code& operator=(_Ep __e) _NOEXCEPT { using __adl_only::make_error_code; *this = make_error_code(__e); return *this; diff --git a/contrib/libs/cxxsupp/libcxx/include/__system_error/error_condition.h b/contrib/libs/cxxsupp/libcxx/include/__system_error/error_condition.h index a43a73cdc2..42898c1f0e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__system_error/error_condition.h +++ b/contrib/libs/cxxsupp/libcxx/include/__system_error/error_condition.h @@ -58,9 +58,8 @@ public: : __val_(__val), __cat_(&__cat) {} - template <class _Ep> - _LIBCPP_HIDE_FROM_ABI - error_condition(_Ep __e, typename enable_if<is_error_condition_enum<_Ep>::value>::type* = nullptr) _NOEXCEPT { + template <class _Ep, __enable_if_t<is_error_condition_enum<_Ep>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI error_condition(_Ep __e) _NOEXCEPT { using __adl_only::make_error_condition; *this = make_error_condition(__e); } @@ -70,9 +69,8 @@ public: __cat_ = &__cat; } - template <class _Ep> - _LIBCPP_HIDE_FROM_ABI typename enable_if< is_error_condition_enum<_Ep>::value, error_condition& >::type - operator=(_Ep __e) _NOEXCEPT { + template <class _Ep, __enable_if_t<is_error_condition_enum<_Ep>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI error_condition& operator=(_Ep __e) _NOEXCEPT { using __adl_only::make_error_condition; *this = make_error_condition(__e); return *this; diff --git a/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h b/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h index bc829491a4..362e675056 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h +++ b/contrib/libs/cxxsupp/libcxx/include/__system_error/system_error.h @@ -13,6 +13,7 @@ #include <__config> #include <__system_error/error_category.h> #include <__system_error/error_code.h> +#include <__verbose_abort> #include <stdexcept> #include <string> @@ -36,12 +37,17 @@ public: ~system_error() _NOEXCEPT override; _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; } - -private: - static string __init(const error_code&, string); }; _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); +_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS + throw system_error(__ec, __what_arg); +#else + _LIBCPP_VERBOSE_ABORT( + "system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", __ec.value(), __what_arg); +#endif +} _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h b/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h new file mode 100644 index 0000000000..fc86b13afb --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__thread/jthread.h @@ -0,0 +1,130 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___THREAD_JTHREAD_H +#define _LIBCPP___THREAD_JTHREAD_H + +#include <__availability> +#include <__config> +#include <__functional/invoke.h> +#include <__stop_token/stop_source.h> +#include <__stop_token/stop_token.h> +#include <__thread/thread.h> +#include <__threading_support> +#include <__type_traits/decay.h> +#include <__type_traits/is_constructible.h> +#include <__type_traits/is_same.h> +#include <__type_traits/remove_cvref.h> +#include <__utility/forward.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) + +_LIBCPP_BEGIN_NAMESPACE_STD + +class _LIBCPP_AVAILABILITY_SYNC jthread { +public: + // types + using id = thread::id; + using native_handle_type = thread::native_handle_type; + + // [thread.jthread.cons], constructors, move, and assignment + _LIBCPP_HIDE_FROM_ABI jthread() noexcept : __stop_source_(std::nostopstate) {} + + template <class _Fun, class... _Args> + _LIBCPP_HIDE_FROM_ABI explicit jthread(_Fun&& __fun, _Args&&... __args) + requires(!std::is_same_v<remove_cvref_t<_Fun>, jthread>) + : __stop_source_(), + __thread_(__init_thread(__stop_source_, std::forward<_Fun>(__fun), std::forward<_Args>(__args)...)) { + static_assert(is_constructible_v<decay_t<_Fun>, _Fun>); + static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...)); + static_assert(is_invocable_v<decay_t<_Fun>, decay_t<_Args>...> || + is_invocable_v<decay_t<_Fun>, stop_token, decay_t<_Args>...>); + } + + _LIBCPP_HIDE_FROM_ABI ~jthread() { + if (joinable()) { + request_stop(); + join(); + } + } + + jthread(const jthread&) = delete; + + _LIBCPP_HIDE_FROM_ABI jthread(jthread&&) noexcept = default; + + jthread& operator=(const jthread&) = delete; + + _LIBCPP_HIDE_FROM_ABI jthread& operator=(jthread&& __other) noexcept { + if (this != &__other) { + if (joinable()) { + request_stop(); + join(); + } + __stop_source_ = std::move(__other.__stop_source_); + __thread_ = std::move(__other.__thread_); + } + + return *this; + } + + // [thread.jthread.mem], members + _LIBCPP_HIDE_FROM_ABI void swap(jthread& __other) noexcept { + std::swap(__stop_source_, __other.__stop_source_); + std::swap(__thread_, __other.__thread_); + } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool joinable() const noexcept { return get_id() != id(); } + + _LIBCPP_HIDE_FROM_ABI void join() { __thread_.join(); } + + _LIBCPP_HIDE_FROM_ABI void detach() { __thread_.detach(); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI id get_id() const noexcept { return __thread_.get_id(); } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __thread_.native_handle(); } + + // [thread.jthread.stop], stop token handling + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI stop_source get_stop_source() noexcept { return __stop_source_; } + + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI stop_token get_stop_token() const noexcept { return __stop_source_.get_token(); } + + _LIBCPP_HIDE_FROM_ABI bool request_stop() noexcept { return __stop_source_.request_stop(); } + + // [thread.jthread.special], specialized algorithms + _LIBCPP_HIDE_FROM_ABI friend void swap(jthread& __lhs, jthread& __rhs) noexcept { __lhs.swap(__rhs); } + + // [thread.jthread.static], static members + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static unsigned int hardware_concurrency() noexcept { + return thread::hardware_concurrency(); + } + +private: + template <class _Fun, class... _Args> + _LIBCPP_HIDE_FROM_ABI static thread __init_thread(const stop_source& __ss, _Fun&& __fun, _Args&&... __args) { + if constexpr (is_invocable_v<decay_t<_Fun>, stop_token, decay_t<_Args>...>) { + return thread(std::forward<_Fun>(__fun), __ss.get_token(), std::forward<_Args>(__args)...); + } else { + return thread(std::forward<_Fun>(__fun), std::forward<_Args>(__args)...); + } + } + + stop_source __stop_source_; + thread __thread_; +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) + +#endif // _LIBCPP___THREAD_JTHREAD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__threading_support b/contrib/libs/cxxsupp/libcxx/include/__threading_support index 1dc5017476..e7c595a8f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__threading_support +++ b/contrib/libs/cxxsupp/libcxx/include/__threading_support @@ -14,7 +14,8 @@ #include <__chrono/convert_to_timespec.h> #include <__chrono/duration.h> #include <__config> -#include <__thread/poll_with_backoff.h> +#include <__fwd/hash.h> +#include <ctime> #include <errno.h> #ifdef __MVS__ @@ -101,7 +102,7 @@ typedef cnd_t __libcpp_condvar_t; #define _LIBCPP_CONDVAR_INITIALIZER {} // Execute once -typedef once_flag __libcpp_exec_once_flag; +typedef ::once_flag __libcpp_exec_once_flag; #define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT // Thread id diff --git a/contrib/libs/cxxsupp/libcxx/include/__tree b/contrib/libs/cxxsupp/libcxx/include/__tree index 58d4a97c04..eccadea8a0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tree +++ b/contrib/libs/cxxsupp/libcxx/include/__tree @@ -615,9 +615,9 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { return __t.__get_value().first; } - template <class _Up> + template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, key_type const&> + static key_type const& __get_key(_Up& __t) { return __t.first; } @@ -774,6 +774,8 @@ public: __node_value_type __value_; + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } + private: ~__tree_node() = delete; __tree_node(__tree_node const&) = delete; @@ -1186,9 +1188,10 @@ public: __can_extract_key<_Pp, key_type>()); } - template <class _First, class _Second> + template <class _First, class _Second, + __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, pair<iterator, bool> > + pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) { return __emplace_unique_key_args(__f, _VSTD::forward<_First>(__f), _VSTD::forward<_Second>(__s)); @@ -1228,9 +1231,10 @@ public: __can_extract_key<_Pp, key_type>()); } - template <class _First, class _Second> + template <class _First, class _Second, + __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, iterator> + iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { return __emplace_hint_unique_key_args(__p, __f, _VSTD::forward<_First>(__f), diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h index f3c00e7ede..a6463bfa59 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/invoke.h @@ -240,11 +240,12 @@ template <class _Fp, class _DecayA0 = __decay_t<_A0>, class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> using __enable_if_bullet1 = - typename enable_if<is_member_function_pointer<_DecayFp>::value && is_base_of<_ClassT, _DecayA0>::value >::type; + __enable_if_t<is_member_function_pointer<_DecayFp>::value && + (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>; template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> > using __enable_if_bullet2 = - typename enable_if<is_member_function_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value >::type; + __enable_if_t<is_member_function_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>; template <class _Fp, class _A0, @@ -252,8 +253,9 @@ template <class _Fp, class _DecayA0 = __decay_t<_A0>, class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> using __enable_if_bullet3 = - typename enable_if<is_member_function_pointer<_DecayFp>::value && !is_base_of<_ClassT, _DecayA0>::value && - !__is_reference_wrapper<_DecayA0>::value >::type; + __enable_if_t<is_member_function_pointer<_DecayFp>::value && + !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) && + !__is_reference_wrapper<_DecayA0>::value>; template <class _Fp, class _A0, @@ -261,11 +263,12 @@ template <class _Fp, class _DecayA0 = __decay_t<_A0>, class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> using __enable_if_bullet4 = - typename enable_if<is_member_object_pointer<_DecayFp>::value && is_base_of<_ClassT, _DecayA0>::value >::type; + __enable_if_t<is_member_object_pointer<_DecayFp>::value && + (is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value)>; template <class _Fp, class _A0, class _DecayFp = __decay_t<_Fp>, class _DecayA0 = __decay_t<_A0> > using __enable_if_bullet5 = - typename enable_if<is_member_object_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value >::type; + __enable_if_t<is_member_object_pointer<_DecayFp>::value && __is_reference_wrapper<_DecayA0>::value>; template <class _Fp, class _A0, @@ -273,8 +276,9 @@ template <class _Fp, class _DecayA0 = __decay_t<_A0>, class _ClassT = typename __member_pointer_class_type<_DecayFp>::type> using __enable_if_bullet6 = - typename enable_if<is_member_object_pointer<_DecayFp>::value && !is_base_of<_ClassT, _DecayA0>::value && - !__is_reference_wrapper<_DecayA0>::value >::type; + __enable_if_t<is_member_object_pointer<_DecayFp>::value && + !(is_same<_ClassT, _DecayA0>::value || is_base_of<_ClassT, _DecayA0>::value) && + !__is_reference_wrapper<_DecayA0>::value>; // __invoke forward declarations diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_convertible.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_convertible.h index 4b189f0327..bc91d8b234 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_convertible.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_convertible.h @@ -24,89 +24,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_convertible) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) && !defined(__CUDACC__) - template <class _T1, class _T2> struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible(_T1, _T2)> {}; -#elif __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) && !defined(__CUDACC__) - -template <class _T1, class _T2> -struct _LIBCPP_TEMPLATE_VIS is_convertible : public integral_constant<bool, __is_convertible_to(_T1, _T2)> {}; - -// TODO: Remove this fallback when GCC < 13 support is no longer required. -// GCC 13 has the __is_convertible built-in. -#else // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) - -namespace __is_convertible_imp { -template <class _Tp> -void __test_convert(_Tp); - -template <class _From, class _To, class = void> -struct __is_convertible_test : public false_type {}; - -template <class _From, class _To> -struct __is_convertible_test<_From, _To, decltype(__is_convertible_imp::__test_convert<_To>(std::declval<_From>()))> - : public true_type {}; - -// clang-format off -template <class _Tp, - bool _IsArray = is_array<_Tp>::value, - bool _IsFunction = is_function<_Tp>::value, - bool _IsVoid = is_void<_Tp>::value> - struct __is_array_function_or_void { enum { value = 0 }; }; -template <class _Tp> struct __is_array_function_or_void<_Tp, true, false, false> { enum { value = 1 }; }; -template <class _Tp> struct __is_array_function_or_void<_Tp, false, true, false> { enum { value = 2 }; }; -template <class _Tp> struct __is_array_function_or_void<_Tp, false, false, true> { enum { value = 3 }; }; -// clang-format on -} // namespace __is_convertible_imp - -template <class _Tp, - unsigned = __is_convertible_imp::__is_array_function_or_void<__libcpp_remove_reference_t<_Tp> >::value> -struct __is_convertible_check { - static const size_t __v = 0; -}; - -template <class _Tp> -struct __is_convertible_check<_Tp, 0> { - static const size_t __v = sizeof(_Tp); -}; - -template <class _T1, - class _T2, - unsigned _T1_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T1>::value, - unsigned _T2_is_array_function_or_void = __is_convertible_imp::__is_array_function_or_void<_T2>::value> -struct __is_convertible - : public integral_constant<bool, __is_convertible_imp::__is_convertible_test<_T1, _T2>::value >{}; - -// clang-format off -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 1> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 1> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 1> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 1> : public false_type{}; - -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 2> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 2> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 2> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 2> : public false_type{}; - -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 0, 3> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type{}; -template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type{}; -// clang-format on - -template <class _T1, class _T2> -struct _LIBCPP_TEMPLATE_VIS is_convertible : public __is_convertible<_T1, _T2> { - static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; - static const size_t __complete_check2 = __is_convertible_check<_T2>::__v; -}; - -#endif // __has_builtin(__is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) - #if _LIBCPP_STD_VER >= 17 template <class _From, class _To> -inline constexpr bool is_convertible_v = is_convertible<_From, _To>::value; +inline constexpr bool is_convertible_v = __is_convertible(_From, _To); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h index 07c5661985..ea8c03a8aa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/is_swappable.h @@ -37,7 +37,7 @@ struct __is_nothrow_swappable; #ifndef _LIBCPP_CXX03_LANG template <class _Tp> -using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type; +using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>; #else template <class> using __swap_result_t = void; @@ -47,10 +47,9 @@ template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y) _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value); -template <class _Tp, size_t _Np> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - typename enable_if<__is_swappable<_Tp>::value>::type swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) - _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); +template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> = 0> +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) + _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value); namespace __detail { // ALL generic swap overloads MUST already have a declaration available at this point. diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/convert_to_integral.h b/contrib/libs/cxxsupp/libcxx/include/__utility/convert_to_integral.h index 0cc858ad15..adead18e05 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/convert_to_integral.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/convert_to_integral.h @@ -39,9 +39,9 @@ long long __convert_to_integral(long long __val) { return __val; } inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } -template<typename _Fp> +template<typename _Fp, __enable_if_t<is_floating_point<_Fp>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR -typename enable_if<is_floating_point<_Fp>::value, long long>::type +long long __convert_to_integral(_Fp __val) { return __val; } #ifndef _LIBCPP_HAS_NO_INT128 diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h b/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h index 6b8c43dbe6..62dac6dd1d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h @@ -165,34 +165,28 @@ struct _LIBCPP_TEMPLATE_VIS pair using _CheckArgsDep _LIBCPP_NODEBUG = typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type; - template<bool _Dummy = true, typename enable_if< - _CheckArgsDep<_Dummy>::__enable_explicit_default() - >::type* = nullptr> + template<bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_explicit_default(), int> = 0> explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value) : first(), second() {} - template<bool _Dummy = true, typename enable_if< - _CheckArgsDep<_Dummy>::__enable_implicit_default() - >::type* = nullptr> + template<bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_implicit_default(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value) : first(), second() {} - template <bool _Dummy = true, typename enable_if< - _CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>() - >::type* = nullptr> + template <bool _Dummy = true, + __enable_if_t<_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(_T1 const& __t1, _T2 const& __t2) _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && is_nothrow_copy_constructible<second_type>::value) : first(__t1), second(__t2) {} - template<bool _Dummy = true, typename enable_if< - _CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>() - >::type* = nullptr> + template<bool _Dummy = true, + __enable_if_t<_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(_T1 const& __t1, _T2 const& __t2) _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value && @@ -205,7 +199,7 @@ struct _LIBCPP_TEMPLATE_VIS pair #else class _U1, class _U2, #endif - typename enable_if<_CheckArgs::template __enable_explicit<_U1, _U2>()>::type* = nullptr + __enable_if_t<_CheckArgs::template __enable_explicit<_U1, _U2>(), int> = 0 > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(_U1&& __u1, _U2&& __u2) @@ -219,7 +213,7 @@ struct _LIBCPP_TEMPLATE_VIS pair #else class _U1, class _U2, #endif - typename enable_if<_CheckArgs::template __enable_implicit<_U1, _U2>()>::type* = nullptr + __enable_if_t<_CheckArgs::template __enable_implicit<_U1, _U2>(), int> = 0 > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(_U1&& __u1, _U2&& __u2) @@ -238,36 +232,28 @@ struct _LIBCPP_TEMPLATE_VIS pair : first(__p.first), second(__p.second) {} #endif - template<class _U1, class _U2, typename enable_if< - _CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>() - >::type* = nullptr> + template<class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2> const& __p) _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && is_nothrow_constructible<second_type, _U2 const&>::value)) : first(__p.first), second(__p.second) {} - template<class _U1, class _U2, typename enable_if< - _CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>() - >::type* = nullptr> + template<class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(pair<_U1, _U2> const& __p) _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value && is_nothrow_constructible<second_type, _U2 const&>::value)) : first(__p.first), second(__p.second) {} - template<class _U1, class _U2, typename enable_if< - _CheckArgs::template __enable_explicit<_U1, _U2>() - >::type* = nullptr> + template<class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_explicit<_U1, _U2>(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2>&&__p) _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && is_nothrow_constructible<second_type, _U2&&>::value)) : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {} - template<class _U1, class _U2, typename enable_if< - _CheckArgs::template __enable_implicit<_U1, _U2>() - >::type* = nullptr> + template<class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_implicit<_U1, _U2>(), int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(pair<_U1, _U2>&& __p) _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value && @@ -688,14 +674,9 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> { }; #endif // _LIBCPP_STD_VER >= 23 -template <class _T1, class _T2> +template <class _T1, class _T2, __enable_if_t<__is_swappable<_T1>::value && __is_swappable<_T2>::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - __is_swappable<_T1>::value && - __is_swappable<_T2>::value, - void ->::type +void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value)) diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h b/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h index 767f69cc2f..91c928a9fd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/swap.h @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_CXX03_LANG template <class _Tp> -using __swap_result_t = typename enable_if<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>::type; +using __swap_result_t = __enable_if_t<is_move_constructible<_Tp>::value && is_move_assignable<_Tp>::value>; #else template <class> using __swap_result_t = void; @@ -44,9 +44,9 @@ inline _LIBCPP_INLINE_VISIBILITY __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CX __y = _VSTD::move(__t); } -template <class _Tp, size_t _Np> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if<__is_swappable<_Tp>::value>::type -swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { +template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> > +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) + _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { for (size_t __i = 0; __i != _Np; ++__i) { swap(__a[__i], __b[__i]); } diff --git a/contrib/libs/cxxsupp/libcxx/include/algorithm b/contrib/libs/cxxsupp/libcxx/include/algorithm index 7813f67f2c..97408acee1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/algorithm +++ b/contrib/libs/cxxsupp/libcxx/include/algorithm @@ -447,6 +447,22 @@ namespace ranges { indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> constexpr bool ranges::any_of(R&& r, Pred pred, Proj proj = {}); // since C++20 + template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2, + class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> + requires (forward_iterator<I1> || sized_sentinel_for<S1, I1>) && + (forward_iterator<I2> || sized_sentinel_for<S2, I2>) && + indirectly_comparable<I1, I2, Pred, Proj1, Proj2> + constexpr bool ranges::ends_with(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 + + template<input_range R1, input_range R2, class Pred = ranges::equal_to, class Proj1 = identity, + class Proj2 = identity> + requires (forward_range<R1> || sized_range<R1>) && + (forward_range<R2> || sized_range<R2>) && + indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2> + constexpr bool ranges::ends_with(R1&& r1, R2&& r2, Pred pred = {}, + Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23 + template<input_iterator I, sentinel_for<I> S, class Proj = identity, indirect_unary_predicate<projected<I, Proj>> Pred> constexpr bool ranges::none_of(I first, S last, Pred pred, Proj proj = {}); // since C++20 @@ -1833,6 +1849,7 @@ template <class BidirectionalIterator, class Compare> #include <__algorithm/ranges_copy_n.h> #include <__algorithm/ranges_count.h> #include <__algorithm/ranges_count_if.h> +#include <__algorithm/ranges_ends_with.h> #include <__algorithm/ranges_equal.h> #include <__algorithm/ranges_equal_range.h> #include <__algorithm/ranges_fill.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/array b/contrib/libs/cxxsupp/libcxx/include/array index 3fc25d4c30..c01d13ef35 100644 --- a/contrib/libs/cxxsupp/libcxx/include/array +++ b/contrib/libs/cxxsupp/libcxx/include/array @@ -444,9 +444,9 @@ operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { #endif // _LIBCPP_STD_VER <= 17 -template <class _Tp, size_t _Size> +template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -__enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, void> +void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) _NOEXCEPT_(noexcept(__x.swap(__y))) { diff --git a/contrib/libs/cxxsupp/libcxx/include/bit b/contrib/libs/cxxsupp/libcxx/include/bit index 6b35bb2c7a..84e2080377 100644 --- a/contrib/libs/cxxsupp/libcxx/include/bit +++ b/contrib/libs/cxxsupp/libcxx/include/bit @@ -34,9 +34,9 @@ namespace std { // [bit.rotate], rotating template<class T> - constexpr T rotl(T x, unsigned int s) noexcept; // C++20 + constexpr T rotl(T x, int s) noexcept; // C++20 template<class T> - constexpr T rotr(T x, unsigned int s) noexcept; // C++20 + constexpr T rotr(T x, int s) noexcept; // C++20 // [bit.count], counting template<class T> diff --git a/contrib/libs/cxxsupp/libcxx/include/bitset b/contrib/libs/cxxsupp/libcxx/include/bitset index 2a14b7a2e9..7ad332cc0d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/bitset +++ b/contrib/libs/cxxsupp/libcxx/include/bitset @@ -40,15 +40,25 @@ public: constexpr bitset() noexcept; constexpr bitset(unsigned long long val) noexcept; template <class charT> - explicit bitset(const charT* str, - typename basic_string<charT>::size_type n = basic_string<charT>::npos, - charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 + constexpr explicit bitset(const charT* str, + typename basic_string<charT>::size_type n = basic_string<charT>::npos, + charT zero = charT('0'), charT one = charT('1')); // until C++26, constexpr since C++23 + template <class charT> + constexpr explicit bitset(const charT* str, + typename basic_string_view<charT>::size_type n = basic_string_view<charT>::npos, + charT zero = charT('0'), charT one = charT('1')); // since C++26 + template<class charT, class traits> + explicit bitset( + const basic_string_view<charT,traits>& str, + typename basic_string_view<charT,traits>::size_type pos = 0, + typename basic_string_view<charT,traits>::size_type n = basic_string_view<charT,traits>::npos, + charT zero = charT('0'), charT one = charT('1')); // since C++26 template<class charT, class traits, class Allocator> - explicit bitset(const basic_string<charT,traits,Allocator>& str, - typename basic_string<charT,traits,Allocator>::size_type pos = 0, - typename basic_string<charT,traits,Allocator>::size_type n = - basic_string<charT,traits,Allocator>::npos, - charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 + constexpr explicit bitset( + const basic_string<charT,traits,Allocator>& str, + typename basic_string<charT,traits,Allocator>::size_type pos = 0, + typename basic_string<charT,traits,Allocator>::size_type n = basic_string<charT,traits,Allocator>::npos, + charT zero = charT('0'), charT one = charT('1')); // constexpr since C++23 // 23.3.5.2 bitset operations: bitset& operator&=(const bitset& rhs) noexcept; // constexpr since C++23 @@ -113,6 +123,7 @@ template <size_t N> struct hash<std::bitset<N>>; */ #include <__algorithm/fill.h> +#include <__algorithm/find.h> #include <__assert> // all public C++ headers provide the assertion handler #include <__bit_reference> #include <__config> @@ -699,13 +710,32 @@ public: template <class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> > _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( const _CharT* __str, +# if _LIBCPP_STD_VER >= 26 + typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos, +# else typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos, - _CharT __zero = _CharT('0'), - _CharT __one = _CharT('1')) { +# endif + _CharT __zero = _CharT('0'), + _CharT __one = _CharT('1')) { size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str)); __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one); } +#if _LIBCPP_STD_VER >= 26 + template <class _CharT, class _Traits> + _LIBCPP_HIDE_FROM_ABI constexpr explicit bitset( + basic_string_view<_CharT, _Traits> __str, + typename basic_string_view<_CharT, _Traits>::size_type __pos = 0, + typename basic_string_view<_CharT, _Traits>::size_type __n = basic_string_view<_CharT, _Traits>::npos, + _CharT __zero = _CharT('0'), + _CharT __one = _CharT('1')) { + if (__pos > __str.size()) + __throw_out_of_range("bitset string pos out of range"); + + size_t __rlen = std::min(__n, __str.size() - __pos); + __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one); + } +#endif template <class _CharT, class _Traits, class _Allocator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset( const basic_string<_CharT, _Traits, _Allocator>& __str, @@ -1016,7 +1046,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 size_t bitset<_Size>::count() const _NOEXCEPT { - return static_cast<size_t>(_VSTD::__count_bool_true(base::__make_iter(0), _Size)); + return static_cast<size_t>(_VSTD::__count_bool<true>(base::__make_iter(0), _Size)); } template <size_t _Size> diff --git a/contrib/libs/cxxsupp/libcxx/include/charconv b/contrib/libs/cxxsupp/libcxx/include/charconv index 5b6c72ea7f..92273b4ce4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/charconv +++ b/contrib/libs/cxxsupp/libcxx/include/charconv @@ -28,6 +28,7 @@ namespace std { char* ptr; errc ec; friend bool operator==(const to_chars_result&, const to_chars_result&) = default; // since C++20 + constexpr explicit operator bool() const noexcept { return ec == errc{}; } // since C++26 }; constexpr to_chars_result to_chars(char* first, char* last, see below value, @@ -58,6 +59,7 @@ namespace std { const char* ptr; errc ec; friend bool operator==(const from_chars_result&, const from_chars_result&) = default; // since C++20 + constexpr explicit operator bool() const noexcept { return ec == errc{}; } // since C++26 }; constexpr from_chars_result from_chars(const char* first, const char* last, diff --git a/contrib/libs/cxxsupp/libcxx/include/chrono b/contrib/libs/cxxsupp/libcxx/include/chrono index ee3da8089f..db4b831cfc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/chrono +++ b/contrib/libs/cxxsupp/libcxx/include/chrono @@ -677,6 +677,39 @@ constexpr bool is_pm(hours const& h) noexcept; constexpr hours make12(const hours& h) noexcept; constexpr hours make24(const hours& h, bool is_pm) noexcept; +// [time.zone.db], time zone database +struct tzdb { // C++20 + string version; +}; + +class tzdb_list { // C++20 +public: + tzdb_list(const tzdb_list&) = delete; + tzdb_list& operator=(const tzdb_list&) = delete; + + // unspecified additional constructors + + class const_iterator; + + const tzdb& front() const noexcept; + + const_iterator erase_after(const_iterator p); + + const_iterator begin() const noexcept; + const_iterator end() const noexcept; + + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; +}; + +// [time.zone.db.access], time zone database access +const tzdb& get_tzdb(); // C++20 +tzdb_list& get_tzdb_list(); // C++20 + +// [time.zone.db.remote], remote time zone database support +const tzdb& reload_tzdb(); // C++20 +string remote_version(); // C++20 + // 25.10.5, class time_zone // C++20 enum class choose {earliest, latest}; class time_zone; @@ -799,6 +832,11 @@ constexpr chrono::year operator ""y(unsigned lo # include <__chrono/statically_widen.h> #endif +#if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ + !defined(_LIBCPP_HAS_NO_LOCALIZATION) +# include <__chrono/tzdb.h> +# include <__chrono/tzdb_list.h> +#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -808,6 +846,8 @@ constexpr chrono::year operator ""y(unsigned lo # include <bit> # include <concepts> # include <cstring> +# include <forward_list> +# include <string> #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 diff --git a/contrib/libs/cxxsupp/libcxx/include/cmath b/contrib/libs/cxxsupp/libcxx/include/cmath index e815b3a4ef..12bcd65b4a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cmath +++ b/contrib/libs/cxxsupp/libcxx/include/cmath @@ -313,6 +313,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept #include <__type_traits/is_same.h> #include <__type_traits/promote.h> #include <__type_traits/remove_cv.h> +#include <limits> #include <version> #include <math.h> @@ -568,9 +569,9 @@ hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT } #endif -template <class _A1> +template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type +_LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isnan) @@ -580,17 +581,17 @@ __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT #endif } -template <class _A1> +template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type +_LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT { return std::isnan(__lcpp_x); } -template <class _A1> +template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type +_LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isinf) @@ -600,17 +601,17 @@ __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT #endif } -template <class _A1> +template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type +_LIBCPP_CONSTEXPR bool __constexpr_isinf(_A1 __lcpp_x) _NOEXCEPT { return std::isinf(__lcpp_x); } -template <class _A1> +template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type +_LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT { #if __has_builtin(__builtin_isfinite) @@ -620,9 +621,9 @@ __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT #endif } -template <class _A1> +template <class _A1, __enable_if_t<!is_floating_point<_A1>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY -_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type +_LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x) _NOEXCEPT { return __builtin_isfinite(__lcpp_x); @@ -641,10 +642,9 @@ __constexpr_copysign(long double __x, long double __y) _NOEXCEPT { return __builtin_copysignl(__x, __y); } -template <class _A1, class _A2> +template <class _A1, class _A2, __enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI - typename std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> >::type + typename __promote<_A1, _A2>::type __constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT { typedef typename std::__promote<_A1, _A2>::type __result_type; static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), ""); diff --git a/contrib/libs/cxxsupp/libcxx/include/codecvt b/contrib/libs/cxxsupp/libcxx/include/codecvt index ef22bf0530..7a8c28d559 100644 --- a/contrib/libs/cxxsupp/libcxx/include/codecvt +++ b/contrib/libs/cxxsupp/libcxx/include/codecvt @@ -562,6 +562,7 @@ _LIBCPP_END_NAMESPACE_STD # include <initializer_list> # include <iosfwd> # include <limits> +# include <mutex> # include <new> # include <stdexcept> # include <type_traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/complex b/contrib/libs/cxxsupp/libcxx/include/complex index 4734b492c6..066141bacd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/complex +++ b/contrib/libs/cxxsupp/libcxx/include/complex @@ -942,35 +942,25 @@ arg(const complex<_Tp>& __c) return std::atan2(__c.imag(), __c.real()); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_same<_Tp, long double>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if< - is_same<_Tp, long double>::value, - long double ->::type +long double arg(_Tp __re) { return std::atan2l(0.L, __re); } -template<class _Tp> +template<class _Tp, __enable_if_t<is_integral<_Tp>::value || is_same<_Tp, double>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_integral<_Tp>::value || is_same<_Tp, double>::value, - double ->::type +double arg(_Tp __re) { return std::atan2(0., __re); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_same<_Tp, float>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if< - is_same<_Tp, float>::value, - float ->::type +float arg(_Tp __re) { return std::atan2f(0.F, __re); @@ -1033,13 +1023,9 @@ proj(const complex<_Tp>& __c) return __r; } -template <class _Tp> +template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_floating_point<_Tp>::value, - typename __libcpp_complex_overload_traits<_Tp>::_ComplexType ->::type +typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { if (std::__constexpr_isinf(__re)) @@ -1047,13 +1033,9 @@ proj(_Tp __re) return complex<_Tp>(__re); } -template <class _Tp> +template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_integral<_Tp>::value, - typename __libcpp_complex_overload_traits<_Tp>::_ComplexType ->::type +typename __libcpp_complex_overload_traits<_Tp>::_ComplexType proj(_Tp __re) { typedef typename __libcpp_complex_overload_traits<_Tp>::_ComplexType _ComplexType; @@ -1173,26 +1155,18 @@ pow(const complex<_Tp>& __x, const complex<_Up>& __y) return _VSTD::pow(result_type(__x), result_type(__y)); } -template<class _Tp, class _Up> +template<class _Tp, class _Up, __enable_if_t<is_arithmetic<_Up>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_arithmetic<_Up>::value, - complex<typename __promote<_Tp, _Up>::type> ->::type +complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) { typedef complex<typename __promote<_Tp, _Up>::type> result_type; return _VSTD::pow(result_type(__x), result_type(__y)); } -template<class _Tp, class _Up> +template<class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_arithmetic<_Tp>::value, - complex<typename __promote<_Tp, _Up>::type> ->::type +complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) { typedef complex<typename __promote<_Tp, _Up>::type> result_type; diff --git a/contrib/libs/cxxsupp/libcxx/include/condition_variable b/contrib/libs/cxxsupp/libcxx/include/condition_variable index ac44eb3248..f6d72b4833 100644 --- a/contrib/libs/cxxsupp/libcxx/include/condition_variable +++ b/contrib/libs/cxxsupp/libcxx/include/condition_variable @@ -100,6 +100,18 @@ public: wait_for(Lock& lock, const chrono::duration<Rep, Period>& rel_time, Predicate pred); + + // [thread.condvarany.intwait], interruptible waits + template <class Lock, class Predicate> + bool wait(Lock& lock, stop_token stoken, Predicate pred); // since C++20 + + template <class Lock, class Clock, class Duration, class Predicate> + bool wait_until(Lock& lock, stop_token stoken, + const chrono::time_point<Clock, Duration>& abs_time, Predicate pred); // since C++20 + + template <class Lock, class Rep, class Period, class Predicate> + bool wait_for(Lock& lock, stop_token stoken, + const chrono::duration<Rep, Period>& rel_time, Predicate pred); // since C++20 }; } // std @@ -107,6 +119,7 @@ public: */ #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__chrono/duration.h> #include <__chrono/steady_clock.h> #include <__chrono/time_point.h> @@ -118,6 +131,7 @@ public: #include <__mutex/mutex.h> #include <__mutex/tag_types.h> #include <__mutex/unique_lock.h> +#include <__stop_token/stop_token.h> #include <__utility/move.h> #include <version> @@ -174,6 +188,21 @@ public: wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); + +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) + + template <class _Lock, class _Predicate> + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred); + + template <class _Lock, class _Clock, class _Duration, class _Predicate> + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait_until(_Lock& __lock, stop_token __stoken, + const chrono::time_point<_Clock, _Duration>& __abs_time, _Predicate __pred); + + template <class _Lock, class _Rep, class _Period, class _Predicate> + _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait_for(_Lock& __lock, stop_token __stoken, + const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred); + +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) }; inline @@ -269,6 +298,38 @@ condition_variable_any::wait_for(_Lock& __lock, _VSTD::move(__pred)); } +#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) + +template <class _Lock, class _Predicate> +bool condition_variable_any::wait(_Lock& __lock, stop_token __stoken, _Predicate __pred) { + while (!__stoken.stop_requested()) { + if (__pred()) + return true; + wait(__lock); + } + return __pred(); +} + +template <class _Lock, class _Clock, class _Duration, class _Predicate> +bool condition_variable_any::wait_until( + _Lock& __lock, stop_token __stoken, const chrono::time_point<_Clock, _Duration>& __abs_time, _Predicate __pred) { + while (!__stoken.stop_requested()) { + if (__pred()) + return true; + if (wait_until(__lock, __abs_time) == cv_status::timeout) + return __pred(); + } + return __pred(); +} + +template <class _Lock, class _Rep, class _Period, class _Predicate> +bool condition_variable_any::wait_for( + _Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred) { + return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred)); +} + +#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) + _LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>); _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/cstdlib b/contrib/libs/cxxsupp/libcxx/include/cstdlib index 080bafecf1..d9ee8630d9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/cstdlib +++ b/contrib/libs/cxxsupp/libcxx/include/cstdlib @@ -136,10 +136,12 @@ using ::div _LIBCPP_USING_IF_EXISTS; using ::ldiv _LIBCPP_USING_IF_EXISTS; using ::lldiv _LIBCPP_USING_IF_EXISTS; using ::mblen _LIBCPP_USING_IF_EXISTS; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS using ::mbtowc _LIBCPP_USING_IF_EXISTS; using ::wctomb _LIBCPP_USING_IF_EXISTS; using ::mbstowcs _LIBCPP_USING_IF_EXISTS; using ::wcstombs _LIBCPP_USING_IF_EXISTS; +#endif #if !defined(_LIBCPP_CXX03_LANG) && __has_attribute(using_if_exists) using ::at_quick_exit _LIBCPP_USING_IF_EXISTS; using ::quick_exit _LIBCPP_USING_IF_EXISTS; diff --git a/contrib/libs/cxxsupp/libcxx/include/deque b/contrib/libs/cxxsupp/libcxx/include/deque index 42c0cb3f75..d4ffc7ff42 100644 --- a/contrib/libs/cxxsupp/libcxx/include/deque +++ b/contrib/libs/cxxsupp/libcxx/include/deque @@ -286,10 +286,9 @@ public: #endif {} - template <class _Pp, class _Rp, class _MP> + template <class _Pp, class _Rp, class _MP, __enable_if_t<is_convertible<_Pp, pointer>::value, int> = 0> _LIBCPP_HIDE_FROM_ABI - __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it, - typename enable_if<is_convertible<_Pp, pointer>::value>::type* = 0) _NOEXCEPT + __deque_iterator(const __deque_iterator<value_type, _Pp, _Rp, _MP, difference_type, _BS>& __it) _NOEXCEPT : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {} _LIBCPP_HIDE_FROM_ABI reference operator*() const {return *__ptr_;} @@ -616,12 +615,10 @@ public: __append(__n, __v); } - template <class _InputIter> - _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, - typename enable_if<__has_input_iterator_category<_InputIter>::value>::type* = 0); - template <class _InputIter> - _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a, - typename enable_if<__has_input_iterator_category<_InputIter>::value>::type* = 0); + template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l); + template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI deque(_InputIter __f, _InputIter __l, const allocator_type& __a); #if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> @@ -664,13 +661,11 @@ public: void assign(initializer_list<value_type> __il) {assign(__il.begin(), __il.end());} #endif // _LIBCPP_CXX03_LANG - template <class _InputIter> - _LIBCPP_HIDE_FROM_ABI void assign(_InputIter __f, _InputIter __l, - typename enable_if<__has_input_iterator_category<_InputIter>::value && - !__has_random_access_iterator_category<_InputIter>::value>::type* = 0); - template <class _RAIter> - _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l, - typename enable_if<__has_random_access_iterator_category<_RAIter>::value>::type* = 0); + template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value && + !__has_random_access_iterator_category<_InputIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI void assign(_InputIter __f, _InputIter __l); + template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI void assign(_RAIter __f, _RAIter __l); #if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> @@ -822,15 +817,12 @@ public: #endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v); _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __v); - template <class _InputIter> - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l, - typename enable_if<__has_exactly_input_iterator_category<_InputIter>::value>::type* = 0); - template <class _ForwardIterator> - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l, - typename enable_if<__has_exactly_forward_iterator_category<_ForwardIterator>::value>::type* = 0); - template <class _BiIter> - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l, - typename enable_if<__has_bidirectional_iterator_category<_BiIter>::value>::type* = 0); + template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InputIter __f, _InputIter __l); + template <class _ForwardIterator, __enable_if_t<__has_exactly_forward_iterator_category<_ForwardIterator>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l); + template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _BiIter __f, _BiIter __l); #if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<_Tp> _Range> @@ -1264,12 +1256,10 @@ public: _LIBCPP_HIDE_FROM_ABI iterator __insert_bidirectional(const_iterator __p, _BiIter __f, _BiIter __l, size_type __n); - template <class _InpIter> - _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l, - typename enable_if<__has_exactly_input_iterator_category<_InpIter>::value>::type* = 0); - template <class _ForIter> - _LIBCPP_HIDE_FROM_ABI void __append(_ForIter __f, _ForIter __l, - typename enable_if<__has_forward_iterator_category<_ForIter>::value>::type* = 0); + template <class _InpIter, __enable_if_t<__has_exactly_input_iterator_category<_InpIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI void __append(_InpIter __f, _InpIter __l); + template <class _ForIter, __enable_if_t<__has_forward_iterator_category<_ForIter>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI void __append(_ForIter __f, _ForIter __l); template <class _InputIterator> _LIBCPP_HIDE_FROM_ABI void __append_with_size(_InputIterator __from, size_type __n); @@ -1379,9 +1369,8 @@ deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) } template <class _Tp, class _Allocator> -template <class _InputIter> -deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, - typename enable_if<__has_input_iterator_category<_InputIter>::value>::type*) +template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > +deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l) : __start_(0), __size_(0, __default_init_tag()) { __annotate_new(0); @@ -1389,9 +1378,8 @@ deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, } template <class _Tp, class _Allocator> -template <class _InputIter> -deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a, - typename enable_if<__has_input_iterator_category<_InputIter>::value>::type*) +template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > +deque<_Tp, _Allocator>::deque(_InputIter __f, _InputIter __l, const allocator_type& __a) : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) { __annotate_new(0); @@ -1516,11 +1504,10 @@ deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type) #endif // _LIBCPP_CXX03_LANG template <class _Tp, class _Allocator> -template <class _InputIter> +template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value && + !__has_random_access_iterator_category<_InputIter>::value, int> > void -deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l, - typename enable_if<__has_input_iterator_category<_InputIter>::value && - !__has_random_access_iterator_category<_InputIter>::value>::type*) +deque<_Tp, _Allocator>::assign(_InputIter __f, _InputIter __l) { __assign_with_sentinel(__f, __l); } @@ -1540,10 +1527,9 @@ void deque<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __f, _Sentinel __l } template <class _Tp, class _Allocator> -template <class _RAIter> +template <class _RAIter, __enable_if_t<__has_random_access_iterator_category<_RAIter>::value, int> > void -deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l, - typename enable_if<__has_random_access_iterator_category<_RAIter>::value>::type*) +deque<_Tp, _Allocator>::assign(_RAIter __f, _RAIter __l) { __assign_with_size_random_access(__f, __l - __f); } @@ -2066,10 +2052,9 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty } template <class _Tp, class _Allocator> -template <class _InputIter> +template <class _InputIter, __enable_if_t<__has_exactly_input_iterator_category<_InputIter>::value, int> > typename deque<_Tp, _Allocator>::iterator -deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l, - typename enable_if<__has_exactly_input_iterator_category<_InputIter>::value>::type*) +deque<_Tp, _Allocator>::insert(const_iterator __p, _InputIter __f, _InputIter __l) { return __insert_with_sentinel(__p, __f, __l); } @@ -2086,10 +2071,9 @@ deque<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __p, _Iterator __f } template <class _Tp, class _Allocator> -template <class _ForwardIterator> +template <class _ForwardIterator, __enable_if_t<__has_exactly_forward_iterator_category<_ForwardIterator>::value, int> > typename deque<_Tp, _Allocator>::iterator -deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l, - typename enable_if<__has_exactly_forward_iterator_category<_ForwardIterator>::value>::type*) +deque<_Tp, _Allocator>::insert(const_iterator __p, _ForwardIterator __f, _ForwardIterator __l) { return __insert_with_size(__p, __f, std::distance(__f, __l)); } @@ -2106,10 +2090,9 @@ deque<_Tp, _Allocator>::__insert_with_size(const_iterator __p, _Iterator __f, si } template <class _Tp, class _Allocator> -template <class _BiIter> +template <class _BiIter, __enable_if_t<__has_bidirectional_iterator_category<_BiIter>::value, int> > typename deque<_Tp, _Allocator>::iterator -deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, - typename enable_if<__has_bidirectional_iterator_category<_BiIter>::value>::type*) +deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l) { return __insert_bidirectional(__p, __f, __l, std::distance(__f, __l)); } @@ -2192,10 +2175,9 @@ deque<_Tp, _Allocator>::__insert_bidirectional(const_iterator __p, _BiIter __f, } template <class _Tp, class _Allocator> -template <class _InpIter> +template <class _InpIter, __enable_if_t<__has_exactly_input_iterator_category<_InpIter>::value, int> > void -deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l, - typename enable_if<__has_exactly_input_iterator_category<_InpIter>::value>::type*) +deque<_Tp, _Allocator>::__append(_InpIter __f, _InpIter __l) { __append_with_sentinel(__f, __l); } @@ -2213,10 +2195,9 @@ void deque<_Tp, _Allocator>::__append_with_sentinel(_InputIterator __f, _Sentine } template <class _Tp, class _Allocator> -template <class _ForIter> +template <class _ForIter, __enable_if_t<__has_forward_iterator_category<_ForIter>::value, int> > void -deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l, - typename enable_if<__has_forward_iterator_category<_ForIter>::value>::type*) +deque<_Tp, _Allocator>::__append(_ForIter __f, _ForIter __l) { __append_with_size(__f, std::distance(__f, __l)); } diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__config b/contrib/libs/cxxsupp/libcxx/include/experimental/__config index 839b80aa63..65227c8b40 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__config +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__config @@ -32,18 +32,6 @@ #define _LIBCPP_END_NAMESPACE_LFTS_PMR _LIBCPP_END_NAMESPACE_LFTS } #define _VSTD_LFTS_PMR _VSTD_LFTS::pmr -#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD \ - _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace parallelism_v2 { - -#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD \ - } _LIBCPP_END_NAMESPACE_EXPERIMENTAL - -#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ - _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD namespace simd_abi { - -#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD_ABI \ - } _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD - // TODO: support more targets #if defined(__AVX__) #define _LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES 32 diff --git a/contrib/libs/cxxsupp/libcxx/include/forward_list b/contrib/libs/cxxsupp/libcxx/include/forward_list index 6cb794070b..09338ab695 100644 --- a/contrib/libs/cxxsupp/libcxx/include/forward_list +++ b/contrib/libs/cxxsupp/libcxx/include/forward_list @@ -209,12 +209,11 @@ template <class T, class Allocator, class Predicate> #include <__memory/addressof.h> #include <__memory/allocation_guard.h> #include <__memory/allocator.h> -#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> +#include <__memory/construct_at.h> #include <__memory/pointer_traits.h> #include <__memory/swap_allocator.h> -#include <__memory/unique_ptr.h> #include <__memory_resource/polymorphic_allocator.h> #include <__ranges/access.h> #include <__ranges/concepts.h> @@ -232,6 +231,7 @@ template <class T, class Allocator, class Predicate> #include <__utility/forward.h> #include <__utility/move.h> #include <limits> +#include <new> // __launder #include <version> // standard-mandated includes @@ -272,13 +272,12 @@ struct __forward_list_node_value_type<__forward_list_node<_Tp, _VoidPtr> > { template <class _NodePtr> struct __forward_node_traits { - typedef __remove_cv_t< - typename pointer_traits<_NodePtr>::element_type> __node; - typedef typename __forward_list_node_value_type<__node>::type __node_value_type; - typedef _NodePtr __node_pointer; - typedef __forward_begin_node<_NodePtr> __begin_node; - typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; - typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; + typedef __remove_cv_t<typename pointer_traits<_NodePtr>::element_type> __node_type; + typedef typename __forward_list_node_value_type<__node_type>::type __node_value_type; + typedef _NodePtr __node_pointer; + typedef __forward_begin_node<_NodePtr> __begin_node; + typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; + typedef __rebind_pointer_t<_NodePtr, void> __void_pointer; #if defined(_LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB) typedef __begin_node_pointer __iter_node_pointer; @@ -321,17 +320,35 @@ template <class _Tp, class _VoidPtr> using __begin_node_of = __forward_begin_node<__rebind_pointer_t<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> > >; template <class _Tp, class _VoidPtr> -struct _LIBCPP_STANDALONE_DEBUG __forward_list_node +struct __forward_list_node : public __begin_node_of<_Tp, _VoidPtr> { typedef _Tp value_type; typedef __begin_node_of<_Tp, _VoidPtr> _Base; typedef typename _Base::pointer _NodePtr; - value_type __value_; + // We allow starting the lifetime of nodes without initializing the value held by the node, + // since that is handled by the list itself in order to be allocator-aware. +#ifndef _LIBCPP_CXX03_LANG +private: + union { + _Tp __value_; + }; - _LIBCPP_HIDE_FROM_ABI __forward_list_node() = default; - _LIBCPP_HIDE_FROM_ABI __forward_list_node(const value_type& __v, _NodePtr __next) : _Base(__next), __value_(__v) {} +public: + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } +#else +private: + _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; + +public: + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { + return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); + } +#endif + + _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {} + _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {} }; @@ -386,10 +403,10 @@ public: __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {} _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return __get_unsafe_node_pointer()->__value_;} + reference operator*() const {return __get_unsafe_node_pointer()->__get_value();} _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__value_); + return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -423,7 +440,7 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator typedef _NodeConstPtr _NodePtr; typedef __forward_node_traits<_NodePtr> __traits; - typedef typename __traits::__node __node; + typedef typename __traits::__node_type __node_type; typedef typename __traits::__node_pointer __node_pointer; typedef typename __traits::__begin_node_pointer __begin_node_pointer; typedef typename __traits::__iter_node_pointer __iter_node_pointer; @@ -471,10 +488,10 @@ public: : __ptr_(__p.__ptr_) {} _LIBCPP_INLINE_VISIBILITY - reference operator*() const {return __get_unsafe_node_pointer()->__value_;} + reference operator*() const {return __get_unsafe_node_pointer()->__get_value();} _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return pointer_traits<pointer>::pointer_to( - __get_unsafe_node_pointer()->__value_);} + __get_unsafe_node_pointer()->__get_value());} _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator& operator++() @@ -508,9 +525,9 @@ protected: typedef _Alloc allocator_type; typedef typename allocator_traits<allocator_type>::void_pointer void_pointer; - typedef __forward_list_node<value_type, void_pointer> __node; + typedef __forward_list_node<value_type, void_pointer> __node_type; typedef __begin_node_of<value_type, void_pointer> __begin_node; - typedef __rebind_alloc<allocator_traits<allocator_type>, __node> __node_allocator; + typedef __rebind_alloc<allocator_traits<allocator_type>, __node_type> __node_allocator; typedef allocator_traits<__node_allocator> __node_traits; typedef typename __node_traits::pointer __node_pointer; @@ -576,6 +593,33 @@ protected: {__move_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());} + template <class ..._Args> + _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&& ...__args) { + __node_allocator& __a = __alloc(); + __allocation_guard<__node_allocator> __guard(__a, 1); + // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value + // held inside the node, since we need to use the allocator's construct() method for that. + // + // We don't use the allocator's construct() method to construct the node itself since the + // Cpp17FooInsertable named requirements don't require the allocator's construct() method + // to work on anything other than the value_type. + std::__construct_at(std::addressof(*__guard.__get()), __next); + + // Now construct the value_type using the allocator's construct() method. + __node_traits::construct(__a, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...); + return __guard.__release_ptr(); + } + + template <class ..._Args> + _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { + // For the same reason as above, we use the allocator's destroy() method for the value_type, + // but not for the node itself. + __node_allocator& __a = __alloc(); + __node_traits::destroy(__a, std::addressof(__node->__get_value())); + std::__destroy_at(std::addressof(*__node)); + __node_traits::deallocate(__a, __node, 1); + } + public: _LIBCPP_INLINE_VISIBILITY void swap(__forward_list_base& __x) @@ -661,12 +705,10 @@ template <class _Tp, class _Alloc> void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT { - __node_allocator& __a = __alloc(); for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;) { __node_pointer __next = __p->__next_; - __node_traits::destroy(__a, _VSTD::addressof(__p->__value_)); - __node_traits::deallocate(__a, __p, 1); + __delete_node(__p); __p = __next; } __before_begin()->__next_ = nullptr; @@ -678,7 +720,7 @@ class _LIBCPP_TEMPLATE_VIS forward_list { typedef __forward_list_base<_Tp, _Alloc> base; typedef typename base::__node_allocator __node_allocator; - typedef typename base::__node __node; + typedef typename base::__node_type __node_type; typedef typename base::__node_traits __node_traits; typedef typename base::__node_pointer __node_pointer; typedef typename base::__begin_node_pointer __begin_node_pointer; @@ -777,8 +819,8 @@ public: // ~forward_list() = default; - template <class _InputIterator> - __enable_if_t<__has_input_iterator_category<_InputIterator>::value, void> + template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> + void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l); #if _LIBCPP_STD_VER >= 23 @@ -836,9 +878,9 @@ public: } _LIBCPP_INLINE_VISIBILITY - reference front() {return base::__before_begin()->__next_->__value_;} + reference front() {return base::__before_begin()->__next_->__get_value();} _LIBCPP_INLINE_VISIBILITY - const_reference front() const {return base::__before_begin()->__next_->__value_;} + const_reference front() const {return base::__before_begin()->__next_->__get_value();} #ifndef _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER >= 17 @@ -872,9 +914,9 @@ public: #endif // _LIBCPP_CXX03_LANG _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v); _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v); - template <class _InputIterator> + template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__has_input_iterator_category<_InputIterator>::value, iterator> + iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l); #if _LIBCPP_STD_VER >= 23 @@ -1006,16 +1048,10 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) { if (__n > 0) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { - __h.reset(__node_traits::allocate(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); - __h->__next_ = nullptr; - __p->__next_ = __h.release(); + __p->__next_ = this->__create_node(/* next = */nullptr); } } } @@ -1028,16 +1064,10 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, { if (__n > 0) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__begin_node_pointer __p = base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) { - __h.reset(__node_traits::allocate(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); - __h->__next_ = nullptr; - __p->__next_ = __h.release(); + __p->__next_ = this->__create_node(/* next = */nullptr); } } } @@ -1170,8 +1200,8 @@ forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il) #endif // _LIBCPP_CXX03_LANG template <class _Tp, class _Alloc> -template <class _InputIterator> -__enable_if_t<__has_input_iterator_category<_InputIterator>::value, void> +template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > +void forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) { __assign_with_sentinel(__f, __l); @@ -1226,15 +1256,9 @@ void #endif forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), - _VSTD::forward<_Args>(__args)...); - __h->__next_ = base::__before_begin()->__next_; - base::__before_begin()->__next_ = __h.release(); + base::__before_begin()->__next_ = this->__create_node(/* next = */base::__before_begin()->__next_, std::forward<_Args>(__args)...); #if _LIBCPP_STD_VER >= 17 - return base::__before_begin()->__next_->__value_; + return base::__before_begin()->__next_->__get_value(); #endif } @@ -1242,12 +1266,7 @@ template <class _Tp, class _Alloc> void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v)); - __h->__next_ = base::__before_begin()->__next_; - base::__before_begin()->__next_ = __h.release(); + base::__before_begin()->__next_ = this->__create_node(/* next = */base::__before_begin()->__next_, std::move(__v)); } #endif // _LIBCPP_CXX03_LANG @@ -1256,23 +1275,16 @@ template <class _Tp, class _Alloc> void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); - __h->__next_ = base::__before_begin()->__next_; - base::__before_begin()->__next_ = __h.release(); + base::__before_begin()->__next_ = this->__create_node(/* next = */base::__before_begin()->__next_, __v); } template <class _Tp, class _Alloc> void forward_list<_Tp, _Alloc>::pop_front() { - __node_allocator& __a = base::__alloc(); __node_pointer __p = base::__before_begin()->__next_; base::__before_begin()->__next_ = __p->__next_; - __node_traits::destroy(__a, _VSTD::addressof(__p->__value_)); - __node_traits::deallocate(__a, __p, 1); + this->__delete_node(__p); } #ifndef _LIBCPP_CXX03_LANG @@ -1283,13 +1295,7 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) { __begin_node_pointer const __r = __p.__get_begin(); - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), - _VSTD::forward<_Args>(__args)...); - __h->__next_ = __r->__next_; - __r->__next_ = __h.release(); + __r->__next_ = this->__create_node(/* next = */__r->__next_, std::forward<_Args>(__args)...); return iterator(__r->__next_); } @@ -1298,12 +1304,7 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) { __begin_node_pointer const __r = __p.__get_begin(); - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), _VSTD::move(__v)); - __h->__next_ = __r->__next_; - __r->__next_ = __h.release(); + __r->__next_ = this->__create_node(/* next = */__r->__next_, std::move(__v)); return iterator(__r->__next_); } @@ -1314,12 +1315,7 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) { __begin_node_pointer const __r = __p.__get_begin(); - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(__node_traits::allocate(__a, 1), _Dp(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); - __h->__next_ = __r->__next_; - __r->__next_ = __h.release(); + __r->__next_ = this->__create_node(/* next = */__r->__next_, __v); return iterator(__r->__next_); } @@ -1328,20 +1324,10 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const value_type& __v) { - using _Guard = __allocation_guard<__node_allocator>; - __begin_node_pointer __r = __p.__get_begin(); if (__n > 0) { - __node_allocator& __a = base::__alloc(); - - __node_pointer __first = nullptr; - { - _Guard __h(__a, 1); - __node_traits::construct(__a, std::addressof(__h.__get()->__value_), __v); - __h.__get()->__next_ = nullptr; - __first = __h.__release_ptr(); - } + __node_pointer __first = this->__create_node(/* next = */nullptr, __v); __node_pointer __last = __first; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try @@ -1349,10 +1335,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (--__n; __n != 0; --__n, __last = __last->__next_) { - _Guard __h(__a, 1); - __node_traits::construct(__a, std::addressof(__h.__get()->__value_), __v); - __h.__get()->__next_ = nullptr; - __last->__next_ = __h.__release_ptr(); + __last->__next_ = this->__create_node(/* next = */nullptr, __v); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -1361,8 +1344,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, while (__first != nullptr) { __node_pointer __next = __first->__next_; - __node_traits::destroy(__a, _VSTD::addressof(__first->__value_)); - __node_traits::deallocate(__a, __first, 1); + this->__delete_node(__first); __first = __next; } throw; @@ -1376,8 +1358,8 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, } template <class _Tp, class _Alloc> -template <class _InputIterator> -__enable_if_t<__has_input_iterator_category<_InputIterator>::value, typename forward_list<_Tp, _Alloc>::iterator> +template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> > +typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) { @@ -1389,19 +1371,11 @@ template <class _InputIterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l) { - using _Guard = __allocation_guard<__node_allocator>; __begin_node_pointer __r = __p.__get_begin(); if (__f != __l) { - __node_allocator& __a = base::__alloc(); - __node_pointer __first = nullptr; - { - _Guard __h(__a, 1); - __node_traits::construct(__a, std::addressof(__h.__get()->__value_), *__f); - __h.__get()->__next_ = nullptr; - __first = __h.__release_ptr(); - } + __node_pointer __first = this->__create_node(/* next = */nullptr, *__f); __node_pointer __last = __first; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS @@ -1410,10 +1384,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { - _Guard __h(__a, 1); - __node_traits::construct(__a, std::addressof(__h.__get()->__value_), *__f); - __h.__get()->__next_ = nullptr; - __last->__next_ = __h.__release_ptr(); + __last->__next_ = this->__create_node(/* next = */nullptr, *__f); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -1422,8 +1393,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp while (__first != nullptr) { __node_pointer __next = __first->__next_; - __node_traits::destroy(__a, _VSTD::addressof(__first->__value_)); - __node_traits::deallocate(__a, __first, 1); + this->__delete_node(__first); __first = __next; } throw; @@ -1445,9 +1415,7 @@ forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) __begin_node_pointer __p = __f.__get_begin(); __node_pointer __n = __p->__next_; __p->__next_ = __n->__next_; - __node_allocator& __a = base::__alloc(); - __node_traits::destroy(__a, _VSTD::addressof(__n->__value_)); - __node_traits::deallocate(__a, __n, 1); + this->__delete_node(__n); return iterator(__p->__next_); } @@ -1464,12 +1432,10 @@ forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) if (__n != __e) { __bp->__next_ = __e; - __node_allocator& __a = base::__alloc(); do { __node_pointer __tmp = __n->__next_; - __node_traits::destroy(__a, _VSTD::addressof(__n->__value_)); - __node_traits::deallocate(__a, __n, 1); + this->__delete_node(__n); __n = __tmp; } while (__n != __e); } @@ -1494,16 +1460,10 @@ forward_list<_Tp, _Alloc>::resize(size_type __n) __n -= __sz; if (__n > 0) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n, __ptr = __ptr->__next_as_begin()) { - __h.reset(__node_traits::allocate(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); - __h->__next_ = nullptr; - __ptr->__next_ = __h.release(); + __ptr->__next_ = this->__create_node(/* next = */nullptr); } } } @@ -1526,16 +1486,10 @@ forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) __n -= __sz; if (__n > 0) { - __node_allocator& __a = base::__alloc(); - typedef __allocator_destructor<__node_allocator> _Dp; - unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n, __ptr = __ptr->__next_as_begin()) { - __h.reset(__node_traits::allocate(__a, 1)); - __node_traits::construct(__a, _VSTD::addressof(__h->__value_), __v); - __h->__next_ = nullptr; - __ptr->__next_ = __h.release(); + __ptr->__next_ = this->__create_node(/* next = */nullptr, __v); } } } @@ -1633,7 +1587,7 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v) const iterator __e = end(); for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;) { - if (__i.__get_begin()->__next_->__value_ == __v) + if (__i.__get_begin()->__next_->__get_value() == __v) { ++__count_removed; iterator __j = _VSTD::next(__i, 2); @@ -1661,7 +1615,7 @@ forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred) const iterator __e = end(); for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;) { - if (__pred(__i.__get_begin()->__next_->__value_)) + if (__pred(__i.__get_begin()->__next_->__get_value())) { ++__count_removed; iterator __j = _VSTD::next(__i, 2); @@ -1724,11 +1678,11 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, if (__f2 == nullptr) return __f1; __node_pointer __r; - if (__comp(__f2->__value_, __f1->__value_)) + if (__comp(__f2->__get_value(), __f1->__get_value())) { __node_pointer __t = __f2; while (__t->__next_ != nullptr && - __comp(__t->__next_->__value_, __f1->__value_)) + __comp(__t->__next_->__get_value(), __f1->__get_value())) __t = __t->__next_; __r = __f2; __f2 = __t->__next_; @@ -1740,11 +1694,11 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, __f1 = __f1->__next_; while (__f1 != nullptr && __f2 != nullptr) { - if (__comp(__f2->__value_, __f1->__value_)) + if (__comp(__f2->__get_value(), __f1->__get_value())) { __node_pointer __t = __f2; while (__t->__next_ != nullptr && - __comp(__t->__next_->__value_, __f1->__value_)) + __comp(__t->__next_->__get_value(), __f1->__get_value())) __t = __t->__next_; __p->__next_ = __f2; __f2 = __t->__next_; @@ -1780,7 +1734,7 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, case 1: return __f1; case 2: - if (__comp(__f1->__next_->__value_, __f1->__value_)) + if (__comp(__f1->__next_->__get_value(), __f1->__get_value())) { __node_pointer __t = __f1->__next_; __t->__next_ = __f1; @@ -1931,7 +1885,9 @@ _LIBCPP_POP_MACROS # include <algorithm> # include <atomic> # include <concepts> +# include <cstdint> # include <cstdlib> +# include <cstring> # include <functional> # include <iosfwd> # include <iterator> diff --git a/contrib/libs/cxxsupp/libcxx/include/fstream b/contrib/libs/cxxsupp/libcxx/include/fstream index d30575e22a..cf5ca142e7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/fstream +++ b/contrib/libs/cxxsupp/libcxx/include/fstream @@ -1752,6 +1752,7 @@ _LIBCPP_POP_MACROS # include <cstdlib> # include <iosfwd> # include <limits> +# include <mutex> # include <new> # include <stdexcept> # include <type_traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/future b/contrib/libs/cxxsupp/libcxx/include/future index 273e4175e6..f372b8e6ad 100644 --- a/contrib/libs/cxxsupp/libcxx/include/future +++ b/contrib/libs/cxxsupp/libcxx/include/future @@ -44,14 +44,15 @@ error_condition make_error_condition(future_errc e) noexcept; const error_category& future_category() noexcept; -class future_error - : public logic_error -{ +class future_error : public logic_error { public: - future_error(error_code ec); // exposition only - explicit future_error(future_errc); // C++17 + explicit future_error(future_errc e); // since C++17 + const error_code& code() const noexcept; const char* what() const noexcept; + +private: + error_code ec_; // exposition only }; template <class R> @@ -516,12 +517,25 @@ make_error_condition(future_errc __e) _NOEXCEPT return error_condition(static_cast<int>(__e), future_category()); } +_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +_LIBCPP_AVAILABILITY_FUTURE_ERROR +#endif +void __throw_future_error(future_errc __ev); + class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_FUTURE_ERROR future_error : public logic_error { error_code __ec_; + + future_error(error_code); + friend void __throw_future_error(future_errc); + template <class> friend class promise; + public: - future_error(error_code __ec); +#if _LIBCPP_STD_VER >= 17 + _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {} +#endif _LIBCPP_INLINE_VISIBILITY const error_code& code() const _NOEXCEPT {return __ec_;} @@ -530,10 +544,7 @@ public: ~future_error() _NOEXCEPT override; }; -_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS -_LIBCPP_AVAILABILITY_FUTURE_ERROR -#endif +// Declared above std::future_error void __throw_future_error(future_errc __ev) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS @@ -1359,9 +1370,7 @@ promise<_Rp>::~promise() if (__state_) { if (!__state_->__has_value() && __state_->use_count() > 1) - __state_->set_exception(make_exception_ptr( - future_error(make_error_code(future_errc::broken_promise)) - )); + __state_->set_exception(make_exception_ptr(future_error(make_error_code(future_errc::broken_promise)))); __state_->__release_shared(); } } @@ -1502,9 +1511,7 @@ promise<_Rp&>::~promise() if (__state_) { if (!__state_->__has_value() && __state_->use_count() > 1) - __state_->set_exception(make_exception_ptr( - future_error(make_error_code(future_errc::broken_promise)) - )); + __state_->set_exception(make_exception_ptr(future_error(make_error_code(future_errc::broken_promise)))); __state_->__release_shared(); } } diff --git a/contrib/libs/cxxsupp/libcxx/include/ios b/contrib/libs/cxxsupp/libcxx/include/ios index 156f685564..a31a558d51 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ios +++ b/contrib/libs/cxxsupp/libcxx/include/ios @@ -1055,6 +1055,7 @@ _LIBCPP_END_NAMESPACE_STD # include <cstring> # include <initializer_list> # include <limits> +# include <mutex> # include <new> # include <stdexcept> # include <system_error> diff --git a/contrib/libs/cxxsupp/libcxx/include/iosfwd b/contrib/libs/cxxsupp/libcxx/include/iosfwd index ea1a8c0ec3..dbbf7fdaf6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iosfwd +++ b/contrib/libs/cxxsupp/libcxx/include/iosfwd @@ -121,7 +121,9 @@ template <class _CharT, class _Traits = char_traits<_CharT> > template <class _State> class _LIBCPP_TEMPLATE_VIS fpos; typedef fpos<mbstate_t> streampos; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef fpos<mbstate_t> wstreampos; +#endif #ifndef _LIBCPP_HAS_NO_CHAR8_T typedef fpos<mbstate_t> u8streampos; #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/istream b/contrib/libs/cxxsupp/libcxx/include/istream index 8b440c036d..8937008610 100644 --- a/contrib/libs/cxxsupp/libcxx/include/istream +++ b/contrib/libs/cxxsupp/libcxx/include/istream @@ -185,6 +185,11 @@ class _LIBCPP_TEMPLATE_VIS basic_istream : virtual public basic_ios<_CharT, _Traits> { streamsize __gc_; + + _LIBCPP_HIDE_FROM_ABI void __inc_gcount() { + if (__gc_ < numeric_limits<streamsize>::max()) + ++__gc_; + } public: // types (inherited from basic_ios (27.5.4)): typedef _CharT char_type; @@ -714,7 +719,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ __sb->sputc(traits_type::to_char_type(__i)), traits_type::eof())) break; - ++__gc_; + __inc_gcount(); this->rdbuf()->sbumpc(); } if (__gc_ == 0) @@ -806,7 +811,7 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __ if (traits_type::eq(__ch, __dlm)) break; *__s++ = __ch; - ++__gc_; + __inc_gcount(); this->rdbuf()->sbumpc(); } if (__gc_ == 0) @@ -867,7 +872,7 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __s break; if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof())) break; - ++__gc_; + __inc_gcount(); this->rdbuf()->sbumpc(); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS @@ -910,7 +915,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ if (traits_type::eq(__ch, __dlm)) { this->rdbuf()->sbumpc(); - ++__gc_; + __inc_gcount(); break; } if (__gc_ >= __n-1) @@ -920,7 +925,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ } *__s++ = __ch; this->rdbuf()->sbumpc(); - ++__gc_; + __inc_gcount(); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -970,7 +975,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) __state |= ios_base::eofbit; break; } - ++__gc_; + __inc_gcount(); if (traits_type::eq_int_type(__i, __dlm)) break; } @@ -985,7 +990,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm) __state |= ios_base::eofbit; break; } - ++__gc_; + __inc_gcount(); if (traits_type::eq_int_type(__i, __dlm)) break; } @@ -1383,10 +1388,8 @@ struct __is_istreamable<_Stream, _Tp, decltype( std::declval<_Stream>() >> std::declval<_Tp>(), void() )> : true_type { }; -template <class _Stream, class _Tp, class = typename enable_if< - _And<is_base_of<ios_base, _Stream>, - __is_istreamable<_Stream&, _Tp&&> >::value ->::type> +template <class _Stream, class _Tp, __enable_if_t< + _And<is_base_of<ios_base, _Stream>, __is_istreamable<_Stream&, _Tp&&> >::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _Stream&& operator>>(_Stream&& __is, _Tp&& __x) { diff --git a/contrib/libs/cxxsupp/libcxx/include/iterator b/contrib/libs/cxxsupp/libcxx/include/iterator index 42843781eb..36fca48a03 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iterator +++ b/contrib/libs/cxxsupp/libcxx/include/iterator @@ -634,25 +634,25 @@ public: bool failed() const noexcept; }; -template <class C> constexpr auto begin(C& c) -> decltype(c.begin()); -template <class C> constexpr auto begin(const C& c) -> decltype(c.begin()); -template <class C> constexpr auto end(C& c) -> decltype(c.end()); -template <class C> constexpr auto end(const C& c) -> decltype(c.end()); -template <class T, size_t N> constexpr T* begin(T (&array)[N]); -template <class T, size_t N> constexpr T* end(T (&array)[N]); - -template <class C> auto constexpr cbegin(const C& c) -> decltype(std::begin(c)); // C++14 -template <class C> auto constexpr cend(const C& c) -> decltype(std::end(c)); // C++14 -template <class C> auto constexpr rbegin(C& c) -> decltype(c.rbegin()); // C++14 -template <class C> auto constexpr rbegin(const C& c) -> decltype(c.rbegin()); // C++14 -template <class C> auto constexpr rend(C& c) -> decltype(c.rend()); // C++14 -template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14 -template <class E> reverse_iterator<const E*> constexpr rbegin(initializer_list<E> il); // C++14 -template <class E> reverse_iterator<const E*> constexpr rend(initializer_list<E> il); // C++14 -template <class T, size_t N> reverse_iterator<T*> constexpr rbegin(T (&array)[N]); // C++14 -template <class T, size_t N> reverse_iterator<T*> constexpr rend(T (&array)[N]); // C++14 -template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 -template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14 +template <class C> constexpr auto begin(C& c) -> decltype(c.begin()); // constexpr since C++17 +template <class C> constexpr auto begin(const C& c) -> decltype(c.begin()); // constexpr since C++17 +template <class C> constexpr auto end(C& c) -> decltype(c.end()); // constexpr since C++17 +template <class C> constexpr auto end(const C& c) -> decltype(c.end()); // constexpr since C++17 +template <class T, size_t N> constexpr T* begin(T (&array)[N]) noexcept; // constexpr since C++14 +template <class T, size_t N> constexpr T* end(T (&array)[N]) noexcept; // constexpr since C++14 + +template <class C> constexpr auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template <class C> constexpr auto cend(const C& c) -> decltype(std::end(c)); // C++14 +template <class C> constexpr auto rbegin(C& c) -> decltype(c.rbegin()); // C++14, constexpr since C++17 +template <class C> constexpr auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14, constexpr since C++17 +template <class C> constexpr auto rend(C& c) -> decltype(c.rend()); // C++14, constexpr since C++17 +template <class C> constexpr auto rend(const C& c) -> decltype(c.rend()); // C++14, constexpr since C++17 +template <class E> constexpr reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14, constexpr since C++17 +template <class E> constexpr reverse_iterator<const E*> rend(initializer_list<E> il); // C++14, constexpr since C++17 +template <class T, size_t N> constexpr reverse_iterator<T*> rbegin(T (&array)[N]); // C++14, constexpr since C++17 +template <class T, size_t N> constexpr reverse_iterator<T*> rend(T (&array)[N]); // C++14, constexpr since C++17 +template <class C> constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14, constexpr since C++17 +template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c)); // C++14, constexpr since C++17 // 24.8, container access: template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17 diff --git a/contrib/libs/cxxsupp/libcxx/include/list b/contrib/libs/cxxsupp/libcxx/include/list index 37bed3cd89..e5b524b883 100644 --- a/contrib/libs/cxxsupp/libcxx/include/list +++ b/contrib/libs/cxxsupp/libcxx/include/list @@ -213,13 +213,13 @@ template <class T, class Allocator, class Predicate> #include <__iterator/prev.h> #include <__iterator/reverse_iterator.h> #include <__memory/addressof.h> +#include <__memory/allocation_guard.h> #include <__memory/allocator.h> -#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> +#include <__memory/construct_at.h> #include <__memory/pointer_traits.h> #include <__memory/swap_allocator.h> -#include <__memory/unique_ptr.h> #include <__memory_resource/polymorphic_allocator.h> #include <__ranges/access.h> #include <__ranges/concepts.h> @@ -238,6 +238,7 @@ template <class T, class Allocator, class Predicate> #include <__utility/swap.h> #include <cstring> #include <limits> +#include <new> // __launder #include <version> // standard-mandated includes @@ -309,6 +310,9 @@ struct __list_node_base __list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())), __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {} + _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__link_pointer __prev, __link_pointer __next) + : __prev_(__prev), __next_(__next) {} + _LIBCPP_INLINE_VISIBILITY __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); @@ -321,14 +325,35 @@ struct __list_node_base }; template <class _Tp, class _VoidPtr> -struct _LIBCPP_STANDALONE_DEBUG __list_node +struct __list_node : public __list_node_base<_Tp, _VoidPtr> { - _Tp __value_; + // We allow starting the lifetime of nodes without initializing the value held by the node, + // since that is handled by the list itself in order to be allocator-aware. +#ifndef _LIBCPP_CXX03_LANG +private: + union { + _Tp __value_; + }; + +public: + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } +#else +private: + _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)]; + +public: + _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { + return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); + } +#endif typedef __list_node_base<_Tp, _VoidPtr> __base; typedef typename __base::__link_pointer __link_pointer; + _LIBCPP_HIDE_FROM_ABI explicit __list_node(__link_pointer __prev, __link_pointer __next) : __base(__prev, __next) {} + _LIBCPP_HIDE_FROM_ABI ~__list_node() {} + _LIBCPP_INLINE_VISIBILITY __link_pointer __as_link() { return static_cast<__link_pointer>(__base::__self()); @@ -371,12 +396,12 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __ptr_->__as_node()->__value_; + return __ptr_->__as_node()->__get_value(); } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_); + return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -443,12 +468,12 @@ public: _LIBCPP_INLINE_VISIBILITY reference operator*() const { - return __ptr_->__as_node()->__value_; + return __ptr_->__as_node()->__get_value(); } _LIBCPP_INLINE_VISIBILITY pointer operator->() const { - return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__value_); + return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value()); } _LIBCPP_INLINE_VISIBILITY @@ -494,8 +519,8 @@ protected: typedef __list_iterator<value_type, __void_pointer> iterator; typedef __list_const_iterator<value_type, __void_pointer> const_iterator; typedef __list_node_base<value_type, __void_pointer> __node_base; - typedef __list_node<value_type, __void_pointer> __node; - typedef __rebind_alloc<__alloc_traits, __node> __node_allocator; + typedef __list_node<value_type, __void_pointer> __node_type; + typedef __rebind_alloc<__alloc_traits, __node_type> __node_allocator; typedef allocator_traits<__node_allocator> __node_alloc_traits; typedef typename __node_alloc_traits::pointer __node_pointer; typedef typename __node_alloc_traits::pointer __node_const_pointer; @@ -597,6 +622,33 @@ protected: {__move_assign_alloc(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());} + template <class ..._Args> + _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__link_pointer __prev, __link_pointer __next, _Args&& ...__args) { + __node_allocator& __alloc = __node_alloc(); + __allocation_guard<__node_allocator> __guard(__alloc, 1); + // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value + // held inside the node, since we need to use the allocator's construct() method for that. + // + // We don't use the allocator's construct() method to construct the node itself since the + // Cpp17FooInsertable named requirements don't require the allocator's construct() method + // to work on anything other than the value_type. + std::__construct_at(std::addressof(*__guard.__get()), __prev, __next); + + // Now construct the value_type using the allocator's construct() method. + __node_alloc_traits::construct(__alloc, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...); + return __guard.__release_ptr(); + } + + template <class ..._Args> + _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) { + // For the same reason as above, we use the allocator's destroy() method for the value_type, + // but not for the node itself. + __node_allocator& __alloc = __node_alloc(); + __node_alloc_traits::destroy(__alloc, std::addressof(__node->__get_value())); + std::__destroy_at(std::addressof(*__node)); + __node_alloc_traits::deallocate(__alloc, __node, 1); + } + private: _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __list_imp& __c, true_type) @@ -670,7 +722,6 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { if (!empty()) { - __node_allocator& __na = __node_alloc(); __link_pointer __f = __end_.__next_; __link_pointer __l = __end_as_link(); __unlink_nodes(__f, __l->__prev_); @@ -679,8 +730,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT { __node_pointer __np = __f->__as_node(); __f = __f->__next_; - __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); - __node_alloc_traits::deallocate(__na, __np, 1); + __delete_node(__np); } } } @@ -718,7 +768,7 @@ class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> { typedef __list_imp<_Tp, _Alloc> base; - typedef typename base::__node __node; + typedef typename base::__node_type __node_type; typedef typename base::__node_allocator __node_allocator; typedef typename base::__node_pointer __node_pointer; typedef typename base::__node_alloc_traits __node_alloc_traits; @@ -880,25 +930,25 @@ public: reference front() { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); - return base::__end_.__next_->__as_node()->__value_; + return base::__end_.__next_->__as_node()->__get_value(); } _LIBCPP_INLINE_VISIBILITY const_reference front() const { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list"); - return base::__end_.__next_->__as_node()->__value_; + return base::__end_.__next_->__as_node()->__get_value(); } _LIBCPP_INLINE_VISIBILITY reference back() { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); - return base::__end_.__prev_->__as_node()->__value_; + return base::__end_.__prev_->__as_node()->__get_value(); } _LIBCPP_INLINE_VISIBILITY const_reference back() const { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list"); - return base::__end_.__prev_->__as_node()->__value_; + return base::__end_.__prev_->__as_node()->__get_value(); } #ifndef _LIBCPP_CXX03_LANG @@ -1032,16 +1082,6 @@ public: _LIBCPP_HIDE_FROM_ABI bool __invariants() const; - typedef __allocator_destructor<__node_allocator> __node_destructor; - typedef unique_ptr<__node, __node_destructor> __hold_pointer; - - _LIBCPP_INLINE_VISIBILITY - __hold_pointer __allocate_node(__node_allocator& __na) { - __node_pointer __p = __node_alloc_traits::allocate(__na, 1); - __p->__prev_ = nullptr; - return __hold_pointer(__p, __node_destructor(__na, 1)); - } - private: template <class _Iterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI @@ -1342,12 +1382,10 @@ template <class _Tp, class _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link()); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, __x); + __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link()); ++base::__sz(); - return iterator(__hold.release()->__as_link()); + return iterator(__node->__as_link()); } template <class _Tp, class _Alloc> @@ -1358,12 +1396,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ if (__n > 0) { size_type __ds = 0; - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, __x); ++__ds; - __r = iterator(__hold->__as_link()); - __hold.release(); + __r = iterator(__node->__as_link()); iterator __e = __r; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try @@ -1371,11 +1406,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (--__n; __n != 0; --__n, (void) ++__e, ++__ds) { - __hold.reset(__node_alloc_traits::allocate(__na, 1)); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __e.__ptr_->__next_ = __hold->__as_link(); - __hold->__prev_ = __e.__ptr_; - __hold.release(); + __e.__ptr_->__next_ = this->__create_node(/* prev = */__e.__ptr_, /* next = */nullptr, __x)->__as_link(); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -1383,9 +1414,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ { while (true) { - __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); __link_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); + __node_pointer __current = __e.__ptr_->__as_node(); + this->__delete_node(__current); if (__prev == 0) break; __e = iterator(__prev); @@ -1417,12 +1448,9 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se if (__f != __l) { size_type __ds = 0; - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, *__f); ++__ds; - __r = iterator(__hold.get()->__as_link()); - __hold.release(); + __r = iterator(__node->__as_link()); iterator __e = __r; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try @@ -1430,11 +1458,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (++__f; __f != __l; ++__f, (void) ++__e, ++__ds) { - __hold.reset(__node_alloc_traits::allocate(__na, 1)); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); - __e.__ptr_->__next_ = __hold.get()->__as_link(); - __hold->__prev_ = __e.__ptr_; - __hold.release(); + __e.__ptr_->__next_ = this->__create_node(/* prev = */__e.__ptr_, /* next = */nullptr, *__f)->__as_link(); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -1442,9 +1466,9 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se { while (true) { - __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); __link_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); + __node_pointer __current = __e.__ptr_->__as_node(); + this->__delete_node(__current); if (__prev == 0) break; __e = iterator(__prev); @@ -1462,25 +1486,20 @@ template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_front(const value_type& __x) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_pointer __nl = __hold->__as_link(); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, __x); + __link_pointer __nl = __node->__as_link(); __link_nodes_at_front(__nl, __nl); ++base::__sz(); - __hold.release(); } template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_back(const value_type& __x) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link()); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, __x); + __link_pointer __nl = __node->__as_link(); + __link_nodes_at_back(__nl, __nl); ++base::__sz(); - __hold.release(); } #ifndef _LIBCPP_CXX03_LANG @@ -1489,24 +1508,20 @@ template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_front(value_type&& __x) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, std::move(__x)); + __link_pointer __nl = __node->__as_link(); + __link_nodes_at_front(__nl, __nl); ++base::__sz(); - __hold.release(); } template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::push_back(value_type&& __x) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link()); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, std::move(__x)); + __link_pointer __nl = __node->__as_link(); + __link_nodes_at_back(__nl, __nl); ++base::__sz(); - __hold.release(); } template <class _Tp, class _Alloc> @@ -1518,15 +1533,12 @@ void #endif list<_Tp, _Alloc>::emplace_front(_Args&&... __args) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, std::forward<_Args>(__args)...); + __link_pointer __nl = __node->__as_link(); + __link_nodes_at_front(__nl, __nl); ++base::__sz(); #if _LIBCPP_STD_VER >= 17 - return __hold.release()->__value_; -#else - __hold.release(); + return __node->__get_value(); #endif } @@ -1539,16 +1551,12 @@ void #endif list<_Tp, _Alloc>::emplace_back(_Args&&... __args) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_pointer __nl = __hold->__as_link(); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, std::forward<_Args>(__args)...); + __link_pointer __nl = __node->__as_link(); __link_nodes_at_back(__nl, __nl); ++base::__sz(); #if _LIBCPP_STD_VER >= 17 - return __hold.release()->__value_; -#else - __hold.release(); + return __node->__get_value(); #endif } @@ -1557,13 +1565,10 @@ template <class... _Args> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_pointer __nl = __hold.get()->__as_link(); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, std::forward<_Args>(__args)...); + __link_pointer __nl = __node->__as_link(); __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); - __hold.release(); return iterator(__nl); } @@ -1571,13 +1576,10 @@ template <class _Tp, class _Alloc> typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) { - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_pointer __nl = __hold->__as_link(); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, std::move(__x)); + __link_pointer __nl = __node->__as_link(); __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); - __hold.release(); return iterator(__nl); } @@ -1588,13 +1590,10 @@ void list<_Tp, _Alloc>::pop_front() { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list"); - __node_allocator& __na = base::__node_alloc(); __link_pointer __n = base::__end_.__next_; base::__unlink_nodes(__n, __n); --base::__sz(); - __node_pointer __np = __n->__as_node(); - __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); - __node_alloc_traits::deallocate(__na, __np, 1); + this->__delete_node(__n->__as_node()); } template <class _Tp, class _Alloc> @@ -1602,13 +1601,10 @@ void list<_Tp, _Alloc>::pop_back() { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list"); - __node_allocator& __na = base::__node_alloc(); __link_pointer __n = base::__end_.__prev_; base::__unlink_nodes(__n, __n); --base::__sz(); - __node_pointer __np = __n->__as_node(); - __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); - __node_alloc_traits::deallocate(__na, __np, 1); + this->__delete_node(__n->__as_node()); } template <class _Tp, class _Alloc> @@ -1617,14 +1613,11 @@ list<_Tp, _Alloc>::erase(const_iterator __p) { _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); - __node_allocator& __na = base::__node_alloc(); __link_pointer __n = __p.__ptr_; __link_pointer __r = __n->__next_; base::__unlink_nodes(__n, __n); --base::__sz(); - __node_pointer __np = __n->__as_node(); - __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); - __node_alloc_traits::deallocate(__na, __np, 1); + this->__delete_node(__n->__as_node()); return iterator(__r); } @@ -1634,16 +1627,13 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) { if (__f != __l) { - __node_allocator& __na = base::__node_alloc(); base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); while (__f != __l) { __link_pointer __n = __f.__ptr_; ++__f; --base::__sz(); - __node_pointer __np = __n->__as_node(); - __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); - __node_alloc_traits::deallocate(__na, __np, 1); + this->__delete_node(__n->__as_node()); } } return iterator(__l.__ptr_); @@ -1659,11 +1649,9 @@ list<_Tp, _Alloc>::resize(size_type __n) { __n -= base::__sz(); size_type __ds = 0; - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr); ++__ds; - iterator __r = iterator(__hold.release()->__as_link()); + iterator __r = iterator(__node->__as_link()); iterator __e = __r; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try @@ -1671,11 +1659,7 @@ list<_Tp, _Alloc>::resize(size_type __n) #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (--__n; __n != 0; --__n, (void) ++__e, ++__ds) { - __hold.reset(__node_alloc_traits::allocate(__na, 1)); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); - __e.__ptr_->__next_ = __hold.get()->__as_link(); - __hold->__prev_ = __e.__ptr_; - __hold.release(); + __e.__ptr_->__next_ = this->__create_node(/* prev = */__e.__ptr_, /* next = */nullptr)->__as_link(); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -1683,9 +1667,9 @@ list<_Tp, _Alloc>::resize(size_type __n) { while (true) { - __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); __link_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); + __node_pointer __current = __e.__ptr_->__as_node(); + this->__delete_node(__current); if (__prev == 0) break; __e = iterator(__prev); @@ -1708,11 +1692,9 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { __n -= base::__sz(); size_type __ds = 0; - __node_allocator& __na = base::__node_alloc(); - __hold_pointer __hold = __allocate_node(__na); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); + __node_pointer __node = this->__create_node(/* prev = */nullptr, /* next = */nullptr, __x); ++__ds; - __link_pointer __nl = __hold.release()->__as_link(); + __link_pointer __nl = __node->__as_link(); iterator __r = iterator(__nl); iterator __e = __r; #ifndef _LIBCPP_HAS_NO_EXCEPTIONS @@ -1721,11 +1703,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) #endif // _LIBCPP_HAS_NO_EXCEPTIONS for (--__n; __n != 0; --__n, (void) ++__e, ++__ds) { - __hold.reset(__node_alloc_traits::allocate(__na, 1)); - __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __e.__ptr_->__next_ = __hold.get()->__as_link(); - __hold->__prev_ = __e.__ptr_; - __hold.release(); + __e.__ptr_->__next_ = this->__create_node(/* prev = */__e.__ptr_, /* next = */nullptr, __x)->__as_link(); } #ifndef _LIBCPP_HAS_NO_EXCEPTIONS } @@ -1733,9 +1711,9 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { while (true) { - __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); __link_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); + __node_pointer __current = __e.__ptr_->__as_node(); + this->__delete_node(__current); if (__prev == 0) break; __e = iterator(__prev); @@ -1779,17 +1757,6 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) } } -template <class _Iterator> -_LIBCPP_HIDE_FROM_ABI -bool __iterator_in_range(_Iterator __first, _Iterator __last, _Iterator __it) { - for (_Iterator __p = __first; __p != __last; ++__p) { - if (__p == __it) { - return true; - } - } - return false; -} - template <class _Tp, class _Alloc> void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) @@ -2135,6 +2102,7 @@ _LIBCPP_POP_MACROS # include <algorithm> # include <atomic> # include <concepts> +# include <cstdint> # include <cstdlib> # include <functional> # include <iosfwd> diff --git a/contrib/libs/cxxsupp/libcxx/include/locale b/contrib/libs/cxxsupp/libcxx/include/locale index 7451299529..2cd033d3f7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/locale +++ b/contrib/libs/cxxsupp/libcxx/include/locale @@ -1085,7 +1085,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, int __base = 16; // Stage 2 char_type __atoms[26]; - char_type __thousands_sep = 0; + char_type __thousands_sep = char_type(); string __grouping; std::use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src, __num_get_base::__src + 26, __atoms); @@ -3459,7 +3459,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>; class _LIBCPP_EXPORTED_FROM_ABI messages_base { public: - typedef ptrdiff_t catalog; + typedef intptr_t catalog; _LIBCPP_INLINE_VISIBILITY messages_base() {} }; @@ -3516,10 +3516,7 @@ typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const { #ifdef _LIBCPP_HAS_CATOPEN - catalog __cat = (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); - if (__cat != -1) - __cat = static_cast<catalog>((static_cast<size_t>(__cat) >> 1)); - return __cat; + return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); #else // !_LIBCPP_HAS_CATOPEN (void)__nm; return -1; @@ -3536,9 +3533,8 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, __narrow_to_utf8<sizeof(char_type)*__CHAR_BIT__>()(std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); - if (__c != -1) - __c <<= 1; nl_catd __cat = (nl_catd)__c; + static_assert(sizeof(catalog) >= sizeof(nl_catd), "Unexpected nl_catd type"); char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str()); string_type __w; __widen_from_utf8<sizeof(char_type)*__CHAR_BIT__>()(std::back_inserter(__w), @@ -3557,10 +3553,7 @@ void messages<_CharT>::do_close(catalog __c) const { #ifdef _LIBCPP_HAS_CATOPEN - if (__c != -1) - __c <<= 1; - nl_catd __cat = (nl_catd)__c; - catclose(__cat); + catclose((nl_catd)__c); #else // !_LIBCPP_HAS_CATOPEN (void)__c; #endif // _LIBCPP_HAS_CATOPEN @@ -4359,6 +4352,7 @@ _LIBCPP_POP_MACROS # include <concepts> # include <cstdarg> # include <iterator> +# include <mutex> # include <stdexcept> # include <type_traits> # include <typeinfo> diff --git a/contrib/libs/cxxsupp/libcxx/include/map b/contrib/libs/cxxsupp/libcxx/include/map index ce8a705eaa..77f2068139 100644 --- a/contrib/libs/cxxsupp/libcxx/include/map +++ b/contrib/libs/cxxsupp/libcxx/include/map @@ -1530,13 +1530,13 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> + iterator find(const _K2& __k) {return __tree_.find(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> + const_iterator find(const _K2& __k) const {return __tree_.find(__k);} #endif @@ -1544,18 +1544,18 @@ public: size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type> + size_type count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif #if _LIBCPP_STD_VER >= 20 _LIBCPP_INLINE_VISIBILITY bool contains(const key_type& __k) const {return find(__k) != end();} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, bool> + bool contains(const _K2& __k) const { return find(__k) != end(); } #endif // _LIBCPP_STD_VER >= 20 @@ -1566,14 +1566,14 @@ public: const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> + iterator lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> + const_iterator lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} #endif @@ -1584,13 +1584,13 @@ public: const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> + iterator upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> + const_iterator upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} #endif @@ -1601,13 +1601,13 @@ public: pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>> + pair<iterator,iterator> equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>> + pair<const_iterator,const_iterator> equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} #endif @@ -2266,13 +2266,13 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> + iterator find(const _K2& __k) {return __tree_.find(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> + const_iterator find(const _K2& __k) const {return __tree_.find(__k);} #endif @@ -2280,18 +2280,18 @@ public: size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, size_type> + size_type count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif #if _LIBCPP_STD_VER >= 20 _LIBCPP_INLINE_VISIBILITY bool contains(const key_type& __k) const {return find(__k) != end();} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, bool> + bool contains(const _K2& __k) const { return find(__k) != end(); } #endif // _LIBCPP_STD_VER >= 20 @@ -2302,14 +2302,14 @@ public: const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> + iterator lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> + const_iterator lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} #endif @@ -2320,13 +2320,13 @@ public: const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, iterator> + iterator upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, const_iterator> + const_iterator upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} #endif @@ -2337,13 +2337,13 @@ public: pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<iterator,iterator>> + pair<iterator,iterator> equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - __enable_if_t<__is_transparent<_Compare, _K2>::value, pair<const_iterator,const_iterator>> + pair<const_iterator,const_iterator> equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/math.h b/contrib/libs/cxxsupp/libcxx/include/math.h index 0ddaa9be8e..33bf0ebc77 100644 --- a/contrib/libs/cxxsupp/libcxx/include/math.h +++ b/contrib/libs/cxxsupp/libcxx/include/math.h @@ -290,6 +290,9 @@ float truncf(float x); long double truncl(long double x); */ +#ifdef __CUDACC__ +#include <math_cuda.h> +#else #include <__config> @@ -307,15 +310,6 @@ long double truncl(long double x); // back to C++ linkage before including these C++ headers. extern "C++" { -#include <__type_traits/enable_if.h> -#include <__type_traits/is_floating_point.h> -#include <__type_traits/is_integral.h> -#include <__type_traits/is_same.h> -#include <__type_traits/promote.h> -#include <limits> -#include <stdlib.h> - - # ifdef fpclassify # undef fpclassify # endif @@ -364,179 +358,78 @@ extern "C++" { # undef isunordered # endif -// signbit +#include <__math/abs.h> +#include <__math/copysign.h> +#include <__math/error_functions.h> +#include <__math/exponential_functions.h> +#include <__math/fdim.h> +#include <__math/fma.h> +#include <__math/gamma.h> +#include <__math/hyperbolic_functions.h> +#include <__math/hypot.h> +#include <__math/inverse_hyperbolic_functions.h> +#include <__math/inverse_trigonometric_functions.h> +#include <__math/logarithms.h> +#include <__math/min_max.h> +#include <__math/modulo.h> +#include <__math/remainder.h> +#include <__math/roots.h> +#include <__math/rounding_functions.h> +#include <__math/traits.h> +#include <__math/trigonometric_functions.h> +#include <__type_traits/enable_if.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> +#include <stdlib.h> -template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { - return __builtin_signbit(__x); -} -template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { - return __x < 0; -} +// fpclassify relies on implementation-defined constants, so we can't move it to a detail header +_LIBCPP_BEGIN_NAMESPACE_STD -template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { - return false; -} +namespace __math { // fpclassify -template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { +// template on non-double overloads to make them weaker than same overloads from MSVC runtime +template <class = int> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } -template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { - return __x == 0 ? FP_ZERO : FP_NORMAL; -} - -// The MSVC runtime already provides these functions as templates -#ifndef _LIBCPP_MSVCRT - -// isfinite - -template <class _A1, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { - return __builtin_isfinite((typename std::__promote<_A1>::type)__x); -} - -template <class _A1, - std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { - return true; -} - -// isinf - -template <class _A1, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { - return __builtin_isinf((typename std::__promote<_A1>::type)__x); -} - -template <class _A1> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI - typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type - isinf(_A1) _NOEXCEPT { - return false; -} - -#if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__) -_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { - return __builtin_isinf(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { - return __builtin_isinf(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { - return __builtin_isinf(__x); -} -# endif - -// isnan - -template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { - return __builtin_isnan(__x); -} - -template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { - return false; -} - -#if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__) -_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { - return __builtin_isnan(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { - return __builtin_isnan(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { - return __builtin_isnan(__x); +template <class = int> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } -# endif -// isnormal - -template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { - return __builtin_isnormal(__x); +template <class = int> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); } template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { - return __x != 0; -} - -// isgreater - -template <class _A1, - class _A2, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type type; - return __builtin_isgreater((type)__x, (type)__y); -} - -// isgreaterequal - -template <class _A1, - class _A2, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type type; - return __builtin_isgreaterequal((type)__x, (type)__y); -} - -// isless - -template <class _A1, - class _A2, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type type; - return __builtin_isless((type)__x, (type)__y); -} - -// islessequal - -template <class _A1, - class _A2, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type type; - return __builtin_islessequal((type)__x, (type)__y); +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { + return __x == 0 ? FP_ZERO : FP_NORMAL; } -// islessgreater - -template <class _A1, - class _A2, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type type; - return __builtin_islessgreater((type)__x, (type)__y); -} +} // namespace __math -// isunordered +_LIBCPP_END_NAMESPACE_STD -template <class _A1, - class _A2, - std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { - typedef typename std::__promote<_A1, _A2>::type type; - return __builtin_isunordered((type)__x, (type)__y); -} +using std::__math::fpclassify; +using std::__math::signbit; +// The MSVC runtime already provides these functions as templates +#ifndef _LIBCPP_MSVCRT +using std::__math::isfinite; +using std::__math::isgreater; +using std::__math::isgreaterequal; +using std::__math::isinf; +using std::__math::isless; +using std::__math::islessequal; +using std::__math::islessgreater; +using std::__math::isnan; +using std::__math::isnormal; +using std::__math::isunordered; #endif // _LIBCPP_MSVCRT // abs @@ -552,1103 +445,70 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 // templates. Functions are preferred over function templates during overload resolution, which means that our overload // will only be selected when the C library doesn't provide one. -// acos - -inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT { - return __builtin_acos(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);} - -// asin - -inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT { - return __builtin_asin(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);} - -// atan - -inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT { - return __builtin_atan(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);} - -// atan2 - -inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT { - return __builtin_atan2(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -atan2(_A1 __y, _A2 __x) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::atan2((__result_type)__y, (__result_type)__x); -} - -// ceil - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { - return __builtin_ceil(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);} - -// cos - -inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT { - return __builtin_cos(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);} - -// cosh - -inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT { - return __builtin_cosh(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);} - -// exp - -inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT { - return __builtin_exp(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);} - -// fabs - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { - return __builtin_fabs(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);} - -// floor - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { - return __builtin_floor(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);} - -// fmod - -inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT { - return __builtin_fmod(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fmod(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fmod((__result_type)__x, (__result_type)__y); -} - -// frexp - -inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT { - return __builtin_frexp(__x, __e); -} - -inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);} - -// ldexp - -inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT { - return __builtin_ldexp(__x, __e); -} - -inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);} - -// log - -inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT { - return __builtin_log(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);} - -// log10 - -inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);} - - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT { - return __builtin_log10(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);} - -// modf - -inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT { - return __builtin_modf(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);} - -// pow - -inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT { - return __builtin_pow(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -pow(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::pow((__result_type)__x, (__result_type)__y); -} - -// sin - -inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT { - return __builtin_sin(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);} - -// sinh - -inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT { - return __builtin_sinh(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);} - -// sqrt - -inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT { - return __builtin_sqrt(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);} - -// tan - -inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT { - return __builtin_tan(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);} - -// tanh - -inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT { - return __builtin_tanh(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);} - -// acosh - -inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT { - return __builtin_acosh(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);} - -// asinh - -inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT { - return __builtin_asinh(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);} - -// atanh - -inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT { - return __builtin_atanh(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);} - -// cbrt - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { - return __builtin_cbrt(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);} - -// copysign - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { - return ::__builtin_copysignf(__x, __y); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { - return ::__builtin_copysignl(__x, __y); -} - -template <class _A1, class _A2> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type - copysign(_A1 __x, _A2 __y) _NOEXCEPT { - return ::__builtin_copysign(__x, __y); -} - -// erf - -inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT { - return __builtin_erf(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);} - -// erfc - -inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT { - return __builtin_erfc(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);} - -// exp2 - -inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT { - return __builtin_exp2(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);} - -// expm1 - -inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT { - return __builtin_expm1(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);} - -// fdim - -inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT { - return __builtin_fdim(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fdim(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fdim((__result_type)__x, (__result_type)__y); -} - -// fma - -inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT -{ - return __builtin_fmaf(__x, __y, __z); -} - - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT { - return __builtin_fma(__x, __y, __z); -} - -inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT -{ - return __builtin_fmal(__x, __y, __z); -} - -template <class _A1, class _A2, class _A3> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value && - std::is_arithmetic<_A3>::value, - std::__promote<_A1, _A2, _A3> ->::type -fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value && - std::_IsSame<_A3, __result_type>::value)), ""); - return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); -} - -// fmax - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { - return __builtin_fmax(__x, __y); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);} - -template <class _A1, class _A2> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fmax(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fmax((__result_type)__x, (__result_type)__y); -} - -// fmin - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { - return __builtin_fmin(__x, __y); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);} - -template <class _A1, class _A2> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -fmin(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::fmin((__result_type)__x, (__result_type)__y); -} - -// hypot - -inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT { - return __builtin_hypot(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -hypot(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::hypot((__result_type)__x, (__result_type)__y); -} - -// ilogb - -inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT { - return __builtin_ilogb(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, int>::type -ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);} - -// lgamma - -inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT { - return __builtin_lgamma(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);} - -// llrint - -inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT -{ - return __builtin_llrintf(__x); -} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT { - return __builtin_llrint(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT -{ - return __builtin_llrintl(__x); -} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, long long>::type -llrint(_A1 __x) _NOEXCEPT -{ - return __builtin_llrint((double)__x); -} - -// llround - -inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT -{ - return __builtin_llroundf(__x); -} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT { - return __builtin_llround(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT -{ - return __builtin_llroundl(__x); -} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, long long>::type -llround(_A1 __x) _NOEXCEPT -{ - return __builtin_llround((double)__x); -} - -// log1p - -inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT { - return __builtin_log1p(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);} - -// log2 - -inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT { - return __builtin_log2(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);} - -// logb - -inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT { - return __builtin_logb(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);} - -// lrint - -inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT -{ - return __builtin_lrintf(__x); -} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT { - return __builtin_lrint(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT -{ - return __builtin_lrintl(__x); -} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, long>::type -lrint(_A1 __x) _NOEXCEPT -{ - return __builtin_lrint((double)__x); -} - -// lround - -inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT -{ - return __builtin_lroundf(__x); -} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT { - return __builtin_lround(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT -{ - return __builtin_lroundl(__x); -} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, long>::type -lround(_A1 __x) _NOEXCEPT -{ - return __builtin_lround((double)__x); -} - -// nan - -// nearbyint - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { - return __builtin_nearbyint(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);} - -// nextafter - -inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT { - return __builtin_nextafter(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -nextafter(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::nextafter((__result_type)__x, (__result_type)__y); -} - -// nexttoward - -inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT { - return __builtin_nexttoward(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);} - -// remainder - -inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT { - return __builtin_remainder(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -remainder(_A1 __x, _A2 __y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::remainder((__result_type)__x, (__result_type)__y); -} - -// remquo - -inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT { - return __builtin_remquo(__x, __y, __z); -} - -inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);} - -template <class _A1, class _A2> -inline _LIBCPP_HIDE_FROM_ABI -typename std::__enable_if_t -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - std::__promote<_A1, _A2> ->::type -remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type __result_type; - static_assert((!(std::_IsSame<_A1, __result_type>::value && - std::_IsSame<_A2, __result_type>::value)), ""); - return ::remquo((__result_type)__x, (__result_type)__y, __z); -} - -// rint - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT -{ - return __builtin_rintf(__x); -} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { - return __builtin_rint(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT -{ - return __builtin_rintl(__x); -} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -rint(_A1 __x) _NOEXCEPT -{ - return __builtin_rint((double)__x); -} - -// round - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT -{ - return __builtin_roundf(__x); -} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { - return __builtin_round(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT -{ - return __builtin_roundl(__x); -} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -round(_A1 __x) _NOEXCEPT -{ - return __builtin_round((double)__x); -} - -// scalbln - -inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT { - return __builtin_scalbln(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);} - -// scalbn - -inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT { - return __builtin_scalbn(__x, __y); -} - -inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);} - -// tgamma - -inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);} - -template <class = int> -_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT { - return __builtin_tgamma(__x); -} - -inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);} - -template <class _A1> -inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);} - -// trunc - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT -{ - return __builtin_truncf(__x); -} - -template <class = int> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { - return __builtin_trunc(__x); -} - -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT -{ - return __builtin_truncl(__x); -} - -template <class _A1> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI -typename std::enable_if<std::is_integral<_A1>::value, double>::type -trunc(_A1 __x) _NOEXCEPT -{ - return __builtin_trunc((double)__x); -} +using std::__math::acosh; +using std::__math::acos; +using std::__math::asinh; +using std::__math::asin; +using std::__math::atanh; +using std::__math::atan; +using std::__math::atan2; +using std::__math::cbrt; +using std::__math::ceil; +using std::__math::copysign; +using std::__math::cos; +using std::__math::cosh; +using std::__math::erf; +using std::__math::erfc; +using std::__math::exp; +using std::__math::exp2; +using std::__math::expm1; +using std::__math::fabs; +using std::__math::fdim; +using std::__math::floor; +using std::__math::fma; +using std::__math::fmax; +using std::__math::fmin; +using std::__math::fmod; +using std::__math::frexp; +using std::__math::hypot; +using std::__math::ilogb; +using std::__math::ldexp; +using std::__math::lgamma; +using std::__math::llrint; +using std::__math::llround; +using std::__math::lrint; +using std::__math::lround; +using std::__math::log; +using std::__math::log10; +using std::__math::log1p; +using std::__math::log2; +using std::__math::logb; +using std::__math::modf; +using std::__math::nearbyint; +using std::__math::nextafter; +using std::__math::nexttoward; +using std::__math::pow; +using std::__math::remainder; +using std::__math::remquo; +using std::__math::rint; +using std::__math::round; +using std::__math::scalbln; +using std::__math::scalbn; +using std::__math::signbit; +using std::__math::sin; +using std::__math::sinh; +using std::__math::sqrt; +using std::__math::tan; +using std::__math::tanh; +using std::__math::tgamma; +using std::__math::trunc; } // extern "C++" #endif // __cplusplus +#endif // __CUDACC__ + #else // _LIBCPP_MATH_H // This include lives outside the header guard in order to support an MSVC diff --git a/contrib/libs/cxxsupp/libcxx/include/math_cuda.h b/contrib/libs/cxxsupp/libcxx/include/math_cuda.h new file mode 100644 index 0000000000..542c1d0544 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/math_cuda.h @@ -0,0 +1,1670 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_MATH_OLD_H +#define _LIBCPP_MATH_OLD_H + +/* + math.h synopsis + +Macros: + + HUGE_VAL + HUGE_VALF // C99 + HUGE_VALL // C99 + INFINITY // C99 + NAN // C99 + FP_INFINITE // C99 + FP_NAN // C99 + FP_NORMAL // C99 + FP_SUBNORMAL // C99 + FP_ZERO // C99 + FP_FAST_FMA // C99 + FP_FAST_FMAF // C99 + FP_FAST_FMAL // C99 + FP_ILOGB0 // C99 + FP_ILOGBNAN // C99 + MATH_ERRNO // C99 + MATH_ERREXCEPT // C99 + math_errhandling // C99 + +Types: + + float_t // C99 + double_t // C99 + +// C90 + +floating_point abs(floating_point x); + +floating_point acos (arithmetic x); +float acosf(float x); +long double acosl(long double x); + +floating_point asin (arithmetic x); +float asinf(float x); +long double asinl(long double x); + +floating_point atan (arithmetic x); +float atanf(float x); +long double atanl(long double x); + +floating_point atan2 (arithmetic y, arithmetic x); +float atan2f(float y, float x); +long double atan2l(long double y, long double x); + +floating_point ceil (arithmetic x); +float ceilf(float x); +long double ceill(long double x); + +floating_point cos (arithmetic x); +float cosf(float x); +long double cosl(long double x); + +floating_point cosh (arithmetic x); +float coshf(float x); +long double coshl(long double x); + +floating_point exp (arithmetic x); +float expf(float x); +long double expl(long double x); + +floating_point fabs (arithmetic x); +float fabsf(float x); +long double fabsl(long double x); + +floating_point floor (arithmetic x); +float floorf(float x); +long double floorl(long double x); + +floating_point fmod (arithmetic x, arithmetic y); +float fmodf(float x, float y); +long double fmodl(long double x, long double y); + +floating_point frexp (arithmetic value, int* exp); +float frexpf(float value, int* exp); +long double frexpl(long double value, int* exp); + +floating_point ldexp (arithmetic value, int exp); +float ldexpf(float value, int exp); +long double ldexpl(long double value, int exp); + +floating_point log (arithmetic x); +float logf(float x); +long double logl(long double x); + +floating_point log10 (arithmetic x); +float log10f(float x); +long double log10l(long double x); + +floating_point modf (floating_point value, floating_point* iptr); +float modff(float value, float* iptr); +long double modfl(long double value, long double* iptr); + +floating_point pow (arithmetic x, arithmetic y); +float powf(float x, float y); +long double powl(long double x, long double y); + +floating_point sin (arithmetic x); +float sinf(float x); +long double sinl(long double x); + +floating_point sinh (arithmetic x); +float sinhf(float x); +long double sinhl(long double x); + +floating_point sqrt (arithmetic x); +float sqrtf(float x); +long double sqrtl(long double x); + +floating_point tan (arithmetic x); +float tanf(float x); +long double tanl(long double x); + +floating_point tanh (arithmetic x); +float tanhf(float x); +long double tanhl(long double x); + +// C99 + +bool signbit(arithmetic x); + +int fpclassify(arithmetic x); + +bool isfinite(arithmetic x); +bool isinf(arithmetic x); +bool isnan(arithmetic x); +bool isnormal(arithmetic x); + +bool isgreater(arithmetic x, arithmetic y); +bool isgreaterequal(arithmetic x, arithmetic y); +bool isless(arithmetic x, arithmetic y); +bool islessequal(arithmetic x, arithmetic y); +bool islessgreater(arithmetic x, arithmetic y); +bool isunordered(arithmetic x, arithmetic y); + +floating_point acosh (arithmetic x); +float acoshf(float x); +long double acoshl(long double x); + +floating_point asinh (arithmetic x); +float asinhf(float x); +long double asinhl(long double x); + +floating_point atanh (arithmetic x); +float atanhf(float x); +long double atanhl(long double x); + +floating_point cbrt (arithmetic x); +float cbrtf(float x); +long double cbrtl(long double x); + +floating_point copysign (arithmetic x, arithmetic y); +float copysignf(float x, float y); +long double copysignl(long double x, long double y); + +floating_point erf (arithmetic x); +float erff(float x); +long double erfl(long double x); + +floating_point erfc (arithmetic x); +float erfcf(float x); +long double erfcl(long double x); + +floating_point exp2 (arithmetic x); +float exp2f(float x); +long double exp2l(long double x); + +floating_point expm1 (arithmetic x); +float expm1f(float x); +long double expm1l(long double x); + +floating_point fdim (arithmetic x, arithmetic y); +float fdimf(float x, float y); +long double fdiml(long double x, long double y); + +floating_point fma (arithmetic x, arithmetic y, arithmetic z); +float fmaf(float x, float y, float z); +long double fmal(long double x, long double y, long double z); + +floating_point fmax (arithmetic x, arithmetic y); +float fmaxf(float x, float y); +long double fmaxl(long double x, long double y); + +floating_point fmin (arithmetic x, arithmetic y); +float fminf(float x, float y); +long double fminl(long double x, long double y); + +floating_point hypot (arithmetic x, arithmetic y); +float hypotf(float x, float y); +long double hypotl(long double x, long double y); + +int ilogb (arithmetic x); +int ilogbf(float x); +int ilogbl(long double x); + +floating_point lgamma (arithmetic x); +float lgammaf(float x); +long double lgammal(long double x); + +long long llrint (arithmetic x); +long long llrintf(float x); +long long llrintl(long double x); + +long long llround (arithmetic x); +long long llroundf(float x); +long long llroundl(long double x); + +floating_point log1p (arithmetic x); +float log1pf(float x); +long double log1pl(long double x); + +floating_point log2 (arithmetic x); +float log2f(float x); +long double log2l(long double x); + +floating_point logb (arithmetic x); +float logbf(float x); +long double logbl(long double x); + +long lrint (arithmetic x); +long lrintf(float x); +long lrintl(long double x); + +long lround (arithmetic x); +long lroundf(float x); +long lroundl(long double x); + +double nan (const char* str); +float nanf(const char* str); +long double nanl(const char* str); + +floating_point nearbyint (arithmetic x); +float nearbyintf(float x); +long double nearbyintl(long double x); + +floating_point nextafter (arithmetic x, arithmetic y); +float nextafterf(float x, float y); +long double nextafterl(long double x, long double y); + +floating_point nexttoward (arithmetic x, long double y); +float nexttowardf(float x, long double y); +long double nexttowardl(long double x, long double y); + +floating_point remainder (arithmetic x, arithmetic y); +float remainderf(float x, float y); +long double remainderl(long double x, long double y); + +floating_point remquo (arithmetic x, arithmetic y, int* pquo); +float remquof(float x, float y, int* pquo); +long double remquol(long double x, long double y, int* pquo); + +floating_point rint (arithmetic x); +float rintf(float x); +long double rintl(long double x); + +floating_point round (arithmetic x); +float roundf(float x); +long double roundl(long double x); + +floating_point scalbln (arithmetic x, long ex); +float scalblnf(float x, long ex); +long double scalblnl(long double x, long ex); + +floating_point scalbn (arithmetic x, int ex); +float scalbnf(float x, int ex); +long double scalbnl(long double x, int ex); + +floating_point tgamma (arithmetic x); +float tgammaf(float x); +long double tgammal(long double x); + +floating_point trunc (arithmetic x); +float truncf(float x); +long double truncl(long double x); + +*/ + +#if defined(__CUDACC_VER_MAJOR__) && __CUDACC_VER_MAJOR__ > 12 +// Try to rewrite the connection condition of this file in math.h, if this warning worked +# warning "This header can lead to problems with CUDA 12+ due to the transfer of mathematical functions to its namespace." +#endif + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +# if __has_include_next(<math.h>) +# include_next <math.h> +# endif + +#ifdef __cplusplus + +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { + +#include <__type_traits/enable_if.h> +#include <__type_traits/is_floating_point.h> +#include <__type_traits/is_integral.h> +#include <__type_traits/is_same.h> +#include <__type_traits/promote.h> +#include <limits> +#include <stdlib.h> + + +# ifdef fpclassify +# undef fpclassify +# endif + +# ifdef signbit +# undef signbit +# endif + +# ifdef isfinite +# undef isfinite +# endif + +# ifdef isinf +# undef isinf +# endif + +# if defined(isnan) && !defined(_LIBCPP_MSVCRT) +# undef isnan +# endif + +# ifdef isnormal +# undef isnormal +# endif + +# ifdef isgreater +# undef isgreater +# endif + +# ifdef isgreaterequal +# undef isgreaterequal +# endif + +# ifdef isless +# undef isless +# endif + +# ifdef islessequal +# undef islessequal +# endif + +# ifdef islessgreater +# undef islessgreater +# endif + +# ifdef isunordered +# undef isunordered +# endif + +// signbit + +template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { + return __builtin_signbit(__x); +} + +template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && std::is_signed<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { + return __x < 0; +} + +template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value && !std::is_signed<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT { + return false; +} + +// fpclassify + +template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { + return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x); +} + +template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT { + return __x == 0 ? FP_ZERO : FP_NORMAL; +} + +// The MSVC runtime already provides these functions as templates +#ifndef _LIBCPP_MSVCRT + +// isfinite + +template <class _A1, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT { + return __builtin_isfinite((typename std::__promote<_A1>::type)__x); +} + +template <class _A1, + std::__enable_if_t<std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT { + return true; +} + +// isinf + +template <class _A1, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT { + return __builtin_isinf((typename std::__promote<_A1>::type)__x); +} + +template <class _A1> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI + typename std::enable_if< std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity, bool>::type + isinf(_A1) _NOEXCEPT { + return false; +} + +#if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__) +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT { + return __builtin_isinf(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isinf(double __x) _NOEXCEPT { + return __builtin_isinf(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT { + return __builtin_isinf(__x); +} +# endif + +// isnan + +template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT { + return __builtin_isnan(__x); +} + +template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT { + return false; +} + +#if defined(_LIBCPP_PREFERRED_OVERLOAD) && !defined(__CUDACC__) +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT { + return __builtin_isnan(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool isnan(double __x) _NOEXCEPT { + return __builtin_isnan(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT { + return __builtin_isnan(__x); +} +# endif + +// isnormal + +template <class _A1, std::__enable_if_t<std::is_floating_point<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { + return __builtin_isnormal(__x); +} + +template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT { + return __x != 0; +} + +// isgreater + +template <class _A1, + class _A2, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT { + typedef typename std::__promote<_A1, _A2>::type type; + return __builtin_isgreater((type)__x, (type)__y); +} + +// isgreaterequal + +template <class _A1, + class _A2, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT { + typedef typename std::__promote<_A1, _A2>::type type; + return __builtin_isgreaterequal((type)__x, (type)__y); +} + +// isless + +template <class _A1, + class _A2, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT { + typedef typename std::__promote<_A1, _A2>::type type; + return __builtin_isless((type)__x, (type)__y); +} + +// islessequal + +template <class _A1, + class _A2, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT { + typedef typename std::__promote<_A1, _A2>::type type; + return __builtin_islessequal((type)__x, (type)__y); +} + +// islessgreater + +template <class _A1, + class _A2, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT { + typedef typename std::__promote<_A1, _A2>::type type; + return __builtin_islessgreater((type)__x, (type)__y); +} + +// isunordered + +template <class _A1, + class _A2, + std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT { + typedef typename std::__promote<_A1, _A2>::type type; + return __builtin_isunordered((type)__x, (type)__y); +} + +#endif // _LIBCPP_MSVCRT + +// abs +// +// handled in stdlib.h + +// div +// +// handled in stdlib.h + +// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math +// functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads +// templates. Functions are preferred over function templates during overload resolution, which means that our overload +// will only be selected when the C library doesn't provide one. + +// acos + +inline _LIBCPP_HIDE_FROM_ABI float acos(float __x) _NOEXCEPT {return __builtin_acosf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double acos(double __x) _NOEXCEPT { + return __builtin_acos(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double acos(long double __x) _NOEXCEPT {return __builtin_acosl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +acos(_A1 __x) _NOEXCEPT {return __builtin_acos((double)__x);} + +// asin + +inline _LIBCPP_HIDE_FROM_ABI float asin(float __x) _NOEXCEPT {return __builtin_asinf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double asin(double __x) _NOEXCEPT { + return __builtin_asin(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double asin(long double __x) _NOEXCEPT {return __builtin_asinl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +asin(_A1 __x) _NOEXCEPT {return __builtin_asin((double)__x);} + +// atan + +inline _LIBCPP_HIDE_FROM_ABI float atan(float __x) _NOEXCEPT {return __builtin_atanf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double atan(double __x) _NOEXCEPT { + return __builtin_atan(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atan(long double __x) _NOEXCEPT {return __builtin_atanl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +atan(_A1 __x) _NOEXCEPT {return __builtin_atan((double)__x);} + +// atan2 + +inline _LIBCPP_HIDE_FROM_ABI float atan2(float __y, float __x) _NOEXCEPT {return __builtin_atan2f(__y, __x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double atan2(double __x, double __y) _NOEXCEPT { + return __builtin_atan2(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x) _NOEXCEPT {return __builtin_atan2l(__y, __x);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +atan2(_A1 __y, _A2 __x) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::atan2((__result_type)__y, (__result_type)__x); +} + +// ceil + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT {return __builtin_ceilf(__x);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT { + return __builtin_ceil(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {return __builtin_ceill(__x);} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +ceil(_A1 __x) _NOEXCEPT {return __builtin_ceil((double)__x);} + +// cos + +inline _LIBCPP_HIDE_FROM_ABI float cos(float __x) _NOEXCEPT {return __builtin_cosf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double cos(double __x) _NOEXCEPT { + return __builtin_cos(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cos(long double __x) _NOEXCEPT {return __builtin_cosl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +cos(_A1 __x) _NOEXCEPT {return __builtin_cos((double)__x);} + +// cosh + +inline _LIBCPP_HIDE_FROM_ABI float cosh(float __x) _NOEXCEPT {return __builtin_coshf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double cosh(double __x) _NOEXCEPT { + return __builtin_cosh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double cosh(long double __x) _NOEXCEPT {return __builtin_coshl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +cosh(_A1 __x) _NOEXCEPT {return __builtin_cosh((double)__x);} + +// exp + +inline _LIBCPP_HIDE_FROM_ABI float exp(float __x) _NOEXCEPT {return __builtin_expf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double exp(double __x) _NOEXCEPT { + return __builtin_exp(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double exp(long double __x) _NOEXCEPT {return __builtin_expl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +exp(_A1 __x) _NOEXCEPT {return __builtin_exp((double)__x);} + +// fabs + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT {return __builtin_fabsf(__x);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT { + return __builtin_fabs(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {return __builtin_fabsl(__x);} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +fabs(_A1 __x) _NOEXCEPT {return __builtin_fabs((double)__x);} + +// floor + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT {return __builtin_floorf(__x);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT { + return __builtin_floor(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {return __builtin_floorl(__x);} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +floor(_A1 __x) _NOEXCEPT {return __builtin_floor((double)__x);} + +// fmod + +inline _LIBCPP_HIDE_FROM_ABI float fmod(float __x, float __y) _NOEXCEPT {return __builtin_fmodf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double fmod(double __x, double __y) _NOEXCEPT { + return __builtin_fmod(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y) _NOEXCEPT {return __builtin_fmodl(__x, __y);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmod(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::fmod((__result_type)__x, (__result_type)__y); +} + +// frexp + +inline _LIBCPP_HIDE_FROM_ABI float frexp(float __x, int* __e) _NOEXCEPT {return __builtin_frexpf(__x, __e);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double frexp(double __x, int* __e) _NOEXCEPT { + return __builtin_frexp(__x, __e); +} + +inline _LIBCPP_HIDE_FROM_ABI long double frexp(long double __x, int* __e) _NOEXCEPT {return __builtin_frexpl(__x, __e);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +frexp(_A1 __x, int* __e) _NOEXCEPT {return __builtin_frexp((double)__x, __e);} + +// ldexp + +inline _LIBCPP_HIDE_FROM_ABI float ldexp(float __x, int __e) _NOEXCEPT {return __builtin_ldexpf(__x, __e);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double ldexp(double __x, int __e) _NOEXCEPT { + return __builtin_ldexp(__x, __e); +} + +inline _LIBCPP_HIDE_FROM_ABI long double ldexp(long double __x, int __e) _NOEXCEPT {return __builtin_ldexpl(__x, __e);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +ldexp(_A1 __x, int __e) _NOEXCEPT {return __builtin_ldexp((double)__x, __e);} + +// log + +inline _LIBCPP_HIDE_FROM_ABI float log(float __x) _NOEXCEPT {return __builtin_logf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log(double __x) _NOEXCEPT { + return __builtin_log(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log(long double __x) _NOEXCEPT {return __builtin_logl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +log(_A1 __x) _NOEXCEPT {return __builtin_log((double)__x);} + +// log10 + +inline _LIBCPP_HIDE_FROM_ABI float log10(float __x) _NOEXCEPT {return __builtin_log10f(__x);} + + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log10(double __x) _NOEXCEPT { + return __builtin_log10(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log10(long double __x) _NOEXCEPT {return __builtin_log10l(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +log10(_A1 __x) _NOEXCEPT {return __builtin_log10((double)__x);} + +// modf + +inline _LIBCPP_HIDE_FROM_ABI float modf(float __x, float* __y) _NOEXCEPT {return __builtin_modff(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double modf(double __x, double* __y) _NOEXCEPT { + return __builtin_modf(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double modf(long double __x, long double* __y) _NOEXCEPT {return __builtin_modfl(__x, __y);} + +// pow + +inline _LIBCPP_HIDE_FROM_ABI float pow(float __x, float __y) _NOEXCEPT {return __builtin_powf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double pow(double __x, double __y) _NOEXCEPT { + return __builtin_pow(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _NOEXCEPT {return __builtin_powl(__x, __y);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +pow(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::pow((__result_type)__x, (__result_type)__y); +} + +// sin + +inline _LIBCPP_HIDE_FROM_ABI float sin(float __x) _NOEXCEPT {return __builtin_sinf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double sin(double __x) _NOEXCEPT { + return __builtin_sin(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sin(long double __x) _NOEXCEPT {return __builtin_sinl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +sin(_A1 __x) _NOEXCEPT {return __builtin_sin((double)__x);} + +// sinh + +inline _LIBCPP_HIDE_FROM_ABI float sinh(float __x) _NOEXCEPT {return __builtin_sinhf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double sinh(double __x) _NOEXCEPT { + return __builtin_sinh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sinh(long double __x) _NOEXCEPT {return __builtin_sinhl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +sinh(_A1 __x) _NOEXCEPT {return __builtin_sinh((double)__x);} + +// sqrt + +inline _LIBCPP_HIDE_FROM_ABI float sqrt(float __x) _NOEXCEPT {return __builtin_sqrtf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double sqrt(double __x) _NOEXCEPT { + return __builtin_sqrt(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double sqrt(long double __x) _NOEXCEPT {return __builtin_sqrtl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +sqrt(_A1 __x) _NOEXCEPT {return __builtin_sqrt((double)__x);} + +// tan + +inline _LIBCPP_HIDE_FROM_ABI float tan(float __x) _NOEXCEPT {return __builtin_tanf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double tan(double __x) _NOEXCEPT { + return __builtin_tan(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tan(long double __x) _NOEXCEPT {return __builtin_tanl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +tan(_A1 __x) _NOEXCEPT {return __builtin_tan((double)__x);} + +// tanh + +inline _LIBCPP_HIDE_FROM_ABI float tanh(float __x) _NOEXCEPT {return __builtin_tanhf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double tanh(double __x) _NOEXCEPT { + return __builtin_tanh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tanh(long double __x) _NOEXCEPT {return __builtin_tanhl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +tanh(_A1 __x) _NOEXCEPT {return __builtin_tanh((double)__x);} + +// acosh + +inline _LIBCPP_HIDE_FROM_ABI float acosh(float __x) _NOEXCEPT {return __builtin_acoshf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double acosh(double __x) _NOEXCEPT { + return __builtin_acosh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double acosh(long double __x) _NOEXCEPT {return __builtin_acoshl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +acosh(_A1 __x) _NOEXCEPT {return __builtin_acosh((double)__x);} + +// asinh + +inline _LIBCPP_HIDE_FROM_ABI float asinh(float __x) _NOEXCEPT {return __builtin_asinhf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double asinh(double __x) _NOEXCEPT { + return __builtin_asinh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double asinh(long double __x) _NOEXCEPT {return __builtin_asinhl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +asinh(_A1 __x) _NOEXCEPT {return __builtin_asinh((double)__x);} + +// atanh + +inline _LIBCPP_HIDE_FROM_ABI float atanh(float __x) _NOEXCEPT {return __builtin_atanhf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double atanh(double __x) _NOEXCEPT { + return __builtin_atanh(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double atanh(long double __x) _NOEXCEPT {return __builtin_atanhl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +atanh(_A1 __x) _NOEXCEPT {return __builtin_atanh((double)__x);} + +// cbrt + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT {return __builtin_cbrtf(__x);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT { + return __builtin_cbrt(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {return __builtin_cbrtl(__x);} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +cbrt(_A1 __x) _NOEXCEPT {return __builtin_cbrt((double)__x);} + +// copysign +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT { + return ::__builtin_copysignf(__x, __y); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT { + return ::__builtin_copysignl(__x, __y); +} + +template <class _A1, class _A2> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type + copysign(_A1 __x, _A2 __y) _NOEXCEPT { + return ::__builtin_copysign(__x, __y); +} + +// erf + +inline _LIBCPP_HIDE_FROM_ABI float erf(float __x) _NOEXCEPT {return __builtin_erff(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double erf(double __x) _NOEXCEPT { + return __builtin_erf(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double erf(long double __x) _NOEXCEPT {return __builtin_erfl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +erf(_A1 __x) _NOEXCEPT {return __builtin_erf((double)__x);} + +// erfc + +inline _LIBCPP_HIDE_FROM_ABI float erfc(float __x) _NOEXCEPT {return __builtin_erfcf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double erfc(double __x) _NOEXCEPT { + return __builtin_erfc(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double erfc(long double __x) _NOEXCEPT {return __builtin_erfcl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +erfc(_A1 __x) _NOEXCEPT {return __builtin_erfc((double)__x);} + +// exp2 + +inline _LIBCPP_HIDE_FROM_ABI float exp2(float __x) _NOEXCEPT {return __builtin_exp2f(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double exp2(double __x) _NOEXCEPT { + return __builtin_exp2(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double exp2(long double __x) _NOEXCEPT {return __builtin_exp2l(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +exp2(_A1 __x) _NOEXCEPT {return __builtin_exp2((double)__x);} + +// expm1 + +inline _LIBCPP_HIDE_FROM_ABI float expm1(float __x) _NOEXCEPT {return __builtin_expm1f(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double expm1(double __x) _NOEXCEPT { + return __builtin_expm1(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double expm1(long double __x) _NOEXCEPT {return __builtin_expm1l(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +expm1(_A1 __x) _NOEXCEPT {return __builtin_expm1((double)__x);} + +// fdim + +inline _LIBCPP_HIDE_FROM_ABI float fdim(float __x, float __y) _NOEXCEPT {return __builtin_fdimf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double fdim(double __x, double __y) _NOEXCEPT { + return __builtin_fdim(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y) _NOEXCEPT {return __builtin_fdiml(__x, __y);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fdim(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::fdim((__result_type)__x, (__result_type)__y); +} + +// fma + +inline _LIBCPP_HIDE_FROM_ABI float fma(float __x, float __y, float __z) _NOEXCEPT +{ + return __builtin_fmaf(__x, __y, __z); +} + + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double fma(double __x, double __y, double __z) _NOEXCEPT { + return __builtin_fma(__x, __y, __z); +} + +inline _LIBCPP_HIDE_FROM_ABI long double fma(long double __x, long double __y, long double __z) _NOEXCEPT +{ + return __builtin_fmal(__x, __y, __z); +} + +template <class _A1, class _A2, class _A3> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value && + std::is_arithmetic<_A3>::value, + std::__promote<_A1, _A2, _A3> +>::type +fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value && + std::_IsSame<_A3, __result_type>::value)), ""); + return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z); +} + +// fmax + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {return __builtin_fmaxf(__x, __y);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT { + return __builtin_fmax(__x, __y); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {return __builtin_fmaxl(__x, __y);} + +template <class _A1, class _A2> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmax(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::fmax((__result_type)__x, (__result_type)__y); +} + +// fmin + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {return __builtin_fminf(__x, __y);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT { + return __builtin_fmin(__x, __y); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {return __builtin_fminl(__x, __y);} + +template <class _A1, class _A2> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmin(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::fmin((__result_type)__x, (__result_type)__y); +} + +// hypot + +inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {return __builtin_hypotf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT { + return __builtin_hypot(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {return __builtin_hypotl(__x, __y);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +hypot(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::hypot((__result_type)__x, (__result_type)__y); +} + +// ilogb + +inline _LIBCPP_HIDE_FROM_ABI int ilogb(float __x) _NOEXCEPT {return __builtin_ilogbf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double ilogb(double __x) _NOEXCEPT { + return __builtin_ilogb(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI int ilogb(long double __x) _NOEXCEPT {return __builtin_ilogbl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, int>::type +ilogb(_A1 __x) _NOEXCEPT {return __builtin_ilogb((double)__x);} + +// lgamma + +inline _LIBCPP_HIDE_FROM_ABI float lgamma(float __x) _NOEXCEPT {return __builtin_lgammaf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double lgamma(double __x) _NOEXCEPT { + return __builtin_lgamma(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double lgamma(long double __x) _NOEXCEPT {return __builtin_lgammal(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +lgamma(_A1 __x) _NOEXCEPT {return __builtin_lgamma((double)__x);} + +// llrint + +inline _LIBCPP_HIDE_FROM_ABI long long llrint(float __x) _NOEXCEPT +{ + return __builtin_llrintf(__x); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long long llrint(double __x) _NOEXCEPT { + return __builtin_llrint(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llrint(long double __x) _NOEXCEPT +{ + return __builtin_llrintl(__x); +} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, long long>::type +llrint(_A1 __x) _NOEXCEPT +{ + return __builtin_llrint((double)__x); +} + +// llround + +inline _LIBCPP_HIDE_FROM_ABI long long llround(float __x) _NOEXCEPT +{ + return __builtin_llroundf(__x); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long long llround(double __x) _NOEXCEPT { + return __builtin_llround(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long long llround(long double __x) _NOEXCEPT +{ + return __builtin_llroundl(__x); +} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, long long>::type +llround(_A1 __x) _NOEXCEPT +{ + return __builtin_llround((double)__x); +} + +// log1p + +inline _LIBCPP_HIDE_FROM_ABI float log1p(float __x) _NOEXCEPT {return __builtin_log1pf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log1p(double __x) _NOEXCEPT { + return __builtin_log1p(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log1p(long double __x) _NOEXCEPT {return __builtin_log1pl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +log1p(_A1 __x) _NOEXCEPT {return __builtin_log1p((double)__x);} + +// log2 + +inline _LIBCPP_HIDE_FROM_ABI float log2(float __x) _NOEXCEPT {return __builtin_log2f(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double log2(double __x) _NOEXCEPT { + return __builtin_log2(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double log2(long double __x) _NOEXCEPT {return __builtin_log2l(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +log2(_A1 __x) _NOEXCEPT {return __builtin_log2((double)__x);} + +// logb + +inline _LIBCPP_HIDE_FROM_ABI float logb(float __x) _NOEXCEPT {return __builtin_logbf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double logb(double __x) _NOEXCEPT { + return __builtin_logb(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double logb(long double __x) _NOEXCEPT {return __builtin_logbl(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +logb(_A1 __x) _NOEXCEPT {return __builtin_logb((double)__x);} + +// lrint + +inline _LIBCPP_HIDE_FROM_ABI long lrint(float __x) _NOEXCEPT +{ + return __builtin_lrintf(__x); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long lrint(double __x) _NOEXCEPT { + return __builtin_lrint(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long lrint(long double __x) _NOEXCEPT +{ + return __builtin_lrintl(__x); +} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, long>::type +lrint(_A1 __x) _NOEXCEPT +{ + return __builtin_lrint((double)__x); +} + +// lround + +inline _LIBCPP_HIDE_FROM_ABI long lround(float __x) _NOEXCEPT +{ + return __builtin_lroundf(__x); +} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI long lround(double __x) _NOEXCEPT { + return __builtin_lround(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long lround(long double __x) _NOEXCEPT +{ + return __builtin_lroundl(__x); +} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, long>::type +lround(_A1 __x) _NOEXCEPT +{ + return __builtin_lround((double)__x); +} + +// nan + +// nearbyint + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {return __builtin_nearbyintf(__x);} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT { + return __builtin_nearbyint(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {return __builtin_nearbyintl(__x);} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +nearbyint(_A1 __x) _NOEXCEPT {return __builtin_nearbyint((double)__x);} + +// nextafter + +inline _LIBCPP_HIDE_FROM_ABI float nextafter(float __x, float __y) _NOEXCEPT {return __builtin_nextafterf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double nextafter(double __x, double __y) _NOEXCEPT { + return __builtin_nextafter(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double __y) _NOEXCEPT {return __builtin_nextafterl(__x, __y);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +nextafter(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::nextafter((__result_type)__x, (__result_type)__y); +} + +// nexttoward + +inline _LIBCPP_HIDE_FROM_ABI float nexttoward(float __x, long double __y) _NOEXCEPT {return __builtin_nexttowardf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double nexttoward(double __x, long double __y) _NOEXCEPT { + return __builtin_nexttoward(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double nexttoward(long double __x, long double __y) _NOEXCEPT {return __builtin_nexttowardl(__x, __y);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +nexttoward(_A1 __x, long double __y) _NOEXCEPT {return __builtin_nexttoward((double)__x, __y);} + +// remainder + +inline _LIBCPP_HIDE_FROM_ABI float remainder(float __x, float __y) _NOEXCEPT {return __builtin_remainderf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double remainder(double __x, double __y) _NOEXCEPT { + return __builtin_remainder(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double __y) _NOEXCEPT {return __builtin_remainderl(__x, __y);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +remainder(_A1 __x, _A2 __y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::remainder((__result_type)__x, (__result_type)__y); +} + +// remquo + +inline _LIBCPP_HIDE_FROM_ABI float remquo(float __x, float __y, int* __z) _NOEXCEPT {return __builtin_remquof(__x, __y, __z);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double remquo(double __x, double __y, int* __z) _NOEXCEPT { + return __builtin_remquo(__x, __y, __z); +} + +inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y, int* __z) _NOEXCEPT {return __builtin_remquol(__x, __y, __z);} + +template <class _A1, class _A2> +inline _LIBCPP_HIDE_FROM_ABI +typename std::__enable_if_t +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::_IsSame<_A1, __result_type>::value && + std::_IsSame<_A2, __result_type>::value)), ""); + return ::remquo((__result_type)__x, (__result_type)__y, __z); +} + +// rint + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT +{ + return __builtin_rintf(__x); +} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT { + return __builtin_rint(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT +{ + return __builtin_rintl(__x); +} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +rint(_A1 __x) _NOEXCEPT +{ + return __builtin_rint((double)__x); +} + +// round + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT +{ + return __builtin_roundf(__x); +} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT { + return __builtin_round(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT +{ + return __builtin_roundl(__x); +} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +round(_A1 __x) _NOEXCEPT +{ + return __builtin_round((double)__x); +} + +// scalbln + +inline _LIBCPP_HIDE_FROM_ABI float scalbln(float __x, long __y) _NOEXCEPT {return __builtin_scalblnf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double scalbln(double __x, long __y) _NOEXCEPT { + return __builtin_scalbln(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double scalbln(long double __x, long __y) _NOEXCEPT {return __builtin_scalblnl(__x, __y);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +scalbln(_A1 __x, long __y) _NOEXCEPT {return __builtin_scalbln((double)__x, __y);} + +// scalbn + +inline _LIBCPP_HIDE_FROM_ABI float scalbn(float __x, int __y) _NOEXCEPT {return __builtin_scalbnf(__x, __y);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double scalbn(double __x, int __y) _NOEXCEPT { + return __builtin_scalbn(__x, __y); +} + +inline _LIBCPP_HIDE_FROM_ABI long double scalbn(long double __x, int __y) _NOEXCEPT {return __builtin_scalbnl(__x, __y);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +scalbn(_A1 __x, int __y) _NOEXCEPT {return __builtin_scalbn((double)__x, __y);} + +// tgamma + +inline _LIBCPP_HIDE_FROM_ABI float tgamma(float __x) _NOEXCEPT {return __builtin_tgammaf(__x);} + +template <class = int> +_LIBCPP_HIDE_FROM_ABI double tgamma(double __x) _NOEXCEPT { + return __builtin_tgamma(__x); +} + +inline _LIBCPP_HIDE_FROM_ABI long double tgamma(long double __x) _NOEXCEPT {return __builtin_tgammal(__x);} + +template <class _A1> +inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +tgamma(_A1 __x) _NOEXCEPT {return __builtin_tgamma((double)__x);} + +// trunc + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT +{ + return __builtin_truncf(__x); +} + +template <class = int> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT { + return __builtin_trunc(__x); +} + +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT +{ + return __builtin_truncl(__x); +} + +template <class _A1> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI +typename std::enable_if<std::is_integral<_A1>::value, double>::type +trunc(_A1 __x) _NOEXCEPT +{ + return __builtin_trunc((double)__x); +} + +} // extern "C++" + +#endif // __cplusplus + +#else // _LIBCPP_MATH_OLD_H + +// This include lives outside the header guard in order to support an MSVC +// extension which allows users to do: +// +// #define _USE_MATH_DEFINES +// #include <math.h> +// +// and receive the definitions of mathematical constants, even if <math.h> +// has previously been included. +#if defined(_LIBCPP_MSVCRT) && defined(_USE_MATH_DEFINES) +#include_next <math.h> +#endif + +#endif // _LIBCPP_MATH_OLD_H
\ No newline at end of file diff --git a/contrib/libs/cxxsupp/libcxx/include/mutex b/contrib/libs/cxxsupp/libcxx/include/mutex index 6cd4f028b0..ec110c8c07 100644 --- a/contrib/libs/cxxsupp/libcxx/include/mutex +++ b/contrib/libs/cxxsupp/libcxx/include/mutex @@ -194,6 +194,7 @@ template<class Callable, class ...Args> #include <__memory/shared_ptr.h> #include <__mutex/lock_guard.h> #include <__mutex/mutex.h> +#include <__mutex/once_flag.h> #include <__mutex/tag_types.h> #include <__mutex/unique_lock.h> #include <__thread/id.h> @@ -206,10 +207,6 @@ template<class Callable, class ...Args> #endif #include <version> -#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG) -#include <atomic> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -559,177 +556,6 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock); #endif // _LIBCPP_STD_VER >= 17 #endif // !_LIBCPP_HAS_NO_THREADS -struct _LIBCPP_TEMPLATE_VIS once_flag; - -#ifndef _LIBCPP_CXX03_LANG - -template<class _Callable, class... _Args> -_LIBCPP_INLINE_VISIBILITY -void call_once(once_flag&, _Callable&&, _Args&&...); - -#else // _LIBCPP_CXX03_LANG - -template<class _Callable> -_LIBCPP_INLINE_VISIBILITY -void call_once(once_flag&, _Callable&); - -template<class _Callable> -_LIBCPP_INLINE_VISIBILITY -void call_once(once_flag&, const _Callable&); - -#endif // _LIBCPP_CXX03_LANG - -struct _LIBCPP_TEMPLATE_VIS once_flag -{ - _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR - once_flag() _NOEXCEPT : __state_(0) {} - once_flag(const once_flag&) = delete; - once_flag& operator=(const once_flag&) = delete; - -#if defined(_LIBCPP_ABI_MICROSOFT) - typedef uintptr_t _State_type; -#else - typedef unsigned long _State_type; -#endif - -private: -#if defined(_LIBCPP_ABI_MICROSOFT) - atomic<_State_type> __state_; -#else - _State_type __state_; -#endif - -#ifndef _LIBCPP_CXX03_LANG - template<class _Callable, class... _Args> - friend - void call_once(once_flag&, _Callable&&, _Args&&...); -#else // _LIBCPP_CXX03_LANG - template<class _Callable> - friend - void call_once(once_flag&, _Callable&); - - template<class _Callable> - friend - void call_once(once_flag&, const _Callable&); -#endif // _LIBCPP_CXX03_LANG -}; - -#ifndef _LIBCPP_CXX03_LANG - -template <class _Fp> -class __call_once_param -{ - _Fp& __f_; -public: - _LIBCPP_INLINE_VISIBILITY - explicit __call_once_param(_Fp& __f) : __f_(__f) {} - - _LIBCPP_INLINE_VISIBILITY - void operator()() - { - typedef typename __make_tuple_indices<tuple_size<_Fp>::value, 1>::type _Index; - __execute(_Index()); - } - -private: - template <size_t ..._Indices> - _LIBCPP_INLINE_VISIBILITY - void __execute(__tuple_indices<_Indices...>) - { - _VSTD::__invoke(_VSTD::get<0>(_VSTD::move(__f_)), _VSTD::get<_Indices>(_VSTD::move(__f_))...); - } -}; - -#else - -template <class _Fp> -class __call_once_param -{ - _Fp& __f_; -public: - _LIBCPP_INLINE_VISIBILITY - explicit __call_once_param(_Fp& __f) : __f_(__f) {} - - _LIBCPP_INLINE_VISIBILITY - void operator()() - { - __f_(); - } -}; - -#endif - -template <class _Fp> -void _LIBCPP_INLINE_VISIBILITY -__call_once_proxy(void* __vp) -{ - __call_once_param<_Fp>* __p = static_cast<__call_once_param<_Fp>*>(__vp); - (*__p)(); -} - -#ifdef _LIBCPP_ABI_MICROSOFT -_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile atomic<once_flag::_State_type>&, void*, void (*)(void*)); -#else -_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*)); -#endif - -#ifndef _LIBCPP_CXX03_LANG - -template<class _Callable, class... _Args> -inline _LIBCPP_INLINE_VISIBILITY -void -call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args) -{ -#if defined(_LIBCPP_ABI_MICROSOFT) - if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0)) -#else - if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0)) -#endif - { - typedef tuple<_Callable&&, _Args&&...> _Gp; - _Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...); - __call_once_param<_Gp> __p(__f); - std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>); - } -} - -#else // _LIBCPP_CXX03_LANG - -template<class _Callable> -inline _LIBCPP_INLINE_VISIBILITY -void -call_once(once_flag& __flag, _Callable& __func) -{ -#if defined(_LIBCPP_ABI_MICROSOFT) - if (__flag.__state_.load(memory_order_acquire) != ~once_flag::_State_type(0)) -#else - if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0)) -#endif - { - __call_once_param<_Callable> __p(__func); - std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>); - } -} - -template<class _Callable> -inline _LIBCPP_INLINE_VISIBILITY -void -call_once(once_flag& __flag, const _Callable& __func) -{ -#if defined(_LIBCPP_ABI_MICROSOFT) - if (__flag.__state_.load(memory_order_relaxed) != ~once_flag::_State_type(0)) -#else - if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0)) -#endif - { - __call_once_param<const _Callable> __p(__func); - std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>); - } -} - -#endif // _LIBCPP_CXX03_LANG - _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/include/new b/contrib/libs/cxxsupp/libcxx/include/new index 3064a0e2f0..0a97c3e37a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/new +++ b/contrib/libs/cxxsupp/libcxx/include/new @@ -133,6 +133,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_alloc { public: bad_alloc() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI bad_alloc(const bad_alloc&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_alloc& operator=(const bad_alloc&) _NOEXCEPT = default; ~bad_alloc() _NOEXCEPT override; const char* what() const _NOEXCEPT override; }; @@ -142,6 +144,8 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_array_new_length { public: bad_array_new_length() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI bad_array_new_length(const bad_array_new_length&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_array_new_length& operator=(const bad_array_new_length&) _NOEXCEPT = default; ~bad_array_new_length() _NOEXCEPT override; const char* what() const _NOEXCEPT override; }; @@ -185,7 +189,7 @@ void __throw_bad_array_new_length() #if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && \ !defined(_LIBCPP_ABI_VCRUNTIME) #ifndef _LIBCPP_CXX03_LANG -enum class _LIBCPP_ENUM_VIS align_val_t : size_t { }; +enum class align_val_t : size_t { }; #else enum align_val_t { __zero = 0, __max = (size_t)-1 }; #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/optional b/contrib/libs/cxxsupp/libcxx/include/optional index ac1a925496..4048fa2f59 100644 --- a/contrib/libs/cxxsupp/libcxx/include/optional +++ b/contrib/libs/cxxsupp/libcxx/include/optional @@ -249,6 +249,9 @@ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_opt : public exception { public: + _LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_optional_access& operator=(const bad_optional_access&) _NOEXCEPT = default; // Get the key function ~bad_optional_access() into the dylib ~bad_optional_access() _NOEXCEPT override; const char* what() const _NOEXCEPT override; @@ -731,7 +734,8 @@ private: template <class _Up> using _CheckOptionalArgsCtor = _If< _IsNotSame<__remove_cvref_t<_Up>, in_place_t>::value && - _IsNotSame<__remove_cvref_t<_Up>, optional>::value, + _IsNotSame<__remove_cvref_t<_Up>, optional>::value && + (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_optional<__remove_cvref_t<_Up>>::value), _CheckOptionalArgsConstructor, __check_tuple_constructor_fail >; @@ -758,12 +762,12 @@ private: template <class _Up, class _QUp = _QualUp> _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_implicit() { return is_convertible<_QUp, _Tp>::value && - !__check_constructible_from_opt<_Up>::value; + (is_same_v<remove_cv_t<_Tp>, bool> || !__check_constructible_from_opt<_Up>::value); } template <class _Up, class _QUp = _QualUp> _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_explicit() { return !is_convertible<_QUp, _Tp>::value && - !__check_constructible_from_opt<_Up>::value; + (is_same_v<remove_cv_t<_Tp>, bool> || !__check_constructible_from_opt<_Up>::value); } template <class _Up, class _QUp = _QualUp> _LIBCPP_HIDE_FROM_ABI static constexpr bool __enable_assign() { diff --git a/contrib/libs/cxxsupp/libcxx/include/ostream b/contrib/libs/cxxsupp/libcxx/include/ostream index 51d944e9c8..f0e90cf28d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ostream +++ b/contrib/libs/cxxsupp/libcxx/include/ostream @@ -1074,10 +1074,9 @@ struct __is_ostreamable<_Stream, _Tp, decltype( std::declval<_Stream>() << std::declval<_Tp>(), void() )> : true_type { }; -template <class _Stream, class _Tp, class = typename enable_if< - _And<is_base_of<ios_base, _Stream>, - __is_ostreamable<_Stream&, const _Tp&> >::value ->::type> +template <class _Stream, + class _Tp, + __enable_if_t<_And<is_base_of<ios_base, _Stream>, __is_ostreamable<_Stream&, const _Tp&> >::value, int> = 0> _LIBCPP_INLINE_VISIBILITY _Stream&& operator<<(_Stream&& __os, const _Tp& __x) { @@ -1117,15 +1116,17 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) return __os << __p.get(); } -template<class _CharT, class _Traits, class _Yp, class _Dp> -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_same<void, __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value, - basic_ostream<_CharT, _Traits>& ->::type -operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) -{ +template < + class _CharT, + class _Traits, + class _Yp, + class _Dp, + __enable_if_t<is_same<void, + __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>() + << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value, + int> = 0> +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& +operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) { return __os << __p.get(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/queue b/contrib/libs/cxxsupp/libcxx/include/queue index b5944e8f9f..21c18ef431 100644 --- a/contrib/libs/cxxsupp/libcxx/include/queue +++ b/contrib/libs/cxxsupp/libcxx/include/queue @@ -565,9 +565,9 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y #endif -template <class _Tp, class _Container> +template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -__enable_if_t<__is_swappable<_Container>::value, void> +void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { @@ -1108,12 +1108,10 @@ priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) swap(comp, __q.comp); } -template <class _Tp, class _Container, class _Compare> +template <class _Tp, class _Container, class _Compare, + __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -__enable_if_t< - __is_swappable<_Container>::value && __is_swappable<_Compare>::value, - void -> +void swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/contrib/libs/cxxsupp/libcxx/include/ranges b/contrib/libs/cxxsupp/libcxx/include/ranges index 523f7cdcb3..db592fd5cb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ranges +++ b/contrib/libs/cxxsupp/libcxx/include/ranges @@ -320,17 +320,24 @@ namespace std::ranges { class zip_view; // C++23 template<class... Views> - inline constexpr bool enable_borrowed_range<zip_view<Views...>> = // C++23 + inline constexpr bool enable_borrowed_range<zip_view<Views...>> = // C++23 (enable_borrowed_range<Views> && ...); - namespace views { inline constexpr unspecified zip = unspecified; } // C++23 + namespace views { inline constexpr unspecified zip = unspecified; } // C++23 // [range.as.rvalue] template <view V> requires input_range<V> - class as_rvalue_view; // since C++23 + class as_rvalue_view; // C++23 - namespace views { inline constexpr unspecified as_rvalue ) unspecified; } // since C++23 + namespace views { inline constexpr unspecified as_rvalue ) unspecified; } // C++23 + + [range.chunk.by] + template<forward_range V, indirect_binary_predicate<iterator_t<V>, iterator_t<V>> Pred> + requires view<V> && is_object_v<Pred> + class chunk_by_view; // C++23 + + namespace views { inline constexpr unspecified chunk_by = unspecified; } // C++23 } namespace std { @@ -373,6 +380,7 @@ namespace std { #include <__ranges/access.h> #include <__ranges/all.h> #include <__ranges/as_rvalue_view.h> +#include <__ranges/chunk_by_view.h> #include <__ranges/common_view.h> #include <__ranges/concepts.h> #include <__ranges/counted.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/regex b/contrib/libs/cxxsupp/libcxx/include/regex index be1bce10eb..e8865ac108 100644 --- a/contrib/libs/cxxsupp/libcxx/include/regex +++ b/contrib/libs/cxxsupp/libcxx/include/regex @@ -1459,7 +1459,7 @@ struct __state _LIBCPP_INLINE_VISIBILITY __state() : __do_(0), __first_(nullptr), __current_(nullptr), __last_(nullptr), - __node_(nullptr), __flags_() {} + __node_(nullptr), __flags_(), __at_first_(false) {} }; // __node @@ -2776,9 +2776,9 @@ public: flag_type __f = regex_constants::ECMAScript) {return assign(__s.begin(), __s.end(), __f);} - template <class _InputIterator> + template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value, basic_regex&>::type + basic_regex& assign(_InputIterator __first, _InputIterator __last, flag_type __f = regex_constants::ECMAScript) { @@ -2798,13 +2798,9 @@ private: } public: - template <class _ForwardIterator> + template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if - < - __has_forward_iterator_category<_ForwardIterator>::value, - basic_regex& - >::type + basic_regex& assign(_ForwardIterator __first, _ForwardIterator __last, flag_type __f = regex_constants::ECMAScript) { @@ -3110,8 +3106,7 @@ private: #if _LIBCPP_STD_VER >= 17 template <class _ForwardIterator, - class = typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value, nullptr_t>::type -> + __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript) -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>; @@ -6957,6 +6952,7 @@ _LIBCPP_POP_MACROS # include <cstdlib> # include <iosfwd> # include <iterator> +# include <mutex> # include <new> # include <type_traits> # include <typeinfo> diff --git a/contrib/libs/cxxsupp/libcxx/include/semaphore b/contrib/libs/cxxsupp/libcxx/include/semaphore index 971ca2f70a..53c9578b79 100644 --- a/contrib/libs/cxxsupp/libcxx/include/semaphore +++ b/contrib/libs/cxxsupp/libcxx/include/semaphore @@ -52,6 +52,7 @@ using binary_semaphore = counting_semaphore<1>; #include <__availability> #include <__chrono/time_point.h> #include <__config> +#include <__thread/poll_with_backoff.h> #include <__thread/timed_backoff_policy.h> #include <__threading_support> #include <cstddef> diff --git a/contrib/libs/cxxsupp/libcxx/include/set b/contrib/libs/cxxsupp/libcxx/include/set index 0577ff080e..3422d43abb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/set +++ b/contrib/libs/cxxsupp/libcxx/include/set @@ -920,13 +920,13 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + iterator find(const _K2& __k) {return __tree_.find(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + const_iterator find(const _K2& __k) const {return __tree_.find(__k);} #endif @@ -934,18 +934,18 @@ public: size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + size_type count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif #if _LIBCPP_STD_VER >= 20 _LIBCPP_INLINE_VISIBILITY bool contains(const key_type& __k) const {return find(__k) != end();} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + bool contains(const _K2& __k) const { return find(__k) != end(); } #endif // _LIBCPP_STD_VER >= 20 @@ -956,14 +956,14 @@ public: const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + iterator lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + const_iterator lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} #endif @@ -974,13 +974,13 @@ public: const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + iterator upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + const_iterator upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} #endif @@ -991,13 +991,13 @@ public: pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + pair<iterator,iterator> equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + pair<const_iterator,const_iterator> equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} #endif }; @@ -1511,13 +1511,13 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + iterator find(const _K2& __k) {return __tree_.find(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + const_iterator find(const _K2& __k) const {return __tree_.find(__k);} #endif @@ -1525,18 +1525,18 @@ public: size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type + size_type count(const _K2& __k) const {return __tree_.__count_multi(__k);} #endif #if _LIBCPP_STD_VER >= 20 _LIBCPP_INLINE_VISIBILITY bool contains(const key_type& __k) const {return find(__k) != end();} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + bool contains(const _K2& __k) const { return find(__k) != end(); } #endif // _LIBCPP_STD_VER >= 20 @@ -1547,14 +1547,14 @@ public: const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + iterator lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + const_iterator lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} #endif @@ -1565,13 +1565,13 @@ public: const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + iterator upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + const_iterator upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} #endif @@ -1582,13 +1582,13 @@ public: pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} #if _LIBCPP_STD_VER >= 14 - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + pair<iterator,iterator> equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} - template <typename _K2> + template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0> _LIBCPP_INLINE_VISIBILITY - typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + pair<const_iterator,const_iterator> equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} #endif }; diff --git a/contrib/libs/cxxsupp/libcxx/include/stack b/contrib/libs/cxxsupp/libcxx/include/stack index 437f57d76b..6d725a84b0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stack +++ b/contrib/libs/cxxsupp/libcxx/include/stack @@ -414,9 +414,9 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y #endif -template <class _Tp, class _Container> +template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -__enable_if_t<__is_swappable<_Container>::value, void> +void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) { diff --git a/contrib/libs/cxxsupp/libcxx/include/stdexcept b/contrib/libs/cxxsupp/libcxx/include/stdexcept index 5428535a10..cc6b0c5f38 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stdexcept +++ b/contrib/libs/cxxsupp/libcxx/include/stdexcept @@ -129,6 +129,7 @@ public: #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI domain_error(const domain_error&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI domain_error& operator=(const domain_error&) _NOEXCEPT = default; ~domain_error() _NOEXCEPT override; #endif }; @@ -142,6 +143,7 @@ public: #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI invalid_argument(const invalid_argument&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI invalid_argument& operator=(const invalid_argument&) _NOEXCEPT = default; ~invalid_argument() _NOEXCEPT override; #endif }; @@ -154,6 +156,7 @@ public: _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {} #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI length_error(const length_error&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI length_error& operator=(const length_error&) _NOEXCEPT = default; ~length_error() _NOEXCEPT override; #endif }; @@ -167,6 +170,7 @@ public: #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI out_of_range& operator=(const out_of_range&) _NOEXCEPT = default; ~out_of_range() _NOEXCEPT override; #endif }; @@ -180,6 +184,7 @@ public: #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI range_error(const range_error&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI range_error& operator=(const range_error&) _NOEXCEPT = default; ~range_error() _NOEXCEPT override; #endif }; @@ -193,6 +198,7 @@ public: #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI overflow_error(const overflow_error&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI overflow_error& operator=(const overflow_error&) _NOEXCEPT = default; ~overflow_error() _NOEXCEPT override; #endif }; @@ -206,6 +212,7 @@ public: #ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI underflow_error(const underflow_error&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI underflow_error& operator=(const underflow_error&) _NOEXCEPT = default; ~underflow_error() _NOEXCEPT override; #endif }; diff --git a/contrib/libs/cxxsupp/libcxx/include/stdio.h b/contrib/libs/cxxsupp/libcxx/include/stdio.h index cea43aa768..72ed5c9f94 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stdio.h +++ b/contrib/libs/cxxsupp/libcxx/include/stdio.h @@ -115,6 +115,8 @@ void perror(const char* s); #undef clearerr #undef feof #undef ferror +#undef putchar +#undef getchar #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string index 30bca6b92e..6550f5baf6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string +++ b/contrib/libs/cxxsupp/libcxx/include/string @@ -2004,7 +2004,8 @@ private: allocator_type __a = __str.__alloc(); auto __allocation = std::__allocate_at_least(__a, __str.__get_long_cap()); __begin_lifetime(__allocation.ptr, __allocation.count); - __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); + if (__is_long()) + __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); __alloc() = std::move(__a); __set_long_pointer(__allocation.ptr); __set_long_cap(__allocation.count); diff --git a/contrib/libs/cxxsupp/libcxx/include/string_view b/contrib/libs/cxxsupp/libcxx/include/string_view index 3219455540..07fcf446a4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string_view +++ b/contrib/libs/cxxsupp/libcxx/include/string_view @@ -779,7 +779,35 @@ template <ranges::contiguous_range _Range> #endif // [string.view.comparison] + +#if _LIBCPP_STD_VER >= 20 + +template<class _CharT, class _Traits> +_LIBCPP_HIDE_FROM_ABI constexpr +bool operator==(basic_string_view<_CharT, _Traits> __lhs, + type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept { + if (__lhs.size() != __rhs.size()) return false; + return __lhs.compare(__rhs) == 0; +} + +template <class _CharT, class _Traits> +_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>( + basic_string_view<_CharT, _Traits> __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept { + if constexpr (requires { typename _Traits::comparison_category; }) { + // [string.view]/4 + static_assert( + __comparison_category<typename _Traits::comparison_category>, + "return type is not a comparison category type"); + return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0); + } else { + return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0); + } +} + +#else + // operator == + template<class _CharT, class _Traits> _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY bool operator==(basic_string_view<_CharT, _Traits> __lhs, @@ -800,8 +828,6 @@ bool operator==(basic_string_view<_CharT, _Traits> __lhs, return __lhs.compare(__rhs) == 0; } -#if _LIBCPP_STD_VER < 20 -// This overload is automatically generated in C++20. template<class _CharT, class _Traits, int = 2> _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY bool operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs, @@ -810,41 +836,6 @@ bool operator==(__type_identity_t<basic_string_view<_CharT, _Traits> > __lhs, if (__lhs.size() != __rhs.size()) return false; return __lhs.compare(__rhs) == 0; } -#endif // _LIBCPP_STD_VER >= 20 - -// operator <=> - -#if _LIBCPP_STD_VER >= 20 - -template <class _CharT, class _Traits> -_LIBCPP_HIDE_FROM_ABI constexpr auto -operator<=>(basic_string_view<_CharT, _Traits> __lhs, basic_string_view<_CharT, _Traits> __rhs) noexcept { - if constexpr (requires { typename _Traits::comparison_category; }) { - // [string.view]/4 - static_assert( - __comparison_category<typename _Traits::comparison_category>, - "return type is not a comparison category type"); - return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0); - } else { - return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0); - } -} - -template <class _CharT, class _Traits, int = 1> -_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>( - basic_string_view<_CharT, _Traits> __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) noexcept { - if constexpr (requires { typename _Traits::comparison_category; }) { - // [string.view]/4 - static_assert( - __comparison_category<typename _Traits::comparison_category>, - "return type is not a comparison category type"); - return static_cast<typename _Traits::comparison_category>(__lhs.compare(__rhs) <=> 0); - } else { - return static_cast<weak_ordering>(__lhs.compare(__rhs) <=> 0); - } -} - -#else // _LIBCPP_STD_VER >= 20 // operator != template<class _CharT, class _Traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/thread b/contrib/libs/cxxsupp/libcxx/include/thread index 4ddcf3ec79..943085b7af 100644 --- a/contrib/libs/cxxsupp/libcxx/include/thread +++ b/contrib/libs/cxxsupp/libcxx/include/thread @@ -90,6 +90,7 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); #include <__availability> #include <__config> #include <__thread/formatter.h> +#include <__thread/jthread.h> #include <__thread/this_thread.h> #include <__thread/thread.h> #include <__threading_support> diff --git a/contrib/libs/cxxsupp/libcxx/include/tuple b/contrib/libs/cxxsupp/libcxx/include/tuple index 8769e2569d..eb1785cc89 100644 --- a/contrib/libs/cxxsupp/libcxx/include/tuple +++ b/contrib/libs/cxxsupp/libcxx/include/tuple @@ -883,13 +883,13 @@ public: template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> _LIBCPP_HIDE_FROM_ABI constexpr - explicit(!(is_convertible_v<_Up&, _Tp> && ...)) + explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t) : __base_(__t) {} template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr> _LIBCPP_HIDE_FROM_ABI constexpr - explicit(!(is_convertible_v<_Up&, _Tp> && ...)) + explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t) : __base_(allocator_arg_t(), __alloc, __t) {} #endif // _LIBCPP_STD_VER >= 23 @@ -947,13 +947,13 @@ public: template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> _LIBCPP_HIDE_FROM_ABI constexpr - explicit(!(is_convertible_v<const _Up&&, _Tp> && ...)) + explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) tuple(const tuple<_Up...>&& __t) : __base_(std::move(__t)) {} template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr> _LIBCPP_HIDE_FROM_ABI constexpr - explicit(!(is_convertible_v<const _Up&&, _Tp> && ...)) + explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value) tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t) : __base_(allocator_arg_t(), __alloc, std::move(__t)) {} #endif // _LIBCPP_STD_VER >= 23 @@ -1367,9 +1367,9 @@ template <class _Alloc, class ..._Tp> tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>; #endif -template <class ..._Tp> +template <class ..._Tp, __enable_if_t<__all<__is_swappable<_Tp>::value...>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 -__enable_if_t<__all<__is_swappable<_Tp>::value...>::value, void> +void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u) _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) {__t.swap(__u);} diff --git a/contrib/libs/cxxsupp/libcxx/include/typeinfo b/contrib/libs/cxxsupp/libcxx/include/typeinfo index 0a640bf984..e6c9648ce1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/typeinfo +++ b/contrib/libs/cxxsupp/libcxx/include/typeinfo @@ -364,15 +364,16 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_cast { public: #ifdef _LIBCPP_ABI_MICROSOFT - bad_cast() _NOEXCEPT {} - virtual ~bad_cast() _NOEXCEPT {} - virtual const char* what() const _NOEXCEPT - { - return "std::bad_cast"; - } + bad_cast() _NOEXCEPT {} + virtual ~bad_cast() _NOEXCEPT {} + virtual const char* what() const _NOEXCEPT + { + return "std::bad_cast"; + } #else bad_cast() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI bad_cast(const bad_cast&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_cast& operator=(const bad_cast&) _NOEXCEPT = default; ~bad_cast() _NOEXCEPT override; const char* what() const _NOEXCEPT override; #endif @@ -383,14 +384,16 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_typeid { public: #ifdef _LIBCPP_ABI_MICROSOFT - bad_typeid() _NOEXCEPT {} - virtual ~bad_typeid() _NOEXCEPT {} - virtual const char* what() const _NOEXCEPT - { - return "std::bad_typeid"; - } + bad_typeid() _NOEXCEPT {} + virtual ~bad_typeid() _NOEXCEPT {} + virtual const char* what() const _NOEXCEPT + { + return "std::bad_typeid"; + } #else bad_typeid() _NOEXCEPT; + _LIBCPP_HIDE_FROM_ABI bad_typeid(const bad_typeid&) _NOEXCEPT = default; + _LIBCPP_HIDE_FROM_ABI bad_typeid& operator=(const bad_typeid&) _NOEXCEPT = default; ~bad_typeid() _NOEXCEPT override; const char* what() const _NOEXCEPT override; #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_map b/contrib/libs/cxxsupp/libcxx/include/unordered_map index 8d83063bbe..e5c58feee5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_map +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_map @@ -874,9 +874,9 @@ public: void operator()(pointer __p) _NOEXCEPT { if (__second_constructed) - __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().second)); + __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__get_value().__get_value().second)); if (__first_constructed) - __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__value_.__get_value().first)); + __alloc_traits::destroy(__na_, _VSTD::addressof(__p->__get_value().__get_value().first)); if (__p) __alloc_traits::deallocate(__na_, __p, 1); } @@ -1828,7 +1828,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( iterator __i = __u.begin(); while (__u.size() != 0) { __table_.__emplace_unique( - __u.__table_.remove((__i++).__i_)->__value_.__move()); + __u.__table_.remove((__i++).__i_)->__get_value().__move()); } } } @@ -1920,9 +1920,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const { __node_allocator& __na = __table_.__node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().first), __k); + __node_traits::construct(__na, _VSTD::addressof(__h->__get_value().__get_value().first), __k); __h.get_deleter().__first_constructed = true; - __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__get_value().second)); + __node_traits::construct(__na, _VSTD::addressof(__h->__get_value().__get_value().second)); __h.get_deleter().__second_constructed = true; return __h; } @@ -2653,7 +2653,7 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( while (__u.size() != 0) { __table_.__insert_multi( - __u.__table_.remove((__i++).__i_)->__value_.__move()); + __u.__table_.remove((__i++).__i_)->__get_value().__move()); } } } diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_set b/contrib/libs/cxxsupp/libcxx/include/unordered_set index 5e47f12446..f1b4104df4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_set +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_set @@ -1150,7 +1150,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( { iterator __i = __u.begin(); while (__u.size() != 0) - __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_)); + __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__get_value())); } } @@ -1835,7 +1835,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( { iterator __i = __u.begin(); while (__u.size() != 0) - __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_)); + __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__get_value())); } } diff --git a/contrib/libs/cxxsupp/libcxx/include/valarray b/contrib/libs/cxxsupp/libcxx/include/valarray index 09a7c9016c..7db1bba018 100644 --- a/contrib/libs/cxxsupp/libcxx/include/valarray +++ b/contrib/libs/cxxsupp/libcxx/include/valarray @@ -971,94 +971,44 @@ public: _LIBCPP_INLINE_VISIBILITY valarray& operator>>=(const value_type& __x); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator*= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator/= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator%= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator+= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator-= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator^= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator|= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator&= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator<<= (const _Expr& __v); - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - valarray& - >::type - _LIBCPP_INLINE_VISIBILITY + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + _LIBCPP_INLINE_VISIBILITY valarray& operator>>= (const _Expr& __v); // member functions: @@ -1219,102 +1169,58 @@ private: size_t __stride_; public: - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; @@ -1353,13 +1259,9 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1377,13 +1279,9 @@ slice_array<_Tp>::operator=(const valarray<value_type>& __va) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator*=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1392,13 +1290,9 @@ slice_array<_Tp>::operator*=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator/=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1407,13 +1301,9 @@ slice_array<_Tp>::operator/=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator%=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1422,13 +1312,9 @@ slice_array<_Tp>::operator%=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator+=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1437,13 +1323,9 @@ slice_array<_Tp>::operator+=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator-=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1452,13 +1334,9 @@ slice_array<_Tp>::operator-=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator^=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1467,13 +1345,9 @@ slice_array<_Tp>::operator^=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator&=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1482,13 +1356,9 @@ slice_array<_Tp>::operator&=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator|=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1497,13 +1367,9 @@ slice_array<_Tp>::operator|=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator<<=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1512,13 +1378,9 @@ slice_array<_Tp>::operator<<=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void slice_array<_Tp>::operator>>=(const _Expr& __v) const { value_type* __t = __vp_; @@ -1610,102 +1472,58 @@ private: valarray<size_t> __1d_; public: - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; @@ -1734,13 +1552,9 @@ private: }; template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1750,13 +1564,9 @@ gslice_array<_Tp>::operator=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator*=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1766,13 +1576,9 @@ gslice_array<_Tp>::operator*=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator/=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1782,13 +1588,9 @@ gslice_array<_Tp>::operator/=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator%=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1798,13 +1600,9 @@ gslice_array<_Tp>::operator%=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator+=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1814,13 +1612,9 @@ gslice_array<_Tp>::operator+=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator-=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1830,13 +1624,9 @@ gslice_array<_Tp>::operator-=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator^=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1846,13 +1636,9 @@ gslice_array<_Tp>::operator^=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator&=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1862,13 +1648,9 @@ gslice_array<_Tp>::operator&=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator|=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1878,13 +1660,9 @@ gslice_array<_Tp>::operator|=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator<<=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1894,13 +1672,9 @@ gslice_array<_Tp>::operator<<=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void gslice_array<_Tp>::operator>>=(const _Expr& __v) const { typedef const size_t* _Ip; @@ -1945,102 +1719,58 @@ private: valarray<size_t> __1d_; public: - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; @@ -2068,13 +1798,9 @@ private: }; template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2083,13 +1809,9 @@ mask_array<_Tp>::operator=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator*=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2098,13 +1820,9 @@ mask_array<_Tp>::operator*=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator/=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2113,13 +1831,9 @@ mask_array<_Tp>::operator/=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator%=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2128,13 +1842,9 @@ mask_array<_Tp>::operator%=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator+=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2143,13 +1853,9 @@ mask_array<_Tp>::operator+=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator-=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2158,13 +1864,9 @@ mask_array<_Tp>::operator-=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator^=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2173,13 +1875,9 @@ mask_array<_Tp>::operator^=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator&=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2188,13 +1886,9 @@ mask_array<_Tp>::operator&=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator|=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2203,13 +1897,9 @@ mask_array<_Tp>::operator|=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator<<=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2218,13 +1908,9 @@ mask_array<_Tp>::operator<<=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, void ->::type mask_array<_Tp>::operator>>=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2301,102 +1987,58 @@ private: valarray<size_t> __1d_; public: - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; - template <class _Expr> - typename enable_if - < - __is_val_expr<_Expr>::value, - void - >::type + template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> + void _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; @@ -2429,13 +2071,9 @@ private: }; template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2444,13 +2082,9 @@ indirect_array<_Tp>::operator=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator*=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2459,13 +2093,9 @@ indirect_array<_Tp>::operator*=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator/=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2474,13 +2104,9 @@ indirect_array<_Tp>::operator/=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator%=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2489,13 +2115,9 @@ indirect_array<_Tp>::operator%=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator+=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2504,13 +2126,9 @@ indirect_array<_Tp>::operator+=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator-=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2519,13 +2137,9 @@ indirect_array<_Tp>::operator-=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator^=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2534,13 +2148,9 @@ indirect_array<_Tp>::operator^=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator&=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2549,13 +2159,9 @@ indirect_array<_Tp>::operator&=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator|=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2564,13 +2170,9 @@ indirect_array<_Tp>::operator|=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator<<=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -2579,13 +2181,9 @@ indirect_array<_Tp>::operator<<=(const _Expr& __v) const } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, - void ->::type +void indirect_array<_Tp>::operator>>=(const _Expr& __v) const { size_t __n = __1d_.size(); @@ -3456,13 +3054,9 @@ valarray<_Tp>::operator>>=(const value_type& __x) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator*=(const _Expr& __v) { size_t __i = 0; @@ -3472,13 +3066,9 @@ valarray<_Tp>::operator*=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator/=(const _Expr& __v) { size_t __i = 0; @@ -3488,13 +3078,9 @@ valarray<_Tp>::operator/=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator%=(const _Expr& __v) { size_t __i = 0; @@ -3504,13 +3090,9 @@ valarray<_Tp>::operator%=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator+=(const _Expr& __v) { size_t __i = 0; @@ -3520,13 +3102,9 @@ valarray<_Tp>::operator+=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator-=(const _Expr& __v) { size_t __i = 0; @@ -3536,13 +3114,9 @@ valarray<_Tp>::operator-=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator^=(const _Expr& __v) { size_t __i = 0; @@ -3552,13 +3126,9 @@ valarray<_Tp>::operator^=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator|=(const _Expr& __v) { size_t __i = 0; @@ -3568,13 +3138,9 @@ valarray<_Tp>::operator|=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator&=(const _Expr& __v) { size_t __i = 0; @@ -3584,13 +3150,9 @@ valarray<_Tp>::operator&=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator<<=(const _Expr& __v) { size_t __i = 0; @@ -3600,13 +3162,9 @@ valarray<_Tp>::operator<<=(const _Expr& __v) } template <class _Tp> -template <class _Expr> +template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> > inline -typename enable_if -< - __is_val_expr<_Expr>::value, valarray<_Tp>& ->::type valarray<_Tp>::operator>>=(const _Expr& __v) { size_t __i = 0; @@ -3789,13 +3347,9 @@ swap(valarray<_Tp>& __x, valarray<_Tp>& __y) _NOEXCEPT __x.swap(__y); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<multiplies<typename _Expr1::value_type>, _Expr1, _Expr2> > operator*(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -3803,14 +3357,10 @@ operator*(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator*(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -3819,14 +3369,10 @@ operator*(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator*(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -3835,13 +3381,9 @@ operator*(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<divides<typename _Expr1::value_type>, _Expr1, _Expr2> > operator/(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -3849,14 +3391,10 @@ operator/(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(divides<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<divides<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<divides<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator/(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -3865,14 +3403,10 @@ operator/(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<divides<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<divides<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator/(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -3881,13 +3415,9 @@ operator/(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<modulus<typename _Expr1::value_type>, _Expr1, _Expr2> > operator%(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -3895,14 +3425,10 @@ operator%(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator%(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -3911,14 +3437,10 @@ operator%(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator%(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -3927,13 +3449,9 @@ operator%(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<plus<typename _Expr1::value_type>, _Expr1, _Expr2> > operator+(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -3941,14 +3459,10 @@ operator+(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(plus<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<plus<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<plus<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator+(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -3957,14 +3471,10 @@ operator+(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<plus<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<plus<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator+(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -3973,13 +3483,9 @@ operator+(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<minus<typename _Expr1::value_type>, _Expr1, _Expr2> > operator-(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -3987,14 +3493,10 @@ operator-(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(minus<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<minus<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<minus<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator-(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4003,14 +3505,10 @@ operator-(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<minus<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<minus<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator-(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4019,13 +3517,9 @@ operator-(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<bit_xor<typename _Expr1::value_type>, _Expr1, _Expr2> > operator^(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4033,14 +3527,10 @@ operator^(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator^(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4049,14 +3539,10 @@ operator^(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator^(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4065,13 +3551,9 @@ operator^(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<bit_and<typename _Expr1::value_type>, _Expr1, _Expr2> > operator&(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4079,14 +3561,10 @@ operator&(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator&(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4095,14 +3573,10 @@ operator&(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator&(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4111,13 +3585,9 @@ operator&(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<bit_or<typename _Expr1::value_type>, _Expr1, _Expr2> > operator|(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4125,14 +3595,10 @@ operator|(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator|(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4141,14 +3607,10 @@ operator|(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator|(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4157,13 +3619,9 @@ operator|(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<__bit_shift_left<typename _Expr1::value_type>, _Expr1, _Expr2> > operator<<(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4171,14 +3629,10 @@ operator<<(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(__bit_shift_left<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator<<(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4187,14 +3641,10 @@ operator<<(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator<<(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4203,13 +3653,9 @@ operator<<(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<__bit_shift_right<typename _Expr1::value_type>, _Expr1, _Expr2> > operator>>(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4217,14 +3663,10 @@ operator>>(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(__bit_shift_right<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator>>(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4233,14 +3675,10 @@ operator>>(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<__bit_shift_right<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator>>(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4249,13 +3687,9 @@ operator>>(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<logical_and<typename _Expr1::value_type>, _Expr1, _Expr2> > operator&&(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4263,14 +3697,10 @@ operator&&(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator&&(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4279,14 +3709,10 @@ operator&&(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator&&(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4295,13 +3721,9 @@ operator&&(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<logical_or<typename _Expr1::value_type>, _Expr1, _Expr2> > operator||(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4309,14 +3731,10 @@ operator||(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator||(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4325,14 +3743,10 @@ operator||(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator||(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4341,13 +3755,9 @@ operator||(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > operator==(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4355,14 +3765,10 @@ operator==(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator==(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4371,14 +3777,10 @@ operator==(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator==(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4387,13 +3789,9 @@ operator==(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<not_equal_to<typename _Expr1::value_type>, _Expr1, _Expr2> > operator!=(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4401,14 +3799,10 @@ operator!=(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator!=(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4417,14 +3811,10 @@ operator!=(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator!=(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4433,13 +3823,9 @@ operator!=(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<less<typename _Expr1::value_type>, _Expr1, _Expr2> > operator<(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4447,14 +3833,10 @@ operator<(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(less<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<less<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<less<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator<(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4463,14 +3845,10 @@ operator<(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<less<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<less<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator<(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4479,13 +3857,9 @@ operator<(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<greater<typename _Expr1::value_type>, _Expr1, _Expr2> > operator>(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4493,14 +3867,10 @@ operator>(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(greater<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<greater<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<greater<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator>(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4509,14 +3879,10 @@ operator>(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<greater<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<greater<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator>(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4525,13 +3891,9 @@ operator>(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<less_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > operator<=(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4539,14 +3901,10 @@ operator<=(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator<=(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4555,14 +3913,10 @@ operator<=(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator<=(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4571,13 +3925,9 @@ operator<=(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<greater_equal<typename _Expr1::value_type>, _Expr1, _Expr2> > operator>=(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4585,14 +3935,10 @@ operator>=(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > operator>=(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4601,14 +3947,10 @@ operator>=(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > operator>=(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4617,13 +3959,9 @@ operator>=(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__abs_expr<typename _Expr::value_type>, _Expr> > abs(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4631,13 +3969,9 @@ abs(const _Expr& __x) return __val_expr<_Op>(_Op(__abs_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__acos_expr<typename _Expr::value_type>, _Expr> > acos(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4645,13 +3979,9 @@ acos(const _Expr& __x) return __val_expr<_Op>(_Op(__acos_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__asin_expr<typename _Expr::value_type>, _Expr> > asin(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4659,13 +3989,9 @@ asin(const _Expr& __x) return __val_expr<_Op>(_Op(__asin_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__atan_expr<typename _Expr::value_type>, _Expr> > atan(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4673,13 +3999,9 @@ atan(const _Expr& __x) return __val_expr<_Op>(_Op(__atan_expr<value_type>(), __x)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<__atan2_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > atan2(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4687,14 +4009,10 @@ atan2(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type atan2(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4703,14 +4021,10 @@ atan2(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type atan2(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4719,13 +4033,9 @@ atan2(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__cos_expr<typename _Expr::value_type>, _Expr> > cos(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4733,13 +4043,9 @@ cos(const _Expr& __x) return __val_expr<_Op>(_Op(__cos_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__cosh_expr<typename _Expr::value_type>, _Expr> > cosh(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4747,13 +4053,9 @@ cosh(const _Expr& __x) return __val_expr<_Op>(_Op(__cosh_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__exp_expr<typename _Expr::value_type>, _Expr> > exp(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4761,13 +4063,9 @@ exp(const _Expr& __x) return __val_expr<_Op>(_Op(__exp_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__log_expr<typename _Expr::value_type>, _Expr> > log(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4775,13 +4073,9 @@ log(const _Expr& __x) return __val_expr<_Op>(_Op(__log_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_UnaryOp<__log10_expr<typename _Expr::value_type>, _Expr> > log10(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4789,13 +4083,9 @@ log10(const _Expr& __x) return __val_expr<_Op>(_Op(__log10_expr<value_type>(), __x)); } -template<class _Expr1, class _Expr2> +template<class _Expr1, class _Expr2, __enable_if_t<__is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr1>::value && __is_val_expr<_Expr2>::value, - __val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > ->::type +__val_expr<_BinaryOp<__pow_expr<typename _Expr1::value_type>, _Expr1, _Expr2> > pow(const _Expr1& __x, const _Expr2& __y) { typedef typename _Expr1::value_type value_type; @@ -4803,14 +4093,10 @@ pow(const _Expr1& __x, const _Expr2& __y) return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, - _Expr, __scalar_expr<typename _Expr::value_type> > > ->::type +__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, + _Expr, __scalar_expr<typename _Expr::value_type> > > pow(const _Expr& __x, const typename _Expr::value_type& __y) { typedef typename _Expr::value_type value_type; @@ -4819,14 +4105,10 @@ pow(const _Expr& __x, const typename _Expr::value_type& __y) __x, __scalar_expr<value_type>(__y, __x.size()))); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, - __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, - __scalar_expr<typename _Expr::value_type>, _Expr> > ->::type +__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, + __scalar_expr<typename _Expr::value_type>, _Expr> > pow(const typename _Expr::value_type& __x, const _Expr& __y) { typedef typename _Expr::value_type value_type; @@ -4835,13 +4117,9 @@ pow(const typename _Expr::value_type& __x, const _Expr& __y) __scalar_expr<value_type>(__x, __y.size()), __y)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__sin_expr<typename _Expr::value_type>, _Expr> > ->::type sin(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4849,13 +4127,9 @@ sin(const _Expr& __x) return __val_expr<_Op>(_Op(__sin_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__sinh_expr<typename _Expr::value_type>, _Expr> > ->::type sinh(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4863,13 +4137,9 @@ sinh(const _Expr& __x) return __val_expr<_Op>(_Op(__sinh_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__sqrt_expr<typename _Expr::value_type>, _Expr> > ->::type sqrt(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4877,13 +4147,9 @@ sqrt(const _Expr& __x) return __val_expr<_Op>(_Op(__sqrt_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__tan_expr<typename _Expr::value_type>, _Expr> > ->::type tan(const _Expr& __x) { typedef typename _Expr::value_type value_type; @@ -4891,13 +4157,9 @@ tan(const _Expr& __x) return __val_expr<_Op>(_Op(__tan_expr<value_type>(), __x)); } -template<class _Expr> +template<class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0> inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - __is_val_expr<_Expr>::value, __val_expr<_UnaryOp<__tanh_expr<typename _Expr::value_type>, _Expr> > ->::type tanh(const _Expr& __x) { typedef typename _Expr::value_type value_type; diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector index cf70d15c03..b72a4b51bf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/vector +++ b/contrib/libs/cxxsupp/libcxx/include/vector @@ -842,11 +842,11 @@ private: template <class _Up> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI - inline void __push_back_slow_path(_Up&& __x); + inline pointer __push_back_slow_path(_Up&& __x); template <class... _Args> _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI - inline void __emplace_back_slow_path(_Args&&... __args); + inline pointer __emplace_back_slow_path(_Args&&... __args); // The following functions are no-ops outside of AddressSanitizer mode. // We call annotations for every allocator, unless explicitly disabled. @@ -1663,7 +1663,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT template <class _Tp, class _Allocator> template <class _Up> _LIBCPP_CONSTEXPR_SINCE_CXX20 -void +typename vector<_Tp, _Allocator>::pointer vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) { allocator_type& __a = this->__alloc(); @@ -1672,6 +1672,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x) __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Up>(__x)); __v.__end_++; __swap_out_circular_buffer(__v); + return this->__end_; } template <class _Tp, class _Allocator> @@ -1680,12 +1681,14 @@ inline _LIBCPP_HIDE_FROM_ABI void vector<_Tp, _Allocator>::push_back(const_reference __x) { - if (this->__end_ != this->__end_cap()) - { + pointer __end = this->__end_; + if (__end < this->__end_cap()) { __construct_one_at_end(__x); + ++__end; + } else { + __end = __push_back_slow_path(__x); } - else - __push_back_slow_path(__x); + this->__end_ = __end; } template <class _Tp, class _Allocator> @@ -1694,18 +1697,20 @@ inline _LIBCPP_HIDE_FROM_ABI void vector<_Tp, _Allocator>::push_back(value_type&& __x) { - if (this->__end_ < this->__end_cap()) - { + pointer __end = this->__end_; + if (__end < this->__end_cap()) { __construct_one_at_end(std::move(__x)); + ++__end; + } else { + __end = __push_back_slow_path(std::move(__x)); } - else - __push_back_slow_path(std::move(__x)); + this->__end_ = __end; } template <class _Tp, class _Allocator> template <class... _Args> _LIBCPP_CONSTEXPR_SINCE_CXX20 -void +typename vector<_Tp, _Allocator>::pointer vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) { allocator_type& __a = this->__alloc(); @@ -1714,6 +1719,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) __alloc_traits::construct(__a, std::__to_address(__v.__end_), std::forward<_Args>(__args)...); __v.__end_++; __swap_out_circular_buffer(__v); + return this->__end_; } template <class _Tp, class _Allocator> @@ -1727,14 +1733,16 @@ void #endif vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { - if (this->__end_ < this->__end_cap()) - { + pointer __end = this->__end_; + if (__end < this->__end_cap()) { __construct_one_at_end(std::forward<_Args>(__args)...); + ++__end; + } else { + __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); } - else - __emplace_back_slow_path(std::forward<_Args>(__args)...); + this->__end_ = __end; #if _LIBCPP_STD_VER >= 17 - return this->back(); + return *(__end - 1); #endif } @@ -2037,18 +2045,6 @@ vector<_Tp, _Allocator>::resize(size_type __sz) this->__destruct_at_end(this->__begin_ + __sz); } -template <class _Tp, class _Allocator> -_LIBCPP_CONSTEXPR_SINCE_CXX20 -void -vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) -{ - size_type __cs = size(); - if (__cs < __sz) - this->__append(__sz - __cs, __x); - else if (__cs > __sz) - this->__destruct_at_end(this->__begin_ + __sz); -} - #if _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED template <class _Tp, class _Allocator> @@ -2069,6 +2065,18 @@ vector<_Tp, _Allocator>::resize_uninitialized(size_type __sz) template <class _Tp, class _Allocator> _LIBCPP_CONSTEXPR_SINCE_CXX20 void +vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x) +{ + size_type __cs = size(); + if (__cs < __sz) + this->__append(__sz - __cs, __x); + else if (__cs > __sz) + this->__destruct_at_end(this->__begin_ + __sz); +} + +template <class _Tp, class _Allocator> +_LIBCPP_CONSTEXPR_SINCE_CXX20 +void vector<_Tp, _Allocator>::swap(vector& __x) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT @@ -2214,18 +2222,14 @@ public: #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v, const allocator_type& __a); - template <class _InputIterator> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, - typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type* = 0); - template <class _InputIterator> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, - typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type* = 0); - template <class _ForwardIterator> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, - typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type* = 0); - template <class _ForwardIterator> - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, - typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type* = 0); + template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last); + template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a); + template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last); + template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a); #if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange<bool> _Range> @@ -2270,17 +2274,11 @@ public: vector& operator=(vector&& __v) _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); - template <class _InputIterator> - typename enable_if <__has_exactly_input_iterator_category<_InputIterator>::value, - void - >::type + template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> + void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last); - template <class _ForwardIterator> - typename enable_if - < - __has_forward_iterator_category<_ForwardIterator>::value, - void - >::type + template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> + void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_ForwardIterator __first, _ForwardIterator __last); #if _LIBCPP_STD_VER >= 23 @@ -2404,17 +2402,11 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, const value_type& __x); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __position, size_type __n, const value_type& __x); - template <class _InputIterator> - typename enable_if <__has_exactly_input_iterator_category<_InputIterator>::value, - iterator - >::type + template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0> + iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _InputIterator __first, _InputIterator __last); - template <class _ForwardIterator> - typename enable_if - < - __has_forward_iterator_category<_ForwardIterator>::value, - iterator - >::type + template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0> + iterator _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last); #if _LIBCPP_STD_VER >= 23 @@ -2769,10 +2761,9 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all } template <class _Allocator> -template <class _InputIterator> +template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 -vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, - typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type*) +vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last) : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) @@ -2781,10 +2772,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, } template <class _Allocator> -template <class _InputIterator> +template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 -vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, - typename enable_if<__has_exactly_input_iterator_category<_InputIterator>::value>::type*) +vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) @@ -2793,10 +2783,9 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, } template <class _Allocator> -template <class _ForwardIterator> +template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 -vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, - typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type*) +vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last) : __begin_(nullptr), __size_(0), __cap_alloc_(0, __default_init_tag()) @@ -2806,10 +2795,9 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la } template <class _Allocator> -template <class _ForwardIterator> +template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 -vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, - typename enable_if<__has_forward_iterator_category<_ForwardIterator>::value>::type*) +vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a) : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) @@ -2996,10 +2984,9 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) } template <class _Allocator> -template <class _InputIterator> -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__has_exactly_input_iterator_category<_InputIterator>::value, - void ->::type +template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > +_LIBCPP_CONSTEXPR_SINCE_CXX20 +void vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { __assign_with_sentinel(__first, __last); @@ -3015,13 +3002,9 @@ void vector<bool, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentin } template <class _Allocator> -template <class _ForwardIterator> +template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - __has_forward_iterator_category<_ForwardIterator>::value, - void ->::type +void vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) { __assign_with_size(__first, __last, std::distance(__first, __last)); @@ -3162,10 +3145,9 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const } template <class _Allocator> -template <class _InputIterator> -_LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if <__has_exactly_input_iterator_category<_InputIterator>::value, - typename vector<bool, _Allocator>::iterator ->::type +template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> > +_LIBCPP_CONSTEXPR_SINCE_CXX20 +typename vector<bool, _Allocator>::iterator vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last) { return __insert_with_sentinel(__position, __first, __last); @@ -3212,13 +3194,9 @@ vector<bool, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inp } template <class _Allocator> -template <class _ForwardIterator> +template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> > _LIBCPP_CONSTEXPR_SINCE_CXX20 -typename enable_if -< - __has_forward_iterator_category<_ForwardIterator>::value, - typename vector<bool, _Allocator>::iterator ->::type +typename vector<bool, _Allocator>::iterator vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last) { return __insert_with_size(__position, __first, __last, std::distance(__first, __last)); diff --git a/contrib/libs/cxxsupp/libcxx/include/version b/contrib/libs/cxxsupp/libcxx/include/version index fed4d6ec17..cbdd87a913 100644 --- a/contrib/libs/cxxsupp/libcxx/include/version +++ b/contrib/libs/cxxsupp/libcxx/include/version @@ -203,7 +203,8 @@ __cpp_lib_text_encoding 202306L <text_encoding> __cpp_lib_three_way_comparison 201907L <compare> __cpp_lib_to_address 201711L <memory> __cpp_lib_to_array 201907L <array> -__cpp_lib_to_chars 201611L <charconv> +__cpp_lib_to_chars 202306L <charconv> + 201611L // C++17 __cpp_lib_to_string 202306L <string> __cpp_lib_to_underlying 202102L <utility> __cpp_lib_transformation_trait_aliases 201304L <type_traits> @@ -379,8 +380,8 @@ __cpp_lib_within_lifetime 202306L <type_traits> // # define __cpp_lib_is_layout_compatible 201907L # define __cpp_lib_is_nothrow_convertible 201806L // # define __cpp_lib_is_pointer_interconvertible 201907L -# if !defined(_LIBCPP_HAS_NO_THREADS) -// # define __cpp_lib_jthread 201911L +# if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_AVAILABILITY_HAS_NO_SYNC) +# define __cpp_lib_jthread 201911L # endif # if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_AVAILABILITY_HAS_NO_SYNC) # define __cpp_lib_latch 201907L @@ -442,7 +443,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> // # define __cpp_lib_print 202207L # define __cpp_lib_ranges_as_rvalue 202207L // # define __cpp_lib_ranges_chunk 202202L -// # define __cpp_lib_ranges_chunk_by 202202L +# define __cpp_lib_ranges_chunk_by 202202L // # define __cpp_lib_ranges_iota 202202L // # define __cpp_lib_ranges_join_with 202202L # define __cpp_lib_ranges_repeat 202207L @@ -467,7 +468,7 @@ __cpp_lib_within_lifetime 202306L <type_traits> // # define __cpp_lib_bind_back 202306L # undef __cpp_lib_bind_front # define __cpp_lib_bind_front 202306L -// # define __cpp_lib_bitset 202306L +# define __cpp_lib_bitset 202306L // # define __cpp_lib_copyable_function 202306L // # define __cpp_lib_fstream_native_handle 202306L // # define __cpp_lib_function_ref 202306L @@ -478,6 +479,8 @@ __cpp_lib_within_lifetime 202306L <type_traits> // # define __cpp_lib_sstream_from_string_view 202306L // # define __cpp_lib_submdspan 202306L // # define __cpp_lib_text_encoding 202306L +# undef __cpp_lib_to_chars +// # define __cpp_lib_to_chars 202306L // # define __cpp_lib_within_lifetime 202306L #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/wchar.h b/contrib/libs/cxxsupp/libcxx/include/wchar.h index eeccf3e937..c416fba6d4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/wchar.h +++ b/contrib/libs/cxxsupp/libcxx/include/wchar.h @@ -186,7 +186,7 @@ size_t mbsnrtowcs(wchar_t *__restrict __dst, const char **__restrict __src, size_t __nmc, size_t __len, mbstate_t *__restrict __ps); size_t wcsnrtombs(char *__restrict __dst, const wchar_t **__restrict __src, size_t __nwc, size_t __len, mbstate_t *__restrict __ps); -} // extern "C" +} // extern "C" #endif // __cplusplus && (_LIBCPP_MSVCRT || __MVS__) #endif // _LIBCPP_WCHAR_H diff --git a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp index a55249a15c..fc90a1f5b2 100644 --- a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp @@ -147,7 +147,7 @@ static void __libcpp_contention_notify(__cxx_atomic_contention_t volatile* __con // We only call 'wake' if we consumed a contention bit here. __libcpp_platform_wake_by_address(__platform_state, __notify_one); } -static __cxx_contention_t __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* __contention_state, +static __cxx_contention_t __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__contention_state*/, __cxx_atomic_contention_t const volatile* __platform_state) { // We will monitor this value. diff --git a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp index f159613202..b31ef19c0a 100644 --- a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp @@ -99,7 +99,7 @@ static system_clock::time_point __libcpp_system_clock_now() { nanoseconds::period>>; // The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970. - static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600}; + static constexpr const seconds nt_to_unix_epoch{11644473600}; FILETIME ft; #if (_WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) || \ diff --git a/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp b/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp index 85f334e024..87ce1d8434 100644 --- a/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp @@ -61,7 +61,7 @@ condition_variable::__do_timed_wait(unique_lock<mutex>& lk, __libcpp_timespec_t ts; seconds s = duration_cast<seconds>(d); typedef decltype(ts.tv_sec) ts_sec; - _LIBCPP_CONSTEXPR ts_sec ts_sec_max = numeric_limits<ts_sec>::max(); + constexpr ts_sec ts_sec_max = numeric_limits<ts_sec>::max(); if (s.count() < ts_sec_max) { ts.tv_sec = static_cast<ts_sec>(s.count()); diff --git a/contrib/libs/cxxsupp/libcxx/src/error_category.cpp b/contrib/libs/cxxsupp/libcxx/src/error_category.cpp new file mode 100644 index 0000000000..8ae460fb5f --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/src/error_category.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include <__config> + +#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS +# define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS +#endif + +#include <system_error> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// class error_category + +#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS) +error_category::error_category() noexcept {} +#endif + +error_category::~error_category() noexcept {} + +error_condition error_category::default_error_condition(int ev) const noexcept { return error_condition(ev, *this); } + +bool error_category::equivalent(int code, const error_condition& condition) const noexcept { + return default_error_condition(code) == condition; +} + +bool error_category::equivalent(const error_code& code, int condition) const noexcept { + return *this == code.category() && code.value() == condition; +} + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h index 965e0eadcd..93da758761 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h @@ -112,7 +112,7 @@ inline error_code make_windows_error(int err) { template <class T> T error_value(); template <> -inline _LIBCPP_CONSTEXPR_SINCE_CXX14 void error_value<void>() {} +inline constexpr void error_value<void>() {} template <> inline bool error_value<bool>() { return false; @@ -128,7 +128,7 @@ inline uintmax_t error_value<uintmax_t>() { return uintmax_t(-1); } template <> -inline _LIBCPP_CONSTEXPR_SINCE_CXX14 file_time_type error_value<file_time_type>() { +inline constexpr file_time_type error_value<file_time_type>() { return file_time_type::min(); } template <> diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h index f11f41552e..fb213d9ec1 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h @@ -322,8 +322,8 @@ inline int statvfs(const wchar_t *p, StatVFS *buf) { inline wchar_t* getcwd([[maybe_unused]] wchar_t* in_buf, [[maybe_unused]] size_t in_size) { // Only expected to be used with us allocating the buffer. - _LIBCPP_ASSERT(in_buf == nullptr, "Windows getcwd() assumes in_buf==nullptr"); - _LIBCPP_ASSERT(in_size == 0, "Windows getcwd() assumes in_size==0"); + _LIBCPP_ASSERT_UNCATEGORIZED(in_buf == nullptr, "Windows getcwd() assumes in_buf==nullptr"); + _LIBCPP_ASSERT_UNCATEGORIZED(in_size == 0, "Windows getcwd() assumes in_size==0"); size_t buff_size = MAX_PATH + 10; std::unique_ptr<wchar_t, decltype(&::free)> buff(static_cast<wchar_t*>(malloc(buff_size * sizeof(wchar_t))), &::free); diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h index 9177e1013d..eb41769368 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h @@ -147,7 +147,7 @@ struct time_util_base { .count(); private: - static _LIBCPP_CONSTEXPR fs_duration get_min_nsecs() { + static constexpr fs_duration get_min_nsecs() { return duration_cast<fs_duration>( fs_nanoseconds(min_nsec_timespec) - duration_cast<fs_nanoseconds>(fs_seconds(1))); @@ -157,7 +157,7 @@ private: FileTimeT::duration::min(), "value doesn't roundtrip"); - static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool check_range() { + static constexpr bool check_range() { // This kinda sucks, but it's what happens when we don't have __int128_t. if (sizeof(TimeT) == sizeof(rep)) { typedef duration<long long, ratio<3600 * 24 * 365> > Years; @@ -225,7 +225,7 @@ struct time_util : time_util_base<FileTimeT, TimeT> { public: template <class CType, class ChronoType> - static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool checked_set(CType* out, + static constexpr bool checked_set(CType* out, ChronoType time) { using Lim = numeric_limits<CType>; if (time > Lim::max() || time < Lim::min()) @@ -234,7 +234,7 @@ public: return true; } - static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(TimeSpecT tm) { + static constexpr bool is_representable(TimeSpecT tm) { if (tm.tv_sec >= 0) { return tm.tv_sec < max_seconds || (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec); @@ -245,7 +245,7 @@ public: } } - static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool is_representable(FileTimeT tm) { + static constexpr bool is_representable(FileTimeT tm) { auto secs = duration_cast<fs_seconds>(tm.time_since_epoch()); auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs); if (nsecs.count() < 0) { @@ -258,7 +258,7 @@ public: return secs.count() >= TLim::min(); } - static _LIBCPP_CONSTEXPR_SINCE_CXX14 FileTimeT + static constexpr FileTimeT convert_from_timespec(TimeSpecT tm) { if (tm.tv_sec >= 0 || tm.tv_nsec == 0) { return FileTimeT(fs_seconds(tm.tv_sec) + @@ -272,7 +272,7 @@ public: } template <class SubSecT> - static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool + static constexpr bool set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) { auto dur = tp.time_since_epoch(); auto sec_dur = duration_cast<fs_seconds>(dur); @@ -289,7 +289,7 @@ public: return checked_set(sec_out, sec_dur.count()) && checked_set(subsec_out, subsec_dur.count()); } - static _LIBCPP_CONSTEXPR_SINCE_CXX14 bool convert_to_timespec(TimeSpecT& dest, + static constexpr bool convert_to_timespec(TimeSpecT& dest, FileTimeT tp) { if (!is_representable(tp)) return false; diff --git a/contrib/libs/cxxsupp/libcxx/src/future.cpp b/contrib/libs/cxxsupp/libcxx/src/future.cpp index f8f466bd5a..3383b506a2 100644 --- a/contrib/libs/cxxsupp/libcxx/src/future.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/future.cpp @@ -59,8 +59,13 @@ _LIBCPP_DIAGNOSTIC_POP const error_category& future_category() noexcept { - static __future_error_category __f; - return __f; + union AvoidDestroyingFutureCategory { + __future_error_category future_error_category; + constexpr explicit AvoidDestroyingFutureCategory() : future_error_category() {} + ~AvoidDestroyingFutureCategory() {} + }; + constinit static AvoidDestroyingFutureCategory helper; + return helper.future_error_category; } future_error::future_error(error_code __ec) @@ -199,9 +204,7 @@ promise<void>::~promise() { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) - __state_->set_exception(make_exception_ptr( - future_error(make_error_code(future_errc::broken_promise)) - )); + __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise))); #endif // _LIBCPP_HAS_NO_EXCEPTIONS __state_->__release_shared(); } diff --git a/contrib/libs/cxxsupp/libcxx/src/ios.cpp b/contrib/libs/cxxsupp/libcxx/src/ios.cpp index bb62eb9948..f17cd6e1db 100644 --- a/contrib/libs/cxxsupp/libcxx/src/ios.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/ios.cpp @@ -52,8 +52,13 @@ __iostream_category::message(int ev) const const error_category& iostream_category() noexcept { - static __iostream_category s; - return s; + union AvoidDestroyingIostreamCategory { + __iostream_category iostream_error_category; + constexpr explicit AvoidDestroyingIostreamCategory() : iostream_error_category() {} + ~AvoidDestroyingIostreamCategory() {} + }; + constinit static AvoidDestroyingIostreamCategory helper; + return helper.iostream_error_category; } // ios_base::failure diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp index e274ede995..071edb903a 100644 --- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include <__utility/unreachable.h> -#include <__verbose_abort> #include <algorithm> #include <clocale> #include <codecvt> @@ -38,8 +37,8 @@ # include <langinfo.h> #endif -#include "atomic" #include "include/sso_allocator.h" +#include <mutex> // On Linux, wint_t and wchar_t have different signed-ness, and this causes // lots of noise in the build log, but no bugs that I know of. @@ -95,7 +94,7 @@ T& make(Args ...args) template <typename T, size_t N> inline -_LIBCPP_CONSTEXPR +constexpr size_t countof(const T (&)[N]) { @@ -104,22 +103,13 @@ countof(const T (&)[N]) template <typename T> inline -_LIBCPP_CONSTEXPR +constexpr size_t countof(const T * const begin, const T * const end) { return static_cast<size_t>(end - begin); } -_LIBCPP_NORETURN static void __throw_runtime_error(const string &msg) -{ -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw runtime_error(msg); -#else - _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg.c_str()); -#endif -} - } string @@ -698,30 +688,9 @@ locale::facet::__on_zero_shared() noexcept // locale::id -namespace -{ - -class __fake_bind -{ - locale::id* id_; - void (locale::id::* pmf_)(); -public: - __fake_bind(void (locale::id::* pmf)(), locale::id* id) - : id_(id), pmf_(pmf) {} - - void operator()() const - { - (id_->*pmf_)(); - } -}; - -} - -int32_t locale::id::__next_id; +constinit int32_t locale::id::__next_id = 0; -long -locale::id::__get() -{ +long locale::id::__get() { int32_t result = __id_.load(std::memory_order_acquire); if (result == 0) { static std::mutex m; @@ -742,8 +711,8 @@ collate_byname<char>::collate_byname(const char* n, size_t refs) __l_(newlocale(LC_ALL_MASK, n, 0)) { if (__l_ == 0) - __throw_runtime_error("collate_byname<char>::collate_byname" - " failed to construct for " + string(n)); + __throw_runtime_error(("collate_byname<char>::collate_byname" + " failed to construct for " + string(n)).c_str()); } collate_byname<char>::collate_byname(const string& name, size_t refs) @@ -751,8 +720,8 @@ collate_byname<char>::collate_byname(const string& name, size_t refs) __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { if (__l_ == 0) - __throw_runtime_error("collate_byname<char>::collate_byname" - " failed to construct for " + name); + __throw_runtime_error(("collate_byname<char>::collate_byname" + " failed to construct for " + name).c_str()); } collate_byname<char>::~collate_byname() @@ -791,8 +760,8 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs) __l_(newlocale(LC_ALL_MASK, n, 0)) { if (__l_ == 0) - __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" - " failed to construct for " + string(n)); + __throw_runtime_error(("collate_byname<wchar_t>::collate_byname(size_t refs)" + " failed to construct for " + string(n)).c_str()); } collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) @@ -800,8 +769,8 @@ collate_byname<wchar_t>::collate_byname(const string& name, size_t refs) __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { if (__l_ == 0) - __throw_runtime_error("collate_byname<wchar_t>::collate_byname(size_t refs)" - " failed to construct for " + name); + __throw_runtime_error(("collate_byname<wchar_t>::collate_byname(size_t refs)" + " failed to construct for " + name).c_str()); } collate_byname<wchar_t>::~collate_byname() @@ -849,7 +818,7 @@ const ctype_base::mask ctype_base::graph; // template <> class ctype<wchar_t>; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -locale::id ctype<wchar_t>::id; +constinit locale::id ctype<wchar_t>::id; ctype<wchar_t>::~ctype() { @@ -982,7 +951,7 @@ ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfau // template <> class ctype<char>; -locale::id ctype<char>::id; +constinit locale::id ctype<char>::id; const size_t ctype<char>::table_size; @@ -1115,7 +1084,7 @@ extern "C" const unsigned short* const _ctype_android; const ctype<char>::mask* ctype<char>::classic_table() noexcept { - static _LIBCPP_CONSTEXPR const ctype<char>::mask builtin_table[table_size] = { + static constexpr const ctype<char>::mask builtin_table[table_size] = { cntrl, cntrl, cntrl, cntrl, cntrl, cntrl, @@ -1294,8 +1263,8 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs) __l_(newlocale(LC_ALL_MASK, name, 0)) { if (__l_ == 0) - __throw_runtime_error("ctype_byname<char>::ctype_byname" - " failed to construct for " + string(name)); + __throw_runtime_error(("ctype_byname<char>::ctype_byname" + " failed to construct for " + string(name)).c_str()); } ctype_byname<char>::ctype_byname(const string& name, size_t refs) @@ -1303,8 +1272,8 @@ ctype_byname<char>::ctype_byname(const string& name, size_t refs) __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { if (__l_ == 0) - __throw_runtime_error("ctype_byname<char>::ctype_byname" - " failed to construct for " + name); + __throw_runtime_error(("ctype_byname<char>::ctype_byname" + " failed to construct for " + name).c_str()); } ctype_byname<char>::~ctype_byname() @@ -1348,8 +1317,8 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs) __l_(newlocale(LC_ALL_MASK, name, 0)) { if (__l_ == 0) - __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" - " failed to construct for " + string(name)); + __throw_runtime_error(("ctype_byname<wchar_t>::ctype_byname" + " failed to construct for " + string(name)).c_str()); } ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) @@ -1357,8 +1326,8 @@ ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs) __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) { if (__l_ == 0) - __throw_runtime_error("ctype_byname<wchar_t>::ctype_byname" - " failed to construct for " + name); + __throw_runtime_error(("ctype_byname<wchar_t>::ctype_byname" + " failed to construct for " + name).c_str()); } ctype_byname<wchar_t>::~ctype_byname() @@ -1544,7 +1513,7 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch // template <> class codecvt<char, char, mbstate_t> -locale::id codecvt<char, char, mbstate_t>::id; +constinit locale::id codecvt<char, char, mbstate_t>::id; codecvt<char, char, mbstate_t>::~codecvt() { @@ -1606,7 +1575,7 @@ codecvt<char, char, mbstate_t>::do_max_length() const noexcept // template <> class codecvt<wchar_t, char, mbstate_t> #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -locale::id codecvt<wchar_t, char, mbstate_t>::id; +constinit locale::id codecvt<wchar_t, char, mbstate_t>::id; codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), @@ -1619,8 +1588,8 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs) __l_(newlocale(LC_ALL_MASK, nm, 0)) { if (__l_ == 0) - __throw_runtime_error("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname" + " failed to construct for " + string(nm)).c_str()); } codecvt<wchar_t, char, mbstate_t>::~codecvt() @@ -3212,7 +3181,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP // template <> class codecvt<char16_t, char, mbstate_t> -locale::id codecvt<char16_t, char, mbstate_t>::id; +constinit locale::id codecvt<char16_t, char, mbstate_t>::id; codecvt<char16_t, char, mbstate_t>::~codecvt() { @@ -3291,7 +3260,7 @@ codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept // template <> class codecvt<char16_t, char8_t, mbstate_t> -locale::id codecvt<char16_t, char8_t, mbstate_t>::id; +constinit locale::id codecvt<char16_t, char8_t, mbstate_t>::id; codecvt<char16_t, char8_t, mbstate_t>::~codecvt() { @@ -3370,7 +3339,7 @@ codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const noexcept // template <> class codecvt<char32_t, char, mbstate_t> -locale::id codecvt<char32_t, char, mbstate_t>::id; +constinit locale::id codecvt<char32_t, char, mbstate_t>::id; codecvt<char32_t, char, mbstate_t>::~codecvt() { @@ -3449,7 +3418,7 @@ codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept // template <> class codecvt<char32_t, char8_t, mbstate_t> -locale::id codecvt<char32_t, char8_t, mbstate_t>::id; +constinit locale::id codecvt<char32_t, char8_t, mbstate_t>::id; codecvt<char32_t, char8_t, mbstate_t>::~codecvt() { @@ -4665,9 +4634,9 @@ static bool checked_string_to_char_convert(char& dest, // numpunct<char> && numpunct<wchar_t> -locale::id numpunct< char >::id; +constinit locale::id numpunct<char>::id; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -locale::id numpunct<wchar_t>::id; +constinit locale::id numpunct<wchar_t>::id; #endif numpunct<char>::numpunct(size_t refs) @@ -4747,8 +4716,8 @@ numpunct_byname<char>::__init(const char* nm) { __libcpp_unique_locale loc(nm); if (!loc) - __throw_runtime_error("numpunct_byname<char>::numpunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("numpunct_byname<char>::numpunct_byname" + " failed to construct for " + string(nm)).c_str()); lconv* lc = __libcpp_localeconv_l(loc.get()); if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point, @@ -4788,8 +4757,8 @@ numpunct_byname<wchar_t>::__init(const char* nm) { __libcpp_unique_locale loc(nm); if (!loc) - __throw_runtime_error("numpunct_byname<wchar_t>::numpunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("numpunct_byname<wchar_t>::numpunct_byname" + " failed to construct for " + string(nm)).c_str()); lconv* lc = __libcpp_localeconv_l(loc.get()); checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point, @@ -5220,16 +5189,14 @@ __time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { if (__loc_ == 0) - __throw_runtime_error("time_get_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str()); } __time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { if (__loc_ == 0) - __throw_runtime_error("time_get_byname" - " failed to construct for " + nm); + __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str()); } __time_get::~__time_get() @@ -5878,16 +5845,14 @@ __time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) { if (__loc_ == 0) - __throw_runtime_error("time_put_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str()); } __time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) { if (__loc_ == 0) - __throw_runtime_error("time_put_byname" - " failed to construct for " + nm); + __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str()); } __time_put::~__time_put() @@ -6305,8 +6270,7 @@ moneypunct_byname<char, false>::init(const char* nm) typedef moneypunct<char, false> base; __libcpp_unique_locale loc(nm); if (!loc) - __throw_runtime_error("moneypunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); lconv* lc = __libcpp_localeconv_l(loc.get()); if (!checked_string_to_char_convert(__decimal_point_, @@ -6349,8 +6313,7 @@ moneypunct_byname<char, true>::init(const char* nm) typedef moneypunct<char, true> base; __libcpp_unique_locale loc(nm); if (!loc) - __throw_runtime_error("moneypunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); lconv* lc = __libcpp_localeconv_l(loc.get()); if (!checked_string_to_char_convert(__decimal_point_, @@ -6410,8 +6373,7 @@ moneypunct_byname<wchar_t, false>::init(const char* nm) typedef moneypunct<wchar_t, false> base; __libcpp_unique_locale loc(nm); if (!loc) - __throw_runtime_error("moneypunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); lconv* lc = __libcpp_localeconv_l(loc.get()); if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, @@ -6475,8 +6437,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) typedef moneypunct<wchar_t, true> base; __libcpp_unique_locale loc(nm); if (!loc) - __throw_runtime_error("moneypunct_byname" - " failed to construct for " + string(nm)); + __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str()); lconv* lc = __libcpp_localeconv_l(loc.get()); if (!checked_string_to_wchar_convert(__decimal_point_, @@ -6554,15 +6515,6 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) void __do_nothing(void*) {} -void __throw_runtime_error(const char* msg) -{ -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw runtime_error(msg); -#else - _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg); -#endif -} - template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>; _LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;) diff --git a/contrib/libs/cxxsupp/libcxx/src/memory.cpp b/contrib/libs/cxxsupp/libcxx/src/memory.cpp index 4682f1267a..e318eee327 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory.cpp @@ -181,7 +181,7 @@ static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER }; -_LIBCPP_CONSTEXPR __sp_mut::__sp_mut(void* p) noexcept +constexpr __sp_mut::__sp_mut(void* p) noexcept : __lx_(p) { } diff --git a/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp b/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp index 3a80b84efa..3786ec5136 100644 --- a/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/memory_resource.cpp @@ -74,7 +74,7 @@ union ResourceInitHelper { __null_memory_resource_imp null_res; } resources; char dummy; - _LIBCPP_CONSTEXPR_SINCE_CXX14 ResourceInitHelper() : resources() {} + constexpr ResourceInitHelper() : resources() {} ~ResourceInitHelper() {} }; diff --git a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp index e304b97e6e..e8637f9275 100644 --- a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp @@ -8,6 +8,7 @@ #include <__assert> #include <__thread/id.h> +#include <__utility/exception_guard.h> #include <limits> #include <mutex> @@ -212,68 +213,52 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, #endif { #if defined(_LIBCPP_HAS_NO_THREADS) - if (flag == 0) - { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - flag = 1; - func(arg); - flag = ~once_flag::_State_type(0); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - } - catch (...) - { - flag = 0; - throw; - } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS + + if (flag == once_flag::_Unset) { + auto guard = std::__make_exception_guard([&flag] { flag = once_flag::_Unset; }); + flag = once_flag::_Pending; + func(arg); + flag = once_flag::_Complete; + guard.__complete(); } + #else // !_LIBCPP_HAS_NO_THREADS + __libcpp_mutex_lock(&mut); - while (flag == 1) + while (flag == once_flag::_Pending) __libcpp_condvar_wait(&cv, &mut); - if (flag == 0) - { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS + if (flag == once_flag::_Unset) { + auto guard = std::__make_exception_guard([&flag] { + __libcpp_mutex_lock(&mut); #ifdef _LIBCPP_ABI_MICROSOFT - flag.store(once_flag::_State_type(1)); + flag.store(once_flag::_Unset); #else - __libcpp_relaxed_store(&flag, once_flag::_State_type(1)); + __libcpp_relaxed_store(&flag, once_flag::_Unset); #endif __libcpp_mutex_unlock(&mut); - func(arg); - __libcpp_mutex_lock(&mut); + __libcpp_condvar_broadcast(&cv); + }); + #ifdef _LIBCPP_ABI_MICROSOFT - flag.store(~once_flag::_State_type(0), memory_order_release); + flag.store(once_flag::_Pending, memory_order_relaxed); #else - __libcpp_atomic_store(&flag, ~once_flag::_State_type(0), - _AO_Release); + __libcpp_relaxed_store(&flag, once_flag::_Pending); #endif - __libcpp_mutex_unlock(&mut); - __libcpp_condvar_broadcast(&cv); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - } - catch (...) - { - __libcpp_mutex_lock(&mut); + __libcpp_mutex_unlock(&mut); + func(arg); + __libcpp_mutex_lock(&mut); #ifdef _LIBCPP_ABI_MICROSOFT - flag.store(once_flag::_State_type(0), memory_order_relaxed); + flag.store(once_flag::_Complete, memory_order_release); #else - __libcpp_relaxed_store(&flag, once_flag::_State_type(0)); + __libcpp_atomic_store(&flag, once_flag::_Complete, _AO_Release); #endif - __libcpp_mutex_unlock(&mut); - __libcpp_condvar_broadcast(&cv); - throw; - } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - } - else __libcpp_mutex_unlock(&mut); + __libcpp_condvar_broadcast(&cv); + guard.__complete(); + } else { + __libcpp_mutex_unlock(&mut); + } + #endif // !_LIBCPP_HAS_NO_THREADS } diff --git a/contrib/libs/cxxsupp/libcxx/src/new_helpers.cpp b/contrib/libs/cxxsupp/libcxx/src/new_helpers.cpp index 45a0a661db..6560d0188e 100644 --- a/contrib/libs/cxxsupp/libcxx/src/new_helpers.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/new_helpers.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include <cstdlib> +#include <__verbose_abort> #include <new> namespace std { // purposefully not versioned @@ -21,7 +21,7 @@ void __throw_bad_alloc() { # ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw bad_alloc(); # else - std::abort(); + _LIBCPP_VERBOSE_ABORT("bad_alloc was thrown in -fno-exceptions mode"); # endif } diff --git a/contrib/libs/cxxsupp/libcxx/src/print.cpp b/contrib/libs/cxxsupp/libcxx/src/print.cpp index 3d8a4c291e..a581dd37fe 100644 --- a/contrib/libs/cxxsupp/libcxx/src/print.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/print.cpp @@ -47,12 +47,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst __view.size(), nullptr, nullptr) == 0) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS - // There is no __throw_system_error overload that takes an error code. - throw system_error{filesystem::detail::make_windows_error(GetLastError()), "failed to write formatted output"}; -# else // _LIBCPP_HAS_NO_EXCEPTIONS - std::abort(); -# endif // _LIBCPP_HAS_NO_EXCEPTIONS + __throw_system_error(filesystem::detail::make_windows_error(GetLastError()), "failed to write formatted output"); } } # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS diff --git a/contrib/libs/cxxsupp/libcxx/src/std_stream.h b/contrib/libs/cxxsupp/libcxx/src/std_stream.h index 0febf42c9f..37b4ffd1b4 100644 --- a/contrib/libs/cxxsupp/libcxx/src/std_stream.h +++ b/contrib/libs/cxxsupp/libcxx/src/std_stream.h @@ -113,7 +113,7 @@ __stdinbuf<_CharT>::uflow() return __getchar(true); } -static bool __do_getc(FILE *__fp, char *__pbuf) { +inline bool __do_getc(FILE *__fp, char *__pbuf) { int __c = getc(__fp); if (__c == EOF) return false; @@ -121,7 +121,7 @@ static bool __do_getc(FILE *__fp, char *__pbuf) { return true; } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -static bool __do_getc(FILE *__fp, wchar_t *__pbuf) { +inline bool __do_getc(FILE *__fp, wchar_t *__pbuf) { wint_t __c = getwc(__fp); if (__c == WEOF) return false; @@ -130,13 +130,13 @@ static bool __do_getc(FILE *__fp, wchar_t *__pbuf) { } #endif -static bool __do_ungetc(int __c, FILE *__fp, char __dummy) { +inline bool __do_ungetc(int __c, FILE *__fp, char __dummy) { if (ungetc(__c, __fp) == EOF) return false; return true; } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -static bool __do_ungetc(std::wint_t __c, FILE *__fp, wchar_t __dummy) { +inline bool __do_ungetc(std::wint_t __c, FILE *__fp, wchar_t __dummy) { if (ungetwc(__c, __fp) == WEOF) return false; return true; @@ -324,13 +324,13 @@ __stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st) __always_noconv_ = true; } -static bool __do_fputc(char __c, FILE* __fp) { +inline bool __do_fputc(char __c, FILE* __fp) { if (fwrite(&__c, sizeof(__c), 1, __fp) != 1) return false; return true; } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -static bool __do_fputc(wchar_t __c, FILE* __fp) { +inline bool __do_fputc(wchar_t __c, FILE* __fp) { // fputwc works regardless of wide/narrow mode of stdout, while // fwrite of wchar_t only works if the stream actually has been set // into wide mode. diff --git a/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp b/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp index d5c9173576..bc25c0f9e6 100644 --- a/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/stdexcept.cpp @@ -6,12 +6,25 @@ // //===----------------------------------------------------------------------===// +#include <__verbose_abort> #include <new> #include <stdexcept> #include <string> #ifdef _LIBCPP_ABI_VCRUNTIME -#include "support/runtime/stdexcept_vcruntime.ipp" +# include "support/runtime/stdexcept_vcruntime.ipp" #else -#include "support/runtime/stdexcept_default.ipp" +# include "support/runtime/stdexcept_default.ipp" #endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_NORETURN void __throw_runtime_error(const char* msg) { +#ifndef _LIBCPP_HAS_NO_EXCEPTIONS + throw runtime_error(msg); +#else + _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg); +#endif +} + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/strstream.cpp b/contrib/libs/cxxsupp/libcxx/src/strstream.cpp index bc56cafa8f..c97db698c0 100644 --- a/contrib/libs/cxxsupp/libcxx/src/strstream.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/strstream.cpp @@ -20,321 +20,239 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD strstreambuf::strstreambuf(streamsize __alsize) - : __strmode_(__dynamic), - __alsize_(__alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ -} + : __strmode_(__dynamic), __alsize_(__alsize), __palloc_(nullptr), __pfree_(nullptr) {} strstreambuf::strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)) - : __strmode_(__dynamic), - __alsize_(__default_alsize), - __palloc_(__palloc), - __pfree_(__pfree) -{ -} + : __strmode_(__dynamic), __alsize_(__default_alsize), __palloc_(__palloc), __pfree_(__pfree) {} -void -strstreambuf::__init(char* __gnext, streamsize __n, char* __pbeg) -{ - if (__n == 0) - __n = static_cast<streamsize>(strlen(__gnext)); - else if (__n < 0) - __n = INT_MAX; - if (__pbeg == nullptr) - setg(__gnext, __gnext, __gnext + __n); - else - { - setg(__gnext, __gnext, __pbeg); - setp(__pbeg, __pbeg + __n); - } +void strstreambuf::__init(char* __gnext, streamsize __n, char* __pbeg) { + if (__n == 0) + __n = static_cast<streamsize>(strlen(__gnext)); + else if (__n < 0) + __n = INT_MAX; + if (__pbeg == nullptr) + setg(__gnext, __gnext, __gnext + __n); + else { + setg(__gnext, __gnext, __pbeg); + setp(__pbeg, __pbeg + __n); + } } strstreambuf::strstreambuf(char* __gnext, streamsize __n, char* __pbeg) - : __strmode_(), - __alsize_(__default_alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ - __init(__gnext, __n, __pbeg); + : __strmode_(), __alsize_(__default_alsize), __palloc_(nullptr), __pfree_(nullptr) { + __init(__gnext, __n, __pbeg); } strstreambuf::strstreambuf(const char* __gnext, streamsize __n) - : __strmode_(__constant), - __alsize_(__default_alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ - __init(const_cast<char *>(__gnext), __n, nullptr); + : __strmode_(__constant), __alsize_(__default_alsize), __palloc_(nullptr), __pfree_(nullptr) { + __init(const_cast<char*>(__gnext), __n, nullptr); } strstreambuf::strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg) - : __strmode_(), - __alsize_(__default_alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ - __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg)); + : __strmode_(), __alsize_(__default_alsize), __palloc_(nullptr), __pfree_(nullptr) { + __init(const_cast<char*>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg)); } strstreambuf::strstreambuf(const signed char* __gnext, streamsize __n) - : __strmode_(__constant), - __alsize_(__default_alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ - __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr); + : __strmode_(__constant), __alsize_(__default_alsize), __palloc_(nullptr), __pfree_(nullptr) { + __init(const_cast<char*>(reinterpret_cast<const char*>(__gnext)), __n, nullptr); } strstreambuf::strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg) - : __strmode_(), - __alsize_(__default_alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ - __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg)); + : __strmode_(), __alsize_(__default_alsize), __palloc_(nullptr), __pfree_(nullptr) { + __init(const_cast<char*>(reinterpret_cast<const char*>(__gnext)), __n, reinterpret_cast<char*>(__pbeg)); } strstreambuf::strstreambuf(const unsigned char* __gnext, streamsize __n) - : __strmode_(__constant), - __alsize_(__default_alsize), - __palloc_(nullptr), - __pfree_(nullptr) -{ - __init(const_cast<char *>(reinterpret_cast<const char*>(__gnext)), __n, nullptr); -} - -strstreambuf::~strstreambuf() -{ - if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0) - { - if (__pfree_) - __pfree_(eback()); - else - delete [] eback(); - } + : __strmode_(__constant), __alsize_(__default_alsize), __palloc_(nullptr), __pfree_(nullptr) { + __init(const_cast<char*>(reinterpret_cast<const char*>(__gnext)), __n, nullptr); } -void -strstreambuf::swap(strstreambuf& __rhs) -{ - streambuf::swap(__rhs); - _VSTD::swap(__strmode_, __rhs.__strmode_); - _VSTD::swap(__alsize_, __rhs.__alsize_); - _VSTD::swap(__palloc_, __rhs.__palloc_); - _VSTD::swap(__pfree_, __rhs.__pfree_); +strstreambuf::~strstreambuf() { + if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0) { + if (__pfree_) + __pfree_(eback()); + else + delete[] eback(); + } } -void -strstreambuf::freeze(bool __freezefl) -{ - if (__strmode_ & __dynamic) - { - if (__freezefl) - __strmode_ |= __frozen; - else - __strmode_ &= ~__frozen; - } +void strstreambuf::swap(strstreambuf& __rhs) { + streambuf::swap(__rhs); + _VSTD::swap(__strmode_, __rhs.__strmode_); + _VSTD::swap(__alsize_, __rhs.__alsize_); + _VSTD::swap(__palloc_, __rhs.__palloc_); + _VSTD::swap(__pfree_, __rhs.__pfree_); } -char* -strstreambuf::str() -{ - if (__strmode_ & __dynamic) - __strmode_ |= __frozen; - return eback(); +void strstreambuf::freeze(bool __freezefl) { + if (__strmode_ & __dynamic) { + if (__freezefl) + __strmode_ |= __frozen; + else + __strmode_ &= ~__frozen; + } } -int -strstreambuf::pcount() const -{ - return static_cast<int>(pptr() - pbase()); +char* strstreambuf::str() { + if (__strmode_ & __dynamic) + __strmode_ |= __frozen; + return eback(); } -strstreambuf::int_type -strstreambuf::overflow(int_type __c) -{ - if (__c == EOF) - return int_type(0); - if (pptr() == epptr()) - { - if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0) - return int_type(EOF); - size_t old_size = static_cast<size_t> ((epptr() ? epptr() : egptr()) - eback()); - size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2*old_size); - if (new_size == 0) - new_size = __default_alsize; - char* buf = nullptr; - if (__palloc_) - buf = static_cast<char*>(__palloc_(new_size)); - else - buf = new char[new_size]; - if (buf == nullptr) - return int_type(EOF); - if (old_size != 0) { - _LIBCPP_ASSERT_UNCATEGORIZED(eback(), "overflow copying from NULL"); - memcpy(buf, eback(), static_cast<size_t>(old_size)); - } - ptrdiff_t ninp = gptr() - eback(); - ptrdiff_t einp = egptr() - eback(); - ptrdiff_t nout = pptr() - pbase(); - if (__strmode_ & __allocated) - { - if (__pfree_) - __pfree_(eback()); - else - delete [] eback(); - } - setg(buf, buf + ninp, buf + einp); - setp(buf + einp, buf + new_size); - __pbump(nout); - __strmode_ |= __allocated; - } - *pptr() = static_cast<char>(__c); - pbump(1); - return int_type(static_cast<unsigned char>(__c)); -} +int strstreambuf::pcount() const { return static_cast<int>(pptr() - pbase()); } -strstreambuf::int_type -strstreambuf::pbackfail(int_type __c) -{ - if (eback() == gptr()) - return EOF; - if (__c == EOF) - { - gbump(-1); - return int_type(0); +strstreambuf::int_type strstreambuf::overflow(int_type __c) { + if (__c == EOF) + return int_type(0); + if (pptr() == epptr()) { + if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0) + return int_type(EOF); + size_t old_size = static_cast<size_t>((epptr() ? epptr() : egptr()) - eback()); + size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2 * old_size); + if (new_size == 0) + new_size = __default_alsize; + char* buf = nullptr; + if (__palloc_) + buf = static_cast<char*>(__palloc_(new_size)); + else + buf = new char[new_size]; + if (buf == nullptr) + return int_type(EOF); + if (old_size != 0) { + _LIBCPP_ASSERT_UNCATEGORIZED(eback(), "overflow copying from NULL"); + memcpy(buf, eback(), static_cast<size_t>(old_size)); } - if (__strmode_ & __constant) - { - if (gptr()[-1] == static_cast<char>(__c)) - { - gbump(-1); - return __c; - } - return EOF; + ptrdiff_t ninp = gptr() - eback(); + ptrdiff_t einp = egptr() - eback(); + ptrdiff_t nout = pptr() - pbase(); + if (__strmode_ & __allocated) { + if (__pfree_) + __pfree_(eback()); + else + delete[] eback(); } - gbump(-1); - *gptr() = static_cast<char>(__c); - return __c; + setg(buf, buf + ninp, buf + einp); + setp(buf + einp, buf + new_size); + __pbump(nout); + __strmode_ |= __allocated; + } + *pptr() = static_cast<char>(__c); + pbump(1); + return int_type(static_cast<unsigned char>(__c)); } -strstreambuf::int_type -strstreambuf::underflow() -{ - if (gptr() == egptr()) - { - if (egptr() >= pptr()) - return EOF; - setg(eback(), gptr(), pptr()); +strstreambuf::int_type strstreambuf::pbackfail(int_type __c) { + if (eback() == gptr()) + return EOF; + if (__c == EOF) { + gbump(-1); + return int_type(0); + } + if (__strmode_ & __constant) { + if (gptr()[-1] == static_cast<char>(__c)) { + gbump(-1); + return __c; } - return int_type(static_cast<unsigned char>(*gptr())); + return EOF; + } + gbump(-1); + *gptr() = static_cast<char>(__c); + return __c; } -strstreambuf::pos_type -strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which) -{ - off_type __p(-1); - bool pos_in = (__which & ios::in) != 0; - bool pos_out = (__which & ios::out) != 0; - bool legal = false; - switch (__way) - { - case ios::beg: - case ios::end: - if (pos_in || pos_out) - legal = true; - break; - case ios::cur: - if (pos_in != pos_out) - legal = true; - break; - } - if (pos_in && gptr() == nullptr) - legal = false; - if (pos_out && pptr() == nullptr) - legal = false; - if (legal) - { - off_type newoff; - char* seekhigh = epptr() ? epptr() : egptr(); - switch (__way) - { - case ios::beg: - newoff = 0; - break; - case ios::cur: - newoff = (pos_in ? gptr() : pptr()) - eback(); - break; - case ios::end: - newoff = seekhigh - eback(); - break; - default: - __libcpp_unreachable(); - } - newoff += __off; - if (0 <= newoff && newoff <= seekhigh - eback()) - { - char* newpos = eback() + newoff; - if (pos_in) - setg(eback(), newpos, _VSTD::max(newpos, egptr())); - if (pos_out) - { - // min(pbase, newpos), newpos, epptr() - __off = epptr() - newpos; - setp(min(pbase(), newpos), epptr()); - __pbump((epptr() - pbase()) - __off); - } - __p = newoff; - } - } - return pos_type(__p); +strstreambuf::int_type strstreambuf::underflow() { + if (gptr() == egptr()) { + if (egptr() >= pptr()) + return EOF; + setg(eback(), gptr(), pptr()); + } + return int_type(static_cast<unsigned char>(*gptr())); } -strstreambuf::pos_type -strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which) -{ - off_type __p(-1); - bool pos_in = (__which & ios::in) != 0; - bool pos_out = (__which & ios::out) != 0; - if (pos_in || pos_out) - { - if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr))) - { - off_type newoff = __sp; - char* seekhigh = epptr() ? epptr() : egptr(); - if (0 <= newoff && newoff <= seekhigh - eback()) - { - char* newpos = eback() + newoff; - if (pos_in) - setg(eback(), newpos, _VSTD::max(newpos, egptr())); - if (pos_out) - { - // min(pbase, newpos), newpos, epptr() - off_type temp = epptr() - newpos; - setp(min(pbase(), newpos), epptr()); - __pbump((epptr() - pbase()) - temp); - } - __p = newoff; - } - } - } - return pos_type(__p); -} +strstreambuf::pos_type strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which) { + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; + switch (__way) { + case ios::beg: + case ios::end: + if (!pos_in && !pos_out) + return pos_type(off_type(-1)); + break; + case ios::cur: + if (pos_in == pos_out) + return pos_type(off_type(-1)); + break; + } -istrstream::~istrstream() -{ -} + if (pos_in && gptr() == nullptr) + return pos_type(off_type(-1)); + if (pos_out && pptr() == nullptr) + return pos_type(off_type(-1)); + + off_type newoff; + char* seekhigh = epptr() ? epptr() : egptr(); + switch (__way) { + case ios::beg: + newoff = 0; + break; + case ios::cur: + newoff = (pos_in ? gptr() : pptr()) - eback(); + break; + case ios::end: + newoff = seekhigh - eback(); + break; + default: + __libcpp_unreachable(); + } + newoff += __off; + if (newoff < 0 || newoff > seekhigh - eback()) + return pos_type(off_type(-1)); -ostrstream::~ostrstream() -{ + char* newpos = eback() + newoff; + if (pos_in) + setg(eback(), newpos, _VSTD::max(newpos, egptr())); + if (pos_out) { + // min(pbase, newpos), newpos, epptr() + __off = epptr() - newpos; + setp(min(pbase(), newpos), epptr()); + __pbump((epptr() - pbase()) - __off); + } + return pos_type(newoff); } -strstream::~strstream() -{ +strstreambuf::pos_type strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which) { + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; + if (!pos_in && !pos_out) + return pos_type(off_type(-1)); + + if ((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr)) + return pos_type(off_type(-1)); + + off_type newoff = __sp; + char* seekhigh = epptr() ? epptr() : egptr(); + if (newoff < 0 || newoff > seekhigh - eback()) + return pos_type(off_type(-1)); + + char* newpos = eback() + newoff; + if (pos_in) + setg(eback(), newpos, _VSTD::max(newpos, egptr())); + if (pos_out) { + // min(pbase, newpos), newpos, epptr() + off_type temp = epptr() - newpos; + setp(min(pbase(), newpos), epptr()); + __pbump((epptr() - pbase()) - temp); + } + return pos_type(newoff); } +istrstream::~istrstream() {} + +ostrstream::~ostrstream() {} + +strstream::~strstream() {} + _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp index 2543686c90..c9d1d63b25 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp @@ -17,8 +17,8 @@ int __libcpp_vasprintf(char **sptr, const char *__restrict fmt, va_list ap); using std::__libcpp_locale_guard; -// FIXME: base currently unused. Needs manual work to construct the new locale -locale_t newlocale( int mask, const char * locale, locale_t /*base*/ ) +// FIXME: base and mask currently unused. Needs manual work to construct the new locale +locale_t newlocale(int /*mask*/, const char * locale, locale_t /*base*/) { return {_create_locale( LC_ALL, locale ), locale}; } diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp index f2072b1435..c25aefcc34 100644 --- a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp @@ -7,6 +7,8 @@ //===----------------------------------------------------------------------===// #include <__threading_support> +#include <chrono> + #define NOMINMAX #define WIN32_LEAN_AND_MEAN #include <windows.h> diff --git a/contrib/libs/cxxsupp/libcxx/src/system_error.cpp b/contrib/libs/cxxsupp/libcxx/src/system_error.cpp index 7875f59d88..1cc6b7d7e1 100644 --- a/contrib/libs/cxxsupp/libcxx/src/system_error.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/system_error.cpp @@ -6,12 +6,8 @@ // //===----------------------------------------------------------------------===// -#include <__config> -#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS -# define _LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS -#endif - #include <__assert> +#include <__config> #include <__verbose_abort> #include <cerrno> #include <cstdio> @@ -29,38 +25,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD -// class error_category - -#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS) -error_category::error_category() noexcept -{ -} -#endif - -error_category::~error_category() noexcept -{ -} - -error_condition -error_category::default_error_condition(int ev) const noexcept -{ - return error_condition(ev, *this); -} - -bool -error_category::equivalent(int code, const error_condition& condition) const noexcept -{ - return default_error_condition(code) == condition; -} - -bool -error_category::equivalent(const error_code& code, int condition) const noexcept -{ - return *this == code.category() && code.value() == condition; -} - -#if !defined(_LIBCPP_HAS_NO_THREADS) namespace { +#if !defined(_LIBCPP_HAS_NO_THREADS) // GLIBC also uses 1024 as the maximum buffer size internally. constexpr size_t strerror_buff_size = 1024; @@ -128,8 +94,26 @@ string do_strerror_r(int ev) { return string(error_message); } #endif + +#endif // !defined(_LIBCPP_HAS_NO_THREADS) + +string make_error_str(const error_code& ec, string what_arg) { + if (ec) { + if (!what_arg.empty()) { + what_arg += ": "; + } + what_arg += ec.message(); + } + return what_arg; +} + +string make_error_str(const error_code& ec) { + if (ec) { + return ec.message(); + } + return string(); +} } // end namespace -#endif string __do_message::message(int ev) const @@ -168,8 +152,13 @@ __generic_error_category::message(int ev) const const error_category& generic_category() noexcept { - static __generic_error_category s; - return s; + union AvoidDestroyingGenericCategory { + __generic_error_category generic_error_category; + constexpr explicit AvoidDestroyingGenericCategory() : generic_error_category() {} + ~AvoidDestroyingGenericCategory() {} + }; + constinit static AvoidDestroyingGenericCategory helper; + return helper.generic_error_category; } class _LIBCPP_HIDDEN __system_error_category @@ -210,8 +199,13 @@ __system_error_category::default_error_condition(int ev) const noexcept const error_category& system_category() noexcept { - static __system_error_category s; - return s; + union AvoidDestroyingSystemCategory { + __system_error_category system_error_category; + constexpr explicit AvoidDestroyingSystemCategory() : system_error_category() {} + ~AvoidDestroyingSystemCategory() {} + }; + constinit static AvoidDestroyingSystemCategory helper; + return helper.system_error_category; } // error_condition @@ -232,50 +226,38 @@ error_code::message() const // system_error -string -system_error::__init(const error_code& ec, string what_arg) -{ - if (ec) - { - if (!what_arg.empty()) - what_arg += ": "; - what_arg += ec.message(); - } - return what_arg; -} - system_error::system_error(error_code ec, const string& what_arg) - : runtime_error(__init(ec, what_arg)), + : runtime_error(make_error_str(ec, what_arg)), __ec_(ec) { } system_error::system_error(error_code ec, const char* what_arg) - : runtime_error(__init(ec, what_arg)), + : runtime_error(make_error_str(ec, what_arg)), __ec_(ec) { } system_error::system_error(error_code ec) - : runtime_error(__init(ec, "")), + : runtime_error(make_error_str(ec)), __ec_(ec) { } system_error::system_error(int ev, const error_category& ecat, const string& what_arg) - : runtime_error(__init(error_code(ev, ecat), what_arg)), + : runtime_error(make_error_str(error_code(ev, ecat), what_arg)), __ec_(error_code(ev, ecat)) { } system_error::system_error(int ev, const error_category& ecat, const char* what_arg) - : runtime_error(__init(error_code(ev, ecat), what_arg)), + : runtime_error(make_error_str(error_code(ev, ecat), what_arg)), __ec_(error_code(ev, ecat)) { } system_error::system_error(int ev, const error_category& ecat) - : runtime_error(__init(error_code(ev, ecat), "")), + : runtime_error(make_error_str(error_code(ev, ecat))), __ec_(error_code(ev, ecat)) { } @@ -288,8 +270,9 @@ void __throw_system_error(int ev, const char* what_arg) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw system_error(error_code(ev, system_category()), what_arg); + std::__throw_system_error(error_code(ev, system_category()), what_arg); #else + // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily. _LIBCPP_VERBOSE_ABORT("system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", ev, what_arg); #endif } diff --git a/contrib/libs/cxxsupp/libcxx/src/tz.cpp b/contrib/libs/cxxsupp/libcxx/src/tz.cpp new file mode 100644 index 0000000000..4425f0e6b9 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/src/tz.cpp @@ -0,0 +1,146 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#include <chrono> +#include <filesystem> +#include <fstream> +#include <stdexcept> +#include <string> + +// Contains a parser for the IANA time zone data files. +// +// These files can be found at https://data.iana.org/time-zones/ and are in the +// public domain. Information regarding the input can be found at +// https://data.iana.org/time-zones/tz-how-to.html and +// https://man7.org/linux/man-pages/man8/zic.8.html. +// +// As indicated at https://howardhinnant.github.io/date/tz.html#Installation +// For Windows another file seems to be required +// https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml +// This file seems to contain the mapping of Windows time zone name to IANA +// time zone names. +// +// However this article mentions another way to do the mapping on Windows +// https://devblogs.microsoft.com/oldnewthing/20210527-00/?p=105255 +// This requires Windows 10 Version 1903, which was released in May of 2019 +// and considered end of life in December 2020 +// https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1903-end-of-servicing +// +// TODO TZDB Implement the Windows mapping in tzdb::current_zone + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace chrono { + +// This function is weak so it can be overriden in the tests. The +// declaration is in the test header test/support/test_tzdb.h +_LIBCPP_WEAK string_view __libcpp_tzdb_directory() { +#if defined(__linux__) + return "/usr/share/zoneinfo/"; +#else +# error "unknown path to the IANA Time Zone Database" +#endif +} + +[[nodiscard]] static bool __is_whitespace(int __c) { return __c == ' ' || __c == '\t'; } + +static void __skip_optional_whitespace(istream& __input) { + while (chrono::__is_whitespace(__input.peek())) + __input.get(); +} + +static void __skip_mandatory_whitespace(istream& __input) { + if (!chrono::__is_whitespace(__input.get())) + std::__throw_runtime_error("corrupt tzdb: expected whitespace"); + + chrono::__skip_optional_whitespace(__input); +} + +static void __matches(istream& __input, char __expected) { + if (std::tolower(__input.get()) != __expected) + std::__throw_runtime_error((string("corrupt tzdb: expected character '") + __expected + '\'').c_str()); +} + +static void __matches(istream& __input, string_view __expected) { + for (auto __c : __expected) + if (std::tolower(__input.get()) != __c) + std::__throw_runtime_error((string("corrupt tzdb: expected string '") + string(__expected) + '\'').c_str()); +} + +[[nodiscard]] static string __parse_string(istream& __input) { + string __result; + while (true) { + int __c = __input.get(); + switch (__c) { + case ' ': + case '\t': + case '\n': + __input.unget(); + [[fallthrough]]; + case istream::traits_type::eof(): + if (__result.empty()) + std::__throw_runtime_error("corrupt tzdb: expected a string"); + + return __result; + + default: + __result.push_back(__c); + } + } +} + +static string __parse_version(istream& __input) { + // The first line in tzdata.zi contains + // # version YYYYw + // The parser expects this pattern + // #\s*version\s*\(.*) + // This part is not documented. + chrono::__matches(__input, '#'); + chrono::__skip_optional_whitespace(__input); + chrono::__matches(__input, "version"); + chrono::__skip_mandatory_whitespace(__input); + return chrono::__parse_string(__input); +} + +static tzdb __make_tzdb() { + tzdb __result; + + filesystem::path __root = chrono::__libcpp_tzdb_directory(); + ifstream __tzdata{__root / "tzdata.zi"}; + + __result.version = chrono::__parse_version(__tzdata); + return __result; +} + +//===----------------------------------------------------------------------===// +// Public API +//===----------------------------------------------------------------------===// + +_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list() { + static tzdb_list __result{chrono::__make_tzdb()}; + return __result; +} + +_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb() { + if (chrono::remote_version() == chrono::get_tzdb().version) + return chrono::get_tzdb(); + + return chrono::get_tzdb_list().__emplace_front(chrono::__make_tzdb()); +} + +_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version() { + filesystem::path __root = chrono::__libcpp_tzdb_directory(); + ifstream __tzdata{__root / "tzdata.zi"}; + return chrono::__parse_version(__tzdata); +} + +} // namespace chrono + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/src/tzdb_list.cpp b/contrib/libs/cxxsupp/libcxx/src/tzdb_list.cpp new file mode 100644 index 0000000000..7eaaedc6ed --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/src/tzdb_list.cpp @@ -0,0 +1,113 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html + +#include <chrono> + +#include <__mutex/unique_lock.h> +#include <forward_list> + +// When threads are not available the locking is not required. +#ifndef _LIBCPP_HAS_NO_THREADS +# include <shared_mutex> +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +namespace chrono { + +//===----------------------------------------------------------------------===// +// Private API +//===----------------------------------------------------------------------===// + +class tzdb_list::__impl { +public: + explicit __impl(tzdb&& __tzdb) { __tzdb_.push_front(std::move(__tzdb)); } + + using const_iterator = tzdb_list::const_iterator; + + const tzdb& front() const noexcept { +#ifndef _LIBCPP_HAS_NO_THREADS + shared_lock __lock{__mutex_}; +#endif + return __tzdb_.front(); + } + + const_iterator erase_after(const_iterator __p) { +#ifndef _LIBCPP_HAS_NO_THREADS + unique_lock __lock{__mutex_}; +#endif + return __tzdb_.erase_after(__p); + } + + tzdb& __emplace_front(tzdb&& __tzdb) { +#ifndef _LIBCPP_HAS_NO_THREADS + unique_lock __lock{__mutex_}; +#endif + return __tzdb_.emplace_front(std::move(__tzdb)); + } + + const_iterator begin() const noexcept { +#ifndef _LIBCPP_HAS_NO_THREADS + shared_lock __lock{__mutex_}; +#endif + return __tzdb_.begin(); + } + const_iterator end() const noexcept { + // forward_list<T>::end does not access the list, so no need to take a lock. + return __tzdb_.end(); + } + + const_iterator cbegin() const noexcept { return begin(); } + const_iterator cend() const noexcept { return end(); } + +private: +#ifndef _LIBCPP_HAS_NO_THREADS + mutable shared_mutex __mutex_; +#endif + forward_list<tzdb> __tzdb_; +}; + +//===----------------------------------------------------------------------===// +// Public API +//===----------------------------------------------------------------------===// + +_LIBCPP_EXPORTED_FROM_ABI tzdb_list::tzdb_list(tzdb&& __tzdb) : __impl_{new __impl(std::move(__tzdb))} {} + +_LIBCPP_EXPORTED_FROM_ABI tzdb_list::~tzdb_list() { delete __impl_; } + +_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const tzdb& tzdb_list::front() const noexcept { + return __impl_->front(); +} + +_LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::erase_after(const_iterator __p) { + return __impl_->erase_after(__p); +} + +_LIBCPP_EXPORTED_FROM_ABI tzdb& tzdb_list::__emplace_front(tzdb&& __tzdb) { + return __impl_->__emplace_front(std::move(__tzdb)); +} + +_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::begin() const noexcept { + return __impl_->begin(); +} +_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::end() const noexcept { + return __impl_->end(); +} + +_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::cbegin() const noexcept { + return __impl_->cbegin(); +} +_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::cend() const noexcept { + return __impl_->cend(); +} + +} // namespace chrono + +_LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make index e4bb75bacf..16db885ad5 100644 --- a/contrib/libs/cxxsupp/libcxx/ya.make +++ b/contrib/libs/cxxsupp/libcxx/ya.make @@ -8,14 +8,15 @@ LICENSE( BSL-1.0 AND MIT AND NCSA AND + Public-Domain AND Unicode ) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2023-06-02) +VERSION(2023-10-05) -ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/308c816de5a47dd7d08a29f91b68381b45ed3552.tar.gz) +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/dc129d6f715cf83a2072fc8de8b4e4c70bca6935.tar.gz) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxx/include @@ -222,6 +223,7 @@ SRCS( src/chrono.cpp src/condition_variable.cpp src/condition_variable_destructor.cpp + src/error_category.cpp src/exception.cpp src/filesystem/directory_entry.cpp src/filesystem/directory_iterator.cpp @@ -270,4 +272,11 @@ IF (NOT OS_WINDOWS) ) ENDIF() +IF (OS_LINUX) + SRCS( + src/tz.cpp + src/tzdb_list.cpp + ) +ENDIF() + END() |