Boost logo

Boost Users :

From: David Abrahams (dave_at_[hidden])
Date: 2004-12-13 13:59:50


Ben Hutchings wrote:
> Jim Lear wrote:
>> The map iterators are really what tripped me up as an STL newbie. One
>> must understand the iterators are implemented as pairs for maps, and
>> pointers for vectors and other things. By providing an "T
>> operator[](iterator)" function for random access and associative
>> containers (and for sequences maybe), one could achieve a consistant
>> interface.
>
> Container-independent code is an impossible and pointless goal. maps
> have different semantics from other containers. You may want to iterate
> over just the mapped values, but other people may want to iterate over
> the keys, or over the pairs (and indeed, so may you, in other part of
> your program). Who's to say which of these is right? What you can do
> is to write iterator-independent code, then use an iterator adapter to
> convert the iterators over pairs into iterators over the mapped values:

Have you seen http://www.zib.de/weiser/vtl/ and
http://www.boost.org/libs/range/index.html?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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