C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Unary operator | (absolute value of)

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 23 Nov 2023 16:12:56 -0800
On Thursday, 23 November 2023 14:43:55 PST Rik van der Brugghen via Std-
Proposals wrote:
> Hi.
>
> Maybe suggested before, but would be great with
>
> a = |b; // a = abs (b)
>

And since we *have* abs(), how often do we need this? Adding an operator to
the language is a VERY high bar, there must be a strong reason for this. What
would it allow one to do that can't be done with the library as it is?

Operator <=> is the only operator we've added since C++ was first standardised.
It was added because the three-way comparison needed to be a language feature
so we could have the other relational operators synthesised from it, otherwise
we could have simply done with a library solution with extension points.

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

Received on 2023-11-24 00:12:58