C++ "error: no matching function"

标签 c++ ros

我看到了这个问题:

   src/planning.cpp:892:95: error: no matching function for call to ‘std::vector<std::pair<pcl::PointXYZ, cv::Point_<float> > >::vector(int, std::pair<pcl::PointXYZ, int>)’
     std::vector<std::pair<PointT,cv::Point2f> > _candidate_points(3,make_pair(PointT(0,0,0),0));

有人知道怎么解决吗?

最佳答案

您作为构造函数的第二个参数提供的值的类型与 vector 中存储的类型不匹配。容器中存储的类型是std::pair<pcl::PointXYZ, cv::Point_<float> , 并且您提供的值的类型是 std::pair<pcl::PointXYZ, int> .

您可能需要显式转换最后一个 0cv::Point_<float>因为隐式转换在模板参数中不起作用。例如,您不能将一对整数传递给需要一对 double 的函数,即使您可以将单个整数传递给需要 double 的函数也是如此。

关于C++ "error: no matching function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52068816/

相关文章:

c++ - 为什么编解码器 x264/x265 会忽略输入帧的 pts 和 dts?

C++ 结构排序错误

c++ - 可以将指向子类的指针分配给具有父类(super class)类型的变量吗?

c++ - ROS Linking errors using boost::filesystem library 在linux下使用C++

python - 如何修复 "[rospack] Error: package ' 未找到 my_package'

ubuntu - 如何使用 Gazebo 从给定的 map 图像构建 map ?

C++:获取时区偏差

c++ - 为什么我必须通过this指针访问模板基类成员?

ros - 无法将 underlay ros2 安装与 drake-ros 一起用作 Bazel 工作区中的外部

c++ - 使用 cv::rgbd::Odometry::compute