#include <iostream>
template <class T>
class A {
T d;
public:
A(T a) : d(a) {}
template<class U, class V>
friend auto operator*(U& x, V& y) -> decltype(U::d * V::d);
};
template<class T, class U>
auto operator*(T& x, U& y) -> decltype(T::d * U::d)
{
return x.d * y.d;
}
int main()
{
A<double> a(3.0);
A<int> b(5);
std::cout << a * b << std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGUgPGNsYXNzIFQ+CmNsYXNzIEEgewogIFQgZDsKcHVibGljOgogIEEoVCBhKSA6IGQoYSkge30KICB0ZW1wbGF0ZTxjbGFzcyBVLCBjbGFzcyBWPgogIGZyaWVuZCBhdXRvIG9wZXJhdG9yKihVJiB4LCBWJiB5KSAtPiBkZWNsdHlwZShVOjpkICogVjo6ZCk7Cn07Cgp0ZW1wbGF0ZTxjbGFzcyBULCBjbGFzcyBVPgphdXRvIG9wZXJhdG9yKihUJiB4LCBVJiB5KSAtPiBkZWNsdHlwZShUOjpkICogVTo6ZCkKewogIHJldHVybiB4LmQgKiB5LmQ7Cn0KCmludCBtYWluKCkKewogIEE8ZG91YmxlPiBhKDMuMCk7CiAgQTxpbnQ+IGIoNSk7CgogIHN0ZDo6Y291dCA8PCBhICogYiA8PCBzdGQ6OmVuZGw7Cn0=