Article View: comp.std.c++
Article #1725Re: STL operators != > <= >=
From: John Max Skaller
Date: Mon, 14 Aug 1995 16:22
Date: Mon, 14 Aug 1995 16:22
44 lines
2240 bytes
2240 bytes
In article <408o8u$c0p@hermes.synopsys.com>,
Mike Chapman <mchapman@synopsys.com> wrote:
>mfinney@inmind.com wrote:
[ snip snip ]
>>This is why the definitions are wrong.
>>
>
>I disagree. If a and b are not ordered (ie not comparable), it is an
>error to try to compare them. Hence a < b (or any of the other 5 operators)
>are free to do whatever they like - throw an exception, return a random
>value or start up a game of tetris.
This is an unacceptably severe overconstraint.
I see nothing wrong with a mathematical SET class with < meaning
subset. This relation is a partial order, but "subset" is well defined
for ALL pairs sets.
The fact is that < is mathematically well defined on
pointers because they are naturally partially ordered -- but the
ISO C Standard does not require correct computation of this
function for no-comparable operands, and neither does STL.
The STL definitions were in fact quite wrong and
completely unnacceptable until overloading of function templates by
partial specialisation was introduced into the C++ language.
Now the definitions in STL remain wrong, but they are
only defaults which can be overriden.
I personally do NOT like this arrangement (and have
deleted the templates from my copy of STL). I'd prefer a mechanism like:
class X : total_order ....
class Y : partial_order
with the default being to issue a diagnostic for an undefined function.
A default, however, is tolerable.
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd,
81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21
NSW 2037, AUSTRALIA Phone: 61-2-566-2189
Technical Details
Message-ID:
<MATT.95Aug14092229@physics10.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!128.32.155.1!mattReferences:
<3vpmv5$4t7@mujibur.inmind.com> <3vtcha$cbv@lyman.pppl.gov> <3vutg6$713@mujibur.inmind.com> <408o8u$c0p@hermes.synopsys.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!128.32.155.1!matt From: maxtal@Physics.usyd.edu.au (John Max Skaller) Newsgroups: comp.std.c++ Subject: Re: STL operators != > <= >= Date: 14 Aug 1995 16:22:29 GMT Organization: School of Physics, University of Sydney, Australia Approved: matt@physics10.Berkeley.EDU (Matt Austern) Message-ID: <MATT.95Aug14092229@physics10.Berkeley.EDU> References: <3vpmv5$4t7@mujibur.inmind.com> <3vtcha$cbv@lyman.pppl.gov> <3vutg6$713@mujibur.inmind.com> <408o8u$c0p@hermes.synopsys.com> NNTP-Posting-Host: physics10.berkeley.edu