class NonCopyable
{
public:
NonCopyable() = default;
NonCopyable(const NonCopyable&) = delete;
NonCopyable& operator=(const NonCopyable&) = delete;
};
我用VS2010试过上面的代码,编译不通过。
1>c:\temp\app1\app1\app1.cpp(12): error C2065: 'default' : undeclared identifier
1>c:\temp\app1\app1\app1.cpp(12): error C2253: 'NonCopyable' : pure specifier or abstract override specifier only allowed on virtual function
1>c:\temp\app1\app1\app1.cpp(13): error C2059: syntax error : ';'
1>c:\temp\app1\app1\app1.cpp(13): error C2238: unexpected token(s) preceding ';'
1>c:\temp\app1\app1\app1.cpp(14): error C2059: syntax error : ';'
1>c:\temp\app1\app1\app1.cpp(14): error C2238: unexpected token(s) preceding ';'
1>
1>Build FAILED.
问题> 据我所知,default
和delete
是C++0x 的新特性。
VS2010 是否支持这些新标准?
//已更新 -- gcc 版本 4.5.2 支持它//
//gcc 版本 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
$ ~/Documents/C++ $ g++ -o t2 t2.cpp -std=c++0x
最佳答案
不,遗憾的是 VC2010 没有。它甚至不支持自动生成的移动构造函数。
Here is a list of C++11 features VC2010 supports.请注意,其中一些仅得到部分支持。
关于c++ - VS2010 支持 'controlling compiler-generated functions' 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8495196/