#include <iostream>

template<typename T>
class X {
public:
     X(T t) {}
    friend void func(const X& lhs, const X& rhs) {}
};

template <typename T> X<T> asX(const T& t) { return {t}; }
template <typename T> const X<T>& asX(const X<T>& x) { return x; }

template<typename LHS, typename RHS>
void func(const LHS& lhs, const RHS& rhs) { return func(asX(lhs), asX(rhs)); }


int main() {
	X<int> x1(42);
	X<int> x2(51);

	func(42, 24);
	func(x1, 24);
	func(x1, x2);


}