...

/

Concepts in the <concepts> Header (cont.)

Concepts in the <concepts> Header (cont.)

Get an overview of the `std::copyable` for copyable types that are shipped with the C++ standard library.

Special Functions in C++

Since C++11, there are six special functions in C++ that are generated by the compiler under certain conditions.

Special Functions in C++ and Their Role

Special functions in C++

Role of Functions

Default constructor (T())

Calls the default constructor of each class member and base class. It doesn’t affect the rest of the special member functions.

Copy constructor (T(const T&))


Calls the copy constructor on each member and base class.

Copy assignment operator (T& operator=(const T&))


Calls a copy assignment operator on each class member and base class.

Move constructor (T(X&&))


Calls the move constructor on each class member and base class.

Move assignment (T& operator=(T&&))


Calls the move constructor on each member and base class.

The destructor (~T())


Calls the destructor of each class member and base class.

Note: The default-generated destructor is never virtual unless it is for a class that inherits from one that has a virtual destructor.

Rule of 5

If there is no constructor specified, the default constructor is ...