Boost logo

Boost :

From: Eyal Farago (eyal.farago_at_[hidden])
Date: 2005-02-14 04:31:59


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. I'm also quite sure that boost bind takes better care of const/mutable return type and any other bad things that you may stumble across when trying to implement this functor youself (same goes for boost.lambda).

eyal.

-----Original Message-----
From: Thorsten Ottosen [mailto:nesotto_at_[hidden]]
Sent: Monday, February 14, 2005 4:19 AM
To: boost_at_[hidden]
Subject: [boost] [iterators] request for utility iterator

Hi all,

I often want to iterate over just the values of a
map or perhaps just the keys of a map. Therefore I
would like to see the following iterator adapters in the
iterator library:

template< class Map >
struct map_key_iterator;

template< class Map >
struct map_value_iterator;

template< class Map >
struct map_const_value_iterator;

I have outlined an implementation in the attached file, but basically
it just a wrapper around transform_iterator<typename Map::iterator>.

Comments?

br

Thorsten


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