I have a struct foo as so -
template <typename T, typename...V>
struct foo;
I want to specialize this struct when T meets a specific condition, namely when it inherits from a class bar.
I know how to write this condition using std::is_base_of<bar, T>::value and combine it with std::enable_if.
Without the variadic template I could use an extra template argument (void) and default argument like so -
template <typename T, class Enable=void>
struct foo {
// default implementation
};
template <typename T>
struct foo <T, typename std::enable_if<std::is_base_of<bar, T>::value>::type> {
// Implementation when T inherits from bar
};
But I cannot combine variadic templates and default template argument because both need to be the last template arguments.
Any suggestions how I can implement this specialization?