diff options
author | mikhnenko <mikhnenko@yandex-team.com> | 2023-11-15 21:10:56 +0300 |
---|---|---|
committer | mikhnenko <mikhnenko@yandex-team.com> | 2023-11-15 22:24:51 +0300 |
commit | 401253f291059c8eb079c95e469cc73af2dc2af5 (patch) | |
tree | d8135d1197aaeab6daa5c9dbde39a5916ee98f1d /contrib | |
parent | 8e70c7251e94222a2475b7d9b2025b5c33cfd6c1 (diff) | |
download | ydb-401253f291059c8eb079c95e469cc73af2dc2af5.tar.gz |
Upd libc++ to 01 July 2022 da1609ad73540978f66111e96ea500b97ca9b39a
```
[libc++] Improve the formatting of static_assert messages
[libc++] Remove dead code and unneeded C++03 specializations from type_traits
[libc++] Implement P0618R0 (Deprecating <codecvt>)
[libc++] Disentangle _If, _Or and _And
Uglify __support/xlocale
[libc++][format] Improve pointer formatters.
[libc++][format] Improve integral formatters.
[libc++] Fix signature of main() in tests
[libc++][ranges] Finish LWG issues directly related to the One Ranges Proposal.
[libc++] Re-add transitive includes that had been removed since LLVM 14
[libc++] Add a few missing min/max macro push/pop
[libc++] Remove dummy command in Dockerfile
[libc++] Use bounded iterators in std::span when the debug mode is enabled
[libc++] Improve Lit's buildhost=XXXX feature on a few platforms
[libc++] Simplify type_traits and use more builtins
[libc++] P2321R2 section [tuple.tuple]. Adding C++23 constructors, assignment operators and swaps to `tuple`
[libc++][AIX] Make basic_string layout compatible with earlier version
[libcxx][test] Suppress complex<int> warnings when testing MSVC
[libc++] Add a test to pin down the set of transitive public includes
[libc++][format] Copy code to new location.
[libc++] Implement ranges::move{, _backward}
[libc++] Implement P0154R1 (Hardware inference size)
[libc++] Simplify the visibility attributes
[libc++] Clarify std::function release note
[libc++] Reduces std::to_chars instantiations.
[libc++] Fixesbuild.
[libc++] fix views::all hard error on lvalue move only views instead of SFINAE
[libc++] Complete the implementation of N4190
[libc++] Remove std::function in C++03
[libc++][format] Improve string formatters
[libc++] Pass -fno-modules to clang-tidy instead of disabling it for the modules build
[libc++][clang-tidy] Enable bugprone-use-after-move and explicitly list all used checks
[libc++] Improve charconv base10 algorithm.
[libc++][format] Improves the handle test.
[libc++] Implement P0174R2 (Deprecating Vestigial Library Parts in C++17)
```
Diffstat (limited to 'contrib')
96 files changed, 2819 insertions, 1858 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h index ffc160cbe4..58919ddbae 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/inplace_merge.h @@ -211,7 +211,10 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _ difference_type __len1 = _VSTD::distance(__first, __middle); difference_type __len2 = _VSTD::distance(__middle, __last); difference_type __buf_size = _VSTD::min(__len1, __len2); +// TODO: Remove the use of std::get_temporary_buffer +_LIBCPP_SUPPRESS_DEPRECATED_PUSH pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size); +_LIBCPP_SUPPRESS_DEPRECATED_POP unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first); typedef typename __comp_ref_type<_Compare>::type _Comp_ref; return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h index 72bf3d76ea..0b08d31c17 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/move.h @@ -11,7 +11,10 @@ #include <__algorithm/unwrap_iter.h> #include <__config> +#include <__iterator/iterator_traits.h> +#include <__iterator/reverse_iterator.h> #include <__utility/move.h> +#include <__utility/pair.h> #include <cstring> #include <type_traits> @@ -23,53 +26,88 @@ _LIBCPP_BEGIN_NAMESPACE_STD // move -template <class _InputIterator, class _OutputIterator> +template <class _InIter, class _Sent, class _OutIter> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -_OutputIterator -__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) -{ - for (; __first != __last; ++__first, (void) ++__result) - *__result = _VSTD::move(*__first); - return __result; +pair<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { + while (__first != __last) { + *__result = std::move(*__first); + ++__first; + ++__result; + } + return std::make_pair(std::move(__first), std::move(__result)); } -template <class _InputIterator, class _OutputIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -_OutputIterator -__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) -{ - return _VSTD::__move_constexpr(__first, __last, __result); +template <class _InType, + class _OutType, + class = __enable_if_t<is_same<typename remove_const<_InType>::type, _OutType>::value + && is_trivially_move_assignable<_OutType>::value> > +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<_InType*, _OutType*> __move_impl(_InType* __first, _InType* __last, _OutType* __result) { + if (__libcpp_is_constant_evaluated() +// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation +#ifndef _LIBCPP_COMPILER_GCC + && !is_trivially_copyable<_InType>::value +#endif + ) + return std::__move_impl<_InType*, _InType*, _OutType*>(__first, __last, __result); + const size_t __n = static_cast<size_t>(__last - __first); + ::__builtin_memmove(__result, __first, __n * sizeof(_OutType)); + return std::make_pair(__first + __n, __result + __n); } -template <class _Tp, class _Up> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 -typename enable_if -< - is_same<typename remove_const<_Tp>::type, _Up>::value && - is_trivially_move_assignable<_Up>::value, - _Up* ->::type -__move(_Tp* __first, _Tp* __last, _Up* __result) -{ - const size_t __n = static_cast<size_t>(__last - __first); - if (__n > 0) - _VSTD::memmove(__result, __first, __n * sizeof(_Up)); - return __result + __n; +template <class> +struct __is_trivially_move_assignable_unwrapped_impl : false_type {}; + +template <class _Type> +struct __is_trivially_move_assignable_unwrapped_impl<_Type*> : is_trivially_move_assignable<_Type> {}; + +template <class _Iter> +struct __is_trivially_move_assignable_unwrapped + : __is_trivially_move_assignable_unwrapped_impl<decltype(std::__unwrap_iter<_Iter>(std::declval<_Iter>()))> {}; + +template <class _InIter, + class _OutIter, + __enable_if_t<is_same<typename remove_const<typename iterator_traits<_InIter>::value_type>::type, + typename iterator_traits<_OutIter>::value_type>::value + && __is_cpp17_contiguous_iterator<_InIter>::value + && __is_cpp17_contiguous_iterator<_OutIter>::value + && is_trivially_move_assignable<__iter_value_type<_OutIter> >::value, int> = 0> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +pair<reverse_iterator<_InIter>, reverse_iterator<_OutIter> > +__move_impl(reverse_iterator<_InIter> __first, + reverse_iterator<_InIter> __last, + reverse_iterator<_OutIter> __result) { + auto __first_base = std::__unwrap_iter(__first.base()); + auto __last_base = std::__unwrap_iter(__last.base()); + auto __result_base = std::__unwrap_iter(__result.base()); + auto __result_first = __result_base - (__first_base - __last_base); + std::__move_impl(__last_base, __first_base, __result_first); + return std::make_pair(__last, reverse_iterator<_OutIter>(std::__rewrap_iter(__result.base(), __result_first))); +} + +template <class _InIter, class _Sent, class _OutIter> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +__enable_if_t<is_copy_constructible<_InIter>::value + && is_copy_constructible<_Sent>::value + && is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > +__move(_InIter __first, _Sent __last, _OutIter __result) { + auto __ret = std::__move_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), std::__unwrap_iter(__result)); + return std::make_pair(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second)); +} + +template <class _InIter, class _Sent, class _OutIter> +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 +__enable_if_t<!is_copy_constructible<_InIter>::value + || !is_copy_constructible<_Sent>::value + || !is_copy_constructible<_OutIter>::value, pair<_InIter, _OutIter> > +__move(_InIter __first, _Sent __last, _OutIter __result) { + return std::__move_impl(std::move(__first), std::move(__last), std::move(__result)); } template <class _InputIterator, class _OutputIterator> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 -_OutputIterator -move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) -{ - if (__libcpp_is_constant_evaluated()) { - return _VSTD::__move_constexpr(__first, __last, __result); - } else { - return _VSTD::__rewrap_iter(__result, - _VSTD::__move(_VSTD::__unwrap_iter(__first), - _VSTD::__unwrap_iter(__last), - _VSTD::__unwrap_iter(__result))); - } +inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { + return std::__move(__first, __last, __result).second; } _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h index c9f49f676c..2f4bba0e7c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h @@ -31,6 +31,9 @@ #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD namespace ranges { @@ -123,6 +126,8 @@ inline namespace __cpo { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) #endif // _LIBCPP___ALGORITHM_RANGES_MINMAX_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h new file mode 100644 index 0000000000..ad4342d7c9 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move.h @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// 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_MOVE_H +#define _LIBCPP___ALGORITHM_RANGES_MOVE_H + +#include <__algorithm/in_out_result.h> +#include <__algorithm/move.h> +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/iter_move.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 _InIter, class _OutIter> +using move_result = in_out_result<_InIter, _OutIter>; + +namespace __move { +struct __fn { + + template <class _InIter, class _Sent, class _OutIter> + requires __iter_move::__move_deref<_InIter> // check that we are allowed to std::move() the value + _LIBCPP_HIDE_FROM_ABI constexpr static + move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { + auto __ret = std::__move(std::move(__first), std::move(__last), std::move(__result)); + return {std::move(__ret.first), std::move(__ret.second)}; + } + + template <class _InIter, class _Sent, class _OutIter> + _LIBCPP_HIDE_FROM_ABI constexpr static + move_result<_InIter, _OutIter> __move_impl(_InIter __first, _Sent __last, _OutIter __result) { + while (__first != __last) { + *__result = ranges::iter_move(__first); + ++__first; + ++__result; + } + return {std::move(__first), std::move(__result)}; + } + + template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter> + requires indirectly_movable<_InIter, _OutIter> + _LIBCPP_HIDE_FROM_ABI constexpr + move_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { + return __move_impl(std::move(__first), std::move(__last), std::move(__result)); + } + + template <input_range _Range, weakly_incrementable _OutIter> + requires indirectly_movable<iterator_t<_Range>, _OutIter> + _LIBCPP_HIDE_FROM_ABI constexpr + move_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __range, _OutIter __result) const { + return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); + } + +}; +} // namespace __move + +inline namespace __cpo { + inline constexpr auto move = __move::__fn{}; +} // namespace __cpo +} // namespace ranges + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) + +#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h new file mode 100644 index 0000000000..b3dfa71396 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_move_backward.h @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// 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_MOVE_BACKWARD_H +#define _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H + +#include <__algorithm/in_out_result.h> +#include <__algorithm/ranges_move.h> +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/iter_move.h> +#include <__iterator/next.h> +#include <__iterator/reverse_iterator.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 _InIter, class _OutIter> +using move_backward_result = in_out_result<_InIter, _OutIter>; + +namespace __move_backward { +struct __fn { + + template <class _InIter, class _Sent, class _OutIter> + _LIBCPP_HIDE_FROM_ABI constexpr static + move_backward_result<_InIter, _OutIter> __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) { + auto __ret = ranges::move(std::make_reverse_iterator(ranges::next(__first, __last)), + std::make_reverse_iterator(__first), + std::make_reverse_iterator(__result)); + return {std::move(__ret.in.base()), std::move(__ret.out.base())}; + } + + template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter> + requires indirectly_movable<_InIter, _OutIter> + _LIBCPP_HIDE_FROM_ABI constexpr + move_backward_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const { + return __move_backward_impl(std::move(__first), std::move(__last), std::move(__result)); + } + + template <bidirectional_range _Range, bidirectional_iterator _Iter> + requires indirectly_movable<iterator_t<_Range>, _Iter> + _LIBCPP_HIDE_FROM_ABI constexpr + move_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __range, _Iter __result) const { + return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result)); + } + +}; +} // namespace __move_backward + +inline namespace __cpo { + inline constexpr auto move_backward = __move_backward::__fn{}; +} // namespace __cpo +} // namespace ranges + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) + +#endif // _LIBCPP___ALGORITHM_RANGES_MOVE_BACKWARD_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h index a0f1360691..969ac7a617 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_partition.h @@ -132,7 +132,10 @@ __stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate unique_ptr<value_type, __return_temporary_buffer> __h; if (__len >= __alloc_limit) { +// TODO: Remove the use of std::get_temporary_buffer +_LIBCPP_SUPPRESS_DEPRECATED_PUSH __p = _VSTD::get_temporary_buffer<value_type>(__len); +_LIBCPP_SUPPRESS_DEPRECATED_POP __h.reset(__p.first); } return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, forward_iterator_tag()); @@ -278,7 +281,10 @@ __stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last unique_ptr<value_type, __return_temporary_buffer> __h; if (__len >= __alloc_limit) { +// TODO: Remove the use of std::get_temporary_buffer +_LIBCPP_SUPPRESS_DEPRECATED_PUSH __p = _VSTD::get_temporary_buffer<value_type>(__len); +_LIBCPP_SUPPRESS_DEPRECATED_POP __h.reset(__p.first); } return _VSTD::__stable_partition<_Predicate&>(__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h index 33df6e8ba7..22b0a64db6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h +++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/stable_sort.h @@ -210,7 +210,10 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar unique_ptr<value_type, __return_temporary_buffer> __h; if (__len > static_cast<difference_type>(__stable_sort_switch<value_type>::value)) { +// TODO: Remove the use of std::get_temporary_buffer +_LIBCPP_SUPPRESS_DEPRECATED_PUSH __buf = _VSTD::get_temporary_buffer<value_type>(__len); +_LIBCPP_SUPPRESS_DEPRECATED_POP __h.reset(__buf.first); } typedef typename __comp_ref_type<_Compare>::type _Comp_ref; diff --git a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_base_10.h b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_base_10.h index 1c6804a852..91c209559a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_base_10.h +++ b/contrib/libs/cxxsupp/libcxx/include/__charconv/to_chars_base_10.h @@ -10,10 +10,10 @@ #ifndef _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H #define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H +#include <__algorithm/copy_n.h> #include <__charconv/tables.h> #include <__config> #include <cstdint> -#include <cstring> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -25,98 +25,97 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace __itoa { -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append1(char* __buffer, _Tp __value) noexcept { - *__buffer = '0' + static_cast<char>(__value); - return __buffer + 1; +_LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept { + *__first = '0' + static_cast<char>(__value); + return __first + 1; } -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append2(char* __buffer, _Tp __value) noexcept { - std::memcpy(__buffer, &__table<>::__digits_base_10[(__value)*2], 2); - return __buffer + 2; +_LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept { + return std::copy_n(&__table<>::__digits_base_10[__value * 2], 2, __first); } -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append3(char* __buffer, _Tp __value) noexcept { - return __itoa::__append2(__itoa::__append1(__buffer, (__value) / 100), (__value) % 100); +_LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept { + return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100); } -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append4(char* __buffer, _Tp __value) noexcept { - return __itoa::__append2(__itoa::__append2(__buffer, (__value) / 100), (__value) % 100); +_LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept { + return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100); } -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append2_no_zeros(char* __buffer, _Tp __value) noexcept { - if (__value < 10) - return __itoa::__append1(__buffer, __value); - else - return __itoa::__append2(__buffer, __value); +_LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept { + return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000); } -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append4_no_zeros(char* __buffer, _Tp __value) noexcept { - if (__value < 100) - return __itoa::__append2_no_zeros(__buffer, __value); - else if (__value < 1000) - return __itoa::__append3(__buffer, __value); - else - return __itoa::__append4(__buffer, __value); +_LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept { + return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000); +} + +_LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept { + return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000); } +_LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept { + return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000); +} + +_LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept { + return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000); +} + +// This function is used for uint32_t and uint64_t. template <class _Tp> -_LIBCPP_HIDE_FROM_ABI char* __append8_no_zeros(char* __buffer, _Tp __value) noexcept { - if (__value < 10000) - __buffer = __itoa::__append4_no_zeros(__buffer, __value); - else { - __buffer = __itoa::__append4_no_zeros(__buffer, __value / 10000); - __buffer = __itoa::__append4(__buffer, __value % 10000); - } - return __buffer; +_LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept { + return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)), + static_cast<uint32_t>(__value % 100000000)); } -_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(uint32_t __value, char* __buffer) noexcept { - if (__value < 100000000) - __buffer = __itoa::__append8_no_zeros(__buffer, __value); - else { - // __value = aabbbbcccc in decimal - const uint32_t __a = __value / 100000000; // 1 to 42 - __value %= 100000000; - - __buffer = __itoa::__append2_no_zeros(__buffer, __a); - __buffer = __itoa::__append4(__buffer, __value / 10000); - __buffer = __itoa::__append4(__buffer, __value % 10000); +_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u32(char* __first, uint32_t __value) noexcept { + if (__value < 1000000) { + if (__value < 10000) { + if (__value < 100) { + // 0 <= __value < 100 + if (__value < 10) + return __itoa::__append1(__first, __value); + return __itoa::__append2(__first, __value); + } + // 100 <= __value < 10'000 + if (__value < 1000) + return __itoa::__append3(__first, __value); + return __itoa::__append4(__first, __value); + } + + // 10'000 <= __value < 1'000'000 + if (__value < 100000) + return __itoa::__append5(__first, __value); + return __itoa::__append6(__first, __value); } - return __buffer; + // __value => 1'000'000 + if (__value < 100000000) { + // 1'000'000 <= __value < 100'000'000 + if (__value < 10000000) + return __itoa::__append7(__first, __value); + return __itoa::__append8(__first, __value); + } + + // 100'000'000 <= __value < max + if (__value < 1000000000) + return __itoa::__append9(__first, __value); + return __itoa::__append10(__first, __value); } -_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(uint64_t __value, char* __buffer) noexcept { - if (__value < 100000000) - __buffer = __itoa::__append8_no_zeros(__buffer, static_cast<uint32_t>(__value)); - else if (__value < 10000000000000000) { - const uint32_t __v0 = static_cast<uint32_t>(__value / 100000000); - const uint32_t __v1 = static_cast<uint32_t>(__value % 100000000); - - __buffer = __itoa::__append8_no_zeros(__buffer, __v0); - __buffer = __itoa::__append4(__buffer, __v1 / 10000); - __buffer = __itoa::__append4(__buffer, __v1 % 10000); - } else { - const uint32_t __a = static_cast<uint32_t>(__value / 10000000000000000); // 1 to 1844 - __value %= 10000000000000000; - - __buffer = __itoa::__append4_no_zeros(__buffer, __a); - - const uint32_t __v0 = static_cast<uint32_t>(__value / 100000000); - const uint32_t __v1 = static_cast<uint32_t>(__value % 100000000); - __buffer = __itoa::__append4(__buffer, __v0 / 10000); - __buffer = __itoa::__append4(__buffer, __v0 % 10000); - __buffer = __itoa::__append4(__buffer, __v1 / 10000); - __buffer = __itoa::__append4(__buffer, __v1 % 10000); - } +_LIBCPP_HIDE_FROM_ABI inline char* __base_10_u64(char* __buffer, uint64_t __value) noexcept { + if (__value <= UINT32_MAX) + return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value)); - return __buffer; + // Numbers in the range UINT32_MAX <= val < 10'000'000'000 always contain 10 + // digits and are outputted after this if statement. + if (__value >= 10000000000) { + // This function properly deterimines the first non-zero leading digit. + __buffer = __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value / 10000000000)); + __value %= 10000000000; + } + return __itoa::__append10(__buffer, __value); } } // namespace __itoa diff --git a/contrib/libs/cxxsupp/libcxx/include/__config b/contrib/libs/cxxsupp/libcxx/include/__config index ae679eb9e5..4249f208a3 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__config +++ b/contrib/libs/cxxsupp/libcxx/include/__config @@ -107,9 +107,6 @@ # define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE // Enable optimized version of __do_get_(un)signed which avoids redundant copies. # define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET -// In C++20 and later, don't derive std::plus from std::binary_function, -// nor std::negate from std::unary_function. -# define _LIBCPP_ABI_NO_BINDER_BASES // Give reverse_iterator<T> one data member of type T, not two. // Also, in C++17 and later, don't derive iterator types from std::iterator. # define _LIBCPP_ABI_NO_ITERATOR_BASES @@ -125,8 +122,6 @@ #endif // All the regex constants must be distinct and nonzero. # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO -// Use raw pointers, not wrapped ones, for std::span's iterator type. -# define _LIBCPP_ABI_SPAN_POINTER_ITERATORS // Re-worked external template instantiations for std::string with a focus on // performance and fast-path inlining. # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION @@ -547,42 +542,31 @@ typedef __char32_t char32_t; # define _LIBCPP_TEMPLATE_DATA_VIS # define _LIBCPP_ENUM_VIS -# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) +# else -# ifndef _LIBCPP_HIDDEN # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_HIDDEN __attribute__((__visibility__("hidden"))) +# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis))) # else -# define _LIBCPP_HIDDEN +# define _LIBCPP_VISIBILITY(vis) # endif -# endif -# ifndef _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS +# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden") +# define _LIBCPP_FUNC_VIS _LIBCPP_VISIBILITY("default") +# define _LIBCPP_TYPE_VIS _LIBCPP_VISIBILITY("default") +# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default") +# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default") +# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default") +# define _LIBCPP_EXCEPTION_ABI _LIBCPP_VISIBILITY("default") +# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default") +# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS + # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) // The inline should be removed once PR32114 is resolved # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN # else # define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS # endif -# endif - -# ifndef _LIBCPP_FUNC_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_FUNC_VIS __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_FUNC_VIS -# endif -# endif - -# ifndef _LIBCPP_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_TYPE_VIS __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_TYPE_VIS -# endif -# endif -# ifndef _LIBCPP_TEMPLATE_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) # if __has_attribute(__type_visibility__) # define _LIBCPP_TEMPLATE_VIS __attribute__((__type_visibility__("default"))) @@ -592,55 +576,14 @@ typedef __char32_t char32_t; # else # define _LIBCPP_TEMPLATE_VIS # endif -# endif - -# ifndef _LIBCPP_TEMPLATE_DATA_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_TEMPLATE_DATA_VIS __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_TEMPLATE_DATA_VIS -# endif -# endif - -# ifndef _LIBCPP_EXPORTED_FROM_ABI -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXPORTED_FROM_ABI __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_EXPORTED_FROM_ABI -# endif -# endif - -# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS -# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_FUNC_VIS -# endif - -# ifndef _LIBCPP_EXCEPTION_ABI -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXCEPTION_ABI __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_EXCEPTION_ABI -# endif -# endif -# ifndef _LIBCPP_ENUM_VIS # if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__) # define _LIBCPP_ENUM_VIS __attribute__((__type_visibility__("default"))) # else # define _LIBCPP_ENUM_VIS # endif -# endif - -# ifndef _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __attribute__((__visibility__("default"))) -# else -# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS -# endif -# endif -# ifndef _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS -# endif +# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF) # if __has_attribute(internal_linkage) # define _LIBCPP_INTERNAL_LINKAGE __attribute__((internal_linkage)) @@ -1145,6 +1088,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD # define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS # define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE # define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS +# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION # endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES # if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) @@ -1263,6 +1207,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD # define _LIBCPP_PACKED_BYTE_FOR_AIX_END /* empty */ # endif +# if __has_attribute(__packed__) && !defined(__CUDACC__) +# define _LIBCPP_PACKED __attribute__((__packed__)) +# else +# define _LIBCPP_PACKED +# endif + #endif // __cplusplus #endif // _LIBCPP___CONFIG diff --git a/contrib/libs/cxxsupp/libcxx/include/__debug b/contrib/libs/cxxsupp/libcxx/include/__debug index 403710600b..d3dd202b54 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__debug +++ b/contrib/libs/cxxsupp/libcxx/include/__debug @@ -12,6 +12,7 @@ #include <__assert> #include <__config> +#include <cstddef> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -51,10 +52,6 @@ #if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_BUILDING_LIBRARY) -#include <cstddef> -#include <cstdio> -#include <cstdlib> - _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_TYPE_VIS __c_node; diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h index 4f219c2b4e..4c9d3fc774 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_bool.h @@ -13,15 +13,18 @@ #include <__algorithm/copy.h> #include <__availability> #include <__config> +#include <__debug> #include <__format/format_error.h> #include <__format/format_fwd.h> +#include <__format/format_parse_context.h> #include <__format/formatter.h> #include <__format/formatter_integral.h> #include <__format/parser_std_format_spec.h> +#include <__utility/unreachable.h> #include <string_view> #ifndef _LIBCPP_HAS_NO_LOCALIZATION -#include <locale> +# include <locale> #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -32,101 +35,39 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -namespace __format_spec { - -template <class _CharT> -class _LIBCPP_TEMPLATE_VIS __parser_bool : public __parser_integral<_CharT> { +template <__formatter::__char_type _CharT> +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); - - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__string; - [[fallthrough]]; - case _Flags::_Type::__string: - this->__handle_bool(); - break; + _LIBCPP_HIDE_FROM_ABI constexpr auto + parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { + auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); + __format_spec::__process_parsed_bool(__parser_); + return __result; + } - case _Flags::_Type::__binary_lower_case: - case _Flags::_Type::__binary_upper_case: - case _Flags::_Type::__octal: - case _Flags::_Type::__decimal: - case _Flags::_Type::__hexadecimal_lower_case: - case _Flags::_Type::__hexadecimal_upper_case: - this->__handle_integer(); - break; + _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) const -> decltype(__ctx.out()) { + switch (__parser_.__type_) { + case __format_spec::__type::__string: + return __formatter::__format_bool(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); + + case __format_spec::__type::__binary_lower_case: + case __format_spec::__type::__binary_upper_case: + case __format_spec::__type::__octal: + case __format_spec::__type::__decimal: + case __format_spec::__type::__hexadecimal_lower_case: + case __format_spec::__type::__hexadecimal_upper_case: + // Promotes bool to an integral type. This reduces the number of + // instantiations of __format_integer reducing code size. + return __formatter::__format_integer( + static_cast<unsigned>(__value), __ctx, __parser_.__get_parsed_std_specifications(__ctx)); default: - __throw_format_error( - "The format-spec type has a type not supported for a bool argument"); + _LIBCPP_ASSERT(false, "The parse function should have validated the type"); + __libcpp_unreachable(); } - - return __it; } -}; - -template <class _CharT> -struct _LIBCPP_TEMPLATE_VIS __bool_strings; - -template <> -struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> { - static constexpr string_view __true{"true"}; - static constexpr string_view __false{"false"}; -}; - -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -template <> -struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> { - static constexpr wstring_view __true{L"true"}; - static constexpr wstring_view __false{L"false"}; -}; -#endif - -template <class _CharT> -using __formatter_bool = __formatter_integral<__parser_bool<_CharT>>; -} //namespace __format_spec - -// [format.formatter.spec]/2.3 -// For each charT, for each cv-unqualified arithmetic type ArithmeticT other -// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization - -template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> - : public __format_spec::__formatter_bool<_CharT> { - using _Base = __format_spec::__formatter_bool<_CharT>; - - _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) - -> decltype(__ctx.out()) { - if (this->__type != __format_spec::_Flags::_Type::__string) - return _Base::format(static_cast<unsigned char>(__value), __ctx); - - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - if (this->__locale_specific_form) { - const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale()); - basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename(); - return __formatter::__write_unicode( - __ctx.out(), basic_string_view<_CharT>{__str}, this->__width, -1, - this->__fill, this->__alignment); - } -#endif - basic_string_view<_CharT> __str = - __value ? __format_spec::__bool_strings<_CharT>::__true - : __format_spec::__bool_strings<_CharT>::__false; - - // The output only uses ASCII so every character is one column. - unsigned __size = __str.size(); - if (__size >= this->__width) - return _VSTD::copy(__str.begin(), __str.end(), __ctx.out()); - - return __formatter::__write(__ctx.out(), __str.begin(), __str.end(), __size, - this->__width, this->__fill, this->__alignment); - } + __format_spec::__parser<_CharT> __parser_; }; #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h index 87521e0fad..cd54abba34 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_char.h @@ -11,12 +11,16 @@ #define _LIBCPP___FORMAT_FORMATTER_CHAR_H #include <__availability> +#include <__concepts/same_as.h> #include <__config> -#include <__format/format_error.h> #include <__format/format_fwd.h> +#include <__format/format_parse_context.h> #include <__format/formatter.h> #include <__format/formatter_integral.h> +#include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> +#include <__type_traits/conditional.h> +#include <__type_traits/is_signed.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -26,69 +30,52 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -namespace __format_spec { - -template <class _CharT> -class _LIBCPP_TEMPLATE_VIS __parser_char : public __parser_integral<_CharT> { +template <__formatter::__char_type _CharT> +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); - - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__char; - [[fallthrough]]; - case _Flags::_Type::__char: - this->__handle_char(); - break; - - case _Flags::_Type::__binary_lower_case: - case _Flags::_Type::__binary_upper_case: - case _Flags::_Type::__octal: - case _Flags::_Type::__decimal: - case _Flags::_Type::__hexadecimal_lower_case: - case _Flags::_Type::__hexadecimal_upper_case: - this->__handle_integer(); - break; - - default: - __throw_format_error( - "The format-spec type has a type not supported for a char argument"); - } - - return __it; + _LIBCPP_HIDE_FROM_ABI constexpr auto + parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { + auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); + __format_spec::__process_parsed_char(__parser_); + return __result; } -}; -template <class _CharT> -using __formatter_char = __formatter_integral<__parser_char<_CharT>>; + _LIBCPP_HIDE_FROM_ABI auto format(_CharT __value, auto& __ctx) const -> decltype(__ctx.out()) { + if (__parser_.__type_ == __format_spec::__type::__char) + return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx)); + + if constexpr (sizeof(_CharT) <= sizeof(int)) + // Promotes _CharT to an integral type. This reduces the number of + // instantiations of __format_integer reducing code size. + return __formatter::__format_integer( + static_cast<conditional_t<is_signed_v<_CharT>, int, unsigned>>(__value), + __ctx, + __parser_.__get_parsed_std_specifications(__ctx)); + else + return __formatter::__format_integer(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx)); + } -} // namespace __format_spec + _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) const -> decltype(__ctx.out()) + requires(same_as<_CharT, wchar_t>) + { + return format(static_cast<wchar_t>(__value), __ctx); + } -// [format.formatter.spec]/2.1 The specializations + __format_spec::__parser<_CharT> __parser_; +}; template <> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> - : public __format_spec::__formatter_char<char> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> : public __formatter_char<char> {}; -#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> - : public __format_spec::__formatter_char<wchar_t> { - using _Base = __format_spec::__formatter_char<wchar_t>; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> : public __formatter_char<wchar_t> {}; - _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) - -> decltype(__ctx.out()) { - return _Base::format(static_cast<wchar_t>(__value), __ctx); - } +template <> +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> { }; -template <> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<wchar_t, wchar_t> - : public __format_spec::__formatter_char<wchar_t> {}; -#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS +# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h index 8c66e4e8fa..c9f5689abd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_floating_point.h @@ -447,7 +447,7 @@ _LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(_OutIt __out_it, cons if (__digits <= __grouping[0]) __grouping.clear(); else - __grouping = __determine_grouping(__digits, __grouping); + __grouping = __formatter::__determine_grouping(__digits, __grouping); } size_t __size = __result.__last - __buffer.begin() + // Formatted string diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h index 1c652ee54f..5d11f8d1d9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integer.h @@ -11,147 +11,120 @@ #define _LIBCPP___FORMAT_FORMATTER_INTEGER_H #include <__availability> +#include <__concepts/arithmetic.h> #include <__config> -#include <__format/format_error.h> +#include <__format/format_error.h> // TODO FMT Remove after adding 128-bit support #include <__format/format_fwd.h> +#include <__format/format_parse_context.h> #include <__format/formatter.h> #include <__format/formatter_integral.h> +#include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> -#include <limits> +#include <limits> // TODO FMT Remove after adding 128-bit support +#include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -_LIBCPP_PUSH_MACROS +_LIBCPP_PUSH_MACROS // TODO FMT Remove after adding 128-bit support #include <__undef_macros> -_LIBCPP_BEGIN_NAMESPACE_STD + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -namespace __format_spec { + template <__formatter::__char_type _CharT> + struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer { -template <class _CharT> -class _LIBCPP_TEMPLATE_VIS __parser_integer : public __parser_integral<_CharT> { public: - _LIBCPP_HIDE_FROM_ABI constexpr auto parse(auto& __parse_ctx) - -> decltype(__parse_ctx.begin()) { - auto __it = __parser_integral<_CharT>::__parse(__parse_ctx); - - switch (this->__type) { - case _Flags::_Type::__default: - this->__type = _Flags::_Type::__decimal; - [[fallthrough]]; - - case _Flags::_Type::__binary_lower_case: - case _Flags::_Type::__binary_upper_case: - case _Flags::_Type::__octal: - case _Flags::_Type::__decimal: - case _Flags::_Type::__hexadecimal_lower_case: - case _Flags::_Type::__hexadecimal_upper_case: - this->__handle_integer(); - break; - - case _Flags::_Type::__char: - this->__handle_char(); - break; - - default: - __throw_format_error("The format-spec type has a type not supported for " - "an integer argument"); - } - return __it; + _LIBCPP_HIDE_FROM_ABI constexpr auto + parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { + auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral); + __format_spec::__process_parsed_integer(__parser_); + return __result; } -}; -template <class _CharT> -using __formatter_integer = __formatter_integral<__parser_integer<_CharT>>; + template <integral _Tp> + _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) { + __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx); + + if (__specs.__std_.__type_ == __format_spec::__type::__char) + return __formatter::__format_char(__value, __ctx.out(), __specs); -} // namespace __format_spec + using _Type = __make_32_64_or_128_bit_t<_Tp>; + static_assert(!is_same<_Type, void>::value, "unsupported integral type used in __formatter_integer::__format"); + + // Reduce the number of instantiation of the integer formatter + return __formatter::__format_integer(static_cast<_Type>(__value), __ctx, __specs); + } -// [format.formatter.spec]/2.3 -// For each charT, for each cv-unqualified arithmetic type ArithmeticT other -// than char, wchar_t, char8_t, char16_t, or char32_t, a specialization + __format_spec::__parser<_CharT> __parser_; +}; // Signed integral types. template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<signed char, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT> + : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> { +}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<long long, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; -#ifndef _LIBCPP_HAS_NO_INT128 +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT> + : public __formatter_integer<_CharT> {}; +# ifndef _LIBCPP_HAS_NO_INT128 template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<__int128_t, _CharT> - : public __format_spec::__formatter_integer<_CharT> { - using _Base = __format_spec::__formatter_integer<_CharT>; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT> + : public __formatter_integer<_CharT> { + using _Base = __formatter_integer<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(__int128_t __value, auto& __ctx) - -> decltype(__ctx.out()) { + _LIBCPP_HIDE_FROM_ABI auto format(__int128_t __value, auto& __ctx) const -> decltype(__ctx.out()) { // TODO FMT Implement full 128 bit support. using _To = long long; - if (__value < numeric_limits<_To>::min() || - __value > numeric_limits<_To>::max()) - __throw_format_error("128-bit value is outside of implemented range"); + if (__value < numeric_limits<_To>::min() || __value > numeric_limits<_To>::max()) + std::__throw_format_error("128-bit value is outside of implemented range"); return _Base::format(static_cast<_To>(__value), __ctx); } }; -#endif +# endif // Unsigned integral types. template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<unsigned char, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT> + : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<unsigned short, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT> + : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<unsigned, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT> + : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<unsigned long, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT> + : public __formatter_integer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<unsigned long long, _CharT> - : public __format_spec::__formatter_integer<_CharT> {}; -#ifndef _LIBCPP_HAS_NO_INT128 +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT> + : public __formatter_integer<_CharT> {}; +# ifndef _LIBCPP_HAS_NO_INT128 template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<__uint128_t, _CharT> - : public __format_spec::__formatter_integer<_CharT> { - using _Base = __format_spec::__formatter_integer<_CharT>; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT> + : public __formatter_integer<_CharT> { + using _Base = __formatter_integer<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(__uint128_t __value, auto& __ctx) - -> decltype(__ctx.out()) { + _LIBCPP_HIDE_FROM_ABI auto format(__uint128_t __value, auto& __ctx) const -> decltype(__ctx.out()) { // TODO FMT Implement full 128 bit support. using _To = unsigned long long; - if (__value < numeric_limits<_To>::min() || - __value > numeric_limits<_To>::max()) - __throw_format_error("128-bit value is outside of implemented range"); + if (__value < numeric_limits<_To>::min() || __value > numeric_limits<_To>::max()) + std::__throw_format_error("128-bit value is outside of implemented range"); return _Base::format(static_cast<_To>(__value), __ctx); } }; -#endif +# endif #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h index 6cc79db1a8..4ad6de0ec6 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_integral.h @@ -10,25 +10,20 @@ #ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H #define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H -#include <__algorithm/copy.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/transform.h> -#include <__assert> +#include <__concepts/arithmetic.h> +#include <__concepts/same_as.h> #include <__config> #include <__format/format_error.h> -#include <__format/format_fwd.h> -#include <__format/formatter.h> +#include <__format/formatter.h> // for __char_type TODO FMT Move the concept? +#include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> #include <__utility/unreachable.h> -#include <array> #include <charconv> -#include <concepts> #include <limits> #include <string> #ifndef _LIBCPP_HAS_NO_LOCALIZATION -#include <locale> +# include <locale> #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -42,91 +37,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -/** - * Integral formatting classes. - * - * There are two types used here: - * * C++-type, the type as used in C++. - * * format-type, the output type specified in the std-format-spec. - * - * Design of the integral formatters consists of several layers. - * * @ref __parser_integral The basic std-format-spec parser for all integral - * classes. This parser does the basic sanity checks. It also contains some - * helper functions that are nice to have available for all parsers. - * * A C++-type specific parser. These parsers must derive from - * @ref __parser_integral. Their task is to validate whether the parsed - * std-format-spec is valid for the C++-type and selected format-type. After - * validation they need to make sure all members are properly set. For - * example, when the alignment hasn't changed it needs to set the proper - * default alignment for the format-type. The following parsers are available: - * - @ref __parser_integer - * - @ref __parser_char - * - @ref __parser_bool - * * A general formatter for all integral types @ref __formatter_integral. This - * formatter can handle all formatting of integers and characters. The class - * derives from the proper formatter. - * Note the boolean string format-type isn't supported in this class. - * * A typedef C++-type group combining the @ref __formatter_integral with a - * parser: - * * @ref __formatter_integer - * * @ref __formatter_char - * * @ref __formatter_bool - * * Then every C++-type has its own formatter specializations. They inherit - * from the C++-type group typedef. Most specializations need nothing else. - * Others need some additional specializations in this class. - */ -namespace __format_spec { - -/** Wrapper around @ref to_chars, returning the output pointer. */ -template <integral _Tp> -_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, - _Tp __value, int __base) { - // TODO FMT Evaluate code overhead due to not calling the internal function - // directly. (Should be zero overhead.) - to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base); - _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); - return __r.ptr; -} - -/** - * Helper to determine the buffer size to output a integer in Base @em x. - * - * There are several overloads for the supported bases. The function uses the - * base as template argument so it can be used in a constant expression. - */ -template <unsigned_integral _Tp, size_t _Base> -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 2) { - return numeric_limits<_Tp>::digits // The number of binary digits. - + 2 // Reserve space for the '0[Bb]' prefix. - + 1; // Reserve space for the sign. -} +namespace __formatter { -template <unsigned_integral _Tp, size_t _Base> -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 8) { - return numeric_limits<_Tp>::digits // The number of binary digits. - / 3 // Adjust to octal. - + 1 // Turn floor to ceil. - + 1 // Reserve space for the '0' prefix. - + 1; // Reserve space for the sign. -} +// +// Generic +// -template <unsigned_integral _Tp, size_t _Base> -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 10) { - return numeric_limits<_Tp>::digits10 // The floored value. - + 1 // Turn floor to ceil. - + 1; // Reserve space for the sign. -} +_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative, __format_spec::__sign __sign) { + if (__negative) + *__buf++ = '-'; + else + switch (__sign) { + case __format_spec::__sign::__default: + case __format_spec::__sign::__minus: + // No sign added. + break; + case __format_spec::__sign::__plus: + *__buf++ = '+'; + break; + case __format_spec::__sign::__space: + *__buf++ = ' '; + break; + } -template <unsigned_integral _Tp, size_t _Base> -_LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept - requires(_Base == 16) { - return numeric_limits<_Tp>::digits // The number of binary digits. - / 4 // Adjust to hexadecimal. - + 2 // Reserve space for the '0[Xx]' prefix. - + 1; // Reserve space for the sign. + return __buf; } /** @@ -144,8 +78,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t __buffer_size() noexcept * @note The grouping field of the locale is always a @c std::string, * regardless whether the @c std::numpunct's type is @c char or @c wchar_t. */ -_LIBCPP_HIDE_FROM_ABI inline string -__determine_grouping(ptrdiff_t __size, const string& __grouping) { +_LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const string& __grouping) { _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0], "The slow grouping formatting is used while there will be no " "separators written"); @@ -175,278 +108,253 @@ __determine_grouping(ptrdiff_t __size, const string& __grouping) { __libcpp_unreachable(); } -template <class _Parser> -requires __formatter::__char_type<typename _Parser::char_type> -class _LIBCPP_TEMPLATE_VIS __formatter_integral : public _Parser { -public: - using _CharT = typename _Parser::char_type; - - template <integral _Tp> - _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) - -> decltype(__ctx.out()) { - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - if (this->__type == _Flags::_Type::__char) - return __format_as_char(__value, __ctx); +// +// Char +// - if constexpr (unsigned_integral<_Tp>) - return __format_unsigned_integral(__value, false, __ctx); - else { - // Depending on the std-format-spec string the sign and the value - // might not be outputted together: - // - alternate form may insert a prefix string. - // - zero-padding may insert additional '0' characters. - // Therefore the value is processed as a positive unsigned value. - // The function @ref __insert_sign will a '-' when the value was negative. - auto __r = __to_unsigned_like(__value); - bool __negative = __value < 0; - if (__negative) - __r = __complement(__r); - - return __format_unsigned_integral(__r, __negative, __ctx); +template <__formatter::__char_type _CharT> +_LIBCPP_HIDE_FROM_ABI auto __format_char( + integral auto __value, + output_iterator<const _CharT&> auto __out_it, + __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) { + using _Tp = decltype(__value); + if constexpr (!same_as<_CharT, _Tp>) { + // cmp_less and cmp_greater can't be used for character types. + if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) { + if (__value < numeric_limits<_CharT>::min() || __value > numeric_limits<_CharT>::max()) + std::__throw_format_error("Integral value outside the range of the char type"); + } else if constexpr (signed_integral<_CharT>) { + // _CharT is signed _Tp is unsigned + if (__value > static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max())) + std::__throw_format_error("Integral value outside the range of the char type"); + } else { + // _CharT is unsigned _Tp is signed + if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) > numeric_limits<_CharT>::max()) + std::__throw_format_error("Integral value outside the range of the char type"); } } -private: - /** Generic formatting for format-type c. */ - _LIBCPP_HIDE_FROM_ABI auto __format_as_char(integral auto __value, - auto& __ctx) - -> decltype(__ctx.out()) { - if (this->__alignment == _Flags::_Alignment::__default) - this->__alignment = _Flags::_Alignment::__right; - - using _Tp = decltype(__value); - if constexpr (!same_as<_CharT, _Tp>) { - // cmp_less and cmp_greater can't be used for character types. - if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) { - if (__value < numeric_limits<_CharT>::min() || - __value > numeric_limits<_CharT>::max()) - __throw_format_error( - "Integral value outside the range of the char type"); - } else if constexpr (signed_integral<_CharT>) { - // _CharT is signed _Tp is unsigned - if (__value > - static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max())) - __throw_format_error( - "Integral value outside the range of the char type"); - } else { - // _CharT is unsigned _Tp is signed - if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) > - numeric_limits<_CharT>::max()) - __throw_format_error( - "Integral value outside the range of the char type"); - } - } + const auto __c = static_cast<_CharT>(__value); + return __formatter::__write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, _VSTD::move(__out_it), __specs); +} - const auto __c = static_cast<_CharT>(__value); - return __write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, - __ctx.out()); - } +// +// Integer +// - /** - * Generic formatting for format-type bBdoxX. - * - * This small wrapper allocates a buffer with the required size. Then calls - * the real formatter with the buffer and the prefix for the base. - */ - _LIBCPP_HIDE_FROM_ABI auto - __format_unsigned_integral(unsigned_integral auto __value, bool __negative, - auto& __ctx) -> decltype(__ctx.out()) { - switch (this->__type) { - case _Flags::_Type::__binary_lower_case: { - array<char, __buffer_size<decltype(__value), 2>()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 2, __ctx, "0b"); - } - case _Flags::_Type::__binary_upper_case: { - array<char, __buffer_size<decltype(__value), 2>()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 2, __ctx, "0B"); - } - case _Flags::_Type::__octal: { - // Octal is special; if __value == 0 there's no prefix. - array<char, __buffer_size<decltype(__value), 8>()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 8, __ctx, - __value != 0 ? "0" : nullptr); - } - case _Flags::_Type::__decimal: { - array<char, __buffer_size<decltype(__value), 10>()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 10, __ctx, nullptr); - } - case _Flags::_Type::__hexadecimal_lower_case: { - array<char, __buffer_size<decltype(__value), 16>()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 16, __ctx, "0x"); - } - case _Flags::_Type::__hexadecimal_upper_case: { - array<char, __buffer_size<decltype(__value), 16>()> __array; - return __format_unsigned_integral(__array.begin(), __array.end(), __value, - __negative, 16, __ctx, "0X"); - } - default: - _LIBCPP_ASSERT(false, "The parser should have validated the type"); - __libcpp_unreachable(); - } - } +/** Wrapper around @ref to_chars, returning the output pointer. */ +template <integral _Tp> +_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, int __base) { + // TODO FMT Evaluate code overhead due to not calling the internal function + // directly. (Should be zero overhead.) + to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base); + _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small"); + return __r.ptr; +} - template <class _Tp> - requires(same_as<char, _Tp> || same_as<wchar_t, _Tp>) _LIBCPP_HIDE_FROM_ABI - auto __write(const _Tp* __first, const _Tp* __last, auto __out_it) - -> decltype(__out_it) { +/** + * Helper to determine the buffer size to output a integer in Base @em x. + * + * There are several overloads for the supported bases. The function uses the + * base as template argument so it can be used in a constant expression. + */ +template <unsigned_integral _Tp, size_t _Base> +consteval size_t __buffer_size() noexcept + requires(_Base == 2) +{ + return numeric_limits<_Tp>::digits // The number of binary digits. + + 2 // Reserve space for the '0[Bb]' prefix. + + 1; // Reserve space for the sign. +} - unsigned __size = __last - __first; - if (this->__type != _Flags::_Type::__hexadecimal_upper_case) [[likely]] { - if (__size >= this->__width) - return _VSTD::copy(__first, __last, _VSTD::move(__out_it)); +template <unsigned_integral _Tp, size_t _Base> +consteval size_t __buffer_size() noexcept + requires(_Base == 8) +{ + return numeric_limits<_Tp>::digits // The number of binary digits. + / 3 // Adjust to octal. + + 1 // Turn floor to ceil. + + 1 // Reserve space for the '0' prefix. + + 1; // Reserve space for the sign. +} - return __formatter::__write(_VSTD::move(__out_it), __first, __last, - __size, this->__width, this->__fill, - this->__alignment); - } +template <unsigned_integral _Tp, size_t _Base> +consteval size_t __buffer_size() noexcept + requires(_Base == 10) +{ + return numeric_limits<_Tp>::digits10 // The floored value. + + 1 // Turn floor to ceil. + + 1; // Reserve space for the sign. +} + +template <unsigned_integral _Tp, size_t _Base> +consteval size_t __buffer_size() noexcept + requires(_Base == 16) +{ + return numeric_limits<_Tp>::digits // The number of binary digits. + / 4 // Adjust to hexadecimal. + + 2 // Reserve space for the '0[Xx]' prefix. + + 1; // Reserve space for the sign. +} - // this->__type == _Flags::_Type::__hexadecimal_upper_case - // This means all characters in the range [a-f] need to be changed to their - // uppercase representation. The transformation is done as transformation - // in the output routine instead of before. This avoids another pass over - // the data. - // TODO FMT See whether it's possible to do this transformation during the - // conversion. (This probably requires changing std::to_chars' alphabet.) - if (__size >= this->__width) - return _VSTD::transform(__first, __last, _VSTD::move(__out_it), - __hex_to_upper); - - return __formatter::__write(_VSTD::move(__out_it), __first, __last, __size, - __hex_to_upper, this->__width, this->__fill, - this->__alignment); +template <unsigned_integral _Tp, class _CharT> +_LIBCPP_HIDE_FROM_ABI auto __format_integer( + _Tp __value, + auto& __ctx, + __format_spec::__parsed_specifications<_CharT> __specs, + bool __negative, + char* __begin, + char* __end, + const char* __prefix, + int __base) -> decltype(__ctx.out()) { + _LIBCPP_ASSERT( + __specs.__alignment_ != __format_spec::__alignment::__default, + "the caller should adjust the default to the value required by the type"); + + char* __first = __formatter::__insert_sign(__begin, __negative, __specs.__std_.__sign_); + if (__specs.__std_.__alternate_form_ && __prefix) + while (*__prefix) + *__first++ = *__prefix++; + + char* __last = __formatter::__to_buffer(__first, __end, __value, __base); + +# ifndef _LIBCPP_HAS_NO_LOCALIZATION + if (__specs.__std_.__locale_specific_form_) { + const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale()); + string __grouping = __np.grouping(); + ptrdiff_t __size = __last - __first; + // Writing the grouped form has more overhead than the normal output + // routines. If there will be no separators written the locale-specific + // form is identical to the normal routine. Test whether to grouped form + // is required. + if (!__grouping.empty() && __size > __grouping[0]) + return __formatter::__write_using_decimal_separators( + __ctx.out(), + __begin, + __first, + __last, + __formatter::__determine_grouping(__size, __grouping), + __np.thousands_sep(), + __specs); + } +# endif + auto __out_it = __ctx.out(); + if (__specs.__alignment_ != __format_spec::__alignment::__zero_padding) + __first = __begin; + else { + // __buf contains [sign][prefix]data + // ^ location of __first + // The zero padding is done like: + // - Write [sign][prefix] + // - Write data right aligned with '0' as fill character. + __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); + __specs.__alignment_ = __format_spec::__alignment::__right; + __specs.__fill_ = _CharT('0'); + int32_t __size = __first - __begin; + + __specs.__width_ -= _VSTD::min(__size, __specs.__width_); } - _LIBCPP_HIDE_FROM_ABI auto - __format_unsigned_integral(char* __begin, char* __end, - unsigned_integral auto __value, bool __negative, - int __base, auto& __ctx, const char* __prefix) - -> decltype(__ctx.out()) { - char* __first = __insert_sign(__begin, __negative, this->__sign); - if (this->__alternate_form && __prefix) - while (*__prefix) - *__first++ = *__prefix++; - - char* __last = __to_buffer(__first, __end, __value, __base); -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - if (this->__locale_specific_form) { - const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale()); - string __grouping = __np.grouping(); - ptrdiff_t __size = __last - __first; - // Writing the grouped form has more overhead than the normal output - // routines. If there will be no separators written the locale-specific - // form is identical to the normal routine. Test whether to grouped form - // is required. - if (!__grouping.empty() && __size > __grouping[0]) - return __format_grouping(__ctx.out(), __begin, __first, __last, - __determine_grouping(__size, __grouping), - __np.thousands_sep()); - } -#endif - auto __out_it = __ctx.out(); - if (this->__alignment != _Flags::_Alignment::__default) - __first = __begin; - else { - // __buf contains [sign][prefix]data - // ^ location of __first - // The zero padding is done like: - // - Write [sign][prefix] - // - Write data right aligned with '0' as fill character. - __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); - this->__alignment = _Flags::_Alignment::__right; - this->__fill = _CharT('0'); - uint32_t __size = __first - __begin; - this->__width -= _VSTD::min(__size, this->__width); - } + if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]] + return __formatter::__write(__first, __last, __ctx.out(), __specs); + + return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper); +} - return __write(__first, __last, _VSTD::move(__out_it)); +template <unsigned_integral _Tp, class _CharT> +_LIBCPP_HIDE_FROM_ABI auto __format_integer( + _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false) + -> decltype(__ctx.out()) { + switch (__specs.__std_.__type_) { + case __format_spec::__type::__binary_lower_case: { + array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array; + return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0b", 2); } + case __format_spec::__type::__binary_upper_case: { + array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array; + return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0B", 2); + } + case __format_spec::__type::__octal: { + // Octal is special; if __value == 0 there's no prefix. + array<char, __formatter::__buffer_size<decltype(__value), 8>()> __array; + return __formatter::__format_integer( + __value, __ctx, __specs, __negative, __array.begin(), __array.end(), __value != 0 ? "0" : nullptr, 8); + } + case __format_spec::__type::__decimal: { + array<char, __formatter::__buffer_size<decltype(__value), 10>()> __array; + return __formatter::__format_integer( + __value, __ctx, __specs, __negative, __array.begin(), __array.end(), nullptr, 10); + } + case __format_spec::__type::__hexadecimal_lower_case: { + array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array; + return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0x", 16); + } + case __format_spec::__type::__hexadecimal_upper_case: { + array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array; + return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0X", 16); + } + default: + _LIBCPP_ASSERT(false, "The parse function should have validated the type"); + __libcpp_unreachable(); + } +} -#ifndef _LIBCPP_HAS_NO_LOCALIZATION - /** Format's the locale-specific form's groupings. */ - template <class _OutIt, class _CharT> - _LIBCPP_HIDE_FROM_ABI _OutIt - __format_grouping(_OutIt __out_it, const char* __begin, const char* __first, - const char* __last, string&& __grouping, _CharT __sep) { - - // TODO FMT This function duplicates some functionality of the normal - // output routines. Evaluate whether these parts can be efficiently - // combined with the existing routines. - - unsigned __size = (__first - __begin) + // [sign][prefix] - (__last - __first) + // data - (__grouping.size() - 1); // number of separator characters - - __formatter::__padding_size_result __padding = {0, 0}; - if (this->__alignment == _Flags::_Alignment::__default) { - // Write [sign][prefix]. - __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); - - if (this->__width > __size) { - // Write zero padding. - __padding.__before = this->__width - __size; - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), this->__width - __size, - _CharT('0')); - } - } else { - if (this->__width > __size) { - // Determine padding and write padding. - __padding = __formatter::__padding_size(__size, this->__width, - this->__alignment); - - __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before, - this->__fill); - } - // Write [sign][prefix]. - __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); - } +template <signed_integral _Tp, class _CharT> +_LIBCPP_HIDE_FROM_ABI auto +__format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) + -> decltype(__ctx.out()) { + // Depending on the std-format-spec string the sign and the value + // might not be outputted together: + // - alternate form may insert a prefix string. + // - zero-padding may insert additional '0' characters. + // Therefore the value is processed as a positive unsigned value. + // The function @ref __insert_sign will a '-' when the value was negative. + auto __r = std::__to_unsigned_like(__value); + bool __negative = __value < 0; + if (__negative) + __r = __complement(__r); + + return __formatter::__format_integer(__r, __ctx, __specs, __negative); +} - auto __r = __grouping.rbegin(); - auto __e = __grouping.rend() - 1; - _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while " - "there will be no separators written."); - // The output is divided in small groups of numbers to write: - // - A group before the first separator. - // - A separator and a group, repeated for the number of separators. - // - A group after the last separator. - // This loop achieves that process by testing the termination condition - // midway in the loop. - // - // TODO FMT This loop evaluates the loop invariant `this->__type != - // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test - // happens in the __write call.) Benchmark whether making two loops and - // hoisting the invariant is worth the effort. - while (true) { - if (this->__type == _Flags::_Type::__hexadecimal_upper_case) { - __last = __first + *__r; - __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), - __hex_to_upper); - __first = __last; - } else { - __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it)); - __first += *__r; - } - - if (__r == __e) - break; - - ++__r; - *__out_it++ = __sep; - } +// +// Formatter arithmetic (bool) +// - return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after, - this->__fill); - } -#endif // _LIBCPP_HAS_NO_LOCALIZATION +template <class _CharT> +struct _LIBCPP_TEMPLATE_VIS __bool_strings; + +template <> +struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> { + static constexpr string_view __true{"true"}; + static constexpr string_view __false{"false"}; +}; + +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +template <> +struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> { + static constexpr wstring_view __true{L"true"}; + static constexpr wstring_view __false{L"false"}; }; +# endif + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI auto +__format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) + -> decltype(__ctx.out()) { +# ifndef _LIBCPP_HAS_NO_LOCALIZATION + if (__specs.__std_.__locale_specific_form_) { + const auto& __np = use_facet<numpunct<_CharT>>(__ctx.locale()); + basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename(); + return __formatter::__write_unicode_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs); + } +# endif + basic_string_view<_CharT> __str = + __value ? __formatter::__bool_strings<_CharT>::__true : __formatter::__bool_strings<_CharT>::__false; + return __formatter::__write(__str.begin(), __str.end(), __ctx.out(), __specs); +} -} // namespace __format_spec +} // namespace __formatter #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h new file mode 100644 index 0000000000..ab016f6f16 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_output.h @@ -0,0 +1,304 @@ +// -*- 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_FORMATTER_OUTPUT_H +#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H + +#include <__algorithm/copy.h> +#include <__algorithm/copy_n.h> +#include <__algorithm/fill_n.h> +#include <__algorithm/transform.h> +#include <__config> +#include <__format/formatter.h> +#include <__format/parser_std_format_spec.h> +#include <__utility/move.h> +#include <__utility/unreachable.h> +#include <cstddef> +#include <string> +#include <string_view> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +namespace __formatter { + +_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char c) { + switch (c) { + case 'a': + return 'A'; + case 'b': + return 'B'; + case 'c': + return 'C'; + case 'd': + return 'D'; + case 'e': + return 'E'; + case 'f': + return 'F'; + } + return c; +} + +// TODO FMT remove _v2 suffix. +struct _LIBCPP_TYPE_VIS __padding_size_result_v2 { + size_t __before_; + size_t __after_; +}; + +// TODO FMT remove _v2 suffix. +_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result_v2 __padding_size_v2(size_t __size, size_t __width, + __format_spec::__alignment __align) { + _LIBCPP_ASSERT(__width > __size, "don't call this function when no padding is required"); + _LIBCPP_ASSERT(__align != __format_spec::__alignment::__default, + "the caller should adjust the default to the value required by the type"); + _LIBCPP_ASSERT(__align != __format_spec::__alignment::__zero_padding, + "the caller should have handled the zero-padding"); + + size_t __fill = __width - __size; + switch (__align) { + case __format_spec::__alignment::__default: + case __format_spec::__alignment::__zero_padding: + __libcpp_unreachable(); + + case __format_spec::__alignment::__left: + return {0, __fill}; + + case __format_spec::__alignment::__center: { + // The extra padding is divided per [format.string.std]/3 + // __before = floor(__fill, 2); + // __after = ceil(__fill, 2); + size_t __before = __fill / 2; + size_t __after = __fill - __before; + return {__before, __after}; + } + case __format_spec::__alignment::__right: + return {__fill, 0}; + } + __libcpp_unreachable(); +} + +template <class _OutIt, class _CharT> +_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first, + const char* __last, string&& __grouping, _CharT __sep, + __format_spec::__parsed_specifications<_CharT> __specs) { + _LIBCPP_ASSERT(__specs.__alignment_ != __format_spec::__alignment::__default, + "the caller should adjust the default to the value required by the type"); + + int __size = (__first - __begin) + // [sign][prefix] + (__last - __first) + // data + (__grouping.size() - 1); // number of separator characters + + __padding_size_result_v2 __padding = {0, 0}; + if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) { + // Write [sign][prefix]. + __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); + + if (__specs.__width_ > __size) { + // Write zero padding. + __padding.__before_ = __specs.__width_ - __size; + __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0')); + } + } else { + if (__specs.__width_ > __size) { + // Determine padding and write padding. + __padding = __padding_size_v2(__size, __specs.__width_, __specs.__alignment_); + + __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); + } + // Write [sign][prefix]. + __out_it = _VSTD::copy(__begin, __first, _VSTD::move(__out_it)); + } + + auto __r = __grouping.rbegin(); + auto __e = __grouping.rend() - 1; + _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while " + "there will be no separators written."); + // The output is divided in small groups of numbers to write: + // - A group before the first separator. + // - A separator and a group, repeated for the number of separators. + // - A group after the last separator. + // This loop achieves that process by testing the termination condition + // midway in the loop. + // + // TODO FMT This loop evaluates the loop invariant `__parser.__type != + // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test + // happens in the __write call.) Benchmark whether making two loops and + // hoisting the invariant is worth the effort. + while (true) { + if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) { + __last = __first + *__r; + __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper); + __first = __last; + } else { + __out_it = _VSTD::copy_n(__first, *__r, _VSTD::move(__out_it)); + __first += *__r; + } + + if (__r == __e) + break; + + ++__r; + *__out_it++ = __sep; + } + + return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); +} + +/// Writes the input to the output with the required padding. +/// +/// Since the output column width is specified the function can be used for +/// ASCII and Unicode output. +/// +/// \pre [\a __first, \a __last) is a valid range. +/// \pre \a __size <= \a __width. Using this function when this pre-condition +/// doesn't hold incurs an unwanted overhead. +/// +/// \param __first Pointer to the first element to write. +/// \param __last Pointer beyond the last element to write. +/// \param __out_it The output iterator to write to. +/// \param __specs The parsed formatting specifications. +/// \param __size The (estimated) output column width. When the elements +/// to be written are ASCII the following condition holds +/// \a __size == \a __last - \a __first. +/// +/// \returns An iterator pointing beyond the last element written. +/// +/// \note The type of the elements in range [\a __first, \a __last) can differ +/// from the type of \a __specs. Integer output uses \c std::to_chars for its +/// conversion, which means the [\a __first, \a __last) always contains elements +/// of the type \c char. +template <class _CharT, class _ParserCharT> +_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last, + output_iterator<const _CharT&> auto __out_it, + __format_spec::__parsed_specifications<_ParserCharT> __specs, ptrdiff_t __size) + -> decltype(__out_it) { + _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); + + if (__size >= __specs.__width_) + return _VSTD::copy(__first, __last, _VSTD::move(__out_it)); + + __padding_size_result_v2 __padding = + __formatter::__padding_size_v2(__size, __specs.__width_, __specs.__std_.__alignment_); + __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); + __out_it = _VSTD::copy(__first, __last, _VSTD::move(__out_it)); + return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); +} + +/// \overload +/// Calls the function above where \a __size = \a __last - \a __first. +template <class _CharT, class _ParserCharT> +_LIBCPP_HIDE_FROM_ABI auto __write(const _CharT* __first, const _CharT* __last, + output_iterator<const _CharT&> auto __out_it, + __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) { + return __write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first); +} + +template <class _CharT, class _ParserCharT, class _UnaryOperation> +_LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _CharT* __last, + output_iterator<const _CharT&> auto __out_it, + __format_spec::__parsed_specifications<_ParserCharT> __specs, + _UnaryOperation __op) -> decltype(__out_it) { + _LIBCPP_ASSERT(__first <= __last, "Not a valid range"); + + ptrdiff_t __size = __last - __first; + if (__size >= __specs.__width_) + return _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op); + + __padding_size_result_v2 __padding = __padding_size_v2(__size, __specs.__width_, __specs.__alignment_); + __out_it = _VSTD::fill_n(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_); + __out_it = _VSTD::transform(__first, __last, _VSTD::move(__out_it), __op); + return _VSTD::fill_n(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_); +} + +# ifndef _LIBCPP_HAS_NO_UNICODE +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI auto __write_unicode_no_precision(basic_string_view<_CharT> __str, + output_iterator<const _CharT&> auto __out_it, + __format_spec::__parsed_specifications<_CharT> __specs) + -> decltype(__out_it) { + + _LIBCPP_ASSERT(!__specs.__has_precision(), "use __write_unicode"); + // No padding -> copy the string + if (!__specs.__has_width()) + return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it)); + + // Non Unicode part larger than width -> copy the string + auto __last = __format_spec::__detail::__estimate_column_width_fast(__str.begin(), __str.end()); + ptrdiff_t __size = __last - __str.begin(); + if (__size >= __specs.__width_) + return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it)); + + // Is there a non Unicode part? + if (__last != __str.end()) { + // Non Unicode and Unicode part larger than width -> copy the string + __format_spec::__detail::__column_width_result __column_width = + __format_spec::__detail::__estimate_column_width(__last, __str.end(), __specs.__width_); + __size += __column_width.__width; // Note this new size is used when __size < __specs.__width_ + if (__size >= __specs.__width_) + return _VSTD::copy(__str.begin(), __str.end(), _VSTD::move(__out_it)); + } + + return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size); +} +# endif + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI auto __write_unicode(basic_string_view<_CharT> __str, + output_iterator<const _CharT&> auto __out_it, + __format_spec::__parsed_specifications<_CharT> __specs) + -> decltype(__out_it) { +# ifndef _LIBCPP_HAS_NO_UNICODE + if (!__specs.__has_precision()) + return __formatter::__write_unicode_no_precision(__str, _VSTD::move(__out_it), __specs); + + // Non unicode part larger than precision -> truncate the output and use the normal write operation. + auto __last = __format_spec::__detail::__estimate_column_width_fast(__str.begin(), __str.end()); + ptrdiff_t __size = __last - __str.begin(); + if (__size >= __specs.__precision_) + return __formatter::__write(__str.begin(), __str.begin() + __specs.__precision_, _VSTD::move(__out_it), __specs, + __specs.__precision_); + + // No non Unicode part, implies __size < __specs.__precision_ -> use normal write operation + if (__last == __str.end()) + return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __str.size()); + + __format_spec::__detail::__column_width_result __column_width = + __format_spec::__detail::__estimate_column_width(__last, __str.end(), __specs.__precision_ - __size); + __size += __column_width.__width; + // Truncate the output + if (__column_width.__ptr != __str.end()) + __str.remove_suffix(__str.end() - __column_width.__ptr); + + return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size); + +# else + if (__specs.__has_precision()) { + ptrdiff_t __size = __str.size(); + if (__size > __specs.__precision_) + return __formatter::__write(__str.begin(), __str.begin() + __specs.__precision_, _VSTD::move(__out_it), __specs, + __specs.__precision_); + } + return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __str.size()); + +# endif +} + +} // namespace __formatter + +#endif //_LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FORMAT_FORMATTER_OUTPUT_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h index aa4fc3398d..3cd4c9bba9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_pointer.h @@ -10,16 +10,14 @@ #ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H #define _LIBCPP___FORMAT_FORMATTER_POINTER_H -#include <__algorithm/copy.h> -#include <__assert> #include <__availability> #include <__config> -#include <__format/format_error.h> #include <__format/format_fwd.h> +#include <__format/format_parse_context.h> #include <__format/formatter.h> #include <__format/formatter_integral.h> +#include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> -#include <__iterator/access.h> #include <cstddef> #include <cstdint> @@ -31,35 +29,27 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -namespace __format_spec { - template <__formatter::__char_type _CharT> -class _LIBCPP_TEMPLATE_VIS __formatter_pointer : public __parser_pointer<_CharT> { +struct _LIBCPP_TEMPLATE_VIS __formatter_pointer { public: - _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) -> decltype(__ctx.out()) { - _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default, - "The call to parse should have updated the alignment"); - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - // This code looks a lot like the code to format a hexadecimal integral, - // but that code isn't public. Making that code public requires some - // refactoring. - // TODO FMT Remove code duplication. - char __buffer[2 + 2 * sizeof(uintptr_t)]; - __buffer[0] = '0'; - __buffer[1] = 'x'; - char* __last = __to_buffer(__buffer + 2, _VSTD::end(__buffer), reinterpret_cast<uintptr_t>(__ptr), 16); + constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; } - unsigned __size = __last - __buffer; - if (__size >= this->__width) - return _VSTD::copy(__buffer, __last, __ctx.out()); + _LIBCPP_HIDE_FROM_ABI constexpr auto + parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) { + auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer); + __format_spec::__process_display_type_pointer(__parser_.__type_); + return __result; + } - return __formatter::__write(__ctx.out(), __buffer, __last, __size, this->__width, this->__fill, this->__alignment); + _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) const -> decltype(__ctx.out()) { + __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx); + __specs.__std_.__alternate_form_ = true; + __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case; + return __formatter::__format_integer(reinterpret_cast<uintptr_t>(__ptr), __ctx, __specs); } -}; -} // namespace __format_spec + __format_spec::__parser<_CharT> __parser_; +}; // [format.formatter.spec]/2.4 // For each charT, the pointer type specializations template<> @@ -68,13 +58,13 @@ public: // - template<> struct formatter<const void*, charT>; template <__formatter::__char_type _CharT> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT> - : public __format_spec::__formatter_pointer<_CharT> {}; + : public __formatter_pointer<_CharT> {}; template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> - : public __format_spec::__formatter_pointer<_CharT> {}; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> { +}; template <__formatter::__char_type _CharT> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT> - : public __format_spec::__formatter_pointer<_CharT> {}; + : public __formatter_pointer<_CharT> {}; #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h index c687e3fd48..139c05e58c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/formatter_string.h @@ -10,13 +10,15 @@ #ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H #define _LIBCPP___FORMAT_FORMATTER_STRING_H -#include <__assert> +#include <__availability> #include <__config> -#include <__format/format_error.h> #include <__format/format_fwd.h> -#include <__format/format_string.h> +#include <__format/format_parse_context.h> #include <__format/formatter.h> +#include <__format/formatter_output.h> #include <__format/parser_std_format_spec.h> +#include <__utility/move.h> +#include <string> #include <string_view> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -27,43 +29,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 -namespace __format_spec { - template <__formatter::__char_type _CharT> -class _LIBCPP_TEMPLATE_VIS __formatter_string : public __parser_string<_CharT> { +struct _LIBCPP_TEMPLATE_VIS __formatter_string { public: - _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, - auto& __ctx) -> decltype(__ctx.out()) { - - _LIBCPP_ASSERT(this->__alignment != _Flags::_Alignment::__default, - "The parser should not use these defaults"); - - if (this->__width_needs_substitution()) - this->__substitute_width_arg_id(__ctx.arg(this->__width)); - - if (this->__precision_needs_substitution()) - this->__substitute_precision_arg_id(__ctx.arg(this->__precision)); - - return __formatter::__write_unicode( - __ctx.out(), __str, this->__width, - this->__has_precision_field() ? this->__precision : -1, this->__fill, - this->__alignment); + _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx) + -> decltype(__parse_ctx.begin()) { + auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_string); + __format_spec::__process_display_type_string(__parser_.__type_); + return __result; } -}; -} //namespace __format_spec + _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) { + return __formatter::__write_unicode(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx)); + } -// [format.formatter.spec]/2.2 For each charT, the string type specializations + __format_spec::__parser<_CharT> __parser_; +}; // Formatter const char*. template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<const _CharT*, _CharT> - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT> + : public __formatter_string<_CharT> { + using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) - -> decltype(__ctx.out()) { + _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) { _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have " "prevented an invalid pointer."); @@ -78,8 +67,9 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT // now these optimizations aren't implemented. Instead the base class // handles these options. // TODO FMT Implement these improvements. - if (this->__has_width_field() || this->__has_precision_field()) - return _Base::format(__str, __ctx); + __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx); + if (__specs.__has_width() || __specs.__has_precision()) + return __formatter::__write_unicode(basic_string_view<_CharT>{__str}, __ctx.out(), __specs); // No formatting required, copy the string to the output. auto __out_it = __ctx.out(); @@ -91,12 +81,11 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT // Formatter char*. template <__formatter::__char_type _CharT> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> { +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT> + : public formatter<const _CharT*, _CharT> { using _Base = formatter<const _CharT*, _CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) - -> decltype(__ctx.out()) { + _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) { return _Base::format(__str, __ctx); } }; @@ -104,39 +93,34 @@ 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>; + : public __formatter_string<_CharT> { + using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) -> decltype(__ctx.out()) { + _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) const -> 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 - formatter<const _CharT[_Size], _CharT> - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT> + : public __formatter_string<_CharT> { + using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) - -> decltype(__ctx.out()) { + _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) { return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx); } }; // Formatter std::string. template <__formatter::__char_type _CharT, class _Traits, class _Allocator> -struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT - formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> + : public __formatter_string<_CharT> { + using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto - format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) + _LIBCPP_HIDE_FROM_ABI auto format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) const -> decltype(__ctx.out()) { - // drop _Traits and _Allocator + // Drop _Traits and _Allocator to have one std::basic_string formatter. return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); } }; @@ -144,13 +128,12 @@ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT // Formatter std::string_view. template <__formatter::__char_type _CharT, class _Traits> struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT> - : public __format_spec::__formatter_string<_CharT> { - using _Base = __format_spec::__formatter_string<_CharT>; + : public __formatter_string<_CharT> { + using _Base = __formatter_string<_CharT>; - _LIBCPP_HIDE_FROM_ABI auto - format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) + _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) const -> decltype(__ctx.out()) { - // drop _Traits + // Drop _Traits to have one std::basic_string_view formatter. return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx); } }; diff --git a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h index 7a0efe10ff..739bdf457e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h +++ b/contrib/libs/cxxsupp/libcxx/include/__format/parser_std_format_spec.h @@ -10,12 +10,20 @@ #ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H #define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H +/// \file Contains the std-format-spec parser. +/// +/// Most of the code can be reused in the chrono-format-spec. +/// This header has some support for the chrono-format-spec since it doesn't +/// affect the std-format-spec. + #include <__algorithm/find_if.h> #include <__algorithm/min.h> #include <__assert> #include <__config> +#include <__debug> #include <__format/format_arg.h> #include <__format/format_error.h> +#include <__format/format_parse_context.h> #include <__format/format_string.h> #include <__variant/monostate.h> #include <bit> @@ -1377,6 +1385,581 @@ __get_string_alignment(const _CharT* __first, const _CharT* __last, } #endif // _LIBCPP_HAS_NO_UNICODE +/// These fields are a filter for which elements to parse. +/// +/// They default to false so when a new field is added it needs to be opted in +/// explicitly. +struct __fields { + uint8_t __sign_ : 1 {false}; + uint8_t __alternate_form_ : 1 {false}; + uint8_t __zero_padding_ : 1 {false}; + uint8_t __precision_ : 1 {false}; + uint8_t __locale_specific_form_ : 1 {false}; + uint8_t __type_ : 1 {false}; +}; + +// By not placing this constant in the formatter class it's not duplicated for +// char and wchar_t. +inline constexpr __fields __fields_integral{ + .__sign_ = true, + .__alternate_form_ = true, + .__zero_padding_ = true, + .__locale_specific_form_ = true, + .__type_ = true}; +inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true}; +inline constexpr __fields __fields_pointer{.__type_ = true}; + +enum class _LIBCPP_ENUM_VIS __alignment : uint8_t { + /// No alignment is set in the format string. + __default, + __left, + __center, + __right, + __zero_padding +}; + +enum class _LIBCPP_ENUM_VIS __sign : uint8_t { + /// No sign is set in the format string. + /// + /// The sign isn't allowed for certain format-types. By using this value + /// it's possible to detect whether or not the user explicitly set the sign + /// flag. For formatting purposes it behaves the same as \ref __minus. + __default, + __minus, + __plus, + __space +}; + +enum class _LIBCPP_ENUM_VIS __type : uint8_t { + __default, + __string, + __binary_lower_case, + __binary_upper_case, + __octal, + __decimal, + __hexadecimal_lower_case, + __hexadecimal_upper_case, + __pointer, + __char, + __hexfloat_lower_case, + __hexfloat_upper_case, + __scientific_lower_case, + __scientific_upper_case, + __fixed_lower_case, + __fixed_upper_case, + __general_lower_case, + __general_upper_case +}; + +struct __std { + __alignment __alignment_ : 3; + __sign __sign_ : 2; + bool __alternate_form_ : 1; + bool __locale_specific_form_ : 1; + __type __type_; +}; + +struct __chrono { + __alignment __alignment_ : 3; + bool __weekday_name_ : 1; + bool __month_name_ : 1; +}; + +/// Contains the parsed formatting specifications. +/// +/// This contains information for both the std-format-spec and the +/// chrono-format-spec. This results in some unused members for both +/// specifications. However these unused members don't increase the size +/// of the structure. +/// +/// This struct doesn't cross ABI boundaries so its layout doesn't need to be +/// kept stable. +template <class _CharT> +struct __parsed_specifications { + union { + // The field __alignment_ is the first element in __std_ and __chrono_. + // This allows the code to always inspect this value regards which member + // of the union is the active member [class.union.general]/2. + // + // This is needed since the generic output routines handle the alignment of + // the output. + __alignment __alignment_ : 3; + __std __std_; + __chrono __chrono_; + }; + + /// The requested width. + /// + /// When the format-spec used an arg-id for this field it has already been + /// replaced with the value of that arg-id. + int32_t __width_; + + /// The requested precision. + /// + /// When the format-spec used an arg-id for this field it has already been + /// replaced with the value of that arg-id. + int32_t __precision_; + + _CharT __fill_; + + _LIBCPP_HIDE_FROM_ABI constexpr bool __has_width() const { return __width_ > 0; } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __has_precision() const { return __precision_ >= 0; } +}; + +// Validate the struct is small and cheap to copy since the struct is passed by +// value in formatting functions. +static_assert(sizeof(__parsed_specifications<char>) == 16); +static_assert(is_trivially_copyable_v<__parsed_specifications<char>>); +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +static_assert(sizeof(__parsed_specifications<wchar_t>) == 16); +static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>); +# endif + +/// The parser for the std-format-spec. +/// +/// Note this class is a member of std::formatter specializations. It's +/// expected developers will create their own formatter specializations that +/// inherit from the std::formatter specializations. This means this class +/// must be ABI stable. To aid the stability the unused bits in the class are +/// set to zero. That way they can be repurposed if a future revision of the +/// Standards adds new fields to std-format-spec. +template <class _CharT> +class _LIBCPP_TEMPLATE_VIS __parser { +public: + _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields) + -> decltype(__parse_ctx.begin()) { + + const _CharT* __begin = __parse_ctx.begin(); + const _CharT* __end = __parse_ctx.end(); + if (__begin == __end) + return __begin; + + if (__parse_fill_align(__begin, __end) && __begin == __end) + return __begin; + + if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end) + return __begin; + + if (__fields.__alternate_form_ && __parse_alternate_form(__begin) && __begin == __end) + return __begin; + + if (__fields.__zero_padding_ && __parse_zero_padding(__begin) && __begin == __end) + return __begin; + + if (__parse_width(__begin, __end, __parse_ctx) && __begin == __end) + return __begin; + + if (__fields.__precision_ && __parse_precision(__begin, __end, __parse_ctx) && __begin == __end) + return __begin; + + if (__fields.__locale_specific_form_ && __parse_locale_specific_form(__begin) && __begin == __end) + return __begin; + + if (__fields.__type_) { + __parse_type(__begin); + + // When __type_ is false the calling parser is expected to do additional + // parsing. In that case that parser should do the end of format string + // validation. + if (__begin != __end && *__begin != _CharT('}')) + __throw_format_error("The format-spec should consume the input or end with a '}'"); + } + + return __begin; + } + + /// \returns the `__parsed_specifications` with the resolved dynamic sizes.. + _LIBCPP_HIDE_FROM_ABI + __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const { + return __parsed_specifications<_CharT>{ + .__std_ = + __std{.__alignment_ = __alignment_, + .__sign_ = __sign_, + .__alternate_form_ = __alternate_form_, + .__locale_specific_form_ = __locale_specific_form_, + .__type_ = __type_}, + .__width_{__get_width(__ctx)}, + .__precision_{__get_precision(__ctx)}, + .__fill_{__fill_}}; + } + + __alignment __alignment_ : 3 {__alignment::__default}; + __sign __sign_ : 2 {__sign::__default}; + bool __alternate_form_ : 1 {false}; + bool __locale_specific_form_ : 1 {false}; + bool __reserved_0_ : 1 {false}; + __type __type_{__type::__default}; + + // These two flags are used for formatting chrono. Since the struct has + // padding space left it's added to this structure. + bool __weekday_name_ : 1 {false}; + bool __month_name_ : 1 {false}; + + uint8_t __reserved_1_ : 6 {0}; + uint8_t __reserved_2_ : 6 {0}; + // These two flags are only used internally and not part of the + // __parsed_specifications. Therefore put them at the end. + bool __width_as_arg_ : 1 {false}; + bool __precision_as_arg_ : 1 {false}; + + /// The requested width, either the value or the arg-id. + int32_t __width_{0}; + + /// The requested precision, either the value or the arg-id. + int32_t __precision_{-1}; + + // LWG 3576 will probably change this to always accept a Unicode code point + // To avoid changing the size with that change align the field so when it + // becomes 32-bit its alignment will remain the same. That also means the + // size will remain the same. (D2572 addresses the solution for LWG 3576.) + _CharT __fill_{_CharT(' ')}; + +private: + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alignment(_CharT __c) { + switch (__c) { + case _CharT('<'): + __alignment_ = __alignment::__left; + return true; + + case _CharT('^'): + __alignment_ = __alignment::__center; + return true; + + case _CharT('>'): + __alignment_ = __alignment::__right; + return true; + } + return false; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(const _CharT*& __begin, const _CharT* __end) { + _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause " + "undefined behavior by evaluating data not in the input"); + if (__begin + 1 != __end) { + if (__parse_alignment(*(__begin + 1))) { + if (*__begin == _CharT('{') || *__begin == _CharT('}')) + __throw_format_error("The format-spec fill field contains an invalid character"); + + __fill_ = *__begin; + __begin += 2; + return true; + } + } + + if (!__parse_alignment(*__begin)) + return false; + + ++__begin; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(const _CharT*& __begin) { + switch (*__begin) { + case _CharT('-'): + __sign_ = __sign::__minus; + break; + case _CharT('+'): + __sign_ = __sign::__plus; + break; + case _CharT(' '): + __sign_ = __sign::__space; + break; + default: + return false; + } + ++__begin; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alternate_form(const _CharT*& __begin) { + if (*__begin != _CharT('#')) + return false; + + __alternate_form_ = true; + ++__begin; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_zero_padding(const _CharT*& __begin) { + if (*__begin != _CharT('0')) + return false; + + if (__alignment_ == __alignment::__default) + __alignment_ = __alignment::__zero_padding; + ++__begin; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) { + if (*__begin == _CharT('0')) + __throw_format_error("A format-spec width field shouldn't have a leading zero"); + + if (*__begin == _CharT('{')) { + __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); + __width_as_arg_ = true; + __width_ = __r.__value; + __begin = __r.__ptr; + return true; + } + + if (*__begin < _CharT('0') || *__begin > _CharT('9')) + return false; + + __format::__parse_number_result __r = __format::__parse_number(__begin, __end); + __width_ = __r.__value; + _LIBCPP_ASSERT(__width_ != 0, "A zero value isn't allowed and should be impossible, " + "due to validations in this function"); + __begin = __r.__ptr; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(const _CharT*& __begin, const _CharT* __end, + auto& __parse_ctx) { + if (*__begin != _CharT('.')) + return false; + + ++__begin; + if (__begin == __end) + __throw_format_error("End of input while parsing format-spec precision"); + + if (*__begin == _CharT('{')) { + __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx); + __precision_as_arg_ = true; + __precision_ = __arg_id.__value; + __begin = __arg_id.__ptr; + return true; + } + + if (*__begin < _CharT('0') || *__begin > _CharT('9')) + __throw_format_error("The format-spec precision field doesn't contain a value or arg-id"); + + __format::__parse_number_result __r = __format::__parse_number(__begin, __end); + __precision_ = __r.__value; + __precision_as_arg_ = false; + __begin = __r.__ptr; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_locale_specific_form(const _CharT*& __begin) { + if (*__begin != _CharT('L')) + return false; + + __locale_specific_form_ = true; + ++__begin; + return true; + } + + _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin) { + // Determines the type. It does not validate whether the selected type is + // valid. Most formatters have optional fields that are only allowed for + // certain types. These parsers need to do validation after the type has + // been parsed. So its easier to implement the validation for all types in + // the specific parse function. + switch (*__begin) { + case 'A': + __type_ = __type::__hexfloat_upper_case; + break; + case 'B': + __type_ = __type::__binary_upper_case; + break; + case 'E': + __type_ = __type::__scientific_upper_case; + break; + case 'F': + __type_ = __type::__fixed_upper_case; + break; + case 'G': + __type_ = __type::__general_upper_case; + break; + case 'X': + __type_ = __type::__hexadecimal_upper_case; + break; + case 'a': + __type_ = __type::__hexfloat_lower_case; + break; + case 'b': + __type_ = __type::__binary_lower_case; + break; + case 'c': + __type_ = __type::__char; + break; + case 'd': + __type_ = __type::__decimal; + break; + case 'e': + __type_ = __type::__scientific_lower_case; + break; + case 'f': + __type_ = __type::__fixed_lower_case; + break; + case 'g': + __type_ = __type::__general_lower_case; + break; + case 'o': + __type_ = __type::__octal; + break; + case 'p': + __type_ = __type::__pointer; + break; + case 's': + __type_ = __type::__string; + break; + case 'x': + __type_ = __type::__hexadecimal_lower_case; + break; + default: + return; + } + ++__begin; + } + + _LIBCPP_HIDE_FROM_ABI + int32_t __get_width(auto& __ctx) const { + if (!__width_as_arg_) + return __width_; + + int32_t __result = __format_spec::__substitute_arg_id(__ctx.arg(__width_)); + if (__result == 0) + __throw_format_error("A format-spec width field replacement should have a positive value"); + return __result; + } + + _LIBCPP_HIDE_FROM_ABI + int32_t __get_precision(auto& __ctx) const { + if (!__precision_as_arg_) + return __precision_; + + return __format_spec::__substitute_arg_id(__ctx.arg(__precision_)); + } +}; + +// Validates whether the reserved bitfields don't change the size. +static_assert(sizeof(__parser<char>) == 16); +# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS +static_assert(sizeof(__parser<wchar_t>) == 16); +# endif + +_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec::__type __type) { + switch (__type) { + case __format_spec::__type::__default: + case __format_spec::__type::__string: + break; + + default: + std::__throw_format_error("The format-spec type has a type not supported for a string argument"); + } +} + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_bool_string(__parser<_CharT>& __parser) { + if (__parser.__sign_ != __sign::__default) + std::__throw_format_error("A sign field isn't allowed in this format-spec"); + + if (__parser.__alternate_form_) + std::__throw_format_error("An alternate form field isn't allowed in this format-spec"); + + if (__parser.__alignment_ == __alignment::__zero_padding) + std::__throw_format_error("A zero-padding field isn't allowed in this format-spec"); + + if (__parser.__alignment_ == __alignment::__default) + __parser.__alignment_ = __alignment::__left; +} + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_char(__parser<_CharT>& __parser) { + __format_spec::__process_display_type_bool_string(__parser); +} + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_integer(__parser<_CharT>& __parser) { + if (__parser.__alignment_ == __alignment::__default) + __parser.__alignment_ = __alignment::__right; +} + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_bool(__parser<_CharT>& __parser) { + switch (__parser.__type_) { + case __format_spec::__type::__default: + __parser.__type_ = __format_spec::__type::__string; + [[fallthrough]]; + case __format_spec::__type::__string: + __format_spec::__process_display_type_bool_string(__parser); + break; + + case __format_spec::__type::__binary_lower_case: + case __format_spec::__type::__binary_upper_case: + case __format_spec::__type::__octal: + case __format_spec::__type::__decimal: + case __format_spec::__type::__hexadecimal_lower_case: + case __format_spec::__type::__hexadecimal_upper_case: + __process_display_type_integer(__parser); + break; + + default: + std::__throw_format_error("The format-spec type has a type not supported for a bool argument"); + } +} + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __parser) { + switch (__parser.__type_) { + case __format_spec::__type::__default: + __parser.__type_ = __format_spec::__type::__char; + [[fallthrough]]; + case __format_spec::__type::__char: + __format_spec::__process_display_type_char(__parser); + break; + + case __format_spec::__type::__binary_lower_case: + case __format_spec::__type::__binary_upper_case: + case __format_spec::__type::__octal: + case __format_spec::__type::__decimal: + case __format_spec::__type::__hexadecimal_lower_case: + case __format_spec::__type::__hexadecimal_upper_case: + __format_spec::__process_display_type_integer(__parser); + break; + + default: + std::__throw_format_error("The format-spec type has a type not supported for a char argument"); + } +} + +template <class _CharT> +_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_integer(__parser<_CharT>& __parser) { + switch (__parser.__type_) { + case __format_spec::__type::__default: + __parser.__type_ = __format_spec::__type::__decimal; + [[fallthrough]]; + case __format_spec::__type::__binary_lower_case: + case __format_spec::__type::__binary_upper_case: + case __format_spec::__type::__octal: + case __format_spec::__type::__decimal: + case __format_spec::__type::__hexadecimal_lower_case: + case __format_spec::__type::__hexadecimal_upper_case: + __format_spec::__process_display_type_integer(__parser); + break; + + case __format_spec::__type::__char: + __format_spec::__process_display_type_char(__parser); + break; + + default: + std::__throw_format_error("The format-spec type has a type not supported for an integer argument"); + } +} + +_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_pointer(__format_spec::__type __type) { + switch (__type) { + case __format_spec::__type::__default: + case __format_spec::__type::__pointer: + break; + + default: + std::__throw_format_error("The format-spec type has a type not supported for a pointer argument"); + } +} + } // namespace __format_spec #endif //_LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/binary_function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/binary_function.h index 51135ef51e..fdedb8b177 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/binary_function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/binary_function.h @@ -18,14 +18,37 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) + template <class _Arg1, class _Arg2, class _Result> -struct _LIBCPP_TEMPLATE_VIS binary_function +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function { typedef _Arg1 first_argument_type; typedef _Arg2 second_argument_type; typedef _Result result_type; }; +#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) + +template <class _Arg1, class _Arg2, class _Result> struct __binary_function_keep_layout_base { +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1; + using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2; + using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result; +#endif +}; + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") +template <class _Arg1, class _Arg2, class _Result> +using __binary_function = binary_function<_Arg1, _Arg2, _Result>; +_LIBCPP_DIAGNOSTIC_POP +#else +template <class _Arg1, class _Arg2, class _Result> +using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/binary_negate.h b/contrib/libs/cxxsupp/libcxx/include/__functional/binary_negate.h index 17c5c20668..c4977f4ebe 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/binary_negate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/binary_negate.h @@ -23,9 +23,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Predicate> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate - : public binary_function<typename _Predicate::first_argument_type, - typename _Predicate::second_argument_type, - bool> + : public __binary_function<typename _Predicate::first_argument_type, + typename _Predicate::second_argument_type, + bool> { _Predicate __pred_; public: diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h b/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h index 7ac44a2d63..85f1a3bf75 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/bind.h @@ -264,10 +264,7 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, } template<class _Fp, class ..._BoundArgs> -class __bind -#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public __weak_result_type<typename decay<_Fp>::type> -#endif +class __bind : public __weak_result_type<typename decay<_Fp>::type> { protected: typedef typename decay<_Fp>::type _Fd; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/binder1st.h b/contrib/libs/cxxsupp/libcxx/include/__functional/binder1st.h index 13b2459dff..dea22c70e1 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/binder1st.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/binder1st.h @@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class __Operation> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st - : public unary_function<typename __Operation::second_argument_type, - typename __Operation::result_type> + : public __unary_function<typename __Operation::second_argument_type, typename __Operation::result_type> { protected: __Operation op; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/binder2nd.h b/contrib/libs/cxxsupp/libcxx/include/__functional/binder2nd.h index ff0f5f0816..c98a146b6a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/binder2nd.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/binder2nd.h @@ -23,8 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class __Operation> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd - : public unary_function<typename __Operation::first_argument_type, - typename __Operation::result_type> + : public __unary_function<typename __Operation::first_argument_type, typename __Operation::result_type> { protected: __Operation op; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/function.h index 8951299d39..59a0f72245 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/function.h @@ -85,7 +85,7 @@ struct __maybe_derive_from_unary_function template<class _Rp, class _A1> struct __maybe_derive_from_unary_function<_Rp(_A1)> - : public unary_function<_A1, _Rp> + : public __unary_function<_A1, _Rp> { }; @@ -96,7 +96,7 @@ struct __maybe_derive_from_binary_function template<class _Rp, class _A1, class _A2> struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> + : public __binary_function<_A1, _A2, _Rp> { }; @@ -956,10 +956,8 @@ public: template<class _Rp, class ..._ArgTypes> class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> -#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> -#endif { #ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION typedef __function::__value_func<_Rp(_ArgTypes...)> __func; @@ -1242,7 +1240,7 @@ void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {return __x.swap(__y);} -#else // _LIBCPP_CXX03_LANG +#elif defined(_LIBCPP_ENABLE_CXX03_FUNCTION) namespace __function { @@ -2808,7 +2806,7 @@ void swap(function<_Fp>& __x, function<_Fp>& __y) {return __x.swap(__y);} -#endif +#endif // _LIBCPP_CXX03_LANG _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h b/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h index f1d5e27343..8a11931288 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/hash.h @@ -265,18 +265,10 @@ __murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)> struct __scalar_hash; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct __scalar_hash<_Tp, 0> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp, size_t> -#endif + : public __unary_function<_Tp, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { @@ -291,18 +283,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct __scalar_hash<_Tp, 1> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp, size_t> -#endif + : public __unary_function<_Tp, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { @@ -316,18 +300,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct __scalar_hash<_Tp, 2> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp, size_t> -#endif + : public __unary_function<_Tp, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { @@ -345,18 +321,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct __scalar_hash<_Tp, 3> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp, size_t> -#endif + : public __unary_function<_Tp, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { @@ -375,18 +343,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct __scalar_hash<_Tp, 4> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp, size_t> -#endif + : public __unary_function<_Tp, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { @@ -418,18 +378,10 @@ inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { return _HashT()(__p); } -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template<class _Tp> struct _LIBCPP_TEMPLATE_VIS hash<_Tp*> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp*, size_t> -#endif + : public __unary_function<_Tp*, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp* __v) const _NOEXCEPT { @@ -443,230 +395,118 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<bool> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<bool, size_t> -#endif + : public __unary_function<bool, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<char> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<char, size_t> -#endif + : public __unary_function<char, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<signed char, size_t> -#endif + : public __unary_function<signed char, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<unsigned char, size_t> -#endif + : public __unary_function<unsigned char, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; #ifndef _LIBCPP_HAS_NO_CHAR8_T -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<char8_t> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<char8_t, size_t> -#endif + : public __unary_function<char8_t, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; #endif // !_LIBCPP_HAS_NO_CHAR8_T -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<char16_t> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<char16_t, size_t> -#endif + : public __unary_function<char16_t, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<char32_t> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<char32_t, size_t> -#endif + : public __unary_function<char32_t, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<wchar_t, size_t> -#endif + : public __unary_function<wchar_t, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; #endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<short> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<short, size_t> -#endif + : public __unary_function<short, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<unsigned short, size_t> -#endif + : public __unary_function<unsigned short, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<int> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<int, size_t> -#endif + : public __unary_function<int, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<unsigned int, size_t> -#endif + : public __unary_function<unsigned int, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<long> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<long, size_t> -#endif + : public __unary_function<long, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<unsigned long, size_t> -#endif + : public __unary_function<unsigned long, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);} }; @@ -777,18 +617,10 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double> } }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp, bool = is_enum<_Tp>::value> struct _LIBCPP_TEMPLATE_VIS __enum_hash -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<_Tp, size_t> -#endif + : public __unary_function<_Tp, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(_Tp __v) const _NOEXCEPT { @@ -810,18 +642,10 @@ struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> #if _LIBCPP_STD_VER > 14 -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <> struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public unary_function<nullptr_t, size_t> -#endif + : public __unary_function<nullptr_t, size_t> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type; -#endif _LIBCPP_INLINE_VISIBILITY size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h b/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h index c0018038db..a5818b3f01 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fn.h @@ -24,10 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -class __mem_fn -#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public __weak_result_type<_Tp> -#endif +class __mem_fn : public __weak_result_type<_Tp> { public: // types @@ -42,6 +39,7 @@ public: // invoke template <class... _ArgTypes> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename __invoke_return<type, _ArgTypes...>::type operator() (_ArgTypes&&... __args) const { return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...); diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fun_ref.h b/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fun_ref.h index 81f48e66e7..65aab0696c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fun_ref.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/mem_fun_ref.h @@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template<class _Sp, class _Tp> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t - : public unary_function<_Tp*, _Sp> + : public __unary_function<_Tp*, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -36,7 +36,7 @@ public: template<class _Sp, class _Tp, class _Ap> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t - : public binary_function<_Tp*, _Ap, _Sp> + : public __binary_function<_Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -60,7 +60,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap)) template<class _Sp, class _Tp> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t - : public unary_function<_Tp, _Sp> + : public __unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -72,7 +72,7 @@ public: template<class _Sp, class _Tp, class _Ap> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t - : public binary_function<_Tp, _Ap, _Sp> + : public __binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -96,7 +96,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) template <class _Sp, class _Tp> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t - : public unary_function<const _Tp*, _Sp> + : public __unary_function<const _Tp*, _Sp> { _Sp (_Tp::*__p_)() const; public: @@ -108,7 +108,7 @@ public: template <class _Sp, class _Tp, class _Ap> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t - : public binary_function<const _Tp*, _Ap, _Sp> + : public __binary_function<const _Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; public: @@ -132,7 +132,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) template <class _Sp, class _Tp> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t - : public unary_function<_Tp, _Sp> + : public __unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)() const; public: @@ -144,7 +144,7 @@ public: template <class _Sp, class _Tp, class _Ap> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t - : public binary_function<_Tp, _Ap, _Sp> + : public __binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; public: diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h b/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h index 9df6d773fe..1c73c999db 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/operations.h @@ -23,24 +23,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD // Arithmetic operations -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS plus -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} @@ -60,24 +51,15 @@ struct _LIBCPP_TEMPLATE_VIS plus<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS minus -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} @@ -97,24 +79,15 @@ struct _LIBCPP_TEMPLATE_VIS minus<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS multiplies -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} @@ -134,24 +107,15 @@ struct _LIBCPP_TEMPLATE_VIS multiplies<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS divides -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} @@ -171,24 +135,15 @@ struct _LIBCPP_TEMPLATE_VIS divides<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS modulus -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} @@ -208,23 +163,15 @@ struct _LIBCPP_TEMPLATE_VIS modulus<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS negate -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : unary_function<_Tp, _Tp> -#endif + : __unary_function<_Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return -__x;} @@ -246,24 +193,15 @@ struct _LIBCPP_TEMPLATE_VIS negate<void> // Bitwise operations -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS bit_and -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} @@ -284,18 +222,10 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> #endif #if _LIBCPP_STD_VER > 11 -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp = void> struct _LIBCPP_TEMPLATE_VIS bit_not -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : unary_function<_Tp, _Tp> -#endif + : __unary_function<_Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const {return ~__x;} @@ -314,24 +244,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_not<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS bit_or -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} @@ -351,24 +272,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_or<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS bit_xor -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, _Tp> -#endif + : __binary_function<_Tp, _Tp, _Tp> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef _Tp __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} @@ -390,24 +302,15 @@ struct _LIBCPP_TEMPLATE_VIS bit_xor<void> // Comparison operations -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS equal_to -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} @@ -427,24 +330,15 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS not_equal_to -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} @@ -464,24 +358,15 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS less -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x < __y;} @@ -501,24 +386,15 @@ struct _LIBCPP_TEMPLATE_VIS less<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS less_equal -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} @@ -538,24 +414,15 @@ struct _LIBCPP_TEMPLATE_VIS less_equal<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS greater_equal -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} @@ -575,24 +442,15 @@ struct _LIBCPP_TEMPLATE_VIS greater_equal<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS greater -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} @@ -614,24 +472,15 @@ struct _LIBCPP_TEMPLATE_VIS greater<void> // Logical operations -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS logical_and -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} @@ -651,23 +500,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_and<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS logical_not -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : unary_function<_Tp, bool> -#endif + : __unary_function<_Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const {return !__x;} @@ -687,24 +528,15 @@ struct _LIBCPP_TEMPLATE_VIS logical_not<void> }; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH #if _LIBCPP_STD_VER > 11 template <class _Tp = void> #else template <class _Tp> #endif struct _LIBCPP_TEMPLATE_VIS logical_or -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<_Tp, _Tp, bool> -#endif + : __binary_function<_Tp, _Tp, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP typedef bool __result_type; // used by valarray -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; -#endif _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_binary_function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_binary_function.h index 187e3098c4..b2676c58f8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_binary_function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_binary_function.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Arg1, class _Arg2, class _Result> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function - : public binary_function<_Arg1, _Arg2, _Result> + : public __binary_function<_Arg1, _Arg2, _Result> { _Result (*__f_)(_Arg1, _Arg2); public: diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_unary_function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_unary_function.h index a0f98c1a55..77d07adf20 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_unary_function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/pointer_to_unary_function.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Arg, class _Result> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function - : public unary_function<_Arg, _Result> + : public __unary_function<_Arg, _Result> { _Result (*__f_)(_Arg); public: diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h b/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h index 497276a080..8245e3a047 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/reference_wrapper.h @@ -23,10 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -class _LIBCPP_TEMPLATE_VIS reference_wrapper -#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : public __weak_result_type<_Tp> -#endif +class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> { public: // types diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/unary_function.h b/contrib/libs/cxxsupp/libcxx/include/__functional/unary_function.h index af2a0b967c..f07cac175a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/unary_function.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/unary_function.h @@ -17,13 +17,35 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) + template <class _Arg, class _Result> -struct _LIBCPP_TEMPLATE_VIS unary_function +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function { typedef _Arg argument_type; typedef _Result result_type; }; +#endif // _LIBCPP_STD_VER <= 14 + +template <class _Arg, class _Result> struct __unary_function_keep_layout_base { +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg; + using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result; +#endif +}; + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION) +_LIBCPP_DIAGNOSTIC_PUSH +_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") +template <class _Arg, class _Result> +using __unary_function = unary_function<_Arg, _Result>; +_LIBCPP_DIAGNOSTIC_POP +#else +template <class _Arg, class _Result> +using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/unary_negate.h b/contrib/libs/cxxsupp/libcxx/include/__functional/unary_negate.h index 7ff1f6e879..7f081903fe 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/unary_negate.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/unary_negate.h @@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Predicate> class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate - : public unary_function<typename _Predicate::argument_type, bool> + : public __unary_function<typename _Predicate::argument_type, bool> { _Predicate __pred_; public: diff --git a/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h b/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h index 81e4bedd2d..96d8cf7146 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h +++ b/contrib/libs/cxxsupp/libcxx/include/__functional/weak_result_type.h @@ -40,8 +40,9 @@ private: struct __two {char __lx; char __lxx;}; static __two __test(...); template <class _Ap, class _Rp> - static unary_function<_Ap, _Rp> - __test(const volatile unary_function<_Ap, _Rp>*); + static __unary_function<_Ap, _Rp> + __test(const volatile __unary_function<_Ap, _Rp>*); + public: static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value; typedef decltype(__test((_Tp*)0)) type; @@ -54,8 +55,9 @@ private: struct __two {char __lx; char __lxx;}; static __two __test(...); template <class _A1, class _A2, class _Rp> - static binary_function<_A1, _A2, _Rp> - __test(const volatile binary_function<_A1, _A2, _Rp>*); + static __binary_function<_A1, _A2, _Rp> + __test(const volatile __binary_function<_A1, _A2, _Rp>*); + public: static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value; typedef decltype(__test((_Tp*)0)) type; @@ -88,7 +90,9 @@ struct __weak_result_type_imp // bool is true : public __maybe_derive_from_unary_function<_Tp>, public __maybe_derive_from_binary_function<_Tp> { - typedef _LIBCPP_NODEBUG typename _Tp::result_type result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = typename _Tp::result_type; +#endif }; template <class _Tp> @@ -109,62 +113,68 @@ struct __weak_result_type template <class _Rp> struct __weak_result_type<_Rp ()> { - typedef _LIBCPP_NODEBUG _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp> struct __weak_result_type<_Rp (&)()> { - typedef _LIBCPP_NODEBUG _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp> struct __weak_result_type<_Rp (*)()> { - typedef _LIBCPP_NODEBUG _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; // 1 argument case template <class _Rp, class _A1> struct __weak_result_type<_Rp (_A1)> - : public unary_function<_A1, _Rp> + : public __unary_function<_A1, _Rp> { }; template <class _Rp, class _A1> struct __weak_result_type<_Rp (&)(_A1)> - : public unary_function<_A1, _Rp> + : public __unary_function<_A1, _Rp> { }; template <class _Rp, class _A1> struct __weak_result_type<_Rp (*)(_A1)> - : public unary_function<_A1, _Rp> + : public __unary_function<_A1, _Rp> { }; template <class _Rp, class _Cp> struct __weak_result_type<_Rp (_Cp::*)()> - : public unary_function<_Cp*, _Rp> + : public __unary_function<_Cp*, _Rp> { }; template <class _Rp, class _Cp> struct __weak_result_type<_Rp (_Cp::*)() const> - : public unary_function<const _Cp*, _Rp> + : public __unary_function<const _Cp*, _Rp> { }; template <class _Rp, class _Cp> struct __weak_result_type<_Rp (_Cp::*)() volatile> - : public unary_function<volatile _Cp*, _Rp> + : public __unary_function<volatile _Cp*, _Rp> { }; template <class _Rp, class _Cp> struct __weak_result_type<_Rp (_Cp::*)() const volatile> - : public unary_function<const volatile _Cp*, _Rp> + : public __unary_function<const volatile _Cp*, _Rp> { }; @@ -172,43 +182,43 @@ struct __weak_result_type<_Rp (_Cp::*)() const volatile> template <class _Rp, class _A1, class _A2> struct __weak_result_type<_Rp (_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> + : public __binary_function<_A1, _A2, _Rp> { }; template <class _Rp, class _A1, class _A2> struct __weak_result_type<_Rp (*)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> + : public __binary_function<_A1, _A2, _Rp> { }; template <class _Rp, class _A1, class _A2> struct __weak_result_type<_Rp (&)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> + : public __binary_function<_A1, _A2, _Rp> { }; template <class _Rp, class _Cp, class _A1> struct __weak_result_type<_Rp (_Cp::*)(_A1)> - : public binary_function<_Cp*, _A1, _Rp> + : public __binary_function<_Cp*, _A1, _Rp> { }; template <class _Rp, class _Cp, class _A1> struct __weak_result_type<_Rp (_Cp::*)(_A1) const> - : public binary_function<const _Cp*, _A1, _Rp> + : public __binary_function<const _Cp*, _A1, _Rp> { }; template <class _Rp, class _Cp, class _A1> struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> - : public binary_function<volatile _Cp*, _A1, _Rp> + : public __binary_function<volatile _Cp*, _A1, _Rp> { }; template <class _Rp, class _Cp, class _A1> struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> - : public binary_function<const volatile _Cp*, _A1, _Rp> + : public __binary_function<const volatile _Cp*, _A1, _Rp> { }; @@ -217,43 +227,57 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> template <class _Rp, class _A1, class _A2, class _A3, class ..._A4> struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp, class _A1, class _A2, class _A3, class ..._A4> struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp, class _A1, class _A2, class _A3, class ..._A4> struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Rp, class _Cp, class _A1, class _A2, class ..._A3> struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> { - typedef _Rp result_type; +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp; +#endif }; template <class _Tp, class ..._Args> diff --git a/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h b/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h new file mode 100644 index 0000000000..0e1944d974 --- /dev/null +++ b/contrib/libs/cxxsupp/libcxx/include/__iterator/bounded_iter.h @@ -0,0 +1,229 @@ +// -*- 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___ITERATOR_BOUNDED_ITER_H +#define _LIBCPP___ITERATOR_BOUNDED_ITER_H + +#include <__assert> +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__memory/pointer_traits.h> +#include <__utility/move.h> +#include <type_traits> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Iterator wrapper that carries the valid range it is allowed to access. +// +// This is a simple iterator wrapper for contiguous iterators that points +// within a [begin, end) range and carries these bounds with it. The iterator +// ensures that it is pointing within that [begin, end) range when it is +// dereferenced. +// +// Arithmetic operations are allowed and the bounds of the resulting iterator +// are not checked. Hence, it is possible to create an iterator pointing outside +// its range, but it is not possible to dereference it. +template <class _Iterator, class = __enable_if_t< __is_cpp17_contiguous_iterator<_Iterator>::value > > +struct ___bounded_iter { + using value_type = typename iterator_traits<_Iterator>::value_type; + using difference_type = typename iterator_traits<_Iterator>::difference_type; + using pointer = typename iterator_traits<_Iterator>::pointer; + using reference = typename iterator_traits<_Iterator>::reference; + using iterator_category = typename iterator_traits<_Iterator>::iterator_category; +#if _LIBCPP_STD_VER > 17 + using iterator_concept = contiguous_iterator_tag; +#endif + + // Create a singular iterator. + // + // Such an iterator does not point to any object and is conceptually out of bounds, so it is + // not dereferenceable. Observing operations like comparison and assignment are valid. + _LIBCPP_HIDE_FROM_ABI ___bounded_iter() = default; + + _LIBCPP_HIDE_FROM_ABI ___bounded_iter(___bounded_iter const&) = default; + _LIBCPP_HIDE_FROM_ABI ___bounded_iter(___bounded_iter&&) = default; + + template <class _OtherIterator, class = __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value > > + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR ___bounded_iter(___bounded_iter<_OtherIterator> const& __other) _NOEXCEPT + : __current_(__other.__current_), + __begin_(__other.__begin_), + __end_(__other.__end_) {} + + // Assign a bounded iterator to another one, rebinding the bounds of the iterator as well. + _LIBCPP_HIDE_FROM_ABI ___bounded_iter& operator=(___bounded_iter const&) = default; + _LIBCPP_HIDE_FROM_ABI ___bounded_iter& operator=(___bounded_iter&&) = default; + +private: + // Create an iterator wrapping the given iterator, and whose bounds are described + // by the provided [begin, end) range. + // + // This constructor does not check whether the resulting iterator is within its bounds. + // However, it does check that the provided [begin, end) range is a valid range (that + // is, begin <= end). + // + // Since it is non-standard for iterators to have this constructor, ___bounded_iter must + // be created via `std::__make_bounded_iter`. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 explicit ___bounded_iter( + _Iterator __current, _Iterator __begin, _Iterator __end) + : __current_(__current), __begin_(__begin), __end_(__end) { + _LIBCPP_ASSERT(__begin <= __end, "___bounded_iter(current, begin, end): [begin, end) is not a valid range"); + } + + template <class _It> + friend _LIBCPP_CONSTEXPR ___bounded_iter<_It> __make_bounded_iter(_It, _It, _It); + +public: + // Dereference and indexing operations. + // + // These operations check that the iterator is dereferenceable, that is within [begin, end). + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator*() const _NOEXCEPT { + _LIBCPP_ASSERT( + __in_bounds(__current_), "___bounded_iter::operator*: Attempt to dereference an out-of-range iterator"); + return *__current_; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 pointer operator->() const _NOEXCEPT { + _LIBCPP_ASSERT( + __in_bounds(__current_), "___bounded_iter::operator->: Attempt to dereference an out-of-range iterator"); + return std::__to_address(__current_); + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 reference operator[](difference_type __n) const _NOEXCEPT { + _LIBCPP_ASSERT( + __in_bounds(__current_ + __n), "___bounded_iter::operator[]: Attempt to index an iterator out-of-range"); + return __current_[__n]; + } + + // Arithmetic operations. + // + // These operations do not check that the resulting iterator is within the bounds, since that + // would make it impossible to create a past-the-end iterator. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 ___bounded_iter& operator++() _NOEXCEPT { + ++__current_; + return *this; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 ___bounded_iter operator++(int) _NOEXCEPT { + ___bounded_iter __tmp(*this); + ++*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 ___bounded_iter& operator--() _NOEXCEPT { + --__current_; + return *this; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 ___bounded_iter operator--(int) _NOEXCEPT { + ___bounded_iter __tmp(*this); + --*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 ___bounded_iter& operator+=(difference_type __n) _NOEXCEPT { + __current_ += __n; + return *this; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend ___bounded_iter + operator+(___bounded_iter const& __self, difference_type __n) _NOEXCEPT { + ___bounded_iter __tmp(__self); + __tmp += __n; + return __tmp; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend ___bounded_iter + operator+(difference_type __n, ___bounded_iter const& __self) _NOEXCEPT { + ___bounded_iter __tmp(__self); + __tmp += __n; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 ___bounded_iter& operator-=(difference_type __n) _NOEXCEPT { + __current_ -= __n; + return *this; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend ___bounded_iter + operator-(___bounded_iter const& __self, difference_type __n) _NOEXCEPT { + ___bounded_iter __tmp(__self); + __tmp -= __n; + return __tmp; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 friend difference_type + operator-(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ - __y.__current_; + } + + // Comparison operations. + // + // These operations do not check whether the iterators are within their bounds. + // The valid range for each iterator is also not considered as part of the comparison, + // i.e. two iterators pointing to the same location will be considered equal even + // if they have different validity ranges. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool + operator==(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ == __y.__current_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool + operator!=(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ != __y.__current_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool + operator<(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ < __y.__current_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool + operator>(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ > __y.__current_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool + operator<=(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ <= __y.__current_; + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool + operator>=(___bounded_iter const& __x, ___bounded_iter const& __y) _NOEXCEPT { + return __x.__current_ >= __y.__current_; + } + +private: + // Return whether the given iterator is in the bounds of this ___bounded_iter. + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Iterator const& __iter) const { + return __iter >= __begin_ && __iter < __end_; + } + + template <class> + friend struct pointer_traits; + _Iterator __current_; // current iterator + _Iterator __begin_, __end_; // valid range represented as [begin, end) +}; + +template <class _It> +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR ___bounded_iter<_It> __make_bounded_iter(_It __it, _It __begin, _It __end) { + return ___bounded_iter<_It>(std::move(__it), std::move(__begin), std::move(__end)); +} + +#if _LIBCPP_STD_VER <= 17 +template <class _Iterator> +struct __is_cpp17_contiguous_iterator<___bounded_iter<_Iterator> > : true_type {}; +#endif + +template <class _Iterator> +struct pointer_traits<___bounded_iter<_Iterator> > { + using pointer = ___bounded_iter<_Iterator>; + using element_type = typename pointer_traits<_Iterator>::element_type; + using difference_type = typename pointer_traits<_Iterator>::difference_type; + + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __it) _NOEXCEPT { + return std::__to_address(__it.__current_); + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_BOUNDED_ITER_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h index 55ce44d047..130cbbfb51 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/allocator.h @@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> class allocator; #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION) +// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17. +// Specializing allocator<void> is deprecated, but not using it. template <> class _LIBCPP_TEMPLATE_VIS allocator<void> { diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/auto_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/auto_ptr.h index 163a46b631..c007b4d21a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/auto_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/auto_ptr.h @@ -16,6 +16,8 @@ # pragma GCC system_header #endif +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) + _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> @@ -77,4 +79,6 @@ public: _LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) + #endif // _LIBCPP___MEMORY_AUTO_PTR_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h index e2cae92e2b..3d73bfaafa 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/shared_ptr.h @@ -20,6 +20,7 @@ #include <__memory/allocation_guard.h> #include <__memory/allocator.h> #include <__memory/allocator_traits.h> +#include <__memory/auto_ptr.h> #include <__memory/compressed_pair.h> #include <__memory/construct_at.h> #include <__memory/pointer_traits.h> @@ -38,9 +39,6 @@ # include <atomic> #endif -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) -# include <__memory/auto_ptr.h> -#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -1683,19 +1681,10 @@ template <class _Tp> struct owner_less; #endif -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> -#endif + : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> second_argument_type; -#endif _LIBCPP_INLINE_VISIBILITY bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} @@ -1707,19 +1696,10 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP {return __x.owner_before(__y);} }; -_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > -#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) - : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> -#endif + : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef weak_ptr<_Tp> second_argument_type; -#endif _LIBCPP_INLINE_VISIBILITY bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT {return __x.owner_before(__y);} diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h b/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h index 2c6e333eba..9822bd30c8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/temporary_buffer.h @@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp> -_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI +_LIBCPP_NODISCARD_EXT _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT { @@ -67,7 +67,7 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17 void return_temporary_buffer(_Tp* __p) _NOEXCEPT { _VSTD::__libcpp_deallocate_unsized((void*)__p, _LIBCPP_ALIGNOF(_Tp)); @@ -75,8 +75,10 @@ void return_temporary_buffer(_Tp* __p) _NOEXCEPT struct __return_temporary_buffer { +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Tp> _LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __p) const {_VSTD::return_temporary_buffer(__p);} +_LIBCPP_SUPPRESS_DEPRECATED_POP }; _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h index 4cc71243f2..8df73cf4ed 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h +++ b/contrib/libs/cxxsupp/libcxx/include/__memory/unique_ptr.h @@ -14,6 +14,7 @@ #include <__functional/hash.h> #include <__functional/operations.h> #include <__memory/allocator_traits.h> // __pointer +#include <__memory/auto_ptr.h> #include <__memory/compressed_pair.h> #include <__utility/forward.h> #include <__utility/move.h> @@ -21,10 +22,6 @@ #include <stlfwd> #include <type_traits> -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) -# include <__memory/auto_ptr.h> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/__random/is_valid.h b/contrib/libs/cxxsupp/libcxx/include/__random/is_valid.h index be3b61b8dc..d41bfa45ea 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__random/is_valid.h +++ b/contrib/libs/cxxsupp/libcxx/include/__random/is_valid.h @@ -10,7 +10,6 @@ #define _LIBCPP___RANDOM_IS_VALID_H #include <__config> -#include <cstdint> #include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -26,20 +25,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD // unsigned int, unsigned long, or unsigned long long. template<class> struct __libcpp_random_is_valid_inttype : false_type {}; -template<> struct __libcpp_random_is_valid_inttype<int8_t> : true_type {}; // extension template<> struct __libcpp_random_is_valid_inttype<short> : true_type {}; template<> struct __libcpp_random_is_valid_inttype<int> : true_type {}; template<> struct __libcpp_random_is_valid_inttype<long> : true_type {}; template<> struct __libcpp_random_is_valid_inttype<long long> : true_type {}; -template<> struct __libcpp_random_is_valid_inttype<uint8_t> : true_type {}; // extension template<> struct __libcpp_random_is_valid_inttype<unsigned short> : true_type {}; template<> struct __libcpp_random_is_valid_inttype<unsigned int> : true_type {}; template<> struct __libcpp_random_is_valid_inttype<unsigned long> : true_type {}; template<> struct __libcpp_random_is_valid_inttype<unsigned long long> : true_type {}; #ifndef _LIBCPP_HAS_NO_INT128 -template<> struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension -template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension +template<> struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; +template<> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; #endif // _LIBCPP_HAS_NO_INT128 // [rand.req.urng]/3: diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h index 5f9bf7e277..181477419c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/all.h @@ -39,6 +39,7 @@ namespace __all { [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))) + -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) { return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)); } diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h index 962bc4e900..b2a8ee5814 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/drop_view.h @@ -40,6 +40,9 @@ # pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES) @@ -298,4 +301,6 @@ inline namespace __cpo { _LIBCPP_END_NAMESPACE_STD +_LIBCPP_POP_MACROS + #endif // _LIBCPP___RANGES_DROP_VIEW_H diff --git a/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h b/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h index b832668313..32ca4b854b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h +++ b/contrib/libs/cxxsupp/libcxx/include/__ranges/size.h @@ -35,68 +35,76 @@ namespace ranges { namespace ranges { namespace __size { - void size(auto&) = delete; - void size(const auto&) = delete; - - template <class _Tp> - concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; - - template <class _Tp> - concept __member_size = - __size_enabled<_Tp> && - __workaround_52970<_Tp> && - requires(_Tp&& __t) { - { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like; - }; - - template <class _Tp> - concept __unqualified_size = - __size_enabled<_Tp> && - !__member_size<_Tp> && - __class_or_enum<remove_cvref_t<_Tp>> && - requires(_Tp&& __t) { - { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like; - }; - - template <class _Tp> - concept __difference = - !__member_size<_Tp> && - !__unqualified_size<_Tp> && - __class_or_enum<remove_cvref_t<_Tp>> && - requires(_Tp&& __t) { - { ranges::begin(__t) } -> forward_iterator; - { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>; - }; - - struct __fn { - template <class _Tp, size_t _Sz> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept { - return _Sz; - } - - template <class _Tp, size_t _Sz> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept { - return _Sz; - } - - template <__member_size _Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) { - return _LIBCPP_AUTO_CAST(__t.size()); - } - - template <__unqualified_size _Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const - noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) { - return _LIBCPP_AUTO_CAST(size(__t)); - } - - template<__difference _Tp> - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const - noexcept(noexcept(ranges::end(__t) - ranges::begin(__t))) { - return std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)); - } +void size(auto&) = delete; +void size(const auto&) = delete; + +template <class _Tp> +concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>; + +template <class _Tp> +concept __member_size = + __size_enabled<_Tp> && + __workaround_52970<_Tp> && + requires(_Tp&& __t) { + { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like; }; + +template <class _Tp> +concept __unqualified_size = + __size_enabled<_Tp> && + !__member_size<_Tp> && + __class_or_enum<remove_cvref_t<_Tp>> && + requires(_Tp&& __t) { + { _LIBCPP_AUTO_CAST(size(__t)) } -> __integer_like; + }; + +template <class _Tp> +concept __difference = + !__member_size<_Tp> && + !__unqualified_size<_Tp> && + __class_or_enum<remove_cvref_t<_Tp>> && + requires(_Tp&& __t) { + { ranges::begin(__t) } -> forward_iterator; + { ranges::end(__t) } -> sized_sentinel_for<decltype(ranges::begin(declval<_Tp>()))>; + }; + +struct __fn { + + // `[range.prim.size]`: the array case (for rvalues). + template <class _Tp, size_t _Sz> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&&)[_Sz]) const noexcept { + return _Sz; + } + + // `[range.prim.size]`: the array case (for lvalues). + template <class _Tp, size_t _Sz> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t operator()(_Tp (&)[_Sz]) const noexcept { + return _Sz; + } + + // `[range.prim.size]`: `auto(t.size())` is a valid expression. + template <__member_size _Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const + noexcept(noexcept(_LIBCPP_AUTO_CAST(__t.size()))) { + return _LIBCPP_AUTO_CAST(__t.size()); + } + + // `[range.prim.size]`: `auto(size(t))` is a valid expression. + template <__unqualified_size _Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __integer_like auto operator()(_Tp&& __t) const + noexcept(noexcept(_LIBCPP_AUTO_CAST(size(__t)))) { + return _LIBCPP_AUTO_CAST(size(__t)); + } + + // [range.prim.size]: the `to-unsigned-like` case. + template <__difference _Tp> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const + noexcept(noexcept(std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)))) + -> decltype( std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t))) + { return std::__to_unsigned_like(ranges::end(__t) - ranges::begin(__t)); + } +}; + } // namespace __size inline namespace __cpo { @@ -108,19 +116,18 @@ inline namespace __cpo { namespace ranges { namespace __ssize { - struct __fn { - template<class _Tp> - requires requires (_Tp&& __t) { ranges::size(__t); } - [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const - noexcept(noexcept(ranges::size(__t))) - { - using _Signed = make_signed_t<decltype(ranges::size(__t))>; - if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed)) - return static_cast<ptrdiff_t>(ranges::size(__t)); - else - return static_cast<_Signed>(ranges::size(__t)); - } - }; +struct __fn { + template<class _Tp> + requires requires (_Tp&& __t) { ranges::size(__t); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr integral auto operator()(_Tp&& __t) const + noexcept(noexcept(ranges::size(__t))) { + using _Signed = make_signed_t<decltype(ranges::size(__t))>; + if constexpr (sizeof(ptrdiff_t) > sizeof(_Signed)) + return static_cast<ptrdiff_t>(ranges::size(__t)); + else + return static_cast<_Signed>(ranges::size(__t)); + } +}; } // namespace __ssize inline namespace __cpo { diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h b/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h index 00d69d19e8..e2b1f62f57 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__posix_l_fallback.h @@ -19,142 +19,142 @@ extern "C" { #endif -inline _LIBCPP_INLINE_VISIBILITY int isalnum_l(int c, locale_t) { - return ::isalnum(c); +inline _LIBCPP_INLINE_VISIBILITY int isalnum_l(int __c, locale_t) { + return ::isalnum(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isalpha_l(int c, locale_t) { - return ::isalpha(c); +inline _LIBCPP_INLINE_VISIBILITY int isalpha_l(int __c, locale_t) { + return ::isalpha(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isblank_l(int c, locale_t) { - return ::isblank(c); +inline _LIBCPP_INLINE_VISIBILITY int isblank_l(int __c, locale_t) { + return ::isblank(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iscntrl_l(int c, locale_t) { - return ::iscntrl(c); +inline _LIBCPP_INLINE_VISIBILITY int iscntrl_l(int __c, locale_t) { + return ::iscntrl(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isdigit_l(int c, locale_t) { - return ::isdigit(c); +inline _LIBCPP_INLINE_VISIBILITY int isdigit_l(int __c, locale_t) { + return ::isdigit(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isgraph_l(int c, locale_t) { - return ::isgraph(c); +inline _LIBCPP_INLINE_VISIBILITY int isgraph_l(int __c, locale_t) { + return ::isgraph(__c); } -inline _LIBCPP_INLINE_VISIBILITY int islower_l(int c, locale_t) { - return ::islower(c); +inline _LIBCPP_INLINE_VISIBILITY int islower_l(int __c, locale_t) { + return ::islower(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isprint_l(int c, locale_t) { - return ::isprint(c); +inline _LIBCPP_INLINE_VISIBILITY int isprint_l(int __c, locale_t) { + return ::isprint(__c); } -inline _LIBCPP_INLINE_VISIBILITY int ispunct_l(int c, locale_t) { - return ::ispunct(c); +inline _LIBCPP_INLINE_VISIBILITY int ispunct_l(int __c, locale_t) { + return ::ispunct(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isspace_l(int c, locale_t) { - return ::isspace(c); +inline _LIBCPP_INLINE_VISIBILITY int isspace_l(int __c, locale_t) { + return ::isspace(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isupper_l(int c, locale_t) { - return ::isupper(c); +inline _LIBCPP_INLINE_VISIBILITY int isupper_l(int __c, locale_t) { + return ::isupper(__c); } -inline _LIBCPP_INLINE_VISIBILITY int isxdigit_l(int c, locale_t) { - return ::isxdigit(c); +inline _LIBCPP_INLINE_VISIBILITY int isxdigit_l(int __c, locale_t) { + return ::isxdigit(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswalnum_l(wint_t c, locale_t) { - return ::iswalnum(c); +inline _LIBCPP_INLINE_VISIBILITY int iswalnum_l(wint_t __c, locale_t) { + return ::iswalnum(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswalpha_l(wint_t c, locale_t) { - return ::iswalpha(c); +inline _LIBCPP_INLINE_VISIBILITY int iswalpha_l(wint_t __c, locale_t) { + return ::iswalpha(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswblank_l(wint_t c, locale_t) { - return ::iswblank(c); +inline _LIBCPP_INLINE_VISIBILITY int iswblank_l(wint_t __c, locale_t) { + return ::iswblank(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) { - return ::iswcntrl(c); +inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t __c, locale_t) { + return ::iswcntrl(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswdigit_l(wint_t c, locale_t) { - return ::iswdigit(c); +inline _LIBCPP_INLINE_VISIBILITY int iswdigit_l(wint_t __c, locale_t) { + return ::iswdigit(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswgraph_l(wint_t c, locale_t) { - return ::iswgraph(c); +inline _LIBCPP_INLINE_VISIBILITY int iswgraph_l(wint_t __c, locale_t) { + return ::iswgraph(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswlower_l(wint_t c, locale_t) { - return ::iswlower(c); +inline _LIBCPP_INLINE_VISIBILITY int iswlower_l(wint_t __c, locale_t) { + return ::iswlower(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswprint_l(wint_t c, locale_t) { - return ::iswprint(c); +inline _LIBCPP_INLINE_VISIBILITY int iswprint_l(wint_t __c, locale_t) { + return ::iswprint(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswpunct_l(wint_t c, locale_t) { - return ::iswpunct(c); +inline _LIBCPP_INLINE_VISIBILITY int iswpunct_l(wint_t __c, locale_t) { + return ::iswpunct(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswspace_l(wint_t c, locale_t) { - return ::iswspace(c); +inline _LIBCPP_INLINE_VISIBILITY int iswspace_l(wint_t __c, locale_t) { + return ::iswspace(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswupper_l(wint_t c, locale_t) { - return ::iswupper(c); +inline _LIBCPP_INLINE_VISIBILITY int iswupper_l(wint_t __c, locale_t) { + return ::iswupper(__c); } -inline _LIBCPP_INLINE_VISIBILITY int iswxdigit_l(wint_t c, locale_t) { - return ::iswxdigit(c); +inline _LIBCPP_INLINE_VISIBILITY int iswxdigit_l(wint_t __c, locale_t) { + return ::iswxdigit(__c); } -inline _LIBCPP_INLINE_VISIBILITY int toupper_l(int c, locale_t) { - return ::toupper(c); +inline _LIBCPP_INLINE_VISIBILITY int toupper_l(int __c, locale_t) { + return ::toupper(__c); } -inline _LIBCPP_INLINE_VISIBILITY int tolower_l(int c, locale_t) { - return ::tolower(c); +inline _LIBCPP_INLINE_VISIBILITY int tolower_l(int __c, locale_t) { + return ::tolower(__c); } -inline _LIBCPP_INLINE_VISIBILITY wint_t towupper_l(wint_t c, locale_t) { - return ::towupper(c); +inline _LIBCPP_INLINE_VISIBILITY wint_t towupper_l(wint_t __c, locale_t) { + return ::towupper(__c); } -inline _LIBCPP_INLINE_VISIBILITY wint_t towlower_l(wint_t c, locale_t) { - return ::towlower(c); +inline _LIBCPP_INLINE_VISIBILITY wint_t towlower_l(wint_t __c, locale_t) { + return ::towlower(__c); } -inline _LIBCPP_INLINE_VISIBILITY int strcoll_l(const char *s1, const char *s2, +inline _LIBCPP_INLINE_VISIBILITY int strcoll_l(const char *__s1, const char *__s2, locale_t) { - return ::strcoll(s1, s2); + return ::strcoll(__s1, __s2); } -inline _LIBCPP_INLINE_VISIBILITY size_t strxfrm_l(char *dest, const char *src, - size_t n, locale_t) { - return ::strxfrm(dest, src, n); +inline _LIBCPP_INLINE_VISIBILITY size_t strxfrm_l(char *__dest, const char *__src, + size_t __n, locale_t) { + return ::strxfrm(__dest, __src, __n); } -inline _LIBCPP_INLINE_VISIBILITY size_t strftime_l(char *s, size_t max, - const char *format, - const struct tm *tm, locale_t) { - return ::strftime(s, max, format, tm); +inline _LIBCPP_INLINE_VISIBILITY size_t strftime_l(char *__s, size_t __max, + const char *__format, + const struct tm *__tm, locale_t) { + return ::strftime(__s, __max, __format, __tm); } -inline _LIBCPP_INLINE_VISIBILITY int wcscoll_l(const wchar_t *ws1, - const wchar_t *ws2, locale_t) { - return ::wcscoll(ws1, ws2); +inline _LIBCPP_INLINE_VISIBILITY int wcscoll_l(const wchar_t *__ws1, + const wchar_t *__ws2, locale_t) { + return ::wcscoll(__ws1, __ws2); } -inline _LIBCPP_INLINE_VISIBILITY size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, - size_t n, locale_t) { - return ::wcsxfrm(dest, src, n); +inline _LIBCPP_INLINE_VISIBILITY size_t wcsxfrm_l(wchar_t *__dest, const wchar_t *__src, + size_t __n, locale_t) { + return ::wcsxfrm(__dest, __src, __n); } #ifdef __cplusplus diff --git a/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h b/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h index 1172a5d572..497148a662 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h +++ b/contrib/libs/cxxsupp/libcxx/include/__support/xlocale/__strtonum_fallback.h @@ -19,44 +19,44 @@ extern "C" { #endif -inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char *nptr, - char **endptr, locale_t) { - return ::strtof(nptr, endptr); +inline _LIBCPP_INLINE_VISIBILITY float strtof_l(const char *__nptr, + char **__endptr, locale_t) { + return ::strtof(__nptr, __endptr); } -inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char *nptr, - char **endptr, locale_t) { - return ::strtod(nptr, endptr); +inline _LIBCPP_INLINE_VISIBILITY double strtod_l(const char *__nptr, + char **__endptr, locale_t) { + return ::strtod(__nptr, __endptr); } -inline _LIBCPP_INLINE_VISIBILITY long double strtold_l(const char *nptr, - char **endptr, locale_t) { - return ::strtold(nptr, endptr); +inline _LIBCPP_INLINE_VISIBILITY long double strtold_l(const char *__nptr, + char **__endptr, locale_t) { + return ::strtold(__nptr, __endptr); } inline _LIBCPP_INLINE_VISIBILITY long long -strtoll_l(const char *nptr, char **endptr, int base, locale_t) { - return ::strtoll(nptr, endptr, base); +strtoll_l(const char *__nptr, char **__endptr, int __base, locale_t) { + return ::strtoll(__nptr, __endptr, __base); } inline _LIBCPP_INLINE_VISIBILITY unsigned long long -strtoull_l(const char *nptr, char **endptr, int base, locale_t) { - return ::strtoull(nptr, endptr, base); +strtoull_l(const char *__nptr, char **__endptr, int __base, locale_t) { + return ::strtoull(__nptr, __endptr, __base); } inline _LIBCPP_INLINE_VISIBILITY long long -wcstoll_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { - return ::wcstoll(nptr, endptr, base); +wcstoll_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) { + return ::wcstoll(__nptr, __endptr, __base); } inline _LIBCPP_INLINE_VISIBILITY unsigned long long -wcstoull_l(const wchar_t *nptr, wchar_t **endptr, int base, locale_t) { - return ::wcstoull(nptr, endptr, base); +wcstoull_l(const wchar_t *__nptr, wchar_t **__endptr, int __base, locale_t) { + return ::wcstoull(__nptr, __endptr, __base); } -inline _LIBCPP_INLINE_VISIBILITY long double wcstold_l(const wchar_t *nptr, - wchar_t **endptr, locale_t) { - return ::wcstold(nptr, endptr); +inline _LIBCPP_INLINE_VISIBILITY 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/__type_traits/conditional.h b/contrib/libs/cxxsupp/libcxx/include/__type_traits/conditional.h index 39852c4480..4b1a560ddc 100644 --- a/contrib/libs/cxxsupp/libcxx/include/__type_traits/conditional.h +++ b/contrib/libs/cxxsupp/libcxx/include/__type_traits/conditional.h @@ -45,6 +45,9 @@ template <bool _Bp, class _IfRes, class _ElseRes> using conditional_t = typename conditional<_Bp, _IfRes, _ElseRes>::type; #endif +// Helper so we can use "conditional_t" in all language versions. +template <bool _Bp, class _If, class _Then> using __conditional_t = typename conditional<_Bp, _If, _Then>::type; + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TYPE_TRAITS_CONDITIONAL_H diff --git a/contrib/libs/cxxsupp/libcxx/include/algorithm b/contrib/libs/cxxsupp/libcxx/include/algorithm index 2dad3e1d41..9146a130bf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/algorithm +++ b/contrib/libs/cxxsupp/libcxx/include/algorithm @@ -19,12 +19,17 @@ namespace std { namespace ranges { + + // [algorithms.results], algorithm result types template <class I, class F> struct in_fun_result; // since C++20 template <class I1, class I2> struct in_in_result; // since C++20 + template <class I, class O> + struct in_out_result; // since C++20 + template <class I1, class I2, class O> struct in_in_out_result; // since C++20 @@ -53,6 +58,9 @@ namespace ranges { indirect_strict_weak_order<projected<iterator_t<R>, Proj>> Comp = ranges::less> constexpr borrowed_iterator_t<R> ranges::max_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + template<class I1, class I2> + using mismatch_result = in_in_result<I1, I2>; + template <input_iterator I1, sentinel_for<_I1> S1, input_iterator I2, sentinel_for<_I2> S2, class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity> requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2> @@ -174,6 +182,9 @@ namespace ranges { constexpr range_difference_t<R> count_if(R&& r, Pred pred, Proj proj = {}); // since C++20 + template<class T> + using minmax_result = min_max_result<T>; + template<class T, class Proj = identity, indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less> constexpr ranges::minmax_result<const T&> @@ -190,6 +201,9 @@ namespace ranges { constexpr ranges::minmax_result<range_value_t<R>> minmax(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 + template<class I> + using minmax_element_result = min_max_result<I>; + template<forward_iterator I, sentinel_for<I> S, class Proj = identity, indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> constexpr ranges::minmax_element_result<I> @@ -201,10 +215,10 @@ namespace ranges { minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20 template<class I, class O> - using copy_result = in_out_result<I, O>; // since C++20 + using copy_result = in_out_result<I, O>; // since C++20 - template<class I, class O> - using copy_n_result = in_out_result<I, O>; // since C++20 + template<class I, class O> + using copy_n_result = in_out_result<I, O>; // since C++20 template<class I, class O> using copy_if_result = in_out_result<I, O>; // since C++20 @@ -450,6 +464,27 @@ namespace ranges { ranges::lexicographical_compare(R1&& r1, R2&& r2, Comp comp = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++20 + template<bidirectional_iterator I1, sentinel_for<I1> S1, bidirectional_iterator I2> + requires indirectly_movable<I1, I2> + constexpr ranges::move_backward_result<I1, I2> + ranges::move_backward(I1 first, S1 last, I2 result); // since C++20 + + template<bidirectional_range R, bidirectional_iterator I> + requires indirectly_movable<iterator_t<R>, I> + constexpr ranges::move_backward_result<borrowed_iterator_t<R>, I> + ranges::move_backward(R&& r, I result); // since C++20 + + template<input_iterator I, sentinel_for<I> S, weakly_incrementable O> + requires indirectly_movable<I, O> + constexpr ranges::move_result<I, O> + ranges::move(I first, S last, O result); // since C++20 + + template<input_range R, weakly_incrementable O> + requires indirectly_movable<iterator_t<R>, O> + constexpr ranges::move_result<borrowed_iterator_t<R>, O> + ranges::move(R&& r, O result); // since C++20 + + } constexpr bool // constexpr in C++20 @@ -617,19 +652,34 @@ template <class BidirectionalIterator1, class BidirectionalIterator2> copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result); +// [alg.move], move +template<class InputIterator, class OutputIterator> + constexpr OutputIterator move(InputIterator first, InputIterator last, + OutputIterator result); + +template<class BidirectionalIterator1, class BidirectionalIterator2> + constexpr BidirectionalIterator2 + move_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, + BidirectionalIterator2 result); + template <class ForwardIterator1, class ForwardIterator2> constexpr ForwardIterator2 // constexpr in C++20 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2); +namespace ranges { + template<class I1, class I2> + using swap_ranges_result = in_in_result<I1, I2>; + template<input_iterator I1, sentinel_for<I1> S1, input_iterator I2, sentinel_for<I2> S2> requires indirectly_swappable<I1, I2> constexpr ranges::swap_ranges_result<I1, I2> - ranges::swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2); + swap_ranges(I1 first1, S1 last1, I2 first2, S2 last2); template<input_range R1, input_range R2> requires indirectly_swappable<iterator_t<R1>, iterator_t<R2>> constexpr ranges::swap_ranges_result<borrowed_iterator_t<R1>, borrowed_iterator_t<R2>> - ranges::swap_ranges(R1&& r1, R2&& r2); + swap_ranges(R1&& r1, R2&& r2); +} template <class ForwardIterator1, class ForwardIterator2> constexpr void // constexpr in C++20 @@ -1195,6 +1245,8 @@ template <class BidirectionalIterator, class Compare> #include <__algorithm/ranges_minmax.h> #include <__algorithm/ranges_minmax_element.h> #include <__algorithm/ranges_mismatch.h> +#include <__algorithm/ranges_move.h> +#include <__algorithm/ranges_move_backward.h> #include <__algorithm/ranges_none_of.h> #include <__algorithm/ranges_replace.h> #include <__algorithm/ranges_replace_if.h> @@ -1237,6 +1289,12 @@ template <class BidirectionalIterator, class Compare> #include <__algorithm/unwrap_iter.h> #include <__algorithm/upper_bound.h> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <chrono> +# include <iterator> +# include <utility> +#endif + // standard-mandated includes #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/any b/contrib/libs/cxxsupp/libcxx/include/any index 991d887bf2..7e12034b45 100644 --- a/contrib/libs/cxxsupp/libcxx/include/any +++ b/contrib/libs/cxxsupp/libcxx/include/any @@ -94,6 +94,10 @@ namespace std { #include <typeinfo> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <chrono> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/array b/contrib/libs/cxxsupp/libcxx/include/array index ab919309b9..e96c3d8133 100644 --- a/contrib/libs/cxxsupp/libcxx/include/array +++ b/contrib/libs/cxxsupp/libcxx/include/array @@ -123,6 +123,12 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <iterator> +# include <utility> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/atomic b/contrib/libs/cxxsupp/libcxx/include/atomic index 3ccc8bc944..0c6d3079c9 100644 --- a/contrib/libs/cxxsupp/libcxx/include/atomic +++ b/contrib/libs/cxxsupp/libcxx/include/atomic @@ -534,6 +534,10 @@ template <class T> # include <__threading_support> #endif +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <chrono> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/bit b/contrib/libs/cxxsupp/libcxx/include/bit index f830302fd5..fe1bcadc81 100644 --- a/contrib/libs/cxxsupp/libcxx/include/bit +++ b/contrib/libs/cxxsupp/libcxx/include/bit @@ -71,11 +71,15 @@ namespace std { #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iosfwd> +#endif + #if defined(__IBMCPP__) -#include "__support/ibm/support.h" +# include "__support/ibm/support.h" #endif #if defined(_LIBCPP_COMPILER_MSVC) -#include <intrin.h> +# include <intrin.h> #endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -89,17 +93,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type"); - const unsigned int __dig = numeric_limits<_Tp>::digits; - if ((__cnt % __dig) == 0) - return __t; - return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); -} - -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT { static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type"); @@ -111,33 +104,6 @@ _Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT template<class _Tp> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -int __countr_zero(_Tp __t) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_zero requires an unsigned integer type"); - if (__t == 0) - return numeric_limits<_Tp>::digits; - - if (sizeof(_Tp) <= sizeof(unsigned int)) - return __libcpp_ctz(static_cast<unsigned int>(__t)); - else if (sizeof(_Tp) <= sizeof(unsigned long)) - return __libcpp_ctz(static_cast<unsigned long>(__t)); - else if (sizeof(_Tp) <= sizeof(unsigned long long)) - return __libcpp_ctz(static_cast<unsigned long long>(__t)); - else - { - int __ret = 0; - const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; - while (static_cast<unsigned long long>(__t) == 0uLL) - { - __ret += __ulldigits; - __t >>= __ulldigits; - } - return __ret + __libcpp_ctz(static_cast<unsigned long long>(__t)); - } -} - -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 int __countl_zero(_Tp __t) _NOEXCEPT { static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type"); @@ -145,13 +111,13 @@ int __countl_zero(_Tp __t) _NOEXCEPT return numeric_limits<_Tp>::digits; if (sizeof(_Tp) <= sizeof(unsigned int)) - return __libcpp_clz(static_cast<unsigned int>(__t)) + return std::__libcpp_clz(static_cast<unsigned int>(__t)) - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits); else if (sizeof(_Tp) <= sizeof(unsigned long)) - return __libcpp_clz(static_cast<unsigned long>(__t)) + return std::__libcpp_clz(static_cast<unsigned long>(__t)) - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits); else if (sizeof(_Tp) <= sizeof(unsigned long long)) - return __libcpp_clz(static_cast<unsigned long long>(__t)) + return std::__libcpp_clz(static_cast<unsigned long long>(__t)) - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits); else { @@ -159,8 +125,8 @@ int __countl_zero(_Tp __t) _NOEXCEPT int __iter = 0; const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; while (true) { - __t = __rotr(__t, __ulldigits); - if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits) + __t = std::__rotr(__t, __ulldigits); + if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits) break; __ret += __iter; } @@ -168,118 +134,97 @@ int __countl_zero(_Tp __t) _NOEXCEPT } } -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -int __countl_one(_Tp __t) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_one requires an unsigned integer type"); - return __t != numeric_limits<_Tp>::max() - ? __countl_zero(static_cast<_Tp>(~__t)) - : numeric_limits<_Tp>::digits; -} - -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -int __countr_one(_Tp __t) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countr_one requires an unsigned integer type"); - return __t != numeric_limits<_Tp>::max() - ? __countr_zero(static_cast<_Tp>(~__t)) - : numeric_limits<_Tp>::digits; -} - -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -int __popcount(_Tp __t) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__popcount requires an unsigned integer type"); - if (sizeof(_Tp) <= sizeof(unsigned int)) - return __libcpp_popcount(static_cast<unsigned int>(__t)); - else if (sizeof(_Tp) <= sizeof(unsigned long)) - return __libcpp_popcount(static_cast<unsigned long>(__t)); - else if (sizeof(_Tp) <= sizeof(unsigned long long)) - return __libcpp_popcount(static_cast<unsigned long long>(__t)); - else - { - int __ret = 0; - while (__t != 0) - { - __ret += __libcpp_popcount(static_cast<unsigned long long>(__t)); - __t >>= numeric_limits<unsigned long long>::digits; - } - return __ret; - } -} - -// integral log base 2 -template<class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 -unsigned __bit_log2(_Tp __t) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type"); - return numeric_limits<_Tp>::digits - 1 - __countl_zero(__t); -} - -template <class _Tp> -_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR -bool __has_single_bit(_Tp __t) _NOEXCEPT -{ - static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__has_single_bit requires an unsigned integer type"); - return __t != 0 && (((__t & (__t - 1)) == 0)); -} - #if _LIBCPP_STD_VER > 17 template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, unsigned int __cnt) noexcept { - return __rotl(__t, __cnt); + const unsigned int __dig = numeric_limits<_Tp>::digits; + if ((__cnt % __dig) == 0) + return __t; + return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, unsigned int __cnt) noexcept { - return __rotr(__t, __cnt); + return std::__rotr(__t, __cnt); } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept { - return __countl_zero(__t); + return std::__countl_zero(__t); } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept { - return __countl_one(__t); + return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept { - return __countr_zero(__t); + if (__t == 0) + return numeric_limits<_Tp>::digits; + + if (sizeof(_Tp) <= sizeof(unsigned int)) + return std::__libcpp_ctz(static_cast<unsigned int>(__t)); + else if (sizeof(_Tp) <= sizeof(unsigned long)) + return std::__libcpp_ctz(static_cast<unsigned long>(__t)); + else if (sizeof(_Tp) <= sizeof(unsigned long long)) + return std::__libcpp_ctz(static_cast<unsigned long long>(__t)); + else { + int __ret = 0; + const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits; + while (static_cast<unsigned long long>(__t) == 0uLL) { + __ret += __ulldigits; + __t >>= __ulldigits; + } + return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t)); + } } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept { - return __countr_one(__t); + return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits; } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept { - return __popcount(__t); + if (sizeof(_Tp) <= sizeof(unsigned int)) + return std::__libcpp_popcount(static_cast<unsigned int>(__t)); + else if (sizeof(_Tp) <= sizeof(unsigned long)) + return std::__libcpp_popcount(static_cast<unsigned long>(__t)); + else if (sizeof(_Tp) <= sizeof(unsigned long long)) + return std::__libcpp_popcount(static_cast<unsigned long long>(__t)); + else { + int __ret = 0; + while (__t != 0) { + __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t)); + __t >>= numeric_limits<unsigned long long>::digits; + } + return __ret; + } } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept { - return __has_single_bit(__t); + return __t != 0 && (((__t & (__t - 1)) == 0)); +} + +// integral log base 2 +template <__libcpp_unsigned_integer _Tp> +_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept { + return numeric_limits<_Tp>::digits - 1 - std::countl_zero(__t); } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept { - return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t); + return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t); } template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { if (__t < 2) return 1; - const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u)); + const unsigned __n = numeric_limits<_Tp>::digits - std::countl_zero((_Tp)(__t - 1u)); _LIBCPP_ASSERT(__n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil"); if constexpr (sizeof(_Tp) >= sizeof(unsigned)) @@ -293,20 +238,19 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept { template <__libcpp_unsigned_integer _Tp> _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept { - return __t == 0 ? 0 : __bit_log2(__t) + 1; + return __t == 0 ? 0 : std::__bit_log2(__t) + 1; } -enum class endian -{ - little = 0xDEAD, - big = 0xFACE, -#if defined(_LIBCPP_LITTLE_ENDIAN) - native = little -#elif defined(_LIBCPP_BIG_ENDIAN) - native = big -#else - native = 0xCAFE -#endif +enum class endian { + little = 0xDEAD, + big = 0xFACE, +# if defined(_LIBCPP_LITTLE_ENDIAN) + native = little +# elif defined(_LIBCPP_BIG_ENDIAN) + native = big +# else + native = 0xCAFE +# endif }; #endif // _LIBCPP_STD_VER > 17 diff --git a/contrib/libs/cxxsupp/libcxx/include/bitset b/contrib/libs/cxxsupp/libcxx/include/bitset index 9597bf3bc1..da85ecc720 100644 --- a/contrib/libs/cxxsupp/libcxx/include/bitset +++ b/contrib/libs/cxxsupp/libcxx/include/bitset @@ -1094,7 +1094,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT template <size_t _Size> struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > - : public unary_function<bitset<_Size>, size_t> + : public __unary_function<bitset<_Size>, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT diff --git a/contrib/libs/cxxsupp/libcxx/include/charconv b/contrib/libs/cxxsupp/libcxx/include/charconv index ce2897cf7c..6a63e5fe90 100644 --- a/contrib/libs/cxxsupp/libcxx/include/charconv +++ b/contrib/libs/cxxsupp/libcxx/include/charconv @@ -96,6 +96,10 @@ namespace std { #include <limits> #include <type_traits> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iosfwd> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif @@ -125,9 +129,9 @@ struct _LIBCPP_HIDDEN __traits_base return __t - (__v < __table<>::__pow10_64[__t]) + 1; } - static _LIBCPP_HIDE_FROM_ABI char* __convert(_Tp __v, char* __p) + static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { - return __itoa::__base_10_u64(__v, __p); + return __itoa::__base_10_u64(__p, __v); } static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_64)& __pow() { return __table<>::__pow10_64; } @@ -145,9 +149,9 @@ struct _LIBCPP_HIDDEN return __t - (__v < __table<>::__pow10_32[__t]) + 1; } - static _LIBCPP_HIDE_FROM_ABI char* __convert(_Tp __v, char* __p) + static _LIBCPP_HIDE_FROM_ABI char* __convert(char* __p, _Tp __v) { - return __itoa::__base_10_u32(__v, __p); + return __itoa::__base_10_u32(__p, __v); } static _LIBCPP_HIDE_FROM_ABI decltype(__table<>::__pow10_32)& __pow() { return __table<>::__pow10_32; } @@ -262,7 +266,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) auto __diff = __last - __first; if (__tx::digits <= __diff || __tx::__width(__value) <= __diff) - return {__tx::__convert(__value, __first), errc(0)}; + return {__tx::__convert(__first, __value), errc(0)}; else return {__last, errc::value_too_large}; } @@ -487,16 +491,21 @@ template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = inline _LIBCPP_HIDE_FROM_ABI to_chars_result to_chars(char* __first, char* __last, _Tp __value) { - return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>()); + using _Type = __make_32_64_or_128_bit_t<_Tp>; + static_assert(!is_same<_Type, void>::value, "unsupported integral type used in to_chars"); + static_assert(sizeof(_Tp) <= sizeof(int64_t), "128-bit integral support isn't available yet in to_chars"); + return std::__to_chars_itoa(__first, __last, static_cast<_Type>(__value), is_signed<_Tp>()); } template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0> inline _LIBCPP_HIDE_FROM_ABI to_chars_result to_chars(char* __first, char* __last, _Tp __value, int __base) { - _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); - return __to_chars_integral(__first, __last, __value, __base, - is_signed<_Tp>()); + _LIBCPP_ASSERT(2 <= __base && __base <= 36, "base not in [2, 36]"); + + using _Type = __make_32_64_or_128_bit_t<_Tp>; + static_assert(sizeof(_Tp) <= sizeof(int64_t), "128-bit integral support isn't available yet in to_chars"); + return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>()); } template <typename _It, typename _Tp, typename _Fn, typename... _Ts> diff --git a/contrib/libs/cxxsupp/libcxx/include/codecvt b/contrib/libs/cxxsupp/libcxx/include/codecvt index d3a9486929..3e5110a008 100644 --- a/contrib/libs/cxxsupp/libcxx/include/codecvt +++ b/contrib/libs/cxxsupp/libcxx/include/codecvt @@ -65,7 +65,7 @@ class codecvt_utf8_utf16 _LIBCPP_BEGIN_NAMESPACE_STD -enum codecvt_mode +enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_header = 2, @@ -82,17 +82,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH codecvt_mode _Mode_; +_LIBCPP_SUPPRESS_DEPRECATED_POP public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} +_LIBCPP_SUPPRESS_DEPRECATED_POP protected: virtual result do_out(state_type& __st, @@ -189,9 +193,10 @@ protected: virtual int do_max_length() const _NOEXCEPT; }; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> -class _LIBCPP_TEMPLATE_VIS codecvt_utf8 +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 : public __codecvt_utf8<_Elem> { public: @@ -202,6 +207,7 @@ public: _LIBCPP_INLINE_VISIBILITY ~codecvt_utf8() {} }; +_LIBCPP_SUPPRESS_DEPRECATED_POP // codecvt_utf16 @@ -213,17 +219,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH codecvt_mode _Mode_; +_LIBCPP_SUPPRESS_DEPRECATED_POP public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} +_LIBCPP_SUPPRESS_DEPRECATED_POP protected: virtual result do_out(state_type& __st, @@ -248,17 +258,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH codecvt_mode _Mode_; +_LIBCPP_SUPPRESS_DEPRECATED_POP public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} +_LIBCPP_SUPPRESS_DEPRECATED_POP protected: virtual result do_out(state_type& __st, @@ -431,9 +445,10 @@ protected: virtual int do_max_length() const _NOEXCEPT; }; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> -class _LIBCPP_TEMPLATE_VIS codecvt_utf16 +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { public: @@ -444,6 +459,7 @@ public: _LIBCPP_INLINE_VISIBILITY ~codecvt_utf16() {} }; +_LIBCPP_SUPPRESS_DEPRECATED_POP // codecvt_utf8_utf16 @@ -455,17 +471,21 @@ class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH codecvt_mode _Mode_; +_LIBCPP_SUPPRESS_DEPRECATED_POP public: typedef wchar_t intern_type; typedef char extern_type; typedef mbstate_t state_type; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH _LIBCPP_INLINE_VISIBILITY explicit __codecvt_utf8_utf16(size_t __refs, unsigned long _Maxcode, codecvt_mode _Mode) : codecvt<wchar_t, char, mbstate_t>(__refs), _Maxcode_(_Maxcode), _Mode_(_Mode) {} +_LIBCPP_SUPPRESS_DEPRECATED_POP protected: virtual result do_out(state_type& __st, @@ -562,9 +582,10 @@ protected: virtual int do_max_length() const _NOEXCEPT; }; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> -class _LIBCPP_TEMPLATE_VIS codecvt_utf8_utf16 +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> { public: @@ -575,6 +596,7 @@ public: _LIBCPP_INLINE_VISIBILITY ~codecvt_utf8_utf16() {} }; +_LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_END_NAMESPACE_STD diff --git a/contrib/libs/cxxsupp/libcxx/include/coroutine b/contrib/libs/cxxsupp/libcxx/include/coroutine index a96c4a7a5a..6582f5554e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/coroutine +++ b/contrib/libs/cxxsupp/libcxx/include/coroutine @@ -46,6 +46,10 @@ struct suspend_always; #include <__coroutine/trivial_awaitables.h> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iosfwd> +#endif + // standard-mandated includes #include <compare> diff --git a/contrib/libs/cxxsupp/libcxx/include/deque b/contrib/libs/cxxsupp/libcxx/include/deque index 371b966c66..0760918265 100644 --- a/contrib/libs/cxxsupp/libcxx/include/deque +++ b/contrib/libs/cxxsupp/libcxx/include/deque @@ -185,6 +185,12 @@ template <class T, class Allocator, class Predicate> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/format b/contrib/libs/cxxsupp/libcxx/include/format index c882066660..bf51edd91e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/format +++ b/contrib/libs/cxxsupp/libcxx/include/format @@ -311,12 +311,22 @@ __compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx // exception of type format_error is thrown. // // Validate whether the arguments are integrals. - if (__formatter.__width_needs_substitution()) - __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width)); - - if constexpr (_HasPrecision) - if (__formatter.__precision_needs_substitution()) - __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision)); + if constexpr (requires(formatter<_Tp, _CharT> __f) { __f.__width_needs_substitution(); }) { + // TODO FMT Remove this when parser v1 has been phased out. + if (__formatter.__width_needs_substitution()) + __format::__compile_time_validate_integral(__ctx.arg(__formatter.__width)); + + if constexpr (_HasPrecision) + if (__formatter.__precision_needs_substitution()) + __format::__compile_time_validate_integral(__ctx.arg(__formatter.__precision)); + } else { + if (__formatter.__parser_.__width_as_arg_) + __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_)); + + if constexpr (_HasPrecision) + if (__formatter.__parser_.__precision_as_arg_) + __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_)); + } } template <class _CharT> diff --git a/contrib/libs/cxxsupp/libcxx/include/forward_list b/contrib/libs/cxxsupp/libcxx/include/forward_list index 4600d82ecd..6a72720273 100644 --- a/contrib/libs/cxxsupp/libcxx/include/forward_list +++ b/contrib/libs/cxxsupp/libcxx/include/forward_list @@ -194,6 +194,12 @@ template <class T, class Allocator, class Predicate> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/functional b/contrib/libs/cxxsupp/libcxx/include/functional index dd39e274a5..de02059f64 100644 --- a/contrib/libs/cxxsupp/libcxx/include/functional +++ b/contrib/libs/cxxsupp/libcxx/include/functional @@ -482,6 +482,16 @@ template <> struct hash<long double>; template<class T> struct hash<T*>; template <> struct hash<nullptr_t>; // C++17 +namespace ranges { + // [range.cmp], concept-constrained comparisons + struct equal_to; + struct not_equal_to; + struct greater; + struct less; + struct greater_equal; + struct less_equal; +} + } // std POLICY: For non-variadic implementations, the number of arguments is limited @@ -529,6 +539,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited #include <typeinfo> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <utility> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/future b/contrib/libs/cxxsupp/libcxx/include/future index 4f49bf158b..f4a5b43eef 100644 --- a/contrib/libs/cxxsupp/libcxx/include/future +++ b/contrib/libs/cxxsupp/libcxx/include/future @@ -378,6 +378,10 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>; #include <thread> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <chrono> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/iterator b/contrib/libs/cxxsupp/libcxx/include/iterator index f0bcff96ad..225ae81536 100644 --- a/contrib/libs/cxxsupp/libcxx/include/iterator +++ b/contrib/libs/cxxsupp/libcxx/include/iterator @@ -406,7 +406,7 @@ public: constexpr Iterator base() &&; // From C++20 constexpr reference operator*() const; - constexpr pointer operator->() const; // Removed in C++20 + constexpr pointer operator->() const; // Deprecated in C++20 constexpr move_iterator& operator++(); constexpr auto operator++(int); // Return type was move_iterator until C++20 constexpr move_iterator& operator--(); @@ -680,6 +680,7 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; #include <__iterator/access.h> #include <__iterator/advance.h> #include <__iterator/back_insert_iterator.h> +#include <__iterator/bounded_iter.h> #include <__iterator/common_iterator.h> #include <__iterator/concepts.h> #include <__iterator/counted_iterator.h> @@ -723,6 +724,13 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept; #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <exception> +# include <new> +# include <typeinfo> +# include <utility> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/list b/contrib/libs/cxxsupp/libcxx/include/list index 0b9525b9fb..acfc206452 100644 --- a/contrib/libs/cxxsupp/libcxx/include/list +++ b/contrib/libs/cxxsupp/libcxx/include/list @@ -202,6 +202,12 @@ template <class T, class Allocator, class Predicate> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/locale b/contrib/libs/cxxsupp/libcxx/include/locale index 669a6e016c..274ef4f73e 100644 --- a/contrib/libs/cxxsupp/libcxx/include/locale +++ b/contrib/libs/cxxsupp/libcxx/include/locale @@ -201,9 +201,7 @@ template <class charT> class messages_byname; #include <__iterator/istreambuf_iterator.h> #include <__iterator/ostreambuf_iterator.h> #include <__locale> -#ifndef __APPLE__ -# include <cstdarg> -#endif +#include <cstdarg> // TODO: Remove this include #include <cstdio> #include <cstdlib> #include <ctime> @@ -213,6 +211,10 @@ template <class charT> class messages_byname; #include <streambuf> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iterator> +#endif + #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) // Most unix variants have catopen. These are the specific ones that don't. # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) @@ -3620,7 +3622,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>; template<class _Codecvt, class _Elem = wchar_t, class _Wide_alloc = allocator<_Elem>, class _Byte_alloc = allocator<char> > -class _LIBCPP_TEMPLATE_VIS wstring_convert +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert { public: typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string; @@ -3687,6 +3689,7 @@ public: state_type state() const {return __cvtstate_;} }; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc> inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: @@ -3694,6 +3697,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) { } +_LIBCPP_SUPPRESS_DEPRECATED_POP template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc> inline @@ -3728,6 +3732,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: #endif // _LIBCPP_CXX03_LANG +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template<class _Codecvt, class _Elem, class _Wide_alloc, class _Byte_alloc> wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::~wstring_convert() { @@ -3739,6 +3744,7 @@ typename wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>::wide_string wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: from_bytes(const char* __frm, const char* __frm_end) { +_LIBCPP_SUPPRESS_DEPRECATED_POP __cvtcount_ = 0; if (__cvtptr_ != nullptr) { @@ -3885,7 +3891,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: } template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> > -class _LIBCPP_TEMPLATE_VIS wbuffer_convert +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> { public: @@ -3962,6 +3968,7 @@ private: wbuffer_convert* __close(); }; +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _Tr> wbuffer_convert<_Codecvt, _Elem, _Tr>:: wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state) @@ -3997,6 +4004,7 @@ template <class _Codecvt, class _Elem, class _Tr> typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() { +_LIBCPP_SUPPRESS_DEPRECATED_POP if (__cv_ == 0 || __bufptr_ == 0) return traits_type::eof(); bool __initial = __read_mode(); @@ -4061,10 +4069,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() return __c; } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _Tr> typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) { +_LIBCPP_SUPPRESS_DEPRECATED_POP if (__cv_ != 0 && __bufptr_ != 0 && this->eback() < this->gptr()) { if (traits_type::eq_int_type(__c, traits_type::eof())) @@ -4082,10 +4092,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) return traits_type::eof(); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _Tr> typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) { +_LIBCPP_SUPPRESS_DEPRECATED_POP if (__cv_ == 0 || __bufptr_ == 0) return traits_type::eof(); __write_mode(); @@ -4144,10 +4156,12 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) return traits_type::not_eof(__c); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _Tr> basic_streambuf<_Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) { +_LIBCPP_SUPPRESS_DEPRECATED_POP this->setg(0, 0, 0); this->setp(0, 0); if (__owns_eb_) @@ -4197,6 +4211,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) return this; } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _Tr> typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, @@ -4228,6 +4243,7 @@ template <class _Codecvt, class _Elem, class _Tr> int wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() { +_LIBCPP_SUPPRESS_DEPRECATED_POP if (__cv_ == 0 || __bufptr_ == 0) return 0; if (__cm_ & ios_base::out) @@ -4296,6 +4312,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() return 0; } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH template <class _Codecvt, class _Elem, class _Tr> bool wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() @@ -4350,6 +4367,8 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() return __rt; } +_LIBCPP_SUPPRESS_DEPRECATED_POP + _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS diff --git a/contrib/libs/cxxsupp/libcxx/include/map b/contrib/libs/cxxsupp/libcxx/include/map index 3a4c58af97..720589b843 100644 --- a/contrib/libs/cxxsupp/libcxx/include/map +++ b/contrib/libs/cxxsupp/libcxx/include/map @@ -546,6 +546,12 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20 #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +# include <iterator> +# include <utility> +#endif + // standard-mandated includes // [iterator.range] @@ -979,24 +985,15 @@ public: static_assert((is_same<typename allocator_type::value_type, value_type>::value), "Allocator::value_type must be same type as value_type"); -_LIBCPP_SUPPRESS_DEPRECATED_PUSH class _LIBCPP_TEMPLATE_VIS value_compare -#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - : public binary_function<value_type, value_type, bool> -#endif + : public __binary_function<value_type, value_type, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP friend class map; protected: key_compare comp; _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} public: -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type; -#endif _LIBCPP_INLINE_VISIBILITY bool operator()(const value_type& __x, const value_type& __y) const {return comp(__x.first, __y.first);} @@ -1764,13 +1761,9 @@ public: static_assert((is_same<typename allocator_type::value_type, value_type>::value), "Allocator::value_type must be same type as value_type"); -_LIBCPP_SUPPRESS_DEPRECATED_PUSH class _LIBCPP_TEMPLATE_VIS value_compare -#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - : public binary_function<value_type, value_type, bool> -#endif + : public __binary_function<value_type, value_type, bool> { -_LIBCPP_SUPPRESS_DEPRECATED_POP friend class multimap; protected: key_compare comp; @@ -1778,11 +1771,6 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_INLINE_VISIBILITY value_compare(key_compare c) : comp(c) {} public: -#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) - _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type first_argument_type; - _LIBCPP_DEPRECATED_IN_CXX17 typedef value_type second_argument_type; -#endif _LIBCPP_INLINE_VISIBILITY bool operator()(const value_type& __x, const value_type& __y) const {return comp(__x.first, __y.first);} diff --git a/contrib/libs/cxxsupp/libcxx/include/memory b/contrib/libs/cxxsupp/libcxx/include/memory index ed4003b1b6..458a955a8b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/memory +++ b/contrib/libs/cxxsupp/libcxx/include/memory @@ -847,6 +847,7 @@ template<size_t N, class T> #include <__memory/allocator_arg_t.h> #include <__memory/allocator_traits.h> #include <__memory/assume_aligned.h> +#include <__memory/auto_ptr.h> #include <__memory/compressed_pair.h> #include <__memory/concepts.h> #include <__memory/construct_at.h> @@ -871,13 +872,14 @@ template<size_t N, class T> #include <typeinfo> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iterator> +# include <utility> +#endif + // standard-mandated includes #include <compare> -#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR) -# include <__memory/auto_ptr.h> -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/mutex b/contrib/libs/cxxsupp/libcxx/include/mutex index 5a5f46923b..1d1d3e05e2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/mutex +++ b/contrib/libs/cxxsupp/libcxx/include/mutex @@ -198,6 +198,10 @@ template<class Callable, class ...Args> #endif #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +#endif + #if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG) #include <atomic> #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/new b/contrib/libs/cxxsupp/libcxx/include/new index e91a42253d..ed95caed1c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/new +++ b/contrib/libs/cxxsupp/libcxx/include/new @@ -360,6 +360,17 @@ constexpr _Tp* launder(_Tp* __p) noexcept } #endif +#if _LIBCPP_STD_VER > 14 + +#if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) + +inline constexpr size_t hardware_destructive_interference_size = __GCC_DESTRUCTIVE_SIZE; +inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUCTIVE_SIZE; + +#endif // defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) + +#endif // _LIBCPP_STD_VER > 14 + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_NEW diff --git a/contrib/libs/cxxsupp/libcxx/include/numeric b/contrib/libs/cxxsupp/libcxx/include/numeric index 476ce5348c..0df01faad5 100644 --- a/contrib/libs/cxxsupp/libcxx/include/numeric +++ b/contrib/libs/cxxsupp/libcxx/include/numeric @@ -163,6 +163,11 @@ template<class T> #include <__numeric/transform_inclusive_scan.h> #include <__numeric/transform_reduce.h> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +# include <iterator> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/optional b/contrib/libs/cxxsupp/libcxx/include/optional index 50ce0af5e7..b4d4a2cbf4 100644 --- a/contrib/libs/cxxsupp/libcxx/include/optional +++ b/contrib/libs/cxxsupp/libcxx/include/optional @@ -177,6 +177,21 @@ template<class T> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <atomic> +# include <chrono> +# include <climits> +# include <concepts> +# include <ctime> +# include <iterator> +# include <memory> +# include <ratio> +# include <tuple> +# include <typeinfo> +# include <utility> +# include <variant> +#endif + // standard-mandated includes #include <compare> diff --git a/contrib/libs/cxxsupp/libcxx/include/ostream b/contrib/libs/cxxsupp/libcxx/include/ostream index aa4c8c3d87..283774585b 100644 --- a/contrib/libs/cxxsupp/libcxx/include/ostream +++ b/contrib/libs/cxxsupp/libcxx/include/ostream @@ -142,6 +142,10 @@ template <class Stream, class T> #include <streambuf> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iterator> +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/queue b/contrib/libs/cxxsupp/libcxx/include/queue index a6e8a52e19..9a5cfb39f2 100644 --- a/contrib/libs/cxxsupp/libcxx/include/queue +++ b/contrib/libs/cxxsupp/libcxx/include/queue @@ -231,6 +231,10 @@ template <class T, class Container, class Compare> #include <vector> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +#endif + // standard-mandated includes #include <compare> #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/random b/contrib/libs/cxxsupp/libcxx/include/random index b0817dd3a7..41ee4d85fd 100644 --- a/contrib/libs/cxxsupp/libcxx/include/random +++ b/contrib/libs/cxxsupp/libcxx/include/random @@ -1718,6 +1718,10 @@ class piecewise_linear_distribution #include <__random/weibull_distribution.h> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +#endif + // standard-mandated includes #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/regex b/contrib/libs/cxxsupp/libcxx/include/regex index a0a6561ef0..a117c50f39 100644 --- a/contrib/libs/cxxsupp/libcxx/include/regex +++ b/contrib/libs/cxxsupp/libcxx/include/regex @@ -778,6 +778,11 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator; #include <vector> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iterator> +# include <utility> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/set b/contrib/libs/cxxsupp/libcxx/include/set index be14a150c2..80e22765fb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/set +++ b/contrib/libs/cxxsupp/libcxx/include/set @@ -485,6 +485,11 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20 #include <__utility/forward.h> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/span b/contrib/libs/cxxsupp/libcxx/include/span index ec8b1cd755..1ebe34d090 100644 --- a/contrib/libs/cxxsupp/libcxx/include/span +++ b/contrib/libs/cxxsupp/libcxx/include/span @@ -131,6 +131,7 @@ template<class R> #include <__config> #include <__debug> #include <__fwd/span.h> +#include <__iterator/bounded_iter.h> #include <__iterator/concepts.h> #include <__iterator/iterator_traits.h> #include <__iterator/wrap_iter.h> @@ -147,6 +148,11 @@ template<class R> #include <type_traits> // for remove_cv, etc #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] @@ -216,10 +222,6 @@ concept __span_compatible_iterator = contiguous_iterator<_It> && __span_array_co template <class _Sentinel, class _It> concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>; -#if defined(_LIBCPP_ENABLE_DEBUG_MODE) || defined(_LIBCPP_ABI_SPAN_POINTER_ITERATORS) -# define _LIBCPP_SPAN_USE_POINTER_ITERATOR -#endif - template <typename _Tp, size_t _Extent> class _LIBCPP_TEMPLATE_VIS span { public: @@ -232,8 +234,8 @@ public: using const_pointer = const _Tp *; using reference = _Tp &; using const_reference = const _Tp &; -#ifdef _LIBCPP_SPAN_USE_POINTER_ITERATOR - using iterator = pointer; +#ifdef _LIBCPP_ENABLE_DEBUG_MODE + using iterator = __bounded_iter<pointer>; #else using iterator = __wrap_iter<pointer>; #endif @@ -314,7 +316,7 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, _Count> first() const noexcept { - static_assert(_Count <= _Extent, "Count out of range in span::first()"); + static_assert(_Count <= _Extent, "span<T, N>::first<Count>(): Count out of range"); return span<element_type, _Count>{data(), _Count}; } @@ -322,21 +324,21 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, _Count> last() const noexcept { - static_assert(_Count <= _Extent, "Count out of range in span::last()"); + static_assert(_Count <= _Extent, "span<T, N>::last<Count>(): Count out of range"); return span<element_type, _Count>{data() + size() - _Count, _Count}; } _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept { - _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)"); + _LIBCPP_ASSERT(__count <= size(), "span<T, N>::first(count): count out of range"); return {data(), __count}; } _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, dynamic_extent> last(size_type __count) const noexcept { - _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)"); + _LIBCPP_ASSERT(__count <= size(), "span<T, N>::last(count): count out of range"); return {data() + size() - __count, __count}; } @@ -345,8 +347,8 @@ public: constexpr auto subspan() const noexcept -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> { - static_assert(_Offset <= _Extent, "Offset out of range in span::subspan()"); - static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "Offset + count out of range in span::subspan()"); + static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range"); + static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset, "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range"); using _ReturnType = span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset>; return _ReturnType{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; @@ -357,11 +359,11 @@ public: constexpr span<element_type, dynamic_extent> subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { - _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)"); - _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "Count out of range in span::subspan(offset, count)"); + _LIBCPP_ASSERT(__offset <= size(), "span<T, N>::subspan(offset, count): offset out of range"); + _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T, N>::subspan(offset, count): count out of range"); if (__count == dynamic_extent) return {data() + __offset, size() - __offset}; - _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)"); + _LIBCPP_ASSERT(__count <= size() - __offset, "span<T, N>::subspan(offset, count): offset + count out of range"); return {data() + __offset, __count}; } @@ -371,7 +373,7 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept { - _LIBCPP_ASSERT(__idx < size(), "span<T,N>[] index out of bounds"); + _LIBCPP_ASSERT(__idx < size(), "span<T, N>::operator[](index): index out of range"); return __data[__idx]; } @@ -391,15 +393,15 @@ public: // [span.iter], span iterator support _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { -#ifdef _LIBCPP_SPAN_USE_POINTER_ITERATOR - return iterator(data()); +#ifdef _LIBCPP_ENABLE_DEBUG_MODE + return std::__make_bounded_iter(data(), data(), data() + size()); #else return iterator(this, data()); #endif } _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { -#ifdef _LIBCPP_SPAN_USE_POINTER_ITERATOR - return iterator(data() + size()); +#ifdef _LIBCPP_ENABLE_DEBUG_MODE + return std::__make_bounded_iter(data() + size(), data(), data() + size()); #else return iterator(this, data() + size()); #endif @@ -430,8 +432,8 @@ public: using const_pointer = const _Tp *; using reference = _Tp &; using const_reference = const _Tp &; -#ifdef _LIBCPP_SPAN_USE_POINTER_ITERATOR - using iterator = pointer; +#ifdef _LIBCPP_ENABLE_DEBUG_MODE + using iterator = __bounded_iter<pointer>; #else using iterator = __wrap_iter<pointer>; #endif @@ -494,7 +496,7 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, _Count> first() const noexcept { - _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::first()"); + _LIBCPP_ASSERT(_Count <= size(), "span<T>::first<Count>(): Count out of range"); return span<element_type, _Count>{data(), _Count}; } @@ -502,21 +504,21 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, _Count> last() const noexcept { - _LIBCPP_ASSERT(_Count <= size(), "Count out of range in span::last()"); + _LIBCPP_ASSERT(_Count <= size(), "span<T>::last<Count>(): Count out of range"); return span<element_type, _Count>{data() + size() - _Count, _Count}; } _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, dynamic_extent> first(size_type __count) const noexcept { - _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::first(count)"); + _LIBCPP_ASSERT(__count <= size(), "span<T>::first(count): count out of range"); return {data(), __count}; } _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, dynamic_extent> last (size_type __count) const noexcept { - _LIBCPP_ASSERT(__count <= size(), "Count out of range in span::last(count)"); + _LIBCPP_ASSERT(__count <= size(), "span<T>::last(count): count out of range"); return {data() + size() - __count, __count}; } @@ -524,8 +526,8 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr span<element_type, _Count> subspan() const noexcept { - _LIBCPP_ASSERT(_Offset <= size(), "Offset out of range in span::subspan()"); - _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "Offset + count out of range in span::subspan()"); + _LIBCPP_ASSERT(_Offset <= size(), "span<T>::subspan<Offset, Count>(): Offset out of range"); + _LIBCPP_ASSERT(_Count == dynamic_extent || _Count <= size() - _Offset, "span<T>::subspan<Offset, Count>(): Offset + Count out of range"); return span<element_type, _Count>{data() + _Offset, _Count == dynamic_extent ? size() - _Offset : _Count}; } @@ -533,11 +535,11 @@ public: _LIBCPP_INLINE_VISIBILITY subspan(size_type __offset, size_type __count = dynamic_extent) const noexcept { - _LIBCPP_ASSERT(__offset <= size(), "Offset out of range in span::subspan(offset, count)"); - _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "count out of range in span::subspan(offset, count)"); + _LIBCPP_ASSERT(__offset <= size(), "span<T>::subspan(offset, count): offset out of range"); + _LIBCPP_ASSERT(__count <= size() || __count == dynamic_extent, "span<T>::subspan(offset, count): count out of range"); if (__count == dynamic_extent) return {data() + __offset, size() - __offset}; - _LIBCPP_ASSERT(__count <= size() - __offset, "Offset + count out of range in span::subspan(offset, count)"); + _LIBCPP_ASSERT(__count <= size() - __offset, "span<T>::subspan(offset, count): offset + count out of range"); return {data() + __offset, __count}; } @@ -547,19 +549,19 @@ public: _LIBCPP_INLINE_VISIBILITY constexpr reference operator[](size_type __idx) const noexcept { - _LIBCPP_ASSERT(__idx < size(), "span<T>[] index out of bounds"); + _LIBCPP_ASSERT(__idx < size(), "span<T>::operator[](index): index out of range"); return __data[__idx]; } _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept { - _LIBCPP_ASSERT(!empty(), "span<T>[].front() on empty span"); + _LIBCPP_ASSERT(!empty(), "span<T>::front() on empty span"); return __data[0]; } _LIBCPP_INLINE_VISIBILITY constexpr reference back() const noexcept { - _LIBCPP_ASSERT(!empty(), "span<T>[].back() on empty span"); + _LIBCPP_ASSERT(!empty(), "span<T>::back() on empty span"); return __data[size()-1]; } @@ -568,15 +570,15 @@ public: // [span.iter], span iterator support _LIBCPP_INLINE_VISIBILITY constexpr iterator begin() const noexcept { -#ifdef _LIBCPP_SPAN_USE_POINTER_ITERATOR - return iterator(data()); +#ifdef _LIBCPP_ENABLE_DEBUG_MODE + return std::__make_bounded_iter(data(), data(), data() + size()); #else return iterator(this, data()); #endif } _LIBCPP_INLINE_VISIBILITY constexpr iterator end() const noexcept { -#ifdef _LIBCPP_SPAN_USE_POINTER_ITERATOR - return iterator(data() + size()); +#ifdef _LIBCPP_ENABLE_DEBUG_MODE + return std::__make_bounded_iter(data() + size(), data(), data() + size()); #else return iterator(this, data() + size()); #endif diff --git a/contrib/libs/cxxsupp/libcxx/include/stack b/contrib/libs/cxxsupp/libcxx/include/stack index 59878c1d84..86435c4559 100644 --- a/contrib/libs/cxxsupp/libcxx/include/stack +++ b/contrib/libs/cxxsupp/libcxx/include/stack @@ -107,6 +107,10 @@ template <class T, class Container> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +#endif + // standard-mandated includes #include <compare> #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string index 45708e376a..c600c6a039 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string +++ b/contrib/libs/cxxsupp/libcxx/include/string @@ -555,6 +555,16 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); # include <cwchar> #endif +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <functional> +# include <iterator> +# include <new> +# include <typeinfo> +# include <utility> +# include <vector> +#endif + // standard-mandated includes // [iterator.range] @@ -727,10 +737,16 @@ private: static const size_type __endian_factor = 2; #endif + // Attribute 'packed' is used to keep the layout compatible with the + // previous definition that did not use bit fields. This is because on + // some platforms bit fields have a default size rather than the actual + // size used, e.g., it is 4 bytes on AIX. See D128285 for details. struct __long { - size_type __is_long_ : 1; - size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; + struct _LIBCPP_PACKED { + size_type __is_long_ : 1; + size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1; + }; size_type __size_; pointer __data_; }; @@ -740,8 +756,10 @@ private: struct __short { - unsigned char __is_long_ : 1; - unsigned char __size_ : 7; + struct _LIBCPP_PACKED { + unsigned char __is_long_ : 1; + unsigned char __size_ : 7; + }; char __padding_[sizeof(value_type) - 1]; value_type __data_[__min_cap]; }; @@ -4580,15 +4598,13 @@ const typename basic_string<_CharT, _Traits, _Allocator>::size_type template <class _CharT, class _Allocator> struct _LIBCPP_TEMPLATE_VIS hash<basic_string<_CharT, char_traits<_CharT>, _Allocator> > - : public unary_function< - basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> + : public __unary_function<basic_string<_CharT, char_traits<_CharT>, _Allocator>, size_t> { size_t operator()(const basic_string<_CharT, char_traits<_CharT>, _Allocator>& __val) const _NOEXCEPT { return __do_string_hash(__val.data(), __val.data() + __val.size()); } }; - template<class _CharT, class _Traits, class _Allocator> basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, diff --git a/contrib/libs/cxxsupp/libcxx/include/string_view b/contrib/libs/cxxsupp/libcxx/include/string_view index 48882b9de2..2191fe9acf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/string_view +++ b/contrib/libs/cxxsupp/libcxx/include/string_view @@ -218,6 +218,12 @@ namespace std { #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] @@ -918,7 +924,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, // [string.view.hash] template<class _CharT> struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > > - : public unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> + : public __unary_function<basic_string_view<_CharT, char_traits<_CharT> >, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const basic_string_view<_CharT, char_traits<_CharT> > __val) const _NOEXCEPT { @@ -926,7 +932,6 @@ struct _LIBCPP_TEMPLATE_VIS hash<basic_string_view<_CharT, char_traits<_CharT> > } }; - #if _LIBCPP_STD_VER > 11 inline namespace literals { diff --git a/contrib/libs/cxxsupp/libcxx/include/strstream b/contrib/libs/cxxsupp/libcxx/include/strstream index 9ffdd9f84a..72386bb956 100644 --- a/contrib/libs/cxxsupp/libcxx/include/strstream +++ b/contrib/libs/cxxsupp/libcxx/include/strstream @@ -266,8 +266,8 @@ public: _LIBCPP_INLINE_VISIBILITY istrstream& operator=(istrstream&& __rhs) { - istream::operator=(_VSTD::move(__rhs)); __sb_ = _VSTD::move(__rhs.__sb_); + istream::operator=(_VSTD::move(__rhs)); return *this; } #endif // _LIBCPP_CXX03_LANG @@ -315,8 +315,8 @@ public: _LIBCPP_INLINE_VISIBILITY ostrstream& operator=(ostrstream&& __rhs) { - ostream::operator=(_VSTD::move(__rhs)); __sb_ = _VSTD::move(__rhs.__sb_); + ostream::operator=(_VSTD::move(__rhs)); return *this; } #endif // _LIBCPP_CXX03_LANG @@ -375,8 +375,8 @@ public: _LIBCPP_INLINE_VISIBILITY strstream& operator=(strstream&& __rhs) { - iostream::operator=(_VSTD::move(__rhs)); __sb_ = _VSTD::move(__rhs.__sb_); + iostream::operator=(_VSTD::move(__rhs)); return *this; } #endif // _LIBCPP_CXX03_LANG diff --git a/contrib/libs/cxxsupp/libcxx/include/system_error b/contrib/libs/cxxsupp/libcxx/include/system_error index d9fe8b211b..2db901847d 100644 --- a/contrib/libs/cxxsupp/libcxx/include/system_error +++ b/contrib/libs/cxxsupp/libcxx/include/system_error @@ -438,7 +438,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT template <> struct _LIBCPP_TEMPLATE_VIS hash<error_code> - : public unary_function<error_code, size_t> + : public __unary_function<error_code, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const error_code& __ec) const _NOEXCEPT @@ -449,7 +449,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<error_code> template <> struct _LIBCPP_TEMPLATE_VIS hash<error_condition> - : public unary_function<error_condition, size_t> + : public __unary_function<error_condition, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const error_condition& __ec) const _NOEXCEPT diff --git a/contrib/libs/cxxsupp/libcxx/include/thread b/contrib/libs/cxxsupp/libcxx/include/thread index b4f782455e..1c8eb19898 100644 --- a/contrib/libs/cxxsupp/libcxx/include/thread +++ b/contrib/libs/cxxsupp/libcxx/include/thread @@ -98,6 +98,11 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time); #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <chrono> +# include <functional> +#endif + // standard-mandated includes #include <compare> @@ -201,7 +206,7 @@ __thread_specific_ptr<_Tp>::set_pointer(pointer __p) template<> struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> - : public unary_function<__thread_id, size_t> + : public __unary_function<__thread_id, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(__thread_id __v) const _NOEXCEPT diff --git a/contrib/libs/cxxsupp/libcxx/include/tuple b/contrib/libs/cxxsupp/libcxx/include/tuple index 27a422cb2b..2837342ecb 100644 --- a/contrib/libs/cxxsupp/libcxx/include/tuple +++ b/contrib/libs/cxxsupp/libcxx/include/tuple @@ -219,6 +219,14 @@ template <class... Types> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <exception> +# include <iosfwd> +# include <new> +# include <typeinfo> +# include <utility> +#endif + // standard-mandated includes #include <compare> diff --git a/contrib/libs/cxxsupp/libcxx/include/type_traits b/contrib/libs/cxxsupp/libcxx/include/type_traits index b2be2f6130..2d160e4e29 100644 --- a/contrib/libs/cxxsupp/libcxx/include/type_traits +++ b/contrib/libs/cxxsupp/libcxx/include/type_traits @@ -517,6 +517,7 @@ namespace std #include <__type_traits/void_t.h> #include <__utility/declval.h> #include <cstddef> +#include <cstdint> #include <version> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -534,36 +535,6 @@ template <bool _Cond, class _Ret = void> using __lazy_enable_if _LIBCPP_NODEBUG = __enable_if_t<_Cond, _Ret>; #endif -template <bool> struct _MetaBase; -template <> -struct _MetaBase<true> { - template <template <class...> class _FirstFn, template <class...> class, class ..._Args> - using _SelectApplyImpl _LIBCPP_NODEBUG = _FirstFn<_Args...>; - template <class _First, class...> - using _FirstImpl _LIBCPP_NODEBUG = _First; - template <class, class _Second, class...> - using _SecondImpl _LIBCPP_NODEBUG = _Second; -}; - -template <> -struct _MetaBase<false> { - template <template <class...> class, template <class...> class _SecondFn, class ..._Args> - using _SelectApplyImpl _LIBCPP_NODEBUG = _SecondFn<_Args...>; -}; - -// Workaround for MSVC. Sometimes compiler thinks that sizeof...(Type) is parameter pack rather than the number. -// So it doesn't allow sizeof...(Type) in expression that goes into the boolean template parameter of _MetaBase. -// This simple wrapper allows us to hide sizeof... from the compiler. -template<class... _Pack> -struct _Sizeof { - static constexpr size_t value = sizeof...(_Pack); -}; - -template <class ..._Args> -using _FirstType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 1)>::template _FirstImpl<_Args...>; -template <class ..._Args> -using _SecondType _LIBCPP_NODEBUG = typename _MetaBase<(sizeof...(_Args) >= 2)>::template _SecondImpl<_Args...>; - template <template <class...> class _Func, class ..._Args> struct _Lazy : _Func<_Args...> {}; @@ -582,6 +553,14 @@ struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {}; // is_same +// Workaround for MSVC. Sometimes compiler thinks that sizeof...(Type) is parameter pack rather than the number. +// So it doesn't allow sizeof...(Type) in expression that goes into the boolean template parameter of _MetaBase. +// This simple wrapper allows us to hide sizeof... from the compiler. +template<class... _Pack> +struct _Sizeof { + static constexpr size_t value = sizeof...(_Pack); +}; + template <class _Tp> using __test_for_primary_template = __enable_if_t< _IsSame<_Tp, typename _Tp::__primary_template>::value @@ -1016,6 +995,29 @@ typename make_unsigned<_Tp>::type __to_unsigned_like(_Tp __x) noexcept { } #endif +template <class _Tp, class _Up> +using __copy_unsigned_t = __conditional_t<is_unsigned<_Tp>::value, typename make_unsigned<_Up>::type, _Up>; + +/// Helper to promote an integral to smallest 32, 64, or 128 bit representation. +/// +/// The restriction is the same as the integral version of to_char. +template <class _Tp> +#if _LIBCPP_STD_VER > 17 + requires (is_signed_v<_Tp> || is_unsigned_v<_Tp> || is_same_v<_Tp, char>) +#endif +using __make_32_64_or_128_bit_t = + __copy_unsigned_t<_Tp, + __conditional_t<sizeof(_Tp) <= sizeof(int32_t), int32_t, + __conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t, +#ifndef _LIBCPP_HAS_NO_INT128 + __conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t, + /* else */ void> +#else + /* else */ void +#endif + > > + >; + #if _LIBCPP_STD_VER > 17 // Let COND_RES(X, Y) be: template <class _Tp, class _Up> @@ -1363,91 +1365,12 @@ struct __is_implicitly_default_constructible<_Tp, decltype(__test_implicit_defau #if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) template <class _Callable> class _LIBCPP_DEPRECATED_IN_CXX17 result_of; -#ifndef _LIBCPP_CXX03_LANG - template <class _Fp, class ..._Args> class _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> { }; -#else // C++03 - -template <class _Fn, bool, bool> -class __result_of -{ -}; - -template <class _Fn, class ..._Args> -class __result_of<_Fn(_Args...), true, false> -{ -public: - typedef decltype(declval<_Fn>()(declval<_Args>()...)) type; -}; - -template <class _MP, class _Tp, bool _IsMemberFunctionPtr> -struct __result_of_mp; - -// member function pointer - -template <class _MP, class _Tp> -struct __result_of_mp<_MP, _Tp, true> -{ - using type = typename __member_pointer_traits<_MP>::_ReturnType; -}; - -// member data pointer - -template <class _MP, class _Tp, bool> -struct __result_of_mdp; - -template <class _Rp, class _Class, class _Tp> -struct __result_of_mdp<_Rp _Class::*, _Tp, false> -{ - using type = typename __apply_cv<decltype(*declval<_Tp>()), _Rp>::type&; -}; - -template <class _Rp, class _Class, class _Tp> -struct __result_of_mdp<_Rp _Class::*, _Tp, true> -{ - using type = typename __apply_cv<_Tp, _Rp>::type&; -}; - -template <class _Rp, class _Class, class _Tp> -struct __result_of_mp<_Rp _Class::*, _Tp, false> - : public __result_of_mdp<_Rp _Class::*, _Tp, - is_base_of<_Class, typename remove_reference<_Tp>::type>::value> -{ -}; - -template <class _Fn, class _Tp> -class __result_of<_Fn(_Tp), false, true> // _Fn must be member pointer - : public __result_of_mp<typename remove_reference<_Fn>::type, - _Tp, - is_member_function_pointer<typename remove_reference<_Fn>::type>::value> -{ -}; - -template <class _Fn, class _Tp, class ..._Args> -class __result_of<_Fn(_Tp, _Args...), false, true> // _Fn must be member pointer - : public __result_of_mp<typename remove_reference<_Fn>::type, - _Tp, - is_member_function_pointer<typename remove_reference<_Fn>::type>::value> -{ -}; - -template <class _Fn, class ..._Args> -class _LIBCPP_TEMPLATE_VIS result_of<_Fn(_Args...)> - : public __result_of<_Fn(_Args...), - is_class<typename remove_reference<_Fn>::type>::value || - is_function<typename remove_pointer<typename remove_reference<_Fn>::type>::type>::value, - is_member_pointer<typename remove_reference<_Fn>::type>::value - > -{ -}; - -#endif // C++03 - #if _LIBCPP_STD_VER > 11 template <class _Tp> using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type; #endif // _LIBCPP_STD_VER > 11 diff --git a/contrib/libs/cxxsupp/libcxx/include/typeindex b/contrib/libs/cxxsupp/libcxx/include/typeindex index 416e48b8d3..5fb7b30ecf 100644 --- a/contrib/libs/cxxsupp/libcxx/include/typeindex +++ b/contrib/libs/cxxsupp/libcxx/include/typeindex @@ -50,6 +50,12 @@ struct hash<type_index> #include <typeinfo> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iosfwd> +# include <new> +# include <utility> +#endif + // standard-mandated includes #include <compare> @@ -95,7 +101,7 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; template <> struct _LIBCPP_TEMPLATE_VIS hash<type_index> - : public unary_function<type_index, size_t> + : public __unary_function<type_index, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(type_index __index) const _NOEXCEPT diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_map b/contrib/libs/cxxsupp/libcxx/include/unordered_map index 12b4e5af63..72749e11e8 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_map +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_map @@ -531,6 +531,12 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <tuple> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <bit> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/unordered_set b/contrib/libs/cxxsupp/libcxx/include/unordered_set index 3fc686c8d3..97aa935f18 100644 --- a/contrib/libs/cxxsupp/libcxx/include/unordered_set +++ b/contrib/libs/cxxsupp/libcxx/include/unordered_set @@ -474,6 +474,11 @@ template <class Value, class Hash, class Pred, class Alloc> #include <__utility/forward.h> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <functional> +# include <iterator> +#endif + // standard-mandated includes // [iterator.range] diff --git a/contrib/libs/cxxsupp/libcxx/include/utility b/contrib/libs/cxxsupp/libcxx/include/utility index fc7909aef1..7a1a45e334 100644 --- a/contrib/libs/cxxsupp/libcxx/include/utility +++ b/contrib/libs/cxxsupp/libcxx/include/utility @@ -243,6 +243,10 @@ template <class T> #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <iosfwd> +#endif + // standard-mandated includes #include <compare> #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/valarray b/contrib/libs/cxxsupp/libcxx/include/valarray index 48262b7281..4f7a61065c 100644 --- a/contrib/libs/cxxsupp/libcxx/include/valarray +++ b/contrib/libs/cxxsupp/libcxx/include/valarray @@ -360,6 +360,11 @@ template <class T> unspecified2 end(const valarray<T>& v); #include <new> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <functional> +#endif + // standard-mandated includes #include <initializer_list> diff --git a/contrib/libs/cxxsupp/libcxx/include/variant b/contrib/libs/cxxsupp/libcxx/include/variant index 316a1c3329..02a223fb08 100644 --- a/contrib/libs/cxxsupp/libcxx/include/variant +++ b/contrib/libs/cxxsupp/libcxx/include/variant @@ -219,6 +219,11 @@ namespace std { #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <typeinfo> +# include <utility> +#endif + // standard-mandated includes #include <compare> diff --git a/contrib/libs/cxxsupp/libcxx/include/vector b/contrib/libs/cxxsupp/libcxx/include/vector index 940443b8d7..2146a21a2a 100644 --- a/contrib/libs/cxxsupp/libcxx/include/vector +++ b/contrib/libs/cxxsupp/libcxx/include/vector @@ -305,6 +305,12 @@ erase_if(vector<T, Allocator>& c, Predicate pred); // C++20 #include <type_traits> #include <version> +#ifndef _LIBCPP_REMOVE_TRANSITIVE_INCLUDES +# include <algorithm> +# include <typeinfo> +# include <utility> +#endif + // standard-mandated includes // [iterator.range] @@ -3210,7 +3216,7 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT template <class _Allocator> struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> > - : public unary_function<vector<bool, _Allocator>, size_t> + : public __unary_function<vector<bool, _Allocator>, size_t> { _LIBCPP_INLINE_VISIBILITY size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT diff --git a/contrib/libs/cxxsupp/libcxx/include/version b/contrib/libs/cxxsupp/libcxx/include/version index 217d1a0148..ec27c5ed25 100644 --- a/contrib/libs/cxxsupp/libcxx/include/version +++ b/contrib/libs/cxxsupp/libcxx/include/version @@ -251,7 +251,9 @@ __cpp_lib_void_t 201411L <type_traits> # define __cpp_lib_filesystem 201703L # endif # define __cpp_lib_gcd_lcm 201606L -// # define __cpp_lib_hardware_interference_size 201703L +# if defined(__GCC_DESTRUCTIVE_SIZE) && defined(__GCC_CONSTRUCTIVE_SIZE) +# define __cpp_lib_hardware_interference_size 201703L +# endif # define __cpp_lib_has_unique_object_representations 201606L # define __cpp_lib_hypot 201603L # define __cpp_lib_incomplete_container_elements 201505L diff --git a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp index 63da85b093..4cccbab59d 100644 --- a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp @@ -21,13 +21,13 @@ namespace __itoa _LIBCPP_FUNC_VIS char* __u32toa(uint32_t value, char* buffer) noexcept { - return __base_10_u32(value, buffer); + return __base_10_u32(buffer, value); } _LIBCPP_FUNC_VIS char* __u64toa(uint64_t value, char* buffer) noexcept { - return __base_10_u64(value, buffer); + return __base_10_u64(buffer, value); } } // namespace __itoa diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp index 8615901034..38319e32f5 100644 --- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp +++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp @@ -1834,6 +1834,7 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept // 040000 - 0FFFFF D8C0 - DBBF, DC00 - DFFF F1 - F3, 80 - BF, 80 - BF, 80 - BF 786432 // 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 65536 +_LIBCPP_SUPPRESS_DEPRECATED_PUSH static codecvt_base::result utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt, @@ -3207,6 +3208,8 @@ utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end, return static_cast<int>(frm_nxt - frm); } +_LIBCPP_SUPPRESS_DEPRECATED_POP + // template <> class codecvt<char16_t, char, mbstate_t> locale::id codecvt<char16_t, char, mbstate_t>::id; @@ -3614,6 +3617,7 @@ __codecvt_utf8<wchar_t>::do_length(state_type&, #endif } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8<wchar_t>::do_max_length() const noexcept { @@ -3696,6 +3700,7 @@ __codecvt_utf8<char16_t>::do_length(state_type&, return utf8_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8<char16_t>::do_max_length() const noexcept { @@ -3703,6 +3708,7 @@ __codecvt_utf8<char16_t>::do_max_length() const noexcept return 6; return 3; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf8<char32_t> @@ -3771,6 +3777,7 @@ __codecvt_utf8<char32_t>::do_length(state_type&, return utf8_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8<char32_t>::do_max_length() const noexcept { @@ -3778,6 +3785,7 @@ __codecvt_utf8<char32_t>::do_max_length() const noexcept return 7; return 4; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf16<wchar_t, false> @@ -4056,6 +4064,7 @@ __codecvt_utf16<char16_t, false>::do_length(state_type&, return utf16be_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char16_t, false>::do_max_length() const noexcept { @@ -4063,6 +4072,7 @@ __codecvt_utf16<char16_t, false>::do_max_length() const noexcept return 4; return 2; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf16<char16_t, true> @@ -4131,6 +4141,7 @@ __codecvt_utf16<char16_t, true>::do_length(state_type&, return utf16le_to_ucs2_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char16_t, true>::do_max_length() const noexcept { @@ -4138,6 +4149,7 @@ __codecvt_utf16<char16_t, true>::do_max_length() const noexcept return 4; return 2; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf16<char32_t, false> @@ -4206,6 +4218,7 @@ __codecvt_utf16<char32_t, false>::do_length(state_type&, return utf16be_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char32_t, false>::do_max_length() const noexcept { @@ -4213,6 +4226,7 @@ __codecvt_utf16<char32_t, false>::do_max_length() const noexcept return 6; return 4; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf16<char32_t, true> @@ -4292,6 +4306,7 @@ __codecvt_utf16<char32_t, true>::do_length(state_type&, return utf16le_to_ucs4_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf16<char32_t, true>::do_max_length() const noexcept { @@ -4299,6 +4314,7 @@ __codecvt_utf16<char32_t, true>::do_max_length() const noexcept return 6; return 4; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf8_utf16<wchar_t> @@ -4456,6 +4472,7 @@ __codecvt_utf8_utf16<char16_t>::do_length(state_type&, return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept { @@ -4463,6 +4480,7 @@ __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept return 7; return 4; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __codecvt_utf8_utf16<char32_t> @@ -4537,6 +4555,7 @@ __codecvt_utf8_utf16<char32_t>::do_length(state_type&, return utf8_to_utf16_length(_frm, _frm_end, mx, _Maxcode_, _Mode_); } +_LIBCPP_SUPPRESS_DEPRECATED_PUSH int __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept { @@ -4544,6 +4563,7 @@ __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept return 7; return 4; } +_LIBCPP_SUPPRESS_DEPRECATED_POP // __narrow_to_utf8<16> diff --git a/contrib/libs/cxxsupp/libcxx/ya.make b/contrib/libs/cxxsupp/libcxx/ya.make index ee3fe7bcea..d45c200f79 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-06-18) +VERSION(2022-07-01) -ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/3766992291fde4b7f5d1ba45be9969e6ad5c6cf1.tar.gz) +ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/da1609ad73540978f66111e96ea500b97ca9b39a.tar.gz) ADDINCL( GLOBAL contrib/libs/cxxsupp/libcxx/include |