我有包含该行的代码
enum struct cols: int8_t {red, blue, green};
当我编译这个时,我得到错误:
test.cpp:4:1: warning: elaborated-type-specifier for a scoped enum must not use the 'struct' keyword
enum struct cols: int8_t {red, blue, green};
^
test.cpp:4:13: error: use of enum 'cols' without previous declaration
enum struct cols: int8_t {red, blue, green};
^
test.cpp:4:17: error: expected unqualified-id before ':' token
enum struct cols: int8_t {red, blue, green};
^
但是,如果我把线
#include <iostream>
在顶部,它毫无怨言地编译。
对此有解释吗?
(我使用的是 g++ 4.9.4,但这种行为也显示在 g++ 5.4.0 中。)