0
为什么这段代码在VS13中成功编译并且无法通过gcc编译?gcc:模板参数数量错误
///// file my_map.h /////
namespace my
{
// my custom map
template<typename K, typename V, typename order = less<K>, typename allocator = cached_alloc<page_allocator<pair<K,V> > > >
class map : public set_base<pair<K, V>, K, select1st, order, ins_unique, allocator>
{
...
};
}
///// file test.h /////
#include "my_map.h"
template <typename T>
class Base
{
protected:
typedef my::map<T, double> MyMap;
MyMap m_map; // this is line NN
public:
void func(const T& key)
{
typename MyMap::iterator it = m_map.find(key);
if(it != m_map.end()) {
// ....
}
}
};
class Inherited1 : public Base <char>
{ };
class Inherited2 : public Base <int>
{ };
它导致以下错误(GCC 4.1.2)
filepath.h:LineNN error: wrong number of template arguments (1, should be 4)
..: error: provided for 'template<class K, class V, class order, class allocator> class my::map'
目前尚不清楚什么对我的编译器实际上是“错误号码的模板参数”意味着什么?
GCC 4.1.2 ?! olllldddd –
请用'#include's提供一个完整的测试用例。 –
@LightnessRacesinOrbit是的。对不起) –