[clang-tidy] false positive on cppcoreguidelines-missing-std-forward with constrained templates
#include <concepts>
class A
{
public:
template <std::derived_from<A> Self>
auto operator|(this Self &&self, int) -> void {}
};
auto main() -> int
{
A a;
a | 1;
}
Self is a regular rvalue reference and not a forwarding reference in A::operator| because of the constraint (and as seen by the compiler error in main), but clang-tidy will still warn cppcoreguidelines-missing-std-forward on this.
@llvm/issue-subscribers-clang-tidy
Author: None (rdong8)
class A { public: template <std::derived_from<A> Self> auto operator|(this Self &&self, int) -> void {} };
auto main() -> int { A a; a | 1; }
`Self` is a regular rvalue reference and not a forwarding reference in `A::operator|` because of the constraint (and as seen by the compiler error in `main`), but clang-tidy will still warn [cppcoreguidelines-missing-std-forward](https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/missing-std-forward.html) on this.
</details>
I had like to work on this. Will submit a PR shortly.
I have no idea about fixing it gracefully. It's hard to tell if a type satisfying a concept is always non-reference.