
On Mon, Jun 28, 2010 at 3:32 PM, Sohail Somani <sohail@taggedtype.net> wrote:
On 10-06-28 8:00 AM, Stefan Strasser wrote:
template<class Mapping> friend void introspect(Mapping mapping,type<A>){ mapping (base_class<A_base>() ) (member<A,int ,&A::m_a>() ) (member<A,float ,&A::m_b>() ) (member<A,std::vector<int>,&A::m_vec>()) (); }
I think a library like this would be useful.
Just FYI there is also another introspection/reflection library being developed for boost called Mirror. It can be downloaded from sourceforge here: http://sourceforge.net/projects/mirror-lib/files/ or from the boost vault. There are actually two versions: pre-c++0x (which is currently on hold) and c++0x (being actively developed) The current (work-in-progress) docs for the c++0x version can be found here: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/index.html To get some idea on how the library is used I suggest looking here: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/examples.html The registering process is explained here: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/mirror__registering.html although much more can be found in the docs.
Isn't it simpler to specialize a template? Why does this need to be done at run-time? How do you introspect a type's constructors?
Mirror allows to introspect constructors and actually there is a utility called factory generator, which uses this meta-information to generate factory classes for various product types.The docs for this utility can be found here: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/mirror__factory__generat... but they are not finished.
[snip] BR, Matus