【发布时间】:2015-07-20 11:02:30
【问题描述】:
此代码在 Visual Studio 2013 上运行,但不在 gcc 4.9.2 上:
template <typename T>
void foo(){
T::value_type bar('a');
cout << bar << endl;
}
int main() {
foo<string>();
return 0;
}
似乎 Visual Studio 2013 推断类型以允许我实现模板参数中定义的类型,而 gcc 4.9.2 does not。
是否有一种解决方法可以在 gcc 中允许这种行为?
【问题讨论】:
-
您遇到的错误是什么,这会有所帮助
标签: c++ visual-studio templates gcc types