tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
for_each.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2020 Tobias Hienzsch
3
4#ifndef TETL_ALGORITHM_FOR_EACH_HPP
5#define TETL_ALGORITHM_FOR_EACH_HPP
6
7namespace etl {
8
9/// \brief Applies the given function object f to the result of dereferencing
10/// every iterator in the range `[first, last)` in order.
11///
12/// \param first The range to apply the function to.
13/// \param last The range to apply the function to.
14/// \param f Function object, to be applied to the result of dereferencing every
15/// iterator in the range.
16///
17/// https://en.cppreference.com/w/cpp/algorithm/for_each
18///
19/// \ingroup algorithm
20template <typename InputIt, typename UnaryFunc>
21constexpr auto for_each(InputIt first, InputIt last, UnaryFunc f) noexcept -> UnaryFunc
22{
23 for (; first != last; ++first) {
24 f(*first);
25 }
26 return f;
27}
28
29} // namespace etl
30
31#endif // TETL_ALGORITHM_FOR_EACH_HPP
constexpr auto for_each(InputIt first, InputIt last, UnaryFunc f) noexcept -> UnaryFunc
Applies the given function object f to the result of dereferencing every iterator in the range [first...
Definition for_each.hpp:21
Definition adjacent_find.hpp:9