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
7
namespace
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
20
template
<
typename
InputIt,
typename
UnaryFunc>
21
constexpr
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
etl::for_each
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
etl
Definition
adjacent_find.hpp:9
include
etl
_algorithm
for_each.hpp
Generated on Sun Sep 7 2025 19:14:46 for tetl by
1.9.8