STL defect?

nbecker@fred.net nbecker@fred.net
Tue Sep 1 12:32:00 GMT 1998


This small test program demonstrates either a defect in STL design or
in egcs implementation.

-----------------
#include <vector>
#include <deque>

main () {
  vector<double> V;
  deque<double> D;
  vector<double>::iterator I;
  deque<double>::iterator J;
  double* p1 = J.operator->();
  double* p2 = I.operator->();
}

---------------
g++ -c Test.cc
Test.cc: In function `int main()':
Test.cc:10: request for member `operator ->' in `I', which is of non-aggregate type `double *'

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->.



More information about the Gcc mailing list