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
3#ifndef TETL_ALGORITHM_REPLACE_IF_HPP
4#define TETL_ALGORITHM_REPLACE_IF_HPP
5
6namespace etl {
7
12template <typename ForwardIt, typename Predicate, typename T>
13constexpr auto replace_if(ForwardIt first, ForwardIt last, Predicate p, T const& newValue) -> void
14{
15 for (; first != last; ++first) {
16 if (p(*first)) {
17 *first = newValue;
18 }
19 }
20}
21
22} // namespace etl
23
24#endif // TETL_ALGORITHM_REPLACE_IF_HPP
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:13
Definition adjacent_find.hpp:8