2012-07-26 65 views
5

我正在使用Xcode 4.4与山狮。我似乎无法理解为什么模板中的非静态成员初始化为变量调用移动构造函数。无论如何克服这个错误?Clang ++ 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和锵抛出该行并称错误:

"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor" 
+0

我不认为这可以是任何东西,而不是一个编译器错误。 – ildjarn 2012-07-26 20:08:54

回答

3

这看起来像开源的SVN主干库中的铿锵错误。您能否提交一份针对clang here的错误报告:http://llvm.org/bugs/

谢谢!