Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Vertex_handle and "operator->"

Subject: CGAL users discussion list

List archive

[cgal-discuss] Vertex_handle and "operator->"


Chronological Thread 
  • From: "Eivind LM" <>
  • To:
  • Subject: [cgal-discuss] Vertex_handle and "operator->"
  • Date: Tue, 07 Oct 2008 19:37:40 +0200

Speaking of Vertex_handle; am I the only one to mix up '.' and '->' with Vertex_handle?

I'm used to having

std::list< MyObject > objects;
std::list< MyObject >::iterator it = objects.begin();

and when I dereference the iterator, then I'm getting a MyObject back, so I would call

(*it).do_something(); // using '.' instead of '->' since (*it) is MyObject


However, if I have

std::list< Vertex_handle > vertices;
std::list< Vertex_handle >::iterator it = vertices.begin();

then I need to do

(*it)->point(); // using '->' instead of '.'


Using '*' and '->' at the same time on a variable (which is not a pointer type) looks "wrong" in my eyes, so I very often automatically write

(*it).point(); // error


The compiler error I would expect in this case is

request for member ‘point’ in ‘* it’, which is of non-class type [...]

but instead I get

[...] has no member named ‘point’

which was very confusing in the beginning. The crucial point is that Vertex_handle implements "operator->", but I didn't realize this until I had a look in the source. Has anyone else been confused by the same thing?

Can I generally assume that all types that end with "_handle" in CGAL implements an "operator->"?

Eivind



Archive powered by MHonArc 2.6.16.

Top of Page