C++ Logo


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: Tom Honermann <tom_at_[hidden]>
Date: Thu, 4 May 2023 15:18:25 -0400
On 5/4/23 7:38 AM, David Brown via Std-Proposals wrote:
> On 04/05/2023 11:47, Timur Doumler via Std-Proposals wrote:
>> I don't think we could ever have operator** because ** has a meaning
>> in C++ today (multiplication followed by dereference, or double
>> dereference). Am I missing something?
>> Cheers, Timur
> Yes, "x ** y" currently parses as "x * (*y)". I don't know how that
> could be resolved without making spaces more significant in token
> parsing.
> (Personally, I'd be happy to see the introduction of rules regulating
> spacing in connection with operators - it would lead to neater, more
> consistent code that is easier for mere humans to read. But the
> standards committee have their little obsessions about backwards
> compatibility of existing code, so I don't think that would be accepted!)
> If only C++ allowed Unicode symbols and punctuation as identifier
> letters, we could use "x ↑ y" for exponentiation (and annoy
> programmers with limited keyboard layouts!).

The draft C23 and C++23 standards both follow Unicode UAX #31
<https://unicode.org/reports/tr31/> recommendations for characters
allowed in identifiers (see N2836
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2836.pdf> for C and
P1949 <https://wg21.link/p1949> for C++). The Unicode standard also
provides a specification of characters that are suitable for use as
operators. Swift relies on such Unicode properties to allow user-defined
custom operators
There is no technical reason that C++ can't do similarly, but no such
proposal has been published at this time.


> David

Received on 2023-05-04 19:18:27