vendredi 29 mai 2015

Add unique_ptr as instance field of a class instead of explicitly removing copy / assignment ctors

There are some macros for preventing classes from being copied, eg: Macros to disallow class copy and assignment. Google -vs- Qt

Would I get identical results just by having a unique_ptr in my class? If so, is there a reason not to do this? eg

class Foo {
  private:
    std::unique_ptr<int> DISABLE_COPY;
};

Aucun commentaire:

Enregistrer un commentaire