You can avoid C++11 lambda's if you want writing your own functor class, but the argument of operator() should be the same. UPD. My original answer was wrong, because I wrote pair<,int, bool>, instead of pair<,const int, bool>,. This mistake shows importance of typedefs: if you used instead of plain map definition, you could write the type as MyMapT::value_type. It is way easier to understand and prevents you from making unnecessary temporaries as I did before. Here's an example of how you can store the bool values in a std::vector at the unsequential indexes used as keys in the std::map (sort of like a hash bucket). The std::vector will be initialized with as many (false) values so that the biggest key number in the std::map will fit. The smallest number used as key must be greater or equal to zero. Source.