Is it possible, using the boost::describe library, to add additional information about a given type or member?
For instance, if I have a class described like this:
BOOST_DESCRIBE_STRUCT(Foo, (), (bar, baz))
Is there any way to add some kind of additional info, like a tag or flag, to either the members or the type? There's a lot of information about members, such as name, type, visibility, etc. Is there a way to add some custom info to that?
To flag types, I've tried using type traits with std::true_type or std::false type.
However, these are cumbersome to use, because template specializations must be done in the namespace where the type traits were defined, not the namespace where the types being described are defined.
You could use a trait that maps by descriptor. Let me show a contrived complex example that combines multiple pieces of meta data and even behavior:
Live On Coliru
Prints
Further Thoughts
You might also use a Fusion/Hana map to associate information to descriptors. It depends mostly on how you want your code to look of course.
UPDATE
Generalizing a bit (deducing the class type from a member pointer) and supporting member function pointers:
Live On Coliru
Prints