#include <map>
#include <utility>
#include <iostream>
#include <algorithm>
using namespace std;
namespace {
auto pair2params = [](auto&& f)
{
return [f](auto&& p) {
f(p.first, p.second);
};
};
template<typename Rng, typename Pred>
auto for_each(const Rng& rng, Pred&& pred) -> void
{
for_each(begin(rng), end(rng), pred);
}
}
int main()
{
auto values = map<int, string>{
{0, "hello"},
{1, "world!"}
};
for_each(values, pair2params([](int key, const string& value) {
cout << key << ": " << value << "\n";
}));
}
I2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPGFsZ29yaXRobT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKbmFtZXNwYWNlIHsKCiAgICBhdXRvIHBhaXIycGFyYW1zID0gW10oYXV0byYmIGYpCiAgICB7CiAgICAJcmV0dXJuIFtmXShhdXRvJiYgcCkgewogICAgCQlmKHAuZmlyc3QsIHAuc2Vjb25kKTsKICAgIAl9OwogICAgfTsKICAgIAogICAgCiAgICB0ZW1wbGF0ZTx0eXBlbmFtZSBSbmcsIHR5cGVuYW1lIFByZWQ+CiAgICBhdXRvIGZvcl9lYWNoKGNvbnN0IFJuZyYgcm5nLCBQcmVkJiYgcHJlZCkgLT4gdm9pZAogICAgewogICAgCWZvcl9lYWNoKGJlZ2luKHJuZyksIGVuZChybmcpLCBwcmVkKTsKICAgIH0KCn0KCgppbnQgbWFpbigpCnsKICAgIGF1dG8gdmFsdWVzID0gbWFwPGludCwgc3RyaW5nPnsKICAgICAgICB7MCwgImhlbGxvIn0sCiAgICAgICAgezEsICJ3b3JsZCEifQogICAgfTsKICAgIAogICAgZm9yX2VhY2godmFsdWVzLCBwYWlyMnBhcmFtcyhbXShpbnQga2V5LCBjb25zdCBzdHJpbmcmIHZhbHVlKSB7CiAgICAgICAgY291dCA8PCBrZXkgPDwgIjogIiA8PCB2YWx1ZSA8PCAiXG4iOwogICAgfSkpOwp9