如何识别 boost::fusion vector 中的类型?
例如
fusion::vector<int, double, string> v;
然后可以让我将 v[0]
识别为 int
类型,将 v[1]
识别为 double 类型
和 v[2]
作为 string
类型。
谢谢。
最佳答案
为了从 boost::fusion::vector
中提取元素,您需要使用 boost::fusion::at_c
,如下所示:
boost::fusion::vector<int, std::string> v(1, "hello");
std::cout << boost::fusion::at_c<0>(v) << std::endl; // prints 1
N位置的类型是:
boost::fusion::result_of::at_c<boost::fusion::vector<int, std::string>, 1>::type
关于c++ - 如何识别boost fusion vector 中的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13100982/