fork(1) download
  1. #include <iostream>
  2. #include <functional>
  3. #include <map>
  4.  
  5. int main(int argc, char *argv[]) {
  6. std::function<bool(int, int)> cmp;
  7. if (argc > 2) cmp = std::less<int>{};
  8. else cmp = std::greater<int>{};
  9. std::multimap<int, int, decltype(cmp)> map(cmp);
  10. map.emplace(1, 1);
  11. map.emplace(2, 2);
  12. map.emplace(3, 3);
  13. for (auto p: map) {
  14. std::cout << p.first << " ";
  15. }
  16. std::cout << std::endl;
  17. return 0;
  18. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
3 2 1