Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
STL algorithm to copy container elements.
std::copy assumes that the memory data is copied to is valid. For example, if you copy a std::vector of size 10 to another std::vector, the latter must have a size of 10 at least. But if the size is unknown, use an inserter like std::back_inserter.
Related algorithms are:
Prefer algorithm calls over hand-written loops [1][2].
#include <algorithm |
Copies a std::map to a std::vector.
#include <algorithm |
#include <algorithm |
#include <iostream> |
#include <iostream> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.