c++ - How to check if std::map contains a key without doing insert? -
the way have found check duplicates inserting , checking std::pair.second
false
, problem still inserts if key unused, whereas want map.contains(key);
function.
use my_map.count( key )
; can return 0 or 1, boolean result want.
alternately my_map.find( key ) != my_map.end()
works too.
Comments
Post a Comment