C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Operator for reference casting
From: Gašper Ažman (gasper.azman_at_[hidden])
Date: 2021-01-15 08:26:15


Related: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98660

On Fri, Jan 15, 2021 at 1:49 PM Jean-Baptiste Vallon Hoarau via
Std-Proposals <std-proposals_at_[hidden]> wrote:

> Hello everyone,
>
> I think you are all aware how verbose perfect forwarding is. I haven't
> seen any proposal that could tackle this (admittedly minor) issue so far,
> except the one on hygienic macros.
> So what if we had an operator for casting to a reference?
> For example, given a value x, than the following could be equivalent :
> x& -> static_cast<decltype(x)&>(x)
> x&& -> static_cast<decltype(x)&&>(x)
>
> This would make forwarding a lot less cumbersome to write/read (goodbye
> decltype(x)(x), hello x&&). However, I don't see many use cases for
> explicit lvalue cast, and this would be at odd with lambda capture syntax.
>
> Let me know what you think.
> -Jean-Baptiste
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>



STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups