【发布时间】:2016-09-21 16:27:52
【问题描述】:
我正在阅读来自here 的Scoped enumerations 页面:
$ cat e.cxx
#include <cstdint>
enum class Handle : uint32_t { Invalid = 0 };
int main()
{
Handle h { 42 }; // OK
return 0;
}
$ g++ -std=c++11 e.cxx
e.cxx: In function ‘int main()’:
e.cxx:5:17: error: cannot convert ‘int’ to ‘Handle’ in initialization
Handle h { 42 }; // OK
^
使用:
$ g++ --version
g++ (Debian 5.3.1-14) 5.3.1 20160409
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
如果我现在检查 GCC 中的 C++11 支持,似乎自 GCC 4.8 以来所有内容都受支持。
那么我读错了哪一页? Score enumertions的例子不是100%正确,还是GCC对C++11的支持还不完善?
【问题讨论】:
-
你尝试在c++11中使用一个c++17的特性,不工作是完全正常的
标签: c++ c++11 gcc language-lawyer