samedi 26 septembre 2015

can I call destructor in move assignment operator?

Is calling a d-tor inside move assignment operator good practice?

here some example code:

VectorList &operator = (VectorList &&other){
    ~VectorList(); // if this is not a good practice,
                   // I will need to paste whole d-tor here.

    _buffer     = std::move(other._buffer       );
    _dataCount  = std::move(other._dataCount    );
    _dataSize   = std::move(other._dataSize     );

    other._clear();

    return *this;
}

Should I use this code, or should I use swap() with move constructed object?

Aucun commentaire:

Enregistrer un commentaire