编辑 - 请忽略 - 围绕一个简单的错字解决了这个问题。我需要休息。
如何访问对升压融合向量元素的引用?
与 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
}