I expected the following to produce the same result:
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
>
>
>
{};
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>
>
>
>
{};
But they do not.
int
main (int ac, char **av)
{
typedef make_vector1<0,3>::type v1;
typedef make_vector2<0,3>::type v2;
std::cout<<"I1 = "<<mpl::at<v1,mpl::int_<0> >::type::value <<std::endl;
std::cout<<"I2 = "<<mpl::at<v2,mpl::int_<0> >::type::value <<std::endl;
}
Any idea what is going on here?
I want to use the second method to build mpl :: vector types Example, where:
template<int i>
struct Example : mpl::int_<i>
{};
but i can't get it to work.
Many thanks
source
share