【发布时间】:2012-12-20 08:58:44
【问题描述】:
我有一个带有原子成员变量的类:
struct Foo
{
std::atomic<bool> bar;
/* ... lots of other stuff, not relevant here ... */
Foo()
: bar( false )
{}
/* Trivial implementation fails in gcc 4.7 with:
* error: use of deleted function ‘std::atomic<bool>::atomic(const td::atomic<bool>&)’
*/
Foo( Foo&& other )
: bar( other.bar )
{}
};
Foo f;
Foo f2(std::move(f)); // use the move
移动构造函数应该是什么样子的?
Gcc 4.7 不喜欢我的任何尝试(比如在 other.bar 周围添加 std::move()),而且这里的网络出奇地安静......
【问题讨论】:
标签: c++ c++11 atomic move-semantics libstdc++