使用Visual Studio 2012时,以下代码编译时没有错误(T是模板参数):
pair<map<T, int>::iterator, bool> ret;
Run Code Online (Sandbox Code Playgroud)
但是,当我使用g ++时,它会抛出错误消息
error: type/value mismatch at argument 1 in template parameter list for template<class _T1, class _T2> struct std::pair
Run Code Online (Sandbox Code Playgroud)
由于某种原因,它不承认map<T, int>::iterator是一种类型.我应该如何解决这个问题?
您需要告诉编译器限定的id map<T, int>::iterator确实是一个类型(它可以是一个静态成员)
pair<typename map<T, int>::iterator, bool> ret;
^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
好像一次一如既往VS做扣更好的错误比G ++.
| 归档时间: |
|
| 查看次数: |
123 次 |
| 最近记录: |