mardi 17 décembre 2019

May I call destructor from move assignement operator?

Well I have non-trivial destructor in my class.

May I do something like:

Foo& Foo::operator=(Foo&& from) {
    ~Foo()
    // Copy the stuff and cleanup "from"
}

What I am trying to achieve is to avoid code duplication.

Also, I could write some cleanup function, but if I can call destructor then what for?

Aucun commentaire:

Enregistrer un commentaire