Std::pair语言 - error:模板参数数目错误
std::pair - error: wrong number of template argument
我有一个std::pair声明,如下面的代码片段所示,在第152行编译错误下面的c++问题说"错误:模板参数数量错误(1,应该是2)"。我对这种std::pair的事情是新的,我想知道我做错了什么。因此,上述行号已在下面的代码片段中标记。谢谢。
std::vector<
std::pair<EndPointAddr* requesterServiceAddr,
EndPointAddr* requestedServiceAddr>* //LINE 152 is HERE
> mServiceSubscriptionsList;
In file included from ServiceRegistrar.hpp:8:0,
from ServiceRegistrar.cpp:7:
../control_api/ServiceRegistrarAPI.hpp:152:95: error: wrong number of template arguments (1, should be 2)
........
.......
../control_api/ServiceRegistrarAPI.hpp:153:14: error: template argument 1 is invalid
../control_api/ServiceRegistrarAPI.hpp:153:14: error: template argument 2 is invalid
In file included from ../control_api/ServiceRegistrarAPI.cpp:5:0:
std::pair
在声明中只需要类型
std::vector<
std::pair<EndPointAddr*,
EndPointAddr* >* //LINE 152 is HERE
> mServiceSubscriptionsList;
您需要将类型作为模板参数,而不是变量:
std::vector< std::pair<EndPointAddr*, EndPointAddr*>* >
相关文章:
- 在函数中使用 const int size 参数创建数组会在 Visual Studio 中抛出错误 C++:表达式的计
- 如何在模板函数中实例化其长度使用模板参数的数组
- 基于参数创建数组
- Pybind11 默认参数 numpy 数组或 None
- 有没有办法根据命令行参数定义数组大小?运行时与编译时实例化?
- 更改为参数的数组的值
- 根据 C++11 中的模板参数选择数组大小
- 是否可以使用C 函数中的const int参数创建数组
- 根据参数将数组分成 5 个不同的数组
- 你究竟如何通过函数的参数传递数组?
- 函数参数中数组大小未指定
- 数组作为函数参数查找数组长度时出错
- 如何使用函数参数设置数组大小
- 可变参数模板数组调用未定义的行为
- 提升 1.55,而 13 信号参数错误数
- 指向作为模板参数的数组的指针
- C++可变参数模板数组/访问元素
- 在 c++ 中没有参数的数组
- 具有双精度参数的数组
- 使用 C++11 的 begin() 和 end() 函数通过参数确定数组维度