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"
我不認爲這可以是任何東西,而不是一個編譯器錯誤。 – ildjarn 2012-07-26 20:08:54