...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Replaces each value within a sequence of a given type and value with a new value.
template<
typename Sequence,
typename T
>
typename result_of::replace
<Sequence const, T>::type replace(
Sequence const& seq, T const& old_value, T const& new_value);
Table 1.70. Parameters
Parameter |
Requirement |
Description |
---|---|---|
|
A model of Forward
Sequence, |
Operation's argument |
|
Any type |
Value to replace |
|
Any type |
Replacement value |
replace
(seq, old_value, new_value);
Return type: A model of Forward Sequence.
Semantics: Returns a new sequence with
all the values of seq
with new_value
assigned
to elements with the same type and equal to old_value
.
Constant. Returns a view which is lazily evaluated.
#include <boost/fusion/algorithm/transformation/replace.hpp> #include <boost/fusion/include/replace.hpp>
assert(replace
(make_vector
(1,2), 2, 3) ==make_vector
(1,3));