使用诸如 Foo 之类的类:
struct Foo { static const int i = 9; };
我发现 GCC 4.5 会拒绝以下内容
Foo f;
int x = decltype(f)::i;
如果我使用中间类型定义,它将起作用,例如:
typedef decltype(f) ftype;
int x = ftype::i;
但我更喜欢保持命名空间干净。我认为优先级可能是一个问题,所以我也尝试了括号,但没有运气。它是不可能的,还是有一段语法可以帮助我?