null stl iterator ?

G

Gianni Mariani

I need to create an object that contains an iterator. The iterator may
or may not be valid in which case I would also need to store a flag
indicating that the iterator is invalid.

Am I missing somthing ?

This object is created way before a container is created so setting it
to end() or somthing does not make sense.
 
M

Moonlit

Hi,

Why not set variables for beginiing end one past end of array.. These var
will be returned by end() and begin().

Then when you assign an array make the 'end' var equal to one past the end
of the array and the other 'begin' var to begining of the array.

Regards, Ron AF Greve
 
R

Ron Natalie

Gianni Mariani said:
This object is created way before a container is created so setting it
to end() or somthing does not make sense.

Then you will need to have an external flag, or create a container specifically
so you can use it's end() (even if you never put anything in it).

The standard provides no "default" value for iterators.
 
R

Ron Natalie

Moonlit said:
Hi,

Forgot to say, initially these variables should be set to zero.
If these "variables" are iterators, then there's no guarantee you can
assign (even a constant) zero to them.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top