On 12/13/04 5:42 PM, "Jim Lear"
So in the absolute most abhorently poor code example (let's just call it "meta-code"), the map operator would behave like:
data_type &operator[](const iterator &i) { return i->second; }
Am I just too ignorant to make any sense? :-) Maybe I'll crawl back into my hole. :-)
As other posters have stated, you're misunderstanding how iterators are used. They gave better explanations, but I'm butting in anyway. An iterator by itself already contains enough information to dereference its pointed-to element, or any sub-part of that element. You're asking for something like: int const a[] = { 1, 2, 3, 4 }; int const * p = &a[0]; assert( a[p] == 1 ); Hopefully you know that the "a[p]" expression is nonsensical in C++ (or C). The library containers and iterators are (mostly) supposed to act like built-in arrays and pointers. So the dereferencing semantics of STL is kept as close as possible, but no closer, to built-in operations. Note that "p" already has enough information to utilize the first element without involving "a". -- Daryle Walker Mac, Internet, and Video Game Junkie darylew AT hotmail DOT com