嵌套名称说明符

2024-03-10

我有一个类似的代码:

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’

我做错了什么?


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

MSVC 在实际使用模板之前不会正确解析模板,因此一些错误直到后来才发现。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

嵌套名称说明符 的相关文章

随机推荐