开发者

reference to element in boost.fusion vector

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> 开发者_JAVA百科(tup) <<std::endl; //outputs 2

}


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜