I am using Xcode 4.4 with a mountain lion. I cannot understand why a non-static member of initialization in templates calls a move constructor for a variable. Is there any way to overcome this error?
Code example:
#include <iostream>
#include <atomic>
class Working
{
public:
int GetValue() { return value_; }
private:
std::atomic<int> value_{0};
};
template <typename Ty1>
class NotWorking
{
public:
int GetValue() { return value_; }
private:
std::atomic<int> value_{0};
};
int main(int argc, const char * argv[])
{
Working working;
NotWorking<int> not_working;
return 0;
}
Xcode 4.4 and Clang throw an error on this line:
"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor"
source
share