
A Flexible Reflection System in C++: Part 1 - signa11
http://preshing.com/20180116/a-primitive-reflection-system-in-cpp-part-1/
======
halayli
Recently I've been using clang's parser Python bindings to parse c++ headers
and generate code that reflect object's members and integrate that into cmake.

It beats the purpose if whatever you're going to come up with requires you to
specify every field and maintenance becomes tricky.

------
tomalpha
> This reflection system is based on preprocessor macros and templates. C++,
> at least in its current form, was not designed to make runtime reflection
> easy.

This is something I’d love to see changed in an upcoming C++ standard. (I lose
track of exactly what we are or aren’t getting with whatever’s coming next so
it’s possible it is already...)

Creating C++ reflection systems seems to be a common need and oft-repeated.
IMHO one of the appeals in doing so is that you have to be _clever_ and use
either complexity or tricks to make it work. That’s not intended to criticize
the author here, but I would really like not to have to be _clever_ in solving
a common problem.

~~~
jcelerier
> This is something I’d love to see changed in an upcoming C++ standard. (I
> lose track of exactly what we are or aren’t getting with whatever’s coming
> next so it’s possible it is already...)

[https://cppx.godbolt.org](https://cppx.godbolt.org) (and
[https://herbsutter.com/2017/07/26/metaclasses-thoughts-on-
ge...](https://herbsutter.com/2017/07/26/metaclasses-thoughts-on-
generative-c/))

~~~
tomalpha
Thanks for the info. It looks like we’ve a little while to wait, but there
does at least appear to be a push for this kind of feature. I’ll keep my
fingers crossed :)

------
signa11
and part-2 is available here: [http://preshing.com/20180124/a-flexible-
reflection-system-in...](http://preshing.com/20180124/a-flexible-reflection-
system-in-cpp-part-2/)

