Why should I delete move constructor and move assignment operator in a singleton?

If you declare a copy constructor (even if you define it as deleted in the declaration), no move constructor will be declared implicitly. Cf. C++11 12.8/9:

If the definition of a class X does not explicitly declare a move constructor, one will be implicitly declared as defaulted if and only if

— X does not have a user-declared copy constructor,

— …

Since you do have a user-declared copy constructor, there won’t be a move constructor at all if you don’t declare one. So you can just get rid of the move constructor declaration-definition entirely. Same for the move-assignment operator.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)