Issue |
150446
|
Summary |
cppcoreguidelines-missing-std-forward should consider std::forward usage in lambda capture also with uniform initialization
|
Labels |
new issue
|
Assignees |
|
Reporter |
mous16
|
Following the issue https://github.com/llvm/llvm-project/issues/68105, I found out that clang-tidy still complains about forwarding in lambda capture, if lambda variable is initialized with braces instead of equal.
Example:
```c++
#include <utility>
template <typename F>
auto makeFuncA(F&& func) {
return [func2 = std::forward<F>(func)]() { func2(); };
}
template <typename F>
auto makeFuncB(F&& func) {
return [func2{std::forward<F>(func)}]() { func2(); };
}
int main() {
auto a{makeFuncA([]() {})};
a();
auto b{makeFuncB([]() {})};
b();
}
```
clang-tidy is ok with `makeFuncA`, while complains on `makeFuncB`.
`func2{std::forward<F>(func)}` should be considered the same of `func2 = std::forward<F>(func)`.
Live example: https://godbolt.org/z/barb17xM7
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs