<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/131231>131231</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: Avoid assigning Boost lambda capturing `this` to a field in a default-copyable class.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzEVUuP2zYQ_jX0ZbAGRVqWfdDBjzW6aJEUae6LkTiy2FCkSlL2ur--oKR9ZJECRfcQgIAg6ePMN9-8MAR9tkQly_csPy5wiK3zpSL7t_OC80Xl1K1kfPeJSAVAqFuqv0FsMcJVGwPKARoDsSUI2BFggDbGPjC5Y-LExOmsYztUy9p1TJyMuTw_7nrv_qQ6MnHSIQwUmDhlgm_WkokDVMNsv8ZYt4BgsKsUQuNdB3vnQgSjK4_-BtqGSK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