Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2006-03-28 11:02:43


Yuval Ronen wrote:
> Hi.
> I have a function which is templated with an integer
>
> template <int N>
> void f()
> {
> ...
> }
>
> Within this function, I wish to use mpl::for_each to call another
> integer-templated (say, g()) function, with all numbers from 0 to N-1.
>
> How can I achieve this?
>
> I thought of making a mpl::vector<int_<0>, int_<1>, ..., int_<N-1> >,
> and then use mpl::for_each to iterate it, but I don't know how to
> generate this mpl::vector. How can I do that? Or maybe there's a better way?
>
> BTW: I first thought of using mpl::vector_c, but it seems that
> mpl:for_each doesn't support mpl::vector_c, only mpl::vector. Is this true?

See mpl::range_c

HTH,
Dave

--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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