#include <iostream> #include <map> #include <string> #include <boost/foreach.hpp> #include <pstade/oven.hpp> using namespace std; using namespace pstade::oven; #define foreach BOOST_FOREACH int main() { map<string, int> dict; dict["Akira"] = 23; dict["Johnny"] = 38; dict["Millia"] = 16; // key のみ出力 foreach (const string& key, dict|map_keys) { cout << key << endl; } // Akira, Johnny, Millia // value のみ出力 foreach (int value, dict|map_values) { cout << value << endl; } // 23, 38, 16 return 0; }
いいなーこれ