Introduction
The rule-of-five states that, if a class C
has one of user-declared
- Destructor
~C
- Copy constructor
C(const C&)
- Copy assignment operator
C& operator=(const C&)
- Move constructor
C(C&&)
- Move assignment operator
C& operator=(C&&)
it should declare all five special member functions.
User-declared !=
User-provided. Any explicitly defaulted (=default
) or deleted (=delete
) functions count as user-declared.
A function is user-provided if it is user-declared and not explicitly defaulted or deleted.
Hinnant Table
The infamous Hinnant table elaborates the various special members implicitly generated by the compiler in the presence of user-declared special functions.