1

I typedef a vector with two elements. Then I push_back into it an other element and expect what result type is also a vector. But that's not so.

Example:

typedef boost::fusion::vector<int, double> vec1;
typedef boost::fusion::result_of::push_back<vec1, std::string> vec2;
//boost::is_same<vec2, boost::fusion::vector<int, double, std::string>>::value == false

http://liveworkspace.org/code/361492801eebe24cc5679a1e899a5240

What am I doing wrong?

Regards.

niXman
  • 1,698
  • 3
  • 16
  • 40

1 Answers1

2

You've aliased the push_back itself as vec2. You need to use

typedef boost::fusion::result_of::push_back<vec1, std::string>::type vec2;

But keep in mind that the type might still not be the same, Fusion algorithms are not required to preserve the type (and since push_back function is supposed to return a lazy view, then vec2 will most likely be some view type). The only guarantee is that vec2 will be "A model of Forward Sequence.".

Cat Plus Plus
  • 125,936
  • 27
  • 200
  • 224