| 1 |
.. title:: clang-tidy - bugprone-lambda-function-name |
| 2 |
|
| 3 |
bugprone-lambda-function-name |
| 4 |
============================= |
| 5 |
|
| 6 |
Checks for attempts to get the name of a function from within a lambda |
| 7 |
expression. The name of a lambda is always something like ``operator()``, which |
| 8 |
is almost never what was intended. |
| 9 |
|
| 10 |
Example: |
| 11 |
|
| 12 |
.. code-block:: c++ |
| 13 |
|
| 14 |
void FancyFunction() { |
| 15 |
[] { printf("Called from %s\n", __func__); }(); |
| 16 |
[] { printf("Now called from %s\n", __FUNCTION__); }(); |
| 17 |
} |
| 18 |
|
| 19 |
Output:: |
| 20 |
|
| 21 |
Called from operator() |
| 22 |
Now called from operator() |
| 23 |
|
| 24 |
Likely intended output:: |
| 25 |
|
| 26 |
Called from FancyFunction |
| 27 |
Now called from FancyFunction |