Issue |
131231
|
Summary |
[clang-tidy] Check request: Avoid assigning Boost lambda capturing `this` to a field in a default-copyable class.
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
denzor200
|
Needs a check that will do all the same as https://github.com/llvm/llvm-project/issues/120863, but will catch a lambda from Boost library instead of C++11 lambda.
```
#include <boost/lambda2.hpp>
using namespace boost::lambda2;
struct test
{
int x = 0;
std::function<bool(int)> fun = x==_1; // INCORRECT
};
```
```
#include <boost/lambda2.hpp>
using namespace boost::lambda2;
struct test
{
int x = 0;
std::function<bool(int)> fun = x==_1; // OK, see copy methods deleted below
test() = default;
test(const test&) = delete;
test& operator=(const test&) = delete;
};
```
Here I provided sample of using [Boost Lambda 2](https://www.boost.org/doc/libs/1_84_0/libs/lambda2/doc/html/lambda2.html) to capture `this`, but Boost is not limited to Lambda 2. There is also well-known [Boost Lambda](https://www.boost.org/doc/libs/1_84_0/doc/html/lambda.html) and [Boost Phoenix](https://www.boost.org/doc/libs/1_84_0/libs/phoenix/doc/html/index.html) and ??? but I have never used them and don't know if they are relevant to this problem.
So if anybody here is an expert on these two libraries(and not only) - feel free to comment.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs