我正在使用带有美洲狮的Xcode 4.4。我似乎不能理解为什么模板中的非静态成员初始化调用变量的移动构造函数。有什么办法可以克服这个错误吗?
示例代码:
#include <iostream>
#include <atomic>
//
// This class can compile
//
class Working
{
public:
int GetValue() { return value_; }
private:
std::atomic<int> value_{0};
};
//
// This class cannot compile
//
template <typename Ty1>
class NotWorking
{
public:
int GetValue() { return value_; }
private:
std::atomic<int> value_{0}; // <---- error here
};
int main(int argc, const char * argv[])
{
Working working;
NotWorking<int> not_working;
return 0;
}Xcode 4.4和Clang在该行抛出错误:
"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor"发布于 2012-07-27 04:29:12
这看起来像是开源svn主干存储库上的clang bug。你能提交一份关于clang here:http://llvm.org/bugs/的bug报告吗?
谢谢!
https://stackoverflow.com/questions/11675851
复制相似问题