C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Automatic perfect forwarding is possible and not too complicated

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sun, 13 Apr 2025 16:41:08 +0100
On Saturday, April 12, 2025, Jonathan Wakely wrote:
>
>
> The fact you don't have a better name for it than "trigraph reference" is
> telling.
>
> I can imagine the conversations now:
> "So what is this ugly &&& thing?"
> "It's a trigraph reference"
> "erm, ok ... so what does it do?"
> "it's a qualifier composed of three characters."
> "ok, but what does it mean?"
> "it's like && but 50% more."
>



Call it a _Kangaroo reference if ya want:

   template<typename T>
   void Func( T _Kangaroo arg ) { }

Or maybe move the _Kangaroo part somewhere else:

   template<typename _Kangaroo T>
   void Func( T &&arg ) { }

I'm not too fussed about the syntax or what it's called, or even if its
invention is attributed to me. Just want a function argument that
automatically gets forwarded where it is safe and efficient. Maybe
_AutoForward would be more intuitive than _Kangaroo, although the image of
a majestic kangaroo in locomotion does conjure up mental images of hopping
forward with efficiency, and such mental images might spur programmers on
to enthusiastically adopt the new feature. Actually yeah I'll go with
_Kangaroo.

......although actually I don't want to seem biased toward Australian
ideals of locomotive supremacy. Let me mull this one over because I'm not
sure if Americans see eye to eye with the Ozzies -- and the last thing I
want is for Trump to up tariffs, all because an Irishman wanted a cool name
for his new feature.

By the way, and I know that there's no point in saying this now since C++11
happened 15 - 25 years ago, but I think that choosing '&&' as the notation
for forwarding references was beyond horrid. I don't know how that got
accepted by a majority of sane, rational, skilled C++ programmers. I didn't
program for a few years around about that time period owing to a
bereavement, but if I had been on the circuit at the time I'd have been
harassing all of you loudly with a megaphone with backup batteries to urge
you all to see sense. '&&' for forwarding references is horrendous. I
probably would have pushed for something like "LorR" to mean "Lvalue or
Rvalue", something like:

    template<typename T>
    void Func( T LorR arg ) { }

This would of course mean that we could do the following:

    template<typename T>
    void Func( T LorR arg0, T &&arg1 ) { }

Guess what that second argument is . . . yeah you guessed right . . . it's
a bloody R-value reference. Isn't that something.

Received on 2025-04-13 15:41:11