Boost logo

Boost Users :

From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2007-11-29 14:26:06


John Kiopela wrote:
> Hi all,
>
> I have been browsing through the docs, but I couldn't find anything
> useful. Does Boost have a std::map<K, V>::iterator adaptor which
> iterates over the values of the map only. That is, I would like to have
> an iterator of which operator*() function returns V, instead of
> std::pair<K, V>. My data is stored in a std::map<K, V> and I would to
> allow my users to iterate over the values.

Off the top of my head, and untested:

typedef std::map<K,V>::value_type pairkv;

boost::make_transform_iterator( map, boost::bind(&pairkv::second, _1 ) )

will get you a value iterator;

Jeff Flinn


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net