Boost logo

Boost Users :

From: Stephan Tolksdorf (andorxor_at_[hidden])
Date: 2006-07-15 05:20:00


OK, part of the problem is that mpl only supports vectors and lists of
maximum size 20 by default. I guess vectors with several thousands of
elements are beyond the realms of MPL code.

Stephan

Stephan Tolksdorf wrote:
> Hi
>
> I'm trying to build a mpl::vector which looks like
>
> [(a,1),(a,2),...,(a,a),(a+1,1),...,(b,b)],
>
> where a < b are int's and (x,y) stands for mpl::pair< int_<x>, int_<y> >.
>
> The following code does not compile with MSVC 8. Could somebody tell me
> what's wrong with my code? Does someone have an idea how to solve this
> problem more elegantly with MPL? Any help is much appreciated.
>
> Code snippet with the vector named "ListofNMPairs":
>
> template <typename N>
> struct NPush :
> mpl::lambda<
> mpl::push_front<
> mpl::_1,
> mpl::pair<N, mpl::_2>
> >
> >::type
> { };
>
> template <typename S>
> struct MyRange :
> mpl::reverse_fold<
> mpl::range_c<int, 1, S::value + 1>,
> mpl::vector< >,
> NPush<S>
> >::type
> { };
>
> typedef mpl::reverse_fold<
> mpl::range_c<int, 16, 66>, // a=16, b=65
> mpl::vector< >,
> mpl::insert_range<
> mpl::_1,
> mpl::begin<mpl::_1>,
> MyRange<mpl::_2>
> >
> >::type ListofNMPairs;
>
> Regards,
> Stephan


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