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: Jonathan Wakely <cxx_at_[hidden]>
Date: Thu, 4 May 2023 09:10:44 +0100
On Thu, 4 May 2023, 08:35 Sebastian Wittmeier via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

>
>
> -----Ursprüngliche Nachricht-----
> *Von:* Simon Hill via Std-Proposals <std-proposals_at_[hidden]>
> *Gesendet:* Mi 03.05.2023 17:21
> *Betreff:* Re: [std-proposals] New draft proposal: Add "%s" (two-digit
> truncated-integer seconds) as a std::format conversion specifier for
> std::chrono time types.
> *An:* std-proposals_at_[hidden];
> *CC:* Simon Hill <protogrammer_at_[hidden]>;
> But people learn that a single logical operator is bitwise, and a double
> logical operator is boolean. They then have to remember that ^ doesn't have
> a bitwise equivalent.
>
>
>
> ^ is already bitwise. You mean ^ has no logical equivalent?
>
> Some logical operators use doubled symbols, some not.
>
> && and || specifically stand for the short-circuit evaluation.
>
> Otherwise for consistency one would want to introduce !! instead of ! for
> logical NOT, which would lead to a lot of confusion and faulty programs.
>

OK I lied, I do have an opinion on this...

^^ looks like it could be an exponentiation operator to me, and apparently
Haskell and D use it for that. And if we added the ability to overload
operator^^ then I'm pretty sure people would start abusing it for
exponentiation (because there's no operator** in C++).

If somewhat confusing, terse syntax is preferable to bool(x)^bool(y) then
you can already do !x != !y. But I'd just use != for this operation on
booleans anyway, not xor (whether in single or double form).


I think new operators need a much more compelling justification than being
a bit less verbose than existing solutions.

Received on 2023-05-04 08:10:58