fork download
  1. #include <map>
  2. #include <string>
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. typedef map<int, string> mymap_t;
  7.  
  8. void somefunction(mymap_t::const_iterator first, mymap_t::const_iterator last)
  9. {
  10. mymap_t subclone(first, last);
  11.  
  12. // use subclone -- it is a mymap_t now :)
  13. for (mymap_t::iterator it = subclone.begin(); it!=subclone.end(); ++it)
  14. {
  15. it->second += '!';
  16. std::cout << "first = " << it->first << ", second = " << it->second << std::endl;
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. mymap_t mymap;
  23. mymap[1] = "One";
  24. mymap[2] = "Two";
  25. mymap[3] = "Three";
  26.  
  27.  
  28. somefunction(mymap.begin(), mymap.end());
  29.  
  30. return 0;
  31.  
  32. }
  33.  
Success #stdin #stdout 0s 2860KB
stdin
Standard input is empty
stdout
first = 1, second = One!
first = 2, second = Two!
first = 3, second = Three!