I am interested if creating a new std::vector (or calling its assign method) creates a copy of the data?
For example,
void fun(char *input) {
std::vector<char> v(input, input+strlen(input));
// is it safe to assume that the data input points to was COPIED into v?
}
Yes. Elements are always copied into or out of STL containers. (At least until move semantics are added in C++0x)
EDIT: Here’s how you can test for copying yourself:
The output should be: