【发布时间】:2016-04-23 04:40:29
【问题描述】:
我正在为 Boost 无序地图容器编写包装器方法。在 boost Unordered Map 中有一个方法 begin(), 它返回一个指向第一个元素的迭代器。在我的包装器中,我试图编写一个模板化的包装器。例如
template< class Tkey, class Tvalue>
class CMyUnorderedMap
{
boost::Unordered_map<TKey, TValue> m_myMap;
public:
boost::unordered_map<TKey, TValue>::iterator Begin();
};
template< class Tkey, class Tvalue>
boost::unordered_map<TKey, TValue>::iterator CMyUnorderedMap< TKey, TValue >::Begin()
{
return m_myMap.begin()
}
在编译上述代码时(带有模板参数),我在 VS 2010 中遇到如下编译错误。
warningc4346: boost::unordered::unordered_map::iterator : 依赖名称不是类型。
error C3860 template argument list following class template name must list paramaters in the order used in tempate paramater list
但是,如果我在没有模板参数的情况下编译代码,则代码符合。 例如,如果像下面这样指定它可以工作
boost::unordered_map< std::string, std::string>::iterator Begin();
有人帮忙吗
【问题讨论】: