Boost logo

Boost Users :

Subject: Re: [Boost-users] [spirit] Cannot find assig_a in spirit 2.1
From: OvermindDL1 (overminddl1_at_[hidden])
Date: 2009-09-25 15:41:31


On Fri, Sep 25, 2009 at 1:21 PM, Christian Henning <chhenning_at_[hidden]> wrote:
> Hi there, I really liked the assign_a actor in classic spirit. Is
> there something like that in spirit 2.1, aka, spirit::qi?

That is because something like assign_a is worthless in QI.

For example (from the docs), in Spirit.Classic:
    int i, j;
    std::string s;
    r = int_p[assign_a(i)] >> (+alpha_p)[assign_a(s)] >> int_p[assign_a(j,i)];

Can be done in Spirit.QI by:
    int i, j;
    std::string s;
    r = int_[ref(i)=_1] >>(+alpha)[ref(s)=_1] >> int_[ref(j)=_1];

Or even better, this will do the same thing, but will execute even faster:
    int i, j;
    std::string s;
    std::string str("123456 Hello 789");
    phrase_parse(str.begin(), str.end(), int_ >> +alpha >> int_,
blank, i,s,j); // This will stuff 12345 into i, "Hello" into S, and
789 into j, *very* fast.

Spirit2.1 is *so* much better, as you might be seeing. :)


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