Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-12-17 17:27:35


David Abrahams wrote:
> Aleksey Gurtovoy <agurtovoy_at_[hidden]> writes:
> > Yep, the later will give you all the functionality of
> > 'boost::tuple<int,...>' except the constructors and assignment from
> > 'std::pair'. A generator for it is as simple as this:
> >
> > template< typename Types > struct tuple_gen
> > : fold_backward<
> > Types
> > , boost::tuples::null_type
> > , boost::tuples::cons<_2,_1>
>
> Wow, is cons a metafunction?

A "reduced" one, yes :).

>
> It doesn't appear to be. I know we discussed making non-metafunctions
> usable as MPL lambda-expressions, but I didn't think you would opt for
> the transparent approach, with automatic detection of nested ::type.

People keep writing code along the lines of 'cons<_2,_1>' and expect it to
work. You can explain to them why it doesn't work, and that they can fix it
easily, by writing, for instance, 'reduced< cons<_2,_1> >' instead - or,
often, they realize the mistake for themselves - but for some reason that
doesn't decrease the likelihood of the same mistake happening the next time
they write a similar code. In other word, the experience shows that the
transparent approach is more intuitive.

>
> I thought you were going to require some explicit wrapper
> template...

Explicit wrapper, something like

    reduced< cons<_2,_1> >

is still planned, to cover all use cases (better names are welcome!).

> Not that I mind this approach.
>

Good! :)

Aleksey


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