开发者

No matching function to call Std::find?

开发者 https://www.devze.com 2023-03-20 14:58 出处:网络
I am trying to do: std::find(images_map.begin(), images_map.end(), current_rgb)); where: QRgb current_rgb;

I am trying to do:

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

where:

QRgb current_rgb;
QMap<QRgb, MI*>开发者_Python百科 images_map;

but I get:

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


The reason is because find expects the value_type of the container to be the same as the searchee type passed in to find. You passed in just the key, not the key and value.

Instead, use the find method on the container itself (which also has the benefit of being logarithmic instead of linear time complexity).


Use the QMap::find() method instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消