| Home | Libraries | People | FAQ | More

##### replace

###### Description

Replaces each value within a sequence of a given type and value with a new value.

###### Synopsis

    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

###### Expression Semantics

    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`.

###### Complexity

Constant. Returns a view which is lazily evaluated.

###### Header

    #include <boost/fusion/algorithm/transformation/replace.hpp>
    #include <boost/fusion/include/replace.hpp>

###### Example

    assert(replace(make_vector(1,2), 2, 3) == make_vector(1,3));