diff options
author | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-11-20 11:14:58 +0000 |
commit | 31773f157bf8164364649b5f470f52dece0a4317 (patch) | |
tree | 33d0f7eef45303ab68cf08ab381ce5e5e36c5240 /contrib/libs | |
parent | 2c7938962d8689e175574fc1e817c05049f27905 (diff) | |
parent | eff600952d5dfe17942f38f510a8ac2b203bb3a5 (diff) | |
download | ydb-31773f157bf8164364649b5f470f52dece0a4317.tar.gz |
Merge branch 'rightlib' into mergelibs-241120-1113
Diffstat (limited to 'contrib/libs')
102 files changed, 2360 insertions, 1507 deletions
diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make b/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make index 6c0a186f88..689ff96961 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make +++ b/contrib/libs/apache/arrow/cpp/src/arrow/python/ya.make @@ -2,12 +2,12 @@ PY3_LIBRARY() -VERSION(5.0.0) - LICENSE(Apache-2.0) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) +VERSION(5.0.0) + PEERDIR( contrib/libs/apache/arrow contrib/libs/python diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/result.h b/contrib/libs/apache/arrow/cpp/src/arrow/result.h index cb7437cd24..af4a72f65e 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/result.h +++ b/contrib/libs/apache/arrow/cpp/src/arrow/result.h @@ -385,7 +385,7 @@ class ARROW_MUST_USE_TYPE Result : public util::EqualityComparable<Result<T>> { /// Apply a function to the internally stored value to produce a new result or propagate /// the stored error. template <typename M> - typename EnsureResult<typename std::result_of<M && (T)>::type>::type Map(M&& m) && { + typename EnsureResult<decltype(std::declval<M&&>()(std::declval<T&&>()))>::type Map(M&& m) && { if (!ok()) { return status(); } @@ -395,7 +395,7 @@ class ARROW_MUST_USE_TYPE Result : public util::EqualityComparable<Result<T>> { /// Apply a function to the internally stored value to produce a new result or propagate /// the stored error. template <typename M> - typename EnsureResult<typename std::result_of<M && (const T&)>::type>::type Map( + typename EnsureResult<decltype(std::declval<M&&>()(std::declval<const T&>()))>::type Map( M&& m) const& { if (!ok()) { return status(); diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/util/bitmap_generate.h b/contrib/libs/apache/arrow/cpp/src/arrow/util/bitmap_generate.h index 129fa91323..6b900f246f 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/util/bitmap_generate.h +++ b/contrib/libs/apache/arrow/cpp/src/arrow/util/bitmap_generate.h @@ -62,7 +62,7 @@ void GenerateBits(uint8_t* bitmap, int64_t start_offset, int64_t length, Generat template <class Generator> void GenerateBitsUnrolled(uint8_t* bitmap, int64_t start_offset, int64_t length, Generator&& g) { - static_assert(std::is_same<typename std::result_of<Generator && ()>::type, bool>::value, + static_assert(std::is_same<decltype(std::declval<Generator>()()), bool>::value, "Functor passed to GenerateBitsUnrolled must return bool"); if (length == 0) { diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/util/functional.h b/contrib/libs/apache/arrow/cpp/src/arrow/util/functional.h index 9da79046fe..41e268852f 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/util/functional.h +++ b/contrib/libs/apache/arrow/cpp/src/arrow/util/functional.h @@ -129,7 +129,7 @@ class FnOnce<R(A...)> { template <typename Fn, typename = typename std::enable_if<std::is_convertible< - typename std::result_of<Fn && (A...)>::type, R>::value>::type> + decltype(std::declval<Fn&&>()(std::declval<A>()...)), R>::value>::type> FnOnce(Fn fn) : impl_(new FnImpl<Fn>(std::move(fn))) { // NOLINT runtime/explicit } diff --git a/contrib/libs/apache/arrow/cpp/src/arrow/util/future.h b/contrib/libs/apache/arrow/cpp/src/arrow/util/future.h index d9e0a939f2..2b8c522096 100644 --- a/contrib/libs/apache/arrow/cpp/src/arrow/util/future.h +++ b/contrib/libs/apache/arrow/cpp/src/arrow/util/future.h @@ -47,8 +47,17 @@ struct is_future : std::false_type {}; template <typename T> struct is_future<Future<T>> : std::true_type {}; +template <typename Signature, typename Enable = void> +struct result_of; + +template <typename Fn, typename... A> +struct result_of<Fn(A...), + std::void_t<decltype(std::declval<Fn>()(std::declval<A>()...))>> { + using type = decltype(std::declval<Fn>()(std::declval<A>()...)); +}; + template <typename Signature> -using result_of_t = typename std::result_of<Signature>::type; +using result_of_t = typename result_of<Signature>::type; // Helper to find the synchronous counterpart for a Future template <typename T> diff --git a/contrib/libs/apache/arrow/patches/no_result_of.patch b/contrib/libs/apache/arrow/patches/no_result_of.patch new file mode 100644 index 0000000000..e75e1109e8 --- /dev/null +++ b/contrib/libs/apache/arrow/patches/no_result_of.patch @@ -0,0 +1,64 @@ +--- contrib/libs/apache/arrow/cpp/src/arrow/result.h (2e0006a95f0ad665eca5b48386842a8a0354061f) ++++ contrib/libs/apache/arrow/cpp/src/arrow/result.h (working tree) +@@ -385,7 +385,7 @@ class ARROW_MUST_USE_TYPE Result : public util::EqualityComparable<Result<T>> { + /// Apply a function to the internally stored value to produce a new result or propagate + /// the stored error. + template <typename M> +- typename EnsureResult<typename std::result_of<M && (T)>::type>::type Map(M&& m) && { ++ typename EnsureResult<decltype(std::declval<M&&>()(std::declval<T&&>()))>::type Map(M&& m) && { + if (!ok()) { + return status(); + } +@@ -395,7 +395,7 @@ class ARROW_MUST_USE_TYPE Result : public util::EqualityComparable<Result<T>> { + /// Apply a function to the internally stored value to produce a new result or propagate + /// the stored error. + template <typename M> +- typename EnsureResult<typename std::result_of<M && (const T&)>::type>::type Map( ++ typename EnsureResult<decltype(std::declval<M&&>()(std::declval<const T&>()))>::type Map( + M&& m) const& { + if (!ok()) { + return status(); +--- contrib/libs/apache/arrow/cpp/src/arrow/util/bitmap_generate.h (2e0006a95f0ad665eca5b48386842a8a0354061f) ++++ contrib/libs/apache/arrow/cpp/src/arrow/util/bitmap_generate.h (working tree) +@@ -62,7 +62,7 @@ void GenerateBits(uint8_t* bitmap, int64_t start_offset, int64_t length, Generat + template <class Generator> + void GenerateBitsUnrolled(uint8_t* bitmap, int64_t start_offset, int64_t length, + Generator&& g) { +- static_assert(std::is_same<typename std::result_of<Generator && ()>::type, bool>::value, ++ static_assert(std::is_same<decltype(std::declval<Generator>()()), bool>::value, + "Functor passed to GenerateBitsUnrolled must return bool"); + + if (length == 0) { +--- contrib/libs/apache/arrow/cpp/src/arrow/util/functional.h (2e0006a95f0ad665eca5b48386842a8a0354061f) ++++ contrib/libs/apache/arrow/cpp/src/arrow/util/functional.h (working tree) +@@ -129,7 +129,7 @@ class FnOnce<R(A...)> { + + template <typename Fn, + typename = typename std::enable_if<std::is_convertible< +- typename std::result_of<Fn && (A...)>::type, R>::value>::type> ++ decltype(std::declval<Fn&&>()(std::declval<A>()...)), R>::value>::type> + FnOnce(Fn fn) : impl_(new FnImpl<Fn>(std::move(fn))) { // NOLINT runtime/explicit + } + +--- contrib/libs/apache/arrow/cpp/src/arrow/util/future.h (2e0006a95f0ad665eca5b48386842a8a0354061f) ++++ contrib/libs/apache/arrow/cpp/src/arrow/util/future.h (working tree) +@@ -47,8 +47,17 @@ struct is_future : std::false_type {}; + template <typename T> + struct is_future<Future<T>> : std::true_type {}; + ++template <typename Signature, typename Enable = void> ++struct result_of; ++ ++template <typename Fn, typename... A> ++struct result_of<Fn(A...), ++ std::void_t<decltype(std::declval<Fn>()(std::declval<A>()...))>> { ++ using type = decltype(std::declval<Fn>()(std::declval<A>()...)); ++}; ++ + template <typename Signature> +-using result_of_t = typename std::result_of<Signature>::type; ++using result_of_t = typename result_of<Signature>::type; + + // Helper to find the synchronous counterpart for a Future + template <typename T> + diff --git a/contrib/libs/apache/arrow/ya.make b/contrib/libs/apache/arrow/ya.make index 1eedb9f95d..f4ed4463d1 100644 --- a/contrib/libs/apache/arrow/ya.make +++ b/contrib/libs/apache/arrow/ya.make @@ -1,4 +1,4 @@ -# Generated by devtools/yamaker from nixpkgs 24.05. +# Generated by devtools/yamaker from nixpkgs 23.05. LIBRARY() diff --git a/contrib/libs/apache/orc/README.md b/contrib/libs/apache/orc/README.md index 60b0da5fcb..cf5c5d0793 100644 --- a/contrib/libs/apache/orc/README.md +++ b/contrib/libs/apache/orc/README.md @@ -43,7 +43,7 @@ The subdirectories are: ### Building * Install java 17 or higher -* Install maven 3.9.6 or higher +* Install maven 3.9.9 or higher * Install cmake 3.12 or higher To build a release version with debug information: diff --git a/contrib/libs/apache/orc/c++/include/orc/orc-config.hh b/contrib/libs/apache/orc/c++/include/orc/orc-config.hh index 6d6ae91a34..5205a56af6 100644 --- a/contrib/libs/apache/orc/c++/include/orc/orc-config.hh +++ b/contrib/libs/apache/orc/c++/include/orc/orc-config.hh @@ -19,7 +19,7 @@ #ifndef ORC_CONFIG_HH #define ORC_CONFIG_HH -#define ORC_VERSION "2.0.2" +#define ORC_VERSION "2.0.3" #define ORC_CXX_HAS_CSTDINT diff --git a/contrib/libs/apache/orc/c++/src/sargs/PredicateLeaf.cc b/contrib/libs/apache/orc/c++/src/sargs/PredicateLeaf.cc index dda89f7c3b..3c23e28beb 100644 --- a/contrib/libs/apache/orc/c++/src/sargs/PredicateLeaf.cc +++ b/contrib/libs/apache/orc/c++/src/sargs/PredicateLeaf.cc @@ -701,6 +701,9 @@ namespace orc { } } + // files written by trino may lack of hasnull field. + if (!colStats.has_has_null()) return TruthValue::YES_NO_NULL; + bool allNull = colStats.has_null() && colStats.number_of_values() == 0; if (mOperator == Operator::IS_NULL || ((mOperator == Operator::EQUALS || mOperator == Operator::NULL_SAFE_EQUALS) && diff --git a/contrib/libs/apache/orc/ya.make b/contrib/libs/apache/orc/ya.make index 3484882d72..12617d59ab 100644 --- a/contrib/libs/apache/orc/ya.make +++ b/contrib/libs/apache/orc/ya.make @@ -6,9 +6,9 @@ LICENSE(Apache-2.0) LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2.0.2) +VERSION(2.0.3) -ORIGINAL_SOURCE(https://github.com/apache/orc/archive/rel/release-2.0.2.tar.gz) +ORIGINAL_SOURCE(https://github.com/apache/orc/archive/rel/release-2.0.3.tar.gz) PEERDIR( contrib/libs/apache/orc-format diff --git a/contrib/libs/clang18-rt/lib/ubsan/ubsan_diag.cpp b/contrib/libs/clang18-rt/lib/ubsan/ubsan_diag.cpp index 67e884e491..27661fa95e 100644 --- a/contrib/libs/clang18-rt/lib/ubsan/ubsan_diag.cpp +++ b/contrib/libs/clang18-rt/lib/ubsan/ubsan_diag.cpp @@ -412,11 +412,17 @@ static const char *kSuppressionTypes[] = { kVptrCheck, }; +SANITIZER_INTERFACE_WEAK_DEF(const char *, __ubsan_default_suppressions, void) { + return ""; +} + void __ubsan::InitializeSuppressions() { CHECK_EQ(nullptr, suppression_ctx); suppression_ctx = new (suppression_placeholder) SuppressionContext(kSuppressionTypes, ARRAY_SIZE(kSuppressionTypes)); suppression_ctx->ParseFromFile(flags()->suppressions); + if (&__ubsan_default_suppressions) + suppression_ctx->Parse(__ubsan_default_suppressions()); } bool __ubsan::IsVptrCheckSuppressed(const char *TypeName) { diff --git a/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym b/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym index be1ee0f885..b68e43beb9 100644 --- a/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym +++ b/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym @@ -1,7 +1,7 @@ {% extends '//builtin/run.ym' %} -{% block current_version %}dc129d6f715cf83a2072fc8de8b4e4c70bca6935{% endblock %} -{% block current_date %}2023-10-05{% endblock %} +{% block current_version %}d173ce4a670e88b65c52f6fc1bf10d133ee35704{% endblock %} +{% block current_date %}2023-10-19{% endblock %} {% block keep_sources %} .yandex_meta/scripts/sysincls.py diff --git a/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report b/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report index c0069d3a5e..f5f134ef30 100644 --- a/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report +++ b/contrib/libs/cxxsupp/libcxx/.yandex_meta/devtools.licenses.report @@ -971,6 +971,7 @@ BELONGS ya.make include/__utility/cmp.h [3:4] include/__utility/convert_to_integral.h [3:4] include/__utility/declval.h [3:4] + include/__utility/empty.h [3:4] include/__utility/exception_guard.h [3:4] include/__utility/exchange.h [3:4] include/__utility/forward.h [4:5] @@ -984,7 +985,6 @@ BELONGS ya.make include/__utility/priority_tag.h [3:4] include/__utility/rel_ops.h [3:4] include/__utility/swap.h [3:4] - include/__utility/terminate_on_exception.h [3:4] include/__utility/to_underlying.h [4:5] include/__utility/unreachable.h [3:4] include/__variant/monostate.h [4:5] @@ -1086,7 +1086,6 @@ BELONGS ya.make include/iterator [4:5] include/latch [4:5] include/limits [4:5] - include/limits.h [4:5] include/list [4:5] include/locale [4:5] include/locale.h [4:5] @@ -1111,7 +1110,6 @@ BELONGS ya.make include/scoped_allocator [4:5] include/semaphore [4:5] include/set [4:5] - include/setjmp.h [4:5] include/shared_mutex [4:5] include/source_location [4:5] include/span [4:5] @@ -2088,6 +2086,7 @@ BELONGS ya.make include/__utility/cmp.h [3:4] include/__utility/convert_to_integral.h [3:4] include/__utility/declval.h [3:4] + include/__utility/empty.h [3:4] include/__utility/exception_guard.h [3:4] include/__utility/exchange.h [3:4] include/__utility/forward.h [4:5] @@ -2101,7 +2100,6 @@ BELONGS ya.make include/__utility/priority_tag.h [3:4] include/__utility/rel_ops.h [3:4] include/__utility/swap.h [3:4] - include/__utility/terminate_on_exception.h [3:4] include/__utility/to_underlying.h [4:5] include/__utility/unreachable.h [3:4] include/__variant/monostate.h [4:5] @@ -2203,7 +2201,6 @@ BELONGS ya.make include/iterator [4:5] include/latch [4:5] include/limits [4:5] - include/limits.h [4:5] include/list [4:5] include/locale [4:5] include/locale.h [4:5] @@ -2228,7 +2225,6 @@ BELONGS ya.make include/scoped_allocator [4:5] include/semaphore [4:5] include/set [4:5] - include/setjmp.h [4:5] include/shared_mutex [4:5] include/source_location [4:5] include/span [4:5] @@ -3265,6 +3261,7 @@ BELONGS ya.make include/__utility/cmp.h [5:5] include/__utility/convert_to_integral.h [5:5] include/__utility/declval.h [5:5] + include/__utility/empty.h [5:5] include/__utility/exception_guard.h [5:5] include/__utility/exchange.h [5:5] include/__utility/forward.h [6:6] @@ -3278,7 +3275,6 @@ BELONGS ya.make include/__utility/priority_tag.h [5:5] include/__utility/rel_ops.h [5:5] include/__utility/swap.h [5:5] - include/__utility/terminate_on_exception.h [5:5] include/__utility/to_underlying.h [6:6] include/__utility/unreachable.h [5:5] include/__variant/monostate.h [6:6] @@ -3380,7 +3376,6 @@ BELONGS ya.make include/iterator [6:6] include/latch [6:6] include/limits [6:6] - include/limits.h [6:6] include/list [6:6] include/locale [6:6] include/locale.h [6:6] @@ -3405,7 +3400,6 @@ BELONGS ya.make include/scoped_allocator [6:6] include/semaphore [6:6] include/set [6:6] - include/setjmp.h [6:6] include/shared_mutex [6:6] include/source_location [6:6] include/span [6:6] @@ -4396,6 +4390,7 @@ BELONGS ya.make include/__utility/cmp.h [5:5] include/__utility/convert_to_integral.h [5:5] include/__utility/declval.h [5:5] + include/__utility/empty.h [5:5] include/__utility/exception_guard.h [5:5] include/__utility/exchange.h [5:5] include/__utility/forward.h [6:6] @@ -4409,7 +4404,6 @@ BELONGS ya.make include/__utility/priority_tag.h [5:5] include/__utility/rel_ops.h [5:5] include/__utility/swap.h [5:5] - include/__utility/terminate_on_exception.h [5:5] include/__utility/to_underlying.h [6:6] include/__utility/unreachable.h [5:5] include/__variant/monostate.h [6:6] @@ -4511,7 +4505,6 @@ BELONGS ya.make include/iterator [6:6] include/latch [6:6] include/limits [6:6] - include/limits.h [6:6] include/list [6:6] include/locale [6:6] include/locale.h [6:6] @@ -4536,7 +4529,6 @@ BELONGS ya.make include/scoped_allocator [6:6] include/semaphore [6:6] include/set [6:6] - include/setjmp.h [6:6] include/shared_mutex [6:6] include/source_location [6:6] include/span [6:6] diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h index 6c8c7fda35..23a7d3c4dc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/count.h @@ -10,26 +10,83 @@ #ifndef _LIBCPP___ALGORITHM_COUNT_H #define _LIBCPP___ALGORITHM_COUNT_H +#include <__algorithm/iterator_operations.h> +#include <__algorithm/min.h> +#include <__bit/invert_if.h> +#include <__bit/popcount.h> #include <__config> +#include <__functional/identity.h> +#include <__functional/invoke.h> +#include <__fwd/bit_reference.h> #include <__iterator/iterator_traits.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD -template <class _InputIterator, class _Tp> -_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - typename iterator_traits<_InputIterator>::difference_type - count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { - typename iterator_traits<_InputIterator>::difference_type __r(0); +// generic implementation +template <class _AlgPolicy, class _Iter, class _Sent, class _Tp, class _Proj> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> +__count(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) { + typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> __r(0); for (; __first != __last; ++__first) - if (*__first == __value) + if (std::__invoke(__proj, *__first) == __value) ++__r; return __r; } +// __bit_iterator implementation +template <bool _ToCount, class _Cp, bool _IsConst> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bit_iterator<_Cp, _IsConst>::difference_type +__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, class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<__bit_iterator<_Cp, _IsConst> > +__count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) { + if (__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)); +} + +template <class _InputIterator, class _Tp> +_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator> +count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { + __identity __proj; + return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj); +} + _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___ALGORITHM_COUNT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/nth_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/nth_element.h index dbacf58f9e..ebd1cbf761 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/nth_element.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/nth_element.h @@ -13,6 +13,7 @@ #include <__algorithm/comp_ref_type.h> #include <__algorithm/iterator_operations.h> #include <__algorithm/sort.h> +#include <__assert> #include <__config> #include <__debug_utils/randomize_range.h> #include <__iterator/iterator_traits.h> @@ -42,6 +43,7 @@ __nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j, template <class _AlgPolicy, class _Compare, class _RandomAccessIterator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void +// NOLINTNEXTLINE(readability-function-cognitive-complexity) __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { using _Ops = _IterOps<_AlgPolicy>; @@ -116,10 +118,18 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando return; } while (true) { - while (!__comp(*__first, *__i)) + while (!__comp(*__first, *__i)) { ++__i; - while (__comp(*__first, *--__j)) - ; + _LIBCPP_ASSERT_UNCATEGORIZED( + __i != __last, + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } + do { + _LIBCPP_ASSERT_UNCATEGORIZED( + __j != __first, + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + --__j; + } while (__comp(*__first, *__j)); if (__i >= __j) break; _Ops::iter_swap(__i, __j); @@ -146,11 +156,19 @@ __nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _Rando while (true) { // __m still guards upward moving __i - while (__comp(*__i, *__m)) + while (__comp(*__i, *__m)) { ++__i; + _LIBCPP_ASSERT_UNCATEGORIZED( + __i != __last, + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + } // It is now known that a guard exists for downward moving __j - while (!__comp(*--__j, *__m)) - ; + do { + _LIBCPP_ASSERT_UNCATEGORIZED( + __j != __first, + "Would read out of bounds, does your comparator satisfy the strict-weak ordering requirement?"); + --__j; + } while (!__comp(*__j, *__m)); if (__i >= __j) break; _Ops::iter_swap(__i, __j); 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 47d280c431..d93fdba222 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 @@ -17,7 +17,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -35,19 +35,35 @@ template <class _ExecutionPolicy, class _Predicate, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool -any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __any_of( + _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept { return std::__pstl_frontend_dispatch( _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; + [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<bool> { + auto __res = std::__find_if(__policy, __g_first, __g_last, __g_pred); + if (!__res) + return nullopt; + return *__res != __g_last; }, std::move(__first), std::move(__last), std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Predicate, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool +any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__any_of(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + template <class> void __pstl_all_of(); // declaration needed for the frontend dispatch below @@ -56,21 +72,37 @@ template <class _ExecutionPolicy, class _Pred, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool -all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> +__all_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept { return std::__pstl_frontend_dispatch( _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) { + [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> { + auto __res = std::__any_of(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) { return !__g_pred(__value); }); + if (!__res) + return nullopt; + return !*__res; }, std::move(__first), std::move(__last), std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Pred, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool +all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__all_of(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + template <class> void __pstl_none_of(); // declaration needed for the frontend dispatch below @@ -79,19 +111,35 @@ template <class _ExecutionPolicy, class _Pred, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool -none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> +__none_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept { return std::__pstl_frontend_dispatch( _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); + [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> { + auto __res = std::__any_of(__policy, __g_first, __g_last, __g_pred); + if (!__res) + return nullopt; + return !*__res; }, std::move(__first), std::move(__last), std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Pred, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool +none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__none_of(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h index 3d9459ef5f..0bf2cca5ee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backend.h @@ -27,41 +27,38 @@ TODO: Documentation of how backends work A PSTL parallel backend is a tag type to which the following functions are associated, at minimum: template <class _ExecutionPolicy, class _Iterator, class _Func> - void __pstl_for_each(_Backend, _ExecutionPolicy&&, _Iterator __first, _Iterator __last, _Func __f); + optional<__empty> __pstl_for_each(_Backend, _ExecutionPolicy&&, _Iterator __first, _Iterator __last, _Func __f); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - _Iterator __pstl_find_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); + optional<_Iterator> __pstl_find_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp> - void __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp); + optional<__empty> + __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); + optional<_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(_Backend, - _InIterator __first, - _InIterator __last, - _OutIterator __result, - _UnaryOperation __op); + optional<_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(_Backend, - _InIterator1 __first1, - _InIterator1 __last1, - _InIterator2 __first2, - _OutIterator __result, - _BinaryOperation __op); + optional<_OutIterator> __pstl_transform(_InIterator1 __first1, + _InIterator2 __first2, + _InIterator1 __last1, + _OutIterator __result, + _BinaryOperation __op); template <class _ExecutionPolicy, class _Iterator1, @@ -69,22 +66,22 @@ A PSTL parallel backend is a tag type to which the following functions are assoc class _Tp, class _BinaryOperation1, class _BinaryOperation2> - _Tp __pstl_transform_reduce(_Backend, - _Iterator1 __first1, - _Iterator1 __last1, - _Iterator2 __first2, - _Iterator2 __last2, - _Tp __init, - _BinaryOperation1 __reduce, - _BinaryOperation2 __transform); + optional<_Tp> __pstl_transform_reduce(_Backend, + _Iterator1 __first1, + _Iterator1 __last1, + _Iterator2 __first2, + _Iterator2 __last2, + _Tp __init, + _BinaryOperation1 __reduce, + _BinaryOperation2 __transform); template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation, class _UnaryOperation> - _Tp __pstl_transform_reduce(_Backend, - _Iterator __first, - _Iterator __last, - _Tp __init, - _BinaryOperation __reduce, - _UnaryOperation __transform); + optional<_Tp> __pstl_transform_reduce(_Backend, + _Iterator __first, + _Iterator __last, + _Tp __init, + _BinaryOperation __reduce, + _UnaryOperation __transform); // TODO: Complete this list @@ -93,86 +90,95 @@ algorithms, otherwise they are implemented in terms of other algorithms. If none implemented, all the algorithms will eventually forward to the basis algorithms listed above: template <class _ExecutionPolicy, class _Iterator, class _Size, class _Func> - void __pstl_for_each_n(_Backend, _Iterator __first, _Size __n, _Func __f); + optional<__empty> __pstl_for_each_n(_Backend, _Iterator __first, _Size __n, _Func __f); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - bool __pstl_any_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); + optional<bool> __pstl_any_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - bool __pstl_all_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); + optional<bool> __pstl_all_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - bool __pstl_none_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); + optional<bool> __pstl_none_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _Iterator, class _Tp> - _Iterator __pstl_find(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); + optional<_Iterator> __pstl_find(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - _Iterator __pstl_find_if_not(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); + optional<_Iterator> __pstl_find_if_not(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _Iterator, class _Tp> - void __pstl_fill(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); + optional<__empty> __pstl_fill(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); template <class _ExecutionPolicy, class _Iterator, class _SizeT, class _Tp> - void __pstl_fill_n(_Backend, _Iterator __first, _SizeT __n, const _Tp& __value); + optional<__empty> __pstl_fill_n(_Backend, _Iterator __first, _SizeT __n, const _Tp& __value); template <class _ExecutionPolicy, class _Iterator, class _Generator> - void __pstl_generate(_Backend, _Iterator __first, _Iterator __last, _Generator __gen); + optional<__empty> __pstl_generate(_Backend, _Iterator __first, _Iterator __last, _Generator __gen); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - void __pstl_is_partitioned(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); + optional<__empty> __pstl_is_partitioned(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _Iterator, class _Size, class _Generator> - void __pstl_generator_n(_Backend, _Iterator __first, _Size __n, _Generator __gen); + optional<__empty> __pstl_generator_n(_Backend, _Iterator __first, _Size __n, _Generator __gen); template <class _ExecutionPolicy, class _terator1, class _Iterator2, class _OutIterator, class _Comp> - _OutIterator __pstl_merge(_Backend, - _Iterator1 __first1, - _Iterator1 __last1, - _Iterator2 __first2, - _Iterator2 __last2, - _OutIterator __result, - _Comp __comp); + optional<_OutIterator> __pstl_merge(_Backend, + _Iterator1 __first1, + _Iterator1 __last1, + _Iterator2 __first2, + _Iterator2 __last2, + _OutIterator __result, + _Comp __comp); template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation> - _Tp __pstl_reduce(_Backend, _Iterator __first, _Iterator __last, _Tp __init, _BinaryOperation __op); + optional<_Tp> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last, _Tp __init, _BinaryOperation __op); temlate <class _ExecutionPolicy, class _Iterator> - __iter_value_type<_Iterator> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last); + optional<__iter_value_type<_Iterator>> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last); template <class _ExecuitonPolicy, class _Iterator, class _Tp> - __iter_diff_t<_Iterator> __pstl_count(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); + optional<__iter_diff_t<_Iterator>> __pstl_count(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value); template <class _ExecutionPolicy, class _Iterator, class _Predicate> - __iter_diff_t<_Iterator> __pstl_count_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); + optional<__iter_diff_t<_Iterator>> __pstl_count_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred); template <class _ExecutionPolicy, class _Iterator, class _Tp> - void __pstl_replace(_Backend, _Iterator __first, _Iterator __last, const _Tp& __old_value, const _Tp& __new_value); + optional<__empty> + __pstl_replace(_Backend, _Iterator __first, _Iterator __last, const _Tp& __old_value, const _Tp& __new_value); template <class _ExecutionPolicy, class _Iterator, class _Pred, class _Tp> - void __pstl_replace_if(_Backend, _Iterator __first, _Iterator __last, _Pred __pred, const _Tp& __new_value); + optional<__empty> + __pstl_replace_if(_Backend, _Iterator __first, _Iterator __last, _Pred __pred, const _Tp& __new_value); template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Tp> - void __pstl_replace_copy(_Backend, - _Iterator __first, - _Iterator __last, - _OutIterator __result, - const _Tp& __old_value, - const _Tp& __new_value); + optional<__empty> __pstl_replace_copy(_Backend, + _Iterator __first, + _Iterator __last, + _OutIterator __result, + const _Tp& __old_value, + const _Tp& __new_value); template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Pred, class _Tp> - void __pstl_replace_copy_if(_Backend, - _Iterator __first, - _Iterator __last, - _OutIterator __result, - _Pred __pred, - const _Tp& __new_value); + optional<__empty> __pstl_replace_copy_if(_Backend, + _Iterator __first, + _Iterator __last, + _OutIterator __result, + _Pred __pred, + const _Tp& __new_value); template <class _ExecutionPolicy, class _Iterator, class _Comp> - void __pstl_sort(_Backend, _Iterator __first, _Iterator __last, _Comp __comp); + optional<__empty> __pstl_sort(_Backend, _Iterator __first, _Iterator __last, _Comp __comp); // TODO: Complete this list +Exception handling +================== + +PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their +implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned +into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the +frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user. */ template <class _ExecutionPolicy> diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backend.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backend.h index e54f331b94..6980ded189 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backend.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backend.h @@ -15,10 +15,11 @@ // _Functor takes a subrange for [__first, __last) that should be executed in serial template <class _RandomAccessIterator, class _Functor> - void __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func); + optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func); template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction> - _Tp __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction); + optional<_Tp> + __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction); // Cancel the execution of other jobs - they aren't needed anymore void __cancel_execution(); @@ -28,7 +29,7 @@ class _RandomAccessIterator3, class _Compare, class _LeafMerge> - void __parallel_merge( + optional<void> __parallel_merge( _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, @@ -44,6 +45,14 @@ _LeafSort __leaf_sort); TODO: Document the parallel backend + +Exception handling +================== + +CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their +implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned +into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the +frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user. */ #include <__algorithm/pstl_backends/cpu_backends/any_of.h> 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 c8a071af82..13dff80086 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 @@ -18,24 +18,30 @@ #include <__functional/operations.h> #include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> +#include <__utility/move.h> #include <__utility/pair.h> -#include <__utility/terminate_on_exception.h> #include <cstdint> +#include <optional> #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +_LIBCPP_PUSH_MACROS +# include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template <class _Index, class _Brick> -_LIBCPP_HIDE_FROM_ABI bool __parallel_or(_Index __first, _Index __last, _Brick __f) { +_LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) { std::atomic<bool> __found(false); - __par_backend::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) { + auto __ret = __par_backend::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) { if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) { __found.store(true, std::memory_order_relaxed); __par_backend::__cancel_execution(); } }); - return __found; + if (!__ret) + return nullopt; + return static_cast<bool>(__found); } // TODO: check whether __simd_first() can be used here @@ -64,17 +70,17 @@ _LIBCPP_HIDE_FROM_ABI bool __simd_or(_Index __first, _DifferenceType __n, _Pred } template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate> -_LIBCPP_HIDE_FROM_ABI bool +_LIBCPP_HIDE_FROM_ABI optional<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_or_concept<_ForwardIterator>::value) { - return std::__terminate_on_exception([&] { - return std::__parallel_or( - __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { - return std::__pstl_any_of<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, __brick_first, __brick_last, __pred); - }); - }); + return std::__parallel_or( + __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { + auto __res = std::__pstl_any_of<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, __brick_first, __brick_last, __pred); + _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); + return *std::move(__res); + }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__simd_or(__first, __last - __first, __pred); @@ -85,6 +91,8 @@ __pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __la _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H 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 8b531887c7..64babe9fd2 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 @@ -14,7 +14,8 @@ #include <__config> #include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> -#include <__utility/terminate_on_exception.h> +#include <__utility/empty.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -34,22 +35,23 @@ _LIBCPP_HIDE_FROM_ABI _Index __simd_fill_n(_Index __first, _DifferenceType __n, } template <class _ExecutionPolicy, class _ForwardIterator, class _Tp> -_LIBCPP_HIDE_FROM_ABI void +_LIBCPP_HIDE_FROM_ABI optional<__empty> __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_or_concept<_ForwardIterator>::value) { - std::__terminate_on_exception([&] { - __par_backend::__parallel_for( - __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { - std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, __brick_first, __brick_last, __value); - }); - }); + return __par_backend::__parallel_for( + __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { + [[maybe_unused]] auto __res = std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, __brick_first, __brick_last, __value); + _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); + }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { std::__simd_fill_n(__first, __last - __first, __value); + return __empty{}; } else { std::fill(__first, __last, __value); + return __empty{}; } } 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 91610c0408..170470e4fb 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 @@ -17,9 +17,10 @@ #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__type_traits/is_execution_policy.h> +#include <__utility/move.h> #include <__utility/pair.h> -#include <__utility/terminate_on_exception.h> #include <cstddef> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -27,31 +28,37 @@ #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +_LIBCPP_PUSH_MACROS +# include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template <class _Index, class _Brick, class _Compare> -_LIBCPP_HIDE_FROM_ABI _Index +_LIBCPP_HIDE_FROM_ABI optional<_Index> __parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool __b_first) { typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType; const _DifferenceType __n = __last - __first; _DifferenceType __initial_dist = __b_first ? __n : -1; std::atomic<_DifferenceType> __extremum(__initial_dist); // TODO: find out what is better here: parallel_for or parallel_reduce - __par_backend::__parallel_for(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) { - // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of - // why using a shared variable scales fairly well in this situation. - if (__comp(__i - __first, __extremum)) { - _Index __res = __f(__i, __j); - // If not '__last' returned then we found what we want so put this to extremum - if (__res != __j) { - const _DifferenceType __k = __res - __first; - for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) { - __extremum.compare_exchange_weak(__old, __k); + auto __res = + __par_backend::__parallel_for(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) { + // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of + // why using a shared variable scales fairly well in this situation. + if (__comp(__i - __first, __extremum)) { + _Index __result = __f(__i, __j); + // If not '__last' returned then we found what we want so put this to extremum + if (__result != __j) { + const _DifferenceType __k = __result - __first; + for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) { + __extremum.compare_exchange_weak(__old, __k); + } + } } - } - } - }); - return __extremum != __initial_dist ? __first + __extremum : __last; + }); + if (!__res) + return nullopt; + return __extremum.load() != __initial_dist ? __first + __extremum.load() : __last; } template <class _Index, class _DifferenceType, class _Compare> @@ -91,21 +98,21 @@ __simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Co } template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate> -_LIBCPP_HIDE_FROM_ABI _ForwardIterator +_LIBCPP_HIDE_FROM_ABI optional<_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_or_concept<_ForwardIterator>::value) { - return std::__terminate_on_exception([&] { - return std::__parallel_find( - __first, - __last, - [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { - return std::__pstl_find_if<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, __brick_first, __brick_last, __pred); - }, - less<>{}, - true); - }); + return std::__parallel_find( + __first, + __last, + [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { + auto __res = std::__pstl_find_if<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, __brick_first, __brick_last, __pred); + _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); + return *std::move(__res); + }, + less<>{}, + true); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { using __diff_t = __iter_diff_t<_ForwardIterator>; @@ -119,6 +126,8 @@ __pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __l _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H 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 f6f22fdd87..81fd4526b8 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 @@ -14,7 +14,8 @@ #include <__config> #include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> -#include <__utility/terminate_on_exception.h> +#include <__utility/empty.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -25,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Iterator, class _DifferenceType, class _Function> -_LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk_1(_Iterator __first, _DifferenceType __n, _Function __f) noexcept { +_LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk(_Iterator __first, _DifferenceType __n, _Function __f) noexcept { _PSTL_PRAGMA_SIMD for (_DifferenceType __i = 0; __i < __n; ++__i) __f(__first[__i]); @@ -34,22 +35,23 @@ _LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk_1(_Iterator __first, _DifferenceType } template <class _ExecutionPolicy, class _ForwardIterator, class _Functor> -_LIBCPP_HIDE_FROM_ABI void +_LIBCPP_HIDE_FROM_ABI optional<__empty> __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_or_concept<_ForwardIterator>::value) { - std::__terminate_on_exception([&] { - std::__par_backend::__parallel_for( - __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { - std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, __brick_first, __brick_last, __func); - }); - }); + return std::__par_backend::__parallel_for( + __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { + [[maybe_unused]] auto __res = std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, __brick_first, __brick_last, __func); + _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); + }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { - std::__simd_walk_1(__first, __last - __first, __func); + std::__simd_walk(__first, __last - __first, __func); + return __empty{}; } else { std::for_each(__first, __last, __func); + return __empty{}; } } 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 50b6e0b1d0..e885e7f225 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 @@ -23,11 +23,13 @@ #include <__memory/construct_at.h> #include <__memory/unique_ptr.h> #include <__numeric/reduce.h> +#include <__utility/empty.h> +#include <__utility/exception_guard.h> #include <__utility/move.h> #include <__utility/pair.h> -#include <__utility/terminate_on_exception.h> #include <cstddef> #include <new> +#include <optional> _LIBCPP_PUSH_MACROS #include <__undef_macros> @@ -61,8 +63,9 @@ struct __chunk_partitions { [[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept; template <class _RandomAccessIterator, class _Functor> -_LIBCPP_HIDE_FROM_ABI void +_LIBCPP_HIDE_FROM_ABI optional<__empty> __dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) { + // Perform the chunked execution. __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) { auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_; auto __index = @@ -71,10 +74,12 @@ __dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator _ : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_); __func(__first + __index, __first + __index + __this_chunk_size); }); + + return __empty{}; } template <class _RandomAccessIterator, class _Functor> -_LIBCPP_HIDE_FROM_ABI void +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) { return __libdispatch::__dispatch_parallel_for( __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func)); @@ -95,23 +100,23 @@ template <typename _RandomAccessIterator1, typename _RandomAccessIterator3, typename _Compare, typename _LeafMerge> -_LIBCPP_HIDE_FROM_ABI void __parallel_merge( +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge( _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _RandomAccessIterator3 __result, _Compare __comp, - _LeafMerge __leaf_merge) { + _LeafMerge __leaf_merge) noexcept { __chunk_partitions __partitions = __libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2)); if (__partitions.__chunk_count_ == 0) - return; + return __empty{}; if (__partitions.__chunk_count_ == 1) { __leaf_merge(__first1, __last1, __first2, __last2, __result, __comp); - return; + return __empty{}; } using __merge_range_t = __merge_range<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator3>; @@ -122,61 +127,76 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge( std::destroy_n(__ptr, __n_ranges); std::allocator<__merge_range_t>().deallocate(__ptr, __n_ranges); }; + unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges( - std::allocator<__merge_range_t>().allocate(__n_ranges), __destroy); + [&]() -> __merge_range_t* { +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + try { +# endif + return std::allocator<__merge_range_t>().allocate(__n_ranges); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + } catch (const std::bad_alloc&) { + return nullptr; + } +# endif + }(), + __destroy); + + if (!__ranges) + return nullopt; // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case - std::__terminate_on_exception([&] { - __merge_range_t* __r = __ranges.get(); - std::__construct_at(__r++, __first1, __first2, __result); - - bool __iterate_first_range = __last1 - __first1 > __last2 - __first2; - - auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t { - auto [__mid1, __mid2] = [&] { - if (__iterate_first_range) { - auto __m1 = __first1 + __chunk_size; - auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp); - return std::make_pair(__m1, __m2); - } else { - auto __m2 = __first2 + __chunk_size; - auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp); - return std::make_pair(__m1, __m2); - } - }(); + __merge_range_t* __r = __ranges.get(); + std::__construct_at(__r++, __first1, __first2, __result); - __result += (__mid1 - __first1) + (__mid2 - __first2); - __first1 = __mid1; - __first2 = __mid2; - return {std::move(__mid1), std::move(__mid2), __result}; - }; + bool __iterate_first_range = __last1 - __first1 > __last2 - __first2; - // handle first chunk - std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_)); - - // handle 2 -> N - 1 chunks - for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i) - std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_)); - - // handle last chunk - std::__construct_at(__r, __last1, __last2, __result); - - __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) { - auto __first_iters = __ranges[__index]; - auto __last_iters = __ranges[__index + 1]; - __leaf_merge( - __first_iters.__mid1_, - __last_iters.__mid1_, - __first_iters.__mid2_, - __last_iters.__mid2_, - __first_iters.__result_, - __comp); - }); + auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t { + auto [__mid1, __mid2] = [&] { + if (__iterate_first_range) { + auto __m1 = __first1 + __chunk_size; + auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp); + return std::make_pair(__m1, __m2); + } else { + auto __m2 = __first2 + __chunk_size; + auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp); + return std::make_pair(__m1, __m2); + } + }(); + + __result += (__mid1 - __first1) + (__mid2 - __first2); + __first1 = __mid1; + __first2 = __mid2; + return {std::move(__mid1), std::move(__mid2), __result}; + }; + + // handle first chunk + std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_)); + + // handle 2 -> N - 1 chunks + for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i) + std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_)); + + // handle last chunk + std::__construct_at(__r, __last1, __last2, __result); + + __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) { + auto __first_iters = __ranges[__index]; + auto __last_iters = __ranges[__index + 1]; + __leaf_merge( + __first_iters.__mid1_, + __last_iters.__mid1_, + __first_iters.__mid2_, + __last_iters.__mid2_, + __first_iters.__result_, + __comp); }); + + return __empty{}; } template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction> -_LIBCPP_HIDE_FROM_ABI _Value __parallel_transform_reduce( +_LIBCPP_HIDE_FROM_ABI optional<_Value> __parallel_transform_reduce( _RandomAccessIterator __first, _RandomAccessIterator __last, _Transform __transform, @@ -216,26 +236,26 @@ _LIBCPP_HIDE_FROM_ABI _Value __parallel_transform_reduce( } }); - return std::__terminate_on_exception([&] { - return std::reduce( - std::make_move_iterator(__values.get()), - std::make_move_iterator(__values.get() + __partitions.__chunk_count_), - std::move(__init), - __combiner); - }); + return std::reduce( + std::make_move_iterator(__values.get()), + std::make_move_iterator(__values.get() + __partitions.__chunk_count_), + std::move(__init), + __combiner); } template <class _RandomAccessIterator, class _Comp, class _LeafSort> -_LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort( +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort( _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) { const auto __size = __last - __first; auto __partitions = __libdispatch::__partition_chunks(__size); if (__partitions.__chunk_count_ == 0) - return; + return __empty{}; - if (__partitions.__chunk_count_ == 1) - return __leaf_sort(__first, __last, __comp); + if (__partitions.__chunk_count_ == 1) { + __leaf_sort(__first, __last, __comp); + return __empty{}; + } using _Value = __iter_value_type<_RandomAccessIterator>; @@ -247,70 +267,70 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort( // 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); - }); + // 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) - __merge_chunks(__values.get(), __first); + __inplace_merge_chunks(__values.get()); 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); + __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); + } + + return __empty{}; } _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 c4b28e9502..b0db70f58b 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 @@ -15,7 +15,7 @@ #include <__iterator/concepts.h> #include <__type_traits/is_execution_policy.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -23,6 +23,9 @@ #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +_LIBCPP_PUSH_MACROS +# include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template <class _ExecutionPolicy, @@ -30,7 +33,7 @@ template <class _ExecutionPolicy, class _ForwardIterator2, class _ForwardOutIterator, class _Comp> -_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge( +_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_merge( __cpu_backend_tag, _ForwardIterator1 __first1, _ForwardIterator1 __last1, @@ -42,31 +45,32 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge( __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, - __last1, - __first2, - __last2, - __result, - __comp, - [](_ForwardIterator1 __g_first1, - _ForwardIterator1 __g_last1, - _ForwardIterator2 __g_first2, - _ForwardIterator2 __g_last2, - _ForwardOutIterator __g_result, - _Comp __g_comp) { - return std::__pstl_merge<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, - std::move(__g_first1), - std::move(__g_last1), - std::move(__g_first2), - std::move(__g_last2), - std::move(__g_result), - std::move(__g_comp)); - }); - return __result + (__last1 - __first1) + (__last2 - __first2); - }); + auto __res = __par_backend::__parallel_merge( + __first1, + __last1, + __first2, + __last2, + __result, + __comp, + [](_ForwardIterator1 __g_first1, + _ForwardIterator1 __g_last1, + _ForwardIterator2 __g_first2, + _ForwardIterator2 __g_last2, + _ForwardOutIterator __g_result, + _Comp __g_comp) { + [[maybe_unused]] auto __g_res = std::__pstl_merge<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, + std::move(__g_first1), + std::move(__g_last1), + std::move(__g_first2), + std::move(__g_last2), + std::move(__g_result), + std::move(__g_comp)); + _LIBCPP_ASSERT_INTERNAL(__g_res, "unsed/sed should never try to allocate!"); + }); + if (!__res) + return nullopt; + return __result + (__last1 - __first1) + (__last2 - __first2); } else { return std::merge(__first1, __last1, __first2, __last2, __result, __comp); } @@ -74,6 +78,8 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_merge( _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h index f151c3b098..afcc7ffb26 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h @@ -11,8 +11,10 @@ #define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H #include <__config> +#include <__utility/empty.h> #include <__utility/move.h> #include <cstddef> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,26 +22,32 @@ #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +_LIBCPP_PUSH_MACROS +# include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD namespace __par_backend { inline namespace __serial_cpu_backend { template <class _RandomAccessIterator, class _Fp> -_LIBCPP_HIDE_FROM_ABI void __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { +_LIBCPP_HIDE_FROM_ABI optional<__empty> +__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { __f(__first, __last); + return __empty{}; } template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce> -_LIBCPP_HIDE_FROM_ABI _Tp +_LIBCPP_HIDE_FROM_ABI optional<_Tp> __parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) { return __reduce(std::move(__first), std::move(__last), std::move(__init)); } template <class _RandomAccessIterator, class _Compare, class _LeafSort> -_LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort( +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort( _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) { __leaf_sort(__first, __last, __comp); + return __empty{}; } _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {} @@ -49,7 +57,7 @@ template <class _RandomAccessIterator1, class _RandomAccessIterator3, class _Compare, class _LeafMerge> -_LIBCPP_HIDE_FROM_ABI void __parallel_merge( +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge( _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, @@ -58,6 +66,7 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge( _Compare __comp, _LeafMerge __leaf_merge) { __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp); + return __empty{}; } // TODO: Complete this list @@ -67,6 +76,8 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge( _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h index 0a701443b3..34c423586c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h @@ -13,7 +13,8 @@ #include <__algorithm/stable_sort.h> #include <__config> #include <__type_traits/is_execution_policy.h> -#include <__utility/terminate_on_exception.h> +#include <__utility/empty.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -24,17 +25,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp> -_LIBCPP_HIDE_FROM_ABI void +_LIBCPP_HIDE_FROM_ABI optional<__empty> __pstl_stable_sort(__cpu_backend_tag, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy>) { - std::__terminate_on_exception([&] { - __par_backend::__parallel_stable_sort( - __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) { - std::stable_sort(__g_first, __g_last, __g_comp); - }); - }); + return __par_backend::__parallel_stable_sort( + __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) { + std::stable_sort(__g_first, __g_last, __g_comp); + }); } else { std::stable_sort(__first, __last, __comp); + return __empty{}; } } diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h index 30eb0ae362..eb11a961b7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h @@ -11,8 +11,10 @@ #include <__assert> #include <__config> +#include <__utility/empty.h> #include <__utility/move.h> #include <cstddef> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -32,20 +34,23 @@ namespace __par_backend { inline namespace __thread_cpu_backend { template <class _RandomAccessIterator, class _Fp> -_LIBCPP_HIDE_FROM_ABI void __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { +_LIBCPP_HIDE_FROM_ABI optional<__empty> +__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) { __f(__first, __last); + return __empty{}; } template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce> -_LIBCPP_HIDE_FROM_ABI _Tp +_LIBCPP_HIDE_FROM_ABI optional<_Tp> __parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) { return __reduce(std::move(__first), std::move(__last), std::move(__init)); } template <class _RandomAccessIterator, class _Compare, class _LeafSort> -_LIBCPP_HIDE_FROM_ABI void __parallel_stable_sort( +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort( _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) { __leaf_sort(__first, __last, __comp); + return __empty{}; } _LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {} @@ -55,7 +60,7 @@ template <class _RandomAccessIterator1, class _RandomAccessIterator3, class _Compare, class _LeafMerge> -_LIBCPP_HIDE_FROM_ABI void __parallel_merge( +_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge( _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, @@ -64,6 +69,7 @@ _LIBCPP_HIDE_FROM_ABI void __parallel_merge( _Compare __comp, _LeafMerge __leaf_merge) { __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp); + return __empty{}; } } // namespace __thread_cpu_backend 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 0259d8a84b..fdf1a2e78d 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 @@ -17,7 +17,7 @@ #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -25,11 +25,14 @@ #if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 +_LIBCPP_PUSH_MACROS +# include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Function> _LIBCPP_HIDE_FROM_ABI _Iterator2 -__simd_walk_2(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept { +__simd_walk(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept { _PSTL_PRAGMA_SIMD for (_DifferenceType __i = 0; __i < __n; ++__i) __f(__first1[__i], __first2[__i]); @@ -37,7 +40,7 @@ __simd_walk_2(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Fu } template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation> -_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( +_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform( __cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, @@ -46,18 +49,18 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && __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) { - return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op); - }); - }); + std::__par_backend::__parallel_for( + __first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) { + auto __res = std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op); + _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); + return *std::move(__res); + }); return __result + (__last - __first); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value && __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) { - return std::__simd_walk_2( + return std::__simd_walk( __first, __last - __first, __result, @@ -70,7 +73,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( } template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Iterator3, class _Function> -_LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_walk_3( +_LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_walk( _Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3, _Function __f) noexcept { _PSTL_PRAGMA_SIMD for (_DifferenceType __i = 0; __i < __n; ++__i) @@ -83,7 +86,7 @@ template <class _ExecutionPolicy, class _ForwardOutIterator, class _BinaryOperation, enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( +_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform( __cpu_backend_tag, _ForwardIterator1 __first1, _ForwardIterator1 __last1, @@ -94,26 +97,26 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( __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, - __last1, - [__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) { - return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, - __brick_first, - __brick_last, - __first2 + (__brick_first - __first1), - __result + (__brick_first - __first1), - __op); - }); - }); + auto __res = std::__par_backend::__parallel_for( + __first1, + __last1, + [__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) { + return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, + __brick_first, + __brick_last, + __first2 + (__brick_first - __first1), + __result + (__brick_first - __first1), + __op); + }); + if (!__res) + return nullopt; return __result + (__last1 - __first1); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __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( + return std::__simd_walk( __first1, __last1 - __first1, __first2, @@ -128,6 +131,8 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator __pstl_transform( _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 #endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H 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 2afe5c7d10..a5ca9c89d1 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 @@ -18,8 +18,8 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/operation_traits.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> #include <new> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -98,7 +98,7 @@ template <class _ExecutionPolicy, class _Tp, class _BinaryOperation1, class _BinaryOperation2> -_LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( +_LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce( __cpu_backend_tag, _ForwardIterator1 __first1, _ForwardIterator1 __last1, @@ -109,27 +109,25 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && __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, - std::move(__last1), - [__first1, __first2, __transform](_ForwardIterator1 __iter) { - return __transform(*__iter, *(__first2 + (__iter - __first1))); - }, - std::move(__init), - std::move(__reduce), - [__first1, __first2, __reduce, __transform]( - _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) { - return std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, - __brick_first, - std::move(__brick_last), - __first2 + (__brick_first - __first1), - std::move(__brick_init), - std::move(__reduce), - std::move(__transform)); - }); - }); + return __par_backend::__parallel_transform_reduce( + __first1, + std::move(__last1), + [__first1, __first2, __transform](_ForwardIterator1 __iter) { + return __transform(*__iter, *(__first2 + (__iter - __first1))); + }, + std::move(__init), + std::move(__reduce), + [__first1, __first2, __reduce, __transform]( + _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) { + return *std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, + __brick_first, + std::move(__brick_last), + __first2 + (__brick_first - __first1), + std::move(__brick_init), + std::move(__reduce), + std::move(__transform)); + }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value && __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) { @@ -149,7 +147,7 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( } template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation> -_LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( +_LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce( __cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, @@ -158,23 +156,23 @@ _LIBCPP_HIDE_FROM_ABI _Tp __pstl_transform_reduce( _UnaryOperation __transform) { if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { - return std::__terminate_on_exception([&] { - return __par_backend::__parallel_transform_reduce( - std::move(__first), - std::move(__last), - [__transform](_ForwardIterator __iter) { return __transform(*__iter); }, - std::move(__init), - __reduce, - [__transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) { - return std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( - __cpu_backend_tag{}, - std::move(__brick_first), - std::move(__brick_last), - std::move(__brick_init), - std::move(__reduce), - std::move(__transform)); - }); - }); + return __par_backend::__parallel_transform_reduce( + std::move(__first), + std::move(__last), + [__transform](_ForwardIterator __iter) { return __transform(*__iter); }, + std::move(__init), + __reduce, + [__transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) { + auto __res = std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>( + __cpu_backend_tag{}, + std::move(__brick_first), + std::move(__brick_last), + std::move(__brick_init), + std::move(__reduce), + std::move(__transform)); + _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!"); + return *std::move(__res); + }); } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> && __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) { return std::__simd_transform_reduce( diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h index e4a6e5a54e..19f275a0d5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_copy.h @@ -22,6 +22,7 @@ #include <__type_traits/is_trivially_copyable.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -41,18 +42,34 @@ template <class _ExecutionPolicy, class _ForwardOutIterator, 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) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> +__copy(_ExecutionPolicy&& __policy, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _ForwardOutIterator&& __result) noexcept { 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()); + return std::__transform(__policy, __g_first, __g_last, __g_result, __identity()); }, std::move(__first), std::move(__last), std::move(__result)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _ForwardOutIterator, + 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) { + auto __res = std::__copy(__policy, std::move(__first), std::move(__last), std::move(__result)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + template <class> void __pstl_copy_n(); @@ -62,21 +79,36 @@ template <class _ExecutionPolicy, class _Size, 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) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __copy_n( + _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _ForwardOutIterator&& __result) noexcept { return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy_n, _RawPolicy), - [&__policy](_ForwardIterator __g_first, _Size __g_n, _ForwardOutIterator __g_result) { + [&__policy]( + _ForwardIterator __g_first, _Size __g_n, _ForwardOutIterator __g_result) -> optional<_ForwardIterator> { if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) - return std::copy(__policy, __g_first, __g_first + __g_n, __g_result); + return std::__copy(__policy, std::move(__g_first), std::move(__g_first + __g_n), std::move(__g_result)); else return std::copy_n(__g_first, __g_n, __g_result); }, std::move(__first), - __n, + std::move(__n), std::move(__result)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _ForwardOutIterator, + class _Size, + 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) { + auto __res = std::__copy_n(__policy, std::move(__first), std::move(__n), std::move(__result)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h index cc1e824570..28806fca06 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_count.h @@ -23,7 +23,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -41,13 +41,13 @@ template <class _ExecutionPolicy, class _Predicate, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> -count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> __count_if( + _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept { using __diff_t = __iter_diff_t<_ForwardIterator>; return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if, _RawPolicy), - [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { - return std::transform_reduce( + [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<__diff_t> { + return std::__transform_reduce( __policy, std::move(__g_first), std::move(__g_last), @@ -60,6 +60,19 @@ count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Predicate, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> +count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { + auto __res = std::__count_if(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + template <class> void __pstl_count(); // declaration needed for the frontend dispatch below @@ -68,11 +81,12 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> -count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__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, _RawPolicy), - [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) { + [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) + -> optional<__iter_diff_t<_ForwardIterator>> { return std::count_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __v) { return __v == __g_value; }); @@ -82,6 +96,19 @@ count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __ __value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator> +count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { + auto __res = std::__count(__policy, std::move(__first), std::move(__last), __value); + if (!__res) + std::__throw_bad_alloc(); + return *__res; +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h index fc817b5c9e..3057dcc04f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_fill.h @@ -20,7 +20,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -38,13 +38,13 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { +_LIBCPP_HIDE_FROM_ABI optional<__empty> +__fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); - std::__pstl_frontend_dispatch( + return std::__pstl_frontend_dispatch( _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) { + return std::__for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) { __element = __g_value; }); }, @@ -53,6 +53,18 @@ fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __l __value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + if (!std::__fill(__policy, std::move(__first), std::move(__last), __value)) + std::__throw_bad_alloc(); +} + template <class> void __pstl_fill_n(); // declaration needed for the frontend dispatch below @@ -62,22 +74,36 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__fill_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _SizeT&& __n, const _Tp& __value) noexcept { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); - std::__pstl_frontend_dispatch( + return std::__pstl_frontend_dispatch( _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_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); + return optional<__empty>{__empty{}}; }, std::move(__first), - __n, + std::move(__n), __value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _SizeT, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + if (!std::__fill_n(__policy, std::move(__first), std::move(__n), __value)) + std::__throw_bad_alloc(); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h index c2894d0875..adc05ea1a9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_find.h @@ -19,7 +19,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -34,13 +34,26 @@ template <class _ExecutionPolicy, class _Predicate, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _ForwardIterator -find_if(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>> +__find_if(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept { using _Backend = typename __select_backend<_RawPolicy>::type; return std::__pstl_find_if<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Predicate, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _ForwardIterator +find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__find_if(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + template <class> void __pstl_find_if_not(); @@ -49,21 +62,36 @@ template <class _ExecutionPolicy, class _Predicate, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _ForwardIterator -find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>> +__find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) { return std::__pstl_frontend_dispatch( _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); - }); + [&](_ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Predicate&& __g_pred) + -> optional<__remove_cvref_t<_ForwardIterator>> { + return std::__find_if( + __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __value) { + return !__g_pred(__value); + }); }, std::move(__first), std::move(__last), std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Predicate, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _ForwardIterator +find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__find_if_not(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + template <class> void __pstl_find(); @@ -72,21 +100,35 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _ForwardIterator -find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>> +__find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept { return std::__pstl_frontend_dispatch( _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; - }); + [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) -> optional<_ForwardIterator> { + return std::find_if( + __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __element) { + return __element == __g_value; + }); }, std::move(__first), std::move(__last), __value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _ForwardIterator +find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__find(__policy, std::move(__first), std::move(__last), __value); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 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 6e6c73d19f..819a43d685 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_for_each.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_for_each.h @@ -20,8 +20,9 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__type_traits/void_t.h> +#include <__utility/empty.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -36,11 +37,22 @@ template <class _ExecutionPolicy, class _Function, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__for_each(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Function&& __func) noexcept { + using _Backend = typename __select_backend<_RawPolicy>::type; + return std::__pstl_for_each<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__func)); +} + +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Function, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI void -for_each(_ExecutionPolicy&&, _ForwardIterator __first, _ForwardIterator __last, _Function __func) { +for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); - using _Backend = typename __select_backend<_RawPolicy>::type; - std::__pstl_for_each<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__func)); + if (!std::__for_each(__policy, std::move(__first), std::move(__last), std::move(__func))) + std::__throw_bad_alloc(); } template <class> @@ -52,23 +64,38 @@ template <class _ExecutionPolicy, class _Function, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) { - _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __size, _Function&& __func) noexcept { return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n, _RawPolicy), - [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) { + [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) -> optional<__empty> { 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)); + return __empty{}; } else { std::for_each_n(std::move(__g_first), __g_size, std::move(__g_func)); + return __empty{}; } }, - __first, - __size, + std::move(__first), + std::move(__size), std::move(__func)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Size, + class _Function, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + auto __res = std::__for_each_n(__policy, std::move(__first), std::move(__size), std::move(__func)); + if (!__res) + std::__throw_bad_alloc(); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h index 9a70e2e26b..56538392d5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_generate.h @@ -19,6 +19,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -36,13 +37,13 @@ template <class _ExecutionPolicy, class _Generator, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__generate(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Generator&& __gen) { _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); - std::__pstl_frontend_dispatch( + return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Generator __g_gen) { - std::for_each( + return std::__for_each( __policy, std::move(__g_first), std::move(__g_last), [&](__iter_reference<_ForwardIterator> __element) { __element = __g_gen(); }); @@ -52,6 +53,18 @@ generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator std::move(__gen)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Generator, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + if (!std::__generate(__policy, std::move(__first), std::move(__last), std::move(__gen))) + std::__throw_bad_alloc(); +} + template <class> void __pstl_generate_n(); @@ -61,21 +74,34 @@ template <class _ExecutionPolicy, class _Generator, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_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( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__generate_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _Generator&& __gen) { + return std::__pstl_frontend_dispatch( _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(); - }); + return std::__for_each_n( + __policy, std::move(__g_first), std::move(__g_n), [&](__iter_reference<_ForwardIterator> __element) { + __element = __g_gen(); + }); }, std::move(__first), __n, std::move(__gen)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Size, + class _Generator, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) { + _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); + if (!std::__generate_n(__policy, std::move(__first), std::move(__n), std::move(__gen))) + std::__throw_bad_alloc(); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 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 1492ce2127..39cf636933 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_is_partitioned.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_is_partitioned.h @@ -18,6 +18,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -35,8 +36,8 @@ template <class _ExecutionPolicy, class _Predicate, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool -is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __is_partitioned( + _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) { return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) { @@ -51,6 +52,19 @@ is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIt std::move(__pred)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Predicate, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool +is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) { + auto __res = std::__is_partitioned(__policy, std::move(__first), std::move(__last), std::move(__pred)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h index f10ac76742..ed80145108 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_merge.h @@ -16,6 +16,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -32,23 +33,51 @@ template <class _ExecutionPolicy, class _Comp = std::less<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> +__merge(_ExecutionPolicy&&, + _ForwardIterator1 __first1, + _ForwardIterator1 __last1, + _ForwardIterator2 __first2, + _ForwardIterator2 __last2, + _ForwardOutIterator __result, + _Comp __comp = {}) noexcept { + using _Backend = typename __select_backend<_RawPolicy>::type; + return std::__pstl_merge<_RawPolicy>( + _Backend{}, + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__last2), + std::move(__result), + std::move(__comp)); +} + +template <class _ExecutionPolicy, + class _ForwardIterator1, + class _ForwardIterator2, + class _ForwardOutIterator, + class _Comp = std::less<>, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator -merge(_ExecutionPolicy&&, +merge(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, _ForwardOutIterator __result, _Comp __comp = {}) { - using _Backend = typename __select_backend<_RawPolicy>::type; - return std::__pstl_merge<_RawPolicy>( - _Backend{}, + auto __res = std::__merge( + __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::move(__result), std::move(__comp)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h index 08f59ce2de..05dee3f6a4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_replace.h @@ -18,6 +18,7 @@ #include <__type_traits/enable_if.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -36,19 +37,21 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -replace_if(_ExecutionPolicy&& __policy, - _ForwardIterator __first, - _ForwardIterator __last, - _Pred __pred, - const _Tp& __new_value) { - std::__pstl_frontend_dispatch( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__replace_if(_ExecutionPolicy&& __policy, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _Pred&& __pred, + const _Tp& __new_value) noexcept { + return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if, _RawPolicy), - [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred, const _Tp& __g_new_value) { + [&__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)) __element = __g_new_value; }); + return optional<__empty>{__empty{}}; }, std::move(__first), std::move(__last), @@ -56,6 +59,23 @@ replace_if(_ExecutionPolicy&& __policy, __new_value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Pred, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +replace_if(_ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + _Pred __pred, + const _Tp& __new_value) { + auto __res = std::__replace_if(__policy, std::move(__first), std::move(__last), std::move(__pred), __new_value); + if (!__res) + std::__throw_bad_alloc(); +} + template <class> void __pstl_replace(); @@ -64,17 +84,17 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -replace(_ExecutionPolicy&& __policy, - _ForwardIterator __first, - _ForwardIterator __last, - const _Tp& __old_value, - const _Tp& __new_value) { - std::__pstl_frontend_dispatch( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> +__replace(_ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + const _Tp& __old_value, + const _Tp& __new_value) noexcept { + return std::__pstl_frontend_dispatch( _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( + return std::__replace_if( __policy, std::move(__g_first), std::move(__g_last), @@ -87,6 +107,21 @@ replace(_ExecutionPolicy&& __policy, __new_value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +replace(_ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + const _Tp& __old_value, + const _Tp& __new_value) { + if (!std::__replace(__policy, std::move(__first), std::move(__last), __old_value, __new_value)) + std::__throw_bad_alloc(); +} + template <class> void __pstl_replace_copy_if(); @@ -97,23 +132,26 @@ template <class _ExecutionPolicy, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void replace_copy_if( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy_if( _ExecutionPolicy&& __policy, - _ForwardIterator __first, - _ForwardIterator __last, - _ForwardOutIterator __result, - _Pred __pred, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _ForwardOutIterator&& __result, + _Pred&& __pred, const _Tp& __new_value) { - std::__pstl_frontend_dispatch( + return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result, _Pred __g_pred, - const _Tp& __g_new_value) { - std::transform(__policy, __g_first, __g_last, __g_result, [&](__iter_reference<_ForwardIterator> __element) { - return __g_pred(__element) ? __g_new_value : __element; - }); + const _Tp& __g_new_value) -> optional<__empty> { + if (!std::__transform( + __policy, __g_first, __g_last, __g_result, [&](__iter_reference<_ForwardIterator> __element) { + return __g_pred(__element) ? __g_new_value : __element; + })) + return nullopt; + return __empty{}; }, std::move(__first), std::move(__last), @@ -122,30 +160,49 @@ _LIBCPP_HIDE_FROM_ABI void replace_copy_if( __new_value); } -template <class> -void __pstl_replace_copy(); - template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, + class _Pred, class _Tp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void replace_copy( +_LIBCPP_HIDE_FROM_ABI void replace_copy_if( _ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result, - const _Tp& __old_value, + _Pred __pred, const _Tp& __new_value) { - std::__pstl_frontend_dispatch( + if (!std::__replace_copy_if( + __policy, std::move(__first), std::move(__last), std::move(__result), std::move(__pred), __new_value)) + std::__throw_bad_alloc(); +} + +template <class> +void __pstl_replace_copy(); + +template <class _ExecutionPolicy, + class _ForwardIterator, + class _ForwardOutIterator, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy( + _ExecutionPolicy&& __policy, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _ForwardOutIterator&& __result, + const _Tp& __old_value, + const _Tp& __new_value) noexcept { + return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result, const _Tp& __g_old_value, const _Tp& __g_new_value) { - return std::replace_copy_if( + return std::__replace_copy_if( __policy, std::move(__g_first), std::move(__g_last), @@ -160,6 +217,24 @@ _LIBCPP_HIDE_FROM_ABI void replace_copy( __new_value); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _ForwardOutIterator, + class _Tp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void replace_copy( + _ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + _ForwardOutIterator __result, + const _Tp& __old_value, + const _Tp& __new_value) { + if (!std::__replace_copy( + __policy, std::move(__first), std::move(__last), std::move(__result), __old_value, __new_value)) + std::__throw_bad_alloc(); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h index 85239df0ab..3e71e0aa5a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_sort.h @@ -16,8 +16,10 @@ #include <__functional/operations.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> +#include <__utility/empty.h> #include <__utility/forward.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -35,12 +37,13 @@ template <class _ExecutionPolicy, class _Comp, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { - std::__pstl_frontend_dispatch( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __sort( + _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) noexcept { + return std::__pstl_frontend_dispatch( _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)); + return optional<__empty>{__empty{}}; }, std::move(__first), std::move(__last), @@ -49,6 +52,17 @@ sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIt template <class _ExecutionPolicy, class _RandomAccessIterator, + class _Comp, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void +sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) { + if (!std::__sort(__policy, std::move(__first), std::move(__last), std::move(__comp))) + std::__throw_bad_alloc(); +} + +template <class _ExecutionPolicy, + class _RandomAccessIterator, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI void diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_stable_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_stable_sort.h index 510ffd8629..c9d375535f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_stable_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_stable_sort.h @@ -15,7 +15,9 @@ #include <__type_traits/enable_if.h> #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> +#include <__utility/empty.h> #include <__utility/move.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -30,10 +32,21 @@ template <class _ExecutionPolicy, class _Comp = less<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI void -stable_sort(_ExecutionPolicy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp = {}) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __stable_sort( + _ExecutionPolicy&&, _RandomAccessIterator&& __first, _RandomAccessIterator&& __last, _Comp&& __comp = {}) noexcept { using _Backend = typename __select_backend<_RawPolicy>::type; - std::__pstl_stable_sort<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__comp)); + return std::__pstl_stable_sort<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__comp)); +} + +template <class _ExecutionPolicy, + class _RandomAccessIterator, + class _Comp = less<>, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI void stable_sort( + _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp = {}) { + if (!std::__stable_sort(__policy, std::move(__first), std::move(__last), std::move(__comp))) + std::__throw_bad_alloc(); } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h index a34439304a..aad59d1f30 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/pstl_transform.h @@ -16,7 +16,7 @@ #include <__type_traits/is_execution_policy.h> #include <__type_traits/remove_cvref.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -32,8 +32,25 @@ template <class _ExecutionPolicy, class _UnaryOperation, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>> +__transform(_ExecutionPolicy&&, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _ForwardOutIterator&& __result, + _UnaryOperation&& __op) noexcept { + using _Backend = typename __select_backend<_RawPolicy>::type; + return std::__pstl_transform<_RawPolicy>( + _Backend{}, std::move(__first), std::move(__last), std::move(__result), std::move(__op)); +} + +template <class _ExecutionPolicy, + class _ForwardIterator, + class _ForwardOutIterator, + class _UnaryOperation, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( - _ExecutionPolicy&&, + _ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result, @@ -41,9 +58,29 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator); _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator); _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first))); + auto __res = std::__transform(__policy, std::move(__first), std::move(__last), std::move(__result), std::move(__op)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + +template <class _ExecutionPolicy, + class _ForwardIterator1, + class _ForwardIterator2, + class _ForwardOutIterator, + class _BinaryOperation, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>> +__transform(_ExecutionPolicy&&, + _ForwardIterator1&& __first1, + _ForwardIterator1&& __last1, + _ForwardIterator2&& __first2, + _ForwardOutIterator&& __result, + _BinaryOperation&& __op) noexcept { using _Backend = typename __select_backend<_RawPolicy>::type; return std::__pstl_transform<_RawPolicy>( - _Backend{}, std::move(__first), std::move(__last), std::move(__result), std::move(__op)); + _Backend{}, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op)); } template <class _ExecutionPolicy, @@ -54,7 +91,7 @@ template <class _ExecutionPolicy, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( - _ExecutionPolicy&&, + _ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, @@ -64,9 +101,11 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform( _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2); _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator); _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first1, *__first2))); - using _Backend = typename __select_backend<_RawPolicy>::type; - return std::__pstl_transform<_RawPolicy>( - _Backend{}, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op)); + auto __res = std::__transform( + __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h index 82f5456756..4c8f1b2cbe 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h @@ -9,7 +9,8 @@ #ifndef _LIBCPP___ALGORITHM_RANGES_COUNT_H #define _LIBCPP___ALGORITHM_RANGES_COUNT_H -#include <__algorithm/ranges_count_if.h> +#include <__algorithm/count.h> +#include <__algorithm/iterator_operations.h> #include <__config> #include <__functional/identity.h> #include <__functional/ranges_operations.h> @@ -36,16 +37,14 @@ struct __fn { requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const { - auto __pred = [&](auto&& __e) { return __e == __value; }; - return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj); + return std::__count<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __proj); } template <input_range _Range, class _Type, class _Proj = identity> requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*> _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range> operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const { - auto __pred = [&](auto&& __e) { return __e == __value; }; - return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj); + return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj); } }; } // namespace __count diff --git a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h index 87100ba5d8..775d06d757 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h +++ b/contrib/libs/cxxsupp/libcxx/include/__atomic/atomic_base.h @@ -39,7 +39,7 @@ struct __atomic_base // false _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT - {return __cxx_atomic_is_lock_free(sizeof(_Tp));} + {return __cxx_atomic_is_lock_free(sizeof(__cxx_atomic_impl<_Tp>));} _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const _NOEXCEPT {return static_cast<__atomic_base const volatile*>(this)->is_lock_free();} diff --git a/contrib/libs/cxxsupp/libcxx/include/__availability b/contrib/libs/cxxsupp/libcxx/include/__availability index 579698ec1e..a6367945ed 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__availability +++ b/contrib/libs/cxxsupp/libcxx/include/__availability @@ -179,6 +179,17 @@ // # define _LIBCPP_AVAILABILITY_HAS_NO_TZDB # define _LIBCPP_AVAILABILITY_TZDB +// Enable additional explicit instantiations of iostreams components. This +// reduces the number of weak definitions generated in programs that use +// iostreams by providing a single strong definition in the shared library. +// +// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation, +// or once libc++ doesn't use the attribute anymore. +// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed. +#if defined(_LIBCPP_COMPILER_GCC) || defined(_WIN32) +# define _LIBCPP_AVAILABILITY_HAS_NO_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 +#endif + #elif defined(__APPLE__) // shared_mutex and shared_timed_mutex @@ -356,6 +367,12 @@ # define _LIBCPP_AVAILABILITY_HAS_NO_TZDB # define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable)) +# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120000) || \ + (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \ + (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000) || \ + (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000) +# define _LIBCPP_AVAILABILITY_HAS_NO_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 +# endif #else // ...New vendors can add availability markup here... diff --git a/contrib/libs/cxxsupp/libcxx/include/__bit_reference b/contrib/libs/cxxsupp/libcxx/include/__bit_reference index 107368759c..9032b8f018 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__bit_reference +++ b/contrib/libs/cxxsupp/libcxx/include/__bit_reference @@ -171,45 +171,6 @@ private: __bit_const_reference& operator=(const __bit_const_reference&) = delete; }; -// count - -template <bool _ToCount, class _Cp, bool _IsConst> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename __bit_iterator<_Cp, _IsConst>::difference_type -__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_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 <bool _FillValue, class _Cp> @@ -1092,7 +1053,7 @@ private: _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 + friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type); }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__concepts/swappable.h b/contrib/libs/cxxsupp/libcxx/include/__concepts/swappable.h index c1969de345..cdffe34205 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__concepts/swappable.h +++ b/contrib/libs/cxxsupp/libcxx/include/__concepts/swappable.h @@ -92,7 +92,7 @@ struct __fn { // 2.3 Otherwise, if `E1` and `E2` are lvalues of the same type `T` that models... template <__exchangeable _Tp> _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Tp& __x, _Tp& __y) const - noexcept(is_nothrow_move_constructible_v<_Tp>&& is_nothrow_move_assignable_v<_Tp>) { + noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_assignable_v<_Tp>) { __y = _VSTD::exchange(__x, _VSTD::move(__y)); } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config index f804928a6a..4856162769 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config +++ b/contrib/libs/cxxsupp/libcxx/include/__config @@ -194,6 +194,11 @@ // The implementation moved to the header, but we still export the symbols from // the dylib for backwards compatibility. # define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10 +// Save memory by providing the allocator more freedom to allocate the most +// efficient size class by dropping the alignment requirements for std::string's +// pointer from 16 to 8. This changes the output of std::string::max_size, +// which makes it ABI breaking +# define _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT # elif _LIBCPP_ABI_VERSION == 1 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) // Enable compiling copies of now inline methods into the dylib to support @@ -220,11 +225,6 @@ # endif # if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2 -// Enable additional explicit instantiations of iostreams components. This -// reduces the number of weak definitions generated in programs that use -// iostreams by providing a single strong definition in the shared library. -# define _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 - // Define a key function for `bad_function_call` in the library, to centralize // its vtable and typeinfo to libc++ rather than having all other libraries // using that class define their own copies. @@ -246,11 +246,10 @@ // HARDENING { -// TODO(hardening): remove this in LLVM 19. +// TODO(hardening): deprecate 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 diff --git a/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h b/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h index 3f468fc63b..3f25e00859 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h +++ b/contrib/libs/cxxsupp/libcxx/include/__expected/expected.h @@ -119,9 +119,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr expected() noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened requires is_default_constructible_v<_Tp> - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_)); - } + : __union_(std::in_place), __has_val_(true) {} _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete; @@ -136,14 +134,7 @@ public: noexcept(is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Err>) // strengthened requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> && !(is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_constructible_v<_Err>)) - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); - } else { - std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); - } - } - + : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) { } _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> @@ -154,13 +145,7 @@ public: noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_constructible_v<_Err>) requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> && !(is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>)) - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); - } else { - std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); - } - } + : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) { } private: template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual> @@ -200,26 +185,14 @@ public: expected(const expected<_Up, _OtherErr>& __other) noexcept(is_nothrow_constructible_v<_Tp, const _Up&> && is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); - } else { - std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); - } - } + : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) {} template <class _Up, class _OtherErr> requires __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp> || !is_convertible_v<_OtherErr, _Err>) expected(expected<_Up, _OtherErr>&& __other) noexcept(is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(__other.__has_val_) { - if (__has_val_) { - std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); - } else { - std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); - } - } + : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) {} template <class _Up = _Tp> requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> && @@ -227,61 +200,47 @@ public: (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_expected<remove_cvref_t<_Up>>::value)) _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>) expected(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_), std::forward<_Up>(__u)); - } + : __union_(std::in_place, std::forward<_Up>(__u)), __has_val_(true) {} template <class _OtherErr> requires is_constructible_v<_Err, const _OtherErr&> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) expected(const unexpected<_OtherErr>& __unex) noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __unex.error()); - } + : __union_(std::unexpect, __unex.error()), __has_val_(false) {} template <class _OtherErr> requires is_constructible_v<_Err, _OtherErr> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) expected(unexpected<_OtherErr>&& __unex) noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); - } + : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} template <class... _Args> requires is_constructible_v<_Tp, _Args...> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, _Args...>) // strengthened - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); - } + : __union_(std::in_place, std::forward<_Args>(__args)...), __has_val_(true) {} template <class _Up, class... _Args> requires is_constructible_v< _Tp, initializer_list<_Up>&, _Args... > _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) // strengthened - : __has_val_(true) { - std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); - } + : __union_(std::in_place, __il, std::forward<_Args>(__args)...), __has_val_(true) {} template <class... _Args> requires is_constructible_v<_Err, _Args...> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) - noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); - } + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened + : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} template <class _Up, class... _Args> requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); - } + : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} // [expected.object.dtor], destructor @@ -440,9 +399,10 @@ public: std::destroy_at(std::addressof(__union_.__val_)); } else { std::destroy_at(std::addressof(__union_.__unex_)); - __has_val_ = true; } - return *std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); + std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); + __has_val_ = true; + return __union_.__val_; } template <class _Up, class... _Args> @@ -452,9 +412,10 @@ public: std::destroy_at(std::addressof(__union_.__val_)); } else { std::destroy_at(std::addressof(__union_.__unex_)); - __has_val_ = true; } - return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); + std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); + __has_val_ = true; + return __union_.__val_; } @@ -893,11 +854,15 @@ public: } private: - struct __empty_t {}; - template <class _ValueType, class _ErrorType> union __union_t { - _LIBCPP_HIDE_FROM_ABI constexpr __union_t() {} + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) + : __val_(std::forward<_Args>(__args)...) {} + + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( @@ -909,6 +874,14 @@ private: std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) = default; @@ -927,10 +900,17 @@ private: template <class _ValueType, class _ErrorType> requires(is_trivially_move_constructible_v<_ValueType> && is_trivially_move_constructible_v<_ErrorType>) union __union_t<_ValueType, _ErrorType> { - _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) + : __val_(std::forward<_Args>(__args)...) {} + + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} + template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( std::__expected_construct_in_place_from_invoke_tag, _Func&& __f, _Args&&... __args) @@ -941,6 +921,14 @@ private: std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) = default; @@ -950,7 +938,6 @@ private: requires(!is_trivially_destructible_v<_ValueType> || !is_trivially_destructible_v<_ErrorType>) {} - _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_; _LIBCPP_NO_UNIQUE_ADDRESS _ValueType __val_; _LIBCPP_NO_UNIQUE_ADDRESS _ErrorType __unex_; }; @@ -998,11 +985,7 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __rhs) noexcept(is_nothrow_copy_constructible_v<_Err>) // strengthened requires(is_copy_constructible_v<_Err> && !is_trivially_copy_constructible_v<_Err>) - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); - } - } + : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) requires(is_move_constructible_v<_Err> && is_trivially_move_constructible_v<_Err>) @@ -1011,51 +994,35 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __rhs) noexcept(is_nothrow_move_constructible_v<_Err>) requires(is_move_constructible_v<_Err> && !is_trivially_move_constructible_v<_Err>) - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); - } - } + : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} template <class _Up, class _OtherErr> requires __can_convert<_Up, _OtherErr, const _OtherErr&>::value _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) expected(const expected<_Up, _OtherErr>& __rhs) noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); - } - } + : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} template <class _Up, class _OtherErr> requires __can_convert<_Up, _OtherErr, _OtherErr>::value _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) expected(expected<_Up, _OtherErr>&& __rhs) noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(__rhs.__has_val_) { - if (!__rhs.__has_val_) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); - } - } + : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} template <class _OtherErr> requires is_constructible_v<_Err, const _OtherErr&> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) expected(const unexpected<_OtherErr>& __unex) noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __unex.error()); - } + : __union_(std::unexpect, __unex.error()), __has_val_(false) {} template <class _OtherErr> requires is_constructible_v<_Err, _OtherErr> _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) expected(unexpected<_OtherErr>&& __unex) noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); - } + : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t) noexcept : __has_val_(true) {} @@ -1063,17 +1030,13 @@ public: requires is_constructible_v<_Err, _Args...> _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); - } + : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} template <class _Up, class... _Args> requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened - : __has_val_(false) { - std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); - } + : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} private: template <class _Func> @@ -1507,11 +1470,23 @@ private: union __union_t { _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} + template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__empty_)); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ErrorType>) = default; @@ -1534,11 +1509,23 @@ private: _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + template <class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) + : __unex_(std::forward<_Args>(__args)...) {} + template <class _Func, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + template <class _Union> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { + if (__has_val) + std::construct_at(std::addressof(__empty_)); + else + std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); + } + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() requires(is_trivially_destructible_v<_ErrorType>) = default; diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h index 60969e1751..c1241da5d1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/reverse_iterator.h @@ -144,7 +144,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator*() const {_Iter __tmp = current; return *--__tmp;} -#if (_LIBCPP_STD_VER >= 20) && !defined(__NVCC__) +#if (_LIBCPP_STD_VER >= 20) && !defined(__CUDACC__) _LIBCPP_INLINE_VISIBILITY constexpr pointer operator->() const requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h b/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h index a510220d40..f6bcd940ee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h +++ b/contrib/libs/cxxsupp/libcxx/include/__mdspan/extents.h @@ -456,7 +456,7 @@ using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::t // Deduction guide for extents template <class... _IndexTypes> -extents(_IndexTypes...) -> extents<size_t, size_t((_IndexTypes(), dynamic_extent))...>; +extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>; namespace __mdspan_detail { diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h index a2e4f6e26f..71ae5bcd32 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/uses_allocator_construction.h @@ -12,6 +12,7 @@ #include <__config> #include <__memory/construct_at.h> #include <__memory/uses_allocator.h> +#include <__tuple/pair_like.h> #include <__type_traits/enable_if.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_cv.h> @@ -36,15 +37,19 @@ inline constexpr bool __is_std_pair = false; template <class _Type1, class _Type2> inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true; -template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_std_pair<_Type>, int> = 0> +template <class _Tp> +inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>; + +template <class _Type, class _Alloc, class... _Args, __enable_if_t<!__is_cv_std_pair<_Type>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept { - if constexpr (!uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args...>) { + if constexpr (!uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, _Args...>) { return std::forward_as_tuple(std::forward<_Args>(__args)...); - } else if constexpr (uses_allocator_v<_Type, _Alloc> && + } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && is_constructible_v<_Type, allocator_arg_t, const _Alloc&, _Args...>) { return tuple<allocator_arg_t, const _Alloc&, _Args&&...>(allocator_arg, __alloc, std::forward<_Args>(__args)...); - } else if constexpr (uses_allocator_v<_Type, _Alloc> && is_constructible_v<_Type, _Args..., const _Alloc&>) { + } else if constexpr (uses_allocator_v<remove_cv_t<_Type>, _Alloc> && + is_constructible_v<_Type, _Args..., const _Alloc&>) { return std::forward_as_tuple(std::forward<_Args>(__args)..., __alloc); } else { static_assert( @@ -52,7 +57,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noe } } -template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, class _Tuple1, class _Tuple2, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args( const _Alloc& __alloc, piecewise_construct_t, _Tuple1&& __x, _Tuple2&& __y) noexcept { return std::make_tuple( @@ -71,12 +76,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args( std::forward<_Tuple2>(__y))); } -template <class _Pair, class _Alloc, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc) noexcept { return std::__uses_allocator_construction_args<_Pair>(__alloc, piecewise_construct, tuple<>{}, tuple<>{}); } -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) noexcept { return std::__uses_allocator_construction_args<_Pair>( @@ -87,7 +92,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Up&& __u, _Vp&& __v) } # if _LIBCPP_STD_VER >= 23 -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair) noexcept { return std::__uses_allocator_construction_args<_Pair>( @@ -95,14 +100,14 @@ __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>& __pair } # endif -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>& __pair) noexcept { return std::__uses_allocator_construction_args<_Pair>( __alloc, piecewise_construct, std::forward_as_tuple(__pair.first), std::forward_as_tuple(__pair.second)); } -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pair) noexcept { return std::__uses_allocator_construction_args<_Pair>( @@ -113,7 +118,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, pair<_Up, _Vp>&& __pai } # if _LIBCPP_STD_VER >= 23 -template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_std_pair<_Pair>, int> = 0> +template <class _Pair, class _Alloc, class _Up, class _Vp, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& __pair) noexcept { return std::__uses_allocator_construction_args<_Pair>( @@ -122,6 +127,20 @@ __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&& std::forward_as_tuple(std::get<0>(std::move(__pair))), std::forward_as_tuple(std::get<1>(std::move(__pair)))); } + +template < class _Pair, + class _Alloc, + __pair_like _PairLike, + __enable_if_t<__is_cv_std_pair<_Pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value, + int> = 0> +_LIBCPP_HIDE_FROM_ABI constexpr auto +__uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept { + return std::__uses_allocator_construction_args<_Pair>( + __alloc, + piecewise_construct, + std::forward_as_tuple(std::get<0>(std::forward<_PairLike>(__p))), + std::forward_as_tuple(std::get<1>(std::forward<_PairLike>(__p)))); +} # endif namespace __uses_allocator_detail { @@ -139,23 +158,33 @@ template <class _Tp> inline constexpr bool __convertible_to_const_pair_ref = decltype(__uses_allocator_detail::__convertible_to_const_pair_ref_impl<_Tp>(0))::value; +# if _LIBCPP_STD_VER >= 23 +template <class _Tp, class _Up> +inline constexpr bool __uses_allocator_constraints = + __is_cv_std_pair<_Tp> && + (__is_specialization_of_subrange<remove_cvref_t<_Up>>::value || + (!__pair_like<_Up> && !__convertible_to_const_pair_ref<_Up>)); +# else +template <class _Tp, class _Up> +inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !__convertible_to_const_pair_ref<_Up>; +# endif + } // namespace __uses_allocator_detail -template < - class _Pair, - class _Alloc, - class _Type, - __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int> = 0> +template < class _Pair, + class _Alloc, + class _Type, + __enable_if_t<__uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int> = 0> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept; template <class _Type, class _Alloc, class... _Args> _LIBCPP_HIDE_FROM_ABI constexpr _Type __make_obj_using_allocator(const _Alloc& __alloc, _Args&&... __args); -template <class _Pair, - class _Alloc, - class _Type, - __enable_if_t<__is_std_pair<_Pair> && !__uses_allocator_detail::__convertible_to_const_pair_ref<_Type>, int>> +template < class _Pair, + class _Alloc, + class _Type, + __enable_if_t< __uses_allocator_detail::__uses_allocator_constraints<_Pair, _Type>, int>> _LIBCPP_HIDE_FROM_ABI constexpr auto __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexcept { struct __pair_constructor { diff --git a/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h b/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h index 22ef2707d7..b19972a46d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h +++ b/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_reduce.h @@ -33,16 +33,16 @@ template <class _ExecutionPolicy, class _BinaryOperation = plus<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _Tp -reduce(_ExecutionPolicy&& __policy, - _ForwardIterator __first, - _ForwardIterator __last, - _Tp __init, - _BinaryOperation __op = {}) { +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_Tp> +__reduce(_ExecutionPolicy&& __policy, + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _Tp&& __init, + _BinaryOperation&& __op = {}) noexcept { return std::__pstl_frontend_dispatch( _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy), [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Tp __g_init, _BinaryOperation __g_op) { - return std::transform_reduce( + return std::__transform_reduce( __policy, std::move(__g_first), std::move(__g_last), std::move(__g_init), std::move(__g_op), __identity{}); }, std::move(__first), @@ -53,19 +53,50 @@ reduce(_ExecutionPolicy&& __policy, template <class _ExecutionPolicy, class _ForwardIterator, + class _Tp, + class _BinaryOperation = plus<>, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> -reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { +_LIBCPP_HIDE_FROM_ABI _Tp +reduce(_ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + _Tp __init, + _BinaryOperation __op = {}) { + auto __res = std::__reduce(__policy, std::move(__first), std::move(__last), std::move(__init), std::move(__op)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + +template <class _ExecutionPolicy, + class _ForwardIterator, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_value_type<_ForwardIterator>> +__reduce(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last) noexcept { return std::__pstl_frontend_dispatch( _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>()); + return std::__reduce( + __policy, std::move(__g_first), std::move(__g_last), __iter_value_type<_ForwardIterator>()); }, std::move(__first), std::move(__last)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator> +reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) { + auto __res = std::__reduce(__policy, std::move(__first), std::move(__last)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_transform_reduce.h b/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_transform_reduce.h index b7c9d8d288..4127ee21e3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_transform_reduce.h +++ b/contrib/libs/cxxsupp/libcxx/include/__numeric/pstl_transform_reduce.h @@ -16,7 +16,7 @@ #include <__numeric/transform_reduce.h> #include <__type_traits/is_execution_policy.h> #include <__utility/move.h> -#include <__utility/terminate_on_exception.h> +#include <optional> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -34,23 +34,53 @@ template <class _ExecutionPolicy, class _BinaryOperation2, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( +_LIBCPP_HIDE_FROM_ABI optional<_Tp> __transform_reduce( _ExecutionPolicy&&, + _ForwardIterator1&& __first1, + _ForwardIterator1&& __last1, + _ForwardIterator2&& __first2, + _Tp&& __init, + _BinaryOperation1&& __reduce, + _BinaryOperation2&& __transform) noexcept { + using _Backend = typename __select_backend<_RawPolicy>::type; + return std::__pstl_transform_reduce<_RawPolicy>( + _Backend{}, + std::move(__first1), + std::move(__last1), + std::move(__first2), + std::move(__init), + std::move(__reduce), + std::move(__transform)); +} + +template <class _ExecutionPolicy, + class _ForwardIterator1, + class _ForwardIterator2, + class _Tp, + class _BinaryOperation1, + class _BinaryOperation2, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( + _ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _Tp __init, _BinaryOperation1 __reduce, _BinaryOperation2 __transform) { - using _Backend = typename __select_backend<_RawPolicy>::type; - return std::__pstl_transform_reduce<_RawPolicy>( - _Backend{}, + auto __res = std::__transform_reduce( + __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__init), std::move(__reduce), std::move(__transform)); + + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); } // This overload doesn't get a customization point because it's trivial to detect (through e.g. @@ -76,13 +106,13 @@ template <class _ExecutionPolicy, class _UnaryOperation, class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> -_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_Tp>> __transform_reduce( _ExecutionPolicy&&, - _ForwardIterator __first, - _ForwardIterator __last, - _Tp __init, - _BinaryOperation __reduce, - _UnaryOperation __transform) { + _ForwardIterator&& __first, + _ForwardIterator&& __last, + _Tp&& __init, + _BinaryOperation&& __reduce, + _UnaryOperation&& __transform) noexcept { using _Backend = typename __select_backend<_RawPolicy>::type; return std::__pstl_transform_reduce<_RawPolicy>( _Backend{}, @@ -93,6 +123,27 @@ _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( std::move(__transform)); } +template <class _ExecutionPolicy, + class _ForwardIterator, + class _Tp, + class _BinaryOperation, + class _UnaryOperation, + class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>, + enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0> +_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce( + _ExecutionPolicy&& __policy, + _ForwardIterator __first, + _ForwardIterator __last, + _Tp __init, + _BinaryOperation __reduce, + _UnaryOperation __transform) { + auto __res = std::__transform_reduce( + __policy, std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform)); + if (!__res) + std::__throw_bad_alloc(); + return *std::move(__res); +} + _LIBCPP_END_NAMESPACE_STD #endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h index a519662e75..cf162100ee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/to.h @@ -207,13 +207,11 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) static_assert( !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile"); - auto __to_func = []<input_range _Range, class... _Tail>(_Range && __range, _Tail && ... __tail) + auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) requires requires { // /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); } - { - return ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); - }; + { return ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...); }; return __range_adaptor_closure_t(std::__bind_back(__to_func, std::forward<_Args>(__args)...)); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__std_clang_module b/contrib/libs/cxxsupp/libcxx/include/__std_clang_module index 4d02336d30..e2e9e85ffc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__std_clang_module +++ b/contrib/libs/cxxsupp/libcxx/include/__std_clang_module @@ -135,7 +135,6 @@ #if !defined(_LIBCPP_HAS_NO_THREADS) # include <latch> #endif -#include <limits.h> #include <limits> #include <list> #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) @@ -170,7 +169,6 @@ # include <semaphore> #endif #include <set> -#include <setjmp.h> #if !defined(_LIBCPP_HAS_NO_THREADS) # include <shared_mutex> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h index 019099a9cf..5688e3293a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/datasizeof.h @@ -47,7 +47,12 @@ struct __libcpp_datasizeof { }; #endif + // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow + // the use as an extension. + _LIBCPP_DIAGNOSTIC_PUSH + _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof") static const size_t value = offsetof(_FirstPaddingByte<>, __first_padding_byte_); + _LIBCPP_DIAGNOSTIC_POP }; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__type_traits/promote.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/promote.h index 018bd69df2..e22b4a422c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/promote.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/promote.h @@ -50,7 +50,7 @@ struct __numeric_type<void> { template <class _A1, class _A2 = void, class _A3 = void, - bool = __numeric_type<_A1>::value&& __numeric_type<_A2>::value&& __numeric_type<_A3>::value> + bool = __numeric_type<_A1>::value && __numeric_type<_A2>::value && __numeric_type<_A3>::value> class __promote_imp { public: static const bool value = false; diff --git a/contrib/libs/cxxsupp/libcxx/include/setjmp.h b/contrib/libs/cxxsupp/libcxx/include/__utility/empty.h index f4a2bbcb0b..8cca197145 100644 --- a/contrib/libs/cxxsupp/libcxx/include/setjmp.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/empty.h @@ -1,4 +1,3 @@ -// -*- C++ -*- //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. @@ -7,23 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP_SETJMP_H -#define _LIBCPP_SETJMP_H - -/* - setjmp.h synopsis - -Macros: - - setjmp - -Types: - - jmp_buf - -void longjmp(jmp_buf env, int val); - -*/ +#ifndef _LIBCPP___UTILITY_EMPTY_H +#define _LIBCPP___UTILITY_EMPTY_H #include <__config> @@ -31,16 +15,10 @@ void longjmp(jmp_buf env, int val); # pragma GCC system_header #endif -#if __has_include_next(<setjmp.h>) -# include_next <setjmp.h> -#endif +_LIBCPP_BEGIN_NAMESPACE_STD -#ifdef __cplusplus - -#ifndef setjmp -#define setjmp(env) setjmp(env) -#endif +struct __empty {}; -#endif // __cplusplus +_LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_SETJMP_H +#endif // _LIBCPP___UTILITY_EMPTY_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h b/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h index 62dac6dd1d..535344eb1e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h +++ b/contrib/libs/cxxsupp/libcxx/include/__utility/pair.h @@ -284,7 +284,8 @@ struct _LIBCPP_TEMPLATE_VIS pair } template <__pair_like _PairLike> - requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike&&>()))> && + requires(!__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value && + is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike&&>()))> && is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike&&>()))>) _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p) diff --git a/contrib/libs/cxxsupp/libcxx/include/__utility/terminate_on_exception.h b/contrib/libs/cxxsupp/libcxx/include/__utility/terminate_on_exception.h deleted file mode 100644 index e035ec3409..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__utility/terminate_on_exception.h +++ /dev/null @@ -1,48 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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___UTILITY_TERMINATE_ON_EXCEPTION_H -#define _LIBCPP___UTILITY_TERMINATE_ON_EXCEPTION_H - -#include <__config> -#include <__exception/terminate.h> -#include <new> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER >= 17 - -_LIBCPP_BEGIN_NAMESPACE_STD - -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS - -template <class _Func> -_LIBCPP_HIDE_FROM_ABI auto __terminate_on_exception(_Func __func) { - try { - return __func(); - } catch (...) { - std::terminate(); - } -} - -# else // _LIBCPP_HAS_NO_EXCEPTIONS - -template <class _Func> -_LIBCPP_HIDE_FROM_ABI auto __terminate_on_exception(_Func __func) { - return __func(); -} - -# endif // _LIBCPP_HAS_NO_EXCEPTIONS - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_STD_VER >= 17 - -#endif // _LIBCPP___UTILITY_TERMINATE_ON_EXCEPTION_H diff --git a/contrib/libs/cxxsupp/libcxx/include/bitset b/contrib/libs/cxxsupp/libcxx/include/bitset index 7ad332cc0d..d7112a7a8c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/bitset +++ b/contrib/libs/cxxsupp/libcxx/include/bitset @@ -122,6 +122,7 @@ template <size_t N> struct hash<std::bitset<N>>; */ +#include <__algorithm/count.h> #include <__algorithm/fill.h> #include <__algorithm/find.h> #include <__assert> // all public C++ headers provide the assertion handler @@ -1046,7 +1047,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>(std::count(base::__make_iter(0), base::__make_iter(_Size), true)); } template <size_t _Size> diff --git a/contrib/libs/cxxsupp/libcxx/include/climits b/contrib/libs/cxxsupp/libcxx/include/climits index d773af50d2..2e8993e4d6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/climits +++ b/contrib/libs/cxxsupp/libcxx/include/climits @@ -42,14 +42,6 @@ Macros: #include <limits.h> -#ifndef _LIBCPP_LIMITS_H -# error <climits> tried including <limits.h> but didn't find libc++'s <limits.h> header. \ - This usually means that your header search paths are not configured properly. \ - The header search paths should contain the C++ Standard Library headers before \ - any C Standard Library, and you are probably using compiler flags that make that \ - not be the case. -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/csetjmp b/contrib/libs/cxxsupp/libcxx/include/csetjmp index 4c64e8327e..d219c8e6cb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/csetjmp +++ b/contrib/libs/cxxsupp/libcxx/include/csetjmp @@ -35,14 +35,6 @@ void longjmp(jmp_buf env, int val); #include <setjmp.h> -#ifndef _LIBCPP_SETJMP_H -# error <csetjmp> tried including <setjmp.h> but didn't find libc++'s <setjmp.h> header. \ - This usually means that your header search paths are not configured properly. \ - The header search paths should contain the C++ Standard Library headers before \ - any C Standard Library, and you are probably using compiler flags that make that \ - not be the case. -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h index 341292612e..479809392f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/scalar.h @@ -46,6 +46,11 @@ struct __simd_operations<_Tp, simd_abi::__scalar> { using _MaskStorage = __mask_storage<_Tp, simd_abi::__scalar>; static _LIBCPP_HIDE_FROM_ABI _SimdStorage __broadcast(_Tp __v) noexcept { return {__v}; } + + template <class _Generator> + static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate(_Generator&& __g) noexcept { + return {__g(std::integral_constant<size_t, 0>())}; + } }; template <class _Tp> diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h index 30856f4b03..954f94c907 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/simd.h @@ -44,6 +44,10 @@ public: template <class _Up, enable_if_t<__can_broadcast_v<value_type, __remove_cvref_t<_Up>>, int> = 0> _LIBCPP_HIDE_FROM_ABI simd(_Up&& __v) noexcept : __s_(_Impl::__broadcast(static_cast<value_type>(__v))) {} + // generator constructor + template <class _Generator, enable_if_t<__can_generate_v<value_type, _Generator, size()>, int> = 0> + explicit _LIBCPP_HIDE_FROM_ABI simd(_Generator&& __g) : __s_(_Impl::__generate(std::forward<_Generator>(__g))) {} + // scalar access [simd.subscr] // Add operator[] temporarily to test braodcast. Add test for it in later patch. _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const { return __s_.__get(__i); } diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h index 0dba345e05..847d006629 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/utility.h @@ -19,6 +19,7 @@ #include <__type_traits/is_volatile.h> #include <__type_traits/void_t.h> #include <__utility/declval.h> +#include <__utility/integer_sequence.h> #include <cstdint> #include <limits> @@ -71,6 +72,25 @@ inline constexpr bool __can_broadcast_v = (!__is_vectorizable_v<_Up> && is_convertible_v<_Up, _Tp>) || is_same_v<_Up, int> || (is_same_v<_Up, unsigned int> && is_unsigned_v<_Tp>); +template <class _Tp, class _Generator, std::size_t _Idx, class = void> +inline constexpr bool __is_well_formed = false; + +template <class _Tp, class _Generator, std::size_t _Idx> +inline constexpr bool + __is_well_formed<_Tp, + _Generator, + _Idx, + std::void_t<decltype(std::declval<_Generator>()(integral_constant<size_t, _Idx>()))>> = + __can_broadcast_v<_Tp, decltype(std::declval<_Generator>()(integral_constant<size_t, _Idx>()))>; + +template <class _Tp, class _Generator, std::size_t... _Idxes> +_LIBCPP_HIDE_FROM_ABI constexpr bool __can_generate(index_sequence<_Idxes...>) { + return (true && ... && __is_well_formed<_Tp, _Generator, _Idxes>); +} + +template <class _Tp, class _Generator, std::size_t _Size> +inline constexpr bool __can_generate_v = experimental::__can_generate<_Tp, _Generator>(make_index_sequence<_Size>()); + } // namespace parallelism_v2 _LIBCPP_END_NAMESPACE_EXPERIMENTAL diff --git a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h index 44a1f481ab..4b23bfe384 100644 --- a/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h +++ b/contrib/libs/cxxsupp/libcxx/include/experimental/__simd/vec_ext.h @@ -11,6 +11,7 @@ #define _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H #include <__bit/bit_ceil.h> +#include <__utility/forward.h> #include <cstddef> #include <experimental/__simd/internal_declaration.h> #include <experimental/__simd/utility.h> @@ -56,6 +57,16 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> { } return __result; } + + template <class _Generator, size_t... _Is> + static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate_init(_Generator&& __g, std::index_sequence<_Is...>) { + return _SimdStorage{{__g(std::integral_constant<size_t, _Is>())...}}; + } + + template <class _Generator> + static _LIBCPP_HIDE_FROM_ABI _SimdStorage __generate(_Generator&& __g) noexcept { + return __generate_init(std::forward<_Generator>(__g), std::make_index_sequence<_Np>()); + } }; template <class _Tp, int _Np> diff --git a/contrib/libs/cxxsupp/libcxx/include/fstream b/contrib/libs/cxxsupp/libcxx/include/fstream index cf5ca142e7..024eef8a9d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/fstream +++ b/contrib/libs/cxxsupp/libcxx/include/fstream @@ -1734,7 +1734,7 @@ basic_fstream<_CharT, _Traits>::close() this->setstate(ios_base::failbit); } -#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1) +#ifndef _LIBCPP_AVAILABILITY_HAS_NO_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ifstream<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>; diff --git a/contrib/libs/cxxsupp/libcxx/include/functional b/contrib/libs/cxxsupp/libcxx/include/functional index 5c60b9fc39..5f9e8fa82a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/functional +++ b/contrib/libs/cxxsupp/libcxx/include/functional @@ -34,7 +34,7 @@ struct binary_function template <class T> class reference_wrapper : public unary_function<T1, R> // if wrapping a unary functor - : public binary_function<T1, T2, R> // if wraping a binary functor + : public binary_function<T1, T2, R> // if wrapping a binary functor { public: // types diff --git a/contrib/libs/cxxsupp/libcxx/include/limits b/contrib/libs/cxxsupp/libcxx/include/limits index 9f5949e63c..51daee6c49 100644 --- a/contrib/libs/cxxsupp/libcxx/include/limits +++ b/contrib/libs/cxxsupp/libcxx/include/limits @@ -43,8 +43,8 @@ public: static constexpr bool has_infinity = false; static constexpr bool has_quiet_NaN = false; static constexpr bool has_signaling_NaN = false; - static constexpr float_denorm_style has_denorm = denorm_absent; - static constexpr bool has_denorm_loss = false; + static constexpr float_denorm_style has_denorm = denorm_absent; // deprecated in C++23 + static constexpr bool has_denorm_loss = false; // deprecated in C++23 static constexpr T infinity() noexcept; static constexpr T quiet_NaN() noexcept; static constexpr T signaling_NaN() noexcept; @@ -68,7 +68,7 @@ enum float_round_style round_toward_neg_infinity = 3 }; -enum float_denorm_style +enum float_denorm_style // deprecated in C++23 { denorm_indeterminate = -1, denorm_absent = 0, @@ -128,7 +128,7 @@ enum float_round_style round_toward_neg_infinity = 3 }; -enum float_denorm_style +enum _LIBCPP_DEPRECATED_IN_CXX23 float_denorm_style { denorm_indeterminate = -1, denorm_absent = 0, @@ -164,8 +164,8 @@ protected: static _LIBCPP_CONSTEXPR const bool has_infinity = false; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type();} @@ -224,8 +224,8 @@ protected: static _LIBCPP_CONSTEXPR const bool has_infinity = false; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);} @@ -277,8 +277,8 @@ protected: static _LIBCPP_CONSTEXPR const bool has_infinity = false; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return type(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return type(0);} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return type(0);} @@ -323,8 +323,8 @@ protected: static _LIBCPP_CONSTEXPR const bool has_infinity = true; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_valf();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanf("");} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansf("");} @@ -373,8 +373,8 @@ protected: static _LIBCPP_CONSTEXPR const bool has_infinity = true; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_val();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nan("");} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nans("");} @@ -423,8 +423,8 @@ protected: static _LIBCPP_CONSTEXPR const bool has_infinity = true; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = true; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __builtin_huge_vall();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __builtin_nanl("");} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __builtin_nansl("");} @@ -477,8 +477,10 @@ public: static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();} @@ -570,8 +572,10 @@ public: static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();} @@ -663,8 +667,10 @@ public: static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();} @@ -756,8 +762,10 @@ public: static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; - static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; - static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; + static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; +_LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {return __base::infinity();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {return __base::quiet_NaN();} _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {return __base::signaling_NaN();} diff --git a/contrib/libs/cxxsupp/libcxx/include/limits.h b/contrib/libs/cxxsupp/libcxx/include/limits.h deleted file mode 100644 index 537a4b1439..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/limits.h +++ /dev/null @@ -1,71 +0,0 @@ -// -*- 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_LIMITS_H -#define _LIBCPP_LIMITS_H - -/* - limits.h synopsis - -Macros: - - CHAR_BIT - SCHAR_MIN - SCHAR_MAX - UCHAR_MAX - CHAR_MIN - CHAR_MAX - MB_LEN_MAX - SHRT_MIN - SHRT_MAX - USHRT_MAX - INT_MIN - INT_MAX - UINT_MAX - LONG_MIN - LONG_MAX - ULONG_MAX - LLONG_MIN // C99 - LLONG_MAX // C99 - ULLONG_MAX // C99 - -*/ - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#ifdef _LIBCPP_COMPILER_GCC - -// GCC header limits.h recursively includes itself through another header called -// syslimits.h for some reason. This setup breaks down if we directly -// #include_next GCC's limits.h (reasons not entirely clear to me). -// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795 for more details. -// Therefore, we manually re-create the necessary include sequence below: - -// Get the system limits.h defines (force recurse into the next level) -#define _GCC_LIMITS_H_ -#define _GCC_NEXT_LIMITS_H -#include_next <limits.h> - -// Get the ISO C defines -#undef _GCC_LIMITS_H_ -#include_next <limits.h> - -#else - -# if __has_include_next(<limits.h>) -# include_next <limits.h> -# endif - -#endif // _LIBCPP_COMPILER_GCC - -#endif // _LIBCPP_LIMITS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/memory b/contrib/libs/cxxsupp/libcxx/include/memory index cd6bcc7eaa..24ba82f43d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/memory +++ b/contrib/libs/cxxsupp/libcxx/include/memory @@ -867,6 +867,43 @@ template <class T> struct hash<shared_ptr<T> >; template <class T, class Alloc> inline constexpr bool uses_allocator_v = uses_allocator<T, Alloc>::value; +// [allocator.uses.construction], uses-allocator construction +template<class T, class Alloc, class... Args> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + Args&&... args) noexcept; +template<class T, class Alloc, class Tuple1, class Tuple2> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + piecewise_construct_t, + Tuple1&& x, Tuple2&& y) noexcept; +template<class T, class Alloc> + constexpr auto uses_allocator_construction_args(const Alloc& alloc) noexcept; // since C++20 +template<class T, class Alloc, class U, class V> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + U&& u, V&& v) noexcept; +template<class T, class Alloc, class U, class V> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++23 + pair<U, V>& pr) noexcept; +template<class T, class Alloc, class U, class V> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + const pair<U, V>& pr) noexcept; +template<class T, class Alloc, class U, class V> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + pair<U, V>&& pr) noexcept; +template<class T, class Alloc, class U, class V> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++23 + const pair<U, V>&& pr) noexcept; +template<class T, class Alloc, pair-like P> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + P&& p) noexcept; +template<class T, class Alloc, class U> + constexpr auto uses_allocator_construction_args(const Alloc& alloc, // since C++20 + U&& u) noexcept; +template<class T, class Alloc, class... Args> + constexpr T make_obj_using_allocator(const Alloc& alloc, Args&&... args); // since C++20 +template<class T, class Alloc, class... Args> + constexpr T* uninitialized_construct_using_allocator(T* p, // since C++20 + const Alloc& alloc, Args&&... args); + // [ptr.align] void* align(size_t alignment, size_t size, void*& ptr, size_t& space); diff --git a/contrib/libs/cxxsupp/libcxx/include/module.modulemap.in b/contrib/libs/cxxsupp/libcxx/include/module.modulemap.in index 6d9bb8653f..3e5a8a391b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/module.modulemap.in +++ b/contrib/libs/cxxsupp/libcxx/include/module.modulemap.in @@ -448,10 +448,6 @@ module std_inttypes_h [system] { export * } // <iso646.h> provided by compiler. -module std_limits_h [system] { - header "limits.h" - export * -} module std_locale_h [system] { header "locale.h" export * @@ -460,10 +456,7 @@ module std_math_h [system] { header "math.h" export * } -module std_setjmp_h [system] { - header "setjmp.h" - export * -} +// <setjmp.h> provided by C library. // <signal.h> provided by C library. // FIXME: <stdalign.h> is missing. // <stdarg.h> provided by compiler. @@ -2053,6 +2046,7 @@ module std_private_utility_cmp [system] { } module std_private_utility_convert_to_integral [system] { header "__utility/convert_to_integral.h" } module std_private_utility_declval [system] { header "__utility/declval.h" } +module std_private_utility_empty [system] { header "__utility/empty.h" } module std_private_utility_exception_guard [system] { header "__utility/exception_guard.h" } module std_private_utility_exchange [system] { header "__utility/exchange.h" } module std_private_utility_forward [system] { header "__utility/forward.h" } @@ -2088,7 +2082,6 @@ module std_private_utility_swap [system] { header "__utility/swap.h" export std_private_type_traits_is_swappable } -module std_private_utility_terminate_on_exception [system] { header "__utility/terminate_on_exception.h" } module std_private_utility_to_underlying [system] { header "__utility/to_underlying.h" } module std_private_utility_unreachable [system] { header "__utility/unreachable.h" } diff --git a/contrib/libs/cxxsupp/libcxx/include/sstream b/contrib/libs/cxxsupp/libcxx/include/sstream index 40930df24c..4fec465d57 100644 --- a/contrib/libs/cxxsupp/libcxx/include/sstream +++ b/contrib/libs/cxxsupp/libcxx/include/sstream @@ -267,6 +267,7 @@ typedef basic_stringstream<wchar_t> wstringstream; */ #include <__assert> // all public C++ headers provide the assertion handler +#include <__availability> #include <__config> #include <__fwd/sstream.h> #include <__utility/swap.h> @@ -399,12 +400,12 @@ public: _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const & { return str(__str_.get_allocator()); } _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { - string_type __result; const basic_string_view<_CharT, _Traits> __view = view(); - if (!__view.empty()) { - auto __pos = __view.data() - __str_.data(); - __result.assign(std::move(__str_), __pos, __view.size()); - } + typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data(); + // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator()); + // But we need something that works in C++20 also. + string_type __result(__str_.get_allocator()); + __result.__move_assign(std::move(__str_), __pos, __view.size()); __str_.clear(); __init_buf_ptrs(); return __result; @@ -1192,7 +1193,7 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, __x.swap(__y); } -#if defined(_LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1) +#ifndef _LIBCPP_AVAILABILITY_HAS_NO_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringbuf<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_stringstream<char>; extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>; diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string index 6550f5baf6..7320cf16a3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string +++ b/contrib/libs/cxxsupp/libcxx/include/string @@ -836,8 +836,8 @@ private: { union { - __long __l; __short __s; + __long __l; __raw __r; }; }; @@ -885,9 +885,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) - : __r_(__default_init_tag(), __default_init_tag()) { - __default_init(); - } + : __r_(__value_init_tag(), __default_init_tag()) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const allocator_type& __a) #if _LIBCPP_STD_VER <= 14 @@ -895,9 +893,7 @@ public: #else _NOEXCEPT #endif - : __r_(__default_init_tag(), __a) { - __default_init(); - } + : __r_(__value_init_tag(), __a) {} _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str) : __r_(__default_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { @@ -923,7 +919,7 @@ public: _NOEXCEPT # endif : __r_(std::move(__str.__r_)) { - __str.__default_init(); + __str.__r_.first() = __rep(); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(basic_string&& __str, const allocator_type& __a) @@ -934,7 +930,7 @@ public: if (__libcpp_is_constant_evaluated()) __r_.first() = __rep(); __r_.first() = __str.__r_.first(); - __str.__default_init(); + __str.__r_.first() = __rep(); } } #endif // _LIBCPP_CXX03_LANG @@ -994,12 +990,7 @@ public: auto __len = std::min<size_type>(__n, __str.size() - __pos); if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc()) { - __r_.first() = __str.__r_.first(); - __str.__default_init(); - - _Traits::move(data(), data() + __pos, __len); - __set_size(__len); - _Traits::assign(data()[__len], value_type()); + __move_assign(std::move(__str), __pos, __len); } else { // Perform a copy because the allocators are not compatible. __init(__str.data() + __pos, __len); @@ -1368,6 +1359,20 @@ public: return assign(__sv.data(), __sv.size()); } +#if _LIBCPP_STD_VER >= 20 + _LIBCPP_HIDE_FROM_ABI constexpr + void __move_assign(basic_string&& __str, size_type __pos, size_type __len) { + // Pilfer the allocation from __str. + _LIBCPP_ASSERT_INTERNAL(__alloc() == __str.__alloc(), "__move_assign called with wrong allocator"); + __r_.first() = __str.__r_.first(); + __str.__r_.first() = __rep(); + + _Traits::move(data(), data() + __pos, __len); + __set_size(__len); + _Traits::assign(data()[__len], value_type()); + } +#endif + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const basic_string& __str) { return *this = __str; } #ifndef _LIBCPP_CXX03_LANG @@ -1764,8 +1769,9 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_long() const _NOEXCEPT { - if (__libcpp_is_constant_evaluated()) - return true; + if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__r_.first().__l.__is_long_)) { + return __r_.first().__l.__is_long_; + } return __r_.first().__s.__is_long_; } @@ -1781,26 +1787,8 @@ private: #endif // _LIBCPP_STD_VER >= 20 } - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __default_init() { - __r_.first() = __rep(); - if (__libcpp_is_constant_evaluated()) { - size_type __sz = __recommend(0) + 1; - pointer __ptr = __alloc_traits::allocate(__alloc(), __sz); - __begin_lifetime(__ptr, __sz); - __set_long_pointer(__ptr); - __set_long_cap(__sz); - __set_long_size(0); - } - } - - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __deallocate_constexpr() { - if (__libcpp_is_constant_evaluated() && __get_pointer() != nullptr) - __alloc_traits::deallocate(__alloc(), __get_pointer(), __get_long_cap()); - } - _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI static bool __fits_in_sso(size_type __sz) { - // SSO is disabled during constant evaluation because `__is_long` isn't constexpr friendly - return !__libcpp_is_constant_evaluated() && (__sz < __min_cap); + return __sz < __min_cap; } template <class _Iterator, class _Sentinel> @@ -1907,15 +1895,19 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT {return (__s + (__a-1)) & ~(__a-1);} - enum {__alignment = 16}; + enum { + __alignment = +#ifdef _LIBCPP_ABI_STRING_8_BYTE_ALIGNMENT + 8 +#else + 16 +#endif + }; static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT { if (__s < __min_cap) { - if (__libcpp_is_constant_evaluated()) - return static_cast<size_type>(__min_cap); - else - return static_cast<size_type>(__min_cap) - 1; + return static_cast<size_type>(__min_cap) - 1; } size_type __guess = __align_it<sizeof(value_type) < __alignment ? __alignment/sizeof(value_type) : 1 > (__s+1) - 1; @@ -2056,7 +2048,7 @@ private: _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_external(const value_type* __s, size_type __n); // Assigns the value in __s, guaranteed to be __n < __min_cap in length. - inline basic_string& __assign_short(const value_type* __s, size_type __n) { + inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& __assign_short(const value_type* __s, size_type __n) { pointer __p = __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer()); @@ -2270,7 +2262,7 @@ template <class _CharT, class _Traits, class _Allocator> template <class _InputIterator, class _Sentinel> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator __first, _Sentinel __last) { - __default_init(); + __r_.first() = __rep(); #ifndef _LIBCPP_HAS_NO_EXCEPTIONS try @@ -2370,7 +2362,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace if (__sec_cp_sz != 0) traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); - if (__old_cap+1 != __min_cap || __libcpp_is_constant_evaluated()) + if (__old_cap+1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap+1); __set_long_pointer(__p); __set_long_cap(__allocation.count); @@ -2410,7 +2402,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t traits_type::copy(std::__to_address(__p) + __n_copy + __n_add, std::__to_address(__old_p) + __n_copy + __n_del, __sec_cp_sz); - if (__libcpp_is_constant_evaluated() || __old_cap + 1 != __min_cap) + if (__old_cap + 1 != __min_cap) __alloc_traits::deallocate(__alloc(), __old_p, __old_cap + 1); __set_long_pointer(__p); __set_long_cap(__allocation.count); @@ -2573,12 +2565,8 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr } __move_assign_alloc(__str); __r_.first() = __str.__r_.first(); - if (__libcpp_is_constant_evaluated()) { - __str.__default_init(); - } else { - __str.__set_short_size(0); - traits_type::assign(__str.__get_short_pointer()[0], value_type()); - } + __str.__set_short_size(0); + traits_type::assign(__str.__get_short_pointer()[0], value_type()); } #endif @@ -2864,13 +2852,6 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t if (__pos > __sz) __throw_out_of_range(); size_type __cap = capacity(); - if (__libcpp_is_constant_evaluated()) { - if (__cap - __sz >= __n) - __grow_by_and_replace(__cap, 0, __sz, __pos, 0, __n, __s); - else - __grow_by_and_replace(__cap, __sz + __n - __cap, __sz, __pos, 0, __n, __s); - return *this; - } if (__cap - __sz >= __n) { if (__n) @@ -2879,7 +2860,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t size_type __n_move = __sz - __pos; if (__n_move != 0) { - if (__p + __pos <= __s && __s < __p + __sz) + if (std::__is_pointer_in_range(__p + __pos, __p + __sz, __s)) __s += __n; traits_type::move(__p + __pos + __n, __p + __pos, __n_move); } @@ -3902,7 +3883,7 @@ basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT if(__is_long()) { __alloc_traits::deallocate(__alloc(), __get_long_pointer(), capacity() + 1); - __default_init(); + __r_.first() = __rep(); } } diff --git a/contrib/libs/cxxsupp/libcxx/include/tuple b/contrib/libs/cxxsupp/libcxx/include/tuple index eb1785cc89..63adb8ec30 100644 --- a/contrib/libs/cxxsupp/libcxx/include/tuple +++ b/contrib/libs/cxxsupp/libcxx/include/tuple @@ -592,51 +592,31 @@ class _LIBCPP_TEMPLATE_VIS tuple public: // [tuple.cnstr] - // tuple() constructors (including allocator_arg_t variants) - template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t< - _And< - _IsImpDefault<_Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - tuple() - _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value) - { } +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") +_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") + // tuple() constructors (including allocator_arg_t variants) template <template<class...> class _IsImpDefault = __is_implicitly_default_constructible, template<class...> class _IsDefault = is_default_constructible, __enable_if_t< _And< - _IsDefault<_Tp>..., - _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check + _IsDefault<_Tp>... >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR - explicit tuple() + explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) tuple() _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value) { } - template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, __enable_if_t< - _And< - _IsImpDefault<_Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, _Alloc const& __a) - : __base_(allocator_arg_t(), __a, - __tuple_indices<>(), __tuple_types<>(), - typename __make_tuple_indices<sizeof...(_Tp), 0>::type(), - __tuple_types<_Tp...>()) {} - template <class _Alloc, template<class...> class _IsImpDefault = __is_implicitly_default_constructible, template<class...> class _IsDefault = is_default_constructible, __enable_if_t< _And< - _IsDefault<_Tp>..., - _Not<_Lazy<_And, _IsImpDefault<_Tp>...> > // explicit check + _IsDefault<_Tp>... >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, _Alloc const& __a) + explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) tuple(allocator_arg_t, _Alloc const& __a) : __base_(allocator_arg_t(), __a, __tuple_indices<>(), __tuple_types<>(), typename __make_tuple_indices<sizeof...(_Tp), 0>::type(), @@ -646,29 +626,11 @@ public: template <template<class...> class _And = _And, __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, - is_copy_constructible<_Tp>..., - is_convertible<const _Tp&, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - tuple(const _Tp& ... __t) - _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value) - : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), - typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), - typename __make_tuple_indices<0>::type(), - typename __make_tuple_types<tuple, 0>::type(), - __t... - ) {} - - template <template<class...> class _And = _And, __enable_if_t< - _And< - _BoolConstant<sizeof...(_Tp) >= 1>, - is_copy_constructible<_Tp>..., - _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check + is_copy_constructible<_Tp>... >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - explicit tuple(const _Tp& ... __t) + explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) tuple(const _Tp& ... __t) _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value) : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(), typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), @@ -680,29 +642,11 @@ public: template <class _Alloc, template<class...> class _And = _And, __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, - is_copy_constructible<_Tp>..., - is_convertible<const _Tp&, _Tp>... // explicit check + is_copy_constructible<_Tp>... >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) - : __base_(allocator_arg_t(), __a, - typename __make_tuple_indices<sizeof...(_Tp)>::type(), - typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), - typename __make_tuple_indices<0>::type(), - typename __make_tuple_types<tuple, 0>::type(), - __t... - ) {} - - template <class _Alloc, template<class...> class _And = _And, __enable_if_t< - _And< - _BoolConstant<sizeof...(_Tp) >= 1>, - is_copy_constructible<_Tp>..., - _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> > // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) + explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, const _Tp& ... __t) : __base_(allocator_arg_t(), __a, typename __make_tuple_indices<sizeof...(_Tp)>::type(), typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(), @@ -725,28 +669,17 @@ public: template <class ..._Up, __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, - _EnableUTypesCtor<_Up...>, - is_convertible<_Up, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - tuple(_Up&&... __u) - _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value)) - : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), - typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), - typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), - typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), - _VSTD::forward<_Up>(__u)...) {} - - template <class ..._Up, __enable_if_t< - _And< - _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, - _EnableUTypesCtor<_Up...>, - _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check + _EnableUTypesCtor<_Up...> +// nvcc 12.2 cannot choose between tuple(const T& ... t) and tuple(U&&... u) +// so we have to added an explicit requires in enable_if +#ifdef __CUDACC__ + , + _Not<_And<is_copy_constructible<_Tp>..., _Lazy<_And, is_convertible<_Up, const _Tp&>...>> > +#endif >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - explicit tuple(_Up&&... __u) + explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(_Up&&... __u) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value)) : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(), typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), @@ -757,28 +690,11 @@ public: template <class _Alloc, class ..._Up, __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, - _EnableUTypesCtor<_Up...>, - is_convertible<_Up, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) - : __base_(allocator_arg_t(), __a, - typename __make_tuple_indices<sizeof...(_Up)>::type(), - typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), - typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(), - typename __make_tuple_types<tuple, sizeof...(_Tp), sizeof...(_Up)>::type(), - _VSTD::forward<_Up>(__u)...) {} - - template <class _Alloc, class ..._Up, __enable_if_t< - _And< - _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, - _EnableUTypesCtor<_Up...>, - _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check + _EnableUTypesCtor<_Up...> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) + explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u) : __base_(allocator_arg_t(), __a, typename __make_tuple_indices<sizeof...(_Up)>::type(), typename __make_tuple_types<tuple, sizeof...(_Up)>::type(), @@ -833,47 +749,22 @@ public: template <class ..._Up, __enable_if_t< _And< - _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, - is_convertible<const _Up&, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - tuple(const tuple<_Up...>& __t) - _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)) - : __base_(__t) - { } - - template <class ..._Up, __enable_if_t< - _And< - _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, - _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check + _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - explicit tuple(const tuple<_Up...>& __t) + explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) tuple(const tuple<_Up...>& __t) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)) : __base_(__t) { } template <class ..._Up, class _Alloc, __enable_if_t< _And< - _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, - is_convertible<const _Up&, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) - : __base_(allocator_arg_t(), __a, __t) - { } - - template <class ..._Up, class _Alloc, __enable_if_t< - _And< - _EnableCtorFromUTypesTuple<const tuple<_Up...>&>, - _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> > // explicit check + _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) + explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t) : __base_(allocator_arg_t(), __a, __t) { } @@ -894,50 +785,24 @@ public: #endif // _LIBCPP_STD_VER >= 23 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants) - - template <class ..._Up, __enable_if_t< - _And< - _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, - is_convertible<_Up, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - tuple(tuple<_Up...>&& __t) - _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value)) - : __base_(_VSTD::move(__t)) - { } - template <class ..._Up, __enable_if_t< _And< - _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, - _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check + _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - explicit tuple(tuple<_Up...>&& __t) + explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(tuple<_Up...>&& __t) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value)) : __base_(_VSTD::move(__t)) { } template <class _Alloc, class ..._Up, __enable_if_t< _And< - _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, - is_convertible<_Up, _Tp>... // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) - : __base_(allocator_arg_t(), __a, _VSTD::move(__t)) - { } - - template <class _Alloc, class ..._Up, __enable_if_t< - _And< - _EnableCtorFromUTypesTuple<tuple<_Up...>&&>, - _Not<_Lazy<_And, is_convertible<_Up, _Tp>...> > // explicit check + _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) + explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value) tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t) : __base_(allocator_arg_t(), __a, _VSTD::move(__t)) { } @@ -986,47 +851,22 @@ public: template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< _And< - _EnableCtorFromPair<const pair<_Up1, _Up2>&>, - _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check + _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - tuple(const pair<_Up1, _Up2>& __p) - _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)) - : __base_(__p) - { } - - template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< - _And< - _EnableCtorFromPair<const pair<_Up1, _Up2>&>, - _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - explicit tuple(const pair<_Up1, _Up2>& __p) + explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) tuple(const pair<_Up1, _Up2>& __p) _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)) : __base_(__p) { } template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< _And< - _EnableCtorFromPair<const pair<_Up1, _Up2>&>, - _BothImplicitlyConvertible<const pair<_Up1, _Up2>&> // explicit check + _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) - : __base_(allocator_arg_t(), __a, __p) - { } - - template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< - _And< - _EnableCtorFromPair<const pair<_Up1, _Up2>&>, - _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> > // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) + explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p) : __base_(allocator_arg_t(), __a, __p) { } @@ -1050,47 +890,22 @@ public: template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< _And< - _EnableCtorFromPair<pair<_Up1, _Up2>&&>, - _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check + _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - tuple(pair<_Up1, _Up2>&& __p) - _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)) - : __base_(_VSTD::move(__p)) - { } - - template <class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< - _And< - _EnableCtorFromPair<pair<_Up1, _Up2>&&>, - _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 - explicit tuple(pair<_Up1, _Up2>&& __p) + explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) tuple(pair<_Up1, _Up2>&& __p) _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)) : __base_(_VSTD::move(__p)) { } template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< _And< - _EnableCtorFromPair<pair<_Up1, _Up2>&&>, - _BothImplicitlyConvertible<pair<_Up1, _Up2>&&> // explicit check + _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value , int> = 0> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) - : __base_(allocator_arg_t(), __a, _VSTD::move(__p)) - { } - - template <class _Alloc, class _Up1, class _Up2, template<class...> class _And = _And, __enable_if_t< - _And< - _EnableCtorFromPair<pair<_Up1, _Up2>&&>, - _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> > // explicit check - >::value - , int> = 0> - _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 - explicit tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) + explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p) : __base_(allocator_arg_t(), __a, _VSTD::move(__p)) { } @@ -1111,6 +926,8 @@ public: : __base_(allocator_arg_t(), __alloc, std::move(__p)) {} #endif // _LIBCPP_STD_VER >= 23 +_LIBCPP_DIAGNOSTIC_POP + // [tuple.assign] _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) diff --git a/contrib/libs/cxxsupp/libcxx/patches/00-future-2023-11-30-fix-std-expected-DEVTOOLSSUPPORT-54349.patch b/contrib/libs/cxxsupp/libcxx/patches/00-future-2023-11-30-fix-std-expected-DEVTOOLSSUPPORT-54349.patch new file mode 100644 index 0000000000..36245f22b7 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/patches/00-future-2023-11-30-fix-std-expected-DEVTOOLSSUPPORT-54349.patch @@ -0,0 +1,385 @@ +diff --git a/include/__expected/expected.h b/include/__expected/expected.h +index 045370a..bf16c8f 100644 +--- a/include/__expected/expected.h ++++ b/include/__expected/expected.h +@@ -119,9 +119,7 @@ public: + _LIBCPP_HIDE_FROM_ABI constexpr expected() + noexcept(is_nothrow_default_constructible_v<_Tp>) // strengthened + requires is_default_constructible_v<_Tp> +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_)); +- } ++ : __union_(std::in_place), __has_val_(true) {} + + _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected&) = delete; + +@@ -136,14 +134,7 @@ public: + noexcept(is_nothrow_copy_constructible_v<_Tp> && is_nothrow_copy_constructible_v<_Err>) // strengthened + requires(is_copy_constructible_v<_Tp> && is_copy_constructible_v<_Err> && + !(is_trivially_copy_constructible_v<_Tp> && is_trivially_copy_constructible_v<_Err>)) +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); +- } +- } +- ++ : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) { } + + _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) + requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> +@@ -154,13 +145,7 @@ public: + noexcept(is_nothrow_move_constructible_v<_Tp> && is_nothrow_move_constructible_v<_Err>) + requires(is_move_constructible_v<_Tp> && is_move_constructible_v<_Err> && + !(is_trivially_move_constructible_v<_Tp> && is_trivially_move_constructible_v<_Err>)) +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); +- } +- } ++ : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) { } + + private: + template <class _Up, class _OtherErr, class _UfQual, class _OtherErrQual> +@@ -200,26 +185,14 @@ public: + expected(const expected<_Up, _OtherErr>& __other) + noexcept(is_nothrow_constructible_v<_Tp, const _Up&> && + is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), __other.__union_.__val_); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), __other.__union_.__unex_); +- } +- } ++ : __union_(__other.__has_val_, __other.__union_), __has_val_(__other.__has_val_) {} + + template <class _Up, class _OtherErr> + requires __can_convert<_Up, _OtherErr, _Up, _OtherErr>::value + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp> || !is_convertible_v<_OtherErr, _Err>) + expected(expected<_Up, _OtherErr>&& __other) + noexcept(is_nothrow_constructible_v<_Tp, _Up> && is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(__other.__has_val_) { +- if (__has_val_) { +- std::construct_at(std::addressof(__union_.__val_), std::move(__other.__union_.__val_)); +- } else { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__other.__union_.__unex_)); +- } +- } ++ : __union_(__other.__has_val_, std::move(__other.__union_)), __has_val_(__other.__has_val_) {} + + template <class _Up = _Tp> + requires(!is_same_v<remove_cvref_t<_Up>, in_place_t> && !is_same_v<expected, remove_cvref_t<_Up>> && +@@ -227,61 +200,47 @@ public: + (!is_same_v<remove_cv_t<_Tp>, bool> || !__is_std_expected<remove_cvref_t<_Up>>::value)) + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up, _Tp>) + expected(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_), std::forward<_Up>(__u)); +- } ++ : __union_(std::in_place, std::forward<_Up>(__u)), __has_val_(true) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, const _OtherErr&> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) + expected(const unexpected<_OtherErr>& __unex) + noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __unex.error()); +- } ++ : __union_(std::unexpect, __unex.error()), __has_val_(false) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, _OtherErr> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) + expected(unexpected<_OtherErr>&& __unex) + noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); +- } ++ : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} + + template <class... _Args> + requires is_constructible_v<_Tp, _Args...> + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Tp, _Args...>) // strengthened +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); +- } ++ : __union_(std::in_place, std::forward<_Args>(__args)...), __has_val_(true) {} + + template <class _Up, class... _Args> + requires is_constructible_v< _Tp, initializer_list<_Up>&, _Args... > + _LIBCPP_HIDE_FROM_ABI constexpr explicit + expected(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Tp, initializer_list<_Up>&, _Args...>) // strengthened +- : __has_val_(true) { +- std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); +- } ++ : __union_(std::in_place, __il, std::forward<_Args>(__args)...), __has_val_(true) {} + + template <class... _Args> + requires is_constructible_v<_Err, _Args...> + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) +- noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); +- } ++ noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened ++ : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} + + template <class _Up, class... _Args> + requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > + _LIBCPP_HIDE_FROM_ABI constexpr explicit + expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); +- } ++ : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} + + // [expected.object.dtor], destructor + +@@ -440,9 +399,10 @@ public: + std::destroy_at(std::addressof(__union_.__val_)); + } else { + std::destroy_at(std::addressof(__union_.__unex_)); +- __has_val_ = true; + } +- return *std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); ++ std::construct_at(std::addressof(__union_.__val_), std::forward<_Args>(__args)...); ++ __has_val_ = true; ++ return __union_.__val_; + } + + template <class _Up, class... _Args> +@@ -452,9 +412,10 @@ public: + std::destroy_at(std::addressof(__union_.__val_)); + } else { + std::destroy_at(std::addressof(__union_.__unex_)); +- __has_val_ = true; + } +- return *std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); ++ std::construct_at(std::addressof(__union_.__val_), __il, std::forward<_Args>(__args)...); ++ __has_val_ = true; ++ return __union_.__val_; + } + + +@@ -893,11 +854,15 @@ public: + } + + private: +- struct __empty_t {}; +- + template <class _ValueType, class _ErrorType> + union __union_t { +- _LIBCPP_HIDE_FROM_ABI constexpr __union_t() {} ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) ++ : __val_(std::forward<_Args>(__args)...) {} ++ ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} + + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( +@@ -909,6 +874,14 @@ private: + std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) + = default; +@@ -927,10 +900,17 @@ private: + template <class _ValueType, class _ErrorType> + requires(is_trivially_move_constructible_v<_ValueType> && is_trivially_move_constructible_v<_ErrorType>) + union __union_t<_ValueType, _ErrorType> { +- _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} + _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; + _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::in_place_t, _Args&&... __args) ++ : __val_(std::forward<_Args>(__args)...) {} ++ ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} ++ + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( + std::__expected_construct_in_place_from_invoke_tag, _Func&& __f, _Args&&... __args) +@@ -941,6 +921,14 @@ private: + std::__expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__val_), std::forward<_Union>(__other).__val_); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ValueType> && is_trivially_destructible_v<_ErrorType>) + = default; +@@ -950,7 +938,6 @@ private: + requires(!is_trivially_destructible_v<_ValueType> || !is_trivially_destructible_v<_ErrorType>) + {} + +- _LIBCPP_NO_UNIQUE_ADDRESS __empty_t __empty_; + _LIBCPP_NO_UNIQUE_ADDRESS _ValueType __val_; + _LIBCPP_NO_UNIQUE_ADDRESS _ErrorType __unex_; + }; +@@ -998,11 +985,7 @@ public: + _LIBCPP_HIDE_FROM_ABI constexpr expected(const expected& __rhs) + noexcept(is_nothrow_copy_constructible_v<_Err>) // strengthened + requires(is_copy_constructible_v<_Err> && !is_trivially_copy_constructible_v<_Err>) +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); +- } +- } ++ : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} + + _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&&) + requires(is_move_constructible_v<_Err> && is_trivially_move_constructible_v<_Err>) +@@ -1011,51 +994,35 @@ public: + _LIBCPP_HIDE_FROM_ABI constexpr expected(expected&& __rhs) + noexcept(is_nothrow_move_constructible_v<_Err>) + requires(is_move_constructible_v<_Err> && !is_trivially_move_constructible_v<_Err>) +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); +- } +- } ++ : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} + + template <class _Up, class _OtherErr> + requires __can_convert<_Up, _OtherErr, const _OtherErr&>::value + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) + expected(const expected<_Up, _OtherErr>& __rhs) + noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), __rhs.__union_.__unex_); +- } +- } ++ : __union_(__rhs.__has_val_, __rhs.__union_), __has_val_(__rhs.__has_val_) {} + + template <class _Up, class _OtherErr> + requires __can_convert<_Up, _OtherErr, _OtherErr>::value + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) + expected(expected<_Up, _OtherErr>&& __rhs) + noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(__rhs.__has_val_) { +- if (!__rhs.__has_val_) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__rhs.__union_.__unex_)); +- } +- } ++ : __union_(__rhs.__has_val_, std::move(__rhs.__union_)), __has_val_(__rhs.__has_val_) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, const _OtherErr&> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<const _OtherErr&, _Err>) + expected(const unexpected<_OtherErr>& __unex) + noexcept(is_nothrow_constructible_v<_Err, const _OtherErr&>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __unex.error()); +- } ++ : __union_(std::unexpect, __unex.error()), __has_val_(false) {} + + template <class _OtherErr> + requires is_constructible_v<_Err, _OtherErr> + _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_OtherErr, _Err>) + expected(unexpected<_OtherErr>&& __unex) + noexcept(is_nothrow_constructible_v<_Err, _OtherErr>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::move(__unex.error())); +- } ++ : __union_(std::unexpect, std::move(__unex.error())), __has_val_(false) {} + + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(in_place_t) noexcept : __has_val_(true) {} + +@@ -1063,17 +1030,13 @@ public: + requires is_constructible_v<_Err, _Args...> + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Err, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), std::forward<_Args>(__args)...); +- } ++ : __union_(std::unexpect, std::forward<_Args>(__args)...), __has_val_(false) {} + + template <class _Up, class... _Args> + requires is_constructible_v< _Err, initializer_list<_Up>&, _Args... > + _LIBCPP_HIDE_FROM_ABI constexpr explicit expected(unexpect_t, initializer_list<_Up> __il, _Args&&... __args) + noexcept(is_nothrow_constructible_v<_Err, initializer_list<_Up>&, _Args...>) // strengthened +- : __has_val_(false) { +- std::construct_at(std::addressof(__union_.__unex_), __il, std::forward<_Args>(__args)...); +- } ++ : __union_(std::unexpect, __il, std::forward<_Args>(__args)...), __has_val_(false) {} + + private: + template <class _Func> +@@ -1507,11 +1470,23 @@ private: + union __union_t { + _LIBCPP_HIDE_FROM_ABI constexpr __union_t() : __empty_() {} + ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} ++ + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( + __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__empty_)); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ErrorType>) + = default; +@@ -1534,11 +1509,23 @@ private: + _LIBCPP_HIDE_FROM_ABI constexpr __union_t(const __union_t&) = default; + _LIBCPP_HIDE_FROM_ABI constexpr __union_t& operator=(const __union_t&) = default; + ++ template <class... _Args> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(std::unexpect_t, _Args&&... __args) ++ : __unex_(std::forward<_Args>(__args)...) {} ++ + template <class _Func, class... _Args> + _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t( + __expected_construct_unexpected_from_invoke_tag, _Func&& __f, _Args&&... __args) + : __unex_(std::invoke(std::forward<_Func>(__f), std::forward<_Args>(__args)...)) {} + ++ template <class _Union> ++ _LIBCPP_HIDE_FROM_ABI constexpr explicit __union_t(bool __has_val, _Union&& __other) { ++ if (__has_val) ++ std::construct_at(std::addressof(__empty_)); ++ else ++ std::construct_at(std::addressof(__unex_), std::forward<_Union>(__other).__unex_); ++ } ++ + _LIBCPP_HIDE_FROM_ABI constexpr ~__union_t() + requires(is_trivially_destructible_v<_ErrorType>) + = default; diff --git a/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch b/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch index bd826ae06e..6e2e94aaab 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/01-commit-e0e82fc-initial.patch @@ -1,5 +1,5 @@ diff --git a/include/__config b/include/__config -index 52bf12f..e431997 100644 +index 65ce6d6..ab696fb 100644 --- a/include/__config +++ b/include/__config @@ -131,7 +131,12 @@ @@ -45,27 +45,26 @@ index 63a119a..61f2cc5 100644 # define _LIBCPP_FILESYSTEM_USE_SENDFILE #elif defined(__APPLE__) || __has_include(<copyfile.h>) diff --git a/src/new.cpp b/src/new.cpp -index c435c5f..6d5b221 100644 +index 033bba5..318b062 100644 --- a/src/new.cpp +++ b/src/new.cpp -@@ -37,8 +37,17 @@ operator new(std::size_t size) _THROW_BAD_ALLOC - else - #ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw std::bad_alloc(); -+#else -+#ifdef __EMSCRIPTEN__ -+ // Abort here so that when exceptions are disabled, we do not just -+ // return 0 when malloc returns 0. -+ // We could also do this with set_new_handler, but that adds a -+ // global constructor and a table entry, overhead that we can avoid -+ // by doing it this way. -+ abort(); - #else - break; -+#endif - #endif - } - return p; +@@ -41,6 +41,16 @@ _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC { + # ifndef _LIBCPP_HAS_NO_EXCEPTIONS + if (p == nullptr) + throw std::bad_alloc(); ++# else ++# ifdef __EMSCRIPTEN__ ++ if (p == nullptr) ++ // Abort here so that when exceptions are disabled, we do not just ++ // return 0 when malloc returns 0. ++ // We could also do this with set_new_handler, but that adds a ++ // global constructor and a table entry, overhead that we can avoid ++ // by doing it this way. ++ abort(); ++# endif + # endif + return p; + } diff --git a/src/support/runtime/exception_fallback.ipp b/src/support/runtime/exception_fallback.ipp index 3b2716d..c14c375 100644 --- a/src/support/runtime/exception_fallback.ipp diff --git a/contrib/libs/cxxsupp/libcxx/patches/22__config.patch b/contrib/libs/cxxsupp/libcxx/patches/22__config.patch index 7cfe9240d7..e974271645 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/22__config.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/22__config.patch @@ -1,5 +1,5 @@ diff --git a/include/__config b/include/__config -index e431997..3b1c3a6 100644 +index ab696fb..6e3b0e3 100644 --- a/include/__config +++ b/include/__config @@ -28,13 +28,35 @@ @@ -48,7 +48,7 @@ index e431997..3b1c3a6 100644 # define _LIBCPP_OBJECT_FORMAT_COFF 1 # elif defined(__wasm__) # define _LIBCPP_OBJECT_FORMAT_WASM 1 -@@ -772,7 +794,7 @@ typedef __char32_t char32_t; +@@ -771,7 +793,7 @@ typedef __char32_t char32_t; // TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing // the length of symbols with an ABI tag. In practice, we should remove the escape hatch and // use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70. @@ -57,7 +57,7 @@ index e431997..3b1c3a6 100644 # define _LIBCPP_HIDE_FROM_ABI \ _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \ __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_VERSIONED_IDENTIFIER)))) -@@ -1075,7 +1097,8 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c +@@ -1074,7 +1096,8 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c defined(__APPLE__) || \ defined(__MVS__) || \ defined(_AIX) || \ @@ -67,7 +67,7 @@ index e431997..3b1c3a6 100644 // clang-format on # define _LIBCPP_HAS_THREAD_API_PTHREAD # elif defined(__Fuchsia__) -@@ -1211,6 +1234,10 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c +@@ -1210,6 +1233,10 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c # define _LIBCPP_CONSTINIT # endif @@ -78,7 +78,7 @@ index e431997..3b1c3a6 100644 # if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS) # define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning"))) # else -@@ -1232,6 +1259,12 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c +@@ -1231,6 +1258,12 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c # define _LIBCPP_LIFETIMEBOUND # endif @@ -91,7 +91,7 @@ index e431997..3b1c3a6 100644 # if __has_attribute(__nodebug__) # define _LIBCPP_NODEBUG __attribute__((__nodebug__)) # else -@@ -1289,6 +1322,10 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c +@@ -1288,6 +1321,10 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c # define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS # endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES diff --git a/contrib/libs/cxxsupp/libcxx/patches/27-bitset.patch b/contrib/libs/cxxsupp/libcxx/patches/27-bitset.patch index c7a2678844..d6113b4851 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/27-bitset.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/27-bitset.patch @@ -1,8 +1,8 @@ diff --git a/include/bitset b/include/bitset -index e4c01e6..7ad332c 100644 +index a3b1dc3..d7112a7 100644 --- a/include/bitset +++ b/include/bitset -@@ -150,6 +150,10 @@ _LIBCPP_PUSH_MACROS +@@ -151,6 +151,10 @@ _LIBCPP_PUSH_MACROS #include <__undef_macros> @@ -13,7 +13,7 @@ index e4c01e6..7ad332c 100644 _LIBCPP_BEGIN_NAMESPACE_STD template <size_t _N_words, size_t _Size> -@@ -289,9 +293,9 @@ inline +@@ -290,9 +294,9 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT #ifndef _LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch b/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch index ca2774a7b6..4dc661418a 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/28-cudacc.patch @@ -1,3 +1,16 @@ +diff --git a/include/__iterator/reverse_iterator.h b/include/__iterator/reverse_iterator.h +index beb10f7..c1241da 100644 +--- a/include/__iterator/reverse_iterator.h ++++ b/include/__iterator/reverse_iterator.h +@@ -144,7 +144,7 @@ public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX17 + reference operator*() const {_Iter __tmp = current; return *--__tmp;} + +-#if _LIBCPP_STD_VER >= 20 ++#if (_LIBCPP_STD_VER >= 20) && !defined(__CUDACC__) + _LIBCPP_INLINE_VISIBILITY + constexpr pointer operator->() const + requires is_pointer_v<_Iter> || requires(const _Iter __i) { __i.operator->(); } diff --git a/include/__iterator/segmented_iterator.h b/include/__iterator/segmented_iterator.h index f3cd1e5..c0a77ef 100644 --- a/include/__iterator/segmented_iterator.h @@ -57,7 +70,7 @@ index c8ffde9..7f44242 100644 } // namespace literals #endif diff --git a/include/tuple b/include/tuple -index e7fc1e2..eb1785c 100644 +index 138c132..63adb8e 100644 --- a/include/tuple +++ b/include/tuple @@ -308,7 +308,7 @@ class __tuple_leaf @@ -69,3 +82,16 @@ index e7fc1e2..eb1785c 100644 return !__reference_binds_to_temporary(_Hp, _Tp); #else return true; +@@ -670,6 +670,12 @@ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") + _And< + _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, + _EnableUTypesCtor<_Up...> ++// nvcc 12.2 cannot choose between tuple(const T& ... t) and tuple(U&&... u) ++// so we have to added an explicit requires in enable_if ++#ifdef __CUDACC__ ++ , ++ _Not<_And<is_copy_constructible<_Tp>..., _Lazy<_And, is_convertible<_Up, const _Tp&>...>> > ++#endif + >::value + , int> = 0> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 diff --git a/contrib/libs/cxxsupp/libcxx/patches/43-string.patch b/contrib/libs/cxxsupp/libcxx/patches/43-string.patch index 10ffa7cbf3..88d1ef5e37 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/43-string.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/43-string.patch @@ -12,7 +12,7 @@ index 5bde46a..33bf0eb 100644 # endif diff --git a/include/string b/include/string -index 123e1d6..57624c7 100644 +index 9193516..0ff5802 100644 --- a/include/string +++ b/include/string @@ -703,6 +703,7 @@ struct __init_with_sentinel_tag {}; @@ -23,7 +23,7 @@ index 123e1d6..57624c7 100644 public: typedef basic_string __self; typedef basic_string_view<_CharT, _Traits> __self_view; -@@ -947,9 +948,11 @@ public: +@@ -943,9 +944,11 @@ public: __init(__s, traits_type::length(__s)); } @@ -36,7 +36,7 @@ index 123e1d6..57624c7 100644 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n) : __r_(__default_init_tag(), __default_init_tag()) { -@@ -957,6 +960,9 @@ public: +@@ -953,6 +956,9 @@ public: __init(__s, __n); } @@ -46,7 +46,7 @@ index 123e1d6..57624c7 100644 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) : __r_(__default_init_tag(), __a) { -@@ -1120,7 +1126,7 @@ public: +@@ -1111,7 +1117,7 @@ public: #endif _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) {return assign(__s);} @@ -55,7 +55,7 @@ index 123e1d6..57624c7 100644 basic_string& operator=(nullptr_t) = delete; #endif _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); -@@ -1182,6 +1188,13 @@ public: +@@ -1173,6 +1179,13 @@ public: return (__is_long() ? __get_long_cap() : static_cast<size_type>(__min_cap)) - 1; } @@ -69,7 +69,7 @@ index 123e1d6..57624c7 100644 _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n, value_type __c); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void resize(size_type __n) { resize(__n, value_type()); } -@@ -1701,7 +1714,7 @@ public: +@@ -1706,7 +1719,7 @@ public: { return ends_with(__self_view(__s)); } #endif diff --git a/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch b/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch index f0fc358b91..08ac3b9d87 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/65-string-iterator-pointer.patch @@ -1,5 +1,5 @@ diff --git a/include/string b/include/string -index 57624c7..6550f5b 100644 +index 0ff5802..7320cf1 100644 --- a/include/string +++ b/include/string @@ -730,9 +730,14 @@ public: @@ -17,7 +17,7 @@ index 57624c7..6550f5b 100644 typedef std::reverse_iterator<iterator> reverse_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; -@@ -1131,6 +1136,7 @@ public: +@@ -1122,6 +1127,7 @@ public: #endif _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c); @@ -25,7 +25,7 @@ index 57624c7..6550f5b 100644 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT {return __make_iterator(__get_pointer());} -@@ -1143,6 +1149,22 @@ public: +@@ -1134,6 +1140,22 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator end() const _NOEXCEPT {return __make_const_iterator(__get_pointer() + size());} diff --git a/contrib/libs/cxxsupp/libcxx/patches/68-asan-contiguous-container.patch b/contrib/libs/cxxsupp/libcxx/patches/68-asan-contiguous-container.patch index 4845273a97..290678ca70 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/68-asan-contiguous-container.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/68-asan-contiguous-container.patch @@ -1,8 +1,8 @@ diff --git a/include/__config b/include/__config -index 3b1c3a6..0b4f9ef 100644 +index 6e3b0e3..c0af95d 100644 --- a/include/__config +++ b/include/__config -@@ -1063,7 +1063,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD +@@ -1062,7 +1062,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD # ifndef _LIBCPP_HAS_NO_ASAN extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*); diff --git a/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch b/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch index 6856fd613b..76711ef036 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/xxx-config-epilogue.patch @@ -1,8 +1,8 @@ diff --git a/include/__config b/include/__config -index 0b4f9ef..f804928 100644 +index c0af95d..4856162 100644 --- a/include/__config +++ b/include/__config -@@ -1517,4 +1517,7 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c +@@ -1516,4 +1516,7 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c #endif // __cplusplus diff --git a/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch b/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch index 0e2e9e1220..b0626579ba 100644 --- a/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch +++ b/contrib/libs/cxxsupp/libcxx/patches/yyy-enable-std-expected.patch @@ -12,7 +12,7 @@ index 27f01d9..174f97f 100644 _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/include/__expected/expected.h b/include/__expected/expected.h -index 045370a..3f468fc 100644 +index bf16c8f..3f25e00 100644 --- a/include/__expected/expected.h +++ b/include/__expected/expected.h @@ -62,7 +62,7 @@ diff --git a/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp b/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp index 01fe199acb..070f989194 100644 --- a/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/ios.instantiations.cpp @@ -31,7 +31,7 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostream<wchar_t>; #endif // Additional instantiations added later. Whether programs rely on these being -// available is protected by _LIBCPP_ABI_ENABLE_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1. +// available is protected by _LIBCPP_AVAILABILITY_HAS_NO_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1. template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringbuf<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_stringstream<char>; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ostringstream<char>; diff --git a/contrib/libs/cxxsupp/libcxx/src/new.cpp b/contrib/libs/cxxsupp/libcxx/src/new.cpp index 6d5b221198..318b062bb0 100644 --- a/contrib/libs/cxxsupp/libcxx/src/new.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/new.cpp @@ -20,248 +20,165 @@ // in this shared library, so that they can be overridden by programs // that define non-weak copies of the functions. -_LIBCPP_WEAK -void * -operator new(std::size_t size) _THROW_BAD_ALLOC -{ - if (size == 0) - size = 1; - void* p; - while ((p = std::malloc(size)) == nullptr) - { - // If malloc fails and there is a new_handler, - // call it to try free up memory. - std::new_handler nh = std::get_new_handler(); - if (nh) - nh(); - else -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw std::bad_alloc(); -#else -#ifdef __EMSCRIPTEN__ - // Abort here so that when exceptions are disabled, we do not just - // return 0 when malloc returns 0. - // We could also do this with set_new_handler, but that adds a - // global constructor and a table entry, overhead that we can avoid - // by doing it this way. - abort(); -#else - break; -#endif -#endif - } - return p; +static void* operator_new_impl(std::size_t size) noexcept { + if (size == 0) + size = 1; + void* p; + while ((p = std::malloc(size)) == nullptr) { + // If malloc fails and there is a new_handler, + // call it to try free up memory. + std::new_handler nh = std::get_new_handler(); + if (nh) + nh(); + else + break; + } + return p; +} + +_LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC { + void* p = operator_new_impl(size); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + if (p == nullptr) + throw std::bad_alloc(); +# else +# ifdef __EMSCRIPTEN__ + if (p == nullptr) + // Abort here so that when exceptions are disabled, we do not just + // return 0 when malloc returns 0. + // We could also do this with set_new_handler, but that adds a + // global constructor and a table entry, overhead that we can avoid + // by doing it this way. + abort(); +# endif +# endif + return p; +} + +_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { + void* p = nullptr; +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + try { +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + p = ::operator new(size); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + } catch (...) { + } +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + return p; +} + +_LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); } + +_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { + void* p = nullptr; +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + try { +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + p = ::operator new[](size); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + } catch (...) { + } +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + return p; +} + +_LIBCPP_WEAK void operator delete(void* ptr) noexcept { std::free(ptr); } + +_LIBCPP_WEAK void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); } + +_LIBCPP_WEAK void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); } + +_LIBCPP_WEAK void operator delete[](void* ptr) noexcept { ::operator delete(ptr); } + +_LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); } + +_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } + +# if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) + +static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) noexcept { + if (size == 0) + size = 1; + if (static_cast<size_t>(alignment) < sizeof(void*)) + alignment = std::align_val_t(sizeof(void*)); + + // Try allocating memory. If allocation fails and there is a new_handler, + // call it to try free up memory, and try again until it succeeds, or until + // the new_handler decides to terminate. + void* p; + while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr) { + std::new_handler nh = std::get_new_handler(); + if (nh) + nh(); + else + break; + } + return p; +} + +_LIBCPP_WEAK void* operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { + void* p = operator_new_aligned_impl(size, alignment); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + if (p == nullptr) + throw std::bad_alloc(); +# endif + return p; } -_LIBCPP_WEAK -void* -operator new(size_t size, const std::nothrow_t&) noexcept -{ - void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - p = ::operator new(size); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - } - catch (...) - { - } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - return p; +_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { + void* p = nullptr; +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + try { +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + p = ::operator new(size, alignment); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + } catch (...) { + } +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + return p; } -_LIBCPP_WEAK -void* -operator new[](size_t size) _THROW_BAD_ALLOC -{ - return ::operator new(size); +_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { + return ::operator new(size, alignment); } -_LIBCPP_WEAK -void* -operator new[](size_t size, const std::nothrow_t&) noexcept -{ - void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - p = ::operator new[](size); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - } - catch (...) - { - } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - return p; +_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { + void* p = nullptr; +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + try { +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + p = ::operator new[](size, alignment); +# ifndef _LIBCPP_HAS_NO_EXCEPTIONS + } catch (...) { + } +# endif // _LIBCPP_HAS_NO_EXCEPTIONS + return p; } -_LIBCPP_WEAK -void -operator delete(void* ptr) noexcept -{ - std::free(ptr); -} - -_LIBCPP_WEAK -void -operator delete(void* ptr, const std::nothrow_t&) noexcept -{ - ::operator delete(ptr); -} - -_LIBCPP_WEAK -void -operator delete(void* ptr, size_t) noexcept -{ - ::operator delete(ptr); -} - -_LIBCPP_WEAK -void -operator delete[] (void* ptr) noexcept -{ - ::operator delete(ptr); -} - -_LIBCPP_WEAK -void -operator delete[] (void* ptr, const std::nothrow_t&) noexcept -{ - ::operator delete[](ptr); -} - -_LIBCPP_WEAK -void -operator delete[] (void* ptr, size_t) noexcept -{ - ::operator delete[](ptr); -} - -#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) - -_LIBCPP_WEAK -void * -operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC -{ - if (size == 0) - size = 1; - if (static_cast<size_t>(alignment) < sizeof(void*)) - alignment = std::align_val_t(sizeof(void*)); - - // Try allocating memory. If allocation fails and there is a new_handler, - // call it to try free up memory, and try again until it succeeds, or until - // the new_handler decides to terminate. - // - // If allocation fails and there is no new_handler, we throw bad_alloc - // (or return nullptr if exceptions are disabled). - void* p; - while ((p = std::__libcpp_aligned_alloc(static_cast<std::size_t>(alignment), size)) == nullptr) - { - std::new_handler nh = std::get_new_handler(); - if (nh) - nh(); - else { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw std::bad_alloc(); -#else - break; -#endif - } - } - return p; -} - -_LIBCPP_WEAK -void* -operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ - void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - p = ::operator new(size, alignment); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - } - catch (...) - { - } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - return p; -} - -_LIBCPP_WEAK -void* -operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC -{ - return ::operator new(size, alignment); -} - -_LIBCPP_WEAK -void* -operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ - void* p = nullptr; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - try - { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - p = ::operator new[](size, alignment); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - } - catch (...) - { - } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS - return p; -} - -_LIBCPP_WEAK -void -operator delete(void* ptr, std::align_val_t) noexcept -{ - std::__libcpp_aligned_free(ptr); -} +_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); } -_LIBCPP_WEAK -void -operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ - ::operator delete(ptr, alignment); +_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { + ::operator delete(ptr, alignment); } -_LIBCPP_WEAK -void -operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept -{ - ::operator delete(ptr, alignment); +_LIBCPP_WEAK void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept { + ::operator delete(ptr, alignment); } -_LIBCPP_WEAK -void -operator delete[] (void* ptr, std::align_val_t alignment) noexcept -{ - ::operator delete(ptr, alignment); +_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment) noexcept { + ::operator delete(ptr, alignment); } -_LIBCPP_WEAK -void -operator delete[] (void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept -{ - ::operator delete[](ptr, alignment); +_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept { + ::operator delete[](ptr, alignment); } -_LIBCPP_WEAK -void -operator delete[] (void* ptr, size_t, std::align_val_t alignment) noexcept -{ - ::operator delete[](ptr, alignment); +_LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept { + ::operator delete[](ptr, alignment); } -#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION // ------------------ END COPY ------------------ #endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make index f38618b46a..7c9363a5d0 100644 --- a/contrib/libs/cxxsupp/libcxx/ya.make +++ b/contrib/libs/cxxsupp/libcxx/ya.make @@ -14,9 +14,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2023-10-05) +VERSION(2023-10-19) -ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/dc129d6f715cf83a2072fc8de8b4e4c70bca6935.tar.gz) +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/d173ce4a670e88b65c52f6fc1bf10d133ee35704.tar.gz) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxx/include diff --git a/contrib/libs/hyperscan/.yandex_meta/__init__.py b/contrib/libs/hyperscan/.yandex_meta/__init__.py index 82a4450293..c56235d3b4 100644 --- a/contrib/libs/hyperscan/.yandex_meta/__init__.py +++ b/contrib/libs/hyperscan/.yandex_meta/__init__.py @@ -103,11 +103,6 @@ def post_install(self): for runtime_name in RUNTIMES.keys(): instantiate_runtime(self, runtime_name=runtime_name, runtime_yamake=runtime_yamake) - with self.yamakes["runtime_avx512"] as m: - # Do not sanitize to workaround the ICE in clang-16 - # See DEVTOOLSSUPPORT-49258 for details. - m.NO_SANITIZE = True - with self.yamakes["."] as hyperscan: hyperscan.RECURSE = [f"runtime_{name}" for name in sorted(RUNTIMES.keys())] # rename make_unique into std::make_unique to resolve ambigousness with boost::make_unique diff --git a/contrib/libs/hyperscan/runtime_avx512/ya.make b/contrib/libs/hyperscan/runtime_avx512/ya.make index 402f020dfc..328de4c598 100644 --- a/contrib/libs/hyperscan/runtime_avx512/ya.make +++ b/contrib/libs/hyperscan/runtime_avx512/ya.make @@ -17,8 +17,6 @@ NO_COMPILER_WARNINGS() NO_RUNTIME() -NO_SANITIZE() - CFLAGS( ${SSE41_CFLAGS} -DHAVE_SSE41 diff --git a/contrib/libs/libidn/config-android.h b/contrib/libs/libidn/config-android.h new file mode 100644 index 0000000000..4acab536aa --- /dev/null +++ b/contrib/libs/libidn/config-android.h @@ -0,0 +1,5 @@ +#pragma once + +#include "config-linux.h" + +#undef ENABLE_NLS diff --git a/contrib/libs/libidn/config.h b/contrib/libs/libidn/config.h index 1614a4f2b6..8c623aca26 100644 --- a/contrib/libs/libidn/config.h +++ b/contrib/libs/libidn/config.h @@ -1,6 +1,8 @@ #pragma once -#if defined(__APPLE__) +#if defined(__ANDROID__) +# include "config-android.h" +#elif defined(__APPLE__) # include "config-osx.h" #elif defined(_MSC_VER) # include "config-win.h" diff --git a/contrib/libs/openssl/.yandex_meta/__init__.py b/contrib/libs/openssl/.yandex_meta/__init__.py index b1e69b9c4c..08770e451d 100644 --- a/contrib/libs/openssl/.yandex_meta/__init__.py +++ b/contrib/libs/openssl/.yandex_meta/__init__.py @@ -31,6 +31,10 @@ def post_install(self): m.SRCS = {P.relpath(s, "crypto") for s in m.SRCS} m.SRCS -= {"dso/dso_dlfcn.c", "rand/rand_vms.c"} + # Add suppression for ubsan, see also https://github.com/openssl/openssl/issues/22896 + with self.yamakes["crypto"] as m: + m.after("NO_RUNTIME", "SUPPRESSIONS(ubsan.supp)") + self.yamakes["crypto"].PEERDIR.add("library/cpp/sanitizer/include") self.yamakes["apps"].PEERDIR.add("library/cpp/sanitizer/include") @@ -142,6 +146,7 @@ openssl = NixProject( "asm/windows/", "openssl.package.json", "sanitizers.h", + "crypto/ubsan.supp", ], post_install=post_install, ) diff --git a/contrib/libs/openssl/crypto/ubsan.supp b/contrib/libs/openssl/crypto/ubsan.supp new file mode 100644 index 0000000000..bc65760319 --- /dev/null +++ b/contrib/libs/openssl/crypto/ubsan.supp @@ -0,0 +1,3 @@ +# clang17-rt and later emits diagnostig related to invalid function pointers +# See also https://github.com/openssl/openssl/issues/22896 +function:*contrib/libs/openssl/*.c diff --git a/contrib/libs/openssl/crypto/ya.make b/contrib/libs/openssl/crypto/ya.make index f588d9ff98..3bf6f03bdb 100644 --- a/contrib/libs/openssl/crypto/ya.make +++ b/contrib/libs/openssl/crypto/ya.make @@ -92,6 +92,8 @@ NO_COMPILER_WARNINGS() NO_RUNTIME() +SUPPRESSIONS(ubsan.supp) + CFLAGS( -DOPENSSL_BN_ASM_MONT -DOPENSSL_CPUID_OBJ diff --git a/contrib/libs/protobuf/python/ya.make b/contrib/libs/protobuf/python/ya.make index 39df5f256f..644b4c32d6 100644 --- a/contrib/libs/protobuf/python/ya.make +++ b/contrib/libs/protobuf/python/ya.make @@ -6,6 +6,11 @@ VERSION(Service-proxy-version) LICENSE(BSD-3-Clause) +SUBSCRIBER( + g:contrib + g:cpp-contrib +) + GENERATE_PY_PROTOS(contrib/libs/protobuf/src/google/protobuf/descriptor.proto) END() diff --git a/contrib/libs/tcmalloc/patches/handler.patch b/contrib/libs/tcmalloc/patches/handler.patch new file mode 100644 index 0000000000..ce30d7e1c2 --- /dev/null +++ b/contrib/libs/tcmalloc/patches/handler.patch @@ -0,0 +1,49 @@ +--- contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc (index) ++++ contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc (working tree) +@@ -468,6 +468,20 @@ void MallocExtension::EnableForkSupport() { + #endif + } + ++static std::atomic<MallocExtension::SoftMemoryLimitCallback*> SoftMemoryLimitHandler_; ++ ++void MallocExtension::SetSoftMemoryLimitHandler(SoftMemoryLimitCallback* handler) { ++#if ABSL_INTERNAL_HAVE_WEAK_MALLOCEXTENSION_STUBS ++ SoftMemoryLimitHandler_.store(handler); ++#endif ++} ++ ++MallocExtension::SoftMemoryLimitCallback* MallocExtension::GetSoftMemoryLimitHandler() { ++#if ABSL_INTERNAL_HAVE_WEAK_MALLOCEXTENSION_STUBS ++ return SoftMemoryLimitHandler_.load(); ++#endif ++} ++ + void MallocExtension::SetSampleUserDataCallbacks( + CreateSampleUserDataCallback create, + CopySampleUserDataCallback copy, +--- contrib/libs/tcmalloc/tcmalloc/malloc_extension.h (index) ++++ contrib/libs/tcmalloc/tcmalloc/malloc_extension.h (working tree) +@@ -475,6 +475,10 @@ class MallocExtension final { + // Allocator will continue to function correctly in the child, after calling fork(). + static void EnableForkSupport(); + ++ using SoftMemoryLimitCallback = void(); ++ static void SetSoftMemoryLimitHandler(SoftMemoryLimitCallback* handler); ++ static SoftMemoryLimitCallback* GetSoftMemoryLimitHandler(); ++ + using CreateSampleUserDataCallback = void*(); + using CopySampleUserDataCallback = void*(void*); + using DestroySampleUserDataCallback = void(void*); +--- contrib/libs/tcmalloc/tcmalloc/page_allocator.cc (index) ++++ contrib/libs/tcmalloc/tcmalloc/page_allocator.cc (working tree) +@@ -151,6 +151,10 @@ void PageAllocator::ShrinkToUsageLimit() { + warned = true; + Log(kLogWithStack, __FILE__, __LINE__, "Couldn't respect usage limit of ", + limit_, "and OOM is likely to follow."); ++ ++ if (auto* handler = MallocExtension::GetSoftMemoryLimitHandler()) { ++ (*handler)(); ++ } + } + + bool PageAllocator::ShrinkHardBy(Length pages) { diff --git a/contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc b/contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc index ad3205fcdc..5a4ad70043 100644 --- a/contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc +++ b/contrib/libs/tcmalloc/tcmalloc/malloc_extension.cc @@ -468,6 +468,20 @@ void MallocExtension::EnableForkSupport() { #endif } +static std::atomic<MallocExtension::SoftMemoryLimitCallback*> SoftMemoryLimitHandler_; + +void MallocExtension::SetSoftMemoryLimitHandler(SoftMemoryLimitCallback* handler) { +#if ABSL_INTERNAL_HAVE_WEAK_MALLOCEXTENSION_STUBS + SoftMemoryLimitHandler_.store(handler); +#endif +} + +MallocExtension::SoftMemoryLimitCallback* MallocExtension::GetSoftMemoryLimitHandler() { +#if ABSL_INTERNAL_HAVE_WEAK_MALLOCEXTENSION_STUBS + return SoftMemoryLimitHandler_.load(); +#endif +} + void MallocExtension::SetSampleUserDataCallbacks( CreateSampleUserDataCallback create, CopySampleUserDataCallback copy, diff --git a/contrib/libs/tcmalloc/tcmalloc/malloc_extension.h b/contrib/libs/tcmalloc/tcmalloc/malloc_extension.h index fcbd347ca1..19b68ba8ac 100644 --- a/contrib/libs/tcmalloc/tcmalloc/malloc_extension.h +++ b/contrib/libs/tcmalloc/tcmalloc/malloc_extension.h @@ -475,6 +475,10 @@ class MallocExtension final { // Allocator will continue to function correctly in the child, after calling fork(). static void EnableForkSupport(); + using SoftMemoryLimitCallback = void(); + static void SetSoftMemoryLimitHandler(SoftMemoryLimitCallback* handler); + static SoftMemoryLimitCallback* GetSoftMemoryLimitHandler(); + using CreateSampleUserDataCallback = void*(); using CopySampleUserDataCallback = void*(void*); using DestroySampleUserDataCallback = void(void*); diff --git a/contrib/libs/tcmalloc/tcmalloc/page_allocator.cc b/contrib/libs/tcmalloc/tcmalloc/page_allocator.cc index e9599ef46a..2999b28ad9 100644 --- a/contrib/libs/tcmalloc/tcmalloc/page_allocator.cc +++ b/contrib/libs/tcmalloc/tcmalloc/page_allocator.cc @@ -151,6 +151,10 @@ void PageAllocator::ShrinkToUsageLimit() { warned = true; Log(kLogWithStack, __FILE__, __LINE__, "Couldn't respect usage limit of ", limit_, "and OOM is likely to follow."); + + if (auto* handler = MallocExtension::GetSoftMemoryLimitHandler()) { + (*handler)(); + } } bool PageAllocator::ShrinkHardBy(Length pages) { |