【发布时间】:2019-01-06 02:49:27
【问题描述】:
基于热门问题What is the copy-and-swap idiom?:
为什么 4.5 的规则不包括移动赋值运算符(实际上成为 5.5 的规则)?相反,我读到(例如,这里What is the Rule of Four (and a half)?)我们的规则是 4.5 还是 5?
-
既然
swap成员函数是noexcept,那么复制赋值运算符不应该也标记为相同(移动构造函数不能因为它调用可以抛出的默认构造函数)?
dumb_array& operator=(dumb_array other) // should be noexcept?
{
swap(*this, other);
return *this;
}
【问题讨论】:
标签: c++ c++11 move-semantics