编辑 - 请忽略 - 围绕一个简单的拼写错误解决了这个问题。我需要休息一下。
如何访问对boost转换载体元素的引用?
与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
}
答案 0 :(得分:1)
你不能只做fusion::at_c<0>(vec) = 2;
吗?