Boost logo

Boost Users :

Subject: [Boost-users] mpl::fold problems
From: sergey kostanbaev (sergey.kostanbaev_at_[hidden])
Date: 2010-08-23 08:26:07

Hello everybody!

I'm a newbie in boost and I've got some problems with boost::mpl

#include <boost/mpl/vector.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/arithmetic.hpp>

template <class T, unsigned space=1> struct tr_field2
   static const unsigned count = space;

typedef boost::mpl::vector4<
   tr_field2<int, 4>,
   tr_field2<int, 7>,
   tr_field2<char, 1>,
   tr_field2<char, 1>
> Test_description;

I want to calculate a sum of all tr_field2::count
I've read in the docs mpl::fold is for the case.

I tried to compose

   typedef boost::mpl::fold<Test_description,
      boost::mpl::plus<boost::mpl::_, boost::mpl::_::count > >
>::type fcount;

but it won't compile. It seems I misundestood something.

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