Boost logo

Boost :

From: Gavin Lambert (boost_at_[hidden])
Date: 2021-03-07 20:57:08


On 6/03/2021 6:23 am, Andrzej Krzemienski wrote:
>> BOOST_DESCRIBE_CLASS goes inside the class definition for two reasons: one,
>> to be able to access private members; two, to support class templates. You
[...]
>> In contrast, BOOST_DESCRIBE_STRUCT being put outside the struct allows
>> you to describe structs whose definitions you don't control, such as
>> structs
>> defined in third party libraries and system headers.
>>
>> So there's a reason for both decisions.
>
> It makes sense to support both cases. Maybe it is just the choice of names.
> In C++ we are taught that struct is actually a class. Maybe a rename
> BOOST_DESCRIBE_STRUCT -> BOOST_DESCRIBE_AGGREGATE (or similar) would make
> the difference easier to spot.

Or perhaps BOOST_DESCRIBE_TYPE_INTERNAL, which is defined inside the
struct/class and can access private members and type parameters, and
BOOST_DESCRIBE_TYPE_EXTERNAL, which is defined outside the struct/class
and can only refer to public members.

You may wish to describe a class that you don't control, for example.


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