Date: Mon, 19 Dec 2022 16:03:14 +0000
Hi,
On 19/12/2022 15:52, Jason McKesson via Std-Discussion wrote:
> 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:
Not quite:
>
> ```
> optional<int> oi = find_index();
This first "if" is not in the quoted text.
> if(oi)
> return false;
> if(!oi)
> return true;
> else
> return false;
> ```
>
> What is that else clause doing?
It's the part that means there is actually a "return false" in the "code"
1. Find the index where xi==yi yields false. Nothing is specified about
the return value V yet.
2. If there isn't such an index, V is true
3. otherwise V is false.
Cheers,
Anthony
On 19/12/2022 15:52, Jason McKesson via Std-Discussion wrote:
> 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:
Not quite:
>
> ```
> optional<int> oi = find_index();
This first "if" is not in the quoted text.
> if(oi)
> return false;
> if(!oi)
> return true;
> else
> return false;
> ```
>
> What is that else clause doing?
It's the part that means there is actually a "return false" in the "code"
1. Find the index where xi==yi yields false. Nothing is specified about
the return value V yet.
2. If there isn't such an index, V is true
3. otherwise V is false.
Cheers,
Anthony
Received on 2022-12-19 16:03:22