Consider the following code:
std::vector vec;
vec.reserve(500);
size_t cap = vec.capacity();
std::vector newVec = std::move(vec);
assert(cap == newVec.capacity());
In pretty much any implementation you run across, this will work. I don’t care about what implementations do. I want to know what the standard requires. Will the moved-to vector have the same capacity as the original? Or will the assert trigger?
Looking at the standard, it appears that nothing is required from the move constructor, however as @amaurea says, it would completely defeat the purpose of move semantics if the move constructor were to try and allocate or deallocate memory, so I would expect the capacity to remain the same in all implementations.
23.2.1 General container requirements
Expression
Assertion/note pre-/post-condition
Requires:
Tis CopyInsertable into X (see below).post:
u == aThe standard only requires that
newVec == vec. As capacity is not taken into consideration forstd::vector::operator==,newVecneed not necessarily have the same capacity asvec.