私は次のことが同じ結果をもたらすと期待していました:
namespace mpl = boost::mpl;
template<int from, int to>
struct
make_vector1
: mpl::copy<
mpl::range_c<int,from,to>,
mpl::inserter<
mpl::vector<>,
mpl::push_back<mpl::placeholders::_1,
mpl::placeholders::_2 // <- Copy int_ types
>
>
>
{};
template<int from, int to>
struct
make_vector2
: mpl::copy<
mpl::range_c<int,from,to>,
mpl::inserter<
mpl::vector<>,
mpl::push_back<mpl::placeholders::_1,
mpl::int_<mpl::placeholders::_2::value> // <- Alternative?
>
>
>
{};
しかし、そうではありません。
int
main (int ac, char **av)
{
typedef make_vector1<0,3>::type v1;
typedef make_vector2<0,3>::type v2;
//returns 0, as I would expect
std::cout<<"I1 = "<<mpl::at<v1,mpl::int_<0> >::type::value <<std::endl;
//returns 2, which has me stumpted.
std::cout<<"I2 = "<<mpl::at<v2,mpl::int_<0> >::type::value <<std::endl;
}
ここで何が起こっているのか分かりますか?
Example
2番目の方法を使用して、タイプのmpl :: vectorを作成します。ここで、
template<int i>
struct Example : mpl::int_<i>
{};
しかし、私はそれを機能させることができません。
どうもありがとう