Use std::copy instead of a loop.