Boost logo

Boost :

Subject: Re: [boost] Is there any interest in a library which solves C++ class reflection feature just like Java does?
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2011-12-07 09:52:39

On Wed, Dec 7, 2011 at 3:46 PM, jinhua luo <ljh.home.king_at_[hidden]> wrote:
> Hi Matus,
> If the reflection requires explicit symbol export/import, then it's not so
> flexible.
> For example, then you must place the Marco declaration within one and only
> one source file due to the ODR (One-Definition-Rule), but can not place it
> anywhere, e.g. the header file. However, the latter one is more reasonable
> and convenient, which makes your macro declaration just follows its class
> definition together.

I get it now, you were talking about exporting something from the library
*per class*, yes that would be bad.

Mirror however requires only one function *per library* so ODR would
not be a problem.

> Another problem is if there exists many classes to be reflected, then your
> library should export an auxiliary symbol per class, which is not a good
> thing, I think, at least it will cause symbol naming collision.
> Last but not least, consider such scenario:
> the main program declares some classes, and the codes within loaded library
> try to reflect them and use them, i.e. the roles exchanges between them.
> Then it's not so possible to export some symbols in the executable on some
> platforms for access by the shared library (of course, on Linux, you can
> export symbols from executable via "-Wl,-E" linker options, but that's also
> bad development practise).


Boost list run by bdawes at, gregod at, cpdaniel at, john at