This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: STL defect?
- To: nbecker at fred dot net
- Subject: Re: STL defect?
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Wed, 2 Sep 1998 07:27:07 +0200
- CC: egcs at cygnus dot com
- References: <E0zDsev-0006Tf-00@hns.com>
> 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