AT
http://blogs.msdn.com/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx
有一个表显示在2010 RC中实现的C++ 0x特性。其中列出了转发枚举和强类型枚举,但它们被列为“部分”。本文的主要内容说,这意味着它们要么不完整,要么以某种非标准的方式实现。
所以我得到了VS2010RC和AM的C++0X特性。我找不到这些特性,也找不到关于这两个特性的任何文档。即使是最简单的编译尝试也不行。
enum class E { test };
int main() {}
fails with:
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(518): error C2332: 'enum' : missing tag name
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(518): error C2236: unexpected 'class' 'E'. Did you forget a ';'?
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(518): error C3381: 'E' : assembly access specifiers are only available in code compiled with a /clr option
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(518): error C2143: syntax error : missing ';' before '}'
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(518): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
int main()
{
enum E : short;
}
Fails with:
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(513): warning C4480: nonstandard extension used: specifying underlying type for enum 'main::E'
1>e:\dev_workspace\experimental\2010_feature_assessment\2010_feature_assessment\main.cpp(513): error C2059: syntax error : ';'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
因此,似乎一定是一些完全非标准的实现让他们有理由将这个特性称为“部分”完成。如何重写该代码以访问转发和强类型功能?
有关我尝试使用的新功能的更多信息:
强类型枚举:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
枚举的转发声明:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf