Date: Wed, 27 Sep 2023 23:58:58 -0400
On Wed, Sep 27, 2023 at 11:28 PM Chris Gary via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>>
>> That's absurd. The point of the semantics of comparisons is so that it
>> behaves a certain way *by default*.
>
>
> All I tried to do was start writing a predicate.
> By default, how do you expect an MP::Integer to behave? Like an integer. std::partial_ordering because it supports NaN. Could that happen with just operator <=>? No. Because.
> What happens now? I end up writing a 3-way called "Compare" that returns either std::partial_ordering or something isomorphic, and then using it to hand-roll all 6. In semi-readable code, that amounts to 12 lines.
> operator <=> didn't help at all. std::x_ordering is the same as thousands of other relationship enums written, and the behavior is now the same as an int.
>
> How can I convey that MP::Integer has std::partial_ordering category?
Like this:
```
namespace MP
class Integer
{
private:
//Members
public:
friend std::partial_ordering operator<=>(Integer const& lhs, Integer
const& rhs)
{
/* Implementation */
}
friend bool operator==(Integer const& lhs, Integer const& rhs)
{
return (lhs <=> rhs) == 0;
}
};
```
There, done.
<std-proposals_at_[hidden]> wrote:
>>
>> That's absurd. The point of the semantics of comparisons is so that it
>> behaves a certain way *by default*.
>
>
> All I tried to do was start writing a predicate.
> By default, how do you expect an MP::Integer to behave? Like an integer. std::partial_ordering because it supports NaN. Could that happen with just operator <=>? No. Because.
> What happens now? I end up writing a 3-way called "Compare" that returns either std::partial_ordering or something isomorphic, and then using it to hand-roll all 6. In semi-readable code, that amounts to 12 lines.
> operator <=> didn't help at all. std::x_ordering is the same as thousands of other relationship enums written, and the behavior is now the same as an int.
>
> How can I convey that MP::Integer has std::partial_ordering category?
Like this:
```
namespace MP
class Integer
{
private:
//Members
public:
friend std::partial_ordering operator<=>(Integer const& lhs, Integer
const& rhs)
{
/* Implementation */
}
friend bool operator==(Integer const& lhs, Integer const& rhs)
{
return (lhs <=> rhs) == 0;
}
};
```
There, done.
Received on 2023-09-28 03:59:10