$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: David Abrahams (dave_at_[hidden])
Date: 2005-05-31 14:38:59
David Abrahams <dave_at_[hidden]> writes:
> So this is pretty verbose using lambdas because the sum is repeated,
> among other things. You might do better to build a custom metafunction
> that gets you the new state:
>
>     template <class PrevState, class Element>
>     struct next_state
>     {
>          typedef typename PrevState::first prev_sequence;
>          typedef typename PrevState::second prev_sum;
>          typedef mpl::size_t<(prev_sum::value + Element::nr_)>  new_sum;
>          typedef typename mpl::push_back<
>              prev_sequence
>            , mpl::pair<Element, new_sum>
>          >::type new_sequence;
>          typedef mpl::pair<new_sequence, new_sum> type;
>     };
>
>     typedef mpl::fold< some_list, mpl::fold<_,_> >::type pair_seq_sum;
>
>     typedef pair_seq_sum::first new_sequence;
Heh, this probably would've been easier using zip_view.
Oh, well, I'm outta time for this one right now.  Again, sorry.
-- Dave Abrahams Boost Consulting www.boost-consulting.com