I am trying to use variadic templates for class composition. The idea is that the Composer class simply aggregates a number of variables and forwards function calls to all instantiated variables.
Firstly I am using the following simple wrapper class:
template< typename T >
struct WrapperType
{
typedef T wrapped_type;
typedef typename wrapped_type::value_type value_type;
wrapped_type wrapee_;
WrapperType() : wrapee_{}
{}
};
This is used with the following Composer class, which hopefully derives from WrapperType instantiated for each type in the parameter pack Args:
template< typename... Args >
struct Composer : public WrapperType<Args>...
{
Composer() : WrapperType<Args>{}...
{}
void display()
{
((WrapperType<Args>...)::wrapee_).display(); // HOW?
}
};
Assuming every wrapped type has a display() member function, how can I call the display() function for every type in the parameter pack?
I.E. If I have:
Composer< T1, T2, T3 > myComposer{};
myComposer.display();
I would like myComposer.display() to call display() for T1, T2, T3.