I think this duplicates How to write a boost::spirit::qi parser to parse an integer range from 0 to std::numeric_limits<int>::max()? as well as the question I remember seeing on the mailing list.
Since it is apparently not documented, have you tested?
Or is this requirement has nothing to do with the parser's range?
I'd expect it to be the latter. I expect the attribute type says something about the attribute, not the parser. The parser parses, attribute propagation assigns to the attribute. Separation of concerns.
The attribute propagation is liable to do any implicit conversions that the C++ language will. This is actually no different from using unsigned
in a scanf("%d")
or reading an unsigned int using std::istream
:
See How to read unsigned int variables from file correctly, using ifstream?
I'd expect this all to be true because C++ combines the language core values of
- pay only for what you need
- the programmer knows what he's doing.
In fact, this is the root of the issue: Spirit defines qi::int_
, qi::uint_
and friends. If you cobble up custom combinations using the underlying qi::[u]int_parser<>
template, you're telling the compiler "I know what I'm doing".
DISCLAIMER: All of this is non-authoritative. I didn't even check the code/docs. I think it is essentially a documentation question which is better asked on the mailing list