4#ifndef TETL_ALGORITHM_BINARY_SEARCH_HPP
5#define TETL_ALGORITHM_BINARY_SEARCH_HPP
7#include <etl/_algorithm/lower_bound.hpp>
8#include <etl/_functional/less.hpp>
20template <
typename ForwardIt,
typename T,
typename Compare>
21[[nodiscard]]
constexpr auto binary_search(ForwardIt first, ForwardIt last, T
const& value, Compare comp) ->
bool
23 first =
etl::lower_bound(first, last, value, comp);
24 return first != last
and not comp(value, *first);
27template <
typename ForwardIt,
typename T>
28[[nodiscard]]
constexpr auto binary_search(ForwardIt first, ForwardIt last, T
const& value) ->
bool
30 return etl::binary_search(first, last, value,
etl::
less());
constexpr auto binary_search(ForwardIt first, ForwardIt last, T const &value, Compare comp) -> bool
Definition binary_search.hpp:21
constexpr auto binary_search(ForwardIt first, ForwardIt last, T const &value) -> bool
Definition binary_search.hpp:28
Definition adjacent_find.hpp:9
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:15