|
Boost Users : |
Subject: [Boost-users] [Phoenix] for_each calling push_back for stl containers
From: Ryan (boost_at_[hidden])
Date: 2012-07-08 17:16:13
Hello,
In upgrading from boost 1.39 to 1.47 I changed my use of the Phoenix
library (which was within Spirit) to the stand alone Phoenix library. This
caused my below code to stop working.
/**** Code Start ***/
static boost::char_separator<char> seperator(":");
boost::tokenizer< boost::char_separator<char> > tokens(s, seperator); //s
is a passed in std::string
std::vector<std::string> string_tokens;
namespace phx = boost::phoenix;
//This line fails to compile now.
std::for_each(tokens.begin(), tokens.end(),
phx::bind(&std::vector<std::string>::push_back, &string_tokens,
phx::arg_names::arg1));
/**** Code Stop ***/
This lead me to three questions.
1. What changed about phoenix bind that caused this not to work any more?
2. I tried using the lazy version of push_back to bypass the bind issue.
In the documentation there are not any examples of multiple algorithm and
container methods calling each other to show how the arguments of one
method is passed to another.
std::for_each(tokens.begin(), tokens.end(), phx::push_back(&string_tokens,
phx::arg_names::arg1));
This compiles but nothing is placed into string_tokens. So I'm assuming
the argument from for_each isn't being passed to push_back. What needs to
changed in this method call?
3. Can that entire line of question 2 be replaced with the lazy version of
the method calls or does the outer most call need to be a non-lazy method?
phx::for_each(phx::arg_names::arg1, phx::push_back(phx::arg_names::arg2,
phx::arg_names::arg3))(tokens, string_tokens, ???);
If the entire line can be a lazy version then how would I map for_each to
push_back for arg3?
Any help for these three questions would really be appreciated.
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