jeudi 3 août 2017

Construct object from vector using move

I have a code like this:

class MyClass {
public:
    MyClass(std::vector &vec):
        v(vec)
    {}
    MyClass(??);

private:
    std::vector v;
};

I would like to construct my class like this MyClass(std::move(some_vector))
How can I achieve that?

I can change 4 line to v(std::move(vec)) but this is hidden move, due to dangerous.

Aucun commentaire:

Enregistrer un commentaire