I have a set of classes that have the following structure:
class U
{
public:
explicit U(int) { ... }
U() {...}
Init(int) {...}
};
I need to be able to compose 1 or more of these classes into a class X. Pseudocode:
template<class TypeSequence>
class X that derives publicly from all the classes in TypeSequence
{
X(int): all bases are initialized with the integer passed
{}
//if the above constructor is impossible, then the following will do as well:
X(int)
{
Call Init on all bases and pass the given int to them.
}
};
I think I need a lot of mpl, but I'm not really good at it. Is what am I trying to do doable? A code sample would be great.
MY FAULT: Forgot to mention I can't use C++11 features. I am looking for an MPL solution.
boost::mpl::vector<>
iterators as template arguments. – Macaroon