fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. template<typename T, typename Allocator = std::allocator<T>>
  5. class Vector: public std::vector<T, Allocator>
  6. {
  7. using basic = std::vector<T, Allocator>;
  8. public:
  9. using basic::basic;
  10. using basic::operator =;
  11.  
  12. template <typename U, typename OtherAllocator = std::allocator<U>>
  13. Vector & operator =(const Vector<U, OtherAllocator>& other) {
  14. this->assign(other.begin(), other.end());
  15. return *this;
  16. }
  17. };
  18.  
  19. int main()
  20. {
  21. Vector<int> vi{1,2,3,4,5};
  22. Vector<double> vd;
  23. vd = vi;
  24. for (double d : vd)
  25. std::cout << d << " ";
  26. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
1 2 3 4 5