以下代码在 G++ 4.8 下无法编译
#include <vector>
using namespace std;
int main() {
vector<int> v;
typeof(v)::iterator it;
}
如果我将 typeof 替换为 decltype,它可以正常工作。我知道使用模板结构的解决方法
template<class T> struct Self {
typedef T Type;
};
接着
Self<typeof(v)>::Type::Iterator it;
但仍然很烦人。
这是一个应该报告的错误吗?或者这是一个功能?