🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: definition of allocator: :difference_type?

#2451
From: Fergus Henderson
Date: Tue, 07 Nov 1995 13:54
35 lines
2253 bytes
David Byrden <100101.2547@CompuServe.COM> writes:

>The basic intent here is that difference_type  will have enough 
>bits, segments, and sundry machine-specific doodads to represent 
>the difference between two addresses, even if they are the two 
>ends of an array as large as all of memory.

Are you sure?  Why?
I'm not at all convinced that that was the intent,
and I'm not convinced that mandating this would
be possible, meaningful, or useful.

>The difference between addresses in separate object is undefined 
>in the sense that it is a meaningless number. None the less, this 
>meaningless number should FIT in a difference_type without 
>overflowing it.

Are you suggesting that if you subtract pointers to objects from
different arrays you should merely get an unspecified result
rather than undefined behaviour?  If so, why?
This is clearly different from the status quo for tbe builtin pointer
types - the definition of subtraction in 5.7 [expr.add] clearly states
that the behaviour is undefined.  Why should implementations be
prohibited from say aborting the program with a diagnostic in this case?

I basically agree with John Skaller's comment - the current definition
of `difference_type' is a bug in the draft standard.

--
Fergus Henderson             	WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au              	PGP: finger fjh@128.250.37.3
---
[ 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: <9531123.19118@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <EBIEDERM.95Oct30235117@cse.unl.edu> <47mqgj$4qf$2@mhafc.production.compuserve.com>

Show Full Headers
Complete Article Headers
Approved: fjh@cs.mu.oz.au
Date: 07 Nov 95 13:54:39 GMT
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Message-ID: <9531123.19118@mulga.cs.mu.OZ.AU>
Newsgroups: comp.std.c++
Organization: Computer Science, University of Melbourne, Australia
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <EBIEDERM.95Oct30235117@cse.unl.edu> <47mqgj$4qf$2@mhafc.production.compuserve.com>
Subject: Re: definition of allocator: :difference_type?
X-Original-Date: Tue, 7 Nov 1995 23:58:36 +1100
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMJ9lO+EDnX0m9pzZAQGfRQF/fkYvtHBVSXAi13vZRjI+aEaDYTSkc6Mb
 o/YJoln4K2I4BlVddzGwB5LKNTht8i65
 =6cb3