![]() |
Home | Libraries | People | FAQ | More |
Replaces each element of a given sequence for which an unary function
object evaluates to true
replaced with a new value.
template<
typename Sequence,
typename F,
typename T>
typename result_of::replace_if<Sequence const, F, T>::type replace_if(
Sequence const& seq, F f, T const& new_value);
Table 1.57. Parameters
| Parameter | Requirement | Description |
|---|---|---|
seq |
A model of Forward Sequence | Operation's argument |
f |
A
function object for which f(e) is a valid expression, convertible
to bool, for each element
e in seq
|
Operation's argument |
new_value |
Any type | Replacement value |
replace_if(seq, f, new_value);
Return type: A model of Forward Sequence.
Semantics: Returns a new sequence with
all the elements of seq,
with new_value assigned
to each element for which f
evaluates to true.
Constant. Returns a view which is lazily evaluated.
#include <boost/fusion/algorithm/transformation/replace_if.hpp>
struct odd { template<typename T> bool operator()(T t) const { return t % 2; } }; ... assert(replace_if(make_vector(1,2), odd(), 3) ==make_vector(3,2));
| Copyright © 2001-2007 Joel de Guzman, Dan Marsden, Tobias Schwinger |