15 Dec
2004
15 Dec
'04
4:05 p.m.
Daryle Walker wrote:
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".
Yes, you are right, the container[iterator] doesn't make sense. I'm just longing for the "for (i in map) print i,map[i];" simplicity of awk and other languages. -- Jim Lear