tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
equal_range.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_EQUAL_RANGE_HPP
4#define TETL_ALGORITHM_EQUAL_RANGE_HPP
5
10
11namespace etl {
12
19template <typename ForwardIt, typename T, typename Compare>
20[[nodiscard]] constexpr auto equal_range(ForwardIt first, ForwardIt last, T const& value, Compare comp)
22{
23 return etl::make_pair(etl::lower_bound(first, last, value, comp), etl::upper_bound(first, last, value, comp));
24}
25
27template <typename ForwardIt, typename T>
28[[nodiscard]] constexpr auto equal_range(ForwardIt first, ForwardIt last, T const& value) -> pair<ForwardIt, ForwardIt>
29{
30 return etl::equal_range(first, last, value, etl::less());
31}
32
33} // namespace etl
34
35#endif // TETL_ALGORITHM_EQUAL_RANGE_HPP
constexpr auto equal_range(ForwardIt first, ForwardIt last, T const &value, Compare comp) -> pair< ForwardIt, ForwardIt >
Returns a range containing all elements equivalent to value in the range [first, last).
Definition equal_range.hpp:20
constexpr auto lower_bound(ForwardIt first, ForwardIt last, T const &value, Compare comp) noexcept -> ForwardIt
Returns an iterator pointing to the first element in the range [first, last) that is not less than (i...
Definition lower_bound.hpp:21
constexpr auto upper_bound(ForwardIt first, ForwardIt last, T const &value, Compare comp) -> ForwardIt
Returns an iterator pointing to the first element in the range [first, last) that is greater than val...
Definition upper_bound.hpp:24
Definition adjacent_find.hpp:8
constexpr auto make_pair(T1 &&t, T2 &&u) -> pair< decay_t< T1 >, decay_t< T2 > >
Creates a etl::pair object, deducing the target type from the types of arguments.
Definition pair.hpp:164
Function object for performing comparisons. Unless specialised, invokes operator< on type T....
Definition less.hpp:14
etl::pair is a class template that provides a way to store two heterogeneous objects as a single unit...
Definition pair.hpp:36