Boost logo

Boost Users :

Subject: Re: [Boost-users] [Phoenix] for_each calling push_back for stl containers
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-07-09 17:57:34


> > //2. Works and looks clean but has the iterator range as part of the call.
> > std::for_each(tokens.begin(), tokens.end(),
> > phx::push_back(phx::ref(string_tokens), phx::arg_names::arg1));
>
> Using the Boost.Range library, that would be:
>
> boost::for_each(tokens, phx::push_back(phx::ref(string_tokens), phx::arg_names::arg1));
>
> I think that's about as clean as you can get.

Actually that's not true. Without using Phoenix at all, just using Boost.Range,
this is simply:

boost::push_back(string_tokens, tokens);

As for your question about why Phoenix for_each requires a lambda, I'm afraid I
don't understand Phoenix well enough to answer that. Perhaps Thomas can help us.

Regards,
Nate
                                               


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