In C++98, I can copy ranges with the std::copy
algorithm.
std::copy(source.begin(), source.end(), destination.begin());
Is there an algorithm in C++0x that moves the elements from source to destination? Or is std::copy
somehow overloaded to accept something like rvalue iterators -- is there even such a thing?
The algorithm might look something like this:
#include <utility>
template<class InputIterator, class OutputIterator>
OutputIterator mooove(InputIterator first, InputIterator last, OutputIterator result)
{
for (; first != last; ++first, ++last) *result = std::move(*first);
return result;
}