Consider the class Dog
inheritng from Animal
:
class Animal { … };
class Dog: public Animal {
public:
Dog(Dog&& other)
: Animal(std::move(other)),
breed(std::move(other.breed)) {
}
private:
std::string breed;
};
The move constructor starts by constructing the parent object with std::move(other)
.
However, the standard library says that:
[After the move operations,] the moved-from objects shall be placed in a valid but unspecified state.
If I understand correctly, this means that the object pointed to by other
is now in an unspecified state. This means that the next line constructing the attribute breed
will result in an unspecified value.
Is this correct?