diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2023-10-16 00:19:28 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2023-10-16 00:40:55 +0300 |
commit | 03562c20be10d96a02cbd83773bf2f3a17c70142 (patch) | |
tree | 3762df6744c5c017b011997a08aeb20d2f92f1a5 /contrib/libs | |
parent | 6851965da19965a2680cfea6815b486fb14e739d (diff) | |
download | ydb-03562c20be10d96a02cbd83773bf2f3a17c70142.tar.gz |
Revert commit rXXXXXX, Upd libc++ to 18 May 4ac0589122830fc6d90e0ea091300c0b979a42dc
Diffstat (limited to 'contrib/libs')
46 files changed, 578 insertions, 1785 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h deleted file mode 100644 index f284c0ee3a..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each.h +++ /dev/null @@ -1,78 +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___ALGORITHM_RANGES_FOR_EACH_H -#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H - -#include <__algorithm/in_fun_result.h> -#include <__config> -#include <__functional/identity.h> -#include <__functional/invoke.h> -#include <__iterator/concepts.h> -#include <__iterator/projected.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__ranges/dangling.h> -#include <__utility/move.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace ranges { - -template <class _Iter, class _Func> -using for_each_result = in_fun_result<_Iter, _Func>; - -namespace __for_each { -struct __fn { -private: - template <class _Iter, class _Sent, class _Proj, class _Func> - _LIBCPP_HIDE_FROM_ABI constexpr static - for_each_result<_Iter, _Func> __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) { - for (; __first != __last; ++__first) - std::invoke(__func, std::invoke(__proj, *__first)); - return {std::move(__first), std::move(__func)}; - } - -public: - template <input_iterator _Iter, sentinel_for<_Iter> _Sent, - class _Proj = identity, - indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> - _LIBCPP_HIDE_FROM_ABI constexpr - for_each_result<_Iter, _Func> operator()(_Iter __first, _Sent __last, _Func __func, _Proj __proj = {}) const { - return __for_each_impl(std::move(__first), std::move(__last), __func, __proj); - } - - template <input_range _Range, - class _Proj = identity, - indirectly_unary_invocable<projected<iterator_t<_Range>, _Proj>> _Func> - _LIBCPP_HIDE_FROM_ABI constexpr - for_each_result<borrowed_iterator_t<_Range>, _Func> operator()(_Range&& __range, - _Func __func, - _Proj __proj = {}) const { - return __for_each_impl(ranges::begin(__range), ranges::end(__range), __func, __proj); - } - -}; -} // namespace __for_each - -inline namespace __cpo { - inline constexpr auto for_each = __for_each::__fn{}; -} // namespace __cpo -} // namespace ranges - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h deleted file mode 100644 index f40f849a00..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_for_each_n.h +++ /dev/null @@ -1,66 +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___ALGORITHM_RANGES_FOR_EACH_N_H -#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H - -#include <__algorithm/in_fun_result.h> -#include <__config> -#include <__functional/identity.h> -#include <__functional/invoke.h> -#include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> -#include <__iterator/projected.h> -#include <__ranges/concepts.h> -#include <__ranges/dangling.h> -#include <__utility/move.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace ranges { - -template <class _Iter, class _Func> -using for_each_n_result = in_fun_result<_Iter, _Func>; - -namespace __for_each_n { -struct __fn { - - template <input_iterator _Iter, - class _Proj = identity, - indirectly_unary_invocable<projected<_Iter, _Proj>> _Func> - _LIBCPP_HIDE_FROM_ABI constexpr - for_each_n_result<_Iter, _Func> operator()(_Iter __first, - iter_difference_t<_Iter> __count, - _Func __func, - _Proj __proj = {}) const { - while (__count-- > 0) { - std::invoke(__func, std::invoke(__proj, *__first)); - ++__first; - } - return {std::move(__first), std::move(__func)}; - } - -}; -} // namespace __for_each_n - -inline namespace __cpo { - inline constexpr auto for_each_n = __for_each_n::__fn{}; -} // namespace __cpo -} // namespace ranges - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -#endif // _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h deleted file mode 100644 index 3d572895eb..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_is_partitioned.h +++ /dev/null @@ -1,81 +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___ALGORITHM_RANGES_IS_PARTITIONED_H -#define _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H - -#include <__config> -#include <__functional/identity.h> -#include <__functional/invoke.h> -#include <__iterator/concepts.h> -#include <__iterator/indirectly_comparable.h> -#include <__iterator/projected.h> -#include <__ranges/access.h> -#include <__ranges/concepts.h> -#include <__utility/move.h> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -_LIBCPP_BEGIN_NAMESPACE_STD - -namespace ranges { -namespace __is_partitioned { -struct __fn { - - template <class _Iter, class _Sent, class _Proj, class _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr static - bool __is_parititioned_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) { - for (; __first != __last; ++__first) { - if (!std::invoke(__pred, std::invoke(__proj, *__first))) - break; - } - - if (__first == __last) - return true; - ++__first; - - for (; __first != __last; ++__first) { - if (std::invoke(__pred, std::invoke(__proj, *__first))) - return false; - } - - return true; - } - - template <input_iterator _Iter, sentinel_for<_Iter> _Sent, - class _Proj = identity, - indirect_unary_predicate<projected<_Iter, _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr - bool operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const { - return __is_parititioned_impl(std::move(__first), std::move(__last), __pred, __proj); - } - - template <input_range _Range, - class _Proj = identity, - indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred> - _LIBCPP_HIDE_FROM_ABI constexpr - bool operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const { - return __is_parititioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj); - } -}; -} // namespace __is_partitioned - -inline namespace __cpo { - inline constexpr auto is_partitioned = __is_partitioned::__fn{}; -} // namespace __cpo -} // namespace ranges - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) - -#endif // _LIBCPP___ALGORITHM_RANGES_IS_PARTITIONED_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__concepts/arithmetic.h b/contrib/libs/cxxsupp/libcxx/include/__concepts/arithmetic.h index 023f031e7e..ed0a95d6e4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__concepts/arithmetic.h +++ b/contrib/libs/cxxsupp/libcxx/include/__concepts/arithmetic.h @@ -39,6 +39,8 @@ concept floating_point = is_floating_point_v<_Tp>; template <class _Tp> concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value; template <class _Tp> +concept __libcpp_not_integral = !is_integral_v<_Tp>; +template <class _Tp> concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value; #endif // _LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config index 3e1a53e6e6..bea1b6a0b9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config +++ b/contrib/libs/cxxsupp/libcxx/include/__config @@ -368,7 +368,7 @@ // When this option is used, the token passed to `std::random_device`'s // constructor *must* be "/dev/urandom" -- anything else is an error. #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \ - defined(__OpenBSD__) || defined(__DragonFly__) || defined(__sun__) + defined(__OpenBSD__) || defined(__DragonFly__) # define _LIBCPP_USING_ARC4_RANDOM #elif defined(__wasi__) # define _LIBCPP_USING_GETENTROPY diff --git a/contrib/libs/cxxsupp/libcxx/include/__debug b/contrib/libs/cxxsupp/libcxx/include/__debug index 39539af0e9..1296b4db5b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__debug +++ b/contrib/libs/cxxsupp/libcxx/include/__debug @@ -226,37 +226,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_inser #endif } -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_erase_c(_Tp* __c) { -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__erase_c(__c); -#else - (void)(__c); -#endif -} - -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_swap(_Tp* __lhs, _Tp* __rhs) { -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->swap(__lhs, __rhs); -#else - (void)(__lhs); - (void)(__rhs); -#endif -} - -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 inline void __debug_db_invalidate_all(_Tp* __c) { -#if _LIBCPP_DEBUG_LEVEL == 2 - if (!__libcpp_is_constant_evaluated()) - __get_db()->__invalidate_all(__c); -#else - (void)(__c); -#endif -} - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___DEBUG diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h b/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h index 14926e32c6..e5c3b9fda2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/buffer.h @@ -11,16 +11,12 @@ #define _LIBCPP___FORMAT_BUFFER_H #include <__algorithm/copy_n.h> -#include <__algorithm/max.h> -#include <__algorithm/min.h> #include <__algorithm/unwrap_iter.h> #include <__config> #include <__format/enable_insertable.h> -#include <__format/format_to_n_result.h> #include <__format/formatter.h> // for __char_type TODO FMT Move the concept? #include <__iterator/back_insert_iterator.h> #include <__iterator/concepts.h> -#include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> #include <__iterator/wrap_iter.h> #include <__utility/move.h> @@ -32,9 +28,6 @@ # pragma GCC system_header #endif -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 @@ -274,97 +267,10 @@ private: size_t __size_{0}; }; -/// The base of a buffer that counts and limits the number of insertions. -template <class _OutIt, __formatter::__char_type _CharT, bool> - requires(output_iterator<_OutIt, const _CharT&>) -struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base { - using _Size = iter_difference_t<_OutIt>; - -public: - _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n) - : __writer_(_VSTD::move(__out_it)), __n_(_VSTD::max(_Size(0), __n)) {} - - _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { - if (_Size(__size_) <= __n_) - __writer_.flush(__ptr, _VSTD::min(_Size(__size), __n_ - __size_)); - __size_ += __size; - } - -protected: - __internal_storage<_CharT> __storage_; - __output_buffer<_CharT> __output_{__storage_.begin(), __storage_.capacity(), this}; - typename __writer_selector<_OutIt, _CharT>::type __writer_; - - _Size __n_; - _Size __size_{0}; -}; - -/// The base of a buffer that counts and limits the number of insertions. -/// -/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true. -/// -/// This class limits the size available the the direct writer so it will not -/// exceed the maximum number of code units. -template <class _OutIt, __formatter::__char_type _CharT> - requires(output_iterator<_OutIt, const _CharT&>) -class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> { - using _Size = iter_difference_t<_OutIt>; - -public: - _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __n) - : __output_(_VSTD::__unwrap_iter(__out_it), __n, this), __writer_(_VSTD::move(__out_it)) { - if (__n <= 0) [[unlikely]] - __output_.reset(__storage_.begin(), __storage_.capacity()); - } - - _LIBCPP_HIDE_FROM_ABI void flush(_CharT* __ptr, size_t __size) { - // A flush to the direct writer happens in two occasions: - // - The format function has written the maximum number of allowed code - // units. At this point it's no longer valid to write to this writer. So - // switch to the internal storage. This internal storage doesn't need to - // be written anywhere so the flush for that storage writes no output. - // - The format_to_n function is finished. In this case there's no need to - // switch the buffer, but for simplicity the buffers are still switched. - // When the __n <= 0 the constructor already switched the buffers. - if (__size_ == 0 && __ptr != __storage_.begin()) { - __writer_.flush(__ptr, __size); - __output_.reset(__storage_.begin(), __storage_.capacity()); - } - - __size_ += __size; - } - -protected: - __internal_storage<_CharT> __storage_; - __output_buffer<_CharT> __output_; - __writer_direct<_OutIt, _CharT> __writer_; - - _Size __size_{0}; -}; - -/// The buffer that counts and limits the number of insertions. -template <class _OutIt, __formatter::__char_type _CharT> - requires(output_iterator<_OutIt, const _CharT&>) -struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final - : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> { - using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>; - using _Size = iter_difference_t<_OutIt>; - -public: - _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __n) : _Base(_VSTD::move(__out_it), __n) {} - _LIBCPP_HIDE_FROM_ABI auto make_output_iterator() { return this->__output_.make_output_iterator(); } - - _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> result() && { - this->__output_.flush(); - return {_VSTD::move(this->__writer_).out(), this->__size_}; - } -}; } // namespace __format #endif //_LIBCPP_STD_VER > 17 _LIBCPP_END_NAMESPACE_STD -_LIBCPP_POP_MACROS - #endif // _LIBCPP___FORMAT_BUFFER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h b/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h deleted file mode 100644 index 8df6493b0a..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__format/concepts.h +++ /dev/null @@ -1,53 +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___FORMAT_CONCEPTS_H -#define _LIBCPP___FORMAT_CONCEPTS_H - -#include <__concepts/same_as.h> -#include <__concepts/semiregular.h> -#include <__config> -#include <__format/format_fwd.h> -#include <__format/format_parse_context.h> -#include <type_traits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -// The output iterator isn't specified. A formatter should accept any -// output_iterator. This iterator is a minimal iterator to test the concept. -// (Note testing for (w)format_context would be a valid choice, but requires -// selecting the proper one depending on the type of _CharT.) -template <class _CharT> -using __fmt_iter_for = _CharT*; - -// The concept is based on P2286R6 -// It lacks the const of __cf as required by, the not yet accepted, LWG-3636. -// The current formatters can't be easily adapted, but that is WIP. -// TODO FMT properly implement this concepts once accepted. -template <class _Tp, class _CharT> -concept __formattable = (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) && - requires(formatter<remove_cvref_t<_Tp>, _CharT> __f, - formatter<remove_cvref_t<_Tp>, _CharT> __cf, _Tp __t, - basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc, - basic_format_parse_context<_CharT> __pc) { - { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>; - { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>; - }; - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_CONCEPTS_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h index 3c61446378..845a20f3c7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg.h @@ -35,14 +35,6 @@ namespace __format { /// /// @note The 128-bit types are unconditionally in the list to avoid the values /// of the enums to depend on the availability of 128-bit integers. -/// -/// @note The value is stored as a 5-bit value in the __packed_arg_t_bits. This -/// limits the maximum number of elements to 32. -/// When modifying update the test -/// test/libcxx/utilities/format/format.arguments/format.arg/arg_t.compile.pass.cpp -/// It could be packed in 4-bits but that means a new type directly becomes an -/// ABI break. The packed type is 64-bit so this reduces the maximum number of -/// packed elements from 16 to 12. enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { __none, __boolean, @@ -61,151 +53,58 @@ enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t { __ptr, __handle }; - -inline constexpr unsigned __packed_arg_t_bits = 5; -inline constexpr uint8_t __packed_arg_t_mask = 0x1f; - -inline constexpr unsigned __packed_types_storage_bits = 64; -inline constexpr unsigned __packed_types_max = __packed_types_storage_bits / __packed_arg_t_bits; - -_LIBCPP_HIDE_FROM_ABI -constexpr bool __use_packed_format_arg_store(size_t __size) { return __size <= __packed_types_max; } - -_LIBCPP_HIDE_FROM_ABI -constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) { - _LIBCPP_ASSERT(__id <= __packed_types_max, ""); - - if (__id > 0) - __types >>= __id * __packed_arg_t_bits; - - return static_cast<__format::__arg_t>(__types & __packed_arg_t_mask); -} - } // namespace __format template <class _Visitor, class _Context> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) visit_format_arg(_Visitor&& __vis, - basic_format_arg<_Context> __arg) { +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto) +visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { switch (__arg.__type_) { case __format::__arg_t::__none: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), monostate{}); case __format::__arg_t::__boolean: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__boolean_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__boolean); case __format::__arg_t::__char_type: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__char_type_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__char_type); case __format::__arg_t::__int: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__int_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__int); case __format::__arg_t::__long_long: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_long_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_long); case __format::__arg_t::__i128: -# ifndef _LIBCPP_HAS_NO_INT128 - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__i128_); -# else +#ifndef _LIBCPP_HAS_NO_INT128 + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__i128); +#else __libcpp_unreachable(); -# endif +#endif case __format::__arg_t::__unsigned: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__unsigned); case __format::__arg_t::__unsigned_long_long: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), + __arg.__unsigned_long_long); case __format::__arg_t::__u128: -# ifndef _LIBCPP_HAS_NO_INT128 - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__u128_); -# else - __libcpp_unreachable(); -# endif +#ifndef _LIBCPP_HAS_NO_INT128 + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__u128); +#else + __libcpp_unreachable(); +#endif case __format::__arg_t::__float: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__float_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__float); case __format::__arg_t::__double: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__double_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__double); case __format::__arg_t::__long_double: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_double_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__long_double); case __format::__arg_t::__const_char_type_ptr: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), + __arg.__const_char_type_ptr); case __format::__arg_t::__string_view: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__string_view_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__string_view); case __format::__arg_t::__ptr: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__ptr_); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__ptr); case __format::__arg_t::__handle: - return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), - typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_}); + return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__handle); } - __libcpp_unreachable(); } -/// Contains the values used in basic_format_arg. -/// -/// This is a separate type so it's possible to store the values and types in -/// separate arrays. -template <class _Context> -class __basic_format_arg_value { - using _CharT = typename _Context::char_type; - -public: - /// Contains the implementation for basic_format_arg::handle. - struct __handle { - template <class _Tp> - _LIBCPP_HIDE_FROM_ABI explicit __handle(const _Tp& __v) noexcept - : __ptr_(_VSTD::addressof(__v)), - __format_([](basic_format_parse_context<_CharT>& __parse_ctx, _Context& __ctx, const void* __ptr) { - using _Formatter = typename _Context::template formatter_type<_Tp>; - using _Qp = conditional_t<requires { _Formatter().format(declval<const _Tp&>(), declval<_Context&>()); }, - const _Tp, _Tp>; - _Formatter __f; - __parse_ctx.advance_to(__f.parse(__parse_ctx)); - __ctx.advance_to(__f.format(*const_cast<_Qp*>(static_cast<const _Tp*>(__ptr)), __ctx)); - }) {} - - const void* __ptr_; - void (*__format_)(basic_format_parse_context<_CharT>&, _Context&, const void*); - }; - - union { - monostate __monostate_; - bool __boolean_; - _CharT __char_type_; - int __int_; - unsigned __unsigned_; - long long __long_long_; - unsigned long long __unsigned_long_long_; -# ifndef _LIBCPP_HAS_NO_INT128 - __int128_t __i128_; - __uint128_t __u128_; -# endif - float __float_; - double __double_; - long double __long_double_; - const _CharT* __const_char_type_ptr_; - basic_string_view<_CharT> __string_view_; - const void* __ptr_; - __handle __handle_; - }; - - // These constructors contain the exact storage type used. If adjustments are - // required, these will be done in __create_format_arg. - - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value() noexcept : __monostate_() {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(bool __value) noexcept : __boolean_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(_CharT __value) noexcept : __char_type_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(int __value) noexcept : __int_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned __value) noexcept : __unsigned_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept - : __unsigned_long_long_(__value) {} -# ifndef _LIBCPP_HAS_NO_INT128 - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {} -# endif - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(float __value) noexcept : __float_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(double __value) noexcept : __double_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long double __value) noexcept : __long_double_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const _CharT* __value) noexcept : __const_char_type_ptr_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(basic_string_view<_CharT> __value) noexcept - : __string_view_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const void* __value) noexcept : __ptr_(__value) {} - _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle __value) noexcept : __handle_(__value) {} -}; - template <class _Context> class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg { public: @@ -232,28 +131,146 @@ private: // .format(declval<const T&>(), declval<Context&>()) // shall be well-formed when treated as an unevaluated operand. -public: - __basic_format_arg_value<_Context> __value_; + template <class _Ctx, class... _Args> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend __format_arg_store<_Ctx, _Args...> + make_format_args(const _Args&...); + + template <class _Visitor, class _Ctx> + _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT friend decltype(auto) + visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx> __arg); + + union { + bool __boolean; + char_type __char_type; + int __int; + unsigned __unsigned; + long long __long_long; + unsigned long long __unsigned_long_long; +#ifndef _LIBCPP_HAS_NO_INT128 + __int128_t __i128; + __uint128_t __u128; +#endif + float __float; + double __double; + long double __long_double; + const char_type* __const_char_type_ptr; + basic_string_view<char_type> __string_view; + const void* __ptr; + handle __handle; + }; __format::__arg_t __type_; - _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type, - __basic_format_arg_value<_Context> __value) noexcept - : __value_(__value), __type_(__type) {} + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const bool& __v) noexcept + : __boolean(__v), __type_(__format::__arg_t::__boolean) {} + + template <class _Tp> + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept + requires(same_as<_Tp, char_type> || + (same_as<_Tp, char> && same_as<char_type, wchar_t>)) + : __char_type(__v), __type_(__format::__arg_t::__char_type) {} + + template <__libcpp_signed_integer _Tp> + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept { + if constexpr (sizeof(_Tp) <= sizeof(int)) { + __int = static_cast<int>(__v); + __type_ = __format::__arg_t::__int; + } else if constexpr (sizeof(_Tp) <= sizeof(long long)) { + __long_long = static_cast<long long>(__v); + __type_ = __format::__arg_t::__long_long; + } +#ifndef _LIBCPP_HAS_NO_INT128 + else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) { + __i128 = __v; + __type_ = __format::__arg_t::__i128; + } +#endif + else + static_assert(sizeof(_Tp) == 0, "An unsupported signed integer was used"); + } + + template <__libcpp_unsigned_integer _Tp> + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept { + if constexpr (sizeof(_Tp) <= sizeof(unsigned)) { + __unsigned = static_cast<unsigned>(__v); + __type_ = __format::__arg_t::__unsigned; + } else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) { + __unsigned_long_long = static_cast<unsigned long long>(__v); + __type_ = __format::__arg_t::__unsigned_long_long; + } +#ifndef _LIBCPP_HAS_NO_INT128 + else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) { + __u128 = __v; + __type_ = __format::__arg_t::__u128; + } +#endif + else + static_assert(sizeof(_Tp) == 0, + "An unsupported unsigned integer was used"); + } + + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(float __v) noexcept + : __float(__v), __type_(__format::__arg_t::__float) {} + + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(double __v) noexcept + : __double(__v), __type_(__format::__arg_t::__double) {} + + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(long double __v) noexcept + : __long_double(__v), __type_(__format::__arg_t::__long_double) {} + + // Note not a 'noexcept' function. + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const char_type* __s) + : __const_char_type_ptr(__s), + __type_(__format::__arg_t::__const_char_type_ptr) { + _LIBCPP_ASSERT(__s, "Used a nullptr argument to initialize a C-string"); + } + + template <class _Traits> + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg( + basic_string_view<char_type, _Traits> __s) noexcept + : __string_view{__s.data(), __s.size()}, + __type_(__format::__arg_t::__string_view) {} + + template <class _Traits, class _Allocator> + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg( + const basic_string<char_type, _Traits, _Allocator>& __s) noexcept + : __string_view{__s.data(), __s.size()}, + __type_(__format::__arg_t::__string_view) {} + + _LIBCPP_HIDE_FROM_ABI + explicit basic_format_arg(nullptr_t) noexcept + : __ptr(nullptr), __type_(__format::__arg_t::__ptr) {} + + template <class _Tp> + requires is_void_v<_Tp> _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(_Tp* __p) noexcept + : __ptr(__p), __type_(__format::__arg_t::__ptr) {} + + template <__libcpp_not_integral _Tp> + _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(const _Tp& __v) noexcept + : __handle(__v), __type_(__format::__arg_t::__handle) {} }; template <class _Context> class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle { + friend class basic_format_arg<_Context>; + public: _LIBCPP_HIDE_FROM_ABI void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const { - __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_); + __format_(__parse_ctx, __ctx, __ptr_); } - _LIBCPP_HIDE_FROM_ABI explicit handle(typename __basic_format_arg_value<_Context>::__handle __handle) noexcept - : __handle_(__handle) {} - private: - typename __basic_format_arg_value<_Context>::__handle __handle_; + const void* __ptr_; + void (*__format_)(basic_format_parse_context<char_type>&, _Context&, const void*); + + template <class _Tp> + _LIBCPP_HIDE_FROM_ABI explicit handle(const _Tp& __v) noexcept + : __ptr_(_VSTD::addressof(__v)), + __format_([](basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx, const void* __ptr) { + typename _Context::template formatter_type<_Tp> __f; + __parse_ctx.advance_to(__f.parse(__parse_ctx)); + __ctx.advance_to(__f.format(*static_cast<const _Tp*>(__ptr), __ctx)); + }) {} }; #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h deleted file mode 100644 index 4a3fcd4ff3..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_arg_store.h +++ /dev/null @@ -1,251 +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___FORMAT_FORMAT_ARG_STORE_H -#define _LIBCPP___FORMAT_FORMAT_ARG_STORE_H - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#include <__config> -#include <__format/concepts.h> -#include <__format/format_arg.h> -#include <__iterator/data.h> -#include <__iterator/size.h> -#include <cstring> -#include <string> -#include <string_view> -#include <type_traits> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -namespace __format { - -/// \returns The @c __arg_t based on the type of the formatting argument. -/// -/// \pre \c __formattable<_Tp, typename _Context::char_type> -template <class _Context, class _Tp> -consteval __arg_t __determine_arg_t(); - -// Boolean -template <class, same_as<bool> _Tp> -consteval __arg_t __determine_arg_t() { - return __arg_t::__boolean; -} - -// Char -template <class _Context, same_as<typename _Context::char_type> _Tp> -consteval __arg_t __determine_arg_t() { - return __arg_t::__char_type; -} -# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -template <class _Context, class _CharT> - requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>) -consteval __arg_t __determine_arg_t() { - return __arg_t::__char_type; -} -# endif - -// Signed integers -template <class, __libcpp_signed_integer _Tp> -consteval __arg_t __determine_arg_t() { - if constexpr (sizeof(_Tp) <= sizeof(int)) - return __arg_t::__int; - else if constexpr (sizeof(_Tp) <= sizeof(long long)) - return __arg_t::__long_long; -# ifndef _LIBCPP_HAS_NO_INT128 - else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) - return __arg_t::__i128; -# endif - else - static_assert(sizeof(_Tp) == 0, "an unsupported signed integer was used"); -} - -// Unsigned integers -template <class, __libcpp_unsigned_integer _Tp> -consteval __arg_t __determine_arg_t() { - if constexpr (sizeof(_Tp) <= sizeof(unsigned)) - return __arg_t::__unsigned; - else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) - return __arg_t::__unsigned_long_long; -# ifndef _LIBCPP_HAS_NO_INT128 - else if constexpr (sizeof(_Tp) == sizeof(__uint128_t)) - return __arg_t::__u128; -# endif - else - static_assert(sizeof(_Tp) == 0, "an unsupported unsigned integer was used"); -} - -// Floating-point -template <class, same_as<float> _Tp> -consteval __arg_t __determine_arg_t() { - return __arg_t::__float; -} -template <class, same_as<double> _Tp> -consteval __arg_t __determine_arg_t() { - return __arg_t::__double; -} -template <class, same_as<long double> _Tp> -consteval __arg_t __determine_arg_t() { - return __arg_t::__long_double; -} - -// Char pointer -template <class _Context, class _Tp> - requires(same_as<typename _Context::char_type*, _Tp> || same_as<const typename _Context::char_type*, _Tp>) -consteval __arg_t __determine_arg_t() { - return __arg_t::__const_char_type_ptr; -} - -// Char array -template <class _Context, class _Tp> - requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>) -consteval __arg_t __determine_arg_t() { - return __arg_t::__string_view; -} - -// String view -template <class _Context, class _Tp> - requires(same_as<typename _Context::char_type, typename _Tp::value_type> && - same_as<_Tp, basic_string_view<typename _Tp::value_type, typename _Tp::traits_type>>) -consteval __arg_t __determine_arg_t() { - return __arg_t::__string_view; -} - -// String -template <class _Context, class _Tp> - requires( - same_as<typename _Context::char_type, typename _Tp::value_type> && - same_as<_Tp, basic_string<typename _Tp::value_type, typename _Tp::traits_type, typename _Tp::allocator_type>>) -consteval __arg_t __determine_arg_t() { - return __arg_t::__string_view; -} - -// Pointers -template <class, class _Ptr> - requires(same_as<_Ptr, void*> || same_as<_Ptr, const void*> || same_as<_Ptr, nullptr_t>) -consteval __arg_t __determine_arg_t() { - return __arg_t::__ptr; -} - -// Handle -// -// Note this version can't be constrained avoiding ambiguous overloads. -// That means it can be instantiated by disabled formatters. To solve this, a -// constrained version for not formattable formatters is added. That overload -// is marked as deleted to fail creating a storage type for disabled formatters. -template <class _Context, class _Tp> -consteval __arg_t __determine_arg_t() { - return __arg_t::__handle; -} - -template <class _Context, class _Tp> - requires(!__formattable<_Tp, typename _Context::char_type>) -consteval __arg_t __determine_arg_t() = delete; - -template <class _Context, class _Tp> -_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp&& __value) noexcept { - constexpr __arg_t __arg = __determine_arg_t<_Context, remove_cvref_t<_Tp>>(); - static_assert(__arg != __arg_t::__none); - - // Not all types can be used to directly initialize the - // __basic_format_arg_value. First handle all types needing adjustment, the - // final else requires no adjustment. - if constexpr (__arg == __arg_t::__char_type) - // On some platforms initializing a wchar_t from a char is a narrowing - // conversion. - return basic_format_arg<_Context>{__arg, static_cast<typename _Context::char_type>(__value)}; - else if constexpr (__arg == __arg_t::__int) - return basic_format_arg<_Context>{__arg, static_cast<int>(__value)}; - else if constexpr (__arg == __arg_t::__long_long) - return basic_format_arg<_Context>{__arg, static_cast<long long>(__value)}; - else if constexpr (__arg == __arg_t::__unsigned) - return basic_format_arg<_Context>{__arg, static_cast<unsigned>(__value)}; - else if constexpr (__arg == __arg_t::__unsigned_long_long) - return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)}; - else if constexpr (__arg == __arg_t::__string_view) - // When the _Traits or _Allocator are different an implicit conversion will - // fail. - // - // Note since the input can be an array use the non-member functions to - // extract the constructor arguments. - return basic_format_arg<_Context>{ - __arg, basic_string_view<typename _Context::char_type>{_VSTD::data(__value), _VSTD::size(__value)}}; - else if constexpr (__arg == __arg_t::__ptr) - return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)}; - else if constexpr (__arg == __arg_t::__handle) - return basic_format_arg<_Context>{ - __arg, typename __basic_format_arg_value<_Context>::__handle{_VSTD::forward<_Tp>(__value)}}; - else - return basic_format_arg<_Context>{__arg, __value}; -} - -template <class _Context, class... _Args> -_LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_format_arg_value<_Context>* __values, - _Args&&... __args) noexcept { - int __shift = 0; - ( - [&] { - basic_format_arg<_Context> __arg = __create_format_arg<_Context>(_VSTD::forward<_Args>(__args)); - if (__shift != 0) - __types |= static_cast<uint64_t>(__arg.__type_) << __shift; - else - // Assigns the initial value. - __types = static_cast<uint64_t>(__arg.__type_); - __shift += __packed_arg_t_bits; - *__values++ = __arg.__value_; - }(), - ...); -} - -template <class _Context, class... _Args> -_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept { - ([&] { *__data++ = __create_format_arg<_Context>(_VSTD::forward<_Args>(__args)); }(), ...); -} - -template <class _Context, size_t N> -struct __packed_format_arg_store { - __basic_format_arg_value<_Context> __values_[N]; - uint64_t __types_; -}; - -template <class _Context, size_t N> -struct __unpacked_format_arg_store { - basic_format_arg<_Context> __args_[N]; -}; - -} // namespace __format - -template <class _Context, class... _Args> -struct _LIBCPP_TEMPLATE_VIS __format_arg_store { - _LIBCPP_HIDE_FROM_ABI - __format_arg_store(_Args&&... __args) noexcept { - if constexpr (sizeof...(_Args) != 0) { - if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) - __format::__create_packed_storage(__storage.__types_, __storage.__values_, _VSTD::forward<_Args>(__args)...); - else - __format::__store_basic_format_arg<_Context>(__storage.__args_, _VSTD::forward<_Args>(__args)...); - } - } - - using _Storage = conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)), - __format::__packed_format_arg_store<_Context, sizeof...(_Args)>, - __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>; - - _Storage __storage; -}; - -#endif //_LIBCPP_STD_VER > 17 - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP___FORMAT_FORMAT_ARG_STORE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h index d90dc50acb..40dde98400 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_args.h @@ -12,11 +12,8 @@ #include <__availability> #include <__config> -#include <__format/format_arg.h> -#include <__format/format_arg_store.h> #include <__format/format_fwd.h> #include <cstddef> -#include <cstdint> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -29,47 +26,29 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Context> class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args { public: + // TODO FMT Implement [format.args]/5 + // [Note 1: Implementations are encouraged to optimize the representation of + // basic_format_args for small number of formatting arguments by storing + // indices of type alternatives separately from values and packing the + // former. - end note] + // Note: Change __format_arg_store to use a built-in array. _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default; template <class... _Args> - _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept - : __size_(sizeof...(_Args)) { - if constexpr (sizeof...(_Args) != 0) { - if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) { - __values_ = __store.__storage.__values_; - __types_ = __store.__storage.__types_; - } else - __args_ = __store.__storage.__args_; - } - } + _LIBCPP_HIDE_FROM_ABI basic_format_args( + const __format_arg_store<_Context, _Args...>& __store) noexcept + : __size_(sizeof...(_Args)), __data_(__store.__args.data()) {} _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> get(size_t __id) const noexcept { - if (__id >= __size_) - return basic_format_arg<_Context>{}; - - if (__format::__use_packed_format_arg_store(__size_)) - return basic_format_arg<_Context>{__format::__get_packed_type(__types_, __id), __values_[__id]}; - - return __args_[__id]; + return __id < __size_ ? __data_[__id] : basic_format_arg<_Context>{}; } _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; } private: size_t __size_{0}; - // [format.args]/5 - // [Note 1: Implementations are encouraged to optimize the representation of - // basic_format_args for small number of formatting arguments by storing - // indices of type alternatives separately from values and packing the - // former. - end note] - union { - struct { - const __basic_format_arg_value<_Context>* __values_; - uint64_t __types_; - }; - const basic_format_arg<_Context>* __args_; - }; + const basic_format_arg<_Context>* __data_{nullptr}; }; #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/format_fwd.h b/contrib/libs/cxxsupp/libcxx/include/__format/format_fwd.h index f7c72e2121..0f2e9085f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/format_fwd.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/format_fwd.h @@ -12,7 +12,6 @@ #include <__availability> #include <__config> -#include <__iterator/concepts.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -25,9 +24,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Context> class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg; -template <class _OutIt, class _CharT> - requires output_iterator<_OutIt, const _CharT&> -class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context; +template <class _Context, class... _Args> +struct _LIBCPP_TEMPLATE_VIS __format_arg_store; template <class _Tp, class _CharT = char> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter; diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h index c687e3fd48..e78b43b8ca 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h @@ -101,18 +101,6 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT } }; -// Formatter char[]. -template <__formatter::__char_type _CharT, size_t _Size> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT> - : public __format_spec::__formatter_string<_CharT> { - static_assert(!is_const_v<_CharT>); - using _Base = __format_spec::__formatter_string<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) -> decltype(__ctx.out()) { - return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); - } -}; - // Formatter const char[]. template <__formatter::__char_type _CharT, size_t _Size> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h b/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h index f0a6e49875..d64981aa9e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/bind_back.h @@ -31,11 +31,12 @@ struct __bind_back_op; template <size_t _NBound, size_t ..._Ip> struct __bind_back_op<_NBound, index_sequence<_Ip...>> { - template <class _Fn, class _BoundArgs, class... _Args> - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const - noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...))) - -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)) - { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...); } + template <class _Fn, class _Bound, class ..._Args> + _LIBCPP_HIDE_FROM_ABI + constexpr auto operator()(_Fn&& __f, _Bound&& __bound, _Args&& ...__args) const + noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...))) + -> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...)) + { return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_Bound>(__bound))...); } }; template <class _Fn, class _BoundArgs> diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h deleted file mode 100644 index f38b8cfa05..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/span.h +++ /dev/null @@ -1,37 +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_FWD_SPAN_H -#define _LIBCPP_FWD_SPAN_H - -#include <__config> -#include <cstddef> -#include <limits> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_PUSH_MACROS -#include <__undef_macros> - -_LIBCPP_BEGIN_NAMESPACE_STD - -#if _LIBCPP_STD_VER > 17 - -inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); -template <typename _Tp, size_t _Extent = dynamic_extent> class span; - -#endif - -_LIBCPP_END_NAMESPACE_STD - -_LIBCPP_POP_MACROS - -#endif // _LIBCPP_FWD_SPAN_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__fwd/string_view.h b/contrib/libs/cxxsupp/libcxx/include/__fwd/string_view.h deleted file mode 100644 index e5e77b292a..0000000000 --- a/contrib/libs/cxxsupp/libcxx/include/__fwd/string_view.h +++ /dev/null @@ -1,37 +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_FWD_STRING_VIEW_H -#define _LIBCPP_FWD_STRING_VIEW_H - -#include <__config> -#include <iosfwd> // char_traits - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -_LIBCPP_BEGIN_NAMESPACE_STD - -template<class _CharT, class _Traits = char_traits<_CharT> > -class _LIBCPP_TEMPLATE_VIS basic_string_view; - -typedef basic_string_view<char> string_view; -#ifndef _LIBCPP_HAS_NO_CHAR8_T -typedef basic_string_view<char8_t> u8string_view; -#endif -typedef basic_string_view<char16_t> u16string_view; -typedef basic_string_view<char32_t> u32string_view; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -typedef basic_string_view<wchar_t> wstring_view; -#endif - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_FWD_STRING_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__hash_table b/contrib/libs/cxxsupp/libcxx/include/__hash_table index 14f53429de..605f13c360 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__hash_table +++ b/contrib/libs/cxxsupp/libcxx/include/__hash_table @@ -1519,7 +1519,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() #endif __deallocate_node(__p1_.first().__next_); - std::__debug_db_erase_c(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__erase_c(this); +#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -1622,7 +1624,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } - std::__debug_db_swap(this, std::addressof(__u)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -2324,7 +2328,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc> void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) { - std::__debug_db_invalidate_all(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__invalidate_all(this); +#endif __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); __bucket_list_.reset(__nbc > 0 ? __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); @@ -2730,7 +2736,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) if (__u.size() > 0) __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = __u.__p1_.first().__ptr(); - std::__debug_db_swap(this, std::addressof(__u)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Tp, class _Hash, class _Equal, class _Alloc> diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h index 28f09773a2..9a74f1421c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/advance.h @@ -117,46 +117,47 @@ public: } } - // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound_sentinel) denotes a range. + // Preconditions: Either `assignable_from<I&, S> || sized_sentinel_for<S, I>` is modeled, or [i, bound) denotes a range. template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, _Sp ___bound_sentinel) const { - // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound_sentinel)`. + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_Ip& __i, _Sp ___bound) const { + // If `I` and `S` model `assignable_from<I&, S>`, equivalent to `i = std::move(bound)`. if constexpr (assignable_from<_Ip&, _Sp>) { - __i = _VSTD::move(___bound_sentinel); + __i = _VSTD::move(___bound); } - // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound_sentinel - i)`. + // Otherwise, if `S` and `I` model `sized_sentinel_for<S, I>`, equivalent to `ranges::advance(i, bound - i)`. else if constexpr (sized_sentinel_for<_Sp, _Ip>) { - (*this)(__i, ___bound_sentinel - __i); + (*this)(__i, ___bound - __i); } - // Otherwise, while `bool(i != bound_sentinel)` is true, increments `i`. + // Otherwise, while `bool(i != bound)` is true, increments `i`. else { - while (__i != ___bound_sentinel) { + while (__i != ___bound) { ++__i; } } } // Preconditions: - // * If `n > 0`, [i, bound_sentinel) denotes a range. - // * If `n == 0`, [i, bound_sentinel) or [bound_sentinel, i) denotes a range. - // * If `n < 0`, [bound_sentinel, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`. - // Returns: `n - M`, where `M` is the difference between the ending and starting position. + // * If `n > 0`, [i, bound) denotes a range. + // * If `n == 0`, [i, bound) or [bound, i) denotes a range. + // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as<I, S>`. + // Returns: `n - M`, where `M` is the difference between the the ending and starting position. template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, - _Sp ___bound_sentinel) const { + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp ___bound) const { _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true."); // If `S` and `I` model `sized_sentinel_for<S, I>`: if constexpr (sized_sentinel_for<_Sp, _Ip>) { - // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`. + // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. // __magnitude_geq(a, b) returns |a| >= |b|, assuming they have the same sign. auto __magnitude_geq = [](auto __a, auto __b) { return __a == 0 ? __b == 0 : __a > 0 ? __a >= __b : __a <= __b; }; - if (const auto __M = ___bound_sentinel - __i; __magnitude_geq(__n, __M)) { - (*this)(__i, ___bound_sentinel); + if (const auto __M = ___bound - __i; __magnitude_geq(__n, __M)) { + (*this)(__i, ___bound); return __n - __M; } @@ -164,16 +165,16 @@ public: (*this)(__i, __n); return 0; } else { - // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at + // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at // most `n` times. - while (__i != ___bound_sentinel && __n > 0) { + while (__i != ___bound && __n > 0) { ++__i; --__n; } - // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times. + // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times. if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { - while (__i != ___bound_sentinel && __n < 0) { + while (__i != ___bound && __n < 0) { --__i; ++__n; } diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h index 0d48165168..7939840b6d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/next.h @@ -58,14 +58,16 @@ struct __fn { } template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, _Sp ___bound_sentinel) const { - ranges::advance(__x, ___bound_sentinel); + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, _Sp ___bound) const { + ranges::advance(__x, ___bound); return __x; } template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp> - _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp ___bound_sentinel) const { - ranges::advance(__x, __n, ___bound_sentinel); + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp ___bound) const { + ranges::advance(__x, __n, ___bound); return __x; } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h index 42d176ff65..e68b8759b7 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/prev.h @@ -57,8 +57,9 @@ struct __fn { } template <bidirectional_iterator _Ip> - _LIBCPP_HIDE_FROM_ABI constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip ___bound_iter) const { - ranges::advance(__x, -__n, ___bound_iter); + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip ___bound) const { + ranges::advance(__x, -__n, ___bound); return __x; } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h index 962bc4e900..93f4b9f188 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h @@ -9,29 +9,18 @@ #ifndef _LIBCPP___RANGES_DROP_VIEW_H #define _LIBCPP___RANGES_DROP_VIEW_H -#include <__algorithm/min.h> #include <__assert> #include <__config> -#include <__functional/bind_back.h> -#include <__fwd/span.h> -#include <__fwd/string_view.h> #include <__iterator/concepts.h> -#include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__iterator/next.h> #include <__ranges/access.h> #include <__ranges/all.h> #include <__ranges/concepts.h> -#include <__ranges/empty_view.h> #include <__ranges/enable_borrowed_range.h> -#include <__ranges/iota_view.h> #include <__ranges/non_propagating_cache.h> -#include <__ranges/range_adaptor.h> #include <__ranges/size.h> -#include <__ranges/subrange.h> #include <__ranges/view_interface.h> -#include <__utility/auto_cast.h> -#include <__utility/forward.h> #include <__utility/move.h> #include <concepts> #include <type_traits> @@ -124,174 +113,11 @@ public: { return __size(*this); } }; -template<class _Range> -drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>; - -template<class _Tp> -inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; - -namespace views { -namespace __drop { - -template <class _Tp> -inline constexpr bool __is_empty_view = false; - -template <class _Tp> -inline constexpr bool __is_empty_view<empty_view<_Tp>> = true; - -template <class _Tp> -inline constexpr bool __is_passthrough_specialization = false; - -template <class _Tp, size_t _Extent> -inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true; - -template <class _CharT, class _Traits> -inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true; - -template <class _Np, class _Bound> -inline constexpr bool __is_passthrough_specialization<iota_view<_Np, _Bound>> = true; - -template <class _Iter, class _Sent, subrange_kind _Kind> -inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = - !subrange<_Iter, _Sent, _Kind>::_StoreSize; - -template <class _Tp> -inline constexpr bool __is_subrange_specialization_with_store_size = false; - -template <class _Iter, class _Sent, subrange_kind _Kind> -inline constexpr bool __is_subrange_specialization_with_store_size<subrange<_Iter, _Sent, _Kind>> = - subrange<_Iter, _Sent, _Kind>::_StoreSize; - -template <class _Tp> -struct __passthrough_type; - -template <class _Tp, size_t _Extent> -struct __passthrough_type<span<_Tp, _Extent>> { - using type = span<_Tp>; -}; - -template <class _CharT, class _Traits> -struct __passthrough_type<basic_string_view<_CharT, _Traits>> { - using type = basic_string_view<_CharT, _Traits>; -}; - -template <class _Np, class _Bound> -struct __passthrough_type<iota_view<_Np, _Bound>> { - using type = iota_view<_Np, _Bound>; -}; - -template <class _Iter, class _Sent, subrange_kind _Kind> -struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { - using type = subrange<_Iter, _Sent, _Kind>; -}; - -template <class _Tp> -using __passthrough_type_t = typename __passthrough_type<_Tp>::type; - -struct __fn { - // [range.drop.overview]: the `empty_view` case. - template <class _Range, convertible_to<range_difference_t<_Range>> _Np> - requires __is_empty_view<remove_cvref_t<_Range>> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __range, _Np&&) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))) - -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) - { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); } - - // [range.drop.overview]: the `span | basic_string_view | iota_view | subrange (StoreSize == false)` case. - template <class _Range, - convertible_to<range_difference_t<_Range>> _Np, - class _RawRange = remove_cvref_t<_Range>, - class _Dist = range_difference_t<_Range>> - requires (!__is_empty_view<_RawRange> && - random_access_range<_RawRange> && - sized_range<_RawRange> && - __is_passthrough_specialization<_RawRange>) - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __rng, _Np&& __n) const - noexcept(noexcept(__passthrough_type_t<_RawRange>( - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), - ranges::end(__rng) - ))) - -> decltype( __passthrough_type_t<_RawRange>( - // Note: deliberately not forwarding `__rng` to guard against double moves. - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), - ranges::end(__rng) - )) - { return __passthrough_type_t<_RawRange>( - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), - ranges::end(__rng) - ); } - - // [range.drop.overview]: the `subrange (StoreSize == true)` case. - template <class _Range, - convertible_to<range_difference_t<_Range>> _Np, - class _RawRange = remove_cvref_t<_Range>, - class _Dist = range_difference_t<_Range>> - requires (!__is_empty_view<_RawRange> && - random_access_range<_RawRange> && - sized_range<_RawRange> && - __is_subrange_specialization_with_store_size<_RawRange>) - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __rng, _Np&& __n) const - noexcept(noexcept(_RawRange( - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), - ranges::end(__rng), - std::__to_unsigned_like(ranges::distance(__rng) - - std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))) - ))) - -> decltype( _RawRange( - // Note: deliberately not forwarding `__rng` to guard against double moves. - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)), - ranges::end(__rng), - std::__to_unsigned_like(ranges::distance(__rng) - - std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n))) - )) - { - // Introducing local variables avoids calculating `min` and `distance` twice (at the cost of diverging from the - // expression used in the `noexcept` clause and the return statement). - auto dist = ranges::distance(__rng); - auto clamped = std::min<_Dist>(dist, std::forward<_Np>(__n)); - return _RawRange( - ranges::begin(__rng) + clamped, - ranges::end(__rng), - std::__to_unsigned_like(dist - clamped) - );} - - // [range.drop.overview]: the "otherwise" case. - template <class _Range, convertible_to<range_difference_t<_Range>> _Np, - class _RawRange = remove_cvref_t<_Range>> - // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other - // overloads. - requires (!(__is_empty_view<_RawRange> || - (__is_subrange_specialization_with_store_size<_RawRange> && - sized_range<_RawRange> && - random_access_range<_RawRange>) || - (__is_passthrough_specialization<_RawRange> && - sized_range<_RawRange> && - random_access_range<_RawRange>) - )) - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __range, _Np&& __n) const - noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))) - -> decltype( drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) - { return drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); } - - template <class _Np> - requires constructible_from<decay_t<_Np>, _Np> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Np&& __n) const - noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) - { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); } -}; - -} // namespace __drop - -inline namespace __cpo { - inline constexpr auto drop = __drop::__fn{}; -} // namespace __cpo -} // namespace views + template<class _Range> + drop_view(_Range&&, range_difference_t<_Range>) -> drop_view<views::all_t<_Range>>; + template<class _Tp> + inline constexpr bool enable_borrowed_range<drop_view<_Tp>> = enable_borrowed_range<_Tp>; } // namespace ranges #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h index e1f03bafa0..62e98d475b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/iota_view.h @@ -90,9 +90,9 @@ namespace ranges { using iterator_category = input_iterator_tag; }; - template <weakly_incrementable _Start, semiregular _BoundSentinel = unreachable_sentinel_t> - requires __weakly_equality_comparable_with<_Start, _BoundSentinel> && copyable<_Start> - class iota_view : public view_interface<iota_view<_Start, _BoundSentinel>> { + template<weakly_incrementable _Start, semiregular _Bound = unreachable_sentinel_t> + requires __weakly_equality_comparable_with<_Start, _Bound> && copyable<_Start> + class iota_view : public view_interface<iota_view<_Start, _Bound>> { struct __iterator : public __iota_iterator_category<_Start> { friend class iota_view; @@ -271,35 +271,35 @@ namespace ranges { friend class iota_view; private: - _BoundSentinel __bound_sentinel_ = _BoundSentinel(); + _Bound __bound_ = _Bound(); public: _LIBCPP_HIDE_FROM_ABI __sentinel() = default; - constexpr explicit __sentinel(_BoundSentinel __bound_sentinel) : __bound_sentinel_(std::move(__bound_sentinel)) {} + constexpr explicit __sentinel(_Bound __bound) : __bound_(std::move(__bound)) {} _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __sentinel& __y) { - return __x.__value_ == __y.__bound_sentinel_; + return __x.__value_ == __y.__bound_; } _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Start> operator-(const __iterator& __x, const __sentinel& __y) - requires sized_sentinel_for<_BoundSentinel, _Start> + requires sized_sentinel_for<_Bound, _Start> { - return __x.__value_ - __y.__bound_sentinel_; + return __x.__value_ - __y.__bound_; } _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Start> operator-(const __sentinel& __x, const __iterator& __y) - requires sized_sentinel_for<_BoundSentinel, _Start> + requires sized_sentinel_for<_Bound, _Start> { return -(__y - __x); } }; _Start __value_ = _Start(); - _BoundSentinel __bound_sentinel_ = _BoundSentinel(); + _Bound __bound_ = _Bound(); public: _LIBCPP_HIDE_FROM_ABI @@ -309,76 +309,75 @@ namespace ranges { constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) { } _LIBCPP_HIDE_FROM_ABI - constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel) - : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) { + constexpr iota_view(type_identity_t<_Start> __value, type_identity_t<_Bound> __bound) + : __value_(std::move(__value)), __bound_(std::move(__bound)) { // Validate the precondition if possible. - if constexpr (totally_ordered_with<_Start, _BoundSentinel>) { - _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_sentinel_), + if constexpr (totally_ordered_with<_Start, _Bound>) { + _LIBCPP_ASSERT(ranges::less_equal()(__value_, __bound_), "Precondition violated: value is greater than bound."); } } _LIBCPP_HIDE_FROM_ABI constexpr iota_view(__iterator __first, __iterator __last) - requires same_as<_Start, _BoundSentinel> - : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {} + requires same_as<_Start, _Bound> + : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {} _LIBCPP_HIDE_FROM_ABI - constexpr iota_view(__iterator __first, _BoundSentinel __last) - requires same_as<_BoundSentinel, unreachable_sentinel_t> - : iota_view(std::move(__first.__value_), std::move(__last)) {} + constexpr iota_view(__iterator __first, _Bound __last) + requires same_as<_Bound, unreachable_sentinel_t> + : iota_view(std::move(__first.__value_), std::move(__last)) {} _LIBCPP_HIDE_FROM_ABI constexpr iota_view(__iterator __first, __sentinel __last) - requires(!same_as<_Start, _BoundSentinel> && !same_as<_Start, unreachable_sentinel_t>) - : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {} + requires (!same_as<_Start, _Bound> && !same_as<_Start, unreachable_sentinel_t>) + : iota_view(std::move(__first.__value_), std::move(__last.__bound_)) {} _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() const { return __iterator{__value_}; } _LIBCPP_HIDE_FROM_ABI constexpr auto end() const { - if constexpr (same_as<_BoundSentinel, unreachable_sentinel_t>) + if constexpr (same_as<_Bound, unreachable_sentinel_t>) return unreachable_sentinel; else - return __sentinel{__bound_sentinel_}; + return __sentinel{__bound_}; } _LIBCPP_HIDE_FROM_ABI - constexpr __iterator end() const - requires same_as<_Start, _BoundSentinel> - { - return __iterator{__bound_sentinel_}; + constexpr __iterator end() const requires same_as<_Start, _Bound> { + return __iterator{__bound_}; } _LIBCPP_HIDE_FROM_ABI constexpr auto size() const - requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) || - (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start> + requires (same_as<_Start, _Bound> && __advanceable<_Start>) || + (integral<_Start> && integral<_Bound>) || + sized_sentinel_for<_Bound, _Start> { - if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) { + if constexpr (__integer_like<_Start> && __integer_like<_Bound>) { if (__value_ < 0) { - if (__bound_sentinel_ < 0) { - return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_sentinel_); + if (__bound_ < 0) { + return std::__to_unsigned_like(-__value_) - std::__to_unsigned_like(-__bound_); } - return std::__to_unsigned_like(__bound_sentinel_) + std::__to_unsigned_like(-__value_); + return std::__to_unsigned_like(__bound_) + std::__to_unsigned_like(-__value_); } - return std::__to_unsigned_like(__bound_sentinel_) - std::__to_unsigned_like(__value_); + return std::__to_unsigned_like(__bound_) - std::__to_unsigned_like(__value_); } - return std::__to_unsigned_like(__bound_sentinel_ - __value_); + return std::__to_unsigned_like(__bound_ - __value_); } }; - template <class _Start, class _BoundSentinel> - requires(!__integer_like<_Start> || !__integer_like<_BoundSentinel> || - (__signed_integer_like<_Start> == __signed_integer_like<_BoundSentinel>)) - iota_view(_Start, _BoundSentinel) -> iota_view<_Start, _BoundSentinel>; + template<class _Start, class _Bound> + requires (!__integer_like<_Start> || !__integer_like<_Bound> || + (__signed_integer_like<_Start> == __signed_integer_like<_Bound>)) + iota_view(_Start, _Bound) -> iota_view<_Start, _Bound>; - template <class _Start, class _BoundSentinel> - inline constexpr bool enable_borrowed_range<iota_view<_Start, _BoundSentinel>> = true; + template<class _Start, class _Bound> + inline constexpr bool enable_borrowed_range<iota_view<_Start, _Bound>> = true; - namespace views { - namespace __iota { +namespace views { +namespace __iota { struct __fn { template<class _Start> _LIBCPP_HIDE_FROM_ABI @@ -387,11 +386,12 @@ namespace ranges { -> decltype( ranges::iota_view(std::forward<_Start>(__start))) { return ranges::iota_view(std::forward<_Start>(__start)); } - template <class _Start, class _BoundSentinel> - _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Start&& __start, _BoundSentinel&& __bound_sentinel) const - noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)))) - -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel))) - { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_BoundSentinel>(__bound_sentinel)); } + template<class _Start, class _Bound> + _LIBCPP_HIDE_FROM_ABI + constexpr auto operator()(_Start&& __start, _Bound&& __bound) const + noexcept(noexcept(ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)))) + -> decltype( ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound))) + { return ranges::iota_view(std::forward<_Start>(__start), std::forward<_Bound>(__bound)); } }; } // namespace __iota diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h index e559a76ef7..68617c48f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/lazy_split_view.h @@ -87,7 +87,8 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr lazy_split_view(_Range&& __r, range_value_t<_Range> __e) : __base_(views::all(std::forward<_Range>(__r))) - , __pattern_(views::single(std::move(__e))) {} + // TODO(varconst): use `views::single` once it's implemented. + , __pattern_(ranges::single_view(std::move(__e))) {} _LIBCPP_HIDE_FROM_ABI constexpr _View base() const& requires copy_constructible<_View> { return __base_; } diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h index 98ebe5f383..e6a873058f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/single_view.h @@ -11,7 +11,6 @@ #include <__config> #include <__ranges/copyable_box.h> -#include <__ranges/range_adaptor.h> #include <__ranges/view_interface.h> #include <__utility/forward.h> #include <__utility/in_place.h> @@ -71,27 +70,8 @@ namespace ranges { constexpr const _Tp* data() const noexcept { return __value_.operator->(); } }; -template<class _Tp> -single_view(_Tp) -> single_view<_Tp>; - -namespace views { -namespace __single_view { - -struct __fn : __range_adaptor_closure<__fn> { - template<class _Range> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __range) const - noexcept(noexcept(single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)))) - -> decltype( single_view<decay_t<_Range&&>>(std::forward<_Range>(__range))) - { return single_view<decay_t<_Range&&>>(std::forward<_Range>(__range)); } -}; -} // namespace __single_view - -inline namespace __cpo { - inline constexpr auto single = __single_view::__fn{}; -} // namespace __cpo - -} // namespace views + template<class _Tp> + single_view(_Tp) -> single_view<_Tp>; } // namespace ranges #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h index 7e42da6ce7..24e5eff3f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/subrange.h @@ -77,11 +77,8 @@ namespace ranges { class _LIBCPP_TEMPLATE_VIS subrange : public view_interface<subrange<_Iter, _Sent, _Kind>> { - public: - // Note: this is an internal implementation detail that is public only for internal usage. - static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>); - private: + static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>); static constexpr bool _MustProvideSizeAtConstruction = !_StoreSize; // just to improve compiler diagnostics struct _Empty { constexpr _Empty(auto) noexcept { } }; using _Size = conditional_t<_StoreSize, make_unsigned_t<iter_difference_t<_Iter>>, _Empty>; diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h index 11d5c9fc36..3ad7810a9c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/take_view.h @@ -9,29 +9,18 @@ #ifndef _LIBCPP___RANGES_TAKE_VIEW_H #define _LIBCPP___RANGES_TAKE_VIEW_H -#include <__algorithm/min.h> #include <__algorithm/ranges_min.h> #include <__config> -#include <__functional/bind_back.h> -#include <__fwd/span.h> -#include <__fwd/string_view.h> #include <__iterator/concepts.h> #include <__iterator/counted_iterator.h> #include <__iterator/default_sentinel.h> -#include <__iterator/distance.h> #include <__iterator/iterator_traits.h> #include <__ranges/access.h> #include <__ranges/all.h> #include <__ranges/concepts.h> -#include <__ranges/empty_view.h> #include <__ranges/enable_borrowed_range.h> -#include <__ranges/iota_view.h> -#include <__ranges/range_adaptor.h> #include <__ranges/size.h> -#include <__ranges/subrange.h> #include <__ranges/view_interface.h> -#include <__utility/auto_cast.h> -#include <__utility/forward.h> #include <__utility/move.h> #include <concepts> #include <type_traits> @@ -126,6 +115,7 @@ public: } } + _LIBCPP_HIDE_FROM_ABI constexpr auto size() requires sized_range<_View> { auto __n = ranges::size(__base_); @@ -184,148 +174,6 @@ take_view(_Range&&, range_difference_t<_Range>) -> take_view<views::all_t<_Range template<class _Tp> inline constexpr bool enable_borrowed_range<take_view<_Tp>> = enable_borrowed_range<_Tp>; -namespace views { -namespace __take { - -template <class _Tp> -inline constexpr bool __is_empty_view = false; - -template <class _Tp> -inline constexpr bool __is_empty_view<empty_view<_Tp>> = true; - -template <class _Tp> -inline constexpr bool __is_passthrough_specialization = false; - -template <class _Tp, size_t _Extent> -inline constexpr bool __is_passthrough_specialization<span<_Tp, _Extent>> = true; - -template <class _CharT, class _Traits> -inline constexpr bool __is_passthrough_specialization<basic_string_view<_CharT, _Traits>> = true; - -template <class _Iter, class _Sent, subrange_kind _Kind> -inline constexpr bool __is_passthrough_specialization<subrange<_Iter, _Sent, _Kind>> = true; - -template <class _Tp> -inline constexpr bool __is_iota_specialization = false; - -template <class _Np, class _Bound> -inline constexpr bool __is_iota_specialization<iota_view<_Np, _Bound>> = true; - -template <class _Tp> -struct __passthrough_type; - -template <class _Tp, size_t _Extent> -struct __passthrough_type<span<_Tp, _Extent>> { - using type = span<_Tp>; -}; - -template <class _CharT, class _Traits> -struct __passthrough_type<basic_string_view<_CharT, _Traits>> { - using type = basic_string_view<_CharT, _Traits>; -}; - -template <class _Iter, class _Sent, subrange_kind _Kind> -struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> { - using type = subrange<_Iter>; -}; - -template <class _Tp> -using __passthrough_type_t = typename __passthrough_type<_Tp>::type; - -struct __fn { - // [range.take.overview]: the `empty_view` case. - template <class _Range, convertible_to<range_difference_t<_Range>> _Np> - requires __is_empty_view<remove_cvref_t<_Range>> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __range, _Np&&) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))) - -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range))) - { return _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)); } - - // [range.take.overview]: the `span | basic_string_view | subrange` case. - template <class _Range, - convertible_to<range_difference_t<_Range>> _Np, - class _RawRange = remove_cvref_t<_Range>, - class _Dist = range_difference_t<_Range>> - requires (!__is_empty_view<_RawRange> && - random_access_range<_RawRange> && - sized_range<_RawRange> && - __is_passthrough_specialization<_RawRange>) - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __rng, _Np&& __n) const - noexcept(noexcept(__passthrough_type_t<_RawRange>( - ranges::begin(__rng), - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) - ))) - -> decltype( __passthrough_type_t<_RawRange>( - // Note: deliberately not forwarding `__rng` to guard against double moves. - ranges::begin(__rng), - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) - )) - { return __passthrough_type_t<_RawRange>( - ranges::begin(__rng), - ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) - ); } - - // [range.take.overview]: the `iota_view` case. - template <class _Range, - convertible_to<range_difference_t<_Range>> _Np, - class _RawRange = remove_cvref_t<_Range>, - class _Dist = range_difference_t<_Range>> - requires (!__is_empty_view<_RawRange> && - random_access_range<_RawRange> && - sized_range<_RawRange> && - __is_iota_specialization<_RawRange>) - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __rng, _Np&& __n) const - noexcept(noexcept(ranges::iota_view( - *ranges::begin(__rng), - *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) - ))) - -> decltype( ranges::iota_view( - // Note: deliberately not forwarding `__rng` to guard against double moves. - *ranges::begin(__rng), - *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) - )) - { return ranges::iota_view( - *ranges::begin(__rng), - *ranges::begin(__rng) + std::min<_Dist>(ranges::distance(__rng), std::forward<_Np>(__n)) - ); } - - // [range.take.overview]: the "otherwise" case. - template <class _Range, convertible_to<range_difference_t<_Range>> _Np, - class _RawRange = remove_cvref_t<_Range>> - // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other - // overloads. - requires (!(__is_empty_view<_RawRange> || - (__is_iota_specialization<_RawRange> && - sized_range<_RawRange> && - random_access_range<_RawRange>) || - (__is_passthrough_specialization<_RawRange> && - sized_range<_RawRange> && - random_access_range<_RawRange>) - )) - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Range&& __range, _Np&& __n) const - noexcept(noexcept(take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)))) - -> decltype( take_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) - { return take_view(std::forward<_Range>(__range), std::forward<_Np>(__n)); } - - template <class _Np> - requires constructible_from<decay_t<_Np>, _Np> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI - constexpr auto operator()(_Np&& __n) const - noexcept(is_nothrow_constructible_v<decay_t<_Np>, _Np>) - { return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Np>(__n))); } -}; - -} // namespace __take - -inline namespace __cpo { - inline constexpr auto take = __take::__fn{}; -} // namespace __cpo -} // namespace views - } // namespace ranges #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h index 2b2d927bae..46e02a6c8b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/gettod_zos.h @@ -12,8 +12,7 @@ #include <time.h> -inline _LIBCPP_HIDE_FROM_ABI int -gettimeofdayMonotonic(struct timespec64* Output) { +static inline int gettimeofdayMonotonic(struct timespec64* Output) { // The POSIX gettimeofday() function is not available on z/OS. Therefore, // we will call stcke and other hardware instructions in implement equivalent. diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h index 11c1847e4c..15b8386dd3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/ibm/xlocale.h @@ -52,50 +52,57 @@ private: // The following are not POSIX routines. These are quick-and-dirty hacks // to make things pretend to work -inline _LIBCPP_HIDE_FROM_ABI long long -strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { +static inline +long long strtoll_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { __setAndRestore __newloc(locale); - return ::strtoll(__nptr, __endptr, __base); + return strtoll(__nptr, __endptr, __base); } -inline _LIBCPP_HIDE_FROM_ABI long -strtol_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { +static inline +long strtol_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { __setAndRestore __newloc(locale); - return ::strtol(__nptr, __endptr, __base); + return strtol(__nptr, __endptr, __base); } -inline _LIBCPP_HIDE_FROM_ABI double -strtod_l(const char *__nptr, char **__endptr, locale_t locale) { +static inline +double strtod_l(const char *__nptr, char **__endptr, + locale_t locale) { __setAndRestore __newloc(locale); - return ::strtod(__nptr, __endptr); + return strtod(__nptr, __endptr); } -inline _LIBCPP_HIDE_FROM_ABI float -strtof_l(const char *__nptr, char **__endptr, locale_t locale) { +static inline +float strtof_l(const char *__nptr, char **__endptr, + locale_t locale) { __setAndRestore __newloc(locale); - return ::strtof(__nptr, __endptr); + return strtof(__nptr, __endptr); } -inline _LIBCPP_HIDE_FROM_ABI long double -strtold_l(const char *__nptr, char **__endptr, locale_t locale) { +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t locale) { __setAndRestore __newloc(locale); - return ::strtold(__nptr, __endptr); + return strtold(__nptr, __endptr); } -inline _LIBCPP_HIDE_FROM_ABI unsigned long long -strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { +static inline +unsigned long long strtoull_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { __setAndRestore __newloc(locale); - return ::strtoull(__nptr, __endptr, __base); + return strtoull(__nptr, __endptr, __base); } -inline _LIBCPP_HIDE_FROM_ABI unsigned long -strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t locale) { +static inline +unsigned long strtoul_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { __setAndRestore __newloc(locale); - return ::strtoul(__nptr, __endptr, __base); + return strtoul(__nptr, __endptr, __base); } -inline _LIBCPP_HIDE_FROM_ABI int -vasprintf(char **strp, const char *fmt, va_list ap) { +static inline +int vasprintf(char **strp, const char *fmt, va_list ap) { const size_t buff_size = 256; if ((*strp = (char *)malloc(buff_size)) == NULL) { return -1; diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/musl/xlocale.h b/contrib/libs/cxxsupp/libcxx/include/__support/musl/xlocale.h index f85cd1cbf2..2508a8e8e0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/musl/xlocale.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/musl/xlocale.h @@ -24,29 +24,30 @@ extern "C" { #endif -inline _LIBCPP_HIDE_FROM_ABI long long -strtoll_l(const char *nptr, char **endptr, int base, locale_t) { - return ::strtoll(nptr, endptr, base); +static inline long long strtoll_l(const char *nptr, char **endptr, int base, + locale_t) { + return strtoll(nptr, endptr, base); } -inline _LIBCPP_HIDE_FROM_ABI unsigned long long -strtoull_l(const char *nptr, char **endptr, int base, locale_t) { - return ::strtoull(nptr, endptr, base); +static inline unsigned long long strtoull_l(const char *nptr, char **endptr, + int base, locale_t) { + return strtoull(nptr, endptr, base); } -inline _LIBCPP_HIDE_FROM_ABI long long -wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { - return ::wcstoll(nptr, endptr, base); +static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, + int base, locale_t) { + return wcstoll(nptr, endptr, base); } -inline _LIBCPP_HIDE_FROM_ABI long long -wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { - return ::wcstoull(nptr, endptr, base); +static inline unsigned long long wcstoull_l(const wchar_t *nptr, + wchar_t **endptr, int base, + locale_t) { + return wcstoull(nptr, endptr, base); } -inline _LIBCPP_HIDE_FROM_ABI long double -wcstold_l(const wchar_t *nptr, wchar_t **endptr, locale_t) { - return ::wcstold(nptr, endptr); +static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr, + locale_t) { + return wcstold(nptr, endptr); } #ifdef __cplusplus diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/solaris/xlocale.h b/contrib/libs/cxxsupp/libcxx/include/__support/solaris/xlocale.h index 373fbfbd60..05131f0272 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/solaris/xlocale.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/solaris/xlocale.h @@ -32,39 +32,40 @@ struct lconv *localeconv(void); struct lconv *localeconv_l(locale_t __l); // FIXME: These are quick-and-dirty hacks to make things pretend to work -inline _LIBCPP_HIDE_FROM_ABI long long -strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { - return ::strtoll(__nptr, __endptr, __base); +static inline +long long strtoll_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtoll(__nptr, __endptr, __base); } - -inline _LIBCPP_HIDE_FROM_ABI long -strtol_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { - return ::strtol(__nptr, __endptr, __base); +static inline +long strtol_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtol(__nptr, __endptr, __base); } - -inline _LIBCPP_HIDE_FROM_ABI unsigned long long -strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) - return ::strtoull(__nptr, __endptr, __base); +static inline +unsigned long long strtoull_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtoull(__nptr, __endptr, __base); } - -inline _LIBCPP_HIDE_FROM_ABI unsigned long -strtoul_l(const char *__nptr, char **__endptr, int __base, locale_t __loc) { - return ::strtoul(__nptr, __endptr, __base); +static inline +unsigned long strtoul_l(const char *__nptr, char **__endptr, + int __base, locale_t __loc) { + return strtoul(__nptr, __endptr, __base); } - -inline _LIBCPP_HIDE_FROM_ABI float -strtof_l(const char *__nptr, char **__endptr, locale_t __loc) { - return ::strtof(__nptr, __endptr); +static inline +float strtof_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtof(__nptr, __endptr); } - -inline _LIBCPP_HIDE_FROM_ABI double -strtod_l(const char *__nptr, char **__endptr, locale_t __loc) { - return ::strtod(__nptr, __endptr); +static inline +double strtod_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtod(__nptr, __endptr); } - -inline _LIBCPP_HIDE_FROM_ABI long double -strtold_l(const char *__nptr, char **__endptr, locale_t __loc) { - return ::strtold(__nptr, __endptr); +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t __loc) { + return strtold(__nptr, __endptr); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__tree b/contrib/libs/cxxsupp/libcxx/include/__tree index c493ff9be0..f8d2226e66 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__tree +++ b/contrib/libs/cxxsupp/libcxx/include/__tree @@ -141,35 +141,35 @@ __tree_invariant(_NodePtr __root) } // Returns: pointer to the left-most node under __x. +// Precondition: __x != nullptr. template <class _NodePtr> inline _LIBCPP_INLINE_VISIBILITY _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null"); while (__x->__left_ != nullptr) __x = __x->__left_; return __x; } // Returns: pointer to the right-most node under __x. +// Precondition: __x != nullptr. template <class _NodePtr> inline _LIBCPP_INLINE_VISIBILITY _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "Root node shouldn't be null"); while (__x->__right_ != nullptr) __x = __x->__right_; return __x; } // Returns: pointer to the next in-order node after __x. +// Precondition: __x != nullptr. template <class _NodePtr> _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); if (__x->__right_ != nullptr) return _VSTD::__tree_min(__x->__right_); while (!_VSTD::__tree_is_left_child(__x)) @@ -182,7 +182,6 @@ inline _LIBCPP_INLINE_VISIBILITY _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); if (__x->__right_ != nullptr) return static_cast<_EndNodePtr>(_VSTD::__tree_min(__x->__right_)); while (!_VSTD::__tree_is_left_child(__x)) @@ -191,13 +190,13 @@ __tree_next_iter(_NodePtr __x) _NOEXCEPT } // Returns: pointer to the previous in-order node before __x. +// Precondition: __x != nullptr. // Note: __x may be the end node. template <class _NodePtr, class _EndNodePtr> inline _LIBCPP_INLINE_VISIBILITY _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); if (__x->__left_ != nullptr) return _VSTD::__tree_max(__x->__left_); _NodePtr __xx = static_cast<_NodePtr>(__x); @@ -207,11 +206,11 @@ __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT } // Returns: pointer to a node which has no children +// Precondition: __x != nullptr. template <class _NodePtr> _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); while (true) { if (__x->__left_ != nullptr) @@ -231,12 +230,11 @@ __tree_leaf(_NodePtr __x) _NOEXCEPT // Effects: Makes __x->__right_ the subtree root with __x as its left child // while preserving in-order order. +// Precondition: __x->__right_ != nullptr template <class _NodePtr> void __tree_left_rotate(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); - _LIBCPP_ASSERT(__x->__right_ != nullptr, "node should have a right child"); _NodePtr __y = __x->__right_; __x->__right_ = __y->__left_; if (__x->__right_ != nullptr) @@ -252,12 +250,11 @@ __tree_left_rotate(_NodePtr __x) _NOEXCEPT // Effects: Makes __x->__left_ the subtree root with __x as its right child // while preserving in-order order. +// Precondition: __x->__left_ != nullptr template <class _NodePtr> void __tree_right_rotate(_NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__x != nullptr, "node shouldn't be null"); - _LIBCPP_ASSERT(__x->__left_ != nullptr, "node should have a left child"); _NodePtr __y = __x->__left_; __x->__left_ = __y->__right_; if (__x->__left_ != nullptr) @@ -272,7 +269,8 @@ __tree_right_rotate(_NodePtr __x) _NOEXCEPT } // Effects: Rebalances __root after attaching __x to a leaf. -// Precondition: __x has no children. +// Precondition: __root != nulptr && __x != nullptr. +// __x has no children. // __x == __root or == a direct or indirect child of __root. // If __x were to be unlinked from __root (setting __root to // nullptr if __root == __x), __tree_invariant(__root) == true. @@ -282,8 +280,6 @@ template <class _NodePtr> void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT { - _LIBCPP_ASSERT(__root != nullptr, "Root of the tree shouldn't be null"); - _LIBCPP_ASSERT(__x != nullptr, "Can't attach null node to a leaf"); __x->__is_black_ = __x == __root; while (__x != __root && !__x->__parent_unsafe()->__is_black_) { @@ -343,7 +339,9 @@ __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT } } -// Precondition: __z == __root or == a direct or indirect child of __root. +// Precondition: __root != nullptr && __z != nullptr. +// __tree_invariant(__root) == true. +// __z == __root or == a direct or indirect child of __root. // Effects: unlinks __z from the tree rooted at __root, rebalancing as needed. // Postcondition: __tree_invariant(end_node->__left_) == true && end_node->__left_ // nor any of its children refer to __z. end_node->__left_ @@ -352,9 +350,6 @@ template <class _NodePtr> void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT { - _LIBCPP_ASSERT(__root != nullptr, "Root node should not be null"); - _LIBCPP_ASSERT(__z != nullptr, "The node to remove should not be null"); - _LIBCPP_DEBUG_ASSERT(__tree_invariant(__root), "The tree invariants should hold"); // __z will be removed from the tree. Client still needs to destruct/deallocate it // __y is either __z, or if __z has two children, __tree_next(__z). // __y will have at most one child. diff --git a/contrib/libs/cxxsupp/libcxx/include/algorithm b/contrib/libs/cxxsupp/libcxx/include/algorithm index c30e3a6ce9..a86e466450 100644 --- a/contrib/libs/cxxsupp/libcxx/include/algorithm +++ b/contrib/libs/cxxsupp/libcxx/include/algorithm @@ -238,33 +238,6 @@ namespace ranges { requires indirectly_copyable<iterator_t<R>, I> constexpr ranges::copy_backward_result<borrowed_iterator_t<R>, I> ranges::copy_backward(R&& r, I result); // since C++20 - - template<class I, class F> - using for_each_result = in_fun_result<I, F>; // since C++20 - - template<input_iterator I, sentinel_for<I> S, class Proj = identity, - indirectly_unary_invocable<projected<I, Proj>> Fun> - constexpr ranges::for_each_result<I, Fun> - ranges::for_each(I first, S last, Fun f, Proj proj = {}); // since C++20 - - template<input_range R, class Proj = identity, - indirectly_unary_invocable<projected<iterator_t<R>, Proj>> Fun> - constexpr ranges::for_each_result<borrowed_iterator_t<R>, Fun> - ranges::for_each(R&& r, Fun f, Proj proj = {}); // since C++20 - - template<input_iterator I, class Proj = identity, - indirectly_unary_invocable<projected<I, Proj>> Fun> - constexpr ranges::for_each_n_result<I, Fun> - ranges::for_each_n(I first, iter_difference_t<I> n, Fun f, Proj proj = {}); // since C++20 - - template<input_iterator I, sentinel_for<I> S, class Proj = identity, - indirect_unary_predicate<projected<I, Proj>> Pred> - constexpr bool ranges::is_partitioned(I first, S last, Pred pred, Proj proj = {}); // since C++20 - - template<input_range R, class Proj = identity, - indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred> - constexpr bool ranges::is_partitioned(R&& r, Pred pred, Proj proj = {}); // since C++20 - } constexpr bool // constexpr in C++20 @@ -990,9 +963,6 @@ template <class BidirectionalIterator, class Compare> #include <__algorithm/ranges_find.h> #include <__algorithm/ranges_find_if.h> #include <__algorithm/ranges_find_if_not.h> -#include <__algorithm/ranges_for_each.h> -#include <__algorithm/ranges_for_each_n.h> -#include <__algorithm/ranges_is_partitioned.h> #include <__algorithm/ranges_max.h> #include <__algorithm/ranges_max_element.h> #include <__algorithm/ranges_min.h> diff --git a/contrib/libs/cxxsupp/libcxx/include/atomic b/contrib/libs/cxxsupp/libcxx/include/atomic index 48c358f5ac..1defb38bee 100644 --- a/contrib/libs/cxxsupp/libcxx/include/atomic +++ b/contrib/libs/cxxsupp/libcxx/include/atomic @@ -542,7 +542,7 @@ template <class T> # error <atomic> is not implemented #endif #ifdef kill_dependency -# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23. +# error C++ standard library is incompatible with <stdatomic.h> #endif #define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \ @@ -1472,11 +1472,11 @@ struct __cxx_atomic_impl : public _Base { : _Base(value) {} }; -#if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__)) +#ifdef __linux__ using __cxx_contention_t = int32_t; #else using __cxx_contention_t = int64_t; -#endif // __linux__ || (_AIX && !__64BIT__) +#endif //__linux__ using __cxx_atomic_contention_t = __cxx_atomic_impl<__cxx_contention_t>; diff --git a/contrib/libs/cxxsupp/libcxx/include/charconv b/contrib/libs/cxxsupp/libcxx/include/charconv index d5e485a367..ca717dc4a0 100644 --- a/contrib/libs/cxxsupp/libcxx/include/charconv +++ b/contrib/libs/cxxsupp/libcxx/include/charconv @@ -319,197 +319,6 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, return __to_chars_integral(__first, __last, __x, __base, false_type()); } -namespace __itoa { - -static constexpr char __base_2_lut[64] = { - '0', '0', '0', '0', - '0', '0', '0', '1', - '0', '0', '1', '0', - '0', '0', '1', '1', - '0', '1', '0', '0', - '0', '1', '0', '1', - '0', '1', '1', '0', - '0', '1', '1', '1', - '1', '0', '0', '0', - '1', '0', '0', '1', - '1', '0', '1', '0', - '1', '0', '1', '1', - '1', '1', '0', '0', - '1', '1', '0', '1', - '1', '1', '1', '0', - '1', '1', '1', '1' -}; - -static constexpr char __base_8_lut[128] = { - '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', - '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', - '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', - '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', - '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', - '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', - '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', - '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7' -}; - -static constexpr char __base_16_lut[512] = { - '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0', 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', - '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', - '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', '2', 'c', '2', 'd', '2', 'e', '2', 'f', - '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', - '4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', '4', 'd', '4', 'e', '4', 'f', - '5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'a', '5', 'b', '5', 'c', '5', 'd', '5', 'e', '5', 'f', - '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', '6', 'e', '6', 'f', - '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7', 'e', '7', 'f', - '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9', '8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', '8', 'f', - '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', - 'a', '0', 'a', '1', 'a', '2', 'a', '3', 'a', '4', 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a', 'c', 'a', 'd', 'a', 'e', 'a', 'f', - 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7', 'b', '8', 'b', '9', 'b', 'a', 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', - 'c', '0', 'c', '1', 'c', '2', 'c', '3', 'c', '4', 'c', '5', 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e', 'c', 'f', - 'd', '0', 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd', 'a', 'd', 'b', 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', - 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5', 'e', '6', 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', - 'f', '0', 'f', '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c', 'f', 'd', 'f', 'e', 'f', 'f' -}; - -template <unsigned _Base> -struct _LIBCPP_HIDDEN __integral; - -template <> -struct _LIBCPP_HIDDEN __integral<2> { - template <typename _Tp> - _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { - // If value == 0 still need one digit. If the value != this has no - // effect since the code scans for the most significant bit set. (Note - // that __libcpp_clz doesn't work for 0.) - return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1); - } - - template <typename _Tp> - _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) { - ptrdiff_t __cap = __last - __first; - int __n = __width(__value); - if (__n > __cap) - return {__last, errc::value_too_large}; - - __last = __first + __n; - char* __p = __last; - const unsigned __divisor = 16; - while (__value > __divisor) { - unsigned __c = __value % __divisor; - __value /= __divisor; - __p -= 4; - std::memcpy(__p, &__base_2_lut[4 * __c], 4); - } - do { - unsigned __c = __value % 2; - __value /= 2; - *--__p = "01"[__c]; - } while (__value != 0); - return {__last, errc(0)}; - } -}; - -template <> -struct _LIBCPP_HIDDEN __integral<8> { - template <typename _Tp> - _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { - // If value == 0 still need one digit. If the value != this has no - // effect since the code scans for the most significat bit set. (Note - // that __libcpp_clz doesn't work for 0.) - return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3; - } - - template <typename _Tp> - _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) { - ptrdiff_t __cap = __last - __first; - int __n = __width(__value); - if (__n > __cap) - return {__last, errc::value_too_large}; - - __last = __first + __n; - char* __p = __last; - unsigned __divisor = 64; - while (__value > __divisor) { - unsigned __c = __value % __divisor; - __value /= __divisor; - __p -= 2; - std::memcpy(__p, &__base_8_lut[2 * __c], 2); - } - do { - unsigned __c = __value % 8; - __value /= 8; - *--__p = "01234567"[__c]; - } while (__value != 0); - return {__last, errc(0)}; - } - -}; - -template <> -struct _LIBCPP_HIDDEN __integral<16> { - template <typename _Tp> - _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept { - // If value == 0 still need one digit. If the value != this has no - // effect since the code scans for the most significat bit set. (Note - // that __libcpp_clz doesn't work for 0.) - return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4; - } - - template <typename _Tp> - _LIBCPP_HIDE_FROM_ABI static to_chars_result __to_chars(char* __first, char* __last, _Tp __value) { - ptrdiff_t __cap = __last - __first; - int __n = __width(__value); - if (__n > __cap) - return {__last, errc::value_too_large}; - - __last = __first + __n; - char* __p = __last; - unsigned __divisor = 256; - while (__value > __divisor) { - unsigned __c = __value % __divisor; - __value /= __divisor; - __p -= 2; - std::memcpy(__p, &__base_16_lut[2 * __c], 2); - } - if (__first != __last) - do { - unsigned __c = __value % 16; - __value /= 16; - *--__p = "0123456789abcdef"[__c]; - } while (__value != 0); - return {__last, errc(0)}; - } -}; - -} // namespace __itoa - -template <unsigned _Base, typename _Tp, - typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0> -_LIBCPP_HIDE_FROM_ABI int -__to_chars_integral_width(_Tp __value) { - return __itoa::__integral<_Base>::__width(__value); -} - -template <unsigned _Base, typename _Tp, - typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0> -_LIBCPP_HIDE_FROM_ABI int -__to_chars_integral_width(_Tp __value) { - return std::__to_chars_integral_width<_Base>(static_cast<unsigned>(__value)); -} - -template <unsigned _Base, typename _Tp, - typename enable_if<(sizeof(_Tp) >= sizeof(unsigned)), int>::type = 0> -_LIBCPP_HIDE_FROM_ABI to_chars_result -__to_chars_integral(char* __first, char* __last, _Tp __value) { - return __itoa::__integral<_Base>::__to_chars(__first, __last, __value); -} - -template <unsigned _Base, typename _Tp, - typename enable_if<(sizeof(_Tp) < sizeof(unsigned)), int>::type = 0> -_LIBCPP_HIDE_FROM_ABI to_chars_result -__to_chars_integral(char* __first, char* __last, _Tp __value) { - return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value)); -} - template <typename _Tp> _LIBCPP_AVAILABILITY_TO_CHARS _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_width(_Tp __value, unsigned __base) { @@ -543,18 +352,9 @@ inline _LIBCPP_HIDE_FROM_ABI to_chars_result __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type) { - if (__base == 10) [[likely]] + if (__base == 10) return __to_chars_itoa(__first, __last, __value, false_type()); - switch (__base) { - case 2: - return __to_chars_integral<2>(__first, __last, __value); - case 8: - return __to_chars_integral<8>(__first, __last, __value); - case 16: - return __to_chars_integral<16>(__first, __last, __value); - } - ptrdiff_t __cap = __last - __first; int __n = __to_chars_integral_width(__value, __base); if (__n > __cap) diff --git a/contrib/libs/cxxsupp/libcxx/include/format b/contrib/libs/cxxsupp/libcxx/include/format index 98fa0b0346..951627852f 100644 --- a/contrib/libs/cxxsupp/libcxx/include/format +++ b/contrib/libs/cxxsupp/libcxx/include/format @@ -127,10 +127,8 @@ namespace std { #include <__config> #include <__debug> #include <__format/buffer.h> -#include <__format/concepts.h> #include <__format/enable_insertable.h> #include <__format/format_arg.h> -#include <__format/format_arg_store.h> #include <__format/format_args.h> #include <__format/format_context.h> #include <__format/format_error.h> @@ -177,25 +175,22 @@ using format_args = basic_format_args<format_context>; using wformat_args = basic_format_args<wformat_context>; #endif -// TODO FMT This helper wrapper can probably be removed after P2418 has been -// implemented. template <class _Context, class... _Args> -_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> -__make_format_args(_Args&&... __args) { - return _VSTD::__format_arg_store<_Context, _Args...>( - _VSTD::forward<_Args>(__args)...); -} +struct _LIBCPP_TEMPLATE_VIS __format_arg_store { + // TODO FMT Use a built-in array. + array<basic_format_arg<_Context>, sizeof...(_Args)> __args; +}; -// TODO FMT After P2418 specify the return type instead of using auto. template <class _Context = format_context, class... _Args> -_LIBCPP_HIDE_FROM_ABI auto make_format_args(const _Args&... __args) { - return _VSTD::__make_format_args<_Context>(__args...); +_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> +make_format_args(const _Args&... __args) { + return {basic_format_arg<_Context>(__args)...}; } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -// TODO FMT After P2418 specify the return type instead of using auto. template <class... _Args> -_LIBCPP_HIDE_FROM_ABI auto make_wformat_args(const _Args&... __args) { +_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> +make_wformat_args(const _Args&... __args) { return _VSTD::make_format_args<wformat_context>(__args...); } #endif @@ -309,9 +304,6 @@ requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt } } -// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining -// https://reviews.llvm.org/D110499#inline-1180704 -// TODO FMT Evaluate whether we want to file a Clang bug report regarding this. template <output_iterator<const char&> _OutIt> _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) { @@ -372,27 +364,31 @@ format(wstring_view __fmt, const _Args&... __args) { } #endif -template <class _Context, class _OutIt, class _CharT> -_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, - basic_string_view<_CharT> __fmt, - basic_format_args<_Context> __args) { - __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n}; - _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()}, - _VSTD::__format_context_create(__buffer.make_output_iterator(), __args)); - return _VSTD::move(__buffer).result(); -} - template <output_iterator<const char&> _OutIt, class... _Args> -_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> -format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt, const _Args&... __args) { - return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt, _VSTD::make_format_args(__args...)); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> +format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, string_view __fmt, + const _Args&... __args) { + // TODO FMT Improve PoC: using std::string is inefficient. + string __str = _VSTD::vformat(__fmt, _VSTD::make_format_args(__args...)); + iter_difference_t<_OutIt> __s = __str.size(); + iter_difference_t<_OutIt> __m = + _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s); + __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it)); + return {_VSTD::move(__out_it), __s}; } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <output_iterator<const wchar_t&> _OutIt, class... _Args> -_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> -format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wstring_view __fmt, const _Args&... __args) { - return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt, _VSTD::make_wformat_args(__args...)); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> +format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wstring_view __fmt, + const _Args&... __args) { + // TODO FMT Improve PoC: using std::string is inefficient. + wstring __str = _VSTD::vformat(__fmt, _VSTD::make_wformat_args(__args...)); + iter_difference_t<_OutIt> __s = __str.size(); + iter_difference_t<_OutIt> __m = + _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s); + __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it)); + return {_VSTD::move(__out_it), __s}; } #endif @@ -506,30 +502,33 @@ format(locale __loc, wstring_view __fmt, const _Args&... __args) { } #endif -template <class _Context, class _OutIt, class _CharT> -_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, - locale __loc, basic_string_view<_CharT> __fmt, - basic_format_args<_Context> __args) { - __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n}; - _VSTD::__format::__vformat_to( - basic_format_parse_context{__fmt, __args.__size()}, - _VSTD::__format_context_create(__buffer.make_output_iterator(), __args, _VSTD::move(__loc))); - return _VSTD::move(__buffer).result(); -} - template <output_iterator<const char&> _OutIt, class... _Args> -_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> -format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, string_view __fmt, const _Args&... __args) { - return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt, - _VSTD::make_format_args(__args...)); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> +format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, + string_view __fmt, const _Args&... __args) { + // TODO FMT Improve PoC: using std::string is inefficient. + string __str = _VSTD::vformat(_VSTD::move(__loc), __fmt, + _VSTD::make_format_args(__args...)); + iter_difference_t<_OutIt> __s = __str.size(); + iter_difference_t<_OutIt> __m = + _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s); + __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it)); + return {_VSTD::move(__out_it), __s}; } #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <output_iterator<const wchar_t&> _OutIt, class... _Args> -_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> -format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wstring_view __fmt, const _Args&... __args) { - return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt, - _VSTD::make_wformat_args(__args...)); +_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt> +format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, + wstring_view __fmt, const _Args&... __args) { + // TODO FMT Improve PoC: using std::string is inefficient. + wstring __str = _VSTD::vformat(_VSTD::move(__loc), __fmt, + _VSTD::make_wformat_args(__args...)); + iter_difference_t<_OutIt> __s = __str.size(); + iter_difference_t<_OutIt> __m = + _VSTD::clamp(__n, iter_difference_t<_OutIt>(0), __s); + __out_it = _VSTD::copy_n(__str.begin(), __m, _VSTD::move(__out_it)); + return {_VSTD::move(__out_it), __s}; } #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/list b/contrib/libs/cxxsupp/libcxx/include/list index f362ef38aa..87da2b17e2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/list +++ b/contrib/libs/cxxsupp/libcxx/include/list @@ -679,6 +679,13 @@ private: void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {} + + _LIBCPP_INLINE_VISIBILITY + void __invalidate_all_iterators() { +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__invalidate_all(this); +#endif + } }; // Unlink nodes [__f, __l] @@ -720,7 +727,9 @@ inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT template <class _Tp, class _Alloc> __list_imp<_Tp, _Alloc>::~__list_imp() { clear(); - std::__debug_db_erase_c(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__erase_c(this); +#endif } template <class _Tp, class _Alloc> @@ -741,7 +750,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); __node_alloc_traits::deallocate(__na, __np, 1); } - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } } @@ -1364,7 +1373,9 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l, insert(__e, __f, __l); else erase(__i, __e); - std::__debug_db_invalidate_all(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__invalidate_all(this); +#endif } template <class _Tp, class _Alloc> @@ -1379,7 +1390,9 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) insert(__e, __n, __x); else erase(__i, __e); - std::__debug_db_invalidate_all(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__invalidate_all(this); +#endif } template <class _Tp, class _Alloc> diff --git a/contrib/libs/cxxsupp/libcxx/include/locale b/contrib/libs/cxxsupp/libcxx/include/locale index d0302db58d..98d1d09af3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/locale +++ b/contrib/libs/cxxsupp/libcxx/include/locale @@ -1936,7 +1936,7 @@ time_get<_CharT, _InputIterator>::__get_month(int& __m, const ctype<char_type>& __ct) const { int __t = __get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1; - if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11) + if (!(__err & ios_base::failbit) && __t <= 11) __m = __t; else __err |= ios_base::failbit; diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span index 75d00c14bf..6b1d4b9aae 100644 --- a/contrib/libs/cxxsupp/libcxx/include/span +++ b/contrib/libs/cxxsupp/libcxx/include/span @@ -130,7 +130,6 @@ template<class R> #include <__assert> // all public C++ headers provide the assertion handler #include <__config> #include <__debug> -#include <__fwd/span.h> #include <__iterator/concepts.h> #include <__iterator/wrap_iter.h> #include <__ranges/concepts.h> @@ -156,6 +155,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 +inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max(); +template <typename _Tp, size_t _Extent = dynamic_extent> class span; + template <class _Tp> struct __is_std_array : false_type {}; diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string index 3602fc046a..e47984f43e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string +++ b/contrib/libs/cxxsupp/libcxx/include/string @@ -682,7 +682,6 @@ public: typedef std::reverse_iterator<const_iterator> const_reverse_iterator; private: - static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits"); #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT @@ -700,13 +699,14 @@ private: struct __short { value_type __data_[__min_cap]; - unsigned char __padding_[sizeof(value_type) - 1]; - size_type __size_ : 7; - size_type __is_long_ : 1; + unsigned char __padding[sizeof(value_type) - 1]; + unsigned char __size_ : 7; + unsigned char __is_long_ : 1; }; // The __endian_factor is required because the field we use to store the size -// has one fewer bit than it would if it were not a bitfield. +// (either size_type or unsigned char depending on long/short) has one fewer +// bit than it would if it were not a bitfield. // // If the LSB is used to store the short-flag in the short string representation, // we have to multiply the size by two when it is stored and divide it by two when @@ -745,9 +745,14 @@ private: struct __short { - size_type __is_long_ : 1; - size_type __size_ : 7; - char __padding_[sizeof(value_type) - 1]; + union + { + struct { + unsigned char __is_long_ : 1; + unsigned char __size_ : 7; + }; + value_type __lx; + }; value_type __data_[__min_cap]; }; @@ -1811,6 +1816,7 @@ private: return *this; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_all_iterators(); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type); template<class _Tp> @@ -1886,6 +1892,17 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _ template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void +basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated()) + __get_db()->__invalidate_all(this); +#endif +} + +template <class _CharT, class _Traits, class _Allocator> +inline _LIBCPP_CONSTEXPR_AFTER_CXX17 +void basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos) { #if _LIBCPP_DEBUG_LEVEL == 2 @@ -2089,8 +2106,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) { __str.__default_init(); std::__debug_db_insert_c(this); - if (__is_long()) - std::__debug_db_swap(this, &__str); +#if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated() && __is_long()) + __get_db()->swap(this, &__str); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -2111,8 +2130,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co __str.__default_init(); } std::__debug_db_insert_c(this); - if (__is_long()) - std::__debug_db_swap(this, &__str); +#if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated() && __is_long()) + __get_db()->swap(this, &__str); +#endif } #endif // _LIBCPP_CXX03_LANG @@ -2350,7 +2371,10 @@ template <class _CharT, class _Traits, class _Allocator> _LIBCPP_CONSTEXPR_AFTER_CXX17 basic_string<_CharT, _Traits, _Allocator>::~basic_string() { - std::__debug_db_erase_c(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated()) + __get_db()->__erase_c(this); +#endif if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); } @@ -2372,7 +2396,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); pointer __p = __allocation.ptr; __begin_lifetime(__p, __allocation.count); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); if (__n_copy != 0) traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy); @@ -2407,7 +2431,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1); pointer __p = __allocation.ptr; __begin_lifetime(__p, __allocation.count); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); if (__n_copy != 0) traits_type::copy(std::__to_address(__p), std::__to_address(__old_p), __n_copy); @@ -3345,7 +3369,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX17 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); if (__is_long()) { traits_type::assign(*__get_long_pointer(), value_type()); @@ -3496,7 +3520,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target } else __set_short_size(__sz); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } template <class _CharT, class _Traits, class _Allocator> @@ -3605,12 +3629,15 @@ basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) __is_nothrow_swappable<allocator_type>::value) #endif { - if (!__is_long()) - std::__debug_db_invalidate_all(this); - if (!__str.__is_long()) - std::__debug_db_invalidate_all(&__str); - std::__debug_db_swap(this, &__str); - +#if _LIBCPP_DEBUG_LEVEL == 2 + if (!__libcpp_is_constant_evaluated()) { + if (!__is_long()) + __get_db()->__invalidate_all(this); + if (!__str.__is_long()) + __get_db()->__invalidate_all(&__str); + __get_db()->swap(this, &__str); + } +#endif _LIBCPP_ASSERT( __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value || diff --git a/contrib/libs/cxxsupp/libcxx/include/string_view b/contrib/libs/cxxsupp/libcxx/include/string_view index 28fbe1a5f7..6864d29532 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string_view +++ b/contrib/libs/cxxsupp/libcxx/include/string_view @@ -199,7 +199,6 @@ namespace std { #include <__algorithm/min.h> #include <__assert> // all public C++ headers provide the assertion handler #include <__config> -#include <__fwd/string_view.h> #include <__ranges/concepts.h> #include <__ranges/data.h> #include <__ranges/enable_borrowed_range.h> @@ -229,6 +228,19 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD +template<class _CharT, class _Traits = char_traits<_CharT> > + class _LIBCPP_TEMPLATE_VIS basic_string_view; + +typedef basic_string_view<char> string_view; +#ifndef _LIBCPP_HAS_NO_CHAR8_T +typedef basic_string_view<char8_t> u8string_view; +#endif +typedef basic_string_view<char16_t> u16string_view; +typedef basic_string_view<char32_t> u32string_view; +#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +typedef basic_string_view<wchar_t> wstring_view; +#endif + // TODO: This is a workaround for some vendors to carry a downstream diff to accept `nullptr` in // string_view constructors. This can be refactored when this exact form isn't needed anymore. template <class _Traits> diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_map b/contrib/libs/cxxsupp/libcxx/include/unordered_map index e5741b0546..a31c2c6dde 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_map +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_map @@ -1693,7 +1693,9 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( : __table_(_VSTD::move(__u.__table_)) { _VSTD::__debug_db_insert_c(this); - std::__debug_db_swap(this, std::addressof(__u)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> @@ -1710,8 +1712,10 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map( __u.__table_.remove((__i++).__i_)->__value_.__move()); } } +#if _LIBCPP_DEBUG_LEVEL == 2 else - std::__debug_db_swap(this, std::addressof(__u)); + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> @@ -2465,7 +2469,9 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( : __table_(_VSTD::move(__u.__table_)) { _VSTD::__debug_db_insert_c(this); - std::__debug_db_swap(this, std::addressof(__u)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> @@ -2483,8 +2489,10 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap( __u.__table_.remove((__i++).__i_)->__value_.__move()); } } +#if _LIBCPP_DEBUG_LEVEL == 2 else - std::__debug_db_swap(this, std::addressof(__u)); + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_set b/contrib/libs/cxxsupp/libcxx/include/unordered_set index de0e12197d..f23de20456 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_set +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_set @@ -1006,7 +1006,9 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( : __table_(_VSTD::move(__u.__table_)) { _VSTD::__debug_db_insert_c(this); - std::__debug_db_swap(this, std::addressof(__u)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Value, class _Hash, class _Pred, class _Alloc> @@ -1021,8 +1023,10 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set( while (__u.size() != 0) __table_.__insert_unique(_VSTD::move(__u.__table_.remove(__i++)->__value_)); } +#if _LIBCPP_DEBUG_LEVEL == 2 else - std::__debug_db_swap(this, std::addressof(__u)); + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Value, class _Hash, class _Pred, class _Alloc> @@ -1643,7 +1647,9 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( : __table_(_VSTD::move(__u.__table_)) { _VSTD::__debug_db_insert_c(this); - std::__debug_db_swap(this, std::addressof(__u)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Value, class _Hash, class _Pred, class _Alloc> @@ -1658,8 +1664,10 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset( while (__u.size() != 0) __table_.__insert_multi(_VSTD::move(__u.__table_.remove(__i++)->__value_)); } +#if _LIBCPP_DEBUG_LEVEL == 2 else - std::__debug_db_swap(this, std::addressof(__u)); + __get_db()->swap(this, _VSTD::addressof(__u)); +#endif } template <class _Value, class _Hash, class _Pred, class _Alloc> diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector index 7e3fb0ee06..d4cfaed952 100644 --- a/contrib/libs/cxxsupp/libcxx/include/vector +++ b/contrib/libs/cxxsupp/libcxx/include/vector @@ -418,7 +418,9 @@ public: ~vector() { __annotate_delete(); - std::__debug_db_erase_c(this); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__erase_c(this); +#endif if (this->__begin_ != nullptr) { @@ -644,7 +646,7 @@ public: size_type __old_size = size(); __clear(); __annotate_shrink(__old_size); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } #if _YNDX_LIBCXX_ENABLE_VECTOR_POD_RESIZE_UNINITIALIZED @@ -679,6 +681,7 @@ private: __compressed_pair<pointer, allocator_type> __end_cap_ = __compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag()); + _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); @@ -940,7 +943,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a _VSTD::swap(this->__end_cap(), __v.__end_cap()); __v.__first_ = __v.__begin_; __annotate_new(size()); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } template <class _Tp, class _Allocator> @@ -956,7 +959,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a _VSTD::swap(this->__end_cap(), __v.__end_cap()); __v.__first_ = __v.__begin_; __annotate_new(size()); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); return __r; } @@ -1238,7 +1241,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x) : __end_cap_(nullptr, _VSTD::move(__x.__alloc())) { _VSTD::__debug_db_insert_c(this); - std::__debug_db_swap(this, std::addressof(__x)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__x)); +#endif this->__begin_ = __x.__begin_; this->__end_ = __x.__end_; this->__end_cap() = __x.__end_cap(); @@ -1257,7 +1262,9 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_ this->__end_ = __x.__end_; this->__end_cap() = __x.__end_cap(); __x.__begin_ = __x.__end_ = __x.__end_cap() = nullptr; - std::__debug_db_swap(this, std::addressof(__x)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__x)); +#endif } else { @@ -1327,7 +1334,9 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) this->__end_ = __c.__end_; this->__end_cap() = __c.__end_cap(); __c.__begin_ = __c.__end_ = __c.__end_cap() = nullptr; - std::__debug_db_swap(this, std::addressof(__c)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__c)); +#endif } #endif // !_LIBCPP_CXX03_LANG @@ -1398,7 +1407,7 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las __vallocate(__recommend(__new_size)); __construct_at_end(__first, __last, __new_size); } - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } template <class _Tp, class _Allocator> @@ -1420,7 +1429,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) __vallocate(__recommend(static_cast<size_type>(__n))); __construct_at_end(__n, __u); } - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } template <class _Tp, class _Allocator> @@ -1989,7 +1998,9 @@ vector<_Tp, _Allocator>::swap(vector& __x) _VSTD::swap(this->__end_cap(), __x.__end_cap()); _VSTD::__swap_allocator(this->__alloc(), __x.__alloc(), integral_constant<bool,__alloc_traits::propagate_on_container_swap::value>()); - std::__debug_db_swap(this, std::addressof(__x)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->swap(this, _VSTD::addressof(__x)); +#endif } template <class _Tp, class _Allocator> @@ -2050,6 +2061,17 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __ template <class _Tp, class _Allocator> inline _LIBCPP_INLINE_VISIBILITY void +vector<_Tp, _Allocator>::__invalidate_all_iterators() +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__invalidate_all(this); +#endif +} + + +template <class _Tp, class _Allocator> +inline _LIBCPP_INLINE_VISIBILITY +void vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) { #if _LIBCPP_DEBUG_LEVEL == 2 __c_node* __c = __get_db()->__find_c_and_lock(this); @@ -2371,6 +2393,7 @@ private: // Precondition: __n > 0 // Postcondition: capacity() >= __n // Postcondition: size() == 0 + _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) { if (__n > max_size()) __throw_length_error(); @@ -2461,13 +2484,20 @@ private: }; template <class _Allocator> +inline _LIBCPP_INLINE_VISIBILITY +void +vector<bool, _Allocator>::__invalidate_all_iterators() +{ +} + +template <class _Allocator> void vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT { if (this->__begin_ != nullptr) { __storage_traits::deallocate(this->__alloc(), this->__begin_, __cap()); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); this->__begin_ = nullptr; this->__size_ = this->__cap() = 0; } @@ -2640,7 +2670,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2667,7 +2697,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2742,7 +2772,7 @@ vector<bool, _Allocator>::~vector() { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } template <class _Allocator> @@ -2886,7 +2916,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x) } _VSTD::fill_n(begin(), __n, __x); } - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } template <class _Allocator> @@ -2940,7 +2970,7 @@ vector<bool, _Allocator>::reserve(size_type __n) __v.__vallocate(__n); __v.__construct_at_end(this->begin(), this->end()); swap(__v); - std::__debug_db_invalidate_all(this); + __invalidate_all_iterators(); } } diff --git a/contrib/libs/cxxsupp/libcxx/include/version b/contrib/libs/cxxsupp/libcxx/include/version index bb8ec21d01..b8d03ac651 100644 --- a/contrib/libs/cxxsupp/libcxx/include/version +++ b/contrib/libs/cxxsupp/libcxx/include/version @@ -404,7 +404,7 @@ __cpp_lib_void_t 201411L <type_traits> // # define __cpp_lib_reference_from_temporary 202202L // # define __cpp_lib_spanstream 202106L // # define __cpp_lib_stacktrace 202011L -# define __cpp_lib_stdatomic_h 202011L +// # define __cpp_lib_stdatomic_h 202011L # define __cpp_lib_string_contains 202011L # define __cpp_lib_string_resize_and_overwrite 202110L # define __cpp_lib_to_underlying 202102L diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp index e205f0f7ad..5db0115f65 100644 --- a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp @@ -1888,7 +1888,7 @@ path path::lexically_relative(const path& base) const { if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR(""))) return PATHSTR("."); - // return a path constructed with 'n' dot-dot elements, followed by the + // return a path constructed with 'n' dot-dot elements, followed by the the // elements of '*this' after the mismatch. path Result; // FIXME: Reserve enough room in Result that it won't have to re-allocate. diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make index f2181d287b..411b23022f 100644 --- a/contrib/libs/cxxsupp/libcxx/ya.make +++ b/contrib/libs/cxxsupp/libcxx/ya.make @@ -13,9 +13,9 @@ LICENSE( LICENSE_TEXTS(.yandex_meta/licenses.list.txt) -VERSION(2022-05-18) +VERSION(2022-05-01) -ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/4ac0589122830fc6d90e0ea091300c0b979a42dc.tar.gz) +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/639b9618f46d75f4dabd2082b3f6ba8433c287bf.tar.gz) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxx/include |