aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-24 15:11:41 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-02-08 19:04:38 +0000
commitfcaf7f8644a9988098ac6be2165bce3ea4786e91 (patch)
tree08a554363df16b968a623d651c09d82a5a0b1c65 /contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
parent753f127f3ace09432b2baeffd71a308760641a62 (diff)
parent4b4fe385e49bd883fd183b5f21c1ea486c722e61 (diff)
downloadsrc-fcaf7f8644a9988098ac6be2165bce3ea4786e91.tar.gz
src-fcaf7f8644a9988098ac6be2165bce3ea4786e91.zip
Merge llvm-project main llvmorg-15-init-17485-ga3e38b4a206b
This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-15-init-17485-ga3e38b4a206b. PR: 265425 MFC after: 2 weeks
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__algorithm/push_heap.h')
-rw-r--r--contrib/llvm-project/libcxx/include/__algorithm/push_heap.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h b/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
index 1e3eec373d4f..716670b76788 100644
--- a/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
+++ b/contrib/llvm-project/libcxx/include/__algorithm/push_heap.h
@@ -11,9 +11,11 @@
#include <__algorithm/comp.h>
#include <__algorithm/comp_ref_type.h>
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__iterator/iterator_traits.h>
#include <__utility/move.h>
+#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -21,7 +23,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Compare, class _RandomAccessIterator>
+template <class _AlgPolicy, class _Compare, class _RandomAccessIterator>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len) {
@@ -32,9 +34,9 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
_RandomAccessIterator __ptr = __first + __len;
if (__comp(*__ptr, *--__last)) {
- value_type __t(std::move(*__last));
+ value_type __t(_IterOps<_AlgPolicy>::__iter_move(__last));
do {
- *__last = std::move(*__ptr);
+ *__last = _IterOps<_AlgPolicy>::__iter_move(__ptr);
__last = __ptr;
if (__len == 0)
break;
@@ -47,18 +49,21 @@ void __sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Com
}
}
-template <class _RandomAccessIterator, class _Compare>
+template <class _AlgPolicy, class _RandomAccessIterator, class _Compare>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
void __push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare& __comp) {
using _CompRef = typename __comp_ref_type<_Compare>::type;
typename iterator_traits<_RandomAccessIterator>::difference_type __len = __last - __first;
- std::__sift_up<_CompRef>(std::move(__first), std::move(__last), __comp, __len);
+ std::__sift_up<_AlgPolicy, _CompRef>(std::move(__first), std::move(__last), __comp, __len);
}
template <class _RandomAccessIterator, class _Compare>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
- std::__push_heap(std::move(__first), std::move(__last), __comp);
+ static_assert(std::is_copy_constructible<_RandomAccessIterator>::value, "Iterators must be copy constructible.");
+ static_assert(std::is_copy_assignable<_RandomAccessIterator>::value, "Iterators must be copy assignable.");
+
+ std::__push_heap<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __comp);
}
template <class _RandomAccessIterator>