STL defect?
Martin von Loewis
martin@mira.isdn.cs.tu-berlin.de
Tue Sep 1 23:40:00 GMT 1998
> The problem is that the builtin pointer types don't implement operator->, so
> operator-> won't work for vector, whose underlying representation of
> an iterator is a pointer. But STL says that iterators should have an
> operator->.
Where exactly does it say so? The -> in C++ is there to access fields
of a structure (or members, in general). Since you don't have
structured values, you don't need it.
To retrieve the entire value, you can use the * operator. I don't
think conversion of iterators to plain pointers is supported; the
following program compiles, though.
#include <vector>
#include <deque>
main () {
vector<double> V;
deque<double> D;
vector<double>::iterator I;
deque<double>::iterator J;
double* p1 = &(*J);
double* p2 = &(*I);
}
Martin
More information about the Gcc
mailing list