gpt4 book ai didi

c++ - 嵌套名称说明符

转载 作者:IT老高 更新时间:2023-10-28 22:17:29 25 4
gpt4 key购买 nike

我有这样的代码:

namespace mymap {
template <class Key,template <typename T > class Allocator> myownmap {
typedef pair<const unsigned int, Key> typename _myPair;
typedef multimap<unsigned int, Key,less<Key> ,Allocator<_myPair> > typename _entriesType;
}
}

它在 MSVC 下编译成功(并且可以工作),但 gcc 提示语法无效:

.hpp:20: error: expected nested-name-specifier before ‘_myPair’
.hpp:20: error: two or more data types in declaration of ‘_myPair’

我做错了什么?

最佳答案

那里不需要typename,因此是不允许的。

MSVC 直到实际使用模板才正确解析模板,所以有些错误要到以后才发现。

关于c++ - 嵌套名称说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6489351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com