Boost logo

Boost Users :

From: Joel de Guzman (joel_at_[hidden])
Date: 2008-08-29 10:50:52


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

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