Boost logo

Boost Users :

Subject: Re: [Boost-users] A forward iterator need not be default-constructible
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-09-29 09:50:29

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.

Dave Abrahams
BoostPro Computing

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