mardi 5 novembre 2019

How to use std::find in a std map with pointers as keys

I created a map where keys are pointers to an array index. and later trying to find the address using std::find and passing address of the index. But what I observed is it looks for dereferenced value of the address

Here is a sample code snippet Iam trying

unsigned char arr[8];
std::map<unsigned char*, unsigned char> arrmap;

arrmap.insert({&arr[0], 5});
auto itr = std::find(&arr[0]);

so when I try to debug the address is inserted as expected but the std::find is not able to search for it.

How do I search for my address in map as key?

Aucun commentaire:

Enregistrer un commentaire