Sorry, I wasn't clear. BoostSpirit comes with the x3 variant which already
requires c++14:
https://www.boost.org/doc/libs/1_75_0/libs/spirit/doc/x3/html/index.html
I meant this one only.
Regards,
&rzej;
That's true, but Spirit relies on Fusion for the support of user-defined structs,
so the straightforward way to make it work on described types is to make
Fusion recognize them.
That's ifdefable and should be doable, but I don't have a proof at this time. :-)
> Andrzej Krzemienski wrote:
> > wt., 2 mar 2021 o 15:05 Edward Diener via Boost <bo...@lists.boost.org>
> > napisał(a):
> >
> > > Boost.Fusion/Boost.Spirit are C++03 libraries while Describe is a
> > > C++14 library. So while Describe might be capable of replacing the
> > > BOOST_FUSION_ADAPT_STRUCT interface in Boost.Fusion I would imagine
> > > that Boost.Fusion/Boost.Spirit might have to upgrade their minimum C++
> > > level to C++14 in order to do so.
> > >
> >
> > Sorry, I wasn't clear. BoostSpirit comes with the x3 variant which
> already
> > requires c++14:
> > https://www.boost.org/doc/libs/1_75_0/libs/spirit/doc/x3/html/index.html
> > I meant this one only.
>
> That's true, but Spirit relies on Fusion for the support of user-defined
> structs,
> so the straightforward way to make it work on described types is to make
> Fusion recognize them.
>
Or have Spirit perform a check: if `describe::members` is found use it,
otherwise fall back to Boost.Fusion.
Regards,
&rzej;
That's possible, but it would require patching all uses of e.g. fusion::at_c
in Spirit. It's easier to only add this support to fusion::at_c, which would
not only take care of Spirit automatically, but of all other clients of
Fusion.
> Andrzej Krzemienski wrote:
> > wt., 2 mar 2021 o 16:34 Peter Dimov via Boost <bo...@lists.boost.org>
> > napisał(a):
> >
> > > That's true, but Spirit relies on Fusion for the support of
> > > user-defined structs, so the straightforward way to make it work on
> > > described types is to make Fusion recognize them.
> > >
> >
> > Or have Spirit perform a check: if `describe::members` is found use it,
> > otherwise fall back to Boost.Fusion.
>
> That's possible, but it would require patching all uses of e.g.
> fusion::at_c
> in Spirit. It's easier to only add this support to fusion::at_c, which
> would
> not only take care of Spirit automatically, but of all other clients of
> Fusion.
>
Ok, I now have a better understanding of the matter. BoostFusion ADAPT
macros and Boost.Describe have different purpose and scope.
The goal of Boost.Describe is to emulate static reflection of declarations
in C++.
The goal of ADAPT macros in Boost.Fusion is to adapt a given class type as
a fusion sequence. This does not require respecting the data members of the
struct. For instance, I may have a struct `Point` that stores Cartessian
coordinate in 2D space, but when adapting as a fusion sequence, I may want
the data to be set as polar coordinates:
```
struct Point
{
double x;
double y;
double get_distance() const;
double get_angle() const;
void set_distance(double r);
void set_angle(double a);
};
BOOST_FUSION_ADAPT_ADT(
Point,
(obj.get_angle(), obj.set_angle(val))
(obj.get_distance(), obj.set_distance(val)))
```
This is orthogonal to having reflection of structures.
I would still like Boost.Spirit to operate with Boost.Describe, but I do
not know how that maps on the idea for adapting Boost.Fuson to work with
Boost.Describe, and if the latter would be consistent with Boost.Fusion
design goals.
Regards,
&rzej;