13#ifndef RANGES_V3_ALGORITHM_BINARY_SEARCH_HPP
14#define RANGES_V3_ALGORITHM_BINARY_SEARCH_HPP
30#include <range/v3/utility/static_const.hpp>
32#include <range/v3/detail/prologue.hpp>
38 RANGES_FUNC_BEGIN(binary_search)
51 constexpr
bool RANGES_FUNC(binary_search)(
52 I first, S last, V const & val, C pred = C{}, P proj = P{})
55 lower_bound(std::move(first), last, val, ranges::ref(pred), ranges::ref(proj));
60 template(
typename Rng,
typename V,
typename C =
less,
typename P =
identity)(
63 constexpr bool RANGES_FUNC(binary_search)(
64 Rng && rng, V
const & val, C pred = C{}, P proj = P{})
66 static_assert(!is_infinite<Rng>::value,
67 "Trying to binary search an infinite range");
68 return (*
this)(begin(rng), end(rng), val, std::move(pred), std::move(proj));
70 RANGES_FUNC_END(binary_search)
74 using ranges::binary_search;
79#include <range/v3/detail/epilogue.hpp>
The forward_iterator concept.
The forward_range concept.
The indirect_strict_weak_order concept.
The sentinel_for concept.
decltype(begin(declval(Rng &))) iterator_t
Definition access.hpp:698
typename Fn::template invoke< Args... > invoke
Evaluate the invocable Fn with the arguments Args.
Definition meta.hpp:541
front< Pair > first
Retrieve the first element of the pair Pair.
Definition meta.hpp:2251
Definition identity.hpp:25
Definition comparisons.hpp:50