Clang ++ Xcode 4.4非静态成员初始化和移动构造函数

时间:2012-07-26 18:36:10

标签: c++ xcode c++11 clang member-initialization

我正在使用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和Clang在该行中抛出错误:

"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor"

1 个答案:

答案 0 :(得分:3)

这看起来像是开源svn trunk存储库中的一个clang bug。你能否提交针对clang here的错误报告:http://llvm.org/bugs/

谢谢!

相关问题