79221654

Date: 2024-11-25 04:38:22
Score: 0.5
Natty:
Report link

To add to the other answers, there's also a special rule ignoring templated functions that could have the signatures of the copy constructor and copy assignment operator.

Citing Effective Modern C++:

Note that there’s nothing in the rules about the existence of a member function template preventing compilers from generating the special member functions. That means that if Widget looks like this,

class Widget {

template Widget(const T& rhs);

template Widget& operator=(const T& rhs); …

// construct Widget // from anything

// assign Widget // from anything

};

compilers will still generate copy and move operations for Widget (assuming the usual conditions governing their generation are fulfilled), even though these templates could be instantiated to produce the signatures for the copy constructor and copy assignment operator. (That would be the case when T is Widget.)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Zack Light