I want to do something similar to the code below, except that I don't want to implement func() twice because it will be the same implementation. Do you have any proposal how to accomplish this?
template <typename First, typename... Rest>
class Base : public Base<Rest...> {
public:
using Base<Rest...>::func;
void func(First object) {
// implementation
}
};
template <typename First>
class Base<First> {
public:
void func(First object) {
// implementation
}
};
struct X {};
struct Y {};
struct Z {};
class Derived : public Base<X, Y, Z> {};
// ...
Derived d;
d.func(X{});
d.func(Y{});
d.func(Z{});