Possible Boost.Variant issue with JSON AST
Hello, I've got an AST I am developing to support JSON parsing using the latest VC++ (15.9.5), however, I am having difficulty persuading the compiler with my forward declarations. i.e. 1>d:\dev\boost.org\boost_1_69_0\boost\mpl\sizeof.hpp(27): error C2027: use of undefined type 'kingdom::json::object_t' In terms of JSON AST modeling, the rub appears to be in a couple of places: defining the JSON AST Array, and making the JSON AST Object available to Value. Re: semantic terminology, Value is interchangeable with Element, in view of the JSON grammar. Here's my attempt at a flattened single source example: https://wandbox.org/permlink/83c3VXZ4W1DHoEBc I seem to recall there being future issues with C++ forward declarations, but this seems to be like a bad language design decision to restrict this, especially in light of this kind of approach. I'm not sure how better to sort this out. At minimum, at least Value needs a forward declaration depending on how I arrange my headers, includes, etc. But then I still run into Value forward declaration undefined type issues. I'm not sure it's as much a language issue as much as it is possible a Boost.Variant issue, per se. Suggestions? Thanks! Michael Powell
On 11/01/2019 07:36, Michael Powell wrote:
Here's my attempt at a flattened single source example:
The problems in that code are that you're using completely the wrong types. In key_t, you're inheriting the base_type copy-constructor and copy-assignment, and then creating new shadowing constructors and assignment operators for the base_type (note: these are *not* a copy-constructor nor copy-assignment operator for key_t itself!). In numeric_t(const sign_type& other), you're getting compile errors because you probably intended to use numeric_t instead of sign_type as the parameter.
On Thu, Jan 10, 2019 at 6:15 PM Gavin Lambert via Boost-users
On 11/01/2019 07:36, Michael Powell wrote:
Here's my attempt at a flattened single source example:
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.
In key_t, you're inheriting the base_type copy-constructor and copy-assignment, and then creating new shadowing constructors and assignment operators for the base_type (note: these are *not* a copy-constructor nor copy-assignment operator for key_t itself!).
In numeric_t(const sign_type& other), you're getting compile errors because you probably intended to use numeric_t instead of sign_type as the parameter. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
On Thu, Jan 10, 2019 at 6:36 PM Michael Powell
On Thu, Jan 10, 2019 at 6:15 PM Gavin Lambert via Boost-users
wrote: On 11/01/2019 07:36, Michael Powell wrote:
Here's my attempt at a flattened single source example:
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"?
I think I got it sorted pending testing, although I am unclear why a couple of the rules skippers' should not be specified.
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.
In key_t, you're inheriting the base_type copy-constructor and copy-assignment, and then creating new shadowing constructors and assignment operators for the base_type (note: these are *not* a copy-constructor nor copy-assignment operator for key_t itself!).
In numeric_t(const sign_type& other), you're getting compile errors because you probably intended to use numeric_t instead of sign_type as the parameter. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
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
wrote: On 11/01/2019 07:36, Michael Powell wrote:
Here's my attempt at a flattened single source example:
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
On Thu, Jan 10, 2019 at 10:17 PM Larry Evans via Boost-users
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
wrote: On 11/01/2019 07:36, Michael Powell wrote:
Here's my attempt at a flattened single source example:
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
; // 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@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Gavin Lambert
-
Larry Evans
-
Michael Powell