ein*_*ica 9 c++ enums gcc forward-declaration c++11
我知道,一般来说,我们可以在 C++11 中前向声明枚举。
那么,为什么会这样:
enum kind_t { kind1, kind2 };
template <kind_t Kind> struct foo {};
template <> struct foo<kind1> {
enum named : int;
};
enum foo<kind1>::named : int {
named1 = 123,
named2 = 456,
};
Run Code Online (Sandbox Code Playgroud)
使用 GCC (12.1) 编译失败?错误是(上帝螺栓):
<source>:9:6: error: cannot add an enumerator list to a template instantiation
9 | enum foo<kind1>::named : int {
| ^~~~~~~~~~
ASM generation compiler returned: 1
<source>:9:6: error: cannot add an enumerator list to a template instantiation
9 | enum foo<kind1>::named : int {
| ^~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
这似乎可以用 clang++ 14.0编译得很好...
| 归档时间: |
|
| 查看次数: |
121 次 |
| 最近记录: |