Consider this simple program:
vector foo = {0, 42, 0, 42, 0, 42}; replace(begin(foo), end(foo), foo.front(), 13); for(const auto& i : foo) co
One liner that should work for any type, not only numeric:
replace(begin(foo), end(foo), make_pair(foo.front(),0).first, 13);
or without creating extra field:
replace(begin(foo), end(foo), get<0>( make_tuple(foo.front()) ), 13);