fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. template<class T>
  7. class A:public vector<T> {
  8. public:
  9. void fillAndMove();
  10.  
  11. vector<T> help;
  12.  
  13. A & operator=(const std::vector<T> & rhs)
  14. {
  15. for(auto it : help)
  16. {
  17. this->push_back(it);
  18. }
  19. return *this;
  20. }
  21. };
  22.  
  23. template<class T>
  24. void A<T>::fillAndMove() {
  25. help.resize(2);
  26. help[0] = 5;
  27. help[1] = 3;
  28.  
  29. (*this) = move(help);
  30. }
  31.  
  32. int main(void)
  33. {
  34. A<int> test;
  35. test.fillAndMove();
  36. std::cout << test[0] << test[1];
  37.  
  38. return 0;
  39. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
53