Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang++ Xcode 4.4 Non Static Member Initialization and Move constructor

I am using Xcode 4.4 with mountain lion. I can't seems to understand why non-static member initalization in templates invokes a move constructor for the variable. Is there anyway to overcome this error?

Example Code:

#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 throws the error in that line saying:

"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor"
like image 879
user1555676 Avatar asked Oct 22 '22 15:10

user1555676


1 Answers

This looks like a clang bug on the open source svn trunk repository. Could you submit a bug report against clang here: http://llvm.org/bugs/ ?

Thanks!

like image 106
Howard Hinnant Avatar answered Oct 30 '22 04:10

Howard Hinnant