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


#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,
>::type NUMBER10;
typedef pair<
typename push_back<
typename PAIR::second,
> 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
> 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]

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at