std::map counts; // populate the map for (auto& num : counts) { auto a = num.first; auto a_count = num.second; // do something useful }