Boost logo

Boost :

From: Dan (dan_at_[hidden])
Date: 2004-06-30 23:15:08


I'm trying to use iter_fold with a vector_c to compute the sum of all of the
integers in the container.

What I have is:

template<typename Sequence>
struct sum
{
        typedef typename mpl::iter_fold<
                Sequence,
                typename mpl::begin<Sequence>::type,
                mpl::plus< mpl::deref<_1>, mpl::deref<_2> >;
                // ^ what should this really be?
> // what do i put after here?
};

Which obviously won't work. I don't know how to keep a running total as I
iterate over the sequence with plus.

Help!

Thanks,
-Dan


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk