本文介绍了前进/强枚举在VS2010的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在有显示℃的表+ + 0x功能在2010 RC实现。其中包括转发枚举和强类型枚举,但它们被列为部分。文章的主要内容说,这意味着他们是不完整或在某些非标准的方式实现的。

At http://blogs.msdn.com/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx there is a table showing C++0x features that are implemented in 2010 RC. Among them are listed forwarding enums and strongly typed enums but they are listed as "partial". The main text of the article says that this means they are either incomplete or implemented in some non-standard way.

所以我有VS2010RC和我在玩弄C ++ 0x功能。我不能把这些出来,找不到这两个功能的任何文档。甚至不是最简单的尝试编译。

So I've got VS2010RC and am playing around with the C++0x features. I can't figure these ones out and can't find any documentation on these two features. Not even the simplest attempts compile.


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 ==========

所以看来它必须是一些完全非标准的实现,允许他们调用这个功能部分完成。如何重写该代码以访问转发和强类型功能?

So it seems it must be some totally non-standard implementation that has allowed them to justify calling this feature "partially" done. How would I rewrite that code to access the forwarding and strong type feature?

有关我尝试使用的新功能的进一步信息:

Some further information about the new features I'm attempting to use:

强类型枚举:

转发枚举声明:

推荐答案

我认为我找到了答案。我在VS 2010文档中的关键字文档下找到枚举类。它仅受管理 - 在实际的C ++构建中不受支持。所以看来,他们的意思是这个C ++ 0x功能是部分完成,因为它根本没有做。

I think I found the answer. I found "enum class" in the VS 2010 documentation under the keywords documentation. It's managed only--unsupported in real C++ builds. So it seems that they mean this C++0x feature is "partially done" in that it isn't done at all.

这篇关于前进/强枚举在VS2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:07