comp.lang.ada
 help / color / mirror / Atom feed
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Top 10 Worst C# Features
Date: Wed, 14 Oct 2015 15:26:21 +0100
Date: 2015-10-14T15:26:21+01:00	[thread overview]
Message-ID: <87mvvla5ma.fsf@bsb.me.uk> (raw)
In-Reply-To: 5cb5c989-4d12-41d8-88df-ab45988ba8a1@googlegroups.com

Maciej Sobczak <see.my.homepage@gmail.com> writes:
<snip>
> Yes, we understand that it is possible to have incompatible
> implementations of operator== and operator!= in C++ (assuming that
> this is the language you are referring to), but we are willing to take
> this risk (and address it by other means) as it allows us to implement
> these operators more efficiently.

Do you mean that there are reasons to permit !(a == b) and a != b to
have different values in some cases?  I don't think you mean this
(because your example does not obviously address that possibility), but
I am not 100% sure.

> One possible example where this could be possible is when the
> encapsulated data has a digital signature or some other short digest
> available with the property that when two digests are different then
> the objects are surely different (and this can be determined very
> quickly), whereas when the digests are equal then more work is needed
> to determine whether the objects are equal, too. In this case, our
> operator!= can be much faster than operator== and we are willing to
> benefit from the optimization opportunity here. This could not be
> possible if one is automatically derived from the other.

I don't see why

  bool operator!=(const T &other) const noexcept
  {
    if (this.hash != other.hash)
      return true;
    return !this.long_slow_equality_test(other);
  }

is any more or less efficient than

  bool operator==(const T &other) const noexcept
  {
    if (this.hash != other.hash)
      return false;
    return this.long_slow_equality_test(other);
  }

but I may have missed the point you are trying to make.

<snip>
-- 
Ben.


  reply	other threads:[~2015-10-14 14:26 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 10:59 Top 10 Worst C# Features Stefan.Lucks
2015-09-02 17:37 ` Álex R. Mosteo
2015-09-02 19:39 ` Randy Brukardt
2015-09-03  8:14   ` Georg Bauhaus
2015-09-03  9:26     ` Dmitry A. Kazakov
2015-09-03 11:39       ` G.B.
2015-09-03 12:00         ` G.B.
2015-09-03 13:59           ` Dmitry A. Kazakov
2015-09-03 19:12           ` Randy Brukardt
2015-09-04  7:33             ` Georg Bauhaus
2015-09-04 21:34               ` Randy Brukardt
2015-09-05  6:31                 ` Dmitry A. Kazakov
2015-09-05  6:44                 ` Georg Bauhaus
2015-09-05  7:07                   ` Dmitry A. Kazakov
2015-09-05  6:45                 ` Niklas Holsti
2015-09-05  7:21                   ` Dmitry A. Kazakov
2015-09-05 12:07                   ` Peter Chapin
2015-09-06 10:45                   ` Georg Bauhaus
2015-10-13 19:57                   ` Eryndlia Mavourneen
2015-09-05  7:16                 ` Shark8
2015-09-03 13:47         ` Dmitry A. Kazakov
2015-09-03  8:51 ` gautier_niouzes
2015-10-01 14:03 ` Paul Colin de Gloucester
2015-10-14  8:00   ` Maciej Sobczak
2015-10-14 14:26     ` Ben Bacarisse [this message]
2015-10-14 16:50       ` Paul Rubin
2015-10-14 18:17         ` Stefan.Lucks
2015-10-14 19:54           ` Ben Bacarisse
2015-10-15 12:24       ` Maciej Sobczak
2015-10-15 13:59         ` Ben Bacarisse
2015-11-06 14:50     ` Nicholas Collin Paul de Gloucester
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox