使用 boost::mpl,我可以创建一个三元素向量的 typedef,如下所示:
typedef boost::mpl::vector_c<int,1,2,3> height_t;
我可以使用以下代码段从这个 typedef 中提取值:
std::vector<int> height;
boost::mpl::for_each<height_t>(boost::bind(&std::vector<int>::push_back, &height, _1));
assert(height[0] == 1);
assert(height[1] == 2);
assert(height[2] == 3);
我想知道是否有办法做同样的事情,但使用普通的 'C' 数组而不是std::vector
. 不幸的是,我不能在这个项目中使用 STL 容器。
uint32_t height[3];
boost::mpl::for_each<height_t>(????, &height, _1));
我怀疑我需要更换????与另一个绑定子句。有任何想法吗?