
-- 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@gmx.de> wrote in message news:4DFCE911.9050706@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@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users