-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
On rule of three / five page on cppreference, this assignment operator with a value parameter can replace assignment with both reference and rvalue reference parameter. This makes it rule of four. Can this be mentioned on the core guidelines if it is legal?
rule_of_five& operator=(rule_of_five other) noexcept
{
std::swap(cstring, other.cstring);
return *this;
}
cppreference is the only place which has a complete and correct example of rule of five. Such an example is not seen in books like C++ Primer
, The C++ Programming Language
. Can future editions of these book include a complete and correct example of rule of five. Is not this the core of c++?
ref:
https://en.cppreference.com/w/cpp/language/rule_of_three.html ,
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cctor-constructors-assignments-and-destructors ,
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-five ,
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-copy-assignment ,
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rc-move-assignment ,