Boost logo

Boost Users :

Subject: Re: [Boost-users] A forward iterator need not be default-constructible
From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2011-09-30 11:40:19

On Fri, Sep 30, 2011 at 12:31 PM, Andrew Sutton <asutton.list_at_[hidden]> wrote:
>>> Why not? Isn't an object equal to itself?
>> Because a singular iterator can be a uninitialized variable and you can't
>> equally-compare a uninitialized variable, nor copy it. All you can do is
>> assign and destroy it.
> I know what the standard says, but shouldn't this always return true?

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);
> Regardless of the actual value? It seems to me that this is a pretty
> fundamental property: an object is always equal to itself*. If you
> believe it, then you're allowed to construct empty bounded ranges of
> singular values [i, i).
> * Excluding volatile objects.


Felipe Magno de Almeida

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at