In a templated class I'd like to enable a function only if a class type and the methods type are std::complex or if both are not complex.
template<typename T>
class M {
public:
template<typename T2>
void method(T2 arg) { }
};
I'd like to the enable method only if T and T2 are std::complex or if both are not std::complex.
I found How to identifying whether a template argument is std::complex? to get a template telling me how to check whether a type is std::complex-based or not. But I'm struggling with the formulation of the template-usage to use std::enable_if. I tried something with std::is_same, I haven't found how to do it. Then there is a way where you get the return-type from within std::enable_if, but again it didn't work as expected.
You can deduce template arguments:
A more complete example:
Live On Coliru
Printing