Boost logo

Boost Users :

Subject: Re: [Boost-users] Getting metadata of class
From: Alex Vinokur (alexvn_at_[hidden])
Date: 2009-12-12 02:01:54

"OvermindDL1" <overminddl1_at_[hidden]> wrote in message
> On Fri, Dec 11, 2009 at 10:45 AM, Alex Vinokur
> <alexvn_at_[hidden]> wrote:
>> Hi,
>> Does Boost contain any features to get metadata of classes?
>> For instance,
>> Let Foo be some class
>> class Foo
>> {
>> int m_var1;
>> long* m_var2]
>> char m_var3[100];
>> dooble m_var4;
>> };
>> I would like to get the following info (as vector, file, etc) of its
>> members:
>> {" m_var1", "int", sizeof (m_var1), offset of (m_var1) },
>> {" m_var2", "long", "Pointer", sizeof (m_var2), sizeof (base-variable,
>> i.e.,
>> long), offset of (m_var2 },
>> {" m_var3, "char", "array", sizeof (m_var3), sizeof (base-variable, i.e.,
>> char), offset of (m_var3 },
>> {" m_var4", "double", sizeof (m_var4), offset of (m_var4) },
>> That info I would like to get as a result of some feature (function, ...)
>> applied to class Foo, not to each member of Foo.
> C++ is not introspective nor reflective, hence there is no way to do
> that according to the language spec. However, you can use Fusion to
> 'convert' your stucts to a fusion map or vector (depending on if you
> need names or not)

Is there such a convertor (struct->map) in

I am not familiar with boost::fusion.

Thank you very much.
> and work on it at compile time, and there is an
> introspective/reflective library in the sandbox if you do not mind
> adding things directly to your structs, it has more power for asking
> information about things instead of just operating on it like with
> Fusion, but you cannot operate on the things like you can with Fusion,
> depends on what you are needing to do... There are a few external
> things like gcc-xml that you can parse the info from as well.
> All in all, no easy way to do this. Would be nice if C++ had this
> ability built in (no real reason why it cannot for compile-time work),
> but meh...



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at