C++ Logo

std-proposals

Advanced search

Re: [std-proposals] ^^operator [was: Re: New draft proposal: Add "%s" (two-digit truncated-integer seconds) as a std::format conversion specifier for std::chrono time types.]

From: Magnus Fromreide <magfr_at_[hidden]>
Date: Thu, 11 May 2023 08:21:07 +0200
On Thu, May 04, 2023 at 10:54:21AM +0200, Sebastian Wittmeier via Std-Proposals wrote:
> Should be:
>
>  
> auto operator^^(auto A, auto B)
>
> {
>
>     if(A && !B)
>
>         return A;
>
>     if(B && !A)
>
>         return B;
>
>     return nil;
>
> }
>

That is a surprising formulation - not bad but surprising.

Consider operator ||, do you propose to change it to something along the
lines of

auto operator||(auto A, auto B)
{
        if (A)
                return A;
        else
                return B;
}

but with extra magic to short-circut?

/MF

Received on 2023-05-11 06:21:11