Clang ++ Xcode 4.4 Initialize Initialization of Non-Static Element and Move

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>

//
// 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 and Clang throw an error on this line:

"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor"
+5
source share
1 answer

This is similar to the clang error in the open source svn repository. Could you submit a bug report against clang here : http://llvm.org/bugs/ ?

Thank!

+3
source

All Articles