Hi Everyone,
Some feedback from playing with Boost.Describe for class types.
1. As others pointed out, it is confusing that BOOST_DESCRIBE_STRUCT() and
BOOST_DESCRIBE_CLASS() have such close names, but their interface and
requirements are so different. Maybe rename the latter to
BOOST_DESCRIBE_THIS_CLASS()?
2. Base class subobjects are in some applications treated equivalently to
member subobject; this is why I found it surprising that I cannot get the
names of base class subobjects. But I guess there are implementation
difficulties. Bases can be qualified names.
3. As with enums, _public_member_descriptor_fn in global namespace is UB or
invalid program as per http://eel.is/c++draft/lex.name#3.2.
4. As others pointed out, the part of the interface that uses enum
modifiers is not intuitive. I think that after a while it starts to make
sense: you decide on your use case (like doing RPC), form your enum
bitmask, and then pass it everywhere. It became more-less clear to me only
after I had a look at the implementation of member_filter:
https://github.com/pdimov/describe/blob/develop/include/boost/describe/membe...
Maybe it makes sense to expose this in the docs.
5. Modifier mod_inherited is great for flattening the inheritance structure:
struct X {
int a;
};
struct Y : X {
int b;
};
struct Z : Y {
int c;
};
BOOST_DESCRIBE_STRUCT(X, (), (a));
BOOST_DESCRIBE_STRUCT(Y, (X), (b));
BOOST_DESCRIBE_STRUCT(Z, (Y), (c));
int main() {
namespace desc = boost::describe;
using namespace std::literals::string_literals;
constexpr auto mod = static_castdesc::modifiers(desc::mod_public |
desc::mod_inherited);
using L = desc::describe_members