mpl::transform<...> --- compile error: is not derived from type

hi, here's the problem i have: struct my{ template<typename UInt> struct apply{ typedef mpl::int_<UInt::value> type; }; }; template<int First,int Last> struct id_range{ typedef mpl::transform< mpl::range_c<int,First,Last> , my , mpl::back_inserter< mpl::vector<> > >::type type; /home/er/cpp/boost/random/mcmc/id_range.hpp|32|error: type ‘boost::mpl::transform<boost::mpl::range_c<int, First, Last>, boost::random::mcmc::<unnamed>::my, boost::mpl::back_inserter<boost::mpl::vector<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, mpl_::na>’ is not derived from type ‘boost::random::mcmc::id_range<First, Last>’| however, for example, this --instead-- compiles fine: struct id_range{ typedef mpl::transform< mpl::range_c<int,1,3> , my , mpl::back_inserter< mpl::vector<> > >::type type; }; any suggestion appreciated. thanks!

e r wrote:
hi,
here's the problem i have: struct my{ template<typename UInt> struct apply{ typedef mpl::int_<UInt::value> type; }; };
template<int First,int Last> struct id_range{ typedef mpl::transform< mpl::range_c<int,First,Last> , my , mpl::back_inserter< mpl::vector<> > >::type type;
/home/er/cpp/boost/random/mcmc/id_range.hpp|32|error: type ‘boost::mpl::transform<boost::mpl::range_c<int, First, Last>, boost::random::mcmc::<unnamed>::my, boost::mpl::back_inserter<boost::mpl::vector<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, mpl_::na>’ is not derived from type ‘boost::random::mcmc::id_range<First, Last>’|
however, for example, this --instead-- compiles fine:
struct id_range{ typedef mpl::transform< mpl::range_c<int,1,3> , my , mpl::back_inserter< mpl::vector<> > >::type type; }; any suggestion appreciated. thanks!
and also, although the second version compiles, i have BOOST_MPL_ASSERT( ( is_same< id_range::type, mpl::vector< mpl::int_<1>, mpl::int_<2>, mpl::int_<3> > > ) ); causes, error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::is_same<boost::mpl::v_item<mpl_::int_<2>, boost::mpl::v_item<mpl_::int_<1>, boost::mpl::vector<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, 0>, 0>, boost::mpl::vector<mpl_::int_<1>, mpl_::int_<2>, mpl_::int_<3>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >::************)’|

e r wrote:
e r wrote:
hi,
here's the problem i have: struct my{ template<typename UInt> struct apply{ typedef mpl::int_<UInt::value> type; }; };
template<int First,int Last> struct id_range{ typedef mpl::transform< mpl::range_c<int,First,Last> , my , mpl::back_inserter< mpl::vector<> > >::type type;
/home/er/cpp/boost/random/mcmc/id_range.hpp|32|error: type ‘boost::mpl::transform<boost::mpl::range_c<int, First, Last>, boost::random::mcmc::<unnamed>::my, boost::mpl::back_inserter<boost::mpl::vector<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, mpl_::na>’ is not derived from type ‘boost::random::mcmc::id_range<First, Last>’|
however, for example, this --instead-- compiles fine:
struct id_range{ typedef mpl::transform< mpl::range_c<int,1,3> , my , mpl::back_inserter< mpl::vector<> > >::type type; }; any suggestion appreciated. thanks!
and also, although the second version compiles, i have
BOOST_MPL_ASSERT( ( is_same< id_range::type, mpl::vector< mpl::int_<1>, mpl::int_<2>, mpl::int_<3> > > ) );
causes,
error: no matching function for call to ‘assertion_failed(mpl_::failed************ boost::is_same<boost::mpl::v_item<mpl_::int_<2>, boost::mpl::v_item<mpl_::int_<1>, boost::mpl::vector<mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, 0>, 0>, boost::mpl::vector<mpl_::int_<1>, mpl_::int_<2>, mpl_::int_<3>, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >::************)’|
In the first post: there's a typename missing, which solves the problem.

AMDG e r wrote:
and also, although the second version compiles, i have
BOOST_MPL_ASSERT( ( is_same< id_range::type, mpl::vector< mpl::int_<1>, mpl::int_<2>, mpl::int_<3> > > ) );
causes,
<snip>
Two boost::mpl::vectors that contain the same elements are not guaranteed to be the same type. If you boost::mpl::equal, it ought to work. BOOST_MPL_ASSERT( ( boost::mpl::equal< id_range::type, mpl::vector< mpl::int_<1>, mpl::int_<2>, mpl::int_<3> > > ) ); In Christ, Steven Watanabe

Steven Watanabe wrote:
AMDG
e r wrote:
and also, although the second version compiles, i have
BOOST_MPL_ASSERT( ( is_same< id_range::type, mpl::vector< mpl::int_<1>, mpl::int_<2>, mpl::int_<3> > > ) );
causes,
<snip>
Two boost::mpl::vectors that contain the same elements are not guaranteed to be the same type. If you boost::mpl::equal, it ought to work.
BOOST_MPL_ASSERT( ( boost::mpl::equal< id_range::type, mpl::vector< mpl::int_<1>, mpl::int_<2>, mpl::int_<3> > > ) );
In Christ, Steven Watanabe
Got it, thanks. And also, I should add that range_c<int,1,3> represent [1,3) ,not [1,3].
participants (2)
-
e r
-
Steven Watanabe