fork(1) download
  1. #include <iostream>
  2. #include <list>
  3.  
  4. class ObjectB
  5. {
  6. std::list<int> l;
  7.  
  8. public:
  9. template<typename T, typename... Args>
  10. ObjectB(T FirstInt, const Args... RemainingInts)
  11. {
  12. this->l = {FirstInt, RemainingInts...};
  13. }
  14.  
  15. ObjectB& operator = (std::list<int> other)
  16. {
  17. for (auto &o : other)
  18. this->l.push_back(o);
  19.  
  20. return *this;
  21. }
  22.  
  23. auto begin() -> decltype(l.begin()) {return l.begin();}
  24. auto end() -> decltype(l.end()) {return l.end();}
  25. };
  26.  
  27.  
  28. int main()
  29. {
  30. std::list<int> b = {1, 2, 3, 4, 5};
  31.  
  32. ObjectB obj_b = b;
  33.  
  34. for (auto it = obj_b.begin(); it != obj_b.end(); ++it)
  35. std::cout<<*it<<" ";
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1 2 3 4 5