The C++11 rules govering the special member funcions are thus:
Default constructor: Same rules as c++98. Generated only if the class contains no user-declared constructors.
Destructor: Essentially same rules as C++98; sole difference is that destrctors are noexcept by default. As in C++98, virtual only if a base class
destructor is virtual.
Copy constructor: Same runtime behavior as C++98: memberwise copy construction of non-static data members. Generated only if the class lacks a user-declared copy constructor. Deleted if the class declares a move operation. Generation of this funcion in a class with a user-declared copy assignment operator is deprecated.
Copy assignment operator: Same runtime behavior as C++98: memberwise copy assignment of non-static data members. Generated only if the class lacks a user-declared copy constructor. Deleted if the class declares a move operation. Generation of this funcion in a class with a user-declared copy assignment operator is deprecated.
Move constructor and move assignment operator: Each performs memberwise moving of non-static data members. Generated only if the class contains no user-declared copy operations, move operaions, or destructor.
本文概述了C++11中对于特殊成员函数的规定,包括默认构造函数、析构函数、拷贝构造函数、拷贝赋值运算符、移动构造函数及移动赋值运算符等。详细介绍了这些函数在不同情况下的生成条件与行为表现。

227

被折叠的 条评论
为什么被折叠?



