I think I understand the gist of move-semantics in general but am wondering, whether the C++ standard actually guarantees move-semantics for std-types like std::vector
. For instance is the following snippet guaranteed to produce check = true
(if the used compiler/std-lib is standard-compliant)?
std::vector<int> myVec;
int *myPtr = myVec.data();
std::vector<int> otherVec = std::move(myVec);
int *otherPtr = otherVec.data();
bool check = myPtr == otherPtr;
In other words: When moving a a std::vector
, does the standard guarantee that I will actually perform a move and not a copy after all (e.g. because the used std-lib hasn't implemented a move-constructor for std::vector
)?