On May 6, 9:12=A0pm, Ian Collins <ian-n...@[EMAIL PROTECTED]
> wrote:
> subramanian10...@[EMAIL PROTECTED]
India wrote:
> > My understanding:
> > Along the same above discussion, shouldn't map<Key, T>::iterator and
> > multimap<Key, T>::iterator also be constant bidirectional iterators ?
> > (This is what I expected because for both set, multiset, map,
> > multimap, the key is constant)
>
> No, the key may be constant, but the value is mutable.
The salient difference between a std::map and a std::set is that each
value stored in a std::set is also a key. So the reason why values
stored in a std::set are immutable - is because the std::set's keys
are immutable (to ensure a proper order). But since the std::set's
keys and its values are one and the same, it follows that a std::set's
values are immutable because they are also keys..
With a std::map, the values are distinct from their keys - so although
the keys in a std::map are immutable, the values in a map need not be.
Because - unlike a std::set - changing a value stored in a std::map
will not affect the sorted order of the container.
Greg


|