0
編輯 - 請忽略 - 圍繞簡單的錯字解決的問題。我需要休息。參考元素在boost.fusion向量
如何訪問提升融合矢量元素的引用?
與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
}
doh!對不起,錯字! – Tom