tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
replace.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_ALGORITHM_REPLACE_HPP
4#define TETL_ALGORITHM_REPLACE_HPP
5
7
8namespace etl {
9
14template <typename ForwardIt, typename T>
15constexpr auto replace(ForwardIt first, ForwardIt last, T const& oldValue, T const& newValue) -> void
16{
17 auto predicate = [&oldValue](auto const& item) { return item == oldValue; };
18 etl::replace_if(first, last, predicate, newValue);
19}
20
21} // namespace etl
22
23#endif // TETL_ALGORITHM_REPLACE_HPP
Definition predicate.hpp:14
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
constexpr auto replace(ForwardIt first, ForwardIt last, T const &oldValue, T const &newValue) -> void
Replaces all elements satisfying specific criteria with new_value in the range [first,...
Definition replace.hpp:15
Definition adjacent_find.hpp:8