mercredi 27 octobre 2021

explanation on Delete copy/move so extra instances can't be created/moved

I am exploring design patterns in cpp, in singleton pattern we usually saw this piece of code

// Delete copy/move so extra instances can't be created/moved.
  Singleton(const Singleton&) = delete;
  Singleton& operator=(const Singleton&) = delete;
  Singleton(Singleton&&) = delete;
  Singleton& operator=(Singleton&&) = delete;

didn't see any good explanation of what these part of code are doing? Is it possible to get a line by line explanation of what each line is doing?

Aucun commentaire:

Enregistrer un commentaire