C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Proposal for Uniform Forward And Move

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Thu, 22 Jun 2023 06:54:10 +0100
On Wed, Jun 21, 2023 at 5:24 PM Михаил Найденов via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hello,
> I am resurrecting another old (2018) proposal of mine, I never submitted.
>
> Proposed is to have a postscript operator &&, which either moves or forwards.
>
> Thank You


I like this proposal. How about if we could also use postfix && on the
function parameters, as follows:

decltype(auto) insert(string &&name&&, auto &&func&&)
{
  return acts.emplace(name, func); //< move or forward? Does not matter!
}

What I'm saying here is that any reference define with postfix && in
its name, has 'move' or 'forward' applied automatically. For example:

int main(void)
{
    int monkey = 7;

    int &&donkey&& = std::move(monkey);

    SomeFunction( donkey ); // <- passed as an Rvalue ref
}

Received on 2023-06-22 05:54:22