Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Spirit. Karma: Kleene star with space separator
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2016-03-01 09:48:55


> 01.03.2016 16:53, Hartmut Kaiser пишет:
> >
> >> There is an example of usage Keele star with Karma generator:
> >>
> http://www.boost.org/doc/libs/1_60_0/libs/spirit/doc/html/spirit/karma/ref
> >> erence/operator/kleene.html
> >>
> >>
> >> std::vector<double> v;
> >> v.push_back(1.0);
> >> v.push_back(2.0);
> >> v.push_back(3.0);
> >> test_generator_attr_delim("1.0 2.0 3.0 ", *double_, space, v);
> >>
> >>
> >> How could the remaining space be omitted? Is (double_ % space) supposed
> >> to be used instead for such cases?
> >
> > Yes.
>
> Many thanks. I've found that % operator fails on empty containers
> whereas Kleene* doesn't.

You can use -(double_ % ' ') to support empty containers.

Regards Hartmut
---------------
http://boost-spirit.com
http://stellar.cct.lsu.edu


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