fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. typedef vector<int> Vect;
  6.  
  7. Vect operator<<(Vect v, const int i){v.push_back(i); return v;};
  8.  
  9. //Vect& operator<<(Vect& v, const int i){v.push_back(i); return v;}; //<-What I would expect
  10.  
  11. const Vect const_vect = Vect() << 1 << 2;
  12.  
  13. int main() {
  14. for(auto e = const_vect.begin(); e!=const_vect.end() ; ++e){ cout << *e << " ";}
  15. return 0;
  16. }
Success #stdin #stdout 0s 3060KB
stdin
Standard input is empty
stdout
1 2