Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-04-29 17:16:19


Toon Knapen wrote:
> On Friday 26 April 2002 13:37, Aleksey Gurtovoy wrote:
> > Toon Knapen wrote:
> > > I have a list of heterogeneous objects, e.g.
> [snip sample code]
>
> > > And now I want to have a function that can accumulate the
> > > value sof all the objects in the tuple, e.g. (pseudocode since
> > > my problem is exacly that I can't figure out how to code this)
> > >
> > > template < typename TypleType >
> > > int accumulate_values(const TupleType& t)
> > > {
> > > int acc = 0;
> > > for(int i = 0 ; i < t.size() ; ++i ) acc += (get< i >(
> t )).value();
> > > }
> > >
> > > Can I do this using mpl (mpl looks great but I can't figure
> > > out how to do this).
> >
> > It's not exactly a part of MPL (the library doesn't target
> "run-time" stuff
> > to that extent yet; I hope it will some day), but "tuple extension"
> > components I wrote some time ago
> >
>
(http://groups.yahoo.com/group/boost/files/tuple_ext/tuple_ext-08-nov-01.zip
)
> allow one to do exactly these kinds of things:
> [snip aleksey's solution]
>
> Thanks, I like tuple_ext a _lot_ !

I am glad you found it useful.

> It would be great to have complete STL-like functionality like this.

Yep. The only problem with this is that we are going to end up with 3
STL-like libraries within the same language :) (the original one
("run-time"), the MPL one (pure compile time), and something in between, -
HSTL (Heterogeneous Sequences Template Library :)). All three with the same
algorithms, just written in different notation :).

Emily's heterogeneous lists (www.oonumerics.org/tmpw01/winch.pdf,
http://groups.yahoo.com/group/boost/files/alist-feb14-02.zip), 'tuple_ext'
components, and MPL's v.2 half-run-time 'for_each' are obviously hanging
around that "in between" thing.

> Plans on adding this tuple_ext to the CVS ?

Some; I think it should be a full-fledged submission that would take the
prior art and build a simple framework on it. It's not a large undertaking,
though - most of the concepts and some code are already here :).

Aleksey


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