|
Boost Users : |
Subject: Re: [Boost-users] [Phoenix] for_each calling push_back for stl containers
From: Ryan (boost_at_[hidden])
Date: 2012-07-15 13:38:55
On Thu, Jul 12, 2012 at 6:46 PM, Joel de Guzman
<joel_at_[hidden]>wrote:
>
> You did not evaluate it. Try adding a () at the end:
>
> phx::for_each(phx::ref(tokens)**,
> phx::lambda
> [
> phx::push_back(phx::ref(**string_tokens), phx::arg_names::arg1)
> ]
> )();
Adding the evaluation worked. I get the expected results now.
I now have the simplest pure phoenix method to parse a boost tokenizer into
a vector of strings. Is there a helper method that can be written to
automatically append the phx::lambda in this case. This would give the
following results.
phx::for_each(phx::ref(tokens), phx::push_back(phx::ref(string_tokens),
phx::arg_names::arg1))();
I understand the advantage of the lambda section. It allows added
variables to be created and more complicated requirements to be
accomplished. I just want to try and remove the extra syntax from my users
view if it isn't necessary (other than to make it work :) ). I would think
it's possible if the argument from one method is being used directly in the
other method without creating any additional variables.
Like I said, I'm not sure if this is possible but would like to try if it
is.
Ryan
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