gcc:模板参数的数量错误
gcc: wrong number of template arguments
为什么这段代码在VS13中编译成功,而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于7年前发布。它和那个时代的旧VC编译器一样有漏洞。由于新的编译器运行良好,很难找到问题所在。尝试更新编译器。
相关文章:
- 如何通过参数抛出错误消息
- 我收到同义重复编译器错误。我应该如何修复"类型"X"的参数与类型"X"的参数不兼容?
- 错误 没有与参数列表匹配的重载函数"getline"实例
- 为什么 std::绑定错误参数可以成功?
- 在函数中使用 const int size 参数创建数组会在 Visual Studio 中抛出错误 C++:表达式的计
- g++ 为 transform() 的参数生成错误
- 如何在C++中使用 Void 而不会收到有关参数的错误
- 错误:参数中无效地使用了无效表达式
- xgboost 构建错误:参数包未扩展为"..":
- src/caffe/parallel.cpp:70:1:错误:“参数”未命名类型
- OpenCV 错误:ERClassifierNM1 中的错误参数
- 为什么显示错误:参数太少而无法正常工作
- 算法错误:参数无法从对中掩盖 1
- 类模板方法的专用化,类型名称是类模板 - 错误:参数处的类型/值不匹配
- C++连接函数错误-参数无效
- 错误:参数无效
- (自适应)opencv中的阈值错误(cvarrToMat中的错误参数(未知数组类型))
- OpenCV错误:cvGetSize中的错误参数(数组应该是CvMat或IplImage)
- OpenCV 2.2:未知函数中的错误参数,文件.. .ocv OpenCV modulescoresr
- 错误:参数声明的存储类说明符无效