Boost logo

Boost Users :

Subject: [Boost-users] [mpl] register types in a mpl sequence type
From: Thomas Lemm (Thomas.Lemm_at_[hidden])
Date: 2009-04-09 08:48:52


All,

I am trying to accomplish a compile time type registry by trying to register a specific subset of my classes into an mpl sequence type. So during compilation that sequence type should hold a sequence of my classes for subsequent processing (e.g. by mpl::for_each).

An example:
--- code start --------------
class Super {
   tyedef mpl::list<> SubTypesList;

   // usage of SubTypesList:
   printSubtypes() { mpl::for_each< SubTypesList >( ... )};
};

class A : public RegisterWith< A, Super > {};

class B : public RegisterWith< B, Super > {};
--- code end --------------

now Super::SubTypesList should be equivalent to mpl::list< A, B >.

I have the feeling that this approach is not achievable with templates alone due to the C++ template mechanism not being able to redefine a type.

Still I would be happy being proven wrong. Any pointers to similiar problems and solutions, alternative approaches (maybe using the boost_pp?) are welcome, too.

Kind regards

Thomas Lemm


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net