fork download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. class X {
  5. public:
  6. X(T t) {}
  7. friend void func(const X& lhs, const X& rhs) {}
  8. };
  9.  
  10. template <typename T> X<T> asX(const T& t) { return {t}; }
  11. template <typename T> const X<T>& asX(const X<T>& x) { return x; }
  12.  
  13. template<typename LHS, typename RHS>
  14. void func(const LHS& lhs, const RHS& rhs) { return func(asX(lhs), asX(rhs)); }
  15.  
  16.  
  17. int main() {
  18. X<int> x1(42);
  19. X<int> x2(51);
  20.  
  21. func(42, 24);
  22. func(x1, 24);
  23. func(x1, x2);
  24.  
  25.  
  26. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty