tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
replace_if.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_REPLACE_IF_HPP
5
#
define
TETL_ALGORITHM_REPLACE_IF_HPP
6
7
namespace
etl
{
8
9
/// \brief Replaces all elements satisfying specific criteria with new_value in
10
/// the range [first, last). Replaces all elements for which predicate p
11
/// returns true.
12
/// \ingroup algorithm
13
template
<
typename
ForwardIt,
typename
Predicate,
typename
T>
14
constexpr
auto
replace_if
(ForwardIt first, ForwardIt last, Predicate p, T
const
& newValue) ->
void
15
{
16
for
(; first != last; ++first) {
17
if
(p(*first)) {
18
*first = newValue;
19
}
20
}
21
}
22
23
}
// namespace etl
24
25
#
endif
// TETL_ALGORITHM_REPLACE_IF_HPP
etl::replace_if
constexpr auto replace_if(ForwardIt first, ForwardIt last, Predicate p, T const &newValue) -> void
Replaces all elements satisfying specific criteria with new_value in the range [first,...
Definition
replace_if.hpp:14
etl
Definition
adjacent_find.hpp:9
include
etl
_algorithm
replace_if.hpp
Generated on Sun Sep 7 2025 19:14:46 for tetl by
1.9.8