C++ Logo

std-proposals

Advanced search

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

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 24 Jun 2023 00:14:47 +0100
On Wed, Jun 21, 2023 at 5:24 PM Михаил Найденов via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Proposed is to have a postscript operator &&, which either moves or forwards.


Another possibility would be to make it look similar to a C-style
cast. So the following:

template<class T>
void Func(T &&arg)
{
    static T obj;
    obj = std::forward<T>(arg);
}

would be the same as:

template<class T>
void Func(T &&arg)
{
    static T obj;
    obj = (&&)arg;
}

or maybe use angle brackets:

template<class T>
void Func(T &&arg)
{
    static T obj;
    obj = <&&>arg;
}

or maybe even a unary '^' operator:

template<class T>
void Func(T &&arg)
{
    static T obj;
    obj = ^arg;
}

or maybe create a new token '^^' as follows:

template<class T>
void Func(T &&arg)
{
    static T obj;
    obj = ^^arg;
}

or maybe:

template<class T>
void Func(T &&arg)
{
    static T obj;
    obj = [{arg}];
}

I think what people want is a symbol that's shorthand for both 'move'
and 'forward'.

Received on 2023-06-23 23:15:00