I need to write a templated function, that behaves differently depending on the class of its parameter:
template<class ContainerType>
bool myFunc(ContainerType in){
//do some stuff
}
template<class NotAContainerType>
bool myFunc(NotAContainerType in){
//do something else
}
I am restricted to C++11, so static_if
is off the table. Also, the classes of ContainerType
and NotAContainerType
are really large and might change in the future, so just adding a few exceptions by hand as a template specialization is not sensible either.
I am aware of the std::enable_if
workaround, but how do I use it, if I need to apply it to two mutually distinct sets of classes?
std::enable_if
is exactly what you are looking for - so just define how you distinguish a "container" type from others. – Gustavo