Boost logo

Boost Users :

Subject: Re: [Boost-users] A forward iterator need not be default-constructible
From: Andrew Sutton (asutton.list_at_[hidden])
Date: 2011-09-30 12:23:12


> It should what the standard says. If it says anything can happen, then
> anything can happen. Including crashing. It is perfectly possible for
> a CPU to trap on uninitialized variables for example.
>
>> int* i;
>> assert(i == i);

Alas, back to the standard. I find the standard's limitations
unfortunate; equality comparison of uninitialized values should be
allowed. I doubt that allowing that such comparisons would have any
significant impact on real programs.

More importantly, it lets you draw a direct relationship between an
iterator with a singular value (say, i) and an empty range [i, i). The
reason why dereferencing a singular iterator is invalid is that you
are dereferencing past the end. It's also the same reason why ++ is
invalid; you're past the end.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net