fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <string>
  5. #include <algorithm>
  6. #include <iostream>
  7.  
  8. typedef std::map<std::string, std::size_t> src_type;
  9. typedef std::vector<std::pair<std::string, std::size_t>> dst_type;
  10.  
  11. int main()
  12. {
  13. src_type src;
  14. dst_type dst;
  15.  
  16. src.insert(std::make_pair("one", 1));
  17. src.insert(std::make_pair("two", 2));
  18. src.insert(std::make_pair("three", 3));
  19.  
  20. std::copy(src.begin(), src.end(), std::back_inserter(dst));
  21.  
  22. for(auto it : dst)
  23. {
  24. std::cout << it.first << " - " << it.second << std::endl;
  25. }
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0s 3232KB
stdin
Standard input is empty
stdout
one - 1
three - 3
two - 2