C++ Logo


Advanced search

Re: Comparison operators

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Mon, 19 Dec 2022 10:52:08 -0500
On Mon, Dec 19, 2022 at 10:05 AM Bo Persson via Std-Discussion
<std-discussion_at_[hidden]> wrote:
> On 2022-12-19 at 15:32, Vladimir Grigoriev via Std-Discussion wrote:
> > There is another unclear phrase in the C++ 20 Standard relative to
> > comparison operators.
> > «3 The return value V of a defaulted == operator function with
> > parameters x and y is determined by comparing corresponding elements xi
> > and yi in the expanded lists of subobjects for x and y (in increasing
> > index order) until the first index i where xi == yi yields a result
> > value which, when contextually converted to bool, yields false. If no
> > such index exists, V is true. Otherwise, V is false.»
> > What does the last statement « Otherwise, V is false.»» mean?
> It is the else-part of the preceding 'if', just to make sure.
> When you only have "If no such index exists, V is true.", you might
> possibly wonder if V can be true anyway? So the next statement
> clarifies(?) that if it is not true, it must be false.

I think the problem is that there is no else. That is, there is no
circumstance where the "otherwise" clause would come into effect.

If you break this paragraph down into C++ code, it reads like this:

optional<int> oi = find_index();
  return false;
  return true;
  return false;

What is that else clause doing?

Received on 2022-12-19 15:54:36