C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Operator for reference casting
From: Arthur O'Dwyer (arthur.j.odwyer_at_[hidden])
Date: 2021-01-17 15:27:53


On Sun, Jan 17, 2021 at 12:21 PM Jason McKesson via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On Sun, Jan 17, 2021 at 4:27 AM Drew Gross via Std-Proposals
> <std-proposals_at_[hidden]> wrote:
> >
> > Some examples of when you don't want to forward a forwarding reference,
> might be easy to create bugs if it forwarded automatically:
> >
> > 1) A generic logging wrapper function
> > ```
> > auto LoggedCall(auto >&& f, auto >&& v) {
> > LogValue(v);
> > return f(v); // Oops, v was moved from! (Maybe, depending on
> signature of LogValue)
> > }
> > ```
>
> Why would a logging function move from its parameter? It should take
> it as a `const&`.
>

I could totally imagine a logging function with the signature
    void LogValue(std::string msg);
Your proposal would break that. That's bad.

–Arthur



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

Standard Proposals Archives on Google Groups