aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2023-10-14 13:00:57 +0300
committermikhnenko <mikhnenko@yandex-team.com>2023-10-14 13:22:30 +0300
commit4371a757495f375ca7c5b1730f4e9f741a71ec40 (patch)
treebe8f3405e7b0534d29bfb8eec493c0dbe108adc5 /contrib/libs/cxxsupp/libcxx/include/__algorithm
parentecb10029a72bb21f92858ff3c0d76c8f255cf4ba (diff)
downloadydb-4371a757495f375ca7c5b1730f4e9f741a71ec40.tar.gz
Update libc++ to 1 May 2022 639b9618f46d75f4dabd2082b3f6ba8433c287bf
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h100
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h64
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h48
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h118
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h65
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h67
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h81
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h76
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h128
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h72
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_iter.h4
11 files changed, 650 insertions, 173 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h
index b4045cd06a..00587ecb5b 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy.h
@@ -12,6 +12,9 @@
#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,74 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// copy
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- for (; __first != __last; ++__first, (void) ++__result)
- *__result = *__first;
- return __result;
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter> __copy_impl(_InIter __first, _Sent __last, _OutIter __result) {
+ while (__first != __last) {
+ *__result = *__first;
+ ++__first;
+ ++__result;
+ }
+ return pair<_InIter, _OutIter>(std::move(__first), std::move(__result));
}
-template <class _InputIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- return _VSTD::__copy_constexpr(__first, __last, __result);
+template <class _InValueT,
+ class _OutValueT,
+ class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
+ && is_trivially_copy_assignable<_OutValueT>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InValueT*, _OutValueT*> __copy_impl(_InValueT* __first, _InValueT* __last, _OutValueT* __result) {
+ if (__libcpp_is_constant_evaluated()
+// TODO: Remove this once GCC supports __builtin_memmove during constant evaluation
+#ifndef _LIBCPP_COMPILER_GCC
+ && !is_trivially_copyable<_InValueT>::value
+#endif
+ )
+ return std::__copy_impl<_InValueT*, _InValueT*, _OutValueT*>(__first, __last, __result);
+ const size_t __n = static_cast<size_t>(__last - __first);
+ if (__n > 0)
+ ::__builtin_memmove(__result, __first, __n * sizeof(_OutValueT));
+ return std::make_pair(__first + __n, __result + __n);
+}
+
+template <class _InValueT,
+ class _OutValueT,
+ class = __enable_if_t<is_same<typename remove_const<_InValueT>::type, _OutValueT>::value
+ && is_trivially_copy_assignable<_OutValueT>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<reverse_iterator<_InValueT*>, reverse_iterator<_OutValueT*> >
+__copy_impl(reverse_iterator<_InValueT*> __first,
+ reverse_iterator<_InValueT*> __last,
+ reverse_iterator<_OutValueT*> __result) {
+ auto __first_base = __first.base();
+ auto __last_base = __last.base();
+ auto __result_base = __result.base();
+ auto __result_first = __result_base - (__first_base - __last_base);
+ std::__copy_impl(__last_base, __first_base, __result_first);
+ return std::make_pair(__last, reverse_iterator<_OutValueT*>(__result_first));
+}
+
+template <class _InIter, class _Sent, class _OutIter>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
+ return std::__copy_impl(std::move(__first), std::move(__last), std::move(__result));
}
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__copy(_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 _InIter, class _Sent, class _OutIter,
+ __enable_if_t<is_copy_constructible<_InIter>::value
+ && is_copy_constructible<_Sent>::value
+ && is_copy_constructible<_OutIter>::value> >
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_InIter, _OutIter> __copy(_InIter __first, _Sent __last, _OutIter __result) {
+ auto __ret = std::__copy_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 _InputIterator, class _OutputIterator>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
-copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_constexpr(__first, __last, __result);
- } else {
- return _VSTD::__rewrap_iter(__result,
- _VSTD::__copy(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
- }
+copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
+ return std::__copy(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h
index 9754f0c95b..dd43a91ffa 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_backward.h
@@ -9,9 +9,11 @@
#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H
#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
+#include <__algorithm/copy.h>
#include <__algorithm/unwrap_iter.h>
#include <__config>
#include <__iterator/iterator_traits.h>
+#include <__iterator/reverse_iterator.h>
#include <cstring>
#include <type_traits>
@@ -21,57 +23,29 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_OutputIterator
-__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- while (__first != __last)
- *--__result = *--__last;
- return __result;
+template <class _Iter1, class _Sent1, class _Iter2>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter2> __copy_backward_impl(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
+ auto __ret = std::__copy(reverse_iterator<_Iter1>(__last),
+ reverse_iterator<_Sent1>(__first),
+ reverse_iterator<_Iter2>(__result));
+ return pair<_Iter1, _Iter2>(__ret.first.base(), __ret.second.base());
}
-template <class _BidirectionalIterator, class _OutputIterator>
-inline _LIBCPP_INLINE_VISIBILITY
-_OutputIterator
-__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result)
-{
- return _VSTD::__copy_backward_constexpr(__first, __last, __result);
-}
-
-template <class _Tp, class _Up>
-inline _LIBCPP_INLINE_VISIBILITY
-typename enable_if
-<
- is_same<typename remove_const<_Tp>::type, _Up>::value &&
- is_trivially_copy_assignable<_Up>::value,
- _Up*
->::type
-__copy_backward(_Tp* __first, _Tp* __last, _Up* __result)
-{
- const size_t __n = static_cast<size_t>(__last - __first);
- if (__n > 0)
- {
- __result -= __n;
- _VSTD::memmove(__result, __first, __n * sizeof(_Up));
- }
- return __result;
+template <class _Iter1, class _Sent1, class _Iter2>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter1, _Iter2> __copy_backward(_Iter1 __first, _Sent1 __last, _Iter2 __result) {
+ auto __ret = std::__copy_backward_impl(std::__unwrap_iter(__first),
+ std::__unwrap_iter(__last),
+ std::__unwrap_iter(__result));
+ return pair<_Iter1, _Iter2>(std::__rewrap_iter(__first, __ret.first), std::__rewrap_iter(__result, __ret.second));
}
template <class _BidirectionalIterator1, class _BidirectionalIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
_BidirectionalIterator2
-copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last,
- _BidirectionalIterator2 __result)
-{
- if (__libcpp_is_constant_evaluated()) {
- return _VSTD::__copy_backward_constexpr(__first, __last, __result);
- } else {
- return _VSTD::__rewrap_iter(__result,
- _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first),
- _VSTD::__unwrap_iter(__last),
- _VSTD::__unwrap_iter(__result)));
- }
+copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
+ return std::__copy_backward(__first, __last, __result).second;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h
index 30a119491a..7e10b8b835 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax.h
@@ -10,7 +10,10 @@
#define _LIBCPP___ALGORITHM_MINMAX_H
#include <__algorithm/comp.h>
+#include <__algorithm/minmax_element.h>
#include <__config>
+#include <__functional/identity.h>
+#include <__type_traits/is_callable.h>
#include <__utility/pair.h>
#include <initializer_list>
@@ -36,47 +39,18 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b)
{
- return _VSTD::minmax(__a, __b, __less<_Tp>());
+ return std::minmax(__a, __b, __less<_Tp>());
}
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_Tp, _Tp>
-minmax(initializer_list<_Tp> __t, _Compare __comp)
-{
- typedef typename initializer_list<_Tp>::const_iterator _Iter;
- _Iter __first = __t.begin();
- _Iter __last = __t.end();
- pair<_Tp, _Tp> __result(*__first, *__first);
-
- ++__first;
- if (__t.size() % 2 == 0)
- {
- if (__comp(*__first, __result.first))
- __result.first = *__first;
- else
- __result.second = *__first;
- ++__first;
- }
-
- while (__first != __last)
- {
- _Tp __prev = *__first++;
- if (__comp(*__first, __prev)) {
- if ( __comp(*__first, __result.first)) __result.first = *__first;
- if (!__comp(__prev, __result.second)) __result.second = __prev;
- }
- else {
- if ( __comp(__prev, __result.first)) __result.first = __prev;
- if (!__comp(*__first, __result.second)) __result.second = *__first;
- }
-
- __first++;
- }
- return __result;
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Tp, _Tp> minmax(initializer_list<_Tp> __t, _Compare __comp) {
+ static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
+ __identity __proj;
+ auto __ret = std::__minmax_element_impl(__t.begin(), __t.end(), __comp, __proj);
+ return pair<_Tp, _Tp>(*__ret.first, *__ret.second);
}
template<class _Tp>
@@ -85,7 +59,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t)
{
- return _VSTD::minmax(__t, __less<_Tp>());
+ return std::minmax(__t, __less<_Tp>());
}
#endif // _LIBCPP_CXX03_LANG
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h
index 80afbdf87a..fe5f20bf1c 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/minmax_element.h
@@ -11,8 +11,10 @@
#include <__algorithm/comp.h>
#include <__config>
+#include <__functional/identity.h>
#include <__iterator/iterator_traits.h>
#include <__utility/pair.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,64 +22,78 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+template <class _Comp, class _Proj>
+class _MinmaxElementLessFunc {
+ _Comp& __comp;
+ _Proj& __proj;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
+ _MinmaxElementLessFunc(_Comp& __comp_, _Proj& __proj_) : __comp(__comp_), __proj(__proj_) {}
+
+ template <class _Iter>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ bool operator()(_Iter& __it1, _Iter& __it2) {
+ return std::__invoke(__comp, std::__invoke(__proj, *__it1), std::__invoke(__proj, *__it2));
+ }
+};
+
+template <class _Iter, class _Sent, class _Proj, class _Comp>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_Iter, _Iter> __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
+ auto __less = _MinmaxElementLessFunc<_Comp, _Proj>(__comp, __proj);
+
+ pair<_Iter, _Iter> __result(__first, __first);
+ if (__first == __last || ++__first == __last)
+ return __result;
+
+ if (__less(__first, __result.first))
+ __result.first = __first;
+ else
+ __result.second = __first;
+
+ while (++__first != __last) {
+ _Iter __i = __first;
+ if (++__first == __last) {
+ if (__less(__i, __result.first))
+ __result.first = __i;
+ else if (!__less(__i, __result.second))
+ __result.second = __i;
+ return __result;
+ }
+
+ if (__less(__first, __i)) {
+ if (__less(__first, __result.first))
+ __result.first = __first;
+ if (!__less(__i, __result.second))
+ __result.second = __i;
+ } else {
+ if (__less(__i, __result.first))
+ __result.first = __i;
+ if (!__less(__first, __result.second))
+ __result.second = __first;
+ }
+ }
+
+ return __result;
+}
+
template <class _ForwardIterator, class _Compare>
_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_ForwardIterator, _ForwardIterator>
-minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
-{
+minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
- "std::minmax_element requires a ForwardIterator");
- pair<_ForwardIterator, _ForwardIterator> __result(__first, __first);
- if (__first != __last)
- {
- if (++__first != __last)
- {
- if (__comp(*__first, *__result.first))
- __result.first = __first;
- else
- __result.second = __first;
- while (++__first != __last)
- {
- _ForwardIterator __i = __first;
- if (++__first == __last)
- {
- if (__comp(*__i, *__result.first))
- __result.first = __i;
- else if (!__comp(*__i, *__result.second))
- __result.second = __i;
- break;
- }
- else
- {
- if (__comp(*__first, *__i))
- {
- if (__comp(*__first, *__result.first))
- __result.first = __first;
- if (!__comp(*__i, *__result.second))
- __result.second = __i;
- }
- else
- {
- if (__comp(*__i, *__result.first))
- __result.first = __i;
- if (!__comp(*__first, *__result.second))
- __result.second = __first;
- }
- }
- }
- }
- }
- return __result;
+ "std::minmax_element requires a ForwardIterator");
+ static_assert(__is_callable<_Compare, decltype(*__first), decltype(*__first)>::value,
+ "The comparator has to be callable");
+ auto __proj = __identity();
+ return std::__minmax_element_impl(__first, __last, __comp, __proj);
}
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-pair<_ForwardIterator, _ForwardIterator>
-minmax_element(_ForwardIterator __first, _ForwardIterator __last)
-{
- return _VSTD::minmax_element(__first, __last,
- __less<typename iterator_traits<_ForwardIterator>::value_type>());
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+pair<_ForwardIterator, _ForwardIterator> minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
+ return std::minmax_element(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h
new file mode 100644
index 0000000000..f5d6d5cd13
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_COPY_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/in_out_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/concepts.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 copy_result = in_out_result<_InIter, _OutIter>;
+
+namespace __copy {
+struct __fn {
+
+ template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
+ requires indirectly_copyable<_InIter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_result<_InIter, _OutIter> operator()(_InIter __first, _Sent __last, _OutIter __result) const {
+ auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_result<borrowed_iterator_t<_Range>, _OutIter> operator()(_Range&& __r, _OutIter __result) const {
+ auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+} // namespace __copy
+
+inline namespace __cpo {
+ inline constexpr auto copy = __copy::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h
new file mode 100644
index 0000000000..49c1b26add
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_COPY_BACKWARD_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_BACKWARD_H
+
+#include <__algorithm/copy_backward.h>
+#include <__algorithm/in_out_result.h>
+#include <__config>
+#include <__iterator/concepts.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 _Ip, class _Op>
+using copy_backward_result = in_out_result<_Ip, _Op>;
+
+namespace __copy_backward {
+struct __fn {
+
+ template <bidirectional_iterator _InIter1, sentinel_for<_InIter1> _Sent1, bidirectional_iterator _InIter2>
+ requires indirectly_copyable<_InIter1, _InIter2>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_backward_result<_InIter1, _InIter2> operator()(_InIter1 __first, _Sent1 __last, _InIter2 __result) const {
+ auto __ret = std::__copy_backward(std::move(__first), std::move(__last), std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+
+ template <bidirectional_range _Range, bidirectional_iterator _Iter>
+ requires indirectly_copyable<iterator_t<_Range>, _Iter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_backward_result<borrowed_iterator_t<_Range>, _Iter> operator()(_Range&& __r, _Iter __result) const {
+ auto __ret = std::__copy_backward(ranges::begin(__r),
+ ranges::end(__r),
+ std::move(__result));
+ return {std::move(__ret.first), std::move(__ret.second)};
+ }
+};
+} // namespace __copy_backward
+
+inline namespace __cpo {
+ inline constexpr auto copy_backward = __copy_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_COPY_BACKWARD_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h
new file mode 100644
index 0000000000..492104fbbf
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_COPY_IF_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
+
+#include <__algorithm/in_out_result.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace ranges {
+
+template<class _Ip, class _Op>
+using copy_if_result = in_out_result<_Ip, _Op>;
+
+namespace __copy_if {
+struct __fn {
+
+ template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
+ _LIBCPP_HIDE_FROM_ABI static constexpr
+ copy_if_result <_InIter, _OutIter>
+ __copy_if_impl(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
+ for (; __first != __last; ++__first) {
+ if (std::invoke(__pred, std::invoke(__proj, *__first))) {
+ *__result = *__first;
+ ++__result;
+ }
+ }
+ return {std::move(__first), std::move(__result)};
+ }
+
+ template <input_iterator _Iter, sentinel_for<_Iter> _Sent, weakly_incrementable _OutIter, class _Proj = identity,
+ indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
+ requires indirectly_copyable<_Iter, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_if_result<_Iter, _OutIter>
+ operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return __copy_if_impl(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
+ }
+
+ template <input_range _Range, weakly_incrementable _OutIter, class _Proj = identity,
+ indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
+ requires indirectly_copyable<iterator_t<_Range>, _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
+ operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
+ return __copy_if_impl(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
+ }
+};
+} // namespace __copy_if
+
+inline namespace __cpo {
+ inline constexpr auto copy_if = __copy_if::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_IF_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h
new file mode 100644
index 0000000000..eaa05c9546
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___ALGORITHM_RANGES_COPY_N_H
+#define _LIBCPP___ALGORITHM_RANGES_COPY_N_H
+
+#include <__algorithm/copy.h>
+#include <__algorithm/in_out_result.h>
+#include <__algorithm/ranges_copy.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/unreachable_sentinel.h>
+#include <__iterator/wrap_iter.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+namespace ranges {
+
+template <class _Ip, class _Op>
+using copy_n_result = in_out_result<_Ip, _Op>;
+
+namespace __copy_n {
+struct __fn {
+
+ template <class _InIter, class _DiffType, class _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
+ while (__n != 0) {
+ *__result = *__first;
+ ++__first;
+ ++__result;
+ --__n;
+ }
+ return {std::move(__first), std::move(__result)};
+ }
+
+ template <random_access_iterator _InIter, class _DiffType, random_access_iterator _OutIter>
+ _LIBCPP_HIDE_FROM_ABI constexpr static
+ copy_n_result<_InIter, _OutIter> __go(_InIter __first, _DiffType __n, _OutIter __result) {
+ auto __ret = std::__copy(__first, __first + __n, __result);
+ return {__ret.first, __ret.second};
+ }
+
+ template <input_iterator _Ip, weakly_incrementable _Op>
+ requires indirectly_copyable<_Ip, _Op>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ copy_n_result<_Ip, _Op> operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const {
+ return __go(std::move(__first), __n, std::move(__result));
+ }
+};
+} // namespace __copy_n
+
+inline namespace __cpo {
+ inline constexpr auto copy_n = __copy_n::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+#endif // _LIBCPP_STD_VER > 17 && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___ALGORITHM_RANGES_COPY_N_H
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h
new file mode 100644
index 0000000000..c9f49f676c
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MINMAX_H
+#define _LIBCPP___ALGORITHM_RANGES_MINMAX_H
+
+#include <__algorithm/min_max_result.h>
+#include <__algorithm/minmax_element.h>
+#include <__assert>
+#include <__concepts/copyable.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <initializer_list>
+
+#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 _T1>
+using minmax_result = min_max_result<_T1>;
+
+namespace __minmax {
+struct __fn {
+ template <class _Type, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
+ operator()(const _Type& __a, const _Type& __b, _Comp __comp = {}, _Proj __proj = {}) const {
+ if (std::invoke(__comp, std::invoke(__proj, __b), std::invoke(__proj, __a)))
+ return {__b, __a};
+ return {__a, __b};
+ }
+
+ template <copyable _Type, class _Proj = identity,
+ indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_result<_Type> operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
+ _LIBCPP_ASSERT(__il.begin() != __il.end(), "initializer_list has to contain at least one element");
+ auto __iters = std::__minmax_element_impl(__il.begin(), __il.end(), __comp, __proj);
+ return ranges::minmax_result<_Type> { *__iters.first, *__iters.second };
+ }
+
+ template <input_range _Range, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
+ requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_result<range_value_t<_Range>> operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __first = ranges::begin(__r);
+ auto __last = ranges::end(__r);
+ using _ValueT = range_value_t<_Range>;
+
+ _LIBCPP_ASSERT(__first != __last, "range has to contain at least one element");
+
+ if constexpr (forward_range<_Range>) {
+ auto __result = std::__minmax_element_impl(__first, __last, __comp, __proj);
+ return {*__result.first, *__result.second};
+ } else {
+ // input_iterators can't be copied, so the implementation for input_iterators has to store
+ // the values instead of a pointer to the correct values
+ auto __less = [&](auto&& __a, auto&& __b) -> bool {
+ return std::invoke(__comp, std::invoke(__proj, std::forward<decltype(__a)>(__a)),
+ std::invoke(__proj, std::forward<decltype(__b)>(__b)));
+ };
+
+ ranges::minmax_result<_ValueT> __result = {*__first, __result.min};
+ if (__first == __last || ++__first == __last)
+ return __result;
+
+ if (__less(*__first, __result.min))
+ __result.min = *__first;
+ else
+ __result.max = *__first;
+
+ while (++__first != __last) {
+ _ValueT __i = *__first;
+ if (++__first == __last) {
+ if (__less(__i, __result.min))
+ __result.min = __i;
+ else if (!__less(__i, __result.max))
+ __result.max = __i;
+ return __result;
+ }
+
+ if (__less(*__first, __i)) {
+ if (__less(*__first, __result.min))
+ __result.min = *__first;
+ if (!__less(__i, __result.max))
+ __result.max = std::move(__i);
+ } else {
+ if (__less(__i, __result.min))
+ __result.min = std::move(__i);
+ if (!__less(*__first, __result.max))
+ __result.max = *__first;
+ }
+ }
+ return __result;
+ }
+ }
+};
+} // namespace __minmax
+
+inline namespace __cpo {
+ inline constexpr auto minmax = __minmax::__fn{};
+} // namespace __cpo
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#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_minmax_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h
new file mode 100644
index 0000000000..b7bb26cefe
--- /dev/null
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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_MINMAX_ELEMENT_H
+#define _LIBCPP___ALGORITHM_RANGES_MINMAX_ELEMENT_H
+
+#include <__algorithm/min_max_result.h>
+#include <__algorithm/minmax_element.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/invoke.h>
+#include <__functional/ranges_operations.h>
+#include <__iterator/concepts.h>
+#include <__iterator/projected.h>
+#include <__ranges/access.h>
+#include <__ranges/concepts.h>
+#include <__ranges/dangling.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/pair.h>
+#include <type_traits>
+
+#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 _T1>
+using minmax_element_result = min_max_result<_T1>;
+
+namespace __minmax_element {
+struct __fn {
+ template <forward_iterator _Ip, sentinel_for<_Ip> _Sp, class _Proj = identity,
+ indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_element_result<_Ip> operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
+ return {__ret.first, __ret.second};
+ }
+
+ template <forward_range _Rp, class _Proj = identity,
+ indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
+ _LIBCPP_HIDE_FROM_ABI constexpr
+ ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
+ operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
+ auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
+ return {__ret.first, __ret.second};
+ }
+};
+} // namespace __minmax_element
+
+inline namespace __cpo {
+ inline constexpr auto minmax_element = __minmax_element::__fn{};
+} // namespace __cpo
+
+} // namespace ranges
+
+_LIBCPP_END_NAMESPACE_STD
+
+#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/unwrap_iter.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_iter.h
index e738cb26fc..2edf16b70d 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_iter.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/unwrap_iter.h
@@ -64,14 +64,14 @@ __unwrap_iter(_Iter __i) _NOEXCEPT
}
template<class _OrigIter>
-_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result)
{
return __result;
}
template<class _OrigIter, class _UnwrappedIter>
-_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result)
{
// Precondition: __result is reachable from __first