|
Boost Users : |
From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2005-01-18 19:05:30
"Martin Pasdzierny" <martin_at_[hidden]> wrote
[...]
> // here is my type list
> typedef mpl::vector<int,double,std::string > my_types;
>
> // from_pos and to_pos are start and end iterators of the subsequence
> typedef typename mpl::find<my_types,int>::type from_pos;
> typedef typename mpl::find<my_types,std::string>::type to_pos;
>
> // all elements (types) of my_types should be copied into the new seuqence
my_sub_types if their iterator (index) is inside the given interval
(from_pos,to_pos)
> typedef mpl::copy_if<my_types,
> mpl::and_<
> mpl::greater< mpl::find<my_types,mpl::_1>::type,
mpl::int_<from_pos> > ,
> mpl::less< mpl::find<my_types,mpl::_1>::type, mpl::int_<to_pos> >
> >,
> mpl::back_inserter< mpl::vector<> >
> >::type my_sub_types;
>
> </code>
>
> This code (and lots of slight variations) does not compile. Why ?
Most likely because mpl::greater, etc., are defined to work with integral
constants, not with iterators.
I think you should just use iterator_range:
typedef mpl::iterator_range<from_pos, to_pos>::type my_sub_types;
HTH,
Arkadiy
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net