关于std::map的错误

想使用一个关联容器来存放2d-3d点,最先想到的是:

std::map<cv::Point, pcl::PointXYZ> map_2d_3d;

这样很直观,但是不行。

no match for ‘operator<’ (operand types are ‘const cv::Point_<int>’ and ‘const cv::Point_<int>’)

根据std::map官方文档可知:

std::map is a sorted associative container that contains key-value pairs with unique keys. Keys are sorted by using the comparison function Compare.

大概意思就是说:关键字的类型是需要可排序的类型。后来改成了

std::map<std::pair<int, int>, pcl::PointXYZ> map_2d_3d;

这个是没问题的,求解。

猜你喜欢

转载自www.cnblogs.com/ChrisCoder/p/10211782.html