Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:11

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
0010 #define _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H
0011 
0012 #include <__algorithm/iterator_operations.h>
0013 #include <__algorithm/make_projected.h>
0014 #include <__algorithm/push_heap.h>
0015 #include <__concepts/same_as.h>
0016 #include <__config>
0017 #include <__functional/identity.h>
0018 #include <__functional/invoke.h>
0019 #include <__functional/ranges_operations.h>
0020 #include <__iterator/concepts.h>
0021 #include <__iterator/iterator_traits.h>
0022 #include <__iterator/next.h>
0023 #include <__iterator/projected.h>
0024 #include <__iterator/sortable.h>
0025 #include <__ranges/access.h>
0026 #include <__ranges/concepts.h>
0027 #include <__ranges/dangling.h>
0028 #include <__utility/forward.h>
0029 #include <__utility/move.h>
0030 
0031 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0032 #  pragma GCC system_header
0033 #endif
0034 
0035 _LIBCPP_PUSH_MACROS
0036 #include <__undef_macros>
0037 
0038 #if _LIBCPP_STD_VER >= 20
0039 
0040 _LIBCPP_BEGIN_NAMESPACE_STD
0041 
0042 namespace ranges {
0043 struct __push_heap {
0044   template <class _Iter, class _Sent, class _Comp, class _Proj>
0045   _LIBCPP_HIDE_FROM_ABI constexpr static _Iter
0046   __push_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
0047     auto __last_iter = ranges::next(__first, __last);
0048 
0049     auto&& __projected_comp = std::__make_projected(__comp, __proj);
0050     std::__push_heap<_RangeAlgPolicy>(std::move(__first), __last_iter, __projected_comp);
0051 
0052     return __last_iter;
0053   }
0054 
0055   template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
0056     requires sortable<_Iter, _Comp, _Proj>
0057   _LIBCPP_HIDE_FROM_ABI constexpr _Iter
0058   operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
0059     return __push_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
0060   }
0061 
0062   template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
0063     requires sortable<iterator_t<_Range>, _Comp, _Proj>
0064   _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
0065   operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
0066     return __push_heap_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
0067   }
0068 };
0069 
0070 inline namespace __cpo {
0071 inline constexpr auto push_heap = __push_heap{};
0072 } // namespace __cpo
0073 } // namespace ranges
0074 
0075 _LIBCPP_END_NAMESPACE_STD
0076 
0077 #endif // _LIBCPP_STD_VER >= 20
0078 
0079 _LIBCPP_POP_MACROS
0080 
0081 #endif // _LIBCPP___ALGORITHM_RANGES_PUSH_HEAP_H