Suppose I have a class template with a type template parameter pack, like
template<typename... types>
class Foo {};
Is there any way I could define methods in Foo, say void bar(T x);
with overloads for each type T in the parameter pack types
?
You can have Foo
inherit each base with void bar(T x)
:
template<typename T>
struct FooBase {
void bar(T x);
};
template<typename... types>
struct Foo : FooBase<types>... {
using FooBase<types>::bar...;
};