samedi 29 septembre 2018

Can a non-copyable member be used as alternative to make an object non-copyable?

A class with non-copyable member is said to be also non-copyable. From SO, to make a class non-copyable these are the options:

  1. Use boost::noncopyable
  2. Declare constructor and assignment operator as private.

    class foo 
    {
        private:
          std::mutex _dummy;
    };
    
    

Question: Will inclusion of a dummy non-copyable member be used for similar purpose and for simplicity? What are the down-sides?

Aucun commentaire:

Enregistrer un commentaire