77 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H10#define _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H11 12#include <__algorithm/equal_range.h>13#include <__algorithm/iterator_operations.h>14#include <__config>15#include <__functional/identity.h>16#include <__functional/invoke.h>17#include <__functional/ranges_operations.h>18#include <__iterator/concepts.h>19#include <__iterator/iterator_traits.h>20#include <__iterator/projected.h>21#include <__ranges/access.h>22#include <__ranges/concepts.h>23#include <__ranges/dangling.h>24#include <__ranges/subrange.h>25#include <__utility/forward.h>26#include <__utility/move.h>27#include <__utility/pair.h>28 29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)30# pragma GCC system_header31#endif32 33_LIBCPP_PUSH_MACROS34#include <__undef_macros>35 36#if _LIBCPP_STD_VER >= 2037 38_LIBCPP_BEGIN_NAMESPACE_STD39 40namespace ranges {41struct __equal_range {42 template <forward_iterator _Iter,43 sentinel_for<_Iter> _Sent,44 class _Tp,45 class _Proj = identity,46 indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>48 operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {49 auto __ret = std::__equal_range<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __comp, __proj);50 return {std::move(__ret.first), std::move(__ret.second)};51 }52 53 template <forward_range _Range,54 class _Tp,55 class _Proj = identity,56 indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>58 operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {59 auto __ret =60 std::__equal_range<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);61 return {std::move(__ret.first), std::move(__ret.second)};62 }63};64 65inline namespace __cpo {66inline constexpr auto equal_range = __equal_range{};67} // namespace __cpo68} // namespace ranges69 70_LIBCPP_END_NAMESPACE_STD71 72#endif // _LIBCPP_STD_VER >= 2073 74_LIBCPP_POP_MACROS75 76#endif // _LIBCPP___ALGORITHM_RANGES_EQUAL_RANGE_H77