File indexing completed on 2026-05-03 08:13:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
0010 #define _LIBCPP___ALGORITHM_RANGES_IS_HEAP_H
0011
0012 #include <__algorithm/is_heap_until.h>
0013 #include <__algorithm/make_projected.h>
0014 #include <__config>
0015 #include <__functional/identity.h>
0016 #include <__functional/ranges_operations.h>
0017 #include <__iterator/concepts.h>
0018 #include <__iterator/iterator_traits.h>
0019 #include <__iterator/next.h>
0020 #include <__iterator/projected.h>
0021 #include <__ranges/access.h>
0022 #include <__ranges/concepts.h>
0023 #include <__utility/move.h>
0024
0025 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0026 # pragma GCC system_header
0027 #endif
0028
0029 _LIBCPP_PUSH_MACROS
0030 #include <__undef_macros>
0031
0032 #if _LIBCPP_STD_VER >= 20
0033
0034 _LIBCPP_BEGIN_NAMESPACE_STD
0035
0036 namespace ranges {
0037 struct __is_heap {
0038 template <class _Iter, class _Sent, class _Proj, class _Comp>
0039 _LIBCPP_HIDE_FROM_ABI constexpr static bool
0040 __is_heap_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
0041 auto __last_iter = ranges::next(__first, __last);
0042 auto&& __projected_comp = std::__make_projected(__comp, __proj);
0043
0044 auto __result = std::__is_heap_until(std::move(__first), std::move(__last_iter), __projected_comp);
0045 return __result == __last;
0046 }
0047
0048 template <random_access_iterator _Iter,
0049 sentinel_for<_Iter> _Sent,
0050 class _Proj = identity,
0051 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
0052 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
0053 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
0054 return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
0055 }
0056
0057 template <random_access_range _Range,
0058 class _Proj = identity,
0059 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
0060 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
0061 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
0062 return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
0063 }
0064 };
0065
0066 inline namespace __cpo {
0067 inline constexpr auto is_heap = __is_heap{};
0068 }
0069 }
0070
0071 _LIBCPP_END_NAMESPACE_STD
0072
0073 #endif
0074
0075 _LIBCPP_POP_MACROS
0076
0077 #endif