Questions tagged «move-assignment-operator»


6
移动赋值运算符和`if(this!=&rhs)`
在类的赋值运算符中,通常需要检查被赋值的对象是否是调用对象,因此您无需搞砸: Class& Class::operator=(const Class& rhs) { if (this != &rhs) { // do the assignment } return *this; } 移动分配运算符是否需要相同的东西?有没有一种情况this == &rhs是对的? ? Class::operator=(Class&& rhs) { ? }
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.