fork download
  1. #include <string>
  2. #include <type_traits>
  3.  
  4. template<typename T>
  5. struct Point {
  6. typedef T value_type;
  7. typedef Point<T> self_type;
  8.  
  9. value_type m_value;
  10.  
  11. Point(value_type value) : m_value(value) {}
  12.  
  13. template<typename RhsT>
  14. self_type& operator = (const Point<RhsT>& rhs) {
  15. m_value = static_cast<value_type>(rhs.m_value);
  16. return *this;
  17. }
  18. };
  19.  
  20. int main() {
  21. Point<int> a1(4);
  22. Point<int> a2(5);
  23. Point<double> a3(6.0);
  24.  
  25. a1 = a2;
  26. a2 = a3;
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3136KB
stdin
Standard input is empty
stdout
Standard output is empty