C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Let spaceship return an int

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 27 Sep 2023 14:52:23 -0700
On Wednesday, 27 September 2023 14:00:51 PDT Chris Gary via Std-Proposals
wrote:
> Type-safe composition of ordering can follow an intuitive definition.
>
> For two structures, compare each pair of members in the declaration order,
> apply common_type<> and take the first result that is not equal. Where one
> structure is longer than the other, let common_type<T,void> -> T, then
> invoke "T{} <=> value". Assuming plain bytes, the result is the same as a
> memcmp with zero-padded arguments.

You've repeated yourself without thinking about what I wrote. You've answered
for equality. Now think about the other operators: how does it implement "is
less" for the type I proposed earlier? Mind you, it is strongly ordered and
memcmp() only returns sign, not constraining itself to -1, 0, 1.

> While an enum is supposed to represent a contract and combine accordingly,
> it really can't. Robust code has to have a path assuming that, like any
> other function, it can produce incorrect results, or a way to debug the
> thing. It can't guarantee that the ordering is implemented correctly, and
> that we have this extra thing called "unordered" instead of
> "something_broke".

Yeah, no. That's not how it works, not how it's implemented, how it's designed
or how we should design.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-09-27 21:52:26