On 2008-05-06 01:14:12 -0400, "subramanian100in@[EMAIL PROTECTED]
India"
<subramanian100in@[EMAIL PROTECTED]
> said:
> I am copying the following lines as it is, from Stanley Lippman's C++
> Primer 4th edition, page 418(First paragraph).
>
> It says:
> "Although the map and set types provide bidirectional iterators, we
> can use only a subset of the algorithms on associative containers. The
> problem is that key in an associative container is const. Hence, any
> algorithm that writes to elements in the sequence cannot be used on an
> associative container. We may use iterators bound to associative
> containers only to supply arguments that will be read."
>
While this explanation is technically correct, it's at the wrong level
of detail. The problem is that modifying elements in an associative
container could disrupt the ordering of the container. So you aren't
allowed to do it. In the library's interface that's enforced by making
the key const and by providing only iterators that don't sup****t
modifying the elements that they point to.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)


|