I want to check if a certain key is found in a map, if so i want to put it in a variable for other uses, but the thing is I dont want to use iterators. I found the find function in the map class, but it returns an iterator, I want to like check if a key is found in map, if it returns true to obtain it
Thanks
std::map::count()will inform you if the map contains a particular key. If the key is in the map, then you could useoperator[]to get at the value, knowing that a default value will not be added (though as ildjarn points out would require two searches of the map):Why
find()is unattractive, is not clear to me: