Copying std::vector of primitive types behavior

Viewed 273

Background:

When copying a std::vector using its copy constructor or copy assignment like this:

std::vector<T> v1{T(),T(),T()};
std::vector<T> v2 = v1;

a deep copy happens.

Is it guaranteed by the standard that the copy constructor of T will be triggered for each element? In other words no memcpy (or something similar) will be called. (Correct me if I am wrong).

Question:

On the other hand, is it guaranteed by the standard that it would call memcpy (or something similar) on primitive types (for performance issues)?

2 Answers
Related