Clang++ Xcode 4.4 Non Static Member Initialization and Move constructor
c++, c++11, clang, member-initialization, xcode
Solution
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!
Problem
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" ```