|
Boost Users : |
Subject: Re: [Boost-users] Possible Boost.Variant issue with JSON AST
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2019-01-11 07:23:32
On Thu, Jan 10, 2019 at 10:17 PM Larry Evans via Boost-users
<boost-users_at_[hidden]> wrote:
>
> On 1/10/19 5:36 PM, Michael Powell via Boost-users wrote:
> > On Thu, Jan 10, 2019 at 6:15 PM Gavin Lambert via Boost-users
> > <boost-users_at_[hidden]> wrote:
> >>
> >> On 11/01/2019 07:36, Michael Powell wrote:
> >>> Here's my attempt at a flattened single source example:
> >>>
> >>> https://wandbox.org/permlink/83c3VXZ4W1DHoEBc
> >>
> >> The problems in that code are that you're using completely the wrong types.
> >
> > Fair observations. I've updated a bit, which I think is now tracking
> > with my local progress. Chiefly now, issues with "incompatible
> > skipper"?
> >
> > https://wandbox.org/permlink/4spQR8yXweIcVfdB
> >
> > Perhaps a repeated tuple issue of some sort? Otherwise, I'm not sure I
> > see what's going on there...
> >
> > I'd also tried forward declared structs to capture Member, Object,
> > Array, etc, but this was running into Boost.Variant incomplete type
> > issues.
> >
> Try altering what's forward declared:
>
> struct member_t;
>
> using members_t = std::vector<member_t>;
>
> // JSON_PARSER_OBJECT_HPP
> struct object_t {
> members_t members;
> object_t();
> object_t(const object_t& other);
> virtual ~object_t();
> };
>
> struct value_t
> : boost::variant
> < null_t, boolean_t, str_t
> , floating_point_number_t
> , integer_number_t, object_t, array_t
> >
> {...};
>
> That way, since sizeof(vector<anything>) is known, sizeof(object_t) is
> known.
>
> HTH.
Thanks, Larry; in fact that's what I ended up doing. value_t is the
hinge upon which everything gets delivered. I defined my types there,
and once defined there, exposed them afterward.
i.e.
struct value_t : boost::variant<...> {
using member_t = ...;
using object_t = ...;
using array_t = ...;
};
using member_t = value_t::member_t;
using object_t = value_t::object_t;
using array_t = value_t::array_t;
Then it is only a minor inconvenience that I use the long hand type in
the variant<...> list.
> -regards,
> Larry
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net