Guest User

Untitled

a guest
Dec 17th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<vector>
  4.  
  5. int main()
  6. {
  7. std::vector<int> v1;
  8. int i;
  9. while(std::cin>>i)
  10. {
  11. v1.push_back(i);
  12. }
  13.  
  14. for(i : v1) //for (int i:v1) works
  15. std::cout<<i<<"t";
  16. cout<<std::endl;
  17. return 0;
  18. }
  19.  
  20. for (auto it = range.begin(), end = range.end(); it != end; ++it) {
  21. use(*it);
  22. }
  23.  
  24. for (<range-decl>: <range>) { <body> }
  25.  
  26. {
  27. auto&& range = <range>; // keep the range alive!
  28. auto it = begin(range); // actually, reality is bit more complicated
  29. auto end = end(range); // actually, reality is a bit more complicated
  30. for (; begin != end; ++it) {
  31. <range-decl> = *it; // this is the rewrite causing your issue
  32. <body>
  33. }
  34. }
  35.  
  36. for ( declaration : range ) statement;
Add Comment
Please, Sign In to add comment