aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-01 14:07:11 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-03-01 14:07:11 +0300
commit2ec7758a9f5564266f5736c249c02d15d8316246 (patch)
tree5fa4cc3fb88d1a1aca0cb65d7e0eb0c710f358ce /contrib/libs/cxxsupp/libcxx/include/__algorithm
parent6e8c5376d75151b514477715c1b9505d017b83eb (diff)
downloadydb-2ec7758a9f5564266f5736c249c02d15d8316246.tar.gz
intermediate changes
ref:ca7f4ea59c35451f4846b211a4122df6ab12b4df
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h2
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h3
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h8
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h21
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h19
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h21
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h21
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h3
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/sift_down.h4
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h39
15 files changed, 99 insertions, 62 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h
index cd1d7b1a75..8fc55b9bec 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/binary_search.h
@@ -11,8 +11,8 @@
#include <__config>
#include <__algorithm/comp.h>
-#include <__algorithm/lower_bound.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/lower_bound.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h
index 6417a0543e..38a84a4105 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/copy_n.h
@@ -57,9 +57,10 @@ typename enable_if
>::type
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result)
{
+ typedef typename iterator_traits<_InputIterator>::difference_type difference_type;
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize;
_IntegralSize __n = __orig_n;
- return _VSTD::copy(__first, __first + __n, __result);
+ return _VSTD::copy(__first, __first + difference_type(__n), __result);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h
index 95ac2199fd..5d971c57a4 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/find_end.h
@@ -95,14 +95,16 @@ template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAcc
_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end(
_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2,
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) {
+ typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1;
+ typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2;
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern
- typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2;
+ _D2 __len2 = __last2 - __first2;
if (__len2 == 0)
return __last1;
- typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1;
+ _D1 __len1 = __last1 - __first1;
if (__len1 < __len2)
return __last1;
- const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here
+ const _RandomAccessIterator1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here
_RandomAccessIterator1 __l1 = __last1;
_RandomAccessIterator2 __l2 = __last2;
--__l2;
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h
index 7fd5d6ff9a..22c27a66d1 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/is_heap_until.h>
#include <__iterator/iterator_traits.h>
@@ -26,7 +27,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
- return _VSTD::is_heap_until(__first, __last, __comp) == __last;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp) == __last;
}
template<class _RandomAccessIterator>
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h
index 99291c102b..dd8a62f07f 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_heap_until.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,9 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _RandomAccessIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
-is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+template <class _Compare, class _RandomAccessIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
difference_type __len = __last - __first;
@@ -46,13 +47,19 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
return __last;
}
+template <class _RandomAccessIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_heap_until<_Comp_ref>(__first, __last, __comp);
+}
+
template<class _RandomAccessIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_RandomAccessIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
- return _VSTD::is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
+ return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h
index c6954934e8..57953295a8 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted.h
@@ -10,6 +10,7 @@
#define _LIBCPP___ALGORITHM_IS_SORTED_H
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/is_sorted_until.h>
#include <__config>
#include <__iterator/iterator_traits.h>
@@ -26,7 +27,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
- return _VSTD::is_sorted_until(__first, __last, __comp) == __last;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp) == __last;
}
template<class _ForwardIterator>
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h
index 5b6385991a..9a7f275c54 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/is_sorted_until.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,9 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
-is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+__is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
if (__first != __last)
{
@@ -36,10 +37,16 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __co
return __last;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__is_sorted_until<_Comp_ref>(__first, __last, __comp);
+}
+
template<class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::is_sorted_until(__first, __last, __less<typename iterator_traits<_ForwardIterator>::value_type>());
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h
index 2fa97cad87..79cbd2be86 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/max_element.h>
#include <initializer_list>
@@ -49,7 +50,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
max(initializer_list<_Tp> __t, _Compare __comp)
{
- return *_VSTD::max_element(__t.begin(), __t.end(), __comp);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return *_VSTD::__max_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h
index c51519605a..f932ca7049 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/max_element.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,11 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::max_element requires a ForwardIterator");
@@ -37,11 +36,17 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
return __first;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__max_element<_Comp_ref>(__first, __last, __comp);
+}
+
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::max_element(__first, __last,
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h
index 9fea7f70a2..5cacb2f28e 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__algorithm/min_element.h>
#include <initializer_list>
@@ -49,7 +50,8 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
min(initializer_list<_Tp> __t, _Compare __comp)
{
- return *_VSTD::min_element(__t.begin(), __t.end(), __comp);
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return *_VSTD::__min_element<_Comp_ref>(__t.begin(), __t.end(), __comp);
}
template<class _Tp>
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h
index 9bfd0793c6..3aebebca91 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/min_element.h
@@ -11,6 +11,7 @@
#include <__config>
#include <__algorithm/comp.h>
+#include <__algorithm/comp_ref_type.h>
#include <__iterator/iterator_traits.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -19,11 +20,9 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _ForwardIterator, class _Compare>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
-min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+template <class _Compare, class _ForwardIterator>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+__min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value,
"std::min_element requires a ForwardIterator");
@@ -37,10 +36,16 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
return __first;
}
+template <class _ForwardIterator, class _Compare>
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
+min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
+{
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ return _VSTD::__min_element<_Comp_ref>(__first, __last, __comp);
+}
+
template <class _ForwardIterator>
-_LIBCPP_NODISCARD_EXT inline
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
-_ForwardIterator
+_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last)
{
return _VSTD::min_element(__first, __last,
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h
index 367a5bf1c8..cfaec0ed1e 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search.h
@@ -68,7 +68,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando
const _D1 __len1 = __last1 - __first1;
if (__len1 < __len2)
return _VSTD::make_pair(__last1, __last1);
- const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here
+ const _RandomAccessIterator1 __s = __last1 - _D1(__len2 - 1); // Start of pattern match can't go beyond here
while (true) {
while (true) {
@@ -83,7 +83,7 @@ __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _Rando
_RandomAccessIterator2 __m2 = __first2;
while (true) {
if (++__m2 == __last2)
- return _VSTD::make_pair(__first1, __first1 + __len2);
+ return _VSTD::make_pair(__first1, __first1 + _D1(__len2));
++__m1; // no need to check range on __m1 because __s guarantees we have enough source
if (!__pred(*__m1, *__m2)) {
++__first1;
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h
index 663edb37b4..67d066aa43 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/search_n.h
@@ -59,12 +59,13 @@ _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIter
_RandomAccessIterator __last, _Size __count,
const _Tp& __value_, _BinaryPredicate __pred,
random_access_iterator_tag) {
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
if (__count <= 0)
return __first;
_Size __len = static_cast<_Size>(__last - __first);
if (__len < __count)
return __last;
- const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here
+ const _RandomAccessIterator __s = __last - difference_type(__count - 1); // Start of pattern match can't go beyond here
while (true) {
// Find first element in sequence that matchs __value_, with a mininum of loop checks
while (true) {
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sift_down.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sift_down.h
index 6e801b48b4..4d99ff237c 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sift_down.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sift_down.h
@@ -38,7 +38,7 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
__child = 2 * __child + 1;
_RandomAccessIterator __child_i = __first + __child;
- if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
+ if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) {
// right-child exists and is greater than left-child
++__child_i;
++__child;
@@ -63,7 +63,7 @@ __sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/,
__child = 2 * __child + 1;
__child_i = __first + __child;
- if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) {
+ if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + difference_type(1)))) {
// right-child exists and is greater than left-child
++__child_i;
++__child;
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h
index 24d0a4935b..bc127689a6 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/sort.h
@@ -131,7 +131,7 @@ __selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last,
_BidirectionalIterator __lm1 = __last;
for (--__lm1; __first != __lm1; ++__first)
{
- _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator, _Compare&>(__first, __last, __comp);
+ _BidirectionalIterator __i = _VSTD::min_element(__first, __last, __comp);
if (__i != __first)
swap(*__first, *__i);
}
@@ -160,10 +160,11 @@ template <class _Compare, class _RandomAccessIterator>
void
__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first+2;
- _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
- for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
+ _RandomAccessIterator __j = __first+difference_type(2);
+ _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);
+ for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i)
{
if (__comp(*__i, *__j))
{
@@ -185,6 +186,7 @@ template <class _Compare, class _RandomAccessIterator>
bool
__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
+ typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
switch (__last - __first)
{
case 0:
@@ -195,21 +197,21 @@ __insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator
swap(*__first, *__last);
return true;
case 3:
- _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
+ _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp);
return true;
case 4:
- _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
+ _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
return true;
case 5:
- _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
+ _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
return true;
}
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
- _RandomAccessIterator __j = __first+2;
- _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp);
+ _RandomAccessIterator __j = __first+difference_type(2);
+ _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), __j, __comp);
const unsigned __limit = 8;
unsigned __count = 0;
- for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i)
+ for (_RandomAccessIterator __i = __j+difference_type(1); __i != __last; ++__i)
{
if (__comp(*__i, *__j))
{
@@ -268,13 +270,12 @@ __insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __
template <class _Compare, class _RandomAccessIterator>
void
__introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
- typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type __depth)
+ typename iterator_traits<_RandomAccessIterator>::difference_type __depth)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
const difference_type __limit = is_trivially_copy_constructible<value_type>::value &&
is_trivially_copy_assignable<value_type>::value ? 30 : 6;
- typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
while (true)
{
__restart:
@@ -289,13 +290,13 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
swap(*__first, *__last);
return;
case 3:
- _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp);
+ _VSTD::__sort3<_Compare>(__first, __first+difference_type(1), --__last, __comp);
return;
case 4:
- _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp);
+ _VSTD::__sort4<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), --__last, __comp);
return;
case 5:
- _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp);
+ _VSTD::__sort5<_Compare>(__first, __first+difference_type(1), __first+difference_type(2), __first+difference_type(3), --__last, __comp);
return;
}
if (__len <= __limit)
@@ -307,7 +308,7 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
if (__depth == 0)
{
// Fallback to heap sort as Introsort suggests.
- _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp));
+ _VSTD::__partial_sort<_Compare>(__first, __last, __last, __comp);
return;
}
--__depth;
@@ -434,7 +435,7 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
if (__n_swaps == 0)
{
bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp);
- if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp))
+ if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+difference_type(1), __last, __comp))
{
if (__fs)
return;
@@ -458,7 +459,7 @@ __introsort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
}
else
{
- _VSTD::__introsort<_Compare>(__i + 1, __last, __comp, __depth);
+ _VSTD::__introsort<_Compare>(__i + difference_type(1), __last, __comp, __depth);
__last = __i;
}
}
@@ -478,7 +479,7 @@ template <class _Compare, class _RandomAccessIterator>
void __sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
difference_type __depth_limit = 2 * __log2i(__last - __first);
- __introsort(__first, __last, __comp, __depth_limit);
+ _VSTD::__introsort<_Compare>(__first, __last, __comp, __depth_limit);
}
template <class _Compare, class _Tp>