How can I add reflection to a C++ application?

前端 未结 28 1610
感动是毒
感动是毒 2020-11-21 11:25

I\'d like to be able to introspect a C++ class for its name, contents (i.e. members and their types) etc. I\'m talking native C++ here, not managed C++, which has reflection

28条回答
  •  爱一瞬间的悲伤
    2020-11-21 11:52

    You can achieve cool static reflection features for structs with BOOST_HANA_DEFINE_STRUCT from the Boost::Hana library.
    Hana is quite versatile, not only for the usecase you have in mind but for a lot of template metaprogramming.

提交回复
热议问题