Boost logo

Boost Users :

Subject: Re: [Boost-users] A forward iterator need not be default-constructible
From: Brian Allison (brian.w.allison_at_[hidden])
Date: 2011-09-29 11:40:51

On Thu, Sep 29, 2011 at 9:50 AM, Dave Abrahams <dave_at_[hidden]> wrote:

> on Thu Sep 29 2011, Krzysztof ¯elechowski <>
> wrote:
> > Dave Abrahams wrote:
> >
> >>
> >> on Wed Sep 28 2011, Nathan Ridge <> wrote:
> >>
> >>>> 2. The concept mechanism used by Boost should not require singular
> >>>> iterators to exist; the standard is obnoxious and misguided here and
> >>>> promotes sloppy coding.
> >>>
> >>> I think the Boost authors are unlikely to decide to ignore a part of
> the
> >>> standard just because one person believes it is obnoxious and misguided
> >>> and promotes sloppy coding.
> >>>
> >>> I would suggest making your case about the default constructibility of
> >>> forward iterators at comp.std.c++. If you gain consensus there that
> >>> this requirement is indeed misguided, then your request will carry
> >>> more weight here.
> >>
> >> I'd also like to point out that there's no rule saying
> >> default-constructed iterators must be singular.
> >>
> >
> > A default-constructed iterator must be singular not because the
> government
> > says so but because of logic.
> No. Well, we have to say what we mean by "is singular." Because the
> concept "singular" only contains two operations (assign and destroy),
> every valid iterator is-a singular iterator in some sense. But I
> suspect you mean "minimally singular," and there's no reason at all that
> a default-constructed iterator need be minimally singular. You usually
> can't make it usefully dereferenceable (would you want to?) but you can
> make it copyable, for example. A wrapper over a plain pointer could
> initialize the pointer to 0. Now it's a valid past-the-end iterator
> into an array of length zero. Such an iterator is also comparable with
> other iterators into the same sequence. That's actually far from
> being minimally singular.

I'm sorry - but regarding the statement "every valid iterator is-a singular
iterator in some sense"... I thought the Standard (2003) explicitly stated
that *singular *values for an iterator had all but one operation as
Undefined Behavior, and the only defined operation on an iterator with a
singular value was to assign it a non-singular value. (24.1, para 5)
*Results of most expressions are undefined for singular values; the only
exception is an assignment of a non-singular value to an iterator that holds
a singular value. In this case the singular value is overwritten the same
way as any other value. Dereferenceable values are always nonsingular.*
Doesn't the last sentence make it true that "every valid iterator is-a

I also thought it was the case that the latest standard defines *singular *to
be the same as *uninitialized *with respect to iterators? If that's the case
then we cannot call a valid iterator a singular iterator in any sense.

"I am but an egg", but it seem that there's no need to create a new term
when the old one is well-defined and sufficient.


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