boost::mpl を使用すると、次のような 3 要素ベクトルの 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));
???? を交換する必要があると思います。別の bind 句を使用します。何か案は?