Search code examples
c++boostboost-fusion

Filling up std::vector with heterogeneous boost::fusion vector type data


I am new to boost and metaprogramming so my problem is this:

typedef fusion::vector<int, char, double, std::string>  my_row;
typedef std::vector<my_row> my_vec;

my_row my_data = my_row(3,"f",2,"2");

my_vec t;

t.push_back(my_data); // this doesn't compile and gives error <C2039>

This might be a very stupid question for most of you, but why doesn't this compile? Do i need to somehow transform the my_row vector into something that can be stored into an ordinary std::vector?

Also could someone point me to a nice introductory book on metaprogramming and boost so that i get the mentality behind boost's use and some programming examples using boost?

I truly think the online manual website is absolute rubbish. At least it looks so to someone that is not completely new to C++ and STL but that gets lost in the scores of 'struct' declarations, and '::' and '<>' uses. In general all the things that just make boost hard to use and understand for a newcomer.


Solution

  • "f" is a string, not a char. Try 'f' instead.