让foo是一个结构或类与拷贝赋值运算符: struct foo {
foo &operator=(const foo &); // or with some other return type?
};
有曾经一个合理理由退货以外*this从operator=()什么?将它用于与作业无关的事情并不合格。
我有一个类,移动任务被明确删除,因为对象不应该是可移动的。但是,如果我分配到使用这个RVO类的一个实例,编译器给我的错误: main.cpp:12:16: note: candidate function has been explicitly deleted
也编译器提现有的拷贝赋值运算符,但不使用它。 这里是我的代码(或(不)运行例如here): class foo {
public:
这是我的原型, MyClass& operator=(MyClass rhs); // copy assignment
MyClass& operator=(MyClass &&rhs); // move assignment
但是,当我打电话 MyClass a, b;
a = std::move(b);
,有错误。 556 IntelliSense: more than one o