[Xcb] xcb_foo_next/xcb_foo_end

Ulrich Eckhardt doomster at knuut.de
Thu Jun 24 22:01:51 PDT 2010


Simple question: When I call xcb_foo_end(), do I really (as documented) get an 
"iterator pointing to the last element" of a sequence? Do I not rather get an 
iterator one element behind that? The point is that the returned iterator's 
"rem" field is zero, meaning "no element left". In terms of the STL[1], that 
would be a "past-the-end iterator".

That said, I wonder if anybody ever used this at all. In order to iterate over 
a sequence, just looking at the "rem" field of the iterator is so much easier 
than retrieving an iterator pointing past the end and then comparing (how?) 
the two.

1. Should this be deprecated now and later be removed?
2. If not, and since I'm hacking on the generator code anyway, any suggestions 
how to improve the comment? I'd just say "Return the end iterator", and not 
claim anywhere that it points to an element.


[1] Standard Template Library, a C++ lib defining various iterator types and 
algorithms operating on them.

More information about the Xcb mailing list