Boost logo

Boost Users :

Subject: [Boost-users] What's the execution sequence of phoenix::lambda function?
From: 饭桶 (arthur.wang2_at_[hidden])
Date: 2012-01-15 09:07:02


I'm a newbie for boost phoenix, I wrote a small piece of code but it
totally confuses me about the execution sequence, you can check the code
------------------clip-----------------

std::vector<int> v;
v.push_back(1);
ph::for_each(v,
             ph::lambda[ph::ref(cout)<<"a",
                        ph::ref(cout)<<"b"
                 ])(v);

ph::for_each(arg1,
             ph::lambda[ph::ref(cout)<<"a",
                        ph::for_each(v,
                                         ph::lambda[ph::ref(cout)<<"b",
                                                    ph::ref(cout)<<"c"
                                             ]),
                        ph::ref(cout)<<"d"
                 ])(v);

------------------------clap--------------------------

The first output is "ab" but the second output is "dbca".

It seams ph::for_each is lazy evaluate , but what is the correct one to
make it execute from left to right?

thanks

-- 
半亩薄田一头牛 老婆孩子热炕头


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