编辑-请忽略-这个问题围绕一个简单的打字错误解决了。我需要休息一下
如何访问助推融合矢量元素的引用?
与boost.tuples的tuples::get<i>(variable)
(返回引用)不同,fusion::at_c<i>(variable)
返回常量,这给我带来了困难。
下面说明了我的问题
#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
}
你就不能做fusion::at_c<0>(vec) = 2;
吗?