I've got problem with creating function that for given type, if it's derived from other one do something and for all other cases do something other. My code:
class BaseClass {};
class DerivedClass : public BaseClass {};
template <typename T>
void Function(typename std::enable_if<std::is_base_of<BaseClass, T>::value, T>::type && arg) {
std::cout << "Proper";
}
template <typename T>
void Function(T && arg) {
std::cout << "Improper";
}
void test() {
Function(DerivedClass{});
}
For class DeriviedClass
and other based on BaseClass
I'd like to call function couting Proper
, but it couts Improper
. Any suggestions?
auto Function(T) -> typename enable_if<???, void>::type
. – Duckboard