boost::range::replace
References
Headers
boost::range::replace
is available by including
any of the following headers:
boost/range/algorithm/replace.hpp
orboost/range/algorithm.hpp
Examples
replace.cpp
#include <functional>
#include <iostream>
#include <vector>
#include <boost/range/algorithm.hpp>
int main() {
std::vector<int> vec = {1, 2, 3, 4, 5};
// replace() is a wrapper for std::replace().
// It returns a reference to the input range.
boost::range::replace(vec, 2, 0);
std::cout << "input vector after replace(vec, 2, 0): ";
boost::range::copy(vec, std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
return 0;
}
Output:
input vector after replace(vec, 2, 0): 1 0 3 4 5
Boost Range for Humans
This reference is part of Boost Range for Humans. Click the link to the overview.