jeudi 23 mai 2019

Why to move rvalue reference in a move constructor?

I've come across the following code:

class X {
    std::vector<int> m_v;
public:
    X(std::vector<int>&& v) : m_v(std::move(v)) {

};

Parametet v is already an rvalue-reference - so why do we need to apply std::move to it?

Aucun commentaire:

Enregistrer un commentaire