🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3097

Allocator pointer operations (was: STL experts, please comment)

#3097
From: Nathan Myers
Date: Wed, 24 Jan 1996 01:03
53 lines
2993 bytes
Joe Buck wrote:
> 
> David Byrden <100101.2547@compuserve.com> writes:
> >In the HP STL, deque::iterator has a default ctor which initialises
> >several of its members with the value 0
> >
> >       iterator() : current(0), first(0), last(0), node(0) {}
> >
> >These members have the type deque::pointer, which is a typedef
> >for the pointer in deque's allocator.
> >An allocator pointer, according to the standard, has exactly the same
> >semantics as a random access iterator.

No... an allocator pointer is something that has pointer semantics.
It can only confuse things to bring in Iterators here.  The list of
required semantics for allocator pointers is quite limited.

Conversion from 0 is not required, but conversion to void* and
default construction are.  Arguably the line above should be:

> >       iterator() : current(Allocator::pointer()),
                       first(Allocator::pointer()), 
                       last(Allocator::pointer()),
                       node(Allocator::pointer()) {}

> >I can find no place where it says that all random access iterators
> >should be constructable from the int value zero, neither in
> >documentation from the time of the HP STL, nor the latest draft standard.
> 
> Correct.

> >So, this ctor seems to break the rules. Yet it was written by the
> >inventors of STL.
> 
> Well, they goofed, I suppose.  Seems the types of allocators they used
> were all pointers, so they didn't test out other cases.

The current definition of allocator pointers didn't exist when 
the HP implementation was written, so you can't blame Stepanov
and Lee.  

The implementations of all the standard containers change in response
to changes in Allocator, and std lib vendors have been working feverishly
to get everything consistent.  A non-pointer allocator "pointer" is an
obvious addition to the test suite for a standard library.

Nathan Myers
http://www.cantrip.org/          <-- note: new site
ncm@cantrip.org                  <-- note: new address
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <31058136.611@cantrip.org>
Path: arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-back
References: <4dnteb$6fo@news.bridge.net> <4e1034$5ar@hermes.synopsys.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!cs.mu.OZ.AU!bounce-back
From: Nathan Myers <ncm@cantrip.org>
Subject: Allocator pointer operations (was: STL experts, please comment)
Message-ID: <31058136.611@cantrip.org>
Originator: fjh@munta.cs.mu.OZ.AU
Sender: news@cs.mu.OZ.AU (CS-Usenet)
Organization: Best Internet Communications
References: <4dnteb$6fo@news.bridge.net> <4e1034$5ar@hermes.synopsys.com>
X-Original-Date: Tue, 23 Jan 1996 16: 45:42 -0800
Date: Wed, 24 Jan 1996 01:03:19 GMT
Approved: fjh@cs.mu.oz.au
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMQWFZ+EDnX0m9pzZAQFhogF9HEIcgLc3j4BA5wEnDTBkJfVEE7flritH
 L9KWdK9cVzG451QquQLkeMyQdjyXX8Qc
 =Eigt
X-Mailer: Mozilla 2.0b3 (X11; I; SunOS 5.4 sun4m)