|
Boost : |
From: Christian Mazakas (christian.mazakas_at_[hidden])
Date: 2024-02-26 16:04:34
> I would recommend putting something like the above in the docs, where the
> motivation for using rule parsers is listed. Currently it states "fix the
> attribute type produced by a parser to something other than the default"
> but what you sayin above is more: "prevent the parsers from doing things
> that they would otherwise do".
Ha, came online to say exactly this. I think that description of the
problem being
solved is more than satisfactory and illuminates the issue quite well.
> I note that parsing a homogenous sequence to a std::set does work, at
least
> without rules:
> https://godbolt.org/z/x57j1dq5T
>
> I was surprised to find that, in the context of other precautions, feeding
> parsed data to a collection is performed via `insert` rather than
> `push_back`.
This is probably a holdover from the X3 days as this is who Spirit treats
collections
generically and, ironically, is done for the exact reason that `std::set`
supports
`insert(pos, val)`.
In principle, I don't think that a free-form grammar like the above parsing
into a `set`
is problematic. Instead, I agree more with Zach that when you're formally
defining rules,
you're really telling the library, "Hey, this is exactly what I want to be
parsing into."
- Christian
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk