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