From 6280674767025724403
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,16c102c32134aea8
X-Google-Attributes: gidf78e5,public
From: jpotter@falcon.lhup.edu (John Potter)
Subject: Re: Defect Report: Unnecessary restriction on past-the-end iterators
Date: 2000/02/04
Message-ID: <3899e0b4.44926675@news.csrlink.net>#1/1
X-Deja-AN: 581233155
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <538B4E4235ECD211B35B0090273CC28B012E28@CECEXCHANGE>
X-Original-Nntp-Posting-Host: 204.249.184.1
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 949610314 mail2news:4348 mail2news mail2news.demon.co.uk
Organization: D&E SuperNet
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Newsgroups: comp.std.c++

On 3 Feb 2000 17:29:40 GMT, scleary@jerviswebb.com wrote:

: Unnecessary restriction on past-the-end iterators
: 
: Section: 24.1 [Iterator requirements]
: Submitter: Stephen Cleary
: Date: 02 February 2000
: 
: In 24.1 [Iterator requirements] paragraph 5, it is stated ". . .
: Dereferenceable and past-the-end values are always non-singular."
: 
: This places an unnecessary restriction on past-the-end iterators for
: containers with forward iterators (for example, a singly-linked list).  If
: the past-the-end value on such a container was a well-known singular value,
: it would still satisfy all forward iterator requirements.
: 
: Removing this restriction would allow, for example, a singly-linked list
: without a "footer" node.

I don't read the standard that way.  The example is
   int* p;    // singular because it has no known value
however
   int* q(0); // the nul pointer is not singular

The only operation allowed on a singular pointer/iterator is assignment
to.  It may not be compared.

istream_iterator<char> it; // Not singular
It is a universal end iterator for all istream_iterator<char> regardless
of the stream.

Forward_iterator requires a default constructor which _might_ produce
a singular value.  It might also not produce a singular value.  That
does not mean that the end iterator for slist<T> is not allowed to
contain a nul pointer which gives it a non-singular value.  AFAIK,
the SGI slist iterator meets all requirements for forward_iterator
and uses a nul pointer within the end iterator.

: This would have an impact on existing code that expects past-the-end
: iterators obtained from different (generic) containers being not equal.

That code is already broken.  The standard does not say that the past
the end iterator is unique for each container.

John

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




