Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++
#include <map>
bool key_exists = m.find(k) != m.end();

m is a std::map. If value is not found, find returns end(), else it returns an iterator to the element.
#include <map>
bool key_exists = m.count(k) != 0;

Need C++14
#include <map>
bool key_exists = m.contains(k);

Need C++20
M.Contains (K)

New implementation...