Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-03-02 21:48:07


Maximilian Riemensberger wrote:
> Hi,
>
> Thank you, Peter, for sharing this library.

You are welcome. :-) Thanks for the feedback.

> While reading through the documentation of describe and considering how to
> use it in a C++14 code base a few questions came to my mind.
>
> 1) I saw that describe does not support describing reference member
> variables. Is there a fundamental limitation that prohibits this? We have quite
> a few `boost::asio::io_context&` members or similar members. (Yes, we
> haven't found time to update them to executor members.) We wouldn't be
> able to describe those.

Reference (and bitfield) members are a problem for reflection libraries (and
even some core proposals) because it's not possible to form a pointer to member
for them (and without injection, there's no good way to describe them in
a useful way.)

> 2) Overloaded functions are not supported. Again, what are the reasons for
> this limitation? Is it fundamentally impossible?

The problem is basically that &X::f doesn't work when f is overloaded. There
are probably ways around that, such as f.ex. using something like

(int (X::*)(float) const, f)

in place of just `f` (ugh), but I haven't yet settled on a solution I'd be
comfortable with.

(Actually I know what solution I'd be comfortable with - adding
__describe_members to clang, gcc and msvc - but that's a difficult endeavor.)

...

> Is it possible to support attaching extra data to the enum or their descriptor.
> As an example consider an error code enum. Without describe we would have
> something like
>
> enum class my_errors {
> success,
> some_thing_went_wrong,
> invalid_path,
> wrong_argument,
> unknown_error
> };
>
> char const* my_errors_s[5] = {
> "success",
> "some thing went wrong",
> "invalid path",
> "wrong argument",
> "unknown error"
> };
>
> std::errc my_errors_map[] = {
> 0,
> std::errc::io_error,
> std::errc::file_or_directory_not_found,
> std::errc::invalid_argument,
> std::errc::io_error
> };

That's an interesting example. I'll have to think about it.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk