...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.57. Parameters
Parameter |
Requirement |
Description |
---|---|---|
seq |
A model of Forward Sequence, e == old_value is a valid expression, convertible to bool, for each element e in seq with type convertible to T |
Operation's argument |
old_value |
Any type |
Value to replace |
new_value |
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));