Derived Constructor Confusion Class Move

I know the move semantics in the C ++ move constructor, but here I have the confusion:

class Derived: public Base {
    std::vector<int> vec;
    std::string name;
    // ...
public:
    // ...
    // move semantics
    Derived(Derived&& x)              // rvalues bind here
        : Base(std::move(x)), 
        vec(std::move(x.vec)),
        name(std::move(x.name)) { }

    Derived& operator=(Derived&& x)   // rvalues bind here
    {
        Base::operator=(std::move(x));
        vec  = std::move(x.vec);
        name = std::move(x.name);
        return *this;
    }
    // ...
};

the base of the move constructor (std :: move (x)), x were converted to an rvalue reference, like vec (std :: move (x.vec))? still x existing?

+3
source share
1 answer

Base Base(Base&& b), , Base(std::move(x)) , rvalue std::move(x), Derived, rvalue Base. Base rvalue Base, Base x. x , .

. , .

+3

All Articles