0

EDIT - please ignore - the question resolved around a simple typo. I need a break.

How do I access a reference to an element of a boost fusion vector?

Unlike boost.tuples's tuples::get<i>(variable) (returns a reference), the fusion::at_c<i>(variable) returns a constant and this causing me difficulties.

The following illustrates my problem

#include <iostream>
#include <boost/tuple/tuple.hpp> 
#include <boost/fusion/include/vector.hpp>
#include <boost/fusion/include/at.hpp>

using namespace boost;
int
main  (int ac, char **av)
{
   fusion::vector<int, char, std::string> vec(1, 'x', "howdy");
   tuples::tuple <int, char, std::string> tup(1, 'x', "howdy");
   std::cout<< fusion::at_c<0>(vec)<<std::endl;  //outputs 1
   std::cout<< tuples::get<0> (tup) <<std::endl; //outputs 1
   //fusion::at<0>(vec) = 2; //doesn't compile
   tuples::get<0>(tup) = 2;    //works fine
   std::cout<< fusion::at_c<0>(vec) <<std::endl; //can't make this output 2.
   std::cout<< tuples::get<0> (tup) <<std::endl; //outputs 2

}
Tom
  • 5,219
  • 2
  • 29
  • 45

1 Answers1

1

Can't you just do fusion::at_c<0>(vec) = 2;?

Diego Sevilla
  • 28,636
  • 4
  • 59
  • 87