Boost logo

Boost Users :

Subject: Re: [Boost-users] mpl pow10 sequence
From: Peter Foelsche (foelsche_at_[hidden])
Date: 2011-06-21 00:04:44


-- or better use the attached file

Peter

#include <boost/mpl/times.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/push_back.hpp>
#include <boost/mpl/pair.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/accumulate.hpp>
#include <boost/mpl/long.hpp>
#include <boost/mpl/integral_c.hpp>
#include <iostream>
?
using namespace boost::mpl;
template<typename PAIR, typename NUMBER>
struct my_op
{ typedef typename times<
typename PAIR::first,
boost::mpl::long_<10>
>::type NUMBER10;
typedef pair<
NUMBER10,
typename push_back<
typename PAIR::second,
NUMBER10
>::type
> type;
};
typedef accumulate<
range_c<long, 1, 10>,
pair<long_<1>, vector<> >,
my_op<_1, _2>
>::type POWER10;
?
struct print
{
template<long I>
void operator()(const long_<I> &) const
{ std::cout << I << std::endl;
}
template<long I, typename T>
void operator()(const integral_c<T, I> &) const
{ std::cout << I << std::endl;
}
};
int main(int argc, char **argv)
{ for_each<POWER10::second>(print());
return 0;
}

"Olaf Peter" <ope-devel_at_[hidden]> wrote in message
news:4DFCE911.9050706_at_gmx.de...
> Hi,
>
> my first steps in mpl :>) I try to build a sequence/vector of pow10
> sequence of integers and access them by index at runtime. See the last
> line of a concept usage. The range of exponents are in range [0..7] so
> the mpl::vector7 would be appropriate. Anyway, I don't get a compile
> able version using mpl's next, fold etc. How can I get this?
>
> Thanks,
> Olaf
>

> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users




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