Browse Source

Update libc++ to 1 May 2022 639b9618f46d75f4dabd2082b3f6ba8433c287bf

mikhnenko 1 year ago
parent
commit
4371a75749

+ 7 - 0
build/sysincl/stl-to-libcxx.yml

@@ -248,6 +248,10 @@
   - __algorithm/pop_heap.h:                       contrib/libs/cxxsupp/libcxx/include/__algorithm/pop_heap.h
   - __algorithm/prev_permutation.h:               contrib/libs/cxxsupp/libcxx/include/__algorithm/prev_permutation.h
   - __algorithm/push_heap.h:                      contrib/libs/cxxsupp/libcxx/include/__algorithm/push_heap.h
+  - __algorithm/ranges_copy.h:                    contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy.h
+  - __algorithm/ranges_copy_backward.h:           contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_backward.h
+  - __algorithm/ranges_copy_if.h:                 contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_if.h
+  - __algorithm/ranges_copy_n.h:                  contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_copy_n.h
   - __algorithm/ranges_count.h:                   contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count.h
   - __algorithm/ranges_count_if.h:                contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_count_if.h
   - __algorithm/ranges_find.h:                    contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_find.h
@@ -257,6 +261,8 @@
   - __algorithm/ranges_max_element.h:             contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_max_element.h
   - __algorithm/ranges_min.h:                     contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min.h
   - __algorithm/ranges_min_element.h:             contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_min_element.h
+  - __algorithm/ranges_minmax.h:                  contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax.h
+  - __algorithm/ranges_minmax_element.h:          contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_minmax_element.h
   - __algorithm/ranges_mismatch.h:                contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_mismatch.h
   - __algorithm/ranges_swap_ranges.h:             contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_swap_ranges.h
   - __algorithm/ranges_transform.h:               contrib/libs/cxxsupp/libcxx/include/__algorithm/ranges_transform.h
@@ -401,6 +407,7 @@
   - __iterator/iterator_traits.h:                 contrib/libs/cxxsupp/libcxx/include/__iterator/iterator_traits.h
   - __iterator/mergeable.h:                       contrib/libs/cxxsupp/libcxx/include/__iterator/mergeable.h
   - __iterator/move_iterator.h:                   contrib/libs/cxxsupp/libcxx/include/__iterator/move_iterator.h
+  - __iterator/move_sentinel.h:                   contrib/libs/cxxsupp/libcxx/include/__iterator/move_sentinel.h
   - __iterator/next.h:                            contrib/libs/cxxsupp/libcxx/include/__iterator/next.h
   - __iterator/ostream_iterator.h:                contrib/libs/cxxsupp/libcxx/include/__iterator/ostream_iterator.h
   - __iterator/ostreambuf_iterator.h:             contrib/libs/cxxsupp/libcxx/include/__iterator/ostreambuf_iterator.h

+ 1 - 1
build/ymake.core.conf

@@ -9,7 +9,7 @@
 FAKEID=628318530716
 
 SANDBOX_FAKEID=${FAKEID}.7600000
-CPP_FAKEID=2023-10-06
+CPP_FAKEID=2023-10-09
 GO_FAKEID=11100371
 ANDROID_FAKEID=2023-05-17
 CLANG_TIDY_FAKEID=2023-06-06

+ 62 - 38
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

+ 19 - 45
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

+ 11 - 37
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

+ 67 - 51
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

+ 65 - 0
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

+ 67 - 0
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

+ 81 - 0
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

+ 76 - 0
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

Some files were not shown because too many files changed in this diff