I know with transform
I can add a constant to some vector like so:
std::vector<int> a(3, 2);
std::transform( a.begin(), a.end(), a.begin(), std::bind2nd( std::plus<double>(), 1 ) );
I was wondering how I could modify transform
to add a constant to some slice [index:end]
of the vector, e.g. the last two elements.
I can do it with a loop e.g.:
for (int i=1; i < a.size(); i++) {
a.at(i) += 1;
}
but maybe there's a better option