fork(1) download
  1. #include <iostream>
  2. #include <map>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. int main() {
  7. using mymap = std::map<int,int>;
  8.  
  9. mymap m1 { { 1,1 }, { 2,2 }, {3,3} };
  10. mymap m2 { { 2,2 }, {4,4} };
  11.  
  12. std::vector<mymap::value_type> diffs;
  13. std::set_difference( m1.begin(), m1.end(), m2.begin(), m2.end(),
  14. std::back_inserter(diffs),
  15. m1.value_comp() );
  16. for( auto p : diffs )
  17. std::cout << p.first << "-" << p.second << std::endl;
  18. return 0;
  19. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
1-1
3-3