tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
find.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_ALGORITHM_FIND_HPP
5#define TETL_ALGORITHM_FIND_HPP
6
7namespace etl {
8
9/// Searches for an element equal to value.
10///
11/// \param first The range of elements to examine.
12/// \param last The range of elements to examine.
13/// \param value Value to compare the elements to.
14///
15/// https://en.cppreference.com/w/cpp/algorithm/find
16///
17/// \ingroup algorithm
18template <typename InputIt, typename T>
19[[nodiscard]] constexpr auto find(InputIt first, InputIt last, T const& value) noexcept -> InputIt
20{
21 for (; first != last; ++first) {
22 if (*first == value) {
23 return first;
24 }
25 }
26 return last;
27}
28
29} // namespace etl
30
31#endif // TETL_ALGORITHM_FIND_HPP
constexpr auto find(InputIt first, InputIt last, T const &value) noexcept -> InputIt
Searches for an element equal to value.
Definition find.hpp:19
Definition adjacent_find.hpp:9