Hello everybody,
just when I thought I've seen it all in C++, the
MPL pops up. Typelists where cool and all, but the way you have created an
STL-ish MPL that seperates algorithm and container is stunning to say the least.
It's work like this that reminds me why I choose computer science over
maths.
Anyway, enough praise, I have a few
questions...
Is the current MPL release (July 17th) designed to
work with MSVC 6.0 Service Pack 5? I've seen the test-matrix, and it seems it
should work.
Does the code-generation facilities of MPL allow
something like the following (pseudocode):
template< typename t_TypeList >
class Tree
{
// Constructor;
Tree( t_TypeList[ 0 ]*
a_Child_0,
t_TypeList[ 0 ]* a_Child_1,
t_TypeList[ 0 ]* a_Child_2,
......
t_TypeList[ 0 ]* a_Child_n );
// Attributes;
t_TypeList[ 0 ]*
m_Child_0;
t_TypeList[ 1 ]*
m_Child_1;
t_TypeList[ 2 ]*
m_Child_2;
........
t_TypeList[ n ]*
m_Child_n;
}
Something of a brainstorm I tried was something
like this (pseudocode)
template< typename t_TypeList >
class Tree : public Tree< tail< t_TypeList
>
{
head< t_TypeList >
m_Child;
}
// Recursion termination;
template<> class Tree< emptyList >
{}
This may add all the children to the derived-most
class, but there are two problems, there is no way to reach the child of a
parent-class. Secondly, there is no way to write a constructor, taking all
the children.
Mmmmm, seems the only way to do this is to
explicitly writing out all the cases for n is 1 to 16 (16 should be
enough for my purposes for a long time to come).
Sincerely,
Jaap Suter