Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No matching function to call Std::find?

Tags:

c++

stl

qt

I am trying to do:

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

where:

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

but I get:

error: no matching function for call to 'find(QMap<unsigned int, MI*>::iterator, QMap<unsigned int, MI*>::iterator, QRgb&)
like image 853
Samuel Avatar asked Jan 30 '26 04:01

Samuel


2 Answers

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).

like image 126
Mark B Avatar answered Jan 31 '26 21:01

Mark B


Use the QMap::find() method instead.

like image 42
Nikolai Fetissov Avatar answered Jan 31 '26 20:01

Nikolai Fetissov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!