6

I'm interested in using a reflection library with my code, without going into details, I'm interested in understand what's available out there, strengths and weaknesses etc.

So far I've noticed:

  • CAMP - half-abandoned, no commits for almost a year.
  • Ponder - A CAMP fork which seems to be more active.
  • XM - quarter-abandoned, no commits for half a year at the time I'm writing this.
  • CppRefl - have not checked it out yet.
  • (non-)Boost.Reflect - A boost-style library which is not part of Boost itself.
  • Boost.Mirror - A boost-style library which is not part of Boost itself.
  • Mirror C++ Reflection Utilities Another Boost'ish-style, but not part of Boost. Seems to have been abandoned in 2011.

I couldn't quite find a comparative review of these, or a recommendation from someone who has experience working with them. So, please recommend (or counter-recommend) one of these, or any other reflection library you know of.

Notes:

  • I prefer libraries which require C++11 or C++14 (and thus less ugly and convoluted).
  • Dependence on Boost is (grudgingly) acceptable, as well as dependence on any other (hopefully non-esoteric) library.
3
  • Its hard to do reflection inside C++. If your willing to step outside the language (this may fail your "nonesoteric" requirement), you can get complete metaprogramming access to every aspect of C++ source code. See programmers.stackexchange.com/questions/257266/…
    – Ira Baxter
    Jan 9, 2016 at 11:51
  • @IraBaxter: I don't care about the source code, only about what the source code represents. And I don't want to transform the source, either, although I suppose some kind of a source transformer may (with a capital M) be relevant.
    – einpoklum
    Jan 9, 2016 at 16:29
  • Agreed you don't want to manipulate source code text. The point of the tool I mentioned is that it provides programmatic aspect to the code structure (as an AST) and (out of the box) to all the facts you might consider asking in a reflection world as data structures. For more exotic questions about the code, they can be implemented as custom analyzers in that framework. Of course, there's always the question of what do you want to do with the answers you get; often it is "modify the behavior of the code", which can be done by source transformation.
    – Ira Baxter
    Jan 9, 2016 at 16:44

1 Answer 1

1

There is Antony Polukhin's

magic_get

now known as “Precise and Flat Reflection”. He gave a talk about this library at CppCon 2016: https://www.youtube.com/watch?v=abdeAew3gmQ

1
  • It allows for a bit of reflection. It's a wonderful hack, but doesn't cover what I need.
    – einpoklum
    Jun 8, 2018 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.