dou*_*lep 6 c++ move-constructor c++11
为什么没有为派生类创建默认移动构造函数或赋值运算符?证明我的意思; 有这个设置代码:
#include <utility>
struct A
{
A () { }
A (A&&) { throw 0; }
A& operator= (A&&) { throw 0; }
};
struct B : A
{ };
Run Code Online (Sandbox Code Playgroud)
抛出以下任一行:
A x (std::move (A ());
A x; x = A ();
Run Code Online (Sandbox Code Playgroud)
但以下都没有:
B x (std::move (B ());
B x; x = B ();
Run Code Online (Sandbox Code Playgroud)
如果重要,我用GCC 4.4测试.
编辑:后来用GCC 4.5测试显示了相同的行为.
小智 6
读取0x FCD中的12.8(特别是移动ctor的12.8/17),这似乎是一个GCC错误.我在4.5中看到了与4.4中相同的事情.
我可能在遗失的函数或类似的东西上遗漏了一个角落案例,但我还没有看到任何迹象.