5 ms·
You're talking about serialization, and I agree that using reflection for that is both an overkill and somewhat hacky (you still have to define the serializatio
by zvrba 10y ago
You're talking about serialization, and I agree that using reflection for that is both an overkill and somewhat hacky (you still have to define the serialization format).
Reflection on the other hand is immensely useful if you want to, for example, automatically generate type-safe bindings for, say, Python or .NET or Java, from your C++ classes.
- ThisIs_MyName 10y agoWouldn't you prefer to generate type-safe bindings at compile-time?
- Kristine1975 10y agoDefinitely. That's why I'm to hyped for compile-time reflection in C++: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/ http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/ (search for "reflection")
- slau 10y agoOne of the authors of that paper, Matúš Chochlík, has been working on this for years. He has a pretty nice implementation that I've used successfully on a number of occasions, even though it requires a pre-compiler pass to generate the necessary data. If I'm not mistaken, he has been working into getting the necessary data available from the compiler directly (which this paper would confirm). Link to his existing library: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/ http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/ Absolutely great guy, as well. Really happy to see him still working on this, year over year. Edit: DYAC.
- billq 10y agoNot to dampen your enthusiasm but it may not happen anytime soon. An explanation, and a solution, is offered on my blog: http://chinbilly.blogspot.co.uk/2016/03/ponder-c-reflection.html http://chinbilly.blogspot.co.uk/2016/03/ponder-c-reflection....