use*_*676 5 c++ xcode clang member-initialization c++11
我正在使用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;
}
Run Code Online (Sandbox Code Playgroud)
Xcode 4.4和Clang抛出该行中的错误说:
"Copying member subobject of type 'std::atomic<int>' invokes deleted constructor"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
759 次 |
| 最近记录: |