我有一个用例,不能以任何方式复制我的对象。我在下面写了一个夸大的复制构造函数和复制赋值运算符删除的完整列表。它们太多了,我无法确定要使用哪些,有时这让我很偏执。我不必将它们全部写在我的代码中,是吗?那么,为了防止任何类型的对象复制,我应该使用哪一个?
MyClass ( MyClass &) = delete;
MyClass (const MyClass &) = delete;
MyClass ( MyClass &&) = delete;
MyClass (const MyClass &&) = delete;
MyClass operator=( MyClass &) = delete;
MyClass operator=(const MyClass &) = delete;
const MyClass operator=( MyClass &) = delete;
const MyClass operator=(const MyClass &) = delete;
MyClass & operator=( MyClass &) = delete;
MyClass & operator=(const MyClass &) = delete;
const MyClass & operator=( MyClass &) = delete;
const MyClass & operator=(const MyClass &) = delete;
MyClass && operator=( MyClass &) = delete;
MyClass && operator=(const MyClass &) = delete;
const MyClass && operator=( MyClass &) = delete;
const MyClass && operator=(const MyClass &) = delete;
MyClass operator=( MyClass &&) = delete;
MyClass operator=(const MyClass &&) = delete;
const MyClass operator=( MyClass &&) = delete;
const MyClass operator=(const MyClass &&) = delete;
MyClass & operator=( MyClass &&) = delete;
MyClass & operator=(const MyClass &&) = delete;
const MyClass & operator=( MyClass &&) = delete;
const MyClass & operator=(const MyClass &&) = delete;
MyClass && operator=( MyClass &&) = delete;
MyClass && operator=(const MyClass &&) = delete;
const MyClass && operator=( MyClass &&) = delete;
const MyClass && operator=(const MyClass &&) = delete;