From -8888108702201839892
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,221e73cda6c65dc7
X-Google-Attributes: gidf78e5,public
From: Francis Glassborow <francis@robinton.demon.co.uk>
Subject: Re: relational operators and pointers
Date: 2000/06/22
Message-ID: <LuV3XWAeX9T5Ew3r@robinton.demon.co.uk>#1/1
X-Deja-AN: 637331785
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <8iog9l$2bo$1@news.rrz.Uni-Koeln.DE>
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 961614363 mail2news:13314 mail2news mail2news.demon.co.uk
Organization: Southfield Microcomputer SS
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
MIME-Version: 1.0
Reply-To: Francis Glassborow <francisG@robinton.demon.co.uk>
Newsgroups: comp.std.c++

In article <8iog9l$2bo$1@news.rrz.Uni-Koeln.DE>, Boris
<boris@gtemail.net> writes
>But this is stupid as you are allowed only to compare pointers that point to
>the same object because the rest is unspecified. That means you have to know
>whether pointers point to the same object before you compare them! Do I
>misunderstand the Standard (I really hope so)?

Possibly (the templates you started with are a red-herring). You are
always allowed to compare for equality any two valid pointers (look
elsewhere for a discussion for what makes a pointer valid).  That means
that providing p1 and p2 are valid pointers you can always evaluate
p1==p2 and p1!=p2. However you can only apply the other four comparison
operators to pointers that point into the same object.  The template
versions may have to walk on eggshells to get round problems with
pointers that do not point to somewhere in the same object.

Consider a generalised pointer concept such as a URL, it is easy to
check if two URL's result in the same location, but how do you provide a
complete ordering (I am not saying this is impossible, just that it is
non-trivial unless you know rather more than just that they are two
valid URL's)



Francis Glassborow      Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA          +44(0)1865 246490
All opinions are mine and do not represent those of any organisation

---
[ 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              ]




