I want to parse a float, but not allow NaN, so I create a policy that inherits from the default policy and creates with it real_parser:
template <typename T>
struct no_nan_policy : real_policies<T>
{
template <typename I, typename A>
static bool
parse_nan(I&, I const&, A&) {
return false;
}
};
real_parser<double, no_nan_policy<double> > no_nan;
bool ok = phrase_parse(first, last,
no_nan[ref(valA) = _1] >> char_('@') >> double_[ref(b) = _1],
space);
But now I also want the total length of the line being processed with help no_nannot to exceed 4, that is, "1.23" or ".123" or even "2.e6", or "inf" in order, "3.2323" is not "nan". I cannot do this in a section parse_n/ parse_frac_npolicy that looks separately to the left / right points and cannot communicate (... purely) what they should have in view of the total length.
, real_parser ( boost/spirit/home/qi/numeric/real.hpp) parse, . real_parser any_real_parser, parse, - .
(), , (return boost::spirit::qi::any_real_parser<T, RealPolicy>::parse(...)), ? , , .
( Boost 1.55, Spirit 2.5.2, ++ 11)