fork(1) download
  1. #include <map>
  2. #include <utility>
  3. #include <iostream>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. namespace {
  10.  
  11. auto pair2params = [](auto&& f)
  12. {
  13. return [f](auto&& p) {
  14. f(p.first, p.second);
  15. };
  16. };
  17.  
  18. }
  19.  
  20.  
  21. int main()
  22. {
  23. auto values = map<int, string>{
  24. {0, "hello"},
  25. {1, "world!"}
  26. };
  27.  
  28. for_each(begin(values), end(values), pair2params([](int i, const string& s) {
  29. cout << i << ": " << s << endl;
  30. }));
  31. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
0: hello
1: world!