|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-02-14 10:00:22
"Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> "Eyal Farago" <eyal.farago_at_[hidden]> wrote in message
> news:BC29F2A417B44F44BD3AA1AD9868CEDC034244_at_ilexchange.adrembi.com...
> | you can easily achieve this using (make_)transform_iterator and boost bind:
> |
> | make_transform_iterator(
> | map.begin(),
> | boost::bind( &MAP_TYPE::value_type::first, _1 )
> | )
> |
> | (give or take a typename before MAP_TYPE::...)
> | I think it's so simple that you don't really need a utility class for it.
>
> well, I cannot use that when I want to write a manual loop.
>
> yes, it is simple, but also frequently used. And we also
> have to think about less experienced users IMO.
Both of you make good points. There's a third point I should bring
up: Thorsten, your iterator isn't legal. Hint: what is the return
type of its operator++?
It has been pointed out that this sort of thing would be very much
easier if, like iterator_facade and iterator_adaptor, all the
specialized adapters could accept one more optional parameter that
specifies the most-derived iterator class. I think that's a good
idea, but I'm not sure how to do it without making the interface
overly complicated. Ideas? I don't want to go back to the "bad old
days" of named template parameters.
In fact, the way default types are calculated and specified in the
iterators library is just too complicated and needs to be re-examined.
The whole iterators library needs some attention, but there just
hasn't been time for me recently. Jeremy is working on his PhD, and
Thomas has allowed his professional life to get the better of him ;-).
I hope to get to it somewhere along the path of my work on the MTL
(http://www.boost-consulting.com/projects/mtl).
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk