Article View: comp.std.c++
Article #2359definition of allocator::difference_type?
From: Eric Biederman
Date: Tue, 31 Oct 1995 08:30
Date: Tue, 31 Oct 1995 08:30
39 lines
1572 bytes
1572 bytes
In reading through 20.1 Allocator requirements [lib.allocator.requirements]
I have come across some wording which I find inconsistent with what is
in the rest of the standard as I understand it.
X::difference_type
the type that can represent the difference between any two pointers in
the memory model.
Which seems to say that the operation
X::pointer a,b;
// initialize a & b to point into different objects
X::difference t = a - b; // seems to be well defined.
later in
20.4.1 The default allocator [lib.default.allocator]
in the definition of the default allocator,
class allocator {
public:
typedef size_t size_type
typedef ptrdiff_t difference_type
If I understand the definition of ptrdiff_t from C the result is
undefined if you take the difference of two pointers which do not
point into the same object.
So is it undefined or not, if you are using the types supplied with
the allocators? What is the intent here?
Eric
---
[ 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:
<EBIEDERM.95Oct30235117@cse.unl.edu>Path:
arc1-ca.pugleaf.net!uwm.edu!msunews!agate!agate!MattShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!uwm.edu!msunews!agate!agate!Matt From: ebiederm@cse.unl.edu (Eric Biederman) Newsgroups: comp.std.c++ Subject: definition of allocator::difference_type? Date: 31 Oct 1995 08:30:47 GMT Organization: University of Nebraska--Lincoln Approved: Matt@Austern Message-ID: <EBIEDERM.95Oct30235117@cse.unl.edu> NNTP-Posting-Host: austern.hip.berkeley.edu