C++ style prefers
for_each(xs.begin(), xs.end(), f);
to xs = std::transform(xs,f);
Because the first does not copy the container and its elements, which in C++ is a meaningful operation which may not be allowed for xs's elements, or may be remarkably expensive.I thought the annoying verbosity when using the whole container with <algorithm> was fixed in C++11 like it was for for loops, but I can't find documentation to that effect. Boost's range algorithms library is still useful here:
http://www.boost.org/doc/libs/1_52_0/libs/range/doc/html/ind...