This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: STL defect?


> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]