没有匹配的函数调用Std::find

No matching function to call Std::find?

本文关键字:Std find 函数调用      更新时间:2023-10-16

我正在尝试:

std::find(images_map.begin(), images_map.end(), current_rgb));

地点:

QRgb current_rgb;
QMap<QRgb, MI*> images_map;

但是我得到:

error: no matching function for call to 'find(QMap<unsigned int, MI*>::iterator, QMap<unsigned int, MI*>::iterator, QRgb&)

原因是find期望容器的value_type与传递给find的搜索对象类型相同。您只传递了键,而不是键和值。

相反,在容器本身上使用find方法(它也具有对数时间复杂度而不是线性时间复杂度的好处)。

请使用QMap::find()方法。