Basically what I'm thinking about is:
template<typename... Types>
class Foo
{
void Bar(Types var) {};...
};
which when specialized like this:
Foo<S1, S2, S3> foo;
to expand to:
class Foo
{
void Bar(S1 var){};
void Bar(S2 var){};
void Bar(S3 var){};
};
Obviously, it does not make sense in some way but I'll be happy to see some thoughts.
template<class D, class T>
struct FooHelper {
void Bar(T var) {
auto* self=static_cast<D*>(this);
// here use self instead of this
};
};
template<typename... Types>
class Foo: FooHelper<Foo,Types>...
{
template<class D,class T>
friend struct FooHelper<D,T>;
};
this is how you do what you want to do.
We use use the CRTP to give the base class access to everything in Foo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With