|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2021-03-05 17:25:04
Andrzej Krzemienski wrote:
> My impression is that the library addresses a number of use cases that are
> fairly unrelated. Of course, they all fall under the category "obtain some meta-
> information about the entity''; but other than that I cannot easily tell the part
> that is the same about the four use cases.
>
> As an example of this, I cannot answer the question if this library is for
> obtaining meta information about already existing definitions, or is it also for
> creating new definitions? If it is the former, then BOOST_DEFINE_ENUM
> clearly does not belong here. If it is the latter, then I am clearly missing an
> analogous definition mechanism for defining structs.
It is a library for obtaining meta information about existing definitions, yes. As
I have mentioned, the original motivation for it was to implement in a library
what could at a later date become a built-in compiler mechanism for
simple reflection. That is, the DESCRIBE macros would be unnecessary as the
metadata would be generated by the compiler automatically, and the
describe_* primitives would be compiler built-ins.
BOOST_DEFINE_ENUM is a concession to practical usability. In the hypothetical
world where the compiler automatically describes the enum, it wouldn't need
to exist. But at the moment, we have to do with what we have, which is the
library without compiler support, and repeating the enumerators for large enums
is simply too cumbersome.
In short, BOOST_DEFINE_ENUM is provided because it pretty much has to be.
In its current state, the library is as close as its fundamental core as it will ever be.
It will almost certainly acquire further usability enhancements as time goes on.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk