VS2013编译含模板代码时的问题
我在VS2013编译模板的时候遇到了很奇怪的问题...
简化代码如下
#include <unordered_map>
template<typename Type, typename Key>
class KVM
{
public:
typedef std::unordered_map<Key, Type> ObjectMap;
typedef ObjectMap::iterator ObjectMapIter;
};
int main(int argc, char* argv[])
{
KVM<int, int> kvm;
return 0;
}
这个报编译错误
1>------ 已启动生成: 项目: TemplateTest, 配置: Debug Win32 ------
1> TemplateTest.cpp
1>e:\myproject\templatetest\templatetest\templatetest.cpp(8): warning C4346: “std::unordered_map<Key,Type,std::hash<Key>,std::equal_to<Key>,std::allocator<std::pair<const Key,Type>>>::iterator”: 依赖名称不是类型
1> 用“typename”为前缀来表示类型
1> e:\myproject\templatetest\templatetest\templatetest.cpp(9): 参见对正在编译的类 模板 实例化“KVM<Type,Key>”的引用
1>e:\myproject\templatetest\templatetest\templatetest.cpp(8): error C2146: 语法错误: 缺少“;”(在标识符“ObjectMapIter”的前面)
1>e:\myproject\templatetest\templatetest\templatetest.cpp(8): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
哪位大神指导如何解决??