I am using this class, not written by me and I can't change its code:
class A {
private:
Val d_val;
public:
void setVal(const Val& val) { d_val = val; }
const Val& getVal() const { return d_val; }
};
Val
supports move but class A
was written without that in mind. Can I somehow avoid a copy of val
in the scenario? I doubt std::move(val)
into setVal
will work since it doesn't take an r value reference.
A a;
Val val;
// populate val
a.setVal(val); // I don't need val after here
Aucun commentaire:
Enregistrer un commentaire