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 07:55:02 -0700
On Wednesday, 27 September 2023 00:30:19 PDT Chris Gary via Std-Proposals
wrote:
> It is possible to keep std::strong_ordering around. Just formally allow
> <signed-int> operator<=>, and let the compiler do the rest. The alternative
> is really just saving around 12 lines of code per thing that needs a full
> suite of comparison operators.

Like so?

struct A { char buf[48]; };
inline int operator<=>(const A &l, const A &r)
{
    return memcmp(&l, &r, sizeof(A));
}


https://gcc.godbolt.org/z/bMzE51v17

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

Received on 2023-09-27 14:55:05