C++核心准则C.63:保证移动赋值运算符为非虚函数,参数类型为右值...
C.63:保证移动赋值运算符为非虚函数,参数类型为右值引用,返回值为常量引用类型
It is simple and efficient.
这样做简单且高效。
The rule for copy-assignment.
拷贝赋值规则。
相关链接:
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-copy-assignment
Equivalent to what is done for copy-assignment.
和拷贝赋值的情况时所做的相同。
(Simple) An assignment operator should not be virtual. Here be dragons!
(简单)赋值运算符不应该是虚函数。那样做很危险。
(Simple) An assignment operator should return T& to enable chaining, not alternatives like const T& which interfere with composability and putting objects in containers.
(简单)赋值运算符应该返回T&,这样才能实现连续赋值。不要改成类似const T&的类型,这样会影响组装性并妨碍将对象放进容器中。
(Moderate) A move assignment operator should (implicitly or explicitly) invoke all base and member move assignment operators.
(中等)移动赋值运算符应该(隐式或显式)调用所有的基类和成员的移动赋值运算符。
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c63-make-move-assignment-non-virtual-take-the-parameter-by--and-return-by-non-const-
觉得本文有帮助?请分享给更多人。
关注【面向对象思考】轻松学习每一天!
面向对象开发,面向对象思考!