
Markus Werle wrote:
Hi!
The following piece of code yields "( 0)" as output, but IMHO the output should be "(test 1)". Looks like at_c creates temporaries, but I expected it to return a reference. How can I fix this?
Markus
#include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_fusion.hpp> #include <boost/tr1/tuple.hpp> #include <string> #include <iostream>
namespace fusion = boost::fusion; namespace phoenix = boost::phoenix;
int main() { typedef fusion::tuple<std::string, int> tuple_t; typedef std::tr1::tuple<std::string, int> tr1_tuple_t;
tuple_t t("test", 1);
tr1_tuple_t tr1_t;
phoenix::at_c<0>(tr1_t) = phoenix::at_c<0>(t); phoenix::at_c<1>(tr1_t) = phoenix::at_c<1>(t);
std::cout << tr1_t << std::endl; }
I don't understand the code. What is phoenix doing there? You know phoenix::at_c is lazy, right? Did you mean fusion::at_c? Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net