C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Forget forget let's redact

From: Ted Lyngmo <ted_at_[hidden]>
Date: Thu, 27 Aug 2026 18:00:21 +0200
2026-08-27 06:12, Yongwei Wu:
>> I don't know how common it actually is but I have seen some cases where
>> `std::forward` has been used multiple times on the same forwarding
>> reference by mistake and I think this feature would catch at least some
>> those mistakes.
>
> This can be checked by clang-tidy already. It does not require a
> language change.
>
> https://godbolt.org/z/ec58376rz
Ok, that might be useful but here it warns in a case where `obj` is
forwarded as an lvalue ref (std::string&). Sure, it may be moved from in
`bar` anyway, but that'd be a surprising API. It even warns if `s` is
`const`.

The idea with the attributes would be to make it reasonably watertight.
We couldn't turn those clang-tidy warnings into errors because that'd
reject a lot of valid code I think.

Br,
Ted

Received on 2026-08-27 16:00:30