Date: Mon, 19 Dec 2022 09:49:27 -0600

Given:

struct Point {

int x;

int y;

bool operator==(Point const&) const = default;

};

bool a = Point{1, 2} == Point{1, 2};

bool b = Point{1, 2} == Point{1, 3};

bool c = Point{1, 2} == Point{3, 4};

Do you understand what a, b, and c are?

On Mon, Dec 19, 2022 at 9:06 AM Vladimir Grigoriev <vlad.moscow_at_[hidden]>

wrote:

> I am sorry but I have not yet understood what this statement «Otherwise, V

> is false.» mean.

>

> With best regards

> (Vlad from Moscow)

>

> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or

> http://ru.stackoverflow.com

>

>

>

> Понедельник, 19 декабря 2022, 17:54 +03:00 от Barry Revzin <

> barry.revzin_at_[hidden]>:

>

>

>

> On Mon, Dec 19, 2022 at 8:32 AM Vladimir Grigoriev via Std-Discussion <

> std-discussion_at_[hidden]

> <//e.mail.ru/compose/?mailto=mailto%3astd%2ddiscussion_at_[hidden]>>

> 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.»

>

>

> It would be helpful if you would point out *where* these phrases exist in

> the C++20 Standard, as it would make it easier for people to answer your

> questions. In this case, this is [class.eq]/3 (

> https://eel.is/c++draft/class.eq#3)

>

>

>

> What does the last statement « Otherwise, V is false.»» mean?

>

>

> Does it mean a case when two expanded lists are unequal or something else?

>

>

> No, the expanded lists have to be equal - we have the same type on both

> sides. There are two separate things going on in this paragraph:

>

>

> 1. What work is done? We compare xi == yi until the first i for which

> xi == yi, contextually convertible to bool, yields false.

> 2. What value is returned? If no such i exists, V (the return value)

> is true. Otherwise, V is false.

>

> Introducing V doesn't seem like it adds anything, if the wording said "If

> no such index exists, the return value is true. Otherwise, the return value

> is false." it'd be more direct.

>

>

>

> In any case a code example of such «otherwise» along with the example of a

> trivial comparison that follows would be useful to make the statement more

> clear.

>

> With best regards

> (Vlad from Moscow)

> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or

> http://ru.stackoverflow.com

>

>

>

> Понедельник, 19 декабря 2022, 14:33 +03:00 от Edward Catmur via

> Std-Discussion <std-discussion_at_[hidden]

> <//e.mail.ru/compose/?mailto=mailto%3astd%2ddiscussion_at_[hidden]>>:

>

>

> On Mon, 19 Dec 2022, 11:31 Vladimir Grigoriev via Std-Discussion, <

> std-discussion_at_[hidden]

> <http://e.mail.ru/compose/?mailto=mailto%3astd%2ddiscussion_at_[hidden]>>

> wrote:

>

> Can anybody translate this phrase from the C++ 20 Standard

>

> «Name lookups in the defaulted definition of a comparison operator

> function are performed from a context equivalent to its function-body.»

>

> to the human language?

>

> How can a context be equivalent to a function body? They are two

> different notions.

>

>

> A context equivalent to the context of the function body.

>

>

>

>

> With best regards

> (Vlad from Moscow)

> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or

> http://ru.stackoverflow.com

> --

> Std-Discussion mailing list

> Std-Discussion_at_[hidden]

> <http://e.mail.ru/compose/?mailto=mailto%3aStd%2dDiscussion_at_[hidden]>

> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

>

> --

> Std-Discussion mailing list

> Std-Discussion_at_[hidden]

> <http:///compose?To=Std%2dDiscussion_at_[hidden]>

> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

>

>

> --

> Std-Discussion mailing list

> Std-Discussion_at_[hidden]

> <//e.mail.ru/compose/?mailto=mailto%3aStd%2dDiscussion_at_[hidden]>

> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

>

>

>

struct Point {

int x;

int y;

bool operator==(Point const&) const = default;

};

bool a = Point{1, 2} == Point{1, 2};

bool b = Point{1, 2} == Point{1, 3};

bool c = Point{1, 2} == Point{3, 4};

Do you understand what a, b, and c are?

On Mon, Dec 19, 2022 at 9:06 AM Vladimir Grigoriev <vlad.moscow_at_[hidden]>

wrote:

> I am sorry but I have not yet understood what this statement «Otherwise, V

> is false.» mean.

>

> With best regards

> (Vlad from Moscow)

>

> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or

> http://ru.stackoverflow.com

>

>

>

> Понедельник, 19 декабря 2022, 17:54 +03:00 от Barry Revzin <

> barry.revzin_at_[hidden]>:

>

>

>

> On Mon, Dec 19, 2022 at 8:32 AM Vladimir Grigoriev via Std-Discussion <

> std-discussion_at_[hidden]

> <//e.mail.ru/compose/?mailto=mailto%3astd%2ddiscussion_at_[hidden]>>

> 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.»

>

>

> It would be helpful if you would point out *where* these phrases exist in

> the C++20 Standard, as it would make it easier for people to answer your

> questions. In this case, this is [class.eq]/3 (

> https://eel.is/c++draft/class.eq#3)

>

>

>

> What does the last statement « Otherwise, V is false.»» mean?

>

>

> Does it mean a case when two expanded lists are unequal or something else?

>

>

> No, the expanded lists have to be equal - we have the same type on both

> sides. There are two separate things going on in this paragraph:

>

>

> 1. What work is done? We compare xi == yi until the first i for which

> xi == yi, contextually convertible to bool, yields false.

> 2. What value is returned? If no such i exists, V (the return value)

> is true. Otherwise, V is false.

>

> Introducing V doesn't seem like it adds anything, if the wording said "If

> no such index exists, the return value is true. Otherwise, the return value

> is false." it'd be more direct.

>

>

>

> In any case a code example of such «otherwise» along with the example of a

> trivial comparison that follows would be useful to make the statement more

> clear.

>

> With best regards

> (Vlad from Moscow)

> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or

> http://ru.stackoverflow.com

>

>

>

> Понедельник, 19 декабря 2022, 14:33 +03:00 от Edward Catmur via

> Std-Discussion <std-discussion_at_[hidden]

> <//e.mail.ru/compose/?mailto=mailto%3astd%2ddiscussion_at_[hidden]>>:

>

>

> On Mon, 19 Dec 2022, 11:31 Vladimir Grigoriev via Std-Discussion, <

> std-discussion_at_[hidden]

> <http://e.mail.ru/compose/?mailto=mailto%3astd%2ddiscussion_at_[hidden]>>

> wrote:

>

> Can anybody translate this phrase from the C++ 20 Standard

>

> «Name lookups in the defaulted definition of a comparison operator

> function are performed from a context equivalent to its function-body.»

>

> to the human language?

>

> How can a context be equivalent to a function body? They are two

> different notions.

>

>

> A context equivalent to the context of the function body.

>

>

>

>

> With best regards

> (Vlad from Moscow)

> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or

> http://ru.stackoverflow.com

> --

> Std-Discussion mailing list

> Std-Discussion_at_[hidden]

> <http://e.mail.ru/compose/?mailto=mailto%3aStd%2dDiscussion_at_[hidden]>

> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

>

> --

> Std-Discussion mailing list

> Std-Discussion_at_[hidden]

> <http:///compose?To=Std%2dDiscussion_at_[hidden]>

> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

>

>

> --

> Std-Discussion mailing list

> Std-Discussion_at_[hidden]

> <//e.mail.ru/compose/?mailto=mailto%3aStd%2dDiscussion_at_[hidden]>

> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

>

>

>

Received on 2022-12-19 15:49:41